-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathadminaction.php
More file actions
executable file
·200 lines (170 loc) · 7.5 KB
/
adminaction.php
File metadata and controls
executable file
·200 lines (170 loc) · 7.5 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<?php
/*********************************************************************
PHPBack
Ivan Diaz <[email protected]>
Copyright (c) 2014 PHPBack
http://www.phpback.org
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
**********************************************************************/
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once(__DIR__ . "../../../vendor/autoload.php");
use \VisualAppeal\AutoUpdate;
class Adminaction extends CI_Controller{
public function __construct(){
parent::__construct();
$this->load->helper('url');
$this->load->model('get');
$this->load->model('post');
$this->lang->load('log', $this->get->getSetting('language'));
$this->version = '1.3.1';
}
public function login(){
session_start();
$email = $this->input->post('email', true);
$pass = $this->input->post('password', true);
$result = $this->get->login($email, $pass);
if($result != 0){
$user = $this->get->getUser($result);
if(!$user->isadmin){
header('Location: ' . base_url() . 'admin/index/error');
exit;
}
$this->get->setSessionUserValues($user);
header('Location: ' . base_url() . 'admin/dashboard');
}
else{
header('Location: ' . base_url() . 'admin/index/error');
}
}
public function banuser(){
$this->start(2);
$id = $this->input->post('id', true);
$days = $this->input->post('days', true);
if($days == 0) $days = -1;
else{
date_default_timezone_set('America/Los_Angeles');
$days = date('Ymd', strtotime("+$days days"));
}
$sql = $this->post->do_ban($id, $days);
$this->post->log(str_replace(array('%s1', '%s2'), array("#$id", $days), $this->lang->language['log_user_banned']), 'user', $_SESSION['phpback_userid']);
$this->post->log(str_replace('%s', '#$id', $this->lang->language['log_user_was_banned']), 'user', $id);
header('Location: ' . base_url() . 'admin/users');
}
public function unban($userid){
$this->start(2);
$this->post->unban($userid);
$this->post->log(str_replace('%s', "#$userid", $this->lang->language['log_user_unbanned']), 'user', $_SESSION['phpback_userid']);
header('Location: ' . base_url() . 'admin/users');
}
public function deletecomment($commentid){
$this->start(1);
$this->post->deletecomment($commentid);
$this->post->log(str_replace('%s', "#$commentid", $this->lang->language['log_comment_deleted']), 'user', $_SESSION['phpback_userid']);
header('Location: ' . base_url() . "admin/ideas");
}
public function deleteidea($id){
$this->start(1);
$this->post->deleteidea($id);
$this->post->log(str_replace('%s', "#$id", $this->lang->language['log_idea_deleted']), 'user', $_SESSION['phpback_userid']);
header('Location: ' . base_url() . "home/");
}
public function approveidea($id){
$this->start(1);
$this->post->approveidea($id);
$this->post->log(str_replace('%s', "#$id", $this->lang->language['log_idea_approved']), 'user', $_SESSION['phpback_userid']);
header('Location: ' . base_url() . "home/idea/$id");
}
public function ideastatus($status, $id){
$this->start(1);
$this->post->change_status($id, $status);
$this->post->log(str_replace(array('%s1', '%s2'), array("#$id", $status), $this->lang->language['log_idea_status']), 'user', $_SESSION['phpback_userid']);
header('Location: ' . base_url() . "home/idea/$id");
}
public function editsettings(){
$this->start(3);
$settings = $this->get->get_all_settings();
foreach($settings as $setting){
$value = $this->input->post('setting-' . $setting->id, true);
$this->post->update_by_id('settings', 'value', $value, $setting->id);
}
$this->post->log($this->lang->language['log_settings'], 'system', $_SESSION['phpback_userid']);
header('Location: ' . base_url() . 'admin/system');
}
public function editadmin(){
$this->start(3);
$id = $this->input->post('id', true);
$level = $this->input->post('level', true);
if($_SESSION['phpback_userid'] != $id){
if($this->post->updateadmin($id, $level))
$this->post->log($this->lang->language['log_user_admin'], 'user', $id);
}
header('Location: ' . base_url() . 'admin/system');
}
public function addcategory(){
$this->start(3);
$name = $this->input->post('name', true);
$description = $this->input->post('description', true);
$result = $this->get->category_id($name);
if ($result){
$this->post->update_by_id('categories', 'description', $description, $result);
$this->post->log("'$name'" . $this->lang->language['log_category_description'], 'user', $_SESSION['phpback_userid']);
}
else{
$this->post->add_category($name, $description);
$this->post->log("'$name'" . $this->lang->language['log_category_created'], 'user', $_SESSION['phpback_userid']);
}
header('Location: ' . base_url() . 'admin/system');
}
public function updatecategories(){
$this->start(3);
$categories = $this->get->getCategories();
foreach ($categories as $cat) {
$temp = $this->input->post("category-$cat->id", true);
if($temp != $cat->name){
$this->post->update_by_id('categories', 'name', $temp , $cat->id);
$this->post->log(str_replace(array('%s1', '%s2'), array($cat->name, $temp), $this->lang->language['log_category_changed']), 'user', $_SESSION['phpback_userid']);
}
}
header('Location: ' . base_url() . 'admin/system');
}
public function deletecategory(){
$this->start(3);
$id = $this->input->post('catid', true);
if($this->input->post('ideas', true)){
$ideas = $this->get->getIdeasByCategory($id , 'id', 'desc', 0);
foreach ($ideas as $idea){
$this->post->deleteidea($idea->id);
}
}
$this->post->delete_category($id);
$this->post->log(str_replace('%s', "#$id", $this->lang->language['log_category_deleted']), 'user', $_SESSION['phpback_userid']);
header('Location: ' . base_url() . 'admin/system');
}
public function upgrade() {
$this->start(3);
$update = new AutoUpdate(__DIR__ . '/temp', __DIR__ . '/../../', 60);
$update->setCurrentVersion($this->version);
$update->setUpdateUrl('http://www.phpback.org/upgrade/');
$update->checkUpdate();
// Check if new update is available
if ($update->newVersionAvailable()) {
//Install new update
$result = $update->update();
if ($result !== true) {
echo 'Update failed!<br>';
$update->printLogs();
}
@include __DIR__. '/../config/update.php';
@unlink(__DIR__.'/../config/update.php');
}
header('Location: ' . base_url() . 'admin/system');
}
private function start($level = 1){
session_start();
if(!isset($_SESSION['phpback_isadmin']) || $_SESSION['phpback_isadmin'] < $level){
header('Location: ' . base_url() . 'admin/');
exit;
}
}
}