Exemplo n.º 1
0
checkLoggedIn();
$updata = array();
$updata["id"] = $_SESSION["user"];
$updata["password"] = param($_POST, 'password', '');
$updata["email"] = param($_POST, 'email', '');
$updata["first_name"] = param($_POST, 'first_name', '');
$updata["last_name"] = param($_POST, 'last_name', '');
$updata["phone"] = param($_POST, 'phone', '');
$updata["city"] = param($_POST, 'city', '');
$updata["state"] = param($_POST, 'state', '');
$updata["zipcode"] = param($_POST, 'zipcode', '');
$updata["avatar"] = param($_POST, 'avatar', '');
$dbh = new PDB();
$db = $dbh->db;
$site = new Site($db);
$user = $dbh->getUser($updata["id"]);
$currentemail = $user->email;
if ($updata["email"] != "" && $updata["email"] != $currentemail) {
    $exists = $site->checkEmail($updata["email"]);
    if ($exists === true) {
        errormsg("Email address already in use.");
    }
}
try {
    $ct = 0;
    $sql = "UPDATE users SET ";
    foreach ($updata as $key => $value) {
        if ($value != "" && $key != "id") {
            if ($ct != 0) {
                $sql .= ", ";
            }
Exemplo n.º 2
0
<?php

// check if logged in
// per project or all tasks?
//
error_reporting(E_ALL);
session_start();
session_regenerate_id(false);
require_once "reqs/common.php";
require_once "reqs/pdo.php";
//require_once("reqs/auth.php");
checkLoggedIn();
$userID = param($_GET, 'userID', $_SESSION["user"]);
$dbh = new PDB();
$db = $dbh->db;
$user = $dbh->getUser($userID);
exitjson(array("user" => $user));
Exemplo n.º 3
0
    errormsg("Password required.");
}
if (empty($email)) {
    errormsg("Email required.");
}
$dbh = new PDB();
$db = $dbh->db;
$site = new Site($db);
$exists = $site->checkName($username);
if ($exists === true) {
    errormsg("Username already exists.");
}
$exists = $site->checkEmail($email);
if ($exists === true) {
    errormsg("Email address already in use.");
}
$hashed = $site->hasher($username, $password);
try {
    $st = $db->prepare("\n\t\tINSERT INTO users \n\t\t(user_n, user_p, salt, email, first_name, last_name, phone, city, state, zipcode, avatar)\n\t\tVALUES (:user, :pass, :salt, :email, :firstname, :lastname, :phone, :city, :state, :zipcode, :avatar)\n\t");
    $st->execute(array(":user" => $username, ":pass" => $hashed["hash"], ":salt" => $hashed["salt"], ":email" => $email, ":firstname" => $firstname, ":lastname" => $lastname, ":phone" => $phone, ":city" => $city, ":state" => $state, ":zipcode" => $zipcode, ":avatar" => $avatar));
    $st = $db->prepare("SELECT LAST_INSERT_ID()");
    $st->execute();
    $lastid = $st->fetch();
    $user = $dbh->getUser($lastid[0]);
} catch (PDOException $e) {
    errormsg($e->getMessage());
}
session_start();
session_regenerate_id(false);
$_SESSION["user"] = $user->id;
exitjson(array("user" => $user));
Exemplo n.º 4
0
<?php

error_reporting(E_ALL);
session_start();
session_regenerate_id(false);
require_once "reqs/common.php";
require_once "reqs/pdo.php";
//require_once("reqs/auth.php");
$dbh = new PDB();
$db = $dbh->db;
if (!isset($_SESSION["user"])) {
    errormsg("Not logged in.");
}
$userID = $_SESSION["user"];
$userdata = $dbh->getUser($userID);
exitjson(array("user" => $userdata));