2012-10-20 13:16:14 +00:00
< ? php
/*
----------------------------------------------------------------------
AlternC - Web Hosting System
Copyright ( C ) 2000 - 2012 by the AlternC Development Team .
https :// alternc . org /
----------------------------------------------------------------------
LICENSE
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License ( GPL )
as published by the Free Software Foundation ; either version 2
of the License , or ( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
To read the license please visit http :// www . gnu . org / copyleft / gpl . html
----------------------------------------------------------------------
Purpose of file : Manage catch - all
----------------------------------------------------------------------
*/
require_once ( " ../class/config.php " );
include_once ( " head.php " );
$fields = array (
2016-05-23 13:03:13 +00:00
" domain_id " => array ( " request " , " integer " , null ),
2012-10-20 13:16:14 +00:00
" target_type " => array ( " post " , " string " , null ),
" target_mail " => array ( " post " , " string " , null ),
" target_domain " => array ( " post " , " string " , null ),
);
getFields ( $fields );
if ( is_null ( $domain_id )) {
2017-08-15 14:11:57 +00:00
$msg -> raise ( " Error " , " mail " , _ ( " Problem with the domain " ));
include_once ( " mail_list.php " );
2012-10-20 13:16:14 +00:00
exit ();
}
if ( ! is_null ( $target_type )) {
switch ( $target_type ) {
case " none " :
2017-08-15 14:11:57 +00:00
if ( $mail -> catchall_del ( $domain_id ))
$msg -> raise ( " Ok " , " mail " , _ ( " Catchall successfully deleted " ));
2015-04-22 15:32:40 +00:00
require_once ( " mail_list.php " );
exit ();
2012-10-20 13:16:14 +00:00
break ;
case " domain " :
2015-04-22 15:32:40 +00:00
if ( $mail -> catchall_set ( $domain_id , $target_domain )) {
2017-08-15 14:11:57 +00:00
$msg -> raise ( " Ok " , " mail " , _ ( " Catchall successfully updated " ));
2015-04-22 15:32:40 +00:00
require_once ( " mail_list.php " );
exit ();
}
2012-10-20 13:16:14 +00:00
break ;
case " mail " :
2015-04-22 15:32:40 +00:00
if ( $mail -> catchall_set ( $domain_id , $target_mail )) {
2017-08-15 14:11:57 +00:00
$msg -> raise ( " Ok " , " mail " , _ ( " Catchall successfully updated " ));
2015-04-22 15:32:40 +00:00
require_once ( " mail_list.php " );
exit ();
}
2012-10-20 13:16:14 +00:00
break ;
default :
2012-10-29 15:25:17 +00:00
$error = _ ( " Unknown target type " );
2012-10-20 13:16:14 +00:00
}
}
$catch = $mail -> catchall_getinfos ( $domain_id );
?>
< h3 >< ? php printf ( _ ( " Manage catch-all configuration of %s " ), $catch [ " domain " ]); ?> </h3>
< hr id = " topbar " />
< br />
< ? php
2017-08-15 14:11:57 +00:00
echo $msg -> msg_html_all ();
2012-10-20 13:16:14 +00:00
2012-10-29 15:25:17 +00:00
__ ( " You can choose what to do with emails sent to unexisting address of this domain " );
2012-10-20 13:16:14 +00:00
?>
< br />< br />
< form action = " mail_manage_catchall.php?domain_id=<?php echo $domain_id ;?> " method = " post " name = " main " id = " main " >
2016-10-27 14:32:49 +00:00
< ? php csrf_get (); ?>
2012-10-20 13:16:14 +00:00
< table class = " tedit " >
< tr >
< th colspan = " 3 " >< b >< ? php __ ( " No catch-all " ); ?> </b></th>
</ tr >
< tr >
2013-04-19 12:39:51 +00:00
< td width = " 1px " >< input type = " radio " name = " target_type " id = 'target_type_none' value = " none " < ? php if ( $catch [ 'type' ] == 'none' ) { echo 'checked="checked"' ;} ?> /></td>
< td colspan = '2' style = " width: 50%; text-align: justify " >< label for = 'target_type_none' >< ? php echo __ ( " No catch-all for this domain. " ); ?> </label></td>
2012-10-20 13:16:14 +00:00
</ tr >
< tr >
< th colspan = " 3 " >< b >< ? php __ ( " Redirect to same address on a different domain " ); ?> </b></th>
</ tr >
< tr >
2013-04-19 12:39:51 +00:00
< td width = " 1px " >< input type = " radio " name = " target_type " id = 'target_type_domain' value = " domain " < ? php if ( $catch [ 'type' ] == 'domain' ) { echo 'checked="checked"' ;} ?> /></td>
< 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>
2012-10-20 13:16:14 +00:00
< td >
< p >
2013-02-08 08:00:07 +00:00
< i >< ? php __ ( " Enter the 'target' domain " ); ?> </i><br/>
2016-05-22 18:14:26 +00:00
< input type = " text " id = " target_domain " name = " target_domain " value = " <?php if( $catch['type'] =='domain') { ehe(substr( $catch['target'] ,1)); } ?> " placeholder = " <?php __( " example . tld " );?> " />
2013-02-08 08:00:07 +00:00
</ p >
2013-02-08 08:10:39 +00:00
< i >< ? php __ ( " Or choose one of your own " ); ?> </i>
2012-10-20 13:16:14 +00:00
< ul >
2012-10-20 14:44:48 +00:00
< ? 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> " ; } ?>
2012-10-20 13:16:14 +00:00
</ ul >
</ td >
</ tr >
< tr >
2012-10-29 15:25:17 +00:00
< th colspan = " 3 " >< b >< ? php __ ( " Redirect to a specific email " ); ?> </b></th>
2012-10-20 13:16:14 +00:00
</ tr >
< tr >
2016-05-22 18:14:26 +00:00
< td width = " 1px " >< input type = " radio " name = " target_type " id = 'target_type_mail' value = " mail " < ? php if ( $catch [ 'type' ] == 'mail' ) { echo 'checked="checked"' ; } ?> /></td>
2013-04-19 12:39:51 +00:00
< 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>
2012-10-20 13:16:14 +00:00
< td >
< p >
2016-05-22 18:14:26 +00:00
< input type = " text " name = " target_mail " size = " 30 " value = " <?php if( $catch['type'] =='mail') { ehe( $catch['target'] ); } ?> " placeholder = " <?php __( " john . doe @ example . tld " );?> " />
2012-10-20 13:16:14 +00:00
</ p >
</ td >
</ tr >
2013-02-08 08:10:39 +00:00
</ table >
2012-10-20 13:16:14 +00:00
2013-02-08 08:10:39 +00:00
< br />
< input type = " submit " class = " inb " name = " submit " value = " <?php __( " Save " ); ?> " />
< input type = " button " class = " inb " name = " cancel " value = " <?php __( " Cancel " ); ?> " onclick = " window.history.go(-1); " />
2012-10-20 13:16:14 +00:00
</ form >
2013-02-08 08:10:39 +00:00
2012-10-20 13:16:14 +00:00
< script type = " text/javascript " >
function set_target_domain_value ( value ) {
$ ( '#target_domain' ) . val ( value );
2012-10-20 14:41:45 +00:00
$ ( '#target_type_domain' ) . prop ( 'checked' , true );
2012-10-20 13:16:14 +00:00
}
</ script >
< ? php include_once ( " foot.php " ); ?>