Alternc  latest
Alternc logiel libre pour l'hébergement
mail_list.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  * List the email account of a domain
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  "mail_arg" => array ("request", "integer", ""), // from mail_add.php in case of error
31  "domain_id" => array ("request", "integer", ""),
32  "show_systemmails" => array ("request", "integer", ""),
33  "search" => array ("request", "string", ""),
34  "offset" => array ("request", "integer", 0),
35  "count" => array ("request", "integer", 50),
36  );
37 
39 
40 $counts=array("10" => "10", "20" => "20", "30" => "30", "50" => "50", "100" => "100", "200" => "200", "500" => "500", "1000" => "1000");
41 
42 if(!$domain_id ) {
43  include("main.php");
44  exit();
45 }
46 
47 if ($domain=$dom->get_domain_byid($domain_id)) {
48  $mails_list = $mail->enum_domain_mails($domain_id,$search,$offset,$count,$show_systemmails);
49  $allmails_list = $mail->enum_domain_mails($domain_id,$search,$offset,$count,'true');
50 }
51 ?>
52 
53 <table>
54  <tr>
55  <td colspan=2>
56 <?php if ($quota->cancreate("mail")) {
57  echo '<h3>'._("Create a new mail account")."</h3>";
58 } else {
59  echo '<h3>'._("Manage Catch-all")."</h3>";
60 }
61 
62 echo $msg->msg_html_all(true, true);
63 ?>
64  </td>
65  </tr>
66  <tr>
67  <td>
68 <?php if ($quota->cancreate("mail")) { ?>
69  <form method="post" action="mail_doadd.php" id="main" name="mail_create">
70  <?php csrf_get(); ?>
71  <input type="text" class="int intleft" style="text-align: right" name="mail_arg" value="<?php ehe($mail_arg); ?>" size="24" id="mail_arg" maxlength="255" /><span id="emaildom" class="int intright"><?php echo "@".$domain; ?></span>
72  <input type="hidden" name="domain_id" value="<?php ehe($domain_id); ?>" />
73  <input type="submit" name="submit" class="inb add" value="<?php __("Create this email address"); ?>" onClick="return false_if_empty('mail_arg', '<?php echo addslashes(_("Can't have empty mail."));?>');" />
74  </form>
75 <?php } // $quota->cancreate("mail") ?>
76  </td>
77  <td>
78  <span class="inb settings" valign='bottom'><a href="mail_manage_catchall.php?domain_id=<?php echo $domain_id?>"><?php __("Manage Catch-all for this domain");?></a></span>
79  </td>
80  </tr>
81 </table>
82 
83 <br />
84 <hr id="topbar"/>
85 <h3><?php printf(_("Email addresses of the domain %s"),$domain); ?> : </h3>
86 <?php
87 if (empty($allmails_list) && empty($search)) {
88  $msg->raise("ERROR", 'mail', _("No mails for this domain."));
89  echo $msg->msg_html_all();
90 } else {
91 
92 ?>
93 
94 <table class="searchtable"><tr><td>
95 <form method="get" name="formlist1" id="formlist1" action="mail_list.php">
96 <input type="hidden" name="domain_id" value="<?php ehe($domain_id); ?>" />
97 <input type="hidden" name="offset" value="0" />
98 <span class="int intleft"><img alt="<?php __("Search"); ?>" title="<?php __("Search"); ?>" src="/images/search.png" style="vertical-align: middle"/> </span><input type="text" name="search" value="<?php ehe($search); ?>" size="20" maxlength="64" class="int intright" />
99 </td><td>
100 <?php pager($offset,$count,$mail->total,"mail_list.php?domain_id=".$domain_id."&amp;count=".$count."&amp;search=".urlencode($search)."&amp;offset=%%offset%%"); ?>
101 </td>
102 <td style="text-align:center">
103  <input type="checkbox" id="show_systemmails" name="show_systemmails" <?php if($show_systemmails) { echo "checked"; } ?> value="1" onclick="document.getElementById('formlist1').submit();" /><label for="show_systemmails" ><?php __("Show system emails");?></label>
104 </td>
105 </form>
106 <td style="text-align:right">
107 <form method="get" name="formlist2" id="formlist2" action="mail_list.php">
108  <input type="hidden" name="domain_id" value="<?php ehe($domain_id); ?>" />
109  <input type="hidden" name="offset" value="0" />
110  <?php __("Items per page:"); ?> <select name="count" class="inl" onchange="submit()"><?php eoption($counts,$count); ?></select>
111 </form>
112 </td></tr></table>
113 
114 <form method="post" action="mail_del.php">
115  <?php csrf_get(); ?>
116  <input type="hidden" name="domain_id" value="<?php ehe($domain_id); ?>" />
117 <table class="tlist">
118 <tr><th></th><th></th><th><?php __("Enabled");?></th><th style="text-align:right"><?php __("Address"); ?></th><th><?php __("Pop/Imap"); ?></th><th><?php __("Other recipients"); ?></th><th><?php __("Last login time"); ?></th></tr>
119 <?php
120 
121 $i=0;
122 //listing of every mail of the current domain.
123 if(!empty($mails_list)) {
124  while (list($key,$val)=each($mails_list)) {
125  $grey="";
126  ?>
127  <tr class="lst">
128  <?php if ($val["mail_action"]=="DELETING") { $grey="grey"; ?>
129  <td colspan="3"><?php __("Deleting..."); ?></td>
130  <?php } else if ($val["mail_action"]=="DELETE") { $grey="grey"; ?>
131  <td></td>
132  <td>
133  <?php if ($val['type'] =='') { ?>
134  <div class="ina"><a href="mail_undelete.php?search=<?php ehe($search); ?>&amp;offset=<?php ehe($offset); ?>&amp;count=<?php ehe($count); ?>&amp;domain_id=<?php ehe($domain_id); ?>&amp;mail_id=<?php echo $val["id"] ?>" title="<?php __("This email will be deleted soon. You may still be able to undelete it by clicking here"); ?>"><img src="images/undelete.png" alt="<?php __("Undelete"); ?>" /><?php __("Undelete"); ?></a></div>
135  <?php } // if val[type] ?>
136  </td>
137  <td><img src="images/check_no.png" alt="<?php __("Disabled"); ?>" /></td>
138  <?php } else if (!$val["type"]) { ?>
139  <td align="center">
140  <input class="inc" type="checkbox" id="del_<?php ehe($i); ?>" name="d[]" value="<?php ehe($val["id"]); ?>" />
141  </td>
142  <td class="<?php echo $grey; ?>">
143  <div class="ina edit"><a href="mail_edit.php?mail_id=<?php echo $val["id"] ?>"><?php __("Edit"); ?></a></div></td>
144  <td class="<?php echo $grey; ?>"><?php if ($val["enabled"] ) { ?>
145  <img src="images/check_ok.png" alt="<?php __("Enabled"); ?>" />
146  <?php } else { ?>
147  <img src="images/check_no.png" alt="<?php __("Disabled"); ?>" />
148  <?php } // if enabled ?>
149  </td>
150  <?php } else { ?>
151  <td colspan="3"></td>
152  <?php } ?>
153  <td class="<?php echo $grey; ?>" style="text-align:right"><?php echo $val["address"]."@".$domain ?></td>
154  <?php if ($val["type"]) { ?>
155  <td colspan="3"><?php echo $val["typedata"]; ?></td>
156  <?php } else { ?>
157  <td class="<?php echo $grey; ?>"><?php if ($val["islocal"]) echo format_size($val["used"]).( ($val["quotabytes"]==0)?'':"/".format_size($val["quotabytes"])) ; else __("No"); ?></td>
158  <td class="<?php echo $grey; ?>"><?php echo $val["recipients"]; /* TODO : if >60chars, use "..." + js close/open */ ?></td>
159  <td class="<?php echo $grey; ?>"><?php if ($val["islocal"]) {
160 if (date("Y-m-d")==substr($val["lastlogin"],0,10)) echo substr($val["lastlogin"],11,5); else if (substr($val["lastlogin"],0,10)=="0000-00-00") __("Never"); else echo format_date(_('%3$d-%2$d-%1$d'),$val["lastlogin"]);
161 } ?></td>
162  <?php } ?>
163  </tr>
164  <?php
165  $i++;
166  }
167 }
168 ?>
169 
170 </table>
171  <p><input type="submit" class="inb delete" name="submit" value="<?php __("Delete the checked email addresses"); ?>" /></p>
172 </form>
173 
174 <?php
175  } // end if no mail for this domain
176 ?>
177 <hr/>
178 
179 <h3><?php __("Mails configuration information");?></h3>
180 
181 <?php __("Here are some configuration information you will need to configure your mail application.");?>
182 <br/>
183 <br/>
184 
185 <div id="tabs-mailhelp">
186 
187 <ul>
188  <li class="help"><a href="#tabs-mailhelp-out"><?php __("Outgoing mail (SMTP)"); ?></a></li>
189  <li class="help"><a href="#tabs-mailhelp-in"><?php __("Incoming mail"); ?></a></li>
190 </ul>
191 
192 <div id="tabs-mailhelp-out">
193 
194  <?php __("Which protocol shall you use?"); ?>
195  <div id="accordion-mailout">
196  <?php if ($mail->srv_postfix) { ?>
197  <h4><?php __("Submission");?></h4>
198  <div>
199  <ul>
200  <li><b><?php __("Server name: ");?></b> <?php __($mail->srv_postfix); ?></li>
201  <li><b><?php __("Username: ");?></b> <?php __("The mail address you want to access <i>(example : myuser@example.tld)</i>");?></li>
202  <li><b><?php __("Port: ");?></b> 587</li>
203  <li><b><?php __("Authentication: ");?></b><?php __("Yes")?></li>
204  <li><b><?php __("Authentication method: ");?></b><?php __("Normal password")?></li>
205  <li><b><?php __("Connection security:");?></b> STARTTLS</li>
206  </ul>
207  </div>
208  <?php } ?>
209  <?php if ($mail->srv_postfix) { ?>
210  <h4><?php __("SMTP");?></h4>
211  <div>
212  <ul>
213  <li><b><?php __("Server name: ");?></b> <?php __($mail->srv_postfix); ?></li>
214  <li><b><?php __("Username: ");?></b> <?php __("The mail address you want to access <i>(example : myuser@example.tld)</i>");?></li>
215  <li><b><?php __("Port: ");?></b> 25</li>
216  <li><b><?php __("Authentication: ");?></b><?php __("Yes")?></li>
217  <li><b><?php __("Authentication method: ");?></b><?php __("Normal Password")?></li>
218  <li><b><?php __("Connection security:");?></b> STARTTLS</li>
219  </ul>
220  </div>
221  <?php } ?>
222  <?php if ($mail->srv_postfix) { ?>
223  <h4><?php __("SMTPS");?></h4>
224  <div>
225  <ul>
226  <li><b><?php __("Server name: ");?></b> <?php __($mail->srv_postfix); ?></li>
227  <li><b><?php __("Username: ");?></b> <?php __("The mail address you want to access <i>(example : myuser@example.tld)</i>");?></li>
228  <li><b><?php __("Port: ");?></b> 465</li>
229  <li><b><?php __("Authentication: ");?></b><?php __("Yes")?></li>
230  <li><b><?php __("Authentication method: ");?></b><?php __("Normal Password")?></li>
231  <li><b><?php __("Connection security:");?></b> SSL</li>
232  </ul>
233  </div>
234  <?php } ?>
235  </div><!-- accordion-mailout -->
236 
237 </div><!-- tabs-mailhelp-out -->
238 
239 <div id="tabs-mailhelp-in">
240 
241  <?php __("Which protocol shall you use?"); ?>
242  <div id="accordion-mailin">
243  <h4><?php __("IMAP");?></h4>
244  <div>
245  <ul>
246  <li><b><?php __("Server name: ");?></b> <?php __($mail->srv_dovecot); ?></li>
247  <li><b><?php __("Port: ");?></b> 143</li>
248  <li><b><?php __("Authentication: ");?></b><?php __("Yes")?></li>
249  <li><b><?php __("Authentication method: ");?></b><?php __("Normal password")?></li>
250  <li><b><?php __("Connection security:");?></b> STARTTLS</li>
251  </ul>
252  </div>
253 
254  <h4><?php __("IMAPS");?></h4>
255  <div>
256  <ul>
257  <li><b><?php __("Server name: ");?></b> <?php __($mail->srv_dovecot); ?></li>
258  <li><b><?php __("Port: ");?></b> 993</li>
259  <li><b><?php __("Authentication: ");?></b><?php __("Yes")?></li>
260  <li><b><?php __("Authentication method: ")?></b><?php __("Normal password")?></li>
261  <li><b><?php __("Connection security:");?></b> SSL</li>
262  </ul>
263  </div>
264 
265  <h4><?php __("POP3");?></h4>
266  <div>
267  <ul>
268  <li><b><?php __("Server name: ");?></b> <?php __($mail->srv_dovecot); ?></li>
269  <li><b><?php __("Port: ");?></b> 110</li>
270  <li><b><?php __("Authentication: ");?></b><?php __("Yes")?></li>
271  <li><b><?php __("Authentication method: ");?></b><?php __("Normal password")?></li>
272  <li><b><?php __("Connection security:");?></b> STARTTLS</li>
273  </ul>
274  </div>
275 
276  <h4><?php __("POP3S");?></h4>
277  <div>
278  <ul>
279  <li><b><?php __("Server name: ");?></b> <?php __($mail->srv_dovecot); ?></li>
280  <li><b><?php __("Port: ");?></b> 995</li>
281  <li><b><?php __("Authentication: ");?></b><?php __("Yes")?></li>
282  <li><b><?php __("Authentication method: ");?></b><?php __("Normal password")?></li>
283  <li><b><?php __("Connection security:");?></b> SSL</li>
284  </ul>
285  </div>
286  </div>
287 </div><!-- tabs-mailhelp-in -->
288 </div><!-- tabs-mailhelp -->
289 
290 <script type="text/javascript">
291 
292  $(function() {
293  $( "#accordion-mailout" ).accordion({
294  collapsible: true, active: false, header: "h4", heightStyle: "content"
295  });
296  });
297 
298  $(function() {
299  $( "#accordion-mailin" ).accordion({
300  collapsible: true, active: false, header: "h4", heightStyle: "content"
301  });
302  });
303 
304 
305 $(function() {$( "#tabs-mailhelp" ).tabs();});
306 
307 </script>
308 
309 
310 <?php include_once("foot.php"); ?>
exit
Definition: adm_doadd.php:70
$msg
Definition: bootstrap.php:75
d($mess)
Debug function that print infos.
Definition: do_actions.php:75
$domain
Definition: dom_import.php:36
ehe($str, $display=TRUE)
Echo the HTMLSpecialChars version of a value.
Definition: functions.php:647
__($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
$champs
Definition: mail_list.php:38
$counts
Definition: mail_list.php:40
$fields
List the email account of a domain.
Definition: mail_list.php:29
$admin enabled
Definition: newone.php:38
$i
$val
Definition: tempovars.php:15
$dom
Definition: whois_test.php:10