3 include_once
'admin_header.php';
4 require_once XOOPS_ROOT_PATH.
'/class/pagenav.php' ;
5 require_once dirname(dirname(__FILE__)).
'/class/gtickets.php' ;
8 if(isset(
$_GET[
'num'])) {
9 $_SERVER[
'REQUEST_URI'] =
'admin/center.php?page=center';
23 require_once dirname(dirname(__FILE__)).
'/class/protector.php' ;
33 if( ! empty(
$_POST[
'action'] ) ) {
36 if ( ! $xoopsGTicket->check(
true ,
'protector_admin' ) ) {
40 if(
$_POST[
'action'] ==
'update_ips' ) {
43 $lines = empty(
$_POST[
'bad_ips'] ) ? array() : explode(
"\n" , trim(
$_POST[
'bad_ips'] ) ) ;
45 foreach( $lines as $line ) {
46 @list( $bad_ip , $jailed_time ) = explode(
':' , $line , 2 ) ;
47 $bad_ips[ trim( $bad_ip ) ] = empty( $jailed_time ) ? 0x7fffffff : intval( $jailed_time ) ;
57 $fp = @fopen(
$protector->get_filepath4group1ips() ,
'w' ) ;
59 @flock( $fp , LOCK_EX ) ;
60 fwrite( $fp , serialize( array_unique(
$group1_ips ) ) .
"\n" ) ;
61 @flock( $fp , LOCK_UN ) ;
71 }
else if(
$_POST[
'action'] ==
'delete' && isset(
$_POST[
'ids'] ) && is_array(
$_POST[
'ids'] ) ) {
73 foreach(
$_POST[
'ids'] as $lid ) {
74 $lid = intval( $lid ) ;
75 $db->query(
"DELETE FROM $log_table WHERE lid='$lid'" ) ;
80 }
else if(
$_POST[
'action'] ==
'deleteall' ) {
82 $db->query(
"DELETE FROM $log_table" ) ;
86 }
else if(
$_POST[
'action'] ==
'compactlog' ) {
88 $result =
$db->query(
"SELECT `lid`,`ip`,`type` FROM $log_table ORDER BY lid DESC" ) ;
92 if( isset( $buf[ $ip .
$type ] ) ) {
98 $db->query(
"DELETE FROM $log_table WHERE lid IN (".implode(
',',$ids).
")" ) ;
110 $rs =
$db->query(
"SELECT count(lid) FROM $log_table" ) ;
111 list( $numrows ) =
$db->fetchRow(
$rs ) ;
112 $prs =
$db->query(
"SELECT l.lid, l.uid, l.ip, l.agent, l.type, l.description, UNIX_TIMESTAMP(l.timestamp), u.uname FROM $log_table l LEFT JOIN ".
$db->prefix(
"users").
" u ON l.uid=u.uid ORDER BY timestamp DESC LIMIT $pos,$num" ) ;
123 $num_options .=
"<option value='$n' selected='selected'>$n</option>\n" ;
131 include dirname(__FILE__).
'/mymenu.php' ;
134 echo
"<h3 style='text-align:left;'>".$xoopsModule->name().
"</h3>\n" ;
137 if( ! is_writable( dirname(dirname(__FILE__)).
'/configs' ) ) {
138 printf(
"<p style='color:red;font-weight:bold;'>".
_AM_FMT_CONFIGSNOTWRITABLE.
"</p>\n" , dirname(dirname(__FILE__)).
'/configs' ) ;
143 uksort(
$bad_ips ,
'protector_ip_cmp' ) ;
145 foreach(
$bad_ips as $bad_ip => $jailed_time ) {
146 $line = $jailed_time ? $bad_ip .
':' . $jailed_time : $bad_ip ;
147 $line = str_replace(
':2147483647' ,
'' , $line ) ;
148 $bad_ips4disp .= htmlspecialchars( $line , ENT_QUOTES ) .
"\n" ;
158 <form name='ConfigForm' action='' method='POST'>
159 ".$xoopsGTicket->getTicketHtml(__LINE__,1800,
'protector_admin').
"
160 <input type='hidden' name='action' value='update_ips' />
161 <table width='95%' class='outer' cellpadding='4' cellspacing='1'>
162 <tr valign='top' align='left'>
167 <textarea name='bad_ips' id='bad_ips' style='width:200px;height:60px;'>$bad_ips4disp</textarea>
169 ".htmlspecialchars(
$protector->get_filepath4badips()).
"
172 <tr valign='top' align='left'>
177 <textarea name='group1_ips' id='group1_ips' style='width:200px;height:60px;'>$group1_ips4disp</textarea>
179 ".htmlspecialchars(
$protector->get_filepath4group1ips()).
"
182 <tr valign='top' align='left'>
186 <input type='submit' value='".
_GO.
"' />
196 <table width='95%' border='0' cellpadding='4' cellspacing='0'><tr><td>
197 <form action='' method='GET' style='margin-bottom:0px;'>
198 <table width='95%' border='0' cellpadding='4' cellspacing='0'>
201 <select name='num' onchange='submit();'>$num_options</select>
202 <input type='submit' value='"._SUBMIT.
"'>
210 <form name='MainForm' action='' method='POST' style='margin-top:0px;'>
211 ".$xoopsGTicket->getTicketHtml(__LINE__,1800,
'protector_admin').
"
212 <input type='hidden' name='action' value='' />
213 <table width='95%' class='outer' cellpadding='4' cellspacing='1'>
215 <th width='5'><input type='checkbox' name='dummy' onclick=\"with(document.MainForm){for(i=0;i<length;i++){if(elements[i].type=='checkbox'){elements[i].checked=this.checked;}}}\" /></th>
229 $ip = htmlspecialchars( $ip , ENT_QUOTES ) ;
230 $type = htmlspecialchars(
$type , ENT_QUOTES ) ;
231 $description = htmlspecialchars( $description , ENT_QUOTES ) ;
235 if( preg_match(
'/MSIE\s+([0-9.]+)/' , $agent , $regs ) ) {
236 $agent_short =
'IE ' . $regs[1] ;
237 }
else if( stristr( $agent ,
'Gecko' ) !==
false ) {
238 $agent_short = strrchr( $agent ,
' ' ) ;
240 $agent_short = substr( $agent , 0 , strpos( $agent ,
' ' ) ) ;
242 $agent4disp = htmlspecialchars( $agent , ENT_QUOTES ) ;
243 $agent_desc = $agent == $agent_short ? $agent4disp : htmlspecialchars( $agent_short , ENT_QUOTES ) .
"<img src='../images/dotdotdot.gif' alt='$agent4disp' title='$agent4disp' />" ;
247 <td class='$oddeven'><input type='checkbox' name='ids[]' value='$lid' /></td>
248 <td class='$oddeven'>".formatTimestamp($timestamp).
"</td>
249 <td class='$oddeven'>$uname</td>
250 <td class='$oddeven'>$ip<br />$agent_desc</td>
251 <td class='$oddeven'>$type</td>
252 <td class='$oddeven' width='100%'>$description</td>
259 <td colspan='8' align='left'>"._AM_LABEL_REMOVE.
"<input type='button' value='".
_AM_BUTTON_REMOVE.
"' onclick='if(confirm(\"".
_AM_JS_REMOVECONFIRM.
"\")){document.MainForm.action.value=\"delete\"; submit();}' /></td>
265 <div style='clear:both;'><br /><br /></div>
280 $as = explode(
'.' , $a ) ;
281 $aval = @$as[0] * 167777216 + @$as[1] * 65536 + @$as[2] * 256 + @$as[3] ;
282 $bs = explode(
'.' , $b ) ;
283 $bval = @$bs[0] * 167777216 + @$bs[1] * 65536 + @$bs[2] * 256 + @$bs[3] ;
285 return $aval > $bval ? 1 : -1 ;