index.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. require dirname(__FILE__).'/../../../inc/classes/class.multipage.php';
  23. $nb_per_page = 40;
  24. # Vidange des logs
  25. if (!empty($_GET['empty']))
  26. {
  27. $delReq = 'DELETE FROM '.$blog->t_log;
  28. if ($con->execute($delReq) !== false) {
  29. $_GET['msg'] = __('Logs have been cleared');
  30. }
  31. }
  32. buffer::str(
  33. '<h2>'.__('DotClear "syslog"').'</h2>'
  34. );
  35. # Récupération des logs
  36. $rs = $con->select('SELECT count(*) FROM '.$blog->t_log);
  37. $nb_log = $rs->f(0);
  38. $max_pages = ceil($nb_log/$nb_per_page);
  39. $env = (!empty($_GET['env']) && $_GET['env'] <= $max_pages) ? $_GET['env'] : 1;
  40. $strReq = 'SELECT `user_id`,`table`,`key`,`date`,`ip`,`log` '.
  41. 'FROM '.$blog->t_log.' '.
  42. 'ORDER BY `date` DESC '.
  43. 'LIMIT '.(($env-1)*$nb_per_page).','.$nb_per_page;
  44. $rs = $con->select($strReq);
  45. $lum = new multipage($env,'log_line',$rs->getData(),$nb_log,$nb_per_page);
  46. $lum->setOption('html_block','<table class="clean-table">'.
  47. '<tr><th>'.__('Date').'</th><th>'.__('User').'</th><th>'.__('IP').'</th>'.
  48. '<th>'.__('Log').'</th><th>'.__('Table').'</th><th>'.__('Key').'</th></tr>%s</table>');
  49. $lum->setOption('html_row','<tr>%s</tr>');
  50. $lum->setOption('html_cell','%s');
  51. $lum->setOption('html_links','<p>'.__('Page(s)').' : %s</p>');
  52. $lum->setOption('html_cur_page','<strong>%s</strong>');
  53. $lum->setOption('html_prev','&lt;'.__('prev. page'));
  54. $lum->setOption('html_next',__('next page').'&gt;');
  55. $lum->setOption('html_prev_grp','...');
  56. $lum->setOption('html_next_grp','...');
  57. $lum->setOption('html_empty','<p><strong>'.__('No log yet.').'</strong></p>');
  58. buffer::str(
  59. $lum->getLinks().
  60. $lum->getPage().
  61. $lum->getLinks()
  62. );
  63. if (!$rs->isEmpty()) {
  64. buffer::str(
  65. '<p><a href="tools.php?p=syslog&amp;empty=1">'.__('Clear logs').'</a></p>'
  66. );
  67. }
  68. # Fonction d'affichage des log
  69. function log_line($data,$i)
  70. {
  71. $style = ($i%2 == 0) ? ' style="background:#eee;"' : '';
  72. return
  73. '<td'.$style.'>'.$data['date'].'</td>'.
  74. '<td'.$style.'>'.$data['user_id'].'</td>'.
  75. '<td'.$style.'>'.$data['ip'].'</td>'.
  76. '<td'.$style.'>'.$data['log'].'</td>'.
  77. '<td'.$style.'>'.$data['table'].'</td>'.
  78. '<td'.$style.'>'.$data['key'].'</td>';
  79. }
  80. ?>