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

@ -57,12 +57,30 @@ class TEXT {
private $Levels = 0; 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 * Used to detect and disable parsing (e.g. TOC) within quotes
* @var int $InQuotes * @var int $InQuotes
*/ */
private $InQuotes = 0; 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) * Array of headlines for Table Of Contents (TOC)
* @var array $HeadLines * @var array $HeadLines
@ -504,8 +522,7 @@ private function parse ($Str) {
* Generates a navigation list for TOC * Generates a navigation list for TOC
* @param int $Min Minimum number of headlines required for a TOC list * @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) { if (count($this->Headlines) > $Min) {
$list = '<ol class="navigation_list">'; $list = '<ol class="navigation_list">';
$i = 0; $i = 0;
@ -548,8 +565,7 @@ public function parse_toc ($Min = 3)
* @param int $i Iterator digit * @param int $i Iterator digit
* @param int $Offset If the list doesn't start at level 1 * @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) { if ($ItemLevel < $Level) {
$diff = $Level - $ItemLevel; $diff = $Level - $ItemLevel;
$List .= '</li>' . str_repeat('</ol></li>', $diff); $List .= '</li>' . str_repeat('</ol></li>', $diff);
@ -569,16 +585,29 @@ private function headline_level (&$ItemLevel, &$Level, &$List, $i, &$Offset)
private function to_html ($Array) { private function to_html ($Array) {
global $SSL; global $SSL;
$this->Levels++; $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 = ''; $Str = '';
foreach ($Array as $Block) { foreach ($Array as $Block) {
if (is_string($Block)) { if (is_string($Block)) {
$Str.=$this->smileys($Block); $Str.=$this->smileys($Block);
continue; continue;
} }
if ($this->Levels < $this->MaximumNests) {
switch ($Block['Type']) { switch ($Block['Type']) {
case 'b': case 'b':
$Str.='<strong>'.$this->to_html($Block['Val']).'</strong>'; $Str.='<strong>'.$this->to_html($Block['Val']).'</strong>';
@ -692,17 +721,24 @@ private function to_html ($Array) {
case 'quote': case 'quote':
$this->NoImg++; // No images inside quote tags $this->NoImg++; // No images inside quote tags
$this->InQuotes++; $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'])) { if (!empty($Block['Attr'])) {
$Exploded = explode('|', $this->to_html($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]); $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 { else {
$Str.='<strong class="quoteheader">'.$Exploded[0].'</strong> wrote: '; $Str.='<strong class="quoteheader">'.$Exploded[0].'</strong> wrote: ';
} }
} }
$Str.='<blockquote>'.$this->to_html($Block['Val']).'</blockquote>'; $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->NoImg--;
$this->InQuotes--; $this->InQuotes--;
break; break;
@ -800,6 +836,7 @@ private function to_html ($Array) {
} }
} }
}
$this->Levels--; $this->Levels--;
return $Str; return $Str;
} }

View File

@ -13,7 +13,7 @@
/* AJAX_LIMIT = array(x,y) = 'x' requests every 'y' seconds. /* AJAX_LIMIT = array(x,y) = 'x' requests every 'y' seconds.
e.g. array(5,10) = 5 requests every 10 seconds */ e.g. array(5,10) = 5 requests every 10 seconds */
$AJAX_LIMIT = array(5,10); $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'); header('Content-Type: application/json; charset=utf-8');

View File

@ -32,7 +32,7 @@
<h3>Subject</h3> <h3>Subject</h3>
<input type="text" name="subject" size="95" value="<?=(!empty($Subject) ? $Subject : '')?>" /><br /> <input type="text" name="subject" size="95" value="<?=(!empty($Subject) ? $Subject : '')?>" /><br />
<h3>Body</h3> <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>
<div id="preview" class="hidden"></div> <div id="preview" class="hidden"></div>
<div id="buttons" class="center"> <div id="buttons" class="center">

View File

@ -92,7 +92,7 @@
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" /> <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="toid" value="<?=implode(',',$ReceiverIDs)?>" /> <input type="hidden" name="toid" value="<?=implode(',',$ReceiverIDs)?>" />
<input type="hidden" name="convid" value="<?=$ConvID?>" /> <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="preview" class="box vertical_space body hidden"></div>
<div id="buttons" class="center"> <div id="buttons" class="center">
<input type="button" value="Preview" onclick="Quick_Preview();" /> <input type="button" value="Preview" onclick="Quick_Preview();" />

View File

@ -21,8 +21,20 @@
} else { } else {
switch ($_GET['type']) { switch ($_GET['type']) {
case 'created': case 'created':
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'; $Title = 'My requests';
$SS->set_filter('userid', array($LoggedUser['ID'])); $SS->set_filter('userid', array($LoggedUser['ID']));
}
break; break;
case 'voted': case 'voted':
if (!empty($_GET['userid'])) { if (!empty($_GET['userid'])) {

View File

@ -104,12 +104,20 @@
$ViewBounty = check_paranoia_here('requestsvoted_bounty'); $ViewBounty = check_paranoia_here('requestsvoted_bounty');
if ($ViewCount && !$ViewBounty && !$ViewAll) { ?> if ($ViewCount && !$ViewBounty && !$ViewAll) { ?>
<li>Requests created: <?=number_format($RequestsCreated)?></li>
<li>Requests voted: <?=number_format($RequestsVoted)?></li> <li>Requests voted: <?=number_format($RequestsVoted)?></li>
<? } elseif (!$ViewCount && $ViewBounty && !$ViewAll) { ?> <? } elseif (!$ViewCount && $ViewBounty && !$ViewAll) { ?>
<li>Requests created: <?=Format::get_size($RequestsCreatedSpent)?> spent</li>
<li>Requests voted: <?=Format::get_size($TotalSpent)?> spent</li> <li>Requests voted: <?=Format::get_size($TotalSpent)?> spent</li>
<? } elseif ($ViewCount && $ViewBounty && !$ViewAll) { ?> <? } 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> <li>Requests voted: <?=number_format($RequestsVoted)?> for <?=Format::get_size($TotalSpent)?></li>
<? } elseif ($ViewAll) { ?> <? } 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> <li>
<span<?= ($ViewCount === 2) ? ' class="paranoia_override"' : ''?>>Requests voted: <?=number_format($RequestsVoted)?></span> <span<?= ($ViewCount === 2) ? ' class="paranoia_override"' : ''?>>Requests voted: <?=number_format($RequestsVoted)?></span>
<span<?= ($ViewBounty === 2) ? ' class="paranoia_override"' : ''?>> for <?=Format::get_size($TotalSpent)?></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')) { 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); $DB->query("SELECT COUNT(rv.RequestID), SUM(rv.Bounty) FROM requests_votes AS rv WHERE rv.UserID = ".$UserID);
list($RequestsVoted, $TotalSpent) = $DB->next_record(); 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 { } else {
$RequestsVoted = $TotalSpent = 0; $RequestsVoted = $TotalSpent = $RequestsCreated = $RequestsCreatedSpent = 0;
} }
if (check_paranoia_here('uploads+')) { if (check_paranoia_here('uploads+')) {