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
@@ -5,71 +5,54 @@
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 8 Aug 2013␍
|
||||
* @since 8 Aug 2013
|
||||
|
||||
*/
|
||||
|
||||
namespace IPS\Application;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use FilesystemIterator;
|
||||
use IPS\Application;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Custom filter iterator for application building
|
||||
*/
|
||||
class _BuilderIterator extends \RecursiveIteratorIterator
|
||||
class BuilderIterator extends RecursiveIteratorIterator
|
||||
{
|
||||
/**
|
||||
* @brief The application
|
||||
*/
|
||||
protected $application;
|
||||
protected Application $application;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\Application $application
|
||||
* @param Application $application
|
||||
*/
|
||||
public function __construct( \IPS\Application $application )
|
||||
public function __construct( Application $application )
|
||||
{
|
||||
$this->application = $application;
|
||||
parent::__construct( new BuilderFilter( new \RecursiveDirectoryIterator( \IPS\ROOT_PATH . "/applications/" . $application->directory, \RecursiveDirectoryIterator::SKIP_DOTS ) ) );
|
||||
parent::__construct( new BuilderFilter( new RecursiveDirectoryIterator( \IPS\ROOT_PATH . "/applications/" . $application->directory, FilesystemIterator::SKIP_DOTS ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Current key
|
||||
*
|
||||
* @return void
|
||||
* @return string
|
||||
*/
|
||||
public function key()
|
||||
public function key() : string
|
||||
{
|
||||
return mb_substr( parent::current(), mb_strlen( \IPS\ROOT_PATH . "/applications/" . $this->application->directory ) + 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Current value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
$file = (string) parent::current();
|
||||
if ( mb_substr( str_replace( '\\', '/', $file ), mb_strlen( \IPS\ROOT_PATH . "/applications/" . $this->application->directory ) + 1, 6 ) === 'hooks/' )
|
||||
{
|
||||
$temporary = tempnam( \IPS\TEMP_DIRECTORY, 'IPS' );
|
||||
\file_put_contents( $temporary, \IPS\Plugin::addExceptionHandlingToHookFile( $file ) );
|
||||
|
||||
register_shutdown_function( function( $temporary ) {
|
||||
unlink( $temporary );
|
||||
}, $temporary );
|
||||
|
||||
return $temporary;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user