| 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: listing of mail accounts for one domain. |
|---|
| 23 | ---------------------------------------------------------------------- |
|---|
| 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 | |
|---|
| 38 | $champs=getFields($fields); |
|---|
| 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 | $fatal=false; |
|---|
| 48 | |
|---|
| 49 | if ($domain=$dom->get_domain_byid($domain_id)) { |
|---|
| 50 | if(!($mails_list = $mail->enum_domain_mails($domain_id,$search,$offset,$count,$show_systemmails)) && $search) { |
|---|
| 51 | $error=$err->errstr(); |
|---|
| 52 | } |
|---|
| 53 | $allmails_list = $mail->enum_domain_mails($domain_id,$search,$offset,$count,'true'); |
|---|
| 54 | } else { |
|---|
| 55 | $error=$err->errstr(); |
|---|
| 56 | $fatal=true; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | if ($fatal) { |
|---|
| 60 | echo "<div class=\"error\">$error</div>"; |
|---|
| 61 | } else { |
|---|
| 62 | |
|---|
| 63 | if (!empty($error)) { echo "<p class='error'>$error</p>"; } |
|---|
| 64 | ?> |
|---|
| 65 | |
|---|
| 66 | <table><tr> |
|---|
| 67 | <?php |
|---|
| 68 | // Mail creation form |
|---|
| 69 | if ($quota->cancreate("mail")) { |
|---|
| 70 | ?> |
|---|
| 71 | <td> |
|---|
| 72 | <h3><?php __("Create a new mail account");?></h3> |
|---|
| 73 | <form method="post" action="mail_doadd.php" id="main" name="mail_create"> |
|---|
| 74 | <input type="text" class="int intleft" style="text-align: right" name="mail_arg" value="<?php ehe($mail_arg); ?>" size="32" id="mail_arg" maxlength="255" /><span id="emaildom" class="int intright"><?php echo "@".$domain; ?></span> |
|---|
| 75 | <input type="hidden" name="domain_id" value="<?php echo $domain_id;?>" /> |
|---|
| 76 | <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."));?>');" /> |
|---|
| 77 | <?php }?> |
|---|
| 78 | <span class="inb configure"><a href="mail_manage_catchall.php?domain_id=<?php echo $domain_id?>"><?php __("Manage Catch-all for this domain");?></a></span> |
|---|
| 79 | <?php if ($quota->cancreate("mail")) { ?> |
|---|
| 80 | </form> |
|---|
| 81 | </td> |
|---|
| 82 | <?php |
|---|
| 83 | } |
|---|
| 84 | ?> |
|---|
| 85 | <td valign='bottom'> |
|---|
| 86 | </td> |
|---|
| 87 | </tr> |
|---|
| 88 | </table> |
|---|
| 89 | |
|---|
| 90 | <br /> |
|---|
| 91 | <hr id="topbar"/> |
|---|
| 92 | <h3><?php printf(_("Email addresses of the domain %s"),$domain); ?> : </h3> |
|---|
| 93 | <?php |
|---|
| 94 | if (empty($allmails_list) && empty($search)) { |
|---|
| 95 | echo "<p><i>"; |
|---|
| 96 | __("No mails for this domain."); |
|---|
| 97 | echo "</i></p><br/>"; |
|---|
| 98 | } else { |
|---|
| 99 | |
|---|
| 100 | ?> |
|---|
| 101 | |
|---|
| 102 | <table class="searchtable"><tr><td> |
|---|
| 103 | <form method="get" name="formlist1" id="formlist1" action="mail_list.php"> |
|---|
| 104 | <input type="hidden" name="domain_id" value="<?php echo $domain_id; ?>" /> |
|---|
| 105 | <input type="hidden" name="offset" value="0" /> |
|---|
| 106 | <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" /> |
|---|
| 107 | </td><td> |
|---|
| 108 | <?php pager($offset,$count,$mail->total,"mail_list.php?domain_id=".$domain_id."&count=".$count."&search=".urlencode($search)."&offset=%%offset%%"); ?> |
|---|
| 109 | </td> |
|---|
| 110 | <td style="text-align:center"> |
|---|
| 111 | <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> |
|---|
| 112 | </td> |
|---|
| 113 | </form> |
|---|
| 114 | <td style="text-align:right"> |
|---|
| 115 | <form method="get" name="formlist2" id="formlist2" action="mail_list.php"> |
|---|
| 116 | <input type="hidden" name="domain_id" value="<?php echo $domain_id; ?>" /> |
|---|
| 117 | <input type="hidden" name="offset" value="0" /> |
|---|
| 118 | <?php __("Items per page:"); ?> <select name="count" class="inl" onchange="submit()"><?php eoption($counts,$count); ?></select> |
|---|
| 119 | </form> |
|---|
| 120 | </td></tr></table> |
|---|
| 121 | |
|---|
| 122 | <form method="post" action="mail_del.php"> |
|---|
| 123 | <input type="hidden" name="domain_id" value="<?php echo $domain_id; ?>" /> |
|---|
| 124 | <table class="tlist"> |
|---|
| 125 | <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> |
|---|
| 126 | <?php |
|---|
| 127 | |
|---|
| 128 | $i=0; |
|---|
| 129 | //listing of every mail of the current domain. |
|---|
| 130 | if(!empty($mails_list)) { |
|---|
| 131 | while (list($key,$val)=each($mails_list)) { |
|---|
| 132 | $grey=""; |
|---|
| 133 | ?> |
|---|
| 134 | <tr class="lst"> |
|---|
| 135 | <?php if ($val["mail_action"]=="DELETING") { $grey="grey"; ?> |
|---|
| 136 | <td colspan="3"><?php __("Deleting..."); ?></td> |
|---|
| 137 | <?php } else if ($val["mail_action"]=="DELETE") { $grey="grey"; ?> |
|---|
| 138 | <td></td> |
|---|
| 139 | <td> |
|---|
| 140 | <?php if ($val['type'] =='') { ?> |
|---|
| 141 | <div class="ina"><a href="mail_undelete.php?search=<?php ehe($search); ?>&offset=<?php ehe($offset); ?>&count=<?php ehe($count); ?>&domain_id=<?php ehe($domain_id); ?>&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> |
|---|
| 142 | <?php } // if val[type] ?> |
|---|
| 143 | </td> |
|---|
| 144 | <td><img src="images/check_no.png" alt="<?php __("Disabled"); ?>" /></td> |
|---|
| 145 | <?php } else if (!$val["type"]) { ?> |
|---|
| 146 | <td align="center"> |
|---|
| 147 | <input class="inc" type="checkbox" id="del_<?php echo $i; ?>" name="d[]" value="<?php ehe($val["id"]); ?>" /> |
|---|
| 148 | </td> |
|---|
| 149 | <td class="<?php echo $grey; ?>"> |
|---|
| 150 | <div class="ina edit"><a href="mail_edit.php?mail_id=<?php echo $val["id"] ?>"><?php __("Edit"); ?></a></div></td> |
|---|
| 151 | <td class="<?php echo $grey; ?>"><?php if ($val["enabled"] ) { ?> |
|---|
| 152 | <img src="images/check_ok.png" alt="<?php __("Enabled"); ?>" /> |
|---|
| 153 | <?php } else { ?> |
|---|
| 154 | <img src="images/check_no.png" alt="<?php __("Disabled"); ?>" /> |
|---|
| 155 | <?php } // if enabled ?> |
|---|
| 156 | </td> |
|---|
| 157 | <?php } else { ?> |
|---|
| 158 | <td colspan="3"></td> |
|---|
| 159 | <?php } ?> |
|---|
| 160 | <td class="<?php echo $grey; ?>" style="text-align:right"><?php echo $val["address"]."@".$domain ?></td> |
|---|
| 161 | <?php if ($val["type"]) { ?> |
|---|
| 162 | <td colspan="3"><?php echo $val["typedata"]; ?></td> |
|---|
| 163 | <?php } else { ?> |
|---|
| 164 | <td class="<?php echo $grey; ?>"><?php if ($val["islocal"]) echo format_size($val["used"]).( ($val["quotabytes"]==0)?'':"/".format_size($val["quotabytes"])) ; else __("No"); ?></td> |
|---|
| 165 | <td class="<?php echo $grey; ?>"><?php echo $val["recipients"]; /* TODO : if >60chars, use "..." + js close/open */ ?></td> |
|---|
| 166 | <td class="<?php echo $grey; ?>"><?php if ($val["islocal"]) { |
|---|
| 167 | 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"]); |
|---|
| 168 | } ?></td> |
|---|
| 169 | <?php } ?> |
|---|
| 170 | </tr> |
|---|
| 171 | <?php |
|---|
| 172 | $i++; |
|---|
| 173 | } |
|---|
| 174 | } |
|---|
| 175 | ?> |
|---|
| 176 | |
|---|
| 177 | </table> |
|---|
| 178 | <p><input type="submit" class="inb delete" name="submit" value="<?php __("Delete the checked email addresses"); ?>" /></p> |
|---|
| 179 | </form> |
|---|
| 180 | |
|---|
| 181 | <?php |
|---|
| 182 | } } // end if no mail for this domain |
|---|
| 183 | ?> |
|---|
| 184 | <hr/> |
|---|
| 185 | |
|---|
| 186 | <h3><?php __("Mails configuration informations");?></h3> |
|---|
| 187 | |
|---|
| 188 | <?php __("Here are some configuration informations you'll need to configure your mail application.");?> |
|---|
| 189 | <br/> |
|---|
| 190 | <br/> |
|---|
| 191 | |
|---|
| 192 | <table width='100%' class="tedit"> |
|---|
| 193 | <tr> |
|---|
| 194 | <th width='50%'> |
|---|
| 195 | <b><?php __("Outgoing mail (SMTP)"); ?></b> |
|---|
| 196 | </th> |
|---|
| 197 | <th width='50%'> |
|---|
| 198 | <b><?php __("Incoming mails"); ?></b> |
|---|
| 199 | </th> |
|---|
| 200 | </tr> |
|---|
| 201 | <tr> |
|---|
| 202 | <td valign='top'> |
|---|
| 203 | <?php __("Which protocol would you use?"); ?> |
|---|
| 204 | <ul> |
|---|
| 205 | <li><b><a href="javascript:;" onClick="$('#cfg-submission').toggle();"><?php __("Submission");?></a></b> |
|---|
| 206 | <ul id='cfg-submission'> |
|---|
| 207 | <li><b><?php __("Server name: ");?></b> <?php __($mail->srv_submission); ?></li> |
|---|
| 208 | <li><b><?php __("Username: ");?></b> <?php __("The mail address you want to access <i>(example : myuser@example.tld)</i>");?></li> |
|---|
| 209 | <li><b><?php __("Port: ");?></b> 587</li> |
|---|
| 210 | <li><b><?php __("Authentication: ");?></b><?php __("Yes")?></li> |
|---|
| 211 | <li><b><?php __("Authentication method: ");?></b><?php __("Normal password")?></li> |
|---|
| 212 | <li><b><?php __("Connection security:");?></b> STARTTLS</li> |
|---|
| 213 | </ul> |
|---|
| 214 | </li> |
|---|
| 215 | <li><b><a href="javascript:;" onClick="$('#cfg-smtp').toggle();"><?php __("SMTP");?></a></b> |
|---|
| 216 | <ul id='cfg-smtp'> |
|---|
| 217 | <li><b><?php __("Server name: ");?></b> <?php __($mail->srv_smtp); ?></li> |
|---|
| 218 | <li><b><?php __("Username: ");?></b> <?php __("The mail address you want to access <i>(example : myuser@example.tld)</i>");?></li> |
|---|
| 219 | <li><b><?php __("Port: ");?></b> 25</li> |
|---|
| 220 | <li><b><?php __("Authentication: ");?></b><?php __("Yes")?></li> |
|---|
| 221 | <li><b><?php __("Authentication method: ");?></b><?php __("Normal Password")?></li> |
|---|
| 222 | <li><b><?php __("Connection security:");?></b> STARTTLS</li> |
|---|
| 223 | </ul> |
|---|
| 224 | </li> |
|---|
| 225 | <li><b><a href="javascript:;" onClick="$('#cfg-smtps').toggle();"><?php __("SMTPS");?></a></b> |
|---|
| 226 | <ul id='cfg-smtps'> |
|---|
| 227 | <li><b><?php __("Server name: ");?></b> <?php __($mail->srv_smtps); ?></li> |
|---|
| 228 | <li><b><?php __("Username: ");?></b> <?php __("The mail address you want to access <i>(example : myuser@example.tld)</i>");?></li> |
|---|
| 229 | <li><b><?php __("Port: ");?></b> 465</li> |
|---|
| 230 | <li><b><?php __("Authentication: ");?></b><?php __("Yes")?></li> |
|---|
| 231 | <li><b><?php __("Authentication method: ");?></b><?php __("Normal Password")?></li> |
|---|
| 232 | <li><b><?php __("Connection security:");?></b> SSL</li> |
|---|
| 233 | </ul> |
|---|
| 234 | </li> |
|---|
| 235 | </ul> |
|---|
| 236 | </td> |
|---|
| 237 | <td valign='top'> |
|---|
| 238 | <?php __("Which protocol would you use?"); ?> |
|---|
| 239 | <ul> |
|---|
| 240 | <li><b><a href="javascript:;" onClick="$('#cfg-imap').toggle();"><?php __("IMAP");?></a></b> |
|---|
| 241 | <ul id='cfg-imap'> |
|---|
| 242 | <li><b><?php __("Server name: ");?></b> <?php __($mail->srv_imap); ?></li> |
|---|
| 243 | <li><b><?php __("Port: ");?></b> 143</li> |
|---|
| 244 | <li><b><?php __("Authentication: ");?></b><?php __("Yes")?></li> |
|---|
| 245 | <li><b><?php __("Authentication method: ");?></b><?php __("Normal password")?></li> |
|---|
| 246 | <li><b><?php __("Connection security:");?></b> STARTTLS</li> |
|---|
| 247 | </ul> |
|---|
| 248 | </li> |
|---|
| 249 | |
|---|
| 250 | <li><b><a href="javascript:;" onClick="$('#cfg-imaps').toggle();"><?php __("IMAPS");?></a></b> |
|---|
| 251 | <ul id='cfg-imaps'> |
|---|
| 252 | <li><b><?php __("Server name: ");?></b> <?php __($mail->srv_imaps); ?></li> |
|---|
| 253 | <li><b><?php __("Port: ");?></b> 993</li> |
|---|
| 254 | <li><b><?php __("Authentication: ");?></b><?php __("Yes")?></li> |
|---|
| 255 | <li><b><?php __("Authentication method: ")?></b><?php __("Normal password")?></li> |
|---|
| 256 | <li><b><?php __("Connection security:");?></b> SSL</li> |
|---|
| 257 | </ul> |
|---|
| 258 | </li> |
|---|
| 259 | |
|---|
| 260 | <li><b><a href="javascript:;" onClick="$('#cfg-pop3').toggle();"><?php __("POP3");?></a></b> |
|---|
| 261 | <ul id='cfg-pop3'> |
|---|
| 262 | <li><b><?php __("Server name: ");?></b> <?php __($mail->srv_pop3); ?></li> |
|---|
| 263 | <li><b><?php __("Port: ");?></b> 110</li> |
|---|
| 264 | <li><b><?php __("Authentication: ");?></b><?php __("Yes")?></li> |
|---|
| 265 | <li><b><?php __("Authentication method: ");?></b><?php __("Normal password")?></li> |
|---|
| 266 | <li><b><?php __("Connection security:");?></b> STARTTLS</li> |
|---|
| 267 | </ul> |
|---|
| 268 | </li> |
|---|
| 269 | |
|---|
| 270 | <li><b><a href="javascript:;" onClick="$('#cfg-pop3s').toggle();"><?php __("POP3S");?></a></b> |
|---|
| 271 | <ul id='cfg-pop3s'> |
|---|
| 272 | <li><b><?php __("Server name: ");?></b> <?php __($mail->srv_pop3s); ?></li> |
|---|
| 273 | <li><b><?php __("Port: ");?></b> 995</li> |
|---|
| 274 | <li><b><?php __("Authentication: ");?></b><?php __("Yes")?></li> |
|---|
| 275 | <li><b><?php __("Authentication method: ");?></b><?php __("Normal password")?></li> |
|---|
| 276 | <li><b><?php __("Connection security:");?></b> SSL</li> |
|---|
| 277 | </ul> |
|---|
| 278 | </li> |
|---|
| 279 | </ul> |
|---|
| 280 | </td> |
|---|
| 281 | </tr> |
|---|
| 282 | </table> |
|---|
| 283 | |
|---|
| 284 | <script type="text/javascript"> |
|---|
| 285 | $('#cfg-submission').toggle(); |
|---|
| 286 | $('#cfg-smtp').toggle(); |
|---|
| 287 | $('#cfg-smtps').toggle(); |
|---|
| 288 | $('#cfg-imap').toggle(); |
|---|
| 289 | $('#cfg-imaps').toggle(); |
|---|
| 290 | $('#cfg-pop3').toggle(); |
|---|
| 291 | $('#cfg-pop3s').toggle(); |
|---|
| 292 | </script> |
|---|
| 293 | |
|---|
| 294 | |
|---|
| 295 | <?php include_once("foot.php"); ?> |
|---|