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,59 +12,51 @@
namespace IPS\downloads\extensions\core\IpAddresses;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\DateTime;
use IPS\Db;
use IPS\downloads\File;
use IPS\Extensions\IpAddressesAbstract;
use IPS\Helpers\Table\Db as TableDb;
use IPS\Http\Url;
use IPS\Http\Useragent;
use IPS\Member;
use IPS\Output\Plugin\Filesize;
use IPS\Theme;
use OutOfRangeException;
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;
}
/**
* IP Address Lookup extension
*/
class _DownloadLog
class DownloadLog extends IpAddressesAbstract
{
/**
* Supported in the ACP IP address lookup tool?
*
* @return bool
* @note If the method does not exist in an extension, the result is presumed to be TRUE
*/
public function supportedInAcp()
{
return TRUE;
}
/**
* Supported in the ModCP IP address lookup tool?
*
* @return bool
* @note If the method does not exist in an extension, the result is presumed to be TRUE
*/
public function supportedInModCp(): bool
{
return TRUE;
}
/**
* Find Records by IP
*
* @param string $ip The IP Address
* @param \IPS\Http\Url $baseUrl URL table will be displayed on or NULL to return a count
* @return \IPS\Helpers\Table|int|null
* @param Url|null $baseUrl URL table will be displayed on or NULL to return a count
* @return string|int|null
*/
public function findByIp( $ip, \IPS\Http\Url $baseUrl = NULL )
public function findByIp( string $ip, ?Url $baseUrl = NULL ): string|int|null
{
/* Return count */
if ( $baseUrl === NULL )
{
return \IPS\Db::i()->select( 'COUNT(*)', 'downloads_downloads', array( "dip LIKE ?", $ip ) )->first();
return Db::i()->select( 'COUNT(*)', 'downloads_downloads', array( "dip LIKE ?", $ip ) )->first();
}
/* Init Table */
$table = new \IPS\Helpers\Table\Db( 'downloads_downloads', $baseUrl, array( "dip LIKE ?", $ip ) );
$table = new TableDb( 'downloads_downloads', $baseUrl, array( "dip LIKE ?", $ip ) );
$table->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'tables', 'core', 'admin' ), 'table' );
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'tables', 'core', 'admin' ), 'rows' );
$table->tableTemplate = array( Theme::i()->getTemplate( 'tables', 'core', 'admin' ), 'table' );
$table->rowsTemplate = array( Theme::i()->getTemplate( 'tables', 'core', 'admin' ), 'rows' );
$table->include = array( 'dfid', 'dtime', 'dsize', 'dua', 'dmid', 'dip' );
$table->sortBy = $table->sortBy ?: 'dtime';
@@ -75,30 +67,30 @@ class _DownloadLog
{
try
{
$file = \IPS\downloads\File::load( $val );
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $file->url(), TRUE, $file->name );
$file = File::load( $val );
return Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $file->url(), TRUE, $file->name );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException $e )
{
return \IPS\Member::loggedIn()->language()->addToStack('content_deleted');
return Member::loggedIn()->language()->addToStack('content_deleted');
}
},
'dtime' => function( $val )
{
return (string) \IPS\DateTime::ts( $val );
return (string) DateTime::ts( $val );
},
'dsize' => function( $val )
{
return \IPS\Output\Plugin\Filesize::humanReadableFilesize( $val );
return Filesize::humanReadableFilesize( $val );
},
'dua' => function( $val )
{
return (string) \IPS\Http\Useragent::parse( $val );
return (string) Useragent::parse( $val );
},
'dmid' => function( $val )
{
$member = \IPS\Member::load( $val );
return \IPS\Theme::i()->getTemplate( 'global', 'core' )->userPhoto( $member, 'tiny' ) . ' ' . $member->link();
$member = Member::load( $val );
return Theme::i()->getTemplate( 'global', 'core' )->userPhoto( $member, 'tiny' ) . ' ' . $member->link();
},
);
@@ -120,11 +112,13 @@ class _DownloadLog
...
);
* @endcode
* @param \IPS\Member $member The member
* @param Member $member The member
* @return array
*/
public function findByMember( $member )
public function findByMember( Member $member ) : array
{
return \IPS\Db::i()->select( "dip AS ip, count(*) AS count, MIN(dtime) AS first, MAX(dtime) AS last", 'downloads_downloads', array( "dmid=?", $member->member_id ), NULL, NULL, 'dip' )->setKeyField( 'ip' );
return iterator_to_array(
Db::i()->select( "dip AS ip, count(*) AS count, MIN(dtime) AS first, MAX(dtime) AS last", 'downloads_downloads', array( "dmid=?", $member->member_id ), NULL, NULL, 'dip' )->setKeyField( 'ip' )
);
}
}