Alternc  3.2
Alternc logiel libre pour l'hébergement
 All Data Structures Namespaces Files Functions Variables Pages
mail_manage_catchall.php
Go to the documentation of this file.
1 <?php
2 /*
3  ----------------------------------------------------------------------
4  AlternC - Web Hosting System
5  Copyright (C) 2000-2012 by the AlternC Development Team.
6  https://alternc.org/
7  ----------------------------------------------------------------------
8  LICENSE
9 
10  This program is free software; you can redistribute it and/or
11  modify it under the terms of the GNU General Public License (GPL)
12  as published by the Free Software Foundation; either version 2
13  of the License, or (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  To read the license please visit http://www.gnu.org/copyleft/gpl.html
21  ----------------------------------------------------------------------
22  Purpose of file: Manage catch-all
23  ----------------------------------------------------------------------
24 */
25 require_once("../class/config.php");
26 include_once("head.php");
27 
28 $fields = array (
29  "domain_id" => array("get","integer",null),
30  "target_type" => array("post", "string", null),
31  "target_mail" => array("post", "string", null),
32  "target_domain" => array("post", "string", null),
33 );
35 
36 if (is_null($domain_id)) {
37  echo "<p alert alert-danger>";
38  __("Problem with the domain");
39  echo"</p>";
40  include_once("foot.php");
41  exit();
42 }
43 
44 if (!is_null($target_type)) {
45  switch ($target_type) {
46  case "none":
47  $error=( ($mail->catchall_del($domain_id))?_("Catchall successfully deleted"):$err->errstr() );
48  break;
49  case "domain":
50  $error=( ($mail->catchall_set($domain_id, $target_domain))?_("Catchall successfully updated"):$err->errstr() );
51  break;
52  case "mail":
53  $error=( ($mail->catchall_set($domain_id, $target_mail))?_("Catchall successfully updated"):$err->errstr() );
54  break;
55  default:
56  $error=_("Unknown target type");
57  }
58 }
59 
60 $catch=$mail->catchall_getinfos($domain_id);
61 
62 ?>
63 <h3><?php printf(_("Manage catch-all configuration of %s"),$catch["domain"]); ?></h3>
64 <hr id="topbar"/>
65 <br />
66 
67 <?php
68 if (isset($error) && !empty($error) ) {
69  echo "<p class=\"alert alert-danger\">$error</p>";
70 }
71 
72 __("You can choose what to do with emails sent to unexisting address of this domain");
73 ?>
74 <br/><br/>
75 
76 <form action="mail_manage_catchall.php?domain_id=<?php echo $domain_id;?>" method="post" name="main" id="main">
77 <table class="tedit">
78 
79  <tr>
80  <th colspan="3"><b><?php __("No catch-all");?></b></th>
81  </tr>
82  <tr>
83  <td width="1px"><input type="radio" name="target_type" id='target_type_none' value="none" <?php if ($catch['type']=='none') {echo 'checked="checked"';}?> /></td>
84  <td colspan='2' style="width: 50%; text-align: justify"><label for='target_type_none'><?php echo __("No catch-all for this domain.");?></label></td>
85  </tr>
86 
87  <tr>
88  <th colspan="3"><b><?php __("Redirect to same address on a different domain");?></b></th>
89  </tr>
90  <tr>
91  <td width="1px"><input type="radio" name="target_type" id='target_type_domain' value="domain" <?php if ($catch['type']=='domain') {echo 'checked="checked"';}?> /></td>
92  <td style="width: 50%; text-align: justify"><label for='target_type_domain'><?php echo sprintf(_("Mails sent to john.doe@%s will be redirect to john.doe@anotherdomain.tld"),$catch['domain']);?></label></td>
93  <td>
94  <p>
95  <i><?php __("Enter the 'target' domain"); ?></i><br/>
96  <input type="text" id="target_domain" name="target_domain" value="<?php if($catch['type']=='domain') { echo substr($catch['target'],1); } ?>" placeholder="<?php __("example.tld");?>" />
97  </p>
98  <i><?php __("Or choose one of your own"); ?></i>
99  <ul>
100  <?php foreach ( $dom->enum_domains() as $d) { if ($d==$catch['domain']) {continue;} echo "<li><a href=\"javascript:set_target_domain_value('".addslashes($d)."');\">$d</a></li>"; } ?>
101  </ul>
102  </td>
103  </tr>
104 
105  <tr>
106  <th colspan="3"><b><?php __("Redirect to a specific email");?></b></th>
107  </tr>
108  <tr>
109  <td width="1px"><input type="radio" name="target_type" id='target_type_mail' value="mail" <?php if ($catch['type']=='mail') {echo 'checked="checked"';}?> /></td>
110  <td style="width: 50%; text-align: justify"><label for='target_type_mail'><?php echo sprintf(_("Mails sent to an unexisting email on '@%s' will be redirect to user@example.tld."),$catch['domain']);?></label></td>
111  <td>
112  <p>
113  <input type="text" name="target_mail" size="30" value="<?php if($catch['type']=='mail') { echo $catch['target']; } ?>" placeholder="<?php __("john.doe@example.tld");?>" />
114  </p>
115  </td>
116  </tr>
117 </table>
118 
119 <br/>
120 
121 <input type="submit" class="inb" name="submit" value="<?php __("Save"); ?>" />
122 <input type="button" class="inb" name="cancel" value="<?php __("Cancel"); ?>" onclick="window.history.go(-1);"/>
123 
124 </form>
125 
126 <script type="text/javascript">
127  function set_target_domain_value(value) {
128  $('#target_domain').val(value);
129  $('#target_type_domain').prop('checked', true);
130  }
131 </script>
132 
133 <?php include_once("foot.php"); ?>