本文整理汇总了PHP中write_syslog函数的典型用法代码示例。如果您正苦于以下问题:PHP write_syslog函数的具体用法?PHP write_syslog怎么用?PHP write_syslog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了write_syslog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: RelayCountryPlugin
function RelayCountryPlugin()
{
$user = new usersMenus();
CleanConf($user->spamassassin_conf_path);
if (!$user->spamassassin_ipcountry) {
write_syslog("wants to add IP countries but IP::Country::Fast is not installed.", __FILE__);
return null;
}
$spam = new spamassassin();
$RelayCountryPlugin_path = dirname($user->spamassassin_conf_path) . "/RelayCountryPlugin.cf";
$init_pre = dirname($user->spamassassin_conf_path) . "/init.pre";
if (is_array($spam->main_country)) {
while (list($country_code, $array) = each($spam->main_country)) {
if (trim($country_code) == null) {
continue;
}
$count = $count + 1;
$conf = $conf . "header\tRELAYCOUNTRY_{$country_code} X-Relay-Countries =~ /{$country_code}/\n";
$conf = $conf . "describe RELAYCOUNTRY_{$country_code} Relayed through {$array["country_name"]}\n";
$conf = $conf . "score RELAYCOUNTRY_{$country_code} {$array["score"]}\n\n";
}
}
file_put_contents($RelayCountryPlugin_path, $conf);
write_syslog("Saved {$count} Countries into spamassassin configuration", __FILE__);
if ($count > 1) {
$file = file_get_contents($user->spamassassin_conf_path);
$file = $file . "\n##### Relay Countries\ninclude\t{$RelayCountryPlugin_path}\n";
$file = $file . "add_header all Relay-Country _RELAYCOUNTRY_\n\n";
file_put_contents($user->spamassassin_conf_path, $file);
$file = null;
$file = file_get_contents($init_pre);
$file = $file . "\nloadplugin\tMail::SpamAssassin::Plugin::RelayCountry\n";
file_put_contents($init_pre, $file);
}
}
示例2: 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;
}
示例3: RoundRobin
function RoundRobin()
{
$filename = "/etc/artica-postfix/settings/Daemons/RoundRobinHosts";
if (!is_file($filename)) {
write_syslog("no round robin servers set", __FILE__);
}
RoundRobinClean();
RoundRobinClean();
$ini = new Bs_IniHandler($filename);
if (!is_array($ini->_params)) {
return null;
}
while (list($num, $ligne) = each($ini->_params)) {
if ($num == null) {
continue;
}
if ($ini->_params[$num]["IP"] != null) {
$ips = explode(",", $ini->_params[$num]["IP"]);
$server = $ini->_params[$num]["servername"];
$array = RoundRobinIncrement($ips, $server, $array);
}
}
if (is_array($array)) {
$hosts = file_get_contents("/etc/hosts");
$hosts = str_replace("\n\n", "\n", $hosts);
$hosts = $hosts . "\n";
$hosts = $hosts . "# Round Robin (added by Artica) dont touch this line !!...\n";
$hosts = $hosts . implode("\n", $array);
$hosts = $hosts . "\n";
$hosts = $hosts . "# EOF Round Robin (added by Artica) dont touch this line !...\n";
@file_put_contents("/etc/hosts", $hosts);
}
}
示例4: fixdb
function fixdb()
{
$q = new mysql();
if (!$q->TABLE_EXISTS('Profile', 'obm2')) {
write_syslog("Create Profile table in obm2 database", __FILE__);
$sql = "CREATE TABLE `Profile` (\n\t `profile_id` int(8) NOT NULL auto_increment,\n\t `profile_domain_id` int(8) NOT NULL,\n\t `profile_timeupdate` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n\t `profile_timecreate` timestamp NOT NULL default '0000-00-00 00:00:00',\n\t `profile_userupdate` int(8) default NULL,\n\t `profile_usercreate` int(8) default NULL,\n\t `profile_name` varchar(64) default NULL,\n\t PRIMARY KEY (`profile_id`)\n\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$q->QUERY_SQL($sql, "obm2");
}
if (!$q->TABLE_EXISTS('ProfileModule', 'obm2')) {
write_syslog("Create ProfileModule table in obm2 database", __FILE__);
$sql = "CREATE TABLE `ProfileModule` (\n\t `profilemodule_id` int(8) NOT NULL auto_increment,\n\t `profilemodule_domain_id` int(8) NOT NULL,\n\t `profilemodule_profile_id` int(8) default NULL,\n\t `profilemodule_module_name` varchar(64) NOT NULL default '',\n\t `profilemodule_right` int(2) default NULL,\n\t PRIMARY KEY (`profilemodule_id`),\n\t KEY `profilemodule_profile_id_profile_id_fkey` (`profilemodule_profile_id`),\n\t CONSTRAINT `profilemodule_profile_id_profile_id_fkey` FOREIGN KEY (`profilemodule_profile_id`) REFERENCES `Profile` (`profile_id`) ON DELETE CASCADE ON UPDATE CASCADE\n\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$q->QUERY_SQL($sql, "obm2");
}
if (!$q->TABLE_EXISTS('ProfileModule', 'obm2')) {
write_syslog("Create ProfileModule table in obm2 database", __FILE__);
$sql = "\n\t\tCREATE TABLE `ProfileProperty` (\n\t\t `profileproperty_id` int(8) NOT NULL auto_increment,\n\t\t `profileproperty_profile_id` int(8) default NULL,\n\t\t `profileproperty_name` varchar(32) NOT NULL default '',\n\t\t `profileproperty_value` text NOT NULL,\n\t\t PRIMARY KEY (`profileproperty_id`),\n\t\t KEY `profileproperty_profile_id_profile_id_fkey` (`profileproperty_profile_id`),\n\t\t CONSTRAINT `profileproperty_profile_id_profile_id_fkey` FOREIGN KEY (`profileproperty_profile_id`) REFERENCES `Profile` (`profile_id`) ON DELETE CASCADE ON UPDATE CASCADE\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$q->QUERY_SQL($sql, "obm2");
}
}
示例5: stop
function stop($id)
{
$unix = new unix();
$sql = "SELECT * FROM imapsync WHERE ID='{$id}'";
$q = new mysql();
$ligne = @mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
if (!$q->ok) {
write_syslog("Mysql error {$q->mysql_error}", __FILE__);
die;
}
$pid_org = $ligne["pid"];
$ligne["imap_server"] = str_replace(".", "\\.", $ligne["imap_server"]);
$ligne["username"] = str_replace(".", "\\.", $ligne["username"]);
exec($unix->find_program("pgrep") . " -f \"imapsync.+?--host1 {$ligne["imap_server"]}.+?--user1 {$ligne["username"]}\"", $pids);
while (list($index, $pid) = each($pids)) {
if ($pid > 5) {
unix_system_kill_force($pid);
}
}
unix_system_kill_force($pid_org);
}
示例6: CreateThisUser
function CreateThisUser($email)
{
if (!preg_match("#(.+?)@(.+)#", $email, $re)) {
return null;
}
$domain = $re[2];
$uid = $re[1];
$ldap = new clladp();
$ou = $ldap->ou_by_smtp_domain($domain);
if ($ou == null) {
write_syslog("CreateThisUser():: Unable to detect organization by domain \"{$domain}\"", __FILE__);
return null;
}
$ct = new user($uid);
$ct->ou = $ou;
$ct->mail = $email;
$ct->uid = $uid;
if (!$ct->add_user()) {
write_syslog("CreateThisUser():: Unable to Create user {$uid} \"{$email}\"", __FILE__);
return null;
}
$uid2 = $ldap->uid_from_email($email);
write_syslog("CreateThisUser():: new user \"{$uid2}\"", __FILE__);
return $uid2;
}
示例7: DeleteCronFilesBackupComputer
function DeleteCronFilesBackupComputer()
{
$path = "/etc/cron.d";
$dir_handle = @opendir($path);
if (!$dir_handle) {
write_syslog("Unable to open \"{$path}\"", __FILE__);
return array();
}
$count = 0;
while ($file = readdir($dir_handle)) {
if ($file == '.') {
continue;
}
if ($file == '..') {
continue;
}
if (!is_file("{$path}/{$file}")) {
continue;
}
if (preg_match("#artica.+?-bcmp\$#", $file)) {
events("Deleting cron job {$path}/{$file}");
@unlink("{$path}/{$file}");
continue;
}
}
if (!is_array($array)) {
return array();
}
@closedir($dir_handle);
}
示例8: exit
exit(0);
}
$tbl = explode("\n", file_get_contents("/etc/imapd.conf"));
if (!is_array($tbl)) {
die;
}
while (list($num, $ligne) = each($tbl)) {
if (preg_match("#^([a-z0-9\\_\\-]+):(.+)#", $ligne, $re)) {
$ri[trim($re[1])] = trim($re[2]);
}
}
if (!is_array($ri)) {
die;
}
$sock = new sockets();
$CyrusPartitionDefault = $sock->GET_INFO("CyrusPartitionDefault");
if ($ri["partition-default"] == null) {
$sock = new sockets();
if ($CyrusPartitionDefault != null) {
$ri["partition-default"] = $CyrusPartitionDefault;
} else {
$ri["partition-default"] = "/var/spool/cyrus/mail";
}
}
while (list($num, $ligne) = each($ri)) {
$conf = $conf . "{$num}:{$ligne}\n";
}
echo $conf . "\n";
write_syslog("Cleaning /etc/imapd.conf done with " . strlen($conf) + ' bytes', __FILE__);
file_put_contents("/etc/imapd.conf", $conf);
die;
示例9: dirname
include_once dirname(__FILE__) . '/ressources/class.ini.inc';
include_once dirname(__FILE__) . '/ressources/class.user.inc';
include_once dirname(__FILE__) . "/framework/class.unix.inc";
include_once dirname(__FILE__) . "/framework/frame.class.inc";
cpulimit();
if ($argv[1] = '--verbose') {
$_GET["debug"] = true;
}
if (!Build_pid_func(__FILE__, "MAIN")) {
writelogs(basename(__FILE__) . ":Already executed.. aborting the process", basename(__FILE__), __FILE__, __LINE__);
die;
}
$pid = getmypid();
$users = new usersMenus();
if (!$users->GNUPLOT_PNG) {
write_syslog("gnuplot is not compiled with png support... aborting", __FILE__);
die;
}
topmem();
topcpu();
function topcpu()
{
if (!is_file("/var/log/artica-postfix/dstat_topcpu.csv")) {
events("Processing dstat unable to stat/var/log/artica-postfix/dstat_topcpu.csv");
return null;
}
events("Processing dstat content file /var/log/artica-postfix/dstat_topcpu.csv");
$content = file_get_contents("/var/log/artica-postfix/dstat_topcpu.csv");
$content = explode("\n", $content);
$maxline = count($content);
events("Processing {$maxline} rows");
示例10: AddSite
function AddSite($domain){
$domainMD5=md5($domain);
if(!$_GET["DD"][$domainMD5]){
if($_GET["DEBUG"]){echo "Adding site $domain\n";}
$q=new mysql();
$sql="INSERT INTO dansguardian_sites(website_md5,website) VALUES('$domainMD5','$domain');";
echo "Adding domain index $domain\n";
$q->QUERY_SQL($sql,"artica_events");
if(!$q->ok){write_syslog("AddSite():: Failed : \"$sql\" ($q->mysql_error)",__FILE__);}
$_GET["DD"][$domainMD5]=TRUE;
}else{
if($_GET["DEBUG"]){echo "$domain already exists in database\n";}
}
}
示例11: sleep
}
continue;
}
sleep(5);
$TTLSeconds = $TTL + 5;
try {
$PROCESSES_CLASS->ParseLocalQueue();
} catch (Exception $e) {
ToSyslog("Fatal while running function ParseLocalQueue {$e}");
}
if (is_file("/etc/artica-postfix/ARTICA_STATUS_RELOAD")) {
ToSyslog("Reloading settings and libraries...");
Reload();
}
}
write_syslog("Shutdown after {$TTLSeconds} seconds. stop_server={$stop_server}");
events("!!! STOPPED DAEMON....die()...", "MAIN", __LINE__);
function sig_handler($signo)
{
global $stop_server;
global $reload;
switch ($signo) {
case SIGTERM:
$GLOBALS["SHUTDOWN_COUNT"] = $GLOBALS["SHUTDOWN_COUNT"] + 1;
if ($GLOBALS["SHUTDOWN_COUNT"] > 3) {
$stop_server = true;
}
events("Memory: " . round(memory_get_usage() / 1024 / 1000, 2) . " Asked to shutdown {$GLOBALS["SHUTDOWN_COUNT"]}/3", __FUNCTION__, __LINE__);
break;
case 1:
$reload = true;
示例12: CleanStorage
function CleanStorage()
{
$users = new usersMenus();
$sock = new sockets();
$Enable = $sock->GET_INFO("StorageAutoCleanEnabled");
$MaxDay = $sock->GET_INFO("StorageMaxDayToLive");
if ($MaxDay == null) {
$MaxDay = 60;
}
if ($Enable == null) {
$Enable = 1;
}
if ($Enable != 1) {
return;
}
echo "\n\n####### Max day to live: {$MaxDay} days in storage #######\n\n";
$sql = "SELECT count(MessageID) AS tcount FROM storage WHERE zDate<DATE_SUB(NOW(),INTERVAL {$MaxDay} DAY)";
$q = new mysql();
$ligne = @mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
if ($ligne["tcount"] < 1) {
echo "Nothing to do ....\n\n";
return;
}
$count = $ligne["tcount"];
echo "{$ligne["tcount"]} messages to clean...\n";
$sql = "DELETE FROM storage WHERE zDate<DATE_SUB(NOW(),INTERVAL {$MaxDay} DAY)";
$results = $q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
echo "Mysql error {$q->mysql_error}\n";
}
$date = date('Y-m-d H:i:s');
$filename = "/var/log/artica-postfix/events/" + md5($date);
$ini = new Bs_IniHandler();
$ini->_params["LOG"]["processname"] = dirname(__FILE__);
$ini->_params["LOG"]["date"] = $date;
$ini->_params["LOG"]["context"] = "system";
$ini->_params["LOG"]["text"] = "{$count} storage mails has been cleaned from disk and database";
$ini->_params["LOG"]["text"] = "[{$date}]{$count} storage mails has been cleaned";
file_put_contents($filename, $ini->toString());
write_syslog("{$ligne["tcount"]} messages cleaned...", __FILE__);
echo "messages cleaned in storage...\n";
}
示例13: GeneratStats
function GeneratStats($ou)
{
$sql_domain = sql_domain($ou);
if ($sql_domain == null) {
return null;
}
$sql = "SELECT COUNT(ID) as tcount,bounce_error FROM smtp_logs \nWHERE {$sql_domain} AND DATE_FORMAT( time_connect, '%Y-%m-%d' ) = DATE_FORMAT( NOW( ) , '%Y-%m-%d' )\nGROUP BY bounce_error";
$q = new mysql();
$results = $q->QUERY_SQL($sql, "artica_events");
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
$bounce_error = TransFormBounceError($ligne["bounce_error"]);
if ($bounce_error == null) {
$bounce_error = "Sended";
}
$arr[] = "\"{$ligne["tcount"]}\"=>\"{$bounce_error}\"";
}
if (!is_array($arr)) {
$day_camember = "array()";
} else {
$day_camember = "array(" . implode(",\n", $arr) . ");";
}
$sql = "SELECT COUNT(ID) as tcount,sender_domain FROM smtp_logs \nWHERE {$sql_domain} AND DATE_FORMAT( time_connect, '%Y-%m-%d' ) = DATE_FORMAT( NOW( ) , '%Y-%m-%d' ) AND (\n\tSPAM=1 OR\n\tspammy=1 \n\tOR bounce_error='Discard' \n\tOR bounce_error='RBL'\n\tOR bounce_error='Greylisting'\n\tOR bounce_error='Domain not found'\n\tOR bounce_error='Relay access denied'\n\tOR bounce_error='Relaying denied'\n\t\n\t)\nGROUP BY sender_domain ORDER BY tcount DESC LIMIT 0,10";
$sql_log_1 = "{$sql}\n";
unset($arr);
$results = $q->QUERY_SQL($sql, "artica_events");
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
$arr1[] = "\"{$ligne["tcount"]}\"=>\"{$ligne["sender_domain"]}\"";
}
if (!is_array($arr1)) {
$top_10_spammers = "array()";
} else {
$top_10_spammers = "array(" . implode(",\n", $arr1) . ");";
}
//--------------------------------------------------------------------------------------------------------------------------
$sql = "\n\nSELECT COUNT(ID) as tcount FROM smtp_logs \nWHERE {$sql_domain} AND DATE_FORMAT( time_connect, '%Y-%m-%d' ) = DATE_FORMAT( NOW( ) , '%Y-%m-%d' ) AND (SPAM=1 OR bounce_error='Discard')";
$ligne = @mysql_fetch_array($q->QUERY_SQL($sql, "artica_events"));
$spams = $ligne["tcount"];
$sql = "SELECT COUNT(ID) as tcount FROM smtp_logs \nWHERE {$sql_domain} AND DATE_FORMAT( time_connect, '%Y-%m-%d' ) = DATE_FORMAT( NOW( ) , '%Y-%m-%d' ) AND (whitelisted=1)";
$sql_log_3 = $sql;
$ligne = @mysql_fetch_array($q->QUERY_SQL($sql, "artica_events"));
$whitelisted = $ligne["tcount"];
if ($whitelisted == null) {
$whitelisted = 0;
}
if ($spams == null) {
$spams = 0;
}
//--------------------------------------------------------------------------------------------------------------------------
$sql = "SELECT COUNT(ID) as tcount, DATE_FORMAT( time_sended, '%k' ) as th FROM smtp_logs \nWHERE {$sql_domain} AND DATE_FORMAT( time_connect, '%Y-%m-%d' ) = DATE_FORMAT( NOW( ) , '%Y-%m-%d' ) GROUP BY th ORDER BY th";
$sql_log_2 = "{$sql}\n";
$results = $q->QUERY_SQL($sql, "artica_events");
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
$arr3[] = "\"{$ligne["tcount"]}\"=>\"{$ligne["th"]}\"";
}
if (!is_array($arr3)) {
$flow_hour = "array()";
} else {
$flow_hour = "array(" . implode(",\n", $arr3) . ");";
}
$file = "<?php\n";
$file = $file . "/*\n{$sql_log_1}\n----------\n{$sql_log_3}\n----------\n{$sql_log_2}\n*/\n";
$file = $file . "\$today_cam_flow={$day_camember}\n";
$file = $file . "\$today_cam_top_ten_spammers={$top_10_spammers};\n";
$file = $file . "\$whitelisted=array('spam'=>{$spams},'whitelisted'=>{$whitelisted});\n";
$file = $file . "\$flow_hour={$flow_hour};\n";
$file = $file . "?>";
write_syslog("Generate mail statistics for {$num} \"" . dirname(__FILE__) . "/ressources/logs/ou-stats/{$ou}/", __FILE__);
@mkdir(dirname(__FILE__) . "/ressources/logs");
@mkdir(dirname(__FILE__) . "/ressources/logs/ou-stats");
@mkdir(dirname(__FILE__) . "/ressources/logs/ou-stats/{$ou}");
@file_put_contents(dirname(__FILE__) . "/ressources/logs/ou-stats/{$ou}/day.inc", $file);
chmod(dirname(__FILE__) . "/ressources/logs/ou-stats/{$ou}/day.inc", 0755);
}
示例14: SyncOrg
function SyncOrg($ou)
{
$ldap = new clladp();
$hash = $ldap->UserSearch($ou, "");
for ($i = 0; $i < $hash["count"]; $i++) {
$uid = $hash[$i]["uid"][0];
write_syslog("Checking {$uid}", __FILE__);
$obm = new obm_user($uid);
}
}
示例15: TransFormToHtml
function TransFormToHtml($file)
{
if (!is_file($file)) {
return false;
}
$original_file = trim(file_get_contents("{$file}"));
$attachmentdir = dirname($file);
$fullmessagesdir = dirname($file);
$attachmenturl = 'images.listener.php?mailattach=';
$cmd = '/usr/bin/mhonarc ';
$cmd = $cmd . "-attachmentdir {$attachmentdir} ";
$cmd = $cmd . "-attachmenturl {$attachmenturl} ";
$cmd = $cmd . '-nodoc ';
$cmd = $cmd . '-nofolrefs ';
$cmd = $cmd . '-nomsgpgs ';
$cmd = $cmd . '-nospammode ';
$cmd = $cmd . '-nosubjectthreads ';
$cmd = $cmd . '-idxfname storage ';
$cmd = $cmd . '-nosubjecttxt "no subject" ';
$cmd = $cmd . '-single ';
$cmd = $cmd . $original_file . ' ';
$cmd = $cmd . ">{$attachmentdir}/message.html 2>&1";
system($cmd);
$size = filesize("{$attachmentdir}/message.html");
write_syslog("Creating html {$attachmentdir}/message.html ({$size} bytes)", __FILE__);
}