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

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