Empty commit

This commit is contained in:
Git 2013-02-10 08:00:29 +00:00
parent 98bc98ed16
commit 35473bd15d
15 changed files with 350 additions and 359 deletions

View File

@ -54,7 +54,7 @@ class TEXT {
); );
private $NoImg = 0; // If images should be turned into URLs private $NoImg = 0; // If images should be turned into URLs
private $Levels = 0; private $Levels = 0;
/** /**
@ -98,7 +98,7 @@ public function __construct ($TOC = false) {
reset($this->Smileys); reset($this->Smileys);
} }
/** /**
* Output BBCode as XHTML * Output BBCode as XHTML
* @param string $Str BBCode text * @param string $Str BBCode text
* @param bool $OutputTOC Ouput TOC near (above) text * @param bool $OutputTOC Ouput TOC near (above) text
@ -434,9 +434,9 @@ private function parse ($Str) {
case 'tex': case 'tex':
$Array[$ArrayPos] = array('Type'=>'tex', 'Val'=>$Block); $Array[$ArrayPos] = array('Type'=>'tex', 'Val'=>$Block);
break; break;
case 'rule': case 'rule':
$Array[$ArrayPos] = array('Type'=>'rule', 'Val'=>$Block); $Array[$ArrayPos] = array('Type'=>'rule', 'Val'=>$Block);
break; break;
case 'pre': case 'pre':
case 'code': case 'code':
case 'plain': case 'plain':
@ -529,10 +529,10 @@ public function parse_toc ($Min = 3)
/** /**
* Generates the list items and proper depth * Generates the list items and proper depth
* *
* First check if the item should be higher than the current level * First check if the item should be higher than the current level
* - Close the list and previous lists * - Close the list and previous lists
* *
* Then check if the item should go lower than the current level * Then check if the item should go lower than the current level
* - If the list doesn't open on level one, use the Offset * - If the list doesn't open on level one, use the Offset
* - Open appropriate sub lists * - Open appropriate sub lists
* *
@ -584,7 +584,7 @@ private function to_html ($Array) {
$Str.='<em>'.$this->to_html($Block['Val'])."</em>"; $Str.='<em>'.$this->to_html($Block['Val'])."</em>";
break; break;
case 's': case 's':
$Str.='<span style="text-decoration: line-through">'.$this->to_html($Block['Val']).'</span>'; $Str.='<span style="text-decoration: line-through;">'.$this->to_html($Block['Val']).'</span>';
break; break;
case 'important': case 'important':
$Str.='<strong class="important_text">'.$this->to_html($Block['Val']).'</strong>'; $Str.='<strong class="important_text">'.$this->to_html($Block['Val']).'</strong>';
@ -595,13 +595,13 @@ private function to_html ($Array) {
case 'artist': case 'artist':
$Str.='<a href="artist.php?artistname='.urlencode(Format::undisplay_str($Block['Val'])).'">'.$Block['Val'].'</a>'; $Str.='<a href="artist.php?artistname='.urlencode(Format::undisplay_str($Block['Val'])).'">'.$Block['Val'].'</a>';
break; break;
case 'rule': case 'rule':
$Rule = trim(strtolower($Block['Val'])); $Rule = trim(strtolower($Block['Val']));
if($Rule[0] != 'r' && $Rule[0] != 'h') { if($Rule[0] != 'r' && $Rule[0] != 'h') {
$Rule = 'r'.$Rule; $Rule = 'r'.$Rule;
} }
$Str.='<a href="rules.php?p=upload#'.urlencode(Format::undisplay_str($Rule)).'">'.preg_replace('/[aA-zZ]/', '', $Block['Val']).'</a>'; $Str.='<a href="rules.php?p=upload#'.urlencode(Format::undisplay_str($Rule)).'">'.preg_replace('/[aA-zZ]/', '', $Block['Val']).'</a>';
break; break;
case 'torrent': case 'torrent':
$Pattern = '/('.NONSSL_SITE_URL.'\/torrents\.php.*[\?&]id=)?(\d+)($|&|\#).*/i'; $Pattern = '/('.NONSSL_SITE_URL.'\/torrents\.php.*[\?&]id=)?(\d+)($|&|\#).*/i';
$Matches = array(); $Matches = array();
@ -635,7 +635,7 @@ private function to_html ($Array) {
$Str.='<code>'.$Block['Val'].'</code>'; $Str.='<code>'.$Block['Val'].'</code>';
break; break;
case 'list': case 'list':
$Str .= '<'.$Block['ListType'].'>'; $Str.='<'.$Block['ListType'].'>';
foreach($Block['Val'] as $Line) { foreach($Block['Val'] as $Line) {
$Str.='<li>'.$this->to_html($Line).'</li>'; $Str.='<li>'.$this->to_html($Line).'</li>';
@ -686,13 +686,13 @@ private function to_html ($Array) {
$this->InQuotes++; $this->InQuotes++;
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(event, '.$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>';
$this->NoImg--; $this->NoImg--;
@ -710,11 +710,11 @@ private function to_html ($Array) {
$Str.='<blockquote class="hidden spoiler">'.$this->to_html($Block['Val']).'</blockquote>'; $Str.='<blockquote class="hidden spoiler">'.$this->to_html($Block['Val']).'</blockquote>';
} }
else { else {
$Str .= '<strong>Use of the [mature] tag requires a description.</strong> The correct format is as follows: <strong>[mature=description] ...content... [/mature]</strong>, where "description" is a mandatory description of the post. Misleading descriptions will be penalized. For further information on our mature content policies, please refer to this <a href="wiki.php?action=article&amp;id=1063">wiki</a>.'; $Str.='<strong>Use of the [mature] tag requires a description.</strong> The correct format is as follows: <strong>[mature=description] ...content... [/mature]</strong>, where "description" is a mandatory description of the post. Misleading descriptions will be penalized. For further information on our mature content policies, please refer to this <a href="wiki.php?action=article&amp;id=1063">wiki</a>.';
} }
} }
else { else {
$Str .= '<span class="mature_blocked" style="font-style:italic;"><a href="wiki.php?action=article&amp;id=1063">Mature content </a>has been blocked. You can choose to view mature content by editing your <a href="user.php?action=edit&amp;userid=' . $LoggedUser['ID'] . '">settings</a>.</span>'; $Str.='<span class="mature_blocked" style="font-style:italic;"><a href="wiki.php?action=article&amp;id=1063">Mature content </a>has been blocked. You can choose to view mature content by editing your <a href="user.php?action=edit&amp;userid=' . $LoggedUser['ID'] . '">settings</a>.</span>';
} }
break; break;
case 'img': case 'img':

View File

@ -49,17 +49,17 @@ class TEXT_2 {
':wtf:' => 'wtf.gif', ':wtf:' => 'wtf.gif',
':wub:' => 'wub.gif', ':wub:' => 'wub.gif',
); );
private $NoImg = 0; // If images should be turned into URLs private $NoImg = 0; // If images should be turned into URLs
private $Levels = 0; // If images should be turned into URLs private $Levels = 0; // If images should be turned into URLs
function __construct() { function __construct() {
foreach($this->Smileys as $Key=>$Val) { foreach($this->Smileys as $Key=>$Val) {
$this->Smileys[$Key] = '<img border="0" src="'.STATIC_SERVER.'common/smileys/'.$Val.'" alt="" />'; $this->Smileys[$Key] = '<img border="0" src="'.STATIC_SERVER.'common/smileys/'.$Val.'" alt="" />';
} }
reset($this->Smileys); reset($this->Smileys);
} }
function full_format($Str) { function full_format($Str) {
$Str = display_str($Str); $Str = display_str($Str);
@ -68,37 +68,37 @@ function full_format($Str) {
$Str = preg_replace('/'.$URLPrefix.'\s+http/i', '$1http', $Str); $Str = preg_replace('/'.$URLPrefix.'\s+http/i', '$1http', $Str);
$Str = preg_replace('/(?<!'.$URLPrefix.')http(s)?:\/\//i', '$1[inlineurl]http$2://', $Str); $Str = preg_replace('/(?<!'.$URLPrefix.')http(s)?:\/\//i', '$1[inlineurl]http$2://', $Str);
// For anonym.to and archive.org links, remove any [inlineurl] in the middle of the link // For anonym.to and archive.org links, remove any [inlineurl] in the middle of the link
$Str = strtr($Str, array('?[inlineurl]http'=>'?http', '=[inlineurl]http'=>'=http')); $Str = strtr($Str, array('?[inlineurl]http'=>'?http', '=[inlineurl]http'=>'=http'));
$callback = create_function('$matches', 'return str_replace("[inlineurl]","",$matches[0]);'); $callback = create_function('$matches', 'return str_replace("[inlineurl]","",$matches[0]);');
$Str = preg_replace_callback('/(?<=\[inlineurl\]|'.$URLPrefix.')(\S*\[inlineurl\]\S*)/m', $callback, $Str); $Str = preg_replace_callback('/(?<=\[inlineurl\]|'.$URLPrefix.')(\S*\[inlineurl\]\S*)/m', $callback, $Str);
$Str = preg_replace('/\=\=\=\=([^=].*)\=\=\=\=/i', '[inlinesize=3]$1[/inlinesize]', $Str); $Str = preg_replace('/\=\=\=\=([^=].*)\=\=\=\=/i', '[inlinesize=3]$1[/inlinesize]', $Str);
$Str = preg_replace('/\=\=\=([^=].*)\=\=\=/i', '[inlinesize=5]$1[/inlinesize]', $Str); $Str = preg_replace('/\=\=\=([^=].*)\=\=\=/i', '[inlinesize=5]$1[/inlinesize]', $Str);
$Str = preg_replace('/\=\=([^=].*)\=\=/i', '[inlinesize=7]$1[/inlinesize]', $Str); $Str = preg_replace('/\=\=([^=].*)\=\=/i', '[inlinesize=7]$1[/inlinesize]', $Str);
$Str = $this->parse($Str); $Str = $this->parse($Str);
$HTML = $this->to_html($Str); $HTML = $this->to_html($Str);
$HTML = nl2br($HTML); $HTML = nl2br($HTML);
return $HTML; return $HTML;
} }
function strip_bbcode($Str) { function strip_bbcode($Str) {
$Str = display_str($Str); $Str = display_str($Str);
//Inline links //Inline links
$Str = preg_replace('/(?<!(\[url\]|\[url\=|\[img\=|\[img\]))http(s)?:\/\//i', '$1[inlineurl]http$2://', $Str); $Str = preg_replace('/(?<!(\[url\]|\[url\=|\[img\=|\[img\]))http(s)?:\/\//i', '$1[inlineurl]http$2://', $Str);
$Str = $this->parse($Str); $Str = $this->parse($Str);
$Str = $this->raw_text($Str); $Str = $this->raw_text($Str);
$Str = nl2br($Str); $Str = nl2br($Str);
return $Str; return $Str;
} }
function valid_url($Str, $Extension = '', $Inline = false) { function valid_url($Str, $Extension = '', $Inline = false) {
$Regex = '/^'; $Regex = '/^';
$Regex .= '(https?|ftps?|irc):\/\/'; // protocol $Regex .= '(https?|ftps?|irc):\/\/'; // protocol
@ -123,10 +123,10 @@ function valid_url($Str, $Extension = '', $Inline = false) {
$Regex .= '(#[a-z0-9\-_.,%\/\@[\]~&=:;()+*\^$!]*)?'; // #anchor $Regex .= '(#[a-z0-9\-_.,%\/\@[\]~&=:;()+*\^$!]*)?'; // #anchor
$Regex .= '$/i'; $Regex .= '$/i';
return preg_match($Regex, $Str, $Matches); return preg_match($Regex, $Str, $Matches);
} }
function local_url($Str) { function local_url($Str) {
$URLInfo = parse_url($Str); $URLInfo = parse_url($Str);
if(!$URLInfo) { return false; } if(!$URLInfo) { return false; }
@ -145,15 +145,15 @@ function local_url($Str) {
} else { } else {
return false; return false;
} }
} }
/* How parsing works /* How parsing works
Parsing takes $Str, breaks it into blocks, and builds it into $Array. Parsing takes $Str, breaks it into blocks, and builds it into $Array.
Blocks start at the beginning of $Str, when the parser encounters a [, and after a tag has been closed. Blocks start at the beginning of $Str, when the parser encounters a [, and after a tag has been closed.
This is all done in a loop. This is all done in a loop.
EXPLANATION OF PARSER LOGIC EXPLANATION OF PARSER LOGIC
@ -173,14 +173,14 @@ function local_url($Str) {
[quote=joe]I am a redneck!**[/quote] [quote=joe]I am a redneck!**[/quote]
Me too! Me too!
***[/quote] ***[/quote]
If we're at the position *, the first [/quote] tag is denoted by **. If we're at the position *, the first [/quote] tag is denoted by **.
However, our quote tag doesn't actually close there. We must perform However, our quote tag doesn't actually close there. We must perform
a loop which checks the number of opening [quote] tags, and make sure a loop which checks the number of opening [quote] tags, and make sure
they are all closed before we find our final [/quote] tag (***). they are all closed before we find our final [/quote] tag (***).
5c) Get the contents between [open] and [/close] and call it the block. 5c) Get the contents between [open] and [/close] and call it the block.
In many cases, this will be parsed itself later on, in a new parse() call. In many cases, this will be parsed itself later on, in a new parse() call.
5d) Move the pointer past the end of the [/close] tag. 5d) Move the pointer past the end of the [/close] tag.
6) Depending on what type of tag we're dealing with, create an array with the attribute and block. 6) Depending on what type of tag we're dealing with, create an array with the attribute and block.
In many cases, the block may be parsed here itself. Stick them in the $Array. In many cases, the block may be parsed here itself. Stick them in the $Array.
7) Increment array pointer, start again (past the end of the [/close] tag) 7) Increment array pointer, start again (past the end of the [/close] tag)
@ -194,7 +194,7 @@ function parse($Str) {
while($i<$Len) { while($i<$Len) {
$Block = ''; $Block = '';
// 1) Find and parse the next tag (regex) // 1) Find and parse the next tag (regex)
// [name=|[name]|[[wiki-link]] // [name=|[name]|[[wiki-link]]
$IsTag = preg_match("/((\[[a-zA-Z*]{1,100})([=\]]))|(\[\[[^\n\"'\[\]]+\]\])/", $Str, $Tag, PREG_OFFSET_CAPTURE, $i); $IsTag = preg_match("/((\[[a-zA-Z*]{1,100})([=\]]))|(\[\[[^\n\"'\[\]]+\]\])/", $Str, $Tag, PREG_OFFSET_CAPTURE, $i);
@ -211,9 +211,9 @@ function parse($Str) {
} elseif ($IsTag) { // 1b) If it's not a wiki link: } elseif ($IsTag) { // 1b) If it's not a wiki link:
$WikiLink = false; $WikiLink = false;
$TagName = strtolower(substr($Tag[2][0], 1)); $TagName = strtolower(substr($Tag[2][0], 1));
$MaxAttribs = $this->ValidTags[$TagName]; $MaxAttribs = $this->ValidTags[$TagName];
// 1bi) check it against the $this->ValidTags array to see if it's actually a tag and not [bullshit] // 1bi) check it against the $this->ValidTags array to see if it's actually a tag and not [bullshit]
if(!isset($this->ValidTags[$TagName])) { if(!isset($this->ValidTags[$TagName])) {
$IsTag = 0; $IsTag = 0;
@ -251,39 +251,39 @@ function parse($Str) {
++$ArrayPos; ++$ArrayPos;
continue; continue;
} }
} }
// 2) If there aren't any tags left, write everything remaining to a block // 2) If there aren't any tags left, write everything remaining to a block
if(!$IsTag) { if(!$IsTag) {
// No more tags // No more tags
$Array[$ArrayPos] = substr($Str, $i); $Array[$ArrayPos] = substr($Str, $i);
break; break;
} }
// 3) If the next tag isn't where the pointer is, write everything up to there to a text block. // 3) If the next tag isn't where the pointer is, write everything up to there to a text block.
if($TagPos>$i) { if($TagPos>$i) {
$Array[$ArrayPos] = substr($Str, $i, $TagPos-$i); $Array[$ArrayPos] = substr($Str, $i, $TagPos-$i);
++$ArrayPos; ++$ArrayPos;
$i=$TagPos; $i=$TagPos;
} }
// 4) Move the pointer past the end of the tag // 4) Move the pointer past the end of the tag
$i=$TagPos+strlen($Tag[0][0])+$ExtraTagLen; $i=$TagPos+strlen($Tag[0][0])+$ExtraTagLen;
// 5) Find out where the tag closes (beginning of [/tag]) // 5) Find out where the tag closes (beginning of [/tag])
// Unfortunately, BBCode doesn't have nice standards like xhtml // Unfortunately, BBCode doesn't have nice standards like xhtml
// [*], [img=...], and http:// follow different formats // [*], [img=...], and http:// follow different formats
// Thus, we have to handle these before we handle the majority of tags // Thus, we have to handle these before we handle the majority of tags
//5a) Different for different types of tag. Some tags don't close, others are weird like [*] //5a) Different for different types of tag. Some tags don't close, others are weird like [*]
if($TagName == 'img' && $HasAttrib) { //[img=...] if($TagName == 'img' && $HasAttrib) { //[img=...]
$Block = ''; // Nothing inside this tag $Block = ''; // Nothing inside this tag
// Don't need to touch $i // Don't need to touch $i
} elseif($TagName == 'inlineurl') { // We did a big replace early on to turn http:// into [inlineurl]http:// } elseif($TagName == 'inlineurl') { // We did a big replace early on to turn http:// into [inlineurl]http://
// Let's say the block can stop at a newline or a space // Let's say the block can stop at a newline or a space
$CloseTag = strcspn($Str, " \n\r", $i); $CloseTag = strcspn($Str, " \n\r", $i);
if($CloseTag === false) { // block finishes with URL if($CloseTag === false) { // block finishes with URL
@ -298,11 +298,11 @@ function parse($Str) {
$URL = substr($URL, 0, -1); $URL = substr($URL, 0, -1);
} }
$Block = $URL; // Get the URL $Block = $URL; // Get the URL
// strcspn returns the number of characters after the offset $i, not after the beginning of the string // strcspn returns the number of characters after the offset $i, not after the beginning of the string
// Therefore, we use += instead of the = everywhere else // Therefore, we use += instead of the = everywhere else
$i += $CloseTag; // 5d) Move the pointer past the end of the [/close] tag. $i += $CloseTag; // 5d) Move the pointer past the end of the [/close] tag.
} elseif($WikiLink == true || $TagName == 'n') { } elseif($WikiLink == true || $TagName == 'n') {
// Don't need to do anything - empty tag with no closing // Don't need to do anything - empty tag with no closing
} elseif($TagName == '*') { } elseif($TagName == '*') {
// We're in a list. Find where it ends // We're in a list. Find where it ends
@ -310,28 +310,28 @@ function parse($Str) {
do { // Look for \n[*] do { // Look for \n[*]
$NewLine = strpos($Str, "\n", $NewLine+1); $NewLine = strpos($Str, "\n", $NewLine+1);
} while($NewLine!== false && substr($Str, $NewLine+1, 3) == '[*]'); } while($NewLine!== false && substr($Str, $NewLine+1, 3) == '[*]');
$CloseTag = $NewLine; $CloseTag = $NewLine;
if($CloseTag === false) { // block finishes with list if($CloseTag === false) { // block finishes with list
$CloseTag = $Len; $CloseTag = $Len;
} }
$Block = substr($Str, $i, $CloseTag-$i); // Get the list $Block = substr($Str, $i, $CloseTag-$i); // Get the list
$i = $CloseTag; // 5d) Move the pointer past the end of the [/close] tag. $i = $CloseTag; // 5d) Move the pointer past the end of the [/close] tag.
} else { } else {
//5b) If it's a normal tag, it may have versions of itself nested inside //5b) If it's a normal tag, it may have versions of itself nested inside
$CloseTag = $i-1; $CloseTag = $i-1;
$InTagPos = $i-1; $InTagPos = $i-1;
$NumInOpens = 0; $NumInOpens = 0;
$NumInCloses = -1; $NumInCloses = -1;
$InOpenRegex = '/\[('.$TagName.')'; $InOpenRegex = '/\[('.$TagName.')';
if($MaxAttribs>0) { if($MaxAttribs>0) {
$InOpenRegex.="(=[^\n'\"\[\]]+)?"; $InOpenRegex.="(=[^\n'\"\[\]]+)?";
} }
$InOpenRegex.='\]/i'; $InOpenRegex.='\]/i';
// Every time we find an internal open tag of the same type, search for the next close tag // Every time we find an internal open tag of the same type, search for the next close tag
// (as the first close tag won't do - it's been opened again) // (as the first close tag won't do - it's been opened again)
do { do {
$CloseTag = stripos($Str, '[/'.$TagName.']', $CloseTag+1); $CloseTag = stripos($Str, '[/'.$TagName.']', $CloseTag+1);
@ -341,7 +341,7 @@ function parse($Str) {
} else { } else {
$NumInCloses++; // Majority of cases $NumInCloses++; // Majority of cases
} }
// Is there another open tag inside this one? // Is there another open tag inside this one?
$OpenTag = preg_match($InOpenRegex, $Str, $InTag, PREG_OFFSET_CAPTURE, $InTagPos+1); $OpenTag = preg_match($InOpenRegex, $Str, $InTag, PREG_OFFSET_CAPTURE, $InTagPos+1);
if(!$OpenTag || $InTag[0][1]>$CloseTag) { if(!$OpenTag || $InTag[0][1]>$CloseTag) {
@ -350,17 +350,17 @@ function parse($Str) {
$InTagPos = $InTag[0][1]; $InTagPos = $InTag[0][1];
$NumInOpens++; $NumInOpens++;
} }
} while($NumInOpens>$NumInCloses); } while($NumInOpens>$NumInCloses);
// Find the internal block inside the tag // Find the internal block inside the tag
$Block = substr($Str, $i, $CloseTag-$i); // 5c) Get the contents between [open] and [/close] and call it the block. $Block = substr($Str, $i, $CloseTag-$i); // 5c) Get the contents between [open] and [/close] and call it the block.
$i = $CloseTag+strlen($TagName)+3; // 5d) Move the pointer past the end of the [/close] tag. $i = $CloseTag+strlen($TagName)+3; // 5d) Move the pointer past the end of the [/close] tag.
} }
// 6) Depending on what type of tag we're dealing with, create an array with the attribute and block. // 6) Depending on what type of tag we're dealing with, create an array with the attribute and block.
switch($TagName) { switch($TagName) {
case 'inlineurl': case 'inlineurl':
@ -408,7 +408,7 @@ function parse($Str) {
$Block = preg_replace('/\[inlinesize\=3\](.*?)\[\/inlinesize\]/i', '====$1====', $Block); $Block = preg_replace('/\[inlinesize\=3\](.*?)\[\/inlinesize\]/i', '====$1====', $Block);
$Block = preg_replace('/\[inlinesize\=5\](.*?)\[\/inlinesize\]/i', '===$1===', $Block); $Block = preg_replace('/\[inlinesize\=5\](.*?)\[\/inlinesize\]/i', '===$1===', $Block);
$Block = preg_replace('/\[inlinesize\=7\](.*?)\[\/inlinesize\]/i', '==$1==', $Block); $Block = preg_replace('/\[inlinesize\=7\](.*?)\[\/inlinesize\]/i', '==$1==', $Block);
$Array[$ArrayPos] = array('Type'=>$TagName, 'Val'=>$Block); $Array[$ArrayPos] = array('Type'=>$TagName, 'Val'=>$Block);
break; break;
case 'hide': case 'hide':
@ -427,27 +427,27 @@ function parse($Str) {
default: default:
if($WikiLink == true) { if($WikiLink == true) {
$Array[$ArrayPos] = array('Type'=>'wiki','Val'=>$TagName); $Array[$ArrayPos] = array('Type'=>'wiki','Val'=>$TagName);
} else { } else {
// Basic tags, like [b] or [size=5] // Basic tags, like [b] or [size=5]
$Array[$ArrayPos] = array('Type'=>$TagName, 'Val'=>$this->parse($Block)); $Array[$ArrayPos] = array('Type'=>$TagName, 'Val'=>$this->parse($Block));
if(!empty($Attrib) && $MaxAttribs>0) { if(!empty($Attrib) && $MaxAttribs>0) {
$Array[$ArrayPos]['Attr'] = strtolower($Attrib); $Array[$ArrayPos]['Attr'] = strtolower($Attrib);
} }
} }
} }
$ArrayPos++; // 7) Increment array pointer, start again (past the end of the [/close] tag) $ArrayPos++; // 7) Increment array pointer, start again (past the end of the [/close] tag)
} }
return $Array; return $Array;
} }
function to_html($Array) { function to_html($Array) {
$this->Levels++; $this->Levels++;
if($this->Levels>10) { return $Block['Val']; } // Hax prevention if($this->Levels>10) { return $Block['Val']; } // Hax prevention
$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);
@ -488,9 +488,9 @@ function to_html($Array) {
$Str.='<code>'.$Block['Val'].'</code>'; $Str.='<code>'.$Block['Val'].'</code>';
break; break;
case 'list': case 'list':
$Str .= '<ul>'; $Str.='<ul>';
foreach($Block['Val'] as $Line) { foreach($Block['Val'] as $Line) {
$Str.='<li>'.$this->to_html($Line).'</li>'; $Str.='<li>'.$this->to_html($Line).'</li>';
} }
$Str.='</ul>'; $Str.='</ul>';
@ -506,7 +506,7 @@ function to_html($Array) {
case 'color': case 'color':
case 'colour': case 'colour':
$ValidAttribs = array('aqua', 'black', 'blue', 'fuchsia', 'green', 'grey', 'lime', 'maroon', 'navy', 'olive', 'purple', 'red', 'silver', 'teal', 'white', 'yellow'); $ValidAttribs = array('aqua', 'black', 'blue', 'fuchsia', 'green', 'grey', 'lime', 'maroon', 'navy', 'olive', 'purple', 'red', 'silver', 'teal', 'white', 'yellow');
if(!in_array($Block['Attr'], $ValidAttribs) && !preg_match('/^#[0-9a-f]{6}$/', $Block['Attr'])) { if(!in_array($Block['Attr'], $ValidAttribs) && !preg_match('/^#[0-9a-f]{6}$/', $Block['Attr'])) {
$Str.='[color='.$Block['Attr'].']'.$this->to_html($Block['Val']).'[/color]'; $Str.='[color='.$Block['Attr'].']'.$this->to_html($Block['Val']).'[/color]';
} else { } else {
$Str.='<span style="color:'.$Block['Attr'].'">'.$this->to_html($Block['Val']).'</span>'; $Str.='<span style="color:'.$Block['Attr'].'">'.$this->to_html($Block['Val']).'</span>';
@ -524,7 +524,7 @@ function to_html($Array) {
case 'quote': case 'quote':
$this->NoImg++; // No images inside quote tags $this->NoImg++; // No images inside quote tags
if(!empty($Block['Attr'])) { if(!empty($Block['Attr'])) {
$Str.= '<strong>'.$this->to_html($Block['Attr']).'</strong> wrote: '; $Str.='<strong>'.$this->to_html($Block['Attr']).'</strong> wrote: ';
} }
$Str.='<blockquote>'.$this->to_html($Block['Val']).'</blockquote>'; $Str.='<blockquote>'.$this->to_html($Block['Val']).'</blockquote>';
$this->NoImg--; $this->NoImg--;
@ -542,13 +542,13 @@ function to_html($Array) {
$Str.='[img]'.$Block['Val'].'[/img]'; $Str.='[img]'.$Block['Val'].'[/img]';
} else { } else {
if(check_perms('site_proxy_images')) { if(check_perms('site_proxy_images')) {
$Str.='<img style="max-width: 500px;" onclick="lightbox.init(this,500);" alt="'.$Block['Val'].'" src="http://'.SITE_URL.'/image.php?i='.urlencode($Block['Val']).'" />'; $Str.='<img style="max-width: 500px;" onclick="lightbox.init(this,500);" alt="'.$Block['Val'].'" src="https://'.SITE_URL.'/image.php?i='.urlencode($Block['Val']).'" />';
} else { } else {
$Str.='<img style="max-width: 500px;" onclick="lightbox.init(this,500);" alt="'.$Block['Val'].'" src="'.$Block['Val'].'" />'; $Str.='<img style="max-width: 500px;" onclick="lightbox.init(this,500);" alt="'.$Block['Val'].'" src="'.$Block['Val'].'" />';
} }
} }
break; break;
case 'aud': case 'aud':
if($this->NoImg>0 && $this->valid_url($Block['Val'])) { if($this->NoImg>0 && $this->valid_url($Block['Val'])) {
$Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Val'].'">'.$Block['Val'].'</a> (audio)'; $Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Val'].'">'.$Block['Val'].'</a> (audio)';
@ -561,7 +561,7 @@ function to_html($Array) {
$Str.='<audio controls="controls" src="'.$Block['Val'].'"><a rel="noreferrer" target="_blank" href="'.$Block['Val'].'">'.$Block['Val'].'</a></audio>'; $Str.='<audio controls="controls" src="'.$Block['Val'].'"><a rel="noreferrer" target="_blank" href="'.$Block['Val'].'">'.$Block['Val'].'</a></audio>';
} }
break; break;
case 'url': case 'url':
// Make sure the URL has a label // Make sure the URL has a label
if(empty($Block['Val'])) { if(empty($Block['Val'])) {
@ -571,7 +571,7 @@ function to_html($Array) {
$Block['Val'] = $this->to_html($Block['Val']); $Block['Val'] = $this->to_html($Block['Val']);
$NoName = false; $NoName = false;
} }
if(!$this->valid_url($Block['Attr'])) { if(!$this->valid_url($Block['Attr'])) {
$Str.='[url='.$Block['Attr'].']'.$Block['Val'].'[/url]'; $Str.='[url='.$Block['Attr'].']'.$Block['Val'].'[/url]';
} else { } else {
@ -584,23 +584,23 @@ function to_html($Array) {
} }
} }
break; break;
case 'inlineurl': case 'inlineurl':
if(!$this->valid_url($Block['Attr'], '', true)) { if(!$this->valid_url($Block['Attr'], '', true)) {
$Array = $this->parse($Block['Attr']); $Array = $this->parse($Block['Attr']);
$Block['Attr'] = $Array; $Block['Attr'] = $Array;
$Str.=$this->to_html($Block['Attr']); $Str.=$this->to_html($Block['Attr']);
} }
else { else {
$LocalURL = $this->local_url($Block['Attr']); $LocalURL = $this->local_url($Block['Attr']);
if($LocalURL) { if($LocalURL) {
$Str.='<a href="'.$LocalURL.'">'.substr($LocalURL,1).'</a>'; $Str.='<a href="'.$LocalURL.'">'.substr($LocalURL,1).'</a>';
} else { } else {
$Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Attr'].'">'.$Block['Attr'].'</a>'; $Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Attr'].'">'.$Block['Attr'].'</a>';
} }
} }
break; break;
} }
@ -608,7 +608,7 @@ function to_html($Array) {
$this->Levels--; $this->Levels--;
return $Str; return $Str;
} }
function raw_text($Array) { function raw_text($Array) {
$Str = ''; $Str = '';
foreach($Array as $Block) { foreach($Array as $Block) {
@ -617,7 +617,7 @@ function raw_text($Array) {
continue; continue;
} }
switch($Block['Type']) { switch($Block['Type']) {
case 'b': case 'b':
case 'u': case 'u':
case 'i': case 'i':
@ -645,7 +645,7 @@ function raw_text($Array) {
$Str.='*'.$this->raw_text($Line); $Str.='*'.$this->raw_text($Line);
} }
break; break;
case 'url': case 'url':
// Make sure the URL has a label // Make sure the URL has a label
if(empty($Block['Val'])) { if(empty($Block['Val'])) {
@ -653,10 +653,10 @@ function raw_text($Array) {
} else { } else {
$Block['Val'] = $this->raw_text($Block['Val']); $Block['Val'] = $this->raw_text($Block['Val']);
} }
$Str.=$Block['Val']; $Str.=$Block['Val'];
break; break;
case 'inlineurl': case 'inlineurl':
if(!$this->valid_url($Block['Attr'], '', true)) { if(!$this->valid_url($Block['Attr'], '', true)) {
$Array = $this->parse($Block['Attr']); $Array = $this->parse($Block['Attr']);
@ -666,13 +666,13 @@ function raw_text($Array) {
else { else {
$Str.=$Block['Attr']; $Str.=$Block['Attr'];
} }
break; break;
} }
} }
return $Str; return $Str;
} }
function smileys($Str) { function smileys($Str) {
global $LoggedUser; global $LoggedUser;
if(!empty($LoggedUser['DisableSmileys'])) { if(!empty($LoggedUser['DisableSmileys'])) {
@ -684,10 +684,10 @@ function smileys($Str) {
} }
/* /*
//Uncomment this part to test the class via command line: //Uncomment this part to test the class via command line:
function display_str($Str) {return $Str;} function display_str($Str) {return $Str;}
function check_perms($Perm) {return true;} function check_perms($Perm) {return true;}
$Str = "hello $Str = "hello
[pre]http://anonym.to/?http://whatshirts.portmerch.com/ [pre]http://anonym.to/?http://whatshirts.portmerch.com/
====hi==== ====hi====
===hi=== ===hi===

View File

@ -46,51 +46,51 @@ class TEXT_3 {
':wtf:' => 'wtf.gif', ':wtf:' => 'wtf.gif',
':wub:' => 'wub.gif' ':wub:' => 'wub.gif'
); );
private $NoImg = 0; // If images should be turned into URLs private $NoImg = 0; // If images should be turned into URLs
private $Levels = 0; // If images should be turned into URLs private $Levels = 0; // If images should be turned into URLs
function __construct() { function __construct() {
foreach($this->Smileys as $Key=>$Val) { foreach($this->Smileys as $Key=>$Val) {
$this->Smileys[$Key] = '<img border="0" src="'.STATIC_SERVER.'common/smileys/'.$Val.'" alt="" />'; $this->Smileys[$Key] = '<img border="0" src="'.STATIC_SERVER.'common/smileys/'.$Val.'" alt="" />';
} }
reset($this->Smileys); reset($this->Smileys);
} }
function full_format($Str) { function full_format($Str) {
$Str = display_str($Str); $Str = display_str($Str);
//Inline links //Inline links
$Str = preg_replace('/(?<!(\[url\]|\[url\=|\[img\=|\[img\]))http(s)?:\/\//i', '$1[inlineurl]http$2://', $Str); $Str = preg_replace('/(?<!(\[url\]|\[url\=|\[img\=|\[img\]))http(s)?:\/\//i', '$1[inlineurl]http$2://', $Str);
// For anonym.to links. We can't have this in the regex because PHP freaks out at the ?, even if it's escaped // For anonym.to links. We can't have this in the regex because PHP freaks out at the ?, even if it's escaped
$Str = strtr($Str, array('?[inlineurl]http'=>'?http', '=[inlineurl]http'=>'=http')); $Str = strtr($Str, array('?[inlineurl]http'=>'?http', '=[inlineurl]http'=>'=http'));
$Str = preg_replace('/\=\=\=\=([^=].*)\=\=\=\=/i', '[inlinesize=3]$1[/inlinesize]', $Str); $Str = preg_replace('/\=\=\=\=([^=].*)\=\=\=\=/i', '[inlinesize=3]$1[/inlinesize]', $Str);
$Str = preg_replace('/\=\=\=([^=].*)\=\=\=/i', '[inlinesize=5]$1[/inlinesize]', $Str); $Str = preg_replace('/\=\=\=([^=].*)\=\=\=/i', '[inlinesize=5]$1[/inlinesize]', $Str);
$Str = preg_replace('/\=\=([^=].*)\=\=/i', '[inlinesize=7]$1[/inlinesize]', $Str); $Str = preg_replace('/\=\=([^=].*)\=\=/i', '[inlinesize=7]$1[/inlinesize]', $Str);
$Str = $this->parse($Str); $Str = $this->parse($Str);
$HTML = $this->to_html($Str); $HTML = $this->to_html($Str);
$HTML = nl2br($HTML); $HTML = nl2br($HTML);
return $HTML; return $HTML;
} }
function strip_bbcode($Str) { function strip_bbcode($Str) {
$Str = display_str($Str); $Str = display_str($Str);
//Inline links //Inline links
$Str = preg_replace('/(?<!(\[url\]|\[url\=|\[img\=|\[img\]))http(s)?:\/\//i', '$1[inlineurl]http$2://', $Str); $Str = preg_replace('/(?<!(\[url\]|\[url\=|\[img\=|\[img\]))http(s)?:\/\//i', '$1[inlineurl]http$2://', $Str);
$Str = $this->parse($Str); $Str = $this->parse($Str);
$Str = $this->raw_text($Str); $Str = $this->raw_text($Str);
$Str = nl2br($Str); $Str = nl2br($Str);
return $Str; return $Str;
} }
function valid_url($Str, $Extension = '', $Inline = false) { function valid_url($Str, $Extension = '', $Inline = false) {
$Regex = '/^'; $Regex = '/^';
$Regex .= '(https?|ftps?|irc):\/\/'; // protocol $Regex .= '(https?|ftps?|irc):\/\/'; // protocol
@ -115,10 +115,10 @@ function valid_url($Str, $Extension = '', $Inline = false) {
$Regex .= '(#[a-z0-9\-_.,%\/\@[\]~&=:;()+*\^$!]*)?'; // #anchor $Regex .= '(#[a-z0-9\-_.,%\/\@[\]~&=:;()+*\^$!]*)?'; // #anchor
$Regex .= '$/i'; $Regex .= '$/i';
return preg_match($Regex, $Str, $Matches); return preg_match($Regex, $Str, $Matches);
} }
function local_url($Str) { function local_url($Str) {
$URLInfo = parse_url($Str); $URLInfo = parse_url($Str);
if(!$URLInfo) { return false; } if(!$URLInfo) { return false; }
@ -137,15 +137,15 @@ function local_url($Str) {
} else { } else {
return false; return false;
} }
} }
/* How parsing works /* How parsing works
Parsing takes $Str, breaks it into blocks, and builds it into $Array. Parsing takes $Str, breaks it into blocks, and builds it into $Array.
Blocks start at the beginning of $Str, when the parser encounters a [, and after a tag has been closed. Blocks start at the beginning of $Str, when the parser encounters a [, and after a tag has been closed.
This is all done in a loop. This is all done in a loop.
EXPLANATION OF PARSER LOGIC EXPLANATION OF PARSER LOGIC
@ -165,14 +165,14 @@ function local_url($Str) {
[quote=joe]I am a redneck!**[/quote] [quote=joe]I am a redneck!**[/quote]
Me too! Me too!
***[/quote] ***[/quote]
If we're at the position *, the first [/quote] tag is denoted by **. If we're at the position *, the first [/quote] tag is denoted by **.
However, our quote tag doesn't actually close there. We must perform However, our quote tag doesn't actually close there. We must perform
a loop which checks the number of opening [quote] tags, and make sure a loop which checks the number of opening [quote] tags, and make sure
they are all closed before we find our final [/quote] tag (***). they are all closed before we find our final [/quote] tag (***).
5c) Get the contents between [open] and [/close] and call it the block. 5c) Get the contents between [open] and [/close] and call it the block.
In many cases, this will be parsed itself later on, in a new parse() call. In many cases, this will be parsed itself later on, in a new parse() call.
5d) Move the pointer past the end of the [/close] tag. 5d) Move the pointer past the end of the [/close] tag.
6) Depending on what type of tag we're dealing with, create an array with the attribute and block. 6) Depending on what type of tag we're dealing with, create an array with the attribute and block.
In many cases, the block may be parsed here itself. Stick them in the $Array. In many cases, the block may be parsed here itself. Stick them in the $Array.
7) Increment array pointer, start again (past the end of the [/close] tag) 7) Increment array pointer, start again (past the end of the [/close] tag)
@ -183,21 +183,21 @@ function parse($Str) {
$Len = strlen($Str); $Len = strlen($Str);
$Array = array(); $Array = array();
$ArrayPos = 0; $ArrayPos = 0;
while($i<$Len) { while($i<$Len) {
$Block = ''; $Block = '';
// 1) Find the next tag (regex) // 1) Find the next tag (regex)
// [name(=attribute)?]|[[wiki-link]] // [name(=attribute)?]|[[wiki-link]]
$IsTag = preg_match("/((\[[a-zA-Z*]+)(=(?:[^\n'\"\[\]]|\[\d*\])+)?\])|(\[\[[^\n\"'\[\]]+\]\])/", $Str, $Tag, PREG_OFFSET_CAPTURE, $i); $IsTag = preg_match("/((\[[a-zA-Z*]+)(=(?:[^\n'\"\[\]]|\[\d*\])+)?\])|(\[\[[^\n\"'\[\]]+\]\])/", $Str, $Tag, PREG_OFFSET_CAPTURE, $i);
// 1a) If there aren't any tags left, write everything remaining to a block // 1a) If there aren't any tags left, write everything remaining to a block
if(!$IsTag) { if(!$IsTag) {
// No more tags // No more tags
$Array[$ArrayPos] = substr($Str, $i); $Array[$ArrayPos] = substr($Str, $i);
break; break;
} }
// 1b) If the next tag isn't where the pointer is, write everything up to there to a text block. // 1b) If the next tag isn't where the pointer is, write everything up to there to a text block.
$TagPos = $Tag[0][1]; $TagPos = $Tag[0][1];
if($TagPos>$i) { if($TagPos>$i) {
@ -205,7 +205,7 @@ function parse($Str) {
++$ArrayPos; ++$ArrayPos;
$i=$TagPos; $i=$TagPos;
} }
// 2) See if it's a [[wiki-link]] or an ordinary tag, and get the tag name // 2) See if it's a [[wiki-link]] or an ordinary tag, and get the tag name
if(!empty($Tag[4][0])) { // Wiki-link if(!empty($Tag[4][0])) { // Wiki-link
$WikiLink = true; $WikiLink = true;
@ -214,7 +214,7 @@ function parse($Str) {
} else { // 3) If it's not a wiki link: } else { // 3) If it's not a wiki link:
$WikiLink = false; $WikiLink = false;
$TagName = strtolower(substr($Tag[2][0], 1)); $TagName = strtolower(substr($Tag[2][0], 1));
//3a) check it against the $this->ValidTags array to see if it's actually a tag and not [bullshit] //3a) check it against the $this->ValidTags array to see if it's actually a tag and not [bullshit]
if(!isset($this->ValidTags[$TagName])) { if(!isset($this->ValidTags[$TagName])) {
$Array[$ArrayPos] = substr($Str, $i, ($TagPos-$i)+strlen($Tag[0][0])); $Array[$ArrayPos] = substr($Str, $i, ($TagPos-$i)+strlen($Tag[0][0]));
@ -222,9 +222,9 @@ function parse($Str) {
++$ArrayPos; ++$ArrayPos;
continue; continue;
} }
$MaxAttribs = $this->ValidTags[$TagName]; $MaxAttribs = $this->ValidTags[$TagName];
// 3b) Get the attribute, if it exists [name=attribute] // 3b) Get the attribute, if it exists [name=attribute]
if(!empty($Tag[3][0])) { if(!empty($Tag[3][0])) {
$Attrib = substr($Tag[3][0], 1); $Attrib = substr($Tag[3][0], 1);
@ -232,23 +232,23 @@ function parse($Str) {
$Attrib=''; $Attrib='';
} }
} }
// 4) Move the pointer past the end of the tag // 4) Move the pointer past the end of the tag
$i=$TagPos+strlen($Tag[0][0]); $i=$TagPos+strlen($Tag[0][0]);
// 5) Find out where the tag closes (beginning of [/tag]) // 5) Find out where the tag closes (beginning of [/tag])
// Unfortunately, BBCode doesn't have nice standards like xhtml // Unfortunately, BBCode doesn't have nice standards like xhtml
// [*], [img=...], and http:// follow different formats // [*], [img=...], and http:// follow different formats
// Thus, we have to handle these before we handle the majority of tags // Thus, we have to handle these before we handle the majority of tags
//5a) Different for different types of tag. Some tags don't close, others are weird like [*] //5a) Different for different types of tag. Some tags don't close, others are weird like [*]
if($TagName == 'img' && !empty($Tag[3][0])) { //[img=...] if($TagName == 'img' && !empty($Tag[3][0])) { //[img=...]
$Block = ''; // Nothing inside this tag $Block = ''; // Nothing inside this tag
// Don't need to touch $i // Don't need to touch $i
} elseif($TagName == 'inlineurl') { // We did a big replace early on to turn http:// into [inlineurl]http:// } elseif($TagName == 'inlineurl') { // We did a big replace early on to turn http:// into [inlineurl]http://
// Let's say the block can stop at a newline or a space // Let's say the block can stop at a newline or a space
$CloseTag = strcspn($Str, " \n\r", $i); $CloseTag = strcspn($Str, " \n\r", $i);
if($CloseTag === false) { // block finishes with URL if($CloseTag === false) { // block finishes with URL
@ -263,11 +263,11 @@ function parse($Str) {
$URL = substr($URL, 0, -1); $URL = substr($URL, 0, -1);
} }
$Block = $URL; // Get the URL $Block = $URL; // Get the URL
// strcspn returns the number of characters after the offset $i, not after the beginning of the string // strcspn returns the number of characters after the offset $i, not after the beginning of the string
// Therefore, we use += instead of the = everywhere else // Therefore, we use += instead of the = everywhere else
$i += $CloseTag; // 5d) Move the pointer past the end of the [/close] tag. $i += $CloseTag; // 5d) Move the pointer past the end of the [/close] tag.
} elseif($WikiLink == true || $TagName == 'n') { } elseif($WikiLink == true || $TagName == 'n') {
// Don't need to do anything - empty tag with no closing // Don't need to do anything - empty tag with no closing
} elseif($TagName == '*') { } elseif($TagName == '*') {
// We're in a list. Find where it ends // We're in a list. Find where it ends
@ -275,28 +275,28 @@ function parse($Str) {
do { // Look for \n[*] do { // Look for \n[*]
$NewLine = strpos($Str, "\n", $NewLine+1); $NewLine = strpos($Str, "\n", $NewLine+1);
} while($NewLine!== false && substr($Str, $NewLine+1, 3) == '[*]'); } while($NewLine!== false && substr($Str, $NewLine+1, 3) == '[*]');
$CloseTag = $NewLine; $CloseTag = $NewLine;
if($CloseTag === false) { // block finishes with list if($CloseTag === false) { // block finishes with list
$CloseTag = $Len; $CloseTag = $Len;
} }
$Block = substr($Str, $i, $CloseTag-$i); // Get the list $Block = substr($Str, $i, $CloseTag-$i); // Get the list
$i = $CloseTag; // 5d) Move the pointer past the end of the [/close] tag. $i = $CloseTag; // 5d) Move the pointer past the end of the [/close] tag.
} else { } else {
//5b) If it's a normal tag, it may have versions of itself nested inside //5b) If it's a normal tag, it may have versions of itself nested inside
$CloseTag = $i-1; $CloseTag = $i-1;
$InTagPos = $i-1; $InTagPos = $i-1;
$NumInOpens = 0; $NumInOpens = 0;
$NumInCloses = -1; $NumInCloses = -1;
$InOpenRegex = '/\[('.$TagName.')'; $InOpenRegex = '/\[('.$TagName.')';
if($MaxAttribs>0) { if($MaxAttribs>0) {
$InOpenRegex.="(=[^\n'\"\[\]]+)?"; $InOpenRegex.="(=[^\n'\"\[\]]+)?";
} }
$InOpenRegex.='\]/i'; $InOpenRegex.='\]/i';
// Every time we find an internal open tag of the same type, search for the next close tag // Every time we find an internal open tag of the same type, search for the next close tag
// (as the first close tag won't do - it's been opened again) // (as the first close tag won't do - it's been opened again)
do { do {
$CloseTag = stripos($Str, '[/'.$TagName.']', $CloseTag+1); $CloseTag = stripos($Str, '[/'.$TagName.']', $CloseTag+1);
@ -306,7 +306,7 @@ function parse($Str) {
} else { } else {
$NumInCloses++; // Majority of cases $NumInCloses++; // Majority of cases
} }
// Is there another open tag inside this one? // Is there another open tag inside this one?
$OpenTag = preg_match($InOpenRegex, $Str, $InTag, PREG_OFFSET_CAPTURE, $InTagPos+1); $OpenTag = preg_match($InOpenRegex, $Str, $InTag, PREG_OFFSET_CAPTURE, $InTagPos+1);
if(!$OpenTag || $InTag[0][1]>$CloseTag) { if(!$OpenTag || $InTag[0][1]>$CloseTag) {
@ -315,17 +315,17 @@ function parse($Str) {
$InTagPos = $InTag[0][1]; $InTagPos = $InTag[0][1];
$NumInOpens++; $NumInOpens++;
} }
} while($NumInOpens>$NumInCloses); } while($NumInOpens>$NumInCloses);
// Find the internal block inside the tag // Find the internal block inside the tag
$Block = substr($Str, $i, $CloseTag-$i); // 5c) Get the contents between [open] and [/close] and call it the block. $Block = substr($Str, $i, $CloseTag-$i); // 5c) Get the contents between [open] and [/close] and call it the block.
$i = $CloseTag+strlen($TagName)+3; // 5d) Move the pointer past the end of the [/close] tag. $i = $CloseTag+strlen($TagName)+3; // 5d) Move the pointer past the end of the [/close] tag.
} }
// 6) Depending on what type of tag we're dealing with, create an array with the attribute and block. // 6) Depending on what type of tag we're dealing with, create an array with the attribute and block.
switch($TagName) { switch($TagName) {
case 'inlineurl': case 'inlineurl':
@ -372,7 +372,7 @@ function parse($Str) {
$Block = preg_replace('/\[inlinesize\=3\](.*?)\[\/inlinesize\]/i', '====$1====', $Block); $Block = preg_replace('/\[inlinesize\=3\](.*?)\[\/inlinesize\]/i', '====$1====', $Block);
$Block = preg_replace('/\[inlinesize\=5\](.*?)\[\/inlinesize\]/i', '===$1===', $Block); $Block = preg_replace('/\[inlinesize\=5\](.*?)\[\/inlinesize\]/i', '===$1===', $Block);
$Block = preg_replace('/\[inlinesize\=7\](.*?)\[\/inlinesize\]/i', '==$1==', $Block); $Block = preg_replace('/\[inlinesize\=7\](.*?)\[\/inlinesize\]/i', '==$1==', $Block);
$Array[$ArrayPos] = array('Type'=>$TagName, 'Val'=>$Block); $Array[$ArrayPos] = array('Type'=>$TagName, 'Val'=>$Block);
break; break;
case 'hide': case 'hide':
@ -391,27 +391,27 @@ function parse($Str) {
default: default:
if($WikiLink == true) { if($WikiLink == true) {
$Array[$ArrayPos] = array('Type'=>'wiki','Val'=>$TagName); $Array[$ArrayPos] = array('Type'=>'wiki','Val'=>$TagName);
} else { } else {
// Basic tags, like [b] or [size=5] // Basic tags, like [b] or [size=5]
$Array[$ArrayPos] = array('Type'=>$TagName, 'Val'=>$this->parse($Block)); $Array[$ArrayPos] = array('Type'=>$TagName, 'Val'=>$this->parse($Block));
if(!empty($Attrib) && $MaxAttribs>0) { if(!empty($Attrib) && $MaxAttribs>0) {
$Array[$ArrayPos]['Attr'] = strtolower($Attrib); $Array[$ArrayPos]['Attr'] = strtolower($Attrib);
} }
} }
} }
$ArrayPos++; // 7) Increment array pointer, start again (past the end of the [/close] tag) $ArrayPos++; // 7) Increment array pointer, start again (past the end of the [/close] tag)
} }
return $Array; return $Array;
} }
function to_html($Array) { function to_html($Array) {
$this->Levels++; $this->Levels++;
if($this->Levels>10) { return $Block['Val']; } // Hax prevention if($this->Levels>10) { return $Block['Val']; } // Hax prevention
$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);
@ -449,9 +449,9 @@ function to_html($Array) {
$Str.='<pre>'.$Block['Val'].'</pre>'; $Str.='<pre>'.$Block['Val'].'</pre>';
break; break;
case 'list': case 'list':
$Str .= '<ul>'; $Str.='<ul>';
foreach($Block['Val'] as $Line) { foreach($Block['Val'] as $Line) {
$Str.='<li>'.$this->to_html($Line).'</li>'; $Str.='<li>'.$this->to_html($Line).'</li>';
} }
$Str.='</ul>'; $Str.='</ul>';
@ -467,7 +467,7 @@ function to_html($Array) {
case 'color': case 'color':
case 'colour': case 'colour':
$ValidAttribs = array('aqua', 'black', 'blue', 'fuchsia', 'green', 'grey', 'lime', 'maroon', 'navy', 'olive', 'purple', 'red', 'silver', 'teal', 'white', 'yellow'); $ValidAttribs = array('aqua', 'black', 'blue', 'fuchsia', 'green', 'grey', 'lime', 'maroon', 'navy', 'olive', 'purple', 'red', 'silver', 'teal', 'white', 'yellow');
if(!in_array($Block['Attr'], $ValidAttribs) && !preg_match('/^#[0-9a-f]{6}$/', $Block['Attr'])) { if(!in_array($Block['Attr'], $ValidAttribs) && !preg_match('/^#[0-9a-f]{6}$/', $Block['Attr'])) {
$Str.='[color='.$Block['Attr'].']'.$this->to_html($Block['Val']).'[/color]'; $Str.='[color='.$Block['Attr'].']'.$this->to_html($Block['Val']).'[/color]';
} else { } else {
$Str.='<span style="color:'.$Block['Attr'].'">'.$this->to_html($Block['Val']).'</span>'; $Str.='<span style="color:'.$Block['Attr'].'">'.$this->to_html($Block['Val']).'</span>';
@ -485,7 +485,7 @@ function to_html($Array) {
case 'quote': case 'quote':
$this->NoImg++; // No images inside quote tags $this->NoImg++; // No images inside quote tags
if(!empty($Block['Attr'])) { if(!empty($Block['Attr'])) {
$Str.= '<strong>'.$this->to_html($Block['Attr']).'</strong> wrote: '; $Str.='<strong>'.$this->to_html($Block['Attr']).'</strong> wrote: ';
} }
$Str.='<blockquote>'.$this->to_html($Block['Val']).'</blockquote>'; $Str.='<blockquote>'.$this->to_html($Block['Val']).'</blockquote>';
$this->NoImg--; $this->NoImg--;
@ -509,7 +509,7 @@ function to_html($Array) {
} }
} }
break; break;
case 'aud': case 'aud':
if($this->NoImg>0 && $this->valid_url($Block['Val'])) { if($this->NoImg>0 && $this->valid_url($Block['Val'])) {
$Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Val'].'">'.$Block['Val'].'</a> (audio)'; $Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Val'].'">'.$Block['Val'].'</a> (audio)';
@ -522,7 +522,7 @@ function to_html($Array) {
$Str.='<audio controls="controls" src="'.$Block['Val'].'"><a rel="noreferrer" target="_blank" href="'.$Block['Val'].'">'.$Block['Val'].'</a></audio>'; $Str.='<audio controls="controls" src="'.$Block['Val'].'"><a rel="noreferrer" target="_blank" href="'.$Block['Val'].'">'.$Block['Val'].'</a></audio>';
} }
break; break;
case 'url': case 'url':
// Make sure the URL has a label // Make sure the URL has a label
if(empty($Block['Val'])) { if(empty($Block['Val'])) {
@ -532,7 +532,7 @@ function to_html($Array) {
$Block['Val'] = $this->to_html($Block['Val']); $Block['Val'] = $this->to_html($Block['Val']);
$NoName = false; $NoName = false;
} }
if(!$this->valid_url($Block['Attr'])) { if(!$this->valid_url($Block['Attr'])) {
$Str.='[url='.$Block['Attr'].']'.$Block['Val'].'[/url]'; $Str.='[url='.$Block['Attr'].']'.$Block['Val'].'[/url]';
} else { } else {
@ -545,23 +545,23 @@ function to_html($Array) {
} }
} }
break; break;
case 'inlineurl': case 'inlineurl':
if(!$this->valid_url($Block['Attr'], '', true)) { if(!$this->valid_url($Block['Attr'], '', true)) {
$Array = $this->parse($Block['Attr']); $Array = $this->parse($Block['Attr']);
$Block['Attr'] = $Array; $Block['Attr'] = $Array;
$Str.=$this->to_html($Block['Attr']); $Str.=$this->to_html($Block['Attr']);
} }
else { else {
$LocalURL = $this->local_url($Block['Attr']); $LocalURL = $this->local_url($Block['Attr']);
if($LocalURL) { if($LocalURL) {
$Str.='<a href="'.$LocalURL.'">'.substr($LocalURL,1).'</a>'; $Str.='<a href="'.$LocalURL.'">'.substr($LocalURL,1).'</a>';
} else { } else {
$Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Attr'].'">'.$Block['Attr'].'</a>'; $Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Attr'].'">'.$Block['Attr'].'</a>';
} }
} }
break; break;
} }
@ -569,7 +569,7 @@ function to_html($Array) {
$this->Levels--; $this->Levels--;
return $Str; return $Str;
} }
function raw_text($Array) { function raw_text($Array) {
$Str = ''; $Str = '';
foreach($Array as $Block) { foreach($Array as $Block) {
@ -578,7 +578,7 @@ function raw_text($Array) {
continue; continue;
} }
switch($Block['Type']) { switch($Block['Type']) {
case 'b': case 'b':
case 'u': case 'u':
case 'i': case 'i':
@ -605,7 +605,7 @@ function raw_text($Array) {
$Str.='*'.$this->raw_text($Line); $Str.='*'.$this->raw_text($Line);
} }
break; break;
case 'url': case 'url':
// Make sure the URL has a label // Make sure the URL has a label
if(empty($Block['Val'])) { if(empty($Block['Val'])) {
@ -613,10 +613,10 @@ function raw_text($Array) {
} else { } else {
$Block['Val'] = $this->raw_text($Block['Val']); $Block['Val'] = $this->raw_text($Block['Val']);
} }
$Str.=$Block['Val']; $Str.=$Block['Val'];
break; break;
case 'inlineurl': case 'inlineurl':
if(!$this->valid_url($Block['Attr'], '', true)) { if(!$this->valid_url($Block['Attr'], '', true)) {
$Array = $this->parse($Block['Attr']); $Array = $this->parse($Block['Attr']);
@ -626,13 +626,13 @@ function raw_text($Array) {
else { else {
$Str.=$Block['Attr']; $Str.=$Block['Attr'];
} }
break; break;
} }
} }
return $Str; return $Str;
} }
function smileys($Str) { function smileys($Str) {
global $LoggedUser; global $LoggedUser;
if(!empty($LoggedUser['DisableSmileys'])) { if(!empty($LoggedUser['DisableSmileys'])) {
@ -644,10 +644,10 @@ function smileys($Str) {
} }
/* /*
//Uncomment this part to test the class via command line: //Uncomment this part to test the class via command line:
function display_str($Str) {return $Str;} function display_str($Str) {return $Str;}
function check_perms($Perm) {return true;} function check_perms($Perm) {return true;}
$Str = "hello $Str = "hello
[pre]http://anonym.to/?http://whatshirts.portmerch.com/ [pre]http://anonym.to/?http://whatshirts.portmerch.com/
====hi==== ====hi====
===hi=== ===hi===

View File

@ -48,7 +48,11 @@ public static function geoip($IP) {
if (isset($IPs[$IP])) { if (isset($IPs[$IP])) {
return $IPs[$IP]; return $IPs[$IP];
} }
$Long = Tools::ip_to_unsigned($IP); if (is_number($IP)) {
$Long = $IP;
} else {
$Long = Tools::ip_to_unsigned($IP);
}
if(!$Long || $Long == 2130706433) { // No need to check cc for 127.0.0.1 if(!$Long || $Long == 2130706433) { // No need to check cc for 127.0.0.1
return false; return false;
} }
@ -126,7 +130,7 @@ public static function lookup_ip($IP) {
*/ */
public static function display_ip($IP) { public static function display_ip($IP) {
$Line = display_str($IP).' ('.Tools::get_country_code_by_ajax($IP).') '; $Line = display_str($IP).' ('.Tools::get_country_code_by_ajax($IP).') ';
$Line .= '[<a href="user.php?action=search&amp;ip_history=on&amp;ip='.display_str($IP).'&amp;matchtype=strict" title="Search">S</a>]'; $Line .= '<a href="user.php?action=search&amp;ip_history=on&amp;ip='.display_str($IP).'&amp;matchtype=strict" title="Search" class="brackets">S</a>';
return $Line; return $Line;
} }
@ -238,7 +242,7 @@ public static function warn_user($UserID, $Duration, $Reason) {
WHERE UserID=\''.db_string($UserID).'\''); WHERE UserID=\''.db_string($UserID).'\'');
} }
} }
/** /**
* Update the notes of a user * Update the notes of a user
* @param unknown $UserID ID of user * @param unknown $UserID ID of user
@ -250,6 +254,6 @@ public static function update_user_notes($UserID, $AdminComment) {
AdminComment=CONCAT(\''.db_string($AdminComment).'\',AdminComment) AdminComment=CONCAT(\''.db_string($AdminComment).'\',AdminComment)
WHERE UserID=\''.db_string($UserID).'\''); WHERE UserID=\''.db_string($UserID).'\'');
} }
} }
?> ?>

View File

@ -223,7 +223,7 @@ function compare($X, $Y){
$DisplayName = $ReleaseTypes[$ReleaseID]."s"; $DisplayName = $ReleaseTypes[$ReleaseID]."s";
break; break;
} }
if (!empty($LoggedUser['DiscogView']) || (isset($LoggedUser['SortHide']) && array_key_exists($ReleaseType, $LoggedUser['SortHide']) && $LoggedUser['SortHide'][$ReleaseType] == 1)) { if (!empty($LoggedUser['DiscogView']) || (isset($LoggedUser['SortHide']) && array_key_exists($ReleaseType, $LoggedUser['SortHide']) && $LoggedUser['SortHide'][$ReleaseType] == 1)) {
$ToggleStr = " onclick=\"$('.releases_$ReleaseID').show(); return true;\""; $ToggleStr = " onclick=\"$('.releases_$ReleaseID').show(); return true;\"";
} else { } else {
@ -252,7 +252,7 @@ function compare($X, $Y){
// $Tags array is for the sidebar on the right. Skip compilations and soundtracks. // $Tags array is for the sidebar on the right. Skip compilations and soundtracks.
if ($Group['ReleaseType'] != 7 && $Group['ReleaseType'] != 3) { if ($Group['ReleaseType'] != 7 && $Group['ReleaseType'] != 3) {
foreach($TagList as $Tag) { foreach($TagList as $Tag) {
if(!isset($Tags[$Tag])) { if(!isset($Tags[$Tag])) {
$Tags[$Tag] = array('name'=>$Tag, 'count'=>1); $Tags[$Tag] = array('name'=>$Tag, 'count'=>1);
} else { } else {
@ -834,7 +834,6 @@ function compare($X, $Y){
$Cache->cache_value('similar_positions_'.$ArtistID, $SimilarData, 3600*24); $Cache->cache_value('similar_positions_'.$ArtistID, $SimilarData, 3600*24);
} }
?> ?>
<div id="similar_artist_map" class="box"> <div id="similar_artist_map" class="box">
<div id="flipper_head" class="head"> <div id="flipper_head" class="head">
<a href="#">&uarr;</a>&nbsp; <a href="#">&uarr;</a>&nbsp;
@ -855,60 +854,55 @@ function compare($X, $Y){
</div> </div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">//<![CDATA[
//<![CDATA[
var cloudLoaded = false; var cloudLoaded = false;
function flipView() { function flipView() {
var state = document.getElementById('flip_view_1').style.display == 'block'; var state = document.getElementById('flip_view_1').style.display == 'block';
if(state) { if(state) {
document.getElementById('flip_view_1').style.display='none';
document.getElementById('flip_view_2').style.display='block';
document.getElementById('flipper_title').innerHTML = 'Similar artist cloud';
document.getElementById('flip_to').innerHTML = 'Switch to map';
document.getElementById('flip_view_1').style.display='none'; if(!cloudLoaded) {
document.getElementById('flip_view_2').style.display='block'; require("static/functions/jquery.js", function () {
document.getElementById('flipper_title').innerHTML = 'Similar Artist Cloud'; require("static/functions/tagcanvas.js", function () {
document.getElementById('flip_to').innerHTML = ' [Switch to Map]'; require("static/functions/artist_cloud.js", function () {
});
if(!cloudLoaded) { });
require("static/functions/jquery.js", function () {
require("static/functions/tagcanvas.js", function () {
require("static/functions/artist_cloud.js", function () {
});
}); });
}); cloudLoaded = true;
cloudLoaded = true; }
} }
else {
} document.getElementById('flip_view_1').style.display='block';
else { document.getElementById('flip_view_2').style.display='none';
document.getElementById('flipper_title').innerHTML = 'Similar artist map';
document.getElementById('flip_view_1').style.display='block'; document.getElementById('flip_to').innerHTML = 'Switch to cloud';
document.getElementById('flip_view_2').style.display='none'; }
document.getElementById('flipper_title').innerHTML = 'Similar Artist Map';
document.getElementById('flip_to').innerHTML = ' [Switch to Cloud]';
}
} }
//TODO move this to global, perhaps it will be used elsewhere in the future //TODO move this to global, perhaps it will be used elsewhere in the future
//http://stackoverflow.com/questions/7293344/load-javascript-dynamically //http://stackoverflow.com/questions/7293344/load-javascript-dynamically
function require(file, callback) { function require(file, callback) {
var script = document.getElementsByTagName('script')[0], var script = document.getElementsByTagName('script')[0],
newjs = document.createElement('script'); newjs = document.createElement('script');
// IE // IE
newjs.onreadystatechange = function () { newjs.onreadystatechange = function () {
if (newjs.readyState === 'loaded' || newjs.readyState === 'complete') { if (newjs.readyState === 'loaded' || newjs.readyState === 'complete') {
newjs.onreadystatechange = null; newjs.onreadystatechange = null;
callback(); callback();
} }
}; };
// others // others
newjs.onload = function () { newjs.onload = function () {
callback(); callback();
}; };
newjs.src = file; newjs.src = file;
script.parentNode.insertBefore(newjs, script); script.parentNode.insertBefore(newjs, script);
} }
//]]> //]]>
</script> </script>
@ -1042,7 +1036,7 @@ function require(file, callback) {
<br /> <br />
<br /> <br />
<? if (check_perms('site_admin_forums')) { ?> <? if (check_perms('site_admin_forums')) { ?>
<a href="#content<?=$PostID?>" onclick="LoadEdit('artist', <?=$PostID?>, 1); return false;">&laquo;</a> <a href="#content<?=$PostID?>" onclick="LoadEdit('artist', <?=$PostID?>, 1); return false;">&laquo;</a>
<? } ?> <? } ?>
Last edited by Last edited by
<?=Users::format_username($EditedUserID, false, false, false) ?> <?=time_diff($EditedTime,2,true,true)?> <?=Users::format_username($EditedUserID, false, false, false) ?> <?=time_diff($EditedTime,2,true,true)?>

View File

@ -125,7 +125,7 @@ function compare($X, $Y){
$FirstUnknown = !isset($FirstUnknown); $FirstUnknown = !isset($FirstUnknown);
} }
$SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : ''; $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
if($Torrent['RemasterTitle'] != $LastRemasterTitle || $Torrent['RemasterYear'] != $LastRemasterYear || if($Torrent['RemasterTitle'] != $LastRemasterTitle || $Torrent['RemasterYear'] != $LastRemasterYear ||
$Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel || $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber || $FirstUnknown || $Torrent['Media'] != $LastMedia) { $Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel || $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber || $FirstUnknown || $Torrent['Media'] != $LastMedia) {
@ -290,8 +290,8 @@ function compare($X, $Y){
<a href="bookmarks.php?type=requests" class="brackets">Requests</a> <a href="bookmarks.php?type=requests" class="brackets">Requests</a>
<? if (count($TorrentList) > 0) { ?> <? if (count($TorrentList) > 0) { ?>
<br /><br /> <br /><br />
<a href="bookmarks.php?action=remove_snatched&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets" onclick="return confirm('Are you sure you want to remove the bookmarks for all items you\'ve snatched?');">Remove Snatched</a> <a href="bookmarks.php?action=remove_snatched&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets" onclick="return confirm('Are you sure you want to remove the bookmarks for all items you\'ve snatched?');">Remove snatched</a>
<a href="bookmarks.php?action=edit&amp;type=torrents" class="brackets">Manage Torrents</a> <a href="bookmarks.php?action=edit&amp;type=torrents" class="brackets">Manage torrents</a>
<? } ?> <? } ?>
</div> </div>
</div> </div>

View File

@ -18,7 +18,7 @@
$Conditions = "WHERE t.UserID = $UserID AND tc.AuthorID != t.UserID AND tc.AddedTime > t.Time"; $Conditions = "WHERE t.UserID = $UserID AND tc.AuthorID != t.UserID AND tc.AddedTime > t.Time";
$Title = 'Comments left on your torrents'; $Title = 'Comments left on your torrents';
$Header = 'Comments left on your uploads'; $Header = 'Comments left on your uploads';
if($Self) $OtherLink = '<a href="comments.php?action=torrents">Display comments you\'ve made</a>'; if($Self) $OtherLink = '<a href="comments.php?action=torrents" class="brackets">Display comments you have made</a>';
} }
else { else {
$Conditions = "WHERE tc.AuthorID = $UserID"; $Conditions = "WHERE tc.AuthorID = $UserID";
@ -72,7 +72,7 @@
<?=$OtherLink?> <?=$OtherLink?>
</div> </div>
<? } ?> <? } ?>
</div> </div>
<div class="linkbox"> <div class="linkbox">
<?=$Pages?> <?=$Pages?>
</div> </div>
@ -87,7 +87,7 @@
} /* end while loop*/ ?> } /* end while loop*/ ?>
<div class="linkbox"><?= $Pages; ?></div> <div class="linkbox"><?= $Pages; ?></div>
</div> </div>
<? <?
View::show_footer(); View::show_footer();

