Page 1 of 1
help again?
Posted: Fri Jul 11, 2008 6:23 am
by chrismarsden
hi i need a little help again...
i have worked out all my login stuff, now im just restricting access to a link on the main page as a test, the link does not appear which is brill but when i try to login or anything the pages do not load...
if i take out the line of code checkLogin ( '1' ); the page loads fine as do any others
this was taken from where i am hiding code.
<?php
require_once('settings.php');
checkLogin ( '1' );
?>
this is the full block of code... any ideas people?

Re: help again?
Posted: Fri Jul 11, 2008 12:56 pm
by chrismarsden
any ideas on this one peeps, been trying to figure it all day!
Re: help again?
Posted: Fri Jul 11, 2008 1:11 pm
by jaoudestudios
Whats in your function checkLogin?
Re: help again?
Posted: Fri Jul 11, 2008 3:49 pm
by chrismarsden
ahhh just figures i did not include functions in the script. how ever if i do it gives a 404 error or gives error:
Not Found
The requested URL /REDIRECT_TO_LOGIN was not found on this server.
can any one please help...
if i include files it stops the page loading...
Code: Select all
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 );
}
}
Re: help again?
Posted: Fri Jul 11, 2008 6:33 pm
by Benjamin
First I would highly recommend that you enable error reporting so that you can see what's going on. It will save you loads of time. Second, based on what you posted I would think that REDIRECT_TO_LOGIN is an undefined constant.