Ejemplo n.º 1
0
 static function user_exists($email, $password = null)
 {
     global $_MYSQLI;
     $query = 'SELECT * FROM user WHERE user_email = "' . $_MYSQLI->real_escape_string($email) . '"';
     if (!is_null($password)) {
         $query .= ' AND user_password = "******"';
     }
     $users_matchs_result = $_MYSQLI->query($query);
     if ($users_matchs_result->num_rows == 1) {
         return $users_matchs_result->fetch_object()->user_id;
     } else {
         return 0;
     }
 }
require_once "include/sqlbuilder.class.php";
$auth = new Auth(true);
$user = Auth::getUser();
$_RULES = array("user_firstname" => Validation::$f->notEmpty_String, "user_lastname" => Validation::$f->notEmpty_String, "user_email" => Validation::$f->Email, "user_schoolname" => Validation::$f->notEmpty_String);
$v = new Validation($_POST, array("user_firstname", "user_lastname", "user_email", "user_schoolname", "user_password", "user_repassword"), $_RULES);
if ($v->fieldsExists()) {
    $setrepassword = Validation::Query($_POST, array("user_password", "user_repassword"));
    $repassword = $setrepassword ? $_POST["user_password"] == $_POST["user_repassword"] : false;
    $email_available = Auth::user_exists($_POST["user_email"]) == 0 || $_POST["user_email"] == $user->user_email;
    if ($v->testAll() && $email_available) {
        $set = $v->export($_MYSQLI, array("user_firstname", "user_lastname", "user_email", "user_schoolname", "user_password"));
        if (false) {
            $set["user_photo_path"] = "";
        }
        if ($repassword) {
            $set["user_password"] = Security::CryptPassword($_POST["user_password"]);
        }
        $statement = new SQLBuilder($_MYSQLI);
        $q = $statement->update('user')->set($set)->where("user_id", "=", Auth::getUserId())->build();
        $r = $_MYSQLI->query($q);
    }
}
$user = Auth::getUser();
/*

$other_query_photo = 'SELECT user_photo_path
				FROM user
				WHERE user_id = '.Auth::getUserId();


$other_result_photo = $_MYSQLI->query($other_query_photo);
Ejemplo n.º 3
0
$repassword = true;
if ($v->fieldsExists()) {
    $repassword = $_POST["user_password"] == $_POST["user_repassword"];
    $email_available = Auth::user_exists($_POST["user_email"]) == 0;
    if (!$email_available) {
        $error = "E-Mail non disponible";
    } else {
        if (!$repassword) {
            $error = "Les mots de passe ne correspondent pas";
        } else {
            $error = "Champ(s) invalide(s)";
        }
    }
    if ($v->testAll() && $repassword && $email_available) {
        $statement = new SQLBuilder($_MYSQLI);
        $q = $statement->insertInto('user')->set($v->export($_MYSQLI, array("user_firstname", "user_lastname", "user_email", "user_schoolname"), array("user_photo_path" => "", "user_password" => Security::CryptPassword($_POST["user_password"]))))->build();
        $r = $_MYSQLI->query($q);
        Auth::login($_POST["user_email"], $_POST["user_password"]);
        header("Location: index.php");
        exit;
    }
}
?>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>QCManager</title>
		<link rel="stylesheet" type="text/css" href="css/auth.css">
	</head>