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.

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