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,30 +11,51 @@
namespace IPS\core\modules\admin\membersettings;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Data\Store;
use IPS\DateTime;
use IPS\Db;
use IPS\Dispatcher;
use IPS\Dispatcher\Controller;
use IPS\Helpers\Form;
use IPS\Helpers\Form\Select;
use IPS\Helpers\Form\Text;
use IPS\Helpers\Table\Db as TableDb;
use IPS\Http\Url;
use IPS\Member;
use IPS\Output;
use IPS\Request;
use IPS\Session;
use IPS\Theme;
use UnderflowException;
use function defined;
use const IPS\Helpers\Table\SEARCH_CONTAINS_TEXT;
use const IPS\Helpers\Table\SEARCH_DATE_RANGE;
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;
}
/**
* ban
*/
class _ban extends \IPS\Dispatcher\Controller
class ban extends Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
public static bool $csrfProtected = TRUE;
/**
* Execute
*
* @return void
*/
public function execute()
public function execute() : void
{
\IPS\Dispatcher::i()->checkAcpPermission( 'ban_manage' );
Dispatcher::i()->checkAcpPermission( 'ban_manage' );
parent::execute();
}
@@ -43,9 +64,9 @@ class _ban extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function manage()
protected function manage() : void
{
$table = new \IPS\Helpers\Table\Db( 'core_banfilters', \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=ban' ) );
$table = new TableDb( 'core_banfilters', Url::internal( 'app=core&module=membersettings&controller=ban' ) );
$table->filters = array(
'ban_filter_ip' => 'ban_type=\'ip\'',
@@ -61,30 +82,30 @@ class _ban extends \IPS\Dispatcher\Controller
$table->sortDirection = $table->sortDirection ?: 'asc';
$table->quickSearch = 'ban_content';
$table->advancedSearch = array(
'ban_reason' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
'ban_date' => \IPS\Helpers\Table\SEARCH_DATE_RANGE
'ban_reason' => SEARCH_CONTAINS_TEXT,
'ban_date' => SEARCH_DATE_RANGE
);
/* Custom parsers */
$table->parsers = array(
'ban_date' => function( $val, $row )
'ban_date' => function( $val )
{
return \IPS\DateTime::ts( $val )->localeDate();
return DateTime::ts( $val )->localeDate();
},
'ban_type' => function( $val, $row )
'ban_type' => function( $val )
{
switch( $val )
{
default:
case 'ip':
return \IPS\Member::loggedIn()->language()->addToStack('ban_filter_ip_select');
break;
return Member::loggedIn()->language()->addToStack('ban_filter_ip_select');
case 'email':
return \IPS\Member::loggedIn()->language()->addToStack('ban_filter_email_select');
break;
return Member::loggedIn()->language()->addToStack('ban_filter_email_select');
case 'name':
return \IPS\Member::loggedIn()->language()->addToStack('ban_filter_name_select');
break;
return Member::loggedIn()->language()->addToStack('ban_filter_name_select');
}
}
);
@@ -97,8 +118,8 @@ class _ban extends \IPS\Dispatcher\Controller
$return['edit'] = array(
'icon' => 'pencil',
'title' => 'edit',
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('edit') ),
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=ban&do=form&id=' ) . $row['ban_id'],
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('edit') ),
'link' => Url::internal( 'app=core&module=membersettings&controller=ban&do=form&id=' ) . $row['ban_id'],
);
@@ -106,7 +127,7 @@ class _ban extends \IPS\Dispatcher\Controller
$return['delete'] = array(
'icon' => 'times-circle',
'title' => 'delete',
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=ban&do=delete&id=' ) . $row['ban_id'],
'link' => Url::internal( 'app=core&module=membersettings&controller=ban&do=delete&id=' ) . $row['ban_id'],
'data' => array( 'delete' => '' ),
);
@@ -114,41 +135,41 @@ class _ban extends \IPS\Dispatcher\Controller
};
/* Specify the buttons */
\IPS\Output::i()->sidebar['actions'] = array(
Output::i()->sidebar['actions'] = array(
'add' => array(
'primary' => TRUE,
'icon' => 'plus',
'title' => 'ban_filter_add',
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('ban_filter_add') ),
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=ban&do=form' )
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('ban_filter_add') ),
'link' => Url::internal( 'app=core&module=membersettings&controller=ban&do=form' )
)
);
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_membersettings_ban');
\IPS\Output::i()->output = (string) $table;
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__core_membersettings_ban');
Output::i()->output = (string) $table;
}
/**
* Add/Edit Rank
*/
public function form()
public function form() : void
{
$current = NULL;
if ( \IPS\Request::i()->id )
if ( Request::i()->id )
{
$current = \IPS\Db::i()->select( '*', 'core_banfilters', array( 'ban_id=?', \IPS\Request::i()->id ) )->first();
$current = Db::i()->select( '*', 'core_banfilters', array( 'ban_id=?', Request::i()->id ) )->first();
}
/* Build form */
$form = new \IPS\Helpers\Form();
$form->add( new \IPS\Helpers\Form\Select( 'ban_type', $current ? $current['ban_type'] : NULL , TRUE, array( 'options' => array(
$form = new Form();
$form->add( new Select( 'ban_type', $current ? $current['ban_type'] : NULL , TRUE, array( 'options' => array(
'ip' => 'ban_filter_ip_select',
'email' => 'ban_filter_email_select',
'name' => 'ban_filter_name_select'
) ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'ban_content', $current ? $current['ban_content'] : "", TRUE ) );
$form->add( new \IPS\Helpers\Form\Text( 'ban_reason', $current ? $current['ban_reason'] : "" ) );
$form->add( new Text( 'ban_content', $current ? $current['ban_content'] : "", TRUE ) );
$form->add( new Text( 'ban_reason', $current ? $current['ban_reason'] : "" ) );
/* Handle submissions */
if ( $values = $form->values() )
@@ -163,22 +184,22 @@ class _ban extends \IPS\Dispatcher\Controller
if ( $current )
{
unset( $save['ban_date'] );
\IPS\Db::i()->update( 'core_banfilters', $save, array( 'ban_id=?', $current['ban_id'] ) );
\IPS\Session::i()->log( 'acplog__ban_edited', array( 'ban_filter_' . $save['ban_type'] . '_select' => TRUE, $save['ban_content'] => FALSE ) );
Db::i()->update( 'core_banfilters', $save, array( 'ban_id=?', $current['ban_id'] ) );
Session::i()->log( 'acplog__ban_edited', array( 'ban_filter_' . $save['ban_type'] . '_select' => TRUE, $save['ban_content'] => FALSE ) );
}
else
{
\IPS\Db::i()->insert( 'core_banfilters', $save );
\IPS\Session::i()->log( 'acplog__ban_created', array( 'ban_filter_' . $save['ban_type'] . '_select' => TRUE, $save['ban_content'] => FALSE ) );
Db::i()->insert( 'core_banfilters', $save );
Session::i()->log( 'acplog__ban_created', array( 'ban_filter_' . $save['ban_type'] . '_select' => TRUE, $save['ban_content'] => FALSE ) );
}
unset( \IPS\Data\Store::i()->bannedIpAddresses );
unset( Store::i()->bannedIpAddresses );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=ban' ), 'saved' );
Output::i()->redirect( Url::internal( 'app=core&module=membersettings&controller=ban' ), 'saved' );
}
/* Display */
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( $current ? $current['ban_content'] : 'add', $form, FALSE );
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( $current ? $current['ban_content'] : 'add', $form, FALSE );
}
/**
@@ -186,20 +207,20 @@ class _ban extends \IPS\Dispatcher\Controller
*
* @return void
*/
public function delete()
public function delete() : void
{
/* Make sure the user confirmed the deletion */
\IPS\Request::i()->confirmedDelete();
Request::i()->confirmedDelete();
try
{
$current = \IPS\Db::i()->select( '*', 'core_banfilters', array( 'ban_id=?', \IPS\Request::i()->id ) )->first();
\IPS\Session::i()->log( 'acplog__ban_deleted', array( 'ban_filter_' . $current['ban_type'] . '_select' => TRUE, $current['ban_content'] => FALSE ) );
\IPS\Db::i()->delete( 'core_banfilters', array( 'ban_id=?', \IPS\Request::i()->id ) );
unset( \IPS\Data\Store::i()->bannedIpAddresses );
$current = Db::i()->select( '*', 'core_banfilters', array( 'ban_id=?', Request::i()->id ) )->first();
Session::i()->log( 'acplog__ban_deleted', array( 'ban_filter_' . $current['ban_type'] . '_select' => TRUE, $current['ban_content'] => FALSE ) );
Db::i()->delete( 'core_banfilters', array( 'ban_id=?', Request::i()->id ) );
unset( Store::i()->bannedIpAddresses );
}
catch ( \UnderflowException $e ) { }
catch ( UnderflowException $e ) { }
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=ban' ) );
Output::i()->redirect( Url::internal( 'app=core&module=membersettings&controller=ban' ) );
}
}