Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+33 -12
View File
@@ -11,7 +11,7 @@
namespace IPS\core\modules\admin\staff;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -22,6 +22,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _admin extends \IPS\Dispatcher\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Execute
*
@@ -231,7 +236,7 @@ class _admin extends \IPS\Dispatcher\Controller
elseif ( $values['acprestrictions_member'] )
{
\IPS\Dispatcher::i()->checkAcpPermission( 'restrictions_add_member' );
if ( $values['acprestrictions_member'] === \IPS\Member::loggedIn() )
if ( $values['acprestrictions_member']->member_id === \IPS\Member::loggedIn()->member_id )
{
$form->error = \IPS\Member::loggedIn()->language()->addToStack('acprestrictions_noself');
}
@@ -245,7 +250,7 @@ class _admin extends \IPS\Dispatcher\Controller
{
$current = \IPS\Db::i()->select( '*', 'core_admin_permission_rows', array( "row_id=? AND row_id_type=?", $rowId, $values['acprestrictions_type'] ) );
if ( !count( $current ) )
if ( !\count( $current ) )
{
$current = array(
'row_id' => $rowId,
@@ -274,6 +279,7 @@ class _admin extends \IPS\Dispatcher\Controller
/**
* Edit
*
* @csrfChecked Uses form helper 7 Oct 2019
* @return void
*/
protected function edit()
@@ -281,7 +287,7 @@ class _admin extends \IPS\Dispatcher\Controller
try
{
/* Get record */
$current = \IPS\Db::i()->select( '*', 'core_admin_permission_rows', array( "row_id=? AND row_id_type=?", intval( \IPS\Request::i()->id ), \IPS\Request::i()->type ) )->first();
$current = \IPS\Db::i()->select( '*', 'core_admin_permission_rows', array( "row_id=? AND row_id_type=?", \intval( \IPS\Request::i()->id ), \IPS\Request::i()->type ) )->first();
}
catch ( \UnderflowException $e )
{
@@ -346,17 +352,19 @@ class _admin extends \IPS\Dispatcher\Controller
*/
protected function save()
{
\IPS\Session::i()->csrfCheck();
/* Get record */
$current = \IPS\Db::i()->select( '*', 'core_admin_permission_rows', array( "row_id=? AND row_id_type=?", intval( \IPS\Request::i()->id ), \IPS\Request::i()->type ) )->first();
$current = \IPS\Db::i()->select( '*', 'core_admin_permission_rows', array( "row_id=? AND row_id_type=?", \intval( \IPS\Request::i()->id ), \IPS\Request::i()->type ) )->first();
if ( !$current )
{
\IPS\Output::i()->error( 'node_error', '2C113/2', 404, '' );
}
$permissions = ( \IPS\Request::i()->admin_use_restrictions == 'no' ) ? '*' : json_encode( ( is_array( \IPS\Request::i()->r ) ) ? \IPS\Request::i()->r : array() );
$permissions = ( \IPS\Request::i()->admin_use_restrictions == 'no' ) ? '*' : json_encode( ( \is_array( \IPS\Request::i()->r ) ) ? \IPS\Request::i()->r : array() );
/* Save */
\IPS\Db::i()->update( 'core_admin_permission_rows', array( 'row_perm_cache' => $permissions, 'row_updated' => time() ), array( "row_id=? AND row_id_type=?", intval( \IPS\Request::i()->id ), \IPS\Request::i()->type ) );
\IPS\Db::i()->update( 'core_admin_permission_rows', array( 'row_perm_cache' => $permissions, 'row_updated' => time() ), array( "row_id=? AND row_id_type=?", \intval( \IPS\Request::i()->id ), \IPS\Request::i()->type ) );
unset( \IPS\Data\Store::i()->administrators );
@@ -374,7 +382,7 @@ class _admin extends \IPS\Dispatcher\Controller
*/
protected function delete()
{
$current = \IPS\Db::i()->select( '*', 'core_admin_permission_rows', array( "row_id=? AND row_id_type=?", intval( \IPS\Request::i()->id ), \IPS\Request::i()->type ) )->first();
$current = \IPS\Db::i()->select( '*', 'core_admin_permission_rows', array( "row_id=? AND row_id_type=?", \intval( \IPS\Request::i()->id ), \IPS\Request::i()->type ) )->first();
if ( $current['row_id_type'] === 'member' )
{
@@ -414,7 +422,7 @@ class _admin extends \IPS\Dispatcher\Controller
}
\IPS\Session::i()->log( 'acplog__acpr_deleted', array( $name => FALSE ) );
\IPS\Db::i()->delete( 'core_admin_permission_rows', array( 'row_id=? AND row_id_type=?', intval( \IPS\Request::i()->id ), \IPS\Request::i()->type ) );
\IPS\Db::i()->delete( 'core_admin_permission_rows', array( 'row_id=? AND row_id_type=?', \intval( \IPS\Request::i()->id ), \IPS\Request::i()->type ) );
unset ( \IPS\Data\Store::i()->administrators );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=staff&controller=admin' ) );
@@ -489,13 +497,26 @@ class _admin extends \IPS\Dispatcher\Controller
$table->sortDirection = $table->sortDirection ?: 'desc';
/* Search */
$table->quickSearch = array( array( 'note', 'word_custom', 'word_default' ), 'note' );
$table->advancedSearch = array(
'member_id' => \IPS\Helpers\Table\SEARCH_MEMBER,
'ip_address' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
'ctime' => \IPS\Helpers\Table\SEARCH_DATE_RANGE,
);
/* Custom quick search function to search unicode entities in JSON encoded data */
$table->quickSearch = function( $val )
{
$searchTerm = mb_strtolower( trim( \IPS\Request::i()->quicksearch ) );
$jsonSearchTerm = str_replace( '\\', '\\\\\\', trim( json_encode( trim( \IPS\Request::i()->quicksearch ) ), '"' ) );
return array(
"(`note` LIKE CONCAT( '%', ?, '%' ) OR LOWER(`word_custom`) LIKE CONCAT( '%', ?, '%' ) OR LOWER(`word_default`) LIKE CONCAT( '%', ?, '%' ))",
$jsonSearchTerm,
$searchTerm,
$searchTerm
);
};
$table->joins = array(
array( 'from' => array( 'core_sys_lang_words', 'w' ), 'where' => "w.word_key=lang_key AND w.lang_id=" . \IPS\Member::loggedIn()->language()->id )
);
@@ -529,7 +550,7 @@ class _admin extends \IPS\Dispatcher\Controller
\IPS\Dispatcher::i()->checkAcpPermission( 'restrictions_adminlogs_prune' );
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\Number( 'prune_log_admin', \IPS\Settings::i()->prune_log_admin, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('days'), 'prune_log_admin' ) );
$form->add( new \IPS\Helpers\Form\Interval( 'prune_log_admin', \IPS\Settings::i()->prune_log_admin, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_log_admin' ) );
if ( $values = $form->values() )
{
@@ -612,7 +633,7 @@ class _admin extends \IPS\Dispatcher\Controller
\IPS\Dispatcher::i()->checkAcpPermission( 'restrictions_acploginlogs_prune' );
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\Number( 'prune_log_adminlogin', \IPS\Settings::i()->prune_log_adminlogin, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('days'), 'prune_log_adminlogin' ) );
$form->add( new \IPS\Helpers\Form\Interval( 'prune_log_adminlogin', \IPS\Settings::i()->prune_log_adminlogin, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_log_adminlogin' ) );
if ( $values = $form->values() )
{
@@ -11,7 +11,7 @@
namespace IPS\core\modules\admin\staff;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -22,6 +22,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _directory extends \IPS\Node\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Node Class
*/
@@ -11,7 +11,7 @@
namespace IPS\core\modules\admin\staff;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -22,6 +22,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _moderators extends \IPS\Dispatcher\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Execute
*
@@ -169,11 +174,11 @@ class _moderators extends \IPS\Dispatcher\Controller
{
$form->add( new \IPS\Helpers\Form\Radio( 'moderators_type', NULL, TRUE, array( 'options' => array( 'g' => 'group', 'm' => 'member' ), 'toggles' => array( 'g' => array( 'moderators_group' ), 'm' => array( 'moderators_member' ) ) ) ) );
}
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'staff', 'moderators_add_member' ) )
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'staff', 'moderators_add_group' ) )
{
$form->add( new \IPS\Helpers\Form\Select( 'moderators_group', NULL, FALSE, array( 'options' => \IPS\Member\Group::groups( TRUE, FALSE ), 'parse' => 'normal' ), NULL, NULL, NULL, 'moderators_group' ) );
}
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'staff', 'moderators_add_group' ) )
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'staff', 'moderators_add_member' ) )
{
$form->add( new \IPS\Helpers\Form\Member( 'moderators_member', NULL, ( \IPS\Request::i()->moderators_type === 'member' ), array(), NULL, NULL, NULL, 'moderators_member' ) );
}
@@ -204,7 +209,7 @@ class _moderators extends \IPS\Dispatcher\Controller
$current = array();
}
if ( !count( $current ) )
if ( !\count( $current ) )
{
$current = array(
'id' => $rowId,
@@ -242,13 +247,23 @@ class _moderators extends \IPS\Dispatcher\Controller
{
try
{
$current = \IPS\Db::i()->select( '*', 'core_moderators', array( "id=? AND type=?", intval( \IPS\Request::i()->id ), \IPS\Request::i()->type ) )->first();
$current = \IPS\Db::i()->select( '*', 'core_moderators', array( "id=? AND type=?", \intval( \IPS\Request::i()->id ), \IPS\Request::i()->type ) )->first();
}
catch ( \UnderflowException $e )
{
\IPS\Output::i()->error( 'node_error', '2C118/2', 404, '' );
}
/* Check acp restrictions */
if ( $current['type'] === 'm' )
{
\IPS\Dispatcher::i()->checkAcpPermission( 'moderators_edit_member' );
}
else
{
\IPS\Dispatcher::i()->checkAcpPermission( 'moderators_edit_group' );
}
/* Load */
try
{
@@ -262,7 +277,7 @@ class _moderators extends \IPS\Dispatcher\Controller
$currentPermissions = ( $current['perms'] === '*' ) ? '*' : ( $current['perms'] ? json_decode( $current['perms'], TRUE ) : array() );
/* Define content field toggles */
$toggles = array( 'view_future' => array(), 'future_publish' => array(), 'pin' => array(), 'unpin' => array(), 'feature' => array(), 'unfeature' => array(), 'edit' => array(), 'hide' => array(), 'unhide' => array(), 'view_hidden' => array(), 'move' => array(), 'lock' => array(), 'unlock' => array(), 'reply_to_locked' => array(), 'delete' => array(), 'split_merge' => array(), 'feature_comments' => array(), 'unfeature_comments' => array(), 'add_item_message' => array(), 'edit_item_message' => array(), 'delete_item_message' => array() );
$toggles = array( 'view_future' => array(), 'future_publish' => array(), 'pin' => array(), 'unpin' => array(), 'feature' => array(), 'unfeature' => array(), 'edit' => array(), 'hide' => array(), 'unhide' => array(), 'view_hidden' => array(), 'move' => array(), 'lock' => array(), 'unlock' => array(), 'reply_to_locked' => array(), 'delete' => array(), 'split_merge' => array(), 'feature_comments' => array(), 'unfeature_comments' => array(), 'add_item_message' => array(), 'edit_item_message' => array(), 'delete_item_message' => array(), 'toggle_item_moderation' => array() );
foreach ( \IPS\Application::allExtensions( 'core', 'ModeratorPermissions', FALSE ) as $k => $ext )
{
if ( $ext instanceof \IPS\Content\ModeratorPermissions )
@@ -303,7 +318,9 @@ class _moderators extends \IPS\Dispatcher\Controller
$form->add(
new \IPS\Helpers\Form\Radio( 'mod_use_restrictions', ( $currentPermissions === '*' ) ? 'no' : 'yes', TRUE, array( 'options' => array( 'no' => 'mod_all_permissions', 'yes' => 'mod_restricted' ), 'toggles' => array( 'yes' => array( 'permission_form_wrapper' ) ) ), NULL, NULL, NULL, 'use_restrictions_id' )
);
$form->add( new \IPS\Helpers\Form\YesNo( 'mod_show_badge', ( $current ) ? $current['show_badge'] : TRUE, TRUE ) );
$extensions = array();
foreach ( \IPS\Application::allExtensions( 'core', 'ModeratorPermissions', FALSE, 'core' ) as $k => $ext )
{
@@ -324,7 +341,7 @@ class _moderators extends \IPS\Dispatcher\Controller
foreach ( $ext->getPermissions( $toggles ) as $name => $data )
{
/* Class */
$type = is_array( $data ) ? $data[0] : $data;
$type = \is_array( $data ) ? $data[0] : $data;
$class = '\IPS\Helpers\Form\\' . ( $type );
/* Remember 'nodes' */
@@ -363,7 +380,7 @@ class _moderators extends \IPS\Dispatcher\Controller
}
/* Options */
$options = is_array( $data ) ? $data[1] : array();
$options = \is_array( $data ) ? $data[1] : array();
if ( $type === 'Number' )
{
$options['unlimited'] = -1;
@@ -372,7 +389,7 @@ class _moderators extends \IPS\Dispatcher\Controller
/* Prefix/Suffix */
$prefix = NULL;
$suffix = NULL;
if ( is_array( $data ) )
if ( \is_array( $data ) )
{
if ( isset( $data[2] ) )
{
@@ -392,6 +409,15 @@ class _moderators extends \IPS\Dispatcher\Controller
/* Handle submissions */
if ( $values = $form->values() )
{
/* Allow extensions an opportunity to inspect the values and make adjustments */
foreach ( \IPS\Application::allExtensions( 'core', 'ModeratorPermissions', FALSE ) as $k => $ext )
{
if( method_exists( $ext, 'preSave' ) )
{
$ext->preSave( $values );
}
}
if( $values['mod_use_restrictions'] == 'no' )
{
$permissions = '*';
@@ -405,7 +431,7 @@ class _moderators extends \IPS\Dispatcher\Controller
foreach ( $values as $k => $v )
{
/* For node fields, if the value is 0 translate it to -1 so mod permissions can merge properly */
if( in_array( $k, $nodeFields ) )
if( \in_array( $k, $nodeFields ) )
{
/* If nothing is checked we have '', but if 'all' is checked then the value is 0 */
if( $v === 0 )
@@ -415,7 +441,7 @@ class _moderators extends \IPS\Dispatcher\Controller
}
}
if ( is_array( $v ) )
if ( \is_array( $v ) )
{
foreach ( $v as $l => $w )
{
@@ -446,7 +472,7 @@ class _moderators extends \IPS\Dispatcher\Controller
$permissions = json_encode( $values );
}
\IPS\Db::i()->update( 'core_moderators', array( 'perms' => $permissions, 'updated' => time() ), array( array( "id=? AND type=?", $current['id'], $current['type'] ) ) );
\IPS\Db::i()->update( 'core_moderators', array( 'perms' => $permissions, 'updated' => time(), 'show_badge' => $values['mod_show_badge'] ), array( array( "id=? AND type=?", $current['id'], $current['type'] ) ) );
if( !( $currentPermissions == '*' AND $changed == '*' ) )
{
@@ -467,7 +493,7 @@ class _moderators extends \IPS\Dispatcher\Controller
/* Display */
\IPS\Output::i()->title = $_name;
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_members.js', 'core', 'admin' ) );
\IPS\Output::i()->output .= $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'members' ) ), 'moderatorPermissions' ) );
\IPS\Output::i()->output .= $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'members' ), 'moderatorPermissions' ) );
}
/**
@@ -480,7 +506,7 @@ class _moderators extends \IPS\Dispatcher\Controller
/* Load */
try
{
$current = \IPS\Db::i()->select( '*', 'core_moderators', array( "id=? AND type=?", intval( \IPS\Request::i()->id ), \IPS\Request::i()->type ) )->first();
$current = \IPS\Db::i()->select( '*', 'core_moderators', array( "id=? AND type=?", \intval( \IPS\Request::i()->id ), \IPS\Request::i()->type ) )->first();
}
catch( \UnderflowException $e )
{
@@ -584,13 +610,26 @@ class _moderators extends \IPS\Dispatcher\Controller
$table->sortDirection = $table->sortDirection ?: 'desc';
/* Search */
$table->quickSearch = array( array( 'note', 'word_custom', 'word_default' ), 'action' );
$table->advancedSearch = array(
'member_id' => \IPS\Helpers\Table\SEARCH_MEMBER,
'ip_address' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
'ctime' => \IPS\Helpers\Table\SEARCH_DATE_RANGE
);
/* Custom quick search function to search unicode entities in JSON encoded data */
$table->quickSearch = function( $val )
{
$searchTerm = mb_strtolower( trim( \IPS\Request::i()->quicksearch ) );
$jsonSearchTerm = str_replace( '\\', '\\\\\\', trim( json_encode( trim( \IPS\Request::i()->quicksearch ) ), '"' ) );
return array(
"(`note` LIKE CONCAT( '%', ?, '%' ) OR LOWER(`word_custom`) LIKE CONCAT( '%', ?, '%' ) OR LOWER(`word_default`) LIKE CONCAT( '%', ?, '%' ))",
$jsonSearchTerm,
$searchTerm,
$searchTerm
);
};
$table->joins = array(
array( 'from' => array( 'core_sys_lang_words', 'w' ), 'where' => "w.word_key=lang_key AND w.lang_id=" . \IPS\Member::loggedIn()->language()->id )
);
@@ -624,7 +663,7 @@ class _moderators extends \IPS\Dispatcher\Controller
\IPS\Dispatcher::i()->checkAcpPermission( 'restrictions_moderatorlogs_prune' );
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\Number( 'prune_log_moderator', \IPS\Settings::i()->prune_log_moderator, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('days'), 'prune_log_moderator' ) );
$form->add( new \IPS\Helpers\Form\Interval( 'prune_log_moderator', \IPS\Settings::i()->prune_log_moderator, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_log_moderator' ) );
if ( $values = $form->values() )
{