init(!empty($argc) && $argc > 1 ? $argv : false); class SypexDumper { const INC = '.sx/'; public $name = 'Sypex Dumper Pro 2.3.2'; public $LNG; public $CFG; public $SES; public $JOB; public $VAR; public $lng_list; protected $mysql; protected $langs; public $try = false; protected $virtualize = false; protected $cron_mode = false; public $error = false; public $fh_rtl; public $fh_log; public $fh_tmp; public $rtl; protected $db; protected $l; public function __construct() { define('V_SXD', 20302); define('V_PHP', $this->verToInt(phpversion())); if(V_PHP < 50203) trigger_error('PHP 5.2+ only', E_USER_ERROR); define('C_DEFAULT', 1); define('C_RESULT', 2); define('C_ERROR', 3); define('C_WARNING', 4); define('TIMER', microtime(1)); $this->url = isset($_SERVER["HTTPS"]) ? ($_SERVER["HTTPS"] === 'on' ? 'https://' : 'http://') . getenv("HTTP_HOST") . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . '/' : ''; } protected 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){ $CFG = array(); include('cfg.php'); define('SXD_DEBUG', $CFG['debug']); $this->loadLang($CFG['lang']); if (!ini_get('safe_mode') && function_exists('set_time_limit') && strpos(ini_get('disable_functions'), 'set_time_limit') === false) @set_time_limit($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'] = ''; } // print_r($args);exit; 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($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']) ? (int)$_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 2;} $auth = !empty($CFG['user']) && isset($CFG['pass']) && $CFG['user']== $user && $CFG['pass'] == $pass; break; case 'mysql': if(empty($user)) {continue 2;} // if($host != 'localhost' && !empty($this->CFG['my_host']) && $this->CFG['my_host'] != $host) {continue;} // echo PHP_INT_MAX; $auth = $this->connect($host, $port, $user, $pass); break; default: $file = 'auth_' . $a . '.php'; if(!file_exists($file)) continue 2; include $file; } if($auth) break; } if($auth){ $key = md5(mt_rand(1,100000) . $user . microtime()); $CFG['lang'] = $this->LNG['name']; $_COOKIE['sxd'] = $key; $this->saveCFG(); setcookie('sxd', $key, !empty($_POST['save']) ? time() + 31536000 : 0, '', '', false, true); header("Location: {$this->url}?"); exit; } foreach(array('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 = '