init(!empty($argc) && $argc > 1 ? $argv : false); class SypexDumper { public function __construct() { define('C_DEFAULT', 1); define('C_RESULT', 2); define('C_ERROR', 3); define('C_WARNING', 4); define('SXD_DEBUG', false); define('TIMER', array_sum(explode(' ', microtime()))); define('V_SXD', 20011); define('V_PHP', sxd_ver2int(phpversion())); $this->name = 'Sypex Dumper 2.0.11'; } public function loadLang($lng_name = 'auto') { if ($lng_name == 'auto') { include 'lang/list.php'; $this->langs = &$langs; $lng = 'en'; if (preg_match_all('/[a-z]{2}(-[a-z]{2})?/', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $m)) { foreach ($m[0] as $l) { if (isset($langs[ $l ])) { $lng_name = $l; break; } } } } if (file_exists("lang/lng_{$lng_name}.php")) { include "lang/lng_{$lng_name}.php"; } else { include 'lang/lng_en.php'; } $this->LNG = &$LNG; $this->LNG['name'] = $lng_name; return true; } public function init($args = false) { if (get_magic_quotes_gpc()) { $_POST = sxd_antimagic($_POST); } include 'cfg.php'; $this->loadLang($CFG['lang']); if (function_exists('set_time_limit') && strpos(ini_get('disable_functions'), 'set_time_limit') === false) { set_time_limit((int)$CFG['time_web']); } elseif (ini_get('max_execution_time') < $CFG['time_web']) { $CFG['time_web'] = ini_get('max_execution_time'); } $this->CFG = &$CFG; $this->try = false; $this->virtualize = false; $this->cron_mode = false; // Проверяем авторизацию и делаем коннект к базе if (empty($this->CFG['my_user'])) { $this->CFG['my_host'] = 'localhost'; $this->CFG['my_port'] = 3306; $this->CFG['my_user'] = 'root'; $this->CFG['my_pass'] = ''; $this->CFG['my_comp'] = 0; $this->CFG['my_db'] = ''; } if ($args) { // консольный режим foreach ($args as $key => $arg) { if (preg_match('/^-([hupoj])=(.*?)$/', $arg, $m)) { switch ($m[1]) { case 'h': $this->CFG['my_host'] = $m[2]; break; // хост case 'o': $this->CFG['my_port'] = $m[2]; break; // порт case 'u': $this->CFG['my_user'] = $m[2]; break; // логин case 'p': $this->CFG['my_pass'] = $m[2]; break; // пароль case 'j': $this->CFG['sjob'] = $m[2]; break; // job-файл } } } $this->cron_mode = true; set_time_limit((int)$CFG['time_cron']); // Загружаем конфиг файл, если нужно $auth = $this->connect(); if ($auth && !empty($this->CFG['sjob'])) { $this->ajax($this->loadJob($this->CFG['sjob'])); echo file_get_contents($this->JOB['file_log']); if (file_exists($this->JOB['file_log'])) { unlink($this->JOB['file_log']); } if (file_exists($this->JOB['file_rtl'])) { unlink($this->JOB['file_rtl']); } } else { echo 'Auth error'; } exit; } elseif (!empty($this->CFG['auth'])) { // Авторизация $auth = false; $sfile = 'ses.php'; if (!empty($_COOKIE['sxd']) && preg_match('/^[\da-f]{32}$/', $_COOKIE['sxd'])) { include $sfile; if (isset($SES[ $_COOKIE['sxd'] ])) { $auth = true; $this->CFG = $SES[ $_COOKIE['sxd'] ]['cfg']; $this->SES = &$SES; $this->loadLang($this->CFG['lang']); } } if (!$auth) { $user = !empty($_POST['user']) ? $_POST['user'] : ''; $pass = !empty($_POST['pass']) ? $_POST['pass'] : ''; $host = !empty($_POST['host']) ? $_POST['host'] : (!empty($this->CFG['my_host']) ? $this->CFG['my_host'] : 'localhost'); $port = !empty($_POST['port']) && is_numeric($_POST['port']) ? $_POST['port'] : 3306; $temp = preg_split('/\s+/', $this->CFG['auth']); if (!empty($_REQUEST['lang']) && preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $_REQUEST['lang'])) { $this->loadLang($_REQUEST['lang']); } foreach ($temp as $a) { switch ($a) { case 'cfg': if (empty($user)) { continue; } $auth = !empty($CFG['user']) && isset($CFG['pass']) && $CFG['user'] == $user && $CFG['pass'] == $pass; break; case 'mysql': if (empty($user)) { continue; } if ($host != 'localhost' && !empty($this->CFG['my_host']) && $this->CFG['my_host'] != $host) { continue; } $auth = $this->connect($host, $port, $user, $pass); break; default: $file = 'auth_' . $a . '.php'; if (!file_exists($file)) { continue; } include $file; } if ($auth) { break; } } if ($auth) { $key = md5(rand(1, 100000) . $user . microtime()); $CFG['lang'] = $this->LNG['name']; $_COOKIE['sxd'] = $key; $this->saveCFG(); if (V_PHP > 50200) { setcookie('sxd', $key, !empty($_POST['save']) ? time() + 31536000 : 0, '', '', false, true); } else { setcookie('sxd', $key, !empty($_POST['save']) ? time() + 31536000 : 0, '', '', false); } header('Location: ./'); exit; } foreach (['user', 'pass', 'host', 'port'] as $key) { $_POST[ $key ] = !empty($_POST[ $key ]) ? htmlspecialchars($_POST[ $key ], ENT_NOQUOTES) : ''; } $_POST['save'] = !empty($_POST['save']) ? ' CHECKED' : ''; } if (!$auth) { if (!empty($_POST['ajax'])) { echo "sxd.hideLoading();alert('Session not found');"; exit; } $this->lng_list = '