2001-04-19 13:18:57 +00:00
|
|
|
<?php
|
|
|
|
/***************************************************************************
|
|
|
|
* functions.php
|
|
|
|
* -------------------
|
|
|
|
* begin : Saturday, Feb 13, 2001
|
|
|
|
* copyright : (C) 2001 The phpBB Group
|
|
|
|
* email : support@phpbb.com
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2001-04-19 15:05:39 +00:00
|
|
|
function get_db_stat($mode)
|
2001-04-19 13:18:57 +00:00
|
|
|
{
|
2001-04-19 15:05:39 +00:00
|
|
|
global $db;
|
|
|
|
|
2001-04-19 13:18:57 +00:00
|
|
|
switch($mode){
|
|
|
|
case 'postcount':
|
2001-06-11 00:22:35 +00:00
|
|
|
$sql = "SELECT COUNT(post_id) AS total
|
2001-05-13 12:12:44 +00:00
|
|
|
FROM ".POSTS_TABLE;
|
2001-04-19 13:18:57 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'usercount':
|
2001-06-11 00:22:35 +00:00
|
|
|
$sql = "SELECT COUNT(user_id) AS total
|
2001-05-13 12:12:44 +00:00
|
|
|
FROM ". USERS_TABLE ."
|
2001-06-11 00:22:35 +00:00
|
|
|
WHERE user_id <> ".ANONYMOUS;
|
2001-04-19 13:18:57 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'newestuser':
|
2001-05-13 12:12:44 +00:00
|
|
|
$sql = "SELECT user_id, username
|
|
|
|
FROM ".USERS_TABLE."
|
|
|
|
WHERE user_id <> " . ANONYMOUS. "
|
2001-05-27 03:11:27 +00:00
|
|
|
ORDER BY user_id DESC
|
2001-05-13 12:12:44 +00:00
|
|
|
LIMIT 1";
|
2001-04-19 13:18:57 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(!$result = $db->sql_query($sql))
|
|
|
|
{
|
|
|
|
return 'ERROR';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$row = $db->sql_fetchrow($result);
|
|
|
|
if($mode == 'newestuser')
|
|
|
|
{
|
|
|
|
return($row);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return($row['total']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-11 00:58:08 +00:00
|
|
|
function get_userdata_from_id($userid)
|
2001-05-30 20:21:42 +00:00
|
|
|
{
|
|
|
|
global $db;
|
|
|
|
|
2001-06-11 00:58:08 +00:00
|
|
|
$sql = "SELECT *
|
|
|
|
FROM ".USERS_TABLE."
|
2001-05-30 20:21:42 +00:00
|
|
|
WHERE user_id = $userid";
|
2001-06-11 00:58:08 +00:00
|
|
|
if(!$result = $db->sql_query($sql))
|
2001-05-30 20:21:42 +00:00
|
|
|
{
|
|
|
|
$userdata = array("error" => "1");
|
|
|
|
return ($userdata);
|
|
|
|
}
|
|
|
|
if($db->sql_numrows($result))
|
|
|
|
{
|
|
|
|
$myrow = $db->sql_fetchrowset($result);
|
|
|
|
return($myrow[0]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$userdata = array("error" => "1");
|
|
|
|
return ($userdata);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_userdata($username) {
|
|
|
|
|
|
|
|
global $db;
|
|
|
|
|
2001-06-11 00:58:08 +00:00
|
|
|
$sql = "SELECT *
|
|
|
|
FROM ".USERS_TABLE."
|
|
|
|
WHERE username = '$username'
|
2001-05-30 20:21:42 +00:00
|
|
|
AND user_level != ".DELETED;
|
|
|
|
if(!$result = $db->sql_query($sql))
|
|
|
|
{
|
|
|
|
$userdata = array("error" => "1");
|
|
|
|
}
|
|
|
|
|
|
|
|
if($db->sql_numrows($result))
|
|
|
|
{
|
|
|
|
$myrow = $db->sql_fetchrowset($result);
|
|
|
|
return($myrow[0]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$userdata = array("error" => "1");
|
|
|
|
return ($userdata);
|
|
|
|
}
|
|
|
|
}
|
2001-04-19 13:18:57 +00:00
|
|
|
|
2001-04-19 15:05:39 +00:00
|
|
|
function make_jumpbox()
|
2001-04-19 13:18:57 +00:00
|
|
|
{
|
2001-04-19 15:05:39 +00:00
|
|
|
global $db;
|
2001-04-19 13:18:57 +00:00
|
|
|
global $l_jumpto, $l_noforums, $l_nocategories;
|
|
|
|
|
2001-05-13 12:12:44 +00:00
|
|
|
$sql = "SELECT c.cat_id, c.cat_title, c.cat_order
|
2001-04-19 13:18:57 +00:00
|
|
|
FROM ".CATEGORIES_TABLE." c, ".FORUMS_TABLE." f
|
|
|
|
WHERE f.cat_id = c.cat_id
|
|
|
|
GROUP BY c.cat_id, c.cat_title, c.cat_order
|
|
|
|
ORDER BY c.cat_order";
|
|
|
|
if(!$q_categories = $db->sql_query($sql))
|
|
|
|
{
|
|
|
|
error_die(SQL_QUERY, "Couldn't obtain category list.", __LINE__, __FILE__);
|
|
|
|
}
|
|
|
|
|
|
|
|
$total_categories = $db->sql_numrows();
|
|
|
|
if($total_categories)
|
|
|
|
{
|
|
|
|
$category_rows = $db->sql_fetchrowset($q_categories);
|
|
|
|
|
|
|
|
$limit_forums = "";
|
|
|
|
|
|
|
|
$sql = "SELECT *
|
|
|
|
FROM ".FORUMS_TABLE."
|
|
|
|
ORDER BY cat_id, forum_order";
|
|
|
|
if(!$q_forums = $db->sql_query($sql))
|
|
|
|
{
|
|
|
|
error_die(SQL_QUERY, "Couldn't obtain forums information.", __LINE__, __FILE__);
|
|
|
|
}
|
|
|
|
$total_forums = $db->sql_numrows($q_forums);
|
|
|
|
$forum_rows = $db->sql_fetchrowset($q_forums);
|
|
|
|
|
|
|
|
$boxstring = '';
|
|
|
|
for($i = 0; $i < $total_categories; $i++)
|
|
|
|
{
|
|
|
|
$boxstring .= "<option value=\"-1\"> </option>\n";
|
2001-05-13 12:12:44 +00:00
|
|
|
$boxstring .= "<option value=\"-1\">".stripslashes($category_rows[$i]['cat_title'])."</option>\n";
|
|
|
|
$boxstring .= "<option value=\"-1\">----------------</option>\n";
|
2001-04-19 13:18:57 +00:00
|
|
|
|
|
|
|
if($total_forums)
|
|
|
|
{
|
|
|
|
for($y = 0; $y < $total_forums; $y++)
|
|
|
|
{
|
2001-05-13 12:12:44 +00:00
|
|
|
if( $forum_rows[$y]['cat_id'] == $category_rows[$i]['cat_id'] )
|
2001-04-19 13:18:57 +00:00
|
|
|
{
|
2001-05-13 12:12:44 +00:00
|
|
|
$name = stripslashes($forum_rows[$y]['forum_name']);
|
|
|
|
$boxstring .= "<option value=\"".$forum_rows[$y]['forum_id']."\">$name</option>\n";
|
2001-04-19 13:18:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$boxstring .= "<option value=\"-1\">-- ! No Forums ! --</option>\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$boxstring .= "<option value=\"-1\">-- ! No Categories ! --</option>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
return($boxstring);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Initialise user settings on page load
|
|
|
|
function init_userprefs($userdata)
|
|
|
|
{
|
2001-05-03 22:10:23 +00:00
|
|
|
global $board_config, $theme, $template, $lang, $phpEx;
|
2001-05-02 00:42:33 +00:00
|
|
|
|
2001-05-03 22:10:23 +00:00
|
|
|
if(!$board_config['override_user_themes'])
|
2001-04-19 13:18:57 +00:00
|
|
|
{
|
2001-06-11 12:43:25 +00:00
|
|
|
if(($userdata['user_id'] != ANONYMOUS || $userdata['user_id'] != DELETED) && isset($userdata['user_theme']))
|
2001-04-19 13:18:57 +00:00
|
|
|
{
|
2001-04-29 20:21:33 +00:00
|
|
|
$theme = setuptheme($userdata['user_theme']);
|
2001-04-19 13:18:57 +00:00
|
|
|
}
|
2001-05-27 03:11:27 +00:00
|
|
|
else
|
2001-04-19 13:18:57 +00:00
|
|
|
{
|
2001-05-03 22:10:23 +00:00
|
|
|
$theme = setuptheme($board_config['default_theme']);
|
2001-04-19 13:18:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-03 22:10:23 +00:00
|
|
|
$theme = setuptheme($board_config['override_user_themes']);
|
2001-04-19 13:18:57 +00:00
|
|
|
}
|
2001-06-11 12:53:35 +00:00
|
|
|
|
|
|
|
if($userdata['user_id'] != ANONYMOUS || $userdata['user_id'] != DELETED)
|
2001-04-19 13:18:57 +00:00
|
|
|
{
|
2001-06-11 12:53:35 +00:00
|
|
|
if(!empty($userdata['user_lang']))
|
|
|
|
{
|
|
|
|
$board_config['default_lang'] = $userdata['user_lang'];
|
|
|
|
}
|
|
|
|
if(!empty($userdata['user_dateformat']))
|
|
|
|
{
|
|
|
|
$board_config['default_dateformat'] = $userdata['user_dateformat'];
|
|
|
|
}
|
|
|
|
if(isset($userdata['user_timezone']))
|
|
|
|
{
|
|
|
|
$board_config['default_timezone'] = $userdata['user_timezone'];
|
|
|
|
}
|
|
|
|
if(!empty($userdata['user_template']))
|
|
|
|
{
|
|
|
|
$board_config['default_template'] = $userdata['user_template'];
|
|
|
|
}
|
2001-04-19 13:18:57 +00:00
|
|
|
}
|
2001-06-11 12:53:35 +00:00
|
|
|
|
2001-04-20 07:30:45 +00:00
|
|
|
// Setup user's Template
|
2001-06-11 12:53:35 +00:00
|
|
|
$template = new Template("templates/" . $board_config['default_template']);
|
2001-05-03 22:10:23 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
2001-06-11 12:43:25 +00:00
|
|
|
if(file_exists("language/lang_".$board_config['default_lang'].".".$phpEx) )
|
2001-04-19 13:18:57 +00:00
|
|
|
{
|
2001-05-03 22:10:23 +00:00
|
|
|
include('language/lang_'.$board_config['default_lang'].'.'.$phpEx);
|
2001-04-19 13:18:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-15 01:22:14 +00:00
|
|
|
include('language/lang_english.'.$phpEx);
|
2001-04-19 13:18:57 +00:00
|
|
|
}
|
2001-05-03 22:10:23 +00:00
|
|
|
|
2001-04-19 13:18:57 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-05-01 19:10:09 +00:00
|
|
|
|
2001-04-19 13:18:57 +00:00
|
|
|
function setuptheme($theme)
|
|
|
|
{
|
|
|
|
global $db;
|
2001-05-03 22:10:23 +00:00
|
|
|
|
2001-05-27 03:11:27 +00:00
|
|
|
$sql = "SELECT *
|
|
|
|
FROM ".THEMES_TABLE."
|
2001-05-13 12:12:44 +00:00
|
|
|
WHERE themes_id = $theme";
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-04-19 13:18:57 +00:00
|
|
|
if(!$result = $db->sql_query($sql))
|
2001-05-01 19:10:09 +00:00
|
|
|
{
|
2001-04-19 13:18:57 +00:00
|
|
|
return(0);
|
2001-05-01 19:10:09 +00:00
|
|
|
}
|
2001-04-19 13:18:57 +00:00
|
|
|
if(!$myrow = $db->sql_fetchrow($result))
|
2001-05-01 19:10:09 +00:00
|
|
|
{
|
2001-04-19 13:18:57 +00:00
|
|
|
return(0);
|
2001-05-01 19:10:09 +00:00
|
|
|
}
|
2001-04-19 13:18:57 +00:00
|
|
|
return($myrow);
|
|
|
|
}
|
|
|
|
|
2001-05-02 22:31:23 +00:00
|
|
|
function generate_activation_key()
|
2001-04-19 13:18:57 +00:00
|
|
|
{
|
2001-05-02 22:31:23 +00:00
|
|
|
$chars = array(
|
|
|
|
"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",
|
|
|
|
"u","U","v","V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8",
|
|
|
|
"9","0"
|
|
|
|
);
|
|
|
|
|
|
|
|
$max_elements = count($chars) - 1;
|
|
|
|
srand((double)microtime()*1000000);
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-05-02 22:31:23 +00:00
|
|
|
$act_key = '';
|
|
|
|
for($i = 0; $i < 8; $i++)
|
2001-04-19 13:18:57 +00:00
|
|
|
{
|
2001-05-02 22:31:23 +00:00
|
|
|
$act_key .= $chars[rand(0,$max_elements)];
|
2001-04-19 13:18:57 +00:00
|
|
|
}
|
2001-05-02 22:31:23 +00:00
|
|
|
$act_key_md = md5($act_key);
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-05-02 22:31:23 +00:00
|
|
|
return($act_key_md);
|
2001-04-19 13:18:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function encode_ip($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]));
|
|
|
|
|
2001-05-30 20:21:42 +00:00
|
|
|
// $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] ) );
|
2001-04-19 13:18:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function decode_ip($int_ip)
|
|
|
|
{
|
|
|
|
$hexipbang = explode(".",chunk_split($int_ip, 2, "."));
|
|
|
|
return hexdec($hexipbang[0]).".".hexdec($hexipbang[1]).".".hexdec($hexipbang[2]).".".hexdec($hexipbang[3]);
|
|
|
|
|
2001-05-30 20:21:42 +00:00
|
|
|
// 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 ) );
|
2001-04-19 13:18:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Create date/time from format and timezone
|
|
|
|
//
|
|
|
|
function create_date($format, $gmepoch, $tz)
|
|
|
|
{
|
|
|
|
return (gmdate($format, $gmepoch + (3600 * $tz)));
|
|
|
|
}
|
2001-05-06 16:16:22 +00:00
|
|
|
|
2001-05-26 00:25:50 +00:00
|
|
|
//
|
|
|
|
// Create a GMT timestamp
|
|
|
|
//
|
|
|
|
function get_gmt_ts()
|
|
|
|
{
|
2001-05-27 03:11:27 +00:00
|
|
|
$time = time();
|
|
|
|
return($time);
|
2001-05-26 00:25:50 +00:00
|
|
|
}
|
|
|
|
|
2001-05-07 23:04:16 +00:00
|
|
|
//
|
|
|
|
// Pagination routine, generates
|
|
|
|
// page number sequence
|
|
|
|
//
|
|
|
|
function generate_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = TRUE)
|
|
|
|
{
|
|
|
|
|
2001-06-11 00:22:35 +00:00
|
|
|
global $lang;
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-05-07 23:04:16 +00:00
|
|
|
$total_pages = ceil($num_items/$per_page);
|
|
|
|
if($total_pages == 1)
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2001-05-26 13:07:18 +00:00
|
|
|
$on_page = floor($start_item/$per_page) + 1;
|
2001-05-07 23:04:16 +00:00
|
|
|
|
|
|
|
$page_string = "";
|
|
|
|
|
|
|
|
$this_block_start = ($on_page < 10) ? 1 : floor($on_page/10) * 10;
|
|
|
|
$this_block_end = ($on_page < 10) ? 9 : $this_block_start + 9;
|
|
|
|
if($this_block_end > $total_pages)
|
|
|
|
{
|
|
|
|
$this_block_end = $total_pages;
|
|
|
|
}
|
|
|
|
|
|
|
|
for($i = $this_block_start; $i <= $this_block_end; $i++)
|
|
|
|
{
|
2001-06-11 00:22:35 +00:00
|
|
|
$page_string .= ($i == $on_page) ? "<b>$i</b>" : "<a href=\"".append_sid($base_url . "&start=" . (($i - 1) * $per_page)) . "\">$i</a>";
|
2001-05-07 23:04:16 +00:00
|
|
|
if($i < $this_block_end)
|
|
|
|
{
|
|
|
|
$page_string .= ", ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if($this_block_start > 1)
|
|
|
|
{
|
|
|
|
$page_string_prepend = "";
|
2001-06-11 00:22:35 +00:00
|
|
|
for($i = 0; $i < $this_block_start; $i += 10)
|
2001-05-07 23:04:16 +00:00
|
|
|
{
|
2001-06-11 00:22:35 +00:00
|
|
|
$page_string_prepend .= "<a href=\"" . append_sid($base_url . "&start=" . ($i * $per_page)) . "\">" . ( ($i == 0) ? ($i + 1) : $i) . " - " . ($i + 9) . "</a>, ";
|
2001-05-07 23:04:16 +00:00
|
|
|
}
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-05-07 23:04:16 +00:00
|
|
|
$page_string = $page_string_prepend . $page_string;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($this_block_end < $total_pages)
|
|
|
|
{
|
|
|
|
$page_string_append = ", ";
|
2001-06-09 21:09:00 +00:00
|
|
|
|
|
|
|
if(!($total_pages%10))
|
|
|
|
{
|
|
|
|
$page_url = append_sid($base_url."&start=".( ( ($this_block_end + 1) * $per_page ) - $per_page ) );
|
|
|
|
$page_string_append .= "<a href=\"$page_url\">$total_pages</a>";
|
|
|
|
}
|
|
|
|
else
|
2001-05-07 23:04:16 +00:00
|
|
|
{
|
2001-06-09 21:09:00 +00:00
|
|
|
|
2001-06-11 00:22:35 +00:00
|
|
|
for($i = $this_block_end + 1; $i < $total_pages; $i += 10)
|
2001-05-07 23:04:16 +00:00
|
|
|
{
|
2001-06-11 00:22:35 +00:00
|
|
|
$page_string_append .= "<a href=\"" . append_sid($base_url . "&start=" . (($i * $per_page) - $per_page)) . "\">" . ( ($i == 0) ? ($i + 1) : $i) . " - " . ((($i + 9) < $total_pages) ? ($i + 9) : $total_pages) . "</a>";
|
2001-06-09 21:09:00 +00:00
|
|
|
if($i < $total_pages - 10)
|
|
|
|
{
|
|
|
|
$page_string_append .= ", ";
|
|
|
|
}
|
2001-05-07 23:04:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$page_string .= $page_string_append;
|
|
|
|
}
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2001-05-07 23:04:16 +00:00
|
|
|
if($add_prevnext_text)
|
|
|
|
{
|
2001-05-26 13:07:18 +00:00
|
|
|
if($on_page > 1)
|
2001-05-07 23:04:16 +00:00
|
|
|
{
|
2001-06-11 00:22:35 +00:00
|
|
|
$page_string = " <a href=\"" . append_sid($base_url . "&start=" . (($on_page - 2) * $per_page)) . "\">" . $lang['Previous'] . "</a> " . $page_string;
|
2001-05-07 23:04:16 +00:00
|
|
|
}
|
2001-05-26 13:07:18 +00:00
|
|
|
if($on_page < $total_pages)
|
2001-05-07 23:04:16 +00:00
|
|
|
{
|
2001-06-11 00:22:35 +00:00
|
|
|
$page_string .= " <a href=\"" . append_sid($base_url . "&start=" . ($on_page * $per_page)) . "\">" . $lang['Next'] . "</a>";
|
2001-05-07 23:04:16 +00:00
|
|
|
}
|
2001-06-11 00:22:35 +00:00
|
|
|
|
|
|
|
$page_string = $lang['Goto_page'] . ": " . $page_string;
|
|
|
|
|
2001-05-07 23:04:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $page_string;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2001-06-11 00:58:08 +00:00
|
|
|
//
|
|
|
|
// Check to see if the username has been taken, or if it is disallowed.
|
|
|
|
// Used for registering, changing names, and posting anonymously with a username
|
|
|
|
//
|
|
|
|
function validate_username($username)
|
|
|
|
{
|
|
|
|
|
|
|
|
global $db;
|
|
|
|
|
|
|
|
switch(SQL_LAYER)
|
|
|
|
{
|
|
|
|
// Along with subqueries MySQL also lacks
|
|
|
|
// a UNION clause which would be very nice here :(
|
|
|
|
// So we have to use two queries
|
|
|
|
case 'mysql':
|
2001-06-12 16:37:52 +00:00
|
|
|
$sql_users = "SELECT group_name AS username
|
|
|
|
FROM " . GROUPS_TABLE . "
|
|
|
|
WHERE LOWER(group_name) = '" . strtolower($username) . "'";
|
2001-06-11 00:58:08 +00:00
|
|
|
$sql_disallow = "SELECT disallow_username
|
2001-06-12 16:37:52 +00:00
|
|
|
FROM " . DISALLOW_TABLE . "
|
2001-06-11 00:58:08 +00:00
|
|
|
WHERE disallow_username = '$username'";
|
|
|
|
|
|
|
|
if($result = $db->sql_query($sql_users))
|
|
|
|
{
|
|
|
|
if($db->sql_numrows($result) > 0)
|
|
|
|
{
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($result = $db->sql_query($sql_disallow))
|
|
|
|
{
|
|
|
|
if($db->sql_numrows($result) > 0)
|
|
|
|
{
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
$sql = "SELECT disallow_username
|
2001-06-12 16:37:52 +00:00
|
|
|
FROM " . DISALLOW_TABLE . "
|
2001-06-11 00:58:08 +00:00
|
|
|
WHERE disallow_username = '$username'
|
|
|
|
UNION
|
2001-06-12 16:37:52 +00:00
|
|
|
SELECT group_name AS username
|
|
|
|
FROM " . GROUPS_TABLE . "
|
|
|
|
WHERE LOWER(group_name) = '" . strtolower($username) . "'";
|
2001-06-11 00:58:08 +00:00
|
|
|
|
|
|
|
if($result = $db->sql_query($sql))
|
|
|
|
{
|
|
|
|
if($db->sql_numrows($result) > 0)
|
|
|
|
{
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
2001-06-09 01:42:24 +00:00
|
|
|
?>
|