function sync($ou){ if(!Build_pid_func(__FILE__,__FUNCTION__)){ writelogs(basename(__FILE__).":Already executed.. aborting the process",basename(__FILE__),__FILE__,__LINE__); return; } $unix=new unix(); $imapsync=$unix->find_program("imapsync"); if(!is_file($unix->find_program("imapsync"))){ writelogs("Unable to stat imapsync",__FUNCTION__,__FILE__,__LINE__); send_email_events("Could not migrate from cyrus to zarafa","Unable to stat imapsync tool,aborting","mailbox"); return; } $ou=base64_decode($ou); $ldap=new clladp(); $members=$ldap->hash_users_ou($ou); writelogs("Loading $ou organization ".count($members)." members imapsync=$imapsync",__FUNCTION__,__FILE__,__LINE__); send_email_events("migration from cyrus to zarafa starting","Cyrus to zarafa starting (". count($members)." members)","mailbox"); while (list ($uid, $name) = each ($members) ){ if($uid==null){continue;} $user=new user($uid); send_email_events("migration from cyrus to zarafa starting","Cyrus to zarafa starting (". count($members)." members)","mailbox"); $cmdline="$imapsync --noauthmd5 --subscribe --host1 127.0.0.1 --port1 1143"; $cmdline=$cmdline." --user1 $uid --password1 $user->password --delete --expunge1"; $cmdline=$cmdline." --sep2 / --prefix2 \"\" --host2 127.0.0.1 --user2 $uid --password2 $user->password >/root/imapsync.$uid 2>&1"; writelogs("$cmdline",__FUNCTION__,__FILE__,__LINE__); shell_exec($cmdline); $datas=@file_get_contents("/root/imapsync.$uid"); if($GLOBALS["VERBOSE"]){ echo "$datas"; } if(strlen($datas)>0){ send_email_events("$uid migration status",@file_get_contents("/root/imapsync.$uid"),"mailbox"); } @unlink("/root/imapsync.$uid"); } }
function FreeSync() { if (!Build_pid_func(__FILE__, __FUNCTION__)) { return null; } $unix = new unix(); $sync = $unix->find_program("sync"); @file_put_contents("/proc/sys/vm/drop_cache", "1"); shell_exec($sync); @file_put_contents("/proc/sys/vm/drop_cache", "2"); shell_exec($sync); @file_put_contents("/proc/sys/vm/drop_cache", "3"); shell_exec($sync); shell_exec("swapoff -a && swapon -a"); @file_put_contents("/proc/sys/vm/drop_cache", "0"); }
<?php include_once dirname(__FILE__) . '/ressources/class.templates.inc'; include_once dirname(__FILE__) . '/ressources/class.ini.inc'; include_once dirname(__FILE__) . '/framework/frame.class.inc'; if (posix_getuid() != 0) { die("Cannot be used in web server mode\n\n"); } if (!Build_pid_func(__FILE__, "MAIN")) { events("Already executed.. aborting the process"); die; } if ($argv[1] == '--date') { echo date("Y-m-d H:i:s") . "\n"; } $pid = getmypid(); $pidfile = "/etc/artica-postfix/" . basename(__FILE__) . ".pid"; @mkdir("/var/log/artica-postfix/squid-stats", 0666, true); events("running {$pid} "); GeoIPavailable(); file_put_contents($pidfile, $pid); $pipe = fopen("php://stdin", "r"); while (!feof($pipe)) { $buffer .= fgets($pipe, 4096); Parseline($buffer); $buffer = null; } fclose($pipe); events("Shutdown..."); die; function Parseline($buffer)
$GLOBALS["postconf"] = $unix->find_program("postconf"); $GLOBALS["postmap"] = $unix->find_program("postmap"); $GLOBALS["newaliases"] = $unix->find_program("newaliases"); $GLOBALS["postalias"] = $unix->find_program("postalias"); $GLOBALS["postfix"] = $unix->find_program("postfix"); $GLOBALS["newaliases"] = $unix->find_program("newaliases"); $GLOBALS["virtual_alias_maps"] = array(); $GLOBALS["alias_maps"] = array(); $GLOBALS["relay_domains"] = array(); $GLOBALS["bcc_maps"] = array(); $GLOBALS["transport_maps"] = array(); $GLOBALS["smtp_generic_maps"] = array(); if (!is_file($GLOBALS["postfix"])) { die; } if (!Build_pid_func(__FILE__, $argv[1])) { echo "Starting......: Already executed\n"; } $ldap = new clladp(); if ($ldap->ldapFailed) { echo "Starting......: failed connecting to ldap server {$ldap->ldap_host}\n"; die; } if ($GLOBALS["EnablePostfixMultiInstance"] == 1) { system(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.postfix-multi.php"); die; } if ($argv[1] == "--postmaster") { postmaster(); die; }
function rebuild_all_mailboxes($ou_encoded) { if (!Build_pid_func(__FILE__, "rebuild_all_mailboxes_{$ou_encoded}")) { rebuild_all_mailboxes_events("Already executed", $ou_encoded); return; } $ldap = new clladp(); $filter = "(&(objectClass=userAccount)(|(cn=*)(mail=*)))"; $attrs = array("displayName", "uid", "mail", "givenname", "telephoneNumber", "title", "sn", "mozillaSecondEmail", "employeeNumber"); $dn = "ou=" . base64_decode($ou_encoded) . ",dc=organizations,{$ldap->suffix}"; $hash = $ldap->Ldap_search($dn, $filter, $attrs); $number = $hash["count"]; rebuild_all_mailboxes_events("{$number} user(s) in {$dn}", $ou_encoded); for ($i = 0; $i < $number; $i++) { $userARR = $hash[$i]; $uid = $userARR["uid"][0]; $ct = new user($uid); if (strpos($uid, '$') > 0) { rebuild_all_mailboxes_events("{$ct->DisplayName} SKIP {computer}=TRUE", $ou_encoded); continue; } if ($ct->MailboxActive != 'TRUE') { rebuild_all_mailboxes_events("{$ct->DisplayName} SKIP MailboxActive=FALSE", $ou_encoded); continue; } $cyrus = new cyrus(); if ($cyrus->MailBoxExists($uid)) { rebuild_all_mailboxes_events("[{$number}/{$i}]:: {$uid}: {mailbox_already_exists}", $ou_encoded); continue; } $cyrus->CreateMailbox($uid); rebuild_all_mailboxes_events("[{$number}/{$i}]::{$uid}: {$cyrus->cyrus_infos}", $ou_encoded); } rebuild_all_mailboxes_events("{success}", $ou_encoded); }
function setup_center() { if (!$GLOBALS["FORCE"]) { if (!Build_pid_func(__FILE__, __FUNCTION__)) { return false; } $time_file = "/etc/artica-postfix/croned.2/" . md5(__FILE__ . __FUNCTION__); $tt = file_time_sec($time_file); if ($tt < 30) { events(__FUNCTION__ . " {$tt} seconds, please wait 30s"); return null; } } include_once dirname(__FILE__) . '/setup.index.php'; error_log("Starting " . __FUNCTION__ . " in " . __FILE__); BuildingExecStatus("Setup center:: statistics...", 52); stat_packages(); BuildingExecStatus("Setup center:: SMTP...", 54); smtp_packages(); BuildingExecStatus("Setup center:: WEB...", 56); web_packages(); BuildingExecStatus("Setup center:: Proxy...", 58); proxy_packages(); BuildingExecStatus("Setup center:: Samba...", 60); samba_packages(); BuildingExecStatus("Setup center:: System...", 62); system_packages(); BuildingExecStatus("Setup center:: Xapian...", 64); xapian_packages(); BuildingExecStatus("Setup center:: done...", 68); events(__FUNCTION__ . "() done.."); }
if($argv[1]=='--compile'){Compile_rules();die();} if($argv[1]=='--parse-queue'){parsequeue();die();} if($argv[1]=='--no-check'){$_GET["nocheck"]=true;} if($argv[1]=='--parse-sql'){ParseLastEvents();die();} if($argv[1]=='--delete-all-iptables'){DeleteAllIpTablesRules();die();} if($argv[1]=='--test-white'){$iptablesClass=new iptables_chains();$GLOBALS["IPTABLES_WHITELISTED"]=$iptablesClass->LoadWhiteLists();$iptablesClass->isWhiteListed($argv[2]);die();} if($argv[1]=='--export-drop'){ExportDrop();die();} if($argv[1]=='--transfert-white'){ParseResolvMX();die();} if($argv[1]=='--upgrade-white'){UpgradeWhiteList();die();} if($argv[1]=='--ipdeny'){ipdeny();die();} if($argv[1]=='--perso'){perso();die();} if($GLOBALS["VERBOSE"]){echo "Parsing ".@implode(" ", $argv)."\n";} if(!Build_pid_func(__FILE__,"MAIN")){writelogs(basename(__FILE__).":Already executed.. aborting the process",basename(__FILE__),__FILE__,__LINE__);die();} parsequeue(); if($GLOBALS["EnablePostfixAutoBlock"]<>1){events("This feature is currently disabled ({$GLOBALS["EnablePostfixAutoBlock"]})");die();} die(); //iptables -L OUTPUT --line-numbers //iptables -A INPUT -s 65.55.44.100 -p tcp --destination-port 25 -j DROP; function DeleteAllIpTablesRules(){ $unix=new unix(); $iptables=$unix->find_program("iptables"); shell_exec("$iptables -F"); shell_exec("$iptables -F"); shell_exec("$iptables -t nat -F"); shell_exec("$iptables -t mangle -F");