Example #1
0
 function signup($data)
 {
     global $_ginfo;
     $outp = array("ec" => 1, "data" => 0);
     $temp = User::signUp(Fun::getflds($_ginfo["action_constrain"]["signup"]["need"], $data));
     if ($temp > 0) {
         $outp["data"] = $temp;
     } else {
         $outp["ec"] = $temp;
     }
     return $outp;
 }
Example #2
0
 public function signUp(Request $request, Response $response, $args)
 {
     $this->logger->info("SignUp page action dispatched");
     $uri = $request->getUri();
     if ($request->getMethod() == 'POST') {
         $data = $request->getParsedBody();
         $v = new $this->validator($data);
         $v->lang('es');
         $v->rule('required', array('email', 'username', 'password', 'company'));
         if ($v->validate()) {
             try {
                 $this->logger->info("Signup with parameters: " . $data['email'] . " - " . $data['username'] . " - " . $data['password'] . " - " . $data['company']);
                 $newUser = new User();
                 $newUser->setUsername($data['username']);
                 $newUser->setEmail($data['email']);
                 $newUser->setPassword($data['password']);
                 $newUser->signUp();
                 if ($newUser != null && $newUser->isAuthenticated()) {
                     $result = ParseCloud::run('addUserToRole', ['roleName' => 'Manager'], false);
                     $this->logger->info("User added to Manager Role? " . $result);
                     $company = new Company();
                     $company->setName($data['company']);
                     $company->save();
                     $this->flash->addMessage('info', 'Sample flash message');
                     return $response->withStatus(302)->withHeader('Location', $uri->withPath(''));
                 }
             } catch (ParseException $e) {
                 ParseErrorHandler::handleParseError($e);
                 $this->flash->addMessage('error', $e->getMessage());
                 return $response->withStatus(302)->withHeader('Location', $uri->withPath('signup'));
             }
         }
         foreach ($v->errors() as $field => $errors) {
             foreach ($errors as $error) {
                 $this->flash->addMessage('error', $error);
             }
         }
         return $response->withStatus(302)->withHeader('Location', $uri->withPath('signup'));
     }
     // Get Messages
     $messages = $this->flash->getMessages();
     // Fetch Template
     $body = $this->view->fetch('login/signup.twig', ['flash' => $messages]);
     // Write Response
     return $response->write($body);
 }
Example #3
0
function signUp()
{
    include_once "../model/User.php";
    $user = new User();
    $fullname = $_REQUEST['fullname'];
    $email = $_REQUEST['email'];
    $username = $_REQUEST['username'];
    $phone = $_REQUEST['phone'];
    $user_password = $_REQUEST['password'];
    if ($user->signUp($fullname, $email, $username, $phone, $user_password)) {
        //successfully added send email for confirmation
        //sendEmail($sender, $receipient, $subject, $message);
        //response alert
        echo '{"result": 1, "message": "Your have successfully signed up"}';
        return;
        //redirect to login page
    } else {
        echo '{"result: 0, "message": "Signup was unsuccessful. Try again."}';
        return;
    }
}
Example #4
0
 public function dealWithPost()
 {
     /*
      *	1.sign in
      *	2.sign up
      *	3.submit xueshu
      *	4.submit xueshu huida
      */
     $way = $this->way;
     if ($way === 1 or $way === 2) {
         $name = $_POST['name'];
         $pass = $_POST['pass'];
         $verify_code = $_POST['verifycode'];
         $sign_token = $_POST['signToken'];
         $verify_name = $way === 1 ? 'in' : 'up';
         $bool = false;
         if ($sign_token !== $_SESSION['token']['sign']) {
             $arr = array('isok' => '0', 'code' => '2', 'info' => 'sign token wrong');
         } else {
             if (strtolower($verify_code) === strtolower($_SESSION['verify_code'][$verify_name])) {
                 $bool = true;
             } else {
                 $arr = array('isok' => '0', 'code' => '1', 'info' => 'wrong verify_code');
             }
         }
         if ($bool) {
             //OK,执行开始!
             switch ($this->way) {
                 case 1:
                     //sign in
                     $arr = array();
                     $arr['name'] = $name;
                     $arr['pass'] = $pass;
                     $user = new User($this->arr);
                     $arr = $user->signIn($arr);
                     break;
                 case 2:
                     //sign up
                     $arr = array();
                     $arr['name'] = $name;
                     $arr['pass'] = $pass;
                     $user = new User($this->arr);
                     $arr = $user->signUp($arr);
                     break;
             }
         }
         echo json_encode($arr);
     }
     if ($way === 3) {
         $arr = array();
         $arr['kinds'] = C::safe($_POST['kinds'], $this->dbc);
         $arr['title'] = C::safe(urldecode($_POST['title']), $this->dbc);
         $arr['content'] = urldecode($_POST['content']);
         $xueshu = new Xueshu($this->arr);
         $arr = $xueshu->insertXueshu($arr);
         echo json_encode($arr);
     }
     if ($way === 4) {
         $user = new User($this->arr);
         if (!$user->isLogin()) {
             $arr = array("isok" => 0, "code" => 1, "info" => 'Not sign in');
             echo json_encode($arr);
             exit;
         }
         $content = Safe::removeXSS(urldecode($_POST['content']));
         $id = (int) $_POST['id'];
         $arr = array("kinds" => "b1", "title" => "", "content" => $content, "huida_id" => $id);
         $xueshu = new Xueshu($this->arr);
         $arr = $xueshu->insertXueshu($arr);
         echo json_encode($arr);
         exit;
     }
 }
