Empty commit

This commit is contained in:
Git 2013-04-20 08:01:01 +00:00
parent ba33634e19
commit 271dfafde4
52 changed files with 1108 additions and 938 deletions

View File

@ -10,15 +10,17 @@
$SSL = ($_SERVER['SERVER_PORT'] === '443');
if (isset($_COOKIE['session'])) { $LoginCookie=$Enc->decrypt($_COOKIE['session']); }
if(isset($LoginCookie)) {
list($SessionID, $UserID)=explode("|~|",$Enc->decrypt($LoginCookie));
if (isset($_COOKIE['session'])) {
$LoginCookie = $Enc->decrypt($_COOKIE['session']);
}
if (isset($LoginCookie)) {
list($SessionID, $UserID) = explode("|~|",$Enc->decrypt($LoginCookie));
if(!$UserID || !$SessionID) {
if (!$UserID || !$SessionID) {
die('Not logged in!');
}
if(!$Enabled = $Cache->get_value('enabled_'.$UserID)){
if (!$Enabled = $Cache->get_value('enabled_'.$UserID)) {
require(SERVER_ROOT.'/classes/class_mysql.php'); //Require the database wrapper
$DB=NEW DB_MYSQL; //Load the database wrapper
$DB->query("SELECT Enabled FROM users_main WHERE ID='$UserID'");
@ -34,39 +36,50 @@ function error($Error) {
}
function is_number($Str) {
if ($Str < 0) { return false; }
if ($Str < 0) {
return false;
}
// We're converting input to a int, then string and comparing to original
return ($Str == strval(intval($Str)) ? true : false);
}
function display_str($Str) {
if ($Str!="") {
$Str=make_utf8($Str);
$Str=mb_convert_encoding($Str,"HTML-ENTITIES","UTF-8");
$Str=preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/m","&amp;",$Str);
if ($Str != '') {
$Str = make_utf8($Str);
$Str = mb_convert_encoding($Str,'HTML-ENTITIES','UTF-8');
$Str = preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/m","&amp;",$Str);
$Replace = array(
"'",'"',"<",">",
'&#128;','&#130;','&#131;','&#132;','&#133;','&#134;','&#135;','&#136;','&#137;','&#138;','&#139;','&#140;','&#142;','&#145;','&#146;','&#147;','&#148;','&#149;','&#150;','&#151;','&#152;','&#153;','&#154;','&#155;','&#156;','&#158;','&#159;'
);
$With=array(
$With = array(
'&#39;','&quot;','&lt;','&gt;',
'&#8364;','&#8218;','&#402;','&#8222;','&#8230;','&#8224;','&#8225;','&#710;','&#8240;','&#352;','&#8249;','&#338;','&#381;','&#8216;','&#8217;','&#8220;','&#8221;','&#8226;','&#8211;','&#8212;','&#732;','&#8482;','&#353;','&#8250;','&#339;','&#382;','&#376;'
);
$Str=str_replace($Replace,$With,$Str);
$Str = str_replace($Replace,$With,$Str);
}
return $Str;
}
function make_utf8($Str) {
if ($Str!="") {
if (is_utf8($Str)) { $Encoding="UTF-8"; }
if (empty($Encoding)) { $Encoding=mb_detect_encoding($Str,'UTF-8, ISO-8859-1'); }
if (empty($Encoding)) { $Encoding="ISO-8859-1"; }
if ($Encoding=="UTF-8") { return $Str; }
else { return @mb_convert_encoding($Str,"UTF-8",$Encoding); }
if ($Str != '') {
if (is_utf8($Str)) {
$Encoding = 'UTF-8';
}
if (empty($Encoding)) {
$Encoding = mb_detect_encoding($Str,'UTF-8, ISO-8859-1');
}
if (empty($Encoding)) {
$Encoding = 'ISO-8859-1';
}
if ($Encoding == 'UTF-8') {
return $Str;
} else {
return @mb_convert_encoding($Str,'UTF-8',$Encoding);
}
}
}
@ -86,7 +99,7 @@ function is_utf8($Str) {
function display_array($Array, $DontEscape = array()) {
foreach ($Array as $Key => $Val) {
if(!in_array($Key, $DontEscape)) {
if (!in_array($Key, $DontEscape)) {
$Array[$Key] = display_str($Val);
}
}

View File

@ -9,16 +9,16 @@ function flush() {
global $Cache, $DB;
$DB->query("SELECT Alias, ArticleID FROM wiki_aliases");
$Aliases = $DB->to_array('Alias');
$Cache->cache_value('wiki_aliases', $Aliases, 3600*24*14);
$Cache->cache_value('wiki_aliases', $Aliases, 3600 * 24 * 14); // 2 weeks
}
function to_id($Alias) {
global $Cache, $DB;
$Aliases = $Cache->get_value('wiki_aliases');
if(!$Aliases){
if (!$Aliases) {
$DB->query("SELECT Alias, ArticleID FROM wiki_aliases");
$Aliases = $DB->to_array('Alias');
$Cache->cache_value('wiki_aliases', $Aliases, 3600*24*14);
$Cache->cache_value('wiki_aliases', $Aliases, 3600 * 24 * 14); // 2 weeks
}
return $Aliases[$this->convert($Alias)]['ArticleID'];
}
@ -38,8 +38,9 @@ function to_id($Alias) {
function article($ArticleID, $Error = true) {
global $Cache, $DB;
$Contents = $Cache->get_value('wiki_article_'.$ArticleID);
if(!$Contents){
$DB->query("SELECT
if (!$Contents) {
$DB->query("
SELECT
w.Revision,
w.Title,
w.Body,
@ -50,14 +51,16 @@ function article($ArticleID, $Error = true) {
u.Username,
GROUP_CONCAT(a.Alias),
GROUP_CONCAT(a.UserID)
FROM wiki_articles AS w
FROM wiki_articles AS w
LEFT JOIN wiki_aliases AS a ON w.ID=a.ArticleID
LEFT JOIN users_main AS u ON u.ID=w.Author
WHERE w.ID='$ArticleID'
GROUP BY w.ID");
if(!$DB->record_count() && $Error) { error(404); }
WHERE w.ID='$ArticleID'
GROUP BY w.ID");
if (!$DB->record_count() && $Error) {
error(404);
}
$Contents = $DB->to_array();
$Cache->cache_value('wiki_article_'.$ArticleID, $Contents, 3600*24*14);
$Cache->cache_value('wiki_article_'.$ArticleID, $Contents, 3600 * 24 * 14); // 2 weeks
}
return $Contents;
}

View File

@ -9,7 +9,7 @@ class ARTIST {
var $y = 0;
var $Similar = array();
function ARTIST($ID='', $Name=''){
function ARTIST($ID = '', $Name = '') {
$this->ID = $ID;
$this->NameLength = mb_strlen($Name, 'utf8');
$this->Name = display_str($Name);
@ -28,19 +28,19 @@ class ARTISTS_SIMILAR extends ARTIST{
function dump_data(){
function dump_data() {
return serialize(array(time(), $this->Name, $this->x, $this->y, serialize($this->Artists), serialize($this->Similar)));
}
function load_data($Data){
function load_data($Data) {
list($LastUpdated, $this->Name, $this->x, $this->y, $this->Artists, $this->Similar) = unserialize($Data);
$this->Artists = unserialize($this->Artists);
$this->Similar = unserialize($this->Similar);
}
function set_up(){
$this->x = ceil(WIDTH/2);
$this->y = ceil(HEIGHT/2);
function set_up() {
$this->x = ceil(WIDTH / 2);
$this->y = ceil(HEIGHT / 2);
$this->xValues[$this->x] = $this->ID;
$this->yValues[$this->y] = $this->ID;
@ -51,24 +51,24 @@ function set_up(){
$ArtistIDs = array();
$DB->query("
SELECT
s2.ArtistID,
ag.Name,
ass.Score
s2.ArtistID,
ag.Name,
ass.Score
FROM artists_similar AS s1
JOIN artists_similar AS s2 ON s1.SimilarID=s2.SimilarID AND s1.ArtistID!=s2.ArtistID
JOIN artists_similar_scores AS ass ON ass.SimilarID=s1.SimilarID
JOIN artists_group AS ag ON ag.ArtistID=s2.ArtistID
JOIN artists_similar AS s2 ON s1.SimilarID=s2.SimilarID AND s1.ArtistID!=s2.ArtistID
JOIN artists_similar_scores AS ass ON ass.SimilarID=s1.SimilarID
JOIN artists_group AS ag ON ag.ArtistID=s2.ArtistID
WHERE s1.ArtistID=".$this->ID."
ORDER BY ass.Score DESC
LIMIT 14");
if($DB->record_count() == 0){
if ($DB->record_count() == 0) {
return;
}
// Build into array. Each artist is its own object in $this->Artists
while(list($ArtistID, $Name, $Score) = $DB->next_record(MYSQLI_NUM, false)){
if($Score<0){
while (list($ArtistID, $Name, $Score) = $DB->next_record(MYSQLI_NUM, false)) {
if ($Score < 0) {
continue;
}
$this->Artists[$ArtistID] = new ARTIST($ArtistID, $Name);
@ -78,40 +78,41 @@ function set_up(){
}
// Get similarities between artists on the map
$DB->query("SELECT
s1.ArtistID,
s2.ArtistID
$DB->query("
SELECT
s1.ArtistID,
s2.ArtistID
FROM artists_similar AS s1
JOIN artists_similar AS s2 ON s1.SimilarID=s2.SimilarID AND s1.ArtistID!=s2.ArtistID
JOIN artists_similar_scores AS ass ON ass.SimilarID=s1.SimilarID
JOIN artists_group AS a ON a.ArtistID=s2.ArtistID
JOIN artists_similar AS s2 ON s1.SimilarID=s2.SimilarID AND s1.ArtistID!=s2.ArtistID
JOIN artists_similar_scores AS ass ON ass.SimilarID=s1.SimilarID
JOIN artists_group AS a ON a.ArtistID=s2.ArtistID
WHERE s1.ArtistID IN(".implode(',',$ArtistIDs).")
AND s2.ArtistID IN(".implode(',',$ArtistIDs).")
AND s2.ArtistID IN(".implode(',',$ArtistIDs).")
");
// Build into array
while(list($Artist1ID, $Artist2ID) = $DB->next_record()){
while (list($Artist1ID, $Artist2ID) = $DB->next_record()) {
$this->Artists[$Artist1ID]->Similar[$Artist2ID] = array('ID'=>$Artist2ID);
}
// Calculate decimal point scores between artists
foreach($this->Similar as $SimilarArtist) {
foreach ($this->Similar as $SimilarArtist) {
list($ArtistID, $Similar) = array_values($SimilarArtist);
$this->Similar[$ArtistID]['Decimal'] = $this->similarity($Similar['Score'], $this->TotalScore);
if($this->Similar[$ArtistID]['Decimal'] < $this->LowestDecimal){
if ($this->Similar[$ArtistID]['Decimal'] < $this->LowestDecimal) {
$this->LowestDecimal = $this->Similar[$ArtistID]['Decimal'];
}
if($this->Similar[$ArtistID]['Decimal'] > $this->LargestDecimal){
if ($this->Similar[$ArtistID]['Decimal'] > $this->LargestDecimal) {
$this->LargestDecimal = $this->Similar[$ArtistID]['Decimal'];
}
}
reset($this->Artists);
}
function set_positions(){
function set_positions() {
$xValues = array(); // Possible x values
$Root = ceil(WIDTH/4); // Half-way into half of the image
$Root = ceil(WIDTH / 4); // Half-way into half of the image
$Offset = 4; // Distance from the root (a quarter of the way into the image) to the x value
// The number of artists placed in the top or the bottom
@ -131,32 +132,32 @@ function set_positions(){
// The script later chooses which side to put them on
// We create more very low x values because they're more likely to be skipped
for($i = 0; $i<=count($this->Artists)*4; $i++){
if($Offset>=((WIDTH/4))){
$Offset=$Offset%(WIDTH/4);
for ($i = 0; $i <= count($this->Artists) * 4; $i++) {
if ($Offset >= ((WIDTH / 4))) {
$Offset = $Offset % (WIDTH / 4);
}
$Plus = $Root+$Offset; // Point on the right of the root
$Minus = abs($Root-$Offset); // Point on the left of the root
$Plus = $Root + $Offset; // Point on the right of the root
$Minus = abs($Root - $Offset); // Point on the left of the root
$xValues[$Plus]=$Plus;
$xValues[$Plus] = $Plus;
$xValues[$Minus]=$Minus;
$xValues[$Minus] = $Minus;
// Throw in an extra x value closer to the edge, because they're more likely to be skipped
if($Minus>30){
// $xValues[$Minus-30]=$Minus-30;
if ($Minus > 30) {
// $xValues[$Minus - 30] = $Minus - 30;
}
$Offset = $Offset+rand(5,20); // Increase offset, and go again
$Offset = $Offset + rand(5,20); // Increase offset, and go again
}
foreach($this->Artists as $Artist){
foreach ($this->Artists as $Artist) {
$ArtistID = $Artist->ID;
if($Artist->Displayed == true){
if ($Artist->Displayed == true) {
continue;
}
$this->Similar[$ArtistID]['Decimal'] = $this->Similar[$ArtistID]['Decimal'] * (1/($this->LargestDecimal))-0.1;
$this->Similar[$ArtistID]['Decimal'] = $this->Similar[$ArtistID]['Decimal'] * (1 / ($this->LargestDecimal)) - 0.1;
// Calculate the distance away from the center, based on similarity
$IdealDistance = $this->calculate_distance($this->Similar[$ArtistID]['Decimal'], $this->x, $this->y);
@ -169,12 +170,12 @@ function set_positions(){
// See if any similar artists have been placed yet. If so, place artist in that half
// (provided that there are enough in the other half to visually balance out)
reset($Artist->Similar);
foreach($Artist->Similar as $SimilarArtist) {
foreach ($Artist->Similar as $SimilarArtist) {
list($Artist2ID) = array_values($SimilarArtist);
if($this->Artists[$Artist2ID]) {
if($this->Artists[$Artist2ID]->x > (WIDTH/2) && ($NumRight-$NumLeft)<1){
if ($this->Artists[$Artist2ID]) {
if ($this->Artists[$Artist2ID]->x > (WIDTH / 2) && ($NumRight-$NumLeft) < 1) {
$Horizontal = 2;
} elseif($NumLeft-$NumRight<1) {
} elseif ($NumLeft - $NumRight < 1) {
$Horizontal = 1;
}
break;
@ -183,21 +184,21 @@ function set_positions(){
shuffle($xValues);
while($xValue = array_shift($xValues)){
if(abs($this->x - $xValue) <= $IdealDistance) {
if(hypot(abs($this->x - $xValue), ($this->y - 50)) > $IdealDistance
|| ceil(sqrt(pow($IdealDistance, 2) - pow($this->x - $xValue, 2))) > (HEIGHT/2)){
$xValue = $this->x - ceil(sqrt(pow($IdealDistance, 2) - pow($IdealDistance*0.1*rand(5,9), 2)));
while ($xValue = array_shift($xValues)) {
if (abs($this->x - $xValue) <= $IdealDistance) {
if (hypot(abs($this->x - $xValue), ($this->y - 50)) > $IdealDistance
|| ceil(sqrt(pow($IdealDistance, 2) - pow($this->x - $xValue, 2))) > (HEIGHT / 2)) {
$xValue = $this->x - ceil(sqrt(pow($IdealDistance, 2) - pow($IdealDistance * 0.1 * rand(5,9), 2)));
//echo "Had to change x value for ".$Artist->Name." to ".$xValue."\n";
}
// Found a match (Is close enough to the center to satisfy $IdealDistance),
// Now it's time to choose which half to put it on
if(!$Horizontal) {
if (!$Horizontal) {
// No similar artists displayed
$Horizontal = ($NumLeft<$NumRight) ? 1 : 2;
$Horizontal = ($NumLeft < $NumRight) ? 1 : 2;
}
if($Horizontal == 2){
$xValue = WIDTH-$xValue;
if ($Horizontal == 2) {
$xValue = WIDTH - $xValue;
$NumRight++;
} else {
$NumLeft++;
@ -210,9 +211,9 @@ function set_positions(){
break;
}
}
if(!$xValue){ // Uh-oh, we were unable to choose an x value.
$xValue = ceil(sqrt(pow($IdealDistance, 2)/2));
$xValue = (WIDTH/2)-$xValue;
if (!$xValue) { // Uh-oh, we were unable to choose an x value.
$xValue = ceil(sqrt(pow($IdealDistance, 2) / 2));
$xValue = (WIDTH / 2) - $xValue;
$Artist->x = $xValue;
$this->xValues[$xValue] = $ArtistID;
unset($xValues[$xValue]);
@ -225,11 +226,11 @@ function set_positions(){
// Now we pick if it should go on the top or bottom
if($NumTop>$NumBottom){ // Send it to the bottom half
$yValue=(HEIGHT/2)+$yValue;
if ($NumTop > $NumBottom) { // Send it to the bottom half
$yValue = (HEIGHT / 2) + $yValue;
$NumBottom++;
} else {
$yValue=(HEIGHT/2)-$yValue;
$yValue=(HEIGHT / 2) - $yValue;
$NumTop++;
}
@ -238,28 +239,28 @@ function set_positions(){
// $yValue is now a proper y coordinate
// Now time to do some spacing out
if($yValue < 10){
$yValue+=(10+abs($yValue))+rand(10,20);
if ($yValue < 10) {
$yValue += (10 + abs($yValue)) + rand(10,20);
}
if($yValue > (HEIGHT - 10)){
$yValue-=((HEIGHT/2)-rand(10,20));
if ($yValue > (HEIGHT - 10)) {
$yValue -= ((HEIGHT / 2) - rand(10,20));
}
$i = 1;
while($Conflict = $this->scan_array_range($this->yValues, abs($yValue-13), $yValue+13)) {
if($i > 10){
while ($Conflict = $this->scan_array_range($this->yValues, abs($yValue - 13), $yValue + 13)) {
if ($i > 10) {
break;
}
if(!$this->scan_array_range($this->yValues, abs($yValue-5), $yValue-20)){
if (!$this->scan_array_range($this->yValues, abs($yValue - 5), $yValue - 20)) {
$yValue -= 20;
}
$yValue=$Conflict + rand(10, 20);
if($yValue>HEIGHT-10){
$yValue-=ceil(HEIGHT/2.5);
} elseif($yValue<10) {
$yValue+=ceil(HEIGHT/2.5);
$yValue = $Conflict + rand(10, 20);
if ($yValue > HEIGHT - 10) {
$yValue -= ceil(HEIGHT / 2.5);
} elseif ($yValue < 10) {
$yValue += ceil(HEIGHT / 2.5);
}
$i++;
}
@ -275,63 +276,61 @@ function set_positions(){
// Calculate the ideal distance from the center point ($Rootx, $Rooty) to the artist's point on the board
// Pythagoras as fun!
function calculate_distance($SimilarityCoefficient, $Rootx, $Rooty){
function calculate_distance($SimilarityCoefficient, $Rootx, $Rooty) {
$MaxWidth = WIDTH - $Rootx;
$MaxHeight = HEIGHT - $Rooty;
$x = $MaxWidth - ($SimilarityCoefficient*$MaxWidth*.01); // Possible x value
$y = $MaxHeight - ($SimilarityCoefficient*$MaxHeight); // Possible y value
$x = $MaxWidth - ($SimilarityCoefficient * $MaxWidth * 0.01); // Possible x value
$y = $MaxHeight - ($SimilarityCoefficient * $MaxHeight); // Possible y value
$Hypot = hypot($Rootx - $x, $Rooty - $y);
return $MaxWidth - $Hypot;
}
function similarity($Score, $TotalArtistScore){
return (pow(($Score/($TotalArtistScore+1)), (1/1)));
function similarity($Score, $TotalArtistScore) {
return (pow(($Score / ($TotalArtistScore + 1)), (1 / 1)));
}
function scan_array_range($Array, $Start, $Finish){
if($Start<0){
function scan_array_range($Array, $Start, $Finish) {
if ($Start < 0) {
die($Start);
}
for ($i = $Start; $i<=$Finish; $i++){
if(isset($Array[$i])){
for ($i = $Start; $i <= $Finish; $i++) {
if (isset($Array[$i])) {
return $i;
}
}
return false;
}
function write_artists(){
function write_artists() {
?>
<div style="position:absolute;bottom:<?=$this->y-10?>px;left:<?=$this->x - $this->NameLength*4?>px;font-size:13pt;white-space:nowrap;" class="similar_artist_header">
<div style="position: absolute; bottom: <?=$this->y - 10 ?>px; left: <?=$this->x - $this->NameLength * 4 ?>px; font-size: 13pt; white-space: nowrap;" class="similar_artist_header">
<?=$this->Name?>
</div>
<?
foreach($this->Artists as $Artist){
if($Artist->ID == $this->ID){
foreach ($this->Artists as $Artist) {
if ($Artist->ID == $this->ID) {
continue;
}
$xPosition = $Artist->x - $Artist->NameLength*4;
if($xPosition<0){
$xPosition=3;
$xPosition = $Artist->x - $Artist->NameLength * 4;
if ($xPosition < 0) {
$xPosition = 3;
$Artist->x = $xPosition;
}
$Decimal = $this->Similar[$Artist->ID]['Decimal'];
if($Decimal<0.2){
if ($Decimal < 0.2) {
$FontSize = 8;
} elseif($Decimal<0.3){
} elseif ($Decimal < 0.3) {
$FontSize = 9;
} elseif($Decimal<0.4){
} elseif ($Decimal < 0.4) {
$FontSize = 10;
} else {
$FontSize = 12;
}
?>
<div style="position:absolute;top:<?=$Artist->y-5?>px;left:<?=$xPosition?>px;font-size:<?=$FontSize?>pt;white-space:nowrap;">
<div style="position: absolute; top: <?=$Artist->y - 5 ?>px; left: <?=$xPosition?> px; font-size: <?=$FontSize?>pt; white-space: nowrap;">
<a href="artist.php?id=<?=$Artist->ID?>" class="similar_artist"><?=$Artist->Name?></a>
</div>
<?
@ -339,22 +338,22 @@ function write_artists(){
reset($this->Artists);
}
function background_image(){
function background_image() {
global $Img;
reset($this->Similar);
foreach($this->Similar as $SimilarArtist) {
foreach ($this->Similar as $SimilarArtist) {
list($ArtistID, $Val) = array_values($SimilarArtist);
$Artist = $this->Artists[$ArtistID];
$Decimal = $this->Similar[$ArtistID]['Decimal'];
$Width = ceil($Decimal*4)+1;
$Width = ceil($Decimal * 4) + 1;
$Img->line($this->x, $this->y, $Artist->x, $Artist->y,$Img->color(199,218,255), $Width);
unset($Artist->Similar[$this->ID]);
reset($Artist->Similar);
foreach($Artist->Similar as $SimilarArtist2) {
foreach ($Artist->Similar as $SimilarArtist2) {
list($Artist2ID) = array_values($SimilarArtist2);
if($this->Artists[$Artist2ID]){
if ($this->Artists[$Artist2ID]) {
$Artist2 = $this->Artists[$Artist2ID];
$Img->line($Artist->x, $Artist->y, $Artist2->x, $Artist2->y,$Img->color(173,201,255));
unset($Artist2->Similar[$ArtistID]);
@ -362,13 +361,12 @@ function background_image(){
}
reset($this->xValues);
}
$Img->make_png(SERVER_ROOT.'/static/similar/'.$this->ID.'.png');
}
function dump(){
function dump() {
echo "Similarities:\n";
foreach($this->Artists as $Artist){
foreach ($this->Artists as $Artist) {
echo $Artist->ID;
echo ' - ';
echo $Artist->Name;
@ -381,9 +379,5 @@ function dump(){
}
}
}
?>

View File

@ -23,9 +23,9 @@ function channel($Title, $Description, $Section='') {
}
function item($Title, $Description, $Page, $Creator, $Comments='', $Category='', $Date='') { //Escape with CDATA, otherwise the feed breaks.
if ($Date == '') {
$Date = date("r");
$Date = date('r');
} else {
$Date = date("r",strtotime($Date));
$Date = date('r',strtotime($Date));
}
$Site = $this->UseSSL ? 'https://'.SSL_SITE_URL : 'http://'.NONSSL_SITE_URL;
$Item = "\t\t<item>\n";
@ -44,25 +44,25 @@ function item($Title, $Description, $Page, $Creator, $Comments='', $Category='',
return $Item;
}
function retrieve($CacheKey,$AuthKey,$PassKey) {
function retrieve($CacheKey, $AuthKey, $PassKey) {
global $Cache;
$Entries = $Cache->get_value($CacheKey);
if(!$Entries){
if (!$Entries) {
$Entries = array();
} else {
foreach($Entries as $Item){
foreach ($Entries as $Item) {
echo str_replace(array('[[PASSKEY]]','[[AUTHKEY]]'),array(display_str($PassKey),display_str($AuthKey)),$Item);
}
}
}
function populate($CacheKey,$Item) {
function populate($CacheKey, $Item) {
global $Cache;
$Entries = $Cache->get_value($CacheKey,true);
if(!$Entries){
if (!$Entries) {
$Entries = array();
} else {
if(count($Entries)>=50) {
if (count($Entries) >= 50) {
array_pop($Entries);
}
}

View File

@ -12,17 +12,17 @@ class IMAGE {
function create($Width, $Height) {
$this->Image = imagecreate($Width, $Height);
$this->Font = SERVER_ROOT.'/classes/fonts/VERDANA.TTF';
if(function_exists('imageantialias')){
if (function_exists('imageantialias')) {
imageantialias($this->Image, true);
}
}
function color($Red, $Green, $Blue, $Alpha=0){
function color($Red, $Green, $Blue, $Alpha = 0) {
return imagecolorallocatealpha($this->Image, $Red, $Green, $Blue, $Alpha);
}
function line($x1, $y1, $x2, $y2, $Color, $Thickness = 1){
if($Thickness == 1){
function line($x1, $y1, $x2, $y2, $Color, $Thickness = 1) {
if ($Thickness == 1) {
return imageline($this->Image, $x1, $y1, $x2, $y2, $Color);
}
$t = $Thickness / 2 - 0.5;
@ -32,24 +32,24 @@ function line($x1, $y1, $x2, $y2, $Color, $Thickness = 1){
$k = ($y2 - $y1) / ($x2 - $x1); //y = kx + q
$a = $t / sqrt(1 + pow($k, 2));
$Points = array(
round($x1 - (1+$k)*$a), round($y1 + (1-$k)*$a),
round($x1 - (1-$k)*$a), round($y1 - (1+$k)*$a),
round($x2 + (1+$k)*$a), round($y2 - (1-$k)*$a),
round($x2 + (1-$k)*$a), round($y2 + (1+$k)*$a),
round($x1 - (1 + $k) * $a), round($y1 + (1 - $k) * $a),
round($x1 - (1 - $k) * $a), round($y1 - (1 + $k) * $a),
round($x2 + (1 + $k) * $a), round($y2 - (1 - $k) * $a),
round($x2 + (1 - $k) * $a), round($y2 + (1 + $k) * $a),
);
imagefilledpolygon($this->Image, $Points, 4, $Color);
return imagepolygon($this->Image, $Points, 4, $Color);
}
function ellipse($x, $y, $Width, $Height, $Color){
function ellipse($x, $y, $Width, $Height, $Color) {
return imageEllipse($this->Image, $x, $y, $Width, $Height, $Color);
}
function text($x, $y, $Color, $Text){
function text($x, $y, $Color, $Text) {
return imagettftext ($this->Image, $this->FontSize,$this->TextAngle, $x, $y, $Color, $this->Font, $Text);
}
function make_png($FileName = NULL){
function make_png($FileName = NULL) {
return imagepng($this->Image, $FileName);
}

View File

@ -11,9 +11,9 @@ class INVITE_TREE {
var $Visible = true;
// Set things up
function INVITE_TREE($UserID, $Options = array()){
function INVITE_TREE($UserID, $Options = array()) {
$this->UserID = $UserID;
if($Options['visible'] === false){
if ($Options['visible'] === false) {
$this->Visible = false;
}
}
@ -54,7 +54,7 @@ function make_tree() {
JOIN users_info AS ui ON ui.UserID=it.UserID
WHERE TreeID=$TreeID
AND TreePosition>$TreePosition".
($MaxPosition ? " AND TreePosition<$MaxPosition" : "")."
($MaxPosition ? " AND TreePosition<$MaxPosition" : '')."
AND TreeLevel>$TreeLevel
ORDER BY TreePosition");
@ -82,44 +82,48 @@ function make_tree() {
// We store this in an output buffer, so we can show the summary at the top without having to loop through twice
ob_start();
while(list($ID, $Enabled, $Class, $Donor, $Uploaded, $Downloaded, $Paranoia, $TreePosition, $TreeLevel) = $DB->next_record()){
while (list($ID, $Enabled, $Class, $Donor, $Uploaded, $Downloaded, $Paranoia, $TreePosition, $TreeLevel) = $DB->next_record()) {
// Do stats
$Count++;
if($TreeLevel > $MaxTreeLevel){
if ($TreeLevel > $MaxTreeLevel) {
$MaxTreeLevel = $TreeLevel;
}
if($TreeLevel == $BaseTreeLevel){
if ($TreeLevel == $BaseTreeLevel) {
$Branches++;
$TopLevelUpload += $Uploaded;
$TopLevelDownload += $Downloaded;
}
$ClassSummary[$Class]++;
if($Enabled == 2){
if ($Enabled == 2) {
$DisabledCount++;
}
if($Donor){
if ($Donor) {
$DonorCount++;
}
// Manage tree depth
if($TreeLevel > $PreviousTreeLevel){
for($i = 0; $i<$TreeLevel-$PreviousTreeLevel; $i++){ echo "<ul class=\"invitetree\"><li>"; }
} elseif($TreeLevel < $PreviousTreeLevel){
for($i = 0; $i<$PreviousTreeLevel-$TreeLevel; $i++){ echo "</li></ul>"; }
echo "</li>";
echo "<li>";
if ($TreeLevel > $PreviousTreeLevel) {
for ($i = 0; $i < $TreeLevel - $PreviousTreeLevel; $i++) {
echo '<ul class="invitetree"><li>';
}
} elseif ($TreeLevel < $PreviousTreeLevel) {
for ($i = 0; $i < $PreviousTreeLevel - $TreeLevel; $i++) {
echo '</li></ul>';
}
echo '</li>';
echo '<li>';
} else {
echo "</li>";
echo "<li>";
echo '</li>';
echo '<li>';
}
?>
<strong><?=Users::format_username($ID, true, true, $Enabled != 2 ? false : true, true)?></strong>
<?
if(check_paranoia(array('uploaded', 'downloaded'), $Paranoia, $UserClass)) {
if (check_paranoia(array('uploaded', 'downloaded'), $Paranoia, $UserClass)) {
$TotalUpload += $Uploaded;
$TotalDownload += $Downloaded;
?>
@ -140,9 +144,11 @@ function make_tree() {
}
$Tree = ob_get_clean();
for($i = 0; $i<$PreviousTreeLevel-$OriginalTreeLevel; $i++){ $Tree .= "</li></ul>\n"; }
for ($i = 0; $i < $PreviousTreeLevel - $OriginalTreeLevel; $i++) {
$Tree .= "</li></ul>\n";
}
if($Count){
if ($Count) {
?> <p style="font-weight: bold;">
This tree has <?=$Count?> entries, <?=$Branches?> branches, and a depth of <?=$MaxTreeLevel - $OriginalTreeLevel?>.
@ -150,20 +156,22 @@ function make_tree() {
<?
$ClassStrings = array();
foreach ($ClassSummary as $ClassID => $ClassCount) {
if($ClassCount == 0) { continue; }
if ($ClassCount == 0) {
continue;
}
$LastClass = Users::make_class_string($ClassID);
if($ClassCount>1) {
if($LastClass == "Torrent Celebrity") {
if ($ClassCount > 1) {
if ($LastClass == 'Torrent Celebrity') {
$LastClass = 'Torrent Celebrities';
} else {
$LastClass.='s';
}
}
$LastClass= $ClassCount.' '.$LastClass.' (' . number_format(($ClassCount/$Count)*100) . '%)';
$LastClass = $ClassCount.' '.$LastClass.' (' . number_format(($ClassCount / $Count) * 100) . '%)';
$ClassStrings []= $LastClass;
$ClassStrings[] = $LastClass;
}
if(count($ClassStrings)>1){
if (count($ClassStrings) > 1) {
array_pop($ClassStrings);
echo implode(', ', $ClassStrings);
echo ' and '.$LastClass;
@ -172,16 +180,22 @@ function make_tree() {
}
echo '. ';
echo $DisabledCount;
echo ($DisabledCount==1)?' user is':' users are';
echo ($DisabledCount == 1) ? ' user is' : ' users are';
echo ' disabled (';
if($DisabledCount == 0) { echo '0%)'; }
else { echo number_format(($DisabledCount/$Count)*100) . '%)';}
if ($DisabledCount == 0) {
echo '0%)';
} else {
echo number_format(($DisabledCount / $Count) * 100) . '%)';
}
echo ', and ';
echo $DonorCount;
echo ($DonorCount==1)?' user has':' users have';
echo ($DonorCount == 1) ? ' user has' : ' users have';
echo ' donated (';
if($DonorCount == 0) { echo '0%)'; }
else { echo number_format(($DonorCount/$Count)*100) . '%)';}
if ($DonorCount == 0) {
echo '0%)';
} else {
echo number_format(($DonorCount / $Count) * 100) . '%)';
}
echo '. </p>';
echo '<p style="font-weight: bold;">';
@ -196,22 +210,21 @@ function make_tree() {
echo '; and the total ratio is '.Format::get_ratio_html($TopLevelUpload, $TopLevelDownload).'. ';
echo 'These numbers include the stats of paranoid users, and will be factored in to the invitation giving script.</p>';
echo 'These numbers include the stats of paranoid users and will be factored into the invitation giving script.</p>';
if($ParanoidCount){
if ($ParanoidCount) {
echo '<p style="font-weight: bold;">';
echo $ParanoidCount;
echo ($ParanoidCount==1)?' user (':' users (';
echo number_format(($ParanoidCount/$Count)*100);
echo ($ParanoidCount == 1) ? ' user (' : ' users (';
echo number_format(($ParanoidCount / $Count) * 100);
echo '%) ';
echo ($ParanoidCount==1)?' is':' are';
echo ($ParanoidCount == 1) ? ' is' : ' are';
echo ' too paranoid to have their stats shown here, and ';
echo ($ParanoidCount==1)?' was':' were';
echo ($ParanoidCount == 1) ? ' was' : ' were';
echo ' not factored into the stats for the total tree.';
echo '</p>';
}
}
?>
<br />
<?=$Tree?>

View File

@ -76,7 +76,7 @@ public function disconnect() {
public function get_channel() {
preg_match('/.+ PRIVMSG ([^:]+) :.+/', $this->Data, $Channel);
if(preg_match('/#.+/',$Channel[1])) {
if (preg_match('/#.+/',$Channel[1])) {
return $Channel[1];
} else {
return false;
@ -133,13 +133,13 @@ protected function whois($Nick) {
You can probably find it in old RC1 code kicking aronud if you need it.
protected function ip_check($IP,$Gline=false,$Channel=BOT_REPORT_CHAN) {
global $Cache, $DB;
if(blacklisted_ip($IP)) {
if (blacklisted_ip($IP)) {
$this->send_to($Channel, 'TOR IP Detected: '.$IP);
if ($Gline) {
$this->send_raw('GLINE *@'.$IP.' 90d :DNSBL Proxy');
}
}
if(Tools::site_ban_ip($IP)) {
if (Tools::site_ban_ip($IP)) {
$this->send_to($Channel, 'Site IP Ban Detected: '.$IP);
if ($Gline) {
$this->send_raw('GLINE *@'.$IP.' 90d :IP Ban');
@ -151,31 +151,31 @@ protected function listen() {
global $Cache,$DB;
$Cache->InternalCache = false;
stream_set_timeout($this->Socket, 10000000000);
while($this->State == 1){
if($this->Data = fgets($this->Socket, 256)) {
while ($this->State == 1) {
if ($this->Data = fgets($this->Socket, 256)) {
//IP checks
//if(preg_match('/:\*\*\* (?:REMOTE)?CONNECT: Client connecting (?:.*) \[(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\] \[(.+)\]/', $this->Data, $IP)) {
//if (preg_match('/:\*\*\* (?:REMOTE)?CONNECT: Client connecting (?:.*) \[(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\] \[(.+)\]/', $this->Data, $IP)) {
// $this->ip_check($IP[1],true);
//}
if($this->Debug === true) {
if ($this->Debug === true) {
$this->send_to(BOT_DEBUG_CHAN, $this->Data);
}
if($this->Whois !== false) {
if ($this->Whois !== false) {
$Exp = explode(' ',$this->Data);
if($Exp[1] == '307') {
if ($Exp[1] == '307') {
$this->Identified[$this->Whois] = 1;
$this->send_to($this->LastChan, "$this->Whois correctly identified as a real person!");
$this->Whois = false;
$this->LastChan = false;
} elseif($Exp[6] == '/WHOIS') {
} elseif ($Exp[6] == '/WHOIS') {
$this->Whois = false;
}
}
if(preg_match("/:([^!]+)![^\s]* QUIT.* /", $this->Data, $Nick)) {
if(isset($this->Identified[$Nick[1]])) {
if (preg_match("/:([^!]+)![^\s]* QUIT.* /", $this->Data, $Nick)) {
if (isset($this->Identified[$Nick[1]])) {
unset($this->Identified[$Nick[1]]);
}
if (isset($this->DisabledUsers[$Nick[1]])) {
@ -202,24 +202,24 @@ protected function listen() {
}
}
if(preg_match("/End of message of the day./", $this->Data)) {
if (preg_match('/End of message of the day./', $this->Data)) {
$this->connect_events();
}
if(preg_match('/PING :(.+)/', $this->Data, $Ping)) {
if (preg_match('/PING :(.+)/', $this->Data, $Ping)) {
$this->send_raw('PONG :'.$Ping[1]);
}
if(preg_match('/.*PRIVMSG #.*/',$this->Data)) {
if (preg_match('/.*PRIVMSG #.*/',$this->Data)) {
$this->channel_events();
}
if(preg_match("/.* PRIVMSG ".BOT_NICK." .*/",$this->Data)) {
if (preg_match("/.* PRIVMSG ".BOT_NICK." .*/",$this->Data)) {
$this->query_events();
}
}
if($this->Listened = @socket_accept($this->ListenSocket)) {
if ($this->Listened = @socket_accept($this->ListenSocket)) {
$this->listener_events();
}

View File

@ -53,7 +53,7 @@
* This is how you loop over the result set:
while(list($All,$Columns,$That,$You,$Select)=$DB->next_record()){
while (list($All,$Columns,$That,$You,$Select)=$DB->next_record()) {
echo "Do stuff with ".$All." of the ".$Columns.$That.$You.$Select;
}
-----
@ -310,7 +310,7 @@ function to_array($Key = false, $Type = MYSQLI_BOTH, $Escape = true) {
if ($Key !== false) {
$Return[$Row[$Key]] = $Row;
} else {
$Return[]=$Row;
$Return[] = $Row;
}
}
mysqli_data_seek($this->QueryID, 0);
@ -337,14 +337,14 @@ function to_pair($KeyField, $ValField, $Escape = true) {
// Loops through the result set, collecting the $Key column into an array
function collect($Key, $Escape = true) {
$Return = array();
while($Row = mysqli_fetch_array($this->QueryID)){
while ($Row = mysqli_fetch_array($this->QueryID)) {
$Return[] = $Escape ? display_str($Row[$Key]) : $Row[$Key];
}
mysqli_data_seek($this->QueryID, 0);
return $Return;
}
function set_query_id(&$ResultSet){
function set_query_id(&$ResultSet) {
$this->QueryID = $ResultSet;
$this->Row = 0;
}

View File

@ -185,7 +185,9 @@ private function valid_url ($Str, $Extension = '', $Inline = false) {
public function local_url ($Str) {
$URLInfo = parse_url($Str);
if (!$URLInfo) { return false; }
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) {
@ -282,7 +284,7 @@ private function parse ($Str) {
//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]));
$Array[$ArrayPos] = substr($Str, $i, ($TagPos - $i) + strlen($Tag[0][0]));
$i = $TagPos + strlen($Tag[0][0]);
++$ArrayPos;
continue;
@ -299,7 +301,7 @@ private function parse ($Str) {
}
// 4) Move the pointer past the end of the tag
$i=$TagPos+strlen($Tag[0][0]);
$i = $TagPos + strlen($Tag[0][0]);
// 5) Find out where the tag closes (beginning of [/tag])
@ -338,19 +340,19 @@ private function parse ($Str) {
// 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) == '['.$TagName.']');
$NewLine = strpos($Str, "\n", $NewLine + 1);
} while ($NewLine !== false && substr($Str, $NewLine + 1, 3) == '['.$TagName.']');
$CloseTag = $NewLine;
if ($CloseTag === false) { // block finishes with list
$CloseTag = $Len;
}
$Block = substr($Str, $i, $CloseTag-$i); // Get the list
$Block = substr($Str, $i, $CloseTag - $i); // Get the list
$i = $CloseTag; // 5d) Move the pointer past the end of the [/close] tag.
} else {
//5b) If it's a normal tag, it may have versions of itself nested inside
$CloseTag = $i-1;
$InTagPos = $i-1;
$CloseTag = $i - 1;
$InTagPos = $i - 1;
$NumInOpens = 0;
$NumInCloses = -1;
@ -364,7 +366,7 @@ private function parse ($Str) {
// 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);
$CloseTag = stripos($Str, '[/'.$TagName.']', $CloseTag + 1);
if ($CloseTag === false) {
$CloseTag = $Len;
break;
@ -373,7 +375,7 @@ private function parse ($Str) {
}
// Is there another open tag inside this one?
$OpenTag = preg_match($InOpenRegex, $Str, $InTag, PREG_OFFSET_CAPTURE, $InTagPos+1);
$OpenTag = preg_match($InOpenRegex, $Str, $InTag, PREG_OFFSET_CAPTURE, $InTagPos + 1);
if (!$OpenTag || $InTag[0][1] > $CloseTag) {
break;
} else {
@ -385,9 +387,9 @@ private function parse ($Str) {
// Find the internal block inside the tag
$Block = substr($Str, $i, $CloseTag-$i); // 5c) Get the contents between [open] and [/close] and call it the block.
$Block = substr($Str, $i, $CloseTag - $i); // 5c) Get the contents between [open] and [/close] and call it the block.
$i = $CloseTag+strlen($TagName)+3; // 5d) Move the pointer past the end of the [/close] tag.
$i = $CloseTag + strlen($TagName) + 3; // 5d) Move the pointer past the end of the [/close] tag.
}
@ -446,7 +448,7 @@ private function parse ($Str) {
$n = $matches[2];
$text = '';
if ($n < 5 && $n > 0) {
$e = str_repeat('=', $matches[2]+1);
$e = str_repeat('=', $matches[2] + 1);
$text = $e . $matches[3] . $e;
}
return $text;
@ -512,7 +514,9 @@ public function parse_toc ($Min = 3)
foreach ($this->Headlines as $t) {
$n = (int) $t[0];
if ($i === 0 && $n > 1) $off = $n - $level;
if ($i === 0 && $n > 1) {
$off = $n - $level;
}
$this->headline_level($n, $level, $list, $i, $off);
$list .= sprintf('<li><a href="#%2$s">%1$s</a>', $t[1], $t[2]);
$level = $t[0];
@ -551,7 +555,7 @@ private function headline_level (&$ItemLevel, &$Level, &$List, $i, &$Offset)
$List .= '</li>' . str_repeat('</ol></li>', $diff);
} elseif ($ItemLevel > $Level) {
$diff = $ItemLevel - $Level;
if ($Offset > 0) $List .= str_repeat('<li><ol>', $Offset-2);
if ($Offset > 0) $List .= str_repeat('<li><ol>', $Offset - 2);
if ($ItemLevel > 1) {
$List .= $i === 0 ? '<li>' : '';
@ -565,7 +569,9 @@ private function headline_level (&$ItemLevel, &$Level, &$List, $i, &$Offset)
private function to_html ($Array) {
global $SSL;
$this->Levels++;
if ($this->Levels>10) { return $Block['Val']; } // Hax prevention
if ($this->Levels > 10) {
return $Block['Val'];
} // Hax prevention
$Str = '';
foreach ($Array as $Block) {
@ -666,9 +672,11 @@ private function to_html ($Array) {
$Str .= sprintf('%1$s%2$s%1$s', str_repeat('=', $Block['Attr'] + 1), $text);
} else {
$id = '_' . crc32($raw . $this->HeadlineID);
if ($this->InQuotes === 0) $this->Headlines[] = array($Block['Attr'], $raw, $id);
if ($this->InQuotes === 0) {
$this->Headlines[] = array($Block['Attr'], $raw, $id);
}
$Str .= sprintf('<h%1$d id="%3$s">%2$s</h%1$d>', ($Block['Attr']+2), $text, $id);
$Str .= sprintf('<h%1$d id="%3$s">%2$s</h%1$d>', ($Block['Attr'] + 2), $text, $id);
$this->HeadlineID++;
}
break;
@ -685,7 +693,7 @@ private function to_html ($Array) {
$this->NoImg++; // No images inside quote tags
$this->InQuotes++;
if (!empty($Block['Attr'])) {
$Exploded = explode("|", $this->to_html($Block['Attr']));
$Exploded = explode('|', $this->to_html($Block['Attr']));
if (isset($Exploded[1]) && is_numeric($Exploded[1])) {
$PostID = trim($Exploded[1]);
$Str.='<a href="#" onclick="QuoteJump(event, '.$PostID.'); return false;"><strong class="quoteheader">'.$Exploded[0].'</strong> wrote: </a>';
@ -718,7 +726,7 @@ private function to_html ($Array) {
}
break;
case 'img':
if ($this->NoImg>0 && $this->valid_url($Block['Val'])) {
if ($this->NoImg > 0 && $this->valid_url($Block['Val'])) {
$Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Val'].'">'.$Block['Val'].'</a> (image)';
break;
}
@ -737,7 +745,7 @@ private function to_html ($Array) {
break;
case 'aud':
if ($this->NoImg>0 && $this->valid_url($Block['Val'])) {
if ($this->NoImg > 0 && $this->valid_url($Block['Val'])) {
$Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Val'].'">'.$Block['Val'].'</a> (audio)';
break;
}

View File

@ -54,7 +54,7 @@ class TEXT_2 {
private $Levels = 0; // If images should be turned into URLs
function __construct() {
foreach($this->Smileys as $Key=>$Val) {
foreach ($this->Smileys as $Key=>$Val) {
$this->Smileys[$Key] = '<img border="0" src="'.STATIC_SERVER.'common/smileys/'.$Val.'" alt="" />';
}
reset($this->Smileys);
@ -110,7 +110,7 @@ function valid_url($Str, $Extension = '', $Inline = false) {
$Regex .= '(:[0-9]{1,5})?'; // port
$Regex .= '\/?'; // slash?
$Regex .= '(\/?[0-9a-z\-_.,&=@~%\/:;()+|!#]+)*'; // /file
if(!empty($Extension)) {
if (!empty($Extension)) {
$Regex.=$Extension;
}
@ -129,16 +129,16 @@ function valid_url($Str, $Extension = '', $Inline = false) {
function local_url($Str) {
$URLInfo = parse_url($Str);
if(!$URLInfo) { return false; }
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)) {
//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'])) {
if (!empty($URLInfo['query'])) {
$URL.='?'.$URLInfo['query'];
}
if(!empty($URLInfo['fragment'])) {
if (!empty($URLInfo['fragment'])) {
$URL.='#'.$URLInfo['fragment'];
}
return $URL;
@ -192,7 +192,7 @@ function parse($Str) {
$Array = array();
$ArrayPos = 0;
while($i<$Len) {
while ($i < $Len) {
$Block = '';
// 1) Find and parse the next tag (regex)
@ -215,7 +215,7 @@ function parse($Str) {
$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])) {
if (!isset($this->ValidTags[$TagName])) {
$IsTag = 0;
}
@ -231,10 +231,10 @@ function parse($Str) {
|| (strpos($Attrib, "'") !== false)
|| (strpos($Attrib, "\"") !== false)) {
$IsTag = 0;
} elseif (strpos($Attrib, "[") !== false) {
} 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) {
if (strpos($Attrib, '['.$PossibleTag) !== false) {
$IsTag = 0;
}
}
@ -246,8 +246,8 @@ function parse($Str) {
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]);
$Array[$ArrayPos] = substr($Str, $i, ($TagPos - $i) + strlen($Tag[0][0]));
$i = $TagPos + strlen($Tag[0][0]);
++$ArrayPos;
continue;
}
@ -255,17 +255,17 @@ function parse($Str) {
}
// 2) If there aren't any tags left, write everything remaining to a block
if(!$IsTag) {
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);
if ($TagPos > $i) {
$Array[$ArrayPos] = substr($Str, $i, $TagPos - $i);
++$ArrayPos;
$i=$TagPos;
$i = $TagPos;
}
// 4) Move the pointer past the end of the tag
@ -279,21 +279,21 @@ function parse($Str) {
//5a) Different for different types of tag. Some tags don't close, others are weird like [*]
if($TagName == 'img' && $HasAttrib) { //[img=...]
if ($TagName == 'img' && $HasAttrib) { //[img=...]
$Block = ''; // Nothing inside this tag
// Don't need to touch $i
} elseif($TagName == 'inlineurl') { // We did a big replace early on to turn http:// into [inlineurl]http://
} elseif ($TagName == 'inlineurl') { // We did a big replace early on to turn http:// into [inlineurl]http://
// Let's say the block can stop at a newline or a space
$CloseTag = strcspn($Str, " \n\r", $i);
if($CloseTag === false) { // block finishes with URL
if ($CloseTag === false) { // block finishes with URL
$CloseTag = $Len;
}
if(preg_match('/[!;,.?:]+$/',substr($Str, $i, $CloseTag), $Match)) {
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, ')')) {
if (substr($URL, -1) == ')' && substr_count($URL, '(') < substr_count($URL, ')')) {
$CloseTag--;
$URL = substr($URL, 0, -1);
}
@ -302,20 +302,20 @@ function parse($Str) {
// 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') {
} elseif ($WikiLink == true || $TagName == 'n') {
// Don't need to do anything - empty tag with no closing
} elseif($TagName == '*') {
} 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) == '[*]');
$NewLine = strpos($Str, "\n", $NewLine + 1);
} while ($NewLine !== false && substr($Str, $NewLine + 1, 3) == '[*]');
$CloseTag = $NewLine;
if($CloseTag === false) { // block finishes with list
if ($CloseTag === false) { // block finishes with list
$CloseTag = $Len;
}
$Block = substr($Str, $i, $CloseTag-$i); // Get the list
$Block = substr($Str, $i, $CloseTag - $i); // Get the list
$i = $CloseTag; // 5d) Move the pointer past the end of the [/close] tag.
} else {
//5b) If it's a normal tag, it may have versions of itself nested inside
@ -325,7 +325,7 @@ function parse($Str) {
$NumInCloses = -1;
$InOpenRegex = '/\[('.$TagName.')';
if($MaxAttribs>0) {
if ($MaxAttribs > 0) {
$InOpenRegex.="(=[^\n'\"\[\]]+)?";
}
$InOpenRegex.='\]/i';
@ -335,7 +335,7 @@ function parse($Str) {
// (as the first close tag won't do - it's been opened again)
do {
$CloseTag = stripos($Str, '[/'.$TagName.']', $CloseTag+1);
if($CloseTag === false) {
if ($CloseTag === false) {
$CloseTag = $Len;
break;
} else {
@ -343,21 +343,21 @@ function parse($Str) {
}
// 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) {
$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);
} 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.
$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.
}
@ -368,7 +368,7 @@ function parse($Str) {
break;
case 'url':
$Array[$ArrayPos] = array('Type'=>'img', 'Attr'=>$Attrib, 'Val'=>$Block);
if(empty($Attrib)) { // [url]http://...[/url] - always set URL to attribute
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));
@ -379,7 +379,7 @@ function parse($Str) {
break;
case 'img':
case 'image':
if(empty($Block)) {
if (empty($Block)) {
$Block = $Attrib;
}
$Array[$ArrayPos] = array('Type'=>'img', 'Val'=>$Block);
@ -387,7 +387,7 @@ function parse($Str) {
case 'aud':
case 'mp3':
case 'audio':
if(empty($Block)) {
if (empty($Block)) {
$Block = $Attrib;
}
$Array[$ArrayPos] = array('Type'=>'aud', 'Val'=>$Block);
@ -417,7 +417,7 @@ function parse($Str) {
case '*':
$Array[$ArrayPos] = array('Type'=>'list');
$Array[$ArrayPos]['Val'] = explode('[*]', $Block);
foreach($Array[$ArrayPos]['Val'] as $Key=>$Val) {
foreach ($Array[$ArrayPos]['Val'] as $Key=>$Val) {
$Array[$ArrayPos]['Val'][$Key] = $this->parse(trim($Val));
}
break;
@ -425,14 +425,14 @@ function parse($Str) {
$ArrayPos--;
break; // n serves only to disrupt bbcode (backwards compatibility - use [pre])
default:
if($WikiLink == true) {
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) {
if (!empty($Attrib) && $MaxAttribs > 0) {
$Array[$ArrayPos]['Attr'] = strtolower($Attrib);
}
}
@ -445,11 +445,13 @@ function parse($Str) {
function to_html($Array) {
$this->Levels++;
if($this->Levels>10) { return $Block['Val']; } // Hax prevention
if ($this->Levels > 10) {
return $Block['Val'];
} // Hax prevention
$Str = '';
foreach($Array as $Block) {
if(is_string($Block)) {
foreach ($Array as $Block) {
if (is_string($Block)) {
$Str.=$this->smileys($Block);
continue;
}
@ -489,7 +491,7 @@ function to_html($Array) {
break;
case 'list':
$Str.='<ul>';
foreach($Block['Val'] as $Line) {
foreach ($Block['Val'] as $Line) {
$Str.='<li>'.$this->to_html($Line).'</li>';
}
@ -497,7 +499,7 @@ function to_html($Array) {
break;
case 'align':
$ValidAttribs = array('left', 'center', 'right');
if(!in_array($Block['Attr'], $ValidAttribs)) {
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>';
@ -506,7 +508,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>';
@ -515,7 +517,7 @@ function to_html($Array) {
case 'inlinesize':
case 'size':
$ValidAttribs = array('1','2','3','4','5','6','7','8','9','10');
if(!in_array($Block['Attr'], $ValidAttribs)) {
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>';
@ -523,7 +525,7 @@ function to_html($Array) {
break;
case 'quote':
$this->NoImg++; // No images inside quote tags
if(!empty($Block['Attr'])) {
if (!empty($Block['Attr'])) {
$Str.='<strong>'.$this->to_html($Block['Attr']).'</strong> wrote: ';
}
$Str.='<blockquote>'.$this->to_html($Block['Val']).'</blockquote>';
@ -534,14 +536,14 @@ function to_html($Array) {
$Str.='<blockquote class="hidden spoiler">'.$this->to_html($Block['Val']).'</blockquote>';
break;
case 'img':
if($this->NoImg>0 && $this->valid_url($Block['Val'])) {
if ($this->NoImg > 0 && $this->valid_url($Block['Val'])) {
$Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Val'].'">'.$Block['Val'].'</a> (image)';
break;
}
if(!$this->valid_url($Block['Val'], '\.(jpe?g|gif|png|bmp|tiff)')) {
if (!$this->valid_url($Block['Val'], '\.(jpe?g|gif|png|bmp|tiff)')) {
$Str.='[img]'.$Block['Val'].'[/img]';
} else {
if(check_perms('site_proxy_images')) {
if (check_perms('site_proxy_images')) {
$Str.='<img style="max-width: 500px;" onclick="lightbox.init(this,500);" alt="'.$Block['Val'].'" src="http'.($SSL?'s':'').'://'.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'].'" />';
@ -550,11 +552,11 @@ function to_html($Array) {
break;
case 'aud':
if($this->NoImg>0 && $this->valid_url($Block['Val'])) {
if ($this->NoImg > 0 && $this->valid_url($Block['Val'])) {
$Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Val'].'">'.$Block['Val'].'</a> (audio)';
break;
}
if(!$this->valid_url($Block['Val'], '\.(mp3|ogg|wav)')) {
if (!$this->valid_url($Block['Val'], '\.(mp3|ogg|wav)')) {
$Str.='[aud]'.$Block['Val'].'[/aud]';
} else {
//TODO: Proxy this for staff?
@ -564,7 +566,7 @@ function to_html($Array) {
case 'url':
// Make sure the URL has a label
if(empty($Block['Val'])) {
if (empty($Block['Val'])) {
$Block['Val'] = $Block['Attr'];
$NoName = true; // If there isn't a Val for this
} else {
@ -572,12 +574,14 @@ function to_html($Array) {
$NoName = false;
}
if(!$this->valid_url($Block['Attr'])) {
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); }
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>';
@ -586,7 +590,7 @@ function to_html($Array) {
break;
case 'inlineurl':
if(!$this->valid_url($Block['Attr'], '', true)) {
if (!$this->valid_url($Block['Attr'], '', true)) {
$Array = $this->parse($Block['Attr']);
$Block['Attr'] = $Array;
$Str.=$this->to_html($Block['Attr']);
@ -594,7 +598,7 @@ function to_html($Array) {
else {
$LocalURL = $this->local_url($Block['Attr']);
if($LocalURL) {
if ($LocalURL) {
$Str.='<a href="'.$LocalURL.'">'.substr($LocalURL,1).'</a>';
} else {
$Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Attr'].'">'.$Block['Attr'].'</a>';
@ -611,8 +615,8 @@ function to_html($Array) {
function raw_text($Array) {
$Str = '';
foreach($Array as $Block) {
if(is_string($Block)) {
foreach ($Array as $Block) {
if (is_string($Block)) {
$Str.=$Block;
continue;
}
@ -641,14 +645,14 @@ function raw_text($Array) {
$Str.=$Block['Val'];
break;
case 'list':
foreach($Block['Val'] as $Line) {
foreach ($Block['Val'] as $Line) {
$Str.='*'.$this->raw_text($Line);
}
break;
case 'url':
// Make sure the URL has a label
if(empty($Block['Val'])) {
if (empty($Block['Val'])) {
$Block['Val'] = $Block['Attr'];
} else {
$Block['Val'] = $this->raw_text($Block['Val']);
@ -658,7 +662,7 @@ function raw_text($Array) {
break;
case 'inlineurl':
if(!$this->valid_url($Block['Attr'], '', true)) {
if (!$this->valid_url($Block['Attr'], '', true)) {
$Array = $this->parse($Block['Attr']);
$Block['Attr'] = $Array;
$Str.=$this->raw_text($Block['Attr']);
@ -675,7 +679,7 @@ function raw_text($Array) {
function smileys($Str) {
global $LoggedUser;
if(!empty($LoggedUser['DisableSmileys'])) {
if (!empty($LoggedUser['DisableSmileys'])) {
return $Str;
}
$Str = strtr($Str, $this->Smileys);

View File

@ -51,7 +51,7 @@ class TEXT_3 {
private $Levels = 0; // If images should be turned into URLs
function __construct() {
foreach($this->Smileys as $Key=>$Val) {
foreach ($this->Smileys as $Key=>$Val) {
$this->Smileys[$Key] = '<img border="0" src="'.STATIC_SERVER.'common/smileys/'.$Val.'" alt="" />';
}
reset($this->Smileys);
@ -102,7 +102,7 @@ function valid_url($Str, $Extension = '', $Inline = false) {
$Regex .= '(:[0-9]{1,5})?'; // port
$Regex .= '\/?'; // slash?
$Regex .= '(\/?[0-9a-z\-_.,&=@~%\/:;()+!#]+)*'; // /file
if(!empty($Extension)) {
if (!empty($Extension)) {
$Regex.=$Extension;
}
@ -121,16 +121,18 @@ function valid_url($Str, $Extension = '', $Inline = false) {
function local_url($Str) {
$URLInfo = parse_url($Str);
if(!$URLInfo) { return false; }
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)) {
//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'])) {
if (!empty($URLInfo['query'])) {
$URL.='?'.$URLInfo['query'];
}
if(!empty($URLInfo['fragment'])) {
if (!empty($URLInfo['fragment'])) {
$URL.='#'.$URLInfo['fragment'];
}
return $URL;
@ -184,7 +186,7 @@ function parse($Str) {
$Array = array();
$ArrayPos = 0;
while($i<$Len) {
while ($i < $Len) {
$Block = '';
// 1) Find the next tag (regex)
@ -192,7 +194,7 @@ function parse($Str) {
$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) {
if (!$IsTag) {
// No more tags
$Array[$ArrayPos] = substr($Str, $i);
break;
@ -200,14 +202,14 @@ function parse($Str) {
// 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);
if ($TagPos > $i) {
$Array[$ArrayPos] = substr($Str, $i, $TagPos - $i);
++$ArrayPos;
$i=$TagPos;
$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
if (!empty($Tag[4][0])) { // Wiki-link
$WikiLink = true;
$TagName = substr($Tag[4][0], 2, -2);
$Attrib = '';
@ -216,9 +218,9 @@ function parse($Str) {
$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]);
if (!isset($this->ValidTags[$TagName])) {
$Array[$ArrayPos] = substr($Str, $i, ($TagPos - $i) + strlen($Tag[0][0]));
$i = $TagPos + strlen($Tag[0][0]);
++$ArrayPos;
continue;
}
@ -226,15 +228,15 @@ function parse($Str) {
$MaxAttribs = $this->ValidTags[$TagName];
// 3b) Get the attribute, if it exists [name=attribute]
if(!empty($Tag[3][0])) {
if (!empty($Tag[3][0])) {
$Attrib = substr($Tag[3][0], 1);
} else {
$Attrib='';
$Attrib = '';
}
}
// 4) Move the pointer past the end of the tag
$i=$TagPos+strlen($Tag[0][0]);
$i = $TagPos + strlen($Tag[0][0]);
// 5) Find out where the tag closes (beginning of [/tag])
@ -244,21 +246,21 @@ function parse($Str) {
//5a) Different for different types of tag. Some tags don't close, others are weird like [*]
if($TagName == 'img' && !empty($Tag[3][0])) { //[img=...]
if ($TagName == 'img' && !empty($Tag[3][0])) { //[img=...]
$Block = ''; // Nothing inside this tag
// Don't need to touch $i
} elseif($TagName == 'inlineurl') { // We did a big replace early on to turn http:// into [inlineurl]http://
} elseif ($TagName == 'inlineurl') { // We did a big replace early on to turn http:// into [inlineurl]http://
// Let's say the block can stop at a newline or a space
$CloseTag = strcspn($Str, " \n\r", $i);
if($CloseTag === false) { // block finishes with URL
if ($CloseTag === false) { // block finishes with URL
$CloseTag = $Len;
}
if(preg_match('/[!;,.?:]+$/',substr($Str, $i, $CloseTag), $Match)) {
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, ')')) {
if (substr($URL, -1) == ')' && substr_count($URL, '(') < substr_count($URL, ')')) {
$CloseTag--;
$URL = substr($URL, 0, -1);
}
@ -267,20 +269,20 @@ function parse($Str) {
// 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') {
} elseif ($WikiLink == true || $TagName == 'n') {
// Don't need to do anything - empty tag with no closing
} elseif($TagName == '*') {
} 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) == '[*]');
$NewLine = strpos($Str, "\n", $NewLine + 1);
} while ($NewLine !== false && substr($Str, $NewLine+1, 3) == '[*]');
$CloseTag = $NewLine;
if($CloseTag === false) { // block finishes with list
if ($CloseTag === false) { // block finishes with list
$CloseTag = $Len;
}
$Block = substr($Str, $i, $CloseTag-$i); // Get the list
$Block = substr($Str, $i, $CloseTag - $i); // Get the list
$i = $CloseTag; // 5d) Move the pointer past the end of the [/close] tag.
} else {
//5b) If it's a normal tag, it may have versions of itself nested inside
@ -290,7 +292,7 @@ function parse($Str) {
$NumInCloses = -1;
$InOpenRegex = '/\[('.$TagName.')';
if($MaxAttribs>0) {
if ($MaxAttribs > 0) {
$InOpenRegex.="(=[^\n'\"\[\]]+)?";
}
$InOpenRegex.='\]/i';
@ -300,7 +302,7 @@ function parse($Str) {
// (as the first close tag won't do - it's been opened again)
do {
$CloseTag = stripos($Str, '[/'.$TagName.']', $CloseTag+1);
if($CloseTag === false) {
if ($CloseTag === false) {
$CloseTag = $Len;
break;
} else {
@ -308,8 +310,8 @@ function parse($Str) {
}
// 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) {
$OpenTag = preg_match($InOpenRegex, $Str, $InTag, PREG_OFFSET_CAPTURE, $InTagPos + 1);
if (!$OpenTag || $InTag[0][1] > $CloseTag) {
break;
} else {
$InTagPos = $InTag[0][1];
@ -333,7 +335,7 @@ function parse($Str) {
break;
case 'url':
$Array[$ArrayPos] = array('Type'=>'img', 'Attr'=>$Attrib, 'Val'=>$Block);
if(empty($Attrib)) { // [url]http://...[/url] - always set URL to attribute
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));
@ -344,7 +346,7 @@ function parse($Str) {
break;
case 'img':
case 'image':
if(empty($Block)) {
if (empty($Block)) {
$Block = $Attrib;
}
$Array[$ArrayPos] = array('Type'=>'img', 'Val'=>$Block);
@ -352,7 +354,7 @@ function parse($Str) {
case 'aud':
case 'mp3':
case 'audio':
if(empty($Block)) {
if (empty($Block)) {
$Block = $Attrib;
}
$Array[$ArrayPos] = array('Type'=>'aud', 'Val'=>$Block);
@ -381,7 +383,7 @@ function parse($Str) {
case '*':
$Array[$ArrayPos] = array('Type'=>'list');
$Array[$ArrayPos]['Val'] = explode('[*]', $Block);
foreach($Array[$ArrayPos]['Val'] as $Key=>$Val) {
foreach ($Array[$ArrayPos]['Val'] as $Key=>$Val) {
$Array[$ArrayPos]['Val'][$Key] = $this->parse(trim($Val));
}
break;
@ -389,14 +391,14 @@ function parse($Str) {
$ArrayPos--;
break; // n serves only to disrupt bbcode (backwards compatibility - use [pre])
default:
if($WikiLink == true) {
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) {
if (!empty($Attrib) && $MaxAttribs>0) {
$Array[$ArrayPos]['Attr'] = strtolower($Attrib);
}
}
@ -409,11 +411,11 @@ function parse($Str) {
function to_html($Array) {
$this->Levels++;
if($this->Levels>10) { return $Block['Val']; } // Hax prevention
if ($this->Levels>10) { return $Block['Val']; } // Hax prevention
$Str = '';
foreach($Array as $Block) {
if(is_string($Block)) {
foreach ($Array as $Block) {
if (is_string($Block)) {
$Str.=$this->smileys($Block);
continue;
}
@ -450,7 +452,7 @@ function to_html($Array) {
break;
case 'list':
$Str.='<ul>';
foreach($Block['Val'] as $Line) {
foreach ($Block['Val'] as $Line) {
$Str.='<li>'.$this->to_html($Line).'</li>';
}
@ -458,7 +460,7 @@ function to_html($Array) {
break;
case 'align':
$ValidAttribs = array('left', 'center', 'right');
if(!in_array($Block['Attr'], $ValidAttribs)) {
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>';
@ -467,7 +469,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>';
@ -476,7 +478,7 @@ function to_html($Array) {
case 'inlinesize':
case 'size':
$ValidAttribs = array('1','2','3','4','5','6','7','8','9','10');
if(!in_array($Block['Attr'], $ValidAttribs)) {
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>';
@ -484,7 +486,7 @@ function to_html($Array) {
break;
case 'quote':
$this->NoImg++; // No images inside quote tags
if(!empty($Block['Attr'])) {
if (!empty($Block['Attr'])) {
$Str.='<strong>'.$this->to_html($Block['Attr']).'</strong> wrote: ';
}
$Str.='<blockquote>'.$this->to_html($Block['Val']).'</blockquote>';
@ -495,14 +497,14 @@ function to_html($Array) {
$Str.='<blockquote class="hidden spoiler">'.$this->to_html($Block['Val']).'</blockquote>';
break;
case 'img':
if($this->NoImg>0 && $this->valid_url($Block['Val'])) {
if ($this->NoImg > 0 && $this->valid_url($Block['Val'])) {
$Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Val'].'">'.$Block['Val'].'</a> (image)';
break;
}
if(!$this->valid_url($Block['Val'], '\.(jpe?g|gif|png|bmp|tiff)')) {
if (!$this->valid_url($Block['Val'], '\.(jpe?g|gif|png|bmp|tiff)')) {
$Str.='[img]'.$Block['Val'].'[/img]';
} else {
if(check_perms('site_proxy_images')) {
if (check_perms('site_proxy_images')) {
$Str.='<img style="max-width: 500px;" onclick="lightbox.init(this,500);" alt="'.$Block['Val'].'" src="http'.($SSL?'s':'').'://'.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'].'" />';
@ -511,11 +513,11 @@ function to_html($Array) {
break;
case 'aud':
if($this->NoImg>0 && $this->valid_url($Block['Val'])) {
if ($this->NoImg > 0 && $this->valid_url($Block['Val'])) {
$Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Val'].'">'.$Block['Val'].'</a> (audio)';
break;
}
if(!$this->valid_url($Block['Val'], '\.(mp3|ogg|wav)')) {
if (!$this->valid_url($Block['Val'], '\.(mp3|ogg|wav)')) {
$Str.='[aud]'.$Block['Val'].'[/aud]';
} else {
//TODO: Proxy this for staff?
@ -525,7 +527,7 @@ function to_html($Array) {
case 'url':
// Make sure the URL has a label
if(empty($Block['Val'])) {
if (empty($Block['Val'])) {
$Block['Val'] = $Block['Attr'];
$NoName = true; // If there isn't a Val for this
} else {
@ -533,12 +535,14 @@ function to_html($Array) {
$NoName = false;
}
if(!$this->valid_url($Block['Attr'])) {
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); }
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>';
@ -547,7 +551,7 @@ function to_html($Array) {
break;
case 'inlineurl':
if(!$this->valid_url($Block['Attr'], '', true)) {
if (!$this->valid_url($Block['Attr'], '', true)) {
$Array = $this->parse($Block['Attr']);
$Block['Attr'] = $Array;
$Str.=$this->to_html($Block['Attr']);
@ -555,7 +559,7 @@ function to_html($Array) {
else {
$LocalURL = $this->local_url($Block['Attr']);
if($LocalURL) {
if ($LocalURL) {
$Str.='<a href="'.$LocalURL.'">'.substr($LocalURL,1).'</a>';
} else {
$Str.='<a rel="noreferrer" target="_blank" href="'.$Block['Attr'].'">'.$Block['Attr'].'</a>';
@ -572,8 +576,8 @@ function to_html($Array) {
function raw_text($Array) {
$Str = '';
foreach($Array as $Block) {
if(is_string($Block)) {
foreach ($Array as $Block) {
if (is_string($Block)) {
$Str.=$Block;
continue;
}
@ -601,14 +605,14 @@ function raw_text($Array) {
$Str.=$Block['Val'];
break;
case 'list':
foreach($Block['Val'] as $Line) {
foreach ($Block['Val'] as $Line) {
$Str.='*'.$this->raw_text($Line);
}
break;
case 'url':
// Make sure the URL has a label
if(empty($Block['Val'])) {
if (empty($Block['Val'])) {
$Block['Val'] = $Block['Attr'];
} else {
$Block['Val'] = $this->raw_text($Block['Val']);
@ -618,7 +622,7 @@ function raw_text($Array) {
break;
case 'inlineurl':
if(!$this->valid_url($Block['Attr'], '', true)) {
if (!$this->valid_url($Block['Attr'], '', true)) {
$Array = $this->parse($Block['Attr']);
$Block['Attr'] = $Array;
$Str.=$this->raw_text($Block['Attr']);
@ -635,7 +639,7 @@ function raw_text($Array) {
function smileys($Str) {
global $LoggedUser;
if(!empty($LoggedUser['DisableSmileys'])) {
if (!empty($LoggedUser['DisableSmileys'])) {
return $Str;
}
$Str = strtr($Str, $this->Smileys);

View File

@ -23,7 +23,7 @@ public static function site_ban_ip($IP) {
return true;
}
}
return false;
}
@ -95,7 +95,7 @@ public static function get_host_by_ip($IP) {
public static function get_host_by_ajax($IP) {
static $ID = 0;
++$ID;
return '<span id="host_'.$ID.'">Resolving host...<script type="text/javascript">ajax.get(\'tools.php?action=get_host&ip='.$IP.'\',function(host){$(\'#host_'.$ID.'\').raw().innerHTML=host;});</script></span>';
return '<span id="host_'.$ID.'">Resolving host...<script type="text/javascript">ajax.get(\'tools.php?action=get_host&ip='.$IP.'\',function(host) {$(\'#host_'.$ID.'\').raw().innerHTML=host;});</script></span>';
}
@ -137,7 +137,7 @@ public static function display_ip($IP) {
public static function get_country_code_by_ajax($IP) {
static $ID = 0;
++$ID;
return '<span id="cc_'.$ID.'">Resolving CC...<script type="text/javascript">ajax.get(\'tools.php?action=get_cc&ip='.$IP.'\',function(cc){$(\'#cc_'.$ID.'\').raw().innerHTML=cc;});</script></span>';
return '<span id="cc_'.$ID.'">Resolving CC...<script type="text/javascript">ajax.get(\'tools.php?action=get_cc&ip='.$IP.'\',function(cc) {$(\'#cc_'.$ID.'\').raw().innerHTML=cc;});</script></span>';
}
@ -154,16 +154,18 @@ public static function disable_users($UserIDs, $AdminComment, $BanReason = 1) {
if (!is_array($UserIDs)) {
$UserIDs = array($UserIDs);
}
$DB->query("UPDATE users_info AS i JOIN users_main AS m ON m.ID=i.UserID
$DB->query("
UPDATE users_info AS i
JOIN users_main AS m ON m.ID=i.UserID
SET m.Enabled='2',
m.can_leech='0',
i.AdminComment = CONCAT('".sqltime()." - ".($AdminComment ? $AdminComment : 'Disabled by system')."\n\n', i.AdminComment),
i.BanDate='".sqltime()."',
i.BanReason='".$BanReason."',
i.RatioWatchDownload=".($BanReason == 2?'m.Downloaded':"'0'")."
m.can_leech='0',
i.AdminComment = CONCAT('".sqltime()." - ".($AdminComment ? $AdminComment : 'Disabled by system')."\n\n', i.AdminComment),
i.BanDate='".sqltime()."',
i.BanReason='".$BanReason."',
i.RatioWatchDownload=".($BanReason == 2 ? 'm.Downloaded' : "'0'")."
WHERE m.ID IN(".implode(',',$UserIDs).") ");
$Cache->decrement('stats_user_count',$DB->affected_rows());
foreach($UserIDs as $UserID) {
foreach ($UserIDs as $UserID) {
$Cache->delete_value('enabled_'.$UserID);
$Cache->delete_value('user_info_'.$UserID);
$Cache->delete_value('user_info_heavy_'.$UserID);

View File

@ -68,8 +68,8 @@ class BENCODE2 {
var $Pos = 1; // Pointer that indicates our position in the string
var $Str = ''; // Torrent string
function __construct($Val, $IsParsed = false){
if(!$IsParsed) {
function __construct($Val, $IsParsed = false) {
if (!$IsParsed) {
$this->Str = $Val;
$this->dec();
} else {
@ -78,20 +78,20 @@ function __construct($Val, $IsParsed = false){
}
// Decode an element based on the type. The type is really just an indicator.
function decode($Type, $Key){
if(is_number($Type)) { // Element is a string
function decode($Type, $Key) {
if (is_number($Type)) { // Element is a string
// Get length of string
$StrLen = $Type;
while($this->Str[$this->Pos+1]!=':'){
while ($this->Str[$this->Pos + 1] != ':') {
$this->Pos++;
$StrLen.=$this->Str[$this->Pos];
}
$this->Val[$Key] = substr($this->Str, $this->Pos+2, $StrLen);
$this->Val[$Key] = substr($this->Str, $this->Pos + 2, $StrLen);
$this->Pos+=$StrLen;
$this->Pos+=2;
$this->Pos += $StrLen;
$this->Pos += 2;
} elseif($Type == 'i') { // Element is an int
} elseif ($Type == 'i') { // Element is an int
$this->Pos++;
// Find end of integer (first occurance of 'e' after position)
@ -99,13 +99,13 @@ function decode($Type, $Key){
// Get the integer, and - IMPORTANT - cast it as an int, so we know later that it's an int and not a string
$this->Val[$Key] = (int)substr($this->Str, $this->Pos, $End-$this->Pos);
$this->Pos = $End+1;
$this->Pos = $End + 1;
} elseif($Type == 'l') { // Element is a list
} elseif ($Type == 'l') { // Element is a list
$this->Val[$Key] = new BENCODE_LIST(substr($this->Str, $this->Pos));
$this->Pos += $this->Val[$Key]->Pos;
} elseif($Type == 'd') { // Element is a dictionary
} elseif ($Type == 'd') { // Element is a dictionary
$this->Val[$Key] = new BENCODE_DICT(substr($this->Str, $this->Pos));
$this->Pos += $this->Val[$Key]->Pos;
// Sort by key to respect spec
@ -118,12 +118,12 @@ function decode($Type, $Key){
}
}
function encode($Val){
if(is_int($Val)) { // Integer
function encode($Val) {
if (is_int($Val)) { // Integer
return 'i'.$Val.'e';
} elseif(is_string($Val)) {
} elseif (is_string($Val)) {
return strlen($Val).':'.$Val;
} elseif(is_object($Val)) {
} elseif (is_object($Val)) {
return $Val->enc();
} else {
return 'fail';
@ -132,7 +132,7 @@ function encode($Val){
}
class BENCODE_LIST extends BENCODE2 {
function enc(){
function enc() {
if (empty($this->Val)) {
return 'le';
}
@ -145,15 +145,15 @@ function enc(){
}
// Decode a list
function dec(){
function dec() {
$Key = 0; // Array index
$Length = strlen($this->Str);
while($this->Pos<$Length){
while ($this->Pos < $Length) {
$Type = $this->Str[$this->Pos];
// $Type now indicates what type of element we're dealing with
// It's either an integer (string), 'i' (an integer), 'l' (a list), 'd' (a dictionary), or 'e' (end of dictionary/list)
if($Type == 'e') { // End of list
if ($Type == 'e') { // End of list
$this->Pos += 1;
unset($this->Str); // Since we're finished parsing the string, we don't need to store it anymore. Benchmarked - this makes the parser run way faster.
return;
@ -169,7 +169,7 @@ function dec(){
}
class BENCODE_DICT extends BENCODE2 {
function enc(){
function enc() {
if (empty($this->Val)) {
return 'de';
}
@ -182,11 +182,11 @@ function enc(){
}
// Decode a dictionary
function dec(){
function dec() {
$Length = strlen($this->Str);
while($this->Pos<$Length) {
while ($this->Pos<$Length) {
if($this->Str[$this->Pos] == 'e') { // End of dictionary
if ($this->Str[$this->Pos] == 'e') { // End of dictionary
$this->Pos += 1;
unset($this->Str); // Since we're finished parsing the string, we don't need to store it anymore. Benchmarked - this makes the parser run way faster.
return;
@ -197,19 +197,19 @@ function dec(){
$KeyLen = $this->Str[$this->Pos];
// Allow for multi-digit lengths
while($this->Str[$this->Pos+1]!=':' && $this->Pos+1<$Length) {
while ($this->Str[$this->Pos + 1] != ':' && $this->Pos + 1 < $Length) {
$this->Pos++;
$KeyLen.=$this->Str[$this->Pos];
}
// $this->Pos is now on the last letter of the key length
// Adding 2 brings it past that character and the ':' to the beginning of the string
$this->Pos+=2;
$this->Pos += 2;
// Get the name of the key
$Key = substr($this->Str, $this->Pos, $KeyLen);
// Move the position past the key to the beginning of the element
$this->Pos+=$KeyLen;
$this->Pos += $KeyLen;
$Type = $this->Str[$this->Pos];
// $Type now indicates what type of element we're dealing with
// It's either an integer (string), 'i' (an integer), 'l' (a list), 'd' (a dictionary), or 'e' (end of dictionary/list)

View File

@ -77,8 +77,8 @@ class BENCODE2 {
var $Pos = 1; // Pointer that indicates our position in the string
var $Str = ''; // Torrent string
function __construct($Val, $IsParsed = false){
if(!$IsParsed) {
function __construct($Val, $IsParsed = false) {
if (!$IsParsed) {
$this->Str = $Val;
$this->dec();
} else {
@ -87,20 +87,20 @@ function __construct($Val, $IsParsed = false){
}
// Decode an element based on the type
function decode($Type, $Key){
if(ctype_digit($Type)) { // Element is a string
function decode($Type, $Key) {
if (ctype_digit($Type)) { // Element is a string
// Get length of string
$StrLen = $Type;
while($this->Str[$this->Pos+1]!=':'){
while ($this->Str[$this->Pos + 1] != ':') {
$this->Pos++;
$StrLen.=$this->Str[$this->Pos];
}
$this->Val[$Key] = substr($this->Str, $this->Pos+2, $StrLen);
$this->Val[$Key] = substr($this->Str, $this->Pos + 2, $StrLen);
$this->Pos+=$StrLen;
$this->Pos+=2;
$this->Pos += $StrLen;
$this->Pos += 2;
} elseif($Type == 'i') { // Element is an int
} elseif ($Type == 'i') { // Element is an int
$this->Pos++;
// Find end of integer (first occurance of 'e' after position)
@ -108,13 +108,13 @@ function decode($Type, $Key){
// Get the integer, and mark it as an int (on our version 64 bit box, we cast it to an int)
$this->Val[$Key] = '[*INT*]'.substr($this->Str, $this->Pos, $End-$this->Pos);
$this->Pos = $End+1;
$this->Pos = $End + 1;
} elseif($Type == 'l') { // Element is a list
} elseif ($Type == 'l') { // Element is a list
$this->Val[$Key] = new BENCODE_LIST(substr($this->Str, $this->Pos));
$this->Pos += $this->Val[$Key]->Pos;
} elseif($Type == 'd') { // Element is a dictionary
} elseif ($Type == 'd') { // Element is a dictionary
$this->Val[$Key] = new BENCODE_DICT(substr($this->Str, $this->Pos));
$this->Pos += $this->Val[$Key]->Pos;
// Sort by key to respect spec
@ -125,14 +125,14 @@ function decode($Type, $Key){
}
}
function encode($Val){
if(is_string($Val)) {
if(substr($Val, 0, 7) == '[*INT*]') {
function encode($Val) {
if (is_string($Val)) {
if (substr($Val, 0, 7) == '[*INT*]') {
return 'i'.substr($Val,7).'e';
} else {
return strlen($Val).':'.$Val;
}
} elseif(is_object($Val)) {
} elseif (is_object($Val)) {
return $Val->enc();
} else {
return 'fail';
@ -141,25 +141,25 @@ function encode($Val){
}
class BENCODE_LIST extends BENCODE2 {
function enc(){
function enc() {
$Str = 'l';
reset($this->Val);
while(list($Key, $Value) = each($this->Val)) {
while (list($Key, $Value) = each($this->Val)) {
$Str.=$this->encode($Value);
}
return $Str.'e';
}
// Decode a list
function dec(){
function dec() {
$Key = 0; // Array index
$Length = strlen($this->Str);
while($this->Pos<$Length){
while ($this->Pos<$Length) {
$Type = $this->Str[$this->Pos];
// $Type now indicates what type of element we're dealing with
// It's either an integer (string), 'i' (an integer), 'l' (a list), 'd' (a dictionary), or 'e' (end of dictionary/list)
if($Type == 'e') { // End of list
if ($Type == 'e') { // End of list
$this->Pos += 1;
unset($this->Str); // Since we're finished parsing the string, we don't need to store it anymore. Benchmarked - this makes the parser run way faster.
return;
@ -175,21 +175,21 @@ function dec(){
}
class BENCODE_DICT extends BENCODE2 {
function enc(){
function enc() {
$Str = 'd';
reset($this->Val);
while(list($Key, $Value) = each($this->Val)) {
while (list($Key, $Value) = each($this->Val)) {
$Str.=strlen($Key).':'.$Key.$this->encode($Value);
}
return $Str.'e';
}
// Decode a dictionary
function dec(){
function dec() {
$Length = strlen($this->Str);
while($this->Pos<$Length) {
while ($this->Pos < $Length) {
if($this->Str[$this->Pos] == 'e') { // End of dictionary
if ($this->Str[$this->Pos] == 'e') { // End of dictionary
$this->Pos += 1;
unset($this->Str); // Since we're finished parsing the string, we don't need to store it anymore. Benchmarked - this makes the parser run way faster.
return;
@ -200,7 +200,7 @@ function dec(){
$KeyLen = $this->Str[$this->Pos];
// Allow for multi-digit lengths
while($this->Str[$this->Pos+1]!=':' && $this->Pos+1<$Length) {
while ($this->Str[$this->Pos + 1] != ':' && $this->Pos + 1 < $Length) {
$this->Pos++;
$KeyLen.=$this->Str[$this->Pos];
}
@ -212,7 +212,7 @@ function dec(){
$Key = substr($this->Str, $this->Pos, $KeyLen);
// Move the position past the key to the beginning of the element
$this->Pos+=$KeyLen;
$this->Pos += $KeyLen;
$Type = $this->Str[$this->Pos];
// $Type now indicates what type of element we're dealing with
// It's either an integer (string), 'i' (an integer), 'l' (a list), 'd' (a dictionary), or 'e' (end of dictionary/list)

View File

@ -258,7 +258,7 @@ function music_form($GenreTags) {
<script type="text/javascript">
//<![CDATA[
hide();
if (document.getElementById("categories").disabled == false){
if (document.getElementById("categories").disabled == false) {
if (navigator.appName == 'Opera') {
var useragent = navigator.userAgent;
var match = useragent.split('Version/');
@ -479,7 +479,7 @@ function show() {
<tr>
<td class="label">Vanity House:</td>
<td>
<label><input type="checkbox" id="vanity_house" name="vanity_house"<? if ($Torrent['GroupID']) { echo ' disabled="disabled"'; } ?><? if ($Torrent['VanityHouse']){ echo ' checked="checked"';} ?> />
<label><input type="checkbox" id="vanity_house" name="vanity_house"<? if ($Torrent['GroupID']) { echo ' disabled="disabled"'; } ?><? if ($Torrent['VanityHouse']) { echo ' checked="checked"';} ?> />
Check this only if you are submitting your own work or submitting on behalf of the artist, and this is intended to be a Vanity House release. Checking this will also automatically add the group as a recommendation.
</label>
</td>
@ -637,7 +637,7 @@ function audiobook_form() {
$Torrent = $this->Torrent;
?>
<table cellpadding="3" cellspacing="1" border="0" class="layout border slice" width="100%">
<? if ($this->NewTorrent){ ?>
<? if ($this->NewTorrent) { ?>
<tr id="title_tr">
<td class="label">Author - Title:</td>
<td>
@ -658,7 +658,9 @@ function audiobook_form() {
<?
foreach (Misc::display_array($this->Formats) as $Format) {
echo '<option value="'.$Format.'"';
if ($Format == $Torrent['Format']) { echo ' selected="selected"'; }
if ($Format == $Torrent['Format']) {
echo ' selected="selected"';
}
echo '>';
echo $Format;
echo "</option>\n";
@ -675,8 +677,8 @@ function audiobook_form() {
<?
if (!$Torrent['Bitrate'] || ($Torrent['Bitrate'] && !in_array($Torrent['Bitrate'], $this->Bitrates))) {
$OtherBitrate = true;
if (substr($Torrent['Bitrate'], strlen($Torrent['Bitrate']) - strlen(" (VBR)")) == " (VBR)") {
$Torrent['Bitrate'] = substr($Torrent['Bitrate'], 0, strlen($Torrent['Bitrate'])-6);
if (substr($Torrent['Bitrate'], strlen($Torrent['Bitrate']) - strlen(' (VBR)')) == ' (VBR)') {
$Torrent['Bitrate'] = substr($Torrent['Bitrate'], 0, strlen($Torrent['Bitrate']) - 6);
$VBR = true;
}
} else {
@ -684,7 +686,7 @@ function audiobook_form() {
}
foreach (Misc::display_array($this->Bitrates) as $Bitrate) {
echo '<option value="'.$Bitrate.'"';
if ($Bitrate == $Torrent['Bitrate'] || ($OtherBitrate && $Bitrate == "Other")) {
if ($Bitrate == $Torrent['Bitrate'] || ($OtherBitrate && $Bitrate == 'Other')) {
echo ' selected="selected"';
}
echo '>';

View File

@ -61,14 +61,16 @@ function table_query($TableName) {
}
function get_rank($TableName, $Value) {
if($Value == 0) { return 0; }
if ($Value == 0) {
return 0;
}
global $Cache, $DB;
$Table = $Cache->get_value(PREFIX.$TableName);
if(!$Table) {
if (!$Table) {
//Cache lock!
$Lock = $Cache->get_value(PREFIX.$TableName."_lock");
if($Lock) {
if ($Lock) {
return false;
} else {
$Cache->cache_value(PREFIX.$TableName."_lock", '1', 300);
@ -79,7 +81,7 @@ function get_rank($TableName, $Value) {
$LastPercentile = 0;
foreach ($Table as $Row) {
list($CurValue) = $Row;
if($CurValue>=$Value) {
if ($CurValue >= $Value) {
return $LastPercentile;
}
$LastPercentile++;
@ -87,11 +89,13 @@ function get_rank($TableName, $Value) {
return 100; // 100th percentile
}
function overall_score($Uploaded, $Downloaded, $Uploads, $Requests, $Posts, $Bounty, $Artists, $Ratio){
function overall_score($Uploaded, $Downloaded, $Uploads, $Requests, $Posts, $Bounty, $Artists, $Ratio) {
// We can do this all in 1 line, but it's easier to read this way
if($Ratio>1) { $Ratio = 1; }
if ($Ratio > 1) {
$Ratio = 1;
}
$TotalScore = 0;
if(in_array(false, func_get_args(), true)) {
if (in_array(false, func_get_args(), true)) {
return false;
}
$TotalScore += $Uploaded*15;

View File

@ -34,13 +34,13 @@ class WIKI {
var $Table = '';
var $PageID = 0;
var $BaseURL = '';
function WIKI($Table, $PageID, $BaseURL = ''){
function WIKI($Table, $PageID, $BaseURL = '') {
$this->Table = $Table;
$this->PageID = $PageID;
$this->BaseURL = $BaseURL;
}
function revision_history(){
function revision_history() {
global $DB;
$BaseURL = $this->BaseURL;
@ -62,7 +62,7 @@ function revision_history(){
</tr>
<? //-----------------------------------------
$Row = 'a';
while(list($RevisionID, $Summary, $Time, $UserID, $Username) = $DB->next_record()){
while (list($RevisionID, $Summary, $Time, $UserID, $Username) = $DB->next_record()) {
$Row = ($Row == 'a') ? 'b' : 'a';
//------------------------------------------------------ ?>
<tr class="row<?=$Row?>">

View File

@ -115,7 +115,7 @@
);
function permissions_form(){ ?>
function permissions_form() { ?>
<div class="permissions">
<div class="permission_container">
<table>

View File

@ -7,15 +7,15 @@
$TorrentForm = new TORRENT_FORM();
$GenreTags = $Cache->get_value('genre_tags');
if(!$GenreTags){
if (!$GenreTags) {
$DB->query('SELECT Name FROM tags WHERE TagType=\'genre\' ORDER BY Name');
$GenreTags = $DB->collect('Name');
$Cache->cache_value('genre_tags', $GenreTags, 3600*24);
$Cache->cache_value('genre_tags', $GenreTags, 3600 * 24);
}
$UploadForm = $Categories[$_GET['categoryid']];
switch($UploadForm) {
switch ($UploadForm) {
case 'Music':
$TorrentForm->music_form($GenreTags);
break;
@ -32,9 +32,7 @@
$TorrentForm->simple_form($_GET['categoryid']);
break;
default:
echo "Invalid action!";
echo 'Invalid action!';
}
?>

View File

@ -10,7 +10,7 @@
if (!empty($_REQUEST['action'])) {
switch ($_REQUEST['action']) {
case 'deadthread' :
if (is_number($_GET['id'])){
if (is_number($_GET['id'])) {
$DB->query("UPDATE blog SET ThreadID=NULL WHERE ID=".$_GET['id']);
$Cache->delete_value('blog');
$Cache->delete_value('feed_blog');
@ -19,7 +19,7 @@
break;
case 'takeeditblog':
authorize();
if (is_number($_POST['blogid']) && is_number($_POST['thread'])){
if (is_number($_POST['blogid']) && is_number($_POST['thread'])) {
$DB->query("UPDATE blog SET Title='".db_string($_POST['title'])."', Body='".db_string($_POST['body'])."', ThreadID=".$_POST['thread']." WHERE ID='".db_string($_POST['blogid'])."'");
$Cache->delete_value('blog');
$Cache->delete_value('feed_blog');
@ -27,14 +27,14 @@
header('Location: blog.php');
break;
case 'editblog':
if (is_number($_GET['id'])){
if (is_number($_GET['id'])) {
$BlogID = $_GET['id'];
$DB->query("SELECT Title, Body, ThreadID FROM blog WHERE ID=$BlogID");
list($Title, $Body, $ThreadID) = $DB->next_record();
}
break;
case 'deleteblog':
if (is_number($_GET['id'])){
if (is_number($_GET['id'])) {
authorize();
$DB->query("DELETE FROM blog WHERE ID='".db_string($_GET['id'])."'");
$Cache->delete_value('blog');
@ -91,7 +91,7 @@
<div class="pad">
<input type="hidden" name="action" value="<?=((empty($_GET['action'])) ? 'takenewblog' : 'takeeditblog')?>" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<? if (!empty($_GET['action']) && $_GET['action'] == 'editblog'){?>
<? if (!empty($_GET['action']) && $_GET['action'] == 'editblog') { ?>
<input type="hidden" name="blogid" value="<?=$BlogID; ?>" />
<? } ?>
<h3>Title</h3>

View File

@ -82,7 +82,7 @@
case 'take_warn':
require(SERVER_ROOT.'/sections/forums/take_warn.php');
break;
default:
error(0);
}

View File

@ -19,7 +19,7 @@
$SS->set_filter('visible', array(1));
}
} else {
switch($_GET['type']) {
switch ($_GET['type']) {
case 'created':
$Title = 'My requests';
$SS->set_filter('userid', array($LoggedUser['ID']));
@ -27,7 +27,9 @@
case 'voted':
if (!empty($_GET['userid'])) {
if (is_number($_GET['userid'])) {
if (!check_paranoia('requestsvoted_list', $UserInfo['Paranoia'], $Perms['Class'], $_GET['userid'])) { error(403); }
if (!check_paranoia('requestsvoted_list', $UserInfo['Paranoia'], $Perms['Class'], $_GET['userid'])) {
error(403);
}
$Title = "Requests voted for by ".$UserInfo['Username'];
$SS->set_filter('voter', array($_GET['userid']));
} else {
@ -42,7 +44,9 @@
if (empty($_GET['userid']) || !is_number($_GET['userid'])) {
error(404);
} else {
if (!check_paranoia('requestsfilled_list', $UserInfo['Paranoia'], $Perms['Class'], $_GET['userid'])) { error(403); }
if (!check_paranoia('requestsfilled_list', $UserInfo['Paranoia'], $Perms['Class'], $_GET['userid'])) {
error(403);
}
$Title = "Requests filled by ".$UserInfo['Username'];
$SS->set_filter('fillerid', array($_GET['userid']));
}
@ -167,7 +171,7 @@
}
}
if (!empty($_GET['tags'])){
if (!empty($_GET['tags'])) {
$Tags = explode(',', $_GET['tags']);
$TagNames = array();
if (!isset($_GET['tags_type']) || $_GET['tags_type'] == 1) {
@ -384,7 +388,7 @@
<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>

View File

@ -1,7 +1,7 @@
<?
enforce_login();
if(!check_perms('site_top10')){
if (!check_perms('site_top10')) {
View::show_header();
?>
<div class="content_basiccontainer">
@ -13,7 +13,7 @@
}
include(SERVER_ROOT.'/sections/torrents/functions.php'); //Has get_reports($TorrentID);
if(empty($_GET['type']) || $_GET['type'] == 'torrents') {
if (empty($_GET['type']) || $_GET['type'] == 'torrents') {
include(SERVER_ROOT.'/sections/top10/torrents.php');
} else {
switch($_GET['type']) {

View File

@ -350,25 +350,25 @@ function generate_torrent_table($Caption, $Tag, $Details, $Limit) {
global $LoggedUser,$Categories,$ReleaseTypes;
?>
<h3>Top <?=$Limit.' '.$Caption?>
<? if (empty($_GET['advanced'])){ ?>
<? if (empty($_GET['advanced'])) { ?>
<small class="top10_quantity_links">
<?
switch($Limit) {
case 100: ?>
- <a href="top10.php?details=<?=$Tag?>" class="brackets">Top 10</a>
- <span class="brackets">Top 100</span>
- <a href="top10.php?type=torrents&amp;limit=250&amp;details=<?=$Tag?>" class="brackets">Top 250</a>
<? break;
case 250: ?>
- <a href="top10.php?details=<?=$Tag?>" class="brackets">Top 10</a>
- <a href="top10.php?type=torrents&amp;limit=100&amp;details=<?=$Tag?>" class="brackets">Top 100</a>
- <span class="brackets">Top 250</span>
<? break;
default: ?>
- <span class="brackets">Top 10</span>
- <a href="top10.php?type=torrents&amp;limit=100&amp;details=<?=$Tag?>" class="brackets">Top 100</a>
- <a href="top10.php?type=torrents&amp;limit=250&amp;details=<?=$Tag?>" class="brackets">Top 250</a>
<? } ?>
switch ($Limit) {
case 100: ?>
- <a href="top10.php?details=<?=$Tag?>" class="brackets">Top 10</a>
- <span class="brackets">Top 100</span>
- <a href="top10.php?type=torrents&amp;limit=250&amp;details=<?=$Tag?>" class="brackets">Top 250</a>
<? break;
case 250: ?>
- <a href="top10.php?details=<?=$Tag?>" class="brackets">Top 10</a>
- <a href="top10.php?type=torrents&amp;limit=100&amp;details=<?=$Tag?>" class="brackets">Top 100</a>
- <span class="brackets">Top 250</span>
<? break;
default: ?>
- <span class="brackets">Top 10</span>
- <a href="top10.php?type=torrents&amp;limit=100&amp;details=<?=$Tag?>" class="brackets">Top 100</a>
- <a href="top10.php?type=torrents&amp;limit=250&amp;details=<?=$Tag?>" class="brackets">Top 250</a>
<? } ?>
</small>
<? } ?>
</h3>
@ -402,7 +402,7 @@ function generate_torrent_table($Caption, $Tag, $Details, $Limit) {
?>
<tr class="rowb">
<td colspan="9" class="center">
Found no torrents matching the criteria
Found no torrents matching the criteria.
</td>
</tr>
</table><br />
@ -449,11 +449,11 @@ function generate_torrent_table($Caption, $Tag, $Details, $Limit) {
$AddExtra = '';
if ($Format) {
$ExtraInfo.=$Format;
$AddExtra=' / ';
$AddExtra = ' / ';
}
if ($Encoding) {
$ExtraInfo.=$AddExtra.$Encoding;
$AddExtra=' / ';
$AddExtra = ' / ';
}
// "FLAC / Lossless / Log (100%) / Cue / CD";
if ($HasLog) {

View File

@ -277,11 +277,11 @@
<? } ?>
| <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" title="Report">RP</a> ]
</span>
&nbsp;&nbsp;&raquo;&nbsp; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Torrent)?><?if($Reported){?> / <strong class="torrent_label tl_reported" title="Reported">Reported</strong><?}?></a>
&nbsp;&nbsp;&raquo;&nbsp; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Torrent)?><? if ($Reported) { ?> / <strong class="torrent_label tl_reported" title="Reported">Reported</strong><? } ?></a>
</td>
<td class="nobr"><?=Format::get_size($Torrent['Size'])?></td>
<td><?=number_format($Torrent['Snatched'])?></td>
<td<?=($Torrent['Seeders']==0)?' class="r00"':''?>><?=number_format($Torrent['Seeders'])?></td>
<td<?=($Torrent['Seeders'] == 0) ? ' class="r00"' : '' ?>><?=number_format($Torrent['Seeders'])?></td>
<td><?=number_format($Torrent['Leechers'])?></td>
</tr>
<?
@ -337,7 +337,7 @@
</td>
<td class="nobr"><?=Format::get_size($Torrent['Size'])?></td>
<td><?=number_format($Torrent['Snatched'])?></td>
<td<?=($Torrent['Seeders']==0)?' class="r00"':''?>><?=number_format($Torrent['Seeders'])?></td>
<td<?=($Torrent['Seeders'] == 0) ? ' class="r00"' : '' ?>><?=number_format($Torrent['Seeders'])?></td>
<td><?=number_format($Torrent['Leechers'])?></td>
</tr>
<?

View File

@ -32,23 +32,23 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProp
}
$SQL .= "
g.ID,
g.Name,
g.Year,
g.RecordLabel,
g.CatalogueNumber,
g.ReleaseType,
g.CategoryID,
g.Time,
g.VanityHouse,
GROUP_CONCAT(DISTINCT tags.Name SEPARATOR '|'),
GROUP_CONCAT(DISTINCT tags.ID SEPARATOR '|'),
GROUP_CONCAT(tt.UserID SEPARATOR '|'),
GROUP_CONCAT(tt.PositiveVotes SEPARATOR '|'),
GROUP_CONCAT(tt.NegativeVotes SEPARATOR '|')
g.ID,
g.Name,
g.Year,
g.RecordLabel,
g.CatalogueNumber,
g.ReleaseType,
g.CategoryID,
g.Time,
g.VanityHouse,
GROUP_CONCAT(DISTINCT tags.Name SEPARATOR '|'),
GROUP_CONCAT(DISTINCT tags.ID SEPARATOR '|'),
GROUP_CONCAT(tt.UserID SEPARATOR '|'),
GROUP_CONCAT(tt.PositiveVotes SEPARATOR '|'),
GROUP_CONCAT(tt.NegativeVotes SEPARATOR '|')
FROM torrents_group AS g
LEFT JOIN torrents_tags AS tt ON tt.GroupID=g.ID
LEFT JOIN tags ON tags.ID=tt.TagID";
LEFT JOIN torrents_tags AS tt ON tt.GroupID=g.ID
LEFT JOIN tags ON tags.ID=tt.TagID";
if ($RevisionID) {
$SQL .= "
@ -66,52 +66,61 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProp
$DB->query("
SELECT
t.ID,
t.Media,
t.Format,
t.Encoding,
t.Remastered,
t.RemasterYear,
t.RemasterTitle,
t.RemasterRecordLabel,
t.RemasterCatalogueNumber,
t.Scene,
t.HasLog,
t.HasCue,
t.LogScore,
t.FileCount,
t.Size,
t.Seeders,
t.Leechers,
t.Snatched,
t.FreeTorrent,
t.Time,
t.Description,
t.FileList,
t.FilePath,
t.UserID,
t.last_action,
HEX(t.info_hash) AS InfoHash,
tbt.TorrentID AS BadTags,
tbf.TorrentID AS BadFolders,
tfi.TorrentID AS BadFiles,
ca.TorrentID AS CassetteApproved,
lma.TorrentID AS LossymasterApproved,
lwa.TorrentID AS LossywebApproved,
t.LastReseedRequest,
tln.TorrentID AS LogInDB,
t.ID AS HasFile
t.ID,
t.Media,
t.Format,
t.Encoding,
t.Remastered,
t.RemasterYear,
t.RemasterTitle,
t.RemasterRecordLabel,
t.RemasterCatalogueNumber,
t.Scene,
t.HasLog,
t.HasCue,
t.LogScore,
t.FileCount,
t.Size,
t.Seeders,
t.Leechers,
t.Snatched,
t.FreeTorrent,
t.Time,
t.Description,
t.FileList,
t.FilePath,
t.UserID,
t.last_action,
HEX(t.info_hash) AS InfoHash,
tbt.TorrentID AS BadTags,
tbf.TorrentID AS BadFolders,
tfi.TorrentID AS BadFiles,
ca.TorrentID AS CassetteApproved,
lma.TorrentID AS LossymasterApproved,
lwa.TorrentID AS LossywebApproved,
t.LastReseedRequest,
tln.TorrentID AS LogInDB,
t.ID AS HasFile
FROM torrents AS t
LEFT JOIN torrents_bad_tags AS tbt ON tbt.TorrentID=t.ID
LEFT JOIN torrents_bad_folders AS tbf on tbf.TorrentID=t.ID
LEFT JOIN torrents_bad_files AS tfi on tfi.TorrentID=t.ID
LEFT JOIN torrents_cassette_approved AS ca on ca.TorrentID=t.ID
LEFT JOIN torrents_lossymaster_approved AS lma on lma.TorrentID=t.ID
LEFT JOIN torrents_lossyweb_approved AS lwa on lwa.TorrentID=t.ID
LEFT JOIN torrents_logs_new AS tln ON tln.TorrentID=t.ID
LEFT JOIN torrents_bad_tags AS tbt ON tbt.TorrentID=t.ID
LEFT JOIN torrents_bad_folders AS tbf on tbf.TorrentID=t.ID
LEFT JOIN torrents_bad_files AS tfi on tfi.TorrentID=t.ID
LEFT JOIN torrents_cassette_approved AS ca on ca.TorrentID=t.ID
LEFT JOIN torrents_lossymaster_approved AS lma on lma.TorrentID=t.ID
LEFT JOIN torrents_lossyweb_approved AS lwa on lwa.TorrentID=t.ID
LEFT JOIN torrents_logs_new AS tln ON tln.TorrentID=t.ID
WHERE t.GroupID='".db_string($GroupID)."'
GROUP BY t.ID
ORDER BY t.Remastered ASC, (t.RemasterYear <> 0) DESC, t.RemasterYear ASC, t.RemasterTitle ASC, t.RemasterRecordLabel ASC, t.RemasterCatalogueNumber ASC, t.Media ASC, t.Format, t.Encoding, t.ID");
ORDER BY t.Remastered ASC,
(t.RemasterYear <> 0) DESC,
t.RemasterYear ASC,
t.RemasterTitle ASC,
t.RemasterRecordLabel ASC,
t.RemasterCatalogueNumber ASC,
t.Media ASC,
t.Format,
t.Encoding,
t.ID");
$TorrentList = $DB->to_array('ID', MYSQLI_ASSOC);
if (count($TorrentList) == 0) {
@ -182,15 +191,17 @@ function get_reports($TorrentID){
global $Cache, $DB;
$Reports = $Cache->get_value('reports_torrent_' . $TorrentID);
if ($Reports === false) {
$DB->query("SELECT r.ID,
$DB->query("
SELECT
r.ID,
r.ReporterID,
r.Type,
r.UserComment,
r.ReportedTime
FROM reportsv2 AS r
WHERE TorrentID = $TorrentID
AND Type != 'edited'
AND Status != 'Resolved'");
FROM reportsv2 AS r
WHERE TorrentID = $TorrentID
AND Type != 'edited'
AND Status != 'Resolved'");
$Reports = $DB->to_array();
$Cache->cache_value('reports_torrent_' . $TorrentID, $Reports, 0);
}
@ -234,7 +245,9 @@ function filelist($Str) {
unset($ReportedTimes);
$Reports = $Cache->get_value('reports_torrent_' . $TorrentID);
if ($Reports === false) {
$DB->query("SELECT r.ID,
$DB->query("
SELECT
r.ID,
r.ReporterID,
r.Type,
r.UserComment,
@ -249,7 +262,7 @@ function filelist($Str) {
if (count($Reports) > 0) {
$Reported = true;
include(SERVER_ROOT . '/sections/reportsv2/array.php');
$ReportInfo = '<table><tr class="colhead_dark" style="font-weight: bold;"><td>This torrent has ' . count($Reports) . ' active ' . (count($Reports) > 1 ? "reports" : "report") . ':</td></tr>';
$ReportInfo = '<table><tr class="colhead_dark" style="font-weight: bold;"><td>This torrent has ' . count($Reports) . ' active ' . (count($Reports) > 1 ? 'reports' : 'report') . ':</td></tr>';
foreach ($Reports as $Report) {
list($ReportID, $ReporterID, $ReportType, $ReportReason, $ReportedTime) = $Report;
@ -466,8 +479,7 @@ function filelist($Str) {
<? }
if (!empty($Description)) {
echo '<blockquote>' . $Text->full_format($Description) . '</blockquote>';
}
?>
} ?>
</td>
</tr>
<?

View File

@ -2,13 +2,13 @@
//Function used for pagination of peer/snatch/download lists on details.php
function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
$NumPages = ceil($NumResults/100);
$NumPages = ceil($NumResults / 100);
$PageLinks = array();
for($i = 1; $i<=$NumPages; $i++) {
if($i == $CurrentPage) {
$PageLinks[]=$i;
for ($i = 1; $i <= $NumPages; $i++) {
if ($i == $CurrentPage) {
$PageLinks[] = $i;
} else {
$PageLinks[]='<a href="#" onclick="'.$Action.'('.$TorrentID.', '.$i.')">'.$i.'</a>';
$PageLinks[] = '<a href="#" onclick="'.$Action.'('.$TorrentID.', '.$i.')">'.$i.'</a>';
}
}
return implode(' | ',$PageLinks);
@ -17,8 +17,8 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
// This gets used in a few places
$ArtistTypes = array(1 => 'Main', 2 => 'Guest', 3 => 'Remixer', 4 => 'Composer', 5 => 'Conductor', 6 => 'DJ/Compiler', 7 => 'Producer');
if(!empty($_REQUEST['action'])) {
switch($_REQUEST['action']){
if (!empty($_REQUEST['action'])) {
switch ($_REQUEST['action']) {
case 'edit':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/edit.php');
@ -53,7 +53,7 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
enforce_login();
include(SERVER_ROOT.'/sections/torrents/peerlist.php');
break;
case 'snatchlist':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/snatchlist.php');
@ -101,7 +101,6 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
include(SERVER_ROOT.'/sections/torrents/delete_alias.php');
break;
case 'history':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/history.php');
@ -180,15 +179,17 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
enforce_login();
authorize();
if (!isset($_POST['groupid']) || !is_number($_POST['groupid']) || trim($_POST['body'])==='' || !isset($_POST['body'])) {
if (!isset($_POST['groupid']) || !is_number($_POST['groupid']) || trim($_POST['body']) === '' || !isset($_POST['body'])) {
error(0);
}
if($LoggedUser['DisablePosting']) {
if ($LoggedUser['DisablePosting']) {
error('Your posting rights have been removed.');
}
$GroupID = $_POST['groupid'];
if(!$GroupID) { error(404); }
if (!$GroupID) {
error(404);
}
$DB->query("SELECT CEIL((SELECT COUNT(ID)+1 FROM torrents_comments AS tc WHERE tc.GroupID='".db_string($GroupID)."')/".TORRENT_COMMENTS_PER_PAGE.") AS Pages");
list($Pages) = $DB->next_record();
@ -197,7 +198,7 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
'".db_string($GroupID)."', '".db_string($LoggedUser['ID'])."','".sqltime()."','".db_string($_POST['body'])."')");
$PostID=$DB->inserted_id();
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE*$Pages-TORRENT_COMMENTS_PER_PAGE)/THREAD_CATALOGUE);
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
$Cache->begin_transaction('torrent_comments_'.$GroupID.'_catalogue_'.$CatalogueID);
$Post = array(
'ID'=>$PostID,
@ -217,7 +218,9 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
case 'get_post':
enforce_login();
if (!$_GET['post'] || !is_number($_GET['post'])) { error(0); }
if (!$_GET['post'] || !is_number($_GET['post'])) {
error(0);
}
$DB->query("SELECT Body FROM torrents_comments WHERE ID='".db_string($_GET['post'])."'");
list($Body) = $DB->next_record(MYSQLI_NUM);
@ -232,7 +235,9 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
$Text = new TEXT;
// Quick SQL injection check
if(!$_POST['post'] || !is_number($_POST['post'])) { error(0); }
if (!$_POST['post'] || !is_number($_POST['post'])) {
error(0);
}
// Mainly
$DB->query("SELECT
@ -247,8 +252,12 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
$DB->query("SELECT ceil(COUNT(ID) / ".TORRENT_COMMENTS_PER_PAGE.") AS Page FROM torrents_comments WHERE GroupID = $GroupID AND ID <= $_POST[post]");
list($Page) = $DB->next_record();
if ($LoggedUser['ID']!=$AuthorID && !check_perms('site_moderate_forums')) { error(404); }
if ($DB->record_count()==0) { error(404); }
if ($LoggedUser['ID'] != $AuthorID && !check_perms('site_moderate_forums')) {
error(404);
}
if ($DB->record_count() == 0) {
error(404);
}
// Perform the update
$DB->query("UPDATE torrents_comments SET
@ -258,7 +267,7 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
WHERE ID='".db_string($_POST['post'])."'");
// Update the cache
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE*$Page-TORRENT_COMMENTS_PER_PAGE)/THREAD_CATALOGUE);
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
$Cache->begin_transaction('torrent_comments_'.$GroupID.'_catalogue_'.$CatalogueID);
$Cache->update_row($_POST['key'], array(
@ -284,10 +293,14 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
authorize();
// Quick SQL injection check
if (!$_GET['postid'] || !is_number($_GET['postid'])) { error(0); }
if (!$_GET['postid'] || !is_number($_GET['postid'])) {
error(0);
}
// Make sure they are moderators
if (!check_perms('site_moderate_forums')) { error(403); }
if (!check_perms('site_moderate_forums')) {
error(403);
}
// Get topicid, forumid, number of pages
$DB->query("SELECT
@ -297,7 +310,7 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
FROM torrents_comments AS tc
WHERE tc.GroupID=(SELECT GroupID FROM torrents_comments WHERE ID=".$_GET['postid'].")
GROUP BY tc.GroupID");
list($GroupID,$Pages,$Page)=$DB->next_record();
list($GroupID, $Pages, $Page) = $DB->next_record();
// $Pages = number of pages in the thread
// $Page = which page the post is on
@ -306,9 +319,9 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
$DB->query("DELETE FROM torrents_comments WHERE ID='".db_string($_GET['postid'])."'");
//We need to clear all subsequential catalogues as they've all been bumped with the absence of this post
$ThisCatalogue = floor((TORRENT_COMMENTS_PER_PAGE*$Page-TORRENT_COMMENTS_PER_PAGE)/THREAD_CATALOGUE);
$LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE*$Pages-TORRENT_COMMENTS_PER_PAGE)/THREAD_CATALOGUE);
for($i=$ThisCatalogue;$i<=$LastCatalogue;$i++) {
$ThisCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
$LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
for ($i = $ThisCatalogue; $i <= $LastCatalogue; $i++) {
$Cache->delete('torrent_comments_'.$GroupID.'_catalogue_'.$i);
}
@ -317,7 +330,7 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
break;
case 'regen_filelist' :
if(check_perms('users_mod') && !empty($_GET['torrentid']) && is_number($_GET['torrentid'])) {
if (check_perms('users_mod') && !empty($_GET['torrentid']) && is_number($_GET['torrentid'])) {
Torrents::regenerate_filelist($_GET['torrentid']);
header('Location: torrents.php?torrentid='.$_GET['torrentid']);
die();
@ -326,14 +339,14 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
}
break;
case 'fix_group' :
if((check_perms('users_mod') || check_perms('torrents_fix_ghosts')) && authorize() && !empty($_GET['groupid']) && is_number($_GET['groupid'])) {
if ((check_perms('users_mod') || check_perms('torrents_fix_ghosts')) && authorize() && !empty($_GET['groupid']) && is_number($_GET['groupid'])) {
$DB->query("SELECT COUNT(ID) FROM torrents WHERE GroupID = ".$_GET['groupid']);
list($Count) = $DB->next_record();
if($Count == 0) {
if ($Count == 0) {
Torrents::delete_group($_GET['groupid']);
} else {
}
if(!empty($_GET['artistid']) && is_number($_GET['artistid'])) {
if (!empty($_GET['artistid']) && is_number($_GET['artistid'])) {
header('Location: artist.php?id='.$_GET['artistid']);
} else {
header('Location: torrents.php?id='.$_GET['groupid']);
@ -351,12 +364,12 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
default:
enforce_login();
if(!empty($_GET['id'])) {
if (!empty($_GET['id'])) {
include(SERVER_ROOT.'/sections/torrents/details.php');
} elseif(isset($_GET['torrentid']) && is_number($_GET['torrentid'])) {
} elseif (isset($_GET['torrentid']) && is_number($_GET['torrentid'])) {
$DB->query("SELECT GroupID FROM torrents WHERE ID=".$_GET['torrentid']);
list($GroupID) = $DB->next_record();
if($GroupID) {
if ($GroupID) {
header("Location: torrents.php?id=".$GroupID."&torrentid=".$_GET['torrentid']);
}
} else {
@ -367,22 +380,22 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
} else {
enforce_login();
if(!empty($_GET['id'])) {
if (!empty($_GET['id'])) {
include(SERVER_ROOT.'/sections/torrents/details.php');
} elseif(isset($_GET['torrentid']) && is_number($_GET['torrentid'])) {
} elseif (isset($_GET['torrentid']) && is_number($_GET['torrentid'])) {
$DB->query("SELECT GroupID FROM torrents WHERE ID=".$_GET['torrentid']);
list($GroupID) = $DB->next_record();
if($GroupID) {
if ($GroupID) {
header("Location: torrents.php?id=".$GroupID."&torrentid=".$_GET['torrentid']."#torrent".$_GET['torrentid']);
} else {
header("Location: log.php?search=Torrent+$_GET[torrentid]");
}
} elseif(!empty($_GET['type'])) {
} elseif (!empty($_GET['type'])) {
include(SERVER_ROOT.'/sections/torrents/user.php');
} elseif(!empty($_GET['groupname']) && !empty($_GET['forward'])) {
} elseif (!empty($_GET['groupname']) && !empty($_GET['forward'])) {
$DB->query("SELECT ID FROM torrents_group WHERE Name LIKE '".db_string($_GET['groupname'])."'");
list($GroupID) = $DB->next_record();
if($GroupID) {
if ($GroupID) {
header("Location: torrents.php?id=".$GroupID);
} else {
include(SERVER_ROOT.'/sections/torrents/browse2.php');

View File

@ -72,7 +72,7 @@
$Properties['TorrentDescription'] = $_POST['release_desc'];
if ($_POST['album_desc']) {
$Properties['GroupDescription'] = trim($_POST['album_desc']);
} elseif ($_POST['desc']){
} elseif ($_POST['desc']) {
$Properties['GroupDescription'] = trim($_POST['desc']);
}
$Properties['GroupID'] = $_POST['groupid'];
@ -116,7 +116,7 @@
}
}
if ($Properties['Remastered'] && !$Properties['UnknownRelease']){
if ($Properties['Remastered'] && !$Properties['UnknownRelease']) {
$Validate->SetFields('remaster_year',
'1','number','Year of remaster/re-issue must be entered.');
} else {
@ -439,11 +439,11 @@
// Don't escape tg.Name. It's written directly to the log table
list($GroupID, $WikiImage, $WikiBody, $RevisionID, $Properties['Title'], $Properties['Year'], $Properties['ReleaseType'], $Properties['TagList']) = $DB->next_record(MYSQLI_NUM, array(4));
$Properties['TagList'] = str_replace(array(" ",".","_"), array(", ",".","."), $Properties['TagList']);
if (!$Properties['Image'] && $WikiImage){
if (!$Properties['Image'] && $WikiImage) {
$Properties['Image'] = $WikiImage;
$T['Image'] = "'".db_string($WikiImage)."'";
}
if (strlen($WikiBody) > strlen($Body)){
if (strlen($WikiBody) > strlen($Body)) {
$Body = $WikiBody;
if (!$Properties['Image'] || $Properties['Image'] == $WikiImage) {
$NoRevision = true;
@ -475,7 +475,7 @@
$Properties['Image'] = $WikiImage;
$T['Image'] = "'".db_string($WikiImage)."'";
}
if (strlen($WikiBody) > strlen($Body)){
if (strlen($WikiBody) > strlen($Body)) {
$Body = $WikiBody;
if (!$Properties['Image'] || $Properties['Image'] == $WikiImage) {
$NoRevision = true;
@ -916,7 +916,7 @@
$DB->query($SQL);
$Debug->set_flag('upload: notification query finished');
if ($DB->record_count()>0){
if ($DB->record_count() > 0) {
$UserArray = $DB->to_array('UserID');
$FilterArray = $DB->to_array('ID');
@ -949,7 +949,7 @@
$Feed->populate('torrents_all',$Item);
$Debug->set_flag('upload: notifications handled');
if ($Type == 'Music'){
if ($Type == 'Music') {
$Feed->populate('torrents_music',$Item);
if ($Properties['Media'] == 'Vinyl') {
$Feed->populate('torrents_vinyl',$Item);

View File

@ -1,9 +1,9 @@
<?
//TODO: Move to somewhere more appropriate, doesn't really belong under users, tools maybe but we don't have that page publicly accessible.
if(isset($_GET['ip']) && isset($_GET['port'])){
if (isset($_GET['ip']) && isset($_GET['port'])) {
$Octets = explode(".", $_GET['ip']);
if(
if (
empty($_GET['ip']) ||
!preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $_GET['ip']) ||
$Octets[0] < 0 ||
@ -20,12 +20,12 @@
die('Invalid IP');
}
if (empty($_GET['port']) || !is_number($_GET['port']) || $_GET['port']<1 || $_GET['port']>65535){
if (empty($_GET['port']) || !is_number($_GET['port']) || $_GET['port'] < 1 || $_GET['port'] > 65535) {
die('Invalid Port');
}
//Error suppression, ugh.
if(@fsockopen($_GET['ip'], $_GET['port'], $Errno, $Errstr, 20)){
if (@fsockopen($_GET['ip'], $_GET['port'], $Errno, $Errstr, 20)) {
die('Port '.$_GET['port'].' on '.$_GET['ip'].' connected successfully.');
} else {
die('Port '.$_GET['port'].' on '.$_GET['ip'].' failed to connect.');

View File

@ -4,14 +4,16 @@
$InviteKey = db_string($_GET['invite']);
$DB->query("SELECT InviterID FROM invites WHERE InviteKey='$InviteKey'");
list($UserID) = $DB->next_record();
if($DB->record_count() == 0 || $UserID!=$LoggedUser['ID']){ error(404); }
if ($DB->record_count() == 0 || $UserID!=$LoggedUser['ID']) {
error(404);
}
$DB->query("DELETE FROM invites WHERE InviteKey='$InviteKey'");
if(!check_perms('site_send_unlimited_invites')){
if (!check_perms('site_send_unlimited_invites')) {
$DB->query("SELECT Invites FROM users_main WHERE ID = ".$UserID." LIMIT 1");
list($Invites) = $DB->next_record();
if($Invites < 10) {
if ($Invites < 10) {
$DB->query("UPDATE users_main SET Invites=Invites+1 WHERE ID='$UserID'");
$Cache->begin_transaction('user_info_heavy_'.$UserID);
$Cache->update_row(false, array('Invites'=>'+1'));

View File

@ -17,22 +17,23 @@
$Val->SetFields('username','1','username','Please enter a username.');
$Err = $Val->ValidateForm($_GET);
if(!$Err){
if (!$Err) {
// Passed validation. Let's rock.
list($Page,$Limit) = Format::page_limit(USERS_PER_PAGE);
if ($Page > 10) {
$Page = 10;
$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("SELECT SQL_CALC_FOUND_ROWS
ID,
Username,
Enabled,
PermissionID,
Donor,
Warned
$DB->query("
SELECT SQL_CALC_FOUND_ROWS
ID,
Username,
Enabled,
PermissionID,
Donor,
Warned
FROM users_main AS um
JOIN users_info AS ui ON ui.UserID=um.ID
JOIN users_info AS ui ON ui.UserID=um.ID
WHERE Username LIKE '%".db_string($_GET['username'], true)."%'
ORDER BY Username
LIMIT $Limit");
@ -53,7 +54,7 @@
</div>
<div class="linkbox">
<?
$Pages=Format::get_pages($Page,$NumResults,USERS_PER_PAGE,9);
$Pages = Format::get_pages($Page, $NumResults, USERS_PER_PAGE, 9);
echo $Pages;
?>
</div>

View File

@ -2,7 +2,7 @@
authorize();
$UserID = $_REQUEST['userid'];
if(!is_number($UserID)) {
if (!is_number($UserID)) {
error(404);
}
@ -39,7 +39,7 @@
$Err = $Val->ValidateForm($_POST);
if($Err) {
if ($Err) {
error($Err);
header('Location: user.php?action=edit&userid='.$UserID);
die();
@ -72,29 +72,29 @@
// if showing exactly 2 of stats, show all 3 of stats
$StatsShown = 0;
$Stats = array('downloaded', 'uploaded', 'ratio');
foreach($Stats as $S) {
if(isset($_POST['p_'.$S])) {
foreach ($Stats as $S) {
if (isset($_POST['p_'.$S])) {
$StatsShown++;
}
}
if($StatsShown == 2) {
foreach($Stats as $S) {
if ($StatsShown == 2) {
foreach ($Stats as $S) {
$_POST['p_'.$S] = 'on';
}
}
$Paranoia = array();
$Checkboxes = array('downloaded', 'uploaded', 'ratio', 'lastseen', 'requiredratio', 'invitedcount', 'artistsadded');
foreach($Checkboxes as $C) {
if(!isset($_POST['p_'.$C])) {
foreach ($Checkboxes as $C) {
if (!isset($_POST['p_'.$C])) {
$Paranoia[] = $C;
}
}
$SimpleSelects = array('torrentcomments', 'collages', 'collagecontribs', 'uploads', 'uniquegroups', 'perfectflacs', 'seeding', 'leeching', 'snatched');
foreach ($SimpleSelects as $S) {
if(!isset($_POST['p_'.$S.'_c']) && !isset($_POST['p_'.$S.'_l'])) {
if (!isset($_POST['p_'.$S.'_c']) && !isset($_POST['p_'.$S.'_l'])) {
// Very paranoid - don't show count or list
$Paranoia[] = $S . '+';
} elseif (!isset($_POST['p_'.$S.'_l'])) {
@ -126,14 +126,14 @@
$DB->query("SELECT Email FROM users_main WHERE ID=".$UserID);
list($CurEmail) = $DB->next_record();
if ($CurEmail != $_POST['email']) {
if(!check_perms('users_edit_profiles')) { // Non-admins have to authenticate to change email
if (!check_perms('users_edit_profiles')) { // Non-admins have to authenticate to change email
$DB->query("SELECT PassHash,Secret FROM users_main WHERE ID='".db_string($UserID)."'");
list($PassHash,$Secret)=$DB->next_record();
if(!Users::check_password($_POST['cur_pass'], $PassHash, $Secret)) {
if (!Users::check_password($_POST['cur_pass'], $PassHash, $Secret)) {
$Err = "You did not enter the correct password.";
}
}
if(!$Err) {
if (!$Err) {
$NewEmail = db_string($_POST['email']);
@ -167,7 +167,7 @@
}
}
if($LoggedUser['DisableAvatar'] && $_POST['avatar'] != $U['Avatar']) {
if ($LoggedUser['DisableAvatar'] && $_POST['avatar'] != $U['Avatar']) {
$Err = "Your avatar rights have been removed.";
}
@ -177,7 +177,7 @@
die();
}
if(!empty($LoggedUser['DefaultSearch'])) {
if (!empty($LoggedUser['DefaultSearch'])) {
$Options['DefaultSearch'] = $LoggedUser['DefaultSearch'];
}
$Options['DisableGrouping2'] = (!empty($_POST['disablegrouping']) ? 1 : 0);
@ -201,14 +201,14 @@
$Options['CoverArt'] = (int) !empty($_POST['coverart']);
if(isset($LoggedUser['DisableFreeTorrentTop10'])) {
if (isset($LoggedUser['DisableFreeTorrentTop10'])) {
$Options['DisableFreeTorrentTop10'] = $LoggedUser['DisableFreeTorrentTop10'];
}
if(!empty($_POST['sorthide'])) {
if (!empty($_POST['sorthide'])) {
$JSON = json_decode($_POST['sorthide']);
foreach($JSON as $J) {
$E = explode("_", $J);
foreach ($JSON as $J) {
$E = explode('_', $J);
$Options['SortHide'][$E[0]] = $E[1];
}
} else {
@ -226,30 +226,29 @@
unset($Options['ShowQueryList']);
unset($Options['ShowCacheList']);
$DownloadAlt = (isset($_POST['downloadalt']))? 1:0;
$UnseededAlerts = (isset($_POST['unseededalerts']))? 1:0;
$DownloadAlt = (isset($_POST['downloadalt'])) ? 1 : 0;
$UnseededAlerts = (isset($_POST['unseededalerts'])) ? 1 : 0;
$LastFMUsername = db_string($_POST['lastfm_username']);
$OldLastFMUsername = "";
$DB->query("SELECT username FROM lastfm_users WHERE ID = '$UserID'");
if($DB->record_count() > 0) {
if ($DB->record_count() > 0) {
list($OldLastFMUsername) = $DB->next_record();
if($OldLastFMUsername != $LastFMUsername) {
if(empty($LastFMUsername)) {
if ($OldLastFMUsername != $LastFMUsername) {
if (empty($LastFMUsername)) {
$DB->query("DELETE FROM lastfm_users WHERE ID = '$UserID'");
} else {
$DB->query("UPDATE lastfm_users SET Username = '$LastFMUsername' WHERE ID = '$UserID'");
}
}
}
elseif(!empty($LastFMUsername)) {
} elseif (!empty($LastFMUsername)) {
$DB->query("INSERT INTO lastfm_users (ID, Username) VALUES ('$UserID', '$LastFMUsername')");
}
// Information on how the user likes to download torrents is stored in cache
if($DownloadAlt != $LoggedUser['DownloadAlt']) {
if ($DownloadAlt != $LoggedUser['DownloadAlt']) {
$Cache->delete_value('user_'.$LoggedUser['torrent_pass']);
}
@ -286,7 +285,7 @@
$SQL .= "m.Paranoia='".db_string(serialize($Paranoia))."'";
if($ResetPassword) {
if ($ResetPassword) {
$ChangerIP = db_string($LoggedUser['IP']);
$PassHash=Users::make_crypt_hash($_POST['new_pass_1']);
$SQL.=",m.PassHash='".db_string($PassHash)."'";

View File

@ -1,6 +1,6 @@
<?
if(!$UserCount = $Cache->get_value('stats_user_count')){
if (!$UserCount = $Cache->get_value('stats_user_count')) {
$DB->query("SELECT COUNT(ID) FROM users_main WHERE Enabled='1'");
list($UserCount) = $DB->next_record();
$Cache->cache_value('stats_user_count', $UserCount, 0);
@ -14,12 +14,11 @@
$DB->query("SELECT can_leech FROM users_main WHERE ID = ".$UserID);
list($CanLeech) = $DB->next_record();
if($LoggedUser['RatioWatch'] ||
if ($LoggedUser['RatioWatch'] ||
!$CanLeech ||
$LoggedUser['DisableInvites'] == '1'||
$LoggedUser['Invites']==0 && !check_perms('site_send_unlimited_invites') ||
$LoggedUser['Invites'] == 0 && !check_perms('site_send_unlimited_invites') ||
($UserCount >= USER_LIMIT && USER_LIMIT != 0 && !check_perms('site_can_invite_always'))) {
error(403);
}
@ -30,15 +29,15 @@
$InviteExpires = time_plus(60*60*24*3); // 3 days
//MultiInvite
if(strpos($Email, '|') && check_perms('site_send_unlimited_invites')) {
if (strpos($Email, '|') && check_perms('site_send_unlimited_invites')) {
$Emails = explode('|', $Email);
} else {
$Emails = array($Email);
}
foreach($Emails as $CurEmail){
foreach ($Emails as $CurEmail) {
if (!preg_match("/^".EMAIL_REGEX."$/i", $CurEmail)) {
if(count($Emails) > 1) {
if (count($Emails) > 1) {
continue;
} else {
error('Invalid email.');
@ -47,7 +46,7 @@
}
}
$DB->query("SELECT Expires FROM invites WHERE InviterID = ".$LoggedUser['ID']." AND Email LIKE '".$CurEmail."'");
if($DB->record_count() > 0) {
if ($DB->record_count() > 0) {
error("You already have a pending invite to that address!");
header('Location: user.php?action=invite');
die();

View File

@ -679,7 +679,7 @@
$Summary = implode(', ', $EditSummary)." by ".$LoggedUser['Username'];
$Summary = sqltime().' - '.ucfirst($Summary);
if ($Reason){
if ($Reason) {
$Summary .= "\nReason: ".$Reason;
}

View File

@ -86,9 +86,9 @@
?>
</tr>
<?
foreach ($History as $Key => $Values){
if (isset($History[$Key+1])) {
$Values['Time'] = $History[$Key+1]['Time'];
foreach ($History as $Key => $Values) {
if (isset($History[$Key + 1])) {
$Values['Time'] = $History[$Key + 1]['Time'];
} else {
$Values['Time'] = $Joined;
}
@ -99,7 +99,16 @@
<td><?=display_str($Values['IP'])?> (<?=display_str($Values['Code'])?>) <a href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($Values['IP'])?>" class="brackets" title="Search">S</a></td>
<?
if ($UsersOnly == 1) {
$ueQuery = $DB->query("SELECT ue.UserID, Username, ue.Time, ue.IP FROM users_history_emails AS ue, users_main WHERE ue.Email = '".db_string($Values['Email'])."' AND UserID != ".$UserID." AND ID = UserID");
$ueQuery = $DB->query("
SELECT
ue.UserID,
Username,
ue.Time,
ue.IP
FROM users_history_emails AS ue, users_main
WHERE ue.Email = '".db_string($Values['Email'])."'
AND UserID != ".$UserID."
AND ID = UserID");
while (list($UserID2, $Time, $IP) = $DB->next_record()) { ?>
</tr>
<tr>
@ -116,7 +125,6 @@
<?
}
}
?>
<? } ?>
} ?>
</table>
<? View::show_footer(); ?>

View File

@ -13,18 +13,26 @@
define('IPS_PER_PAGE', 25);
$UserID = $_GET['userid'];
if (!is_number($UserID)) { error(404); }
if (!is_number($UserID)) {
error(404);
}
$DB->query("SELECT um.Username, p.Level AS Class FROM users_main AS um LEFT JOIN permissions AS p ON p.ID=um.PermissionID WHERE um.ID = ".$UserID);
$DB->query("
SELECT
um.Username,
p.Level AS Class
FROM users_main AS um
LEFT JOIN permissions AS p ON p.ID=um.PermissionID
WHERE um.ID = ".$UserID);
list($Username, $Class) = $DB->next_record();
if(!check_perms('users_view_ips', $Class)) {
if (!check_perms('users_view_ips', $Class)) {
error(403);
}
$UsersOnly = $_GET['usersonly'];
if(isset($_POST['ip'])) {
if (isset($_POST['ip'])) {
$SearchIP = db_string($_POST['ip']);
$SearchIPQuery = " AND h1.IP = '$SearchIP' ";
}
@ -38,7 +46,7 @@ function ShowIPs(rowname) {
}
function Ban(ip, id, elemID) {
var notes = prompt("Enter notes for this ban");
if(notes != null && notes.length > 0) {
if (notes != null && notes.length > 0) {
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
@ -79,7 +87,8 @@ function UnBan(ip, id, elemID) {
list($Page,$Limit) = Format::page_limit(IPS_PER_PAGE);
if ($UsersOnly == 1) {
$RS = $DB->query("SELECT SQL_CALC_FOUND_ROWS
$RS = $DB->query("
SELECT SQL_CALC_FOUND_ROWS
h1.IP,
h1.StartTime,
h1.EndTime,
@ -90,39 +99,42 @@ function UnBan(ip, id, elemID) {
GROUP_CONCAT(um2.Enabled SEPARATOR '|'),
GROUP_CONCAT(ui2.Donor SEPARATOR '|'),
GROUP_CONCAT(ui2.Warned SEPARATOR '|')
FROM users_history_ips AS h1
FROM users_history_ips AS h1
LEFT JOIN users_history_ips AS h2 ON h2.IP=h1.IP AND h2.UserID!=$UserID
LEFT JOIN users_main AS um2 ON um2.ID=h2.UserID
LEFT JOIN users_info AS ui2 ON ui2.UserID=h2.UserID
WHERE h1.UserID='$UserID'
AND h2.UserID>0 $SearchIPQuery
GROUP BY h1.IP, h1.StartTime
ORDER BY h1.StartTime DESC LIMIT $Limit");
AND h2.UserID>0 $SearchIPQuery
GROUP BY h1.IP, h1.StartTime
ORDER BY h1.StartTime DESC
LIMIT $Limit");
} else {
$RS = $DB->query("SELECT SQL_CALC_FOUND_ROWS
h1.IP,
h1.StartTime,
h1.EndTime,
GROUP_CONCAT(h2.UserID SEPARATOR '|'),
GROUP_CONCAT(h2.StartTime SEPARATOR '|'),
GROUP_CONCAT(IFNULL(h2.EndTime,0) SEPARATOR '|'),
GROUP_CONCAT(um2.Username SEPARATOR '|'),
GROUP_CONCAT(um2.Enabled SEPARATOR '|'),
GROUP_CONCAT(ui2.Donor SEPARATOR '|'),
GROUP_CONCAT(ui2.Warned SEPARATOR '|')
$RS = $DB->query("
SELECT SQL_CALC_FOUND_ROWS
h1.IP,
h1.StartTime,
h1.EndTime,
GROUP_CONCAT(h2.UserID SEPARATOR '|'),
GROUP_CONCAT(h2.StartTime SEPARATOR '|'),
GROUP_CONCAT(IFNULL(h2.EndTime,0) SEPARATOR '|'),
GROUP_CONCAT(um2.Username SEPARATOR '|'),
GROUP_CONCAT(um2.Enabled SEPARATOR '|'),
GROUP_CONCAT(ui2.Donor SEPARATOR '|'),
GROUP_CONCAT(ui2.Warned SEPARATOR '|')
FROM users_history_ips AS h1
LEFT JOIN users_history_ips AS h2 ON h2.IP=h1.IP AND h2.UserID!=$UserID
LEFT JOIN users_main AS um2 ON um2.ID=h2.UserID
LEFT JOIN users_info AS ui2 ON ui2.UserID=h2.UserID
LEFT JOIN users_history_ips AS h2 ON h2.IP=h1.IP AND h2.UserID!=$UserID
LEFT JOIN users_main AS um2 ON um2.ID=h2.UserID
LEFT JOIN users_info AS ui2 ON ui2.UserID=h2.UserID
WHERE h1.UserID='$UserID' $SearchIPQuery
GROUP BY h1.IP, h1.StartTime
ORDER BY h1.StartTime DESC LIMIT $Limit");
ORDER BY h1.StartTime DESC
LIMIT $Limit");
}
$DB->query("SELECT FOUND_ROWS()");
list($NumResults) = $DB->next_record();
$DB->set_query_id($RS);
$Pages=Format::get_pages($Page,$NumResults,IPS_PER_PAGE,9);
$Pages = Format::get_pages($Page, $NumResults, IPS_PER_PAGE, 9);
?>
<div class="thin">
@ -130,11 +142,11 @@ function UnBan(ip, id, elemID) {
<h2>IP address history for <a href="/user.php?id=<?=$UserID?>"><?=$Username?></a></h2>
</div>
<div class="linkbox">
<? if($UsersOnly) { ?>
<? if ($UsersOnly) { ?>
<a href="userhistory.php?action=ips&amp;userid=<?=$UserID?>" class="brackets">View all IP addresses</a>
<? } else { ?>
<? } else { ?>
<a href="userhistory.php?action=ips&amp;userid=<?=$UserID?>&amp;usersonly=1" class="brackets">View IP addresses with users</a>
<? } ?>
<? } ?>
<br />
<?=$Pages?>
</div>
@ -164,13 +176,15 @@ function UnBan(ip, id, elemID) {
$Results = $DB->to_array();
$CanManageIPBans = check_perms('admin_manage_ipbans');
foreach($Results as $Index => $Result) {
foreach ($Results as $Index => $Result) {
list($IP, $StartTime, $EndTime, $UserIDs, $UserStartTimes, $UserEndTimes, $Usernames, $UsersEnabled, $UsersDonor, $UsersWarned) = $Result;
$HasDupe = false;
$UserIDs = explode('|', $UserIDs);
if(!$EndTime) { $EndTime = sqltime(); }
if($UserIDs[0] != 0){
if (!$EndTime) {
$EndTime = sqltime();
}
if ($UserIDs[0] != 0) {
$HasDupe = true;
$UserStartTimes = explode('|', $UserStartTimes);
$UserEndTimes = explode('|', $UserEndTimes);
@ -182,14 +196,13 @@ function UnBan(ip, id, elemID) {
?>
<tr class="rowa">
<td>
<?=$IP?> (<?=Tools::get_country_code_by_ajax($IP)?>)
<?
if($CanManageIPBans) {
if(!isset($IPs[$IP])) {
<?=$IP?> (<?=Tools::get_country_code_by_ajax($IP)?>)<?
if ($CanManageIPBans) {
if (!isset($IPs[$IP])) {
$sql = "SELECT ID, FromIP, ToIP FROM ip_bans WHERE '".Tools::ip_to_unsigned($IP)."' BETWEEN FromIP AND ToIP LIMIT 1";
$DB->query($sql);
if($DB->record_count() > 0) {
if ($DB->record_count() > 0) {
$IPs[$IP] = true;
?>
<strong>[Banned]
@ -214,10 +227,12 @@ function UnBan(ip, id, elemID) {
<td><?//time_diff(strtotime($StartTime), strtotime($EndTime)); ?></td>
</tr>
<?
if($HasDupe){
if ($HasDupe) {
$HideMe = (count($UserIDs) > 10);
foreach ($UserIDs as $Key => $Val) {
if(!$UserEndTimes[$Key]){ $UserEndTimes[$Key] = sqltime(); }
if (!$UserEndTimes[$Key]) {
$UserEndTimes[$Key] = sqltime();
}
?>
<tr class="rowb<?=($HideMe ? ' hidden' : '')?>" name="<?=$Index?>">
<td>&nbsp;&nbsp;&#187;&nbsp;<?=Users::format_username($Val, true, true, true)?></td>

View File

@ -11,22 +11,31 @@
************************************************************************/
$UserID = $_GET['userid'];
if (!is_number($UserID)) { error(404); }
if (!is_number($UserID)) {
error(404);
}
$DB->query("SELECT um.Username, p.Level AS Class FROM users_main AS um LEFT JOIN permissions AS p ON p.ID=um.PermissionID WHERE um.ID = ".$UserID);
$DB->query("
SELECT
um.Username,
p.Level AS Class
FROM users_main AS um
LEFT JOIN permissions AS p ON p.ID=um.PermissionID
WHERE um.ID = ".$UserID);
list($Username, $Class) = $DB->next_record();
if(!check_perms('users_view_keys', $Class)) {
if (!check_perms('users_view_keys', $Class)) {
error(403);
}
View::show_header("PassKey history for $Username");
$DB->query("SELECT
OldPassKey,
NewPassKey,
ChangeTime,
ChangerIP
$DB->query("
SELECT
OldPassKey,
NewPassKey,
ChangeTime,
ChangerIP
FROM users_history_passkeys
WHERE UserID=$UserID
ORDER BY ChangeTime DESC");
@ -42,7 +51,7 @@
<td>Changed</td>
<td>IP <a href="/userhistory.php?action=ips&amp;userid=<?=$UserID?>" class="brackets">H</a></td>
</tr>
<? while(list($OldPassKey, $NewPassKey, $ChangeTime, $ChangerIP) = $DB->next_record()){ ?>
<? while (list($OldPassKey, $NewPassKey, $ChangeTime, $ChangerIP) = $DB->next_record()) { ?>
<tr class="rowa">
<td><?=display_str($OldPassKey)?></td>
<td><?=display_str($NewPassKey)?></td>

View File

@ -11,20 +11,29 @@
************************************************************************/
$UserID = $_GET['userid'];
if (!is_number($UserID)) { error(404); }
if (!is_number($UserID)) {
error(404);
}
$DB->query("SELECT um.Username, p.Level AS Class FROM users_main AS um LEFT JOIN permissions AS p ON p.ID=um.PermissionID WHERE um.ID = ".$UserID);
$DB->query("
SELECT
um.Username,
p.Level AS Class
FROM users_main AS um
LEFT JOIN permissions AS p ON p.ID=um.PermissionID
WHERE um.ID = ".$UserID);
list($Username, $Class) = $DB->next_record();
if(!check_perms('users_view_keys', $Class)) {
if (!check_perms('users_view_keys', $Class)) {
error(403);
}
View::show_header("Password reset history for $Username");
$DB->query("SELECT
ChangeTime,
ChangerIP
$DB->query("
SELECT
ChangeTime,
ChangerIP
FROM users_history_passwords
WHERE UserID=$UserID
ORDER BY ChangeTime DESC");
@ -38,7 +47,7 @@
<td>Changed</td>
<td>IP <a href="/userhistory.php?action=ips&amp;userid=<?=$UserID?>" class="brackets">H</a></td>
</tr>
<? while(list($ChangeTime, $ChangerIP) = $DB->next_record()){ ?>
<? while (list($ChangeTime, $ChangerIP) = $DB->next_record()) { ?>
<tr class="rowa">
<td><?=time_diff($ChangeTime)?></td>
<td><?=display_str($ChangerIP)?> <a href="/user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($ChangerIP)?>" class="brackets" title="Search">S</a><br /><?=Tools::get_host_by_ajax($ChangerIP)?></td>

View File

@ -4,7 +4,7 @@
User post history page
*/
if(!empty($LoggedUser['DisableForums'])) {
if (!empty($LoggedUser['DisableForums'])) {
error(403);
}
@ -14,7 +14,7 @@
$UserID = empty($_GET['userid']) ? $LoggedUser['ID'] : $_GET['userid'];
if(!is_number($UserID)){
if (!is_number($UserID)) {
error(0);
}
@ -26,7 +26,7 @@
list($Page,$Limit) = Format::page_limit($PerPage);
if(($UserInfo = $Cache->get_value('user_info_'.$UserID)) === false) {
if (($UserInfo = $Cache->get_value('user_info_'.$UserID)) === false) {
$DB->query("SELECT
m.Username,
m.Enabled,
@ -38,7 +38,7 @@
JOIN users_info AS i ON i.UserID = m.ID
WHERE m.ID = $UserID");
if($DB->record_count() == 0){ // If user doesn't exist
if ($DB->record_count() == 0) { // If user doesn't exist
error(404);
}
list($Username, $Enabled, $Title, $Avatar, $Donor, $Warned) = $DB->next_record();
@ -46,26 +46,26 @@
extract(array_intersect_key($UserInfo, array_flip(array('Username', 'Enabled', 'Title', 'Avatar', 'Donor', 'Warned'))));
}
if(check_perms('site_proxy_images') && !empty($Avatar)) {
if (check_perms('site_proxy_images') && !empty($Avatar)) {
$Avatar = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?c=1&amp;i='.urlencode($Avatar);
}
View::show_header('Post history for '.$Username,'subscriptions,comments,bbcode');
if($LoggedUser['CustomForums']) {
if ($LoggedUser['CustomForums']) {
unset($LoggedUser['CustomForums']['']);
$RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0));
}
$ViewingOwn = ($UserID == $LoggedUser['ID']);
$ShowUnread = ($ViewingOwn && (!isset($_GET['showunread']) || !!$_GET['showunread']));
$ShowGrouped = ($ViewingOwn && (!isset($_GET['group']) || !!$_GET['group']));
if($ShowGrouped) {
if ($ShowGrouped) {
$sql = 'SELECT
SQL_CALC_FOUND_ROWS
MAX(p.ID) AS ID
FROM forums_posts AS p
LEFT JOIN forums_topics AS t ON t.ID = p.TopicID';
if($ShowUnread) {
if ($ShowUnread) {
$sql.='
LEFT JOIN forums_last_read_topics AS l ON l.TopicID = t.ID AND l.UserID = '.$LoggedUser['ID'];
}
@ -73,17 +73,17 @@
LEFT JOIN forums AS f ON f.ID = t.ForumID
WHERE p.AuthorID = '.$UserID.'
AND ((f.MinClassRead <= '.$LoggedUser['EffectiveClass'];
if(!empty($RestrictedForums)) {
if (!empty($RestrictedForums)) {
$sql.='
AND f.ID NOT IN (\''.$RestrictedForums.'\')';
}
$sql .= ')';
if(!empty($PermittedForums)) {
if (!empty($PermittedForums)) {
$sql.='
OR f.ID IN (\''.$PermittedForums.'\')';
}
$sql .= ')';
if($ShowUnread) {
if ($ShowUnread) {
$sql .= '
AND ((t.IsLocked=\'0\' OR t.IsSticky=\'1\')
AND (l.PostID<t.LastPostID OR l.PostID IS NULL))';
@ -95,29 +95,30 @@
$DB->query("SELECT FOUND_ROWS()");
list($Results) = $DB->next_record();
if($Results > $PerPage*($Page-1)) {
if ($Results > $PerPage*($Page-1)) {
$DB->set_query_id($PostIDs);
$PostIDs = $DB->collect('ID');
$sql = 'SELECT
p.ID,
p.AddedTime,
p.Body,
p.EditedUserID,
p.EditedTime,
ed.Username,
p.TopicID,
t.Title,
t.LastPostID,
l.PostID AS LastRead,
t.IsLocked,
t.IsSticky
$sql = '
SELECT
p.ID,
p.AddedTime,
p.Body,
p.EditedUserID,
p.EditedTime,
ed.Username,
p.TopicID,
t.Title,
t.LastPostID,
l.PostID AS LastRead,
t.IsLocked,
t.IsSticky
FROM forums_posts as p
LEFT JOIN users_main AS um ON um.ID = p.AuthorID
LEFT JOIN users_info AS ui ON ui.UserID = p.AuthorID
LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID
JOIN forums_topics AS t ON t.ID = p.TopicID
JOIN forums AS f ON f.ID = t.ForumID
LEFT JOIN forums_last_read_topics AS l ON l.UserID = '.$UserID.' AND l.TopicID = t.ID
LEFT JOIN users_main AS um ON um.ID = p.AuthorID
LEFT JOIN users_info AS ui ON ui.UserID = p.AuthorID
LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID
JOIN forums_topics AS t ON t.ID = p.TopicID
JOIN forums AS f ON f.ID = t.ForumID
LEFT JOIN forums_last_read_topics AS l ON l.UserID = '.$UserID.' AND l.TopicID = t.ID
WHERE p.ID IN ('.implode(',',$PostIDs).')
ORDER BY p.ID DESC';
$Posts = $DB->query($sql);
@ -125,7 +126,7 @@
} else {
$sql = 'SELECT
SQL_CALC_FOUND_ROWS';
if($ShowGrouped) {
if ($ShowGrouped) {
$sql.=' * FROM (SELECT';
}
$sql .= '
@ -138,7 +139,7 @@
p.TopicID,
t.Title,
t.LastPostID,';
if($UserID == $LoggedUser['ID']) {
if ($UserID == $LoggedUser['ID']) {
$sql .= '
l.PostID AS LastRead,';
}
@ -146,21 +147,21 @@
t.IsLocked,
t.IsSticky
FROM forums_posts as p
LEFT JOIN users_main AS um ON um.ID = p.AuthorID
LEFT JOIN users_info AS ui ON ui.UserID = p.AuthorID
LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID
JOIN forums_topics AS t ON t.ID = p.TopicID
JOIN forums AS f ON f.ID = t.ForumID
LEFT JOIN forums_last_read_topics AS l ON l.UserID = '.$UserID.' AND l.TopicID = t.ID
LEFT JOIN users_main AS um ON um.ID = p.AuthorID
LEFT JOIN users_info AS ui ON ui.UserID = p.AuthorID
LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID
JOIN forums_topics AS t ON t.ID = p.TopicID
JOIN forums AS f ON f.ID = t.ForumID
LEFT JOIN forums_last_read_topics AS l ON l.UserID = '.$UserID.' AND l.TopicID = t.ID
WHERE p.AuthorID = '.$UserID.'
AND f.MinClassRead <= '.$LoggedUser['EffectiveClass'];
AND f.MinClassRead <= '.$LoggedUser['EffectiveClass'];
if(!empty($RestrictedForums)) {
if (!empty($RestrictedForums)) {
$sql.='
AND f.ID NOT IN (\''.$RestrictedForums.'\')';
}
if($ShowUnread) {
if ($ShowUnread) {
$sql.='
AND ((t.IsLocked=\'0\' OR t.IsSticky=\'1\') AND (l.PostID<t.LastPostID OR l.PostID IS NULL)) ';
}
@ -168,7 +169,7 @@
$sql .= '
ORDER BY p.ID DESC';
if($ShowGrouped) {
if ($ShowGrouped) {
$sql.='
) AS sub
GROUP BY TopicID ORDER BY ID DESC';
@ -188,10 +189,10 @@
<div class="header">
<h2>
<?
if($ShowGrouped) {
echo "Grouped ".($ShowUnread?"unread ":"")."post history for <a href=\"user.php?id=$UserID\">$Username</a>";
if ($ShowGrouped) {
echo 'Grouped '.($ShowUnread ? 'unread ' : '')."post history for <a href=\"user.php?id=$UserID\">$Username</a>";
}
elseif($ShowUnread) {
elseif ($ShowUnread) {
echo "Unread post history for <a href=\"user.php?id=$UserID\">$Username</a>";
}
else {
@ -237,45 +238,45 @@
</div>
</div>
<?
if(empty($Results)) {
if (empty($Results)) {
?>
<div class="center">
No topics<?=$ShowUnread?' with unread posts':''?>
No topics<?=$ShowUnread ? ' with unread posts' : '' ?>
</div>
<?
} else {
?>
<div class="linkbox">
<?
$Pages=Format::get_pages($Page,$Results,$PerPage, 11);
$Pages=Format::get_pages($Page, $Results, $PerPage, 11);
echo $Pages;
?>
</div>
<?
while(list($PostID, $AddedTime, $Body, $EditedUserID, $EditedTime, $EditedUsername, $TopicID, $ThreadTitle, $LastPostID, $LastRead, $Locked, $Sticky) = $DB->next_record()){
while (list($PostID, $AddedTime, $Body, $EditedUserID, $EditedTime, $EditedUsername, $TopicID, $ThreadTitle, $LastPostID, $LastRead, $Locked, $Sticky) = $DB->next_record()) {
?>
<table class="forum_post vertical_margin<?=$HeavyInfo['DisableAvatars'] ? ' noavatar' : ''?>" id="post<?=$PostID ?>">
<table class="forum_post vertical_margin<?=$HeavyInfo['DisableAvatars'] ? ' noavatar' : '' ?>" id="post<?=$PostID ?>">
<colgroup>
<? if(empty($HeavyInfo['DisableAvatars'])) { ?>
<? if (empty($HeavyInfo['DisableAvatars'])) { ?>
<col class="col_avatar" />
<? } ?>
<col class="col_post_body" />
</colgroup>
<tr class="colhead_dark">
<td colspan="<?=empty($HeavyInfo['DisableAvatars']) ? 2 : 1?>">
<span style="float:left;">
<td colspan="<?=empty($HeavyInfo['DisableAvatars']) ? 2 : 1 ?>">
<span style="float: left;">
<?=time_diff($AddedTime) ?>
in <a href="forums.php?action=viewthread&amp;threadid=<?=$TopicID?>&amp;postid=<?=$PostID?>#post<?=$PostID?>" title="<?=display_str($ThreadTitle)?>"><?=Format::cut_string($ThreadTitle, 75)?></a>
<?
if($ViewingOwn) {
if ($ViewingOwn) {
if ((!$Locked || $Sticky) && (!$LastRead || $LastRead < $LastPostID)) { ?>
<span class="new">(New!)</span>
<?
}
?>
</span>
<? if(!empty($LastRead)) { ?>
<span style="float:left;" class="last_read" title="Jump to last read">
<? if (!empty($LastRead)) { ?>
<span style="float: left;" class="last_read" title="Jump to last read">
<a href="forums.php?action=viewthread&amp;threadid=<?=$TopicID?>&amp;postid=<?=$LastRead?>#post<?=$LastRead?>"></a>
</span>
<? }
@ -284,8 +285,8 @@
</span>
<? }
?>
<span id="bar<?=$PostID ?>" style="float:right;">
<? if($ViewingOwn && !in_array($TopicID, $UserSubscriptions)) { ?>
<span id="bar<?=$PostID ?>" style="float: right;">
<? if ($ViewingOwn && !in_array($TopicID, $UserSubscriptions)) { ?>
<a href="#" onclick="Subscribe(<?=$TopicID?>);$('.subscribelink<?=$TopicID?>').remove();return false;" class="brackets subscribelink<?=$TopicID?>">Subscribe</a>
&nbsp;
<? } ?>
@ -294,15 +295,15 @@
</td>
</tr>
<?
if(!$ShowGrouped) {
if (!$ShowGrouped) {
?>
<tr>
<?
if(empty($HeavyInfo['DisableAvatars'])) {
if (empty($HeavyInfo['DisableAvatars'])) {
?>
<td class="avatar" valign="top">
<?
if($Avatar) {
if ($Avatar) {
?>
<img src="<?=$Avatar?>" width="150" style="max-height:400px;" alt="<?=$Username?>'s avatar" />
<?
@ -315,10 +316,10 @@
<td class="body" valign="top">
<div id="content<?=$PostID?>">
<?=$Text->full_format($Body)?>
<? if($EditedUserID) { ?>
<? if ($EditedUserID) { ?>
<br />
<br />
<? if(check_perms('site_moderate_forums')) { ?>
<? if (check_perms('site_moderate_forums')) { ?>
<a href="#content<?=$PostID?>" onclick="LoadEdit(<?=$PostID?>, 1)">&laquo;</a>
<? } ?>
Last edited by

View File

@ -3,7 +3,7 @@
User topic subscription page
*/
if(!empty($LoggedUser['DisableForums'])) {
if (!empty($LoggedUser['DisableForums'])) {
error(403);
}
@ -19,7 +19,7 @@
View::show_header('Subscribed topics','subscriptions,bbcode');
if($LoggedUser['CustomForums']) {
if ($LoggedUser['CustomForums']) {
unset($LoggedUser['CustomForums']['']);
$RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0));
$PermittedForums = implode("','", array_keys($LoggedUser['CustomForums'], 1));
@ -39,15 +39,15 @@
JOIN forums AS f ON f.ID = t.ForumID
WHERE p.ID <= IFNULL(l.PostID,t.LastPostID)
AND ((f.MinClassRead <= '.$LoggedUser['Class'];
if(!empty($RestrictedForums)) {
if (!empty($RestrictedForums)) {
$sql.=' AND f.ID NOT IN (\''.$RestrictedForums.'\')';
}
$sql .= ')';
if(!empty($PermittedForums)) {
if (!empty($PermittedForums)) {
$sql.=' OR f.ID IN (\''.$PermittedForums.'\')';
}
$sql .= ')';
if($ShowUnread) {
if ($ShowUnread) {
$sql .= '
@ -63,7 +63,7 @@
$DB->query('SELECT FOUND_ROWS()');
list($NumResults) = $DB->next_record();
if($NumResults > $PerPage*($Page-1)) {
if ($NumResults > $PerPage*($Page-1)) {
$DB->set_query_id($PostIDs);
$PostIDs = $DB->collect('ID');
$sql = 'SELECT
@ -99,7 +99,7 @@
<div class="linkbox">
<?
if(!$ShowUnread) {
if (!$ShowUnread) {
?>
<br /><br />
<a href="userhistory.php?action=subscriptions&amp;showunread=1" class="brackets">Only display topics with unread replies</a>&nbsp;&nbsp;&nbsp;
@ -110,7 +110,7 @@
<a href="userhistory.php?action=subscriptions&amp;showunread=0" class="brackets">Show all subscribed topics</a>&nbsp;&nbsp;&nbsp;
<?
}
if($NumResults) {
if ($NumResults) {
?>
<a href="#" onclick="Collapse();return false;" id="collapselink" class="brackets"><?=$ShowCollapsed?'Show':'Hide'?> post bodies</a>&nbsp;&nbsp;&nbsp;
<?
@ -122,10 +122,10 @@
</div>
</div>
<?
if(!$NumResults) {
if (!$NumResults) {
?>
<div class="center">
No subscribed topics<?=$ShowUnread?' with unread posts':''?>
No subscribed topics<?=$ShowUnread ? ' with unread posts' : '' ?>
</div>
<?
} else {
@ -137,23 +137,23 @@
?>
</div>
<?
while(list($ForumID, $ForumName, $TopicID, $ThreadTitle, $Body, $LastPostID, $Locked, $Sticky, $PostID, $AuthorID, $AuthorName, $AuthorAvatar, $EditedUserID, $EditedTime, $EditedUsername) = $DB->next_record()){
while (list($ForumID, $ForumName, $TopicID, $ThreadTitle, $Body, $LastPostID, $Locked, $Sticky, $PostID, $AuthorID, $AuthorName, $AuthorAvatar, $EditedUserID, $EditedTime, $EditedUsername) = $DB->next_record()) {
?>
<table class="forum_post box vertical_margin<?=$HeavyInfo['DisableAvatars'] ? ' noavatar' : ''?>">
<table class="forum_post box vertical_margin<?=$HeavyInfo['DisableAvatars'] ? ' noavatar' : '' ?>">
<colgroup>
<? if(empty($HeavyInfo['DisableAvatars'])) { ?>
<? if (empty($HeavyInfo['DisableAvatars'])) { ?>
<col class="col_avatar" />
<? } ?>
<col class="col_post_body" />
</colgroup>
<tr class="colhead_dark">
<td colspan="<?=empty($HeavyInfo['DisableAvatars']) ? 2 : 1?>">
<td colspan="<?=empty($HeavyInfo['DisableAvatars']) ? 2 : 1 ?>">
<span style="float:left;">
<a href="forums.php?action=viewforum&amp;forumid=<?=$ForumID?>"><?=$ForumName?></a> &gt;
<a href="forums.php?action=viewthread&amp;threadid=<?=$TopicID?>" title="<?=display_str($ThreadTitle)?>"><?=Format::cut_string($ThreadTitle, 75)?></a>
<? if($PostID<$LastPostID && !$Locked) { ?>
<? if ($PostID < $LastPostID && !$Locked) { ?>
<span class="new">(New!)</span>
<? } ?>
<? } ?>
</span>
<span style="float:left;" class="last_read" title="Jump to last read">
<a href="forums.php?action=viewthread&amp;threadid=<?=$TopicID.($PostID?'&amp;postid='.$PostID.'#post'.$PostID:'')?>"></a>
@ -165,36 +165,36 @@
</span>
</td>
</tr>
<tr class="row<?=$ShowCollapsed?' hidden':''?>">
<? if(empty($HeavyInfo['DisableAvatars'])) { ?>
<tr class="row<?=$ShowCollapsed ? ' hidden' : '' ?>">
<? if (empty($HeavyInfo['DisableAvatars'])) { ?>
<td class="avatar" valign="top">
<? if(check_perms('site_proxy_images') && preg_match('/^https?:\/\/(localhost(:[0-9]{2,5})?|[0-9]{1,3}(\.[0-9]{1,3}){3}|([a-zA-Z0-9\-\_]+\.)+([a-zA-Z]{1,5}[^\.]))(:[0-9]{2,5})?(\/[^<>]+)+\.(jpg|jpeg|gif|png|tif|tiff|bmp)$/is',$AuthorAvatar)) {
<? if (check_perms('site_proxy_images') && preg_match('/^https?:\/\/(localhost(:[0-9]{2,5})?|[0-9]{1,3}(\.[0-9]{1,3}){3}|([a-zA-Z0-9\-\_]+\.)+([a-zA-Z]{1,5}[^\.]))(:[0-9]{2,5})?(\/[^<>]+)+\.(jpg|jpeg|gif|png|tif|tiff|bmp)$/is',$AuthorAvatar)) {
$AuthorAvatar = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?c=1&amp;i='.urlencode($AuthorAvatar); ?>
<img src="<?=$AuthorAvatar?>" width="150" style="max-height:400px;" alt="<?=$AuthorName?>'s avatar" />
<? } elseif(!$AuthorAvatar) { ?>
<img src="<?=STATIC_SERVER.'common/avatars/default.png'?>" width="150" style="max-height:400px;" alt="Default avatar" />
<? } else { ?>
<img src="<?=$AuthorAvatar?>" width="150" style="max-height:400px;" alt="<?=$AuthorName?>'s avatar" />
<? } ?>
<img src="<?=$AuthorAvatar?>" width="150" style="max-height: 400px;" alt="<?=$AuthorName?>'s avatar" />
<? } elseif (!$AuthorAvatar) { ?>
<img src="<?=STATIC_SERVER.'common/avatars/default.png'?>" width="150" style="max-height: 400px;" alt="Default avatar" />
<? } else { ?>
<img src="<?=$AuthorAvatar?>" width="150" style="max-height: 400px;" alt="<?=$AuthorName?>'s avatar" />
<? } ?>
</td>
<? } ?>
<? } ?>
<td class="body" valign="top">
<div class="content3">
<?=$Text->full_format($Body) ?>
<? if($EditedUserID) { ?>
<? if ($EditedUserID) { ?>
<br /><br />
Last edited by
<?=Users::format_username($EditedUserID, false, false, false) ?> <?=time_diff($EditedTime)?>
<? } ?>
<? } ?>
</div>
</td>
</tr>
</table>
<? } // while(list(...)) ?>
<? } // while (list(...)) ?>
<div class="linkbox">
<?=$Pages?>
</div>
<? } // else -- if(empty($NumResults)) ?>
<? } // else -- if (empty($NumResults)) ?>
</div>
<?

View File

@ -1,14 +1,16 @@
<?
authorize();
//Todo, check that loggeduser > edit
if(!is_number($_POST['article']) || $_POST['article'] == ''){ error(0); }
//TODO, check that loggeduser > edit
if (!is_number($_POST['article']) || $_POST['article'] == '') {
error(0);
}
$ArticleID = $_POST['article'];
$NewAlias = $Alias->convert($_POST['alias']);
$Dupe = $Alias->to_id($_POST['alias']);
if($NewAlias!='' && $NewAlias!='addalias' && !$Dupe){ //Not null, and not dupe
if ($NewAlias != '' && $NewAlias!='addalias' && !$Dupe) { //Not null, and not dupe
$DB->query("INSERT INTO wiki_aliases (Alias, UserID, ArticleID) VALUES ('$NewAlias', '$LoggedUser[ID]', '$ArticleID')");
$Alias->flush();
} else {

View File

@ -1,10 +1,14 @@
<?
if(!isset($_GET['id']) || !is_number($_GET['id'])) { error(404); }
if (!isset($_GET['id']) || !is_number($_GET['id'])) {
error(404);
}
$ArticleID = $_GET['id'];
$Latest = $Alias->article($ArticleID);
list($Revision, $Title, $Body, $Read, $Edit, $Date, $AuthorID, $AuthorName) = array_shift($Latest);
if($Edit > $LoggedUser['EffectiveClass']){ error(404); }
if ($Edit > $LoggedUser['EffectiveClass']) {
error(404);
}
View::show_header($Title." Aliases");
?>
@ -43,7 +47,7 @@
</tr>
<?
$DB->query("SELECT Alias FROM wiki_aliases WHERE ArticleID='$ArticleID'");
while(list($Revision, $Title, $AuthorID, $AuthorName, $Date) = $DB->next_record()) { ?>
while (list($Revision, $Title, $AuthorID, $AuthorName, $Date) = $DB->next_record()) { ?>
<tr>
<td><?=$Revision?></td>
<td><?=$Title?></td>
@ -57,4 +61,4 @@
</table>
</form>
</div>
<? View::show_footer(); ?>
<? View::show_footer(); ?>

View File

@ -2,7 +2,7 @@
include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class
$Text = new TEXT(true);
if(!empty($_GET['id']) && is_number($_GET['id'])){ //Visiting article via ID
if (!empty($_GET['id']) && is_number($_GET['id'])) { //Visiting article via ID
$ArticleID = $_GET['id'];
} elseif ($_GET['name'] != '') { //Retrieve article ID via alias.
$ArticleID = $Alias->to_id($_GET['name']);
@ -11,14 +11,14 @@
error('Unknown article ['.display_str($_GET['id']).']');
}
if(!$ArticleID) { //No article found
if (!$ArticleID) { //No article found
View::show_header('No article found');
?>
<div class="thin">
<div class="header">
<h2>No article found</h2>
</div>
<div class="box pad" style="padding:10px 10px 10px 20px;">
<div class="box pad" style="padding: 10px 10px 10px 20px;">
There is no article matching the name you requested.
<ul>
<li><a href="wiki.php?action=search&amp;search=<?=display_str($_GET['name'])?>">Search</a> for an article similar to this.</li>
@ -33,7 +33,9 @@
}
$Article = $Alias->article($ArticleID);
list($Revision, $Title, $Body, $Read, $Edit, $Date, $AuthorID, $AuthorName, $Aliases, $UserIDs) = array_shift($Article);
if($Read > $LoggedUser['EffectiveClass']){ error('You must be a higher user class to view this wiki article'); }
if ($Read > $LoggedUser['EffectiveClass']) {
error('You must be a higher user class to view this wiki article');
}
$TextBody = $Text->full_format($Body, false);
$TOC = $Text->parse_toc(0);
@ -47,7 +49,7 @@
<a href="wiki.php?action=create" class="brackets">Create</a>
<a href="wiki.php?action=edit&amp;id=<?=$ArticleID?>" class="brackets">Contribute</a>
<a href="wiki.php?action=revisions&amp;id=<?=$ArticleID?>" class="brackets">History</a>
<? if(check_perms('admin_manage_wiki') && $_GET['id'] != '136'){ ?>
<? if (check_perms('admin_manage_wiki') && $_GET['id'] != '136') { ?>
<a href="wiki.php?action=delete&amp;id=<?=$ArticleID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>" class="brackets" onclick="return confirm('Are you sure you want to delete?\nYes, DELETE, not as in \'Oh hey, if this is wrong we can get someone to magically undelete it for us later\' it will be GONE.\nGiven this new information, do you still want to DELETE this article and all its revisions and all its alias\' and act like it never existed?')">Delete</a>
<? } ?>
<!--<a href="reports.php?action=submit&amp;type=wiki&amp;article=<?=$ArticleID ?>" class="brackets">Report</a>-->
@ -96,13 +98,13 @@
<li>
<strong>Aliases:</strong>
<ul>
<? if($Aliases!=$Title){
<? if ($Aliases != $Title) {
$AliasArray = explode(',', $Aliases);
$UserArray = explode(',', $UserIDs);
$i = 0;
foreach($AliasArray as $AliasItem){
foreach ($AliasArray as $AliasItem) {
?>
<li id="alias_<?=$AliasItem?>"><a href="wiki.php?action=article&amp;name=<?=$AliasItem?>"><?=Format::cut_string($AliasItem,20,1)?></a><? if(check_perms('admin_manage_wiki')){ ?> <a href="#" onclick="Remove_Alias('<?=$AliasItem?>');return false;" class="brackets" title="Delete Alias">X</a> <a href="user.php?id=<?=$UserArray[$i]?>" class="brackets" title="View User">U</a><? } ?></li>
<li id="alias_<?=$AliasItem?>"><a href="wiki.php?action=article&amp;name=<?=$AliasItem?>"><?=Format::cut_string($AliasItem,20,1)?></a><? if (check_perms('admin_manage_wiki')) { ?> <a href="#" onclick="Remove_Alias('<?=$AliasItem?>');return false;" class="brackets" title="Delete Alias">X</a> <a href="user.php?id=<?=$UserArray[$i]?>" class="brackets" title="View User">U</a><? } ?></li>
<? $i++;
}
}
@ -111,9 +113,9 @@
</li>
</ul>
</div>
<? if($Edit <= $LoggedUser['EffectiveClass']){ ?>
<? if ($Edit <= $LoggedUser['EffectiveClass']) { ?>
<div class="box box_addalias">
<div style="padding:5px;">
<div style="padding: 5px;">
<form class="add_form" name="aliases" action="wiki.php" method="post">
<input type="hidden" name="action" value="add_alias" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />

View File

@ -6,12 +6,14 @@ function diff($OldText, $NewText) {
$LineOffset = 0;
$Result = array();
foreach($LineArrayOld as $OldLine => $OldString) {
foreach ($LineArrayOld as $OldLine => $OldString) {
$Key = $OldLine + $LineOffset;
if($Key<0) { $Key = 0; }
if ($Key < 0) {
$Key = 0;
}
$Found = -1;
while($Key<count($LineArrayNew)) {
while ($Key<count($LineArrayNew)) {
if ($OldString != $LineArrayNew[$Key]) {
$Key++;
} elseif ($OldString == $LineArrayNew[$Key]) {
@ -20,18 +22,18 @@ function diff($OldText, $NewText) {
}
}
if($Found=='-1') { //we never found the old line in the new array
if ($Found == '-1') { //we never found the old line in the new array
$Result[] = '<span class="line_deleted">&larr; '.$OldString.'</span><br />';
$LineOffset = $LineOffset - 1;
} elseif ($Found ==$OldLine+$LineOffset) {
} elseif ($Found == $OldLine + $LineOffset) {
$Result[] = '<span class="line_unchanged">&#8597; '.$OldString.'</span><br />';
} elseif ($Found != $OldLine+$LineOffset) {
if ($Found < $OldLine+$LineOffset) {
} elseif ($Found != $OldLine + $LineOffset) {
if ($Found < $OldLine + $LineOffset) {
$Result[] = '<span class="line_moved">&#8676; '.$OldString.'</span><br />';
} else {
$Result[] = '<span class="line_moved">&larr; '.$OldString.'</span><br />';
$Key = $OldLine + $LineOffset;
while ($Key<$Found) {
while ($Key < $Found) {
$Result[] = '<span class="line_new">&rarr; '.$LineArrayNew[$Key].'</span><br />';
$Key++;
}
@ -40,9 +42,9 @@ function diff($OldText, $NewText) {
$LineOffset = $Found-$OldLine;
}
}
if(count($LineArrayNew)>count($LineArrayOld) + $LineOffset) {
if (count($LineArrayNew) > count($LineArrayOld) + $LineOffset) {
$Key = count($LineArrayOld) + $LineOffset;
while($Key<count($LineArrayNew)) {
while ($Key < count($LineArrayNew)) {
$Result[] = '<span class="line_new">&rarr; '.$LineArrayNew[$Key].'</span><br />';
$Key++;
}
@ -53,11 +55,13 @@ function diff($OldText, $NewText) {
function get_body($ID, $Rev) {
global $DB, $Revision, $Body;
if($Rev == $Revision) {
if ($Rev == $Revision) {
$Str = $Body;
} else {
$DB->query("SELECT Body FROM wiki_revisions WHERE ID='$ID' AND Revision='$Rev'");
if(!$DB->record_count()) { error(404); }
if (!$DB->record_count()) {
error(404);
}
list($Str) = $DB->next_record();
}
return $Str;
@ -77,7 +81,9 @@ function get_body($ID, $Rev) {
$Article = $Alias->article($ArticleID);
list($Revision, $Title, $Body, $Read, $Edit, $Date, $AuthorID, $AuthorName) = array_shift($Article);
if($Read > $LoggedUser['EffectiveClass']){ error(404); }
if ($Read > $LoggedUser['EffectiveClass']) {
error(404);
}
View::show_header('Compare Article Revisions');
$Diff2 = get_body($ArticleID, $_GET['new']);
@ -88,7 +94,7 @@ function get_body($ID, $Rev) {
<h2>Compare <a href="wiki.php?action=article&amp;id=<?=$ArticleID?>"><?=$Title?></a> Revisions</h2>
</div>
<div class="box center_revision" id="center">
<div class="body"><? foreach(diff($Diff1, $Diff2) AS $Line) { echo $Line; } ?></div>
<div class="body"><? foreach (diff($Diff1, $Diff2) AS $Line) { echo $Line; } ?></div>
</div>
</div>
<?

View File

@ -9,7 +9,7 @@
<div>
<h3>Title</h3>
<input type="text" name="title" size="92" maxlength="100" />
<? /* if($_GET['alias']){ ?>
<? /* if ($_GET['alias']) { ?>
<input type="hidden" name="alias" value="<?=display_str(alias($_GET['alias']))?>" />
<? } else { ?>
<h3>Alias</h3>
@ -18,14 +18,14 @@
<? } */?>
<h3>Body </h3>
<?
$ReplyText = new TEXTAREA_PREVIEW('body', 'body', '', 91, 22, true, false);
?>
<? if(check_perms('admin_manage_wiki')){ ?>
$ReplyText = new TEXTAREA_PREVIEW('body', 'body', '', 91, 22, true, false);
if (check_perms('admin_manage_wiki')) { ?>
<h3>Access</h3>
<p>There are some situations in which the viewing or editing of an article should be restricted to a certain class.</p>
<strong>Restrict Read:</strong> <select name="minclassread"><?=class_list()?></select>
<strong>Restrict Edit:</strong> <select name="minclassedit"><?=class_list()?></select>
<? } ?>
<strong>Restrict read:</strong> <select name="minclassread"><?=class_list()?></select>
<strong>Restrict edit:</strong> <select name="minclassedit"><?=class_list()?></select>
<? } ?>
<div style="text-align: center;">
<input type="button" value="Preview" class="hidden button_preview_<?=$ReplyText->getID()?>" title="Preview text" tabindex="1" />
<input type="submit" value="Submit" />
@ -34,4 +34,4 @@
</form>
</div>
</div>
<? View::show_footer(); ?>
<? View::show_footer(); ?>

View File

@ -1,10 +1,12 @@
<?
if(!is_number($_GET['id']) || $_GET['id'] == ''){ error(404); }
$ArticleID=$_GET['id'];
if (!is_number($_GET['id']) || $_GET['id'] == '') {
error(404);
}
$ArticleID = $_GET['id'];
$Article = $Alias->article($ArticleID);
list($Revision, $Title, $Body, $Read, $Edit, $Date, $Author) = array_shift($Article);
if($Edit > $LoggedUser['EffectiveClass']){
if ($Edit > $LoggedUser['EffectiveClass']) {
error('You do not have access to edit this article.');
}
@ -22,14 +24,14 @@
<input type="text" name="title" size="92" maxlength="100" value="<?=$Title?>" />
<h3>Body </h3>
<?
$ReplyText = new TEXTAREA_PREVIEW('body', 'body', $Body, 91, 22, true, false);
?>
<? if(check_perms('admin_manage_wiki')){ ?>
$ReplyText = new TEXTAREA_PREVIEW('body', 'body', $Body, 91, 22, true, false);
if (check_perms('admin_manage_wiki')) { ?>
<h3>Access</h3>
<p>There are some situations in which the viewing or editing of an article should be restricted to a certain class.</p>
<strong>Restrict Read:</strong> <select name="minclassread"><?=class_list($Read)?></select>
<strong>Restrict Edit:</strong> <select name="minclassedit"><?=class_list($Edit)?></select>
<? } ?>
<strong>Restrict read:</strong> <select name="minclassread"><?=class_list($Read)?></select>
<strong>Restrict edit:</strong> <select name="minclassedit"><?=class_list($Edit)?></select>
<? } ?>
<div style="text-align: center;">
<input type="button" value="Preview" class="hidden button_preview_<?=$ReplyText->getID()?>" title="Preview text" tabindex="1" />
<input type="submit" value="Submit" />
@ -38,4 +40,4 @@
</form>
</div>
</div>
<? View::show_footer(); ?>
<? View::show_footer(); ?>

View File

@ -9,13 +9,13 @@
define('INDEX_ARTICLE', '1');
function class_list($Selected=0){
function class_list($Selected = 0) {
global $Classes, $LoggedUser;
$Return = '';
foreach ($Classes as $ID => $Class) {
if($Class['Level'] <= $LoggedUser['EffectiveClass']){
if ($Class['Level'] <= $LoggedUser['EffectiveClass']) {
$Return.='<option value="'.$Class['Level'].'"';
if($Selected == $Class['Level']){
if ($Selected == $Class['Level']) {
$Return.=' selected="selected"';
}
$Return.='>'.Format::cut_string($Class['Name'], 20, 1).'</option>'."\n";
@ -25,31 +25,31 @@ function class_list($Selected=0){
return $Return;
}
if(!empty($_REQUEST['action'])) {
switch($_REQUEST['action']) {
if (!empty($_REQUEST['action'])) {
switch ($_REQUEST['action']) {
case 'create':
if($_POST['action']){
if ($_POST['action']) {
include('takecreate.php');
} else {
include('create.php');
}
break;
case 'edit':
if($_POST['action']){
if ($_POST['action']) {
include('takeedit.php');
} else {
include('edit.php');
}
break;
case 'link':
if($_POST['action']){
if ($_POST['action']) {
include('takelink.php');
} else {
include('link.php');
}
break;
case 'delete':
if($_POST['action']){
if ($_POST['action']) {
include('takedelete.php');
} else {
include('delete.php');

View File

@ -1,11 +1,17 @@
<?
if(!isset($_GET['id']) || !is_number($_GET['id'])) { error(404); }
if (!isset($_GET['id']) || !is_number($_GET['id'])) {
error(404);
}
$ArticleID = $_GET['id'];
$Latest = $Alias->article($ArticleID);
list($Revision, $Title, $Body, $Read, $Edit, $Date, $AuthorID, $AuthorName) = array_shift($Latest);
if($Read > $LoggedUser['EffectiveClass']){ error(404); }
if($Edit > $LoggedUser['EffectiveClass']){ error(403); }
if ($Read > $LoggedUser['EffectiveClass']) {
error(404);
}
if ($Edit > $LoggedUser['EffectiveClass']) {
error(403);
}
View::show_header("Revisions of ".$Title);
?>
@ -34,15 +40,16 @@
<td><input type="radio" name="new" value="<?=$Revision?>" checked="checked" /></td>
</tr>
<?
$DB->query("SELECT
w.Revision,
w.Title,
w.Author,
w.Date
$DB->query("
SELECT
w.Revision,
w.Title,
w.Author,
w.Date
FROM wiki_revisions AS w
WHERE w.ID='$ArticleID'
ORDER BY Revision DESC");
while(list($Revision, $Title, $AuthorID, $Date) = $DB->next_record()) { ?>
while (list($Revision, $Title, $AuthorID, $Date) = $DB->next_record()) { ?>
<tr>
<td><?=$Revision?></td>
<td><?=$Title?></td>

View File

@ -1,7 +1,7 @@
<?
if(empty($_GET['nojump'])) {
if (empty($_GET['nojump'])) {
$ArticleID = $Alias->to_id($_GET['search']);
if($ArticleID) { //Found Article
if ($ArticleID) { //Found Article
header('Location: wiki.php?action=article&id='.$ArticleID);
}
}
@ -18,28 +18,37 @@
// What are we looking for? Let's make sure it isn't dangerous.
$Search = db_string(trim($_GET['search']));
if(!in_array($Type, array('w.Title', 'w.Body'))) { $Type = 'w.Title'; }
if (!in_array($Type, array('w.Title', 'w.Body'))) {
$Type = 'w.Title';
}
// Break search string down into individual words
$Words = explode(' ', $Search);
$Type = $TypeTable[$_GET['type']];
if(!$Type) { $Type = 'w.Title'; }
if (!$Type) {
$Type = 'w.Title';
}
$Order = $OrderTable[$_GET['order']];
if(!$Order) { $Order = 'ID'; }
if (!$Order) {
$Order = 'ID';
}
$Way = $WayTable[$_GET['way']];
if(!$Way) { $Way = 'DESC'; }
if (!$Way) {
$Way = 'DESC';
}
$SQL = "SELECT SQL_CALC_FOUND_ROWS
w.ID,
w.Title,
w.Date,
w.Author
$SQL = "
SELECT SQL_CALC_FOUND_ROWS
w.ID,
w.Title,
w.Date,
w.Author
FROM wiki_articles AS w
WHERE w.MinClassRead <= '".$LoggedUser['EffectiveClass']."'";
if($Search!='') {
if ($Search != '') {
$SQL .= " AND $Type LIKE '%";
$SQL .= implode("%' AND $Type LIKE '%", $Words);
$SQL .= "%' ";
@ -76,21 +85,20 @@
<tr>
<td class="label"><strong>Search in:</strong></td>
<td>
<input type="radio" name="type" value="Title" <? if($Type == 'w.Title') { echo 'checked="checked" '; }?>/> Title
<input type="radio" name="type" value="Body" <? if($Type == 'w.Body') { echo 'checked="checked" '; }?>/> Body
<input type="radio" name="type" value="Title" <? if ($Type == 'w.Title') { echo 'checked="checked" '; }?>/> Title
<input type="radio" name="type" value="Body" <? if ($Type == 'w.Body') { echo 'checked="checked" '; }?>/> Body
</td>
<td class="label"><strong>Order by:</strong></td>
<td>
<select name="order">
<?
foreach($OrderVals as $Cur){ ?>
<option value="<?=$Cur?>"<? if($_GET['order'] == $Cur || (!$_GET['order'] && $Cur == 'Time')) { echo ' selected="selected"'; } ?>><?=$Cur?></option>
<? }?>
<? foreach ($OrderVals as $Cur) { ?>
<option value="<?=$Cur?>"<? if ($_GET['order'] == $Cur || (!$_GET['order'] && $Cur == 'Time')) { echo ' selected="selected"'; } ?>><?=$Cur?></option>
<? } ?>
</select>
<select name="way">
<? foreach($WayVals as $Cur){ ?>
<option value="<?=$Cur?>"<? if($_GET['way'] == $Cur || (!$_GET['way'] && $Cur == 'Descending')) { echo ' selected="selected"'; } ?>><?=$Cur?></option>
<? }?>
<? foreach ($WayVals as $Cur) { ?>
<option value="<?=$Cur?>"<? if ($_GET['way'] == $Cur || (!$_GET['way'] && $Cur == 'Descending')) { echo ' selected="selected"'; } ?>><?=$Cur?></option>
<? } ?>
</select>
</td>
</tr>
@ -105,7 +113,7 @@
<br />
<div class="linkbox">
<?
$Pages=Format::get_pages($Page,$NumResults,ARTICLES_PER_PAGE);
$Pages = Format::get_pages($Page, $NumResults, ARTICLES_PER_PAGE);
echo $Pages;
?>
</div>
@ -115,7 +123,7 @@
<td>Last updated on</td>
<td>Last edited by</td>
</tr>
<? while(list($ID, $Title, $Date, $UserID) = $DB->next_record()) {?>
<? while (list($ID, $Title, $Date, $UserID) = $DB->next_record()) { ?>
<tr>
<td><a href="wiki.php?action=article&amp;id=<?=$ID?>"><?=$Title?></a></td>
<td><?=$Date?></td>

View File

@ -1,8 +1,8 @@
<?
authorize();
$P=array();
$P=db_array($_POST);
$P = array();
$P = db_array($_POST);
include(SERVER_ROOT.'/classes/class_validate.php');
$Val = new VALIDATE;
@ -11,25 +11,33 @@
//$Val->SetFields('alias', '1','string','Please include at least 1 alias, the entire string should be between 2 and 100 characters.',array('maxlength'=>100, 'minlength'=>2));
$Err = $Val->ValidateForm($_POST);
if(!$Err) {
if (!$Err) {
$DB->query("SELECT ID FROM wiki_articles WHERE Title='$P[title]'");
if($DB->record_count()>0) {
if ($DB->record_count() > 0) {
list($ID) = $DB->next_record();
$Err = 'An article with that name already exists <a href="wiki.php?action=article&amp;id='.$ID.'">here</a>.';
}
}
if($Err) {
if ($Err) {
error($Err);
}
if(check_perms('admin_manage_wiki')){
$Read=$_POST['minclassread'];
$Edit=$_POST['minclassedit'];
if(!is_number($Read)) { error(0); } //int?
if(!is_number($Edit)) { error(0); }
if($Edit > $LoggedUser['EffectiveClass']){ error('You can\'t restrict articles above your own level'); }
if($Edit < $Read){ $Edit = $Read; } //Human error fix.
if (check_perms('admin_manage_wiki')) {
$Read = $_POST['minclassread'];
$Edit = $_POST['minclassedit'];
if (!is_number($Read)) {
error(0); //int?
}
if (!is_number($Edit)) {
error(0);
}
if ($Edit > $LoggedUser['EffectiveClass']) {
error('You can\'t restrict articles above your own level');
}
if ($Edit < $Read) {
$Edit = $Read; //Human error fix.
}
} else {
$Read=100;
$Edit=100;
@ -42,12 +50,12 @@
$ArticleID = $DB->inserted_id();
//$NewAlias = $Alias->convert($_POST['alias']);
//if($NewAlias!=''){
//if ($NewAlias != '') {
// $DB->query("INSERT INTO wiki_aliases (Alias, ArticleID) VALUES ('$NewAlias', '$ArticleID')");
//}
$TitleAlias = $Alias->convert($_POST['title']);
if($TitleAlias!=$Alias) {
if ($TitleAlias != $Alias) {
$DB->query("INSERT INTO wiki_aliases (Alias, ArticleID) VALUES ('".db_string($TitleAlias)."', '$ArticleID')");
}

View File

@ -4,40 +4,54 @@
include(SERVER_ROOT.'/classes/class_validate.php');
$Val = new VALIDATE;
if(!is_number($_POST['id']) || $_POST['id'] == ''){ error(0); }
if (!is_number($_POST['id']) || $_POST['id'] == '') {
error(0);
}
$Val->SetFields('title', '1','string','The title must be between 3 and 100 characters',array('maxlength'=>100, 'minlength'=>3));
$Err = $Val->ValidateForm($_POST);
$ArticleID=$_POST['id'];
$ArticleID = $_POST['id'];
if($Err) {
if ($Err) {
error($Err);
}
$P=array();
$P=db_array($_POST);
$P = array();
$P = db_array($_POST);
$Article = $Alias->article($ArticleID);
list($Revision, $Title, $Body, $CurRead, $CurEdit, $Date, $Author) = array_shift($Article);
if($CurEdit > $LoggedUser['EffectiveClass']){ error(403); }
if(check_perms('admin_manage_wiki')){
$Read=$_POST['minclassread'];
$Edit=$_POST['minclassedit'];
if(!is_number($Read)) { error(0); } //int?
if(!is_number($Edit)) { error(0); }
if($Edit > $LoggedUser['EffectiveClass']){ error('You can\'t restrict articles above your own level.'); }
if($Edit < $Read){ $Edit = $Read; } //Human error fix.
if ($CurEdit > $LoggedUser['EffectiveClass']) {
error(403);
}
$MyRevision=$_POST['revision'];
if($MyRevision!=$Revision){ error('This article has already been modified from its original version.'); }
if (check_perms('admin_manage_wiki')) {
$Read=$_POST['minclassread'];
$Edit=$_POST['minclassedit'];
if (!is_number($Read)) {
error(0); //int?
}
if (!is_number($Edit)) {
error(0);
}
if ($Edit > $LoggedUser['EffectiveClass']) {
error('You can\'t restrict articles above your own level.');
}
if ($Edit < $Read) {
$Edit = $Read; //Human error fix.
}
}
$MyRevision = $_POST['revision'];
if ($MyRevision != $Revision) {
error('This article has already been modified from its original version.');
}
$DB->query("INSERT INTO wiki_revisions (ID, Revision, Title, Body, Date, Author) VALUES ('".db_string($ArticleID)."', '".db_string($Revision)."', '".db_string($Title)."', '".db_string($Body)."', '".db_string($Date)."', '".db_string($Author)."')");
$SQL = "UPDATE wiki_articles SET
Revision='".db_string($Revision+1)."',
Revision='".db_string($Revision + 1)."',
Title='$P[title]',
Body='$P[body]',";
if($Read && $Edit) {
if ($Read && $Edit) {
$SQL .= "MinClassRead='$Read',
MinClassEdit='$Edit',";
}

View File

@ -1,17 +1,17 @@
<?
authorize();
if(preg_match('/^https?:\/\/(www\.|ssl\.)?'.NONSSL_SITE_URL.'\/wiki\.php\?action=article\&id=([0-9]+)/i',$_POST['url'],$Match)){
$ArticleID=$Match[2];
if (preg_match('/^https?:\/\/(www\.|ssl\.)?'.NONSSL_SITE_URL.'\/wiki\.php\?action=article\&id=([0-9]+)/i',$_POST['url'],$Match)) {
$ArticleID = $Match[2];
}
if (preg_match('/^https?:\/\/(www\.|ssl\.)?'.NONSSL_SITE_URL.'\/wiki\.php\?action=article\&name=(.+)/i',$_POST['url'],$Match)){
if (preg_match('/^https?:\/\/(www\.|ssl\.)?'.NONSSL_SITE_URL.'\/wiki\.php\?action=article\&name=(.+)/i',$_POST['url'],$Match)) {
$ArticleID = $Alias->to_id($Match[2]);
}
if(!$ArticleID){
if (!$ArticleID) {
error('Unable to link alias to an article.');
}
$NewAlias = $Alias->convert($_POST['alias']);
if($NewAlias!=''){
if ($NewAlias != '') {
$DB->query("INSERT INTO wiki_aliases (Alias, ArticleID) VALUES ('$NewAlias', '$ArticleID')");
$Alias->flush();
}