Example #1
0
 public function checkIfUserExists($userNameToFind)
 {
     include_once '/kunden/homepages/0/d643120834/htdocs/config/index.php';
     $user = new User();
     if ($user->userExists($userNameToFind) == true) {
         return true;
     } else {
         return false;
     }
 }
Example #2
0
 public function displayMain()
 {
     global $smarty, $link;
     $errors = array();
     if (Tools::isSubmit('CreateUser')) {
         if (!Validate::isEmail(Tools::getRequest('email')) || User::userExists(Tools::getRequest('email'))) {
             $errors[] = 'The email is invalid or an account is already registered with this e-mail!';
         } elseif (empty($_POST['passwd'])) {
             $errors[] = 'The password is empty!';
         } else {
             $user = new User();
             $user->copyFromPost();
             $user->active = 1;
             if ($user->add()) {
                 $address = new Address();
                 $address->copyFromPost();
                 $address->id_user = $user->id;
                 $address->is_default = 1;
                 if ($address->add()) {
                     $user->logined(array('id_address' => $address->id));
                     if (Tools::getRequest("step") == 2) {
                         Tools::redirect($link->getPage('CheckoutView'));
                     } else {
                         Tools::redirect($link->getPage('MyaccountView'));
                     }
                     return;
                 } else {
                     $errors = $address->_errors;
                 }
             } else {
                 $errors = $user->_errors;
             }
         }
     }
     $countrys = Country::loadData(1, 500, null, null, array('active' => 1));
     $smarty->assign(array('id_default_country' => Configuration::get('TM_DEFAULT_COUNTRY_ID'), 'countrys' => $countrys, 'step' => Tools::getRequest("step"), 'errors' => $errors));
     return $smarty->fetch('join.tpl');
 }
