Alternc  latest
Alternc logiel libre pour l'hébergement
mail_manage_catchall.php
Go to the documentation of this file.
1 <?php
2 /*
3  ----------------------------------------------------------------------
4  LICENSE
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License (GPL)
8  as published by the Free Software Foundation; either version 2
9  of the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  To read the license please visit http://www.gnu.org/copyleft/gpl.html
17  ----------------------------------------------------------------------
18 */
19 
20 /**
21  * Manages the catch-all account of a domain for a user
22  *
23  * @copyright AlternC-Team 2000-2017 https://alternc.com/
24  */
25 
26  require_once("../class/config.php");
27 include_once("head.php");
28 
29 $fields = array (
30  "domain_id" => array("request","integer",null),
31  "target_type" => array("post", "string", null),
32  "target_mail" => array("post", "string", null),
33  "target_domain" => array("post", "string", null),
34 );
36 
37 if (is_null($domain_id)) {
38  $msg->raise("ERROR", "mail", _("Problem with the domain"));
39  include_once("mail_list.php");
40  exit();
41 }
42 
43 if (!is_null($target_type)) {
44  switch ($target_type) {
45  case "none":
46  if ($mail->catchall_del($domain_id))
47  $msg->raise("INFO", "mail", _("Catchall successfully deleted"));
48 
49  require_once("mail_list.php");
50  exit();
51  break;
52  case "domain":
53  if ($mail->catchall_set($domain_id, $target_domain)) {
54  $msg->raise("INFO", "mail", _("Catchall successfully updated"));
55  require_once("mail_list.php");
56  exit();
57  }
58  break;
59  case "mail":
60  if ($mail->catchall_set($domain_id, $target_mail)) {
61  $msg->raise("INFO", "mail", _("Catchall successfully updated"));
62  require_once("mail_list.php");
63  exit();
64  }
65  break;
66  default:
67  $error=_("Unknown target type");
68  }
69 }
70 
71 $catch=$mail->catchall_getinfos($domain_id);
72 
73 ?>
74 <h3><?php printf(_("Manage catch-all configuration of %s"),$catch["domain"]); ?></h3>
75 <hr id="topbar"/>
76 <br />
77 
78 <?php
79 echo $msg->msg_html_all();
80 
81 __("You can choose what to do with emails sent to unexisting address of this domain");
82 ?>
83 <br/><br/>
84 
85 <form action="mail_manage_catchall.php?domain_id=<?php echo $domain_id;?>" method="post" name="main" id="main">
86  <?php csrf_get(); ?>
87 <table class="tedit">
88 
89  <tr>
90  <th colspan="3"><b><?php __("No catch-all");?></b></th>
91  </tr>
92  <tr>
93  <td width="1px"><input type="radio" name="target_type" id='target_type_none' value="none" <?php if ($catch['type']=='none') {echo 'checked="checked"';}?> /></td>
94  <td colspan='2' style="width: 50%; text-align: justify"><label for='target_type_none'><?php echo __("No catch-all for this domain.");?></label></td>
95  </tr>
96 
97  <tr>
98  <th colspan="3"><b><?php __("Redirect to same address on a different domain");?></b></th>
99  </tr>
100  <tr>
101  <td width="1px"><input type="radio" name="target_type" id='target_type_domain' value="domain" <?php if ($catch['type']=='domain') {echo 'checked="checked"';}?> /></td>
102  <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>
103  <td>
104  <p>
105  <i><?php __("Enter the 'target' domain"); ?></i><br/>
106  <input type="text" id="target_domain" name="target_domain" value="<?php if($catch['type']=='domain') { ehe(substr($catch['target'],1)); } ?>" placeholder="<?php __("example.tld");?>" />
107  </p>
108  <i><?php __("Or choose one of your own"); ?></i>
109  <ul>
110  <?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>"; } ?>
111  </ul>
112  </td>
113  </tr>
114 
115  <tr>
116  <th colspan="3"><b><?php __("Redirect to a specific email");?></b></th>
117  </tr>
118  <tr>
119  <td width="1px"><input type="radio" name="target_type" id='target_type_mail' value="mail" <?php if ($catch['type']=='mail') { echo 'checked="checked"'; } ?> /></td>
120  <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>
121  <td>
122  <p>
123  <input type="text" name="target_mail" size="30" value="<?php if($catch['type']=='mail') { ehe($catch['target']); } ?>" placeholder="<?php __("john.doe@example.tld");?>" />
124  </p>
125  </td>
126  </tr>
127 </table>
128 
129 <br/>
130 
131 <input type="submit" class="inb" name="submit" value="<?php __("Save"); ?>" />
132 <input type="button" class="inb" name="cancel" value="<?php __("Cancel"); ?>" onclick="window.history.go(-1);"/>
133 
134 </form>
135 
136 <script type="text/javascript">
137  function set_target_domain_value(value) {
138  $('#target_domain').val(value);
139  $('#target_type_domain').prop('checked', true);
140  }
141 </script>
142 
143 <?php include_once("foot.php"); ?>
exit
Definition: adm_doadd.php:70
$msg
Definition: bootstrap.php:75
$d
__($str)
Definition: functions.php:404
getFields($fields, $requestOnly=false)
Get the Fields of the posted form from $_REQUEST or POST or GET and check their type.
Definition: functions.php:688
csrf_get($return=false)
Give a new CSRF uniq token for a form the session must be up since the CSRF is linked to the session ...
Definition: functions.php:1159
if(is_null($domain_id)) if(!is_null($target_type)) $catch
$fields
Manages the catch-all account of a domain for a user.
$error
Definition: ssl_delete.php:45
$dom
Definition: whois_test.php:10