initial commit from dcLog 1.0.1
commit
17bb4ab0f1
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of dcLog, a plugin for Dotclear.
|
||||
#
|
||||
# Copyright (c) 2010 Tomtom
|
||||
# http://blog.zenstyle.fr/
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_CONTEXT_ADMIN')) { return; }
|
||||
|
||||
$_menu['System']->addItem(__('Log'),'plugin.php?p=dcLog','index.php?pf=dcLog/icon.png',
|
||||
preg_match('/plugin.php\?p=dcLog(&.*)?$/',$_SERVER['REQUEST_URI']),
|
||||
$core->auth->isSuperAdmin());
|
||||
|
||||
?>
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of dcLog, a plugin for Dotclear.
|
||||
#
|
||||
# Copyright (c) 2010 Tomtom
|
||||
# http://blog.zenstyle.fr/
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_RC_PATH')) { return; }
|
||||
|
||||
$this->registerModule(
|
||||
/* Name */ "dcLog",
|
||||
/* Description*/ "Displays Dotclear logs",
|
||||
/* Author */ "Tomtom (http://blog.zenstyle.fr)",
|
||||
/* Version */ '1.0.1'
|
||||
);
|
||||
|
||||
?>
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of dcLog, a plugin for Dotclear.
|
||||
#
|
||||
# Copyright (c) 2010 Tomtom
|
||||
# http://blog.zenstyle.fr/
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_RC_PATH')) { return; }
|
||||
|
||||
$__autoload['dcLogList'] = dirname(__FILE__).'/inc/class.dc.log.list.php';
|
||||
|
||||
?>
|
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of dcLog, a plugin for Dotclear.
|
||||
#
|
||||
# Copyright (c) 2010 Tomtom
|
||||
# http://blog.zenstyle.fr/
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_RC_PATH')) { return; }
|
||||
|
||||
class dcLogList extends adminGenericList
|
||||
{
|
||||
/**
|
||||
* Display data table for logs
|
||||
*
|
||||
* @param int page
|
||||
* @param int nb_per_page
|
||||
* @param string html_block
|
||||
* @param string url
|
||||
*/
|
||||
public function display($page,$nb_per_page,$html_block = '%s')
|
||||
{
|
||||
if (!$this->rs->isEmpty()) {
|
||||
$pager = new pager($page,$this->rs_count,$nb_per_page,10);
|
||||
$pager->var_page = 'page';
|
||||
|
||||
echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
|
||||
|
||||
$blocks = explode('%s',$html_block);
|
||||
|
||||
echo $blocks[0];
|
||||
|
||||
echo
|
||||
'<table summary="logs" class="maximal">'.
|
||||
'<thead>'.
|
||||
'<tr>'.
|
||||
'<th>'.__('Date').'</th>'.
|
||||
'<th>'.__('Message').'</th>'.
|
||||
'<th>'.__('Blog').'</th>'.
|
||||
'<th>'.__('Component').'</th>'.
|
||||
'<th>'.__('User').'</th>'.
|
||||
'<th>'.__('IP').'</th>'.
|
||||
'</tr>'.
|
||||
'</thead>'.
|
||||
'<tbody>';
|
||||
|
||||
$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
|
||||
'</tbody>'.
|
||||
'</table>';
|
||||
|
||||
echo $blocks[1];
|
||||
|
||||
echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
|
||||
}
|
||||
else {
|
||||
echo '<p>'.__('No log').'</p>';
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
'<tr class="line wide" id="log_'.$this->rs->log_id.'">'."\n".
|
||||
'<td class="minimal nowrap">'.
|
||||
form::checkbox(array('ids[]'),$this->rs->log_id).
|
||||
' '.html::escapeHTML($date).
|
||||
"</td>\n".
|
||||
'<td class="maximal">'.
|
||||
html::escapeHTML($this->rs->log_msg).
|
||||
"</td>\n".
|
||||
'<td class="minimal nowrap">'.
|
||||
html::escapeHTML($this->rs->blog_id).
|
||||
"</td>\n".
|
||||
'<td class="minimal nowrap">'.
|
||||
html::escapeHTML($this->rs->log_table).
|
||||
"</td>\n".
|
||||
'<td class="minimal nowrap">'.
|
||||
html::escapeHTML($this->rs->getUserCN()).
|
||||
"</td>\n".
|
||||
'<td class="minimal nowrap">'.
|
||||
html::escapeHTML($this->rs->log_ip).
|
||||
"</td>\n".
|
||||
"</tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of dcLog, a plugin for Dotclear.
|
||||
#
|
||||
# Copyright (c) 2010 Tomtom
|
||||
# http://blog.zenstyle.fr/
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_CONTEXT_ADMIN')) { return; }
|
||||
|
||||
# Get out not superAdmin!
|
||||
if (!$core->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
|
||||
'<html>'.
|
||||
'<head>'.
|
||||
'<title>'.__('Log').'</title>'.
|
||||
dcPage::jsLoad('js/filter-controls.js').
|
||||
dcPage::jsLoad('index.php?pf=dcLog/js/dclog.js').
|
||||
'<script type="text/javascript">'.
|
||||
'//<![CDATA['."\n".
|
||||
dcPage::jsVar('dotclear.msg.confirm_delete_selected_log',__('Are you sure you want to delete selected logs?')).
|
||||
dcPage::jsVar('dotclear.msg.confirm_delete_all_log',__('Are you sure you want to delete all logs?')).
|
||||
'//]]>'.
|
||||
'</script>'.
|
||||
'</head>'."\n".
|
||||
'<body>';
|
||||
|
||||
# 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) ? '<p class="message">'.$msg.'</p>' : '';
|
||||
}
|
||||
|
||||
# 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
|
||||
'<h2>'.html::escapeHTML($core->blog->name).' › '.__('Log').'</h2>'.
|
||||
'<p><a id="filter-control" class="form-control" href="#">'.
|
||||
__('Filters').'</a></p>'.
|
||||
'<form action="'.$p_url.'" method="get" id="filters-form">'.
|
||||
form::hidden('p','dcLog').
|
||||
'<fieldset><legend>'.__('Filters').'</legend>'.
|
||||
'<div class="two-cols"><div class="col">'.
|
||||
'<p><label>'.__('Blog:').
|
||||
form::combo('blog_id',$combo_blog,$blog_id).'</label></p>'.
|
||||
'<p><label>'.__('User:').
|
||||
form::field('user_id',20,50,$user_id).'</label></p>'.
|
||||
'<p><label class="classic">'. form::field('nb',3,3,$nb).' '.
|
||||
__('Logs per page').'</label> '.
|
||||
'<input type="submit" value="'.__('filter').'" /></p>'.
|
||||
'</div><div class="col">'.
|
||||
'<p><label>'.__('IP:').
|
||||
form::field('ip',20,50,$ip).'</label></p>'.
|
||||
'<p><label>'.__('Component:').
|
||||
form::field('table',20,50,$table).'</label></p>'.
|
||||
'</div></div>'.
|
||||
'<br class="clear" />'. //Opera sucks
|
||||
'</fieldset>'.
|
||||
'</form>';
|
||||
|
||||
$l_list->display($page,$nb,
|
||||
'<form action="'.$p_url.'" method="post" id="form-logs">'.
|
||||
|
||||
'%s'.
|
||||
|
||||
'<div class="two-cols">'.
|
||||
'<p class="col checkboxes-helpers"></p>'.
|
||||
|
||||
'<p class="col right"><input type="submit" value="'.
|
||||
__('Delete selected logs').'" name="del_logs" /> '.
|
||||
'<input type="submit" value="'.__('Delete all logs').'" '.
|
||||
'name="del_all_logs" /></p>'.
|
||||
$core->formNonce().
|
||||
'</div>'.
|
||||
'</form>'
|
||||
);
|
||||
|
||||
echo
|
||||
'</body>'.
|
||||
'</html>';
|
||||
|
||||
?>
|
|
@ -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)})})
|
|
@ -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"
|
||||
|
Loading…
Reference in New Issue