[ Index ]
 

Code source de Dotclear 1.2.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/ecrire/tools/syslog/ -> index.php (source)

   1  <?php
   2  # ***** BEGIN LICENSE BLOCK *****
   3  # This file is part of DotClear.
   4  # Copyright (c) 2004 Olivier Meunier and contributors. All rights
   5  # reserved.
   6  #
   7  # DotClear is free software; you can redistribute it and/or modify
   8  # it under the terms of the GNU General Public License as published by
   9  # the Free Software Foundation; either version 2 of the License, or
  10  # (at your option) any later version.
  11  # 
  12  # DotClear is distributed in the hope that it will be useful,
  13  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15  # GNU General Public License for more details.
  16  # 
  17  # You should have received a copy of the GNU General Public License
  18  # along with DotClear; if not, write to the Free Software
  19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20  #
  21  # ***** END LICENSE BLOCK *****
  22  
  23  require dirname(__FILE__).'/../../../inc/classes/class.multipage.php';
  24  
  25  $nb_per_page = 40;
  26  
  27  # Vidange des logs
  28  if (!empty($_GET['empty']))
  29  {
  30      $delReq = 'DELETE FROM '.$blog->t_log;
  31      
  32      if ($con->execute($delReq) !== false) {
  33          $_GET['msg'] = __('Logs have been cleared');
  34      }
  35  }
  36  
  37  buffer::str(
  38  '<h2>'.__('DotClear "syslog"').'</h2>'
  39  );
  40  
  41  # Récupération des logs
  42  $rs = $con->select('SELECT count(*) FROM '.$blog->t_log);
  43  $nb_log = $rs->f(0);
  44  
  45  $max_pages = ceil($nb_log/$nb_per_page);
  46  $env = (!empty($_GET['env']) && (integer)$_GET['env'] <= $max_pages) ? (integer)$_GET['env'] : 1;
  47  
  48  $strReq = 'SELECT `user_id`,`table`,`key`,`date`,`ip`,`log` '.
  49          'FROM '.$blog->t_log.' '.
  50          'ORDER BY `date` DESC '.
  51          'LIMIT '.(($env-1)*$nb_per_page).','.$nb_per_page;
  52  
  53  $rs = $con->select($strReq);
  54  
  55  $lum = new multipage($env,'log_line',$rs->getData(),$nb_log,$nb_per_page);
  56  
  57  $lum->setOption('html_block','<table class="clean-table">'.
  58              '<tr><th>'.__('Date').'</th><th>'.__('User').'</th><th>'.__('IP').'</th>'.
  59              '<th>'.__('Log').'</th><th>'.__('Table').'</th><th>'.__('Key').'</th></tr>%s</table>');
  60  $lum->setOption('html_row','<tr>%s</tr>');
  61  $lum->setOption('html_cell','%s');
  62  
  63  $lum->setOption('html_links','<p>'.__('Page(s)').' : %s</p>');
  64  $lum->setOption('html_cur_page','<strong>%s</strong>');
  65  
  66  $lum->setOption('html_prev','&lt;'.__('prev. page'));
  67  $lum->setOption('html_next',__('next page').'&gt;');
  68  $lum->setOption('html_prev_grp','...');
  69  $lum->setOption('html_next_grp','...');
  70  
  71  $lum->setOption('html_empty','<p><strong>'.__('No log yet.').'</strong></p>');
  72  
  73  buffer::str(
  74      $lum->getLinks().
  75      $lum->getPage().
  76      $lum->getLinks()
  77  );
  78  
  79  if (!$rs->isEmpty()) {
  80      buffer::str(
  81      '<p><a href="tools.php?p=syslog&amp;empty=1">'.__('Clear logs').'</a></p>'
  82      );
  83  }
  84  
  85  # Fonction d'affichage des log
  86  function log_line($data,$i)
  87  {
  88      $style = ($i%2 == 0) ? ' style="background:#eee;"' : '';
  89      
  90      return
  91      '<td'.$style.'>'.$data['date'].'</td>'.
  92      '<td'.$style.'>'.$data['user_id'].'</td>'.
  93      '<td'.$style.'>'.$data['ip'].'</td>'.
  94      '<td'.$style.'>'.$data['log'].'</td>'.
  95      '<td'.$style.'>'.$data['table'].'</td>'.
  96      '<td'.$style.'>'.$data['key'].'</td>';
  97  }
  98  ?>


Généré le : Fri Feb 23 21:40:15 2007 par Balluche grâce à PHPXref 0.7