| Server IP : 146.190.157.162 / Your IP : 216.73.217.6 Web Server : Apache System : Linux ubuntu-s-2vcpu-4gb-amd-sfo3-01-KIT-DIGITAL 6.5.0-44-generic #44-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 7 15:10:09 UTC 2024 x86_64 User : businessweek ( 639) PHP Version : 8.2.10-2ubuntu2.2 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,pcntl_exec,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_signal,pcntl_signal_dispatch,pcntl_getpriority,pcntl_setpriority,dl,putenv,parse_ini_file,show_source MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/html/ |
Upload File : |
#!/bin/bash
# =============================================================
# fix_wp_index.sh
# Reescribe el index.php al contenido original de WordPress
# en todos los sitios bajo /var/www/html/
# Maneja archivos protegidos con chattr +i
# =============================================================
WEB_ROOT="/var/www/html"
# Contenido oficial del index.php de WordPress (igual en todas las versiones)
WP_INDEX_CONTENT='<?php
/**
* Front to the WordPress application. This file does not do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define( '"'"'WP_USE_THEMES'"'"', true );
/** Loads the WordPress Environment and Template */
require __DIR__ . '"'"'/wp-blog-header.php'"'"';
'
# Contadores
COUNT_FIXED=0
COUNT_SKIPPED=0
echo "=============================================="
echo " fix_wp_index.sh - Iniciando..."
echo " Web root: $WEB_ROOT"
echo "=============================================="
echo ""
# Recorre cada subdirectorio directo de WEB_ROOT
for SITE_PATH in "$WEB_ROOT"/*/; do
SITE_NAME=$(basename "$SITE_PATH")
if [ ! -d "$SITE_PATH" ]; then
continue
fi
# ¿Tiene wp-config.php? → es WordPress
if [ -f "$SITE_PATH/wp-config.php" ]; then
INDEX_FILE="$SITE_PATH/index.php"
# Quita el atributo inmutable para poder escribir
chattr -i "$INDEX_FILE" 2>/dev/null
# Reescribe el index.php con el contenido original de WP
echo "$WP_INDEX_CONTENT" > "$INDEX_FILE"
# Vuelve a proteger el archivo como inmutable
chattr +i "$INDEX_FILE"
echo "[✔] WORDPRESS → $SITE_NAME (index.php reescrito)"
COUNT_FIXED=$((COUNT_FIXED + 1))
else
echo "[–] IGNORADO → $SITE_NAME (no es WordPress)"
COUNT_SKIPPED=$((COUNT_SKIPPED + 1))
fi
done
echo ""
echo "=============================================="
echo " Resumen:"
echo " ✔ Sitios WP corregidos : $COUNT_FIXED"
echo " – Sitios ignorados : $COUNT_SKIPPED"
echo "=============================================="