1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 03:40:37 +02:00

Fixes #598, Fixes #274 - ban user admin-ui fix.

This commit is contained in:
Cameron
2014-05-28 23:17:13 -07:00
parent 266fc14e06
commit 3dabe6fee0
4 changed files with 32 additions and 14 deletions

View File

@@ -90,21 +90,22 @@ class banlist_ui extends e_admin_ui
protected $pluginTitle = BANLAN_16; protected $pluginTitle = BANLAN_16;
// protected $pluginName = 'myplugin'; // protected $pluginName = 'myplugin';
protected $table = 'banlist'; protected $table = 'banlist';
protected $pid = 'banlist_datestamp'; //XXX Not Ideal - From Cam: Should we add a primary ID field to the banlist table? protected $pid = 'banlist_id';
protected $perPage = 10; protected $perPage = 10;
//FIXME banlist_ip should be data => 'str' - however, edit link will not contain a value for 'id' when this is the case. //FIXME banlist_ip should be data => 'str' - however, edit link will not contain a value for 'id' when this is the case.
//FIXME need to edit/display primary key value. ie. banlist_ip //FIXME need to edit/display primary key value. ie. banlist_ip
protected $fields = array ( protected $fields = array (
'checkboxes' => array ( 'title' => '', 'type' => null, 'data' => null, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect', ), 'checkboxes' => array ( 'title' => '', 'type' => null, 'data' => null, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect', ),
'banlist_ip' => array ( 'title' => 'Ip', 'type' => 'ip', 'data' => 'int', 'noedit'=>false, 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'banlist_id' => array ( 'title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'banlist_bantype' => array ( 'title' => 'Type', 'type' => 'method', 'data' => 'str', 'width' => 'auto', 'filter'=>true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ), 'banlist_ip' => array ( 'title' => LAN_IP, 'type' => 'ip', 'data' => 'str', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'banlist_datestamp' => array ( 'title' => 'LAN_DATESTAMP', 'type' => 'datestamp', 'data' => 'int', 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => 'auto=1&hidden=1&readonly=1', 'class' => 'left', 'thclass' => 'left', ), 'banlist_bantype' => array ( 'title' => LAN_TYPE, 'type' => 'method', 'data' => 'str', 'width' => 'auto', 'filter'=>true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
'banlist_datestamp' => array ( 'title' => LAN_DATESTAMP, 'type' => 'datestamp', 'data' => 'int', 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => 'auto=1&hidden=1&readonly=1', 'class' => 'left', 'thclass' => 'left', ),
'banlist_banexpires' => array ( 'title' => 'Expires', 'type' => 'method', 'data' => 'int', 'inline'=>true, 'width' => 'auto', 'batch' => true, 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'banlist_banexpires' => array ( 'title' => 'Expires', 'type' => 'method', 'data' => 'int', 'inline'=>true, 'width' => 'auto', 'batch' => true, 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'banlist_admin' => array ( 'title' => 'Admin', 'type' => 'boolean', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ), 'banlist_admin' => array ( 'title' => 'Admin', 'type' => 'boolean', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
'banlist_reason' => array ( 'title' => 'Reason', 'type' => 'text', 'data' => 'str', 'inline'=>true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ), 'banlist_reason' => array ( 'title' => 'Reason', 'type' => 'text', 'data' => 'str', 'inline'=>true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
'banlist_notes' => array ( 'title' => 'Notes', 'type' => 'text', 'data' => 'str', 'inline'=>true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ), 'banlist_notes' => array ( 'title' => 'Notes', 'type' => 'text', 'data' => 'str', 'inline'=>true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
'options' => array ( 'title' => 'Options', 'type' => '', 'data' => '', 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1', ), 'options' => array ( 'title' => LAN_OPTIONS, 'type' => '', 'data' => '', 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1', ),
); );
protected $fieldpref = array('checkboxes', 'banlist_ip', 'banlist_bantype', 'banlist_datestamp', 'banlist_banexpires', 'banlist_reason', 'banlist_notes', 'options'); protected $fieldpref = array('checkboxes', 'banlist_ip', 'banlist_bantype', 'banlist_datestamp', 'banlist_banexpires', 'banlist_reason', 'banlist_notes', 'options');
@@ -828,6 +829,7 @@ switch ($action)
{ {
break; break;
} }
RETURN;
if (!isset($banlist_reason)) $banlist_reason = ''; if (!isset($banlist_reason)) $banlist_reason = '';
if (!isset($banlist_ip)) $banlist_ip = ''; if (!isset($banlist_ip)) $banlist_ip = '';

View File

@@ -651,6 +651,19 @@ function update_706_to_800($type='')
//@TODO de-serialize the user_prefs also. //@TODO de-serialize the user_prefs also.
// Banlist
if(!$sql->field('banlist','banlist_id'))
{
if ($just_check) return update_needed('Banlist table requires updating.');
$sql->gen("ALTER TABLE #banlist DROP PRIMARY KEY");
$sql->gen("ALTER TABLE `#banlist` ADD `banlist_id` INT( 11 ) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
}
// Move the maximum online counts from menu prefs to a separate pref - 'history' // Move the maximum online counts from menu prefs to a separate pref - 'history'

View File

@@ -72,6 +72,7 @@ CREATE TABLE audit_log (
# #
CREATE TABLE banlist ( CREATE TABLE banlist (
banlist_id int(10) unsigned NOT NULL auto_increment,
banlist_ip varchar(100) NOT NULL default '', banlist_ip varchar(100) NOT NULL default '',
banlist_bantype tinyint(3) signed NOT NULL default '0', banlist_bantype tinyint(3) signed NOT NULL default '0',
banlist_datestamp int(10) unsigned NOT NULL default '0', banlist_datestamp int(10) unsigned NOT NULL default '0',
@@ -79,7 +80,8 @@ CREATE TABLE banlist (
banlist_admin smallint(5) unsigned NOT NULL default '0', banlist_admin smallint(5) unsigned NOT NULL default '0',
banlist_reason tinytext NOT NULL, banlist_reason tinytext NOT NULL,
banlist_notes tinytext NOT NULL, banlist_notes tinytext NOT NULL,
PRIMARY KEY (banlist_ip), PRIMARY KEY (banlist_id),
KEY banlist_ip (banlist_ip),
KEY banlist_datestamp (banlist_datestamp), KEY banlist_datestamp (banlist_datestamp),
KEY banlist_banexpires (banlist_banexpires) KEY banlist_banexpires (banlist_banexpires)
) ENGINE=MyISAM; ) ENGINE=MyISAM;

View File

@@ -984,15 +984,16 @@ class eIPHandler
$ban_message .= 'Host: '.$this->get_host_name($ban_ip); $ban_message .= 'Host: '.$this->get_host_name($ban_ip);
} }
// Add using an array - handles DB changes better // Add using an array - handles DB changes better
$sql->db_Insert('banlist', $sql->insert('banlist',
array( array(
'banlist_ip' => $ban_ip , 'banlist_id' => 0,
'banlist_bantype' => $bantype , 'banlist_ip' => $ban_ip ,
'banlist_datestamp' => time() , 'banlist_bantype' => $bantype ,
'banlist_banexpires' => (varsettrue($pref['ban_durations'][$bantype]) ? time()+($pref['ban_durations'][$bantype]*60*60) : 0) , 'banlist_datestamp' => time() ,
'banlist_admin' => $ban_user , 'banlist_banexpires' => (varsettrue($pref['ban_durations'][$bantype]) ? time()+($pref['ban_durations'][$bantype]*60*60) : 0) ,
'banlist_reason' => $ban_message , 'banlist_admin' => $ban_user ,
'banlist_notes' => $ban_notes 'banlist_reason' => $ban_message ,
'banlist_notes' => $ban_notes
)); ));
$this->regenerateFiles(); $this->regenerateFiles();