You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.2 KiB

  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Frank Karlitschek
  6. * @copyright 2010 Frank Karlitschek karlitschek@kde.org
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * Class for logging features
  24. *
  25. */
  26. class OC_LOG {
  27. /**
  28. * array to define different log types
  29. *
  30. */
  31. public static $TYPE = array (
  32. 1=>'login',
  33. 2=>'logout',
  34. 3=>'read',
  35. 4=>'write',
  36. );
  37. /**
  38. * log an event
  39. *
  40. * @param username $user
  41. * @param type $type
  42. * @param message $message
  43. */
  44. public static function event($user,$type,$message){
  45. $result = OC_DB::query('insert into log (timestamp,user,type,message) values ("'.time().'","'.addslashes($user).'","'.addslashes($type).'","'.addslashes($message).'")');
  46. OC_DB::free_result($result);
  47. }
  48. /**
  49. * show the log entries in a web GUI
  50. *
  51. */
  52. public static function show(){
  53. global $CONFIG_DATEFORMAT;
  54. echo('<div class="center"><table cellpadding="6" cellspacing="0" border="0" class="log">');
  55. $result = OC_DB::query('select timestamp,user,type,message from log order by timestamp desc limit 20');
  56. $count=OC_DB::numrows($result);
  57. for ($i=0; $i < $count;$i++) {
  58. $entry=OC_DB::fetch_assoc($result);
  59. echo('<tr class="browserline">');
  60. echo('<td class="sizetext">'.date($CONFIG_DATEFORMAT,$entry['timestamp']).'</td>');
  61. echo('<td class="highlighttext">'.OC_LOG::$TYPE[$entry['type']].'</td>');
  62. echo('<td class="nametext">'.$entry['user'].'</td>');
  63. echo('<td class="nametext">'.$entry['message'].'</td>');
  64. echo('</tr>');
  65. }
  66. echo('</table></div>');
  67. OC_DB::free_result($result);
  68. }
  69. }
  70. ?>