$value) { if (is_array($value)) { $array[$key] = array_map_r($value,$callback); } else { $array[$key] = call_user_func($callback,$value); } } } return $array; } if (get_magic_quotes_gpc()) { $_POST = array_map_r('stripslashes', $_POST); $_GET = array_map_r('stripslashes', $_GET); $_REQUEST = array_map_r('stripslashes', $_REQUEST); $_COOKIE = array_map_r('stripslashes', $_COOKIE); } $mysqli = new Mysqli(BASE_HOST, BASE_USER, BASE_PASS, BASE_NAME); $mysqli->set_charset('utf8'); function auth($login, $password) { $crc = md5($login.$password.MAGIC_KEY); $data = array( 'login' => $login, 'password' => $password, 'crc' => $crc, 'new' => true, 'ip' => $_SERVER['REMOTE_ADDR'], ); $result = file_get_contents('http://login.appchi.ru/auth.php?'.http_build_query($data)); if (!$result = unserialize($result)) { return false; } if ($result['auth'] == true) { unset($result['auth']); return $result; } else { return false; } } if (!isset($_SESSION['user']) && isset($_COOKIE['login']) && isset($_COOKIE['password'])) { if ($result = auth($_COOKIE['login'], $_COOKIE['password'])) { $_SESSION['user'] = $result; } else { setcookie('login', '', 0, '/', '.appchi.ru'); setcookie('password', '', 0, '/', '.appchi.ru'); } } if (isset($_SESSION['user']['id'])) { if (isset($mysqli) && $mysqli) { $result = $mysqli->query('SELECT * FROM id_users u WHERE u.id = '.$_SESSION['user']['id']); $_SESSION['user'] = $result->fetch_assoc(); } else { $result = mysql_query('SELECT * FROM id_users u WHERE u.id = '.$_SESSION['user']['id']); $_SESSION['user'] = mysql_fetch_assoc($result); } $login = true; define('LOGIN', true); define('USER_ID', $_SESSION['user']['id']); define('USER_LOGIN', $_SESSION['user']['login']); define('USER_EMAIL', $_SESSION['user']['email']); define('USER_TRUST', $_SESSION['user']['trust']); define('USER_KARMA', $_SESSION['user']['karma']); define('BALANCE', $_SESSION['user']['balance']); define('USER_BAN', (boolean)$_SESSION['user']['ban']); if ($_SESSION['user']['super'] > 0) { define('SUPER_USER', $_SESSION['user']['super']); } else { define('SUPER_USER', false); } //* if (isset($_SESSION['messages']['update']) && ($_SESSION['messages']['update'] + 60) > time()) { define('NEW_MESSAGES', $_SESSION['messages']['new']); } else { $sql = ' SELECT id FROM id_messages WHERE from_user_id = '.USER_ID.' AND deleted <> -1 AND deleted <> '.USER_ID.' UNION SELECT id FROM id_messages WHERE to_user_id = '.USER_ID.' AND deleted <> -1 AND deleted <> '.USER_ID.' '; $messages = array(); $newMessages = 0; if (isset($mysqli) && $mysqli) { $result = $mysqli->query($sql); while ($row = $result->fetch_assoc()) { $messages[] = $row['id']; } } else { $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { $messages[] = $row['id']; } } if ($messages) { $sql = ' SELECT COUNT(*) FROM id_messages_replays WHERE message_id IN ('.implode(', ', $messages).') AND user_id <> '.USER_ID.' AND viewed <> 1 '; if (isset($mysqli) && $mysqli) { $result = $mysqli->query($sql); list($newMessages) = $result->fetch_row(); } else { $result = mysql_query($sql); list($newMessages) = mysql_fetch_row($result); } } $_SESSION['messages']['new'] = $newMessages; $_SESSION['messages']['update'] = time(); define('NEW_MESSAGES', $newMessages); } //*/ } else { define('LOGIN', false); define('SUPER_USER', false); } function formatdate($date,$format){ if($date){ $d=date($format,strtotime($date)); $m1=array(" ","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); $m2=array("  ","янв","фев","март","апр","май","июн","июл","авг","сен","окт","ноя","дек"); // $m2=array("  ","Января","Февраля","Марта","Апреля","Мая","Июня","Июля","Августа","Сентября","Октября","Ноября","Декабря"); return str_replace($m1,$m2,$d); } } function today($date,$format=false){ //* list($c,$t)=explode(" ",$date); $t=date("H:i",strtotime($date)); if(date("Y-m-d")==$c){ return "сегодня в $t"; }elseif(date("Y-m-d",time()-60*60*24)==$c){ return "вчера в $t"; }else{ if($format) return formatdate($date,$format); return $date; } //*/ } function todayBig($date,$format=false){ list($c,$t)=explode(" ",$date); $t=date("H:i",strtotime($date)); if(date("Y-m-d")==$c){ return "Сегодня в $t"; }elseif(date("Y-m-d",time()-60*60*24)==$c){ return "Вчера в $t"; }else{ if($format) return formatdate($date,$format); return $date; } } function num_sing($n) { return ($n ? ($n > 0 ? '+' : '-') : ''); } function format_bytes($size) { $units = array(' б', ' Кб', ' Мб', ' Гб', ' Тб'); for ($i = 0; $size >= 1024 && $i < 4; $i++) $size /= 1024; return round($size, 2).$units[$i]; } function crop_str($string, $limit) { $substring_limited = substr($string,0, $limit); return substr($substring_limited, 0, strrpos($substring_limited, ' ' )); } require_once ROOT_PATH.'/includes/HTMLPurifier/HTMLPurifier.standalone.php'; require_once ROOT_PATH.'/includes/rutoen.php'; if (!defined('_SAPE_USER')){ define('_SAPE_USER', '4875a41b6b09ba24ddf9fbaa10c2e1de'); } require_once(realpath($_SERVER['DOCUMENT_ROOT'].'/'._SAPE_USER.'/sape.php')); $o['charset'] = 'UTF-8'; $sape = new SAPE_client($o); unset($o); //error_reporting(USER_ID != 1 ? E_ALL : 0); ?>