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 $Levels = 0;
/**
@ -98,7 +98,7 @@ public function __construct ($TOC = false) {
reset($this->Smileys);
}
/**
/**
* Output BBCode as XHTML
* @param string $Str BBCode text
* @param bool $OutputTOC Ouput TOC near (above) text
@ -434,9 +434,9 @@ private function parse ($Str) {
case 'tex':
$Array[$ArrayPos] = array('Type'=>'tex', 'Val'=>$Block);
break;
case 'rule':
$Array[$ArrayPos] = array('Type'=>'rule', 'Val'=>$Block);
break;
case 'rule':
$Array[$ArrayPos] = array('Type'=>'rule', 'Val'=>$Block);
break;
case 'pre':
case 'code':
case 'plain':
@ -529,10 +529,10 @@ public function parse_toc ($Min = 3)
/**
* 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
*
* 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
* - Open appropriate sub lists
*
@ -584,7 +584,7 @@ private function to_html ($Array) {
$Str.='<em>'.$this->to_html($Block['Val'])."</em>";
break;
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;
case 'important':
$Str.='<strong class="important_text">'.$this->to_html($Block['Val']).'</strong>';
@ -595,13 +595,13 @@ private function to_html ($Array) {
case 'artist':
$Str.='<a href="artist.php?artistname='.urlencode(Format::undisplay_str($Block['Val'])).'">'.$Block['Val'].'</a>';
break;
case 'rule':
$Rule = trim(strtolower($Block['Val']));
if($Rule[0] != 'r' && $Rule[0] != 'h') {
$Rule = 'r'.$Rule;
}
$Str.='<a href="rules.php?p=upload#'.urlencode(Format::undisplay_str($Rule)).'">'.preg_replace('/[aA-zZ]/', '', $Block['Val']).'</a>';
break;
case 'rule':
$Rule = trim(strtolower($Block['Val']));
if($Rule[0] != 'r' && $Rule[0] != 'h') {
$Rule = 'r'.$Rule;
}
$Str.='<a href="rules.php?p=upload#'.urlencode(Format::undisplay_str($Rule)).'">'.preg_replace('/[aA-zZ]/', '', $Block['Val']).'</a>';
break;
case 'torrent':
$Pattern = '/('.NONSSL_SITE_URL.'\/torrents\.php.*[\?&]id=)?(\d+)($|&|\#).*/i';
$Matches = array();
@ -635,7 +635,7 @@ private function to_html ($Array) {
$Str.='<code>'.$Block['Val'].'</code>';
break;
case 'list':
$Str .= '<'.$Block['ListType'].'>';
$Str.='<'.$Block['ListType'].'>';
foreach($Block['Val'] as $Line) {
$Str.='<li>'.$this->to_html($Line).'</li>';
@ -686,13 +686,13 @@ private function to_html ($Array) {
$this->InQuotes++;
if(!empty($Block['Attr'])) {
$Exploded = explode("|", $this->to_html($Block['Attr']));
if(isset($Exploded[1]) && is_numeric($Exploded[1])) {
if(isset($Exploded[1]) && is_numeric($Exploded[1])) {
$PostID = trim($Exploded[1]);
$Str.= '<a href="#" onclick="QuoteJump(event, '.$PostID.'); return false;"><strong class="quoteheader">'.$Exploded[0].'</strong> wrote: </a>';
$Str.='<a href="#" onclick="QuoteJump(event, '.$PostID.'); return false;"><strong class="quoteheader">'.$Exploded[0].'</strong> wrote: </a>';
}
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>';
$this->NoImg--;
@ -710,11 +710,11 @@ private function to_html ($Array) {
$Str.='<blockquote class="hidden spoiler">'.$this->to_html($Block['Val']).'</blockquote>';
}
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 {
$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;
case 'img':

View File

@ -49,17 +49,17 @@ class TEXT_2 {
':wtf:' => 'wtf.gif',
':wub:' => 'wub.gif',
);
private $NoImg = 0; // If images should be turned into URLs
private $Levels = 0; // If images should be turned into URLs
function __construct() {
foreach($this->Smileys as $Key=>$Val) {
$this->Smileys[$Key] = '<img border="0" src="'.STATIC_SERVER.'common/smileys/'.$Val.'" alt="" />';
}
reset($this->Smileys);
}
function full_format($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.')http(s)?:\/\//i', '$1[inlineurl]http$2://', $Str);
// 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]);');
$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=5]$1[/inlinesize]', $Str);
$Str = preg_replace('/\=\=([^=].*)\=\=/i', '[inlinesize=7]$1[/inlinesize]', $Str);
$Str = $this->parse($Str);
$HTML = $this->to_html($Str);
$HTML = nl2br($HTML);
return $HTML;
}
function strip_bbcode($Str) {
$Str = display_str($Str);
//Inline links
$Str = preg_replace('/(?<!(\[url\]|\[url\=|\[img\=|\[img\]))http(s)?:\/\//i', '$1[inlineurl]http$2://', $Str);
$Str = $this->parse($Str);
$Str = $this->raw_text($Str);
$Str = nl2br($Str);
return $Str;
}
function valid_url($Str, $Extension = '', $Inline = false) {
$Regex = '/^';
$Regex .= '(https?|ftps?|irc):\/\/'; // protocol
@ -123,10 +123,10 @@ function valid_url($Str, $Extension = '', $Inline = false) {
$Regex .= '(#[a-z0-9\-_.,%\/\@[\]~&=:;()+*\^$!]*)?'; // #anchor
$Regex .= '$/i';
return preg_match($Regex, $Str, $Matches);
}
function local_url($Str) {
$URLInfo = parse_url($Str);
if(!$URLInfo) { return false; }
@ -145,15 +145,15 @@ function local_url($Str) {
} else {
return false;
}
}
/* 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.
This is all done in a loop.
This is all done in a loop.
EXPLANATION OF PARSER LOGIC
@ -173,14 +173,14 @@ function local_url($Str) {
[quote=joe]I am a redneck!**[/quote]
Me too!
***[/quote]
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
a loop which checks the number of opening [quote] tags, and make sure
they are all closed before we find our final [/quote] tag (***).
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
a loop which checks the number of opening [quote] tags, and make sure
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.
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.
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)
@ -194,7 +194,7 @@ function parse($Str) {
while($i<$Len) {
$Block = '';
// 1) Find and parse the next tag (regex)
// [name=|[name]|[[wiki-link]]
$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:
$WikiLink = false;
$TagName = strtolower(substr($Tag[2][0], 1));
$MaxAttribs = $this->ValidTags[$TagName];
// 1bi) check it against the $this->ValidTags array to see if it's actually a tag and not [bullshit]
if(!isset($this->ValidTags[$TagName])) {
$IsTag = 0;
@ -251,39 +251,39 @@ function parse($Str) {
++$ArrayPos;
continue;
}
}
// 2) If there aren't any tags left, write everything remaining to a block
if(!$IsTag) {
// No more tags
$Array[$ArrayPos] = substr($Str, $i);
break;
}
// 3) If the next tag isn't where the pointer is, write everything up to there to a text block.
if($TagPos>$i) {
$Array[$ArrayPos] = substr($Str, $i, $TagPos-$i);
++$ArrayPos;
$i=$TagPos;
}
// 4) Move the pointer past the end of the tag
$i=$TagPos+strlen($Tag[0][0])+$ExtraTagLen;
// 5) Find out where the tag closes (beginning of [/tag])
// Unfortunately, BBCode doesn't have nice standards like xhtml
// [*], [img=...], and http:// follow different formats
// 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 [*]
if($TagName == 'img' && $HasAttrib) { //[img=...]
$Block = ''; // Nothing inside this tag
// Don't need to touch $i
} 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
$CloseTag = strcspn($Str, " \n\r", $i);
if($CloseTag === false) { // block finishes with URL
@ -298,11 +298,11 @@ function parse($Str) {
$URL = substr($URL, 0, -1);
}
$Block = $URL; // Get the URL
// 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
$i += $CloseTag; // 5d) Move the pointer past the end of the [/close] tag.
} elseif($WikiLink == true || $TagName == 'n') {
$i += $CloseTag; // 5d) Move the pointer past the end of the [/close] tag.
} elseif($WikiLink == true || $TagName == 'n') {
// Don't need to do anything - empty tag with no closing
} elseif($TagName == '*') {
// We're in a list. Find where it ends
@ -310,28 +310,28 @@ function parse($Str) {
do { // Look for \n[*]
$NewLine = strpos($Str, "\n", $NewLine+1);
} while($NewLine!== false && substr($Str, $NewLine+1, 3) == '[*]');
$CloseTag = $NewLine;
if($CloseTag === false) { // block finishes with list
$CloseTag = $Len;
}
$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 {
//5b) If it's a normal tag, it may have versions of itself nested inside
$CloseTag = $i-1;
$InTagPos = $i-1;
$NumInOpens = 0;
$NumInCloses = -1;
$InOpenRegex = '/\[('.$TagName.')';
if($MaxAttribs>0) {
$InOpenRegex.="(=[^\n'\"\[\]]+)?";
}
$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)
do {
$CloseTag = stripos($Str, '[/'.$TagName.']', $CloseTag+1);
@ -341,7 +341,7 @@ function parse($Str) {
} else {
$NumInCloses++; // Majority of cases
}
// Is there another open tag inside this one?
$OpenTag = preg_match($InOpenRegex, $Str, $InTag, PREG_OFFSET_CAPTURE, $InTagPos+1);
if(!$OpenTag || $InTag[0][1]>$CloseTag) {
@ -350,17 +350,17 @@ function parse($Str) {
$InTagPos = $InTag[0][1];
$NumInOpens++;
}
} while($NumInOpens>$NumInCloses);
// 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.
$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.
switch($TagName) {
case 'inlineurl':
@ -408,7 +408,7 @@ function parse($Str) {
$Block = preg_replace('/\[inlinesize\=3\](.*?)\[\/inlinesize\]/i', '====$1====', $Block);
$Block = preg_replace('/\[inlinesize\=5\](.*?)\[\/inlinesize\]/i', '===$1===', $Block);
$Block = preg_replace('/\[inlinesize\=7\](.*?)\[\/inlinesize\]/i', '==$1==', $Block);
$Array[$ArrayPos] = array('Type'=>$TagName, 'Val'=>$Block);
break;
case 'hide':
@ -427,27 +427,27 @@ function parse($Str) {
default:
if($WikiLink == true) {
$Array[$ArrayPos] = array('Type'=>'wiki','Val'=>$TagName);
} else {
} else {
// Basic tags, like [b] or [size=5]
$Array[$ArrayPos] = array('Type'=>$TagName, 'Val'=>$this->parse($Block));
if(!empty($Attrib) && $MaxAttribs>0) {
$Array[$ArrayPos]['Attr'] = strtolower($Attrib);
}
}
}
$ArrayPos++; // 7) Increment array pointer, start again (past the end of the [/close] tag)
}
return $Array;
}
function to_html($Array) {
$this->Levels++;
if($this->Levels>10) { return $Block['Val']; } // Hax prevention
$Str = '';
foreach($Array as $Block) {
if(is_string($Block)) {
$Str.=$this->smileys($Block);
@ -488,9 +488,9 @@ function to_html($Array) {
$Str.='<code>'.$Block['Val'].'</code>';
break;
case 'list':
$Str .= '<ul>';
$Str.='<ul>';
foreach($Block['Val'] as $Line) {
$Str.='<li>'.$this->to_html($Line).'</li>';
}
$Str.='</ul>';
@ -506,7 +506,7 @@ function to_html($Array) {
case 'color':
case 'colour':
$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]';
} else {
$Str.='<span style="color:'.$Block['Attr'].'">'.$this->to_html($Block['Val']).'</span>';
@ -524,7 +524,7 @@ function to_html($Array) {
case 'quote':
$this->NoImg++; // No images inside quote tags
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>';
$this->NoImg--;
@ -542,13 +542,13 @@ function to_html($Array) {
$Str.='[img]'.$Block['Val'].'[/img]';
} else {
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 {
$Str.='<img style="max-width: 500px;" onclick="lightbox.init(this,500);" alt="'.$Block['Val'].'" src="'.$Block['Val'].'" />';
}
}
break;
case 'aud':
if($this->NoImg>0 && $this->valid_url($Block['Val'])) {
$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>';
}
break;
case 'url':
// Make sure the URL has a label
if(empty($Block['Val'])) {
@ -571,7 +571,7 @@ function to_html($Array) {
$Block['Val'] = $this->to_html($Block['Val']);
$NoName = false;
}
if(!$this->valid_url($Block['Attr'])) {
$Str.='[url='.$Block['Attr'].']'.$Block['Val'].'[/url]';
} else {
@ -584,23 +584,23 @@ function to_html($Array) {
}
}
break;
case 'inlineurl':
if(!$this->valid_url($Block['Attr'], '', true)) {
$Array = $this->parse($Block['Attr']);
$Block['Attr'] = $Array;
$Str.=$this->to_html($Block['Attr']);
}
else {
$LocalURL = $this->local_url($Block['Attr']);
if($LocalURL) {
$Str.='<a href="'.$LocalURL.'">'.substr($LocalURL,1).'</a>';
} else {
$Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Attr'].'">'.$Block['Attr'].'</a>';
}
}
}
break;
}
@ -608,7 +608,7 @@ function to_html($Array) {
$this->Levels--;
return $Str;
}
function raw_text($Array) {
$Str = '';
foreach($Array as $Block) {
@ -617,7 +617,7 @@ function raw_text($Array) {
continue;
}
switch($Block['Type']) {
case 'b':
case 'u':
case 'i':
@ -645,7 +645,7 @@ function raw_text($Array) {
$Str.='*'.$this->raw_text($Line);
}
break;
case 'url':
// Make sure the URL has a label
if(empty($Block['Val'])) {
@ -653,10 +653,10 @@ function raw_text($Array) {
} else {
$Block['Val'] = $this->raw_text($Block['Val']);
}
$Str.=$Block['Val'];
break;
case 'inlineurl':
if(!$this->valid_url($Block['Attr'], '', true)) {
$Array = $this->parse($Block['Attr']);
@ -666,13 +666,13 @@ function raw_text($Array) {
else {
$Str.=$Block['Attr'];
}
break;
}
}
return $Str;
}
function smileys($Str) {
global $LoggedUser;
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 check_perms($Perm) {return true;}
$Str = "hello
$Str = "hello
[pre]http://anonym.to/?http://whatshirts.portmerch.com/
====hi====
===hi===

View File

@ -46,51 +46,51 @@ class TEXT_3 {
':wtf:' => 'wtf.gif',
':wub:' => 'wub.gif'
);
private $NoImg = 0; // If images should be turned into URLs
private $Levels = 0; // If images should be turned into URLs
function __construct() {
foreach($this->Smileys as $Key=>$Val) {
$this->Smileys[$Key] = '<img border="0" src="'.STATIC_SERVER.'common/smileys/'.$Val.'" alt="" />';
}
reset($this->Smileys);
}
function full_format($Str) {
$Str = display_str($Str);
//Inline links
$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
$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=5]$1[/inlinesize]', $Str);
$Str = preg_replace('/\=\=([^=].*)\=\=/i', '[inlinesize=7]$1[/inlinesize]', $Str);
$Str = $this->parse($Str);
$HTML = $this->to_html($Str);
$HTML = nl2br($HTML);
return $HTML;
}
function strip_bbcode($Str) {
$Str = display_str($Str);
//Inline links
$Str = preg_replace('/(?<!(\[url\]|\[url\=|\[img\=|\[img\]))http(s)?:\/\//i', '$1[inlineurl]http$2://', $Str);
$Str = $this->parse($Str);
$Str = $this->raw_text($Str);
$Str = nl2br($Str);
return $Str;
}
function valid_url($Str, $Extension = '', $Inline = false) {
$Regex = '/^';
$Regex .= '(https?|ftps?|irc):\/\/'; // protocol
@ -115,10 +115,10 @@ function valid_url($Str, $Extension = '', $Inline = false) {
$Regex .= '(#[a-z0-9\-_.,%\/\@[\]~&=:;()+*\^$!]*)?'; // #anchor
$Regex .= '$/i';
return preg_match($Regex, $Str, $Matches);
}
function local_url($Str) {
$URLInfo = parse_url($Str);
if(!$URLInfo) { return false; }
@ -137,15 +137,15 @@ function local_url($Str) {
} else {
return false;
}
}
/* 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.
This is all done in a loop.
This is all done in a loop.
EXPLANATION OF PARSER LOGIC
@ -165,14 +165,14 @@ function local_url($Str) {
[quote=joe]I am a redneck!**[/quote]
Me too!
***[/quote]
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
a loop which checks the number of opening [quote] tags, and make sure
they are all closed before we find our final [/quote] tag (***).
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
a loop which checks the number of opening [quote] tags, and make sure
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.
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.
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)
@ -183,21 +183,21 @@ function parse($Str) {
$Len = strlen($Str);
$Array = array();
$ArrayPos = 0;
while($i<$Len) {
$Block = '';
// 1) Find the next tag (regex)
// [name(=attribute)?]|[[wiki-link]]
$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
if(!$IsTag) {
// No more tags
$Array[$ArrayPos] = substr($Str, $i);
break;
}
// 1b) If the next tag isn't where the pointer is, write everything up to there to a text block.
$TagPos = $Tag[0][1];
if($TagPos>$i) {
@ -205,7 +205,7 @@ function parse($Str) {
++$ArrayPos;
$i=$TagPos;
}
// 2) See if it's a [[wiki-link]] or an ordinary tag, and get the tag name
if(!empty($Tag[4][0])) { // Wiki-link
$WikiLink = true;
@ -214,7 +214,7 @@ function parse($Str) {
} else { // 3) If it's not a wiki link:
$WikiLink = false;
$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]
if(!isset($this->ValidTags[$TagName])) {
$Array[$ArrayPos] = substr($Str, $i, ($TagPos-$i)+strlen($Tag[0][0]));
@ -222,9 +222,9 @@ function parse($Str) {
++$ArrayPos;
continue;
}
$MaxAttribs = $this->ValidTags[$TagName];
// 3b) Get the attribute, if it exists [name=attribute]
if(!empty($Tag[3][0])) {
$Attrib = substr($Tag[3][0], 1);
@ -232,23 +232,23 @@ function parse($Str) {
$Attrib='';
}
}
// 4) Move the pointer past the end of the tag
$i=$TagPos+strlen($Tag[0][0]);
// 5) Find out where the tag closes (beginning of [/tag])
// Unfortunately, BBCode doesn't have nice standards like xhtml
// [*], [img=...], and http:// follow different formats
// 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 [*]
if($TagName == 'img' && !empty($Tag[3][0])) { //[img=...]
$Block = ''; // Nothing inside this tag
// Don't need to touch $i
} 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
$CloseTag = strcspn($Str, " \n\r", $i);
if($CloseTag === false) { // block finishes with URL
@ -263,11 +263,11 @@ function parse($Str) {
$URL = substr($URL, 0, -1);
}
$Block = $URL; // Get the URL
// 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
$i += $CloseTag; // 5d) Move the pointer past the end of the [/close] tag.
} elseif($WikiLink == true || $TagName == 'n') {
$i += $CloseTag; // 5d) Move the pointer past the end of the [/close] tag.
} elseif($WikiLink == true || $TagName == 'n') {
// Don't need to do anything - empty tag with no closing
} elseif($TagName == '*') {
// We're in a list. Find where it ends
@ -275,28 +275,28 @@ function parse($Str) {
do { // Look for \n[*]
$NewLine = strpos($Str, "\n", $NewLine+1);
} while($NewLine!== false && substr($Str, $NewLine+1, 3) == '[*]');
$CloseTag = $NewLine;
if($CloseTag === false) { // block finishes with list
$CloseTag = $Len;
}
$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 {
//5b) If it's a normal tag, it may have versions of itself nested inside
$CloseTag = $i-1;
$InTagPos = $i-1;
$NumInOpens = 0;
$NumInCloses = -1;
$InOpenRegex = '/\[('.$TagName.')';
if($MaxAttribs>0) {
$InOpenRegex.="(=[^\n'\"\[\]]+)?";
}
$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)
do {
$CloseTag = stripos($Str, '[/'.$TagName.']', $CloseTag+1);
@ -306,7 +306,7 @@ function parse($Str) {
} else {
$NumInCloses++; // Majority of cases
}
// Is there another open tag inside this one?
$OpenTag = preg_match($InOpenRegex, $Str, $InTag, PREG_OFFSET_CAPTURE, $InTagPos+1);
if(!$OpenTag || $InTag[0][1]>$CloseTag) {
@ -315,17 +315,17 @@ function parse($Str) {
$InTagPos = $InTag[0][1];
$NumInOpens++;
}
} while($NumInOpens>$NumInCloses);
// 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.
$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.
switch($TagName) {
case 'inlineurl':
@ -372,7 +372,7 @@ function parse($Str) {
$Block = preg_replace('/\[inlinesize\=3\](.*?)\[\/inlinesize\]/i', '====$1====', $Block);
$Block = preg_replace('/\[inlinesize\=5\](.*?)\[\/inlinesize\]/i', '===$1===', $Block);
$Block = preg_replace('/\[inlinesize\=7\](.*?)\[\/inlinesize\]/i', '==$1==', $Block);
$Array[$ArrayPos] = array('Type'=>$TagName, 'Val'=>$Block);
break;
case 'hide':
@ -391,27 +391,27 @@ function parse($Str) {
default:
if($WikiLink == true) {
$Array[$ArrayPos] = array('Type'=>'wiki','Val'=>$TagName);
} else {
} else {
// Basic tags, like [b] or [size=5]
$Array[$ArrayPos] = array('Type'=>$TagName, 'Val'=>$this->parse($Block));
if(!empty($Attrib) && $MaxAttribs>0) {
$Array[$ArrayPos]['Attr'] = strtolower($Attrib);
}
}
}
$ArrayPos++; // 7) Increment array pointer, start again (past the end of the [/close] tag)
}
return $Array;
}
function to_html($Array) {
$this->Levels++;
if($this->Levels>10) { return $Block['Val']; } // Hax prevention
$Str = '';
foreach($Array as $Block) {
if(is_string($Block)) {
$Str.=$this->smileys($Block);
@ -449,9 +449,9 @@ function to_html($Array) {
$Str.='<pre>'.$Block['Val'].'</pre>';
break;
case 'list':
$Str .= '<ul>';
$Str.='<ul>';
foreach($Block['Val'] as $Line) {
$Str.='<li>'.$this->to_html($Line).'</li>';
}
$Str.='</ul>';
@ -467,7 +467,7 @@ function to_html($Array) {
case 'color':
case 'colour':
$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]';
} else {
$Str.='<span style="color:'.$Block['Attr'].'">'.$this->to_html($Block['Val']).'</span>';
@ -485,7 +485,7 @@ function to_html($Array) {
case 'quote':
$this->NoImg++; // No images inside quote tags
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>';
$this->NoImg--;
@ -509,7 +509,7 @@ function to_html($Array) {
}
}
break;
case 'aud':
if($this->NoImg>0 && $this->valid_url($Block['Val'])) {
$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>';
}
break;
case 'url':
// Make sure the URL has a label
if(empty($Block['Val'])) {
@ -532,7 +532,7 @@ function to_html($Array) {
$Block['Val'] = $this->to_html($Block['Val']);
$NoName = false;
}
if(!$this->valid_url($Block['Attr'])) {
$Str.='[url='.$Block['Attr'].']'.$Block['Val'].'[/url]';
} else {
@ -545,23 +545,23 @@ function to_html($Array) {
}
}
break;
case 'inlineurl':
if(!$this->valid_url($Block['Attr'], '', true)) {
$Array = $this->parse($Block['Attr']);
$Block['Attr'] = $Array;
$Str.=$this->to_html($Block['Attr']);
}
else {
$LocalURL = $this->local_url($Block['Attr']);
if($LocalURL) {
$Str.='<a href="'.$LocalURL.'">'.substr($LocalURL,1).'</a>';
} else {
$Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Attr'].'">'.$Block['Attr'].'</a>';
}
}
}
break;
}
@ -569,7 +569,7 @@ function to_html($Array) {
$this->Levels--;
return $Str;
}
function raw_text($Array) {
$Str = '';
foreach($Array as $Block) {
@ -578,7 +578,7 @@ function raw_text($Array) {
continue;
}
switch($Block['Type']) {
case 'b':
case 'u':
case 'i':
@ -605,7 +605,7 @@ function raw_text($Array) {
$Str.='*'.$this->raw_text($Line);
}
break;
case 'url':
// Make sure the URL has a label
if(empty($Block['Val'])) {
@ -613,10 +613,10 @@ function raw_text($Array) {
} else {
$Block['Val'] = $this->raw_text($Block['Val']);
}
$Str.=$Block['Val'];
break;
case 'inlineurl':
if(!$this->valid_url($Block['Attr'], '', true)) {
$Array = $this->parse($Block['Attr']);
@ -626,13 +626,13 @@ function raw_text($Array) {
else {
$Str.=$Block['Attr'];
}
break;
}
}
return $Str;
}
function smileys($Str) {
global $LoggedUser;
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 check_perms($Perm) {return true;}
$Str = "hello
$Str = "hello
[pre]http://anonym.to/?http://whatshirts.portmerch.com/
====hi====
===hi===

View File

@ -48,7 +48,11 @@ public static function geoip($IP) {
if (isset($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
return false;
}
@ -126,7 +130,7 @@ public static function lookup_ip($IP) {
*/
public static function display_ip($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;
}
@ -238,7 +242,7 @@ public static function warn_user($UserID, $Duration, $Reason) {
WHERE UserID=\''.db_string($UserID).'\'');
}
}
/**
* Update the notes of a 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)
WHERE UserID=\''.db_string($UserID).'\'');
}
}
?>

View File

@ -223,7 +223,7 @@ function compare($X, $Y){
$DisplayName = $ReleaseTypes[$ReleaseID]."s";
break;
}
if (!empty($LoggedUser['DiscogView']) || (isset($LoggedUser['SortHide']) && array_key_exists($ReleaseType, $LoggedUser['SortHide']) && $LoggedUser['SortHide'][$ReleaseType] == 1)) {
$ToggleStr = " onclick=\"$('.releases_$ReleaseID').show(); return true;\"";
} else {
@ -252,7 +252,7 @@ function compare($X, $Y){
// $Tags array is for the sidebar on the right. Skip compilations and soundtracks.
if ($Group['ReleaseType'] != 7 && $Group['ReleaseType'] != 3) {
foreach($TagList as $Tag) {
foreach($TagList as $Tag) {
if(!isset($Tags[$Tag])) {
$Tags[$Tag] = array('name'=>$Tag, 'count'=>1);
} else {
@ -834,7 +834,6 @@ function compare($X, $Y){
$Cache->cache_value('similar_positions_'.$ArtistID, $SimilarData, 3600*24);
}
?>
<div id="similar_artist_map" class="box">
<div id="flipper_head" class="head">
<a href="#">&uarr;</a>&nbsp;
@ -855,60 +854,55 @@ function compare($X, $Y){
</div>
</div>
<script type="text/javascript">
//<![CDATA[
<script type="text/javascript">//<![CDATA[
var cloudLoaded = false;
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';
document.getElementById('flip_view_2').style.display='block';
document.getElementById('flipper_title').innerHTML = 'Similar Artist Cloud';
document.getElementById('flip_to').innerHTML = ' [Switch to Map]';
if(!cloudLoaded) {
require("static/functions/jquery.js", function () {
require("static/functions/tagcanvas.js", function () {
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;
}
}
else {
document.getElementById('flip_view_1').style.display='block';
document.getElementById('flip_view_2').style.display='none';
document.getElementById('flipper_title').innerHTML = 'Similar Artist Map';
document.getElementById('flip_to').innerHTML = ' [Switch to Cloud]';
}
cloudLoaded = true;
}
}
else {
document.getElementById('flip_view_1').style.display='block';
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
//http://stackoverflow.com/questions/7293344/load-javascript-dynamically
function require(file, callback) {
var script = document.getElementsByTagName('script')[0],
newjs = document.createElement('script');
var script = document.getElementsByTagName('script')[0],
newjs = document.createElement('script');
// IE
newjs.onreadystatechange = function () {
if (newjs.readyState === 'loaded' || newjs.readyState === 'complete') {
newjs.onreadystatechange = null;
callback();
}
};
// others
newjs.onload = function () {
callback();
};
newjs.src = file;
script.parentNode.insertBefore(newjs, script);
// IE
newjs.onreadystatechange = function () {
if (newjs.readyState === 'loaded' || newjs.readyState === 'complete') {
newjs.onreadystatechange = null;
callback();
}
};
// others
newjs.onload = function () {
callback();
};
newjs.src = file;
script.parentNode.insertBefore(newjs, script);
}
//]]>
</script>
@ -1042,7 +1036,7 @@ function require(file, callback) {
<br />
<br />
<? 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
<?=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);
}
$SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
if($Torrent['RemasterTitle'] != $LastRemasterTitle || $Torrent['RemasterYear'] != $LastRemasterYear ||
$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>
<? if (count($TorrentList) > 0) { ?>
<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=edit&amp;type=torrents" class="brackets">Manage Torrents</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>
<? } ?>
</div>
</div>

View File

@ -18,7 +18,7 @@
$Conditions = "WHERE t.UserID = $UserID AND tc.AuthorID != t.UserID AND tc.AddedTime > t.Time";
$Title = 'Comments left on your torrents';
$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 {
$Conditions = "WHERE tc.AuthorID = $UserID";
@ -72,7 +72,7 @@
<?=$OtherLink?>
</div>
<? } ?>
</div>
</div>
<div class="linkbox">
<?=$Pages?>
</div>
@ -87,7 +87,7 @@
} /* end while loop*/ ?>
<div class="linkbox"><?= $Pages; ?></div>
</div>
<?
<?
View::show_footer();

View File

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

View File

@ -36,8 +36,6 @@
$ThreadID = $_GET['threadid'];
}
if (isset($LoggedUser['PostsPerPage'])) {
$PerPage = $LoggedUser['PostsPerPage'];
} else {
@ -165,13 +163,13 @@
<div class="center">
<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="#" 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 id="searchthread" class="hidden center">
<div style="display: inline-block;">
<h3>Search this thread:</h3>
<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>
<td><strong>Search for:</strong></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 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
$Attempts++;
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)."'");
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");
if($DB->record_count() > 0) {
//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
(FromIP, ToIP, Reason) VALUES
('$IP','$IP', 'Automated ban per >60 failed login attempts')");
$A = substr($_SERVER['REMOTE_ADDR'], 0, strcspn($_SERVER['REMOTE_ADDR'], '.'));
$Cache->delete_value('ip_bans_'.$A);
$Cache->delete_value('ip_bans_'.$IPA);
}
}
} else {
@ -216,12 +217,16 @@ function log_attempt($UserID) {
$Attempts=1;
$DB->query("INSERT INTO login_attempts
(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
// If user has submitted form
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);
if(!$Err) {

View File

@ -10,7 +10,7 @@
$Text = new TEXT;
if(empty($_GET['id']) || !is_number($_GET['id'])) {
if(empty($_GET['id']) || !is_number($_GET['id'])) {
error(0);
}
@ -18,7 +18,7 @@
//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];
if(empty($Request)) {
error(404);
@ -42,14 +42,14 @@
$ArtistForm = get_request_artists($RequestID);
$ArtistName = Artists::display_artists($ArtistForm, false, true);
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
if($IsFilled) {
$DisplayLink = $ArtistLink."<a href='torrents.php?torrentid=".$TorrentID."'>".$Title."</a> [".$Year."]";
} else {
$DisplayLink = $ArtistLink.$Title." [".$Year."]";
}
$FullName = $ArtistName.$Title." [".$Year."]";
if($BitrateList != "") {
$BitrateString = implode(", ", explode("|", $BitrateList));
$FormatString = implode(", ", explode("|", $FormatList));
@ -59,13 +59,13 @@
$FormatString = "Unknown, please read the description.";
$MediaString = "Unknown, please read the description.";
}
if(empty($ReleaseType)) {
$ReleaseName = "Unknown";
} else {
$ReleaseName = $ReleaseTypes[$ReleaseType];
}
} else if($CategoryName == "Audiobooks" || $CategoryName == "Comedy") {
$FullName = $Title." [".$Year."]";
$DisplayLink = $Title." [".$Year."]";
@ -88,20 +88,20 @@
<div class="header">
<h2><a href="requests.php">Requests</a> &gt; <?=$CategoryName?> &gt; <?=$DisplayLink?></h2>
<div class="linkbox">
<? if($CanEdit) { ?>
<? if($CanEdit) { ?>
<a href="requests.php?action=edit&amp;id=<?=$RequestID?>" class="brackets">Edit</a>
<? }
if($UserCanEdit || check_perms('users_mod')) { //check_perms('site_moderate_requests')) { ?>
<a href="requests.php?action=delete&amp;id=<?=$RequestID?>" class="brackets">Delete</a>
<? } ?>
<? 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 { ?>
<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>
<? 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))) { ?>
<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>
<? } ?>
</div>
<? }
if($CategoryName == "Music") { ?>
<? }
if($CategoryName == "Music") { ?>
<div class="box box_artists">
<div class="head"><strong>Artists</strong></div>
<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>
<? foreach($ArtistForm[4] as $Artist) {
@ -154,7 +154,7 @@
</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>
<? foreach($ArtistForm[6] as $Artist) {
@ -176,7 +176,7 @@
<?=Artists::display_artist($Artist)?>
</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>
<? foreach($ArtistForm[2] as $Artist) {
@ -186,7 +186,7 @@
</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>
<? foreach($ArtistForm[5] as $Artist) {
@ -196,7 +196,7 @@
</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>
<? 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>
<? foreach($ArtistForm[7] as $Artist) {
@ -238,7 +238,7 @@
<table class="layout">
<? $VoteMax = ($VoteCount < 5 ? $VoteCount : 5);
$ViewerVote = false;
for($i = 0; $i < $VoteMax; $i++) {
for($i = 0; $i < $VoteMax; $i++) {
$User = array_shift($RequestVotes['Voters']);
$Boldify = false;
if ($User['UserID'] == $LoggedUser['ID']) {
@ -254,7 +254,7 @@
<?=$Boldify?'<strong>':''?><?=Format::get_size($User['Bounty'])?><?=$Boldify?'</strong>':''?>
</td>
</tr>
<? }
<? }
reset($RequestVotes['Voters']);
if (!$ViewerVote) {
foreach ($RequestVotes['Voters'] as $User) {
@ -281,7 +281,7 @@
<td>
<?=time_diff($TimeAdded)?> by <strong><?=Users::format_username($RequestorID, false, false, false)?></strong>
</td>
</tr>
</tr>
<? if($CategoryName == "Music") {
if(!empty($RecordLabel)) { ?>
<tr>
@ -290,7 +290,7 @@
<?=$RecordLabel?>
</td>
</tr>
<? }
<? }
if(!empty($CatalogueNumber)) { ?>
<tr>
<td class="label">Catalogue Number</td>
@ -365,11 +365,11 @@
<tr>
<td class="label">Votes</td>
<td>
<span id="votecount"><?=$VoteCount?></span>
<span id="votecount"><?=$VoteCount?></span>
<? if($CanVote) { ?>
&nbsp;<a href="javascript:Vote(0)"><strong>(+)</strong></a>
<strong>Costs <?=Format::get_size($MinimumVote, 0)?></strong>
<? } ?>
<? } ?>
</td>
</tr>
<? if ($LastVote > $TimeAdded) { ?>
@ -379,7 +379,7 @@
<?=time_diff($LastVote)?>
</td>
</tr>
<? } ?>
<? } ?>
<? if($CanVote) { ?>
<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>
@ -414,7 +414,7 @@
</form>
</td>
</tr>
<? }?>
<? }?>
<tr id="bounty">
<td class="label">Bounty</td>
<td id="formatted_bounty"><?=Format::get_size($RequestVotes['TotalBounty'])?></td>
@ -426,10 +426,10 @@
<tr>
<td class="label">Filled</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)?>
<? 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>
</tr>
@ -450,7 +450,7 @@
<br />
<? } ?>
<input type="submit" value="Fill request" />
<br />
<br />
</div>
</form>
</td>
@ -458,7 +458,7 @@
<? } ?>
<?
//<strip>
if(check_perms("users_mod")) {
if(check_perms("users_mod")) {
$RequestLog = Requests::get_request_log($RequestID);
if($RequestLog) {
?>
@ -472,7 +472,7 @@
</div>
</td>
</tr>
<? }
<? }
}
//<strip>
?>
@ -578,7 +578,7 @@
<br />
<br />
<? 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
<?=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');
list($Page,$Limit) = Format::page_limit(REQUESTS_PER_PAGE);
$Submitted = !empty($_GET['submit']);
//Paranoia
//Paranoia
$UserInfo = Users::user_info((int)$_GET['userid']);
$Perms = Permissions::get_permissions($UserInfo['PermissionID']);
$UserClass = $Perms['Class'];
$BookmarkView = false;
if(empty($_GET['type'])) {
if(empty($_GET['type'])) {
$Title = 'Requests';
if(!check_perms('site_see_old_requests') || empty($_GET['showall'])) {
$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"<? } ?> />
</td>
</tr>
<? if(check_perms('site_see_old_requests')){ ?>
<? if(check_perms('site_see_old_requests')){ ?>
<tr id="include_old">
<td class="label">Include old:</td>
<td>
<input type="checkbox" name="showall" <? if(!empty($_GET['showall'])) {?>checked="checked"<? } ?> />
</td>
</tr>
<? /* ?>
<? /* ?>
<tr>
<td class="label">Requested by:</td>
<td>
@ -404,7 +404,7 @@
</table>
<table class="layout">
<tr id="release_list">
<td class="label">Release Types</td>
<td class="label">Release types</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>
<? $i = 0;
@ -431,7 +431,7 @@
/> <label for="format_<?=$Key?>"><?=$Val?></label>
<? }?>
</td>
</tr>
</tr>
<tr id="bitrate_list">
<td class="label">Bitrates</td>
<td>
@ -467,7 +467,7 @@
<input type="submit" value="Search requests" />
</td>
</tr>
</table>
</table>
</form>
<div class="linkbox">
<? if (!$BookmarkView) {
@ -495,7 +495,7 @@
<table id="request_table" class="request_table border" cellpadding="6" cellspacing="1" border="0" width="100%">
<tr class="colhead_dark">
<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 class="nobr">
<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>
</td>
<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>
</tr>
<? if($NumResults == 0) { ?>
@ -560,26 +560,26 @@
$Row = 'a';
$TimeCompare = 1267643718; // Requests v2 was implemented 2010-03-03 20:15:18
foreach ($Requests as $RequestID => $Request) {
//list($BitrateList, $CatalogueNumber, $CategoryID, $Description, $FillerID, $FormatList, $RequestID, $Image, $LogCue, $MediaList, $ReleaseType,
// $Tags, $TimeAdded, $TimeFilled, $Title, $TorrentID, $RequestorID, $RequestorName, $Year, $RequestID, $Categoryid, $FillerID, $LastVote,
//list($BitrateList, $CatalogueNumber, $CategoryID, $Description, $FillerID, $FormatList, $RequestID, $Image, $LogCue, $MediaList, $ReleaseType,
// $Tags, $TimeAdded, $TimeFilled, $Title, $TorrentID, $RequestorID, $RequestorName, $Year, $RequestID, $Categoryid, $FillerID, $LastVote,
// $ReleaseType, $TagIDs, $TimeAdded, $TimeFilled, $TorrentID, $RequestorID, $Voters) = array_values($Request);
list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, $RecordLabel,
$ReleaseType, $BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled) = $Request;
$RequestVotes = get_votes_array($RequestID);
$VoteCount = count($RequestVotes['Voters']);
if($CategoryID == 0) {
$CategoryName = "Unknown";
} else {
$CategoryName = $Categories[$CategoryID - 1];
}
$IsFilled = ($TorrentID != 0);
if($CategoryName == "Music") {
$ArtistForm = get_request_artists($RequestID);
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
@ -589,16 +589,16 @@
} else {
$FullName ="<a href='requests.php?action=view&amp;id=".$RequestID."'>".$Title."</a>";
}
$Row = ($Row == 'a') ? 'b' : 'a';
$Tags = $Request['Tags'];
?>
<tr class="row<?=$Row?>">
<td>
<?=$FullName?>
<div class="tags">
<?
<?
$TagList = array();
foreach($Tags as $TagID => $TagName) {
$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;
}
tr.torrent .bookmark > a:before { content:""; }
tr.torrent .bookmark > a:after { content:""; }
tr.torrent .bookmark > a:before { content: ""; }
tr.torrent .bookmark > a:after { content: ""; }
.sidebar .navigation_list li {
margin-left: 20px;
}
.linkbox .brackets:before {
content: "[ ";
color: #757575;
}
.linkbox .brackets:after {
content: " ]";
.linkbox .brackets:before, .linkbox .brackets:after {
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 .forum_post tr,
#userhistory .forum_post tr,
#collage .forum_post tr,
#forums .forum_post tr,
#userhistory .forum_post tr,
#collage .forum_post tr,
#torrents .forum_post tr{border-bottom:1px solid #757575}
#forums .forum_post,
#userhistory .forum_post,
#collage .forum_post,
#forums .forum_post,
#userhistory .forum_post,
#collage .forum_post,
#torrents .forum_post{border:0; margin:0}
.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{margin-bottom:0}
#forums .forum_post .body,
#userhistory .forum_post .body,
#collage .forum_post .body,
#forums .forum_post .body,
#userhistory .forum_post .body,
#collage .forum_post .body,
#torrents .forum_post .body{padding:0; border-left:0}
#forums .forum_post td,
#userhistory .forum_post td,
#collage .forum_post td,
#forums .forum_post td,
#userhistory .forum_post td,
#collage .forum_post td,
#torrents .forum_post td{border-left:0; border-right:0}
#forums .forum_post .body div,
#collage .forum_post .body div,
#forums .forum_post .body div,
#collage .forum_post .body div,
#torrents .forum_post .body div,
#requests .forum_post .body div{padding:10px 15px}
#userhistory .forum_post .body{padding:20px}
#userhistory .forum_post tr.colhead_dark{background-image:none}
#forums .forum_post .body div div,
#collage .forum_post .body div div,
#forums .forum_post .body div div,
#collage .forum_post .body div div,
#torrents .forum_post .body div div{background:none; 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:hover, #torrent_table tr.group_torrent a:hover{color:#007dc6}
#torrents #content .center .box form div input[type="text"],
#wiki #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"],
#artist #content .center .box form div input[type="text"]{width:500px; margin-bottom:10px}
#torrents #content .center .box form div textarea,
#wiki #content .center .box form div textarea,
#upload textarea#album_desc,
#forums #content .thin .box form .box textarea,
#torrents #content .center .box form div textarea,
#wiki #content .center .box form div textarea,
#upload textarea#album_desc,
#forums #content .thin .box form .box textarea,
#forums #quickpost{height:200px}
#torrents #content .center .box form div,
#wiki #content .center .box form div,
#torrents #content .center .box form div,
#wiki #content .center .box form div,
#artist #content .center .box form div{text-align:left !important}
/* PROFILE PAGE */
@ -350,10 +350,10 @@ table tr.colhead_dark td{background:#555; border:0}
.box table{margin:0; background-color:#FFF}
#discog_table, #collage_table{margin-top:1px}
.sidebar form br,
.sidebar form br,
.sidebar .pad br{line-height:1em}
.main_column .body,
.main_column .body,
.sidebar .box .body{/*ADD TAG ON ALBUM PAGE */ 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 .linkbox,
#artist .linkbox,
#collage .linkbox,
#forums .linkbox,
#bookmarks .linkbox,
#user .linkbox,
#artist .linkbox,
#collage .linkbox,
#forums .linkbox,
#bookmarks .linkbox,
#torrents .linkbox{border-bottom: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_comics{width:30px; height:30px; background:url(https://what.cd/static/styles/minimal/images/icons/comics.png) top left no-repeat}
.linkbox .brackets:before {
content: "[ ";
color: #757575;
}
.linkbox .brackets:after {
content: " ]";
.linkbox .brackets:before, .linkbox .brackets:after {
color: #757575;
}

View File

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