Example #3
0
    public function displayMain()
    {
        global $cookie;
        /*
        when user add or change address,from addressView or joinView
        */
        if (isset($_GET['ajaxStates']) and isset($_GET['id_country'])) {
            $states = Db::getInstance()->getAll('
			SELECT s.id_state, s.name
			FROM ' . DB_PREFIX . 'state s
			LEFT JOIN ' . DB_PREFIX . 'country c ON (s.`id_country` = c.`id_country`)
			WHERE s.id_country = ' . (int) Tools::G('id_country') . ' AND s.active = 1 AND c.`need_state` = 1
			ORDER BY s.`name` ASC');
            if (is_array($states) and !empty($states)) {
                $list = '';
                if (Tools::G('no_empty') != true) {
                    $list = '<option value="0">-----------</option>' . "\n";
                }
                foreach ($states as $state) {
                    $list .= '<option value="' . (int) $state['id_state'] . '"' . (Tools::G('id_state') == $state['id_state'] ? ' selected="selected"' : '') . '>' . $state['name'] . '</option>' . "\n";
                }
            } else {
                $list = 'false';
            }
            die($list);
        }
        //end get states
        /*
        from cartView get total
        */
        if (isset($_GET['getTotal']) and isset($_GET['id_cart']) and isset($_GET['id_carrier'])) {
            $carrier = new Carrier((int) $_GET['id_carrier']);
            $cart = new Cart((int) $_GET['id_cart']);
            $shipping = $carrier->shipping;
            $p_total = $cart->getProductTotal();
            $total = $shipping + $p_total - $cart->discount;
            $arr = array('name' => $carrier->name, 'shipping' => Tools::displayPrice($shipping), 'total' => Tools::displayPrice($total));
            echo json_encode($arr);
            exit;
        }
        //end use gettotal
        /*
        start use promo code,from CartView
        */
        if (isset($_GET['validatedPromocode']) && isset($_GET['code'])) {
            if (!isset($cookie->id_cart)) {
                $arr = array('status' => "NO", 'msg' => "cart is not init!");
                echo json_encode($arr);
                exit;
            }
            $row = Db::getInstance()->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'coupon WHERE code="' . pSQL($_GET['code']) . '" AND active=1');
            if ($row) {
                if ($row['id_user'] == 0 || $row['id_user'] == @$cookie->id_user) {
                    $cart = new Cart($cookie->id_cart);
                    $total = $cart->getProductTotal();
                    $quantity = $cart->getProductQantity();
                    $discount = 0;
                    if ($total > $row['total_over'] || $row['quantity_over'] > 0 && $quantity > $row['quantity_over']) {
                        if ($row['off'] > 0) {
                            $discount = (double) $total * $row['off'] / 100;
                        } else {
                            $discount = (double) $row['amount'];
                        }
                        $cart->discount = $discount;
                        if ($cart->update()) {
                            $arr = array('status' => "YES", 'discount' => "-" . Tools::displayPrice($discount), 'total' => Tools::displayPrice($cart->getOrderTotal()));
                            echo json_encode($arr);
                            exit;
                        }
                    }
                }
            }
            $arr = array('status' => "NO", 'msg' => "the code don't found!");
            echo json_encode($arr);
            exit;
        }
        //end use promo code
        /**
         * 购物车
         */
        if (Tools::G('c') == 'Cart') {
            global $cart;
            switch (Tools::G('m')) {
                case 'removeItem':
                    if ($cart->deleteProduct(Tools::G('id'))) {
                        $cart_info = $cart->getCartInfo();
                        $result = array('status' => 'yes', 'cart_total' => Tools::displayPrice($cart_info['cart_total']), 'cart_quantity' => $cart_info['cart_quantity']);
                        die(json_encode($result));
                    }
                    die(json_encode(array("status" => "no")));
                    break;
                case 'plusItem':
                    if ($row = $cart->plusProduct(Tools::G('id'))) {
                        $cart_info = $cart->getCartInfo();
                        $result = array('status' => 'yes', 'cart_total' => Tools::displayPrice($cart_info['cart_total']), 'cart_quantity' => $cart_info['cart_quantity'], 'item' => array('quantity' => $row['quantity'], 'total' => Tools::displayPrice($row['total'])));
                        die(json_encode($result));
                    }
                    die(json_encode(array("status" => "no")));
                    break;
                case 'minusItem':
                    if ($row = $cart->minusProduct(Tools::G('id'))) {
                        $cart_info = $cart->getCartInfo();
                        $result = array('status' => 'yes', 'cart_total' => Tools::displayPrice($cart_info['cart_total']), 'cart_quantity' => $cart_info['cart_quantity'], 'item' => array('quantity' => $row['quantity'], 'total' => Tools::displayPrice($row['total'])));
                        die(json_encode($result));
                    }
                    die(json_encode(array("status" => "no")));
                    break;
                case 'deleteMultiItem':
                    if ($cart->deleteMultiProduct(explode(',', Tools::G('id')))) {
                        $cart_info = $cart->getCartInfo();
                        $result = array('status' => 'yes', 'cart_total' => Tools::displayPrice($cart_info['cart_total']), 'cart_quantity' => $cart_info['cart_quantity']);
                        die(json_encode($result));
                    }
                    die(json_encode(array("status" => "no")));
                    break;
                default:
                    break;
            }
        }
        /**
         * 商品收藏
         */
        if (Tools::G('c') == 'Wish') {
            if (!isset($cookie->id_user)) {
                die(json_encode(array("status" => "no", "msg" => "d'not login!")));
            }
            $user = new User((int) $cookie->id_user);
            if (!Validate::isLoadedObject($user)) {
                die(json_encode(array("status" => "no", "msg" => "user load fail!")));
            }
            switch (Tools::G('m')) {
                case 'addItem':
                    if ($status = $user->addToWish(Tools::G('id'))) {
                        if ($status === 1) {
                            $result = array("m" => "add", 'status' => 'yes');
                        } else {
                            if ($status === -1) {
                                $result = array("m" => "delete", 'status' => 'yes');
                            }
                        }
                        die(json_encode($result));
                    }
                    die(json_encode(array("status" => "no")));
                    break;
                default:
                    break;
            }
        }
        /*
        start use add wish,from ProductView or CategoryView
        */
        if (isset($_GET['action']) && $_GET['action'] == 'add_wish' && isset($_GET['id_product'])) {
            if ($action = Wish::userAddWishProduct($_GET['id_product'])) {
                $wishs = Wish::getWishSumByUser();
                $count_html = "";
                if ($wishs['count'] > 0) {
                    $count_html = "<i>{$wishs['count']}</i>";
                }
                $arr = array('action' => $action, 'count' => $count_html, 'status' => "YES");
                echo json_encode($arr);
            } else {
                $arr = array('status' => "NO");
                echo json_encode($arr);
            }
            exit;
        }
        //end use add wish
        /**
         * 邮箱是否已被注册
         */
        if (Tools::P('existsEmail')) {
            $valid = true;
            if (User::userExists(Tools::P('existsEmail'))) {
                $valid = false;
            }
            echo json_encode(array('valid' => $valid));
        }
    }
