Page 1 of 1

Integrating the user system with the template system

Posted: Wed Sep 28, 2011 4:06 pm
by saycey
Hi

I'm having a problem integrating the user system with the template system...When I load up a page I keep getting the redirect loop error...I have looked through the code but have no idea what is causing the error.

Below is my init.inc.php file.
<?php
 
session_start();
 
if (empty($_GET['page'])) {
        header('Location: home');
        die();
}
$core_path = dirname(__FILE__);
 
$pages = scandir("{$core_path}/pages");
unset($pages[0], $pages[1]);
 
foreach ($pages as &$page) {
        $page = substr($page, 0, strpos($page, '.'));
}
 
if (in_array($_GET['page'], $pages)) {
        $include_file = "{$core_path}/pages/{$_GET['page']}.page.inc.php";
}else{
        $include_file = "{$core_path}/pages/home.page.inc.php";
}
 
//login starts below
 
$exceptions = array('register', 'login');
 
//$page1 = substr(end(explode('/', $_SERVER['SCRIPT_NAME'])), 0, -4);
 
if (in_array($include_file, $exceptions) === false){
        if (isset($_SESSION['username']) === false){
                header('Location: login');
                die();
        }
}
 
mysql_connect('localhost', 'user', 'pass');
mysql_select_db('db');
 
$path = dirname(__FILE__);
 
include("{$path}/core/user.inc.php");
 
?>
Anyone know whats wrong :S

Thanks,
Saycey :)

Re: Integrating the user system with the template system

Posted: Fri Sep 30, 2011 5:54 pm
by jacek
I have seen this before ;)

what does your .htaccess file look like ?

Re: Integrating the user system with the template system

Posted: Fri Sep 30, 2011 6:20 pm
by saycey
RewriteEngine On

RewriteRule ^([a-zA-Z_]+)/?$ index.php?page=$1 [QSA]

Re: Integrating the user system with the template system

Posted: Sun Oct 02, 2011 7:08 pm
by jacek
Okay, that looks pretty much fine. Are you being sent to home or login ?

Re: Integrating the user system with the template system

Posted: Sun Oct 02, 2011 9:28 pm
by saycey
Fixed the redirect error but I dont think any of the login part is working since protected.php isnt protected...

Re: Integrating the user system with the template system

Posted: Mon Oct 03, 2011 9:13 pm
by jacek
saycey wrote:Fixed the redirect error but I dont think any of the login part is working since protected.php isnt protected...
Put your self on the other side of that question. From what you told us "the login part is [not] working" how can we help !?