From afee192d2a77afa1c11d25156d0a44df94e19aed Mon Sep 17 00:00:00 2001
From: A. Täffner <darkalex@firesplash.de>
Date: Sat, 23 Jan 2016 07:30:37 -0500
Subject: [PATCH] fixed the cronjob and noticed a bug in ISPC but not able to report as FlySpray is offline

---
 server/lib/classes/cron.d/400-openvz.inc.php |   90 ++++++++++++++++++++++-----------------------
 1 files changed, 44 insertions(+), 46 deletions(-)

diff --git a/server/lib/classes/cron.d/400-openvz.inc.php b/server/lib/classes/cron.d/400-openvz.inc.php
index daee5c4..5eba8d2 100644
--- a/server/lib/classes/cron.d/400-openvz.inc.php
+++ b/server/lib/classes/cron.d/400-openvz.inc.php
@@ -29,54 +29,52 @@
 */
 
 class cronjob_openvz extends cronjob {
-    
-    // job schedule
-    protected $_schedule = '0 0 * * *';
-    
-    /* this function is optional if it contains no custom code */
-    public function onPrepare() {
-        global $app;
-        
-        parent::onPrepare();
-    }
-    
-    /* this function is optional if it contains no custom code */
-    public function onBeforeRun() {
-        global $app;
-        
-        return parent::onBeforeRun();
-    }
-    
-    public function onRunJob() {
-        global $app, $conf;
-        
-        #######################################################################################################
-        // deactivate virtual servers (run only on the "master-server")
-        #######################################################################################################
 
-        if ($app->dbmaster == $app->db) {
-            $current_date = date('Y-m-d');
+	// job schedule
+	protected $_schedule = '0 0 * * *';
 
-            //* 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);
-                }
-            }
-        }
-        
-        parent::onRunJob();
-    }
-    
-    /* this function is optional if it contains no custom code */
-    public function onAfterRun() {
-        global $app;
-        
-        parent::onAfterRun();
-    }
+	/* this function is optional if it contains no custom code */
+	public function onPrepare() {
+		global $app;
+
+		parent::onPrepare();
+	}
+
+	/* this function is optional if it contains no custom code */
+	public function onBeforeRun() {
+		global $app;
+
+		return parent::onBeforeRun();
+	}
+
+	public function onRunJob() {
+		global $app, $conf;
+
+		//######################################################################################################
+		// deactivate virtual servers (run only on the "master-server")
+		//######################################################################################################
+
+		if ($app->dbmaster == $app->db) {
+			//* 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 < CURDATE()";
+			$records = $app->db->queryAllRecords($sql);
+			if(is_array($records)) {
+				foreach($records as $rec) {
+					$app->dbmaster->datalogUpdate('openvz_vm', array("active" => 'n'), 'vm_id', $rec['vm_id']);
+					$app->log('Virtual machine active date expired. Disabling VM '.$rec['veid'], LOGLEVEL_DEBUG);
+				}
+			}
+		}
+
+		parent::onRunJob();
+	}
+
+	/* this function is optional if it contains no custom code */
+	public function onAfterRun() {
+		global $app;
+
+		parent::onAfterRun();
+	}
 
 }
 

--
Gitblit v1.9.1