Files
IPB/upload/sources/action_admin/task_manager.php
T
2025-12-19 00:21:15 -08:00

771 lines
26 KiB
PHP

<?php
/*
+--------------------------------------------------------------------------
| Invision Power Board 2.1.7
| =============================================
| by Matthew Mecham
| (c) 2001 - 2005 Invision Power Services, Inc.
| http://www.invisionpower.com
| =============================================
| Web: http://www.invisionboard.com
| http://www.ibresource.ru/products/invisionpowerboard/
| Time: Tuesday 18th of July 2006 05:56:00 PM
| Release: 52f408a29988b02f45b5e6f4ba5af0ae
| Licence Info: http://www.invisionboard.com/?license
| http://www.ibresource.ru/license
+---------------------------------------------------------------------------
| INVISION POWER BOARD IS NOT FREE / OPEN SOURCE!
+---------------------------------------------------------------------------
| INVISION POWER BOARD ÍÅ ßÂËßÅÒÑß ÁÅÑÏËÀÒÍÛÌ ÏÐÎÃÐÀÌÌÍÛÌ ÎÁÅÑÏÅ×ÅÍÈÅÌ!
| Ïðàâà íà ÏÎ ïðèíàäëåæàò Invision Power Services
+---------------------------------------------------------------------------
| > $Date: 2005-10-28 15:18:16 +0100 (Fri, 28 Oct 2005) $
| > $Revision: 67 $
| > $Author: bfarber $
+---------------------------------------------------------------------------
|
| > Task Manager
| > Module written by Matt Mecham
| > Date started: 27th January 2004
|
| > Module Version Number: 1.0.0
| > DBA Checked: Tue 25th May 2004
+--------------------------------------------------------------------------
*/
if ( ! defined( 'IN_ACP' ) )
{
print "<h1>Íåâåðíûé âõîä</h1> Ó Âàñ íåò äîñòóïà ê äèðåêòèâå ýòîãî ôàéëà. Åñëè Âû ïðîâîäèëè îáíîâëåíèÿ, óáåäèòåñü, ÷òî íå çàáûëè îáíîâèòü 'admin.php'.";
exit();
}
class ad_task_manager
{
# Global
var $ipsclass;
var $functions = "";
/**
* Section title name
*
* @var string
*/
var $perm_main = "tools";
/**
* Section title name
*
* @var string
*/
var $perm_child = "task";
function auto_run()
{
$this->ipsclass->form_code = "{$this->ipsclass->form_code}";
//-----------------------------------------
// Require and RUN !! THERES A BOMB
//-----------------------------------------
require_once( ROOT_PATH.'sources/lib/func_taskmanager.php' );
$this->functions = new func_taskmanager();
$this->functions->ipsclass =& $this->ipsclass;
//-----------------------------------------
// Load skin
//-----------------------------------------
$this->html = $this->ipsclass->acp_load_template('cp_skin_taskmanager');
//-----------------------------------------
// Continue
//-----------------------------------------
$this->ipsclass->admin->page_detail = "Ýòà ñåêöèÿ ñîäåðæèò âñå âàøè óñòàíîâëåííûå çàäà÷è.<br />Ïîæàëóéñòà, ó÷òèòå, ÷òî âñå ýòè çàäà÷è çàïóñêàþòñÿ òîëüêî òîãäà, êîãäà âàø ôîðóì äîñòóïåí ïîñåòèòåëÿì, ñëåäóþùèé çàïóñê ïðîèñõîäèò òîëüêî ïðè âûçîâå ôîðóìà.";
$this->ipsclass->admin->page_title = "Óïðàâëåíèå çàäà÷àìè";
//-----------------------------------------
// Kill globals - globals bad, Homer good.
//-----------------------------------------
$tmp_in = array_merge( $_GET, $_POST, $_COOKIE );
foreach ( $tmp_in as $k => $v )
{
unset($$k);
}
$this->ipsclass->admin->nav[] = array( $this->ipsclass->form_code, 'Óïðàâëåíèå çàäà÷àìè' );
//-----------------------------------------
// Using "do"?
//-----------------------------------------
if ( $this->ipsclass->input['j_do'] )
{
$this->ipsclass->input['code'] = $this->ipsclass->input['j_do'];
}
else if ( $this->ipsclass->input['do'] )
{
$this->ipsclass->input['code'] = $this->ipsclass->input['do'];
}
//-----------------------------------------
// What to do...
//-----------------------------------------
switch($this->ipsclass->input['code'])
{
case 'task_edit':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' );
$this->task_form('edit');
break;
case 'task_add':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':add' );
$this->task_form('add');
break;
case 'task_edit_do':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' );
$this->task_do_save('edit');
break;
case 'task_add_do':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':add' );
$this->task_do_save('add');
break;
case 'task_delete':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':remove' );
$this->task_delete_task();
break;
case 'task_run_now':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':runnow' );
$this->task_run_task();
break;
case 'task_unlock':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' );
$this->task_unlock();
break;
case 'log':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':log' );
$this->task_log_setup();
break;
case 'showlog':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':log' );
$this->task_log_show();
break;
case 'deletelog':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':remove' );
$this->task_log_delete();
break;
default:
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':' );
$this->task_show_tasks();
break;
}
}
/*-------------------------------------------------------------------------*/
// TASK LOG DELETE
/*-------------------------------------------------------------------------*/
function task_log_delete()
{
//-----------------------------------------
// SHOW 'EM
//-----------------------------------------
$prune = $this->ipsclass->input['task_prune'] ? $this->ipsclass->input['task_prune'] : 30;
$prune = time() - ( $prune * 86400 );
if ( $this->ipsclass->input['task_id'] != -1 )
{
$where = "log_title='".$this->ipsclass->input['task_id']."' AND log_date < $prune";
}
else
{
$where = "log_date < $prune";
}
$this->ipsclass->DB->simple_exec_query( array( 'delete' => 'task_logs', 'where' => $where ) );
$this->ipsclass->main_msg = 'Âûáðàííûå ëîãè âûïîëíåííûõ çàäà÷ óäàëåíû';
$this->task_log_setup();
}
/*-------------------------------------------------------------------------*/
// TASK LOG SHOW
/*-------------------------------------------------------------------------*/
function task_log_show()
{
//-----------------------------------------
// SHOW 'EM
//-----------------------------------------
$limit = $this->ipsclass->input['task_count'] ? $this->ipsclass->input['task_count'] : 30;
$limit = $limit > 150 ? 150 : $limit;
if ( $this->ipsclass->input['task_id'] != -1 )
{
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'task_logs', 'where' => "log_title='".$this->ipsclass->input['task_id']."'", 'order' => 'log_date DESC', 'limit' => array(0,$limit) ) );
}
else
{
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'task_logs', 'order' => 'log_date DESC', 'limit' => array(0,$limit) ) );
}
$this->ipsclass->DB->simple_exec();
$this->ipsclass->adskin->td_header[] = array( "Âûïîëíåííàÿ çàäà÷à" , "20%" );
$this->ipsclass->adskin->td_header[] = array( "Äàòà è Âðåìÿ" , "35%" );
$this->ipsclass->adskin->td_header[] = array( "Èíôîðìàöèÿ", "45%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Âûáðàííûå ëîãè çàäà÷" );
if ( $this->ipsclass->DB->get_num_rows() )
{
while ( $row = $this->ipsclass->DB->fetch_row() )
{
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "<b>{$row['log_title']}</b>",
$this->ipsclass->admin->get_date( $row['log_date'], 'SHORT' ),
"{$row['log_desc']}",
) );
}
}
else
{
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_basic("<center>Íåò çàïèñåé</center>");
}
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
$this->ipsclass->admin->output();
}
/*-------------------------------------------------------------------------*/
// TASK LOG START
/*-------------------------------------------------------------------------*/
function task_log_setup()
{
//-----------------------------------------
// Some set up
//-----------------------------------------
$tasks = array( 0 => array( -1, 'Âñå çàäà÷è' ) );
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'task_manager', 'order' => 'task_title' ) );
$this->ipsclass->DB->simple_exec();
while ( $pee = $this->ipsclass->DB->fetch_row() )
{
$tasks[] = array( $pee['task_title'], $pee['task_title'] );
}
//-----------------------------------------
// LAST FIVE ACTIONS
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'task_logs', 'order' => 'log_date DESC', 'limit' => array(0,5) ) );
$this->ipsclass->DB->simple_exec();
$this->ipsclass->adskin->td_header[] = array( "Âûïîëíåííàÿ çàäà÷à" , "20%" );
$this->ipsclass->adskin->td_header[] = array( "Äàòà Âðåìÿ" , "35%" );
$this->ipsclass->adskin->td_header[] = array( "Èíôîðìàöèÿ" , "45%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "5 ïîñëåäíèõ çàïóùåííûõ çàäà÷" );
if ( $this->ipsclass->DB->get_num_rows() )
{
while ( $row = $this->ipsclass->DB->fetch_row() )
{
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "<b>{$row['log_title']}</b>",
$this->ipsclass->admin->get_date( $row['log_date'], 'SHORT' ),
"{$row['log_desc']}",
) );
}
}
else
{
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_basic("<center>Íåò çàïèñåé</center>");
}
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
// Show more...
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'act' , 'task' ),
2 => array( 'code' , 'showlog' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( "&nbsp;" , "60%" );
$this->ipsclass->adskin->td_header[] = array( "&nbsp;" , "40%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Ïðîñìîòð ëîãîâ âûïîëíåííûõ çàäà÷" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "<b>Ïðîñìîòð ëîãîâ âûïîëíåííîé çàäà÷è:</b>",
$this->ipsclass->adskin->form_dropdown( 'task_id', $tasks )
) );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "<b>Ñêîëüêî âûâåñòè çàïèñåé?</b>",
$this->ipsclass->adskin->form_input( 'task_count', '30' )
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form('Ñìîòðåòü ëîãè');
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
// Delete...
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'act' , 'task' ),
2 => array( 'code' , 'deletelog' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( "&nbsp;" , "60%" );
$this->ipsclass->adskin->td_header[] = array( "&nbsp;" , "40%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Óäàëèòü ëîãè âûïîëíåííîé çàäà÷è" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "<b>Óäàëèòü ëîãè çàäà÷è:</b>",
$this->ipsclass->adskin->form_dropdown( 'task_id', $tasks )
) );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "<b>Óäàëèòü ëîãè ñòàðøå, ÷åì (â äíÿõ):</b>",
$this->ipsclass->adskin->form_input( 'task_prune', '30' )
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form('Óäàëèòü ëîãè');
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
$this->ipsclass->admin->output();
}
/*-------------------------------------------------------------------------*/
// UNLOCK TASK
/*-------------------------------------------------------------------------*/
function task_unlock()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$task_id = intval( $this->ipsclass->input['task_id'] );
$this->ipsclass->DB->do_update( 'task_manager', array( 'task_locked' => 0 ), "task_id=".$task_id );
$this->ipsclass->main_msg = 'Çàêðûòûå çàäà÷è óäàëåíû';
$this->task_show_tasks();
}
/*-------------------------------------------------------------------------*/
// RUN TASK
/*-------------------------------------------------------------------------*/
function task_run_task()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$task_id = intval( $this->ipsclass->input['task_id'] );
//-----------------------------------------
// Check
//-----------------------------------------
if ( ! $task_id )
{
$this->ipsclass->main_msg = 'Íå óêàçàí ID çàäà÷è, äåéñòâèå íå âûïîëíåíî';
$this->task_show_tasks();
}
$this_task = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'task_manager', 'where' => 'task_id='.$task_id ) );
if ( ! $this_task['task_id'] )
{
$this->ipsclass->main_msg = 'Íåò çàäà÷ äëÿ âûïîëíåíèÿ.';
$this->show_tasks();
}
if ( ! $this_task['task_enabled'] )
{
$this->ipsclass->main_msg = "Ýòà çàäà÷à îòêëþ÷åíà. Ïîæàëóéñòà, âêëþ÷èòå åå äî çàïóñêà.";
$this->task_show_tasks();
}
//-----------------------------------------
// Get new instance of functions
//-----------------------------------------
$func = new func_taskmanager();
$func->ipsclass =& $this->ipsclass;
//-----------------------------------------
// Locked?
//-----------------------------------------
if ( $this_task['task_locked'] > 0 )
{
$this->ipsclass->main_msg = "Ýòà çàäà÷à áûëà çàêðûòà â ". gmdate( 'j M Y - G:i', $this_task['task_locked'] ) ." è íå ìîæåò áûòü çàïóùåíà ïîêà Âû åå íå îòêðîåòå ñíîâà.";
$this->task_show_tasks();
}
$newdate = $func->generate_next_run($this_task);
$this->ipsclass->DB->do_update( 'task_manager', array( 'task_next_run' => $newdate, 'task_locked' => time() ), "task_id=".$this_task['task_id'] );
$func->save_next_run_stamp();
$func->root_path = ROOT_PATH;
if ( file_exists( $func->root_path.'sources/tasks/'.$this_task['task_file'] ) )
{
require_once( $func->root_path.'sources/tasks/'.$this_task['task_file'] );
$myobj = new task_item();
$myobj->register_class( $func );
$myobj->pass_task( $this_task );
$myobj->run_task();
$this->ipsclass->main_msg = 'Çàäà÷à óñïåøíî çàïóùåíà';
$this->task_show_tasks();
}
else
{
$this->ipsclass->main_msg = 'Íåâîçìîæíî íàéòè: '.$func->root_path.'sources/tasks/'.$this_task['task_file'];
$this->task_show_tasks();
}
}
/*-------------------------------------------------------------------------*/
// DELETE TASK
/*-------------------------------------------------------------------------*/
function task_delete_task()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$task_id = intval( $this->ipsclass->input['task_id'] );
//-----------------------------------------
// Check
//-----------------------------------------
$task = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'task_manager', 'where' => "task_id=$task_id" ) );
if ( $task['task_safemode'] and ! IN_DEV )
{
$this->ipsclass->main_msg = "Âû íå ìîæåòå óäàëèòü ýòó çàäà÷ó.";
$this->task_show_tasks();
return;
}
//-----------------------------------------
// Remove from the DB
//-----------------------------------------
$this->ipsclass->DB->simple_exec_query( array( 'delete' => 'task_manager', 'where' => 'task_id='.$task_id ) );
$this->functions->save_next_run_stamp();
$this->ipsclass->main_msg = 'Çàäà÷à óäàëåíà!';
$this->task_show_tasks();
}
/*-------------------------------------------------------------------------*/
// DO SAVE
/*-------------------------------------------------------------------------*/
function task_do_save($type='edit')
{
//-----------------------------------------
// INIT
//-----------------------------------------
$task_id = intval($this->ipsclass->input['task_id']);
$task_cronkey = $this->ipsclass->input['task_cronkey'];
//-----------------------------------------
// Check...
//-----------------------------------------
if ( $type == 'edit' )
{
if ( ! $task_id )
{
$this->ipsclass->main_msg = 'Íå óêàçàí ID çàäà÷è, äåéñòâèå íå âûïîëíåíî';
$this->task_form();
}
}
if ( ! $this->ipsclass->input['task_title'] )
{
$this->ipsclass->main_msg = 'Âû äîëæíû ââåñòè íàçâàíèå çàäà÷è.';
$this->task_form();
}
if ( ! $this->ipsclass->input['task_file'] )
{
$this->ipsclass->main_msg = 'Âû äîëæíû ââåñòè èìÿ ôàéëà äëÿ èñïîëíåíèÿ';
$this->task_form();
}
//-----------------------------------------
// Check the task file...
//-----------------------------------------
$this->ipsclass->input['task_file'] = str_replace( '../', '', $this->ipsclass->input['task_file'] );
//-----------------------------------------
// Compile task
//-----------------------------------------
$save = array( 'task_title' => $this->ipsclass->input['task_title'],
'task_description' => $this->ipsclass->input['task_description'],
'task_file' => $this->ipsclass->input['task_file'],
'task_week_day' => $this->ipsclass->input['task_week_day'],
'task_month_day' => $this->ipsclass->input['task_month_day'],
'task_hour' => $this->ipsclass->input['task_hour'],
'task_minute' => $this->ipsclass->input['task_minute'],
'task_log' => $this->ipsclass->input['task_log'],
'task_cronkey' => $this->ipsclass->input['task_cronkey'] ? $task_cronkey : md5(microtime()),
'task_enabled' => $this->ipsclass->input['task_enabled']
);
if ( IN_DEV )
{
$save['task_key'] = $this->ipsclass->input['task_key'];
$save['task_safemode'] = $this->ipsclass->input['task_safemode'];
}
//-----------------------------------------
// Get next run date...
//-----------------------------------------
$save['task_next_run'] = $this->functions->generate_next_run( $save );
if ( $type == 'edit' )
{
$this->ipsclass->DB->do_update( 'task_manager', $save, 'task_id='.$task_id );
$this->ipsclass->main_msg = 'Çàäà÷à óñïåøíî èçìåíåíà';
}
else
{
$this->ipsclass->DB->do_insert( 'task_manager', $save );
$this->ipsclass->main_msg = 'Çàäà÷à óñïåøíî ñîõðàíåíà';
}
$this->functions->save_next_run_stamp();
$this->task_show_tasks();
}
/*-------------------------------------------------------------------------*/
// Task Manager: Form
/*-------------------------------------------------------------------------*/
function task_form($type='edit')
{
//-----------------------------------------
// Init Vars
//-----------------------------------------
$form = array();
$task_id = intval( $this->ipsclass->input['task_id'] );
# Drop downs
$dropdows = array();
//-----------------------------------------
// Edit or add?
//-----------------------------------------
if ( $type == 'edit' )
{
$button = "Îòðåäàêòèðîâàòü çàäà÷ó";
$formbit = "task_edit_do";
$this->ipsclass->html_help_title = "";
$this->ipsclass->html_help_msg = "";
$task = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'task_manager', 'where' => "task_id=$task_id" ) );
if ( $task['task_safemode'] and ! IN_DEV )
{
$this->ipsclass->main_msg = "Âû íå ìîæåòå èçìåíèòü ýòó çàäà÷ó.";
$this->task_show_tasks();
return;
}
$title = "Èçìåíåíèå çàäà÷è: ".$group['cb_group_name'];
}
else
{
$button = "Äîáàâèòü ýòó çàäà÷ó";
$formbit = "task_add_do";
$this->ipsclass->html_help_title = "";
$this->ipsclass->html_help_msg = "";
$task = array();
$title = "Äîáàâëåíèå çàäà÷è";
}
//-----------------------------------------
// Create drop downs
//-----------------------------------------
$dropdown['_minute'] = array( 0 => array( '-1', 'Êàæäóþ ìèíóòó' ) );
$dropdown['_hour'] = array( 0 => array( '-1', 'Êàæäûé ÷àñ' ), 1 => array( '0', '0 - Ïîëíî÷ü' ) );
$dropdown['_wday'] = array( 0 => array( '-1', 'Êàæäûé äåíü íåäåëè' ) );
$dropdown['_mday'] = array( 0 => array( '-1', 'Êàæäûé äåíü ìåñÿöà' ) );
for( $i = 0 ; $i < 60; $i++ )
{
$dropdown['_minute'][] = array( $i, $i );
}
for( $i = 1 ; $i < 24; $i++ )
{
if ( $i < 12 )
{
$ampm = $i.' am';
}
else if ( $i == 12 )
{
$ampm = 'Ïîëäåíü';
}
else
{
$ampm = $i - 12 . ' pm';
}
$dropdown['_hour'][] = array( $i, $i. ' - ('.$ampm.')' );
}
for( $i = 1 ; $i < 32; $i++ )
{
$dropdown['_mday'][] = array( $i, $i );
}
$dropdown['_wday'][] = array( '0', 'Âîñêðåñåíüå' );
$dropdown['_wday'][] = array( '1', 'Ïîíåäåëüíèê' );
$dropdown['_wday'][] = array( '2', 'Âòîðíèê' );
$dropdown['_wday'][] = array( '3', 'Ñðåäà' );
$dropdown['_wday'][] = array( '4', '×åòâåðã' );
$dropdown['_wday'][] = array( '5', 'Ïÿòíèöà' );
$dropdown['_wday'][] = array( '6', 'Ñóááîòà' );
//-----------------------------------------
// Form elements
//-----------------------------------------
$form['task_title'] = $this->ipsclass->adskin->form_input( 'task_title' , $_POST['task_title'] ? $_POST['task_title'] : $task['task_title'] );
$form['task_description'] = $this->ipsclass->adskin->form_input( 'task_description', $_POST['task_description'] ? $_POST['task_description'] : $task['task_description'] );
$form['task_file'] = $this->ipsclass->adskin->form_simple_input( 'task_file' , $_POST['task_file'] ? $_POST['task_file'] : $task['task_file'] , '20' );
$form['task_minute'] = $this->ipsclass->adskin->form_dropdown( 'task_minute' , $dropdown['_minute'] , $_POST['task_minute'] ? $_POST['task_minute'] : $task['task_minute'] , 'onchange="updatepreview()"' );
$form['task_hour'] = $this->ipsclass->adskin->form_dropdown( 'task_hour' , $dropdown['_hour'] , $_POST['task_hour'] ? $_POST['task_hour'] : $task['task_hour'] , 'onchange="updatepreview()"' );
$form['task_week_day'] = $this->ipsclass->adskin->form_dropdown( 'task_week_day' , $dropdown['_wday'] , $_POST['task_week_day'] ? $_POST['task_week_day'] : $task['task_week_day'] , 'onchange="updatepreview()"' );
$form['task_month_day'] = $this->ipsclass->adskin->form_dropdown( 'task_month_day' , $dropdown['_mday'] , $_POST['task_month_day'] ? $_POST['task_month_day'] : $task['task_month_day'], 'onchange="updatepreview()"' );
$form['task_log'] = $this->ipsclass->adskin->form_yes_no( 'task_log' , $_POST['task_log'] ? $_POST['task_log'] : $task['task_log'] );
$form['task_enabled'] = $this->ipsclass->adskin->form_yes_no( 'task_enabled' , $_POST['task_enabled'] ? $_POST['task_enabled'] : $task['task_enabled'] );
if ( IN_DEV )
{
$form['task_key'] = $this->ipsclass->adskin->form_input( 'task_key' , $_POST['task_key'] ? $_POST['task_key'] : $task['task_key'] );
$form['task_safemode'] = $this->ipsclass->adskin->form_yes_no( 'task_safemode', $_POST['task_safemode'] ? $_POST['task_safemode'] : $task['task_safemode'] );
}
$this->ipsclass->html .= $this->html->task_manager_form( $form, $button, $formbit, $type, $title, $task );
$this->ipsclass->admin->output();
}
/*-------------------------------------------------------------------------*/
// Task Manager: Overview
/*-------------------------------------------------------------------------*/
function task_show_tasks()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$row = array();
$content = "";
//-----------------------------------------
// List tasks (pointless comment)
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'task_manager', 'order' => 'task_safemode, task_next_run' ) );
$this->ipsclass->DB->simple_exec();
while ( $row = $this->ipsclass->DB->fetch_row() )
{
$row['task_minute'] = $row['task_minute'] != '-1' ? $row['task_minute'] : '-';
$row['task_hour'] = $row['task_hour'] != '-1' ? $row['task_hour'] : '-';
$row['task_month_day'] = $row['task_month_day'] != '-1' ? $row['task_month_day'] : '-';
$row['task_week_day'] = $row['task_week_day'] != '-1' ? $row['task_week_day'] : '-';
if ( time() > $row['task_next_run'] )
{
$row['_image'] = 'task_run_now.gif';
}
else
{
$row['_image'] = 'task_run.gif';
}
$row['_next_run'] = gmdate( 'j.n.Y, G:i', $row['task_next_run'] );
if ( $row['task_enabled'] != 1 )
{
$row['_class'] = " style='color:gray'";
$row['_title'] = " (Îòêëþ÷åíî)";
$row['_next_run'] = "<span style='color:gray'><s>{$row['_next_run']}</s></span>";
}
$content .= $this->html->task_manager_row( $row );
}
//-------------------------------
// Print it
//-------------------------------
$this->ipsclass->html .= $this->html->task_manager_wrapper( $content, gmdate( 'j.n.Y, G:i' ) );
$this->ipsclass->admin->output();
}
}
?>