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.

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