Example #1
0
<!-- add class "multiple-expanded" to allow multiple submenus to open -->
<!-- class "auto-inherit-active-class" will automatically add "active" class for parent elements who are marked already with class "active" -->
<?php 
require_once '../helper/crypter.php';
require_once '../helper/Utils.php';
require_once '../helper/Context.php';
if (isset($_SESSION["IsLogin"]) && $_SESSION["IsLogin"] == 1 && Context::getCurrentUser()["userPermission"] == 1) {
    //set token
    $crypter = new Crypter("nhatanh");
    if (!isset($_SESSION["token"])) {
        $datetime = new DateTime();
        $str_datetime = date_format($datetime, 'Y-m-d H:i:s');
        $security = $str_datetime . " " . strval(rand());
        $encrypted = $crypter->Encrypt($security);
        $_SESSION["token"] = $security;
        $token = "token=" . $encrypted;
    } else {
        $encrypted = $crypter->Encrypt($_SESSION["token"]);
        $token = "token=" . $encrypted;
    }
} else {
    require_once '../helper/Utils.php';
    $url = "adminLogin.php";
    Utils::Redirect($url);
}
?>

<li class="">
    <a href="index.php?<?php 
echo $token;
Example #2
0
<?php

session_start();
if (!isset($_SESSION["IsLogin"])) {
    $_SESSION["IsLogin"] = 0;
    // chưa đăng nhập
}
require_once '../entities/User.php';
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require_once '../helper/Context.php';
require_once '../helper/Utils.php';
date_default_timezone_set('Asia/Bangkok');
if (Context::IsLogged()) {
    //Cập nhập lại đăng nhập lần cuối
    $User = new User();
    $User->setUserID(Context::getCurrentUser()["userID"]);
    $lastLogon = new DateTime();
    $User->setLastLogon($lastLogon);
    $User->updateLastLogon();
    Context::destroy();
    unset($_SESSION["token"]);
} else {
}
Utils::Redirect("adminLogin.php");
Example #3
0
                                <h4 class="modal-title">THAY ĐỔI MẬT KHẨU</h4>
                            </div>
                            <div class="modal-body">
                                <?php 
    if (!$updatePW) {
        ?>
                                    <div class="col-sm-offset-4 alert alert-danger alert-dismissible"
                                         id="boardChangePassWord" role="alert">
                                        <label class="error">Đổi mật khẩu thất bại!</label>
                                    </div>
                                <?php 
    }
    ?>
                                <input type="hidden" readonly
                                       value="<?php 
    echo Context::getCurrentUser()["userName"];
    ?>
"
                                       class="form-control"
                                       id="txtUserName"
                                       name="txtUserName">

                                <div class="form-group">
                                    <label for="txtPassWordOld" class="col-sm-4 control-label note">Mật Khẩu Cũ
                                        :</label>

                                    <div class="col-sm-7">
                                        <input type="password" autocomplete="off" class="form-control"
                                               id="txtPassWordOld"
                                               name="txtPassWordOld">
                                    </div>
Example #4
0
     }
 }
 if (isset($_POST["txtUpdProId"])) {
     $updProId = explode(',', $_POST["txtUpdProId"]);
     $q = explode(',', $_POST["txtUpdQ"]);
     for ($i = 0; $i < count($updProId); $i++) {
         Cart::updateItem($updProId[$i], $q[$i]);
     }
 }
 if (isset($_POST["btnCheckout"])) {
     require_once 'helper/Context.php';
     $total = $_POST["txtTotal"];
     $ord = new Order();
     $ord->setOrderDate(new DateTime());
     $ord->setTotal($total);
     $ord->setUser(new User(Context::getCurrentUser()["userID"]));
     $ord->insert();
     foreach ($_SESSION["Cart"] as $proId => $quantity) {
         $pro = Product::loadProductByProID($proId);
         $amount = $pro->getPrice() * $quantity;
         $detail = new OrderDetail(-1, $pro, $ord, $pro->getPrice(), $quantity, $amount);
         $detail->insert();
         //Cap nhap lai so luong ton
         $inStock = $pro->getInStock() - $quantity;
         $pro->setInStock($inStock);
         $pro->updateInStock();
         //Cap nhap lai so luong ban
         $onOrder = $pro->getOnOrder() + $quantity;
         $pro->setOnOrder($onOrder);
         $pro->updateOnOrder();
     }