Beispiel #1
0
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 relayhostSave(){
	
	
	
	if($_GET["relay_port"]==null){$_GET["relay_port"]=25;}
	$tpl=new templates();
	if($_GET["relay_address"]==null){
		echo $tpl->_ENGINE_parse_body("{error_no_server_specified}");
		exit;
	}	
	$tool=new DomainsTools();
	writepostfixlogs("Port={$_GET["relay_port"]} address={$_GET["relay_address"]}",__FUNCTION__,__FILE__);
	$data=$tool->transport_maps_implode($_GET["relay_address"],$_GET["relay_port"],'smtp',$_GET["MX_lookups"]);
	writepostfixlogs("Port={$_GET["relay_port"]} address={$_GET["relay_address"]}=$data",__FUNCTION__,__FILE__);
	$data=str_replace('smtp:','',$data);
	$main=new main_cf();
	$main->main_array["relayhost"]=$data;
	$sock=new sockets();
	$sock->SET_INFO("PostfixRelayHost",$data);
	$main->save_conf();
	
	if($_GET["relay_username"]<>null){
		$sals=new smtp_sasl_password_maps();
		$sals->add($data,$_GET["relay_username"],$_GET["relay_password"]);
	}
	$sock->getFrameWork("cmd.php?postfix-relayhost=yes");
	
	}
function USER_TRANSPORT_SALS_SAVE()
{
    $smtp_sasl_password_maps = new smtp_sasl_password_maps();
    if (!$smtp_sasl_password_maps->add($_GET["sasl_server"], $_GET["sasl_username"], $_GET["sasl_password"])) {
        echo "ERROR: {$smtp_sasl_password_maps->ldap_infos}\nLine: " . __LINE__ . "\nPage: " . basename(__FILE__) . "\n";
    }
}
Beispiel #4
0
function smtp_sender_dependent_authentication_submit(){
	$sasl=new smtp_sasl_password_maps();
	$tpl=new templates();
	if($sasl->add($_POST["smtp_sender_dependent_authentication_email"],$_POST["smtp_sender_dependent_authentication_username"],$_POST["smtp_sender_dependent_authentication_password"])){
		echo $tpl->_ENGINE_parse_body('{success}');
	}else{
		echo $sasl->ldap_infos;
	}
	
}
Beispiel #5
0
function SaveISPAddress()
{
    $tpl = new templates();
    $domain = new DomainsTools();
    $page = CurrentPageName();
    $address = $domain->transport_maps_implode($_GET["isp_address"], $_GET["isp_port"]);
    $sasl = new smtp_sasl_password_maps();
    writepostfixlogs("Set ISP server has {$address}", __FUNCTION__, __FILE__);
    $sock = new sockets();
    $sock->SET_INFO("PostfixRelayHost", "{$address}");
    writepostfixlogs("is this server {$address} must use authentication ?", __FUNCTION__, __FILE__);
    if (trim($_GET["isp_username"]) == null) {
        $sasl->delete($address);
        exit;
    }
    if (trim($_GET["isp_password"]) == null) {
        die("password NULL !");
    }
    writepostfixlogs("Enable SMTP Sasl", __FUNCTION__, __FILE__);
    $main = new main_cf();
    $main->smtp_sasl_password_maps_enable();
    if (!$sasl->add($address, trim($_GET["isp_username"]), trim($_GET["isp_password"]))) {
        die($sasl->ldap_infos);
    }
}
Beispiel #6
0
function save_datas(){
	
	$smtp_sender_dependent_authentication_password=$_GET["smtp_sender_dependent_authentication_password"];
	$smtp_sender_dependent_authentication_username=$_GET["smtp_sender_dependent_authentication_username"];
	$canonical=$_GET["SenderCanonical"];
	unset($_GET["smtp_sender_dependent_authentication_password"]);
	unset($_GET["smtp_sender_dependent_authentication_username"]);	
	
	if($canonical<>null){
		if($smtp_sender_dependent_authentication_password<>null){
			if($smtp_sender_dependent_authentication_username<>null){
				$sasl=new smtp_sasl_password_maps();
				$sasl->add($canonical,$smtp_sender_dependent_authentication_username,$smtp_sender_dependent_authentication_password);
			}
		}
	}	
	
	
	
	if(isset($_GET["SenderCanonical"])){
	if(trim($_GET["SenderCanonical"])==null){
			$ldap=new clladp();
			$hash=$ldap->UserDatas($_SESSION["uid"]);
			if($hash['SenderCanonical']<>null){
				writelogs("delete SenderCanonical:{$_SESSION["uid"]}=>{$hash['SenderCanonical']}",__FUNCTION__,__FILE__);
				$upd["SenderCanonical"][0]=$hash['SenderCanonical'];
				$ldap->Ldap_del_mod($hash["dn"],$upd);
				}
		unset($_GET["SenderCanonical"]);
		}
	}	
	
	$uiserid=$_SESSION["uid"];
	$ldap=new clladp();
	$hash=$ldap->UserDatas($uiserid);	
	$cn=$hash["dn"];
	
	while (list ($num, $ligne) = each ($_GET) ){
		$update_array[$num][]=$ligne;
		
	}
	$update_array["displayName"][]=$_GET["givenName"] . " " . $_GET["sn"];
	
	$ldap->Ldap_modify($cn,$update_array);
	if($ldap->ldap_last_error<>null){
		echo $ldap->ldap_last_error;
	}else{echo "OK";}
	
}