Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

@@ -12,16 +12,25 @@
namespace IPS\downloads\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;
}
/**
* tempFileCleanup Task
*/
class _tempFileCleanup extends \IPS\Task
class tempFileCleanup extends Task
{
/**
* Execute
@@ -32,40 +41,40 @@ class _tempFileCleanup 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( '*', 'downloads_files_records', array( 'record_file_id=0 AND record_time<?', \IPS\DateTime::create()->sub( new \DateInterval( 'P1D' ) )->getTimestamp() ) ) as $file )
foreach ( Db::i()->select( '*', 'downloads_files_records', array( 'record_file_id=0 AND record_time<?', DateTime::create()->sub( new DateInterval( 'P1D' ) )->getTimestamp() ) ) as $file )
{
try
{
\IPS\File::get( $file['record_type'] === 'upload' ? 'downloads_Files' : 'downloads_Screenshots', $file['record_location'] )->delete();
File::get( $file['record_type'] === 'upload' ? 'downloads_Files' : 'downloads_Screenshots', $file['record_location'] )->delete();
}
catch ( \Exception $e ) { }
catch ( Exception $e ) { }
if( $file['record_thumb'] )
{
try
{
\IPS\File::get( 'downloads_Screenshots', $file['record_thumb'] )->delete();
File::get( 'downloads_Screenshots', $file['record_thumb'] )->delete();
}
catch ( \Exception $e ) { }
catch ( Exception $e ) { }
}
if( $file['record_no_watermark'] )
{
try
{
\IPS\File::get( 'downloads_Screenshots', $file['record_no_watermark'] )->delete();
File::get( 'downloads_Screenshots', $file['record_no_watermark'] )->delete();
}
catch ( \Exception $e ) { }
catch ( Exception $e ) { }
}
}
\IPS\Db::i()->delete( 'downloads_files_records', array( 'record_file_id=0 AND record_time<?', \IPS\DateTime::create()->sub( new \DateInterval( 'P1D' ) )->getTimestamp() ) );
Db::i()->delete( 'downloads_files_records', array( 'record_file_id=0 AND record_time<?', DateTime::create()->sub( new DateInterval( 'P1D' ) )->getTimestamp() ) );
\IPS\Db::i()->delete( 'downloads_sessions', array( 'dsess_start<?', \IPS\DateTime::create()->sub( new \DateInterval( 'PT6H' ) )->getTimestamp() ) );
Db::i()->delete( 'downloads_sessions', array( 'dsess_start<?', DateTime::create()->sub( new DateInterval( 'PT6H' ) )->getTimestamp() ) );
return NULL;
}