mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
Some tidying up and switchover to message_die
git-svn-id: file:///svn/phpbb/trunk@605 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
d9ff52198b
commit
613d62ac79
1 changed files with 50 additions and 59 deletions
|
@ -26,7 +26,8 @@ function get_db_stat($mode)
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
switch($mode){
|
switch($mode)
|
||||||
|
{
|
||||||
case 'postcount':
|
case 'postcount':
|
||||||
$sql = "SELECT COUNT(post_id) AS total
|
$sql = "SELECT COUNT(post_id) AS total
|
||||||
FROM ".POSTS_TABLE;
|
FROM ".POSTS_TABLE;
|
||||||
|
@ -45,14 +46,13 @@ function get_db_stat($mode)
|
||||||
ORDER BY user_id DESC
|
ORDER BY user_id DESC
|
||||||
LIMIT 1";
|
LIMIT 1";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'topiccount':
|
case 'topiccount':
|
||||||
$sql = "SELECT SUM(forum_topics) AS total
|
$sql = "SELECT SUM(forum_topics) AS total
|
||||||
FROM ".FORUMS_TABLE;
|
FROM ".FORUMS_TABLE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!$result = $db->sql_query($sql))
|
if(!$result = $db->sql_query($sql))
|
||||||
{
|
{
|
||||||
return 'ERROR';
|
return 'ERROR';
|
||||||
|
@ -80,9 +80,9 @@ function get_userdata_from_id($userid)
|
||||||
WHERE user_id = $userid";
|
WHERE user_id = $userid";
|
||||||
if(!$result = $db->sql_query($sql))
|
if(!$result = $db->sql_query($sql))
|
||||||
{
|
{
|
||||||
$userdata = array("error" => "1");
|
message_die(GENERAL_ERROR, "Couldn't obtain userdata for id", "", __LINE__, __FILE__, $sql);
|
||||||
return ($userdata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($db->sql_numrows($result))
|
if($db->sql_numrows($result))
|
||||||
{
|
{
|
||||||
$myrow = $db->sql_fetchrowset($result);
|
$myrow = $db->sql_fetchrowset($result);
|
||||||
|
@ -90,8 +90,7 @@ function get_userdata_from_id($userid)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$userdata = array("error" => "1");
|
message_die(GENERAL_ERROR, "No userdata for this user_id", "", __LINE__, __FILE__, $sql);
|
||||||
return ($userdata);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,10 +101,10 @@ function get_userdata($username) {
|
||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
FROM " . USERS_TABLE . "
|
FROM " . USERS_TABLE . "
|
||||||
WHERE username = '$username'
|
WHERE username = '$username'
|
||||||
AND user_level != ".DELETED;
|
AND user_id <> " . ANONYMOUS;
|
||||||
if(!$result = $db->sql_query($sql))
|
if(!$result = $db->sql_query($sql))
|
||||||
{
|
{
|
||||||
$userdata = array("error" => "1");
|
message_die(GENERAL_ERROR, "Tried obtaining data for a non-existent user", "", __LINE__, __FILE__, $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($db->sql_numrows($result))
|
if($db->sql_numrows($result))
|
||||||
|
@ -115,8 +114,7 @@ function get_userdata($username) {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$userdata = array("error" => "1");
|
message_die(GENERAL_ERROR, "Tried obtaining data for a non-existent user", "", __LINE__, __FILE__, $sql);
|
||||||
return ($userdata);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +130,7 @@ function make_jumpbox()
|
||||||
ORDER BY c.cat_order";
|
ORDER BY c.cat_order";
|
||||||
if(!$q_categories = $db->sql_query($sql))
|
if(!$q_categories = $db->sql_query($sql))
|
||||||
{
|
{
|
||||||
error_die(SQL_QUERY, "Couldn't obtain category list.", __LINE__, __FILE__);
|
message_die(GENERAL_ERROR, "Couldn't obtain category list.", "", __LINE__, __FILE__, $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
$total_categories = $db->sql_numrows();
|
$total_categories = $db->sql_numrows();
|
||||||
|
@ -147,11 +145,13 @@ function make_jumpbox()
|
||||||
ORDER BY cat_id, forum_order";
|
ORDER BY cat_id, forum_order";
|
||||||
if(!$q_forums = $db->sql_query($sql))
|
if(!$q_forums = $db->sql_query($sql))
|
||||||
{
|
{
|
||||||
error_die(SQL_QUERY, "Couldn't obtain forums information.", __LINE__, __FILE__);
|
message_die(GENERAL_ERROR, "Couldn't obtain forums information.", "", __LINE__, __FILE__, $sql);
|
||||||
}
|
}
|
||||||
$total_forums = $db->sql_numrows($q_forums);
|
$total_forums = $db->sql_numrows($q_forums);
|
||||||
$forum_rows = $db->sql_fetchrowset($q_forums);
|
$forum_rows = $db->sql_fetchrowset($q_forums);
|
||||||
|
|
||||||
|
// $is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata);
|
||||||
|
|
||||||
$boxstring = '';
|
$boxstring = '';
|
||||||
for($i = 0; $i < $total_categories; $i++)
|
for($i = 0; $i < $total_categories; $i++)
|
||||||
{
|
{
|
||||||
|
@ -192,9 +192,13 @@ function init_userprefs($userdata)
|
||||||
|
|
||||||
if(!$board_config['override_user_themes'])
|
if(!$board_config['override_user_themes'])
|
||||||
{
|
{
|
||||||
if(($userdata['user_id'] != ANONYMOUS || $userdata['user_id'] != DELETED) && isset($userdata['user_theme']))
|
if( $userdata['user_id'] != ANONYMOUS && isset($userdata['user_theme']) )
|
||||||
{
|
{
|
||||||
$theme = setuptheme($userdata['user_theme']);
|
$theme = setuptheme($userdata['user_theme']);
|
||||||
|
if($theme == FALSE)
|
||||||
|
{
|
||||||
|
$theme = setuptheme($board_config['default_theme']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -206,36 +210,31 @@ function init_userprefs($userdata)
|
||||||
$theme = setuptheme($board_config['override_user_themes']);
|
$theme = setuptheme($board_config['override_user_themes']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($userdata['user_id'] != ANONYMOUS || $userdata['user_id'] != DELETED)
|
if( $userdata['user_id'] != ANONYMOUS )
|
||||||
{
|
{
|
||||||
if(!empty($userdata['user_lang']))
|
if(!empty($userdata['user_lang']))
|
||||||
{
|
{
|
||||||
$board_config['default_lang'] = $userdata['user_lang'];
|
$board_config['default_lang'] = $userdata['user_lang'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($userdata['user_dateformat']))
|
if(!empty($userdata['user_dateformat']))
|
||||||
{
|
{
|
||||||
$board_config['default_dateformat'] = $userdata['user_dateformat'];
|
$board_config['default_dateformat'] = $userdata['user_dateformat'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($userdata['user_timezone']))
|
if(isset($userdata['user_timezone']))
|
||||||
{
|
{
|
||||||
$board_config['default_timezone'] = $userdata['user_timezone'];
|
$board_config['default_timezone'] = $userdata['user_timezone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($userdata['user_template']))
|
if(!empty($userdata['user_template']))
|
||||||
{
|
{
|
||||||
$board_config['default_template'] = $userdata['user_template'];
|
$board_config['default_template'] = $userdata['user_template'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup user's Template
|
|
||||||
$template = new Template("templates/" . $board_config['default_template']);
|
$template = new Template("templates/" . $board_config['default_template']);
|
||||||
|
|
||||||
//
|
|
||||||
// This is currently worthless since all the individual
|
|
||||||
// language variables will only be locally defined in this
|
|
||||||
// function and not accessible to the board code globally.
|
|
||||||
// This will be fixed by moving all $l_xxxx vars into a single
|
|
||||||
// $lang[''] array
|
|
||||||
//
|
|
||||||
if(file_exists("language/lang_".$board_config['default_lang'].".".$phpEx) )
|
if(file_exists("language/lang_".$board_config['default_lang'].".".$phpEx) )
|
||||||
{
|
{
|
||||||
include('language/lang_'.$board_config['default_lang'].'.'.$phpEx);
|
include('language/lang_'.$board_config['default_lang'].'.'.$phpEx);
|
||||||
|
@ -255,14 +254,13 @@ function setuptheme($theme)
|
||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
FROM " . THEMES_TABLE . "
|
FROM " . THEMES_TABLE . "
|
||||||
WHERE themes_id = $theme";
|
WHERE themes_id = $theme";
|
||||||
|
|
||||||
if(!$result = $db->sql_query($sql))
|
if(!$result = $db->sql_query($sql))
|
||||||
{
|
{
|
||||||
return(0);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
if(!$myrow = $db->sql_fetchrow($result))
|
if(!$myrow = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
return(0);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
return($myrow);
|
return($myrow);
|
||||||
}
|
}
|
||||||
|
@ -273,10 +271,10 @@ function generate_activation_key()
|
||||||
"a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J",
|
"a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J",
|
||||||
"k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T",
|
"k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T",
|
||||||
"u","U","v","V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8",
|
"u","U","v","V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8",
|
||||||
"9","0"
|
"9","0");
|
||||||
);
|
|
||||||
|
|
||||||
$max_elements = count($chars) - 1;
|
$max_elements = count($chars) - 1;
|
||||||
|
|
||||||
srand((double)microtime()*1000000);
|
srand((double)microtime()*1000000);
|
||||||
|
|
||||||
$act_key = '';
|
$act_key = '';
|
||||||
|
@ -294,10 +292,6 @@ function encode_ip($dotquad_ip)
|
||||||
$ip_sep = explode(".", $dotquad_ip);
|
$ip_sep = explode(".", $dotquad_ip);
|
||||||
return (sprintf("%02x%02x%02x%02x", $ip_sep[0], $ip_sep[1], $ip_sep[2], $ip_sep[3]));
|
return (sprintf("%02x%02x%02x%02x", $ip_sep[0], $ip_sep[1], $ip_sep[2], $ip_sep[3]));
|
||||||
|
|
||||||
// $ip_p = (!empty($dotquad_proxy_ip)) ? explode(".", $dotquad_proxy_ip) : explode(".", "0.0.0.0");
|
|
||||||
|
|
||||||
// return (sprintf("%03d.%03d.%03d.%03d:%03d.%03d.%03d.%03d", $ip[0], $ip[1], $ip[2], $ip[3], $ip_p[0], $ip_p[1], $ip_p[2], $ip_p[3]));
|
|
||||||
|
|
||||||
// return (( $ip_sep[0] * 0xFFFFFF + $ip_sep[0] ) + ( $ip_sep[1] * 0xFFFF + $ip_sep[1] ) + ( $ip_sep[2] * 0xFF + $ip_sep[2] ) + ( $ip_sep[3] ) );
|
// return (( $ip_sep[0] * 0xFFFFFF + $ip_sep[0] ) + ( $ip_sep[1] * 0xFFFF + $ip_sep[1] ) + ( $ip_sep[2] * 0xFF + $ip_sep[2] ) + ( $ip_sep[3] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,7 +300,6 @@ function decode_ip($int_ip)
|
||||||
$hexipbang = explode(".",chunk_split($int_ip, 2, "."));
|
$hexipbang = explode(".",chunk_split($int_ip, 2, "."));
|
||||||
return hexdec($hexipbang[0]).".".hexdec($hexipbang[1]).".".hexdec($hexipbang[2]).".".hexdec($hexipbang[3]);
|
return hexdec($hexipbang[0]).".".hexdec($hexipbang[1]).".".hexdec($hexipbang[2]).".".hexdec($hexipbang[3]);
|
||||||
|
|
||||||
// list($ip['remote'], $ip['forwarded']) = explode(":", $c_ip);
|
|
||||||
// return sprintf( "%d.%d.%d.%d", ( ( $int_ip >> 24 ) & 0xFF ), ( ( $int_ip >> 16 ) & 0xFF ), ( ( $int_ip >> 8 ) & 0xFF ), ( ( $int_ip ) & 0xFF ) );
|
// return sprintf( "%d.%d.%d.%d", ( ( $int_ip >> 24 ) & 0xFF ), ( ( $int_ip >> 16 ) & 0xFF ), ( ( $int_ip >> 8 ) & 0xFF ), ( ( $int_ip ) & 0xFF ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +326,6 @@ function get_gmt_ts()
|
||||||
//
|
//
|
||||||
function generate_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = TRUE)
|
function generate_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = TRUE)
|
||||||
{
|
{
|
||||||
|
|
||||||
global $lang;
|
global $lang;
|
||||||
|
|
||||||
$total_pages = ceil($num_items/$per_page);
|
$total_pages = ceil($num_items/$per_page);
|
||||||
|
@ -431,13 +423,12 @@ function validate_username($username)
|
||||||
// a UNION clause which would be very nice here :(
|
// a UNION clause which would be very nice here :(
|
||||||
// So we have to use two queries
|
// So we have to use two queries
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
$sql_users = "SELECT group_name AS username
|
$sql_users = "SELECT username
|
||||||
FROM " . GROUPS_TABLE . "
|
FROM " . USERS_TABLE . "
|
||||||
WHERE LOWER(group_name) = '" . strtolower($username) . "'";
|
WHERE LOWER(username) = '" . strtolower($username) . "'";
|
||||||
$sql_disallow = "SELECT disallow_username
|
$sql_disallow = "SELECT disallow_username
|
||||||
FROM " . DISALLOW_TABLE . "
|
FROM " . DISALLOW_TABLE . "
|
||||||
WHERE disallow_username = '$username'";
|
WHERE disallow_username = '$username'";
|
||||||
|
|
||||||
if($result = $db->sql_query($sql_users))
|
if($result = $db->sql_query($sql_users))
|
||||||
{
|
{
|
||||||
if($db->sql_numrows($result) > 0)
|
if($db->sql_numrows($result) > 0)
|
||||||
|
@ -459,10 +450,9 @@ function validate_username($username)
|
||||||
FROM " . DISALLOW_TABLE . "
|
FROM " . DISALLOW_TABLE . "
|
||||||
WHERE disallow_username = '$username'
|
WHERE disallow_username = '$username'
|
||||||
UNION
|
UNION
|
||||||
SELECT group_name AS username
|
SELECT username
|
||||||
FROM " . GROUPS_TABLE . "
|
FROM " . USERS_TABLE . "
|
||||||
WHERE LOWER(group_name) = '" . strtolower($username) . "'";
|
WHERE LOWER(username) = '" . strtolower($username) . "'";
|
||||||
|
|
||||||
if($result = $db->sql_query($sql))
|
if($result = $db->sql_query($sql))
|
||||||
{
|
{
|
||||||
if($db->sql_numrows($result) > 0)
|
if($db->sql_numrows($result) > 0)
|
||||||
|
@ -475,4 +465,5 @@ function validate_username($username)
|
||||||
|
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue