HEX
Server: nginx/1.29.3
System: Linux 11979.bigscoots-wpo.com 6.8.0-88-generic #89-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 01:02:46 UTC 2025 x86_64
User: nginx (1068)
PHP: 7.4.33
Disabled: exec,system,passthru,shell_exec,proc_open,proc_close,popen,show_source,cmd# Do not modify this line # 1684243876
Upload Files
File: //bigscoots/wpo/extras/ahmad_stats.sh
#!/bin/bash

# Created by Ahmad - BigScoots

source /bigscoots/includes/common.sh
source /bigscoots/wpo/extras/bigscoots.menu

# Colors
BLUE='\033[0;34m'
GREEN='\033[0;32m'
NC='\033[0m'
CYAN='\033[0;36m'
RED='\033[0;31m'
PINK='\033[95m'
LIGHT_RED='\033[91m'
YELLOW='\033[1;33m'

if [ -z "$1" ]
then
    # Check if current directory is a WP installation
    if ! wpcli core is-installed > /dev/null 2>&1
    then
        printf "${LIGHT_RED}ERROR ! This is not a WordPress installation.${NC}\n"
        exit 1
    fi

    # Set DOMAIN and WEB_ROOT variables
    DOMAIN=$(pwd)
    DOMAIN=$(echo "$DOMAIN" | sed -n 's|.*/domains/\([^/]*\)/public|\1|p')
    WEB_ROOT="/home/nginx/domains/$DOMAIN/public/"
else
    DOMAIN="$1"
    WEB_ROOT="/home/nginx/domains/$DOMAIN/public/"

    # Check if the domain directory exists
    if [ ! -d "$WEB_ROOT" ]; then
        printf "${LIGHT_RED}ERROR ! Domain does not exist on this server.${NC}\n"
        exit 1
    fi
fi

FINAL_URL=$(curl -Ls -o /dev/null -w '%{url_effective}' $DOMAIN)
CLI_FLAGS="--skip-plugins --path=${WEB_ROOT} --skip-themes --allow-root"
DB_PREFIX=$(wp config get table_prefix $CLI_FLAGS)
HEADERS_CURL=$(curl -sI $FINAL_URL)
X_HOSTED_BY=$(echo "$HEADERS_CURL" | grep -i 'X-Hosted-By' | awk -F': ' '{print $2}' | tr '[:upper:]' '[:lower:]' | tr -d '\r\n')



# Domain
domain() {
    printf "${GREEN}%-30s : ${NC}%s\n" "Domain" "$DOMAIN"
}
# WordPress Version
wp_version() {
    WP_VERSION=$(wp core version $CLI_FLAGS)
    printf "${GREEN}%-30s : ${NC}%s\n" "WordPress Version" "$WP_VERSION"
}
# Plugin Count
plugin_count() {
    PLUGIN_COUNT=$(wp plugin list --status=active --field=name $CLI_FLAGS | wc -l)
    printf "${GREEN}%-30s : ${NC}%s\n" "Plugin Count" "$PLUGIN_COUNT"
}
# Theme Activated
active_theme() {
    ACTIVE_THEME=$(wp theme list --status=active --field=name $CLI_FLAGS)
    printf "${GREEN}%-30s : ${NC}%s\n" "Theme Activated" "$ACTIVE_THEME"
}
# Cron Count
cron_count(){
    CRON_COUNT=$(wp cron event list --field=hook $CLI_FLAGS | wc -l)
    printf "${GREEN}%-30s : ${NC}%s\n" "Cron Count" "$CRON_COUNT"
}
# Autoload Size
autoload_size() {
    AUTOLOAD_SIZE=$(wp db query 'SELECT SUM(LENGTH(option_value)) / 1024 / 1024 as autoload_size_mb FROM '"${DB_PREFIX}"'options WHERE autoload="yes"' --skip-column-names --silent $CLI_FLAGS)
    
    if (( $(echo "$AUTOLOAD_SIZE > 1" | bc -l) )); then
        COLOR="${RED}"
    else
        COLOR="${NC}"
    fi
    
    printf "${GREEN}%-30s : ${NC}" "Autoloaded Data Size"
    printf "${COLOR}%s MBs${NC}\n" "$AUTOLOAD_SIZE"
}

#MU check
multisite_check() {
MULTI_SITE=$(wp core is-installed --network $CLI_FLAGS)
if [ $? -eq 0 ]; then
    MULTI_SITE="Yes"
else
    MULTI_SITE="No"
fi
printf "${GREEN}%-30s : ${NC}%s\n" "Multsite" "$MULTI_SITE"
}

# PHP Version
php_version() {
    PHP_INFO=$(scoots php info | grep "\- $DOMAIN" | awk '{print $1, $3}')
    PHP_MODE=$(echo $PHP_INFO | awk '{print $1}')
    PHP_VERSION=$(echo $PHP_INFO | awk '{print $2}')
    
    if [[ "$PHP_MODE" == "Multi" ]]
    then
        MODE="(Multi)"
    else
        MODE="(Native)"
    fi

    printf "${GREEN}%-30s : ${NC}%s\n" "PHP Version $MODE" "$PHP_VERSION"
}


# Cloudflare Cache
cloudflare_cache() {
    for i in {1..2}
    do
    CLOUDFLARE_CACHE=$(echo "$HEADERS_CURL" | grep -i CF-Cache-Status | awk '{print $2}')
        if [ -z "$CLOUDFLARE_CACHE" ]; then
            CLOUDFLARE_CACHE="No CF Cache header"
        fi
    done 
    printf "${GREEN}%-30s : ${NC}%s\n" "Cloudflare Cache" "$CLOUDFLARE_CACHE"
}

