Окраска ников (часть 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
This commit is contained in:
nanosimbiot 2011-08-21 02:33:47 +00:00
commit 7a5a954982
20 changed files with 119 additions and 493 deletions

View file

@ -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 .= '<input type="hidden" name="mode" value="save" />';
$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'] ) ? '<img src="../' . $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']) ? '<img src="../' . $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'] ) ? '<img src="../' . $rank_rows[$i]['rank_image'] . '" />' : "",
"STYLE" => $rank_rows[$i]['rank_style'],
"IMAGE_DISPLAY" => ($rank_rows[$i]['rank_image']) ? '<img src="../' . $rank_rows[$i]['rank_image'] . '" />' : "",
"SPECIAL_RANK" => $rank_is_special,
"RANK_MIN" => $rank_min,

View file

@ -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'] = '<span class="signature"><br />_________________<br />';
$bb_cfg['user_signature_end'] = '</span>'; //Это позволит использовать html теги, которые требуют закрытия. Например <table> или <font color>
$bb_cfg['user_signature_start'] = '<div class="signature"><br />_________________<br />';
$bb_cfg['user_signature_end'] = '</div>'; //Это позволит использовать html теги, которые требуют закрытия. Например <table> или <font color>
// Posts
$bb_cfg['use_posts_cache'] = true; // if you switch from ON to OFF, you need to TRUNCATE `bb_posts_html` table

View file

