Ejemplo n.º 1
0
function registration($username, $firstName, $lastName, $password, $email, $date, $gender)
{
    //Check another time email and username if exist.
    //If somebody sent registration request don't through front end
    if (!check_reg_nickName($username)) {
        return 0;
    }
    if (!check_reg_email($email)) {
        return 0;
    }
    //gender convert
    if ($gender == "male") {
        $gender = 1;
    } else {
        $gender = 0;
    }
    //generate UUID
    $uuid = uniqid(rand(), true);
    //Date convert to SQl format
    $date = date("Y-m-d", strtotime(str_replace('/', '-', $date)));
    //Password encryption
    $password = password_hash($password, PASSWORD_DEFAULT);
    $user_image = 'def_img';
    $connection = connect();
    $ps = $connection->prepare("insert into users (u_uID, u_email, u_pwd, u_f_name, u_l_name, u_b_day, u_gender, u_userName, u_image) values( ?, ?, ?, ?, ?, ?, ?, ?, ?) ");
    $ps->bind_param("ssssssiss", $uuid, $email, $password, $firstName, $lastName, $date, $gender, $username, $user_image);
    $ps->execute();
    $u_id = $ps->insert_id;
    $ps->close();
    $connection->close();
    //Custom date Formating d/m/Y function from helpers.php
    $date = dateFormat($date);
    $about = '';
    //gender convert
    if ($gender == 1) {
        $gender = "male";
    } else {
        $gender = 'female';
    }
    $userSession = new stdClass();
    $userSession->u_id = $u_id;
    $userSession->uuid = $uuid;
    $userSession->email = $email;
    $userSession->firstName = $firstName;
    $userSession->lastName = $lastName;
    $userSession->date = $date;
    $userSession->gender = $gender;
    $userSession->username = $username;
    $userSession->about = $about;
    //Add userData to Session helpers.php
    session_write($userSession);
    //Some bug with write to session througt stdClass
    $_SESSION['user_image'] = $user_image;
    set_user_cookies($u_id, $username, $email);
    return TRUE;
}
Ejemplo n.º 2
0
<?php

require_once 'usersLogic.php';
require_once __DIR__ . '/../includes/helpers.php';
$command = $_REQUEST['command'];
switch ($command) {
    //Registration NickName check if exist
    case 'username':
        $user_name = $_POST['username'];
        $user_name = addslashes($user_name);
        $result = check_reg_nickName($user_name);
        echo json_encode(array('valid' => $result));
        break;
        //Registration Email check if exist
    //Registration Email check if exist
    case 'email':
        $email = $_POST['email'];
        $email = addslashes($email);
        $result = check_reg_email($email);
        echo json_encode(array('valid' => $result));
        break;
        // http://localhost/SemiProjectLayers/users/usersAPI.php?command=registration&username=asdf&firstName=bla&lastName=foo&password=12345678&confirmPassword=12345678&email=vvv@dfdfd.com&date=15/12/2015&gender=male
        /*     * ********************
              Registration New User
             * ********************* */
    // http://localhost/SemiProjectLayers/users/usersAPI.php?command=registration&username=asdf&firstName=bla&lastName=foo&password=12345678&confirmPassword=12345678&email=vvv@dfdfd.com&date=15/12/2015&gender=male
    /*     * ********************
          Registration New User
         * ********************* */
    case 'registration':
        $username = $_POST['username'];