mirror of
https://github.com/e107inc/e107.git
synced 2025-06-10 04:55:43 +02:00
IP handler checks and fixes.
This commit is contained in:
parent
0b96543a1a
commit
ec36f1dc87
@ -328,7 +328,7 @@ class banlist_ui extends e_admin_ui
|
|||||||
<div class='field-help'>".$ipAdministrator->getBanTypeString($bt, TRUE)."</div>
|
<div class='field-help'>".$ipAdministrator->getBanTypeString($bt, TRUE)."</div>
|
||||||
</td>
|
</td>
|
||||||
<td class='left'>
|
<td class='left'>
|
||||||
".$frm->textarea('ban_text_'.($i), $pref['ban_messages'][$bt], 4, 120)."
|
".$frm->textarea('ban_text_'.($i), $pref['ban_messages'][$bt], 4, 120, array('size'=>'xxlarge'))."
|
||||||
</td>
|
</td>
|
||||||
<td class='center'>".ban_time_dropdown('', BANLAN_32, $pref['ban_durations'][$bt], 'ban_time_'.($i))."</td>
|
<td class='center'>".ban_time_dropdown('', BANLAN_32, $pref['ban_durations'][$bt], 'ban_time_'.($i))."</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -451,6 +451,7 @@ e107::js('footer-inline', js());
|
|||||||
|
|
||||||
if(isset($new_data['user_extended_struct_values']))
|
if(isset($new_data['user_extended_struct_values']))
|
||||||
{
|
{
|
||||||
|
$new_data['user_extended_struct_values'] = array_filter($new_data['user_extended_struct_values']);
|
||||||
$new_data['user_extended_struct_values'] = implode(',',$new_data['user_extended_struct_values']);
|
$new_data['user_extended_struct_values'] = implode(',',$new_data['user_extended_struct_values']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3613,7 +3613,7 @@ class e_form
|
|||||||
|
|
||||||
case 'ip':
|
case 'ip':
|
||||||
//$e107 = e107::getInstance();
|
//$e107 = e107::getInstance();
|
||||||
$value = e107::getIPHandler()->ipDecode($value);
|
$value = "<span title='".$value."'>".e107::getIPHandler()->ipDecode($value).'</span>';;
|
||||||
// else same
|
// else same
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ class eIPHandler
|
|||||||
*/
|
*/
|
||||||
private $ourIP = '';
|
private $ourIP = '';
|
||||||
|
|
||||||
|
private $debug = false;
|
||||||
/**
|
/**
|
||||||
* Host name of current user
|
* Host name of current user
|
||||||
* Initialised when requested
|
* Initialised when requested
|
||||||
@ -156,6 +156,7 @@ class eIPHandler
|
|||||||
public function __construct($configDir = '')
|
public function __construct($configDir = '')
|
||||||
{
|
{
|
||||||
$configDir = trim($configDir);
|
$configDir = trim($configDir);
|
||||||
|
|
||||||
if ($configDir)
|
if ($configDir)
|
||||||
{
|
{
|
||||||
$this->ourConfigDir = realpath($configDir);
|
$this->ourConfigDir = realpath($configDir);
|
||||||
@ -164,6 +165,8 @@ class eIPHandler
|
|||||||
{
|
{
|
||||||
$this->ourConfigDir = e_SYSTEM.eIPHandler::BAN_FILE_DIRECTORY;
|
$this->ourConfigDir = e_SYSTEM.eIPHandler::BAN_FILE_DIRECTORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->ourIP = $this->ipEncode($this->getCurrentIP());
|
$this->ourIP = $this->ipEncode($this->getCurrentIP());
|
||||||
$this->makeUserToken();
|
$this->makeUserToken();
|
||||||
$ipStatus = $this->checkIP($this->ourIP);
|
$ipStatus = $this->checkIP($this->ourIP);
|
||||||
@ -181,6 +184,19 @@ class eIPHandler
|
|||||||
// Continue here - user not banned (so far)
|
// Continue here - user not banned (so far)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setIP($ip)
|
||||||
|
{
|
||||||
|
$this->ourIP = $this->ipEncode($ip);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function debug($value)
|
||||||
|
{
|
||||||
|
$this->debug = ($value === true) ? true: false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -401,7 +417,13 @@ class eIPHandler
|
|||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
// Otherwise just display any message and die
|
// Otherwise just display any message and die
|
||||||
|
if($this->debug)
|
||||||
|
{
|
||||||
|
print_a("User Banned");
|
||||||
|
}
|
||||||
|
|
||||||
echo $line;
|
echo $line;
|
||||||
|
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -471,10 +493,25 @@ class eIPHandler
|
|||||||
{
|
{
|
||||||
$now = time();
|
$now = time();
|
||||||
$checkLists = $this->getWhiteBlackList();
|
$checkLists = $this->getWhiteBlackList();
|
||||||
|
|
||||||
|
if($this->debug)
|
||||||
|
{
|
||||||
|
echo "<h4>Banlist.php</h4>";
|
||||||
|
print_a($checkLists);
|
||||||
|
print_a("Now: ".$now. " ".date('r',$now));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
foreach ($checkLists as $val)
|
foreach ($checkLists as $val)
|
||||||
{
|
{
|
||||||
if (strpos($addr, $val['ip']) === 0) // See if our address begins with an entry - handles wildcards
|
if (strpos($addr, $val['ip']) === 0) // See if our address begins with an entry - handles wildcards
|
||||||
{ // Match found
|
{ // Match found
|
||||||
|
|
||||||
|
if($this->debug)
|
||||||
|
{
|
||||||
|
print_a("Found ".$addr." in file. TimeLimit: ".date('r',$val['time_limit']));
|
||||||
|
}
|
||||||
|
|
||||||
if (($val['time_limit'] == 0) || ($val['time_limit'] > $now))
|
if (($val['time_limit'] == 0) || ($val['time_limit'] > $now))
|
||||||
{ // Indefinite ban, or timed ban (not expired) or whitelist entry
|
{ // Indefinite ban, or timed ban (not expired) or whitelist entry
|
||||||
if ($val['action']== eIPHandler::BAN_TYPE_LEGACY) return eIPHandler::BAN_TYPE_MANUAL; // Precautionary
|
if ($val['action']== eIPHandler::BAN_TYPE_LEGACY) return eIPHandler::BAN_TYPE_MANUAL; // Precautionary
|
||||||
@ -485,6 +522,7 @@ class eIPHandler
|
|||||||
$this->clearBan = $val['ip']; // Note what triggered the match - it could be a wildcard (although timed ban unlikely!)
|
$this->clearBan = $val['ip']; // Note what triggered the match - it could be a wildcard (although timed ban unlikely!)
|
||||||
return 0; // Can just return - shouldn't be another entry
|
return 0; // Can just return - shouldn't be another entry
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -832,11 +870,14 @@ class eIPHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// do other checks - main IP check is in _construct()
|
||||||
if($this->actionCount)
|
if($this->actionCount)
|
||||||
{
|
{
|
||||||
$ip = $this->getip(); // This will be in normalised IPV6 form
|
$ip = $this->getip(); // This will be in normalised IPV6 form
|
||||||
if ($ip != e107::LOCALHOST_IP && $ip != e107::LOCALHOST_IP2)
|
|
||||||
{ // Check host name, user email to see if banned
|
if ($ip != e107::LOCALHOST_IP && $ip != e107::LOCALHOST_IP2) // Check host name, user email to see if banned
|
||||||
|
{
|
||||||
$vals = array();
|
$vals = array();
|
||||||
if (e107::getPref('enable_rdns'))
|
if (e107::getPref('enable_rdns'))
|
||||||
{
|
{
|
||||||
@ -850,10 +891,21 @@ class eIPHandler
|
|||||||
if (count($vals))
|
if (count($vals))
|
||||||
{
|
{
|
||||||
$vals = array_unique($vals); // Could get identical values from domain name check and email check
|
$vals = array_unique($vals); // Could get identical values from domain name check and email check
|
||||||
|
|
||||||
|
if($this->debug)
|
||||||
|
{
|
||||||
|
print_a($vals);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$match = "`banlist_ip`='".implode("' OR `banlist_ip`='", $vals)."'";
|
$match = "`banlist_ip`='".implode("' OR `banlist_ip`='", $vals)."'";
|
||||||
$this->checkBan($match);
|
$this->checkBan($match);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elseif($this->debug)
|
||||||
|
{
|
||||||
|
print_a("IP is LocalHost - skipping ban-check");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -917,8 +969,23 @@ class eIPHandler
|
|||||||
echo $tp->toHTML(varset($pref['ban_messages'][$row['banlist_bantype']])); // Show message if one set
|
echo $tp->toHTML(varset($pref['ban_messages'][$row['banlist_bantype']])); // Show message if one set
|
||||||
}
|
}
|
||||||
//$admin_log->e_log_event(4, __FILE__."|".__FUNCTION__."@".__LINE__, 'BAN_03', 'LAN_AUDIT_LOG_003', $query, FALSE, LOG_TO_ROLLING);
|
//$admin_log->e_log_event(4, __FILE__."|".__FUNCTION__."@".__LINE__, 'BAN_03', 'LAN_AUDIT_LOG_003', $query, FALSE, LOG_TO_ROLLING);
|
||||||
|
|
||||||
|
if($this->debug)
|
||||||
|
{
|
||||||
|
echo "<pre>query: ".$query;
|
||||||
|
echo "\nBanned</pre>";
|
||||||
|
}
|
||||||
|
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($this->debug)
|
||||||
|
{
|
||||||
|
echo "query: ".$query;
|
||||||
|
echo "<br />Not Banned ";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//$admin_log->e_log_event(4,__FILE__."|".__FUNCTION__."@".__LINE__,"DBG","No ban found",$query,FALSE,LOG_TO_ROLLING);
|
//$admin_log->e_log_event(4,__FILE__."|".__FUNCTION__."@".__LINE__,"DBG","No ban found",$query,FALSE,LOG_TO_ROLLING);
|
||||||
return TRUE; // Email address OK
|
return TRUE; // Email address OK
|
||||||
}
|
}
|
||||||
|
@ -1344,8 +1344,11 @@ class themeHandler
|
|||||||
|
|
||||||
|
|
||||||
//TODO Later.
|
//TODO Later.
|
||||||
// $itext .= e107::getForm()->userclass('layoutUserclass['.$key.']',null, null, array('options'=>'public,member,admin,classes,no-excludes','size'=>'xxlarge'));
|
if(e_DEBUG === true)
|
||||||
|
{
|
||||||
|
$itext .= "<small>(Not functional yet)</small>";
|
||||||
|
$itext .= e107::getForm()->userclass('layoutUserclass['.$key.']',null, null, array('options'=>'public,member,admin,classes,no-excludes','size'=>'xxlarge'));
|
||||||
|
}
|
||||||
|
|
||||||
$itext .= "
|
$itext .= "
|
||||||
</div>\n";
|
</div>\n";
|
||||||
|
@ -327,6 +327,7 @@ if (!$forumList)
|
|||||||
$forum_string = '';
|
$forum_string = '';
|
||||||
$pVars = new e_vars;
|
$pVars = new e_vars;
|
||||||
$frm = e107::getForm();
|
$frm = e107::getForm();
|
||||||
|
|
||||||
foreach ($forumList['parents'] as $parent)
|
foreach ($forumList['parents'] as $parent)
|
||||||
{
|
{
|
||||||
$status = parse_parent($parent);
|
$status = parse_parent($parent);
|
||||||
@ -391,7 +392,6 @@ function parse_forum($f, $restricted_string = '')
|
|||||||
|
|
||||||
if(USER && is_array($newflag_list) && in_array($f['forum_id'], $newflag_list))
|
if(USER && is_array($newflag_list) && in_array($f['forum_id'], $newflag_list))
|
||||||
{
|
{
|
||||||
|
|
||||||
$fVars->NEWFLAG = "<a href='".$e107->url->create('forum/forum/mfar', $f)."'>".IMAGE_new.'</a>';
|
$fVars->NEWFLAG = "<a href='".$e107->url->create('forum/forum/mfar', $f)."'>".IMAGE_new.'</a>';
|
||||||
}
|
}
|
||||||
elseif(empty($f['forum_replies']) && defined('IMAGE_noreplies'))
|
elseif(empty($f['forum_replies']) && defined('IMAGE_noreplies'))
|
||||||
|
@ -530,7 +530,7 @@ if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'post') && $thread
|
|||||||
$url = e107::url('forum','post', null, array('query'=>$urlParms));; // ."?f=rp&id=".$thread->threadInfo['thread_id']."&post=".$thread->threadInfo['thread_id'];
|
$url = e107::url('forum','post', null, array('query'=>$urlParms));; // ."?f=rp&id=".$thread->threadInfo['thread_id']."&post=".$thread->threadInfo['thread_id'];
|
||||||
|
|
||||||
$tVars->QUICKREPLY = "
|
$tVars->QUICKREPLY = "
|
||||||
<form action='" . $e107->url->create('forum/thread/reply', array('id' => $thread->threadId)) . "' method='post'>
|
<form action='" . $url . "' method='post'>
|
||||||
<div class='form-group'>
|
<div class='form-group'>
|
||||||
<textarea cols='80' placeholder='".LAN_FORUM_2007."' rows='4' id='forum-quickreply-text' class='tbox input-xxlarge form-control' name='post' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'></textarea>
|
<textarea cols='80' placeholder='".LAN_FORUM_2007."' rows='4' id='forum-quickreply-text' class='tbox input-xxlarge form-control' name='post' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user