mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
Cron "Run Now" is now functional.
This commit is contained in:
31
cron.php
31
cron.php
@@ -4,7 +4,7 @@
|
|||||||
+ ----------------------------------------------------------------------------+
|
+ ----------------------------------------------------------------------------+
|
||||||
|| e107 website system
|
|| e107 website system
|
||||||
|
|
|
|
||||||
| Copyright (C) 2001-2009 e107 Inc
|
| Copyright (C) 2008-2009 e107 Inc
|
||||||
| http://e107.org
|
| http://e107.org
|
||||||
|
|
|
|
||||||
|
|
|
|
||||||
@@ -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.6 $
|
| $Revision: 1.7 $
|
||||||
| $Date: 2009-10-24 10:07:30 $
|
| $Date: 2009-10-24 12:01:24 $
|
||||||
| $Author: e107coders $
|
| $Author: e107coders $
|
||||||
+----------------------------------------------------------------------------+
|
+----------------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
@@ -103,31 +103,6 @@ foreach($list as $func=>$val)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class _system_cron
|
|
||||||
{
|
|
||||||
|
|
||||||
// See admin/cron.php to configure more core cron function to be added below.
|
|
||||||
|
|
||||||
|
|
||||||
function myfunction()
|
|
||||||
{
|
|
||||||
// Whatever code you wish.
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function sendEmail() // Test Email.
|
|
||||||
{
|
|
||||||
global $pref;
|
|
||||||
require_once(e_HANDLER."mail.php");
|
|
||||||
$message = "Your Cron test worked correctly. Sent at ".date("r").".";
|
|
||||||
|
|
||||||
sendemail($pref['siteadminemail'], "e107 - TEST Email Sent by cron.".date("r"), $message, $pref['siteadmin'],$pref['siteadminemail'], $pref['siteadmin']);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// echo "<br />Cron '$cron_str0' last due at: " . date('r', $cron->getLastRanUnix()) . "<p>";
|
// echo "<br />Cron '$cron_str0' last due at: " . date('r', $cron->getLastRanUnix()) . "<p>";
|
||||||
|
@@ -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.11 $
|
| $Revision: 1.12 $
|
||||||
| $Date: 2009-10-24 10:48:11 $
|
| $Date: 2009-10-24 12:01:24 $
|
||||||
| $Author: e107coders $
|
| $Author: e107coders $
|
||||||
+----------------------------------------------------------------------------+
|
+----------------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
@@ -40,6 +40,7 @@ class cron
|
|||||||
{
|
{
|
||||||
var $coreCrons = array();
|
var $coreCrons = array();
|
||||||
var $cronAction;
|
var $cronAction;
|
||||||
|
var $e_cron = array();
|
||||||
|
|
||||||
function cron()
|
function cron()
|
||||||
{
|
{
|
||||||
@@ -47,18 +48,29 @@ class cron
|
|||||||
$mes = $mes = e107::getMessage();
|
$mes = $mes = e107::getMessage();
|
||||||
$this->cronAction = e_QUERY;
|
$this->cronAction = e_QUERY;
|
||||||
|
|
||||||
|
$this->coreCrons['_system_cron'] = array(
|
||||||
|
0 => array('name' => "Test Email", 'function' => "sendEmail", 'description' => "Send a test email to ".$pref['siteadminemail']."<br />Recommended to test the scheduling system."),
|
||||||
|
// 1 => array('name'=>'User Purge', 'function' => 'userPurge', 'description'=>'Purge Unactivated Users'),
|
||||||
|
// 2 => array('name'=>'User UnActivated', 'function' => 'userUnactivated', 'description'=>'Resend activation email to unactivated users.'),
|
||||||
|
// 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();
|
||||||
}
|
}
|
||||||
$this->lastRefresh();
|
|
||||||
|
|
||||||
|
|
||||||
if(isset($_POST['submit']))
|
if(isset($_POST['submit']))
|
||||||
{
|
{
|
||||||
$this -> cronSave();
|
$this->cronSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->lastRefresh();
|
||||||
|
$this->cronLoad();
|
||||||
|
|
||||||
if(isset($_POST['save_prefs']))
|
if(isset($_POST['save_prefs']))
|
||||||
{
|
{
|
||||||
$this -> cronSavePrefs();
|
$this -> cronSavePrefs();
|
||||||
@@ -66,18 +78,14 @@ class cron
|
|||||||
|
|
||||||
if(isset($_POST['execute']))
|
if(isset($_POST['execute']))
|
||||||
{
|
{
|
||||||
|
|
||||||
$class_func = key($_POST['execute']);
|
$class_func = key($_POST['execute']);
|
||||||
$this -> cronExecute($class_func);
|
$this -> cronExecute($class_func);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Core Cron Options.
|
// Set Core Cron Options.
|
||||||
|
|
||||||
$this->coreCrons['_system'] = array(
|
|
||||||
0 => array('name' => "Test Email", 'function' => "sendEmail", 'description' => "Send a test email to ".$pref['siteadminemail']."<br />Recommended to test the scheduling system."),
|
|
||||||
// 1 => array('name'=>'User Purge', 'function' => 'userPurge', 'description'=>'Purge Unactivated Users'),
|
|
||||||
// 2 => array('name'=>'User UnActivated', 'function' => 'userUnactivated', 'description'=>'Resend activation email to unactivated users.'),
|
|
||||||
// 3 => array('name'=>'News Sticky', 'function' => 'newsPurge', 'description'=>'Remove Sticky News Items')
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -106,7 +114,7 @@ class cron
|
|||||||
$ago = (time() - $lastload);
|
$ago = (time() - $lastload);
|
||||||
|
|
||||||
$active = ($ago < 125) ? TRUE : FALSE;
|
$active = ($ago < 125) ? TRUE : FALSE;
|
||||||
$status = ($active) ? "Enabled" : "Offline";
|
$status = ($active) ? LAN_ENABLED : LAN_DISABLED; // "Enabled" : "Offline";
|
||||||
|
|
||||||
$mes->add("Status: <b>".$status."</b>", E_MESSAGE_INFO);
|
$mes->add("Status: <b>".$status."</b>", E_MESSAGE_INFO);
|
||||||
|
|
||||||
@@ -132,22 +140,51 @@ class cron
|
|||||||
Using your server control panel (eg. cPanel,Plesk etc.) please create a crontab to run this command on your server every minute.";
|
Using your server control panel (eg. cPanel,Plesk etc.) please create a crontab to run this command on your server every minute.";
|
||||||
$mes->add($setpwd_message, E_MESSAGE_INFO);
|
$mes->add($setpwd_message, E_MESSAGE_INFO);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(count($list) && !is_executable(e_BASE."cron.php"))
|
||||||
|
{
|
||||||
|
$mes->add("Please CHMOD /cron.php to 777" , E_MESSAGE_WARNING);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function cronName($classname,$method)
|
||||||
|
{
|
||||||
|
$tp = e107::getParser();
|
||||||
|
|
||||||
|
foreach($this->e_cron as $class=>$val)
|
||||||
|
{
|
||||||
|
|
||||||
|
if($class == $classname)
|
||||||
|
{
|
||||||
|
foreach($val as $func)
|
||||||
|
{
|
||||||
|
if($func['function'] == $method)
|
||||||
|
{
|
||||||
|
return $tp->toHtml($func['name']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function cronExecute($class_func)
|
function cronExecute($class_func)
|
||||||
{
|
{
|
||||||
//TODO LANs
|
//TODO LANs
|
||||||
|
list($class_name,$method_name) = explode("__",$class_func);
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
if(!function_exists($func) || !call_user_func($func))
|
|
||||||
|
if($class_name =='_system_cron')
|
||||||
{
|
{
|
||||||
$mes->add("Error running ".$func."()", E_MESSAGE_ERROR);
|
require_once(e_HANDLER."cron_class.php");
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$mes->add("Success running ".$func."()", E_MESSAGE_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$status = $this->cronExecuteMethod($class_name,$method_name) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
|
||||||
|
$mes->add("Running <b>".$this->cronName($class_name,$method_name)."</b>", $status);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function cronSavePref()
|
function cronSavePref()
|
||||||
@@ -266,7 +303,33 @@ function setCronPwd()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cronLoad()
|
||||||
|
{
|
||||||
|
global $pref;
|
||||||
|
|
||||||
|
$core_cron = $this->coreCrons;
|
||||||
|
$new_cron = array();
|
||||||
|
|
||||||
|
if(vartrue($pref['e_cron_list']))
|
||||||
|
{
|
||||||
|
|
||||||
|
foreach($pref['e_cron_list'] as $key=>$val)
|
||||||
|
{
|
||||||
|
$eplug_cron = array();
|
||||||
|
if(is_readable(e_PLUGIN.$key."/e_cron.php"))
|
||||||
|
{
|
||||||
|
include_once(e_PLUGIN.$key."/e_cron.php");
|
||||||
|
|
||||||
|
$class_name = $key."_cron";
|
||||||
|
$method_name = 'config';
|
||||||
|
|
||||||
|
$this->cronExecuteMethod($class_name,$method_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->e_cron = array_merge($core_cron,$new_cron);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -280,44 +343,8 @@ function setCronPwd()
|
|||||||
$frm = e107::getForm();
|
$frm = e107::getForm();
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
|
|
||||||
$core_cron = $this->coreCrons;
|
$e_cron = $this->e_cron;
|
||||||
$new_cron = array();
|
|
||||||
|
|
||||||
if(vartrue($pref['e_cron_list']))
|
|
||||||
{
|
|
||||||
foreach($pref['e_cron_list'] as $key=>$val)
|
|
||||||
{
|
|
||||||
$eplug_cron = array();
|
|
||||||
if(is_readable(e_PLUGIN.$key."/e_cron.php"))
|
|
||||||
{
|
|
||||||
include_once(e_PLUGIN.$key."/e_cron.php");
|
|
||||||
|
|
||||||
$class_name = $key."_cron";
|
|
||||||
$method_name = 'config';
|
|
||||||
|
|
||||||
if(class_exists($class_name))
|
|
||||||
{
|
|
||||||
$obj = new $class_name;
|
|
||||||
if(method_exists($obj,$method_name))
|
|
||||||
{
|
|
||||||
$mes->add("Executing config function <b>".$key." : ".$method_name."()</b>", E_MESSAGE_DEBUG);
|
|
||||||
$new_cron[$key] = call_user_func(array($obj,$method_name));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$mes->add("Config function <b>".$method_name."()</b> NOT found.", E_MESSAGE_DEBUG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$e_cron = array_merge($core_cron,$new_cron);
|
|
||||||
|
|
||||||
// print_a($e_cron);
|
|
||||||
|
|
||||||
// ---------------------- List All Functions -----------------------------
|
// ---------------------- List All Functions -----------------------------
|
||||||
|
|
||||||
@@ -525,9 +552,30 @@ function setCronPwd()
|
|||||||
|
|
||||||
e_admin_menu(PAGE_NAME, $action, $var);
|
e_admin_menu(PAGE_NAME, $action, $var);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
function cronExecuteMethod($class_name,$method_name)
|
||||||
|
{
|
||||||
|
$mes = e107::getMessage();
|
||||||
|
|
||||||
|
if(class_exists($class_name))
|
||||||
|
{
|
||||||
|
$obj = new $class_name;
|
||||||
|
if(method_exists($obj,$method_name))
|
||||||
|
{
|
||||||
|
$mes->add("Executing config function <b>".$key." : ".$method_name."()</b>", E_MESSAGE_DEBUG);
|
||||||
|
call_user_func(array($obj,$method_name));
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mes->add("Config function <b>".$method_name."()</b> NOT found.", E_MESSAGE_DEBUG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function cron_adminmenu()
|
function cron_adminmenu()
|
||||||
{
|
{
|
||||||
global $cron;
|
global $cron;
|
||||||
|
@@ -1,22 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
+ ----------------------------------------------------------------------------+
|
+ ----------------------------------------------------------------------------+
|
||||||
| e107 website system
|
|| e107 website system
|
||||||
|
|
|
|
||||||
| <EFBFBD>Steve Dunstan 2001-2002
|
| Copyright (C) 2008-2009 e107 Inc
|
||||||
| http://e107.org
|
| http://e107.org
|
||||||
| jalist@e107.org
|
|
||||||
|
|
|
|
||||||
| Released under the terms and conditions of the
|
| Released under the terms and conditions of the
|
||||||
| GNU General Public License (http://gnu.org).
|
| GNU General Public License (http://gnu.org).
|
||||||
|
|
|
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_handlers/cli_class.php,v $
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/cli_class.php,v $
|
||||||
| $Revision: 1.2 $
|
| $Revision: 1.3 $
|
||||||
| $Date: 2008-01-22 02:06:35 $
|
| $Date: 2009-10-24 12:01:24 $
|
||||||
| $Author: e107coders $
|
| $Author: e107coders $
|
||||||
+----------------------------------------------------------------------------+
|
+----------------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (!defined('e107_INIT')) { exit; }
|
||||||
|
|
||||||
class eCLI
|
class eCLI
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@@ -1,4 +1,54 @@
|
|||||||
<?php /* $Id: cron_class.php,v 1.2 2009-07-23 08:34:20 marj_nl_fr Exp $ */
|
<?php
|
||||||
|
/*
|
||||||
|
+ ----------------------------------------------------------------------------+
|
||||||
|
|| e107 website system
|
||||||
|
|
|
||||||
|
| Copyright (C) 2008-2009 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_handlers/cron_class.php,v $
|
||||||
|
| $Revision: 1.3 $
|
||||||
|
| $Date: 2009-10-24 12:01:24 $
|
||||||
|
| $Author: e107coders $
|
||||||
|
+----------------------------------------------------------------------------+
|
||||||
|
*/
|
||||||
|
if (!defined('e107_INIT')) { exit; }
|
||||||
|
|
||||||
|
class _system_cron
|
||||||
|
{
|
||||||
|
|
||||||
|
// See admin/cron.php to configure more core cron function to be added below.
|
||||||
|
|
||||||
|
|
||||||
|
function myfunction()
|
||||||
|
{
|
||||||
|
// Whatever code you wish.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function sendEmail() // Test Email.
|
||||||
|
{
|
||||||
|
global $pref;
|
||||||
|
require_once(e_HANDLER."mail.php");
|
||||||
|
$message = "Your Cron test worked correctly. Sent at ".date("r").".";
|
||||||
|
|
||||||
|
sendemail($pref['siteadminemail'], "e107 - TEST Email Sent by cron.".date("r"), $message, $pref['siteadmin'],$pref['siteadminemail'], $pref['siteadmin']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* $Id: cron_class.php,v 1.3 2009-10-24 12:01:24 e107coders Exp $ */
|
||||||
|
|
||||||
/**####################################################################################################**\
|
/**####################################################################################################**\
|
||||||
Version: V1.01
|
Version: V1.01
|
||||||
|
Reference in New Issue
Block a user