function section_rules_list()
{
    if ($_GET["tab"] == 1) {
        section_config();
        exit;
    }
    $fetch = new Fetchmail_settings();
    $rules = $fetch->LoadAllRules();
    $html = section_tabs() . "<br><H5>{fetchmail_rules}</H5>";
    $rd = "<table style='width:1OO%' class=table_form>";
    while (list($num, $hash) = each($rules)) {
        $uid = $hash["uid"];
        $user = new user($uid);
        if ($hash["enabled"] == 0) {
            $img = 'status_ok-grey.gif';
        } else {
            $img = "status_ok.gif";
        }
        $link = CellRollOver("UserFetchMailRule('{$num}','{$uid}')", '{edit}');
        $rd = $rd . "<tr {$link}>\n\t\t<td width=1% valign='top'><img src='img/{$img}'></td>\n\t\t<td valign='top'><strong>{$user->mail}</strong></td>\n\t\t<td ><strong>{$hash["poll"]}</strong></td>\n\t\t<td ><strong>{$hash["proto"]}</strong></td>\n\t\t<td ><strong>{$hash["user"]}</strong></td>\n\t\t\n\t\t</tr>";
    }
    $rd = $rd . "</table>";
    $rd = "<div style='width:100%;height:400px;overflow:auto'>{$rd}</div>";
    $tpl = new templates();
    if (isset($_GET["ajax"])) {
        return $tpl->_ENGINE_parse_body($html . $rd);
    }
    echo $tpl->_ENGINE_parse_body($html . $rd);
}
Esempio n. 2
0
function js()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $fetchmail = new Fetchmail_settings();
    $ligne = $fetchmail->LoadRule($_GET["ruleid"]);
    $explain = $tpl->_ENGINE_parse_body("{debug}:{$_GET["uid"]}::{$ligne["user"]}@{$ligne["poll"]}");
    echo "YahooWinBrowse('700','{$page}?popup=yes&uid={$_GET["uid"]}&ruleid={$_GET["ruleid"]}','{$explain}')";
}
function HumanRule($ligne)
{
    $fr = new Fetchmail_settings();
    $arr = $fr->parse_config($ligne);
    $arr = $arr[1];
    if ($arr["ssl"]) {
        $ssl = "{using_ssl}";
    }
    if ($arr["port"] != null) {
        $port = "{with_port} {$arr["port"]}";
    } else {
        $port = null;
    }
    $line = "{fetch_address} &#34;<strong>" . $arr["user"] . "</strong>&#34;<br>\n\t{protocol}: <strong>{$arr["proto"]} {$port} {$ssl}</strong><br>\n\t{and_send_to} <strong>&#34;" . $arr["is"] . "&#34;</strong>";
    return $line;
}
Esempio n. 4
0
function section_rules_list()
{
    if ($_GET["tab"] == 1) {
        section_config();
        exit;
    }
    $fetch = new Fetchmail_settings();
    $rules = $fetch->LoadAllRules();
    include_once dirname(__FILE__) . "/ressources/class.user.inc";
    $html = "";
    $rd = "\t<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:98%'>\n\t<thead class='thead'>\n\t\t<tr>\n\t\t<th width=5%>{date}</th>\n\t\t{$th_add}\n\t\t<th width=99% colsan=2>{website}</th>\n\t\t<th width=1% colspan=2>{size}</th>\n\t\t<th width=1% colspan=2>{client}</th>\n\t\t</tr>\n\t</thead>\n\t<tbody class='tbody'>";
    $classtr = "";
    while (list($num, $hash) = each($rules)) {
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        $uid = $hash["uid"];
        $user = new user($uid);
        if ($hash["enabled"] == 0) {
            $img = 'status_ok-grey.gif';
        } else {
            $img = "status_ok.gif";
        }
        $js = "UserFetchMailRule('{$num}','{$uid}')";
        $href = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\" style='font-size:13px;font-weight:bold;text-decoration:underline' >";
        $rd = $rd . "<tr class={$classtr}>\n\t\t<td width=1%><img src='img/{$img}'></td>\n\t\t<td >{$href}{$user->mail}</a></td>\n\t\t<td >{$href}{$hash["poll"]}</a></td>\n\t\t<td >{$href}{$hash["proto"]}</a></td>\n\t\t<td >{$href}{$hash["user"]}</a></td>\n\t\t</tr>";
    }
    $rd = $rd . "</table>";
    $tpl = new templates();
    if (isset($_GET["ajax"])) {
        return $tpl->_ENGINE_parse_body($html . $rd);
    }
    echo $tpl->_ENGINE_parse_body($html . $rd);
}
Esempio n. 5
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);
	
	
}
Esempio n. 6
0
function UserDeleteFetchMailRule()
{
    $rule_num = $_GET["UserDeleteFetchMailRule"];
    $fetch = new Fetchmail_settings();
    $fetch->DeleteRule($rule_num, $_GET["uid"]);
}
function FETCHMAIL_EDIT($value)
{
    $array = unserialize(base64_decode($value));
    $tasksynchro = shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --export-fetchmail-rules");
    foreach ($array as $key => $value) {
        $FINAL[$key] = $value;
    }
    include_once dirname(__FILE__) . "/ressources/class.fetchmail.inc";
    $fetch = new Fetchmail_settings();
    if ($FINAL["ID"] > 0) {
        if ($fetch->EditRule($FINAL, $FINAL["ID"])) {
            send_email_events("Success Editing rule ID {$FINAL["ID"]} for {$FINAL["uid"]}", null, "CLOUD");
            return true;
        } else {
            send_email_events("Failed Editing rule ID {$FINAL["ID"]} for {$FINAL["uid"]}", null, "CLOUD");
            return true;
        }
    }
    if ($fetch->AddRule($FINAL)) {
        send_email_events("Success Adding new rule for {$FINAL["uid"]}", null, "CLOUD");
        shell_exec($tasksynchro);
    } else {
        send_email_events("Failed Adding new rule for {$FINAL["uid"]}", null, "CLOUD");
        shell_exec($tasksynchro);
    }
    return true;
}
Esempio n. 8
0
function import($path)
{
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".{$ID}.pid";
    $unix = new unix();
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid)) {
        echo "This task is aborted, it already running PID {$pid}, please wait before executing a new task\n";
        return;
    }
    $t = time();
    //Mailbox server;Protocol;username;password;local account;SSL Protocol;Use SSL 0/1
    $array = file($path);
    unset($f[0]);
    $c = 0;
    $FD = 0;
    echo "Importing " . count($array) . " lines/rules form \"{$path}\"\n";
    while (list($num, $ligne) = each($array)) {
        $ligne = str_replace("\r", "", $ligne);
        $ligne = str_replace("\n", "", $ligne);
        $ligne = str_replace('"', "", $ligne);
        if (trim($ligne) == null) {
            continue;
        }
        if (strpos($ligne, ";") == 0) {
            continue;
        }
        $POSTED_ARRAY = array();
        $tb = explode(";", $ligne);
        if (count($tb) < 7) {
            echo "Error line: {$num}..\n";
            $FD++;
            continue;
        }
        $POSTED_ARRAY["poll"] = $tb[0];
        $POSTED_ARRAY["proto"] = $tb[1];
        $POSTED_ARRAY["user"] = $tb[2];
        $POSTED_ARRAY["pass"] = $tb[3];
        $POSTED_ARRAY["uid"] = $tb[4];
        $POSTED_ARRAY["sslproto"] = $tb[5];
        $POSTED_ARRAY["ssl"] = intval($tb[6]);
        $ct = new user($POSTED_ARRAY["uid"]);
        if ($ct->mail == null) {
            echo "Error line:{$num} {$POSTED_ARRAY["uid"]} no such member\n";
            $FD++;
            continue;
        }
        $POSTED_ARRAY["is"] = $ct->mail;
        $fetchmail = new Fetchmail_settings();
        if (!$fetchmail->AddRule($POSTED_ARRAY)) {
            echo "Error adding rule line {$num}\n";
            continue;
        }
        echo "Success adding rule line {$num}\n";
        $c++;
    }
    $took = $unix->distanceOfTimeInWords($t, time(), true);
    echo "Import task finish took:{$took} {$FD} failed, {$c} success\n";
}
Esempio n. 9
0
function rule_delete()
{
    $user = new user($_SESSION["uid"]);
    $fr = new Fetchmail_settings();
    $fr->DeleteRule($_GET["rule_delete"], $_SESSION["uid"]);
}
Esempio n. 10
0
function page_del(){
	$num=$_GET["DeleteFetchAccount"];
	$uid=$_GET["uid"];
	$fetchmail=new Fetchmail_settings();
	$fetchmail->DeleteRule($num,$uid);
	}
