unset($_SESSION[$esid]); } $c = isset($t_m) ? yjl_getMsg($t_m) : ''; if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST['password']) && trim($_POST['password']) != '' && isset($_POST['email']) && trim($_POST['email']) != '') { $p = htmlspecialchars(trim($_POST['password']), ENT_QUOTES); $email = htmlspecialchars(trim($_POST['email']), ENT_QUOTES); if (yjl_cemail($email)) { $ip = yjl_getIP(); $u = str_replace('@', '_', $email); $u = str_replace('.', '_', $u); $ue = preg_match("/^\\w+\$/i", $u) ? $u : ''; if ($ue == '') { $u = substr(md5(time() . rand(1, 1000)), 0, 16); } $u = yjl_chkusername($u); if ($u != '') { $un_c = 0; $em_c = 0; $q_res = sprintf('select uid from %s where username=%s limit 1', $dbprefix . 'members', yjl_SQLString($u, 'text')); $res = mysql_query($q_res) or die(''); if (mysql_num_rows($res) > 0) { $un_c = 1; } mysql_free_result($res); $q_res = sprintf('select uid from %s where email=%s limit 1', $dbprefix . 'members', yjl_SQLString($email, 'text')); $res = mysql_query($q_res) or die(''); if (mysql_num_rows($res) > 0) { $em_c = 1; } mysql_free_result($res);
function yjl_chkusername($u, $t = 0) { global $dbprefix; $un = $u . ($t > 0 ? '_' . $t : ''); $q_res = sprintf('select uid from %s where username=%s limit 1', $dbprefix . 'members', yjl_SQLString($un, 'text')); $res = mysql_query($q_res) or die(mysql_error()); if (mysql_num_rows($res) > 0) { $t++; $u = yjl_chkusername($u, $t); } else { $u = $un; } mysql_free_result($res); return $u; }