$db->query("insert into author (username,password,email,plan,defaultLanguageId) values ('{$username}','{$password}','{$email}','{$plan}','{$languageId}')"); show_message('Your account is created! Now you can login and enjoy yourself!', 'Go To Home Page', 'index.php'); } elseif ($action == 'login') { $username = isset($_POST['username']) ? htmlspecialchars(trim($_POST['username'])) : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; $smarty->caching = 0; user_login($username, $password); header('location: index.php'); } elseif ($action == 'logout') { setcookie('user_id', ''); setcookie('password', ''); header('location: index.php'); } elseif ($action == 'update') { $smarty->assign('title', 'Update Person Info'); $smarty->assign('user_info', $login_user); $smarty->assign('compilers', get_compilers()); $smarty->caching = 0; $smarty->display('user.tpl'); } elseif ($action == 'detail') { $user_id = isset($_GET['authorId']) ? intval($_GET['authorId']) : 0; if (empty($user_id) && !empty($login_user)) { $user_id = $login_user['user_id']; } $user_info = $db->getRow("select * from author where user_id='{$user_id}'"); if (!$user_info) { show_message('There is no such user'); } $smarty->assign('user_info', $user_info); $solved_problems = $db->getAll("select distinct problemId from status where judgeStatus='Accepted' and authorId='{$user_id}' order by problemId asc"); $smarty->assign('solved_problems', $solved_problems); $smarty->assign('title', 'User Statistics');
} $smarty->assign('compilers', get_compilers()); $smarty->assign('problemId', $problemId); $smarty->assign('cid', $cid); if ($cid) { $contest = $db->getRowCached("select * from contest where id='{$cid}'"); $smarty->assign('contest', $contest); } $smarty->display('submit.tpl'); } elseif ($action == 'sendfile') { $problemId = isset($_POST['problemId']) ? intval($_POST['problemId']) : 0; $cid = isset($_POST['cid']) ? intval($_POST['cid']) : 0; $languageId = isset($_POST['languageId']) ? intval($_POST['languageId']) : 0; $code = isset($_POST['source']) ? $_POST['source'] : ''; $enable_search = 1; $compilers = get_compilers(); $lst = isset($_SESSION['lst']) ? intval($_SESSION['lst']) : 0; $smarty->assign('cid', $cid); if ($cid) { $enable_search = 0; $contest = $db->getRowCached("select * from contest where id='{$cid}'"); if (!$contest) { $smarty->assign('error_mesg', 'There is no such contest'); $_POST['source'] = stripslashes($_POST['source']); $smarty->assign('submit', $_POST); $smarty->assign('compilers', $compilers); $smarty->display('submit.tpl'); exit; } $now = time(); if ($now < $contest['startTime'] || $now > $contest['endTime']) {