Version 4.0.13.1

This commit is contained in:
Neo committed 2025-12-19 04:57:54 -08:00
1 parent f9e857d255
commit c6a86f0d9b
7517 files changed
+597400 -668041

No files matched your search

@@ -0,0 +1,97 @@
<?php
/**
* @brief Core AJAX Responders
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 13 Mar 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\admin\system;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Core AJAX Responders
*/
class _ajax extends \IPS\core\modules\front\system\ajax
{
/**
* Save ACP Tabs
*
* @return void
*/
protected function saveTabs()
{
if ( is_array( \IPS\Request::i()->tabOrder ) )
{
$tabs = array();
foreach( \IPS\Request::i()->tabOrder as $topLevelTab )
{
$tabs[ str_replace( "tab_", "", $topLevelTab ) ] = ( isset( \IPS\Request::i()->menuOrder[ $topLevelTab ] ) ) ? \IPS\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 );
\IPS\Request::i()->setCookie( 'acpTabs', $tabs );
}
\IPS\Output::i()->json( 'ok' );
}
/**
* Save search keywords
*
* @return void
*/
protected function searchKeywords()
{
if ( \IPS\IN_DEV )
{
$url = base64_decode( \IPS\Request::i()->url );
$qs = array();
parse_str( $url, $qs );
\IPS\Db::i()->delete( 'core_acp_search_index', array( 'url=?', $url ) );
$inserts = array();
foreach ( \IPS\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
);
}
if( count( $inserts ) )
{
\IPS\Db::i()->insert( 'core_acp_search_index', $inserts );
}
$keywords = array();
foreach ( \IPS\Db::i()->select( '*', 'core_acp_search_index', array( 'app=?', $qs['app'] ) ) as $word )
{
$keywords[ $word['url'] ]['lang_key'] = $word['lang_key'];
$keywords[ $word['url'] ]['restriction'] = $word['restriction'];
$keywords[ $word['url'] ]['keywords'][] = $word['keyword'];
}
\file_put_contents( \IPS\ROOT_PATH . "/applications/{$qs['app']}/data/acpsearch.json", json_encode( $keywords ) );
}
\IPS\Output::i()->json( 'ok' );
}
}
@@ -0,0 +1,193 @@
<?php
/**
* @brief Background processes 'Run Now'
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 28 Jan 2015
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\admin\system;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Background processes 'Run Now'
*/
class _background extends \IPS\Dispatcher\Controller
{
/**
* Execute
*
* @return void
*/
public function execute()
{
parent::execute();
}
/**
* Manage
*
* @return void
*/
protected function manage()
{
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('background_process_run_title');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'system' )->backgroundProcessesRunNow();
}
/**
* Process
*
* @return void
*/
protected function process()
{
$self = $this;
$multiRedirect = new \IPS\Helpers\MultipleRedirect(
\IPS\Http\Url::internal('app=core&module=system&controller=background&do=process'),
function( $data ) use ( $self )
{
/* Make sure the task is locked */
$task = \IPS\Task::load('queue', 'key');
$task->running = TRUE;
$task->next_run = time() + 900;
$task->save();
if ( ! is_array( $data ) )
{
$count = $self->getCount();
return array( array( 'count' => $count, 'done' => 0 ), 'Starting...' );
}
else
{
try
{
$queueData = \IPS\Db::i()->select( '*', 'core_queue', NULL, 'priority ASC, RAND()', 1 )->first();
$newOffset = 0;
try
{
$extensions = \IPS\Application::load( $queueData['app'] )->extensions( 'core', 'Queue', FALSE );
if ( !isset( $extensions[ $queueData['key'] ] ) )
{
throw new \OutOfRangeException;
}
$class = new $extensions[ $queueData['key'] ];
$json = json_decode( $queueData['data'], TRUE );
$newOffset = $class->run( $json, $queueData['offset'] );
if ( is_null( $newOffset ) )
{
\IPS\Log::i( LOG_ERR )->write( "Finished " . json_encode( $queueData ), 'runQueue_log' );
\IPS\Db::i()->delete( 'core_queue', array( 'id=?', $queueData['id'] ) );
/* Update count */
$data['count'] = $self->getCount();
}
else
{
\IPS\Db::i()->update( 'core_queue', array( 'offset' => $newOffset ), array( 'id=?', $queueData['id'] ) );
$newData = json_encode( $json );
/* Did it change?? */
if ( $newData !== $json )
{
\IPS\Db::i()->update( 'core_queue', array( 'data' => $newData ), array( 'id=?', $queueData['id'] ) );
}
}
}
catch ( \OutOfRangeException $e )
{
\IPS\Log::i( LOG_ERR )->write( "Finished " . json_encode( $queueData ), 'runQueue_log' );
\IPS\Db::i()->delete( 'core_queue', array( 'id=?', $queueData['id'] ) );
/* Update count */
$data['count'] = $self->getCount();
}
}
catch ( \UnderflowException $e )
{
/* All done */
return NULL;
}
$data['done'] = $data['done'] + ( $newOffset - $queueData['offset'] );
$lang = array( $queueData['key'] );
if ( isset( $json['class'] ) )
{
$lang[] = $json['class'];
}
else if ( isset( $json['extension'] ) )
{
$lang[] = $json['extension'];
}
else if ( isset( $json['storageExtension'] ) )
{
$lang[] = $json['storageExtension'];
}
if ( isset( $json['count'] ) )
{
$lang[] = " " . intval( $newOffset ) . ' / ' . $json['count'];
}
return array( $data, \IPS\Member::loggedIn()->language()->addToStack('background_processes_processing', FALSE, array( 'sprintf' => array( implode( ' - ', $lang ) ) ) ), ( $data['count'] ) ? round( ( 100 / $data['count'] * $data['done'] ), 2 ) : 100 );
}
},
function()
{
/* Make sure the task is unlocked */
$task = \IPS\Task::load('queue', 'key');
$task->running = FALSE;
$task->next_run = time() + 60;
$task->save();
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=overview&controller=dashboard'), 'completed' );
}
);
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('background_process_run_title');
\IPS\Output::i()->output = $multiRedirect;
}
/**
* Get the count of items to process
*
* @return int
*/
public function getCount()
{
$count = 0;
foreach( \IPS\Db::i()->select( '*', 'core_queue' ) as $row )
{
if ( ! empty( $row['data'] ) )
{
$data = json_decode( $row['data'], TRUE );
if ( isset( $data['count'] ) )
{
$count += intval( $data['count'] );
}
else
{
$count++;
}
}
}
return $count;
}
}
@@ -0,0 +1,27 @@
<?php
/**
* @brief Editor AJAX functions Controller
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 29 Apr 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\admin\system;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Editor AJAX functions Controller
*/
class _editor extends \IPS\core\modules\front\system\editor
{
}
Whitespace-only changes.
@@ -0,0 +1,50 @@
<?php
/**
* @brief Language Changer
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 7 Oct 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\admin\system;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Language Changer
*/
class _language extends \IPS\Dispatcher\Controller
{
/**
* Execute
*
* @return void
*/
public function execute()
{
parent::execute();
}
/**
* Manage
*
* @return void
*/
protected function manage()
{
\IPS\Session::i()->csrfCheck();
\IPS\Member::loggedIn()->acp_language = (int) \IPS\Request::i()->id;
\IPS\Member::loggedIn()->save();
\IPS\Output::i()->redirect( \IPS\Http\Url::external( $_SERVER['HTTP_REFERER'] ) ?: \IPS\Http\Url::internal( '' ) );
}
}
@@ -0,0 +1,62 @@
<?php
/**
* @brief ACP Live Search
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 18 Sep 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\admin\system;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Live Search
*/
class _livesearch extends \IPS\Dispatcher\Controller
{
/**
* Execute
*
* @return void
*/
public function execute()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'livesearch_manage', 'core', 'livesearch' );
parent::execute();
}
/**
* Manage
*
* @return void
*/
protected function manage()
{
$results = array();
try
{
$exploded = explode( '_', \IPS\Request::i()->search_key );
$app = \IPS\Application::load( $exploded[0] );
foreach ( $app->extensions( 'core', 'LiveSearch' ) as $k => $extension )
{
if ( $k === $exploded[1] and method_exists( $extension, 'getResults' ) )
{
$results = $extension->getResults( urldecode( \IPS\Request::i()->search_term ) );
}
}
}
catch ( \OutOfRangeException $e ) { }
\IPS\Output::i()->json( array_values( $results ) );
}
}
@@ -0,0 +1,168 @@
<?php
/**
* @brief Admin CP Login
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 13 Mar 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\admin\system;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Admin CP Login
*/
class _login extends \IPS\Dispatcher\Controller
{
/**
* Log In
*
* @return void
*/
protected function manage()
{
/* Init login class */
$url = \IPS\Http\Url::internal( "app=core&module=system&controller=login", 'admin', NULL, array(), \IPS\Settings::i()->logins_over_https );
if ( isset( \IPS\Request::i()->ref ) )
{
$url = $url->setQueryString( 'ref', base64_encode( \IPS\Request::i()->ref ) );
}
$login = new \IPS\Login( $url );
$login->flagOptions = FALSE;
/* Set the default tab */
$forms = $login->forms( TRUE, ( \IPS\Request::i()->ref ?: TRUE ) );
$this->activeTab = \IPS\Request::i()->tab ?: key($forms);
/* Process */
$error = NULL;
try
{
/* Authenticate */
$member = $login->authenticate();
if ( $member !== NULL and $member->member_id )
{
/* Success */
if ( $member->isAdmin() )
{
/* Set the member */
\IPS\Session::i()->setMember( $member );
/* Log */
$this->log( 'ok' );
/* Clean out any existing session ID in the URL */
$queryString = '';
if( isset( \IPS\Request::i()->ref ) )
{
$queryString = preg_replace( "/adsess=([a-zA-Z0-9]+)(?:&|$)/", '', base64_decode( \IPS\Request::i()->ref ) );
}
/* Boink */
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( $queryString ) );
}
/* Error */
else
{
$error = 'no_access_cp';
/* Log */
$this->log( 'fail' );
}
}
}
catch ( \IPS\Login\Exception $e )
{
$error = $e->getMessage();
/* Log */
$this->log( 'fail' );
}
if ( is_null( $error ) AND isset( \IPS\Request::i()->error ) )
{
switch( \IPS\Request::i()->error )
{
case 'BAD_IP':
$error = \IPS\Member::loggedIn()->language()->addToStack( 'cp_bad_ip' );
break;
case 'NO_ACPACCESS':
$error = \IPS\Member::loggedIn()->language()->addToStack( 'no_access_cp' );
break;
}
}
/* Get icons */
$icons = array();
$haveStandard = FALSE;
foreach ( \IPS\Login::handlers() as $key => $handler )
{
$icons[ $key ] = $handler::$icon;
}
/* Do we need an error? */
$upgradeError = FALSE;
if ( !\IPS\IN_DEV and !isset( \IPS\Request::i()->noWarning ) )
{
if( \IPS\Application::load('core')->long_version < \IPS\Application::getAvailableVersion('core') )
{
$upgradeError = \IPS\Application::getAvailableVersion( 'core', TRUE );
}
}
/* Display Login Form */
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_system.js', 'core', 'admin' ) );
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'system/login.css', 'core', 'admin' ) );
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'system' )->login( $forms, $this->activeTab, $error, $icons, $upgradeError ) );
}
/**
* Log Out
*
* @return void
*/
protected function logout()
{
session_destroy();
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=system&controller=login" ) );
}
/**
* Log
*
* @return void
*/
protected function log( $status )
{
/* Generate request details */
foreach( \IPS\Request::i() as $k => $v )
{
if ( $k == 'password' AND mb_strlen( $v ) > 1 )
{
$v = $v ? ( (mb_strlen( $v ) - 1) > 0 ? str_repeat( '*', mb_strlen( $v ) - 1 ) : '' ) . mb_substr( $v, -1, 1 ) : '';
}
$request[ $k ] = $v;
}
$save = array(
'admin_ip_address' => \IPS\Request::i()->ipAddress(),
'admin_username' => \IPS\Request::i()->auth ?: '',
'admin_time' => time(),
'admin_success' => ( $status == 'ok' ) ? 1 : 0,
'admin_request' => json_encode( $request ),
);
\IPS\Db::i()->insert( 'core_admin_login_logs', $save );
}
}
@@ -0,0 +1,50 @@
<?php
/**
* @brief Theme Changer
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 7 Oct 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\admin\system;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Theme Changer
*/
class _theme extends \IPS\Dispatcher\Controller
{
/**
* Execute
*
* @return void
*/
public function execute()
{
parent::execute();
}
/**
* Manage
*
* @return void
*/
protected function manage()
{
\IPS\Session::i()->csrfCheck();
\IPS\Member::loggedIn()->acp_skin = (int) \IPS\Request::i()->id;
\IPS\Member::loggedIn()->save();
\IPS\Output::i()->redirect( \IPS\Http\Url::external( $_SERVER['HTTP_REFERER'] ) ?: \IPS\Http\Url::internal( '' ) );
}
}