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.

119 lines
3.2 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-alias.php
  16. * Users can use this to set forwards etc for their mailbox.
  17. *
  18. * Template File: users_edit-alias.php
  19. *
  20. * Template Variables:
  21. *
  22. * tMessage
  23. * tGotoArray
  24. * tStoreAndForward
  25. *
  26. * Form POST \ GET Variables:
  27. *
  28. * fAddress
  29. * fGoto
  30. */
  31. require_once('../common.php');
  32. authentication_require_role('user');
  33. $USERID_USERNAME = authentication_get_username();
  34. $tmp = preg_split ('/@/', $USERID_USERNAME);
  35. $USERID_DOMAIN = $tmp[1];
  36. $vacation_domain = $CONF['vacation_domain'];
  37. $vacation_goto = preg_replace('/@/', '#', $USERID_USERNAME) . '@' . $vacation_domain;
  38. $ah = new AliasHandler($USERID_USERNAME);
  39. $tGotoArray = $ah->get();
  40. $tStoreAndForward = $ah->hasStoreAndForward();
  41. $vacation_domain = $CONF['vacation_domain'];
  42. if ($_SERVER['REQUEST_METHOD'] == "GET")
  43. {
  44. include ("../templates/header.php");
  45. include ("../templates/users_menu.php");
  46. include ("../templates/users_edit-alias.php");
  47. include ("../templates/footer.php");
  48. }
  49. if ($_SERVER['REQUEST_METHOD'] == "POST")
  50. {
  51. // user clicked on cancel button
  52. if(isset($_POST['fCancel'])) {
  53. header("Location: main.php");
  54. exit(0);
  55. }
  56. $pEdit_alias_goto = $PALANG['pEdit_alias_goto'];
  57. if (isset($_POST['fVacation'])) $fVacation = $_POST['fVacation'];
  58. if (isset($_POST['fGoto'])) $fGoto = trim($_POST['fGoto']);
  59. if (isset($_POST['fForward_and_store'])) $fForward_and_store = $_POST['fForward_and_store'];
  60. $goto = strtolower ($fGoto);
  61. $goto = preg_replace ('/\\\r\\\n/', ',', $goto);
  62. $goto = preg_replace ('/\r\n/', ',', $goto);
  63. $goto = preg_replace ('/[\s]+/i', '', $goto);
  64. $goto = preg_replace ('/\,*$/', '', $goto);
  65. $goto = explode(",",$goto);
  66. $goto = array_merge(array_unique($goto));
  67. $good_goto = array();
  68. if($fForward_and_store == 'NO' && sizeof($goto) == 1 && $goto[0] == '') {
  69. $tMessage = $PALANG['pEdit_alias_goto_text_error1'];
  70. $error += 1;
  71. }
  72. if($error === 0) {
  73. foreach($goto as $address) {
  74. if(!check_email($address)) {
  75. $error += 1;
  76. $tMessage = $PALANG['pEdit_alias_goto_text_error2'] . " $address</font>";
  77. }
  78. else {
  79. $good_goto[] = $address;
  80. }
  81. }
  82. $goto = $good_goto;
  83. }
  84. if ($error == 0) {
  85. $flags = 'remote_only';
  86. if($fForward_and_store == "YES" ) {
  87. $flags = 'forward_and_store';
  88. }
  89. $updated = $ah->update($goto, $flags);
  90. if($updated) {
  91. header ("Location: main.php");
  92. exit;
  93. }
  94. $tMessage = $PALANG['pEdit_alias_result_error'];
  95. }
  96. else {
  97. $tGotoArray = $goto;
  98. }
  99. include ("../templates/header.php");
  100. include ("../templates/users_menu.php");
  101. include ("../templates/users_edit-alias.php");
  102. include ("../templates/footer.php");
  103. }
  104. /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
  105. ?>