Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

viewlog.php 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * Postfix Admin
  4. *
  5. * LICENSE
  6. * This source file is subject to the GPL license that is bundled with
  7. * this package in the file LICENSE.TXT.
  8. *
  9. * Further details on the project are available at http://postfixadmin.sf.net
  10. *
  11. * @version $Id: viewlog.php 1822 2015-12-06 23:27:45Z christian_boltz $
  12. * @license GNU GPL v2 or later.
  13. *
  14. * File: viewlog.php
  15. * Shows entries from the log table to users.
  16. *
  17. * Template File: viewlog.tpl
  18. *
  19. * Template Variables:
  20. *
  21. * tLog
  22. *
  23. * Form POST \ GET Variables:
  24. *
  25. * fDomain
  26. */
  27. require_once('common.php');
  28. authentication_require_role('admin');
  29. $SESSID_USERNAME = authentication_get_username();
  30. if(authentication_has_role('global-admin')) {
  31. $list_domains = list_domains ();
  32. }
  33. else {
  34. $list_domains = list_domains_for_admin ($SESSID_USERNAME);
  35. }
  36. if ($_SERVER['REQUEST_METHOD'] == "GET")
  37. {
  38. if ((is_array ($list_domains) and sizeof ($list_domains) > 0)) $fDomain = $list_domains[0];
  39. } elseif ($_SERVER['REQUEST_METHOD'] == "POST") {
  40. if (isset ($_POST['fDomain'])) $fDomain = escape_string ($_POST['fDomain']);
  41. } else {
  42. die('Unknown request method');
  43. }
  44. if (! (check_owner ($SESSID_USERNAME, $fDomain) || authentication_has_role('global-admin')))
  45. {
  46. $error = 1;
  47. flash_error($PALANG['pViewlog_result_error']);
  48. }
  49. // we need to initialize $tLog as an array!
  50. $tLog = array();
  51. if ($error != 1)
  52. {
  53. $table_log = table_by_key('log');
  54. $query = "SELECT timestamp,username,domain,action,data FROM $table_log WHERE domain='$fDomain' ORDER BY timestamp DESC LIMIT 10";
  55. if (db_pgsql()) {
  56. $query = "SELECT extract(epoch from timestamp) as timestamp,username,domain,action,data FROM $table_log WHERE domain='$fDomain' ORDER BY timestamp DESC LIMIT 10";
  57. }
  58. $result=db_query($query);
  59. if ($result['rows'] > 0)
  60. {
  61. while ($row = db_array ($result['result']))
  62. {
  63. if (db_pgsql()) {
  64. $row['timestamp']=gmstrftime('%c %Z',$row['timestamp']);
  65. }
  66. $tLog[] = $row;
  67. }
  68. }
  69. }
  70. for ($i = 0; $i < count ($tLog); $i++)
  71. $tLog[$i]['action'] = $PALANG ['pViewlog_action_'.$tLog [$i]['action']];
  72. $smarty->assign ('domain_list', $list_domains);
  73. $smarty->assign ('domain_selected', $fDomain);
  74. $smarty->assign ('tLog', $tLog,false);
  75. $smarty->assign ('fDomain', $fDomain);
  76. $smarty->assign ('smarty_template', 'viewlog');
  77. $smarty->display ('index.tpl');
  78. /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
  79. ?>