Alternc  3.2
Alternc logiel libre pour l'hébergement
 All Data Structures Namespaces Files Functions Variables Pages
mail_doedit.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: Edit mail account settings
23  ----------------------------------------------------------------------
24 */
25 
26 
27 require_once("../class/config.php");
28 
29 $fields = array (
30  "mail_id" =>array ("request","integer",""),
31  "pass" => array ("request","string",""),
32  "passconf" => array("request","string",""),
33  "quotamb" => array("request","integer",0),
34  "enabled" => array("request","boolean",true),
35  "islocal" => array("request","boolean",true),
36  "recipients" => array("request","string",""),
37  );
38 
40 
41 $isedit=true; // if we go back to edit, it will know ;)
42 $error="";
43 
44 // We check that email first ... so that we can compare its status with our ...
45 if (!$res=$mail->get_details($mail_id)) {
46  $error=$err->errstr();
47  include("main.php");
48  exit();
49 } else {
50 
51 
52  /*
53  * checking the password
54  */
55  if(isset($pass) && $pass != ""){
56  if($pass != $passconf){
57  $error = _("Passwords do not match");
58  include ("mail_edit.php");
59  exit();
60  } else {
61  if (!$mail->set_passwd($mail_id,$pass)) { /* SET THE PASSWORD */
62  $error=$err->errstr();
63  include ("mail_edit.php");
64  exit();
65  } else {
66  $error.=$err->errstr()."<br />";
67  }
68  }
69  }
70 
71 
72  /*
73  * now the enable/disable status
74  */
75  if ($res["enabled"] && !$enabled) {
76  if (!$mail->disable($mail_id)) { /* DISABLE */
77  $error=$err->errstr();
78  include ("mail_edit.php");
79  exit();
80  } else {
81  $error.=$err->errstr()."<br />";
82  }
83  }
84  if (!$res["enabled"] && $enabled) {
85  if (!$mail->enable($mail_id)) { /* ENABLE */
86  $error=$err->errstr();
87  include ("mail_edit.php");
88  exit();
89  } else {
90  $error.=$err->errstr()."<br />";
91  }
92  }
93 
94 
95  /*
96  * now the islocal + quota + recipients
97  */
98  if (!$mail->set_details($mail_id,$islocal,$quotamb,$recipients)) { /* SET OTHERS */
99  $error=$err->errstr();
100  include ("mail_edit.php");
101  exit();
102  } else {
103  $error.=$err->errstr()."<br />";
104  }
105 
106 
107  /*
108  * Other elements by hooks
109  */
110  $rh=$hooks->invoke("mail_edit_post",array($mail_id));
111  if (in_array(false,$res,true)) {
112  include ("mail_edit.php");
113  exit();
114  } else {
115  foreach($rh as $h) if ($h) $error.=$h."<br />";
116  }
117 
118 }
119 
120 if (!$error || !trim($error,"<br />")) $error=_("Your email has been edited successfully");
121 
122 $_REQUEST["domain_id"]=$dom->get_domain_byname($res["domain"]);
123 include("mail_list.php");
124