1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK ---------------------------------- |
---|
3 | # This file is part of dcLog, a plugin for Dotclear. |
---|
4 | # |
---|
5 | # Copyright (c) 2010 Tomtom |
---|
6 | # http://blog.zenstyle.fr/ |
---|
7 | # |
---|
8 | # Licensed under the GPL version 2.0 license. |
---|
9 | # A copy of this license is available in LICENSE file or at |
---|
10 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
11 | # -- END LICENSE BLOCK ------------------------------------ |
---|
12 | if (!defined('DC_CONTEXT_ADMIN')) { return; } |
---|
13 | |
---|
14 | # Get out not superAdmin! |
---|
15 | if (!$core->auth->isSuperAdmin()) { return; } |
---|
16 | |
---|
17 | # Var initialisation |
---|
18 | $p_url = 'plugin.php?p=dcLog'; |
---|
19 | $page = isset($_GET['page']) ? $_GET['page'] : 1; |
---|
20 | $status = isset($_GET['status']) ? $_GET['status'] : null; |
---|
21 | # filter initialisation |
---|
22 | $blog_id = isset($_GET['blog_id']) ? $_GET['blog_id'] : 'all'; |
---|
23 | $user_id = isset($_GET['user_id']) ? $_GET['user_id'] : ''; |
---|
24 | $table = isset($_GET['table']) ? $_GET['table'] : ''; |
---|
25 | $ip = isset($_GET['ip']) ? $_GET['ip'] : ''; |
---|
26 | $nb = isset($_GET['nb']) ? $_GET['nb'] : 20; |
---|
27 | # form initialisation |
---|
28 | $ids = isset($_POST['ids']) ? $_POST['ids'] : null; |
---|
29 | $del_all_log = isset($_POST['del_all_logs']) ? true : false; |
---|
30 | |
---|
31 | # Delete logs |
---|
32 | if (isset($_POST['del_logs']) || isset($_POST['del_all_logs'])) |
---|
33 | { |
---|
34 | try { |
---|
35 | $core->log->delLogs($ids,$del_all_log); |
---|
36 | $status = $del_all_log ? '2' : '1'; |
---|
37 | http::redirect($p_url.'&del='.$status); |
---|
38 | } |
---|
39 | catch (Exception $e) { |
---|
40 | $core->error->add($e->getMessage()); |
---|
41 | } |
---|
42 | } |
---|
43 | |
---|
44 | # Gets logs & prepares display object |
---|
45 | $params = array('blog_id' => $blog_id,'user_id' => $user_id,'log_table' => $table,'log_ip' => $ip); |
---|
46 | $l_rs = $core->log->getLogs($params); |
---|
47 | $l_nb = $l_rs->count(); |
---|
48 | $l_list = new dcLogList($core,$l_rs,$l_nb); |
---|
49 | |
---|
50 | # Display |
---|
51 | echo |
---|
52 | '<html>'. |
---|
53 | '<head>'. |
---|
54 | '<title>'.__('Log').'</title>'. |
---|
55 | dcPage::jsLoad('js/filter-controls.js'). |
---|
56 | dcPage::jsLoad('index.php?pf=dcLog/js/dclog.js'). |
---|
57 | '<script type="text/javascript">'. |
---|
58 | '//<![CDATA['."\n". |
---|
59 | dcPage::jsVar('dotclear.msg.confirm_delete_selected_log',__('Are you sure you want to delete selected logs?')). |
---|
60 | dcPage::jsVar('dotclear.msg.confirm_delete_all_log',__('Are you sure you want to delete all logs?')). |
---|
61 | '//]]>'. |
---|
62 | '</script>'. |
---|
63 | '</head>'."\n". |
---|
64 | '<body>'; |
---|
65 | |
---|
66 | # Message |
---|
67 | if (isset($_GET['del'])) { |
---|
68 | $msg = ''; |
---|
69 | |
---|
70 | if ((integer) $_GET['del'] === 1) { |
---|
71 | $msg = __('Selected logs have been successfully deleted'); |
---|
72 | } |
---|
73 | if ((integer) $_GET['del'] === 2) { |
---|
74 | $msg = __('All logs have been successfully deleted'); |
---|
75 | } |
---|
76 | |
---|
77 | echo !empty($msg) ? '<p class="message">'.$msg.'</p>' : ''; |
---|
78 | } |
---|
79 | |
---|
80 | # Combo blog |
---|
81 | $combo_blog = array(__('All blogs') => 'all'); |
---|
82 | $blogs = $core->getBlogs(); |
---|
83 | while ($blogs->fetch()) { |
---|
84 | $combo_blog[$blogs->blog_name] = $blogs->blog_id; |
---|
85 | } |
---|
86 | |
---|
87 | echo |
---|
88 | '<h2>'.html::escapeHTML($core->blog->name).' › '.__('Log').'</h2>'. |
---|
89 | '<p><a id="filter-control" class="form-control" href="#">'. |
---|
90 | __('Filters').'</a></p>'. |
---|
91 | '<form action="'.$p_url.'" method="get" id="filters-form">'. |
---|
92 | form::hidden('p','dcLog'). |
---|
93 | '<fieldset><legend>'.__('Filters').'</legend>'. |
---|
94 | '<div class="two-cols"><div class="col">'. |
---|
95 | '<p><label>'.__('Blog:'). |
---|
96 | form::combo('blog_id',$combo_blog,$blog_id).'</label></p>'. |
---|
97 | '<p><label>'.__('User:'). |
---|
98 | form::field('user_id',20,50,$user_id).'</label></p>'. |
---|
99 | '</div><div class="col">'. |
---|
100 | '<p><label>'.__('IP:'). |
---|
101 | form::field('ip',20,50,$ip).'</label></p>'. |
---|
102 | '<p><label class="classic">'. form::field('nb',3,3,$nb).' '. |
---|
103 | __('Logs per page').'</label><p>'. |
---|
104 | '<p><input type="submit" value="'.__('filter').'" /></p>'. |
---|
105 | '</div></div>'. |
---|
106 | '<br class="clear" />'. //Opera sucks |
---|
107 | '</fieldset>'. |
---|
108 | '</form>'; |
---|
109 | |
---|
110 | $l_list->display($page,$nb, |
---|
111 | '<form action="'.$p_url.'" method="post" id="form-logs">'. |
---|
112 | |
---|
113 | '%s'. |
---|
114 | |
---|
115 | '<div class="two-cols">'. |
---|
116 | '<p class="col checkboxes-helpers"></p>'. |
---|
117 | |
---|
118 | '<p class="col right"><input type="submit" value="'. |
---|
119 | __('Delete selected logs').'" name="del_logs" /> '. |
---|
120 | '<input type="submit" value="'.__('Delete all logs').'" '. |
---|
121 | 'name="del_all_logs" /></p>'. |
---|
122 | $core->formNonce(). |
---|
123 | '</div>'. |
---|
124 | '</form>' |
---|
125 | ); |
---|
126 | |
---|
127 | echo |
---|
128 | '</body>'. |
---|
129 | '</html>'; |
---|
130 | |
---|
131 | ?> |
---|