1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 05:37:32 +02:00

Set profanity list limit to 1000. (Could reduce performance)

Fix for comment template. Prevent secureImage from buffering too many keys.
This commit is contained in:
Cameron
2021-02-14 07:02:09 -08:00
parent e6bdc0e6ec
commit aee77a102f
5 changed files with 74 additions and 8 deletions

View File

@@ -1230,7 +1230,7 @@ if ($savePrefs) $core_pref->setPref($pref)->save(false, true);
<tr> <tr>
<td><label for='profanity-words'>".PRFLAN_43.":</label>".$frm->help(PRFLAN_44)."</td> <td><label for='profanity-words'>".PRFLAN_43.":</label>".$frm->help(PRFLAN_44)."</td>
<td> <td>
".$frm->tags('profanity_words', $pref['profanity_words'], 250, array('maxItems'=>40))." ".$frm->tags('profanity_words', $pref['profanity_words'], 250, array('maxItems'=>1000))."
</td> </td>
</tr> </tr>

View File

@@ -56,7 +56,7 @@ $COMMENT_TEMPLATE['item'] = '
<div class="media-object comment-box-left pull-left col-md-2 span1"> <div class="media-object comment-box-left pull-left col-md-2 span1">
{COMMENT_AVATAR: shape=circle} {COMMENT_AVATAR: shape=circle}
</div> </div>
<div class="media-body col-md-10 comment-box-right "> <div class="media-body comment-box-right ">
<div class="row"> <div class="row">
<div class="comment-box-username span2 col-xs-6 col-sm-6 col-md-6">{USERNAME}</div> <div class="comment-box-username span2 col-xs-6 col-sm-6 col-md-6">{USERNAME}</div>

View File

@@ -67,7 +67,30 @@ class secure_image
$this->secret = e107::getUserSession()->generateRandomString('*****'); $this->secret = e107::getUserSession()->generateRandomString('*****');
e107::getSession('secureImage')->set($this->random_number, $this->secret); $secImg = e107::getSession('secureImage');
$list = $secImg->get('secret');
$maxCache = 6;
if(!empty($list) && count($list) > $maxCache)
{
$total = count($list) - $maxCache;
$c = 1;
foreach($list as $key=>$v)
{
if($c > $total)
{
continue;
}
$secImg->clear('secret/'.$key);
$c++;
}
}
$secImg->set('secret/'.$this->random_number, $this->secret);
return $this->random_number; return $this->random_number;
} }
@@ -96,7 +119,8 @@ class secure_image
return call_user_func($user_func,$recnum,$checkstr); return call_user_func($user_func,$recnum,$checkstr);
} }
$secret = e107::getSession('secureImage')->get($recnum); $tmp = e107::getSession('secureImage')->get('secret');
$secret = varset($tmp[$recnum]);
if(!empty($secret) && ($secret === $checkstr)) if(!empty($secret) && ($secret === $checkstr))
{ {
@@ -269,10 +293,10 @@ class secure_image
// $code = intval($row['tmp_info']); // new value // $code = intval($row['tmp_info']); // new value
$tmp = e107::getSession('secureImage')->get('secret');
if($tmp = e107::getSession('secureImage')->get($recnum)) if(isset($tmp[$recnum]))
{ {
$code = $tmp; $code = $tmp[$recnum];
} }
else else
{ {

View File

@@ -397,7 +397,29 @@ class e_session
$this->_data = array(); // must be set to array() not unset. $this->_data = array(); // must be set to array() not unset.
} }
unset($this->_data[$key]); if(strpos($key,'/') !== false) // multi-dimensional
{
$keyArr = explode('/',$key);
$count = count($keyArr);
if($count === 2)
{
list($k1, $k2) = $keyArr;
unset($this->_data[$k1][$k2]);
}
elseif($count === 3)
{
list($k1, $k2, $k3) = $keyArr;
unset($this->_data[$k1][$k2][$k3]);
}
}
else
{
unset($this->_data[$key]);
}
return $this; return $this;
} }

View File

@@ -49,6 +49,26 @@
} }
public function testClear()
{
$this->sess->set('clear/one', 'Test 1');
$this->sess->set('clear/two', 'Test 2');
$this->sess->set('clear/three', 'Test 3');
$this->sess->clear('clear/two');
$expected = array (
'one' => 'Test 1',
'three' => 'Test 3',
);
$result = $this->sess->get('clear');
$this->assertSame($expected, $result);
}
public function testSetGet() public function testSetGet()
{ {
$expected = '123456'; $expected = '123456';