View File

@ -53,7 +53,8 @@
list($Stickies) = $DB->next_record(); list($Stickies) = $DB->next_record();
$Cache->cache_value('forums_'.$ForumID, array($Forum,'',0,$Stickies), 0); $Cache->cache_value('forums_'.$ForumID, array($Forum,'',0,$Stickies), 0);
} }
} }
if(!isset($Forums[$ForumID])) { error(404); } if(!isset($Forums[$ForumID])) { error(404); }
// Make sure they're allowed to look at the page // Make sure they're allowed to look at the page

View File

@ -36,8 +36,6 @@
$ThreadID = $_GET['threadid']; $ThreadID = $_GET['threadid'];
} }
if (isset($LoggedUser['PostsPerPage'])) { if (isset($LoggedUser['PostsPerPage'])) {
$PerPage = $LoggedUser['PostsPerPage']; $PerPage = $LoggedUser['PostsPerPage'];
} else { } else {
@ -165,13 +163,13 @@
<div class="center"> <div class="center">
<a href="reports.php?action=report&amp;type=thread&amp;id=<?=$ThreadID?>" class="brackets">Report Thread</a> <a href="reports.php?action=report&amp;type=thread&amp;id=<?=$ThreadID?>" class="brackets">Report Thread</a>
<a href="#" onclick="Subscribe(<?=$ThreadID?>);return false;" id="subscribelink<?=$ThreadID?>" class="brackets"><?=(in_array($ThreadID, $UserSubscriptions) ? 'Unsubscribe' : 'Subscribe')?></a> <a href="#" onclick="Subscribe(<?=$ThreadID?>);return false;" id="subscribelink<?=$ThreadID?>" class="brackets"><?=(in_array($ThreadID, $UserSubscriptions) ? 'Unsubscribe' : 'Subscribe')?></a>
<a href="#" class="brackets" onclick="$('#searchthread').toggle(); this.innerHTML = (this.innerHTML == 'Search this Thread'?'Hide Search':'Search this Thread'); return false;">Search this Thread</a> <a href="#" onclick="$('#searchthread').toggle(); this.innerHTML = (this.innerHTML == 'Search this Thread'?'Hide Search':'Search this Thread'); return false;" class="brackets">Search this Thread</a>
</div> </div>
<div id="searchthread" class="hidden center"> <div id="searchthread" class="hidden center">
<div style="display: inline-block;"> <div style="display: inline-block;">
<h3>Search this thread:</h3> <h3>Search this thread:</h3>
<form class="search_form" name="forum_thread" action="forums.php" method="get"> <form class="search_form" name="forum_thread" action="forums.php" method="get">
<table cellpadding="6" cellspacing="1" border="0" class="layout border"> <table cellpadding="6" cellspacing="1" border="0" class="layout border">
<tr> <tr>
<td><strong>Search for:</strong></td> <td><strong>Search for:</strong></td>
<td><input type="text" id="searchbox" name="search" size="70" /></td> <td><input type="text" id="searchbox" name="search" size="70" /></td>

View File

@ -172,7 +172,10 @@
// Function to log a user's login attempt // Function to log a user's login attempt
function log_attempt($UserID) { function log_attempt($UserID) {
global $DB, $Cache, $AttemptID, $Attempts, $Bans, $BannedUntil, $Time; global $DB, $Cache, $AttemptID, $Attempts, $Bans, $BannedUntil, $Time, $UserID;
$IPStr = $_SERVER['REMOTE_ADDR'];
$IPA = substr($IPStr, 0, strcspn($IPStr, '.'));
$IP = Tools::ip_to_unsigned($IPStr);
if($AttemptID) { // User has attempted to log in recently if($AttemptID) { // User has attempted to log in recently
$Attempts++; $Attempts++;
if ($Attempts>5) { // Only 6 allowed login attempts, ban user's IP if ($Attempts>5) { // Only 6 allowed login attempts, ban user's IP
@ -185,7 +188,6 @@ function log_attempt($UserID) {
WHERE ID='".db_string($AttemptID)."'"); WHERE ID='".db_string($AttemptID)."'");
if ($Bans>9) { // Automated bruteforce prevention if ($Bans>9) { // Automated bruteforce prevention
$IP = Tools::ip_to_unsigned($_SERVER['REMOTE_ADDR']);
$DB->query("SELECT Reason FROM ip_bans WHERE ".$IP." BETWEEN FromIP AND ToIP"); $DB->query("SELECT Reason FROM ip_bans WHERE ".$IP." BETWEEN FromIP AND ToIP");
if($DB->record_count() > 0) { if($DB->record_count() > 0) {
//Ban exists already, only add new entry if not for same reason //Ban exists already, only add new entry if not for same reason
@ -200,8 +202,7 @@ function log_attempt($UserID) {
$DB->query("INSERT IGNORE INTO ip_bans $DB->query("INSERT IGNORE INTO ip_bans
(FromIP, ToIP, Reason) VALUES (FromIP, ToIP, Reason) VALUES
('$IP','$IP', 'Automated ban per >60 failed login attempts')"); ('$IP','$IP', 'Automated ban per >60 failed login attempts')");
$A = substr($_SERVER['REMOTE_ADDR'], 0, strcspn($_SERVER['REMOTE_ADDR'], '.')); $Cache->delete_value('ip_bans_'.$IPA);
$Cache->delete_value('ip_bans_'.$A);
} }
} }
} else { } else {
@ -216,12 +217,16 @@ function log_attempt($UserID) {
$Attempts=1; $Attempts=1;
$DB->query("INSERT INTO login_attempts $DB->query("INSERT INTO login_attempts
(UserID,IP,LastAttempt,Attempts) VALUES (UserID,IP,LastAttempt,Attempts) VALUES
('".db_string($UserID)."','".db_string($_SERVER['REMOTE_ADDR'])."','".sqltime()."',1)"); ('".db_string($UserID)."','".db_string($IPStr)."','".sqltime()."',1)");
} }
} // end log_attempt function } // end log_attempt function
// If user has submitted form // If user has submitted form
if(isset($_POST['username']) && !empty($_POST['username']) && isset($_POST['password']) && !empty($_POST['password'])) { if(isset($_POST['username']) && !empty($_POST['username']) && isset($_POST['password']) && !empty($_POST['password'])) {
if (strtotime($BannedUntil) > time()) {
header("Location: login.php");
die();
}
$Err=$Validate->ValidateForm($_POST); $Err=$Validate->ValidateForm($_POST);
if(!$Err) { if(!$Err) {

View File

@ -10,7 +10,7 @@
$Text = new TEXT; $Text = new TEXT;
if(empty($_GET['id']) || !is_number($_GET['id'])) { if(empty($_GET['id']) || !is_number($_GET['id'])) {
error(0); error(0);
} }
@ -18,7 +18,7 @@
//First things first, lets get the data for the request. //First things first, lets get the data for the request.
$Request = Requests::get_requests(array($RequestID)); $Request = Requests::get_requests(array($RequestID));
$Request = $Request['matches'][$RequestID]; $Request = $Request['matches'][$RequestID];
if(empty($Request)) { if(empty($Request)) {
error(404); error(404);
@ -42,14 +42,14 @@
$ArtistForm = get_request_artists($RequestID); $ArtistForm = get_request_artists($RequestID);
$ArtistName = Artists::display_artists($ArtistForm, false, true); $ArtistName = Artists::display_artists($ArtistForm, false, true);
$ArtistLink = Artists::display_artists($ArtistForm, true, true); $ArtistLink = Artists::display_artists($ArtistForm, true, true);
if($IsFilled) { if($IsFilled) {
$DisplayLink = $ArtistLink."<a href='torrents.php?torrentid=".$TorrentID."'>".$Title."</a> [".$Year."]"; $DisplayLink = $ArtistLink."<a href='torrents.php?torrentid=".$TorrentID."'>".$Title."</a> [".$Year."]";
} else { } else {
$DisplayLink = $ArtistLink.$Title." [".$Year."]"; $DisplayLink = $ArtistLink.$Title." [".$Year."]";
} }
$FullName = $ArtistName.$Title." [".$Year."]"; $FullName = $ArtistName.$Title." [".$Year."]";
if($BitrateList != "") { if($BitrateList != "") {
$BitrateString = implode(", ", explode("|", $BitrateList)); $BitrateString = implode(", ", explode("|", $BitrateList));
$FormatString = implode(", ", explode("|", $FormatList)); $FormatString = implode(", ", explode("|", $FormatList));
@ -59,13 +59,13 @@
$FormatString = "Unknown, please read the description."; $FormatString = "Unknown, please read the description.";
$MediaString = "Unknown, please read the description."; $MediaString = "Unknown, please read the description.";
} }
if(empty($ReleaseType)) { if(empty($ReleaseType)) {
$ReleaseName = "Unknown"; $ReleaseName = "Unknown";
} else { } else {
$ReleaseName = $ReleaseTypes[$ReleaseType]; $ReleaseName = $ReleaseTypes[$ReleaseType];
} }
} else if($CategoryName == "Audiobooks" || $CategoryName == "Comedy") { } else if($CategoryName == "Audiobooks" || $CategoryName == "Comedy") {
$FullName = $Title." [".$Year."]"; $FullName = $Title." [".$Year."]";
$DisplayLink = $Title." [".$Year."]"; $DisplayLink = $Title." [".$Year."]";
@ -88,20 +88,20 @@
<div class="header"> <div class="header">
<h2><a href="requests.php">Requests</a> &gt; <?=$CategoryName?> &gt; <?=$DisplayLink?></h2> <h2><a href="requests.php">Requests</a> &gt; <?=$CategoryName?> &gt; <?=$DisplayLink?></h2>
<div class="linkbox"> <div class="linkbox">
<? if($CanEdit) { ?> <? if($CanEdit) { ?>
<a href="requests.php?action=edit&amp;id=<?=$RequestID?>" class="brackets">Edit</a> <a href="requests.php?action=edit&amp;id=<?=$RequestID?>" class="brackets">Edit</a>
<? } <? }
if($UserCanEdit || check_perms('users_mod')) { //check_perms('site_moderate_requests')) { ?> if($UserCanEdit || check_perms('users_mod')) { //check_perms('site_moderate_requests')) { ?>
<a href="requests.php?action=delete&amp;id=<?=$RequestID?>" class="brackets">Delete</a> <a href="requests.php?action=delete&amp;id=<?=$RequestID?>" class="brackets">Delete</a>
<? } ?> <? } ?>
<? if(has_bookmarked('request', $RequestID)) { ?> <? if(has_bookmarked('request', $RequestID)) { ?>
<a href="#" id="bookmarklink_request_<?=$RequestID?>" onclick="Unbookmark('request', <?=$RequestID?>,'[Bookmark]');return false;" class="brackets">Remove bookmark</a> <a href="#" id="bookmarklink_request_<?=$RequestID?>" onclick="Unbookmark('request', <?=$RequestID?>,'Bookmark');return false;" class="brackets">Remove bookmark</a>
<? } else { ?> <? } else { ?>
<a href="#" id="bookmarklink_request_<?=$RequestID?>" onclick="Bookmark('request', <?=$RequestID?>,'[Remove bookmark]');return false;" class="brackets">Bookmark</a> <a href="#" id="bookmarklink_request_<?=$RequestID?>" onclick="Bookmark('request', <?=$RequestID?>,'Remove bookmark');return false;" class="brackets">Bookmark</a>
<? } ?> <? } ?>
<a href="reports.php?action=report&amp;type=request&amp;id=<?=$RequestID?>" class="brackets">Report request</a> <a href="reports.php?action=report&amp;type=request&amp;id=<?=$RequestID?>" class="brackets">Report request</a>
<? if(!$IsFilled) { ?> <? if(!$IsFilled) { ?>
<a href="upload.php?requestid=<?=$RequestID?><?=($GroupID?"&groupid=$GroupID":'')?>" class="brackets">Upload request</a> <a href="upload.php?requestid=<?=$RequestID?><?= ($GroupID ? "&amp;groupid=$GroupID" : '') ?>" class="brackets">Upload request</a>
<? } <? }
if(!$IsFilled && (($CategoryID == 0) || ($CategoryName == "Music" && $Year == 0))) { ?> if(!$IsFilled && (($CategoryID == 0) || ($CategoryName == "Music" && $Year == 0))) { ?>
<a href="reports.php?action=report&amp;type=request_update&amp;id=<?=$RequestID?>" class="brackets">Request update</a> <a href="reports.php?action=report&amp;type=request_update&amp;id=<?=$RequestID?>" class="brackets">Request update</a>
@ -138,13 +138,13 @@
<p align="center"><img src="<?=STATIC_SERVER?>common/noartwork/<?=$CategoryIcons[$CategoryID-1]?>" alt="<?=$CategoryName?>" title="<?=$CategoryName?>" width="220" height="220" border="0" /></p> <p align="center"><img src="<?=STATIC_SERVER?>common/noartwork/<?=$CategoryIcons[$CategoryID-1]?>" alt="<?=$CategoryName?>" title="<?=$CategoryName?>" width="220" height="220" border="0" /></p>
<? } ?> <? } ?>
</div> </div>
<? } <? }
if($CategoryName == "Music") { ?> if($CategoryName == "Music") { ?>
<div class="box box_artists"> <div class="box box_artists">
<div class="head"><strong>Artists</strong></div> <div class="head"><strong>Artists</strong></div>
<ul class="stats nobullet"> <ul class="stats nobullet">
<? <?
if(!empty($ArtistForm[4]) && count($ArtistForm[4]) > 0) { if(!empty($ArtistForm[4]) && count($ArtistForm[4]) > 0) {
?> ?>
<li class="artists_composer"><strong>Composers:</strong></li> <li class="artists_composer"><strong>Composers:</strong></li>
<? foreach($ArtistForm[4] as $Artist) { <? foreach($ArtistForm[4] as $Artist) {
@ -154,7 +154,7 @@
</li> </li>
<? } <? }
} }
if(!empty($ArtistForm[6]) && count($ArtistForm[6]) > 0) { if(!empty($ArtistForm[6]) && count($ArtistForm[6]) > 0) {
?> ?>
<li class="artists_dj"><strong>DJ / Compiler:</strong></li> <li class="artists_dj"><strong>DJ / Compiler:</strong></li>
<? foreach($ArtistForm[6] as $Artist) { <? foreach($ArtistForm[6] as $Artist) {
@ -176,7 +176,7 @@
<?=Artists::display_artist($Artist)?> <?=Artists::display_artist($Artist)?>
</li> </li>
<? } <? }
if(!empty($ArtistForm[2]) && count($ArtistForm[2]) > 0) { if(!empty($ArtistForm[2]) && count($ArtistForm[2]) > 0) {
?> ?>
<li class="artists_with"><strong>With:</strong></li> <li class="artists_with"><strong>With:</strong></li>
<? foreach($ArtistForm[2] as $Artist) { <? foreach($ArtistForm[2] as $Artist) {
@ -186,7 +186,7 @@
</li> </li>
<? } <? }
} }
if(!empty($ArtistForm[5]) && count($ArtistForm[5]) > 0) { if(!empty($ArtistForm[5]) && count($ArtistForm[5]) > 0) {
?> ?>
<li class="artists_conductor"><strong>Conducted by:</strong></li> <li class="artists_conductor"><strong>Conducted by:</strong></li>
<? foreach($ArtistForm[5] as $Artist) { <? foreach($ArtistForm[5] as $Artist) {
@ -196,7 +196,7 @@
</li> </li>
<? } <? }
} }
if(!empty($ArtistForm[3]) && count($ArtistForm[3]) > 0) { if(!empty($ArtistForm[3]) && count($ArtistForm[3]) > 0) {
?> ?>
<li class="artists_remix"><strong>Remixed by:</strong></li> <li class="artists_remix"><strong>Remixed by:</strong></li>
<? foreach($ArtistForm[3] as $Artist) { <? foreach($ArtistForm[3] as $Artist) {
@ -207,7 +207,7 @@
<? <?
} }
} }
if(!empty($ArtistForm[7]) && count($ArtistForm[7]) > 0) { if(!empty($ArtistForm[7]) && count($ArtistForm[7]) > 0) {
?> ?>
<li class="artists_producer"><strong>Produced by:</strong></li> <li class="artists_producer"><strong>Produced by:</strong></li>
<? foreach($ArtistForm[7] as $Artist) { <? foreach($ArtistForm[7] as $Artist) {
@ -238,7 +238,7 @@
<table class="layout"> <table class="layout">
<? $VoteMax = ($VoteCount < 5 ? $VoteCount : 5); <? $VoteMax = ($VoteCount < 5 ? $VoteCount : 5);
$ViewerVote = false; $ViewerVote = false;
for($i = 0; $i < $VoteMax; $i++) { for($i = 0; $i < $VoteMax; $i++) {
$User = array_shift($RequestVotes['Voters']); $User = array_shift($RequestVotes['Voters']);
$Boldify = false; $Boldify = false;
if ($User['UserID'] == $LoggedUser['ID']) { if ($User['UserID'] == $LoggedUser['ID']) {
@ -254,7 +254,7 @@
<?=$Boldify?'<strong>':''?><?=Format::get_size($User['Bounty'])?><?=$Boldify?'</strong>':''?> <?=$Boldify?'<strong>':''?><?=Format::get_size($User['Bounty'])?><?=$Boldify?'</strong>':''?>
</td> </td>
</tr> </tr>
<? } <? }
reset($RequestVotes['Voters']); reset($RequestVotes['Voters']);
if (!$ViewerVote) { if (!$ViewerVote) {
foreach ($RequestVotes['Voters'] as $User) { foreach ($RequestVotes['Voters'] as $User) {
@ -281,7 +281,7 @@
<td> <td>
<?=time_diff($TimeAdded)?> by <strong><?=Users::format_username($RequestorID, false, false, false)?></strong> <?=time_diff($TimeAdded)?> by <strong><?=Users::format_username($RequestorID, false, false, false)?></strong>
</td> </td>
</tr> </tr>
<? if($CategoryName == "Music") { <? if($CategoryName == "Music") {
if(!empty($RecordLabel)) { ?> if(!empty($RecordLabel)) { ?>
<tr> <tr>
@ -290,7 +290,7 @@
<?=$RecordLabel?> <?=$RecordLabel?>
</td> </td>
</tr> </tr>
<? } <? }
if(!empty($CatalogueNumber)) { ?> if(!empty($CatalogueNumber)) { ?>
<tr> <tr>
<td class="label">Catalogue Number</td> <td class="label">Catalogue Number</td>
@ -365,11 +365,11 @@
<tr> <tr>
<td class="label">Votes</td> <td class="label">Votes</td>
<td> <td>
<span id="votecount"><?=$VoteCount?></span> <span id="votecount"><?=$VoteCount?></span>
<? if($CanVote) { ?> <? if($CanVote) { ?>
&nbsp;<a href="javascript:Vote(0)"><strong>(+)</strong></a> &nbsp;<a href="javascript:Vote(0)"><strong>(+)</strong></a>
<strong>Costs <?=Format::get_size($MinimumVote, 0)?></strong> <strong>Costs <?=Format::get_size($MinimumVote, 0)?></strong>
<? } ?> <? } ?>
</td> </td>
</tr> </tr>
<? if ($LastVote > $TimeAdded) { ?> <? if ($LastVote > $TimeAdded) { ?>
@ -379,7 +379,7 @@
<?=time_diff($LastVote)?> <?=time_diff($LastVote)?>
</td> </td>
</tr> </tr>
<? } ?> <? } ?>
<? if($CanVote) { ?> <? if($CanVote) { ?>
<tr id="voting"> <tr id="voting">
<td class="label" title="These units are in base 2, not base 10. For example, there are 1,024 MB in 1 GB.">Custom vote (MB)</td> <td class="label" title="These units are in base 2, not base 10. For example, there are 1,024 MB in 1 GB.">Custom vote (MB)</td>
@ -414,7 +414,7 @@
</form> </form>
</td> </td>
</tr> </tr>
<? }?> <? }?>
<tr id="bounty"> <tr id="bounty">
<td class="label">Bounty</td> <td class="label">Bounty</td>
<td id="formatted_bounty"><?=Format::get_size($RequestVotes['TotalBounty'])?></td> <td id="formatted_bounty"><?=Format::get_size($RequestVotes['TotalBounty'])?></td>
@ -426,10 +426,10 @@
<tr> <tr>
<td class="label">Filled</td> <td class="label">Filled</td>
<td> <td>
<strong><a href="torrents.php?<?=(strtotime($TimeFilled)<$TimeCompare?'id=':'torrentid=').$TorrentID?>">Yes</a></strong>, <strong><a href="torrents.php?<?=(strtotime($TimeFilled)<$TimeCompare?'id=':'torrentid=').$TorrentID?>">Yes</a></strong>,
by user <?=Users::format_username($FillerID, false, false, false)?> by user <?=Users::format_username($FillerID, false, false, false)?>
<? if($LoggedUser['ID'] == $RequestorID || $LoggedUser['ID'] == $FillerID || check_perms('site_moderate_requests')) { ?> <? if($LoggedUser['ID'] == $RequestorID || $LoggedUser['ID'] == $FillerID || check_perms('site_moderate_requests')) { ?>
<strong><a href="requests.php?action=unfill&amp;id=<?=$RequestID?>">(Unfill)</a></strong> Unfilling a request without a valid, nontrivial reason will result in a warning. <strong><a href="requests.php?action=unfill&amp;id=<?=$RequestID?>">(Unfill)</a></strong> Unfilling a request without a valid, nontrivial reason will result in a warning.
<? } ?> <? } ?>
</td> </td>
</tr> </tr>
@ -450,7 +450,7 @@
<br /> <br />
<? } ?> <? } ?>
<input type="submit" value="Fill request" /> <input type="submit" value="Fill request" />
<br /> <br />
</div> </div>
</form> </form>
</td> </td>
@ -458,7 +458,7 @@
<? } ?> <? } ?>
<? <?
//<strip> //<strip>
if(check_perms("users_mod")) { if(check_perms("users_mod")) {
$RequestLog = Requests::get_request_log($RequestID); $RequestLog = Requests::get_request_log($RequestID);
if($RequestLog) { if($RequestLog) {
?> ?>
@ -472,7 +472,7 @@
</div> </div>
</td> </td>
</tr> </tr>
<? } <? }
} }
//<strip> //<strip>
?> ?>
@ -578,7 +578,7 @@
<br /> <br />
<br /> <br />
<? if(check_perms('site_moderate_forums')) { ?> <? if(check_perms('site_moderate_forums')) { ?>
<a href="#content<?=$PostID?>" onclick="LoadEdit('requests', <?=$PostID?>, 1); return false;">&laquo;</a> <a href="#content<?=$PostID?>" onclick="LoadEdit('requests', <?=$PostID?>, 1); return false;">&laquo;</a>
<? } ?> <? } ?>
Last edited by Last edited by
<?=Users::format_username($EditedUserID, false, false, false) ?> <?=time_diff($EditedTime,2,true,true)?> <?=Users::format_username($EditedUserID, false, false, false) ?> <?=time_diff($EditedTime,2,true,true)?>

View File

@ -5,15 +5,15 @@
$OrderWays = array('year', 'votes', 'bounty', 'created', 'lastvote', 'filled'); $OrderWays = array('year', 'votes', 'bounty', 'created', 'lastvote', 'filled');
list($Page,$Limit) = Format::page_limit(REQUESTS_PER_PAGE); list($Page,$Limit) = Format::page_limit(REQUESTS_PER_PAGE);
$Submitted = !empty($_GET['submit']); $Submitted = !empty($_GET['submit']);
//Paranoia //Paranoia
$UserInfo = Users::user_info((int)$_GET['userid']); $UserInfo = Users::user_info((int)$_GET['userid']);
$Perms = Permissions::get_permissions($UserInfo['PermissionID']); $Perms = Permissions::get_permissions($UserInfo['PermissionID']);
$UserClass = $Perms['Class']; $UserClass = $Perms['Class'];
$BookmarkView = false; $BookmarkView = false;
if(empty($_GET['type'])) { if(empty($_GET['type'])) {
$Title = 'Requests'; $Title = 'Requests';
if(!check_perms('site_see_old_requests') || empty($_GET['showall'])) { if(!check_perms('site_see_old_requests') || empty($_GET['showall'])) {
$SS->set_filter('visible', array(1)); $SS->set_filter('visible', array(1));
@ -363,14 +363,14 @@
<input type="checkbox" name="show_filled" <? if(!$Submitted || !empty($_GET['show_filled']) || (!$Submitted && !empty($_GET['type']) && $_GET['type'] == "filled")) { ?>checked="checked"<? } ?> /> <input type="checkbox" name="show_filled" <? if(!$Submitted || !empty($_GET['show_filled']) || (!$Submitted && !empty($_GET['type']) && $_GET['type'] == "filled")) { ?>checked="checked"<? } ?> />
</td> </td>
</tr> </tr>
<? if(check_perms('site_see_old_requests')){ ?> <? if(check_perms('site_see_old_requests')){ ?>
<tr id="include_old"> <tr id="include_old">
<td class="label">Include old:</td> <td class="label">Include old:</td>
<td> <td>
<input type="checkbox" name="showall" <? if(!empty($_GET['showall'])) {?>checked="checked"<? } ?> /> <input type="checkbox" name="showall" <? if(!empty($_GET['showall'])) {?>checked="checked"<? } ?> />
</td> </td>
</tr> </tr>
<? /* ?> <? /* ?>
<tr> <tr>
<td class="label">Requested by:</td> <td class="label">Requested by:</td>
<td> <td>
@ -404,7 +404,7 @@
</table> </table>
<table class="layout"> <table class="layout">
<tr id="release_list"> <tr id="release_list">
<td class="label">Release Types</td> <td class="label">Release types</td>
<td> <td>
<input type="checkbox" id="toggle_releases" onchange="Toggle('releases', 0)" <?=(!$Submitted || !empty($ReleaseArray) && count($ReleaseArray) == count($ReleaseTypes) ? ' checked="checked"' : '')?>/> <label for="toggle_releases">All</label> <input type="checkbox" id="toggle_releases" onchange="Toggle('releases', 0)" <?=(!$Submitted || !empty($ReleaseArray) && count($ReleaseArray) == count($ReleaseTypes) ? ' checked="checked"' : '')?>/> <label for="toggle_releases">All</label>
<? $i = 0; <? $i = 0;
@ -431,7 +431,7 @@
/> <label for="format_<?=$Key?>"><?=$Val?></label> /> <label for="format_<?=$Key?>"><?=$Val?></label>
<? }?> <? }?>
</td> </td>
</tr> </tr>
<tr id="bitrate_list"> <tr id="bitrate_list">
<td class="label">Bitrates</td> <td class="label">Bitrates</td>
<td> <td>
@ -467,7 +467,7 @@
<input type="submit" value="Search requests" /> <input type="submit" value="Search requests" />
</td> </td>
</tr> </tr>
</table> </table>
</form> </form>
<div class="linkbox"> <div class="linkbox">
<? if (!$BookmarkView) { <? if (!$BookmarkView) {
@ -495,7 +495,7 @@
<table id="request_table" class="request_table border" cellpadding="6" cellspacing="1" border="0" width="100%"> <table id="request_table" class="request_table border" cellpadding="6" cellspacing="1" border="0" width="100%">
<tr class="colhead_dark"> <tr class="colhead_dark">
<td style="width: 38%;" class="nobr"> <td style="width: 38%;" class="nobr">
<strong>Request Name</strong> / <a href="?order=year&amp;sort=<?=(($CurrentOrder == 'year') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>"><strong>Year</strong></a> <strong>Request name</strong> / <a href="?order=year&amp;sort=<?=(($CurrentOrder == 'year') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>"><strong>Year</strong></a>
</td> </td>
<td class="nobr"> <td class="nobr">
<a href="?order=votes&amp;sort=<?=(($CurrentOrder == 'votes') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>"><strong>Votes</strong></a> <a href="?order=votes&amp;sort=<?=(($CurrentOrder == 'votes') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>"><strong>Votes</strong></a>
@ -516,7 +516,7 @@
<a href="?order=created&amp;sort=<?=(($CurrentOrder == 'created') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>"><strong>Created</strong></a> <a href="?order=created&amp;sort=<?=(($CurrentOrder == 'created') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>"><strong>Created</strong></a>
</td> </td>
<td class="nobr"> <td class="nobr">
<a href="?order=lastvote&amp;sort=<?=(($CurrentOrder == 'lastvote') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>"><strong>Last Vote</strong></a> <a href="?order=lastvote&amp;sort=<?=(($CurrentOrder == 'lastvote') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>"><strong>Last vote</strong></a>
</td> </td>
</tr> </tr>
<? if($NumResults == 0) { ?> <? if($NumResults == 0) { ?>
@ -560,26 +560,26 @@
$Row = 'a'; $Row = 'a';
$TimeCompare = 1267643718; // Requests v2 was implemented 2010-03-03 20:15:18 $TimeCompare = 1267643718; // Requests v2 was implemented 2010-03-03 20:15:18
foreach ($Requests as $RequestID => $Request) { foreach ($Requests as $RequestID => $Request) {
//list($BitrateList, $CatalogueNumber, $CategoryID, $Description, $FillerID, $FormatList, $RequestID, $Image, $LogCue, $MediaList, $ReleaseType, //list($BitrateList, $CatalogueNumber, $CategoryID, $Description, $FillerID, $FormatList, $RequestID, $Image, $LogCue, $MediaList, $ReleaseType,
// $Tags, $TimeAdded, $TimeFilled, $Title, $TorrentID, $RequestorID, $RequestorName, $Year, $RequestID, $Categoryid, $FillerID, $LastVote, // $Tags, $TimeAdded, $TimeFilled, $Title, $TorrentID, $RequestorID, $RequestorName, $Year, $RequestID, $Categoryid, $FillerID, $LastVote,
// $ReleaseType, $TagIDs, $TimeAdded, $TimeFilled, $TorrentID, $RequestorID, $Voters) = array_values($Request); // $ReleaseType, $TagIDs, $TimeAdded, $TimeFilled, $TorrentID, $RequestorID, $Voters) = array_values($Request);
list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, $RecordLabel, list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, $RecordLabel,
$ReleaseType, $BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled) = $Request; $ReleaseType, $BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled) = $Request;
$RequestVotes = get_votes_array($RequestID); $RequestVotes = get_votes_array($RequestID);
$VoteCount = count($RequestVotes['Voters']); $VoteCount = count($RequestVotes['Voters']);
if($CategoryID == 0) { if($CategoryID == 0) {
$CategoryName = "Unknown"; $CategoryName = "Unknown";
} else { } else {
$CategoryName = $Categories[$CategoryID - 1]; $CategoryName = $Categories[$CategoryID - 1];
} }
$IsFilled = ($TorrentID != 0); $IsFilled = ($TorrentID != 0);
if($CategoryName == "Music") { if($CategoryName == "Music") {
$ArtistForm = get_request_artists($RequestID); $ArtistForm = get_request_artists($RequestID);
$ArtistLink = Artists::display_artists($ArtistForm, true, true); $ArtistLink = Artists::display_artists($ArtistForm, true, true);
@ -589,16 +589,16 @@
} else { } else {
$FullName ="<a href='requests.php?action=view&amp;id=".$RequestID."'>".$Title."</a>"; $FullName ="<a href='requests.php?action=view&amp;id=".$RequestID."'>".$Title."</a>";
} }
$Row = ($Row == 'a') ? 'b' : 'a'; $Row = ($Row == 'a') ? 'b' : 'a';
$Tags = $Request['Tags']; $Tags = $Request['Tags'];
?> ?>
<tr class="row<?=$Row?>"> <tr class="row<?=$Row?>">
<td> <td>
<?=$FullName?> <?=$FullName?>
<div class="tags"> <div class="tags">
<? <?
$TagList = array(); $TagList = array();
foreach($Tags as $TagID => $TagName) { foreach($Tags as $TagID => $TagName) {
$TagList[] = "<a href='?tags=".$TagName.($BookmarkView ? "&amp;type=requests" : "")."'>".display_str($TagName)."</a>"; $TagList[] = "<a href='?tags=".$TagName.($BookmarkView ? "&amp;type=requests" : "")."'>".display_str($TagName)."</a>";

View File

@ -536,20 +536,13 @@ h3{margin:10px 0}
font-weight: bold; font-weight: bold;
} }
tr.torrent .bookmark > a:before { content: ""; }
tr.torrent .bookmark > a:before { content:""; } tr.torrent .bookmark > a:after { content: ""; }
tr.torrent .bookmark > a:after { content:""; }
.sidebar .navigation_list li { .sidebar .navigation_list li {
margin-left: 20px; margin-left: 20px;
} }
.linkbox .brackets:before { .linkbox .brackets:before, .linkbox .brackets:after {
content: "[ ";
color: #757575;
}
.linkbox .brackets:after {
content: " ]";
color: #757575; color: #757575;
} }

View File

@ -242,14 +242,14 @@ table tr.colhead_dark td{background:#555; border:0}
#forums .rowb .min_padding img, #forums .rowa .min_padding img{position:relative; top:3px} #forums .rowb .min_padding img, #forums .rowa .min_padding img{position:relative; top:3px}
#forums .forum_post tr, #forums .forum_post tr,
#userhistory .forum_post tr, #userhistory .forum_post tr,
#collage .forum_post tr, #collage .forum_post tr,
#torrents .forum_post tr{border-bottom:1px solid #757575} #torrents .forum_post tr{border-bottom:1px solid #757575}
#forums .forum_post, #forums .forum_post,
#userhistory .forum_post, #userhistory .forum_post,
#collage .forum_post, #collage .forum_post,
#torrents .forum_post{border:0; margin:0} #torrents .forum_post{border:0; margin:0}
.avatar{border:0 !important; padding:1px 1px 1px 0; background-color:#161616 !important; width:150px} .avatar{border:0 !important; padding:1px 1px 1px 0; background-color:#161616 !important; width:150px}
@ -258,26 +258,26 @@ table tr.colhead_dark td{background:#555; border:0}
#requests .forum_post .body{border:0} #requests .forum_post .body{border:0}
#requests .forum_post{margin-bottom:0} #requests .forum_post{margin-bottom:0}
#forums .forum_post .body, #forums .forum_post .body,
#userhistory .forum_post .body, #userhistory .forum_post .body,
#collage .forum_post .body, #collage .forum_post .body,
#torrents .forum_post .body{padding:0; border-left:0} #torrents .forum_post .body{padding:0; border-left:0}
#forums .forum_post td, #forums .forum_post td,
#userhistory .forum_post td, #userhistory .forum_post td,
#collage .forum_post td, #collage .forum_post td,
#torrents .forum_post td{border-left:0; border-right:0} #torrents .forum_post td{border-left:0; border-right:0}
#forums .forum_post .body div, #forums .forum_post .body div,
#collage .forum_post .body div, #collage .forum_post .body div,
#torrents .forum_post .body div, #torrents .forum_post .body div,
#requests .forum_post .body div{padding:10px 15px} #requests .forum_post .body div{padding:10px 15px}
#userhistory .forum_post .body{padding:20px} #userhistory .forum_post .body{padding:20px}
#userhistory .forum_post tr.colhead_dark{background-image:none} #userhistory .forum_post tr.colhead_dark{background-image:none}
#forums .forum_post .body div div, #forums .forum_post .body div div,
#collage .forum_post .body div div, #collage .forum_post .body div div,
#torrents .forum_post .body div div{background:none; padding:0} #torrents .forum_post .body div div{background:none; padding:0}
#forums .forum_post ul{margin:5px 0 0 0; padding:0} #forums .forum_post ul{margin:5px 0 0 0; padding:0}
@ -325,18 +325,18 @@ table tr.colhead_dark td{background:#555; border:0}
.torrent_table tr.group_torrent a, #torrent_table tr.group_torrent a{color:#999; font-weight:normal} .torrent_table tr.group_torrent a, #torrent_table tr.group_torrent a{color:#999; font-weight:normal}
.torrent_table tr.group_torrent a:hover, #torrent_table tr.group_torrent a:hover{color:#007dc6} .torrent_table tr.group_torrent a:hover, #torrent_table tr.group_torrent a:hover{color:#007dc6}
#torrents #content .center .box form div input[type="text"], #torrents #content .center .box form div input[type="text"],
#wiki #content .center .box form div input[type="text"], #wiki #content .center .box form div input[type="text"],
#artist #content .center .box form div input[type="text"]{width:500px; margin-bottom:10px} #artist #content .center .box form div input[type="text"]{width:500px; margin-bottom:10px}
#torrents #content .center .box form div textarea, #torrents #content .center .box form div textarea,
#wiki #content .center .box form div textarea, #wiki #content .center .box form div textarea,
#upload textarea#album_desc, #upload textarea#album_desc,
#forums #content .thin .box form .box textarea, #forums #content .thin .box form .box textarea,
#forums #quickpost{height:200px} #forums #quickpost{height:200px}
#torrents #content .center .box form div, #torrents #content .center .box form div,
#wiki #content .center .box form div, #wiki #content .center .box form div,
#artist #content .center .box form div{text-align:left !important} #artist #content .center .box form div{text-align:left !important}
/* PROFILE PAGE */ /* PROFILE PAGE */
@ -350,10 +350,10 @@ table tr.colhead_dark td{background:#555; border:0}
.box table{margin:0; background-color:#FFF} .box table{margin:0; background-color:#FFF}
#discog_table, #collage_table{margin-top:1px} #discog_table, #collage_table{margin-top:1px}
.sidebar form br, .sidebar form br,
.sidebar .pad br{line-height:1em} .sidebar .pad br{line-height:1em}
.main_column .body, .main_column .body,
.sidebar .box .body{/*ADD TAG ON ALBUM PAGE */ padding:10px} .sidebar .box .body{/*ADD TAG ON ALBUM PAGE */ padding:10px}
.sidebar .box .stats{list-style:none; margin:0; padding:10px} .sidebar .box .stats{list-style:none; margin:0; padding:10px}
@ -448,11 +448,11 @@ h3{margin:10px 0}
#user #userform{padding:20px 0 0 0} #user #userform{padding:20px 0 0 0}
#user .linkbox, #user .linkbox,
#artist .linkbox, #artist .linkbox,
#collage .linkbox, #collage .linkbox,
#forums .linkbox, #forums .linkbox,
#bookmarks .linkbox, #bookmarks .linkbox,
#torrents .linkbox{border-bottom:0} #torrents .linkbox{border-bottom:0}
#rules #content li{margin:0 0 5px 0} #rules #content li{margin:0 0 5px 0}
@ -466,12 +466,6 @@ h3{margin:10px 0}
.cats_comedy{width:30px; height:30px; background:url(https://what.cd/static/styles/minimal/images/icons/comedy.png) top left no-repeat} .cats_comedy{width:30px; height:30px; background:url(https://what.cd/static/styles/minimal/images/icons/comedy.png) top left no-repeat}
.cats_comics{width:30px; height:30px; background:url(https://what.cd/static/styles/minimal/images/icons/comics.png) top left no-repeat} .cats_comics{width:30px; height:30px; background:url(https://what.cd/static/styles/minimal/images/icons/comics.png) top left no-repeat}
.linkbox .brackets:before { .linkbox .brackets:before, .linkbox .brackets:after {
content: "[ ";
color: #757575;
}
.linkbox .brackets:after {
content: " ]";
color: #757575; color: #757575;
} }

View File

@ -489,6 +489,8 @@ table tr td.edition_info {
position:absolute; position:absolute;
top:0; top:0;
left:734px; left:734px;
right:0;
width: 300px;
} }
#artist #content .linkbox:first-of-type a { #artist #content .linkbox:first-of-type a {
margin-right:5px; margin-right:5px;