From ed30c60150ffda0301eb1f8d30c93cac94de41df Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Mon, 25 Jul 2011 10:38:22 -0400
Subject: [PATCH] Fixed some warnings in the installer.

---
 server/cron_daily.php |   43 +++++++++++++++++++++++++++++++++++--------
 1 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/server/cron_daily.php b/server/cron_daily.php
index e9aedac..2d12f2c 100644
--- a/server/cron_daily.php
+++ b/server/cron_daily.php
@@ -92,7 +92,7 @@
 		$out = '';
 		$found = 0;
 		foreach($lines as $line) {
-			list($key, $value) = preg_split('/[\t= ]+/', $line, 2);
+			@list($key, $value) = preg_split('/[\t= ]+/', $line, 2);
 			if($key == $varName) {
 				$out .= $varName.' '.$varValue."\n";
 				$found = 1;
@@ -116,7 +116,8 @@
 $records = $app->db->queryAllRecords($sql);
 
 foreach($records as $rec) {
-	$yesterday = date('Ymd',time() - 86400);
+	//$yesterday = date('Ymd',time() - 86400);
+	$yesterday = date('Ymd',strtotime("-1 day", time()));
 	$logfile = escapeshellcmd($rec['document_root'].'/log/'.$yesterday.'-access.log');
 	if(!@is_file($logfile)) {
 		$logfile = escapeshellcmd($rec['document_root'].'/log/'.$yesterday.'-access.log.gz');
@@ -156,7 +157,8 @@
 $web_config = $app->getconf->get_server_config($conf['server_id'], 'web');
 
 foreach($records as $rec) {
-	$yesterday = date('Ymd',time() - 86400);
+	//$yesterday = date('Ymd',time() - 86400);
+	$yesterday = date('Ymd',strtotime("-1 day", time()));
 	$logfile = escapeshellcmd($rec['document_root'].'/log/'.$yesterday.'-access.log');
 	if(!@is_file($logfile)) {
 		$logfile = escapeshellcmd($rec['document_root'].'/log/'.$yesterday.'-access.log.gz');
@@ -173,16 +175,19 @@
 	$awstats_conf_dir = $web_config['awstats_conf_dir'];
 	$awstats_website_conf_file = $web_config['awstats_conf_dir'].'/awstats.'.$domain.'.conf';
 	
+	if(is_file($awstats_website_conf_file)) unlink($awstats_website_conf_file);
+	
 	if(!is_file($awstats_website_conf_file)) {
 		$awstats_conf_file_content = 'Include "'.$awstats_conf_dir.'/awstats.conf"
-LogFile="/var/log/ispconfig/httpd/'.$domain.'/access.log"
+LogFile="/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log"
 SiteDomain="'.$domain.'"
 HostAliases="www.'.$domain.' localhost 127.0.0.1"';
 		file_put_contents($awstats_website_conf_file,$awstats_conf_file_content);
 	}
 	
-	
 	if(!@is_dir($statsdir)) mkdir($statsdir);
+	if(is_link('/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log')) unlink('/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log');
+	symlink($logfile,'/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log');
 	
 	// awstats_buildstaticpages.pl -update -config=mydomain.com -lang=en -dir=/var/www/domain.com/web/stats -awstatsprog=/path/to/awstats.pl
 	$command = "$awstats_buildstaticpages_pl -update -config='$domain' -lang=en -dir='$statsdir' -awstatsprog='$awstats_pl'";
@@ -211,7 +216,7 @@
 $sql = "SELECT domain_id, domain, document_root FROM web_domain WHERE server_id = ".$conf['server_id'];
 $records = $app->db->queryAllRecords($sql);
 foreach($records as $rec) {
-	$yesterday = date('Ymd',time() - 86400);
+	$yesterday = date('Ymd',time() - 86400*2);
 	$logfile = escapeshellcmd($rec['document_root'].'/log/'.$yesterday.'-access.log');
 	if(@is_file($logfile)) {
 		// Compress yesterdays logfile
@@ -295,7 +300,7 @@
 	$maxId = $res['max(action_id)'];
 	$sql =  "DELETE FROM sys_remoteaction " .
 			"WHERE tstamp < " . $tstamp . " " .
-			" AND action_status = 'ok' " .
+			" AND action_state = 'ok' " .
 			" AND action_id <" . intval($maxId);
 	$app->dbmaster->query($sql);
 
@@ -389,6 +394,27 @@
 
 }
 
+
+#######################################################################################################
+// deactivate virtual servers (run only on the "master-server")
+#######################################################################################################
+
+if ($app->dbmaster == $app->db) {
+	$current_date = date('Y-m-d');
+
+	//* Check which virtual machines have to be deactivated
+	$sql = "SELECT * FROM openvz_vm WHERE active = 'y' AND active_until_date != '0000-00-00' AND active_until_date < '$current_date'";
+	$records = $app->db->queryAllRecords($sql);
+	if(is_array($records)) {
+		foreach($records as $rec) {
+			$app->dbmaster->datalogUpdate('openvz_vm', "active = 'n'", 'vm_id', $rec['vm_id']);
+			$app->log('Virtual machine active date expired. Disabling VM '.$rec['veid'],LOGLEVEL_DEBUG);
+		}
+	}
+
+
+}
+
 #######################################################################################################
 // Create website backups
 #######################################################################################################
@@ -415,7 +441,7 @@
 				$web_group = $rec['system_group'];
 				$web_id = $rec['domain_id'];
 				$web_backup_dir = $backup_dir.'/web'.$web_id;
-				if(!is_dir($web_backup_dir)) mkdir($web_backup_dir, 0750);
+				if(!is_dir($web_backup_dir)) mkdir($web_backup_dir, 0755);
 				
 				chmod($web_backup_dir, 0755);
 				chown($web_backup_dir, 'root');
@@ -438,6 +464,7 @@
 				// Create backupdir symlink
 				if(is_link($web_path.'/backup')) unlink($web_path.'/backup');
 				symlink($web_backup_dir,$web_path.'/backup');
+				chmod($web_path.'/backup', 0755);
 				
 			}
 			

--
Gitblit v1.9.1