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.

postfixadmin_forward.php 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. require_once(dirname(__FILE__) . '/common.php');
  3. $USERID_USERNAME = $username;
  4. $tmp = preg_split('/@/', $USERID_USERNAME);
  5. $USERID_LOCALPART = $tmp[0];
  6. $USERID_DOMAIN = $tmp[1];
  7. $xmlrpc = get_xmlrpc();
  8. $alias = $xmlrpc->getProxy('alias');
  9. do_header();
  10. // Normal page request (GET)
  11. if ($_SERVER['REQUEST_METHOD'] == "GET") {
  12. $row = $alias->get();
  13. if ($row === false) {
  14. bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
  15. textdomain('postfixadmin');
  16. $tMessage = _("Unable to locate alias!");
  17. bindtextdomain('squirrelmail', SM_PATH . 'locale');
  18. textdomain('squirrelmail');
  19. exit(0);
  20. }
  21. }
  22. if ($_SERVER['REQUEST_METHOD'] == "POST") {
  23. $pEdit_alias_goto = _("To");
  24. $fGoto = $_POST['fGoto'];
  25. // reform string into a list...
  26. $goto = preg_replace('/\r\n/', ',', $fGoto);
  27. $goto = preg_replace('/[\s]+/i', '', $goto);
  28. $goto = preg_replace('/\,*$/', '', $goto);
  29. $array = preg_split('/,/', $goto);
  30. $error = 0;
  31. // check that we have valid addresses in the list
  32. foreach ($array as $key => $email_address) {
  33. if (empty($email_address)) {
  34. unset($array[$key]);
  35. continue;
  36. }
  37. if (!check_email($email_address)) {
  38. $error = 1;
  39. $tGoto = $goto;
  40. bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
  41. textdomain('postfixadmin');
  42. $tMessage = _("The email address that you have entered is not valid:") . " $email_address</font>";
  43. bindtextdomain('squirrelmail', SM_PATH . 'locale');
  44. textdomain('squirrelmail');
  45. }
  46. }
  47. if ($error != 1) {
  48. $flag = 'forward_and_store'; // goto = $USERID_USERNAME;
  49. $success = $alias->update($array, $flag);
  50. if (!$success) {
  51. bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
  52. textdomain('postfixadmin');
  53. $tMessage = _("Unable to modify the alias!");
  54. bindtextdomain('squirrelmail', SM_PATH . 'locale');
  55. textdomain('squirrelmail');
  56. } else {
  57. bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
  58. textdomain('postfixadmin');
  59. echo "<p align=center><b>". _("Alias successfully changed!"). "\n</b></p>";
  60. bindtextdomain('squirrelmail', SM_PATH . 'locale');
  61. textdomain('squirrelmail');
  62. echo "<p align=center><a href=\"javascript:history.go(-1)\">". _("Click here to go back") ."</a></p>";
  63. exit;
  64. }
  65. }
  66. }
  67. bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
  68. textdomain('postfixadmin');
  69. if (!isset($tMessage)) {
  70. $tMessage = '';
  71. }
  72. echo "<table bgcolor=\"$color[0]\" align=\"center\" width=\"95%\" cellpadding=\"1\" cellspacing=\"0\" border=\"0\">
  73. <tr>
  74. <td align=\"center\" bgcolor=\"$color[0]\" colspan=\"2\">
  75. <b>". _("Options") ." - ". _("Edit Alias"). " </b>
  76. <table align=\"center\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">
  77. <tr>
  78. <td bgcolor=\"$color[4]\" align=\"center\">
  79. <table align=\"center\" width=\"100%\">
  80. <tr>
  81. <td align=\"left\">". _("Edit an alias* for your email address.<br />One entry per line."). " </td>
  82. </tr>
  83. <tr>
  84. <td align=\"left\">". _("*Additional forward-aliases always receive messages BCC!"). "\n
  85. </tr>
  86. <tr>
  87. <td align=\"left\">" . _("To remove an alias, simply delete its line from the text box.") . "</td>
  88. </tr>
  89. </table>
  90. <table align=\"center\" width\"95%\" cellpadding=\"5\" cellspacing=\"1\">
  91. <form name=\"mailbox\" method=\"post\">
  92. <tr>
  93. <td bgcolor=\"$color[3]\" align=\"center\"><b>". _("Edit Forwards"). "</b>
  94. </td>
  95. </tr>
  96. <tr>
  97. <td bgcolor=\"$color[5]\" align=\"center\">$tMessage
  98. <table cellpadding=\"5\" cellspacing=\"1\">
  99. <tr>
  100. <th align=\"left\">". _("Alias"). ":\n
  101. </th>
  102. <td align=\"left\">" . $_SESSION['username'] . "</td>
  103. </tr>
  104. <tr>
  105. <th>&nbsp;</th>
  106. <td>&nbsp;</td>
  107. </tr>
  108. <tr>
  109. <th align=\"left\" valign=\"top\">". _("To"). ":\n</th>
  110. <td>
  111. <textarea rows=\"8\" cols=\"50\" name=\"fGoto\">";
  112. bindtextdomain('squirrelmail', SM_PATH . 'locale');
  113. textdomain('squirrelmail');
  114. $aliases = $alias->get();
  115. foreach ($aliases as $address) {
  116. if ($address == "" || $address == null) {
  117. continue;
  118. }
  119. print "$address\n";
  120. }
  121. bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
  122. textdomain('postfixadmin');
  123. echo "
  124. </textarea>
  125. </td>
  126. </tr>
  127. <tr>
  128. <th>&nbsp;</th>
  129. <td>&nbsp;</td>
  130. </tr>
  131. <tr>
  132. <th>&nbsp;</th>
  133. <td align=\"left\"colspan=\"2\">
  134. <input type=\"submit\" name=\"submit\" value=\"" . _("Edit Alias") . "\">
  135. </td>
  136. </tr>
  137. </table>
  138. </td>
  139. </tr>
  140. </table>
  141. </form>
  142. </td>
  143. </tr>
  144. </table>
  145. </td></tr>
  146. </table>
  147. ";
  148. bindtextdomain('squirrelmail', SM_PATH . 'locale');
  149. textdomain('squirrelmail');