mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 20:57:26 +02:00
cron administration clean up
This commit is contained in:
@@ -1,29 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
+ ----------------------------------------------------------------------------+
|
* e107 website system
|
||||||
| e107 website system
|
*
|
||||||
|
|
* Copyright (C) 2008-2010 e107 Inc (e107.org)
|
||||||
| Copyright (C) 2008-2010 e107 Inc
|
* Released under the terms and conditions of the
|
||||||
| http://e107.org/
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
|
*
|
||||||
|
|
* Cron Administration
|
||||||
| Released under the terms and conditions of the
|
*
|
||||||
| GNU General Public License (http://gnu.org/).
|
* $URL$
|
||||||
|
|
* $Id$
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_admin/cron.php,v $
|
*
|
||||||
| $Revision$
|
|
||||||
| $Date$
|
|
||||||
| $Author$
|
|
||||||
+----------------------------------------------------------------------------+
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package e107
|
* @package e107
|
||||||
* @subpackage admin
|
* @subpackage admin
|
||||||
* @version $Revision$
|
* @version $Id$
|
||||||
* @author $Author$
|
|
||||||
|
|
||||||
* Admin-related functions for cron (Scheduler) management
|
* Admin-related functions for cron (Scheduler) management
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -39,24 +33,22 @@ include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE);
|
|||||||
$e_sub_cat = 'cron';
|
$e_sub_cat = 'cron';
|
||||||
|
|
||||||
require_once('auth.php');
|
require_once('auth.php');
|
||||||
require_once (e_HANDLER.'message_handler.php');
|
$frm = e107::getForm();
|
||||||
require_once(e_HANDLER.'form_handler.php');
|
$cron = new cron();
|
||||||
$frm = new e_form(true);
|
|
||||||
$cron = new cron;
|
|
||||||
|
|
||||||
require_once(e_ADMIN.'footer.php');
|
require_once(e_ADMIN.'footer.php');
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
class cron
|
class cron
|
||||||
{
|
{
|
||||||
var $coreCrons = array();
|
protected $coreCrons = array();
|
||||||
var $cronAction;
|
protected $cronAction;
|
||||||
var $e_cron = array();
|
protected $e_cron = array();
|
||||||
|
|
||||||
function cron()
|
public function __construct()
|
||||||
{
|
{
|
||||||
global $pref;
|
$pref = e107::getPref();
|
||||||
$mes = $mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
$this->cronAction = e_QUERY;
|
$this->cronAction = e_QUERY;
|
||||||
|
|
||||||
// The 'available' flag only gives the option to configure the cron if the underlying feature is enabled
|
// The 'available' flag only gives the option to configure the cron if the underlying feature is enabled
|
||||||
@@ -69,14 +61,11 @@ class cron
|
|||||||
// 3 => array('name'=>'News Sticky', 'function' => 'newsPurge', 'description'=>'Remove Sticky News Items')
|
// 3 => array('name'=>'News Sticky', 'function' => 'newsPurge', 'description'=>'Remove Sticky News Items')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
if (!vartrue($pref['e_cron_pwd']))
|
if (!vartrue($pref['e_cron_pwd']))
|
||||||
{
|
{
|
||||||
$pwd = $this->setCronPwd();
|
$pwd = $this->setCronPwd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (isset($_POST['submit']))
|
if (isset($_POST['submit']))
|
||||||
{
|
{
|
||||||
$this->cronSave();
|
$this->cronSave();
|
||||||
@@ -99,10 +88,6 @@ class cron
|
|||||||
|
|
||||||
// Set Core Cron Options.
|
// Set Core Cron Options.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// These core functions need to be put into e_BASE/cron.php ie. news_purge()
|
// These core functions need to be put into e_BASE/cron.php ie. news_purge()
|
||||||
|
|
||||||
if ($this->cronAction == "" || $this->cronAction == "main")
|
if ($this->cronAction == "" || $this->cronAction == "main")
|
||||||
@@ -110,18 +95,15 @@ class cron
|
|||||||
$this->cronRenderPage();
|
$this->cronRenderPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($this->cronAction == "pref")
|
if ($this->cronAction == "pref")
|
||||||
{
|
{
|
||||||
$this->cronRenderPrefs();
|
$this->cronRenderPrefs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function lastRefresh()
|
function lastRefresh()
|
||||||
{
|
{
|
||||||
global $pref;
|
$pref = e107::getPref();
|
||||||
e107::getCache()->CachePageMD5 = '_';
|
e107::getCache()->CachePageMD5 = '_';
|
||||||
$lastload = e107::getCache()->retrieve('cronLastLoad', FALSE, TRUE, TRUE);
|
$lastload = e107::getCache()->retrieve('cronLastLoad', FALSE, TRUE, TRUE);
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
@@ -135,7 +117,6 @@ class cron
|
|||||||
|
|
||||||
$lastRun = ($mins) ? $mins." minutes and ".$secs." seconds ago." : $secs." seconds ago.";
|
$lastRun = ($mins) ? $mins." minutes and ".$secs." seconds ago." : $secs." seconds ago.";
|
||||||
|
|
||||||
|
|
||||||
$lastRefresh = ($ago < 10000) ? $lastRun : 'Never';
|
$lastRefresh = ($ago < 10000) ? $lastRun : 'Never';
|
||||||
|
|
||||||
$mes->add("Status: <b>".$status."</b>", E_MESSAGE_INFO);
|
$mes->add("Status: <b>".$status."</b>", E_MESSAGE_INFO);
|
||||||
@@ -143,6 +124,7 @@ class cron
|
|||||||
// print_a($pref['e_cron_pref']);
|
// print_a($pref['e_cron_pref']);
|
||||||
|
|
||||||
if ($pref['e_cron_pref']) // grab cron
|
if ($pref['e_cron_pref']) // grab cron
|
||||||
|
|
||||||
{
|
{
|
||||||
foreach ($pref['e_cron_pref'] as $func => $cron)
|
foreach ($pref['e_cron_pref'] as $func => $cron)
|
||||||
{
|
{
|
||||||
@@ -170,11 +152,8 @@ class cron
|
|||||||
$mes->add($setpwd_message, E_MESSAGE_INFO);
|
$mes->add($setpwd_message, E_MESSAGE_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function cronName($classname, $method)
|
function cronName($classname, $method)
|
||||||
{
|
{
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
@@ -195,7 +174,6 @@ function cronName($classname,$method)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function cronExecute($class_func)
|
function cronExecute($class_func)
|
||||||
{
|
{
|
||||||
//TODO LANs
|
//TODO LANs
|
||||||
@@ -271,7 +249,6 @@ function cronName($classname,$method)
|
|||||||
$mes->add($setpwd_message, E_MESSAGE_WARNING);
|
$mes->add($setpwd_message, E_MESSAGE_WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// print_a($pref['e_cron_pref']);
|
// print_a($pref['e_cron_pref']);
|
||||||
|
|
||||||
if (save_prefs())
|
if (save_prefs())
|
||||||
@@ -286,33 +263,33 @@ function cronName($classname,$method)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function setCronPwd()
|
function setCronPwd()
|
||||||
{
|
{
|
||||||
global $pref;
|
//global $pref;
|
||||||
|
|
||||||
$userMethods = e107::getUserSession();
|
$userMethods = e107::getUserSession();
|
||||||
$newpwd = $userMethods->generateRandomString('*^*#.**^*');
|
$newpwd = $userMethods->generateRandomString('*^*#.**^*');
|
||||||
$newpwd = sha1($newpwd.time());
|
$newpwd = sha1($newpwd.time());
|
||||||
$pref['e_cron_pwd'] = $newpwd;
|
//$pref['e_cron_pwd'] = $newpwd;
|
||||||
|
e107::getConfig()->set('e_cron_pwd', $newpwd)->save(false);
|
||||||
return save_prefs();
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
function cronRenderPrefs()
|
function cronRenderPrefs()
|
||||||
{
|
{
|
||||||
global $frm,$ns;
|
//global $frm,$ns;
|
||||||
|
$frm = e107::getForm();
|
||||||
$text = "<div style='text-align:center'>
|
$text = "<div style='text-align:center'>
|
||||||
<form method='post' action='".e_SELF."' id='linkform'>
|
<form method='post' action='"
|
||||||
|
.e_SELF."' id='linkform'>
|
||||||
<table class='adminlist'>
|
<table class='adminlist'>
|
||||||
<tr>
|
<tr>
|
||||||
<td style='width:30%'>Cron Password</td>
|
<td style='width:30%'>Cron Password</td>
|
||||||
<td style='width:70%'>
|
<td style='width:70%'>
|
||||||
".$frm->password('cron_password',100)."
|
"
|
||||||
|
.$frm->password('cron_password', 100)."
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@@ -328,13 +305,14 @@ function setCronPwd()
|
|||||||
</form>
|
</form>
|
||||||
</div>";
|
</div>";
|
||||||
|
|
||||||
$ns -> tablerender(LAN_PREFS, $text);
|
e107::getRender()->tablerender(LAN_PREFS, $text);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function cronLoad() //TODO Make a generic function to work with e_cron, e_sitelink, e_url etc.
|
function cronLoad() //TODO Make a generic function to work with e_cron, e_sitelink, e_url etc.
|
||||||
|
|
||||||
{
|
{
|
||||||
global $pref;
|
$pref = e107::getPref();
|
||||||
|
|
||||||
$core_cron = $this->coreCrons; // May need to check 'available' flag here
|
$core_cron = $this->coreCrons; // May need to check 'available' flag here
|
||||||
$new_cron = e107::getAddonConfig('e_cron');
|
$new_cron = e107::getAddonConfig('e_cron');
|
||||||
@@ -343,13 +321,11 @@ function setCronPwd()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ----------- Grab All e_cron parameters -----------------------------------
|
// ----------- Grab All e_cron parameters -----------------------------------
|
||||||
|
|
||||||
function cronRenderPage()
|
function cronRenderPage()
|
||||||
{
|
{
|
||||||
global $pref;
|
$pref = e107::getPref();
|
||||||
$cronpref = $pref['e_cron_pref'];
|
$cronpref = $pref['e_cron_pref'];
|
||||||
$ns = e107::getRender();
|
$ns = e107::getRender();
|
||||||
$frm = e107::getForm();
|
$frm = e107::getForm();
|
||||||
@@ -357,11 +333,11 @@ function setCronPwd()
|
|||||||
|
|
||||||
$e_cron = $this->e_cron;
|
$e_cron = $this->e_cron;
|
||||||
|
|
||||||
|
|
||||||
// ---------------------- List All Functions -----------------------------
|
// ---------------------- List All Functions -----------------------------
|
||||||
|
|
||||||
$text = "<div style='text-align:center'>
|
$text = "<div style='text-align:center'>
|
||||||
<form method='post' action='".e_SELF."' id='cronform'>
|
<form method='post' action='"
|
||||||
|
.e_SELF."' id='cronform'>
|
||||||
<table class='adminlist'>
|
<table class='adminlist'>
|
||||||
<colgroup span='8'>
|
<colgroup span='8'>
|
||||||
<col></col>
|
<col></col>
|
||||||
@@ -375,14 +351,22 @@ function setCronPwd()
|
|||||||
</colgroup>
|
</colgroup>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>".LAN_CRON_1."</th>
|
<th>"
|
||||||
<th>".LAN_CRON_2."</th>
|
.LAN_CRON_1."</th>
|
||||||
<th>".LAN_CRON_3."</th>
|
<th>"
|
||||||
<th>".LAN_CRON_4."</th>
|
.LAN_CRON_2."</th>
|
||||||
<th>".LAN_CRON_5."</th>
|
<th>"
|
||||||
<th>".LAN_CRON_6."</th>
|
.LAN_CRON_3."</th>
|
||||||
<th>".LAN_CRON_7."</th>
|
<th>"
|
||||||
<th>".LAN_CRON_8."</th>
|
.LAN_CRON_4."</th>
|
||||||
|
<th>"
|
||||||
|
.LAN_CRON_5."</th>
|
||||||
|
<th>"
|
||||||
|
.LAN_CRON_6."</th>
|
||||||
|
<th>"
|
||||||
|
.LAN_CRON_7."</th>
|
||||||
|
<th>"
|
||||||
|
.LAN_CRON_8."</th>
|
||||||
<th>Run Now</th>
|
<th>Run Now</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -393,6 +377,7 @@ function setCronPwd()
|
|||||||
foreach ($cfg as $class => $cron)
|
foreach ($cfg as $class => $cron)
|
||||||
{
|
{
|
||||||
if (!isset($cron['available']) || $cron['available']) // Only display cron functions which are available
|
if (!isset($cron['available']) || $cron['available']) // Only display cron functions which are available
|
||||||
|
|
||||||
{
|
{
|
||||||
$c = $plug.'__'.$cron['function']; // class and function.
|
$c = $plug.'__'.$cron['function']; // class and function.
|
||||||
$sep = array();
|
$sep = array();
|
||||||
@@ -430,8 +415,10 @@ function setCronPwd()
|
|||||||
);
|
);
|
||||||
|
|
||||||
$text .= "<tr>
|
$text .= "<tr>
|
||||||
<td>".$cron['name']."</td>
|
<td>"
|
||||||
<td>".$cron['description']."</td>
|
.$cron['name']."</td>
|
||||||
|
<td>"
|
||||||
|
.$cron['description']."</td>
|
||||||
<td>
|
<td>
|
||||||
<input type='hidden' name='cron[$c][path]' value='".$cron['path']."' />
|
<input type='hidden' name='cron[$c][path]' value='".$cron['path']."' />
|
||||||
<select class='tbox' style='height:70px' multiple='multiple' name='tab[$c][minute][]'>\n";
|
<select class='tbox' style='height:70px' multiple='multiple' name='tab[$c][minute][]'>\n";
|
||||||
@@ -450,7 +437,6 @@ function setCronPwd()
|
|||||||
$text .= "<option value='$key' $sel>".$val."</option>\n";
|
$text .= "<option value='$key' $sel>".$val."</option>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for ($i = 0; $i <= 59; $i++)
|
for ($i = 0; $i <= 59; $i++)
|
||||||
{
|
{
|
||||||
$sel = (in_array(strval($i), $minute)) ? "selected='selected'" : "";
|
$sel = (in_array(strval($i), $minute)) ? "selected='selected'" : "";
|
||||||
@@ -555,7 +541,7 @@ function setCronPwd()
|
|||||||
|
|
||||||
function cronOptions()
|
function cronOptions()
|
||||||
{
|
{
|
||||||
$e107 = &e107::getInstance();
|
$e107 = e107::getInstance();
|
||||||
|
|
||||||
$var['main']['text'] = PAGE_NAME;
|
$var['main']['text'] = PAGE_NAME;
|
||||||
$var['main']['link'] = e_SELF;
|
$var['main']['link'] = e_SELF;
|
||||||
@@ -569,7 +555,6 @@ function setCronPwd()
|
|||||||
e_admin_menu(PAGE_NAME, $action, $var);
|
e_admin_menu(PAGE_NAME, $action, $var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function cronExecuteMethod($class_name, $method_name, $return = 'boolean')
|
function cronExecuteMethod($class_name, $method_name, $return = 'boolean')
|
||||||
{
|
{
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
@@ -579,7 +564,7 @@ function setCronPwd()
|
|||||||
$obj = new $class_name;
|
$obj = new $class_name;
|
||||||
if (method_exists($obj, $method_name))
|
if (method_exists($obj, $method_name))
|
||||||
{
|
{
|
||||||
$mes->add("Executing config function <b>".$key." : ".$method_name."()</b>", E_MESSAGE_DEBUG);
|
$mes->add("Executing config function <b>".$class_name." : ".$method_name."()</b>", E_MESSAGE_DEBUG);
|
||||||
if ($return == 'boolean')
|
if ($return == 'boolean')
|
||||||
{
|
{
|
||||||
call_user_func(array($obj, $method_name));
|
call_user_func(array($obj, $method_name));
|
||||||
@@ -605,5 +590,4 @@ function cron_adminmenu()
|
|||||||
$cron->cronOptions();
|
$cron->cronOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
Reference in New Issue
Block a user