From fdc7e579ed2c3c0088f06ac3d9641153fa01613c Mon Sep 17 00:00:00 2001
From: CaMer0n <cameron@e107coders.org>
Date: Sat, 24 Oct 2009 10:07:30 +0000
Subject: [PATCH] More cron work.

---
 cron.php                        |  9 ++++--
 e107_admin/cron.php             | 49 +++++++++++++++++++++++++++++----
 e107_handlers/cache_handler.php | 28 +++++++++----------
 3 files changed, 65 insertions(+), 21 deletions(-)

diff --git a/cron.php b/cron.php
index 00b70c368..05807a293 100644
--- a/cron.php
+++ b/cron.php
@@ -12,8 +12,8 @@
 |     GNU General Public License (http://gnu.org).
 |
 |     $Source: /cvs_backup/e107_0.8/cron.php,v $
-|     $Revision: 1.5 $
-|     $Date: 2009-10-23 14:16:07 $
+|     $Revision: 1.6 $
+|     $Date: 2009-10-24 10:07:30 $
 |     $Author: e107coders $
 +----------------------------------------------------------------------------+
 */
@@ -38,6 +38,11 @@ require_once(realpath(dirname(__FILE__)."/class2.php"));
 		exit;
 	}
 
+e107::getCache()->CachePageMD5 = '_';
+e107::getCache()->set('cronLastLoad',time(),TRUE,FALSE,TRUE);
+
+
+
 // from the plugin directory:
 // realpath(dirname(__FILE__)."/../../")."/";
 
diff --git a/e107_admin/cron.php b/e107_admin/cron.php
index 93f5de9de..73889d772 100644
--- a/e107_admin/cron.php
+++ b/e107_admin/cron.php
@@ -11,8 +11,8 @@
 |     GNU General Public License (http://gnu.org).
 |
 |     $Source: /cvs_backup/e107_0.8/e107_admin/cron.php,v $
-|     $Revision: 1.6 $
-|     $Date: 2009-10-23 14:16:07 $
+|     $Revision: 1.7 $
+|     $Date: 2009-10-24 10:07:30 $
 |     $Author: e107coders $
 +----------------------------------------------------------------------------+
 */
@@ -44,8 +44,11 @@ class cron
     function cron()
 	{
 		global $pref;
-		
+		$mes = $mes = e107::getMessage();
     	$this->cronAction = e_QUERY;
+		
+		$this->lastRefresh();
+	
 
         if(isset($_POST['submit']))
 		{
@@ -88,12 +91,49 @@ class cron
         	$this -> cronRenderPrefs();
 		}
 	}
+
+
+	function lastRefresh()
+	{
+	
+		e107::getCache()->CachePageMD5 = '_';
+		$lastload = e107::getCache()->retrieve('cronLastLoad',FALSE,TRUE,TRUE);
+		$mes = e107::getMessage();
+		$ago = (time() - $lastload); 
+		
+		$active = ($ago < 125) ? TRUE : FALSE;
+		$status = ($active) ? "Enabled" : "Offline";
+
+		$mes->add("Status: <b>".$status."</b>", E_MESSAGE_INFO);
+			
+		
+		if($pref['e_cron_pref']) // grab cron
+		{
+			foreach($pref['e_cron_pref'] as $func=>$cron)
+			{
+		    	if($cron['active']==1)
+				{
+		        	$list[$func] = $cron;
+				}
+			}
+		}
+		$mes->add("Active Crons: <b>".count($list)."</b>", E_MESSAGE_INFO);			
+		$mes->add("Last cron refresh was ".$ago.' seconds ago.', E_MESSAGE_INFO);
+		
+		if(!$active)
+		{
+					$setpwd_message = "Use the following Cron Command:<br /><b style='color:black'>".$_SERVER['DOCUMENT_ROOT'].e_HTTP."cron.php ".$pref['e_cron_pwd']."</b><br />
+					This cron command is unique and will not be displayed again. Please copy and paste it into your webserver cron area to be run every minute of every day.";
+					$mes->add($setpwd_message, E_MESSAGE_INFO);
+		}		
+	}
+
 	
 	
 	function cronExecute($class_func)
 	{
 		//TODO LANs
-		$mes = eMessage::getInstance();
+		$mes = e107::getMessage();
 		if(!function_exists($func) || !call_user_func($func))
 		{	    	
 	    	$mes->add("Error running ".$func."()", E_MESSAGE_ERROR);    
@@ -452,7 +492,6 @@ class cron
 		   </form>
 		   </div>";
 
-           $mes = e107::getMessage();
 		   $ns -> tablerender(PAGE_NAME, $mes->render() . $text);
 	}
 
diff --git a/e107_handlers/cache_handler.php b/e107_handlers/cache_handler.php
index 765999a93..282ecf95e 100644
--- a/e107_handlers/cache_handler.php
+++ b/e107_handlers/cache_handler.php
@@ -9,9 +9,9 @@
  * Cache handler
  *
  * $Source: /cvs_backup/e107_0.8/e107_handlers/cache_handler.php,v $
- * $Revision: 1.14 $
- * $Date: 2009-09-25 20:17:34 $
- * $Author: secretr $
+ * $Revision: 1.15 $
+ * $Date: 2009-10-24 10:07:30 $
+ * $Author: e107coders $
 */
 
 if (!defined('e107_INIT')) { exit; }
@@ -23,8 +23,8 @@ define('CACHE_PREFIX','<?php exit;');
  * 
  * @package     e107
  * @category	e107_handlers
- * @version     $Revision: 1.14 $
- * @author      $Author: secretr $
+ * @version     $Revision: 1.15 $
+ * @author      $Author: e107coders $
  */
 class ecache {
 
@@ -155,15 +155,15 @@ class ecache {
 
 
 	/**
-	* @return void
-	* @param string $CacheTag - name of tag for future retrieval
-	* @param string $Data - data to be cached
-	* @param bool   $ForceCache (optional, default false) - if TRUE, writes cache even when disabled
-	* @param bool   $bRaw (optional, default false) - if TRUE, writes data exactly as provided instead of prefacing with php leadin
-	* @desc Creates / overwrites the cache file for $query, $text is the data to store for $query.
-	* @scope public
-	*/
-	function set($CacheTag, $Data, $ForceCache = false, $bRaw=0, $syscache = false) 
+	 * 
+	 * @param string $CacheTag - name of tag for future retrieval
+	 * @param data $Data		- data to be cached
+	 * @param boolean $ForceCache [optional] if TRUE, writes cache even when disabled
+	 * @param boolean $bRaw [optional] if TRUE, writes data exactly as provided instead of prefacing with php leadin
+	 * @param boolean $syscache [optional]
+	 * @return 
+	 */
+	public function set($CacheTag, $Data, $ForceCache = false, $bRaw=0, $syscache = false) 
 	{
 		global $pref, $FILES_DIRECTORY, $tp;
 		if(($ForceCache != false ) || ($syscache == false && varsettrue($pref['cachestatus'])) || ($syscache == true && varsettrue($pref['syscachestatus'])) && !$tp->checkHighlighting())