コード例 #1
0
ファイル: process_login.php プロジェクト: jackyFeng/unisol
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
include_once "./Manager/ConnectionManager.php";
include_once "./Manager/ProductManager.php";
include_once "./Manager/CustomerManager.php";
include_once "./Manager/CreditManager.php";
$errors = array();
//To store errors
$form_data = array();
//Pass back the data to `form.php`
/* Validate the form on the server side */
$userid = addslashes(filter_input(INPUT_POST, 'userid'));
$pwd = addslashes(filter_input(INPUT_POST, 'pwdInput'));
$customerMgr = new CustomerManager();
$customer = $customerMgr->getCustomerByIDPassword($userid, $pwd);
$creditMgr = new CreditManager();
$productMgr = new ProductManager();
session_start();
//echo mysql_num_rows($resultSet);
if ($customer !== []) {
    $form_data['success'] = true;
    $_SESSION["userid"] = $userid;
    if (isset($_COOKIE["sender_email"])) {
        $sender_email = $_COOKIE["sender_email"];
        if ($sender_email !== $userid) {
            $has_received = $creditMgr->checkInvitationStatus($sender_email, $userid);
            if ($has_received === null) {
                $creditMgr->addCredit($sender_email, $userid);
                $customerMgr->updateCredit($userid, 10.0);
                setcookie('sender_email', '', time() - 1);
コード例 #2
0
ファイル: process_FB_login.php プロジェクト: jackyFeng/unisol
include_once "./Manager/ProductManager.php";
include_once "./Manager/CustomerManager.php";
include_once "./Manager/CreditManager.php";
$errors = array();
//To store errors
$form_data = array();
//Pass back the data to `form.php`
$fbId = addslashes(filter_input(INPUT_POST, 'fbId'));
$email = addslashes(filter_input(INPUT_POST, 'email'));
$random_no = (string) rand(0, 10000000000);
$invitation_link = 'invite.php?src=' . $random_no;
$customerMgr = new CustomerManager();
$creditMgr = new CreditManager();
$form_data['success'] = true;
$fbFirst = true;
$customer_fb = $customerMgr->getCustomerByIDPassword($email, $fbId);
$pwd = $fbId;
$pwdConfirm = $fbId;
if (!empty($customer_fb)) {
    $fbFirst = false;
} else {
    // add user to the database
    $customerMgr->addCustomer($email, $pwd, $email, 0.0, $invitation_link);
}
session_start();
//echo mysql_num_rows($resultSet);
$form_data['success'] = true;
$form_data['email'] = $email;
$form_data['pwd'] = $pwd;
$form_data['pwdConfirm'] = $pwdConfirm;
$_SESSION["userid"] = $email;