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); - } -?> - - + private static function replace_extension($String, $Extension) { + return preg_replace('/\.[^.]*$/', $Extension, $String); } /** @@ -197,48 +152,70 @@ public static function cover_thumb($Source, $Category = 0, $Size = 90, $Title = */ public static function proxy_url($Url) { global $SSL; - return ($SSL ? 'https' : 'http') . '://' . SITE_URL - . '/image.php?i=' . urlencode($Url); + return ($SSL ? 'https' : 'http') . '://' . SITE_URL . '/image.php?c=1&i=' . urlencode($Url); } -} -/** - * This non-class determines the thumbnail equivalent of an image's URL after being passed the original - * - **/ - - -/** - * Replaces the extension. - */ -function replace_extension($String, $Extension) { - return preg_replace('/\.[^.]*$/', $Extension, $String); -} - -function contains($Substring, $String) { - return strpos($String, $Substring) !== false; -} - -/** - * Checks if URL points to a whatimg thumbnail. - */ -function has_whatimg_thumb($Url) { - return contains("_thumb", $Url); -} - -/** - * Cleans up imgur URL if it already has a modifier attached to the end of it. - */ -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); + /** + * Determine the image URL. This takes care of the image proxy and thumbnailing. + * @param string $Url + * @param bool $Thumb + * @return string + */ + public static function process($Url, $Thumb = false) { + global $LoggedUser; + if (empty($Url)) { + return ''; } + if (($Found = self::get_stored($Url . ($Thumb ? '_thumb' : '')))) { + return $Found; + } + + $ProcessedUrl = $Url; + if ($Thumb) { + $Extension = pathinfo($Url, PATHINFO_EXTENSION); + if (self::thumbnailable($Url) && self::valid_extension($Extension)) { + if (strpos($Url, 'whatimg') !== false && !self::has_whatimg_thumb($Url)) { + $ProcessedUrl = self::replace_extension($Url, '_thumb.' . $Extension); + } elseif (strpos($Url, 'imgur') !== false) { + $ProcessedUrl = self::replace_extension(self::clean_imgur_url($Url), 'm.' . $Extension); + } + } + } + + if (isset($LoggedUser['Permissions'])) { + /* + * We only want to apply the proxy and store the processed URL if the + * permissions were loaded before. This is necessary because self::process + * is used in Users::user_info which is called in script_start.php before + * the permissions are loaded, causing the own avatar to always load without + * proxy later on. + */ + if (check_perms('site_proxy_images')) { + $ProcessedUrl = self::proxy_url($ProcessedUrl); + } + + self::store($Url . ($Thumb ? '_thumb' : ''), $ProcessedUrl); + } + return $ProcessedUrl; + } + + /** + * Cover art thumbnail in browse, on artist pages etc. + * @global array $CategoryIcons + * @param string $Url + * @param int $CategoryID + */ + public static function cover_thumb($Url, $CategoryID) { + global $CategoryIcons; + if ($Url) { + $Src = self::process($Url, true); + $Lightbox = self::process($Url); + } else { + $Src = STATIC_SERVER . 'common/noartwork/' . $CategoryIcons[$CategoryID - 1]; + $Lightbox = $Src; + } +?> + + } - return $Base . '/' . $Path . '.' . $Extension; } diff --git a/classes/class_paranoia.php b/classes/class_paranoia.php index b68b0bb4..fdfa1ea5 100644 --- a/classes/class_paranoia.php +++ b/classes/class_paranoia.php @@ -50,51 +50,54 @@ function check_paranoia($Property, $Paranoia, $UserClass, $UserID = false) { if ($Property == false) { return false; } - if(!is_array($Paranoia)) { + if (!is_array($Paranoia)) { $Paranoia = unserialize($Paranoia); } - if(!is_array($Paranoia)) { + if (!is_array($Paranoia)) { $Paranoia = array(); } - if(is_array($Property)) { + if (is_array($Property)) { $all = true; - foreach ($Property as $P) { $all = $all && check_paranoia($P, $Paranoia, $UserClass, $UserID); } + foreach ($Property as $P) { + $all = $all && check_paranoia($P, $Paranoia, $UserClass, $UserID); + } return $all; } else { - if(($UserID !== false) && ($LoggedUser['ID'] == $UserID)) { + if (($UserID !== false) && ($LoggedUser['ID'] == $UserID)) { return PARANOIA_ALLOWED; } $May = !in_array($Property, $Paranoia) && !in_array($Property . '+', $Paranoia); - if($May) + if ($May) return PARANOIA_ALLOWED; - if(check_perms('users_override_paranoia', $UserClass)) + if (check_perms('users_override_paranoia', $UserClass)) { return PARANOIA_OVERRIDDEN; + } $Override=false; switch ($Property) { case 'downloaded': case 'ratio': case 'uploaded': case 'lastseen': - if(check_perms('users_mod', $UserClass)) + if (check_perms('users_mod', $UserClass)) return PARANOIA_OVERRIDDEN; break; case 'snatched': case 'snatched+': - if(check_perms('users_view_torrents_snatchlist', $UserClass)) + if (check_perms('users_view_torrents_snatchlist', $UserClass)) return PARANOIA_OVERRIDDEN; break; case 'uploads': case 'uploads+': case 'seeding': case 'seeding+': case 'leeching': case 'leeching+': - if(check_perms('users_view_seedleech', $UserClass)) + if (check_perms('users_view_seedleech', $UserClass)) return PARANOIA_OVERRIDDEN; break; case 'invitedcount': - if(check_perms('users_view_invites', $UserClass)) + if (check_perms('users_view_invites', $UserClass)) return PARANOIA_OVERRIDDEN; break; } return false; } -} \ No newline at end of file +} diff --git a/classes/class_search.php b/classes/class_search.php index 1c9f1331..a39d1505 100644 --- a/classes/class_search.php +++ b/classes/class_search.php @@ -1,6 +1,6 @@ //Require base class -if(!extension_loaded('sphinx')) { +if (!extension_loaded('sphinx')) { require(SERVER_ROOT.'/classes/sphinxapi.php'); } @@ -51,17 +51,17 @@ function search($Query='', $CachePrefix='', $CacheLength=0, $ReturnData=array(), $QueryEndTime=microtime(true); $Filters = array(); - foreach($this->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; $i
'.$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.='