text("uname"); $form->text("passwd", false); if (!$form->populate(input())) goto prep; if (!(($user = user::getByUname($form->uname)) && $user->validatePasswd($form->passwd))) { logError(ERROR, "Username or password is incorrect"); if ($user) $log = mesg::initNewAdminLog("Failed login for username '%s'", $user); goto prep; } user::setCurrent($user); location(); } /* * Action: signup - Attempt to register a new account */ if (isAction("signup")) { if (!settings::allowPublicSignup() && count(user::getAll_ordByUname()) > 0) { logError(ERROR, "You may not signup at this time"); goto prep; } $form = new form(); $form->text("uname"); $form->text("passwd", false); $form->text("cpasswd", false); if (!$form->populate(input())) goto prep; if ($form->passwd != $form->cpasswd) { logError(ERROR, "Passwords do not match"); goto prep; } if (!($user = user::initNew($form->uname, $form->passwd))) { logError(ERROR, "Your requested username is already in use"); goto prep; } user::setCurrent($user); $log = mesg::initNewAdminLog("%s account registered", $user); location("/"); } prep: if (count(user::getAll_ordByUname()) == 0) { $noaccounts = true; $activeTab['login'] = ""; $activeTab['signup'] = "in active"; $tabSwap = false; } else { $activeTab['login'] = "in active"; $activeTab['signup'] = ""; $tabSwap = settings::allowPublicSignup(); } ?>