1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 13:17:24 +02:00

More cron work.

This commit is contained in:
CaMer0n
2009-10-24 10:07:30 +00:00
parent c8daa0efcd
commit fdc7e579ed
3 changed files with 65 additions and 21 deletions

View File

@@ -12,8 +12,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/cron.php,v $ | $Source: /cvs_backup/e107_0.8/cron.php,v $
| $Revision: 1.5 $ | $Revision: 1.6 $
| $Date: 2009-10-23 14:16:07 $ | $Date: 2009-10-24 10:07:30 $
| $Author: e107coders $ | $Author: e107coders $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -38,6 +38,11 @@ require_once(realpath(dirname(__FILE__)."/class2.php"));
exit; exit;
} }
e107::getCache()->CachePageMD5 = '_';
e107::getCache()->set('cronLastLoad',time(),TRUE,FALSE,TRUE);
// from the plugin directory: // from the plugin directory:
// realpath(dirname(__FILE__)."/../../")."/"; // realpath(dirname(__FILE__)."/../../")."/";

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_admin/cron.php,v $ | $Source: /cvs_backup/e107_0.8/e107_admin/cron.php,v $
| $Revision: 1.6 $ | $Revision: 1.7 $
| $Date: 2009-10-23 14:16:07 $ | $Date: 2009-10-24 10:07:30 $
| $Author: e107coders $ | $Author: e107coders $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -44,8 +44,11 @@ class cron
function cron() function cron()
{ {
global $pref; global $pref;
$mes = $mes = e107::getMessage();
$this->cronAction = e_QUERY; $this->cronAction = e_QUERY;
$this->lastRefresh();
if(isset($_POST['submit'])) if(isset($_POST['submit']))
{ {
@@ -88,12 +91,49 @@ class cron
$this -> cronRenderPrefs(); $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) function cronExecute($class_func)
{ {
//TODO LANs //TODO LANs
$mes = eMessage::getInstance(); $mes = e107::getMessage();
if(!function_exists($func) || !call_user_func($func)) if(!function_exists($func) || !call_user_func($func))
{ {
$mes->add("Error running ".$func."()", E_MESSAGE_ERROR); $mes->add("Error running ".$func."()", E_MESSAGE_ERROR);
@@ -452,7 +492,6 @@ class cron
</form> </form>
</div>"; </div>";
$mes = e107::getMessage();
$ns -> tablerender(PAGE_NAME, $mes->render() . $text); $ns -> tablerender(PAGE_NAME, $mes->render() . $text);
} }

View File

@@ -9,9 +9,9 @@
* Cache handler * Cache handler
* *
* $Source: /cvs_backup/e107_0.8/e107_handlers/cache_handler.php,v $ * $Source: /cvs_backup/e107_0.8/e107_handlers/cache_handler.php,v $
* $Revision: 1.14 $ * $Revision: 1.15 $
* $Date: 2009-09-25 20:17:34 $ * $Date: 2009-10-24 10:07:30 $
* $Author: secretr $ * $Author: e107coders $
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
@@ -23,8 +23,8 @@ define('CACHE_PREFIX','<?php exit;');
* *
* @package e107 * @package e107
* @category e107_handlers * @category e107_handlers
* @version $Revision: 1.14 $ * @version $Revision: 1.15 $
* @author $Author: secretr $ * @author $Author: e107coders $
*/ */
class ecache { class ecache {
@@ -155,15 +155,15 @@ class ecache {
/** /**
* @return void *
* @param string $CacheTag - name of tag for future retrieval * @param string $CacheTag - name of tag for future retrieval
* @param string $Data - data to be cached * @param data $Data - data to be cached
* @param bool $ForceCache (optional, default false) - if TRUE, writes cache even when disabled * @param boolean $ForceCache [optional] 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 * @param boolean $bRaw [optional] 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. * @param boolean $syscache [optional]
* @scope public * @return
*/ */
function set($CacheTag, $Data, $ForceCache = false, $bRaw=0, $syscache = false) public function set($CacheTag, $Data, $ForceCache = false, $bRaw=0, $syscache = false)
{ {
global $pref, $FILES_DIRECTORY, $tp; global $pref, $FILES_DIRECTORY, $tp;
if(($ForceCache != false ) || ($syscache == false && varsettrue($pref['cachestatus'])) || ($syscache == true && varsettrue($pref['syscachestatus'])) && !$tp->checkHighlighting()) if(($ForceCache != false ) || ($syscache == false && varsettrue($pref['cachestatus'])) || ($syscache == true && varsettrue($pref['syscachestatus'])) && !$tp->checkHighlighting())