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