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

+38 -27
View File
@@ -11,48 +11,59 @@
namespace IPS\core\modules\admin\system;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\core\modules\front\system\ajax as SystemAjax;
use IPS\Db;
use IPS\Member;
use IPS\Output;
use IPS\Request;
use IPS\Session;
use function count;
use function defined;
use function file_put_contents;
use function is_array;
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;
}
/**
* Core AJAX Responders
*/
class _ajax extends \IPS\core\modules\front\system\ajax
class ajax extends SystemAjax
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
public static bool $csrfProtected = TRUE;
/**
* Save ACP Tabs
*
* @return void
*/
protected function saveTabs()
protected function saveTabs() : void
{
\IPS\Session::i()->csrfCheck();
if ( \is_array( \IPS\Request::i()->tabOrder ) )
{
$tabs = array();
Session::i()->csrfCheck();
foreach( \IPS\Request::i()->tabOrder as $topLevelTab )
$tabs = array();
if ( is_array( Request::i()->tabOrder ) )
{
foreach( Request::i()->tabOrder as $topLevelTab )
{
$tabs[ str_replace( "tab_", "", $topLevelTab ) ] = ( isset( \IPS\Request::i()->menuOrder[ $topLevelTab ] ) ) ? \IPS\Request::i()->menuOrder[ $topLevelTab ] : array();
$tabs[ str_replace( "tab_", "", $topLevelTab ) ] = ( isset( Request::i()->menuOrder[ $topLevelTab ] ) ) ? Request::i()->menuOrder[ $topLevelTab ] : array();
}
$tabs = json_encode( $tabs );
\IPS\Db::i()->insert( 'core_acp_tab_order', array( 'id' => \IPS\Member::loggedIn()->member_id, 'data' => $tabs ), TRUE );
Db::i()->insert( 'core_acp_tab_order', array( 'id' => Member::loggedIn()->member_id, 'data' => $tabs ), TRUE );
\IPS\Request::i()->setCookie( 'acpTabs', $tabs );
Request::i()->setCookie( 'acpTabs', $tabs );
}
\IPS\Output::i()->json( 'ok' );
Output::i()->json( ['message' =>'ok', 'tabs' => $tabs], 201 );
}
/**
@@ -60,38 +71,38 @@ class _ajax extends \IPS\core\modules\front\system\ajax
*
* @return void
*/
protected function searchKeywords()
protected function searchKeywords() : void
{
\IPS\Session::i()->csrfCheck();
Session::i()->csrfCheck();
if ( \IPS\IN_DEV )
{
$url = base64_decode( \IPS\Request::i()->url );
$url = base64_decode( Request::i()->url );
$qs = array();
parse_str( $url, $qs );
\IPS\Db::i()->delete( 'core_acp_search_index', array( 'url=?', $url ) );
Db::i()->delete( 'core_acp_search_index', array( 'url=?', $url ) );
$inserts = array();
foreach ( \IPS\Request::i()->keywords as $word )
foreach ( Request::i()->keywords as $word )
{
$inserts[] = array(
'url' => $url,
'keyword' => $word,
'app' => $qs['app'],
'lang_key' => \IPS\Request::i()->lang_key,
'restriction' => \IPS\Request::i()->restriction ?: NULL
'lang_key' => Request::i()->lang_key,
'restriction' => Request::i()->restriction ?: NULL
);
}
if( \count( $inserts ) )
if( count( $inserts ) )
{
\IPS\Db::i()->insert( 'core_acp_search_index', $inserts );
Db::i()->insert( 'core_acp_search_index', $inserts );
}
$keywords = array();
foreach ( \IPS\Db::i()->select( '*', 'core_acp_search_index', array( 'app=?', $qs['app'] ), 'url ASC, keyword ASC' ) as $word )
foreach ( Db::i()->select( '*', 'core_acp_search_index', array( 'app=?', $qs['app'] ), 'url ASC, keyword ASC' ) as $word )
{
$keywords[ $word['url'] ]['lang_key'] = $word['lang_key'];
$keywords[ $word['url'] ]['restriction'] = $word['restriction'];
@@ -104,9 +115,9 @@ class _ajax extends \IPS\core\modules\front\system\ajax
$keywords[ $url ]['keywords'] = array_unique( $entry['keywords'] );
}
\file_put_contents( \IPS\ROOT_PATH . "/applications/{$qs['app']}/data/acpsearch.json", json_encode( $keywords, JSON_PRETTY_PRINT ) );
file_put_contents( \IPS\ROOT_PATH . "/applications/{$qs['app']}/data/acpsearch.json", json_encode( $keywords, JSON_PRETTY_PRINT ) );
}
\IPS\Output::i()->json( 'ok' );
Output::i()->json( 'ok' );
}
}