function relayhost_save(){ $main=new main_cf(); $tpl=new templates(); $stunnel=new stunnel4(); $continue=true; $main->smtp_sasl_password_maps_enable_2(); $localport=$stunnel->main_array["postfix_relayhost"]["accept"]; writelogs("Saving [127.0.0.1]:$localport -> {$_GET["username"]}",__FUNCTION__,__FILE__,__LINE__); $main->main_array["relayhost"]="[127.0.0.1]:$localport"; $main->save_conf(); $sock=new sockets(); $sock->SET_INFO("PostfixRelayHost","[127.0.0.1]:$localport"); $sock->getFrameWork("cmd.php?postfix-relayhost=yes"); if($_GET["username"]==null){$continue=false;} if($_GET["password"]==null){$continue=false;} $saslpswd=new smtp_sasl_password_maps(); if($continue){ writelogs("UPDATE [127.0.0.1]:$localport",__FUNCTION__,__FILE__,__LINE__); if(!$saslpswd->add("[127.0.0.1]:$localport",$_GET["username"],$_GET["password"])){ echo $tpl->javascript_parse_text("{err_sasl_saveldap}<br>$saslpswd->ldap_infos"); return; } $sock->SET_INFO("smtp_sender_dependent_authentication",1); $sock->getFrameWork("cmd.php?postfix-hash-senderdependent=yes"); $sock->getFrameWork("cmd.php?postfix-smtp-sasl=yes"); }else{ writelogs("Delete [127.0.0.1]:$localport",__FUNCTION__,__FILE__,__LINE__); $saslpswd->delete("[127.0.0.1]:$localport"); } }
function main_fetchmail_build(){ include_once('ressources/class.user.inc'); include_once('ressources/class.main_cf.inc'); include_once('ressources/class.fetchmail.inc'); $failed=false; $isp_address_mail=$_GET["isp_address_mail"]; $isp_pop3_server=$_GET["isp_pop3_server"]; $isp_smtp_server=$_GET["isp_smtp_server"]; $isp_account=$_GET["isp_account"]; $isp_password=$_GET["isp_password"]; $local_email=$_GET["local_email"]; $local_password=$_GET["local_password"]; $isp_smtp_account=$_GET["isp_smtp_account"]; $isp_smtp_password=$_GET["isp_smtp_password"]; $relay_server=$_GET["relay_server"]; if($local_email==null){ echo main_fetchmail_build_results(true,'local mail (False)'); exit; } $ldap=new clladp(); writelogs("i try to found if user exists",__FUNCTION__,__FILE__); $uid=$ldap->uid_from_email($local_email); if($uid<>null){ $user=new user($local_email); $ou=$user->ou; }else{ writelogs("no user found, create it",__FUNCTION__,__FILE__); $tb=explode("@",$local_email); $local_domain=$tb[1]; $user=new user($tb[0]); $ou=$ldap->ou_by_smtp_domain($local_domain); if($ou==null){ $ou=$local_domain; writelogs("Adding new organization $ou",__FUNCTION__,__FILE__); $ldap->AddOrganization($ou); } } writelogs("Creating user",__FUNCTION__,__FILE__); $user=new user($local_email); $user->mail=$local_email; $user->password=$local_password; $user->ou=$ou; $user->SenderCanonical=$isp_address_mail; if(!$user->add_user()){ echo main_fetchmail_build_results(true,$user->ldap_error); exit; } if($isp_smtp_account<>null){ writelogs("Creating SMTP authentification for $isp_smtp_server width $isp_smtp_account",__FUNCTION__,__FILE__); $sasl=new smtp_sasl_password_maps(); $sasl->add($isp_address_mail,$isp_smtp_account,$isp_password); $main=new main_cf(); writelogs("Enable sasl engine in postfix",__FUNCTION__,__FILE__); $main->smtp_sasl_password_maps_enable_2(); } writelogs("Creating sender_dependent_relayhost_maps -> $isp_smtp_server",__FUNCTION__,__FILE__); $sender=new sender_dependent_relayhost_maps(); if(!$sender->Add($isp_address_mail,$isp_smtp_server)){ echo main_fetchmail_build_results(true,"sender_dependent_relayhost_maps:$sender->ldap_error"); exit; } $fetchmail=new Fetchmail_settings(); $array["poll"]=$isp_pop3_server; $array["proto"]="auto"; $array["keep"]="yes"; $array["user"]=$isp_account; $array["pass"]=$isp_password; $array["is"]=$local_email; $array["fetchall"]="yes"; $line=$fetchmail->compile($array); if(!$user->fetchmail_add_rule($line)){ echo main_fetchmail_build_results(true,"fetchmail rule:$user->ldap_error"); exit; } $relay=new Routing($ou); if($relay_server<>null){ if(!$relay->create_relay_server($local_domain,$relay_server,$ou)){ echo main_fetchmail_build_results(true,"relay:$relay->ldap_error"); } }else{ if(!$relay->create_localdomain($ou,$local_domain)){ echo main_fetchmail_build_results(true,"local domain:$relay->ldap_error"); } } $fetchmail=new fetchmail(); $fetchmail->Save(); $main=new main_cf(); $main->save_conf(); $main->save_conf_to_server(); $info="<table style='width:100%'> <tr> <td width=1%><img src='img/fw_bold.gif'></td> <td nowrap align='right'><strong>{organization}</strong>:</td> <td nowrap><strong>$ou</strong></td> </tr> <tr> <td width=1%><img src='img/fw_bold.gif'></td> <td nowrap align='right'><strong>{local_mail}</strong>:</td> <td nowrap><strong>$local_email</strong></td> </tr> <tr> <td width=1%><img src='img/fw_bold.gif'></td> <td nowrap align='right'><strong>{isp_address_mail}</strong>:</td> <td nowrap><strong>$isp_address_mail</strong></td> </tr> </table> "; echo main_fetchmail_build_results(false,$info); }
function save_step_sasl_enable() { $main = new main_cf(); $main->smtp_sasl_password_maps_enable_2(); $main->main_array["relayhost"] = "localhost:{$_POST["localport"]}"; $main->save_conf(); $tpl = new templates(); echo $tpl->_ENGINE_parse_body(save_step_infos(true, '{step_sasl_enabled}')); }