@ -1,372 +0,0 @@
<?php
if (!defined('BB_ROOT')) die(basename(__FILE__));
/**_______________________________________
*
* FastJSON,
* simple and fast Pear Service_JSON encoder/decoder alternative
* [http://pear.php.net/pepr/pepr-proposal-show.php?id=198]
* ---------------------------------------
* This class is about two time faster than Pear Service_JSON class.
* This class is probably not powerful as Service_JSON but it has
* no dependencies and converts correctly ASCII range 0x00 - 0x1F too.
* There's any string convertion, just regular RFC specific characters are converted
* into \u00XX string.
* To don't have problems with other chars try to use utf8_encode($json_encoded_string).
* To recieve correctly JSON strings from JavaScript use encodeURIComponent then
* use, if is necessary, utf8_decode before JS to PHP convertion.
* decode method doesn't returns a standard object class but You can
* create the corret class directly with FastJSON::convert method
* and with them You can manage JS Date objects too.
* ---------------------------------------
* Summary of static public methods
*
* convert
* extra, special method
*
* decode
* converts a valid JSON string
* into a native PHP variable
*
* encode
* converts a native php variable
* into a valid JSON string
* ---------------------------------------
*
* Special FastJSON::convert method Informations
* _______________________________________
* ---------------------------------------
* This method is used by FastJSON::encode method but should be used
* to do these convertions too:
*
* - JSON string to time() integer:
*
* FastJSON::convert(decodedDate:String):time()
*
* If You recieve a date string rappresentation You
* could convert into respective time() integer.
* Example:
* FastJSON::convert(FastJSON::decode($clienttime));
* // i.e. $clienttime = 2006-11-09T14:42:30
* // returned time will be an integer useful with gmdate or date
* // to create, for example, this string
* // Thu Nov 09 2006 14:42:30 GMT+0100 (Rome, Europe)
*
* - time() to JSON string:
*
* FastJSON::convert(time():Int32, true:Boolean):JSON Date String format
*
* You could send server time() informations and send them to clients.
* Example:
* FastJSON::convert(time(), true);
* // i.e. 2006-11-09T14:42:30
*
* - associative array to generic class:
*
* FastJSON::convert(array(params=>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;
}
}
?>

View file

@ -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)
{

View file

@ -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'],
);

View file

@ -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 = '<span title="'. $title .'" class="'. $style .'">'. $username .'</span>';
if(!in_array($user_id, array('', ANONYMOUS, BOT_UID)) && $username)
{
$profile = '<a href="'. make_url(PROFILE_URL . $user_id) .'">'. $profile .'</a>';
}
return $profile;
}

View file

@ -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)

View file

@ -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'],

View file

@ -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[] = '<a href="'. PROFILE_URL . $week['user_id'] .'">'. $week['username'] .'</a> <span class="small">('. birthday_age($week['age']) .')</span>';
$week_list[] = profile_url($week) .' <span class="small">('. birthday_age($week['age']) .')</span>';
}
$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[] = '<a href="'. PROFILE_URL . $today['user_id'] .'">'. $today['username'] .'</a> <span class="small">('. birthday_age($today['age'], 1) .')</span>';
$today_list[] = profile_url($today) .' <span class="small">('. birthday_age($today['age'], 1) .')</span>';
}
$today_list = join(', ', $today_list);
$today_list = $lang['BIRTHDAY_TODAY'] . $today_list;

View file

@ -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']) ? '<a class="txtb" href="'. append_sid("privmsg.php?mode=post&amp;". POST_USERS_URL ."=$user_id") .'">'. $lang['SEND_PM_TXTB'] .'</a>' : '<a href="' . append_sid("privmsg.php?mode=post&amp;". POST_USERS_URL ."=$user_id") .'"><img src="' . $images['icon_pm'] . '" alt="' . $lang['SEND_PRIVATE_MESSAGE'] . '" title="' . $lang['SEND_PRIVATE_MESSAGE'] . '" border="0" /></a>';
if (bf($row['user_opt'], 'user_opt', 'viewemail') || IS_AM)
{
$email_uri = ($bb_cfg['board_email_form']) ? append_sid("profile.php?mode=email&amp;". 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&amp;". POST_USERS_URL ."=$user_id"))
);
$i++;
}
while ( $row = DB()->sql_fetchrow($result) );
DB()->sql_freeresult($result);
}
else
{

View file

@ -22,6 +22,12 @@
<input class="post" type="text" name="title" size="60" maxlength="40" value="{RANK}" />
</td>
</tr>
<tr>
<td width="40%"><h4>Style</h4></td>
<td>
<input class="post" type="text" name="style" size="60" maxlength="40" value="{STYLE}" />
</td>
</tr>
<tr>
<td valign="top"><h4>{L_RANK_IMAGE}:</h4></td>
<td>
@ -64,7 +70,7 @@
</tr>
<!-- BEGIN ranks -->
<tr class="{ranks.ROW_CLASS} tCenter">
<td>{ranks.RANK}</td>
<td><div class="{ranks.STYLE}">{ranks.RANK}</div></td>
<td>{ranks.IMAGE_DISPLAY}</td>
<td><a href="{ranks.U_RANK_EDIT}">{L_EDIT}</a></td>
<td><a href="{ranks.U_RANK_DELETE}">{L_DELETE}</a></td>

View file

@ -112,11 +112,7 @@
<p class="last_post_time">
<span class="last_time">{c.f.last.LAST_POST_TIME}</span>
<span class="last_author">&middot;
<!-- IF c.f.last.LAST_POST_USER_ID -->
<a href="{PROFILE_URL}{c.f.last.LAST_POST_USER_ID}">{c.f.last.LAST_POST_USER_NAME}</a>
<!-- ELSE -->
{c.f.last.LAST_POST_USER_NAME}
<!-- ENDIF -->
{c.f.last.LAST_POST_USER}
</span>
</p>
<!-- END last -->
@ -186,7 +182,7 @@
<p>{WHOSBIRTHDAY_TODAY}</p>
<p>{WHOSBIRTHDAY_WEEK}</p>
<!-- ENDIF -->
<div class="hr1" style="margin: 5px 0 4px;"></div>
<p>{TOTAL_USERS_ONLINE}<!-- IF SHOW_ADMIN_OPTIONS --> &nbsp;{USERS_ONLINE_COUNTS}<!-- ENDIF --></p>

View file

@ -37,7 +37,7 @@
<!-- BEGIN memberrow -->
<tr class="{memberrow.ROW_CLASS} tCenter">
<td>{memberrow.ROW_NUMBER}</td>
<td><a href="{memberrow.U_VIEWPROFILE}" class="gen"><b>{memberrow.USERNAME}</b></a></td>
<td><b>{memberrow.USER}</b></td>
<td>{memberrow.PM}</td>
<td>{memberrow.EMAIL}</td>
<td>{memberrow.FROM}</td>

View file

@ -333,7 +333,7 @@ function OpenInEditor ($file, $line)
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="40%">
{L_USER_WELCOME} &nbsp;<a href="{U_PROFILE}"><b class="med">{THIS_USERNAME}</b></a>&nbsp; [ <a href="{U_LOGIN_LOGOUT}" onclick="return confirm('{L_CONFIRM_LOGOUT}');">{L_LOGOUT}</a> ]
{L_USER_WELCOME} &nbsp;<b class="med">{THIS_USER}</b>&nbsp; [ <a href="{U_LOGIN_LOGOUT}" onclick="return confirm('{L_CONFIRM_LOGOUT}');">{L_LOGOUT}</a> ]
</td>
<td align="center" nowrap="nowrap">

View file

@ -456,10 +456,7 @@ td.topic_id { cursor: pointer; }
<!-- ENDIF -->
</div>
<div class="topicAuthor" style="padding-top: 2px;">
<!-- IF t.TOPIC_AUTHOR_ID --><a href="{PROFILE_URL}{t.TOPIC_AUTHOR_ID}" class="topicAuthor">{t.TOPIC_AUTHOR_NAME}</a>
<!-- ELSE -->{t.TOPIC_AUTHOR_NAME}<!-- ENDIF -->
<!-- IF t.PAGINATION --><span class="topicPG">&nbsp;[{ICON_GOTOPOST}{L_GOTO_SHORT} {t.PAGINATION} ]</span><!-- ENDIF -->
</div>
{t.TOPIC_AUTHOR}
</td>
<td class="tCenter nowrap" style="padding: 2px 4px;">
@ -487,7 +484,7 @@ td.topic_id { cursor: pointer; }
<td class="tCenter small nowrap" style="padding: 3px 6px 2px;">
<p>{t.LAST_POST_TIME}</p>
<p style="padding-top: 2px">
<!-- IF t.LAST_POSTER_HREF --><a href="{PROFILE_URL}{t.LAST_POSTER_HREF}">{t.LAST_POSTER_NAME}</a><!-- ELSE -->{t.LAST_POSTER_NAME}<!-- ENDIF -->
{t.LAST_POSTER}
<a href="{POST_URL}{t.LAST_POST_ID}#{t.LAST_POST_ID}">{ICON_LATEST_REPLY}</a>
</p>
</td>
@ -555,12 +552,12 @@ td.topic_id { cursor: pointer; }
<!-- IF t.PAGINATION --><span class="topicPG">[{ICON_GOTOPOST}{L_GOTO_SHORT} {t.PAGINATION} ]</span><!-- ENDIF -->
</td>
<td class="tCenter med">{t.REPLIES}</td>
<td class="tCenter med"><!-- IF t.TOPIC_AUTHOR_ID --><a href="{PROFILE_URL}{t.TOPIC_AUTHOR_ID}">{t.TOPIC_AUTHOR_NAME}</a><!-- ELSE -->{t.TOPIC_AUTHOR_NAME}<!-- ENDIF --></td>
<td class="tCenter med">{t.TOPIC_AUTHOR}</td>
<td class="tCenter med">{t.VIEWS}</td>
<td class="tCenter nowrap small" style="padding: 1px 6px 2px;">
<p>{t.LAST_POST_TIME}</p>
<p>
<!-- IF t.LAST_POSTER_HREF --><a href="{PROFILE_URL}{t.LAST_POSTER_HREF}">{t.LAST_POSTER_NAME}</a><!-- ELSE -->{t.LAST_POSTER_NAME}<!-- ENDIF -->
{t.LAST_POSTER}
<a href="{POST_URL}{t.LAST_POST_ID}#{t.LAST_POST_ID}">{ICON_LATEST_REPLY}</a>
</p>
</td>

View file

@ -13,7 +13,7 @@
</thead>
<!-- BEGIN reg_user_row -->
<tr class="{reg_user_row.ROW_CLASS}">
<td><a href="{reg_user_row.U_USER_PROFILE}" class="gen">{reg_user_row.USERNAME}</a></td>
<td><b>{reg_user_row.USER}</b></td>
<td class="tCenter"><u>{reg_user_row.LASTUPDATE_RAW}</u>{reg_user_row.LASTUPDATE}</td>
<!-- IF IS_ADMIN --><td class="tCenter"><a href="{reg_user_row.U_WHOIS_IP}" class="gen" target="_blank">{reg_user_row.USERIP}</a></td><!-- ENDIF -->
</tr>
@ -24,7 +24,7 @@
</tr>
<!-- BEGIN guest_user_row -->
<tr class="{guest_user_row.ROW_CLASS}">
<td>{guest_user_row.USERNAME}</td>
<td>{guest_user_row.USER}</td>
<td class="tCenter">{guest_user_row.LASTUPDATE}</td>
<!-- IF SHOW_ADMIN_OPTIONS --><td class="tCenter"><a href="{guest_user_row.U_WHOIS_IP}" class="gen" target="_blank">{guest_user_row.USERIP}</a></td><!-- ENDIF -->
</tr>

View file

@ -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') .' <b>&middot;</b> '. 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,

View file

@ -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']))

View file

@ -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 = '<b class="colorAdmin">' . $username . '</b>';
}
else if ( $row['user_level'] == MOD )
{
$username = '<b class="colorMod">' . $username . '</b>';
}
else if ( $row['user_level'] == GROUP_MEMBER )
{
$username = '<b class="colorGroup">' . $username . '</b>';
}
$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&amp;" . POST_USERS_URL . '=' . $user_id) : ''),
));
$which_counter++;

View file

@ -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,