本文整理汇总了PHP中send_email_events函数的典型用法代码示例。如果您正苦于以下问题:PHP send_email_events函数的具体用法?PHP send_email_events怎么用?PHP send_email_events使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send_email_events函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: BuildDayTable
function BuildDayTable()
{
$q = new mysql();
$q->BuildTables();
if (!$q->TABLE_EXISTS('smtp_logs_day', 'artica_events')) {
send_email_events("Mysql error on smtp_logs_day table", "Artica was unable to create or detect smtp_logs_day table...", "system");
return false;
}
$today = date('Y-m-d');
$sql = "SELECT COUNT(id) as tcount,delivery_domain,DATE_FORMAT(time_stamp,'%Y-%m-%d') as tdate,bounce_error FROM \n\tsmtp_logs \n\tGROUP BY delivery_domain,tdate,bounce_error HAVING tdate<'{$today}' ORDER BY tdate DESC";
$q = new mysql();
$results = $q->QUERY_SQL($sql, "artica_events");
if (!$q->ok) {
echo "Wrong sql query {$q->mysql_error}\n";
write_syslog("Wrong sql query {$q->mysql_error}", __FILE__);
return false;
}
while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
$count = $count + 1;
$emails = $ligne["tcount"];
$delivery_domain = $ligne["delivery_domain"];
$date = $ligne["tdate"];
$bounce_error = $ligne["bounce_error"];
$md5 = md5($delivery_domain . $date . $bounce_error . $emails);
$sql = "INSERT INTO smtp_logs_day (`key`,`day`,`delivery_domain`,`bounce_error`,`emails`)\n\t\tVALUES('{$md5}','{$date}','{$delivery_domain}','{$bounce_error}','{$emails}')";
$q->QUERY_SQL($sql, "artica_events");
if (!$q->ok) {
echo "Wrong sql query {$q->mysql_error}\n";
write_syslog("Wrong sql query \"{$sql}\" {$q->mysql_error}", __FILE__);
return false;
}
}
return true;
}
示例2: watchdog
function watchdog()
{
$ini = new Bs_IniHandler("/etc/artica-postfix/smtpnotif.conf");
$PostfixQueueEnabled = $ini->get("SMTP", "PostfixQueueEnabled");
$PostfixQueueMaxMails = $ini->get("SMTP", "PostfixQueueMaxMails");
if ($PostfixQueueEnabled == null) {
$PostfixQueueEnabled = 1;
}
if ($PostfixQueueMaxMails == null) {
$PostfixQueueMaxMails = 20;
}
if ($PostfixQueueEnabled != 1) {
return;
}
$postfix_system = new postfix_system();
$array = $postfix_system->getQueuesNumber();
while (list($num, $val) = each($array)) {
$logs[] = "{$num}={$val} message(s)";
if (intval($val) > $PostfixQueueMaxMails) {
if (is_file("/etc/artica-postfix/croned.1/postfix.{$num}.exceed")) {
if (file_time_min("/etc/artica-postfix/croned.1/postfix.{$num}.exceed") < 30) {
continue;
}
}
@file_put_contents("/etc/artica-postfix/croned.1/postfix.{$num}.exceed", "#");
$subject = "Postfix queue {$num} exceed limit";
$text = "The {$num} storage queue contains {$val} messages\nIt exceed the maximum {$PostfixQueueMaxMails} messages number...";
send_email_events($subject, $text, 'system');
}
}
$logs[] = "{$num}={$val} message(s)";
RTMevents(implode(" ", $logs));
}
示例3: fetchtimeout
function fetchtimeout($server, $port, $ip, $buffer)
{
$file = "/etc/artica-postfix/cron.1/" . md5(__FILE__) . "-" . md5("{$server},{$port},{$ip}");
if (file_time_min($file) < 15) {
return null;
}
send_email_events("fetchmail network error on {$server} {$port}", "fetchmail claim \"{$buffer}\", please set the right server for fetching messages", 'system');
@unlink($file);
@file_put_contents("#", $file);
}
示例4: sync
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");
}
}
示例5: CleanLogs
function CleanLogs()
{
cleanTmplogs();
CleanDirLogs('/var/log');
CleanDirLogs('/opt/artica/tmp');
CleanDirLogs('/etc/artica-postfix/pids');
CleanDirLogs('/opt/artica/install');
phplogs();
CleanClamav();
$size = str_replace(" ", " ", FormatBytes($GLOBALS["DELETED_SIZE"]));
echo "{$size} cleaned : {$GLOBALS["DELETED_FILES"]} files\n";
if ($GLOBALS["DELETED_SIZE"] > 500) {
send_email_events("{$size} logs files cleaned", "{$GLOBALS["DELETED_FILES"]} files cleaned for {$size} free disk space", "logs_cleaning");
}
}
示例6: orphans
function orphans(){
$unix=new unix();
$zarafaadmin=$unix->find_program("zarafa-admin");
exec("$zarafaadmin --list-orphans 2>&1",$array);
$users=array();
$ff=false;
while (list ($index, $line) = each ($array) ){
if(preg_match("#Users without stores#",$line)){$ff=true;}
if(!$ff){continue;}
if(preg_match("#\s+[0-9+\.\-a-zA-Z@]+$#",$line,$re)){
$re[1]==trim($re[1]);
if($re[1]=="Username"){continue;}
if(strpos($re[1],"---")>0){continue;}
if($re[1]=="--------------------------------------------------------"){continue;}
if($re[1]=="---------------"){continue;}
if($re[1]=="without stores:"){continue;}
if($GLOBALS["VERBOSE"]){echo "found \"{$re[1]}\"\n";}
$users[$re[1]]=$re[1];
}
}
if(count($users)>1){
while (list ($uid, $line) = each ($users) ){
exec("$zarafaadmin --create-store $uid",$results);
$logs[]="Create store for $uid";
while (list ($a, $b) = each ($results) ){$logs[]="$b";}
unset($results);
}
if($GLOBALS["VERBOSE"]){
echo @implode("\n",$logs);
}
send_email_events("Creating store for ". count($users),"Artica has successfully created store in zarafa server:\n".@implode("\n",$logs));
}
}
示例7: Parseline
function Parseline($buffer){
$buffer=trim($buffer);
if($buffer==null){return null;}
if(strpos($buffer,"init urllist")>0){return ;}
if(strpos($buffer,"init expressionlist")>0){return ;}
if(strpos($buffer,"init domainlist")>0){return ;}
if(preg_match('#INFO: loading dbfile (.+)#',$buffer,$re)){
events("LOADING $re[1]");
$GLOBALS[__FILE__]["DBFILE"]=trim($re[1]);
return null;
}
if(preg_match("#FATAL: Error db_open: Unknown error#",$buffer,$re)){
events("ERROR ON {$GLOBALS[__FILE__]["DBFILE"]}");
$file="/etc/artica-postfix/croned.1/squidguard.". md5($GLOBALS[__FILE__]["DBFILE"]).".error";
if(IfFileTime($file)){
shell_exec(LOCATE_PHP5_BIN2()." /usr/share/artica-postfix/exec.squidguard.php --compile-single \"{$GLOBALS[__FILE__]["DBFILE"]}\" &");
WriteFileCache($file);
}
return null;
}
if(strpos($buffer,"ERROR: Going into emergency mode")>0){
events("ERROR: Going into emergency mode");
send_email_events("squidguard: squidguard turn to emergency mode","SquidGuard claim\n$buffer\nPlease contact your support to fix this problem\ncurrently, no filtering urls will be enabled","proxy");
return ;
}
events("Not filtered: $buffer");
}
示例8: BuildWarning
function BuildWarning($cpu, $time)
{
$load = sys_getloadavg();
$unix = new unix();
$hostname = $unix->hostname_g();
$ldtext[] = "**** Current system load ****";
$ldtext[] = "Load 1mn.: " . $load[0];
$ldtext[] = "Load 5mn.: " . $load[1];
$ldtext[] = "Load 15mn: " . $load[2];
$ldtext[] = "*****************************";
$subject = "CPU overload ({$cpu}%) and overloaded ({$GLOBALS["SYSTEM_INTERNAL_LOAD"]}/{$GLOBALS["SYSTEM_MAX_LOAD"]})";
shell_exec("/bin/ps -w axo ppid,pcpu,pmem,time,args --sort -pcpu,-pmem|/usr/bin/head --lines=20 >/tmp.top.txt 2>&1");
$top = file_get_contents("/tmp.top.txt");
@unlink("/tmp.top.txt");
$top = SafeProcesses() . "\n" . $top;
$text = "Server report that your {$hostname} server has reach {$cpu}% CPU average consumption in {$time} minute(s)\n" . @implode("\n", $ldtext) . "\nYou will find below a processes report:\n---------------------------------------------\n{$top}\nGenerated by " . basename(__FILE__) . " (" . __FUNCTION__ . " on line " . __LINE__ . ") at " . date("H:i:s") . "";
send_email_events($subject, $text, 'system');
}
示例9: BlockQuotaFrom
function BlockQuotaFrom($from,$mailto,$size){
$from=trim(strtolower($from));
$mailto=trim(strtolower($mailto));
$date=date("Y-m-d");
$action=false;
$log=false;
if($from==$mailto){return false;}
if(preg_match("#(.+?)@(.+)#",$from,$re)){$domain_from=strtolower(trim($re[2]));}
if(!$GLOBALS["LOCAL_DOMAINS"][$domain_from]){
events("from=<$from> $domain_from not internal (on ". count($GLOBALS["LOCAL_DOMAINS"]). "domains",__FUNCTION__,__LINE__);
return false;
}
if(!is_array($GLOBALS["INTERNAL_FROM"][$from])){PopulateUser($from);}
if($GLOBALS["INTERNAL_FROM"][$from]["uid"]==null){return false;}
$uid=$GLOBALS["INTERNAL_FROM"][$from]["uid"];
if($GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES"]==null){$GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES"]=0;}
if($GLOBALS["INTERNAL_FROM"][$uid]["MaxMailsDay"]>0){
$log=true;
$mem_quota=$GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES"];
$mem_quota=$mem_quota+1;
$GLOBALS["CACHE"][$date][$uid]["MESSAGES"][]=date("Y-m-d H:i:s")." => $mailto (" .str_replace(" ",FormatBytes($size/1024)," ").")";
if($mem_quota>=$GLOBALS["INTERNAL_FROM"][$uid]["MaxMailsDay"]){$action=true;}
$GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES"]=$mem_quota;
}
if($GLOBALS["INTERNAL_FROM"][$uid]["MaxMailDaySize"]>0){
$log=true;
$mem_quota=$GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES_SIZE"];
$mem_quota=$mem_quota+$size;
if($mem_quota>=$GLOBALS["INTERNAL_FROM"][$uid]["MaxMailDaySize"]){$action=true;}
$GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES_SIZE"]=$mem_quota;
}else{
$GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES_SIZE"]=$size;
}
if($log){
events("from=<$from> ($uid) to=<$mailto> notify={$GLOBALS["INTERNAL_FROM"][$uid]["OnlyNotify"]} , quota message(s): {$GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES"]}, size:{$GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES_SIZE"]}",__FUNCTION__,__LINE__);
}
if($action){
if($GLOBALS["INTERNAL_FROM"][$uid]["OnlyNotify"]==1){
events("Send notification and clean cache",__FUNCTION__,__FILE__);
$text[]="Messages count : {$GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES"]}";
$text[]="Messages Size : {$GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES_SIZE"]}";
$text[]="-------------------------------";
$text[]=@implode("\n",$GLOBALS["CACHE"][$date][$uid]["MESSAGES"]);
send_email_events("$uid exceed SMTP quotas",@implode("\n",$text),"postfix");
unset($GLOBALS["CACHE"][$date][$uid]);
return false;
}
return true;
}else{
return false;
}
}
示例10: ufdbguard_remote
function ufdbguard_remote()
{
include_once dirname(__FILE__) . "/ressources/class.ccurl.inc";
$users = new usersMenus();
$sock = new sockets();
$unix = new unix();
$trace = debug_backtrace();
if (isset($trace[1])) {
$called = " called by " . basename($trace[1]["file"]) . " {$trace[1]["function"]}() line {$trace[1]["line"]}";
}
$timeFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
if ($unix->file_time_min($timeFile) < 5) {
writelogs("too short time to change settings, aborting {$called}...", __FUNCTION__, __FILE__, __LINE__);
return;
}
@unlink($timeFile);
@file_put_contents($timeFile, time());
@mkdir("/etc/ufdbguard", null, true);
$tar = $unix->find_program("tar");
$RemoteStatisticsApplianceSettings = unserialize(base64_decode($sock->GET_INFO("RemoteStatisticsApplianceSettings")));
if (!is_numeric($RemoteStatisticsApplianceSettings["SSL"])) {
$RemoteStatisticsApplianceSettings["SSL"] = 1;
}
if (!is_numeric($RemoteStatisticsApplianceSettings["PORT"])) {
$RemoteStatisticsApplianceSettings["PORT"] = 9000;
}
$GLOBALS["REMOTE_SSERVER"] = $RemoteStatisticsApplianceSettings["SERVER"];
$GLOBALS["REMOTE_SPORT"] = $RemoteStatisticsApplianceSettings["PORT"];
$GLOBALS["REMOTE_SSL"] = $RemoteStatisticsApplianceSettings["SSL"];
if ($GLOBALS["REMOTE_SSL"] == 1) {
$refix = "https";
} else {
$refix = "http";
}
$DenyUfdbWriteConf = $sock->GET_INFO("DenyUfdbWriteConf");
if (!is_numeric($DenyUfdbWriteConf)) {
$DenyUfdbWriteConf = 0;
}
$baseUri = "{$refix}://{$GLOBALS["REMOTE_SSERVER"]}:{$GLOBALS["REMOTE_SPORT"]}/ressources/databases";
if ($DenyUfdbWriteConf == 0) {
$uri = "{$baseUri}/ufdbGuard.conf";
$curl = new ccurl($uri, true);
if ($curl->GetFile("/tmp/ufdbGuard.conf")) {
@file_put_contents("/etc/ufdbguard/ufdbGuard.conf", @file_get_contents("/tmp/ufdbGuard.conf"));
@file_put_contents("/etc/squid3/ufdbGuard.conf", @file_get_contents("/tmp/ufdbGuard.conf"));
} else {
ufdbguard_admin_events("Failed to download ufdbGuard.conf aborting `{$curl->error}`", __FUNCTION__, __FILE__, __LINE__, "global-compile");
}
}
$uri = "{$baseUri}/blacklist.tar.gz";
$curl = new ccurl($uri, true);
if ($curl->GetFile("/tmp/blacklist.tar.gz")) {
$cmd = "{$tar} -xf /tmp/blacklist.tar.gz -C /var/lib/squidguard/";
writelogs($cmd, __FUNCTION__, __FILE__, __LINE__);
shell_exec($cmd);
} else {
ufdbguard_admin_events("Failed to download blacklist.tar.gz aborting `{$curl->error}`", __FUNCTION__, __FILE__, __LINE__, "global-compile");
}
$uri = "{$baseUri}/ftpunivtlse1fr.tar.gz";
$curl = new ccurl($uri, true);
if ($curl->GetFile("/tmp/ftpunivtlse1fr.tar.gz")) {
$cmd = "{$tar} -xf /tmp/ftpunivtlse1fr.tar.gz -C /var/lib/ftpunivtlse1fr/";
writelogs($cmd, __FUNCTION__, __FILE__, __LINE__);
shell_exec($cmd);
} else {
ufdbguard_admin_events("Failed to download ftpunivtlse1fr.tar.gz aborting `{$curl->error}`", __FUNCTION__, __FILE__, __LINE__, "global-compile");
}
Dansguardian_remote();
CheckPermissions();
ufdbguard_schedule();
if ($unix->Ufdbguard_remote_srvc_bool()) {
ufdbguard_admin_events("Using a remote UfdbGuard service, aborting", __FUNCTION__, __FILE__, __LINE__, "config");
return;
}
ufdbguard_admin_events("Service will be rebuiled and restarted", __FUNCTION__, __FILE__, __LINE__, "config");
build_ufdbguard_HUP();
$nohup = $unix->find_program("nohup");
$php5 = $unix->LOCATE_PHP5_BIN();
if (is_file($GLOBALS["SQUIDBIN"])) {
echo "Starting......: " . date("H:i:s") . " Squid reloading service\n";
shell_exec("{$nohup} {$php5} " . basename(__FILE__) . "/exec.squid.php --reconfigure-squid >/dev/null 2>&1");
}
$datas = @file_get_contents("/etc/ufdbguard/ufdbGuard.conf");
send_email_events("SquidGuard/ufdbGuard/Dansguardian rules was rebuilded", basename(__FILE__) . "\nFunction:" . __FUNCTION__ . "\nLine:" . __LINE__ . "\n" . "This is new configuration file of the squidGuard/ufdbGuard:\n-------------------------------------\n{$datas}", "proxy");
shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.c-icap.php --maint-schedule");
}
示例11: BuildTunServer
//.........这里部分代码省略.........
if($NETMASK=="255.255.255.255"){$NETMASK="255.255.255.0";}
echo "Starting......: OpenVPN Netmask is null for the range $calc_ip, assume $NETMASK\n";
$ini->set("GLOBAL","NETMASK",$NETMASK);
}
$OpenVpnPasswordCert=$sock->GET_INFO("OpenVpnPasswordCert");
if($OpenVpnPasswordCert==null){$OpenVpnPasswordCert="MyKey";}
$askpass=null;
if(is_file("/etc/artica-postfix/openvpn/keys/password")){
$askpass=" --askpass /etc/artica-postfix/openvpn/keys/password ";
}
$ifconfig_pool_persist=" --ifconfig-pool-persist /etc/artica-postfix/openvpn/ipp.txt ";
if(isset($GLOBALS["OPENVPNPARAMS"]["duplicate-cn"])){
echo "Starting......: OpenVPN duplicate-cn is enabled\n";
$duplicate_cn=" --duplicate-cn ";
$ifconfig_pool_persist=null;
}
if(isset($GLOBALS["OPENVPNPARAMS"]["script-security"])){
echo "Starting......: OpenVPN script-security is enabled\n";
$script_security=" --script-security 2";
}
if(!is_dir("/etc/openvpn/cdd")){@mkdir("/etc/openvpn/cdd");}
$already=array();
echo "Starting......: OpenVPN get remote sites routes...\n";
$sql="SELECT sitename,IP_START,netmask,remote_site_routes,FixedIPAddr FROM vpnclient WHERE connexion_type=1";
$q=new mysql();
$results=$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){echo2("Starting......: OpenVPN : $q->mysql_error");}
while($ligne=mysql_fetch_array($results,MYSQL_ASSOC)){
$iroute=array();
$sitename=$ligne["sitename"];
$FixedIPAddr=$ligne["FixedIPAddr"];
if(!is_numeric($FixedIPAddr)){$FixedIPAddr=0;}
if($IP_START_PREFIX<>null){
if($FixedIPAddr>2){
if($FixedIPAddr<255){
echo "Starting......: OpenVPN $sitename $IP_START_PREFIX.$FixedIPAddr fixed IP address\n";
$iroute[]="ifconfig-push $IP_START_PREFIX.$FixedIPAddr $IP_START_PREFIX.2";
}
}
}
if(!isset($already[$ligne["IP_START"]])){
echo "Starting......: OpenVPN $sitename ({$ligne["IP_START"]} {$ligne["netmask"]})\n";
$rou[]=" --route {$ligne["IP_START"]} {$ligne["netmask"]}";
$iroute[]="iroute {$ligne["IP_START"]} {$ligne["netmask"]}";
$already[$ligne["IP_START"]]=true;
}
$remote_site_routes=unserialize(base64_decode($ligne["remote_site_routes"]));
while (list ($num, $site_mask) = each ($remote_site_routes) ){
if(!isset($already[$num])){
echo "Starting......: OpenVPN $sitename ($num $site_mask)\n";
$rou[]=" --route $num $site_mask";
$iroute[]="iroute $num $site_mask";
$already[$num]=true;
}
}
echo "Starting......: OpenVPN cdd $sitename\n";
@file_put_contents("/etc/openvpn/cdd/$sitename",@implode("\n", $iroute) );
}
if(count($rou)>0){
$localroutes=@implode(" ", $rou);
$client_config_dir=" --client-config-dir /etc/openvpn/cdd";
}
$LDAP_AUTH=$ini->_params["GLOBAL"]["LDAP_AUTH"];
if($LDAP_AUTH==1){
if(is_file("/usr/lib/openvpn/openvpn-auth-pam.so")){
$plugin=" --plugin /usr/lib/openvpn/openvpn-auth-pam.so common-auth";
echo "Starting......: OpenVPN auth is enabled\n";
shell_exec("/usr/share/artica-postfix/bin/artica-install --nsswitch");
}
}
@mkdir("/etc/openvpn/ccd",0666,true);
$php5=$unix->LOCATE_PHP5_BIN();
$me=__FILE__;
$cmd=" --port $port --dev tun $proto --server $IP_START $NETMASK$localroutes$client_config_dir --comp-lzo $local --ca $ca --dh $dh --key $key --cert $crt";
$cmd=$cmd. "$ifconfig_pool_persist " . implode(" ",$routess);
$cmd=$cmd. " $askpass$duplicate_cn--client-to-client$script_security$plugin --learn-address \"$php5 $me --client-connect\" --keepalive 10 60 --persist-tun --verb 5 --daemon --writepid /var/run/openvpn/openvpn-server.pid --log \"/var/log/openvpn/openvpn.log\"";
$cmd=$cmd. " --status /var/log/openvpn/openvpn-status.log 10";
echo "Starting......: OpenVPN building /etc/openvpn/cmdline.conf done\n";
@file_put_contents("/etc/openvpn/cmdline.conf",$cmd);
$sock->SaveConfigFile($ini->toString(),"ArticaOpenVPNSettings");
send_email_events("OpenVPN was successfully reconfigured",$cmd,"VPN");
echo "Starting......: OpenVPN building settings done.\n";
if($GLOBALS["VERBOSE"]){writelogs("$cmd",__FUNCTION__,__FILE__,__LINE__);}
}
示例12: execute
function execute()
{
$nice = EXEC_NICE();
if (is_file(dirname(__FILE__) . "/exec.sarg.gilou.php")) {
events("Executing exec.sarg.gilou.php instead...");
shell_exec($nice . LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.sarg.gilou.php --exec");
return;
}
$sock = new sockets();
$SargOutputDir = $sock->GET_INFO("SargOutputDir");
if ($SargOutputDir == null) {
$SargOutputDir = "/var/www/html/squid-reports";
}
$nice = EXEC_NICE();
$unix = new unix();
$today = date("d/m/Y");
$sarg_bin = $unix->find_program("sarg");
if (!is_file($sarg_bin)) {
sarg_admin_events("Fatal, unable to locate sarg binary, aborting...", __FUNCTION__, __FILE__, __LINE__, "sarg");
return;
}
events("Building settings..");
buildconf();
$usersauth = false;
$squid = new squidbee();
if ($squid->LDAP_AUTH == 1) {
$usersauth = true;
}
if ($squid->LDAP_EXTERNAL_AUTH == 1) {
$usersauth = true;
}
if (!is_file("/etc/squid/exclude_codes")) {
@file_put_contents("/etc/squid/exclude_codes", "\nNONE/400\n");
}
@mkdir("{$SargOutputDir}", 0755, true);
$u = " -i ";
$cmd = "{$nice}{$sarg_bin} -d {$today}-{$today} {$u}-f /etc/squid3/sarg.conf -l /var/log/squid/access.log -o \"{$SargOutputDir}\" -x -z 2>&1";
$t1 = time();
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$cmd}\n";
sargevents("execute(): {$cmd}");
exec($cmd, $results);
while (list($index, $line) = each($results)) {
if (preg_match("#SARG: No records found#", $line)) {
events("No records found");
$subject_add = "(No records found)";
}
if (preg_match("#SARG:\\s+.+?mixed records format#", $line)) {
send_email_events("SARG: Error, squid was reloaded", "It seems that there is a mixed log file format detected in squid\n\t\t\tThis reason is Artica change squid log format from orginial to http access mode.\n\t\t\tIn this case, the log will be moved and squid will be reloaded \n\t\t\tin order to build a full log file with only one log format.\n\t\t\t\n" . @implode("\n", $results), "proxy");
shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.squid.php --reconfigure");
shell_exec($unix->LOCATE_SQUID_BIN() . " -k rotate");
shell_exec("/etc/init.d/auth-tail restart >/dev/null 2>&1");
shell_exec("/etc/init.d/cache-tail restart >/dev/null 2>&1");
return;
}
if (preg_match("#SARG:\\s+.+?enregistrements de plusieurs formats#", $line)) {
send_email_events("SARG: Error, squid was reloaded", "It seems that there is a mixed log file format detected in squid\n\t\t\tThis reason is Artica change squid log format from orginial to http access mode.\n\t\t\tIn this case, the log will be moved and squid will be reloaded \n\t\t\tin order to build a full log file with only one log format.\n\t\t\t\n" . @implode("\n", $results), "proxy");
shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.squid.php --reconfigure");
shell_exec($unix->LOCATE_SQUID_BIN() . " -k rotate");
shell_exec("/etc/init.d/auth-tail restart >/dev/null 2>&1");
shell_exec("/etc/init.d/cache-tail restart >/dev/null 2>&1");
return;
}
if (preg_match("#SARG.+?Unknown input log file format#", $line)) {
send_email_events("SARG: \"Unknown input log file format\", squid was reloaded", "It seems that there is a input log file format log file format detected in squid\n\t\t\tThis reason is Artica change squid log format from orginial to log_fqn on, this will be disabled\n\t\t\tIn this case, the log will be moved and squid will be reloaded \n\t\t\tin order to build a full log file with only one log format.\n\t\t\t\n" . @implode("\n", $results), "proxy");
shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.squid.php --reconfigure");
shell_exec($unix->LOCATE_SQUID_BIN() . " -k rotate");
shell_exec("/etc/init.d/auth-tail restart >/dev/null 2>&1");
shell_exec("/etc/init.d/cache-tail restart >/dev/null 2>&1");
return;
}
}
$NICE = EXEC_NICE();
$unix = new unix();
$lighttpd_user = $unix->APACHE_SRC_ACCOUNT();
$php = $unix->LOCATE_PHP5_BIN();
$nohup = $unix->find_program("nohup");
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, lighttpd user: {$lighttpd_user}\n";
$chown = $unix->find_program("chown");
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]},{$chown} -R {$lighttpd_user}:{$lighttpd_user} {$SargOutputDir}/*\n";
exec("{$chown} -R {$lighttpd_user}:{$lighttpd_user} {$SargOutputDir}/* >/dev/null 2>&1", $results2);
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]},\n" . @implode("\n" . $results2) . "\n";
shell_exec("{$nohup} {$php} " . __FILE__ . " --backup >/dev/null 2>&1 &");
$t2 = time();
$distanceOfTimeInWords = distanceOfTimeInWords($t1, $t2);
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$distanceOfTimeInWords}\n";
events("Statistics generated ({$distanceOfTimeInWords})");
if ($GLOBALS["VERBOSE"]) {
echo "SARG: Statistics generated ({$distanceOfTimeInWords})\n\n";
echo @implode("\n", $results) . "\n";
}
status(true);
sarg_admin_events("SARG: Statistics generated ({$distanceOfTimeInWords}) {$subject_add}", "Command line:\n-----------\n{$cmd}\n" . @implode("\n", $results), __FUNCTION__, __FILE__, __LINE__, "sarg");
}
示例13: backup_mysql
function backup_mysql($ID, $instance_id = 0)
{
include_once dirname(__FILE__) . '/ressources/class.mysql-multi.inc';
$sock = new sockets();
$unix = new unix();
$date_start = time();
$TpmPrefix = null;
$RemotePathSuffix = null;
$instancename = null;
$mysqlhotcopy = $unix->find_program("mysqlhotcopy");
$email_spacer = "==========================================";
if ($instance_id > 0) {
$mysql = new mysql_multi($instance_id);
$instancename = " ({$mysql->MyServer}) ";
}
if ($mysqlhotcopy == null) {
backup_events($ID, "mysql", "ERROR, unable to stat mysqlhotcopy");
if (is_file($unix->find_program("mysqldump"))) {
backup_events($ID, "mysql", "INFO,{$instancename} switch to mysqldump processing");
return backup_mysql_oldway($ID, $instance_id);
}
events("ERROR, unable to stat mysqlhotcopy", __FUNCTION__, __LINE__);
send_email_events("Backup Task {$ID}:: Unable to backup mysql datas ", "ERROR, unable to stat mysqlhotcopy", "backup");
return false;
}
$array = backup_mysql_databases_list($ID, $instance_id);
if (!is_array($array)) {
events("ERROR,{$instancename} unable to get databases list", __FUNCTION__, __LINE__);
send_email_events("Backup Task {$ID}::{$instancename} Unable to backup mysql datas ", "ERROR, unable to get databases list", "backup");
backup_events($ID, "mysql", "ERROR,{$instancename} unable to get databases list", __LINE__);
return false;
}
$q = new mysql();
if ($instance_id > 0) {
$q = new mysql_multi($instance_id);
$TpmPrefix = $instance_id;
$Socket = " --socket={$q->SocketPath}";
$RemotePathSuffix = "-{$q->MyServerCMDLINE}";
}
if ($q->mysql_password != null) {
$password = " --password={$q->mysql_password}";
}
if ($q->mysql_admin != null) {
$user = " --user={$q->mysql_admin}";
}
$temporarySourceDir = $sock->GET_INFO("ExecBackupTemporaryPath");
if ($temporarySourceDir == null) {
$temporarySourceDir = "/home/mysqlhotcopy";
}
$temporarySourceDir = "{$temporarySourceDir}/mysql{$TpmPrefix}";
events("temporarySourceDir has ExecBackupTemporaryPath token was \"{$temporarySourceDir}\"", __FUNCTION__, __LINE__);
events("Creating {$temporarySourceDir}", __FUNCTION__, __LINE__);
@mkdir($temporarySourceDir, 0755, true);
if (!is_dir($temporarySourceDir)) {
events("Creating Unable to backup mysql datas ", "ERROR,{$instancename} {$temporarySourceDir} permission denied or no such file or directory", __FUNCTION__, __LINE__);
send_email_events("Backup Task {$ID}::{$instancename} Unable to backup mysql datas ", "ERROR, {$temporarySourceDir} permission denied or no such file or directory", "backup");
backup_events($ID, "mysql", "ERROR,{$instancename} {$temporarySourceDir} permission denied or no such file or directory");
return;
}
$BlacklistDatabases["performance_schema"] = true;
$BlacklistDatabases["mysql"] = true;
$BlacklistDatabases["log"] = true;
backup_events($ID, "mysql", "INFO,{$instancename} using {$temporarySourceDir} for temp backup");
while (list($num, $line) = each($array)) {
if (trim($line) == null) {
continue;
}
$database_name = trim(basename($line));
$database_nameSTR = strtolower($database_name);
if (isset($BlacklistDatabases[$database_nameSTR])) {
events("{$instancename}skipping database \"{$database_name}\"", __FUNCTION__, __LINE__);
backup_events($ID, "mysql", "INFO,{$instancename} mysqlhotcopy skip {$database_nameSTR} database", __LINE__);
continue;
}
backup_events($ID, "mysql", "INFO,{$instancename} mysqlhotcopy database ({$database_name}) stored in {$line} -> {$temporarySourceDir}");
$mysqlhotcopy_command = "{$mysqlhotcopy} --addtodest{$Socket}{$user}{$password} {$database_name} {$temporarySourceDir} 2>&1";
events("\"{$mysqlhotcopy_command}\"", __FUNCTION__, __LINE__);
exec($mysqlhotcopy_command, $results);
while (list($num_line, $evenement) = each($results)) {
if (preg_match("#No space left on device#", $evenement)) {
events("ERROR, backup No space left on device ({$temporarySourceDir})", __FUNCTION__, __LINE__);
backup_events($ID, "mysql", "ERROR,{$instancename} backup No space left on device ({$temporarySourceDir})\n" . implode("\n", $results));
if (is_dir($temporarySourceDir)) {
shell_exec("/bin/rm -rf {$temporarySourceDir}/*");
}
return;
}
events("{$evenement}", __FUNCTION__, __LINE__);
if (preg_match("#failed:#", $evenement)) {
events("ERROR,{$instancename} database: \"{$database_name}\" ({$evenement})", __FUNCTION__, __LINE__);
backup_events($ID, "mysql", "ERROR,{$instancename} database: \"{$database_name}\" ({$evenement})");
$fulltext = @implode("\n", $results);
send_email_events("Backup Task {$ID}::{$instancename} database: \"{$database_name}\" failed to backup ", "{$email_spacer}\n{$mysqlhotcopy_command}{$email_spacer}\nERROR:{$email_spacer}\n{$evenement}\n{$email_spacer}\n{$fulltext}", "backup");
}
}
backup_events($ID, "mysql", "INFO,{$instancename} backup {$database_name}\n" . implode("\n", $results), __LINE__);
if (strtolower($database_name) == "zarafa") {
events("{$instancename}zarafa database -> backup_mysql_database_mysqldump({$ID},zarafa,{$temporarySourceDir})", __FUNCTION__, __LINE__);
backup_mysql_database_mysqldump($ID, "zarafa", $temporarySourceDir, $instance_id);
}
//.........这里部分代码省略.........
示例14: ParseRetranslatorLogs
function ParseRetranslatorLogs()
{
$unix = new unix();
if ($unix->PIDOF("/usr/share/artica-postfix/bin/retranslator.bin") > 0) {
return;
}
$dir = "/var/log/kretranslator";
if (!is_dir($dir)) {
return null;
}
$unix = new unix();
$files = $unix->DirFiles($dir);
while (list($num, $file) = each($files)) {
if (!preg_match("#retranslator-([0-9\\-]+)_([0-9]+)-([0-9]+)-([0-9]+).debug#", $file, $re)) {
continue;
}
$date = "{$re[1]} {$re[2]}:{$re[3]}:{$re[4]}";
$NumberofFilesUpdated = NumberofRestransFilesUpdated("{$dir}/{$file}");
if ($NumberofFilesUpdated[0] > 0) {
$subject = "Kaspersky Retranslator: {$NumberofFilesUpdated[0]} files updated ({$NumberofFilesUpdated[1]})";
send_email_events($subject, @file_get_contents("{$dir}/{$file}"), "KASPERSKY_UPDATES", $date);
@unlink("{$dir}/{$file}");
continue;
}
@unlink("{$dir}/{$file}");
}
}
示例15: unix
$unix = new unix();
if ($unix->process_exists(@file_get_contents($pidfile))) {
echo "Process already exists...\n";
die;
}
@file_put_contents($pidfile, getmypid());
$t1 = time();
$time = date('Y-m-d') . "_" . date('h:i');
$ini = new Bs_IniHandler();
$ini->loadFile("/etc/artica-postfix/settings/Daemons/CyrusAVConfig");
$nice = EXEC_NICE();
$clamscan = $unix->find_program("clamscan");
if (!is_file($clamscan)) {
die;
}
$partition_default = $unix->IMAPD_GET("partition-default");
if (!is_dir($partition_default)) {
send_email_events("Mailboxes antivirus scanning failed", "partition-default: \"{$partition_default}\"\nno such directory", "mailbox");
echo "partition-default: no such directory\n";
die;
}
@mkdir("/var/log/artica-postfix/antivirus/cyrus-imap", 0755, true);
$time = date('Y-m-d') . "_" . date('h:I');
$cmd = "{$nice} /usr/bin/clamscan --recursive=yes --infected ";
$cmd = $cmd . "--max-filesize=10M --max-scansize=10M --max-recursion=5 --max-dir-recursion=10 ";
$cmd = $cmd . "--log=/log/artica-postfix/antivirus/cyrus-imap/{$time}.scan {$partition_default}";
shell_exec($cmd);
$t2 = time();
$time_duration = distanceOfTimeInWords($t1, $t2);
send_email_events("Mailboxes antivirus scan terminated: {$time_duration}", @file_get_contents("/log/artica-postfix/antivirus/cyrus-imap/{$time}.scan"), "mailbox");