config = parse_ini_file('settings.ini', true); $this->mysqli = @new mysqli($this->config['MySQL']['HOST'], $this->config['MySQL']['USER'], $this->config['MySQL']['PASSWORD'], $this->config['MySQL']['DATABASE']); if($this->mysqli->connect_errno) die('Error connect to MySQL server. Try again later. ' . $this->mysqli->connect_error); session_start(); $this->smarty = new Smarty(); $this->smarty->setTemplateDir(DR . '/style/templates/PDA/'); $this->smarty->setCompileDir(DR . '/style/templates/PDA/compile/'); $this->smarty->setCacheDir(DR . '/style/templates/PDA/cache/'); //$this->smarty->assign('request', microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']); $this->smarty->assign('keywords', $this->config['Site']['keywords']); $this->smarty->assign('link', $this->config['Site']['link']); $this->smarty->assign('mobtop', (!isset($_GET['razd']) && !isset($_GET['file']) && !isset($_GET['sogl']) ? '' : '')); } public function showGames(){ $vip = false; if(isset($_GET['phone']) && preg_match('/^[0-9X]+$/', $_GET['phone']) && isset($_GET['key']) && preg_match('/^\d{6}$/', $_GET['key'])){ $q = $this->mysqli->query("SELECT COUNT(*) AS count FROM users WHERE phone = '$_GET[phone]' AND password = '$_GET[key]'"); $q = $q->fetch_assoc(); if($q['count'] > 0){ $_SESSION['phone'] = $_GET['phone']; $_SESSION['password'] = $_GET['key']; } } if(isset($_SESSION['phone']) && isset($_SESSION['password'])){ $this->smarty->assign('phone', $_SESSION['phone']); $q = $this->mysqli->query("SELECT COUNT(*) AS count FROM users WHERE phone = '$_SESSION[phone]' AND password = '$_SESSION[password]'"); $q = $q->fetch_assoc(); if($q['count'] > 0){ $w = $this->mysqli->query("SELECT time FROM users WHERE phone = '$_SESSION[phone]'"); $w = $w->fetch_assoc(); $dostup = $w['time'] - time(); if($dostup > 0){ $vip = true; $days = intval($dostup / 60 / 60 / 24); $hours = intval(($dostup - ($days * 60 * 60 * 24)) / 60 / 60); $minutes = intval(($dostup - ($days * 60 * 60 * 24) - ($hours * 60 * 60))/60); $seconds = intval($dostup - ($days * 60 * 60 * 24) - ($hours * 60 * 60) - ($minutes * 60)); $str = ($days > 0 ? $days.' дней ' : '').($hours > 0 ? $hours.' часов ' : '').($minutes > 0 ? $minutes.' минут ' : '').$seconds.' секунд'; $this->smarty->assign('dostup', $str); } }else session_unset(); } $this->smarty->assign('vip', $vip); if(!isset($_GET['sogl'])){ if(isset($_GET['download']) && intval($_GET['download']) > 0 && !isset($_GET['razd']) && !isset($_GET['file'])){ if($vip){ $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_USERAGENT => $this->ua, CURLOPT_HEADER => true, CURLOPT_RETURNTRANSFER => true )); curl_setopt($ch, CURLOPT_URL, 'http://android.zaycu.ru/download.php?id='.$_GET['download']); $res = curl_exec($ch); preg_match("/Location\:\s(.*?)\n/", $res, $loc); header('Location: '.$loc[1]); }else header('Location: '.$this->config['Site']['link']); }else{ $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_USERAGENT => $this->ua, CURLOPT_RETURNTRANSFER => true )); curl_setopt($ch, CURLOPT_URL, 'http://android.zaycu.ru/'.(isset($_GET['razd']) && intval($_GET['razd']) > 0 ? intval($_GET['razd']).'/' : (isset($_GET['file']) && intval($_GET['file']) > 0 ? 'file/'.intval($_GET['file']).'/' : '')).(isset($_GET['page']) && intval($_GET['page']) > 0 ? '?p='.intval($_GET['page']) : '')); $res = curl_exec($ch); $res = preg_replace('/<\?xml.*?
\s+/i', '', $res); $res = preg_replace('/Сортировка(.*?)\s+/', '', $res); preg_match('/^(.*?)<\/b>/', $res, $razd); $razd = preg_replace('/\:$/', '', $razd[1]); $res = preg_replace('/<\/div>
(.*?)$/', '', $res); $res = preg_replace('/Главная<\/a>(\s+)?» /', '', $res); $res = str_replace('', '', $res); $res = preg_replace('/^(.*?)Поиск<\/a>/', '', $res); $res = preg_replace('/\s+\s+\s+$/', '', $res); $res = preg_replace('/(\s+)?()?/', '', $res); $res = preg_replace('/\+\d+<\/span>/', '', $res); $res = preg_replace('/ (.*?)<\/a> \((\d+)\)<\/b>/', "\"\"/ $2$3\n", $res); $res = str_replace('

', '