ok for example (this is the other part of the functions.php file ) i put var_dump($db) after global $db right?
<?php
function checkLogin ( $levels )
{
session_start ();
global $db;
$kt = split ( ' ', $levels );
if ( ! $_SESSION['logged_in'] ) {
$access = FALSE;
if ( isset ( $_COOKIE['cookie_id'] ) ) {//if we have a cookie
$query = 'SELECT * FROM ' . DBPREFIX . 'users WHERE ID = ' . $db->qstr ( $_COOKIE['cookie_id'] );
if ( $db->RecordCount ( $query ) == 1 ) {//only one user can match that query
$row = $db->getRow ( $query );
//let's see if we pass the validation, no monkey business
if ( $_COOKIE['authenticate'] == md5 ( getIP () . $row->Password . $_SERVER['USER_AGENT'] ) ) {
//we set the sessions so we don't repeat this step over and over again
$_SESSION['user_id'] = $row->ID;
$_SESSION['logged_in'] = TRUE;
//now we check the level access, we might not have the permission
if ( in_array ( get_level_access ( $_SESSION['user_id'] ), $kt ) ) {
//we do?! horray!
$access = TRUE;
}
}
}
}
}
else {
$access = FALSE;
if ( in_array ( get_level_access ( $_SESSION['user_id'] ), $kt ) ) {
$access = TRUE;
}
}
if ( $access == FALSE ) {
header ( "Location: " . REDIRECT_TO_LOGIN );
}
}
?>