cron.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:9k
- <?php
- // +-------------------------------------------------------------+
- // | DeskPRO v [2.0.1 Production]
- // | Copyright (C) 2001 - 2004 Headstart Solutions Limited
- // | Supplied by WTN-WDYL
- // | Nullified by WTN-WDYL
- // | Distribution via WebForum, ForumRU and associated file dumps
- // +-------------------------------------------------------------+
- // | DESKPRO IS NOT FREE SOFTWARE
- // +-------------------------------------------------------------+
- // | License ID : Full Enterprise License =) ...
- // | License Owner : WTN-WDYL Team
- // +-------------------------------------------------------------+
- // | $RCSfile: cron.php,v $
- // | $Date: 2004/02/10 01:34:25 $
- // | $Revision: 1.19 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - Automatic task maintenance (administration interface)
- // +-------------------------------------------------------------+
- error_reporting(E_ALL & ~E_NOTICE);
- require_once('./global.php');
- //Nullify WTN-WDYL Team
- // default do
- $_REQUEST['do'] = trim($_REQUEST['do']);
- if (!isset($_REQUEST['do']) or $_REQUEST['do'] == "") {
- $_REQUEST['do'] = "list";
- }
- // globalise variables
- $global = array (
- array('id', 'number'),
- array('editvars')
- );
- rg($global);
- ############################### UPDATE CRON ###############################
- if ($_REQUEST['do'] == "update") {
- if (is_array($_REQUEST['name'])) {
- foreach ($_REQUEST[name] AS $key => $var) {
- if ($var != "") {
- $options[$var] = array('value' => $_REQUEST[value][$key], 'description' => $_REQUEST[description][$key], 'is_radio' => $_REQUEST[is_radio][$key]);
- }
- }
- }
- $options = serialize($options);
- $db->query("UPDATE cron_options SET options = '" . mysql_escape_string($options) . "' WHERE id = $id");
- $_REQUEST['do'] = "view";
- unset($editvars);
- alert('Task options updated.');
- }
- ############################### UPDATE CRON ###############################
- if ($_REQUEST['do'] == "update2") {
- if (developer_check(1)) {
- $db->query("UPDATE cron_options SET
- title = '" . mysql_escape_string($_REQUEST[name]) . "',
- description = '" . mysql_escape_string($_REQUEST[description]) . "',
- scriptname = '" . mysql_escape_string($_REQUEST[scriptname]) . "',
- day = '" . mysql_escape_string($_REQUEST[day]) . "',
- hour = '" . mysql_escape_string($_REQUEST[hour]) . "'
- WHERE id = $id
- ");
- } else {
- $db->query("UPDATE cron_options SET
- day = '" . mysql_escape_string($_REQUEST[day]) . "',
- hour = '" . mysql_escape_string($_REQUEST[hour]) . "'
- WHERE id = $id
- ");
- }
-
- $_REQUEST['do'] = "list";
- alert('Task settings updated.');
- }
- ############################### CREATE CRON JOB ###############################
- if ($_REQUEST['do'] == "create") {
- $db->query("INSERT INTO cron_options SET title = 'New Cron Job'");
- alert('Cron job created');
- $_REQUEST['do'] = 'list';
- }
- ############################### DELETE CRON JOB ###############################
- if ($_REQUEST['do'] == "delete") {
- if (!$_REQUEST['id']) {
- mistake('No ID was specified.');
- }
- $db->query("DELETE FROM cron_options WHERE id = '$_REQUEST[id]'");
- if (!$db->affected_rows()) {
- mistake('The specified ID doesn't exist.');
- } else {
- alert('Cron job deleted');
- }
- $_REQUEST['do'] = 'list';
- }
- ############################### LIST CRON JOBS ###############################
- if ($_REQUEST['do'] == "list") {
- admin_header('Scheduled Tasks', 'Manage');
- require_once(INCLUDE_PATH . 'functions/calendar_functions.php');
- $db->query("SELECT * FROM cron_options");
- while ($cron = $db->row_array()) {
-
- if ($cron['day']) {
- $cron['day'] = 'Yes';
- $cron['hour'] = 'No';
- } else {
- $cron['day'] = 'No';
- $cron['hour'] = "at " . time_ampm("$cron[hour]:00", 1);
- }
- $table[] = array(
- $cron[title],
- $cron[scriptname],
- $cron[day],
- $cron[hour],
- "<a href="cron.php?do=view&id=$cron[id]">View Options</a>",
- iff(developer_check(1), jprompt(
- 'This will delete this task. It will no longer be run.',
- "cron.php?do=delete&id=$cron[id]",
- 'Delete'
- ), 'n/a')
- );
- $secondrow[] = "<table width="100%" cellpadding="0" cellspacing="0" class="table_midheader"><tr><td><table cellspacing="1" cellpadding="3" width="100%"><tr><td bgcolor="FFFFFF">$cron[description]</td></tr></table></td></tr></table>";
- }
- $cols = array('Entry Name', 'Script Name', 'Run hourly', 'Run daily', 'Edit Options', 'Delete');
- table_header('Your Scheduled Task');
- table_content($cols, $table, '', '', '', $secondrow);
- table_footer();
- if (developer_check(1)) {
- echo "<center><a href="cron.php?do=create">Create a new scheduled task</a></center>";
- }
- }
- ############################### VIEW CRON ###############################
- if ($_REQUEST['do'] == "view") {
- admin_header('Scheduled Tasks', 'Manage');
- $cron = $db->query_return("SELECT * FROM cron_options WHERE id = $id");
- if (developer_check(1)) {
- $table[] = array("<b>Cron Name</b>", form_input('name', $cron[title]));
- $table[] = array("<b>Description</b>", form_textarea('description', 70, 7, $cron[description]));
- $table[] = array("<b>Filename</b>", form_input('scriptname', $cron[scriptname]));
- $table[] = array("<b>Run hourly</b>", form_checkbox_single('day', 1, $cron[day]));
-
- $array = make_numberarray(0, 23);
- $array = array(
- -1 => "Don't Run Daily",
- 0 => "Midnight",
- 1 => "1:00am",
- 2 => "2:00am",
- 3 => "3:00am",
- 4 => "4:00am",
- 5 => "5:00am",
- 6 => "6:00am",
- 7 => "7:00am",
- 8 => "8:00am",
- 9 => "9:00am",
- 10 => "10:00am",
- 11 => "11:00am",
- 12 => "Noon",
- 13 => "1:00pm",
- 14 => "2:00pm",
- 15 => "3:00pm",
- 16 => "4:00pm",
- 17 => "5:00pm",
- 18 => "6:00pm",
- 19 => "7:00pm",
- 20 => "8:00pm",
- 21 => "8:00pm",
- 22 => "10:00pm",
- 23 => "11:00pm"
- );
- $table[] = array("<b>Run daily</b><br />Choose hour to run", form_select('hour', $array, '', $cron[hour]));
- } else {
- $table[] = array("<b>Cron Name</b>", $cron[title]);
- $table[] = array("<b>Description</b>", $cron[description]);
- $table[] = array("<b>Filename</b>", $cron[scriptname]);
- $table[] = array("<b>Run hourly</b>", form_checkbox_single('day', 1, $cron[day]));
-
- $array = make_numberarray(0, 23);
- $array2[] = "";
- $array = array_merge($array2, $array);
- $table[] = array("<b>Run daily</b><br />Choose hour to run", form_select('hour', $array, '', $cron[hour]));
-
- }
- table_header('Scheduled Task Details', 'cron.php', array('do' => 'update2', 'id' => $id, 'editvars' => $editvars));
- table_content($cols, $table);
- table_footer('Update Values');
- unset($table);
- // get actual options
- $options = unserialize($cron[options]);
- if (is_array($options)) {
- foreach ($options AS $key => $var) {
-
- $i++;
- if (!$editvars) {
-
- if (developer_check(1)) {
- $table[] = array(
- "<b>$key</b>",
- $var[description],
- iff($var[is_radio], form_radio_yn($i, 'value', $var[value]), form_input($i, $var[value], '20', 'value'))
- );
- $cols = array('Variable Name', 'Description', 'Value');
- } else {
- $table[] = array(
- $var[description],
- iff($var[is_radio], form_radio_yn($i, 'value', $var[value]), form_input($i, $var[value], '20', 'value'))
- );
- $cols = array('Description', 'Value');
- }
- $hidden["name[" . $i . "]"] = $key;
- $hidden["description[" . $i . "]"] = $var[description];
- $hidden["is_radio[" . $i . "]"] = $var[is_radio];
- } else {
- $cols = array('Variable Name', 'Description', 'Value', 'Use Radio Element');
- $table[] = array(
- form_input($i, $key, 20, 'name'),
- form_textarea($i, 50, 3, $var[description], 'description'),
- form_input($i, $var[value], '20', 'value'),
- form_checkbox_single($i, 1, $var[is_radio], 'is_radio')
- );
- }
- }
- }
- if ($editvars) {
-
- $cols = array('Variable Name', 'Description', 'Value', 'Use Radio Element');
- $table[] = array(
- form_input($i+1, '', 20, 'name'),
- form_textarea($i+1, 50, 3, '', 'description'),
- form_input($i+1, '', '20', 'value'),
- form_checkbox_single($i, 1, 0, 'radio')
- );
- $table[] = array(
- form_input($i+2, '', 20, 'name'),
- form_textarea($i+2, 50, 3, '', 'description'),
- form_input($i+2, '', '20', 'value'),
- form_checkbox_single($i, 1, 0, 'radio')
- );
- }
-
- $hidden['do'] = "update";
- $hidden['id'] = $id;
- $hidden['editvars'] = $editvars;
-
- if (is_array($table) AND !$editvars) {
- table_header('Scheduled Task Options', 'cron.php', $hidden);
- table_content($cols, $table, '', '', '', $secondrow);
- table_footer('Update Values');
- }
- if (!$editvars AND developer_check(1)) {
- echo "<BR><BR><BR><center><a href="cron.php?do=view&id=$id&editvars=1"><b>Edit Variable Details</b></a></center>";
- } elseif (developer_check(1)) {
- echo "<BR><BR><BR><center><a href="cron.php?do=view&id=$id"><b>Display Variables</b></a></center>";
- }
- }