function check_login() { global $PHP_SELF, $PHORUM, $q, $DB; $success = false; if (isset($_GET["logout"])) { setcookie("phorum_admin_session", ""); $success = true; header("Location: {$PHP_SELF}"); exit; } if (isset($_COOKIE["phorum_admin_session"])) { $SQL = "Select * from {$PHORUM['auth_table']} where sess_id='{$_COOKIE['phorum_admin_session']}'"; $q->query($DB, $SQL); $PHORUM["admin_user"] = $q->getrow(); if ($PHORUM["admin_user"]["id"]) { $SQL = "Select forum_id from {$PHORUM['mod_table']} where user_id=" . $PHORUM["admin_user"]["id"]; $q->query($DB, $SQL); while ($rec = $q->getrow()) { $PHORUM["admin_user"]["forums"][$rec["forum_id"]] = true; } if (is_array($PHORUM["admin_user"]["forums"])) { $success = true; } } } if (!$success && isset($_POST["login"]) && isset($_POST["passwd"])) { $id = phorum_check_login($_POST['login'], $_POST["passwd"]); if ($id) { $sess_id = phorum_session_id($_POST['login'], $_POST["passwd"]); setcookie("phorum_admin_session", "{$sess_id}"); phorum_login_user($sess_id, $id); header("Location: {$PHP_SELF}"); exit; } } if (!$success) { $SQL = "select user_id from {$PHORUM['mod_table']} where forum_id=0 limit 1"; $q->query($DB, $SQL); if ($q->numrows() > 0) { show_login(); exit; } else { // create temporary user $PHORUM["admin_user"]["name"] = "Temporary User"; $PHORUM["admin_user"]["forums"][0] = true; } } }
$Error = $lDupName; } if (strtolower($rec['email']) == strtolower($email)) { $Error = $lDupEmail; } } else { $md5_pass = md5($password); $id = $DB->nextid($pho_main . "_auth"); $SQL = "Insert into {$pho_main}" . "_auth\r\n (id, name, username, email, webpage, image, password, signature, icq, yahoo, aol, msn, jabber)\r\n values\r\n ({$id}, '{$safe_name}', '{$safe_user}', '{$safe_email}', '{$safe_webpage}', '{$safe_image}', '{$md5_pass}', '{$safe_signature}', '{$safe_icq}', '{$safe_yahoo}', '{$safe_aol}', '{$safe_msn}', '{$safe_jabber}')"; $q->query($DB, $SQL); echo $q->error(); if ($DB->type == "mysql") { $id = $DB->lastid(); } $sess_id = md5($user . $password); phorum_login_user($sess_id, $id); $done = true; } } } elseif ($process) { $Error = $lFillInAll; } $title = " - {$lRegisterCaption}"; include phorum_get_file_name("header"); // hack $login_page = "login"; ////////////////////////// // START NAVIGATION // ////////////////////////// if (count($ActiveForums) > 1) { addnav($menu, $lForumList, "{$forum_page}.{$ext}?f={$ForumParent}{$GetVars}");