mirror of
https://github.com/WhatCD/Gazelle.git
synced 2025-01-18 20:21:37 +00:00
Empty commit
This commit is contained in:
parent
07804af8e4
commit
b7ca8d3cf6
@ -1,45 +0,0 @@
|
|||||||
<?
|
|
||||||
class Collages {
|
|
||||||
public static function get_comment_count($CollageID) {
|
|
||||||
global $DB, $Cache;
|
|
||||||
$NumComments = $Cache->get_value('collage_comments_'.$CollageID);
|
|
||||||
if ($NumComments === false) {
|
|
||||||
$DB->query("SELECT COUNT(ID) FROM collages_comments WHERE CollageID = '$CollageID'");
|
|
||||||
list($NumComments) = $DB->next_record();
|
|
||||||
$Cache->cache_value('collage_comments_'.$CollageID, $NumComments, 0);
|
|
||||||
}
|
|
||||||
return $NumComments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function get_comment_catalogue($CollageID, $CatalogueID) {
|
|
||||||
global $DB, $Cache;
|
|
||||||
$Catalogue = $Cache->get_value('collage_comments_'.$CollageID.'_catalogue_'.$CatalogueID);
|
|
||||||
if ($Catalogue === false) {
|
|
||||||
$CatalogueLimit = $CatalogueID * THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
|
|
||||||
$DB->query("
|
|
||||||
SELECT
|
|
||||||
ID,
|
|
||||||
UserID,
|
|
||||||
Time,
|
|
||||||
Body
|
|
||||||
FROM collages_comments
|
|
||||||
WHERE CollageID = '$CollageID'
|
|
||||||
LIMIT $CatalogueLimit");
|
|
||||||
$Catalogue = $DB->to_array(false, MYSQLI_ASSOC);
|
|
||||||
$Cache->cache_value('collage_comments_'.$CollageID.'_catalogue_'.$CatalogueID, $Catalogue, 0);
|
|
||||||
}
|
|
||||||
return $Catalogue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function increase_subscriptions($CollageID) {
|
|
||||||
global $DB;
|
|
||||||
$DB->query("UPDATE collages SET Subscribers = Subscribers + 1 WHERE ID = '$CollageID'");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function decrease_subscriptions($CollageID) {
|
|
||||||
global $DB;
|
|
||||||
$DB->query("UPDATE collages SET Subscribers = IF(Subscribers < 1, 0, Subscribers - 1) WHERE ID = '$CollageID'");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
class Reports {
|
|
||||||
/**
|
|
||||||
* This function formats a string containing a torrent's remaster information
|
|
||||||
* to be used in Reports v2.
|
|
||||||
*
|
|
||||||
* @param boolean $Remastered - whether the torrent contains remaster information
|
|
||||||
* @param string $RemasterTitle - the title of the remaster information
|
|
||||||
* @param string $RemasterYear - the year of the remaster information
|
|
||||||
*/
|
|
||||||
public static function format_reports_remaster_info($Remastered, $RemasterTitle, $RemasterYear) {
|
|
||||||
if ($Remastered) {
|
|
||||||
$RemasterDisplayString = ' <';
|
|
||||||
if ($RemasterTitle != '' && $RemasterYear != '') {
|
|
||||||
$RemasterDisplayString .= "$RemasterTitle - $RemasterYear";
|
|
||||||
} else if ($RemasterTitle != '' && $RemasterYear == '') {
|
|
||||||
$RemasterDisplayString .= $RemasterTitle;
|
|
||||||
} else if ($RemasterTitle == '' && $RemasterYear != '') {
|
|
||||||
$RemasterDisplayString .= $RemasterYear;
|
|
||||||
}
|
|
||||||
$RemasterDisplayString .= '>';
|
|
||||||
} else {
|
|
||||||
$RemasterDisplayString = '';
|
|
||||||
}
|
|
||||||
return $RemasterDisplayString;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,700 +0,0 @@
|
|||||||
<?
|
|
||||||
class TEXT_2 {
|
|
||||||
// tag=>max number of attributes
|
|
||||||
private $ValidTags = array('b'=>0, 'u'=>0, 'i'=>0, 's'=>0, '*'=>0, 'artist'=>0, 'user'=>0, 'n'=>0, 'inlineurl'=>0, 'inlinesize'=>1, 'align'=>1, 'color'=>1, 'colour'=>1, 'size'=>1, 'url'=>1, 'img'=>1, 'quote'=>1, 'pre'=>1, 'code'=>1, 'tex'=>0, 'hide'=>1, 'plain'=>0
|
|
||||||
);
|
|
||||||
private $Smileys = array(
|
|
||||||
':angry:' => 'angry.gif',
|
|
||||||
':-D' => 'biggrin.gif',
|
|
||||||
':D' => 'biggrin.gif',
|
|
||||||
':|' => 'blank.gif',
|
|
||||||
':-|' => 'blank.gif',
|
|
||||||
':blush:' => 'blush.gif',
|
|
||||||
':cool:' => 'cool.gif',
|
|
||||||
':'(' => 'crying.gif',
|
|
||||||
':crying:' => 'crying.gif',
|
|
||||||
'>.>' => 'eyesright.gif',
|
|
||||||
':frown:' => 'frown.gif',
|
|
||||||
'<3' => 'heart.gif',
|
|
||||||
':unsure:' => 'hmm.gif',
|
|
||||||
':\\' => 'hmm.gif',
|
|
||||||
':whatlove:' => 'ilu.gif',
|
|
||||||
':lol:' => 'laughing.gif',
|
|
||||||
':loveflac:' => 'loveflac.gif',
|
|
||||||
':ninja:' => 'ninja.gif',
|
|
||||||
':no:' => 'no.gif',
|
|
||||||
':nod:' => 'nod.gif',
|
|
||||||
':ohno:' => 'ohnoes.gif',
|
|
||||||
':ohnoes:' => 'ohnoes.gif',
|
|
||||||
':omg:' => 'omg.gif',
|
|
||||||
':o' => 'ohshit.gif',
|
|
||||||
':O' => 'ohshit.gif',
|
|
||||||
':paddle:' => 'paddle.gif',
|
|
||||||
':(' => 'sad.gif',
|
|
||||||
':-(' => 'sad.gif',
|
|
||||||
':shifty:' => 'shifty.gif',
|
|
||||||
':sick:' => 'sick.gif',
|
|
||||||
':)' => 'smile.gif',
|
|
||||||
':-)' => 'smile.gif',
|
|
||||||
':sorry:' => 'sorry.gif',
|
|
||||||
':thanks:' => 'thanks.gif',
|
|
||||||
':P' => 'tongue.gif',
|
|
||||||
':-P' => 'tongue.gif',
|
|
||||||
':-p' => 'tongue.gif',
|
|
||||||
':wave:' => 'wave.gif',
|
|
||||||
';-)' => 'wink.gif',
|
|
||||||
':wink:' => 'wink.gif',
|
|
||||||
':creepy:' => 'creepy.gif',
|
|
||||||
':worried:' => 'worried.gif',
|
|
||||||
':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
|
|
||||||
$URLPrefix = '(\[url\]|\[url\=|\[img\=|\[img\])';
|
|
||||||
$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'));
|
|
||||||
$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
|
|
||||||
$Regex .= '(\w+(:\w+)?@)?'; // user:pass@
|
|
||||||
$Regex .= '(';
|
|
||||||
$Regex .= '(([0-9]{1,3}\.){3}[0-9]{1,3})|'; // IP or...
|
|
||||||
$Regex .= '(([a-z0-9\-\_]+\.)+\w{2,6})'; // sub.sub.sub.host.com
|
|
||||||
$Regex .= ')';
|
|
||||||
$Regex .= '(:[0-9]{1,5})?'; // port
|
|
||||||
$Regex .= '\/?'; // slash?
|
|
||||||
$Regex .= '(\/?[0-9a-z\-_.,&=@~%\/:;()+|!#]+)*'; // /file
|
|
||||||
if (!empty($Extension)) {
|
|
||||||
$Regex.=$Extension;
|
|
||||||
}
|
|
||||||
|
|
||||||
// query string
|
|
||||||
if ($Inline) {
|
|
||||||
$Regex .= '(\?([0-9a-z\-_.,%\/\@~&=:;()+*\^$!#|]|\[\d*\])*)?';
|
|
||||||
} else {
|
|
||||||
$Regex .= '(\?[0-9a-z\-_.,%\/\@[\]~&=:;()+*\^$!#|]*)?';
|
|
||||||
}
|
|
||||||
|
|
||||||
$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; }
|
|
||||||
$Host = $URLInfo['host'];
|
|
||||||
// If for some reason your site does not require subdomains or contains a directory in the SITE_URL, revert to the line below.
|
|
||||||
//if ($Host == NONSSL_SITE_URL || $Host == SSL_SITE_URL || $Host == 'www.'.NONSSL_SITE_URL) {
|
|
||||||
if (preg_match('/(\S+\.)*'.NONSSL_SITE_URL.'/', $Host)) {
|
|
||||||
$URL = $URLInfo['path'];
|
|
||||||
if (!empty($URLInfo['query'])) {
|
|
||||||
$URL.='?'.$URLInfo['query'];
|
|
||||||
}
|
|
||||||
if (!empty($URLInfo['fragment'])) {
|
|
||||||
$URL.='#'.$URLInfo['fragment'];
|
|
||||||
}
|
|
||||||
return $URL;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* How parsing works
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
EXPLANATION OF PARSER LOGIC
|
|
||||||
|
|
||||||
1) Find and parse the next tag (regex)
|
|
||||||
1a) See if it's a [[wiki-link]] or an ordinary tag, and get the tag name
|
|
||||||
1b) If it's not a wiki link:
|
|
||||||
1bi) check it against the $this->ValidTags array to see if it's actually a tag and not [bullshit]
|
|
||||||
1bii) Get the attribute, if it exists [name=attribute]
|
|
||||||
If it's [not a tag] or has an invalid attribute, just leave it as plaintext and move on
|
|
||||||
2) If there aren't any tags left, write everything remaining to a block and return (done parsing)
|
|
||||||
3) If the next tag isn't where the pointer is, write everything up to there to a text block.
|
|
||||||
4) Move the pointer past the end of the tag
|
|
||||||
5) Find out where the tag closes (beginning of [/tag])
|
|
||||||
5a) Different for different types of tag. Some tags don't close, others are weird like [*]
|
|
||||||
5b) If it's a normal tag, it may have versions of itself nested inside - e.g.:
|
|
||||||
[quote=bob]*
|
|
||||||
[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 (***).
|
|
||||||
|
|
||||||
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.
|
|
||||||
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)
|
|
||||||
|
|
||||||
*/
|
|
||||||
function parse($Str) {
|
|
||||||
$i = 0; // Pointer to keep track of where we are in $Str
|
|
||||||
$Len = strlen($Str);
|
|
||||||
$Array = array();
|
|
||||||
$ArrayPos = 0;
|
|
||||||
|
|
||||||
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);
|
|
||||||
$TagPos = $Tag[0][1];
|
|
||||||
// At this point we still don't know whether the tag code is valid
|
|
||||||
// $IsTag will be updated with new information
|
|
||||||
|
|
||||||
// 1a) See if it's a [[wiki-link]] or an ordinary tag, and get the tag name
|
|
||||||
if ($IsTag && !empty($Tag[4][0])) { // Wiki-link
|
|
||||||
$WikiLink = true;
|
|
||||||
$TagName = substr($Tag[4][0], 2, -2);
|
|
||||||
$Attrib = '';
|
|
||||||
$ExtraTagLen = 0;
|
|
||||||
} 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1bii) Get the attribute, if it exists [name=attribute]
|
|
||||||
$HasAttrib = ($Tag[3][0] == '=');
|
|
||||||
if ($IsTag && $HasAttrib) {
|
|
||||||
$AttribFrom = $TagPos + strlen($Tag[0][0]);
|
|
||||||
$Attrib = substr($Str, $AttribFrom, strpos($Str, ']', $AttribFrom) - $AttribFrom);
|
|
||||||
$ExtraTagLen = strlen($Attrib) + 1;
|
|
||||||
// check $Attrib is valid, i.e. the tag is in a valid format
|
|
||||||
// disallowed characters
|
|
||||||
if ((strpos($Attrib, "\n") !== false)
|
|
||||||
|| (strpos($Attrib, "'") !== false)
|
|
||||||
|| (strpos($Attrib, "\"") !== false)) {
|
|
||||||
$IsTag = 0;
|
|
||||||
} elseif (strpos($Attrib, '[') !== false) {
|
|
||||||
// attributes aren't allowed to contain any tag (or something which looks like it might be one) inside them
|
|
||||||
foreach ($this->ValidTags as $PossibleTag=>$_) {
|
|
||||||
if (strpos($Attrib, '['.$PossibleTag) !== false) {
|
|
||||||
$IsTag = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$Attrib = '';
|
|
||||||
$ExtraTagLen = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$IsTag) {
|
|
||||||
// we jump past the beginning of the "tag", but not the attribute value, as this may contain real tags
|
|
||||||
$Array[$ArrayPos] = substr($Str, $i, ($TagPos - $i) + strlen($Tag[0][0]));
|
|
||||||
$i = $TagPos + strlen($Tag[0][0]);
|
|
||||||
++$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
|
|
||||||
$CloseTag = $Len;
|
|
||||||
}
|
|
||||||
if (preg_match('/[!;,.?:]+$/',substr($Str, $i, $CloseTag), $Match)) {
|
|
||||||
$CloseTag -= strlen($Match[0]);
|
|
||||||
}
|
|
||||||
$URL = substr($Str, $i, $CloseTag);
|
|
||||||
if (substr($URL, -1) == ')' && substr_count($URL, '(') < substr_count($URL, ')')) {
|
|
||||||
$CloseTag--;
|
|
||||||
$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') {
|
|
||||||
// Don't need to do anything - empty tag with no closing
|
|
||||||
} elseif ($TagName == '*') {
|
|
||||||
// We're in a list. Find where it ends
|
|
||||||
$NewLine = $i;
|
|
||||||
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.
|
|
||||||
} 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
|
|
||||||
// (as the first close tag won't do - it's been opened again)
|
|
||||||
do {
|
|
||||||
$CloseTag = stripos($Str, '[/'.$TagName.']', $CloseTag+1);
|
|
||||||
if ($CloseTag === false) {
|
|
||||||
$CloseTag = $Len;
|
|
||||||
break;
|
|
||||||
} 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) {
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
$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.
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 6) Depending on what type of tag we're dealing with, create an array with the attribute and block.
|
|
||||||
switch ($TagName) {
|
|
||||||
case 'inlineurl':
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'inlineurl', 'Attr'=>$Block, 'Val'=>'');
|
|
||||||
break;
|
|
||||||
case 'url':
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'img', 'Attr'=>$Attrib, 'Val'=>$Block);
|
|
||||||
if (empty($Attrib)) { // [url]http://...[/url] - always set URL to attribute
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'url', 'Attr'=>$Block, 'Val'=>'');
|
|
||||||
} else {
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'url', 'Attr'=>$Attrib, 'Val'=>$this->parse($Block));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'quote':
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'quote', 'Attr'=>$this->Parse($Attrib), 'Val'=>$this->parse($Block));
|
|
||||||
break;
|
|
||||||
case 'img':
|
|
||||||
case 'image':
|
|
||||||
if (empty($Block)) {
|
|
||||||
$Block = $Attrib;
|
|
||||||
}
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'img', 'Val'=>$Block);
|
|
||||||
break;
|
|
||||||
case 'aud':
|
|
||||||
case 'mp3':
|
|
||||||
case 'audio':
|
|
||||||
if (empty($Block)) {
|
|
||||||
$Block = $Attrib;
|
|
||||||
}
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'aud', 'Val'=>$Block);
|
|
||||||
break;
|
|
||||||
case 'user':
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'user', 'Val'=>$Block);
|
|
||||||
break;
|
|
||||||
case 'artist':
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'artist', 'Val'=>$Block);
|
|
||||||
break;
|
|
||||||
case 'tex':
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'tex', 'Val'=>$Block);
|
|
||||||
break;
|
|
||||||
case 'pre':
|
|
||||||
case 'code':
|
|
||||||
case 'plain':
|
|
||||||
$Block = strtr($Block, array('[inlineurl]'=>''));
|
|
||||||
$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':
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'hide', 'Attr'=>$Attrib, 'Val'=>$this->parse($Block));
|
|
||||||
break;
|
|
||||||
case '*':
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'list');
|
|
||||||
$Array[$ArrayPos]['Val'] = explode('[*]', $Block);
|
|
||||||
foreach ($Array[$ArrayPos]['Val'] as $Key=>$Val) {
|
|
||||||
$Array[$ArrayPos]['Val'][$Key] = $this->parse(trim($Val));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'n':
|
|
||||||
$ArrayPos--;
|
|
||||||
break; // n serves only to disrupt bbcode (backwards compatibility - use [pre])
|
|
||||||
default:
|
|
||||||
if ($WikiLink == true) {
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'wiki','Val'=>$TagName);
|
|
||||||
} 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);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
switch ($Block['Type']) {
|
|
||||||
case 'b':
|
|
||||||
$Str.='<strong>'.$this->to_html($Block['Val']).'</strong>';
|
|
||||||
break;
|
|
||||||
case 'u':
|
|
||||||
$Str.='<span style="text-decoration: underline;">'.$this->to_html($Block['Val']).'</span>';
|
|
||||||
break;
|
|
||||||
case 'i':
|
|
||||||
$Str.='<em>'.$this->to_html($Block['Val'])."</em>";
|
|
||||||
break;
|
|
||||||
case 's':
|
|
||||||
$Str.='<span style="text-decoration: line-through;">'.$this->to_html($Block['Val']).'</span>';
|
|
||||||
break;
|
|
||||||
case 'user':
|
|
||||||
$Str.='<a href="user.php?action=search&search='.urlencode($Block['Val']).'">'.$Block['Val'].'</a>';
|
|
||||||
break;
|
|
||||||
case 'artist':
|
|
||||||
$Str.='<a href="artist.php?artistname='.urlencode(Format::undisplay_str($Block['Val'])).'">'.$Block['Val'].'</a>';
|
|
||||||
break;
|
|
||||||
case 'wiki':
|
|
||||||
$Str.='<a href="wiki.php?action=article&name='.urlencode($Block['Val']).'">'.$Block['Val'].'</a>';
|
|
||||||
break;
|
|
||||||
case 'tex':
|
|
||||||
$Str.='<img style="vertical-align: middle;" src="'.STATIC_SERVER.'blank.gif" onload="if (this.src.substr(this.src.length-9,this.src.length) == \'blank.gif\') { this.src = \'http://chart.apis.google.com/chart?cht=tx&chf=bg,s,FFFFFF00&chl='.urlencode(mb_convert_encoding($Block['Val'],"UTF-8","HTML-ENTITIES")).'&chco=\' + hexify(getComputedStyle(this.parentNode,null).color); }" />';
|
|
||||||
break;
|
|
||||||
case 'plain':
|
|
||||||
$Str.=$Block['Val'];
|
|
||||||
break;
|
|
||||||
case 'pre':
|
|
||||||
$Str.='<pre>'.$Block['Val'].'</pre>';
|
|
||||||
break;
|
|
||||||
case 'code':
|
|
||||||
$Str.='<code>'.$Block['Val'].'</code>';
|
|
||||||
break;
|
|
||||||
case 'list':
|
|
||||||
$Str.='<ul>';
|
|
||||||
foreach ($Block['Val'] as $Line) {
|
|
||||||
|
|
||||||
$Str.='<li>'.$this->to_html($Line).'</li>';
|
|
||||||
}
|
|
||||||
$Str.='</ul>';
|
|
||||||
break;
|
|
||||||
case 'align':
|
|
||||||
$ValidAttribs = array('left', 'center', 'right');
|
|
||||||
if (!in_array($Block['Attr'], $ValidAttribs)) {
|
|
||||||
$Str.='[align='.$Block['Attr'].']'.$this->to_html($Block['Val']).'[/align]';
|
|
||||||
} else {
|
|
||||||
$Str.='<div style="text-align: '.$Block['Attr'].';">'.$this->to_html($Block['Val']).'</div>';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
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'])) {
|
|
||||||
$Str.='[color='.$Block['Attr'].']'.$this->to_html($Block['Val']).'[/color]';
|
|
||||||
} else {
|
|
||||||
$Str.='<span style="color: '.$Block['Attr'].';">'.$this->to_html($Block['Val']).'</span>';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'inlinesize':
|
|
||||||
case 'size':
|
|
||||||
$ValidAttribs = array('1','2','3','4','5','6','7','8','9','10');
|
|
||||||
if (!in_array($Block['Attr'], $ValidAttribs)) {
|
|
||||||
$Str.='[size='.$Block['Attr'].']'.$this->to_html($Block['Val']).'[/size]';
|
|
||||||
} else {
|
|
||||||
$Str.='<span class="size'.$Block['Attr'].'">'.$this->to_html($Block['Val']).'</span>';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'quote':
|
|
||||||
$this->NoImg++; // No images inside quote tags
|
|
||||||
if (!empty($Block['Attr'])) {
|
|
||||||
$Str.='<strong>'.$this->to_html($Block['Attr']).'</strong> wrote: ';
|
|
||||||
}
|
|
||||||
$Str.='<blockquote>'.$this->to_html($Block['Val']).'</blockquote>';
|
|
||||||
$this->NoImg--;
|
|
||||||
break;
|
|
||||||
case 'hide':
|
|
||||||
$Str.='<strong>'.(($Block['Attr']) ? $Block['Attr'] : 'Hidden text').'</strong>: <a href="javascript:void(0);" onclick="BBCode.spoiler(this);">Show</a>';
|
|
||||||
$Str.='<blockquote class="hidden spoiler">'.$this->to_html($Block['Val']).'</blockquote>';
|
|
||||||
break;
|
|
||||||
case 'img':
|
|
||||||
if ($this->NoImg > 0 && $this->valid_url($Block['Val'])) {
|
|
||||||
$Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Val'].'">'.$Block['Val'].'</a> (image)';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!$this->valid_url($Block['Val'], '\.(jpe?g|gif|png|bmp|tiff)')) {
|
|
||||||
$Str.='[img]'.$Block['Val'].'[/img]';
|
|
||||||
} else {
|
|
||||||
$Str.='<img style="max-width: 500px;" onclick="lightbox.init(this,500);" alt="'.$Block['Val'].'" src="'.ImageTools::process($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)';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!$this->valid_url($Block['Val'], '\.(mp3|ogg|wav)')) {
|
|
||||||
$Str.='[aud]'.$Block['Val'].'[/aud]';
|
|
||||||
} else {
|
|
||||||
//TODO: Proxy this for staff?
|
|
||||||
$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'])) {
|
|
||||||
$Block['Val'] = $Block['Attr'];
|
|
||||||
$NoName = true; // If there isn't a Val for this
|
|
||||||
} else {
|
|
||||||
$Block['Val'] = $this->to_html($Block['Val']);
|
|
||||||
$NoName = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$this->valid_url($Block['Attr'])) {
|
|
||||||
$Str.='[url='.$Block['Attr'].']'.$Block['Val'].'[/url]';
|
|
||||||
} else {
|
|
||||||
$LocalURL = $this->local_url($Block['Attr']);
|
|
||||||
if ($LocalURL) {
|
|
||||||
if ($NoName) {
|
|
||||||
$Block['Val'] = substr($LocalURL,1);
|
|
||||||
}
|
|
||||||
$Str.='<a href="'.$LocalURL.'">'.$Block['Val'].'</a>';
|
|
||||||
} else {
|
|
||||||
$Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Attr'].'">'.$Block['Val'].'</a>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->Levels--;
|
|
||||||
return $Str;
|
|
||||||
}
|
|
||||||
|
|
||||||
function raw_text($Array) {
|
|
||||||
$Str = '';
|
|
||||||
foreach ($Array as $Block) {
|
|
||||||
if (is_string($Block)) {
|
|
||||||
$Str.=$Block;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
switch ($Block['Type']) {
|
|
||||||
|
|
||||||
case 'b':
|
|
||||||
case 'u':
|
|
||||||
case 'i':
|
|
||||||
case 's':
|
|
||||||
case 'color':
|
|
||||||
case 'size':
|
|
||||||
case 'quote':
|
|
||||||
case 'align':
|
|
||||||
|
|
||||||
$Str.=$this->raw_text($Block['Val']);
|
|
||||||
break;
|
|
||||||
case 'tex': //since this will never strip cleanly, just remove it
|
|
||||||
break;
|
|
||||||
case 'artist':
|
|
||||||
case 'user':
|
|
||||||
case 'wiki':
|
|
||||||
case 'pre':
|
|
||||||
case 'code':
|
|
||||||
case 'aud':
|
|
||||||
case 'img':
|
|
||||||
$Str.=$Block['Val'];
|
|
||||||
break;
|
|
||||||
case 'list':
|
|
||||||
foreach ($Block['Val'] as $Line) {
|
|
||||||
$Str.='*'.$this->raw_text($Line);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'url':
|
|
||||||
// Make sure the URL has a label
|
|
||||||
if (empty($Block['Val'])) {
|
|
||||||
$Block['Val'] = $Block['Attr'];
|
|
||||||
} 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']);
|
|
||||||
$Block['Attr'] = $Array;
|
|
||||||
$Str.=$this->raw_text($Block['Attr']);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$Str.=$Block['Attr'];
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $Str;
|
|
||||||
}
|
|
||||||
|
|
||||||
function smileys($Str) {
|
|
||||||
global $LoggedUser;
|
|
||||||
if (!empty($LoggedUser['DisableSmileys'])) {
|
|
||||||
return $Str;
|
|
||||||
}
|
|
||||||
$Str = strtr($Str, $this->Smileys);
|
|
||||||
return $Str;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
|
|
||||||
//Uncomment this part to test the class via command line:
|
|
||||||
function display_str($Str) {return $Str;}
|
|
||||||
function check_perms($Perm) {return true;}
|
|
||||||
$Str = "hello
|
|
||||||
[pre]http://anonym.to/?http://whatshirts.portmerch.com/
|
|
||||||
====hi====
|
|
||||||
===hi===
|
|
||||||
==hi==[/pre]
|
|
||||||
====hi====
|
|
||||||
hi";
|
|
||||||
$Text = NEW TEXT;
|
|
||||||
echo $Text->full_format($Str);
|
|
||||||
echo "\n"
|
|
||||||
*/
|
|
||||||
?>
|
|
@ -1,663 +0,0 @@
|
|||||||
<?
|
|
||||||
class TEXT_3 {
|
|
||||||
// tag=>max number of attributes
|
|
||||||
private $ValidTags = array('b'=>0, 'u'=>0, 'i'=>0, 's'=>0, '*'=>0, 'artist'=>0, 'user'=>0, 'n'=>0, 'inlineurl'=>0, 'inlinesize'=>1, 'align'=>1, 'color'=>1, 'colour'=>1, 'size'=>1, 'url'=>1, 'img'=>1, 'quote'=>1, 'pre'=>1, 'tex'=>0, 'hide'=>1, 'plain'=>0
|
|
||||||
);
|
|
||||||
private $Smileys = array(
|
|
||||||
':angry:' => 'angry.gif',
|
|
||||||
':-D' => 'biggrin.gif',
|
|
||||||
':D' => 'biggrin.gif',
|
|
||||||
':|' => 'blank.gif',
|
|
||||||
':-|' => 'blank.gif',
|
|
||||||
':blush:' => 'blush.gif',
|
|
||||||
':cool:' => 'cool.gif',
|
|
||||||
':\'(' => 'crying.gif',
|
|
||||||
'>.>' => 'eyesright.gif',
|
|
||||||
':frown:' => 'frown.gif',
|
|
||||||
'<3' => 'heart.gif',
|
|
||||||
':unsure:' => 'hmm.gif',
|
|
||||||
':whatlove:' => 'ilu.gif',
|
|
||||||
':lol:' => 'laughing.gif',
|
|
||||||
':loveflac:' => 'loveflac.gif',
|
|
||||||
':ninja:' => 'ninja.gif',
|
|
||||||
':no:' => 'no.gif',
|
|
||||||
':nod:' => 'nod.gif',
|
|
||||||
':ohno:' => 'ohnoes.gif',
|
|
||||||
':ohnoes:' => 'ohnoes.gif',
|
|
||||||
':omg:' => 'omg.gif',
|
|
||||||
':o' => 'ohshit.gif',
|
|
||||||
':O' => 'ohshit.gif',
|
|
||||||
':paddle:' => 'paddle.gif',
|
|
||||||
':(' => 'sad.gif',
|
|
||||||
':-(' => 'sad.gif',
|
|
||||||
':shifty:' => 'shifty.gif',
|
|
||||||
':sick:' => 'sick.gif',
|
|
||||||
':)' => 'smile.gif',
|
|
||||||
':-)' => 'smile.gif',
|
|
||||||
':sorry:' => 'sorry.gif',
|
|
||||||
':thanks:' => 'thanks.gif',
|
|
||||||
':P' => 'tongue.gif',
|
|
||||||
':-P' => 'tongue.gif',
|
|
||||||
':-p' => 'tongue.gif',
|
|
||||||
':wave:' => 'wave.gif',
|
|
||||||
':wink:' => 'wink.gif',
|
|
||||||
':creepy:' => 'creepy.gif',
|
|
||||||
':worried:' => 'worried.gif',
|
|
||||||
':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 = 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
|
|
||||||
$Regex .= '(\w+(:\w+)?@)?'; // user:pass@
|
|
||||||
$Regex .= '(';
|
|
||||||
$Regex .= '(([0-9]{1,3}\.){3}[0-9]{1,3})|'; // IP or...
|
|
||||||
$Regex .= '(([a-z0-9\-\_]+\.)+\w{2,6})'; // sub.sub.sub.host.com
|
|
||||||
$Regex .= ')';
|
|
||||||
$Regex .= '(:[0-9]{1,5})?'; // port
|
|
||||||
$Regex .= '\/?'; // slash?
|
|
||||||
$Regex .= '(\/?[0-9a-z\-_.,&=@~%\/:;()+!#]+)*'; // /file
|
|
||||||
if (!empty($Extension)) {
|
|
||||||
$Regex.=$Extension;
|
|
||||||
}
|
|
||||||
|
|
||||||
// query string
|
|
||||||
if ($Inline) {
|
|
||||||
$Regex .= '(\?([0-9a-z\-_.,%\/\@~&=:;()+*\^$!#]|\[\d*\])*)?';
|
|
||||||
} else {
|
|
||||||
$Regex .= '(\?[0-9a-z\-_.,%\/\@[\]~&=:;()+*\^$!#]*)?';
|
|
||||||
}
|
|
||||||
|
|
||||||
$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;
|
|
||||||
}
|
|
||||||
$Host = $URLInfo['host'];
|
|
||||||
// If for some reason your site does not require subdomains or contains a directory in the SITE_URL, revert to the line below.
|
|
||||||
//if ($Host == NONSSL_SITE_URL || $Host == SSL_SITE_URL || $Host == 'www.'.NONSSL_SITE_URL) {
|
|
||||||
if (preg_match('/(\S+\.)*'.NONSSL_SITE_URL.'/', $Host)) {
|
|
||||||
$URL = $URLInfo['path'];
|
|
||||||
if (!empty($URLInfo['query'])) {
|
|
||||||
$URL.='?'.$URLInfo['query'];
|
|
||||||
}
|
|
||||||
if (!empty($URLInfo['fragment'])) {
|
|
||||||
$URL.='#'.$URLInfo['fragment'];
|
|
||||||
}
|
|
||||||
return $URL;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* How parsing works
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
EXPLANATION OF PARSER LOGIC
|
|
||||||
|
|
||||||
1) Find the next tag (regex)
|
|
||||||
1a) If there aren't any tags left, write everything remaining to a block and return (done parsing)
|
|
||||||
1b) If the next tag isn't where the pointer is, write everything up to there to a text block.
|
|
||||||
2) See if it's a [[wiki-link]] or an ordinary tag, and get the tag name
|
|
||||||
3) If it's not a wiki link:
|
|
||||||
3a) check it against the $this->ValidTags array to see if it's actually a tag and not [bullshit]
|
|
||||||
If it's [not a tag], just leave it as plaintext and move on
|
|
||||||
3b) Get the attribute, if it exists [name=attribute]
|
|
||||||
4) Move the pointer past the end of the tag
|
|
||||||
5) Find out where the tag closes (beginning of [/tag])
|
|
||||||
5a) Different for different types of tag. Some tags don't close, others are weird like [*]
|
|
||||||
5b) If it's a normal tag, it may have versions of itself nested inside - e.g.:
|
|
||||||
[quote=bob]*
|
|
||||||
[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 (***).
|
|
||||||
|
|
||||||
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.
|
|
||||||
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)
|
|
||||||
|
|
||||||
*/
|
|
||||||
function parse($Str) {
|
|
||||||
$i = 0; // Pointer to keep track of where we are in $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) {
|
|
||||||
$Array[$ArrayPos] = substr($Str, $i, $TagPos - $i);
|
|
||||||
++$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;
|
|
||||||
$TagName = substr($Tag[4][0], 2, -2);
|
|
||||||
$Attrib = '';
|
|
||||||
} 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]));
|
|
||||||
$i = $TagPos + strlen($Tag[0][0]);
|
|
||||||
++$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);
|
|
||||||
} else {
|
|
||||||
$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
|
|
||||||
$CloseTag = $Len;
|
|
||||||
}
|
|
||||||
if (preg_match('/[!;,.?:]+$/',substr($Str, $i, $CloseTag), $Match)) {
|
|
||||||
$CloseTag -= strlen($Match[0]);
|
|
||||||
}
|
|
||||||
$URL = substr($Str, $i, $CloseTag);
|
|
||||||
if (substr($URL, -1) == ')' && substr_count($URL, '(') < substr_count($URL, ')')) {
|
|
||||||
$CloseTag--;
|
|
||||||
$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') {
|
|
||||||
// Don't need to do anything - empty tag with no closing
|
|
||||||
} elseif ($TagName == '*') {
|
|
||||||
// We're in a list. Find where it ends
|
|
||||||
$NewLine = $i;
|
|
||||||
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.
|
|
||||||
} 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
|
|
||||||
// (as the first close tag won't do - it's been opened again)
|
|
||||||
do {
|
|
||||||
$CloseTag = stripos($Str, '[/'.$TagName.']', $CloseTag+1);
|
|
||||||
if ($CloseTag === false) {
|
|
||||||
$CloseTag = $Len;
|
|
||||||
break;
|
|
||||||
} 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) {
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
$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.
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 6) Depending on what type of tag we're dealing with, create an array with the attribute and block.
|
|
||||||
switch ($TagName) {
|
|
||||||
case 'inlineurl':
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'inlineurl', 'Attr'=>$Block, 'Val'=>'');
|
|
||||||
break;
|
|
||||||
case 'url':
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'img', 'Attr'=>$Attrib, 'Val'=>$Block);
|
|
||||||
if (empty($Attrib)) { // [url]http://...[/url] - always set URL to attribute
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'url', 'Attr'=>$Block, 'Val'=>'');
|
|
||||||
} else {
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'url', 'Attr'=>$Attrib, 'Val'=>$this->parse($Block));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'quote':
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'quote', 'Attr'=>$this->Parse($Attrib), 'Val'=>$this->parse($Block));
|
|
||||||
break;
|
|
||||||
case 'img':
|
|
||||||
case 'image':
|
|
||||||
if (empty($Block)) {
|
|
||||||
$Block = $Attrib;
|
|
||||||
}
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'img', 'Val'=>$Block);
|
|
||||||
break;
|
|
||||||
case 'aud':
|
|
||||||
case 'mp3':
|
|
||||||
case 'audio':
|
|
||||||
if (empty($Block)) {
|
|
||||||
$Block = $Attrib;
|
|
||||||
}
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'aud', 'Val'=>$Block);
|
|
||||||
break;
|
|
||||||
case 'user':
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'user', 'Val'=>$Block);
|
|
||||||
break;
|
|
||||||
case 'artist':
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'artist', 'Val'=>$Block);
|
|
||||||
break;
|
|
||||||
case 'tex':
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'tex', 'Val'=>$Block);
|
|
||||||
break;
|
|
||||||
case 'pre':
|
|
||||||
case 'plain':
|
|
||||||
$Block = strtr($Block, array('[inlineurl]'=>''));
|
|
||||||
$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':
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'hide', 'Attr'=>$Attrib, 'Val'=>$this->parse($Block));
|
|
||||||
break;
|
|
||||||
case '*':
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'list');
|
|
||||||
$Array[$ArrayPos]['Val'] = explode('[*]', $Block);
|
|
||||||
foreach ($Array[$ArrayPos]['Val'] as $Key=>$Val) {
|
|
||||||
$Array[$ArrayPos]['Val'][$Key] = $this->parse(trim($Val));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'n':
|
|
||||||
$ArrayPos--;
|
|
||||||
break; // n serves only to disrupt bbcode (backwards compatibility - use [pre])
|
|
||||||
default:
|
|
||||||
if ($WikiLink == true) {
|
|
||||||
$Array[$ArrayPos] = array('Type'=>'wiki','Val'=>$TagName);
|
|
||||||
} 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) { // Hax prevention
|
|
||||||
return $Block['Val'];
|
|
||||||
}
|
|
||||||
$Str = '';
|
|
||||||
|
|
||||||
foreach ($Array as $Block) {
|
|
||||||
if (is_string($Block)) {
|
|
||||||
$Str.=$this->smileys($Block);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
switch ($Block['Type']) {
|
|
||||||
case 'b':
|
|
||||||
$Str.='<strong>'.$this->to_html($Block['Val']).'</strong>';
|
|
||||||
break;
|
|
||||||
case 'u':
|
|
||||||
$Str.='<span style="text-decoration: underline;">'.$this->to_html($Block['Val']).'</span>';
|
|
||||||
break;
|
|
||||||
case 'i':
|
|
||||||
$Str.='<em>'.$this->to_html($Block['Val'])."</em>";
|
|
||||||
break;
|
|
||||||
case 's':
|
|
||||||
$Str.='<span style="text-decoration: line-through">'.$this->to_html($Block['Val']).'</span>';
|
|
||||||
break;
|
|
||||||
case 'user':
|
|
||||||
$Str.='<a href="user.php?action=search&search='.urlencode($Block['Val']).'">'.$Block['Val'].'</a>';
|
|
||||||
break;
|
|
||||||
case 'artist':
|
|
||||||
$Str.='<a href="artist.php?artistname='.urlencode(mb_convert_encoding($Block['Val'],"UTF-8","HTML-ENTITIES")).'">'.$Block['Val'].'</a>';
|
|
||||||
break;
|
|
||||||
case 'wiki':
|
|
||||||
$Str.='<a href="wiki.php?action=article&name='.urlencode($Block['Val']).'">'.$Block['Val'].'</a>';
|
|
||||||
break;
|
|
||||||
case 'tex':
|
|
||||||
$Str.='<img style="vertical-align: middle" src="'.STATIC_SERVER.'blank.gif" onload="if (this.src.substr(this.src.length-9,this.src.length) == \'blank.gif\') { this.src = \'http://chart.apis.google.com/chart?cht=tx&chf=bg,s,FFFFFF00&chl='.urlencode(mb_convert_encoding($Block['Val'],"UTF-8","HTML-ENTITIES")).'&chco=\' + hexify(getComputedStyle(this.parentNode,null).color); }" alt="TeX" />';
|
|
||||||
break;
|
|
||||||
case 'plain':
|
|
||||||
$Str.=$Block['Val'];
|
|
||||||
break;
|
|
||||||
case 'pre':
|
|
||||||
$Str.='<pre>'.$Block['Val'].'</pre>';
|
|
||||||
break;
|
|
||||||
case 'list':
|
|
||||||
$Str.='<ul>';
|
|
||||||
foreach ($Block['Val'] as $Line) {
|
|
||||||
|
|
||||||
$Str.='<li>'.$this->to_html($Line).'</li>';
|
|
||||||
}
|
|
||||||
$Str.='</ul>';
|
|
||||||
break;
|
|
||||||
case 'align':
|
|
||||||
$ValidAttribs = array('left', 'center', 'right');
|
|
||||||
if (!in_array($Block['Attr'], $ValidAttribs)) {
|
|
||||||
$Str.='[align='.$Block['Attr'].']'.$this->to_html($Block['Val']).'[/align]';
|
|
||||||
} else {
|
|
||||||
$Str.='<div style="text-align:'.$Block['Attr'].'">'.$this->to_html($Block['Val']).'</div>';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
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'])) {
|
|
||||||
$Str.='[color='.$Block['Attr'].']'.$this->to_html($Block['Val']).'[/color]';
|
|
||||||
} else {
|
|
||||||
$Str.='<span style="color:'.$Block['Attr'].'">'.$this->to_html($Block['Val']).'</span>';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'inlinesize':
|
|
||||||
case 'size':
|
|
||||||
$ValidAttribs = array('1','2','3','4','5','6','7','8','9','10');
|
|
||||||
if (!in_array($Block['Attr'], $ValidAttribs)) {
|
|
||||||
$Str.='[size='.$Block['Attr'].']'.$this->to_html($Block['Val']).'[/size]';
|
|
||||||
} else {
|
|
||||||
$Str.='<span class="size'.$Block['Attr'].'">'.$this->to_html($Block['Val']).'</span>';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'quote':
|
|
||||||
$this->NoImg++; // No images inside quote tags
|
|
||||||
if (!empty($Block['Attr'])) {
|
|
||||||
$Str.='<strong>'.$this->to_html($Block['Attr']).'</strong> wrote: ';
|
|
||||||
}
|
|
||||||
$Str.='<blockquote>'.$this->to_html($Block['Val']).'</blockquote>';
|
|
||||||
$this->NoImg--;
|
|
||||||
break;
|
|
||||||
case 'hide':
|
|
||||||
$Str.='<strong>'.(($Block['Attr']) ? $Block['Attr'] : 'Hidden text').'</strong>: <a href="javascript:void(0);" onclick="BBCode.spoiler(this);">Show</a>';
|
|
||||||
$Str.='<blockquote class="hidden spoiler">'.$this->to_html($Block['Val']).'</blockquote>';
|
|
||||||
break;
|
|
||||||
case 'img':
|
|
||||||
if ($this->NoImg > 0 && $this->valid_url($Block['Val'])) {
|
|
||||||
$Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Val'].'">'.$Block['Val'].'</a> (image)';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!$this->valid_url($Block['Val'], '\.(jpe?g|gif|png|bmp|tiff)')) {
|
|
||||||
$Str.='[img]'.$Block['Val'].'[/img]';
|
|
||||||
} else {
|
|
||||||
$Str.='<img style="max-width: 500px;" onclick="lightbox.init(this,500);" alt="'.$Block['Val'].'" src="'.ImageTools::process($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)';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!$this->valid_url($Block['Val'], '\.(mp3|ogg|wav)')) {
|
|
||||||
$Str.='[aud]'.$Block['Val'].'[/aud]';
|
|
||||||
} else {
|
|
||||||
//TODO: Proxy this for staff?
|
|
||||||
$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'])) {
|
|
||||||
$Block['Val'] = $Block['Attr'];
|
|
||||||
$NoName = true; // If there isn't a Val for this
|
|
||||||
} else {
|
|
||||||
$Block['Val'] = $this->to_html($Block['Val']);
|
|
||||||
$NoName = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$this->valid_url($Block['Attr'])) {
|
|
||||||
$Str.='[url='.$Block['Attr'].']'.$Block['Val'].'[/url]';
|
|
||||||
} else {
|
|
||||||
$LocalURL = $this->local_url($Block['Attr']);
|
|
||||||
if ($LocalURL) {
|
|
||||||
if ($NoName) {
|
|
||||||
$Block['Val'] = substr($LocalURL,1);
|
|
||||||
}
|
|
||||||
$Str.='<a href="'.$LocalURL.'">'.$Block['Val'].'</a>';
|
|
||||||
} else {
|
|
||||||
$Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Attr'].'">'.$Block['Val'].'</a>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->Levels--;
|
|
||||||
return $Str;
|
|
||||||
}
|
|
||||||
|
|
||||||
function raw_text($Array) {
|
|
||||||
$Str = '';
|
|
||||||
foreach ($Array as $Block) {
|
|
||||||
if (is_string($Block)) {
|
|
||||||
$Str.=$Block;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
switch ($Block['Type']) {
|
|
||||||
|
|
||||||
case 'b':
|
|
||||||
case 'u':
|
|
||||||
case 'i':
|
|
||||||
case 's':
|
|
||||||
case 'color':
|
|
||||||
case 'size':
|
|
||||||
case 'quote':
|
|
||||||
case 'align':
|
|
||||||
|
|
||||||
$Str.=$this->raw_text($Block['Val']);
|
|
||||||
break;
|
|
||||||
case 'tex': //since this will never strip cleanly, just remove it
|
|
||||||
break;
|
|
||||||
case 'artist':
|
|
||||||
case 'user':
|
|
||||||
case 'wiki':
|
|
||||||
case 'pre':
|
|
||||||
case 'aud':
|
|
||||||
case 'img':
|
|
||||||
$Str.=$Block['Val'];
|
|
||||||
break;
|
|
||||||
case 'list':
|
|
||||||
foreach ($Block['Val'] as $Line) {
|
|
||||||
$Str.='*'.$this->raw_text($Line);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'url':
|
|
||||||
// Make sure the URL has a label
|
|
||||||
if (empty($Block['Val'])) {
|
|
||||||
$Block['Val'] = $Block['Attr'];
|
|
||||||
} 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']);
|
|
||||||
$Block['Attr'] = $Array;
|
|
||||||
$Str.=$this->raw_text($Block['Attr']);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$Str.=$Block['Attr'];
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $Str;
|
|
||||||
}
|
|
||||||
|
|
||||||
function smileys($Str) {
|
|
||||||
global $LoggedUser;
|
|
||||||
if (!empty($LoggedUser['DisableSmileys'])) {
|
|
||||||
return $Str;
|
|
||||||
}
|
|
||||||
$Str = strtr($Str, $this->Smileys);
|
|
||||||
return $Str;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
|
|
||||||
//Uncomment this part to test the class via command line:
|
|
||||||
function display_str($Str) {return $Str;}
|
|
||||||
function check_perms($Perm) {return true;}
|
|
||||||
$Str = "hello
|
|
||||||
[pre]http://anonym.to/?http://whatshirts.portmerch.com/
|
|
||||||
====hi====
|
|
||||||
===hi===
|
|
||||||
==hi==[/pre]
|
|
||||||
====hi====
|
|
||||||
hi";
|
|
||||||
$Text = NEW TEXT;
|
|
||||||
echo $Text->full_format($Str);
|
|
||||||
echo "\n"
|
|
||||||
*/
|
|
||||||
?>
|
|
@ -38,11 +38,7 @@ function compare($X, $Y) {
|
|||||||
$RevisionID = false;
|
$RevisionID = false;
|
||||||
}
|
}
|
||||||
if ($Data) {
|
if ($Data) {
|
||||||
if (!is_array($Data)) {
|
|
||||||
$Data = unserialize($Data);
|
|
||||||
}
|
|
||||||
list($K, list($Name, $Image, $Body, $NumSimilar, $SimilarArray, , , $VanityHouseArtist)) = each($Data);
|
list($K, list($Name, $Image, $Body, $NumSimilar, $SimilarArray, , , $VanityHouseArtist)) = each($Data);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ($RevisionID) {
|
if ($RevisionID) {
|
||||||
$sql = "
|
$sql = "
|
||||||
|
@ -7,7 +7,8 @@
|
|||||||
list($Page, $Limit) = Format::page_limit(NOTIFICATIONS_PER_PAGE);
|
list($Page, $Limit) = Format::page_limit(NOTIFICATIONS_PER_PAGE);
|
||||||
|
|
||||||
$Results = $DB->query("
|
$Results = $DB->query("
|
||||||
SELECT SQL_CALC_FOUND_ROWS
|
SELECT
|
||||||
|
SQL_CALC_FOUND_ROWS
|
||||||
unt.TorrentID,
|
unt.TorrentID,
|
||||||
unt.UnRead,
|
unt.UnRead,
|
||||||
unt.FilterID,
|
unt.FilterID,
|
||||||
@ -50,7 +51,7 @@
|
|||||||
}
|
}
|
||||||
if (!isset($FilterGroups[$Result['FilterID']])) {
|
if (!isset($FilterGroups[$Result['FilterID']])) {
|
||||||
$FilterGroups[$Result['FilterID']] = array();
|
$FilterGroups[$Result['FilterID']] = array();
|
||||||
$FilterGroups[$Result['FilterID']]['FilterLabel'] = $Result['Label'] ? $Result['Label'] : false;
|
$FilterGroups[$Result['FilterID']]['FilterLabel'] = ($Result['Label'] ? $Result['Label'] : false);
|
||||||
}
|
}
|
||||||
array_push($FilterGroups[$Result['FilterID']], $Result);
|
array_push($FilterGroups[$Result['FilterID']], $Result);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,8 @@
|
|||||||
|
|
||||||
list($Page, $Limit) = Format::page_limit(USERS_PER_PAGE);
|
list($Page, $Limit) = Format::page_limit(USERS_PER_PAGE);
|
||||||
$DB->query("
|
$DB->query("
|
||||||
SELECT SQL_CALC_FOUND_ROWS
|
SELECT
|
||||||
|
SQL_CALC_FOUND_ROWS
|
||||||
ID,
|
ID,
|
||||||
Username,
|
Username,
|
||||||
Enabled,
|
Enabled,
|
||||||
@ -42,7 +43,7 @@
|
|||||||
'userId' => (int) $UserID,
|
'userId' => (int) $UserID,
|
||||||
'username' => $Username,
|
'username' => $Username,
|
||||||
'donor' => $Donor == 1,
|
'donor' => $Donor == 1,
|
||||||
'warned' => ($Warned!='0000-00-00 00:00:00'),
|
'warned' => ($Warned != '0000-00-00 00:00:00'),
|
||||||
'enabled' => ($Enabled == 2 ? false : true),
|
'enabled' => ($Enabled == 2 ? false : true),
|
||||||
'class' => Users::make_class_string($PermissionID)
|
'class' => Users::make_class_string($PermissionID)
|
||||||
);
|
);
|
||||||
|
@ -32,9 +32,6 @@ function compare($X, $Y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($Data) {
|
if ($Data) {
|
||||||
if (!is_array($Data)) {
|
|
||||||
$Data = unserialize($Data);
|
|
||||||
}
|
|
||||||
list($K, list($Name, $Image, $Body, $NumSimilar, $SimilarArray, , , $VanityHouseArtist)) = each($Data);
|
list($K, list($Name, $Image, $Body, $NumSimilar, $SimilarArray, , , $VanityHouseArtist)) = each($Data);
|
||||||
} else {
|
} else {
|
||||||
if ($RevisionID) {
|
if ($RevisionID) {
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
}
|
}
|
||||||
$Categories = array_keys($Categories);
|
$Categories = array_keys($Categories);
|
||||||
} else {
|
} else {
|
||||||
$Categories = array(1,2,3,4,5,6,7);
|
$Categories = array(1, 2, 3, 4, 5, 6, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ordering
|
// Ordering
|
||||||
@ -71,7 +71,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$BaseSQL = $SQL = "
|
$BaseSQL = $SQL = "
|
||||||
SELECT SQL_CALC_FOUND_ROWS
|
SELECT
|
||||||
|
SQL_CALC_FOUND_ROWS
|
||||||
c.ID,
|
c.ID,
|
||||||
c.Name,
|
c.Name,
|
||||||
c.NumTorrents,
|
c.NumTorrents,
|
||||||
@ -88,8 +89,6 @@
|
|||||||
$SQL .= " AND bc.UserID = '" . $LoggedUser['ID'] . "'";
|
$SQL .= " AND bc.UserID = '" . $LoggedUser['ID'] . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!empty($Search)) {
|
if (!empty($Search)) {
|
||||||
$SQL .= " AND $Type LIKE '%";
|
$SQL .= " AND $Type LIKE '%";
|
||||||
$SQL .= implode("%' AND $Type LIKE '%", $Words);
|
$SQL .= implode("%' AND $Type LIKE '%", $Words);
|
||||||
|
@ -21,9 +21,6 @@ function compare($X, $Y) {
|
|||||||
$Data = $Cache->get_value('collage_'.$CollageID);
|
$Data = $Cache->get_value('collage_'.$CollageID);
|
||||||
|
|
||||||
if ($Data) {
|
if ($Data) {
|
||||||
if (!is_array($Data)) {
|
|
||||||
$Data = unserialize($Data);
|
|
||||||
}
|
|
||||||
list($K, list($Name, $Description, , , $CommentList, $Deleted, $CollageCategoryID, $CreatorID, $Locked, $MaxGroups, $MaxGroupsPerUser)) = each($Data);
|
list($K, list($Name, $Description, , , $CommentList, $Deleted, $CollageCategoryID, $CreatorID, $Locked, $MaxGroups, $MaxGroupsPerUser)) = each($Data);
|
||||||
} else {
|
} else {
|
||||||
$DB->query("SELECT Name, Description, UserID, Deleted, CategoryID, Locked, MaxGroups, MaxGroupsPerUser FROM collages WHERE ID='$CollageID'");
|
$DB->query("SELECT Name, Description, UserID, Deleted, CategoryID, Locked, MaxGroups, MaxGroupsPerUser FROM collages WHERE ID='$CollageID'");
|
||||||
|
@ -35,7 +35,8 @@
|
|||||||
$Sort = (empty($_GET['sort']) || $_GET['sort'] != 'unread' ? 'Date DESC' : "cu.Unread = '1' DESC, DATE DESC");
|
$Sort = (empty($_GET['sort']) || $_GET['sort'] != 'unread' ? 'Date DESC' : "cu.Unread = '1' DESC, DATE DESC");
|
||||||
|
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT SQL_CALC_FOUND_ROWS
|
SELECT
|
||||||
|
SQL_CALC_FOUND_ROWS
|
||||||
c.ID,
|
c.ID,
|
||||||
c.Subject,
|
c.Subject,
|
||||||
cu.Unread,
|
cu.Unread,
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
}
|
}
|
||||||
$Words = explode(' ', $Search);
|
$Words = explode(' ', $Search);
|
||||||
$sql = '
|
$sql = '
|
||||||
SELECT SQL_CALC_FOUND_ROWS
|
SELECT
|
||||||
|
SQL_CALC_FOUND_ROWS
|
||||||
ID,
|
ID,
|
||||||
Message,
|
Message,
|
||||||
Time
|
Time
|
||||||
|
@ -46,7 +46,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$Reports = $DB->query("
|
$Reports = $DB->query("
|
||||||
SELECT SQL_CALC_FOUND_ROWS
|
SELECT
|
||||||
|
SQL_CALC_FOUND_ROWS
|
||||||
r.ID,
|
r.ID,
|
||||||
r.UserID,
|
r.UserID,
|
||||||
um.Username,
|
um.Username,
|
||||||
|
@ -124,7 +124,8 @@
|
|||||||
|
|
||||||
|
|
||||||
$DB->query("
|
$DB->query("
|
||||||
SELECT SQL_CALC_FOUND_ROWS
|
SELECT
|
||||||
|
SQL_CALC_FOUND_ROWS
|
||||||
r.ID,
|
r.ID,
|
||||||
r.ReporterID,
|
r.ReporterID,
|
||||||
reporter.Username,
|
reporter.Username,
|
||||||
|
@ -37,7 +37,8 @@
|
|||||||
|
|
||||||
//Torrent exists, check it's applicable
|
//Torrent exists, check it's applicable
|
||||||
$DB->query("
|
$DB->query("
|
||||||
SELECT t.UserID,
|
SELECT
|
||||||
|
t.UserID,
|
||||||
t.Time,
|
t.Time,
|
||||||
tg.ReleaseType,
|
tg.ReleaseType,
|
||||||
t.Encoding,
|
t.Encoding,
|
||||||
@ -50,7 +51,7 @@
|
|||||||
IF(t.Remastered = '1', t.RemasterCatalogueNumber, tg.CatalogueNumber)
|
IF(t.Remastered = '1', t.RemasterCatalogueNumber, tg.CatalogueNumber)
|
||||||
FROM torrents AS t
|
FROM torrents AS t
|
||||||
LEFT JOIN torrents_group AS tg ON t.GroupID=tg.ID
|
LEFT JOIN torrents_group AS tg ON t.GroupID=tg.ID
|
||||||
WHERE t.ID = ".$TorrentID."
|
WHERE t.ID = $TorrentID
|
||||||
LIMIT 1");
|
LIMIT 1");
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,14 +30,18 @@
|
|||||||
if (empty($_POST['id']) || !is_number($_POST['id'])) {
|
if (empty($_POST['id']) || !is_number($_POST['id'])) {
|
||||||
error(404);
|
error(404);
|
||||||
}
|
}
|
||||||
$DB->query("UPDATE ip_bans SET
|
$DB->query("
|
||||||
|
UPDATE ip_bans
|
||||||
|
SET
|
||||||
FromIP=$Start,
|
FromIP=$Start,
|
||||||
ToIP='$End',
|
ToIP='$End',
|
||||||
Reason='$Notes'
|
Reason='$Notes'
|
||||||
WHERE ID='".$_POST['id']."'");
|
WHERE ID='".$_POST['id']."'");
|
||||||
} else { //Create
|
} else { //Create
|
||||||
$DB->query("INSERT INTO ip_bans
|
$DB->query("
|
||||||
(FromIP, ToIP, Reason) VALUES
|
INSERT INTO ip_bans
|
||||||
|
(FromIP, ToIP, Reason)
|
||||||
|
VALUES
|
||||||
('$Start','$End', '$Notes')");
|
('$Start','$End', '$Notes')");
|
||||||
}
|
}
|
||||||
$Cache->delete_value('ip_bans_'.$IPA);
|
$Cache->delete_value('ip_bans_'.$IPA);
|
||||||
@ -47,7 +51,14 @@
|
|||||||
define('BANS_PER_PAGE', '20');
|
define('BANS_PER_PAGE', '20');
|
||||||
list($Page, $Limit) = Format::page_limit(BANS_PER_PAGE);
|
list($Page, $Limit) = Format::page_limit(BANS_PER_PAGE);
|
||||||
|
|
||||||
$sql = "SELECT SQL_CALC_FOUND_ROWS ID, FromIP, ToIP, Reason FROM ip_bans AS i ";
|
$sql = "
|
||||||
|
SELECT
|
||||||
|
SQL_CALC_FOUND_ROWS
|
||||||
|
ID,
|
||||||
|
FromIP,
|
||||||
|
ToIP,
|
||||||
|
Reason
|
||||||
|
FROM ip_bans AS i ";
|
||||||
|
|
||||||
if (!empty($_REQUEST['notes'])) {
|
if (!empty($_REQUEST['notes'])) {
|
||||||
$sql .= "WHERE Reason LIKE '%".db_string($_REQUEST['notes'])."%' ";
|
$sql .= "WHERE Reason LIKE '%".db_string($_REQUEST['notes'])."%' ";
|
||||||
@ -68,7 +79,7 @@
|
|||||||
$DB->query('SELECT FOUND_ROWS()');
|
$DB->query('SELECT FOUND_ROWS()');
|
||||||
list($Results) = $DB->next_record();
|
list($Results) = $DB->next_record();
|
||||||
|
|
||||||
$PageLinks=Format::get_pages($Page,$Results,BANS_PER_PAGE,11);
|
$PageLinks = Format::get_pages($Page, $Results, BANS_PER_PAGE, 11);
|
||||||
|
|
||||||
View::show_header('IP Address Bans');
|
View::show_header('IP Address Bans');
|
||||||
$DB->set_query_id($Bans);
|
$DB->set_query_id($Bans);
|
||||||
@ -132,8 +143,8 @@
|
|||||||
$Row = 'a';
|
$Row = 'a';
|
||||||
while (list($ID, $Start, $End, $Reason) = $DB->next_record()) {
|
while (list($ID, $Start, $End, $Reason) = $DB->next_record()) {
|
||||||
$Row = ($Row === 'a' ? 'b' : 'a');
|
$Row = ($Row === 'a' ? 'b' : 'a');
|
||||||
$Start=long2ip($Start);
|
$Start = long2ip($Start);
|
||||||
$End=long2ip($End);
|
$End = long2ip($End);
|
||||||
?>
|
?>
|
||||||
<tr class="row<?=$Row?>">
|
<tr class="row<?=$Row?>">
|
||||||
<form class="manage_form" name="ban" action="" method="post">
|
<form class="manage_form" name="ban" action="" method="post">
|
||||||
|
@ -131,8 +131,8 @@ function compare($X, $Y) {
|
|||||||
<div class="box box_image box_image_albumart box_albumart"><!-- .box_albumart deprecated -->
|
<div class="box box_image box_image_albumart box_albumart"><!-- .box_albumart deprecated -->
|
||||||
<div class="head">
|
<div class="head">
|
||||||
<strong><?=(count($CoverArt) > 0 ? 'Covers (' . (count($CoverArt) + 1) . ')' : 'Cover')?></strong>
|
<strong><?=(count($CoverArt) > 0 ? 'Covers (' . (count($CoverArt) + 1) . ')' : 'Cover')?></strong>
|
||||||
|
|
||||||
<? if(count($CoverArt) > 0) {
|
<? if(count($CoverArt) > 0) {
|
||||||
|
if(empty($LoggedUser['ShowExtraCovers'])) {
|
||||||
for ($Index = 0; $Index <= count($CoverArt); $Index++) { ?>
|
for ($Index = 0; $Index <= count($CoverArt); $Index++) { ?>
|
||||||
<span id="cover_controls_<?=($Index)?>"<?=($Index > 0 ? ' style="display: none;"' : '')?>>
|
<span id="cover_controls_<?=($Index)?>"<?=($Index > 0 ? ' style="display: none;"' : '')?>>
|
||||||
<? if ($Index == count($CoverArt)) { ?>
|
<? if ($Index == count($CoverArt)) { ?>
|
||||||
@ -150,7 +150,12 @@ function compare($X, $Y) {
|
|||||||
<? } ?>
|
<? } ?>
|
||||||
</span>
|
</span>
|
||||||
<? }
|
<? }
|
||||||
} ?>
|
} else { ?>
|
||||||
|
<span>
|
||||||
|
<a class="brackets show_all_covers" href="#">Hide</a>
|
||||||
|
</span>
|
||||||
|
<? }
|
||||||
|
}?>
|
||||||
</div>
|
</div>
|
||||||
<?
|
<?
|
||||||
$Index = 0;
|
$Index = 0;
|
||||||
@ -169,10 +174,13 @@ function compare($X, $Y) {
|
|||||||
<? foreach ($CoverArt as $Cover) {
|
<? foreach ($CoverArt as $Cover) {
|
||||||
list($ImageID, $Image, $Summary, $AddedBy) = $Cover;
|
list($ImageID, $Image, $Summary, $AddedBy) = $Cover;
|
||||||
?>
|
?>
|
||||||
<div id="cover_div_<?=$Index?>" style="display: none;">
|
<div id="cover_div_<?=$Index?>" <?=empty($LoggedUser['ShowExtraCovers']) ? 'style="display: none;"' : ""?>>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<?
|
<? if(empty($LoggedUser['ShowExtraCovers'])) {
|
||||||
$Src = 'src="" data-gazelle-temp-src="' . ImageTools::process($Image, true) . '"';
|
$Src = 'src="" data-gazelle-temp-src="' . ImageTools::process($Image, true) . '"';
|
||||||
|
} else {
|
||||||
|
$Src = 'src="' . ImageTools::process($Image, true) . '"';
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<img id="cover_<?=$Index?>" style="max-width: 220px;" <?=$Src?> alt="<?=$Summary?>" onclick="lightbox.init('<?=ImageTools::process($Image)?>',220);" />
|
<img id="cover_<?=$Index?>" style="max-width: 220px;" <?=$Src?> alt="<?=$Summary?>" onclick="lightbox.init('<?=ImageTools::process($Image)?>',220);" />
|
||||||
</p>
|
</p>
|
||||||
|
@ -15,7 +15,8 @@
|
|||||||
|
|
||||||
|
|
||||||
$DB->query("
|
$DB->query("
|
||||||
SELECT SQL_CALC_FOUND_ROWS
|
SELECT
|
||||||
|
SQL_CALC_FOUND_ROWS
|
||||||
ud.UserID,
|
ud.UserID,
|
||||||
ud.Time
|
ud.Time
|
||||||
FROM users_downloads AS ud
|
FROM users_downloads AS ud
|
||||||
@ -30,10 +31,19 @@
|
|||||||
|
|
||||||
if (count($UserIDs) > 0) {
|
if (count($UserIDs) > 0) {
|
||||||
$UserIDs = implode(',',$UserIDs);
|
$UserIDs = implode(',',$UserIDs);
|
||||||
$DB->query("SELECT uid FROM xbt_snatched WHERE fid='$TorrentID' AND uid IN($UserIDs)");
|
$DB->query("
|
||||||
|
SELECT uid
|
||||||
|
FROM xbt_snatched
|
||||||
|
WHERE fid='$TorrentID'
|
||||||
|
AND uid IN($UserIDs)");
|
||||||
$Snatched = $DB->to_array('uid');
|
$Snatched = $DB->to_array('uid');
|
||||||
|
|
||||||
$DB->query("SELECT uid FROM xbt_files_users WHERE fid='$TorrentID' AND Remaining=0 AND uid IN($UserIDs)");
|
$DB->query("
|
||||||
|
SELECT uid
|
||||||
|
FROM xbt_files_users
|
||||||
|
WHERE fid='$TorrentID'
|
||||||
|
AND Remaining=0
|
||||||
|
AND uid IN($UserIDs)");
|
||||||
$Seeding = $DB->to_array('uid');
|
$Seeding = $DB->to_array('uid');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,12 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
$Results = $DB->to_array(false, MYSQLI_ASSOC, false);
|
$Results = $DB->to_array(false, MYSQLI_ASSOC, false);
|
||||||
} else {
|
} else {
|
||||||
$DB->query("
|
$DB->query("
|
||||||
SELECT SQL_CALC_FOUND_ROWS unt.TorrentID, unt.UnRead, unt.FilterID, t.GroupID
|
SELECT
|
||||||
|
SQL_CALC_FOUND_ROWS
|
||||||
|
unt.TorrentID,
|
||||||
|
unt.UnRead,
|
||||||
|
unt.FilterID,
|
||||||
|
t.GroupID
|
||||||
FROM users_notify_torrents AS unt
|
FROM users_notify_torrents AS unt
|
||||||
JOIN torrents AS t ON t.ID = unt.TorrentID
|
JOIN torrents AS t ON t.ID = unt.TorrentID
|
||||||
WHERE unt.UserID=$UserID".
|
WHERE unt.UserID=$UserID".
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$Result = $DB->query("
|
$Result = $DB->query("
|
||||||
SELECT SQL_CALC_FOUND_ROWS
|
SELECT
|
||||||
|
SQL_CALC_FOUND_ROWS
|
||||||
xu.uid,
|
xu.uid,
|
||||||
t.Size,
|
t.Size,
|
||||||
xu.active,
|
xu.active,
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$Result = $DB->query("
|
$Result = $DB->query("
|
||||||
SELECT SQL_CALC_FOUND_ROWS
|
SELECT
|
||||||
|
SQL_CALC_FOUND_ROWS
|
||||||
xs.uid,
|
xs.uid,
|
||||||
xs.tstamp
|
xs.tstamp
|
||||||
FROM xbt_snatched AS xs
|
FROM xbt_snatched AS xs
|
||||||
|
@ -209,7 +209,7 @@ function header_link($SortKey,$DefaultWay="DESC") {
|
|||||||
if (empty($_GET['media'])) {
|
if (empty($_GET['media'])) {
|
||||||
$ExtraWhere .= " AND (
|
$ExtraWhere .= " AND (
|
||||||
t.LogScore = 100 OR
|
t.LogScore = 100 OR
|
||||||
t.Media IN ('Vinyl','WEB','DVD','Soundboard','Casette','SACD','Blu-ray','DAT')
|
t.Media IN ('Vinyl','WEB','DVD','Soundboard','Cassette','SACD','Blu-ray','DAT')
|
||||||
)";
|
)";
|
||||||
} elseif (strtoupper($_GET['media']) == 'CD' && empty($_GET['log'])) {
|
} elseif (strtoupper($_GET['media']) == 'CD' && empty($_GET['log'])) {
|
||||||
$ExtraWhere .= " AND t.LogScore = 100";
|
$ExtraWhere .= " AND t.LogScore = 100";
|
||||||
@ -226,18 +226,22 @@ function header_link($SortKey,$DefaultWay="DESC") {
|
|||||||
$GroupBy = 't.ID';
|
$GroupBy = 't.ID';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((empty($_GET['search']) || trim($_GET['search']) == '') && $Order!='Name') {
|
if ((empty($_GET['search']) || trim($_GET['search']) == '') && $Order != 'Name') {
|
||||||
$SQL = "
|
$SQL = "
|
||||||
SELECT
|
SELECT
|
||||||
SQL_CALC_FOUND_ROWS t.GroupID,
|
SQL_CALC_FOUND_ROWS
|
||||||
|
t.GroupID,
|
||||||
t.ID AS TorrentID,
|
t.ID AS TorrentID,
|
||||||
$Time AS Time,
|
$Time AS Time,
|
||||||
tg.CategoryID
|
tg.CategoryID
|
||||||
FROM $From
|
FROM $From
|
||||||
JOIN torrents_group AS tg ON tg.ID=t.GroupID
|
JOIN torrents_group AS tg ON tg.ID=t.GroupID
|
||||||
WHERE $UserField='$UserID' $ExtraWhere $SearchWhere
|
WHERE $UserField='$UserID'
|
||||||
GROUP BY ".$GroupBy."
|
$ExtraWhere
|
||||||
ORDER BY $Order $Way LIMIT $Limit";
|
$SearchWhere
|
||||||
|
GROUP BY $GroupBy
|
||||||
|
ORDER BY $Order $Way
|
||||||
|
LIMIT $Limit";
|
||||||
} else {
|
} else {
|
||||||
$DB->query("
|
$DB->query("
|
||||||
CREATE TEMPORARY TABLE temp_sections_torrents_user (
|
CREATE TEMPORARY TABLE temp_sections_torrents_user (
|
||||||
@ -267,7 +271,9 @@ function header_link($SortKey,$DefaultWay="DESC") {
|
|||||||
JOIN torrents_group AS tg ON tg.ID=t.GroupID
|
JOIN torrents_group AS tg ON tg.ID=t.GroupID
|
||||||
LEFT JOIN torrents_artists AS ta ON ta.GroupID=tg.ID
|
LEFT JOIN torrents_artists AS ta ON ta.GroupID=tg.ID
|
||||||
LEFT JOIN artists_alias AS aa ON aa.AliasID=ta.AliasID
|
LEFT JOIN artists_alias AS aa ON aa.AliasID=ta.AliasID
|
||||||
WHERE $UserField='$UserID' $ExtraWhere $SearchWhere
|
WHERE $UserField='$UserID'
|
||||||
|
$ExtraWhere
|
||||||
|
$SearchWhere
|
||||||
GROUP BY TorrentID, Time");
|
GROUP BY TorrentID, Time");
|
||||||
|
|
||||||
if (!empty($_GET['search']) && trim($_GET['search']) != '') {
|
if (!empty($_GET['search']) && trim($_GET['search']) != '') {
|
||||||
@ -275,8 +281,12 @@ function header_link($SortKey,$DefaultWay="DESC") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$SQL = "
|
$SQL = "
|
||||||
SELECT SQL_CALC_FOUND_ROWS
|
SELECT
|
||||||
GroupID, TorrentID, Time, CategoryID
|
SQL_CALC_FOUND_ROWS
|
||||||
|
GroupID,
|
||||||
|
TorrentID,
|
||||||
|
Time,
|
||||||
|
CategoryID
|
||||||
FROM temp_sections_torrents_user";
|
FROM temp_sections_torrents_user";
|
||||||
if (!empty($Words)) {
|
if (!empty($Words)) {
|
||||||
$SQL .= "
|
$SQL .= "
|
||||||
|
@ -190,6 +190,8 @@ function checked($Checked) {
|
|||||||
<input type="hidden" name="coverart" value="" />
|
<input type="hidden" name="coverart" value="" />
|
||||||
<input type="checkbox" name="coverart" id="coverart"<?=$SiteOptions['CoverArt'] ? ' checked="checked"' : ''?> />
|
<input type="checkbox" name="coverart" id="coverart"<?=$SiteOptions['CoverArt'] ? ' checked="checked"' : ''?> />
|
||||||
<label for="coverart">Show cover artwork next to torrent information</label>
|
<label for="coverart">Show cover artwork next to torrent information</label>
|
||||||
|
<input type="checkbox" name="show_extra_covers" id="show_extra_covers"<?=$SiteOptions['ShowExtraCovers'] ? ' checked="checked"' : ''?> />
|
||||||
|
<label for="show_extra_covers">Show all additional cover art on torrent pages by default</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -25,7 +25,8 @@
|
|||||||
$Limit = sprintf("%d, %d", ($Page - 1) * USERS_PER_PAGE, USERS_PER_PAGE);
|
$Limit = sprintf("%d, %d", ($Page - 1) * USERS_PER_PAGE, USERS_PER_PAGE);
|
||||||
}
|
}
|
||||||
$DB->query("
|
$DB->query("
|
||||||
SELECT SQL_CALC_FOUND_ROWS
|
SELECT
|
||||||
|
SQL_CALC_FOUND_ROWS
|
||||||
ID,
|
ID,
|
||||||
Username,
|
Username,
|
||||||
Enabled,
|
Enabled,
|
||||||
|
@ -208,6 +208,7 @@
|
|||||||
$Options['DisableAutoSave'] = (!empty($_POST['disableautosave']) ? 1 : 0);
|
$Options['DisableAutoSave'] = (!empty($_POST['disableautosave']) ? 1 : 0);
|
||||||
$Options['NoVoteLinks'] = (!empty($_POST['novotelinks']) ? 1 : 0);
|
$Options['NoVoteLinks'] = (!empty($_POST['novotelinks']) ? 1 : 0);
|
||||||
$Options['CoverArt'] = (int) !empty($_POST['coverart']);
|
$Options['CoverArt'] = (int) !empty($_POST['coverart']);
|
||||||
|
$Options['ShowExtraCovers'] = (int) !empty($_POST['show_extra_covers']);
|
||||||
|
|
||||||
if (isset($LoggedUser['DisableFreeTorrentTop10'])) {
|
if (isset($LoggedUser['DisableFreeTorrentTop10'])) {
|
||||||
$Options['DisableFreeTorrentTop10'] = $LoggedUser['DisableFreeTorrentTop10'];
|
$Options['DisableFreeTorrentTop10'] = $LoggedUser['DisableFreeTorrentTop10'];
|
||||||
|
@ -460,7 +460,7 @@ function check_paranoia_here($Setting) {
|
|||||||
|
|
||||||
if (check_perms('users_view_keys',$Class) || $OwnProfile) {
|
if (check_perms('users_view_keys',$Class) || $OwnProfile) {
|
||||||
?>
|
?>
|
||||||
<li>Passkey: <a href="#" onclick="this.innerHTML='<?=display_str($torrent_pass)?>'; return false;" class="brackets">View</a></li>
|
<li>Passkey: <a href="#" id="passkey" onclick="togglePassKey('<?=display_str($torrent_pass)?>'); return false;" class="brackets">View</a></li>
|
||||||
<? }
|
<? }
|
||||||
if (check_perms('users_view_invites')) {
|
if (check_perms('users_view_invites')) {
|
||||||
if (!$InviterID) {
|
if (!$InviterID) {
|
||||||
|
@ -88,7 +88,8 @@ function UnBan(ip, id, elemID) {
|
|||||||
|
|
||||||
if ($UsersOnly == 1) {
|
if ($UsersOnly == 1) {
|
||||||
$RS = $DB->query("
|
$RS = $DB->query("
|
||||||
SELECT SQL_CALC_FOUND_ROWS
|
SELECT
|
||||||
|
SQL_CALC_FOUND_ROWS
|
||||||
h1.IP,
|
h1.IP,
|
||||||
h1.StartTime,
|
h1.StartTime,
|
||||||
h1.EndTime,
|
h1.EndTime,
|
||||||
@ -110,7 +111,8 @@ function UnBan(ip, id, elemID) {
|
|||||||
LIMIT $Limit");
|
LIMIT $Limit");
|
||||||
} else {
|
} else {
|
||||||
$RS = $DB->query("
|
$RS = $DB->query("
|
||||||
SELECT SQL_CALC_FOUND_ROWS
|
SELECT
|
||||||
|
SQL_CALC_FOUND_ROWS
|
||||||
h1.IP,
|
h1.IP,
|
||||||
h1.StartTime,
|
h1.StartTime,
|
||||||
h1.EndTime,
|
h1.EndTime,
|
||||||
|
@ -21,7 +21,8 @@
|
|||||||
}
|
}
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT
|
SELECT
|
||||||
SQL_CALC_FOUND_ROWS f.ID as ForumID,
|
SQL_CALC_FOUND_ROWS
|
||||||
|
f.ID as ForumID,
|
||||||
f.Name as ForumName,
|
f.Name as ForumName,
|
||||||
t.Title,
|
t.Title,
|
||||||
q.PageID,
|
q.PageID,
|
||||||
|
@ -28,7 +28,8 @@
|
|||||||
$ShowUnread = (!isset($_GET['showunread']) && !isset($HeavyInfo['SubscriptionsUnread']) || isset($HeavyInfo['SubscriptionsUnread']) && !!$HeavyInfo['SubscriptionsUnread'] || isset($_GET['showunread']) && !!$_GET['showunread']);
|
$ShowUnread = (!isset($_GET['showunread']) && !isset($HeavyInfo['SubscriptionsUnread']) || isset($HeavyInfo['SubscriptionsUnread']) && !!$HeavyInfo['SubscriptionsUnread'] || isset($_GET['showunread']) && !!$_GET['showunread']);
|
||||||
$ShowCollapsed = (!isset($_GET['collapse']) && !isset($HeavyInfo['SubscriptionsCollapse']) || isset($HeavyInfo['SubscriptionsCollapse']) && !!$HeavyInfo['SubscriptionsCollapse'] || isset($_GET['collapse']) && !!$_GET['collapse']);
|
$ShowCollapsed = (!isset($_GET['collapse']) && !isset($HeavyInfo['SubscriptionsCollapse']) || isset($HeavyInfo['SubscriptionsCollapse']) && !!$HeavyInfo['SubscriptionsCollapse'] || isset($_GET['collapse']) && !!$_GET['collapse']);
|
||||||
$sql = '
|
$sql = '
|
||||||
SELECT SQL_CALC_FOUND_ROWS
|
SELECT
|
||||||
|
SQL_CALC_FOUND_ROWS
|
||||||
MAX(p.ID) AS ID
|
MAX(p.ID) AS ID
|
||||||
FROM ( SELECT TopicID
|
FROM ( SELECT TopicID
|
||||||
FROM users_subscriptions
|
FROM users_subscriptions
|
||||||
|
@ -39,7 +39,11 @@
|
|||||||
}
|
}
|
||||||
$DB->query("SELECT info_hash FROM torrents where ID = $TorrentID");
|
$DB->query("SELECT info_hash FROM torrents where ID = $TorrentID");
|
||||||
if (list($InfoHash) = $DB->next_record(MYSQLI_NUM, FALSE)) {
|
if (list($InfoHash) = $DB->next_record(MYSQLI_NUM, FALSE)) {
|
||||||
$DB->query("UPDATE users_freeleeches SET Expired=TRUE WHERE UserID=$UserID AND TorrentID=$TorrentID");
|
$DB->query("
|
||||||
|
UPDATE users_freeleeches
|
||||||
|
SET Expired=TRUE
|
||||||
|
WHERE UserID=$UserID
|
||||||
|
AND TorrentID=$TorrentID");
|
||||||
$Cache->delete_value('users_tokens_'.$UserID);
|
$Cache->delete_value('users_tokens_'.$UserID);
|
||||||
Tracker::update_tracker('remove_token', array('info_hash' => rawurlencode($InfoHash), 'userid' => $UserID));
|
Tracker::update_tracker('remove_token', array('info_hash' => rawurlencode($InfoHash), 'userid' => $UserID));
|
||||||
}
|
}
|
||||||
@ -51,7 +55,8 @@
|
|||||||
list($Page, $Limit) = Format::page_limit(25);
|
list($Page, $Limit) = Format::page_limit(25);
|
||||||
|
|
||||||
$DB->query("
|
$DB->query("
|
||||||
SELECT SQL_CALC_FOUND_ROWS
|
SELECT
|
||||||
|
SQL_CALC_FOUND_ROWS
|
||||||
f.TorrentID,
|
f.TorrentID,
|
||||||
t.GroupID,
|
t.GroupID,
|
||||||
f.Time,
|
f.Time,
|
||||||
|
@ -41,7 +41,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$SQL = "
|
$SQL = "
|
||||||
SELECT SQL_CALC_FOUND_ROWS
|
SELECT
|
||||||
|
SQL_CALC_FOUND_ROWS
|
||||||
w.ID,
|
w.ID,
|
||||||
w.Title,
|
w.Title,
|
||||||
w.Date,
|
w.Date,
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
View::show_header($Title);
|
View::show_header($Title);
|
||||||
|
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT SQL_CALC_FOUND_ROWS
|
SELECT
|
||||||
|
SQL_CALC_FOUND_ROWS
|
||||||
w.ID,
|
w.ID,
|
||||||
w.Title,
|
w.Title,
|
||||||
w.Date,
|
w.Date,
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
var show_all = false;
|
var show_all = false;
|
||||||
var current;
|
var current;
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
show_all = $(".show_all_covers").text() == "Hide";
|
||||||
$(".next_cover").click(function(e) {
|
$(".next_cover").click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var next = $(this).data("gazelle-next-cover");
|
var next = $(this).data("gazelle-next-cover");
|
||||||
|
@ -167,3 +167,12 @@ function userform_submit() {
|
|||||||
userform.submit();
|
userform.submit();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function togglePassKey(key) {
|
||||||
|
if ($('#passkey').raw().innerHTML == 'View') {
|
||||||
|
$('#passkey').raw().innerHTML = key;
|
||||||
|
} else {
|
||||||
|
$('#passkey').raw().innerHTML = 'View';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user