From 17bb4ab0f17b55a0221ba1520543eacc5864cb59 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sun, 27 Nov 2022 15:38:40 +0100 Subject: [PATCH] initial commit from dcLog 1.0.1 --- _admin.php | 18 +++++ _define.php | 21 ++++++ _prepend.php | 16 +++++ icon.png | Bin 0 -> 525 bytes inc/class.dc.log.list.php | 110 ++++++++++++++++++++++++++++++ index.php | 138 ++++++++++++++++++++++++++++++++++++++ js/dclog.js | 1 + locales/fr/main.po | 78 +++++++++++++++++++++ 8 files changed, 382 insertions(+) create mode 100644 _admin.php create mode 100644 _define.php create mode 100644 _prepend.php create mode 100644 icon.png create mode 100644 inc/class.dc.log.list.php create mode 100644 index.php create mode 100644 js/dclog.js create mode 100644 locales/fr/main.po diff --git a/_admin.php b/_admin.php new file mode 100644 index 0000000..600147b --- /dev/null +++ b/_admin.php @@ -0,0 +1,18 @@ +addItem(__('Log'),'plugin.php?p=dcLog','index.php?pf=dcLog/icon.png', + preg_match('/plugin.php\?p=dcLog(&.*)?$/',$_SERVER['REQUEST_URI']), + $core->auth->isSuperAdmin()); + +?> \ No newline at end of file diff --git a/_define.php b/_define.php new file mode 100644 index 0000000..0b30694 --- /dev/null +++ b/_define.php @@ -0,0 +1,21 @@ +registerModule( + /* Name */ "dcLog", + /* Description*/ "Displays Dotclear logs", + /* Author */ "Tomtom (http://blog.zenstyle.fr)", + /* Version */ '1.0.1' +); + +?> \ No newline at end of file diff --git a/_prepend.php b/_prepend.php new file mode 100644 index 0000000..721ce18 --- /dev/null +++ b/_prepend.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/icon.png b/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..b3d8ce01e2e9c5a6ce83c3b6d7715cbb2b9d3fb0 GIT binary patch literal 525 zcmV+o0`mQdP)>Z+sNt2+U0SgfoD!Wm8sxbT>nyV*Byc6US+Mev^`pI%-cR#%pfrES|$2%tg@7${Im zLBJqCKm^~%kqyWahMtFC{m)BDn@^W+n<9Vs4o8^{xZi&Mv#JmPg~hDhyn9@iQaYl1 zb`JLD2V96U6l8WL=?n97fC_~~t>ED5npj0DEXy*Oju~q^dmy7QgiIy_{eJ&PQrd=O zTr3tLpD%!=R5+2n4HYIFZ-%8JGt|1(g~rh-D=YFj+Az zW(A5Kmc(%jan)&(SOLdLpDi*0KTl?3g3&8WuNWgH;XS@00@rm1q##!+l~R*`BVp_N zo+o>~-p$tT{t5Bs0?k82!-S(@;vSVo<7@Jfu3S^qP;(9ryrKIh{yWa!k>a)0QvY16 P00000NkvXXu0mjf=yc!b literal 0 HcmV?d00001 diff --git a/inc/class.dc.log.list.php b/inc/class.dc.log.list.php new file mode 100644 index 0000000..7fc8657 --- /dev/null +++ b/inc/class.dc.log.list.php @@ -0,0 +1,110 @@ +rs->isEmpty()) { + $pager = new pager($page,$this->rs_count,$nb_per_page,10); + $pager->var_page = 'page'; + + echo '

'.__('Page(s)').' : '.$pager->getLinks().'

'; + + $blocks = explode('%s',$html_block); + + echo $blocks[0]; + + echo + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''; + + $this->rs->index(((integer)$page - 1) * $nb_per_page); + $iter = 0; + while ($iter < $nb_per_page) { + $this->logLine(); + + if ($this->rs->isEnd()) { + break; + } + else { + $this->rs->moveNext(); + $iter++; + } + } + + echo + ''. + '
'.__('Date').''.__('Message').''.__('Blog').''.__('Component').''.__('User').''.__('IP').'
'; + + echo $blocks[1]; + + echo '

'.__('Page(s)').' : '.$pager->getLinks().'

'; + } + else { + echo '

'.__('No log').'

