Rev 236 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
117 | daniel-mar | 1 | <?php |
2 | |||
3 | /* |
||
4 | * OIDplus 2.0 |
||
5 | * Copyright 2019 Daniel Marschall, ViaThinkSoft |
||
6 | * |
||
7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
||
8 | * you may not use this file except in compliance with the License. |
||
9 | * You may obtain a copy of the License at |
||
10 | * |
||
11 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
12 | * |
||
13 | * Unless required by applicable law or agreed to in writing, software |
||
14 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
16 | * See the License for the specific language governing permissions and |
||
17 | * limitations under the License. |
||
18 | */ |
||
19 | |||
20 | if (!defined('IN_OIDPLUS')) die(); |
||
21 | |||
22 | class OIDplusPageRaObjectLog extends OIDplusPagePlugin { |
||
23 | public function type() { |
||
24 | return 'ra'; |
||
25 | } |
||
26 | |||
222 | daniel-mar | 27 | public static function getPluginInformation() { |
28 | $out = array(); |
||
29 | $out['name'] = 'Object Log'; |
||
30 | $out['author'] = 'ViaThinkSoft'; |
||
31 | $out['version'] = null; |
||
32 | $out['descriptionHTML'] = null; |
||
33 | return $out; |
||
34 | } |
||
35 | |||
117 | daniel-mar | 36 | public function priority() { |
37 | return 99; |
||
38 | } |
||
39 | |||
40 | public function action(&$handled) { |
||
41 | // Nothing |
||
42 | } |
||
43 | |||
44 | public function init($html=true) { |
||
45 | } |
||
46 | |||
47 | public function cfgSetValue($name, $value) { |
||
48 | } |
||
49 | |||
50 | public function gui($id, &$out, &$handled) { |
||
51 | } |
||
52 | |||
53 | public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') { |
||
54 | return false; |
||
55 | } |
||
56 | |||
57 | public function modifyContent($id, &$title, &$icon, &$text) { |
||
58 | $obj = OIDplusObject::parse($id); |
||
59 | if (!$obj) return; |
||
60 | if (!$obj->userHasWriteRights()) return; |
||
61 | |||
62 | // TODO: I want that this content comes before the WHOIS modifyContent. |
||
63 | // The problem is that first all public and then all RA plugins get loaded, not mixed by their priority |
||
64 | $res = OIDplus::db()->query("select lo.id, lo.unix_ts, lo.addr, lo.event from ".OIDPLUS_TABLENAME_PREFIX."log lo ". |
||
65 | "left join ".OIDPLUS_TABLENAME_PREFIX."log_object lu on lu.log_id = lo.id ". |
||
150 | daniel-mar | 66 | "where lu.object = ? " . |
67 | "order by lo.unix_ts desc", array($id)); |
||
118 | daniel-mar | 68 | $text .= "<h2>Log messages for object ".htmlentities($id)."</h2>"; |
236 | daniel-mar | 69 | if ($res->num_rows() > 0) { |
117 | daniel-mar | 70 | $text .= '<pre>'; |
236 | daniel-mar | 71 | while ($row = $res->fetch_array()) { |
117 | daniel-mar | 72 | $users = array(); |
239 | daniel-mar | 73 | $res2 = OIDplus::db()->query("select username from ".OIDPLUS_TABLENAME_PREFIX."log_user ". |
150 | daniel-mar | 74 | "where log_id = ?", array($row['id'])); |
236 | daniel-mar | 75 | while ($row2 = $res2->fetch_array()) { |
239 | daniel-mar | 76 | $users[] = $row2['username']; |
117 | daniel-mar | 77 | } |
78 | $users = count($users) > 0 ? ", ".implode('/',$users) : ''; |
||
79 | |||
80 | $addr = empty($row['addr']) ? 'no address' : $row['addr']; |
||
81 | |||
82 | $text .= date('Y-m-d H:i:s', $row['unix_ts']) . ': ' . htmlentities($row["event"])." (" . htmlentities($addr.$users) . ")\n"; |
||
83 | } |
||
84 | $text .= '</pre>'; |
||
85 | |||
86 | // TODO: List logs in a table instead of a <pre> text |
||
87 | // TODO: Load only X events and then re-load new events via AJAX when the user scrolls down |
||
118 | daniel-mar | 88 | } else { |
89 | $text .= '<p>Currently there are no log entries</p>'; |
||
117 | daniel-mar | 90 | } |
91 | |||
92 | } |
||
93 | |||
94 | public function tree_search($request) { |
||
95 | return false; |
||
96 | } |
||
97 | } |