Location: PHPKode > projects > top serious project > bco/include.php
<?

function getmicrotime(){ 

    list($usec, $sec) = explode(" ",microtime()); 

    return ((float)$usec + (float)$sec); 

}

$time_start = getmicrotime();

/***************************************************************************
 *   Copyright 2003 Ian Meyer, Ian Pitcher
 *
 *   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.
 *
 ***************************************************************************/

// If Sybase magic quotes are enabled, we can not run the board. It's just how it is. Turn it off.
if (ini_get("magic_quotes_sybase") == 1) {
    $sybase_error  = "Sorry, but it looks like the magic_quotes_sybase runtime has been set to 1.";
    $sybase_error .= "</br >Please change this value to 0 in order for this board to work.";
    exit ($sybase_error);
}

//
// Turn the runtime off so things will work like I want them to.
//
set_magic_quotes_runtime(0);

error_reporting(E_NONE);

// Uncomment the following line to turn on gzip compression.
// If your webserver is already using mod_gzip do NOT uncomment the line
// as it will cause PHP to spew a warning.

// Comment the following line out if you don't want to enable compression.
ob_start("ob_gzhandler");

// Define the base url here
//$base_url = "http://" . $_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']); // This should automatically work.
if (preg_match("/^\/$/", dirname($_SERVER['REQUEST_URI']))) {
    $base_url = "http://" . $_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']);
} else {
    $base_url = "http://" . $_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']) . "/";
}

// Define cookie variables here.
$cookie_url = $_SERVER['SERVER_NAME']; // This should automatically work.
$cookie_dir = dirname($_SERVER['REQUEST_URI']); // This should automatically work.
$cookie_name_user = "bco_user_cookie";
$cookie_name_color = "bco_color_cookie";

// Set some variables for the messageboard
//define("BOARD_TITLE", "It's all rainbows, hearts, and diamonds.");
define("BOARD_TITLE", "Get her all alone and out come the kneepads");
define("ADMIN_NAME", "Ian Meyer");
define("ADMIN_EMAIL", "hide@address.com");

// These have to be required to make anything work.
require("functions/functions.html.php");
require("functions/functions.menus.php");
require("functions/functions.db.php");

if (!$pg_result = bco_dbconnect()) {
    pg_last_error($pg_result);
}

require("functions/functions.users.php");
require("functions/functions.auth.php");
require("admin/functions.admin.php");
require("functions/functions.threads.php");

$logged_in = '';

// Are we logged in?
if (bco_check_login()) {
	// If we are banned, error out.
	$userinfo = bco_user_info($user_array['myuserid']);
	if ($userinfo['banned'] == 1) {
		bco_logout();
		bco_error("You are banned.");
	}
    $logged_in = 1;

	// Are we an admin?
    if (bco_is_admin()) {
        $is_admin = 1;
    } else {
		// No, we're not an admin.
        $is_admin = 0;
    }

} else {
	// No, we're not logged in.
    $logged_id = 0;
}

if ($logged_in) {
    $query = "select show_stylesheet, hidden, images from users where id=$user_array[myuserid]";
    if (!$result = pg_query($pg_result, $query)) {
        exit(pg_last_error());
    }
    $user_data = pg_fetch_array($result);
} else {
    $user_data['show_stylesheet'] = 1;
    $user_data['hidden'] = 0;
    $user_data['images'] = 0;
}

// How many threads are there?
$query = "select total_topics from bco_config_new limit 1";
$number_of_threads = pg_fetch_result(pg_query($query), 0);

// Poll the blocked_ips table and exit() to any ip listed.
$query = "select ip from blocked_ips";

if (!$blocked_result = pg_query($query)) {
	exit("Blocked query fail.");
}

$blocked_ips = array();
while ($blocked_row = pg_fetch_array($blocked_result)) {
	// don't do anything but populate the array
	array_push($blocked_ips, $blocked_row['ip']);
}

unset($blocked_row, $blocked_result, $query);

if (in_array($_SERVER['REMOTE_ADDR'], $blocked_ips)) {
    bco_error("Sorry but your account has been suspended.");
}

?>
Return current item: top serious project