/* Author: Andrey Goglev VK: https://vk.com/ru151 */ ajax_only(); $email = textFilter(strtolower($_POST['email'])); $name = textFilter($_POST['name']); $lname = textFilter($_POST['lname']); $pass = textFilter($_POST['pass']); $pass2 = textFilter($_POST['pass2']); if(preg_match('/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i', $email)){ if(strlen($name) > 1 && preg_match("/^[\s\x{600}-\x{6FF}a-zA-Zа-яА-Я]+$/iu", $name)){ if(strlen($lname) > 1 && preg_match("/^[\s\x{600}-\x{6FF}a-zA-Zа-яА-Я]+$/iu", $lname)){ if($pass == $pass2){ $check_email = mysql_query("SELECT COUNT(uid) as cnt FROM `users` WHERE email = '{$email}'"); if(!$check_email['cnt']){ $pass = md5('fast'.$pass); mysql_query("INSERT INTO `users` (email, password, name, lname) VALUES ('{$email}', '{$pass}', '{$name}', '{$lname}')"); extend_auth($mysql_iid, md5($mysql_iid.$pass2.time())); echo 'ok'; }else echo 'mail'; } } } } exit;
VK: https://vk.com/ru151 */ if((isset($_POST['logout']) || $_SERVER['REQUEST_URI'] == '/login?logout') && $logged){ setcookie('uid', $uid, time()-3600); setcookie('hash', $hash, time()-3600); $pmc->delete('session'.$uid.$hash); header('Location: /'); exit; } ajax_only(); $email = mb_strtolower(textFilter($_POST['email'])); $pass = textFilter($_POST['pass']); if($email && $pass){ $pass5 = md5('fast'.$pass); $check = mysql_query("SELECT uid FROM `users` WHERE email = '{$email}' AND password = '******'"); if($check['uid']){ extend_auth($check['uid'], md5($check['uid'].$pass.time())); echo 'ok'; }else echo 'no'; }else echo 'no'; exit;
*/ include 'app/config.php'; $pmc = new Memcache; $pmc->addServer('localhost', PMC_PORT); include 'app/lib/tpl.php'; include 'app/lib/mysql.php'; include 'app/functions.php'; $server_time = time(); $online_time = $server_time-600; if($_COOKIE['uid'] > 0){ $uid = intval($_COOKIE['uid']); $hash = $_COOKIE['hash']; if($pmc->get('session'.$uid.$hash) == 'logged'){ $logged = true; $uinfo = get_user_data($uid); if($online_time > $uinfo['last_update']){ $uinfo['last_update'] = $server_time; $pmc->set('uinfo'.$uid, $uinfo, 3600*24); extend_auth($uid, $hash); mysql_query("UPDATE `users` SET last_update = '{$server_time}' WHERE uid = '{$uid}'"); } } }