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
@@ -11,16 +11,25 @@
|
||||
namespace IPS\core\tasks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DateInterval;
|
||||
use Exception;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\File;
|
||||
use IPS\Task;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Task that removes files from core_files_temp that were never claimed
|
||||
*/
|
||||
class _cleanupfiles extends \IPS\Task
|
||||
class cleanupfiles extends Task
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
@@ -31,24 +40,24 @@ class _cleanupfiles extends \IPS\Task
|
||||
* Tasks should execute within the time of a normal HTTP request.
|
||||
*
|
||||
* @return mixed Message to log or NULL
|
||||
* @throws \IPS\Task\Exception
|
||||
* @throws Task\Exception
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : mixed
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_files_temp', array( 'time < ?', \IPS\DateTime::create()->sub( new \DateInterval( 'P1D' ) )->getTimestamp() ) ) as $file )
|
||||
foreach ( Db::i()->select( '*', 'core_files_temp', array( 'time < ?', DateTime::create()->sub( new DateInterval( 'P1D' ) )->getTimestamp() ) ) as $file )
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->delete( 'core_files_temp', array( '`id`=?', $file['id'] ) );
|
||||
Db::i()->delete( 'core_files_temp', array( '`id`=?', $file['id'] ) );
|
||||
|
||||
/* storage_extension was added in 4.1.14. If available, remove the file on disk too */
|
||||
if ( ! empty( $file['storage_extension'] ) )
|
||||
{
|
||||
\IPS\File::get( $file['storage_extension'], $file['contents'] )->delete();
|
||||
File::get( $file['storage_extension'], $file['contents'] )->delete();
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
catch ( Exception $e ) { }
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
Reference in new issue
Block a user