/** * 初始化记账管理基本数据 */ function init_bill_manage_data() { $userId = (int) $_SESSION['userId']; $code = '0'; // 加载账户列表 $accountDefault = get_user_config('accountDefault'); $accountService = new AccountService(); $accountList = $accountService->getAccountSimpleList($userId, null); $accountDebtList = $accountService->getAccountSimpleList($userId, 2); $accountCreditList = $accountService->getAccountSimpleList($userId, 3); // 加载收支类别列表 $billTypeService = new BillTypeService(); $billTypeList = $billTypeService->getBillTypeSimpleList($userId, null); $billTypeInList = array(); $billTypeOutList = array(); foreach ($billTypeList as $row) { // print_r($row); $flag = (int) $row['bill_type_flag']; if ($flag == 1) { $billTypeInList[] = $row; } else { if ($flag == 0) { $billTypeOutList[] = $row; } } } $output = array('retCode' => $code, 'accountDefault' => $accountDefault, 'accountList' => $accountList, 'accountDebtList' => $accountDebtList, 'accountCreditList' => $accountCreditList, 'billTypeList' => $billTypeList, 'billTypeInList' => $billTypeInList, 'billTypeOutList' => $billTypeOutList); echo get_json($output); }
public static function Verification($permission_name, $crud = __CanRead__) { session_start(); $account_name = $_SESSION['login']; if (!is_null($account_name)) { $account = AccountService::GetByName($account_name, true); if (!is_null($account)) { $roles = UserRoleService::GetByUserId($account->account_id); $permission = PermissionService::GetByName($permission_name); $res = false; for ($i = 0; $i < count($roles); $i++) { $rps = RolePermissionService::GetByRoleIdPermissionId($roles[$i]->role_id, $permission->permission_id); foreach ($rps as $value) { $rr = PermissionHelper::setPermissionFlag(__CanCreate__, $value->cancreate) | PermissionHelper::setPermissionFlag(__CanRead__, $value->canread) | PermissionHelper::setPermissionFlag(__CanUpdate__, $value->canupdate) | PermissionHelper::setPermissionFlag(__CanRemove__, $value->canremove); if (($rr & $crud) == $crud) { $res = true; } } } } } else { header('Location: /account/permission'); } if (!$res) { header('Location: /account/permission'); } }
function action_order() { session_start(); $model = $_SESSION['basket']; $login = $_SESSION["login"]; if (!is_null($_SESSION["login"])) { $account = AccountService::GetByName($login, true); $order = OrderHelper::PopulateOrderFromBasketViewModel($model, $account->account_id); $order = OrderService::Create($order); $products = $model->products; for ($i = 0; $i < count($products); $i++) { for ($j = 0; $j < $model->counts[$i]; $j++) { $orderlist = new OrderList(); $orderlist->order_id = $order->order_id; $orderlist->product_id = $products[$i]->Id; OrderListService::Create($orderlist); } } $_SESSION['basket'] = null; EmailService::SendNewOrderMessage($account, $order->order_id, $model->SumPrice()); $data = $order->order_id; $this->view->generate('Order_view.php', 'template_view.php', $data); } else { header('Location: /Account/login'); } }
public function create() { require 'application/views/general/header.php'; $userService = new AccountService($this->db); if (!empty($_POST['reg_email']) && !empty($_POST['reg_password']) && !empty($_POST['reg_retypepassword'])) { if ($_POST['reg_password'] == $_POST['reg_retypepassword']) { $user = $userService->create(new Account($_POST['reg_email'], $_POST['reg_password'])); if ($user != null) { session_regenerate_id(true); $_SESSION['login_user'] = $_POST['reg_email']; header("Location: /"); exit; } } } header("Location: /user/login"); exit; }
public static function PopulateReviewViewModel($review) { $model = new ReviewViewModel(); $model->id = $review->review_id; $model->product = ProductHelper::PopulateProductViewModel(ProductService::GetById($review->product_id)); $model->account = AccountHelper::PopulateAccountViewModel(AccountService::GetById($review->account_id)); $model->value = $review->value; return $model; }
public static function Get($accountName, $password) { $account = AccountService::GetByName($accountName, true); if ($account->passwordkey == hash_pbkdf2("sha256", $password, $account->passwordsalt, 1000, 20)) { return $account; } else { return null; } }
public static function PopulateOrderDetailViewModel($order) { $model = new OrderDetailViewModel(); $model->id = $order->order_id; $model->branch_name = BranchService::GetById($order->branch_id)->name; $model->date_order = $order->date_order->format('Y-m-d H:i:s'); $model->status_name = Statusorder::find(['statusorder_id' => $order->statusorder_id])->name; $model->account_name = AccountService::GetById($order->account_id)->account_name; $model->products = OrderListService::GetProductsByOrderId($order->order_id); return $model; }
function userLogin($user, $password) { if (!AccountService::isLoggedIn()) { $query = 'SELECT * FROM Users WHERE User_Name = "' . $user . '" AND Password = "******"'; $result = $this->db->count_rows($query); $user = $this->db->execute_assoc_query($query); if ($result === 1) { $admin = $user[0]['Admin'] == 1 ? true : false; AccountService::setSession(true, $user[0]['User_Name'], $admin); return true; } else { return false; } } else { echo 'already logged in'; //header('Location: /user/dashboard'); } }
function action_newReview() { session_start(); $login = $_SESSION["login"]; if (!is_null($login)) { $tovarId = $_POST['tovarId']; $review = new Review(); $review->product_id = $tovarId; $review->account_id = AccountService::GetByName($login, true)->account_id; $review->value = $_POST['reviewText']; ReviewService::Create($review); header("Location: /Review/thanks"); } else { header("Location: /Account/Login"); } }
/** * Check pattern is created by user * @param Number $patternId * @param Number $fbId * @return Number 0 --> no, 1 --> yes */ public function checkAccountPattern($patternId, $fbId) { $ptn = $this->patternDao->getById($patternId); $accountSrv = new AccountService($this->dp); $account = $accountSrv->getByFbId($fbId); if (is_null($ptn) || is_null($account)) { return 0; } if ($ptn->accountid == $account->id) { return 1; } return 0; }
$helper = new FacebookRedirectLoginHelper(REDIRECT_URL); $session = null; try { $session = $helper->getSessionFromRedirect(); } catch (Exception $ex) { // When validation fails or other local issues PLog::log($ex); } if (!is_null($session)) { // Get fb information $userProfile = (new FacebookRequest($session, 'GET', '/me'))->execute()->getGraphObject(GraphUser::className()); $fbName = $userProfile->getName(); $fbId = $userProfile->getId(); // Get account from database $db = DP::getInstant(); $accountSrv = new AccountService($db); $account = $accountSrv->getByFbId($fbId); // Insert into database If account not exist if (is_null($account)) { $account = new Account(); $account->fbId = $fbId; $account->fbName = $fbName; $accountSrv->insert($account); } $_SESSION[FB_TOKEN] = $session->getToken(); $_SESSION[FB_UID] = $fbId; } // Redirect to specified page if (isset($_SESSION['PREV_URL1'])) { $url = $_SESSION['PREV_URL1']; $_SESSION['PREV_URL1'] = null;
/** * 获取账户简单列表 */ function get_account_simple_list() { $userId = $_SESSION['userId']; $accountTypeFlag = isset($_REQUEST['accountTypeFlag']) ? (int) $_REQUEST['accountTypeFlag'] : null; $accountService = new AccountService(); $result = $accountService->getAccountSimpleList($userId, $accountTypeFlag); $code = '0'; if ($result == null) { $code = '-1'; } $output = array('retCode' => $code, 'accountList' => $result); echo get_json($output); }
public static function requiresAdmin() { if (!AccountService::isAdmin()) { header('Location: /user/login'); } }
/** * Get verified addresses for the account * @param string $accessToken - Constant Contact OAuth2 access token * @param string $status - Status to filter query results by * @return array of VerifiedEmailAddress objects */ public function getVerifiedEmailAddresses($accessToken, $status = null) { $params = array(); if ($status) { $params['status'] = $status; } return $this->accountService->getVerifiedEmailAddresses($accessToken, $params); }
/** * 收支趋势基础数据初始化 */ function init_trend_statistic_data() { $userId = (int) $_SESSION['userId']; $code = '0'; // 获取首次记账年份,生成年份列表 $billService = new BillService(); $firstBillTime = $billService->getFirstBillTime($userId); $yearList = array(); if ($firstBillTime != null) { $firstYear = (int) date('Y', $firstBillTime); $nowYear = (int) date('Y'); if ($firstYear > $nowYear) { for ($i = $firstYear; $i <= $nowYear; $i++) { $yearList[] = array('yearVal' => (string) $i, 'yearStr' => (string) $i); } } } else { $yearList[] = array('yearVal' => date('Y'), 'yearStr' => date('Y')); } // 加载账户列表 $accountService = new AccountService(); $accountList = $accountService->getAccountSimpleList($userId, null); // 加载收支类别列表 $billTypeService = new BillTypeService(); $billTypeList = $billTypeService->getBillTypeSimpleList($userId, null); $output = array('retCode' => $code, 'yearList' => $yearList, 'accountList' => $accountList, 'billTypeList' => $billTypeList); echo get_json($output); }
<div id="top-bar"> <div class="top-bar-wrap"> <?php if (AccountService::isLoggedIn()) { echo '<p>Welcome back ' . $_SESSION['USER_NAME']; echo ' Click here to <a href="/user/logout"><span class="glyphicon-user"></span></a>'; echo '<a href="#"><span class="glyphicon glyphicon-user"></span></a>'; if (AccountService::isAdmin() == true) { echo '<a href="/admin/dashboard"> Admin </a>'; } echo '<a href="#"><span class="glyphicon glyphicon-shopping-cart"></span> £29.00 </a>'; } else { echo '<a href="/user/login"> Login </a></p>'; } ?> </div> </div> <header> <div id="Header-wrap"> <object id="Logo" data="<?php echo '/' . STATIC_1 . 'img/svg/Logo.svg'; ?> " type="image/svg+xml"> <img src="<?php echo '/' . STATIC_1 . 'img/svg/Logo.svg'; ?> " /> </object> <a href="/home">HOME</a> <a href="/product/search">SHOP</a>