mirror of
https://github.com/e107inc/e107.git
synced 2025-07-29 19:00:26 +02:00
Bit of work on admin -> crons
This commit is contained in:
@@ -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.1 $
|
| $Revision: 1.2 $
|
||||||
| $Date: 2008-06-17 05:39:22 $
|
| $Date: 2009-07-08 12:01:06 $
|
||||||
| $Author: e107coders $
|
| $Author: e107coders $
|
||||||
+----------------------------------------------------------------------------+
|
+----------------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
@@ -25,9 +25,63 @@ if (!getperms('U'))
|
|||||||
$e_sub_cat = 'cron';
|
$e_sub_cat = 'cron';
|
||||||
|
|
||||||
require_once('auth.php');
|
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;
|
||||||
|
|
||||||
if(isset($_POST['submit']))
|
require_once(e_ADMIN."footer.php");
|
||||||
|
exit;
|
||||||
|
|
||||||
|
class cron
|
||||||
{
|
{
|
||||||
|
var $coreCrons = array();
|
||||||
|
var $cronAction;
|
||||||
|
|
||||||
|
function cron()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->cronAction = e_QUERY;
|
||||||
|
|
||||||
|
if(isset($_POST['submit']))
|
||||||
|
{
|
||||||
|
$this -> cronSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_POST['save_prefs']))
|
||||||
|
{
|
||||||
|
$this -> cronSavePrefs();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set Core Cron Options.
|
||||||
|
|
||||||
|
$this->coreCrons[] = array('name'=>'User Purge','function' => 'user_purge', 'description'=>'Purge Unactivated Users');
|
||||||
|
$this->coreCrons[] = array('name'=>'User UnActivated','function' => 'user_unactivated', 'description'=>'Resend activation email to unactivated users.');
|
||||||
|
$this->coreCrons[] = array('name'=>'News Sticky','function' => 'news_purge', 'description'=>'Remove Sticky News Items');
|
||||||
|
|
||||||
|
// These core functions need to be put into e_BASE/cron.php ie. news_purge()
|
||||||
|
|
||||||
|
if($this->cronAction == "" || $this->cronAction == "main")
|
||||||
|
{
|
||||||
|
$this -> cronRenderPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->cronAction == "pref")
|
||||||
|
{
|
||||||
|
$this -> cronRenderPrefs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function cronSavePref()
|
||||||
|
{
|
||||||
|
// Store the USERID with the password.
|
||||||
|
// This way only the one password is needed, and the user login can be looked up in e_base/cron.php
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function cronSave()
|
||||||
|
{
|
||||||
|
global $pref;
|
||||||
foreach($_POST['cron'] as $key=>$val)
|
foreach($_POST['cron'] as $key=>$val)
|
||||||
{
|
{
|
||||||
if(!$val['active'])
|
if(!$val['active'])
|
||||||
@@ -47,18 +101,70 @@ if(isset($_POST['submit']))
|
|||||||
}
|
}
|
||||||
|
|
||||||
$pref['e_cron_pref'] = $cron;
|
$pref['e_cron_pref'] = $cron;
|
||||||
save_prefs();
|
$emessage = &eMessage::getInstance();
|
||||||
$ns -> tablerender(LAN_SAVED,"<div style='text-align:center'>".LAN_SETSAVED."</div>");
|
if(save_prefs())
|
||||||
}
|
{
|
||||||
|
$emessage->add(LAN_SETSAVED, E_MESSAGE_SUCCESS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$emessage->add("There was a problem saving your settings.", E_MESSAGE_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
function cronRenderPrefs()
|
||||||
|
{
|
||||||
|
global $frm,$ns;
|
||||||
|
|
||||||
|
$text = "<div style='text-align:center'>
|
||||||
|
<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)."
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style='width:30%'>bcc: </td>
|
||||||
|
<td style='width:70%'>
|
||||||
|
<input type='text' name='name2' class='tbox' style='width:80%' value='' />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr style='vertical-align:top'>
|
||||||
|
<td colspan='2' class='center buttons-bar'>";
|
||||||
|
$text .= $frm->admin_button('save_prefs',LAN_SAVE, 'update');
|
||||||
|
$text .= "</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
</div>";
|
||||||
|
|
||||||
|
$ns -> tablerender(LAN_PREFS, $text);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$cronpref = $pref['e_cron_pref'];
|
|
||||||
|
|
||||||
// ----------- Grab All e_cron parameters -----------------------------------
|
// ----------- Grab All e_cron parameters -----------------------------------
|
||||||
|
|
||||||
$count = 0;
|
function cronRenderPage()
|
||||||
foreach($pref['e_cron_list'] as $key=>$val)
|
{
|
||||||
{
|
global $pref,$ns,$frm;
|
||||||
|
$cronpref = $pref['e_cron_pref'];
|
||||||
|
|
||||||
|
// $count = 0;
|
||||||
|
|
||||||
|
$e_cron = $this->coreCrons;
|
||||||
|
$count = count($this->coreCrons);
|
||||||
|
|
||||||
|
foreach($pref['e_cron_list'] as $key=>$val)
|
||||||
|
{
|
||||||
$eplug_cron = array();
|
$eplug_cron = array();
|
||||||
if(is_readable(e_PLUGIN.$key."/e_cron.php"))
|
if(is_readable(e_PLUGIN.$key."/e_cron.php"))
|
||||||
{
|
{
|
||||||
@@ -73,27 +179,40 @@ foreach($pref['e_cron_list'] as $key=>$val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------- 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='linkform'>
|
<form method='post' action='".e_SELF."' id='cronform'>
|
||||||
<table style='".ADMIN_WIDTH."' class='fborder'>
|
<table class='adminlist'>
|
||||||
|
<colgroup span='8'>
|
||||||
|
<col></col>
|
||||||
|
<col></col>
|
||||||
|
<col></col>
|
||||||
|
<col></col>
|
||||||
|
<col></col>
|
||||||
|
<col></col>
|
||||||
|
<col></col>
|
||||||
|
<col></col>
|
||||||
|
</colgroup>
|
||||||
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td class='fcaption'>".LAN_CRON_1."</td>
|
<th>".LAN_CRON_1."</th>
|
||||||
<td class='fcaption'>".LAN_CRON_2."</td>
|
<th>".LAN_CRON_2."</th>
|
||||||
<td class='fcaption'>".LAN_CRON_3."</td>
|
<th>".LAN_CRON_3."</th>
|
||||||
<td class='fcaption'>".LAN_CRON_4."</td>
|
<th>".LAN_CRON_4."</th>
|
||||||
<td class='fcaption'>".LAN_CRON_5."</td>
|
<th>".LAN_CRON_5."</th>
|
||||||
<td class='fcaption'>".LAN_CRON_6."</td>
|
<th>".LAN_CRON_6."</th>
|
||||||
<td class='fcaption'>".LAN_CRON_7."</td>
|
<th>".LAN_CRON_7."</th>
|
||||||
<td class='fcaption'>".LAN_CRON_8."</td>
|
<th>".LAN_CRON_8."</th>
|
||||||
</tr>";
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>";
|
||||||
|
|
||||||
|
|
||||||
foreach($e_cron as $cron)
|
foreach($e_cron as $cron)
|
||||||
{
|
{
|
||||||
$c = $cron['function'];
|
$c = $cron['function'];
|
||||||
$sep = array();
|
$sep = array();
|
||||||
|
|
||||||
@@ -129,9 +248,9 @@ foreach($e_cron as $cron)
|
|||||||
);
|
);
|
||||||
|
|
||||||
$text .= "<tr>
|
$text .= "<tr>
|
||||||
<td class='forumheader3'>".$cron['name']."</td>
|
<td>".$cron['name']."</td>
|
||||||
<td class='forumheader3'>".$cron['description']."</td>
|
<td>".$cron['description']."</td>
|
||||||
<td class='forumheader3'>
|
<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";
|
||||||
|
|
||||||
@@ -157,7 +276,7 @@ foreach($e_cron as $cron)
|
|||||||
}
|
}
|
||||||
$text .= "</select>
|
$text .= "</select>
|
||||||
</td>
|
</td>
|
||||||
<td class='forumheader3'>
|
<td>
|
||||||
<select class='tbox' style='height:70px' multiple='multiple' name='tab[$c][hour][]'>
|
<select class='tbox' style='height:70px' multiple='multiple' name='tab[$c][hour][]'>
|
||||||
\n";
|
\n";
|
||||||
|
|
||||||
@@ -183,7 +302,7 @@ foreach($e_cron as $cron)
|
|||||||
}
|
}
|
||||||
$text .= "</select>
|
$text .= "</select>
|
||||||
</td>
|
</td>
|
||||||
<td class='forumheader3'>
|
<td>
|
||||||
<select class='tbox' style='height:70px' multiple='multiple' name='tab[$c][day][]'>\n";
|
<select class='tbox' style='height:70px' multiple='multiple' name='tab[$c][day][]'>\n";
|
||||||
|
|
||||||
$sel_day = ($day[0] == "*") ? "selected='selected'" : "";
|
$sel_day = ($day[0] == "*") ? "selected='selected'" : "";
|
||||||
@@ -196,7 +315,7 @@ foreach($e_cron as $cron)
|
|||||||
}
|
}
|
||||||
$text .= "</select>
|
$text .= "</select>
|
||||||
</td>
|
</td>
|
||||||
<td class='forumheader3'>
|
<td>
|
||||||
<select class='tbox' style='height:70px' multiple='multiple' name='tab[$c][month][]'>\n";
|
<select class='tbox' style='height:70px' multiple='multiple' name='tab[$c][month][]'>\n";
|
||||||
|
|
||||||
$sel_month = ($month[0] == "*") ? "selected='selected'" : "";
|
$sel_month = ($month[0] == "*") ? "selected='selected'" : "";
|
||||||
@@ -210,7 +329,7 @@ foreach($e_cron as $cron)
|
|||||||
}
|
}
|
||||||
$text .= "</select>
|
$text .= "</select>
|
||||||
</td>
|
</td>
|
||||||
<td class='forumheader3'>
|
<td>
|
||||||
<select class='tbox' style='height:70px' multiple='multiple' name='tab[$c][weekday][]'>\n";
|
<select class='tbox' style='height:70px' multiple='multiple' name='tab[$c][weekday][]'>\n";
|
||||||
|
|
||||||
$sel_weekday = ($weekday[0] == "*") ? "selected='selected'" : "";
|
$sel_weekday = ($weekday[0] == "*") ? "selected='selected'" : "";
|
||||||
@@ -224,28 +343,54 @@ foreach($e_cron as $cron)
|
|||||||
}
|
}
|
||||||
$text .= "</select>
|
$text .= "</select>
|
||||||
</td>
|
</td>
|
||||||
<td class='forumheader3' style='text-align:center'>";
|
<td style='text-align:center'>";
|
||||||
$checked = ($cronpref[$c]['active'] == 1) ? "checked='checked'" : "";
|
$checked = ($cronpref[$c]['active'] == 1) ? "checked='checked'" : "";
|
||||||
$text .= "<input type='checkbox' name='cron[$c][active]' value='1' $checked />
|
$text .= "<input type='checkbox' name='cron[$c][active]' value='1' $checked />
|
||||||
</td>
|
</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$text .= "
|
$text .= "
|
||||||
|
|
||||||
<tr style='vertical-align:top'>
|
<tr >
|
||||||
<td colspan='8' style='text-align:center' class='forumheader'>";
|
<td colspan='8' class='center'>
|
||||||
$text .= "<input class='button' type='submit' name='submit' value='".LAN_SAVE."' />";
|
<div class='center buttons-bar'>";
|
||||||
$text .= "</td>
|
// $text .= "<input class='button' type='submit' name='submit' value='".LAN_SAVE."' />";
|
||||||
|
$text .= $frm->admin_button('submit', LAN_SAVE, $action = 'update');
|
||||||
|
$text .= "</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
</div>";
|
</div>";
|
||||||
|
|
||||||
$ns -> tablerender(PAGE_NAME, $text);
|
$emessage = &eMessage::getInstance();
|
||||||
|
$ns -> tablerender(PAGE_NAME, $emessage->render() . $text);
|
||||||
|
}
|
||||||
|
|
||||||
|
function cronOptions()
|
||||||
|
{
|
||||||
|
$e107 = &e107::getInstance();
|
||||||
|
|
||||||
|
$var['main']['text'] = PAGE_NAME;
|
||||||
|
$var['main']['link'] = e_SELF;
|
||||||
|
|
||||||
|
$var['pref']['text'] = LAN_PREFS;
|
||||||
|
$var['pref']['link'] = e_SELF."?pref";
|
||||||
|
$var['pref']['perm'] = "N";
|
||||||
|
|
||||||
|
$action = ($this->cronAction) ? $this->cronAction : "main";
|
||||||
|
|
||||||
|
e_admin_menu(PAGE_NAME, $action, $var);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
require_once(e_ADMIN."footer.php");
|
function cron_adminmenu()
|
||||||
exit;
|
{
|
||||||
|
global $cron;
|
||||||
|
$cron->cronOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
Reference in New Issue
Block a user