sql_query($sql)) { return 'ERROR'; } else { $row = $db->sql_fetchrow($result); if($mode == 'newestuser') { return($row); } else if($mode == "usersonline") { return ($row['online']); } else { return($row['total']); } } } function make_jumpbox($db) { global $l_jumpto, $l_noforums, $l_nocategories; $sql = "SELECT c.* 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)) { $db_error = $db->sql_error(); 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 .= "\n"; $boxstring .= "\n"; $boxstring .= "\n"; if($total_forums) { for($y = 0; $y < $total_forums; $y++) { if( $forum_rows[$y]["cat_id"] == $category_rows[$i]["cat_id"] ) { $name = stripslashes($forum_rows[$y]["forum_name"]); $boxstring .= "\n"; } } } else { $boxstring .= "\n"; } } } else { $boxstring .= "\n"; } return($boxstring); } function language_select($default, $name="language", $dirname="language/") { global $phpEx; $dir = opendir($dirname); $lang_select = "\n"; closedir($dir); return $lang_select; } function theme_select($default, $db) { $sql = "SELECT theme_id, theme_name FROM ".THEMES_TABLE." ORDER BY theme_name"; if($result = $db->sql_query($sql)) { $num = $db->sql_numrows($result); $rowset = $db->sql_fetchrowset($result); $theme_select = "\n"; } else { $theme_select = ""; } return($theme_select); } // // Initialise user settings on page load // function init_userprefs($userdata) { global $override_user_theme; global $bgcolor, $table_bgcolor, $textcolor, $category_title, $table_header; global $color1, $color2, $header_image, $newtopic_image; global $reply_locked_image, $reply_image, $linkcolor, $vlinkcolor; global $default_lang, $date_format, $sys_timezone; if(!$override_user_theme) { if($userdata['user_id'] != ANONYMOUS || $userdata['user_id'] != DELETED) { $theme = setuptheme($userdata["user_theme"]); } else { $theme = setuptheme($default_theme); } } else { $theme = setuptheme($override_user_theme); } if($theme) { $bgcolor = $theme["bgcolor"]; $table_bgcolor = $theme["table_bgcolor"]; $textcolor = $theme["textcolor"]; $category_title = $theme["category_title"]; $table_header = $theme["table_header"]; $color1 = $theme["color1"]; $color2 = $theme["color2"]; $header_image = $theme["header_image"]; $newtopic_image = $theme["newtopic_image"]; $reply_locked_image = $theme["reply_locked_image"]; $reply_image = $theme["reply_image"]; $linkcolor = $theme["linkcolor"]; $vlinkcolor = $theme["vlinkcolor"]; } if($userdata["user_lang"] != "") { $default_lang = $userdata["user_lang"]; } if($userdata["user_dateformat"] != "") { $date_format = $userdata["user_dateformat"]; } if($userdata["user_timezone"]) { $sys_timezone = $userdata["user_timezone"]; } // Include the appropriate language file ... if it exists. if(!strstr($PHP_SELF, "admin")) { if(file_exists('language/lang_'.$default_lang.'.'.$phpEx)) { include('language/lang_'.$default_lang.'.'.$phpEx); } } else { if(strstr($PHP_SELF, "topicadmin")) { include('language/lang_'.$default_lang.'.'.$phpEx); } else { include('../language/lang_'.$default_lang.'.'.$phpEx); } } return; } function setuptheme($theme) { global $db; $sql = "SELECT * FROM ".THEMES_TABLE." WHERE theme_id = '$theme'"; if(!$result = $db->sql_query($sql)) return(0); if(!$myrow = $db->sql_fetchrow($result)) return(0); return($myrow); } function tz_select($default) { global $board_tz; if(!isset($default)) { $default == $board_tz; } $tz_select = "\n"; return($tz_select); } function validate_username(&$username, $db) { $username = trim($username); $username = strip_tags($username); $username = htmlspecialchars($username); if(empty($username)) { return(FALSE); } $valid_name = TRUE; $sql = "SELECT LOWER(username) FROM ".USERS_TABLE." WHERE username = '$username'"; if($result = $db->sql_query($sql)) { if( ($numrows = $db->sql_numrows($result) ) > 0) { $valid_name = FALSE; } } $sql = "SELECT disallow_username FROM ".DISALLOW_TABLE." WHERE disallow_username = '$username'"; if($result = $db->sql_query($sql)) { if(($numrows = $db->sql_numrows($result)) > 0) { $valid_name = FALSE; } } return($valid_name); } function generate_activation_key() { $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); $act_key = $chars[rand(0,$max_elements)]; $act_key .= $chars[rand(0,$max_elements)]; $act_key .= $chars[rand(0,$max_elements)]; $act_key .= $chars[rand(0,$max_elements)]; $act_key .= $chars[rand(0,$max_elements)]; $act_key .= $chars[rand(0,$max_elements)]; $act_key .= $chars[rand(0,$max_elements)]; $act_key .= $chars[rand(0,$max_elements)]; $act_key_md = md5($act_key); return($act_key_md); } 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]); 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] ) ); } 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]); return sprintf( "%d.%d.%d.%d", ( ( $int_ip >> 24 ) & 0xFF ), ( ( $int_ip >> 16 ) & 0xFF ), ( ( $int_ip >> 8 ) & 0xFF ), ( ( $int_ip ) & 0xFF ) ); } // // Create date/time from format and timezone // function create_date($format, $gmepoch, $tz) { return (date($format, $gmepoch + (3600 * $tz))); } ?>