From 7a5a9549824664cdeecca9b293443ec73df315cc Mon Sep 17 00:00:00 2001 From: nanosimbiot Date: Sun, 21 Aug 2011 02:33:47 +0000 Subject: [PATCH] r231 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Окраска ников (часть 1) sql - ALTER TABLE `bb_ranks` ADD `rank_style` VARCHAR( 255 ) NOT NULL git-svn-id: https://torrentpier2.googlecode.com/svn/trunk@231 a8ac35ab-4ca4-ca47-4c2d-a49a94f06293 --- upload/admin/admin_ranks.php | 79 ++--- upload/config.php | 6 +- upload/includes/FastJSON.class.php | 372 ---------------------- upload/includes/datastore/build_ranks.php | 2 +- upload/includes/datastore/build_stats.php | 3 +- upload/includes/functions.php | 41 ++- upload/includes/init_bb.php | 2 +- upload/includes/page_header.php | 2 +- upload/index.php | 10 +- upload/memberlist.php | 17 +- upload/templates/admin/admin_ranks.tpl | 8 +- upload/templates/default/index.tpl | 8 +- upload/templates/default/memberlist.tpl | 2 +- upload/templates/default/page_header.tpl | 2 +- upload/templates/default/viewforum.tpl | 11 +- upload/templates/default/viewonline.tpl | 4 +- upload/tracker.php | 4 +- upload/viewforum.php | 14 +- upload/viewonline.php | 23 +- upload/viewtopic.php | 2 +- 20 files changed, 119 insertions(+), 493 deletions(-) delete mode 100644 upload/includes/FastJSON.class.php diff --git a/upload/admin/admin_ranks.php b/upload/admin/admin_ranks.php index 8d660dfe2..92f854ffd 100644 --- a/upload/admin/admin_ranks.php +++ b/upload/admin/admin_ranks.php @@ -16,7 +16,7 @@ require('./pagestart.php'); $_POST['special_rank'] = 1; $_POST['min_posts'] = -1; -if( isset($_GET['mode']) || isset($_POST['mode']) ) +if(isset($_GET['mode']) || isset($_POST['mode'])) { $mode = isset($_GET['mode']) ? $_GET['mode'] : $_POST['mode']; } @@ -25,11 +25,11 @@ else // // These could be entered via a form button // - if( isset($_POST['add']) ) + if(isset($_POST['add'])) { $mode = "add"; } - else if( isset($_POST['save']) ) + else if(isset($_POST['save'])) { $mode = "save"; } @@ -40,20 +40,20 @@ else } -if( $mode != "" ) +if($mode != "") { - if( $mode == "edit" || $mode == "add" ) + if($mode == "edit" || $mode == "add") { // // They want to add a new rank, show the form. // - $rank_id = ( isset($_GET['id']) ) ? intval($_GET['id']) : 0; + $rank_id = (isset($_GET['id'])) ? intval($_GET['id']) : 0; $s_hidden_fields = ""; - if( $mode == "edit" ) + if($mode == "edit") { - if( empty($rank_id) ) + if(empty($rank_id)) { message_die(GENERAL_MESSAGE, $lang['MUST_SELECT_RANK']); } @@ -76,42 +76,44 @@ if( $mode != "" ) $s_hidden_fields .= ''; - $rank_is_special = ( $rank_info['rank_special'] ) ? "checked=\"checked\"" : ""; - $rank_is_not_special = ( !$rank_info['rank_special'] ) ? "checked=\"checked\"" : ""; + $rank_is_special = ($rank_info['rank_special']) ? HTML_CHECKED : ""; + $rank_is_not_special = (!$rank_info['rank_special']) ? HTML_CHECKED : ""; $template->assign_vars(array( 'TPL_RANKS_EDIT' => true, - "RANK" => @$rank_info['rank_title'], + "RANK" => $rank_info['rank_title'], "SPECIAL_RANK" => $rank_is_special, "NOT_SPECIAL_RANK" => $rank_is_not_special, - "MINIMUM" => ( $rank_is_special ) ? "" : @$rank_info['rank_min'], - "IMAGE" => ( @$rank_info['rank_image'] ) ? $rank_info['rank_image'] : "images/ranks/rank_image.gif", - "IMAGE_DISPLAY" => ( @$rank_info['rank_image'] ) ? '' : "", + "MINIMUM" => ($rank_is_special) ? "" : $rank_info['rank_min'], + "IMAGE" => ($rank_info['rank_image']) ? $rank_info['rank_image'] : "images/ranks/rank_image.gif", + "STYLE" => $rank_info['rank_style'], + "IMAGE_DISPLAY" => ($rank_info['rank_image']) ? '' : "", "S_RANK_ACTION" => append_sid("admin_ranks.php"), "S_HIDDEN_FIELDS" => $s_hidden_fields) ); } - else if( $mode == "save" ) + else if($mode == "save") { // // Ok, they sent us our info, let's update it. // - $rank_id = ( isset($_POST['id']) ) ? intval($_POST['id']) : 0; - $rank_title = ( isset($_POST['title']) ) ? trim($_POST['title']) : ""; - $special_rank = ( $_POST['special_rank'] == 1 ) ? TRUE : 0; - $min_posts = ( isset($_POST['min_posts']) ) ? intval($_POST['min_posts']) : -1; - $rank_image = ( (isset($_POST['rank_image'])) ) ? trim($_POST['rank_image']) : ""; + $rank_id = (isset($_POST['id'])) ? intval($_POST['id']) : 0; + $rank_title = (isset($_POST['title'])) ? trim($_POST['title']) : ""; + $rank_style = (isset($_POST['style'])) ? trim($_POST['style']) : ""; + $special_rank = ($_POST['special_rank'] == 1) ? TRUE : 0; + $min_posts = (isset($_POST['min_posts'])) ? intval($_POST['min_posts']) : -1; + $rank_image = ((isset($_POST['rank_image']))) ? trim($_POST['rank_image']) : ""; - if( $rank_title == "" ) + if($rank_title == "") { message_die(GENERAL_MESSAGE, $lang['MUST_SELECT_RANK']); } - if( $special_rank == 1 ) + if($special_rank == 1) { $max_posts = -1; $min_posts = -1; @@ -122,7 +124,7 @@ if( $mode != "" ) // if($rank_image != "") { - if ( !preg_match("/(\.gif|\.png|\.jpg)$/is", $rank_image)) + if (!preg_match("/(\.gif|\.png|\.jpg)$/is", $rank_image)) { $rank_image = ""; } @@ -136,26 +138,26 @@ if( $mode != "" ) SET user_rank = 0 WHERE user_rank = $rank_id"; - if( !$result = DB()->sql_query($sql) ) + if(!$result = DB()->sql_query($sql)) { message_die(GENERAL_ERROR, $lang['NO_UPDATE_RANKS'], "", __LINE__, __FILE__, $sql); } } $sql = "UPDATE " . BB_RANKS . " - SET rank_title = '" . DB()->escape($rank_title) . "', rank_special = $special_rank, rank_min = $min_posts, rank_image = '" . DB()->escape($rank_image) . "' + SET rank_title = '". DB()->escape($rank_title) ."', rank_special = $special_rank, rank_min = $min_posts, rank_image = '". DB()->escape($rank_image) . "', rank_style = '". DB()->escape($rank_style) ."' WHERE rank_id = $rank_id"; $message = $lang['RANK_UPDATED']; } else { - $sql = "INSERT INTO " . BB_RANKS . " (rank_title, rank_special, rank_min, rank_image) - VALUES ('" . DB()->escape($rank_title) . "', $special_rank, $min_posts, '" . DB()->escape($rank_image) . "')"; + $sql = "INSERT INTO " . BB_RANKS . " (rank_title, rank_special, rank_min, rank_image, rank_style) + VALUES ('". DB()->escape($rank_title) ."', $special_rank, $min_posts, '". DB()->escape($rank_image) ."', '". DB()->escape($rank_style) ."')"; $message = $lang['RANK_ADDED']; } - if( !$result = DB()->sql_query($sql) ) + if(!$result = DB()->sql_query($sql)) { message_die(GENERAL_ERROR, "Couldn't update/insert into ranks table", "", __LINE__, __FILE__, $sql); } @@ -165,27 +167,27 @@ if( $mode != "" ) message_die(GENERAL_MESSAGE, $message); } - else if( $mode == "delete" ) + else if($mode == "delete") { // // Ok, they want to delete their rank // - if( isset($_POST['id']) || isset($_GET['id']) ) + if(isset($_POST['id']) || isset($_GET['id'])) { - $rank_id = ( isset($_POST['id']) ) ? intval($_POST['id']) : intval($_GET['id']); + $rank_id = (isset($_POST['id'])) ? intval($_POST['id']) : intval($_GET['id']); } else { $rank_id = 0; } - if( $rank_id ) + if($rank_id) { $sql = "DELETE FROM " . BB_RANKS . " WHERE rank_id = $rank_id"; - if( !$result = DB()->sql_query($sql) ) + if(!$result = DB()->sql_query($sql)) { message_die(GENERAL_ERROR, "Couldn't delete rank data", "", __LINE__, __FILE__, $sql); } @@ -194,7 +196,7 @@ if( $mode != "" ) SET user_rank = 0 WHERE user_rank = $rank_id"; - if( !$result = DB()->sql_query($sql) ) + if(!$result = DB()->sql_query($sql)) { message_die(GENERAL_ERROR, $lang['NO_UPDATE_RANKS'], "", __LINE__, __FILE__, $sql); } @@ -221,7 +223,7 @@ else // $sql = "SELECT * FROM " . BB_RANKS . " ORDER BY rank_min, rank_title"; - if( !$result = DB()->sql_query($sql) ) + if(!$result = DB()->sql_query($sql)) { message_die(GENERAL_ERROR, "Couldn't obtain ranks data", "", __LINE__, __FILE__, $sql); } @@ -241,19 +243,20 @@ else $rank_id = $rank_rows[$i]['rank_id']; $rank_min = $rank_rows[$i]['rank_min']; - if( $special_rank == 1 ) + if($special_rank == 1) { $rank_min = $rank_max = "-"; } $row_class = !($i % 2) ? 'row1' : 'row2'; - $rank_is_special = ( $special_rank ) ? $lang['YES'] : $lang['NO']; + $rank_is_special = ($special_rank) ? $lang['YES'] : $lang['NO']; $template->assign_block_vars("ranks", array( "ROW_CLASS" => $row_class, "RANK" => $rank, - "IMAGE_DISPLAY" => ( @$rank_rows[$i]['rank_image'] ) ? '' : "", + "STYLE" => $rank_rows[$i]['rank_style'], + "IMAGE_DISPLAY" => ($rank_rows[$i]['rank_image']) ? '' : "", "SPECIAL_RANK" => $rank_is_special, "RANK_MIN" => $rank_min, diff --git a/upload/config.php b/upload/config.php index 5e7062686..11b3b98b3 100644 --- a/upload/config.php +++ b/upload/config.php @@ -365,6 +365,8 @@ ini_set('error_log', LOG_DIR .'php_err.log'); // magic quotes if (get_magic_quotes_gpc()) die('set magic_quotes off'); +// json +if (!function_exists('json_encode')) die('not json_encode'); // Triggers define('BB_ENABLED', TRIGGERS_DIR .'$on'); @@ -404,8 +406,8 @@ $bb_cfg['ext_link_new_win'] = true; // open external links in new $bb_cfg['topic_moved_days_keep'] = 7; // remove topic moved links after xx days (or FALSE to disable) $bb_cfg['allowed_posts_per_page'] = array(15, 30, 50, 100); -$bb_cfg['user_signature_start'] = '
_________________
'; -$bb_cfg['user_signature_end'] = '
'; //Это позволит использовать html теги, которые требуют закрытия. Например или +$bb_cfg['user_signature_start'] = '

