Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -13,6 +13,12 @@
|
||||
// e.g: /usr/bin/php /path/to/site/applications/core/interface/task/task.php abc1234 6
|
||||
// would execute task with ID 6
|
||||
|
||||
use IPS\Application;
|
||||
use IPS\Log;
|
||||
use IPS\Settings;
|
||||
use IPS\Task;
|
||||
use const IPS\CIC;
|
||||
|
||||
@header( "Cache-Control: no-cache, no-store, must-revalidate, max-age=0, s-maxage=0" );
|
||||
@header( "Expires: 0" );
|
||||
|
||||
@@ -24,8 +30,8 @@ if ( !isset( $_SERVER['argv'] ) )
|
||||
}
|
||||
|
||||
/* Init Invision Community */
|
||||
\define('READ_WRITE_SEPARATION', FALSE);
|
||||
\define('REPORT_EXCEPTIONS', TRUE);
|
||||
define('READ_WRITE_SEPARATION', FALSE);
|
||||
define('REPORT_EXCEPTIONS', TRUE);
|
||||
|
||||
$path = str_replace( 'interface/task/task.php', 'data/requirements.json', str_replace( '\\', '/', __FILE__ ) );
|
||||
|
||||
@@ -42,7 +48,7 @@ if( version_compare($phpVersion, $requirements['php']['required'] ) < 0 )
|
||||
|
||||
require_once str_replace( 'applications/core/interface/task/task.php', 'init.php', str_replace( '\\', '/', __FILE__ ) );
|
||||
|
||||
if ( !\IPS\CIC and $_SERVER['argv'][1] !== \IPS\Settings::i()->task_cron_key )
|
||||
if ( !CIC and $_SERVER['argv'][1] !== Settings::i()->task_cron_key )
|
||||
{
|
||||
echo "Incorrect key\n";
|
||||
exit;
|
||||
@@ -52,30 +58,30 @@ if ( !\IPS\CIC and $_SERVER['argv'][1] !== \IPS\Settings::i()->task_cron_key )
|
||||
try
|
||||
{
|
||||
/* Ensure applications set up correctly before task is executed. Pages, for example, needs to set up spl autoloaders first */
|
||||
\IPS\Application::applications();
|
||||
Application::applications();
|
||||
|
||||
if( isset( $_SERVER['argv'][2] ) )
|
||||
{
|
||||
$task = \IPS\Task::load( $_SERVER['argv'][2], ( \is_numeric( $_SERVER['argv'][2] ) ) ? NULL : 'key' );
|
||||
$task = Task::load( $_SERVER['argv'][2], ( is_numeric( $_SERVER['argv'][2] ) ) ? NULL : 'key' );
|
||||
|
||||
if ( !$task )
|
||||
{
|
||||
throw new \OutOfRangeException( 'NO_TASK' );
|
||||
throw new OutOfRangeException( 'NO_TASK' );
|
||||
}
|
||||
|
||||
$task->runAndLog();
|
||||
}
|
||||
else
|
||||
{
|
||||
while( $task = \IPS\Task::queued() )
|
||||
while( $task = Task::queued() )
|
||||
{
|
||||
$task->runAndLog();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch (Exception $e )
|
||||
{
|
||||
\IPS\Log::log( $e, 'uncaught_exception' );
|
||||
Log::log( $e, 'uncaught_exception' );
|
||||
|
||||
echo "Exception:\n";
|
||||
print_r( $e );
|
||||
|
||||
@@ -9,33 +9,41 @@
|
||||
*/
|
||||
|
||||
/* Init Invision Community */
|
||||
\define('REPORT_EXCEPTIONS', TRUE);
|
||||
\define('READ_WRITE_SEPARATION', FALSE);
|
||||
|
||||
use IPS\Application;
|
||||
use IPS\Log;
|
||||
use IPS\Login;
|
||||
use IPS\Request;
|
||||
use IPS\Settings;
|
||||
use IPS\Task;
|
||||
|
||||
define('REPORT_EXCEPTIONS', TRUE);
|
||||
define('READ_WRITE_SEPARATION', FALSE);
|
||||
require_once str_replace( 'applications/core/interface/task/web.php', 'init.php', str_replace( '\\', '/', __FILE__ ) );
|
||||
|
||||
@header( "Cache-Control: no-cache, no-store, must-revalidate, max-age=0, s-maxage=0" );
|
||||
@header( "Expires: 0" );
|
||||
|
||||
/* Set HTTP status */
|
||||
$http = ( isset( $_SERVER['SERVER_PROTOCOL'] ) and \strstr( $_SERVER['SERVER_PROTOCOL'], '/1.0' ) !== false ) ? '1.0' : '1.1';
|
||||
$http = ( isset( $_SERVER['SERVER_PROTOCOL'] ) and strstr( $_SERVER['SERVER_PROTOCOL'], '/1.0' ) !== false ) ? '1.0' : '1.1';
|
||||
|
||||
/* Execute */
|
||||
try
|
||||
{
|
||||
/* Ensure applications set up correctly before task is executed. Pages, for example, needs to set up spl autoloaders first */
|
||||
\IPS\Application::applications();
|
||||
Application::applications();
|
||||
|
||||
if( \IPS\Settings::i()->task_use_cron != 'web' )
|
||||
if( Settings::i()->task_use_cron != 'web' )
|
||||
{
|
||||
throw new \OutOfRangeException( "Invalid Task Method" );
|
||||
throw new OutOfRangeException( "Invalid Task Method" );
|
||||
}
|
||||
|
||||
if( !\IPS\Login::compareHashes( (string) \IPS\Settings::i()->task_cron_key, (string) \IPS\Request::i()->key ) )
|
||||
if( !Login::compareHashes( (string) Settings::i()->task_cron_key, (string) Request::i()->key ) )
|
||||
{
|
||||
throw new \OutOfRangeException( "Invalid Key" );
|
||||
throw new OutOfRangeException( "Invalid Key" );
|
||||
}
|
||||
|
||||
$task = \IPS\Task::queued();
|
||||
$task = Task::queued();
|
||||
|
||||
if ( $task )
|
||||
{
|
||||
@@ -45,17 +53,17 @@ try
|
||||
@header( "HTTP/{$http} 200 OK" );
|
||||
print "Task Ran";
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch (OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Log::debug( $e, $e->getMessage() );
|
||||
Log::debug( $e, $e->getMessage() );
|
||||
|
||||
@header( "HTTP/{$http} 500 Internal Server Error" );
|
||||
echo "Exception:\n";
|
||||
print $e->getMessage();
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch (Exception $e )
|
||||
{
|
||||
\IPS\Log::log( $e, 'uncaught_exception' );
|
||||
Log::log( $e, 'uncaught_exception' );
|
||||
|
||||
@header( "HTTP/{$http} 500 Internal Server Error" );
|
||||
echo "Exception:\n";
|
||||
|
||||
Reference in new issue
Block a user