示例#1
0
function insertUser($username, $password, $emailAddress)
{
    //Instance class
    $obj = createInstance();
    //Clean strings for security
    secureStrings($username, $password)->{$username};
    secureStrings($username, $password)->{$password};
    //Salt password
    $password = saltPassword($password);
    //Check if username already exists
    if (!checkIfUserAlreadyExists($username, $password)) {
        echo "utaken";
    } else {
        if (checkIfEmailExists($emailAddress)) {
            echo "eused";
        } else {
            //Hash username
            $hash = saltPassword($username);
            //Get structure string
            $structure_login = $obj->structure_login();
            //Create query
            $databaseQuery = "INSERT INTO login {$structure_login} VALUES ('{$username}', '{$password}', '{$emailAddress}', '{$hash}', 'false')";
            //Execute database query
            executeDatabase($databaseQuery);
            //Get email address string
            $email_webmaster = $obj->email_webmaster();
            //Get confirmation url
            $url_confirm = $obj->confirm_url();
            //Create message
            $message = "Thank you for registering!\n\nUsername: {$username}\n\nEmail Address: {$emailAddress}\n\nConfirm User: {$url_confirm}" . $hash . "&emailAddress=" . $emailAddress;
            $subject = "Thank you for registering!";
            //Send Email
            sendEmail($message, $emailAddress, $subject);
            print 'Correct';
        }
    }
}
示例#2
0
function insertUser($username, $password, $emailAddress)
{
    //Instance class
    $obj = createInstance();
    //Clean strings for security
    $username = secureStrings($username, $password);
    $password = secureStrings($username, $password);
    /*	secureStrings($username, $password)->$username;
    	secureStrings($username, $password)->$password;*/
    //Salt password
    $password = saltPassword($password);
    //Check if username already exists
    if (!checkIfUserAlreadyExists($username, $password)) {
        echo "utaken";
    } else {
        if (checkIfEmailExists($emailAddress)) {
            echo "eused";
        } else {
            //Hash username
            $hash = saltPassword($username);
            //Get structure string
            $structure_login = $obj->structure_login();
            //Create query
            $databaseQuery = "INSERT INTO login {$structure_login} VALUES ('{$username}', '{$password}', '{$emailAddress}', '{$hash}', 'false')";
            //Execute database query
            executeDatabase($databaseQuery);
            //Get email address string
            $email_webmaster = $obj->email_webmaster();
            //Get confirmation url
            $url_confirm = $obj->confirm_url();
            //Create message
            $message = "感谢您的注册<br>\n\t\t用户名: {$username}<br>\n\t\t邮箱: {$emailAddress}<br>\n\t\t认证账号: {$url_confirm}" . $hash . "&emailAddress=" . $emailAddress . "</a><br>";
            $subject = "感谢您的注册";
            /*		$message = "Thank you for registering!<br>
            		Username: $username<br>
            		Email Address: $emailAddress<br>
            		Confirm User:<a href='$url_confirm".$hash."&emailAddress=".$emailAddress."'>
            		 $url_confirm".$hash."&emailAddress=".$emailAddress."</a><br>";
            		$subject = "Thank you for registering!";
            */
            //Send Email
            sendEmail($message, $emailAddress, $subject);
            //echo "sendEmail<br>";
            print 'Correct';
        }
    }
}