Jump to content

[SOLVED] restricting access


runnerjp

Recommended Posts

I personally use sessions to do this...  and use the item 'intime'...

 

I also use a switch thus keeping all my pages in one file...  to make it easier I use smarty as my template engine...  but i do something like this..

 

<?php
$login = '';

$_action = isset($_REQUEST['a']) ? $_REQUEST['a'] : ''; // get the action from the browser
if ($_action != 'logout' && $_action != 'login') { // make sure they arent logging in or logging out.
	if (!isset($_SESSION['admin']['intime'])) { // session isnt started
		$interface = 'login.tpl'; // show smarty template login.tpl
		$aws->assign('errMsg', 'ERROR: You must be logged in, in order to access the administration panel'); // my own class that extends smarty assign the error message.
	} elseif ($_SESSION['admin']['intime'] < time() - 1800) { // check if intime is current time - 1800 seconds.
		$interface = 'login.tpl';  // show smarty template login.tpl
		$aws->assign('errMsg', 'ERROR: Session expired.  Please login again.'); // assign error message
	}
} else {
$interface = 'constructor.tpl';
switch($_action) {

default: 

break;

case login:

break;

case logout:

break;
}


}
?>

 

Thats just basic how I do mine.

Absolutely.  It's basically the same thing...  except for in the place of $interface and $aws->assign you'd use like echo "You are not logged in"  and then in the else is where your page would be... 

 

then you might think about using, a header and footer php file for your template, so in each case you can include('header.php'); then do all of your code, then at the bottom include footer.php...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.