_________________
'; +$bb_cfg['user_signature_end'] = '
'; //Это позволит использовать html теги, которые требуют закрытия. Например
или // Posts $bb_cfg['use_posts_cache'] = true; // if you switch from ON to OFF, you need to TRUNCATE `bb_posts_html` table diff --git a/upload/includes/FastJSON.class.php b/upload/includes/FastJSON.class.php deleted file mode 100644 index 896b66877..000000000 --- a/upload/includes/FastJSON.class.php +++ /dev/null @@ -1,372 +0,0 @@ -values), new GenericClass):new Instance of GenericClass - * - * With a decoded JSON object You could convert them - * into a new instance of your Generic Class. - * Example: - * class MyClass { - * var $param = "somevalue"; - * function MyClass($somevar) { - * $this->somevar = $somevar; - * }; - * function getVar = function(){ - * return $this->somevar; - * }; - * }; - * - * $instance = new MyClass("example"); - * $encoded = FastJSON::encode($instance); - * // {"param":"somevalue"} - * - * $decoded = FastJSON::decode($encoded); - * // $decoded instanceof Object => true - * // $decoded instanceof MyClass => false - * - * $decoded = FastJSON::convert($decoded, new MyClass("example")); - * // $decoded instanceof Object => true - * // $decoded instanceof MyClass => true - * - * $decoded->getVar(); // example - * - * --------------------------------------- - * - * @author Andrea Giammarchi - * @site http://www.devpro.it/ - * @version 0.4 [fixed string convertion problems, add stdClass optional convertion instead of associative array (used by default)] - * @requires anything - * @compatibility PHP >= 4 - * @license - * --------------------------------------- - * - * Copyright (c) 2006 - 2007 Andrea Giammarchi - * - * Permission is hereby granted, free of charge, - * to any person obtaining a copy of this software and associated - * documentation files (the "Software"), - * to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * _______________________________________ - */ -class FastJSON { - - // public methods - - /** - * public static method - * - * FastJSON::convert(params:* [, result:Instance]):* - * - * @param * String or Object - * @param Instance optional new generic class instance if first - * parameter is an object. - * @return * time() value or new Instance with object parameters. - * - * @note please read Special FastJSON::convert method Informations - */ - function convert($params, $result = null){ - switch(gettype($params)){ - case 'array': - $tmp = array(); - foreach($params as $key => $value) { - if(($value = FastJSON::encode($value)) !== '') - array_push($tmp, FastJSON::encode(strval($key)).':'.$value); - }; - $result = '{'.implode(',', $tmp).'}'; - break; - case 'boolean': - $result = $params ? 'true' : 'false'; - break; - case 'double': - case 'float': - case 'integer': - $result = $result !== null ? strftime('%Y-%m-%dT%H:%M:%S', $params) : strval($params); - break; - case 'NULL': - $result = 'null'; - break; - case 'string': - $i = create_function('&$e, $p, $l', 'return intval(substr($e, $p, $l));'); - if(preg_match('/^[0-9]{4}\-[0-9]{2}\-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $params)) - $result = mktime($i($params, 11, 2), $i($params, 14, 2), $i($params, 17, 2), $i($params, 5, 2), $i($params, 9, 2), $i($params, 0, 4)); - break; - case 'object': - $tmp = array(); - if(is_object($result)) { - foreach($params as $key => $value) - $result->$key = $value; - } else { - $result = get_object_vars($params); - foreach($result as $key => $value) { - if(($value = FastJSON::encode($value)) !== '') - array_push($tmp, FastJSON::encode($key).':'.$value); - }; - $result = '{'.implode(',', $tmp).'}'; - } - break; - } - return $result; - } - - /** - * public method - * - * FastJSON::decode(params:String[, useStdClass:Boolean]):* - * - * @param String valid JSON encoded string - * @param Bolean uses stdClass instead of associative array if params contains objects (default false) - * @return * converted variable or null - * is params is not a JSON compatible string. - * @note This method works in an optimist way. If JSON string is not valid - * the code execution will die using exit. - * This is probably not so good but JSON is often used combined with - * XMLHttpRequest then I suppose that's better more protection than - * just some WARNING. - * With every kind of valid JSON string the old error_reporting level - * and the old error_handler will be restored. - * - * @example - * FastJSON::decode('{"param":"value"}'); // associative array - * FastJSON::decode('{"param":"value"}', true); // stdClass - * FastJSON::decode('["one",two,true,false,null,{},[1,2]]'); // array - */ - function decode($encode, $stdClass = false){ - $pos = 0; - $slen = is_string($encode) ? strlen($encode) : null; - if($slen !== null) { - $error = error_reporting(0); - set_error_handler(array('FastJSON', '__exit')); - $result = FastJSON::__decode($encode, $pos, $slen, $stdClass); - error_reporting($error); - restore_error_handler(); - } - else - $result = null; - return $result; - } - - /** - * public method - * - * FastJSON::encode(params:*):String - * - * @param * Array, Boolean, Float, Int, Object, String or NULL variable. - * @return String JSON genric object rappresentation - * or empty string if param is not compatible. - * - * @example - * FastJSON::encode(array(1,"two")); // '[1,"two"]' - * - * $obj = new MyClass(); - * obj->param = "value"; - * obj->param2 = "value2"; - * FastJSON::encode(obj); // '{"param":"value","param2":"value2"}' - */ - function encode($decode){ - $result = ''; - switch(gettype($decode)){ - case 'array': - if(!count($decode) || array_keys($decode) === range(0, count($decode) - 1)) { - $keys = array(); - foreach($decode as $value) { - if(($value = FastJSON::encode($value)) !== '') - array_push($keys, $value); - } - $result = '['.implode(',', $keys).']'; - } - else - $result = FastJSON::convert($decode); - break; - case 'string': - $replacement = FastJSON::__getStaticReplacement(); - $result = '"'.str_replace($replacement['find'], $replacement['replace'], $decode).'"'; - break; - default: - if(!is_callable($decode)) - $result = FastJSON::convert($decode); - break; - } - return $result; - } - - // private methods, uncommented, sorry - function __getStaticReplacement(){ - static $replacement = array('find'=>array(), 'replace'=>array()); - if($replacement['find'] == array()) { - foreach(array_merge(range(0, 7), array(11), range(14, 31)) as $v) { - $replacement['find'][] = chr($v); - $replacement['replace'][] = "\\u00".sprintf("%02x", $v); - } - $replacement['find'] = array_merge(array(chr(0x5c), chr(0x2F), chr(0x22), chr(0x0d), chr(0x0c), chr(0x0a), chr(0x09), chr(0x08)), $replacement['find']); - $replacement['replace'] = array_merge(array('\\\\', '\\/', '\\"', '\r', '\f', '\n', '\t', '\b'), $replacement['replace']); - } - return $replacement; - } - function __decode(&$encode, &$pos, &$slen, &$stdClass){ - switch($encode{$pos}) { - case 't': - $result = true; - $pos += 4; - break; - case 'f': - $result = false; - $pos += 5; - break; - case 'n': - $result = null; - $pos += 4; - break; - case '[': - $result = array(); - ++$pos; - while($encode{$pos} !== ']') { - array_push($result, FastJSON::__decode($encode, $pos, $slen, $stdClass)); - if($encode{$pos} === ',') - ++$pos; - } - ++$pos; - break; - case '{': - $result = $stdClass ? new stdClass : array(); - ++$pos; - while($encode{$pos} !== '}') { - $tmp = FastJSON::__decodeString($encode, $pos); - ++$pos; - if($stdClass) - $result->$tmp = FastJSON::__decode($encode, $pos, $slen, $stdClass); - else - $result[$tmp] = FastJSON::__decode($encode, $pos, $slen, $stdClass); - if($encode{$pos} === ',') - ++$pos; - } - ++$pos; - break; - case '"': - switch($encode{++$pos}) { - case '"': - $result = ""; - break; - default: - $result = FastJSON::__decodeString($encode, $pos); - break; - } - ++$pos; - break; - default: - $tmp = ''; - preg_replace('/^(\-)?([0-9]+)(\.[0-9]+)?([eE]\+[0-9]+)?/e', '$tmp = "\\1\\2\\3\\4"', substr($encode, $pos)); - if($tmp !== '') { - $pos += strlen($tmp); - $nint = intval($tmp); - $nfloat = floatval($tmp); - $result = $nfloat == $nint ? $nint : $nfloat; - } - break; - } - return $result; - } - function __decodeString(&$encode, &$pos) { - $replacement = FastJSON::__getStaticReplacement(); - $endString = FastJSON::__endString($encode, $pos, $pos); - $result = str_replace($replacement['replace'], $replacement['find'], substr($encode, $pos, $endString)); - $pos += $endString; - return $result; - } - function __endString(&$encode, $position, &$pos) { - do { - $position = strpos($encode, '"', $position + 1); - }while($position !== false && FastJSON::__slashedChar($encode, $position - 1)); - if($position === false) - trigger_error('', E_USER_WARNING); - return $position - $pos; - } - function __exit($str, $a, $b) { - exit($a.'FATAL: FastJSON decode method failure [malicious or incorrect JSON string]'); - } - function __slashedChar(&$encode, $position) { - $pos = 0; - while($encode{$position--} === '\\') - $pos++; - return $pos % 2; - } -} - -?> diff --git a/upload/includes/datastore/build_ranks.php b/upload/includes/datastore/build_ranks.php index 7e09b93c9..9e5dd40ac 100644 --- a/upload/includes/datastore/build_ranks.php +++ b/upload/includes/datastore/build_ranks.php @@ -4,7 +4,7 @@ if (!defined('BB_ROOT')) die(basename(__FILE__)); $ranks = array(); -$sql = "SELECT rank_id, rank_title, rank_image FROM ". BB_RANKS; +$sql = "SELECT rank_id, rank_title, rank_image, rank_style FROM ". BB_RANKS; foreach (DB()->fetch_rowset($sql) as $row) { diff --git a/upload/includes/datastore/build_stats.php b/upload/includes/datastore/build_stats.php index 1783b3b1a..0a24719b5 100644 --- a/upload/includes/datastore/build_stats.php +++ b/upload/includes/datastore/build_stats.php @@ -48,7 +48,7 @@ if ($bb_cfg['gender']) // birthday stat if ($bb_cfg['birthday']['check_day'] && $bb_cfg['birthday']['enabled']) { - $sql = DB()->fetch_rowset("SELECT user_id, username, user_birthday, user_birthday, user_level, user_rank FROM ". BB_USERS ." WHERE user_id NOT IN(". EXCLUDED_USERS_CSV .") ORDER BY user_level DESC, username"); + $sql = DB()->fetch_rowset("SELECT user_id, username, user_birthday, user_birthday, user_rank FROM ". BB_USERS ." WHERE user_id NOT IN(". EXCLUDED_USERS_CSV .") ORDER BY user_level DESC, username"); $this_year = bb_date(TIMENOW, 'Y', '', false); $date_today = bb_date(TIMENOW, 'Ymd', '', false); $date_forward = bb_date(TIMENOW + ($bb_cfg['birthday']['check_day']*86400), 'Ymd', '', false); @@ -68,7 +68,6 @@ if ($bb_cfg['birthday']['check_day'] && $bb_cfg['birthday']['enabled']) $birthday_week_list[] = array( 'user_id' => $row['user_id'], 'username' => $row['username'], - 'level' => $row['user_level'], 'rank' => $row['user_rank'], 'age' => $row['user_birthday'], ); diff --git a/upload/includes/functions.php b/upload/includes/functions.php index af325537b..72ea794ab 100644 --- a/upload/includes/functions.php +++ b/upload/includes/functions.php @@ -2504,11 +2504,6 @@ function caching_output ($enabled, $mode, $cache_var_name, $ttl = 300) */ function bb_json_encode ($data) { - if (!function_exists('json_encode')) { - require_once( INC_DIR . 'FastJSON.class.php' ); - $json = new FastJSON(); - return $json->encode(utf8_encode($data)); - } return json_encode($data); } @@ -2518,12 +2513,6 @@ function bb_json_encode ($data) function bb_json_decode ($data) { if (!is_string($data)) trigger_error('invalid argument for '. __FUNCTION__, E_USER_ERROR); - - if (!function_exists('json_decode')) { - require_once( INC_DIR . 'FastJSON.class.php' ); - $json = new FastJSON(); - return utf8_decode($json->decode($data)); - } return json_decode($data, true); } @@ -2810,3 +2799,33 @@ function send_pm($user_id, $subject, $message, $poster_id = false) WHERE user_id = $user_id"); } +function profile_url($data) +{ + global $bb_cfg, $lang, $datastore; + + if (!$ranks = $datastore->get('ranks')) + { + $datastore->update('ranks'); + $ranks = $datastore->get('ranks'); + } + + if(isset($ranks[$data['user_rank']])) + { $title = $ranks[$data['user_rank']]['rank_title']; $style = $ranks[$data['user_rank']]['rank_style']; + } + if(empty($title)) $title = 'User'; + if(empty($style)) $style = 'colorUser'; + + $username = !empty($data['username']) ? $data['username'] : $lang['GUEST']; + $user_id = (!empty($data['user_id']) && $username != $lang['GUEST']) ? $data['user_id'] : ANONYMOUS; + + $profile = ''. $username .''; + + if(!in_array($user_id, array('', ANONYMOUS, BOT_UID)) && $username) + { + $profile = ''. $profile .''; + } + + return $profile; +} + + diff --git a/upload/includes/init_bb.php b/upload/includes/init_bb.php index 1d67974f2..493d90272 100644 --- a/upload/includes/init_bb.php +++ b/upload/includes/init_bb.php @@ -272,7 +272,7 @@ define('POST_REPORT_REASON_URL', 'r'); // Report [END] // Gender -define('MALE', 1); +define('MALE', 1); define('FEMALE', 2); // Torrents (reserved: -1) diff --git a/upload/includes/page_header.php b/upload/includes/page_header.php index 3e2974949..c7b38c51c 100644 --- a/upload/includes/page_header.php +++ b/upload/includes/page_header.php @@ -204,7 +204,7 @@ $template->assign_vars(array( 'LOGGED_IN' => $logged_in, 'SESSION_USER_ID' => $userdata['user_id'], - 'THIS_USERNAME' => $userdata['username'], + 'THIS_USER' => profile_url($userdata), 'THIS_AVATAR' => get_avatar($userdata['user_avatar'], $userdata['user_avatar_type'], !bf($userdata['user_opt'], 'user_opt', 'allow_avatar')), 'SHOW_LOGIN_LINK' => !defined('IN_LOGIN'), 'AUTOLOGIN_DISABLED' => !$bb_cfg['allow_autologin'], diff --git a/upload/index.php b/upload/index.php index 4a2388c9d..3d4f0bec0 100644 --- a/upload/index.php +++ b/upload/index.php @@ -99,7 +99,7 @@ $sql = " f.cat_id, f.forum_id, f.forum_status, f.forum_parent, f.show_on_index, p.post_id AS last_post_id, p.post_time AS last_post_time, t.topic_id AS last_topic_id, t.topic_title AS last_topic_title, - u.user_id AS last_post_user_id, + u.user_id AS last_post_user_id, u.user_rank AS last_post_user_rank, IF(p.poster_id = $anon, p.post_username, u.username) AS last_post_username FROM ". BB_CATEGORIES ." c INNER JOIN ". BB_FORUMS ." f ON($forums_join_sql) @@ -115,6 +115,7 @@ $replace_in_parent = array( 'last_post_time', 'last_post_user_id', 'last_post_username', + 'last_post_user_rank', 'last_topic_title', 'last_topic_id', ); @@ -300,8 +301,7 @@ foreach ($cat_forums as $cid => $c) 'LAST_TOPIC_TITLE' => wbr(str_short($f['last_topic_title'], $last_topic_max_len)), 'LAST_POST_TIME' => bb_date($f['last_post_time'], $bb_cfg['last_post_date_format']), - 'LAST_POST_USER_ID' => ($f['last_post_user_id'] != ANONYMOUS) ? $f['last_post_user_id'] : false, - 'LAST_POST_USER_NAME' => ($f['last_post_username']) ? str_short($f['last_post_username'], 15) : $lang['GUEST'], + 'LAST_POST_USER' => profile_url(array('username' => str_short($f['last_post_username'], 15), 'user_id' => $f['last_post_user_id'], 'user_rank' => $f['last_post_user_rank'])), )); } } @@ -344,7 +344,7 @@ if ($bb_cfg['birthday']['check_day'] && $bb_cfg['birthday']['enabled']) { foreach($stats['birthday_week_list'] as $week) { - $week_list[] = ''. $week['username'] .' ('. birthday_age($week['age']) .')'; + $week_list[] = profile_url($week) .' ('. birthday_age($week['age']) .')'; } $week_list = join(', ', $week_list); $week_list = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday']['check_day'], $week_list); @@ -355,7 +355,7 @@ if ($bb_cfg['birthday']['check_day'] && $bb_cfg['birthday']['enabled']) { foreach($stats['birthday_today_list'] as $today) { - $today_list[] = ''. $today['username'] .' ('. birthday_age($today['age'], 1) .')'; + $today_list[] = profile_url($today) .' ('. birthday_age($today['age'], 1) .')'; } $today_list = join(', ', $today_list); $today_list = $lang['BIRTHDAY_TODAY'] . $today_list; diff --git a/upload/memberlist.php b/upload/memberlist.php index 0002ed34b..b69e363a6 100644 --- a/upload/memberlist.php +++ b/upload/memberlist.php @@ -152,7 +152,7 @@ $template->assign_vars(array( )); // per-letter selection end -$sql = "SELECT username, user_id, user_opt, user_posts, user_regdate, user_from, user_website, user_email +$sql = "SELECT username, user_id, user_rank, user_opt, user_posts, user_regdate, user_from, user_website, user_email FROM ". BB_USERS ." WHERE user_id NOT IN(". EXCLUDED_USERS_CSV .")"; if ( $username ) @@ -163,20 +163,16 @@ if ( $username ) $sql .= ($letter_sql) ? " AND $letter_sql" : ''; $sql .= " ORDER BY $order_by"; -$result = DB()->sql_query($sql) OR message_die(GENERAL_ERROR, 'Could not query users', '', __LINE__, __FILE__, $sql); - -if ( $row = DB()->sql_fetchrow($result) ) +if ($result = DB()->fetch_rowset($sql)) { - $i = 0; - do + foreach($result as $i => $row) { - $username = $row['username']; $user_id = $row['user_id']; $from = $row['user_from']; $joined = bb_date($row['user_regdate'], $lang['DATE_FORMAT']); $posts = $row['user_posts']; $pm = ($bb_cfg['text_buttons']) ? ''. $lang['SEND_PM_TXTB'] .'' : '' . $lang['SEND_PRIVATE_MESSAGE'] . ''; - + if (bf($row['user_opt'], 'user_opt', 'viewemail') || IS_AM) { $email_uri = ($bb_cfg['board_email_form']) ? append_sid("profile.php?mode=email&". POST_USERS_URL ."=$user_id") : 'mailto:'. $row['user_email']; @@ -200,7 +196,7 @@ if ( $row = DB()->sql_fetchrow($result) ) $template->assign_block_vars('memberrow', array( 'ROW_NUMBER' => $i + ( $start + 1 ), 'ROW_CLASS' => $row_class, - 'USERNAME' => $username, + 'USER' => profile($row), 'FROM' => $from, 'JOINED_RAW' => $row['user_regdate'], 'JOINED' => $joined, @@ -210,10 +206,7 @@ if ( $row = DB()->sql_fetchrow($result) ) 'WWW' => $www, 'U_VIEWPROFILE' => append_sid("profile.php?mode=viewprofile&". POST_USERS_URL ."=$user_id")) ); - $i++; } - while ( $row = DB()->sql_fetchrow($result) ); - DB()->sql_freeresult($result); } else { diff --git a/upload/templates/admin/admin_ranks.tpl b/upload/templates/admin/admin_ranks.tpl index 090bddbbd..47f609e35 100644 --- a/upload/templates/admin/admin_ranks.tpl +++ b/upload/templates/admin/admin_ranks.tpl @@ -22,6 +22,12 @@ + + + + - + diff --git a/upload/templates/default/index.tpl b/upload/templates/default/index.tpl index 139e3c1d7..d64944165 100644 --- a/upload/templates/default/index.tpl +++ b/upload/templates/default/index.tpl @@ -112,11 +112,7 @@

