diff --git a/classes/ajax_start.php b/classes/ajax_start.php index a5ed2b80..babe71d9 100644 --- a/classes/ajax_start.php +++ b/classes/ajax_start.php @@ -14,7 +14,7 @@ $LoginCookie = $Enc->decrypt($_COOKIE['session']); } if (isset($LoginCookie)) { - list($SessionID, $UserID) = explode("|~|",$Enc->decrypt($LoginCookie)); + list($SessionID, $UserID) = explode("|~|", $Enc->decrypt($LoginCookie)); if (!$UserID || !$SessionID) { die('Not logged in!'); @@ -49,8 +49,8 @@ function is_number($Str) { 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","&",$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", '&', $Str); $Replace = array( "'",'"',"<",">", @@ -62,7 +62,7 @@ function display_str($Str) { '€','‚','ƒ','„','…','†','‡','ˆ','‰','Š','‹','Œ','Ž','‘','’','“','”','•','–','—','˜','™','š','›','œ','ž','Ÿ' ); - $Str = str_replace($Replace,$With,$Str); + $Str = str_replace($Replace, $With, $Str); } return $Str; } diff --git a/classes/artists.class.php b/classes/artists.class.php index 6ed0eea4..b88ac4fc 100644 --- a/classes/artists.class.php +++ b/classes/artists.class.php @@ -49,7 +49,7 @@ public static function get_artists($GroupIDs) { ORDER BY ta.GroupID ASC, ta.Importance ASC, aa.Name ASC;"); - while (list($GroupID,$ArtistID,$ArtistName,$ArtistImportance,$AliasID) = $DB->next_record(MYSQLI_BOTH, false)) { + while (list($GroupID, $ArtistID, $ArtistName, $ArtistImportance, $AliasID) = $DB->next_record(MYSQLI_BOTH, false)) { $Results[$GroupID][$ArtistImportance][] = array('id' => $ArtistID, 'name' => $ArtistName, 'aliasid' => $AliasID); $New[$GroupID][$ArtistImportance][] = array('id' => $ArtistID, 'name' => $ArtistName, 'aliasid' => $AliasID); } diff --git a/classes/artists_similar.class.php b/classes/artists_similar.class.php index 92acb540..6337acde 100644 --- a/classes/artists_similar.class.php +++ b/classes/artists_similar.class.php @@ -72,7 +72,7 @@ function set_up() { continue; } $this->Artists[$ArtistID] = new ARTIST($ArtistID, $Name); - $this->Similar[$ArtistID] = array('ID'=>$ArtistID,'Score'=>$Score); + $this->Similar[$ArtistID] = array('ID' => $ArtistID, 'Score' => $Score); $this->TotalScore += $Score; $ArtistIDs[] = $ArtistID; } @@ -86,8 +86,8 @@ function set_up() { 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).')'); + WHERE s1.ArtistID IN(".implode(',', $ArtistIDs).') + AND s2.ArtistID IN('.implode(',', $ArtistIDs).')'); // Build into array while (list($Artist1ID, $Artist2ID) = $DB->next_record()) { diff --git a/classes/charts.class.php b/classes/charts.class.php index de35cb3b..3127a555 100644 --- a/classes/charts.class.php +++ b/classes/charts.class.php @@ -30,7 +30,7 @@ public function lines($Thickness, $Solid = 1, $Blank = 0) { } public function title($Title, $Color = '', $Size = '') { - $this->URL .= '&chtt='.str_replace(array(' ',"\n"), array('+','|'), $Title); + $this->URL .= '&chtt='.str_replace(array(' ', "\n"), array('+', '|'), $Title); if (!empty($Color)) { $this->URL .= '&chts='.$Color; } diff --git a/classes/collages.class.php b/classes/collages.class.php index cabcfc9d..3050c4d3 100644 --- a/classes/collages.class.php +++ b/classes/collages.class.php @@ -51,4 +51,32 @@ public static function decrease_subscriptions($CollageID) { WHERE ID = '$CollageID'"); } + public static function create_personal_collage() { + global $DB, $LoggedUser; + + $DB->query(" + SELECT + COUNT(ID) + FROM collages + WHERE UserID = '$LoggedUser[ID]' + AND CategoryID = '0' + AND Deleted = '0'"); + list($CollageCount) = $DB->next_record(); + + if ($CollageCount >= $LoggedUser['Permissions']['MaxCollages']) { + list($CollageID) = $DB->next_record(); + header('Location: collage.php?id='.$CollageID); + die(); + } + $NameStr = ($CollageCount > 0) ? ' no. ' . ($CollageCount + 1) : ''; + $DB->query(" + INSERT INTO collages + (Name, Description, CategoryID, UserID) + VALUES + ('$LoggedUser[Username]\'s personal collage$NameStr', 'Personal collage for $LoggedUser[Username]. The first 5 albums will appear on his or her [url=https:\/\/".SSL_SITE_URL."\/user.php?id=$LoggedUser[ID]]profile[\/url].', '0', $LoggedUser[ID])"); + $CollageID = $DB->inserted_id(); + header('Location: collage.php?id='.$CollageID); + die(); + } + } diff --git a/classes/cookie.class.php b/classes/cookie.class.php index 1fc3bf72..ccc3a66b 100644 --- a/classes/cookie.class.php +++ b/classes/cookie.class.php @@ -12,7 +12,7 @@ /* interface COOKIE_INTERFACE { public function get($Key); - public function set($Key,$Value,$Seconds,$LimitAccess); + public function set($Key, $Value, $Seconds, $LimitAccess); public function del($Key); public function flush(); @@ -31,12 +31,12 @@ public function get($Key) { } //Pass the 4th optional param as false to allow JS access to the cookie - public function set($Key,$Value,$Seconds = 86400,$LimitAccess = SELF::LIMIT_ACCESS) { - setcookie(SELF::PREFIX.$Key,$Value,time()+$Seconds,'/',SITE_URL,$_SERVER['SERVER_PORT'] === '443',$LimitAccess,false); + public function set($Key, $Value, $Seconds = 86400, $LimitAccess = SELF::LIMIT_ACCESS) { + setcookie(SELF::PREFIX.$Key, $Value, time() + $Seconds, '/', SITE_URL, $_SERVER['SERVER_PORT'] === '443', $LimitAccess, false); } public function del($Key) { - setcookie(SELF::PREFIX.$Key,'',time()-24*3600); //3600 vs 1 second to account for potential clock desyncs + setcookie(SELF::PREFIX.$Key, '', time() - 24 * 3600); //3600 vs 1 second to account for potential clock desyncs } public function flush() { diff --git a/classes/encrypt.class.php b/classes/encrypt.class.php index 6bf214fc..54a4aa37 100644 --- a/classes/encrypt.class.php +++ b/classes/encrypt.class.php @@ -12,20 +12,20 @@ } class CRYPT { - public function encrypt($Str,$Key=ENCKEY) { + public function encrypt($Str, $Key = ENCKEY) { srand(); - $Str=str_pad($Str, 32-strlen($Str)); - $IVSize=mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); - $IV=mcrypt_create_iv($IVSize, MCRYPT_RAND); - $CryptStr=mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $Key, $Str, MCRYPT_MODE_CBC, $IV); + $Str = str_pad($Str, 32 - strlen($Str)); + $IVSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); + $IV = mcrypt_create_iv($IVSize, MCRYPT_RAND); + $CryptStr = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $Key, $Str, MCRYPT_MODE_CBC, $IV); return base64_encode($IV.$CryptStr); } - public function decrypt($CryptStr,$Key=ENCKEY) { - if ($CryptStr!='') { - $IV=substr(base64_decode($CryptStr),0,16); - $CryptStr=substr(base64_decode($CryptStr),16); - return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $Key, $CryptStr, MCRYPT_MODE_CBC,$IV)); + public function decrypt($CryptStr, $Key = ENCKEY) { + if ($CryptStr != '') { + $IV = substr(base64_decode($CryptStr), 0, 16); + $CryptStr = substr(base64_decode($CryptStr), 16); + return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $Key, $CryptStr, MCRYPT_MODE_CBC, $IV)); } else { return ''; } diff --git a/classes/format.class.php b/classes/format.class.php index bb7df04e..8009c2c2 100644 --- a/classes/format.class.php +++ b/classes/format.class.php @@ -352,7 +352,7 @@ public static function human_format($Number) { * @return Number of bytes it represents, e.g. (123.45 * 1024) */ public static function get_bytes($Size) { - list($Value,$Unit) = sscanf($Size, "%f%s"); + list($Value, $Unit) = sscanf($Size, "%f%s"); $Unit = ltrim($Unit); if (empty($Unit)) { return $Value ? round($Value) : 0; @@ -487,7 +487,7 @@ public static function make_utf8($Str) { $Encoding = 'UTF-8'; } if (empty($Encoding)) { - $Encoding = mb_detect_encoding($Str,'UTF-8, ISO-8859-1'); + $Encoding = mb_detect_encoding($Str, 'UTF-8, ISO-8859-1'); } if (empty($Encoding)) { $Encoding = 'ISO-8859-1'; @@ -495,7 +495,7 @@ public static function make_utf8($Str) { if ($Encoding == 'UTF-8') { return $Str; } else { - return @mb_convert_encoding($Str,'UTF-8',$Encoding); + return @mb_convert_encoding($Str, 'UTF-8', $Encoding); } } } diff --git a/classes/image.class.php b/classes/image.class.php index 1c6df30d..6540425b 100644 --- a/classes/image.class.php +++ b/classes/image.class.php @@ -46,7 +46,7 @@ function ellipse($x, $y, $Width, $Height, $Color) { } function text($x, $y, $Color, $Text) { - return imagettftext ($this->Image, $this->FontSize,$this->TextAngle, $x, $y, $Color, $this->Font, $Text); + return imagettftext ($this->Image, $this->FontSize, $this->TextAngle, $x, $y, $Color, $this->Font, $Text); } function make_png($FileName = NULL) { diff --git a/classes/irc.class.php b/classes/irc.class.php index 3a1897b0..5a19f6bd 100644 --- a/classes/irc.class.php +++ b/classes/irc.class.php @@ -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; @@ -100,7 +100,7 @@ protected function get_irc_host() { protected function get_word($Select=1) { preg_match('/:.+ PRIVMSG [^:]+ :(.+)/', $this->Data, $Word); - $Word = split(' ',$Word[1]); + $Word = split(' ', $Word[1]); return trim($Word[$Select]); } @@ -131,7 +131,7 @@ protected function whois($Nick) { /* This function uses blacklisted_ip, which is no longer in RC2. 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) { + protected function ip_check($IP, $Gline = false, $Channel = BOT_REPORT_CHAN) { global $Cache, $DB; if (blacklisted_ip($IP)) { $this->send_to($Channel, 'TOR IP Detected: '.$IP); @@ -148,7 +148,7 @@ protected function ip_check($IP,$Gline=false,$Channel=BOT_REPORT_CHAN) { }*/ protected function listen() { - global $Cache,$DB; + global $Cache, $DB; $Cache->InternalCache = false; stream_set_timeout($this->Socket, 10000000000); while ($this->State == 1) { @@ -163,7 +163,7 @@ protected function listen() { } if ($this->Whois !== false) { - $Exp = explode(' ',$this->Data); + $Exp = explode(' ', $this->Data); if ($Exp[1] == '307') { $this->Identified[$this->Whois] = 1; $this->send_to($this->LastChan, "$this->Whois correctly identified as a real person!"); @@ -185,7 +185,7 @@ protected function listen() { } } - if (preg_match("/:([^!]+)![^\s]* PART #what.cd-disabled/", $this->Data, $Nick)) { + if (preg_match("/:([^!]+)![^\s]* PART ".BOT_DISABLED_CHAN.'/', $this->Data, $Nick)) { if (isset($this->DisabledUsers[$Nick[1]])) { $DB->query("DELETE FROM disable_list WHERE Nick = '" . $Nick[1] . "'"); $Cache->increment_value('num_disablees', -1); @@ -193,7 +193,7 @@ protected function listen() { } } - if (preg_match("/:([^!]+)![^\s]* KICK #what.cd-disabled.* /", $this->Data, $Nick)) { + if (preg_match("/:([^!]+)![^\s]* KICK ".BOT_DISABLED_CHAN.'.* /', $this->Data, $Nick)) { $Nick = explode(" ", $Nick[0]); if (isset($this->DisabledUsers[$Nick[3]])) { $DB->query("DELETE FROM disable_list WHERE Nick = '" . $Nick[3] . "'"); @@ -210,11 +210,11 @@ protected function listen() { $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(); } } diff --git a/classes/misc.class.php b/classes/misc.class.php index c56c22dc..1dda6e5b 100644 --- a/classes/misc.class.php +++ b/classes/misc.class.php @@ -193,7 +193,7 @@ public static function create_thread($ForumID, $AuthorID, $Title, $PostBody) { WHERE ID = '$TopicID'"); // Bump this topic to head of the cache - list($Forum,,,$Stickies) = $Cache->get_value('forums_'.$ForumID); + list($Forum,,, $Stickies) = $Cache->get_value('forums_'.$ForumID); if (!empty($Forum)) { if (count($Forum) == TOPICS_PER_PAGE && $Stickies < TOPICS_PER_PAGE) { array_pop($Forum); @@ -407,7 +407,7 @@ public static function get_alias_tag($BadTag) { * @param string $Message the message to write. */ public static function write_log($Message) { - global $DB,$Time; + global $DB, $Time; $DB->query(" INSERT INTO log (Message, Time) VALUES ('" . db_string($Message) . "', '" . sqltime() . "')"); @@ -423,7 +423,7 @@ public static function write_log($Message) { public static function sanitize_tag($Str) { $Str = strtolower($Str); $Str = preg_replace('/[^a-z0-9.]/', '', $Str); - $Str = preg_replace('/(^[.,]*)|([.,]*$)/','',$Str); + $Str = preg_replace('/(^[.,]*)|([.,]*$)/', '', $Str); $Str = htmlspecialchars($Str); $Str = db_string(trim($Str)); return $Str; diff --git a/classes/mysql.class.php b/classes/mysql.class.php index 9b0eb306..ad3cdf24 100644 --- a/classes/mysql.class.php +++ b/classes/mysql.class.php @@ -248,7 +248,7 @@ function query($Query, $AutoHandle = 1) { function query_unb($Query) { $this->connect(); - mysqli_real_query($this->LinkID,$Query); + mysqli_real_query($this->LinkID, $Query); } function inserted_id() { @@ -257,9 +257,9 @@ function inserted_id() { } } - function next_record($Type=MYSQLI_BOTH, $Escape = true) { // $Escape can be true, false, or an array of keys to not escape + function next_record($Type = MYSQLI_BOTH, $Escape = true) { // $Escape can be true, false, or an array of keys to not escape if ($this->LinkID) { - $this->Record = mysqli_fetch_array($this->QueryID,$Type); + $this->Record = mysqli_fetch_array($this->QueryID, $Type); $this->Row++; if (!is_array($this->Record)) { $this->QueryID = false; @@ -302,7 +302,7 @@ function escape_str($Str) { trigger_error('Attempted to escape array.'); return ''; } - return mysqli_real_escape_string($this->LinkID,$Str); + return mysqli_real_escape_string($this->LinkID, $Str); } // Creates an array from a result set @@ -310,7 +310,7 @@ function escape_str($Str) { // Otherwise, use an integer function to_array($Key = false, $Type = MYSQLI_BOTH, $Escape = true) { $Return = array(); - while ($Row = mysqli_fetch_array($this->QueryID,$Type)) { + while ($Row = mysqli_fetch_array($this->QueryID, $Type)) { if ($Escape !== false) { $Row = Misc::display_array($Row, $Escape); } diff --git a/classes/permissions.class.php b/classes/permissions.class.php index f8024779..3d312a47 100644 --- a/classes/permissions.class.php +++ b/classes/permissions.class.php @@ -6,13 +6,14 @@ class Permissions { * @param string PermissionName * @param string $MinClass Return false if the user's class level is below this. */ - public static function check_perms($PermissionName,$MinClass = 0) { + public static function check_perms($PermissionName, $MinClass = 0) { global $LoggedUser; return ( isset($LoggedUser['Permissions'][$PermissionName]) && $LoggedUser['Permissions'][$PermissionName] - && ($LoggedUser['Class']>=$MinClass - || $LoggedUser['EffectiveClass']>=$MinClass)) ? true : false; + && ($LoggedUser['Class'] >= $MinClass + || $LoggedUser['EffectiveClass'] >= $MinClass) + ) ? true : false; } /** diff --git a/classes/proxies.class.php b/classes/proxies.class.php index af3206b0..942e20b6 100644 --- a/classes/proxies.class.php +++ b/classes/proxies.class.php @@ -1,7 +1,7 @@ open('inv.tpl'); -// $TPL->set('ADDRESS1',$TPL->str_align(57,$UADDRESS1,'l',' ')); +// $TPL->set('ADDRESS1', $TPL->str_align(57, $UADDRESS1, 'l', ' ')); // $TPL->get(); class TEMPLATE { diff --git a/classes/text.class.php b/classes/text.class.php index a385af0f..8cfcaf8c 100644 --- a/classes/text.class.php +++ b/classes/text.class.php @@ -132,7 +132,7 @@ public function full_format ($Str, $OutputTOC = true, $Min = 3) { $Str = preg_replace('/'.$URLPrefix.'\s+/i', '$1', $Str); $Str = preg_replace('/(?TOC) { @@ -647,11 +647,11 @@ private function to_html ($Array) { $Group = $Groups['matches'][$Matches[2]]; $Str .= Artists::display_artists($Group['ExtendedArtists']).''.$Group['Name'].''; } else { - $Str .= '[torrent]'.str_replace('[inlineurl]','',$Block['Val']).'[/torrent]'; + $Str .= '[torrent]'.str_replace('[inlineurl]', '', $Block['Val']).'[/torrent]'; } } } else { - $Str .= '[torrent]'.str_replace('[inlineurl]','',$Block['Val']).'[/torrent]'; + $Str .= '[torrent]'.str_replace('[inlineurl]', '', $Block['Val']).'[/torrent]'; } break; case 'wiki': diff --git a/classes/tools.class.php b/classes/tools.class.php index 7ff0d8f3..00e89970 100644 --- a/classes/tools.class.php +++ b/classes/tools.class.php @@ -169,8 +169,8 @@ public static function disable_users($UserIDs, $AdminComment, $BanReason = 1) { 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()); + WHERE m.ID IN(".implode(',', $UserIDs).') '); + $Cache->decrement('stats_user_count', $DB->affected_rows()); foreach ($UserIDs as $UserID) { $Cache->delete_value('enabled_'.$UserID); $Cache->delete_value('user_info_'.$UserID); @@ -197,7 +197,7 @@ public static function disable_users($UserIDs, $AdminComment, $BanReason = 1) { $DB->query(" SELECT torrent_pass FROM users_main - WHERE ID in (".implode(', ',$UserIDs).')'); + WHERE ID in (".implode(', ', $UserIDs).')'); $PassKeys = $DB->collect('torrent_pass'); $Concat = ''; foreach ($PassKeys as $PassKey) { diff --git a/classes/torrent.class.php b/classes/torrent.class.php index 55ba4eda..2f66a081 100644 --- a/classes/torrent.class.php +++ b/classes/torrent.class.php @@ -277,7 +277,7 @@ function file_list() { $FileSize = $File->Val['length']; $TotalSize += $FileSize; - $FileName = ltrim(implode('/',$File->Val[$PathKey]->Val), '/'); + $FileName = ltrim(implode('/', $File->Val[$PathKey]->Val), '/'); $FileSizes[] = $FileSize; $FileNames[] = $FileName; } diff --git a/classes/torrent_32bit.class.php b/classes/torrent_32bit.class.php index d36c7d62..2af39f47 100644 --- a/classes/torrent_32bit.class.php +++ b/classes/torrent_32bit.class.php @@ -266,7 +266,7 @@ function file_list() { $FileSize = substr($File->Val['length'], 7); $TotalSize += $FileSize; - $FileName = ltrim(implode('/',$File->Val[$PathKey]->Val), '/'); + $FileName = ltrim(implode('/', $File->Val[$PathKey]->Val), '/'); $FileSizes[] = $FileSize; $FileNames[] = $FileName; } diff --git a/classes/torrents.class.php b/classes/torrents.class.php index 8f4f5523..5b141457 100644 --- a/classes/torrents.class.php +++ b/classes/torrents.class.php @@ -213,7 +213,7 @@ public static function torrent_properties(&$Torrent, &$Flags) { * @param boolean $Hidden Currently does fuck all. TODO: Fix that. */ public static function write_group_log($GroupID, $TorrentID, $UserID, $Message, $Hidden) { - global $DB,$Time; + global $DB, $Time; $DB->query(" INSERT INTO group_log (GroupID, TorrentID, UserID, Info, Time, Hidden) @@ -371,7 +371,7 @@ public static function delete_group($GroupID) { $DB->query(" UPDATE collages SET NumTorrents=NumTorrents-1 - WHERE ID IN (".implode(', ',$CollageIDs).')'); + WHERE ID IN (".implode(', ', $CollageIDs).')'); $DB->query(" DELETE FROM collages_torrents WHERE GroupID='$GroupID'"); @@ -659,7 +659,7 @@ public static function torrent_info($Data, $ShowMedia = false, $ShowEdition = fa $EditionInfo = array(); if (!empty($Data['RemasterYear'])) { $EditionInfo[] = $Data['RemasterYear']; } if (!empty($Data['RemasterTitle'])) { $EditionInfo[] = $Data['RemasterTitle']; } - if (count($EditionInfo)) { $Info[] = implode(' ',$EditionInfo); } + if (count($EditionInfo)) { $Info[] = implode(' ', $EditionInfo); } } if ($Data['IsSnatched']) { $Info[] = Format::torrent_label('Snatched!'); } if ($Data['FreeTorrent'] == '1') { $Info[] = Format::torrent_label('Freeleech!'); } diff --git a/classes/users.class.php b/classes/users.class.php index 3f20236b..37a3df76 100644 --- a/classes/users.class.php +++ b/classes/users.class.php @@ -184,13 +184,13 @@ public static function user_heavy_info($UserID) { foreach ($PermIDs AS $PermID) { $Perms = Permissions::get_permissions($PermID); if (!empty($Perms['PermittedForums'])) { - $PermittedForums = array_merge($PermittedForums, array_map('trim', explode(',',$Perms['PermittedForums']))); + $PermittedForums = array_merge($PermittedForums, array_map('trim', explode(',', $Perms['PermittedForums']))); } } $Perms = Permissions::get_permissions($HeavyInfo['PermissionID']); unset($HeavyInfo['PermissionID']); if (!empty($Perms['PermittedForums'])) { - $PermittedForums = array_merge($PermittedForums, array_map('trim', explode(',',$Perms['PermittedForums']))); + $PermittedForums = array_merge($PermittedForums, array_map('trim', explode(',', $Perms['PermittedForums']))); } if (!empty($PermittedForums) || !empty($RestrictedForums)) { diff --git a/classes/util.php b/classes/util.php index 659b4167..263ef91c 100644 --- a/classes/util.php +++ b/classes/util.php @@ -35,8 +35,8 @@ function display_str($Str) { } if ($Str != '' && !is_number($Str)) { $Str = Format::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","&",$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", '&', $Str); $Replace = array( "'",'"',"<",">", diff --git a/classes/validate.class.php b/classes/validate.class.php index 9790dbd2..1e907280 100644 --- a/classes/validate.class.php +++ b/classes/validate.class.php @@ -6,9 +6,9 @@ //-----------------------------------*/ class VALIDATE { - var $Fields=array(); + var $Fields = array(); - function SetFields($FieldName,$Required,$FieldType,$ErrorMessage,$Options=array()) { + function SetFields($FieldName, $Required, $FieldType, $ErrorMessage, $Options = array()) { $this->Fields[$FieldName]['Type'] = strtolower($FieldType); $this->Fields[$FieldName]['Required'] = $Required; $this->Fields[$FieldName]['ErrorMessage'] = $ErrorMessage; @@ -153,7 +153,7 @@ function ValidateForm($ValidateArray) { } } elseif ($Field['Type'] == 'compare') { - if ($ValidateArray[$Field['CompareField']]!=$ValidateVar) { + if ($ValidateArray[$Field['CompareField']] != $ValidateVar) { return $Field['ErrorMessage']; } diff --git a/robots.txt b/robots.txt index e7018c50..d6645aba 100644 --- a/robots.txt +++ b/robots.txt @@ -2,9 +2,4 @@ User-agent: * Allow: /index.php Allow: /login.php Allow: /register.php -# -Allow: /what-network/ -Allow: /gazelle/ -Sitemap: https://what.cd/sitemap.xml -# Disallow: / diff --git a/sections/artist/index.php b/sections/artist/index.php index 9de37ad5..291f6124 100644 --- a/sections/artist/index.php +++ b/sections/artist/index.php @@ -268,7 +268,10 @@ } elseif (!empty($_GET['artistname'])) { $NameSearch = str_replace('\\', '\\\\', trim($_GET['artistname'])); - $DB->query("SELECT ArtistID, Name FROM artists_alias WHERE Name LIKE '" . db_string($NameSearch) . "'"); + $DB->query(" + SELECT ArtistID, Name + FROM artists_alias + WHERE Name LIKE '" . db_string($NameSearch) . "'"); if ($DB->record_count() == 0) { if (isset($LoggedUser['SearchType']) && $LoggedUser['SearchType']) { header('Location: torrents.php?action=advanced&artistname=' . urlencode($_GET['artistname'])); diff --git a/sections/better/folders.php b/sections/better/folders.php index 4ce1f32f..56dc26f8 100644 --- a/sections/better/folders.php +++ b/sections/better/folders.php @@ -1,14 +1,19 @@ query("DELETE FROM torrents_bad_folders WHERE TorrentID = ".$_GET['remove']); - $DB->query("SELECT GroupID FROM torrents WHERE ID = ".$_GET['remove']); + $DB->query(" + DELETE FROM torrents_bad_folders + WHERE TorrentID = ".$_GET['remove']); + $DB->query(" + SELECT GroupID + FROM torrents + WHERE ID = ".$_GET['remove']); list($GroupID) = $DB->next_record(); $Cache->delete_value('torrents_details_'.$GroupID); } -if (!empty($_GET['filter']) && $_GET['filter'] == "all") { +if (!empty($_GET['filter']) && $_GET['filter'] == 'all') { $Join = ''; $All = true; } else { @@ -61,17 +66,17 @@ } else { $DisplayName = ''; } - $DisplayName.=''.$GroupName.''; + $DisplayName .= ''.$GroupName.''; if ($GroupYear > 0) { - $DisplayName.=" [$GroupYear]"; + $DisplayName .= " [$GroupYear]"; } if ($ReleaseType > 0) { - $DisplayName.=' ['.$ReleaseTypes[$ReleaseType].']'; + $DisplayName .= ' ['.$ReleaseTypes[$ReleaseType].']'; } $ExtraInfo = Torrents::torrent_info($Torrents[$TorrentID]); if ($ExtraInfo) { - $DisplayName.=' - '.$ExtraInfo; + $DisplayName .= ' - '.$ExtraInfo; } ?> diff --git a/sections/better/single.php b/sections/better/single.php index 762d46af..faa7c703 100644 --- a/sections/better/single.php +++ b/sections/better/single.php @@ -1,18 +1,19 @@ get_value('better_single_groupids')) === false) { - $DB->query("SELECT - t.ID AS TorrentID, - t.GroupID AS GroupID - FROM xbt_files_users AS x - JOIN torrents AS t ON t.ID=x.fid - WHERE t.Format='FLAC' - GROUP BY x.fid - HAVING COUNT(x.uid) = 1 - ORDER BY t.LogScore DESC, t.Time ASC - LIMIT 30"); + $DB->query(" + SELECT + t.ID AS TorrentID, + t.GroupID AS GroupID + FROM xbt_files_users AS x + JOIN torrents AS t ON t.ID=x.fid + WHERE t.Format='FLAC' + GROUP BY x.fid + HAVING COUNT(x.uid) = 1 + ORDER BY t.LogScore DESC, t.Time ASC + LIMIT 30"); $GroupIDs = $DB->to_array('GroupID'); - $Cache->cache_value('better_single_groupids', $GroupIDs, 30*60); + $Cache->cache_value('better_single_groupids', $GroupIDs, 30 * 60); } $Results = Torrents::get_groups(array_keys($GroupIDs)); @@ -42,17 +43,17 @@ } $FlacID = $GroupIDs[$GroupID]['TorrentID']; - $DisplayName.=''.$GroupName.''; + $DisplayName .= ''.$GroupName.''; if ($GroupYear > 0) { - $DisplayName.=" [$GroupYear]"; + $DisplayName .= " [$GroupYear]"; } if ($ReleaseType > 0) { - $DisplayName.=" [".$ReleaseTypes[$ReleaseType]."]"; + $DisplayName .= " [".$ReleaseTypes[$ReleaseType]."]"; } $ExtraInfo = Torrents::torrent_info($Torrents[$FlacID]); if ($ExtraInfo) { - $DisplayName.=' - '.$ExtraInfo; + $DisplayName .= ' - '.$ExtraInfo; } ?> diff --git a/sections/better/snatch.php b/sections/better/snatch.php index 380fd382..539ca9af 100644 --- a/sections/better/snatch.php +++ b/sections/better/snatch.php @@ -19,7 +19,8 @@ } // Get list of FLAC snatches -$DB->query("SELECT t.GroupID, x.fid +$DB->query(" + SELECT t.GroupID, x.fid FROM ".($SeedingOnly ? 'xbt_files_users' : 'xbt_snatched')." AS x JOIN torrents AS t ON t.ID=x.fid JOIN torrents_group AS tg ON tg.ID = t.GroupID @@ -27,7 +28,8 @@ AND ((t.LogScore = '100' AND t.Media = 'CD') OR t.Media != 'CD') AND tg.CategoryID = 1 - AND x.uid='$UserID'" . ($SeedingOnly ? ' AND x.active = 1 AND x.remaining = 0' : '')); + AND x.uid='$UserID'" . + ($SeedingOnly ? ' AND x.active = 1 AND x.remaining = 0' : '')); $SnatchedTorrentIDs = array_fill_keys($DB->collect('fid'), true); $SnatchedGroupIDs = array_unique($DB->collect('GroupID')); @@ -41,19 +43,26 @@ } // Create hash table -$DB->query("CREATE TEMPORARY TABLE temp_sections_better_snatch - SELECT t.GroupID, - GROUP_CONCAT(t.Encoding SEPARATOR ' ') AS EncodingList, - CRC32(CONCAT_WS(' ', Media, Remasteryear, Remastertitle, - Remasterrecordlabel, Remastercataloguenumber)) AS RemIdent +$DB->query(" + CREATE TEMPORARY TABLE temp_sections_better_snatch + SELECT + t.GroupID, + GROUP_CONCAT(t.Encoding SEPARATOR ' ') AS EncodingList, + CRC32(CONCAT_WS( + ' ', Media, Remasteryear, Remastertitle, + Remasterrecordlabel, Remastercataloguenumber) + ) AS RemIdent FROM torrents AS t - WHERE t.GroupID IN(".implode(',',$SnatchedGroupIDs).") AND t.Format IN ('FLAC', 'MP3') + WHERE t.GroupID IN(".implode(',', $SnatchedGroupIDs).") + AND t.Format IN ('FLAC', 'MP3') GROUP BY t.GroupID, RemIdent"); //$DB->query('SELECT * FROM t'); -$DB->query("SELECT GroupID FROM temp_sections_better_snatch - WHERE EncodingList NOT LIKE '%V0 (VBR)%' +$DB->query(" + SELECT GroupID + FROM temp_sections_better_snatch + WHERE EncodingList NOT LIKE '%V0 (VBR)%' OR EncodingList NOT LIKE '%V2 (VBR)%' OR EncodingList NOT LIKE '%320%'"); @@ -218,9 +227,9 @@
format()?>
- YES' : 'class="important_text">NO'?> - YES' : 'class="important_text">NO'?> - YES' : 'class="important_text">NO'?> + YES' : 'NO'?> + YES' : 'NO'?> + YES' : 'NO'?> query("DELETE FROM torrents_bad_tags WHERE TorrentID = ".$_GET['remove']); - $DB->query("SELECT GroupID FROM torrents WHERE ID = ".$_GET['remove']); + $DB->query(" + DELETE FROM torrents_bad_tags + WHERE TorrentID = ".$_GET['remove']); + $DB->query(" + SELECT GroupID + FROM torrents + WHERE ID = ".$_GET['remove']); list($GroupID) = $DB->next_record(); $Cache->delete_value('torrents_details_'.$GroupID); } @@ -62,17 +67,17 @@ } else { $DisplayName = ''; } - $DisplayName.=''.$GroupName.''; + $DisplayName .= ''.$GroupName.''; if ($GroupYear > 0) { - $DisplayName.=" [$GroupYear]"; + $DisplayName .= " [$GroupYear]"; } if ($ReleaseType > 0) { - $DisplayName.=' ['.$ReleaseTypes[$ReleaseType].']'; + $DisplayName .= ' ['.$ReleaseTypes[$ReleaseType].']'; } $ExtraInfo = Torrents::torrent_info($Torrents[$TorrentID]); if ($ExtraInfo) { - $DisplayName.=' - '.$ExtraInfo; + $DisplayName .= ' - '.$ExtraInfo; } ?> diff --git a/sections/better/transcode.php b/sections/better/transcode.php index 6b9a724e..73160c66 100644 --- a/sections/better/transcode.php +++ b/sections/better/transcode.php @@ -178,9 +178,9 @@
format()?>
- YES' : 'class="important_text">NO'?> - YES' : 'class="important_text">NO'?> - YES' : 'class="important_text">NO'?> + YES' : 'NO'?> + YES' : 'NO'?> + YES' : 'NO'?>
format('better.php?action=transcode&tags=')?>
- YES' : 'class="important_text">NO')?> - YES' : 'class="important_text">NO')?> - YES' : 'class="important_text">NO')?> + YES' : 'NO')?> + YES' : 'NO')?> + YES' : 'NO')?> query("SELECT t.GroupID, t.ID +$DB->query(" + SELECT t.GroupID, t.ID FROM torrents AS t - JOIN torrents_group AS tg ON tg.ID = t.GroupID - WHERE - t.Format='FLAC' - AND ((t.LogScore = '100' AND t.Media = 'CD') - OR t.Media != 'CD') - AND tg.CategoryID = 1 - AND t.UserID='$UserID'"); + JOIN torrents_group AS tg ON tg.ID = t.GroupID + WHERE t.Format='FLAC' + AND ((t.LogScore = '100' AND t.Media = 'CD') + OR t.Media != 'CD') + AND tg.CategoryID = 1 + AND t.UserID = '$UserID'"); $UploadedTorrentIDs = array_fill_keys($DB->collect('ID'), true); $UploadedGroupIDs = $DB->collect('GroupID'); @@ -31,17 +31,24 @@ } // Create hash table -$DB->query("CREATE TEMPORARY TABLE temp_sections_better_upload - SELECT t.GroupID, - GROUP_CONCAT(t.Encoding SEPARATOR ' ') AS EncodingList, - CRC32(CONCAT_WS(' ', Media, Remasteryear, Remastertitle, - Remasterrecordlabel, Remastercataloguenumber)) AS RemIdent +$DB->query(" + CREATE TEMPORARY TABLE temp_sections_better_upload + SELECT + t.GroupID, + GROUP_CONCAT(t.Encoding SEPARATOR ' ') AS EncodingList, + CRC32(CONCAT_WS( + ' ', Media, Remasteryear, Remastertitle, + Remasterrecordlabel, Remastercataloguenumber) + ) AS RemIdent FROM torrents AS t - WHERE t.GroupID IN(".implode(',',$UploadedGroupIDs).") AND t.Format IN ('FLAC', 'MP3') + WHERE t.GroupID IN(".implode(',', $UploadedGroupIDs).") + AND t.Format IN ('FLAC', 'MP3') GROUP BY t.GroupID, RemIdent"); -$DB->query("SELECT GroupID FROM temp_sections_better_upload - WHERE EncodingList NOT LIKE '%V0 (VBR)%' +$DB->query(" + SELECT GroupID + FROM temp_sections_better_upload + WHERE EncodingList NOT LIKE '%V0 (VBR)%' OR EncodingList NOT LIKE '%V2 (VBR)%' OR EncodingList NOT LIKE '%320%'"); @@ -197,9 +204,9 @@
format()?>
- YES' : 'class="important_text">NO'?> - YES' : 'class="important_text">NO'?> - YES' : 'class="important_text">NO'?> + YES' : 'NO'?> + YES' : 'NO'?> + YES' : 'NO'?> query(" - SELECT - COUNT(ID) - FROM collages - WHERE UserID='$LoggedUser[ID]' - AND CategoryID='0' - AND Deleted='0'"); - list($CollageCount) = $DB->next_record(); - - if ($CollageCount >= $LoggedUser['Permissions']['MaxCollages']) { - list($CollageID) = $DB->next_record(); - header('Location: collage.php?id='.$CollageID); - die(); - } - $NameStr = ($CollageCount > 0)?" no. " . ($CollageCount + 1):''; - $DB->query(" - INSERT INTO collages - (Name, Description, CategoryID, UserID) - VALUES - ('$LoggedUser[Username]\'s personal collage$NameStr', 'Personal collage for $LoggedUser[Username]. The first 5 albums will appear on his or her [url=https:\/\/".SSL_SITE_URL."\/user.php?id=$LoggedUser[ID]]profile[\/url].', '0', $LoggedUser[ID])"); - $CollageID = $DB->inserted_id(); - header('Location: collage.php?id='.$CollageID); - die(); + break; default: if (!empty($_GET['id'])) { diff --git a/sections/user/takemoderate.php b/sections/user/takemoderate.php index 34d20b32..8d6076d5 100644 --- a/sections/user/takemoderate.php +++ b/sections/user/takemoderate.php @@ -580,7 +580,7 @@ $EditSummary[] = "IRC status changed"; $HeavyUpdates['DisableIRC'] = $DisableIRC; if (!empty($UserReason)) { - Misc::send_pm($UserID, 0, 'Your IRC privileges have been disabled', "Your IRC privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=https://".SSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url]. This loss of privileges does not affect the ability to join and talk to staff in #what.cd-disabled."); + Misc::send_pm($UserID, 0, 'Your IRC privileges have been disabled', "Your IRC privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=https://".SSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url]. This loss of privileges does not affect the ability to join and talk to staff in ".BOT_DISABLED_CHAN.'.'); } } @@ -589,7 +589,7 @@ $EditSummary[] = "request status changed"; $HeavyUpdates['DisableRequests'] = $DisableRequests; if (!empty($UserReason)) { - Misc::send_pm($UserID, 0, 'Your request privileges have been disabled', "Your request privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=https://".SSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url]. This loss of privileges does not affect the ability to join and talk to staff in #what.cd-disabled."); + Misc::send_pm($UserID, 0, 'Your request privileges have been disabled', "Your request privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this please join ".BOT_DISABLED_CHAN." on our IRC network. Instructions can be found [url=https://".SSL_SITE_URL."/wiki.php?action=article&name=IRC+-+How+to+join]here[/url]. This loss of privileges does not affect the ability to join and talk to staff in ".BOT_DISABLED_CHAN.'.'); } } diff --git a/static/functions/comments.js b/static/functions/comments.js index 7e889531..d19d86ac 100644 --- a/static/functions/comments.js +++ b/static/functions/comments.js @@ -26,7 +26,7 @@ function Quote(post, user, link) { if ($('#quickpost').raw().value !== '') { $('#quickpost').raw().value = $('#quickpost').raw().value + "\n\n"; } - $('#quickpost').raw().value = $('#quickpost').raw().value + "[quote="+username + (link == true ? "|" + post : "") + "]" + + $('#quickpost').raw().value = $('#quickpost').raw().value + "[quote=" + username + (link == true ? "|" + post : "") + "]" + //response.replace(/(img|aud)(\]|=)/ig,'url$2').replace(/\[url\=(https?:\/\/[^\s\[\]<>"\'()]+?)\]\[url\](.+?)\[\/url\]\[\/url\]/gi, "[url]$1[/url]") html_entity_decode(response) + "[/quote]"; @@ -41,9 +41,9 @@ function Edit_Form(post,key) { $('#reply_box').ghide(); if (location.href.match(/torrents\.php/) || location.href.match(/artist\.php/)) { - boxWidth="50"; + boxWidth = "50"; } else { - boxWidth="80"; + boxWidth = "80"; } postuserid = $('#post' + postid + ' strong a').raw().getAttribute('href').split('=')[1] /* jQuery isnt enabled on comments, artist comments, or basically anywhere but thread.php @@ -52,13 +52,13 @@ function Edit_Form(post,key) { postuserid = jQuery('#post' + postid + ' strong a').attr('href').split('=')[1]; */ if (postuserid != userid) { - pmbox = 'PM user on edit? '; + pmbox = ''; } else { pmbox = ''; }; $('#bar' + postid).raw().cancel = $('#content' + postid).raw().innerHTML; $('#bar' + postid).raw().oldbar = $('#bar' + postid).raw().innerHTML; - $('#content' + postid).raw().innerHTML = "
"+pmbox+"
"; + $('#content' + postid).raw().innerHTML = "
" + pmbox + "
"; $('#bar' + postid).raw().innerHTML = ''; } /* If it's the initial edit, fetch the post content to be edited. @@ -161,7 +161,7 @@ function Quick_Preview() { var quickreplybuttons; $('#post_preview').raw().value = "Make changes"; $('#post_preview').raw().preview = true; - ajax.post("ajax.php?action=preview","quickpostform", function(response) { + ajax.post("ajax.php?action=preview", "quickpostform", function(response) { $('#quickreplypreview').gshow(); $('#contentpreview').raw().innerHTML = response; $('#quickreplytext').ghide(); @@ -180,7 +180,7 @@ function Newthread_Preview(mode) { $('#newthreadpreviewbutton').gtoggle(); $('#newthreadeditbutton').gtoggle(); if (mode) { // Preview - ajax.post("ajax.php?action=preview","newthreadform", function(response) { + ajax.post("ajax.php?action=preview", "newthreadform", function(response) { $('#contentpreview').raw().innerHTML = response; }); $('#newthreadtitle').raw().innerHTML = $('#title').raw().value; diff --git a/static/functions/detect_mobile.js b/static/functions/detect_mobile.js index 5164e2b7..14f9d05a 100644 --- a/static/functions/detect_mobile.js +++ b/static/functions/detect_mobile.js @@ -27,7 +27,7 @@ var isMobile = { if (isMobile.Android()) { if (!hasCookie(ANDROID_COOKIE_NAME)) { setCookie(ANDROID_COOKIE_NAME, true, 365); - var result = confirm("An Android App is available for What.CD, would you like to download it?"); + var result = confirm("An Android app is available for What.CD. Would you like to download it?"); if (result == true) { window.location = ANDROID_APP_URL; } @@ -35,7 +35,7 @@ if (isMobile.Android()) { } else if (isMobile.NotAndroid()) { if (!hasCookie(OTHER_COOKIE_NAME)) { setCookie(OTHER_COOKIE_NAME, true, 365); - var result = confirm("A mobile version of What.CD is available, would you like to use it?"); + var result = confirm("A mobile version of What.CD is available. Would you like to use it?"); if (result == true) { window.location = MOBILE_SITE_URL; } diff --git a/static/styles/mono/style.css b/static/styles/mono/style.css index 242d231e..a00f796e 100644 --- a/static/styles/mono/style.css +++ b/static/styles/mono/style.css @@ -1,5 +1,5 @@ /* -Mono What.cd Stylesheet +Mono What.CD Stylesheet Author: Callum Jefferies (callumj) Contact: callum.jefferies@gmail.com @@ -16,7 +16,7 @@ All icons Copyright (c) Callum Jefferies 2011 body { padding: 120px 20px 60px 20px; background: #eee !important; - font: 9pt/14pt 'Lucida Grande',Helvetica,Arial,sans-serif; + font: 9pt/14pt 'Lucida Grande', Helvetica, Arial, sans-serif; } table { @@ -38,7 +38,7 @@ a:hover { } h1,h2,h3 { - font-family: Helvetica,Arial,sans-serif; + font-family: Helvetica, Arial, sans-serif; font-weight: bold; color: #444 !important; } diff --git a/static/styles/proton/style.css b/static/styles/proton/style.css index dc611c43..ca23b6f8 100644 --- a/static/styles/proton/style.css +++ b/static/styles/proton/style.css @@ -2043,7 +2043,7 @@ tr.torrent .bookmark > a:after { } .group_image img { - background: url(https://what.cd/static/common/noartwork/music.png) no-repeat top left; + background: url(static/common/noartwork/music.png) no-repeat top left; background-size: 90px; color: transparent; }