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

@@ -11,29 +11,43 @@
namespace IPS\core\modules\front\system;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DateInterval;
use Exception;
use IPS\Data\Cache;
use IPS\DateTime;
use IPS\Dispatcher\Controller;
use IPS\Http\Url;
use IPS\Output;
use IPS\Request;
use IPS\Settings;
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;
}
/**
* Editor AJAX functions Controller
*/
class _pixabay extends \IPS\Dispatcher\Controller
class pixabay extends Controller
{
/**
* Show the dialog window
*
* @return void
* @throws \Exception
* @throws Exception
*/
protected function manage()
protected function manage() : void
{
if ( \IPS\Settings::i()->pixabay_enabled )
if ( Settings::i()->pixabay_enabled )
{
$output = \IPS\Theme::i()->getTemplate( 'system' )->pixabay( \IPS\Request::i()->uploader );
\IPS\Output::i()->sendOutput( $output );
$output = Theme::i()->getTemplate( 'system' )->pixabay( Request::i()->uploader );
Output::i()->sendOutput( $output );
}
}
@@ -41,23 +55,23 @@ class _pixabay extends \IPS\Dispatcher\Controller
* Search pixabay
*
* @return void
* @throws \Exception
* @throws Exception
*/
protected function search()
protected function search() : void
{
if ( \IPS\Settings::i()->pixabay_enabled )
if ( Settings::i()->pixabay_enabled )
{
$limit = isset( \IPS\Request::i()->limit ) ? \IPS\Request::i()->limit : 20;
$offset = isset( \IPS\Request::i()->offset ) ? \IPS\Request::i()->offset : 0;
$query = isset( \IPS\Request::i()->search ) ? \IPS\Request::i()->search : '';
$url = \IPS\Http\Url::external( "https://pixabay.com/api/" );
$limit = isset( Request::i()->limit ) ? Request::i()->limit : 20;
$offset = isset( Request::i()->offset ) ? Request::i()->offset : 0;
$query = isset( Request::i()->search ) ? Request::i()->search : '';
$url = Url::external( "https://pixabay.com/api/" );
$parameters = array(
'key' => \IPS\Settings::i()->pixabay_apikey,
'key' => Settings::i()->pixabay_apikey,
'image_type' => 'photo',
'per_page' => 20,
'page' => ( $offset ) ? ceil( $offset / 20 ) + 1 : 1,
'safesearch' => ( \IPS\Settings::i()->pixabay_safesearch ) ? 'true' : 'false',
'safesearch' => ( Settings::i()->pixabay_safesearch ) ? 'true' : 'false',
);
$parameters['q'] = urlencode( $query );
@@ -65,19 +79,19 @@ class _pixabay extends \IPS\Dispatcher\Controller
try
{
$request = \IPS\Data\Cache::i()->getWithExpire( $cacheKey, TRUE );
$request = Cache::i()->getWithExpire( $cacheKey, TRUE );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
$url = $url->setQueryString($parameters);
$request = json_decode( $url->request()->get()->content, true );
\IPS\Data\Cache::i()->storeWithExpire( $cacheKey, $request, \IPS\DateTime::create()->add( new \DateInterval('P1D') ), TRUE );
Cache::i()->storeWithExpire( $cacheKey, $request, DateTime::create()->add( new DateInterval('P1D') ), TRUE );
}
if ( isset( $request['message'] ) AND $request['message'] )
{
\IPS\Output::i()->json( array('error' => $request['message'] ) );
Output::i()->json( array('error' => $request['message'] ) );
}
@@ -88,15 +102,19 @@ class _pixabay extends \IPS\Dispatcher\Controller
'thumb' => $row['webformatURL'],
'url' => $row['largeImageURL'],
'imgid' => $row['id'],
'imageHeight' => $row['imageHeight'],
'imageWidth' => $row['imageWidth'],
'thumbHeight' => $row['webformatHeight'],
'thumbWidth' => $row['webformatWidth'],
);
}
if ( empty( $results['images'] ) )
{
\IPS\Output::i()->json( array( 'error' => \IPS\Theme::i()->getTemplate( 'system', 'core' )->noResults() ) );
Output::i()->json( array( 'error' => Theme::i()->getTemplate( 'system', 'core' )->noResults() ) );
}
\IPS\Output::i()->json( $results );
Output::i()->json( $results );
}
}
@@ -105,14 +123,14 @@ class _pixabay extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function getById()
protected function getById() : void
{
if ( isset( \IPS\Request::i()->id ) )
if ( isset( Request::i()->id ) )
{
$url = \IPS\Http\Url::external( "https://pixabay.com/api/" )->setQueryString( array(
'key' => \IPS\Settings::i()->pixabay_apikey,
'id' => \IPS\Request::i()->id
$url = Url::external( "https://pixabay.com/api/" )->setQueryString( array(
'key' => Settings::i()->pixabay_apikey,
'id' => Request::i()->id
) );
@@ -131,7 +149,7 @@ class _pixabay extends \IPS\Dispatcher\Controller
}
/* Now get the URL contents */
$data = \IPS\Http\Url::external( $url )->request()->get();
$data = Url::external( $url )->request()->get();
if ( ! $filename )
{
@@ -139,7 +157,7 @@ class _pixabay extends \IPS\Dispatcher\Controller
}
list( $image, $type ) = explode( '/', $data->httpHeaders['Content-Type'] );
\IPS\Output::i()->json( array( 'content' => base64_encode( $data->content ), 'type' => $data->httpHeaders['Content-Type'], 'imageType' => $type, 'filename' => $filename ) );
Output::i()->json( array( 'content' => base64_encode( $data->content ), 'type' => $data->httpHeaders['Content-Type'], 'imageType' => $type, 'filename' => $filename ) );
}
}
}