Empty commit

This commit is contained in:
Git 2013-04-22 08:00:58 +00:00
parent b8e7deff78
commit 7c417c6c16
7 changed files with 77 additions and 18 deletions

View File

@ -56,12 +56,30 @@ class TEXT {
private $NoImg = 0; // If images should be turned into URLs
private $Levels = 0;
/**
* The maximum amount of nesting allowed (exclusive)
* In reality n-1 nests are shown.
* @var int $MaximumNests
*/
private $MaximumNests = 10;
/**
* Used to detect and disable parsing (e.g. TOC) within quotes
* @var int $InQuotes
*/
private $InQuotes = 0;
/**
* Used to [hide] quote trains starting with the specified depth (inclusive)
* @var int $NestsBeforeHide
*
* This defaulted to 5 but was raised to 10 to effectively "disable" it until
* an optimal number of nested [quote] tags is chosen. The variable $MaximumNests
* effectively overrides this variable, if $MaximumNests is less than the value
* of $NestsBeforeHide.
*/
private $NestsBeforeHide = 10;
/**
* Array of headlines for Table Of Contents (TOC)
@ -504,8 +522,7 @@ private function parse ($Str) {
* Generates a navigation list for TOC
* @param int $Min Minimum number of headlines required for a TOC list
*/
public function parse_toc ($Min = 3)
{
public function parse_toc ($Min = 3) {
if (count($this->Headlines) > $Min) {
$list = '<ol class="navigation_list">';
$i = 0;
@ -548,8 +565,7 @@ public function parse_toc ($Min = 3)
* @param int $i Iterator digit
* @param int $Offset If the list doesn't start at level 1
*/
private function headline_level (&$ItemLevel, &$Level, &$List, $i, &$Offset)
{
private function headline_level (&$ItemLevel, &$Level, &$List, $i, &$Offset) {
if ($ItemLevel < $Level) {
$diff = $Level - $ItemLevel;
$List .= '</li>' . str_repeat('</ol></li>', $diff);
@ -569,17 +585,30 @@ private function headline_level (&$ItemLevel, &$Level, &$List, $i, &$Offset)
private function to_html ($Array) {
global $SSL;
$this->Levels++;
if ($this->Levels > 10) {
return $Block['Val'];
} // Hax prevention
/*
* Hax prevention
* That's the original comment on this.
* Most likely this was implemented to avoid anyone nesting enough
* elements to reach PHP's memory limit as nested elements are
* solved recursively.
* Original value of 10, it is now replaced in favor of
* $MaximumNests.
* If this line is ever executed then something is, infact
* being haxed as the if before the block type switch for different
* tags should always be limiting ahead of this line.
* (Larger than vs. smaller than.)
*/
if ($this->Levels > $this->MaximumNests) {
return $Block['Val']; // Hax prevention, breaks upon exceeding nests.
}
$Str = '';
foreach ($Array as $Block) {
if (is_string($Block)) {
$Str.=$this->smileys($Block);
continue;
}
switch($Block['Type']) {
if ($this->Levels < $this->MaximumNests) {
switch ($Block['Type']) {
case 'b':
$Str.='<strong>'.$this->to_html($Block['Val']).'</strong>';
break;
@ -692,17 +721,24 @@ private function to_html ($Array) {
case 'quote':
$this->NoImg++; // No images inside quote tags
$this->InQuotes++;
if ($this->InQuotes == $this->NestsBeforeHide) { //Put quotes that are nested beyond the specified limit in [hide] tags.
$Str.='<strong>Older quotes</strong>: <a href="javascript:void(0);" onclick="BBCode.spoiler(this);">Show</a>';
$Str.='<blockquote class="hidden spoiler">';
}
if (!empty($Block['Attr'])) {
$Exploded = explode('|', $this->to_html($Block['Attr']));
if (isset($Exploded[1]) && is_numeric($Exploded[1])) {
if (isset($Exploded[1]) && is_numeric($Exploded[1])) {
$PostID = trim($Exploded[1]);
$Str.='<a href="#" onclick="QuoteJump(event, '.$PostID.'); return false;"><strong class="quoteheader">'.$Exploded[0].'</strong> wrote: </a>';
$Str.= '<a href="#" onclick="QuoteJump('.$PostID.'); return false;"><strong class="quoteheader">'.$Exploded[0].'</strong> wrote: </a>';
}
else {
$Str.='<strong class="quoteheader">'.$Exploded[0].'</strong> wrote: ';
}
}
$Str.='<blockquote>'.$this->to_html($Block['Val']).'</blockquote>';
if($this->InQuotes == $this->NestsBeforeHide) { //Close quote the deeply nested quote [hide].
$Str.='</blockquote><br />'; // Ensure new line after quote train hiding
}
$this->NoImg--;
$this->InQuotes--;
break;
@ -800,6 +836,7 @@ private function to_html ($Array) {
}
}
}
$this->Levels--;
return $Str;
}
@ -811,7 +848,7 @@ private function raw_text ($Array) {
$Str.=$Block;
continue;
}
switch($Block['Type']) {
switch ($Block['Type']) {
case 'headline':
break;
case 'b':

View File

@ -13,7 +13,7 @@
/* AJAX_LIMIT = array(x,y) = 'x' requests every 'y' seconds.
e.g. array(5,10) = 5 requests every 10 seconds */
$AJAX_LIMIT = array(5,10);
$Limited_Pages = array('tcomments','user','forum','top10','browse','usersearch','requests','artist','inbox','subscriptions','bookmarks','announcements','notifications','request','better','similar_artists','userhistory','votefavorite','wiki');
$Limited_Pages = array('tcomments','user','forum','top10','browse','usersearch','requests','artist','inbox','subscriptions','bookmarks','announcements','notifications','request','better','similar_artists','userhistory','votefavorite','wiki','torrentgroup');
header('Content-Type: application/json; charset=utf-8');

View File

@ -32,7 +32,7 @@
<h3>Subject</h3>
<input type="text" name="subject" size="95" value="<?=(!empty($Subject) ? $Subject : '')?>" /><br />
<h3>Body</h3>
<textarea id="body" name="body" cols="95" rows="10"><?=(!empty($Body) ? $Body : '')?></textarea>
<textarea id="body" name="body" cols="95" rows="10" onkeyup="resize('body')"><?=(!empty($Body) ? $Body : '')?></textarea>
</div>
<div id="preview" class="hidden"></div>
<div id="buttons" class="center">

View File

@ -92,7 +92,7 @@
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="toid" value="<?=implode(',',$ReceiverIDs)?>" />
<input type="hidden" name="convid" value="<?=$ConvID?>" />
<textarea id="quickpost" name="body" cols="90" rows="10"></textarea> <br />
<textarea id="quickpost" name="body" cols="90" rows="10" onkeyup="resize('quickpost')"></textarea> <br />
<div id="preview" class="box vertical_space body hidden"></div>
<div id="buttons" class="center">
<input type="button" value="Preview" onclick="Quick_Preview();" />

View File

@ -21,8 +21,20 @@
} else {
switch ($_GET['type']) {
case 'created':
$Title = 'My requests';
$SS->set_filter('userid', array($LoggedUser['ID']));
if (!empty($_GET['userid'])) {
if (is_number($_GET['userid'])) {
if (!check_paranoia('requestsvoted_list', $UserInfo['Paranoia'], $Perms['Class'], $_GET['userid'])) {
error(403);
}
$Title = 'Requests created by ' . $UserInfo['Username'];
$SS->set_filter('userid', array($_GET['userid']));
} else {
error(404);
}
} else {
$Title = 'My requests';
$SS->set_filter('userid', array($LoggedUser['ID']));
}
break;
case 'voted':
if (!empty($_GET['userid'])) {

View File

@ -104,12 +104,20 @@
$ViewBounty = check_paranoia_here('requestsvoted_bounty');
if ($ViewCount && !$ViewBounty && !$ViewAll) { ?>
<li>Requests created: <?=number_format($RequestsCreated)?></li>
<li>Requests voted: <?=number_format($RequestsVoted)?></li>
<? } elseif (!$ViewCount && $ViewBounty && !$ViewAll) { ?>
<li>Requests created: <?=Format::get_size($RequestsCreatedSpent)?> spent</li>
<li>Requests voted: <?=Format::get_size($TotalSpent)?> spent</li>
<? } elseif ($ViewCount && $ViewBounty && !$ViewAll) { ?>
<li>Requests created: <?=number_format($RequestsCreated)?> for <?=Format::get_size($RequestsCreatedSpent)?></li>
<li>Requests voted: <?=number_format($RequestsVoted)?> for <?=Format::get_size($TotalSpent)?></li>
<? } elseif ($ViewAll) { ?>
<li>
<span<?= ($ViewCount === 2) ? ' class="paranoia_override"' : ''?>>Requests created: <?=number_format($RequestsCreated)?></span>
<span<?= ($ViewBounty === 2) ? ' class="paranoia_override"' : ''?>> for <?=Format::get_size($RequestsCreatedSpent)?></span>
<a href="requests.php?type=created&amp;userid=<?=$UserID?>" class="brackets<?= ($ViewAll === 2) ? ' paranoia_override' : '' ?>" title="View">View</a>
</li>
<li>
<span<?= ($ViewCount === 2) ? ' class="paranoia_override"' : ''?>>Requests voted: <?=number_format($RequestsVoted)?></span>
<span<?= ($ViewBounty === 2) ? ' class="paranoia_override"' : ''?>> for <?=Format::get_size($TotalSpent)?></span>

View File

@ -266,8 +266,10 @@ function check_paranoia_here($Setting) {
if (check_paranoia_here('requestsvoted_count') || check_paranoia_here('requestsvoted_bounty')) {
$DB->query("SELECT COUNT(rv.RequestID), SUM(rv.Bounty) FROM requests_votes AS rv WHERE rv.UserID = ".$UserID);
list($RequestsVoted, $TotalSpent) = $DB->next_record();
$DB->query('SELECT COUNT(r.ID), SUM(rv.Bounty) FROM requests AS r LEFT JOIN requests_votes AS rv ON rv.RequestID = r.ID AND rv.UserID = r.UserID WHERE r.UserID = ' . $UserID);
list($RequestsCreated, $RequestsCreatedSpent) = $DB->next_record();
} else {
$RequestsVoted = $TotalSpent = 0;
$RequestsVoted = $TotalSpent = $RequestsCreated = $RequestsCreatedSpent = 0;
}
if (check_paranoia_here('uploads+')) {