{c.f.last.LAST_POST_TIME} · - - {c.f.last.LAST_POST_USER_NAME} - - {c.f.last.LAST_POST_USER_NAME} - + {c.f.last.LAST_POST_USER}

@@ -186,7 +182,7 @@

{WHOSBIRTHDAY_TODAY}

{WHOSBIRTHDAY_WEEK}

- +

{TOTAL_USERS_ONLINE}  {USERS_ONLINE_COUNTS}

diff --git a/upload/templates/default/memberlist.tpl b/upload/templates/default/memberlist.tpl index 076efe39d..a9f435e86 100644 --- a/upload/templates/default/memberlist.tpl +++ b/upload/templates/default/memberlist.tpl @@ -37,7 +37,7 @@
- + diff --git a/upload/templates/default/page_header.tpl b/upload/templates/default/page_header.tpl index 523b81546..a69b8af6b 100644 --- a/upload/templates/default/page_header.tpl +++ b/upload/templates/default/page_header.tpl @@ -333,7 +333,7 @@ function OpenInEditor ($file, $line)

Style

+ +

{L_RANK_IMAGE}:

@@ -64,7 +70,7 @@
{ranks.RANK}
{ranks.RANK}
{ranks.IMAGE_DISPLAY} {L_EDIT} {L_DELETE}
{memberrow.ROW_NUMBER}{memberrow.USERNAME}{memberrow.USER} {memberrow.PM} {memberrow.EMAIL} {memberrow.FROM}
@@ -555,12 +552,12 @@ td.topic_id { cursor: pointer; } [{ICON_GOTOPOST}{L_GOTO_SHORT} {t.PAGINATION} ] - + diff --git a/upload/templates/default/viewonline.tpl b/upload/templates/default/viewonline.tpl index ca087c076..81d139218 100644 --- a/upload/templates/default/viewonline.tpl +++ b/upload/templates/default/viewonline.tpl @@ -13,7 +13,7 @@ - + @@ -24,7 +24,7 @@ - + diff --git a/upload/tracker.php b/upload/tracker.php index 6d5ef9e9b..ee1b3e06f 100644 --- a/upload/tracker.php +++ b/upload/tracker.php @@ -660,7 +660,7 @@ if ($allowed_forums) $select .= (!$hide_speed) ? ", sn.speed_up, sn.speed_down" : ''; $select .= (!$hide_forum) ? ", tor.forum_id" : ''; $select .= (!$hide_cat) ? ", f.cat_id" : ''; - $select .= (!$hide_author) ? ", tor.poster_id, u.username" : ''; + $select .= (!$hide_author) ? ", tor.poster_id, u.username, u.user_rank" : ''; $select .= (!IS_GUEST) ? ", dl.user_status AS dl_status" : ''; // FROM @@ -752,7 +752,7 @@ if ($allowed_forums) 'TOPIC_TIME' => bb_date($tor['topic_time'], 'd-M-y') .' · '. delta_time($tor['topic_time']), 'POST_ID' => $tor['post_id'], 'POSTER_ID' => $poster_id, - 'USERNAME' => isset($tor['username']) ? wbr($tor['username']) : '', + 'USERNAME' => profile_url(array('username' => $tor['username'], 'user_rank' => $tor['user_rank'])), 'ROW_CLASS' => $row_class, 'ROW_NUM' => $row_num, diff --git a/upload/viewforum.php b/upload/viewforum.php index bd79d178b..42d1bba12 100644 --- a/upload/viewforum.php +++ b/upload/viewforum.php @@ -410,9 +410,9 @@ if ($topics_csv = join(',', $topic_ids)) { $topic_rowset = DB()->fetch_rowset(" SELECT - t.*, t.topic_poster AS first_user_id, + t.*, t.topic_poster AS first_user_id, u1.user_rank as first_user_rank, IF(t.topic_poster = $anon, p1.post_username, u1.username) AS first_username, - p2.poster_id AS last_user_id, + p2.poster_id AS last_user_id, u2.user_rank as last_user_rank, IF(p2.poster_id = $anon, p2.post_username, u2.username) AS last_username $select_tor_sql FROM ". BB_TOPICS ." t @@ -554,12 +554,10 @@ foreach ($topic_rowset as $topic) 'POLL' => $topic['topic_vote'], 'DL_CLASS' => isset($topic['dl_status']) ? $dl_link_css[$topic['dl_status']] : '', - 'TOPIC_AUTHOR_ID' => ($topic['first_user_id'] != ANONYMOUS) ? $topic['first_user_id'] : '', - 'TOPIC_AUTHOR_NAME' => ($topic['first_username']) ? wbr($topic['first_username']) : $lang['GUEST'], - 'LAST_POSTER_HREF' => ($topic['last_user_id'] != ANONYMOUS) ? $topic['last_user_id'] : '', - 'LAST_POSTER_NAME' => ($topic['last_username']) ? str_short($topic['last_username'], 15) : $lang['GUEST'], - 'LAST_POST_TIME' => bb_date($topic['topic_last_post_time']), - 'LAST_POST_ID' => $topic['topic_last_post_id'], + 'TOPIC_AUTHOR' => profile_url(array('username' => str_short($topic['first_username'], 15), 'user_id' => $topic['first_user_id'], 'user_rank' => $topic['first_user_rank'])), + 'LAST_POSTER' => profile_url(array('username' => str_short($topic['last_username'], 15), 'user_id' => $topic['last_user_id'], 'user_rank' => $topic['last_user_rank'])), + 'LAST_POST_TIME' => bb_date($topic['topic_last_post_time']), + 'LAST_POST_ID' => $topic['topic_last_post_id'], )); if (isset($topic['tor_size'])) diff --git a/upload/viewonline.php b/upload/viewonline.php index 4a7556c8b..4c0e92df9 100644 --- a/upload/viewonline.php +++ b/upload/viewonline.php @@ -25,7 +25,7 @@ $is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata); // // Get user list // -$sql = "SELECT u.user_id, u.username, u.user_opt, u.user_level, s.session_logged_in, s.session_time, s.session_ip +$sql = "SELECT u.user_id, u.username, u.user_opt, u.user_rank, s.session_logged_in, s.session_time, s.session_ip FROM ".BB_USERS." u, ".BB_SESSIONS." s WHERE u.user_id = s.session_user_id AND s.session_time >= ".( time() - 300 ) . " @@ -56,21 +56,7 @@ while ( $row = DB()->sql_fetchrow($result) ) if ( $user_id != $prev_user ) { - $username = $row['username']; - - $style_color = ''; - if ( $row['user_level'] == ADMIN ) - { - $username = '' . $username . ''; - } - else if ( $row['user_level'] == MOD ) - { - $username = '' . $username . ''; - } - else if ( $row['user_level'] == GROUP_MEMBER ) - { - $username = '' . $username . ''; - } + $username = profile_url($row); if ( bf($row['user_opt'], 'user_opt', 'allow_viewonline') ) { @@ -111,13 +97,12 @@ while ( $row = DB()->sql_fetchrow($result) ) $row_class = !($which_counter % 2) ? 'row1' : 'row2'; $template->assign_block_vars("$which_row", array( - 'ROW_CLASS' => $row_class, - 'USERNAME' => $username, + 'ROW_CLASS' => $row_class, + 'USER' => $username, 'LASTUPDATE' => bb_date($row['session_time']), 'LASTUPDATE_RAW' => $row['session_time'], 'USERIP' => $user_ip, 'U_WHOIS_IP' => "http://ip-whois.net/ip_geo.php?ip=$user_ip", - 'U_USER_PROFILE' => ((isset($user_id)) ? append_sid("profile.php?mode=viewprofile&" . POST_USERS_URL . '=' . $user_id) : ''), )); $which_counter++; diff --git a/upload/viewtopic.php b/upload/viewtopic.php index 8807dcb5a..c7381099d 100644 --- a/upload/viewtopic.php +++ b/upload/viewtopic.php @@ -947,7 +947,7 @@ for($i = 0; $i < $total_posts; $i++) 'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2', 'POST_ID' => $postrow[$i]['post_id'], 'IS_NEWEST' => ($postrow[$i]['post_id'] == $newest), - 'POSTER_NAME' => wbr($poster), + 'POSTER_NAME' => profile_url(array('username' => $poster, 'user_rank' => $user_rank)), 'POSTER_NAME_JS' => addslashes($poster), 'POSTER_RANK' => $poster_rank, 'RANK_IMAGE' => $rank_image,
- {L_USER_WELCOME}  {THIS_USERNAME}  [ {L_LOGOUT} ] + {L_USER_WELCOME}  {THIS_USER}  [ {L_LOGOUT} ] diff --git a/upload/templates/default/viewforum.tpl b/upload/templates/default/viewforum.tpl index ae4f05ee8..1eb10287f 100644 --- a/upload/templates/default/viewforum.tpl +++ b/upload/templates/default/viewforum.tpl @@ -456,10 +456,7 @@ td.topic_id { cursor: pointer; }
- {t.TOPIC_AUTHOR_NAME} - {t.TOPIC_AUTHOR_NAME} -  [{ICON_GOTOPOST}{L_GOTO_SHORT} {t.PAGINATION} ] -
+ {t.TOPIC_AUTHOR}
@@ -487,7 +484,7 @@ td.topic_id { cursor: pointer; }

{t.LAST_POST_TIME}

- {t.LAST_POSTER_NAME}{t.LAST_POSTER_NAME} + {t.LAST_POSTER} {ICON_LATEST_REPLY}

{t.REPLIES}{t.TOPIC_AUTHOR_NAME}{t.TOPIC_AUTHOR_NAME}{t.TOPIC_AUTHOR} {t.VIEWS}

{t.LAST_POST_TIME}

- {t.LAST_POSTER_NAME}{t.LAST_POSTER_NAME} + {t.LAST_POSTER} {ICON_LATEST_REPLY}

{reg_user_row.USERNAME}{reg_user_row.USER} {reg_user_row.LASTUPDATE_RAW}{reg_user_row.LASTUPDATE} {reg_user_row.USERIP}
{guest_user_row.USERNAME}{guest_user_row.USER} {guest_user_row.LASTUPDATE} {guest_user_row.USERIP}