Esempio n. 11
0
function browse_imap()
{
    $fetch = new Fetchmail_settings();
    $rule = $fetch->LoadRule($_GET["ruldeid"]);
    $port = 143;
    $tls = "notls";
    if ($rule["ssl"] == 1) {
        $port = 993;
        $tls = "ssl/novalidate-cert";
    }
    if ($rule["poll"] == null) {
        json_error_show("Fatal, No IMAP server defined for rule id:{$_GET["ruldeid"]}");
        return;
    }
    //$host,$username,$password,$folder='INBOX',$port=143,$tls='notls
    $imap = new ImapRead($rule["poll"], $rule["user"], $rule["pass"], "INBOX", $port, $tls);
    if ($imap->is_connected == 0) {
        json_error_show("could not connect to {$rule["poll"]}:{$port}<div>{$imap->imap_error}</div>");
        return;
    }
    $array = $imap->returnMailboxListArr();
    $sql = "SELECT folders FROM fetchmail_rules WHERE ID='{$_GET["ruldeid"]}'";
    $q = new mysql();
    $arrayF = array();
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
    $arrayF = unserialize(base64_decode($ligne["folders"]));
    $page = 1;
    $data = array();
    $data['page'] = $page;
    $data['total'] = count($array);
    $data['rows'] = array();
    $search = null;
    if ($_POST["query"] != null) {
        $search = string_to_regex($_POST["query"]);
    }
    while (list($num, $ligne) = each($array)) {
        if (preg_match("#^\\{.*?\\}(.+)#", $ligne, $re)) {
            $folder = $re[1];
        }
        if (preg_match("#^.*?INBOX\\/(.+)#", $ligne, $re)) {
            $folder = $re[1];
        }
        if ($folder == "INBOX") {
            continue;
        }
        if ($search != null) {
            if (!preg_match("#{$search}#i", $folder)) {
                continue;
            }
        }
        $c++;
        $md = md5($folder);
        $base = base64_encode($folder);
        $enabledv = 0;
        if (isset($arrayF[$md])) {
            $enabledv = 1;
        }
        $enable = Field_checkbox("ck_{$md}", 1, $enabledv, "EnableImapf('{$md}','{$base}')");
        $span = "<span style='font-size:16px;font-weight:bolder'>";
        $data['rows'][] = array('id' => $md, 'cell' => array($span . $href . $folder . "</a></span>", $enable));
    }
    $data['total'] = $c;
    echo json_encode($data);
}
Esempio n. 12
0
function delete()
{
    $num = $_POST["del-ID"];
    $uid = $_POST["uid"];
    $fetchmail = new Fetchmail_settings();
    $fetchmail->DeleteRule($num, $uid);
}