コード例 #1
0
ファイル: login.php プロジェクト: BackupTheBerlios/jonescms
function finish($uname, $pwd)
{
    global $dbi;
    $md5_pwd = md5($pwd);
    $l_result = sql_query("select * from jones_user where uname='{$uname}' and pwd='{$md5_pwd}'", $dbi);
    if (sql_num_rows($l_result, $dbi) == 0) {
        $error = "Incorrect username or password";
        Header("Location: login.php?error={$error}");
        die;
    }
    list($uid, $uname, $pwd, $fname, $lname, $email, $privs) = sql_fetch_row($l_result, $dbi);
    sendCookie($uid, $uname, $pwd, $fname, $lname, $email, $privs);
    Header("Location: index.php");
}
コード例 #2
0
ファイル: user.php プロジェクト: BackupTheBerlios/jonescms
function finish($uid, $uname, $pwd1, $pwd2, $fname, $lname, $email)
{
    global $dbi;
    # is it a valid email?
    if (!$email || $email == "" || !eregi("^[_\\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\\.)+[a-z]{2,6}\$", $email) || strrpos($email, ' ') > 0) {
        $error = "Invalid email address!";
        Header("Location: user.php?error={$error}&uid={$uid}&uname={$uname}&fname={$fname}&lname={$lname}&email={$email}");
        die;
    }
    if (strlen($pwd1) > 0 || strlen($pwd2) > 0) {
        # do the passwords differ?
        if (strcmp($pwd1, $pwd2) != 0) {
            $error = "The two passwords provided differ!";
            Header("Location: user.php?error={$error}&uid={$uid}&uname={$uname}&fname={$fname}&lname={$lname}&email={$email}");
            die;
        }
        # is the pwd longer than 6 chars?
        if (strlen($pwd1) < 6) {
            $error = "Password cannot be shorter than 6 chars!";
            Header("Location: user.php?error={$error}&uid={$uid}&uname={$uname}&fname={$fname}&lname={$lname}&email={$email}");
            die;
        }
        # cypher pwd
        $pwd = md5($pwd1);
        sql_query("update jones_user set pwd='{$pwd}', fname='{$fname}', lname='{$lname}', email='{$email}' where id='{$uid}'", $dbi);
        list($privs) = sql_fetch_row(sql_query("select privs from jones_user where id='{$uid}'", $dbi), $dbi);
        sendCookie($uid, $uname, $pwd, $fname, $lname, $email, $privs);
    } else {
        sql_query("update jones_user set fname='{$fname}', lname='{$lname}', email='{$email}' where id='{$uid}'", $dbi);
    }
    Header("Location: index.php");
}