Jump to content

[SOLVED] sessions help


runnerjp

Recommended Posts

hey guys gonna try keep this simple as possible lol

 

ok so i have my page set out like so

 

<?php 
require_once('http://www.website.com/settings.php');
checkLogin('1 2');
?>
<?php
echo 'Hello <em><b><u>' . get_username ( $_SESSION['user_id'] ) . '</u></b></em>!<br />You are now logged in.<br /><br />.';	
?>

 

settings has this at the start

<?php
require ( 'http://www.website.com/lib/connection.php' );			// - the connection class needed to operate with mysql
require ( 'http://www.website.com/functions.php' );				// - the functions

 

and functions holds this part of the code that is supposed to work

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: http://website.com/members/index.php');
	}		
}

 

yet im getting the error code Call to undefined function: checklogin()

 

as it works on other pages outside the members folder how comes this does not work??

Link to comment
Share on other sites

but i have used this command before and it worked fine outside of the folder im using?

 

also when correcting it i get this error

<?php 
require_once('http://www.website.com/settings.php');
checkLogin('1 2').;

echo 'Hello <em><b><u>' . get_username ( $_SESSION['user_id'] ) . '</u></b></em>!<br />You are now logged in.<br /><br />.';	
?>

 

Parse error: syntax error, unexpected ';' in /home/runningp/public_html/members/profile.php on line 17

 

i have used require_once('http://www.website.com/settings.php');

checkLogin('1 2');

before and it worked fine :S

 

Link to comment
Share on other sites

but i have used this command before and it worked fine outside of the folder im using?

 

also when correcting it i get this error

<?php 
require_once('http://www.website.com/settings.php');
checkLogin('1 2').;

echo 'Hello <em><b><u>' . get_username ( $_SESSION['user_id'] ) . '</u></b></em>!<br />You are now logged in.<br /><br />.';	
?>

 

Parse error: syntax error, unexpected ';' in /home/runningp/public_html/members/profile.php on line 17

 

i have used require_once('http://www.website.com/settings.php');

checkLogin('1 2');

before and it worked fine :S

 

 

what is line 17?

 

Link to comment
Share on other sites

The OP said:

> yet im getting the error code Call to undefined function: checklogin()

 

Does the error handler do a strtolower function on function names?

 

I saw that in his code he posted, he had it correctly capitalized, but I thought maybe he was calling checklogin() from somewhere else too (something that wasn't posted). Oh well...

 

PhREEEk

Link to comment
Share on other sites

yes but the file im using to call it is in members file and settings is just in route folder

 

<?php
require ( 'http://www.website.com/lib/connection.php' );			// - the connection class needed to operate with mysql
require ( 'http://www.website.com/functions.php' );				// - the functions

 

to

 

<?php
require ( 'lib/connection.php' );			// - the connection class needed to operate with mysql
require ( 'functions.php' );				// - the functions

Link to comment
Share on other sites

wow ok that just made MAJOR errors

 

Warning: main() [function.main]: open_basedir restriction in effect. File(/lib/connection.php) is not within the allowed path(s): (/home/runningp:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp) in /home/runningp/public_html/settings.php on line 2

 

Warning: main(/lib/connection.php) [function.main]: failed to open stream: Operation not permitted in /home/runningp/public_html/settings.php on line 2

 

Warning: main() [function.main]: open_basedir restriction in effect. File(/lib/connection.php) is not within the allowed path(s): (/home/runningp:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp) in /home/runningp/public_html/settings.php on line 2

 

Warning: main(/lib/connection.php) [function.main]: failed to open stream: Operation not permitted in /home/runningp/public_html/settings.php on line 2

 

Fatal error: main() [function.require]: Failed opening required '/lib/connection.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/runningp/public_html/settings.php on line 2

Link to comment
Share on other sites

wow ok that just made MAJOR errors

 

Warning: main() [function.main]: open_basedir restriction in effect. File(/lib/connection.php) is not within the allowed path(s): (/home/runningp:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp) in /home/runningp/public_html/settings.php on line 2

 

Warning: main(/lib/connection.php) [function.main]: failed to open stream: Operation not permitted in /home/runningp/public_html/settings.php on line 2

 

Warning: main() [function.main]: open_basedir restriction in effect. File(/lib/connection.php) is not within the allowed path(s): (/home/runningp:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp) in /home/runningp/public_html/settings.php on line 2

 

Warning: main(/lib/connection.php) [function.main]: failed to open stream: Operation not permitted in /home/runningp/public_html/settings.php on line 2

 

Fatal error: main() [function.require]: Failed opening required '/lib/connection.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/runningp/public_html/settings.php on line 2

 

Might just be how i included the files, since I don't know the exact root.

 

Try putting those lines I edited right on your page where your using your functions.

Link to comment
Share on other sites

You'll want to use....

 

<?php

  require '../lib/connection.php';
  require '../functions.php';

?>

 

Using a url to include files will (most likely) break when you move to a remote host. Because, as I told you in another thread, this feature is commonly disabled.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.