Example #5
0
<?php

require_once "User.php";
require_once "db.php";
@Database::connect();
if (!Database::$link) {
    Database::error();
}
if (!isset($_POST["firstName"]) || !isset($_POST["lastName"]) || !isset($_POST["email"]) || !isset($_POST["password"]) || !isset($_POST["confirmPassword"])) {
    die;
}
$firstName = $_POST["firstName"];
$lastName = $_POST["lastName"];
$email = $_POST["email"];
$password = $_POST["password"];
$confirmPassword = $_POST["confirmPassword"];
$imgLink = basename($_FILES["photo"]["name"]);
copy($_FILES["photo"]["tmp_name"], "avatars/" . $imgLink);
$newUser = new User($email, $password, $firstName, $lastName, null, null, 0, $imgLink);
$newUser->signUp();
header("Location: ../front-end/signIn.html");
Database::close();
Example #6
0
    }
    header('Content-Type: application/json');
    echo json_encode($result);
}, $f3->get('route_ttl'));
/**
 * Route: FB "ping", becuase we don't know if they're signin in or signing up, this route will take care of figuring that out
 *
 * @example /user/fb-ping
 */
$f3->route(array('POST /user/fb-ping'), function ($f3, $params) use($db) {
    $facebook_id = $f3->get('POST.facebook_id');
    $registration_id = getRegistrationID();
    if ($facebook_id) {
        $user = new User(null, null, $facebook_id);
        if (!$user->existsAlready()) {
            if ($user->signUp($registration_id)) {
                $result = (object) array('status' => 1, 'status_explanation' => 'Success.', 'user_info' => $user->getInfo(), 'token' => $user->getToken());
            } else {
                $result = (object) array('status' => -1, 'status_explanation' => 'Database error, couldn\'t insert facebook user record.');
            }
        } else {
            // Generates a token based on facebook_id and tries to sign in with that.
            if ($user->signIn(null, $user->getToken(), $registration_id)) {
                $result = (object) array('status' => 1, 'status_explanation' => 'Success.', 'user_info' => $user->getInfo(false, true), 'token' => $user->getToken());
            } else {
                $result = (object) array('status' => -2, 'status_explanation' => 'A user with provided facebook ID already exists. But that shouldnt matter...');
            }
        }
    } else {
        $result = (object) array('status' => -3, 'status_explanation' => 'Missing/Invalid data.');
    }