Skip to content

Commit 4594969

Browse files
committed
上传源码
1 parent 3ac443e commit 4594969

File tree

290 files changed

+53145
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

290 files changed

+53145
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
//默认配置
3+
return [
4+
5+
'rule' => 'auth'
6+
7+
];

application/admin/config/view.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
//默认视图配置
3+
return [
4+
5+
'driver' => 'smarty', //视图驱动
6+
'debug_template' => COMMON_VIEW . '/debug', //DEBUG模板
7+
'404_template' => COMMON_VIEW . '/404', //404模板
8+
'error_template' => VIEW_PATH . '/public/message', //错误消息模板
9+
'success_template' => VIEW_PATH . '/public/message', //成功消息模板
10+
11+
'smarty' => [
12+
'template_suffix' => 'html', //模板文件扩展名
13+
'left_delimiter' => '{{', //左定界符
14+
'right_delimiter' => '}}', //右定界符
15+
'cache_enable' => false, //是否缓存
16+
'cache_lifetime' => 120, //缓存时间,单位秒
17+
'plugin_path' => COMMON_PATH . '/smarty',
18+
19+
],
20+
21+
22+
];
23+
24+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace app\admin\controller;
4+
5+
use app\user;
6+
use gophp\controller;
7+
use gophp\response;
8+
9+
class auth extends controller {
10+
11+
public $user_id;
12+
13+
public function __construct()
14+
{
15+
16+
// 判断是否登录
17+
$this->user_id = user::get_user_id();
18+
19+
if(!$this->user_id){
20+
21+
response::redirect('login');
22+
23+
}
24+
25+
}
26+
27+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?php
2+
3+
namespace app\admin\controller;
4+
5+
use gophp\db;
6+
use gophp\page;
7+
use gophp\request;
8+
9+
class history extends auth {
10+
11+
// 登录历史
12+
public function login()
13+
{
14+
15+
$user_id = request::get('user_id', 0);
16+
$search = request::get('search', []);
17+
18+
$db = db::instance();
19+
20+
$table_suffix = $db->suffix;
21+
$table_name = $table_suffix .'login_log';
22+
23+
if($user_id){
24+
25+
$where = "user_id = $user_id ";
26+
27+
}
28+
29+
if($name = trim($search['name'])){
30+
31+
$user_sql = 'select id from ' . $table_suffix . 'user where ' . "(name like '%{$name}%' or email like '%{$name}%') ";
32+
33+
$user_ids = $db->show(false)->query($user_sql);
34+
35+
$user_ids = array_column($user_ids, 'id');
36+
37+
$user_ids = $user_ids ? $user_ids : 0;
38+
39+
$where = $where ? $where .= ' and ' : '';
40+
41+
if($user_ids){
42+
43+
$where .= "user_id in (" . implode(',', $user_ids) . ')';
44+
45+
}else{
46+
47+
$where .= 'user_id in (0)';
48+
49+
}
50+
51+
}
52+
53+
if($ip = trim($search['ip'])){
54+
55+
$where = $where ? $where .= ' and ' : '';
56+
57+
$where = "ip like '%{$ip}%'";
58+
59+
}
60+
61+
if($device = trim($search['device'])){
62+
63+
$where = $where ? $where .= ' and ' : '';
64+
65+
$where .= " device = '{$device}' ";
66+
67+
}
68+
69+
$where = $where ? ' where ' . $where : '';
70+
71+
$sql = "select * from $table_name $where";
72+
73+
$total = count($db->show(false)->query($sql));
74+
75+
$pre_rows = 10;
76+
77+
$page = new page($total, $pre_rows);
78+
79+
$historys = $db->show(false)->query($sql, $pre_rows);
80+
81+
$this->assign('search', $search);
82+
$this->assign('historys', $historys);
83+
$this->assign('page', $page);
84+
85+
$this->display('history/login');
86+
87+
}
88+
89+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace app\admin\controller;
4+
5+
class index extends auth {
6+
7+
public function index(){
8+
9+
$user = \app\user::get_user_info();
10+
11+
$last_login = \app\user::get_last_login();
12+
13+
$system = [
14+
'version' => GOPHP_VERSION,
15+
];
16+
17+
$this->assign('user', $user);
18+
$this->assign('last_login', $last_login);
19+
$this->assign('system', $system);
20+
21+
$this->display('index');
22+
23+
}
24+
25+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?php
2+
3+
namespace app\admin\controller;
4+
5+
use gophp\db;
6+
use gophp\page;
7+
use gophp\request;
8+
9+
class project extends auth {
10+
11+
public function index()
12+
{
13+
14+
$search = request::get('search', []);
15+
16+
$db = db::instance();
17+
18+
$table_suffix = $db->suffix;
19+
$table_name = $table_suffix .'project';
20+
21+
if($title = trim($search['project'])){
22+
23+
$where = "title like '%{$title}%'";
24+
25+
}
26+
27+
if($user = trim($search['user'])){
28+
29+
$user_sql = 'select id from ' . $table_suffix . 'user where ' . "(name like '%{$user}%' or email like '%{$user}%') ";
30+
31+
$user_ids = $db->show(false)->query($user_sql);
32+
33+
$user_ids = array_column($user_ids, 'id');
34+
35+
$where = $where ? $where .= ' and ' : '';
36+
37+
if($user_ids){
38+
39+
$where .= "user_id in (" . implode(',', $user_ids) . ')';
40+
41+
}else{
42+
43+
$where .= 'user_id in (0)';
44+
45+
}
46+
47+
}
48+
49+
$where = $where ? ' where ' . $where : '';
50+
51+
$sql = "select * from $table_name $where";
52+
53+
$total = count($db->show(false)->query($sql));
54+
55+
$pre_rows = 10;
56+
57+
$page = new page($total, $pre_rows);
58+
59+
$projects = $db->show(false)->query($sql, $pre_rows);
60+
61+
$this->assign('search', $search);
62+
$this->assign('page', $page);
63+
$this->assign('projects', $projects);
64+
65+
$this->display('project/index');
66+
67+
}
68+
69+
/**
70+
* 删除项目
71+
*/
72+
public function delete(){
73+
74+
$project_id = request::post('project_id', 0);
75+
$password = request::post('password', '');
76+
77+
$project = \app\project::get_project_info($project_id);
78+
79+
if(!$project){
80+
81+
response::ajax(['code' => 301, 'msg' => '请选择要删除的项目!']);
82+
83+
}
84+
85+
if(!user::check_password($password)){
86+
87+
response::ajax(['code' => 302, 'msg' => '抱歉,密码验证失败!']);
88+
89+
}
90+
91+
if(!user::is_creater($project_id) && !user::is_admin()){
92+
93+
response::ajax(['code' => 303, 'msg' => '抱歉,您无权删除该项目!']);
94+
95+
}
96+
97+
if(\app\project::delete($project_id)){
98+
99+
response::ajax(['code' => 200, 'msg' => '删除成功!']);
100+
101+
}else{
102+
103+
response::ajax(['code' => 403, 'msg' => '删除失败!']);
104+
105+
}
106+
107+
}
108+
109+
110+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace app\admin\controller;
4+
5+
use app\config;
6+
use gophp\request;
7+
use gophp\response;
8+
9+
class setting extends auth {
10+
11+
/**
12+
* 管理配置
13+
*/
14+
public function index()
15+
{
16+
if(request::isAjax()){
17+
18+
$config = request::post('config', []);
19+
20+
if(!$config){
21+
22+
response::ajax(['code' => 300, 'msg' => '缺失必要参数']);
23+
24+
}
25+
26+
if(db('config')->find()){
27+
28+
$result = db('config')->update(['config' => json_encode($config)]);
29+
30+
}else{
31+
32+
$result = db('config')->add(['config' => json_encode($config)]);
33+
34+
}
35+
36+
if($result !== false){
37+
38+
response::ajax(['code' => 200, 'msg' => '系统配置成功']);
39+
40+
}else{
41+
42+
response::ajax(['code' => 304, 'msg' => '该模块名称已存在']);
43+
44+
}
45+
46+
}else{
47+
48+
$config = config::get_config_value();
49+
50+
$this->assign('config', $config);
51+
$this->display('setting/index');
52+
53+
}
54+
55+
}
56+
57+
58+
}

0 commit comments

Comments
 (0)