diff --git a/classes/ajax_start.php b/classes/ajax_start.php index a835b6e4..5a7c391d 100644 --- a/classes/ajax_start.php +++ b/classes/ajax_start.php @@ -70,7 +70,7 @@ 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'; @@ -78,7 +78,7 @@ 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); } } } @@ -108,9 +108,9 @@ function display_array($Array, $DontEscape = array()) { function make_secret($Length = 32) { $Secret = ''; - $Chars='abcdefghijklmnopqrstuvwxyz0123456789'; - for($i=0; $i<$Length; $i++) { - $Rand = mt_rand(0, strlen($Chars)-1); + $Chars = 'abcdefghijklmnopqrstuvwxyz0123456789'; + for ($i = 0; $i < $Length; $i++) { + $Rand = mt_rand(0, strlen($Chars) - 1); $Secret .= substr($Chars, $Rand, 1); } return str_shuffle($Secret); diff --git a/classes/class_cache.php b/classes/class_cache.php index 04fd1c79..a3d53454 100644 --- a/classes/class_cache.php +++ b/classes/class_cache.php @@ -97,7 +97,7 @@ public function replace_value($Key, $Value, $Duration=2592000) { } public function get_value($Key, $NoCache=false) { - if(!$this->InternalCache) { + if (!$this->InternalCache) { $NoCache = true; } $StartTime=microtime(true); diff --git a/classes/class_debug.php b/classes/class_debug.php index 93d41a0a..d0c96456 100644 --- a/classes/class_debug.php +++ b/classes/class_debug.php @@ -456,7 +456,7 @@ public function constant_table($Constants=false) { public function cache_table($CacheKeys=false) { global $Cache; - $Header = 'Cache Keys'; + $Header = 'Cache keys'; if (!is_array($CacheKeys)) { $CacheKeys = $this->get_cache_keys(); $Header .= ' ('.number_format($this->get_cache_time(), 5).' ms)'; diff --git a/classes/class_forums.php b/classes/class_forums.php index 506e1fc0..3530a791 100644 --- a/classes/class_forums.php +++ b/classes/class_forums.php @@ -63,4 +63,4 @@ public static function quote_notify($Body, $PostID, $Page, $PageID) { } } -} \ No newline at end of file +} diff --git a/classes/class_image_tools.php b/classes/class_image_tools.php index b36671d8..c3f84f4d 100644 --- a/classes/class_image_tools.php +++ b/classes/class_image_tools.php @@ -9,13 +9,13 @@ class ImageTools { * Store processed links to avoid repetition * @var array 'URL' => 'Parsed URL' */ - static private $Storage = array(); + private static $Storage = array(); /** * We use true as an extra property to make the domain an array key * @var array $Hosts Array of image hosts */ - static private $Hosts = array( + private static $Hosts = array( 'whatimg.com' => true, 'imgur.com' => true ); @@ -24,7 +24,7 @@ class ImageTools { * Blacklisted sites * @var array $Blacklist Array of blacklisted hosts */ - static private $Blacklist = array( + private static $Blacklist = array( 'tinypic.com' ); @@ -32,7 +32,7 @@ class ImageTools { * Array of image hosts that provide thumbnailing * @var array $Thumbs */ - static private $Thumbs = array( + private static $Thumbs = array( 'i.imgur.com' => true, 'whatimg.com' => true ); @@ -41,7 +41,7 @@ class ImageTools { * Array of extensions * @var array $Extensions */ - static private $Extensions = array( + private static $Extensions = array( 'jpg' => true, 'jpeg' => true, 'png' => true, @@ -78,7 +78,7 @@ public static function blacklisted($Url) { * @param string $Url Link to an image * @return string|false Matched host or false */ - public static function thumbnailable($Url) { + private static function thumbnailable($Url) { $ParsedUrl = parse_url($Url); return !empty(self::$Thumbs[$ParsedUrl['host']]); } @@ -88,7 +88,7 @@ public static function thumbnailable($Url) { * @param string $Ext Extension to check * @return boolean */ - public static function valid_extension($Ext) { + private static function valid_extension($Ext) { // return @self::$Extensions[$Ext] === true; return !empty(self::$Extensions[$Ext]) && self::$Extensions[$Ext] === true; } @@ -98,7 +98,7 @@ public static function valid_extension($Ext) { * @param type $Link * @param type $Processed */ - public static function store($Link, $Processed) { + private static function store($Link, $Processed) { self::$Storage[$Link] = $Processed; } @@ -107,7 +107,7 @@ public static function store($Link, $Processed) { * @param type $Link * @return boolean|string Returns false if no match */ - public static function get_stored($Link) { + private static function get_stored($Link) { if (isset(self::$Storage[$Link])) { return self::$Storage[$Link]; } @@ -115,79 +115,34 @@ public static function get_stored($Link) { } /** - * Turns link into thumbnail (if possible) or default group image (if missing) - * Automatically applies proxy when appropriate - * - * @global array $CategoryIcons - * @param string $Link Link to an image - * @param int $Groupid The torrent's group ID for a default image - * @param boolean $Thumb Thumbnail image - * @return string Link to image + * Checks if URL points to a whatimg thumbnail. */ - public static function wiki_image($Link, $GroupID = 0, $Thumb = true) { - global $CategoryIcons; - - if ($Link && $Thumb) { - $Thumb = self::thumbnail($Link); - if (check_perms('site_proxy_images')) { - return self::proxy_url($Thumb); - } - return $Thumb; - } - - return STATIC_SERVER . 'common/noartwork/' . $CategoryIcons[$GroupID]; + private static function has_whatimg_thumb($Url) { + return (strpos($Url, '_thumb') !== false); } /** - * The main function called to get a thumbnail link. - * Use wiki_image() instead of this method for more advanced options - * - * @param string $Link Image link - * @return string Image link + * Cleans up imgur URL if it already has a modifier attached to the end of it. */ - public static function thumbnail($Link) { - if (($Found = self::get_stored($Link))) { - return $Found; - } - return self::process_thumbnail($Link); + private static function clean_imgur_url($Url) { + $Extension = pathinfo($Url, PATHINFO_EXTENSION); + $Full = preg_replace('/\.[^.]*$/', '', $Url); + $Base = substr($Full, 0, strrpos($Full, '/')); + $Path = substr($Full, strrpos($Full, '/') + 1); + if (strlen($Path) == 6) { + $Last = $Path[strlen($Path) - 1]; + if ($Last == 'm' || $Last == 'l' || $Last == 's' || $Last == 'h' || $Last == 'b') { + $Path = substr($Path, 0, -1); + } + } + return $Base . '/' . $Path . '.' . $Extension; } /** - * Matches a hosts that thumbnails and stores link - * @param string $Link Image link - * @return string Thumbnail link or Image link + * Replaces the extension. */ - static private function process_thumbnail($Link) { - $Thumb = $Link; - $Extension = pathinfo($Link, PATHINFO_EXTENSION); - - if (self::thumbnailable($Link) && self::valid_extension($Extension)) { - if (contains('whatimg', $Link) && !has_whatimg_thumb($Link)) { - $Thumb = replace_extension($Link, '_thumb.' . $Extension); - } elseif (contains('imgur', $Link)) { - $Thumb = replace_extension(clean_imgur_url($Link), 'm.' . $Extension); - } - } - self::store($Link, $Thumb); - return $Thumb; - } - - /** - * Creates an HTML thumbnail - * @param type $Source - * @param type $Category - * @param type $Size - */ - public static function cover_thumb($Source, $Category = 0, $Size = 90, $Title = 'Cover') { - $Img = self::wiki_image($Source, $Category); - if (!$Source) { - $Source = $Img; - } elseif (check_perms('site_proxy_images')) { - $Source = self::proxy_url($Source); - } -?> - <?=$Title?> - + Cover +Filters as $Name => $Values) { - foreach($Values as $Value) { + foreach ($this->Filters as $Name => $Values) { + foreach ($Values as $Value) { $Filters[] = $Name." - ".$Value; } } - $this->Queries[]=array('Params: '.$Query.' Filters: '.implode(", ", $Filters).' Indicies: '.$this->Index,($QueryEndTime-$QueryStartTime)*1000); - $this->Time+=($QueryEndTime-$QueryStartTime)*1000; + $this->Queries[] = array('Params: '.$Query.' Filters: '.implode(", ", $Filters).' Indicies: '.$this->Index,($QueryEndTime-$QueryStartTime) * 1000); + $this->Time += ($QueryEndTime-$QueryStartTime) * 1000; - if($Result === false) { - if($this->_connerror && !$Cache->get_value('sphinx_crash_reported')) { + if ($Result === false) { + if ($this->_connerror && !$Cache->get_value('sphinx_crash_reported')) { send_irc('PRIVMSG '.ADMIN_CHAN.' :!dev Connection to searchd failed'); $Cache->cache_value('sphinx_crash_reported', 1, 3600); } @@ -71,7 +71,7 @@ function search($Query='', $CachePrefix='', $CacheLength=0, $ReturnData=array(), $this->TotalResults = $Result['total_found']; $this->SearchTime = $Result['time']; - if(empty($Result['matches'])) { + if (empty($Result['matches'])) { return false; } $Matches = $Result['matches']; @@ -82,49 +82,49 @@ function search($Query='', $CachePrefix='', $CacheLength=0, $ReturnData=array(), $NotFound = array(); $Skip = array(); - if(!empty($ReturnData)) { + if (!empty($ReturnData)) { $AllFields = false; } else { $AllFields = true; } - foreach($MatchIDs as $Match) { + foreach ($MatchIDs as $Match) { $Matches[$Match] = $Matches[$Match]['attrs']; - if(!empty($CachePrefix)) { + if (!empty($CachePrefix)) { $Data = $Cache->get_value($CachePrefix.'_'.$Match); - if($Data == false) { - $NotFound[]=$Match; + if ($Data == false) { + $NotFound[] = $Match; continue; } } else { - $NotFound[]=$Match; + $NotFound[] = $Match; } - if(!$AllFields) { + if (!$AllFields) { // Populate list of fields to unset (faster than picking out the ones we need). Should only be run once, on the first cache key - if(empty($Skip)) { - foreach(array_keys($Data) as $Key) { - if(!in_array($Key, $ReturnData)) { - $Skip[]=$Key; + if (empty($Skip)) { + foreach (array_keys($Data) as $Key) { + if (!in_array($Key, $ReturnData)) { + $Skip[] = $Key; } } - if(empty($Skip)) { + if (empty($Skip)) { $AllFields = true; } } - foreach($Skip as $Key) { + foreach ($Skip as $Key) { unset($Data[$Key]); } reset($Skip); } - if(!empty($Data)) { + if (!empty($Data)) { $Matches[$Match] = array_merge($Matches[$Match], $Data); } } - if($SQL!='') { - if(!empty($NotFound)) { + if ($SQL != '') { + if (!empty($NotFound)) { $DB->query(str_replace('%ids', implode(',',$NotFound), $SQL)); - while($Data = $DB->next_record(MYSQLI_ASSOC)) { + while ($Data = $DB->next_record(MYSQLI_ASSOC)) { $Matches[$Data[$IDColumn]] = array_merge($Matches[$Data[$IDColumn]], $Data); $Cache->cache_value($CachePrefix.'_'.$Data[$IDColumn], $Data, $CacheLength); } @@ -148,8 +148,8 @@ function set_index($Index) { } function set_filter($Name, $Vals, $Exclude=false) { - foreach($Vals as $Val) { - if($Exclude) { + foreach ($Vals as $Val) { + if ($Exclude) { $this->Filters[$Name][] = "!$Val"; } else { $this->Filters[$Name][] = $Val; diff --git a/classes/class_sphinxql.php b/classes/class_sphinxql.php index 9c411e00..d7d41c6b 100644 --- a/classes/class_sphinxql.php +++ b/classes/class_sphinxql.php @@ -38,7 +38,7 @@ public function __construct($Server, $Port, $Socket) { * @return identification string */ private function get_ident($Server, $Port, $Socket) { - if($Socket) { + if ($Socket) { return $Socket; } else { return "$Server:$Port"; @@ -55,7 +55,7 @@ private function get_ident($Server, $Port, $Socket) { */ public static function init_connection($Server, $Port, $Socket) { $Ident = self::get_ident($Server, $Port, $Socket); - if(!isset(self::$Connections[$Ident])) { + if (!isset(self::$Connections[$Ident])) { self::$Connections[$Ident] = new Sphinxql($Server, $Port, $Socket); } return self::$Connections[$Ident]; @@ -65,11 +65,11 @@ public static function init_connection($Server, $Port, $Socket) { * Connect the Sphinxql object to the Sphinx server */ public function connect() { - if(!$this->Connected) { + if (!$this->Connected) { global $Debug; $Debug->set_flag('Connecting to Sphinx server '.$this->Ident); parent::__construct($this->Server, '', '', '', $this->Port, $this->Socket); - if($this->connect_error) { + if ($this->connect_error) { $Errno = $this->connect_errno; $Error = $this->connect_error; $this->error("Connection failed. ".strval($Errno)." (".strval($Error).")"); @@ -90,10 +90,10 @@ public function error($Msg, $Halt = false) { global $Debug; $ErrorMsg = 'SphinxQL ('.$this->Ident.'): '.strval($Msg); $Debug->analysis('SphinxQL Error', $ErrorMsg, 3600*24); - if($Halt === true && (DEBUG_MODE || check_perms('site_debug'))) { + if ($Halt === true && (DEBUG_MODE || check_perms('site_debug'))) { echo '
'.display_str($ErrorMsg).'
'; die(); - } elseif($Halt === true) { + } elseif ($Halt === true) { error('-1'); } } diff --git a/classes/class_sphinxqlquery.php b/classes/class_sphinxqlquery.php index e5909eef..03e2668a 100644 --- a/classes/class_sphinxqlquery.php +++ b/classes/class_sphinxqlquery.php @@ -56,26 +56,26 @@ public function from($Indexes) { * @return current Sphinxql query object */ public function where($Attribute, $Values, $Exclude = false) { - if(empty($Attribute) && empty($Values)) { + if (empty($Attribute) && empty($Values)) { return false; } $Filters = array(); - if(is_array($Values)) { - foreach($Values as $Value) { - if(!is_number($Value)) { + if (is_array($Values)) { + foreach ($Values as $Value) { + if (!is_number($Value)) { $this->error("Filters require numeric values"); } } - if($Exclude) { + if ($Exclude) { $Filters[] = "$Attribute NOT IN (".implode(",", $Values).")"; } else { $Filters[] = "$Attribute IN (".implode(",", $Values).")"; } } else { - if(!is_number($Values)) { + if (!is_number($Values)) { $this->error("Filters require numeric values"); } - if($Exclude) { + if ($Exclude) { $Filters[] = "$Attribute != $Values"; } else { $Filters[] = "$Attribute = $Values"; @@ -93,7 +93,7 @@ public function where($Attribute, $Values, $Exclude = false) { * @return current Sphinxql query object */ public function where_between($Attribute, $Values) { - if(empty($Attribute) || empty($Values) || count($Values) != 2 || !is_number($Values[0]) || !is_number($Values[1])) { + if (empty($Attribute) || empty($Values) || count($Values) != 2 || !is_number($Values[0]) || !is_number($Values[1])) { $this->error("Filter range requires array of two numerical boundaries as values."); } $this->Filters[] = "$Attribute BETWEEN $Values[0] AND $Values[1]"; @@ -109,7 +109,7 @@ public function where_between($Attribute, $Values) { * @return current Sphinxql query object */ public function where_match($Expr, $Field = '*', $Escape = true) { - if(empty($Expr)) { + if (empty($Expr)) { return $this; } if ($Field !== false) { @@ -216,29 +216,29 @@ private function build_options() { * Combine the query conditions into a valid Sphinx query segment */ private function build_query() { - if(!$this->Indexes) { + if (!$this->Indexes) { $this->error('Index name is required.'); } $this->QueryString = "SELECT $this->Select\nFROM $this->Indexes"; - if(!empty($this->Expressions)) { + if (!empty($this->Expressions)) { $this->Filters['expr'] = "MATCH('".implode(" ", $this->Expressions)."')"; } - if(!empty($this->Filters)) { + if (!empty($this->Filters)) { $this->QueryString .= "\nWHERE ".implode("\n\tAND ", $this->Filters); } - if(!empty($this->GroupBy)) { + if (!empty($this->GroupBy)) { $this->QueryString .= "\nGROUP BY $this->GroupBy"; } - if(!empty($this->SortGroupBy)) { + if (!empty($this->SortGroupBy)) { $this->QueryString .= "\nWITHIN GROUP ORDER BY $this->SortGroupBy"; } - if(!empty($this->SortBy)) { + if (!empty($this->SortBy)) { $this->QueryString .= "\nORDER BY ".implode(", ", $this->SortBy); } - if(!empty($this->Limits)) { + if (!empty($this->Limits)) { $this->QueryString .= "\nLIMIT $this->Limits"; } - if(!empty($this->Options)) { + if (!empty($this->Options)) { $Options = $this->build_options(); $this->QueryString .= "\nOPTION $Options"; } @@ -279,12 +279,12 @@ public function raw_query($Query, $GetMeta = true) { * @return Sphinxql result object */ private function send_query($GetMeta) { - if(!$this->QueryString) { + if (!$this->QueryString) { return false; } $this->Sphinxql->connect(); $Result = $this->Sphinxql->query($this->QueryString); - if($Result === false) { + if ($Result === false) { $Errno = $this->Sphinxql->errno; $Error = $this->Sphinxql->error; $this->error("Query returned error $Errno ($Error).\n$this->QueryString"); diff --git a/classes/class_sphinxqlresult.php b/classes/class_sphinxqlresult.php index 11a42957..1c2491cf 100644 --- a/classes/class_sphinxqlresult.php +++ b/classes/class_sphinxqlresult.php @@ -39,7 +39,7 @@ public function __call($Name, $Arguments) { */ public function collect($Key) { $Return = array(); - while($Row = $this->fetch_array()) { + while ($Row = $this->fetch_array()) { $Return[] = $Row[$Key]; } $this->data_seek(0); @@ -55,8 +55,8 @@ public function collect($Key) { */ public function to_array($Key, $ResultType = MYSQLI_ASSOC) { $Return = array(); - while($Row = $this->fetch_array($ResultType)) { - if($Key !== false) { + while ($Row = $this->fetch_array($ResultType)) { + if ($Key !== false) { $Return[$Row[$Key]] = $Row; } else { $Return[] = $Row; @@ -75,7 +75,7 @@ public function to_array($Key, $ResultType = MYSQLI_ASSOC) { */ public function to_pair($Key1, $Key2) { $Return = array(); - while($Row = $this->fetch_array()) { + while ($Row = $this->fetch_array()) { $Return[$Row[$Key1]] = $Row[$Key2]; } $this->data_seek(0); @@ -89,11 +89,11 @@ public function to_pair($Key1, $Key2) { * @return array with meta data */ public function get_meta($Keys = false) { - if($Keys !== false) { - if(is_array($Keys)) { + if ($Keys !== false) { + if (is_array($Keys)) { $Return = array(); - foreach($Keys as $Key) { - if(!isset($this->Meta[$Key])) { + foreach ($Keys as $Key) { + if (!isset($this->Meta[$Key])) { continue; } $Return[$Key] = $this->Meta[$Key]; @@ -114,11 +114,11 @@ public function get_meta($Keys = false) { * @return array with result information */ public function get_result_info($Keys = false) { - if($Keys !== false) { - if(is_array($Keys)) { + if ($Keys !== false) { + if (is_array($Keys)) { $Return = array(); - foreach($Keys as $Key) { - if(!isset($this->Result->$Key)) { + foreach ($Keys as $Key) { + if (!isset($this->Result->$Key)) { continue; } $Return[$Key] = $this->Result->$Key; diff --git a/classes/class_templates.php b/classes/class_templates.php index 05e8acf5..9e69d9d5 100644 --- a/classes/class_templates.php +++ b/classes/class_templates.php @@ -6,15 +6,15 @@ // $TPL->get(); class TEMPLATE { - var $file=''; - var $vars=array(); + var $file = ''; + var $vars = array(); function open($file) { - $this->file=file($file); + $this->file = file($file); } function set($name,$var,$ifnone='-None-') { - if ($name!='') { + if ($name != '') { $this->vars[$name][0]=$var; $this->vars[$name][1]=$ifnone; } @@ -22,24 +22,28 @@ function set($name,$var,$ifnone='-None- function show() { $TMPVAR=''; - for($i=0; $ifile); $i++) { + for ($i=0; $ifile); $i++) { $TMPVAR=$this->file[$i]; - foreach($this->vars as $k=>$v) { - if ($v[1]!="" && $v[0]=="") { $v[0]=$v[1]; } - $TMPVAR=str_replace('{{'.$k.'}}',$v[0],$TMPVAR); + foreach ($this->vars as $k=>$v) { + if ($v[1] != '' && $v[0] == '') { + $v[0] = $v[1]; + } + $TMPVAR = str_replace('{{'.$k.'}}',$v[0],$TMPVAR); } print $TMPVAR; } } function get() { - $RESULT=''; - $TMPVAR=''; - for($i=0; $ifile); $i++) { + $RESULT = ''; + $TMPVAR = ''; + for ($i = 0; $i < sizeof($this->file); $i++) { $TMPVAR=$this->file[$i]; - foreach($this->vars as $k=>$v) { - if ($v[1]!="" && $v[0]=="") { $v[0]=$v[1]; } - $TMPVAR=str_replace('{{'.$k.'}}',$v[0],$TMPVAR); + foreach ($this->vars as $k=>$v) { + if ($v[1] != '' && $v[0] == '') { + $v[0] = $v[1]; + } + $TMPVAR = str_replace('{{'.$k.'}}',$v[0],$TMPVAR); } $RESULT.=$TMPVAR; } @@ -47,33 +51,32 @@ function get() { } function str_align($len,$str,$align,$fill) { - $strlen=strlen($str); - if ($strlen>$len) { + $strlen = strlen($str); + if ($strlen > $len) { return substr($str, 0, $len); - } elseif (($strlen==0)||($len==0)) { + } elseif (($strlen == 0) || ($len == 0)) { return ''; } else { - if (($align=='l')||($align=='left')) { - $result=$str.str_repeat($fill,($len-$strlen)); + if (($align == 'l') || ($align == 'left')) { + $result = $str.str_repeat($fill,($len - $strlen)); - } elseif (($align=='r')||($align=='right')) { - $result=str_repeat($fill,($len-$strlen)).$str; + } elseif (($align == 'r') || ($align == 'right')) { + $result = str_repeat($fill,($len - $strlen)).$str; - } elseif (($align=='c')||($align=='center')) { - $snm=intval(($len-$strlen)/2); - if (($strlen+($snm*2))==$len) { - $result=str_repeat($fill,$snm).$str; + } elseif (($align == 'c') || ($align == 'center')) { + $snm = intval(($len - $strlen) / 2); + if (($strlen + ($snm * 2)) == $len) { + $result = str_repeat($fill,$snm).$str; } else { - $result=str_repeat($fill,$snm+1).$str; + $result = str_repeat($fill,$snm + 1).$str; } $result.=str_repeat($fill,$snm); } - return $result; } } diff --git a/classes/class_text.php b/classes/class_text.php index bb497fc8..9389a4cf 100644 --- a/classes/class_text.php +++ b/classes/class_text.php @@ -736,7 +736,7 @@ private function to_html ($Array) { } } $Str.='
'.$this->to_html($Block['Val']).'
'; - if($this->InQuotes == $this->NestsBeforeHide) { //Close quote the deeply nested quote [hide]. + if ($this->InQuotes == $this->NestsBeforeHide) { //Close quote the deeply nested quote [hide]. $Str.='
'; // Ensure new line after quote train hiding } $this->NoImg--; @@ -772,10 +772,8 @@ private function to_html ($Array) { $LocalURL = $this->local_url($Block['Val']); if ($LocalURL) { $Str.=''.$Block['Val'].''; - } elseif (check_perms('site_proxy_images')) { - $Str.=''.$Block['Val'].''; } else { - $Str.=''.$Block['Val'].''; + $Str.=''.$Block['Val'].''; } } break; diff --git a/classes/class_text2.php b/classes/class_text2.php index 89d7d485..b79ed17b 100644 --- a/classes/class_text2.php +++ b/classes/class_text2.php @@ -543,11 +543,7 @@ function to_html($Array) { if (!$this->valid_url($Block['Val'], '\.(jpe?g|gif|png|bmp|tiff)')) { $Str.='[img]'.$Block['Val'].'[/img]'; } else { - if (check_perms('site_proxy_images')) { - $Str.=''.$Block['Val'].''; - } else { - $Str.=''.$Block['Val'].''; - } + $Str.=''.$Block['Val'].''; } break; diff --git a/classes/class_text3.php b/classes/class_text3.php index e0f2e7a3..ca8abb3b 100644 --- a/classes/class_text3.php +++ b/classes/class_text3.php @@ -286,8 +286,8 @@ function parse($Str) { $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; @@ -318,7 +318,7 @@ function parse($Str) { $NumInOpens++; } - } while($NumInOpens>$NumInCloses); + } while ($NumInOpens > $NumInCloses); // Find the internal block inside the tag @@ -504,11 +504,7 @@ function to_html($Array) { if (!$this->valid_url($Block['Val'], '\.(jpe?g|gif|png|bmp|tiff)')) { $Str.='[img]'.$Block['Val'].'[/img]'; } else { - if (check_perms('site_proxy_images')) { - $Str.=''.$Block['Val'].''; - } else { - $Str.=''.$Block['Val'].''; - } + $Str.=''.$Block['Val'].''; } break; diff --git a/classes/class_textarea_preview.php b/classes/class_textarea_preview.php index 536996ae..b7c0f543 100644 --- a/classes/class_textarea_preview.php +++ b/classes/class_textarea_preview.php @@ -3,8 +3,7 @@ * This super class is used to manage the ammount of textareas there are and to * generate the required JavaScript that enables the previews to work. */ -class TEXTAREA_PREVIEW_SUPER -{ +class TEXTAREA_PREVIEW_SUPER { /** * @static * @var int $Textareas Total number of textareas created @@ -37,11 +36,13 @@ class TEXTAREA_PREVIEW_SUPER * @example
* @return void */ - static public function JavaScript ($all = true) - { - if (self::$Textareas === 0) return; - if (self::$Exectuted === false && $all) + static public function JavaScript ($all = true) { + if (self::$Textareas === 0) { + return; + } + if (self::$Exectuted === false && $all) { View::parse('generic/textarea/script.phtml'); + } self::$Exectuted = true; self::iterator(); @@ -55,10 +56,9 @@ static public function JavaScript ($all = true) * @static * @return void */ - static private function iterator () - { + static private function iterator () { $script = array(); - for($i = 0; $i < self::$Textareas; $i++) { + for ($i = 0; $i < self::$Textareas; $i++) { if (isset(self::$_ID[$i]) && is_string(self::$_ID[$i])) { $a = sprintf('%d, "%s"', $i, self::$_ID[$i]); } else { @@ -66,9 +66,9 @@ static private function iterator () } $script[] = sprintf('[%s]', $a); } - if (!empty($script)) - View::parse('generic/textarea/script_factory.phtml', - array('script' => join(', ', $script))); + if (!empty($script)) { + View::parse('generic/textarea/script_factory.phtml', array('script' => join(', ', $script))); + } } } @@ -111,8 +111,7 @@ static private function iterator () * * */ -class TEXTAREA_PREVIEW extends TEXTAREA_PREVIEW_SUPER -{ +class TEXTAREA_PREVIEW extends TEXTAREA_PREVIEW_SUPER { /** * @var int Unique ID */ @@ -157,14 +156,19 @@ public function __construct ($Name, $ID = '', $Value = '', $Cols = 50, $Rows = 1 parent::$Textareas += 1; array_push(parent::$_ID, $ID); - if (empty($ID)) $ID = 'quickpost_' . $this->id; + if (empty($ID)) { + $ID = 'quickpost_' . $this->id; + } - if (!empty($ExtraAttributes)) + if (!empty($ExtraAttributes)) { $Attributes = ' ' . implode(' ', $ExtraAttributes); - else + } else { $Attributes = ''; + } - if ($Preview === true) $this->preview(); + if ($Preview === true) { + $this->preview(); + } $this->buffer = View::parse('generic/textarea/textarea.phtml', array( 'ID' => $ID, @@ -176,17 +180,19 @@ public function __construct ($Name, $ID = '', $Value = '', $Cols = 50, $Rows = 1 'Attributes' => &$Attributes ), $Buffer); - if ($Buttons === true) $this->buttons(); + if ($Buttons === true) { + $this->buttons(); + } } /** * Outputs the divs required for previewing the AJAX content * Will only output once */ - public function preview () - { - if (!$this->preview) + public function preview () { + if (!$this->preview) { View::parse('generic/textarea/preview.phtml', array('ID' => $this->id)); + } $this->preview = true; } @@ -194,16 +200,14 @@ public function preview () * Outputs the preview and edit buttons * Can be called many times to place buttons in different areas */ - public function buttons () - { + public function buttons () { View::parse('generic/textarea/buttons.phtml', array('ID' => $this->id)); } /** * Returns the textarea's numeric ID. */ - public function getID () - { + public function getID () { return $this->id; } @@ -211,8 +215,7 @@ public function getID () * Returns textarea string when buffer is enabled in the constructor * @return string */ - public function getBuffer () - { + public function getBuffer () { return $this->buffer; } } diff --git a/classes/class_time.php b/classes/class_time.php index b8d8a770..510a99e6 100644 --- a/classes/class_time.php +++ b/classes/class_time.php @@ -121,7 +121,7 @@ function time_diff($TimeStamp, $Levels=2, $Span=true, $Lowercase=false) { if ($Return != '') { $Return.=' and '; } - if ($Minutes>1) { + if ($Minutes > 1) { $Return.=$Minutes.' mins'; } else { $Return.=$Minutes.' min'; diff --git a/classes/class_tools.php b/classes/class_tools.php index 4ffa2406..fc60a952 100644 --- a/classes/class_tools.php +++ b/classes/class_tools.php @@ -172,7 +172,7 @@ public static function disable_users($UserIDs, $AdminComment, $BanReason = 1) { $Cache->delete_value('user_stats_'.$UserID); $DB->query("SELECT SessionID FROM users_sessions WHERE UserID='$UserID' AND Active = 1"); - while(list($SessionID) = $DB->next_record()) { + while (list($SessionID) = $DB->next_record()) { $Cache->delete_value('session_'.$UserID.'_'.$SessionID); } $Cache->delete_value('users_sessions_'.$UserID); diff --git a/classes/class_torrents.php b/classes/class_torrents.php index 6a361773..0ac2ddf6 100644 --- a/classes/class_torrents.php +++ b/classes/class_torrents.php @@ -81,7 +81,7 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true, g.ID, g.Name, g.Year, g.RecordLabel, g.CatalogueNumber, g.TagList, g.ReleaseType, g.VanityHouse, g.WikiImage, g.CategoryID FROM torrents_group AS g WHERE g.ID IN ($IDs)"); - while($Group = $DB->next_record(MYSQLI_ASSOC, true)) { + while ($Group = $DB->next_record(MYSQLI_ASSOC, true)) { unset($NotFound[$Group['ID']]); $Found[$Group['ID']] = $Group; $Found[$Group['ID']]['Torrents'] = array(); @@ -104,7 +104,7 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true, WHERE GroupID IN($IDs) ORDER BY GroupID, Remastered, (RemasterYear <> 0) DESC, RemasterYear, RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber, Media, Format, Encoding, ID"); - while($Torrent = $DB->next_record(MYSQLI_ASSOC, true)) { + while ($Torrent = $DB->next_record(MYSQLI_ASSOC, true)) { $Found[$Torrent['GroupID']]['Torrents'][$Torrent['ID']] = $Torrent; } @@ -262,7 +262,7 @@ public static function delete_torrent($ID, $GroupID=0, $OcelotReason=-1) { // Torrent notifications $DB->query("SELECT UserID FROM users_notify_torrents WHERE TorrentID='$ID'"); - while(list($UserID) = $DB->next_record()) { + while (list($UserID) = $DB->next_record()) { $Cache->delete_value('notifications_new_'.$UserID); } $DB->query("DELETE FROM users_notify_torrents WHERE TorrentID='$ID'"); diff --git a/classes/class_tracker.php b/classes/class_tracker.php index ef6251fb..5de49a55 100644 --- a/classes/class_tracker.php +++ b/classes/class_tracker.php @@ -23,7 +23,7 @@ function update_tracker($Action, $Updates, $ToIRC = false) { } $Path = TRACKER_SECRET.$Get; - $Return = ""; + $Return = ''; $Attempts = 0; while ($Return != "success" && $Attempts < 3) { @@ -52,7 +52,7 @@ function update_tracker($Action, $Updates, $ToIRC = false) { } while (!feof($File) && !Misc::ends_with($ResHeader, "\r\n\r\n")); $Response = ''; - while($Line = fgets($File)) { + while ($Line = fgets($File)) { $Response .= $Line; } diff --git a/classes/class_users.php b/classes/class_users.php index 340e66df..daba2765 100644 --- a/classes/class_users.php +++ b/classes/class_users.php @@ -104,9 +104,7 @@ public static function user_info($UserID) { } // Image proxy - if (check_perms('site_proxy_images') && !empty($UserInfo['Avatar'])) { - $UserInfo['Avatar'] = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?c=1&avatar='.$UserID.'&i='.urlencode($UserInfo['Avatar']); - } + $UserInfo['Avatar'] = ImageTools::process($UserInfo['Avatar']); return $UserInfo; } @@ -397,12 +395,12 @@ public static function gen_crypt_salt() { $Numchars = strlen($Chars) - 1; if ($Handle = @fopen('/dev/urandom', 'r')) { $Bytes = fread($Handle, 22); - for($i = 0; $i < 21; $i++) { + for ($i = 0; $i < 21; $i++) { $Salt .= $Chars[ord($Bytes[$i]) & $Numchars]; } $Salt[$i] = $Chars[(ord($Bytes[$i]) & 3) << 4]; } else { - for($i = 0; $i < 21; $i++) { + for ($i = 0; $i < 21; $i++) { $Salt .= $Chars[mt_rand(0, $Numchars)]; } $Salt[$i] = $Chars[mt_rand(0, 3) << 4]; @@ -481,7 +479,7 @@ public static function format_username($UserID, $Badges = false, $IsWarned = tru if (check_perms('site_proxy_images') && !empty($UserInfo['Title'])) { $UserInfo['Title'] = preg_replace_callback('~src=("?)(http.+?)(["\s>])~', function($Matches) { - return 'src='.$Matches[1].'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?c=1&i='.urlencode($Matches[2]).$Matches[3]; + return 'src=' . $Matches[1] . ImageTools::process($Matches[2]) . $Matches[3]; }, $UserInfo['Title']); } diff --git a/classes/script_start.php b/classes/script_start.php index da6f05f5..ce7af932 100644 --- a/classes/script_start.php +++ b/classes/script_start.php @@ -10,7 +10,6 @@ /*------------------------------------------------------*/ /********************************************************/ require 'config.php'; //The config contains all site wide configuration information - //Deal with dumbasses if (isset($_REQUEST['info_hash']) && isset($_REQUEST['peer_id'])) { die('d14:failure reason40:Invalid .torrent, try downloading again.e'); } @@ -435,8 +434,6 @@ function authorize($Ajax = false) { $Document = basename(parse_url($_SERVER['SCRIPT_FILENAME'], PHP_URL_PATH), '.php'); if (!preg_match('/^[a-z0-9]+$/i', $Document)) { error(404); } - - require(SERVER_ROOT.'/sections/'.$Document.'/index.php'); $Debug->set_flag('completed module execution'); diff --git a/design/privateheader.php b/design/privateheader.php index 3d92778c..9afdfd7e 100644 --- a/design/privateheader.php +++ b/design/privateheader.php @@ -229,7 +229,7 @@ $Cache->cache_value('news_latest_id', $CurrentNews, 0); } if ($MyNews < $CurrentNews) { - $Alerts[] = ''.'New announcement!'.''; + $Alerts[] = 'New announcement!'; } // Blog @@ -245,7 +245,7 @@ $Cache->cache_value('blog_latest_id', $CurrentBlog, 0); } if ($MyBlog < $CurrentBlog) { - $Alerts[] = ''.'New blog post!'.''; + $Alerts[] = 'New blog post!'; } // Staff blog @@ -270,7 +270,7 @@ $Cache->cache_value('staff_blog_latest_time', $LatestSBlogTime, 1209600); } if ($SBlogReadTime < $LatestSBlogTime) { - $Alerts[] = ''.'New staff blog post!'.''; + $Alerts[] = 'New staff blog post!'; } } @@ -283,7 +283,7 @@ } if ($NewStaffPMs > 0) { - $Alerts[] = ''.'You have '.$NewStaffPMs.(($NewStaffPMs > 1) ? ' new staff messages' : ' new staff message').''; + $Alerts[] = 'You have '.$NewStaffPMs.(($NewStaffPMs > 1) ? ' new staff messages' : ' new staff message').''; } //Inbox @@ -295,13 +295,13 @@ } if ($NewMessages > 0) { - $Alerts[] = ''.'You have '.$NewMessages.(($NewMessages > 1) ? ' new messages' : ' new message').''; + $Alerts[] = 'You have '.$NewMessages.(($NewMessages > 1) ? ' new messages' : ' new message').''; } if ($LoggedUser['RatioWatch']) { - $Alerts[] = ''.'Ratio Watch'.': '.'You have '.time_diff($LoggedUser['RatioWatchEnds'], 3).' to get your ratio over your required ratio or your leeching abilities will be disabled.'; + $Alerts[] = 'Ratio Watch: You have '.time_diff($LoggedUser['RatioWatchEnds'], 3).' to get your ratio over your required ratio or your leeching abilities will be disabled.'; } elseif ($LoggedUser['CanLeech'] != 1) { - $Alerts[] = ''.'Ratio Watch'.': '.'Your downloading privileges are disabled until you meet your required ratio.'; + $Alerts[] = 'Ratio Watch: Your downloading privileges are disabled until you meet your required ratio.'; } if (check_perms('site_torrents_notify')) { @@ -316,7 +316,7 @@ $Cache->cache_value('notifications_new_'.$LoggedUser['ID'], $NewNotifications, 0); } if ($NewNotifications > 0) { - $Alerts[] = ''.'You have '.$NewNotifications.(($NewNotifications > 1) ? ' new torrent notifications' : ' new torrent notification').''; + $Alerts[] = 'You have '.$NewNotifications.(($NewNotifications > 1) ? ' new torrent notifications' : ' new torrent notification').''; } } @@ -333,11 +333,11 @@ $Cache->cache_value('collage_subs_user_new_'.$LoggedUser['ID'], $NewCollages, 0); } if ($NewCollages > 0) { - $Alerts[] = ''.'You have '.$NewCollages.(($NewCollages > 1) ? ' new collage updates' : ' new collage update').''; + $Alerts[] = 'You have '.$NewCollages.(($NewCollages > 1) ? ' new collage updates' : ' new collage update').''; } } if (check_perms('users_mod')) { - $ModBar[] = ''.'Toolbox'.''; + $ModBar[] = 'Toolbox'; } if (check_perms('users_mod') || $LoggedUser['PermissionID'] == FORUM_MOD) { $NumStaffPMs = $Cache->get_value('num_staff_pms_'.$LoggedUser['ID']); @@ -387,7 +387,7 @@ } if ($NumUpdateReports > 0) { - $ModBar[] = ''.'Request update reports'.''; + $ModBar[] = 'Request update reports'; } } elseif (check_perms('site_moderate_forums')) { $NumForumReports = $Cache->get_value('num_forum_reports'); diff --git a/gazelle.sql b/gazelle.sql index 41a8efe8..c7fe9830 100644 --- a/gazelle.sql +++ b/gazelle.sql @@ -1510,7 +1510,7 @@ CREATE TABLE `users_sessions` ( `SessionID` char(32) NOT NULL, `KeepLogged` enum('0','1') NOT NULL DEFAULT '0', `Browser` varchar(40) DEFAULT NULL, - `OperatingSystem` varchar(8) DEFAULT NULL, + `OperatingSystem` varchar(13) DEFAULT NULL, `IP` varchar(15) NOT NULL, `LastUpdate` datetime NOT NULL, `Active` tinyint(4) NOT NULL DEFAULT '1', diff --git a/opensearch.php b/opensearch.php index 791b84fe..7fc25f01 100644 --- a/opensearch.php +++ b/opensearch.php @@ -24,7 +24,7 @@ case 'artists': ?> - + http:///torrents.php?action=advanced query($Query); - $TopTorrentsActiveLastDay = $DB->to_array(); + $TopTorrentsActiveLastDay = $DB->to_array(); // TODO: MYSQLI_NUM to avoid duplicate data in the cache (does that break something with generate_torrent_json?) $Cache->cache_value('top10tor_day_'.$Limit.$WhereSum,$TopTorrentsActiveLastDay,3600*2); } $OuterResults[] = generate_torrent_json('Most Active Torrents Uploaded in the Past Day', 'day', $TopTorrentsActiveLastDay, $Limit); @@ -144,7 +145,7 @@ function generate_torrent_json($Caption, $Tag, $Details, $Limit) { global $LoggedUser,$Categories; $results = array(); foreach ($Details as $Detail) { - list($TorrentID,$GroupID,$GroupName,$GroupCategoryID,$TorrentTags, + list($TorrentID,$GroupID,$GroupName,$GroupCategoryID,$WikiImage,$TorrentTags, $Format,$Encoding,$Media,$Scene,$HasLog,$HasCue,$LogScore,$Year,$GroupYear, $RemasterTitle,$Snatched,$Seeders,$Leechers,$Data,$ReleaseType,$Size) = $Detail; diff --git a/sections/ajax/userhistory/post_history.php b/sections/ajax/userhistory/post_history.php index edf96e52..9fa1b600 100644 --- a/sections/ajax/userhistory/post_history.php +++ b/sections/ajax/userhistory/post_history.php @@ -54,10 +54,6 @@ function error_out($reason = '') { extract(array_intersect_key($UserInfo, array_flip(array('Username', 'Enabled', 'Title', 'Avatar', 'Donor', 'Warned')))); } -if (check_perms('site_proxy_images') && !empty($Avatar)) { - $Avatar = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?c=1&i='.urlencode($Avatar); -} - if ($LoggedUser['CustomForums']) { unset($LoggedUser['CustomForums']['']); $RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0)); diff --git a/sections/artist/artist.php b/sections/artist/artist.php index aba47d8f..0a03f502 100644 --- a/sections/artist/artist.php +++ b/sections/artist/artist.php @@ -387,7 +387,7 @@ function compare($X, $Y) {
- +
@@ -527,15 +527,11 @@ function compare($X, $Y) {