Example #4
0
        break;
    case PACKAGE4_DIAMONDS_ID:
        $diamonds = PACKAGE4_DIAMONDS_COUNT;
        $amount = PACKAGE4_DIAMONDS_COST;
        break;
    case PACKAGE5_DIAMONDS_ID:
        $diamonds = PACKAGE5_DIAMONDS_COUNT;
        $amount = PACKAGE5_DIAMONDS_COST;
        break;
}
$valid_transction = validTransction($transaction_id);
$valid_request = detectLevel6Request();
$level = User::getUserLevel($udid);
if ($valid_request) {
    if (DiamondPurchasedHistory::addPurchasedDiamond($udid, $amount, $diamonds, $product_id, $transaction_id, $purchase_date, $app_item_id, $quantity, $bid, $bvrs, $valid_transction, $level)) {
        if (User::userExists($udid) != null && $valid_transction) {
            if (User::addUserPurchasedDiamonds($udid, $diamonds)) {
                echo "success";
                exit;
            } else {
                $fp = fopen('log.txt', 'a');
                fwrite($fp, 'Enable award diamond to user' . date('l jS \\of F Y h:i:s A') . "\r\n");
                foreach ($recipt as $key => $value) {
                    fwrite($fp, $key . '=>' . $value . "\r\n");
                }
                fwrite($fp, 'udid=>' . $udid . "\r\n");
                fwrite($fp, 'amount=>' . $amount . "\r\n");
                fclose($fp);
                echo "failure";
                exit;
            }
Example #5
0
session_start();
$hascss = false;
include "header.php";
include "common/sessionuser.inc";
if (REQMETHOD == 'POST') {
    include "common/checktoken.php";
    if (isset($_POST['action']) && isset($_POST['email']) && isset($_POST['password']) && isset($_POST['password2'])) {
        $action = $_POST['action'];
        $email = strtolower($_POST['email']);
        $password = trim($_POST['password']);
        $password2 = trim($_POST['password2']);
        if ($action == "createaccount") {
            if (strlen($password) > 0 && strlen($password2) > 0 && strlen($email) > 0 && $password2 === $password) {
                try {
                    $user = new User();
                    if (User::userExists($email)) {
                        $formmessage = 'Email exists.';
                        $formmessageclass = 'red';
                    } else {
                        $userisowner = Database::DBTRUE;
                        $user->signup($email, $password, $userisowner);
                        $formmessage = 'Your account has been created. ';
                        $formmessage .= '<a href="login">Login here.</a>';
                        $formmessageclass = 'green';
                    }
                } catch (Exception $e) {
                    $errormessage = $e->getMessage();
                    trigger_error($errormessage, E_USER_WARNING);
                    $formmessage = $errormessage;
                    $formmessageclass = 'red';
                }
Example #6
0
 public function unique_username($usr)
 {
     $exists = User::userExists($usr);
     if ($exists) {
         $this->form_validation->set_message('unique_username', 'The Username already exists. Enter another one.');
         return FALSE;
     } else {
         return TRUE;
     }
 }
Example #7
0
    } else {
        $user->copyFromPost();
        if ($user->add()) {
            UIAdminAlerts::conf('用户已添加');
        }
    }
    if (is_array($user->_errors) and count($user->_errors) > 0) {
        $errors = $user->_errors;
    }
}
if (isset($_GET['id'])) {
    $id = (int) Tools::G('id');
    $obj = new User($id);
}
if (Tools::P('saveUser') == 'edit') {
    if (Tools::P('email') != $obj->email && User::userExists(Tools::P('email'))) {
        $obj->_errors[] = '邮箱地址已存在!';
    } elseif (Validate::isLoadedObject($obj)) {
        $obj->copyFromPost();
        $obj->update();
    }
    if (is_array($obj->_errors) and count($obj->_errors) > 0) {
        $errors = $obj->_errors;
    } else {
        UIAdminAlerts::conf('用户已更新');
    }
}
$breadcrumb = new UIAdminBreadcrumb();
$breadcrumb->home();
$breadcrumb->add(array('title' => '用户', 'active' => true));
$bread = $breadcrumb->draw();
Example #8
0
 public function checkIfUserExists($userNameToFind)
 {
     include_once $_SERVER['DOCUMENT_ROOT'] . $_SERVER['REQUEST_URI'] . '/config/index.php';
     $user = new User();
     if ($user->userExists($userNameToFind) == true) {
         return true;
     } else {
         return false;
     }
 }
Example #9
0
<?php

include "../config/config.php";
include "../config/autoloadapi.php";
$user = new User();
$username = $_GET['u'];
$result = $user->userExists($username);
if ($result) {
    echo "exists";
} else {
    echo "not";
}
Example #10
0
    } else {
        echo "Morate uneti koriscnicko ime!";
        return false;
    }
    if (!empty($_POST['password'])) {
        $password = test_input($_POST['password']);
    } else {
        echo "Morate uneti lozinku!";
        return false;
    }
    if (!empty($_POST['email'])) {
        if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
            $email = test_input($_POST['email']);
        } else {
            echo "Neispravna email adresa";
            return false;
        }
    } else {
        echo "Morate uneti email adresu!";
        return false;
    }
    if (User::userExists($username)) {
        echo "Korisnicko ime " . $username . " je zauzeto!";
        return false;
    }
    if (User::register($username, $email, $password)) {
        echo "Uspesna registracija! Uskoro cete biti prihvaceni i od strane administratora.";
    } else {
        echo "Greska! Desio se problem prilikom registracije. Pokusajte ponovo.";
    }
}
Example #11
0
<?php

include_once '../classes/User.php';
if (isset($_GET['udid'])) {
    if (User::userExists($_GET['udid'])) {
        echo "success";
        exit;
    } else {
        echo "failure";
        exit;
    }
} else {
    echo "failure";
    exit;
}
Example #12
0
 $diamonds = $items[0]['merchant-private-item-data']['diamonds']['VALUE'];
 $google_order_number = $data[$root]['google-order-number']['VALUE'];
 //TODO: Make the entry in the database for local use...
 $udid = $user_id;
 $amount = $unit_price;
 $product_id = "";
 $transaction_id = $google_order_number;
 $purchase_date = $data[$root]['timestamp']['VALUE'];
 $app_item_id = "";
 $quantity = 1;
 $bid = "";
 $bvrs = "";
 $valid_transction = 1;
 $level = User::getUserLevel($udid);
 if (DiamondPurchasedHistory::addPurchasedDiamond($udid, $amount, $diamonds, $product_id, $transaction_id, $purchase_date, $app_item_id, $quantity, $bid, $bvrs, $valid_transction, $level)) {
     if (User::userExists($udid) != null) {
         if (User::addUserPurchasedDiamonds($udid, $diamonds)) {
             $Grequest->SendDeliverOrder($google_order_number);
             break;
         } else {
             $fp = fopen('log.txt', 'a');
             fwrite($fp, 'Enable award diamond to user' . date('l jS \\of F Y h:i:s A') . "\r\n");
             foreach ($recipt as $key => $value) {
                 fwrite($fp, $key . '=>' . $value . "\r\n");
             }
             fwrite($fp, 'udid=>' . $udid . "\r\n");
             fwrite($fp, 'amount=>' . $amount . "\r\n");
             fclose($fp);
             break;
         }
     } else {
Example #13
0
 /**
  * Login user or create a new user
  * @param $username
  * @return array
  */
 public function loginUser($username)
 {
     $Object = new User();
     $result = $Object->userExists($username);
     return $result;
 }