array( 'controller' => 'generic_ui', 'path' => null, 'ui' => 'generic_form_ui', 'uipath' => null ), ); protected $adminMenu = array( 'main/list' => array('caption'=> LAN_MANAGE, 'perm' => 'P'), ); protected $adminMenuAliases = array( 'main/edit' => 'main/list' ); protected $menuTitle = ADLAN_146; } class generic_ui extends e_admin_ui { protected $pluginTitle = ADLAN_146; protected $pluginName = 'failed_login'; protected $table = 'generic'; protected $pid = 'gen_id'; protected $perPage = 10; protected $listQry = "SELECT * FROM #generic WHERE gen_type='failed_login' ORDER BY gen_datestamp DESC"; protected $fields = array ( 'checkboxes' => array ( 'title' => '', 'type' => null, 'data' => null, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect', ), 'gen_id' => array ( 'title' => LAN_ID, 'nolist'=>true, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), // 'gen_type' => array ( 'title' => LAN_BAN, 'type' => 'method', 'data' => 'str', 'width' => 'auto', 'batch' => true, 'filter' => true, 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'gen_datestamp' => array ( 'title' => LAN_DATESTAMP, 'type' => 'datestamp', 'data' => 'int', 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'gen_chardata' => array ( 'title' => 'Chardata', 'type' => 'method', 'data' => 'str', 'width' => '40%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), // 'gen_user_id' => array ( 'title' => LAN_BAN, 'type' => 'method', 'batch'=>true, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'gen_ip' => array ( 'title' => LAN_IP, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), // 'gen_intdata' => array ( 'title' => LAN_BAN, 'type' => 'method', 'batch'=>true, 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ), 'options' => array ( 'title' => 'Options', 'type' => null, 'data' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1', 'readParms'=>'edit=0' ), ); protected $fieldpref = array('gen_datestamp', 'gen_ip', 'gen_chardata'); // optional public function init() { if($_POST['etrigger_batch'] == 'gen_intdata__1' && count($_POST['e-multiselect'])) // Do we need BAN here? { $dels = implode(',',$_POST['e-multiselect']); //$e107::getDb()->insert('banlist', } } } class generic_form_ui extends e_admin_form_ui { // Custom Method/Function function gen_intdata($curVal,$mode) { $frm = e107::getForm(); switch($mode) { case 'read': // List Page return $curVal; break; case 'write': // Edit Page return $frm->text('gen_type',$curVal); break; case 'filter': case 'batch': return array(1=>LAN_BAN); break; } } // Custom Method/Function function gen_chardata($curVal,$mode) { $frm = e107::getForm(); switch($mode) { case 'read': // List Page return str_replace(":::","
",$curVal); break; case 'write': // Edit Page return $frm->text('gen_chardata',$curVal); break; case 'filter': case 'batch': // return $array; break; } } } new failed_login_admin(); require_once(e_ADMIN."auth.php"); e107::getAdminUI()->runPage(); require_once(e_ADMIN."footer.php"); exit; // ---------- OLD STUFF BELOW - For Review --- // $e_sub_cat = 'failed_login'; //require_once('auth.php'); $frm = e107::getForm(); $mes = e107::getMessage(); $tmp = (e_QUERY) ? explode('.', e_QUERY) : ''; $from = intval(varset($tmp[0], 0)); $amount = intval(varset($tmp[1], 50)); function deleteBan($banID, $banIP = '') { $sql2 = e107::getDb('sql2'); $banID = intval($banID); if ($banIP == '') { if($sql2->db_Select('generic', 'gen_ip', 'gen_id='.$banID)) { $at = $sql2->db_Fetch(); $banIP = $at['gen_ip']; } } $sql2->db_Delete('generic', 'gen_id='.$banID); // Delete from generic table if ($banIP == '') return FALSE; $sql2->db_Delete('banlist', "banlist_ip='{$banIP}'"); // Delete from main banlist // @todo Admin log messages return TRUE; } /* * FIXME - refine messages (strange messages on delete all & reload) */ if(isset($_POST['delbanSubmit'])) { $message = ''; $delcount = 0; $spacer = ''; foreach($_POST['fladelete'] as $delete) { $delcount++; $sql->db_Delete("generic", "gen_id='{$delete}' "); } if ($delcount) { $mes->addSuccess(FLALAN_3.": ".$delcount); } $bancount = 0; foreach($_POST['flaban'] as $ban) { if($sql->db_Select("generic", "*", "gen_id={$ban}")) { $at = $sql->db_Fetch(); //if (!$e107->add_ban(4, FLALAN_4, $at['gen_ip'], ADMINID)) if (!e107::getIPHandler()->add_ban(4, FLALAN_4, $at['gen_ip'], ADMINID)) { // IP on whitelist (although possibly we shouldn't get to this stage, but check anyway $mes->addWarning(str_replace(FLALAN_18,'--IP--',$at['gen_ip'])); } else $bancount++; $banlist_ip = $at['gen_ip']; //XXX - why inserting it twice? //$sql->db_Insert("banlist", "'$banlist_ip', '".ADMINID."', '".FLALAN_4."' "); $sql->db_Delete("generic", "gen_id='{$ban}' "); } } $mes->add(FLALAN_5.": ".$bancount, $bancount ? E_MESSAGE_SUCCESS : E_MESSAGE_INFO); // FIXME } if(e_QUERY == 'dabl') { $sql->db_Select("generic", 'gen_ip,gen_id',"gen_type='auto_banned' "); while ($row = $sql->db_Fetch()) { if (deleteBan($row['gen_id'],$row['gen_ip'])) { $delcount++; } } //XXX - add delcount to the message $mes->addSuccess(FLALAN_17); } // Now display any outstanding auto-banned IP addresses if($sql->db_Select('generic', "*", "gen_type='auto_banned' ORDER BY gen_datestamp DESC ")) { $abArray = $sql->db_getList(); $message = FLALAN_15; foreach($abArray as $ab) { $message .= " - ".$ab['gen_ip']; } $message .= "
(".FLALAN_16.")
"; $mes->addInfo($message); } $gen = new convert; $fla_total = $sql->db_Count('generic', '(*)', "WHERE gen_type='failed_login'"); if(!$sql->db_Select('generic', '*', "gen_type='failed_login' ORDER BY gen_datestamp DESC LIMIT {$from},{$amount}")) { $mes->addInfo(FLALAN_2); } else { $faArray = $sql->db_getList('ALL', FALSE, FALSE); $text = "
".ADLAN_146." "; foreach($faArray as $fa) { extract($fa);//FIXME kill extract() $gen_chardata = str_replace(":::", "
", $tp->toHTML($gen_chardata)); $host = e107::getIPHandler()->get_host_name(getenv($gen_ip)); $text .= " "; } $text .= "
".LAN_DATE." ".FLALAN_7." ".FLALAN_8." ".LAN_DELETE."
".$frm->checkbox('check_all_del', 'jstarget:fladelete', false, array('id'=>false,'class'=>'checkbox toggle-all'))."
".LAN_BAN."
".$frm->checkbox_toggle('check-all-ban', 'flaban')."
".$gen->convert_date($gen_datestamp, "forum")." ".$gen_chardata." ".e107::getIPHandler()->ipDecode($fa['gen_ip'])."
{$host}
".$frm->checkbox('fladelete[]', $gen_id)." ".$frm->checkbox('flaban[]', $gen_id)."
".$frm->admin_button('delbanSubmit', FLALAN_10, 'delete', FLALAN_10, 'title=')."
"; $parms = $fla_total.",".$amount.",".$from.",".e_SELF.'?'."[FROM].".$amount; $nextprev = $tp->parseTemplate("{NEXTPREV={$parms}}"); if ($nextprev) $text .= "
".$nextprev."
"; } $ns->tablerender(ADLAN_146, $mes->render().$text); require_once("footer.php"); /** * Handle page DOM within the page header * * @return string JS source */ function headerjs() { require_once(e_HANDLER.'js_helper.php'); $ret = " "; return $ret; }