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; }
function page_save(){ $ldap=new clladp(); $user=new user($_GET["uid"]); $fetchmail=new Fetchmail_settings(); if($_GET["fetchmail_rule_id"]>-1){ $fetchmail->EditRule($_GET,$_GET["fetchmail_rule_id"]); }else{ if(!$fetchmail->AddRule($_GET)){ echo "->AddRule Class, Mysql error !\n"; return; } } $fetchmail=new fetchmail(); $fetchmail->Save(); }
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"; }
function page_save(){ $_POST["pass"]=url_decode_special_tool($_POST["pass"]); $ldap=new clladp(); $user=new user($_POST["uid"]); $fetchmail=new Fetchmail_settings(); if($_POST["fetchmail_rule_id"]>-1){ $fetchmail->EditRule($_POST,$_POST["fetchmail_rule_id"]); }else{ if(!$fetchmail->AddRule($_POST)){ echo "->AddRule Class, Mysql error !\n"; return; } } $fetchmail=new fetchmail(); $fetchmail->Save(); }