Version 2.2.2

This commit is contained in:
Neo committed 2025-12-19 00:24:35 -08:00
1 parent 22f1b963ee
commit a3bb603c96
858 files changed
+479463 -188140

No files matched your search

+220
View File
@@ -0,0 +1,220 @@
<?php
/*
+--------------------------------------------------------------------------
| Invision Power Board 2.2.2
| =============================================
| by Matthew Mecham
| (c) 2001 - 2006 Invision Power Services, Inc.
| http://www.invisionpower.com
| =============================================
| Web: http://www.invisionboard.com
| http://www.ibresource.ru/products/invisionpowerboard/
| Time: Monday 05th of March 2007 10:10:54 PM
| Release: e3790216629e5a2aaf37070b32237f06
| 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
| Ïðàâà íà ïåðåâîä IBResource (http://www.ibresource.ru)
+---------------------------------------------------------------------------
| > $Date: 2006-05-25 10:15:22 -0400 (Thu, 25 May 2006) $
| > $Revision: 278 $
| > $Author: bfarber $
+---------------------------------------------------------------------------
|
| > API: Tasks
| > Module written by Brandon Farber
| > Date started: Oct 25th 2006 (15:16 EST)
|
+--------------------------------------------------------------------------
*/
/**
* API: Ìåíåäæåðà çàäà÷
*
* ÏÐÈÌÅÐ ÈÑÏÎËÜÇÎÂÀÍÈß
* <code>
* $api = new api_tasks();
* # Îïöèîíàëüíî - åñëè $ipsclass íå ïåðåäàåòñÿ â îáúåêò, îí áóäåò èíèöèàëèçèðîâàí ñàìîñòîÿòåëüíî
* $api->ipsclass =& $this->ipsclass;
* $api->api_init();
* $api->add_task( $path_to_xml_file );
* </code>
*
*
* @package InvisionPowerBoard
* @subpackage APIs
* @author Matt Mecham
* @copyright Invision Power Services, Inc.
* @version 2.1
*/
if ( ! defined( 'IPS_API_PATH' ) )
{
/**
* Define classes path
*/
define( 'IPS_API_PATH', dirname(__FILE__) ? dirname(__FILE__) : '.' );
}
if ( ! class_exists( 'api_core' ) )
{
require_once( IPS_API_PATH.'/api_core.php' );
}
/**
* API: Ìåíåäæåðà çàäà÷
*
* Êëàññ ïðåäîñòàâëÿåò âñå ìåòîäû API äëÿ äîáàâëåíèÿ çàäàíèé â ïëàíèðîâùèê ôîðóìà.
*
* @package InvisionPowerBoard
* @subpackage APIs
* @author Brandon Farber
* @version 2.2
* @since 2.2.0
*/
class api_tasks extends api_core
{
/**
* Îáúåêò ñóïåð-êëàññà IPS
*
* @var object
*/
//var $ipsclass;
var $xml;
var $error = '';
var $updated = 0;
var $inserted = 0;
/*-------------------------------------------------------------------------*/
// Äîáàâëåíèå çàäà÷/Ñîçäàíèå íîâîãî ñïèñêà çàäà÷
/*-------------------------------------------------------------------------*/
/**
* Äîáàâëÿåò çàäà÷ó â ïëàíèðîâùèê IPB, èëè ñîçäàåò íîâûé ñïèñîê çàäà÷ èç XML
*
* @param string Ïóòü ê xml-ôàéëó ñî ñïèñêîì çàäà÷
* @return void;
*/
function add_task( $xml_file_path='' )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$file = $xml_file_path ? $xml_file_path : ROOT_PATH . 'resources/tasks.xml';
$inserted = 0;
$updated = 0;
$tasks = array();
//-----------------------------------------
// Check
//-----------------------------------------
if ( ! file_exists( $file ) )
{
$this->error = 'no_file';
return;
}
//-----------------------------------------
// Get current task info
//-----------------------------------------
$this->ipsclass->DB->build_query( array( 'select' => '*',
'from' => 'task_manager' ) );
$this->ipsclass->DB->exec_query();
while( $row = $this->ipsclass->DB->fetch_row() )
{
$tasks[ $row['task_key'] ] = $row;
}
//-----------------------------------------
// Get XML
//-----------------------------------------
require_once( KERNEL_PATH.'class_xml.php' );
$xml = new class_xml();
$xml->lite_parser = 1;
//-----------------------------------------
// Get XML file (TASKS)
//-----------------------------------------
$task_xml = implode( "", file($file) );
//-----------------------------------------
// Unpack the datafile
//-----------------------------------------
$xml->xml_parse_document( $task_xml );
if ( ! is_array( $xml->xml_array['export']['group']['row'][0] ) )
{
//-----------------------------------------
// Ensure [0] is populated
//-----------------------------------------
$tmp = $xml->xml_array['export']['group']['row'];
unset($xml->xml_array['export']['group']['row']);
$xml->xml_array['export']['group']['row'][0] = $tmp;
}
//-----------------------------------------
// TASKS
//-----------------------------------------
foreach( $xml->xml_array['export']['group']['row'] as $id => $entry )
{
$newrow = array();
$_key = $entry['task_key']['VALUE'];
foreach( $entry as $f => $data )
{
if ( $f == 'VALUE' or $f == 'task_id' )
{
continue;
}
if ( $f == 'task_cronkey' )
{
$entry[ $f ]['VALUE'] = $tasks[ $_key ]['task_cronkey'] ? $tasks[ $_key ]['task_cronkey'] : md5( uniqid( microtime() ) );
}
if ( $f == 'task_next_run' )
{
$entry[ $f ]['VALUE'] = $tasks[ $_key ]['task_next_run'] ? $tasks[ $_key ]['task_next_run'] : time();
}
$newrow[$f] = $entry[ $f ]['VALUE'];
}
if ( $tasks[ $_key ]['task_key'] )
{
$this->updated++;
$this->ipsclass->DB->do_update( 'task_manager', $newrow, "task_key='" . $tasks[ $_key ]['task_key'] . "'" );
}
else
{
$this->inserted++;
$this->ipsclass->DB->do_insert( 'task_manager', $newrow );
}
}
return TRUE;
}
}
?>