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.

120 lines
3.4 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: edit-active.php
  16. * Responsible for toggling the active status of a mailbox.
  17. *
  18. * Template File: message.php
  19. *
  20. * Template Variables:
  21. *
  22. * tMessage
  23. *
  24. * Form POST \ GET Variables:
  25. *
  26. * fUsername
  27. * fDomain
  28. * fReturn
  29. */
  30. require_once('common.php');
  31. authentication_require_role('admin');
  32. $SESSID_USERNAME = authentication_get_username();
  33. $fAliasDomain = '';
  34. $fUsername = '';
  35. $fAlias = '';
  36. $fDomain = '';
  37. $fReturn = '';
  38. if ($_SERVER['REQUEST_METHOD'] == "GET")
  39. {
  40. if (isset ($_GET['alias_domain'])) $fAliasDomain = escape_string ($_GET['alias_domain']);
  41. if (isset ($_GET['username'])) $fUsername = escape_string ($_GET['username']);
  42. if (isset ($_GET['alias'])) $fAlias = escape_string ($_GET['alias']); else $fAlias = escape_string ($_GET['username']);
  43. if (isset ($_GET['domain'])) $fDomain = escape_string ($_GET['domain']);
  44. if (isset ($_GET['return'])) $fReturn = escape_string ($_GET['return']);
  45. if (! (check_owner ($SESSID_USERNAME, $fDomain) || authentication_has_role('global-admin') ) )
  46. {
  47. $error = 1;
  48. $tMessage = $PALANG['pEdit_mailbox_domain_error'] . "<b>$fDomain</b>!</font>";
  49. }
  50. else
  51. {
  52. $setSql=('pgsql'==$CONF['database_type']) ? 'active=NOT active' : 'active=1-active';
  53. $setSql.=', modified=NOW()';
  54. if ($fUsername != '')
  55. {
  56. $result = db_query ("UPDATE $table_mailbox SET $setSql WHERE username='$fUsername' AND domain='$fDomain'");
  57. if ($result['rows'] != 1)
  58. {
  59. $error = 1;
  60. $tMessage = $PALANG['pEdit_mailbox_result_error'];
  61. }
  62. else
  63. {
  64. db_log ($SESSID_USERNAME, $fDomain, 'edit_mailbox_state', $fUsername);
  65. }
  66. }
  67. if ($fAlias != '')
  68. {
  69. $result = db_query ("UPDATE $table_alias SET $setSql WHERE address='$fAlias' AND domain='$fDomain'");
  70. if ($result['rows'] != 1)
  71. {
  72. $error = 1;
  73. $tMessage = $PALANG['pEdit_mailbox_result_error'];
  74. }
  75. else
  76. {
  77. db_log ($SESSID_USERNAME, $fDomain, 'edit_alias_state', $fAlias);
  78. }
  79. }
  80. if ($fAliasDomain != '')
  81. {
  82. $result = db_query ("UPDATE $table_alias_domain SET $setSql WHERE alias_domain='$fDomain'");
  83. if ($result['rows'] != 1)
  84. {
  85. $error = 1;
  86. $tMessage = $PALANG['pEdit_alias_domain_result_error'];
  87. }
  88. else
  89. {
  90. db_log ($SESSID_USERNAME, $fDomain, 'edit_alias_domain_state', $fDomain);
  91. }
  92. }
  93. }
  94. if ($error != 1)
  95. {
  96. if ( preg_match( "/^list-virtual.php.*/", $fReturn ) ||
  97. preg_match( "/^search.php.*/", $fReturn ) )
  98. {
  99. //$fReturn appears OK, jump there
  100. header ("Location: $fReturn");
  101. }
  102. else
  103. {
  104. header ("Location: list-virtual.php?domain=$fDomain");
  105. }
  106. exit;
  107. }
  108. }
  109. include ("templates/header.php");
  110. include ("templates/menu.php");
  111. include ("templates/message.php");
  112. include ("templates/footer.php");
  113. /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
  114. ?>