'; + } + } + + private function logLine() + { + $format = $this->core->blog->settings->system->date_format.' - '.$this->core->blog->settings->system->time_format; + + $tz = dt::getTimeOffset($this->core->blog->settings->system->blog_timezone); + + $date = dt::str($format,strtotime($this->rs->log_dt) + $tz); + + echo + ''."\n". + ''. + form::checkbox(array('ids[]'),$this->rs->log_id). + ' '.html::escapeHTML($date). + "\n". + ''. + html::escapeHTML($this->rs->log_msg). + "\n". + ''. + html::escapeHTML($this->rs->blog_id). + "\n". + ''. + html::escapeHTML($this->rs->log_table). + "\n". + ''. + html::escapeHTML($this->rs->getUserCN()). + "\n". + ''. + html::escapeHTML($this->rs->log_ip). + "\n". + "\n"; + } +} + +?> \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..f19cd70 --- /dev/null +++ b/index.php @@ -0,0 +1,138 @@ +auth->isSuperAdmin()) { return; } + +# Var initialisation +$p_url = 'plugin.php?p=dcLog'; +$page = isset($_GET['page']) ? $_GET['page'] : 1; +$status = isset($_GET['status']) ? $_GET['status'] : null; +# filter initialisation +$blog_id = isset($_GET['blog_id']) ? $_GET['blog_id'] : null; +$user_id = isset($_GET['user_id']) ? $_GET['user_id'] : null; +$table = isset($_GET['table']) ? $_GET['table'] : null; +$ip = isset($_GET['ip']) ? $_GET['ip'] : null; +$nb = isset($_GET['nb']) ? $_GET['nb'] : 20; +# form initialisation +$ids = isset($_POST['ids']) ? $_POST['ids'] : null; +$del_all_log = isset($_POST['del_all_logs']) ? true : false; + +# Delete logs +if (isset($_POST['del_logs']) || isset($_POST['del_all_logs'])) +{ + try { + $core->log->delLogs($ids,$del_all_log); + $status = $del_all_log ? '2' : '1'; + http::redirect($p_url.'&del='.$status); + } + catch (Exception $e) { + $core->error->add($e->getMessage()); + } +} + +# Gets logs & prepares display object +$params = array( + 'blog_id' => $blog_id, + 'user_id' => !is_null($user_id) && $user_id !== '' ? explode(',',$user_id) : $user_id, + 'log_table' => !is_null($table) && $table !== '' ? explode(',',$table) : $table, + 'log_ip' => !is_null($ip) && $ip !== '' ? explode(',',$ip) : $ip +); +$l_rs = $core->log->getLogs($params); +$l_nb = $l_rs->count(); +$l_list = new dcLogList($core,$l_rs,$l_nb); + +# Display +echo +''. +''. + ''.__('Log').''. + dcPage::jsLoad('js/filter-controls.js'). + dcPage::jsLoad('index.php?pf=dcLog/js/dclog.js'). + ''. +''."\n". +''; + +# Message +if (isset($_GET['del'])) { + $msg = ''; + + if ((integer) $_GET['del'] === 1) { + $msg = __('Selected logs have been successfully deleted'); + } + if ((integer) $_GET['del'] === 2) { + $msg = __('All logs have been successfully deleted'); + } + + echo !empty($msg) ? '

'.$msg.'

' : ''; +} + +# Combo blog +$combo_blog = array(__('All blogs') => 'all'); +$blogs = $core->getBlogs(); +while ($blogs->fetch()) { + $combo_blog[sprintf('%s (%s)',$blogs->blog_name,$blogs->blog_id)] = $blogs->blog_id; +} + +echo +'

'.html::escapeHTML($core->blog->name).' › '.__('Log').'

'. +'

'. +__('Filters').'

'. +'
'. + form::hidden('p','dcLog'). + '
'.__('Filters').''. + '
'. + '

'. + '

'. + '

 '. + '

'. + '
'. + '

'. + '

'. + '
'. + '
'. //Opera sucks + '
'. +'
'; + +$l_list->display($page,$nb, + '
'. + + '%s'. + + '
'. + '

'. + + '

 '. + '

'. + $core->formNonce(). + '
'. + '
' +); + +echo +''. +''; + +?> \ No newline at end of file diff --git a/js/dclog.js b/js/dclog.js new file mode 100644 index 0000000..29be3a1 --- /dev/null +++ b/js/dclog.js @@ -0,0 +1 @@ +$(function(){$('.checkboxes-helpers').each(function(){dotclear.checkboxesHelpers(this)});$('input[name="del_logs"]').click(function(){return window.confirm(dotclear.msg.confirm_delete_selected_log)});$('input[name="del_all_logs"]').click(function(){return window.confirm(dotclear.msg.confirm_delete_all_log)})}) \ No newline at end of file diff --git a/locales/fr/main.po b/locales/fr/main.po new file mode 100644 index 0000000..f30f71b --- /dev/null +++ b/locales/fr/main.po @@ -0,0 +1,78 @@ +# Language: français +# Module: dcLog - 1.0 +# Date: 2010-05-08 09:25:09 +# Translated with translater 1.3 + +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Project-Id-Version: dcLog 1.0\n" +"POT-Creation-Date: \n" +"PO-Revision-Date: 2010-05-08T09:25:09+00:00\n" +"Last-Translator: Thomas Bouron\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Transfer-Encoding: 8bit\n" + +#: _admin.php:14 +#: index.php:54 +#: index.php:88 +msgid "Log" +msgstr "Log" + +#: inc/class.dc.log.list.php:41 +msgid "Message" +msgstr "Message" + +#: inc/class.dc.log.list.php:43 +msgid "Component" +msgstr "Composant" + +#: inc/class.dc.log.list.php:44 +msgid "User" +msgstr "Utilisateur" + +#: inc/class.dc.log.list.php:45 +msgid "IP" +msgstr "IP" + +#: inc/class.dc.log.list.php:73 +msgid "No log" +msgstr "Aucun log" + +#: index.php:59 +msgid "Are you sure you want to delete selected logs?" +msgstr "Êtes vous sur de vouloir supprimer les logs sélectionnés?" + +#: index.php:60 +msgid "Are you sure you want to delete all logs?" +msgstr "Êtes vous sur de vouloir supprimer tous les logs" + +#: index.php:71 +msgid "Selected logs have been successfully deleted" +msgstr "Les logs sélectionnés ont été supprimé avec succès" + +#: index.php:74 +msgid "All logs have been successfully deleted" +msgstr "Tous les logs ont été supprimé avec succès" + +#: index.php:81 +msgid "All blogs" +msgstr "Tous les blogs" + +#: index.php:100 +msgid "IP:" +msgstr "IP :" + +#: index.php:103 +msgid "Logs per page" +msgstr "Logs par page" + +#: index.php:119 +msgid "Delete selected logs" +msgstr "Supprimer les logs sélectionnés" + +#: index.php:120 +msgid "Delete all logs" +msgstr "Supprimer tous les logs" +