Пример #1
0
function checkSubmitValues()
{
    // Errors to show if we find any
    $msg = array();
    global $t;
    // reassign vars to user input in case we need to send them back to fix something.
    $t->assign('email', cleanFormData($_POST['email']));
    $t->assign('user', cleanFormData($_POST['user']));
    if (strlen($_POST['pass']) < 6) {
        array_push($msg, "Your password must be at least 6 characters.");
    }
    if (strlen($_POST['pass']) > 25) {
        array_push($msg, "Your password cannot be more than 25 characters.");
    }
    if ($_POST['pass'] != $_POST['pass2']) {
        array_push($msg, "Your retyped password did not match the first typed password.");
    }
    /* Spruce up username, check length */
    if (strlen(stripslashes($_POST['user'])) > 40 || strlen(stripslashes($_POST['user'])) < 3) {
        array_push($msg, "Username must be between 3 and 40 characters.");
    } elseif (!preg_match('|^[a-zA-Z0-9-_]+$|i', $_POST['user'])) {
        array_push($msg, "Username can only contain letters, numbers, hyphens, and underscores");
    } elseif (usernameTaken($_POST['user'])) {
        array_push($msg, "The username \"" . cleanFormData($_POST['user']) . "\"is already taken. Please pick another one.");
    }
    /* Check if email is valid */
    if (!emailValid($_POST['email'])) {
        array_push($msg, "Email address is not valid.");
    }
    if (count($msg) <= 0) {
        /* Verify the captcha, but only if everything else is good */
        $securimage = new Securimage();
        if ($securimage->check($_POST['captcha_code']) == false) {
            array_push($msg, "The \"captcha\" text entered was incorrect.<br />Please try again.");
        }
    }
    if (count($msg) > 0) {
        $t->assign('messages', $msg);
        $t->assign('captchaHtml', Securimage::getCaptchaHtml());
        $t->display('register.tpl');
        die;
    } else {
        return true;
    }
}
Пример #2
0
  */
 if (isset($_POST['subjoin'])) {
     /* Make sure all fields were entered */
     if (!$_POST['user'] || !$_POST['pass']) {
         die('You didn\'t fill in a required field.');
     }
     /* Spruce up username, check length */
     $_POST['user'] = trim($_POST['user']);
     if (strlen($_POST['user']) < 5) {
         die("<br>\n  <div align=center>\n  <center>\n  <table border=1 cellpadding=5 cellspacing=0 style=border-collapse: collapse id=AutoNumber1 bordercolor=#FFFFFF>\n    <tr>\n      <td width=100% bgcolor=#666666>\n      &nbsp;\n      <font color=#FF0000><b>ERROR:</b></font> Sorry, the username is shorter than 5 characters, please make it longer!<br>\n    </tr>\n  </table>\n  </center>\n</div>");
     }
     if (strlen($_POST['user']) > 30) {
         die("<br>\n  <div align=center>\n  <center>\n  <table border=1 cellpadding=5 cellspacing=0 style=border-collapse: collapse id=AutoNumber1 bordercolor=#FFFFFF>\n    <tr>\n      <td width=100% bgcolor=#666666>\n      &nbsp;\n      <font color=#FF0000><b>ERROR:</b></font> Sorry, the username is longer than 30 characters, please shorten it!<br>\n    </tr>\n  </table>\n  </center>\n</div>");
     }
     /* Check if username is already in use */
     if (usernameTaken($_POST['user'])) {
         $use = $_POST['user'];
         die("<br>\n  <div align=center>\n  <center>\n  <table border=1 cellpadding=5 cellspacing=0 style=border-collapse: collapse id=AutoNumber1 bordercolor=#FFFFFF>\n    <tr>\n      <td width=100% bgcolor=#666666>\n      &nbsp;\n      <font color=#FF0000><b>ERROR:</b></font> Sorry, the username: <strong>{$use}</strong> is already taken, please pick another one!<br>\n    </tr>\n  </table>\n  </center>\n</div>");
     }
     /* Check pass length */
     if (strlen($_POST['pass']) < 5) {
         die("<br>\n  <div align=center>\n  <center>\n  <table border=1 cellpadding=5 cellspacing=0 style=border-collapse: collapse id=AutoNumber1 bordercolor=#FFFFFF>\n    <tr>\n      <td width=100% bgcolor=#666666>\n      &nbsp;\n      <font color=#FF0000><b>ERROR:</b></font> Sorry, the password is shorter than 5 characters, please make it longer!<br>\n    </tr>\n  </table>\n  </center>\n</div>");
     }
     if (strlen($_POST['pass']) > 32) {
         die("<br>\n  <div align=center>\n  <center>\n  <table border=1 cellpadding=5 cellspacing=0 style=border-collapse: collapse id=AutoNumber1 bordercolor=#FFFFFF>\n    <tr>\n      <td width=100% bgcolor=#666666>\n      &nbsp;\n      <font color=#FF0000><b>ERROR:</b></font> Sorry, the password is longer than 32 characters, please shorten it!<br>\n    </tr>\n  </table>\n  </center>\n</div>");
     }
     /* Add the new account to the database */
     $md5pass = md5($_POST['pass']);
     $_SESSION['reguname'] = $_POST['user'];
     $_SESSION['regresult'] = addNewUser($_POST['user'], $md5pass);
     $_SESSION['registered'] = true;