PostfixAdmin - web based virtual user administration interface for Postfix mail servers https://postfixadmin.github.io/postfixadmin/
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.

83 lines
2.1 KiB

  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 :
  10. * http://www.postfixadmin.com or http://postfixadmin.sf.net
  11. *
  12. * @version $Id$
  13. * @license GNU GPL v2 or later.
  14. *
  15. * File: viewlog.php
  16. * Shows entries from the log table to users.
  17. *
  18. * Template File: viewlog.tpl
  19. *
  20. * Template Variables:
  21. *
  22. * tMessage
  23. * tLog
  24. *
  25. * Form POST \ GET Variables:
  26. *
  27. * fDomain
  28. */
  29. require_once('common.php');
  30. authentication_require_role('admin');
  31. $SESSID_USERNAME = authentication_get_username();
  32. if(authentication_has_role('global-admin')) {
  33. $list_domains = list_domains ();
  34. }
  35. else {
  36. $list_domains = list_domains_for_admin ($SESSID_USERNAME);
  37. }
  38. if ($_SERVER['REQUEST_METHOD'] == "GET")
  39. {
  40. if ((is_array ($list_domains) and sizeof ($list_domains) > 0)) $fDomain = $list_domains[0];
  41. } elseif ($_SERVER['REQUEST_METHOD'] == "POST") {
  42. if (isset ($_POST['fDomain'])) $fDomain = escape_string ($_POST['fDomain']);
  43. } else {
  44. die('Unknown request method');
  45. }
  46. if (! (check_owner ($SESSID_USERNAME, $fDomain) || authentication_has_role('global-admin')))
  47. {
  48. $error = 1;
  49. $tMessage = $PALANG['pViewlog_result_error'];
  50. }
  51. if ($error != 1)
  52. {
  53. $query = "SELECT timestamp,username,domain,action,data FROM $table_log WHERE domain='$fDomain' ORDER BY timestamp DESC LIMIT 10";
  54. if ('pgsql'==$CONF['database_type'])
  55. {
  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 ('pgsql'==$CONF['database_type'])
  64. {
  65. $row['timestamp']=gmstrftime('%c %Z',$row['timestamp']);
  66. }
  67. $tLog[] = $row;
  68. }
  69. }
  70. }
  71. include ("$incpath/templates/header.tpl");
  72. include ("$incpath/templates/menu.tpl");
  73. include ("$incpath/templates/viewlog.tpl");
  74. include ("$incpath/templates/footer.tpl");
  75. /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
  76. ?>