-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
77 lines (68 loc) · 1.71 KB
/
admin.php
File metadata and controls
77 lines (68 loc) · 1.71 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
<?php
namespace Parser\Classes;
/**
* @var obj $obj
* @var obj $admin
*/
//init
require_once("init.php");
$src = new Sources();
$parser = new Parser();
$news = new News();
$images = new Images();
$flash = new Flash();
//auth
if (!$admin->auth_check()) {
header('Location: login.php');
}
//dummy ROUTES
switch ($_REQUEST['route']) {
case 'del_source':
if (!empty($_REQUEST['id']) && (int)$_REQUEST['id'] > 0) {
$src->delete($_REQUEST['id']);
}
$_SESSION['alert'] = 'success';
header('Location: admin.php');
break;
case 'create':
if (!empty($_POST['srcName']) && !empty($_POST['srcUrl'])) {
$src->create($_POST);
}
$_SESSION['alert'] = 'success';
header('Location: admin.php');
break;
case 'parser':
if (!empty($_REQUEST['id']) && (int)$_REQUEST['id'] > 0) {
$id = (int)$_REQUEST['id'];
$parser->init($id);
}
$_SESSION['alert'] = 'success';
header('Location: admin.php');
break;
case 'del_news':
if (!empty($_REQUEST['id']) && (int)$_REQUEST['id'] > 0) {
$id = (int)$_REQUEST['id'];
$news->delete($id);
$images->delete_by_news_id($_REQUEST['del_news']);
}
$_SESSION['alert'] = 'success';
header('Location: index.php');
break;
case 'logout':
$admin->logout();
header('Location: index.php');
break;
case 'index':
default:
(!empty($_SESSION['alert']) && $_SESSION['alert'] == 'success') ? $flash->success($obj) : null;
(!empty($_SESSION['alert']) && $_SESSION['alert'] == 'fail') ? $flash->fail($obj) : null;
$src->get_source_list($obj);
//light menu
$obj->assign("ACTIVE_ADMIN", 'active');
//admin page
$obj->parse("CONTEXT", ".admin");
break;
}
$obj->no_strict(); //для отладки
$obj->parse('result', "index");
$obj->FastPrint('result');