# Ezoic Check
ezoic_check() {
    EZOIC_COOKIE=$(echo "$HEADERS_CURL" | grep -i 'set-cookie: ezo')
    if [ -z "$EZOIC_COOKIE" ]; then
        EZOIC_STATUS="No"
    else
        EZOIC_STATUS="Enabled"
    fi
    printf "${GREEN}%-30s : ${NC}%s\n" "Ezoic" "$EZOIC_STATUS"
}

#status_code

status_code() {

    STATUS_CODE=$(echo "$HEADERS_CURL" | grep HTTP | awk '{print $2}' | head -1)
    if [[ "$STATUS_CODE" -eq 200 ]]
        then
            COLOR="${NC}"
    elif [[ "$STATUS_CODE" -eq 301 || "$STATUS_CODE" -eq 302 ]]
        then
            COLOR="${YELLOW}"
        else
            COLOR="${RED}"
fi

    printf "${GREEN}%-30s : ${NC}" "Status Code"
    printf "${COLOR}%s ${NC}\n" "$STATUS_CODE"

}

# Core Checksums
verify_checksums() {
    
    wp core verify-checksums $CLI_FLAGS > /tmp/checksums_output.txt > /dev/null 2>&1
    CHECKSUM_WARNINGS=$(grep 'Warning:' /tmp/checksums_output.txt)
    CHECKSUM_ERRORS=$(grep 'Error:' /tmp/checksums_output.txt)
    if [ -z "$CHECKSUM_WARNINGS" ]; then
        CHECKSUM_WARNINGS="No Warnings"
    fi
    if [ -z "$CHECKSUM_ERRORS" ]; then
        CHECKSUM_ERRORS="No Errors"
    fi
    printf "${GREEN}%-30s : ${NC}%s\n" "Core Checksums (Warnings)" "$CHECKSUM_WARNINGS"
    printf "${GREEN}%-30s : ${NC}%s\n" "Core Checksums (Errors)" "$CHECKSUM_ERRORS"
    rm /tmp/checksums_output.txt
}

slow_logs_check() {
    LOG_FILE="/var/log/php-fpm/www-slow.log"  # replace with the path to your log file
    
    printf "${BLUE}%-30s${NC}\n" "==================================================="
    printf "${CYAN}%-15s %s %15s${NC}\n" "" "Plugins In SLOW logs" ""
    printf "${BLUE}%-30s${NC}\n" "==================================================="

    grep "$DOMAIN" "$LOG_FILE" | awk -F'/plugins/' '{print $2}' | awk -F'/' '{print $1}' | sort -u | while read -r PLUGIN_NAME; do
        echo "$PLUGIN_NAME"
    done
}

redis_check() {
    REDIS_CHECK=$(wp config get WP_CACHE_KEY_SALT $CLI_FLAGS 2>/dev/null && grep 'Plugin Name: Redis Object Cache Drop-In' $WEB_ROOT/wp-content/object-cache.php 2>/dev/null && wp plugin is-active redis-cache $CLI_FLAGS)


    if [ $? -eq 0 ]; then
        REDIS_STATUS="Enabled"
    else
        REDIS_STATUS="Disabled"
    fi

    printf "${GREEN}%-30s : ${NC}%s\n" "Redis: " "$REDIS_STATUS"
}




# Recently Updated Plugins
recent_updated_plugin_themes() {
    
    RECENT_PLUGINS=$(find "${WEB_ROOT}/wp-content/plugins" -maxdepth 1 -type d -mtime 0 | awk -F '/plugins/' '{if (NF>1) print $2}')

    printf "${BLUE}%-30s${NC}\n" "==================================================="
    printf "${CYAN}%-15s %s %15s${NC}\n" "" "PLUGIN Updated last 24 hr" ""
    printf "${BLUE}%-30s${NC}\n" "==================================================="

    if [ -z "$RECENT_PLUGINS" ]; then
        printf "No plugins have been updated in the last 24 hours\n"
    else
        printf "%s\n" "$RECENT_PLUGINS"
    fi

# Recently Updated Themes
    RECENT_THEMES=$(find "${WEB_ROOT}/wp-content/themes" -maxdepth 1 -type d -mtime 0 | awk -F '/themes/' '{if (NF>1) print $2}')

    printf "${BLUE}%-30s${NC}\n" "==================================================="
    printf "${CYAN}%-15s %s %15s${NC}\n" "" "THEMES Updated last 24 hr" ""
    printf "${BLUE}%-30s${NC}\n" "==================================================="

    if [ -z "$RECENT_THEMES" ]; then
        printf "No themes have been updated in the last 24 hours\n\n"
    else
        printf "%s\n" "$RECENT_THEMES"
    fi
}

if [[ "$X_HOSTED_BY" == "bigscoots" ]]; then
    LIVE_STATUS="Live from BigScoots"
    printf "${BLUE}%-30s${NC}\n" "==================================================="
    printf "${CYAN}%-15s ${GREEN}●${NC} %s %15s${NC}\n" "" "WPO DIAGNOSTIC TOOL - Live" ""
    printf "${BLUE}%-30s${NC}\n" "==================================================="
else
    LIVE_STATUS="Not live from BigScoots"
    printf "${BLUE}%-30s${NC}\n" "==================================================="
    printf "${CYAN}%-15s ${RED}●${NC} %s %15s${NC}\n" "" "WPO DIAGNOSTIC TOOL - Not Live" ""
    printf "${BLUE}%-30s${NC}\n" "==================================================="
fi

domain
status_code
wp_version
plugin_count
active_theme
cron_count
autoload_size
multisite_check
php_version
cloudflare_cache
verify_checksums
redis_check
ezoic_check
slow_logs_check
recent_updated_plugin_themes