-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAdmin.php
More file actions
48 lines (39 loc) · 1.31 KB
/
Admin.php
File metadata and controls
48 lines (39 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require APPPATH . '/libraries/ImplementJwt.php';
class Admin extends CI_Controller {
public function __construct(){
parent::__construct();
$this->objOfJwt = new ImplementJwt();
}
public function index(){
// CREATE A RANDOM SESSION TOKEN
session_start();
$length = 32;
$_SESSION['nonces'] = substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, $length);
if(isset($_COOKIE['auth'])){
$decodeToken = $this->objOfJwt->DecodeToken($_COOKIE['auth']);
$user = $decodeToken;
if( $user['role'] == 0){
$this->load->library('layout');
$this->load->model('admin_model');
$product = $this->admin_model->getProductData();
$catgory = $this->admin_model->getCatgoryData();
$user = $this->admin_model->getUserData();
$orders = $this->admin_model->getOrdersData();
$data['products'] = $product;
$data['catgory'] = $catgory;
$data['user'] = $user;
$data['orders'] = $orders;
// var_dump($user);
// $this->load->view('home',['products' => $products]);
$this->layout->view('admin',['data' => $data]);
}else {
echo '你不是管理员';
}
}else {
echo '请<a href="login">登录</a> <a href="home">Home</a>';
}
// var_dump($user);
}
}