Topic: Url in admin section issue + default page shown to logged in admin
in admin section, If you acces something like /admin/jobs/administrators/
in $params you will find only nistrators (admin is stripped).
Also, if I already logged in as admin, and I go to: /admin/ the login form shows up... instead of homepage ....
A diff for these issues (This forum should have some attachment feature or code formatting - more than @code@):
Index: admin/index.php
===================================================================
--- admin/index.php (revision 1)
+++ admin/index.php (revision 4)
@@ -14,5 +14,4 @@
}
require_once 'config.php';
-
$page = (isset($_app_info['params'][0]) ? $db->real_escape_string($_app_info['params'][0]) : '');
$id = (isset($_app_info['params'][1]) ? $db->real_escape_string($_app_info['params'][1]) : 0);
@@ -31,5 +30,14 @@
// home
case '':
- require_once 'page_login.php';
+ #show login page only if the admin is not logged in
+ #else show homepage
+ if(!isset($_SESSION['AdminId']))
+ {
+ require_once 'page_login.php';
+ }
+ else
+ {
+ require_once 'page_home.php';
+ }
$flag = 1;
break;
Index: config.php
===================================================================
--- config.php (revision 3)
+++ config.php (revision 4)
@@ -120,5 +120,5 @@
$smarty = new Smarty();
$smarty->template_dir = APP_PATH . '_templates/';
- $smarty->compile_dir = APP_PATH . '_templates/_cache/';
+ $smarty->compile_dir = APP_PATH . '_templates/_cache/';
@@ -128,9 +128,13 @@
// Split URL - get parameters
$_app_info['params'] = array();
- $_url = str_replace(_APP_MAIN_DIR, '', $_SERVER['REQUEST_URI']);
+ #_APP_MAIN_DIR can be found twice in $_SERVER['REQUEST_URI'], only first occurence needs to be replaced
+ #eg: /admin/jobs/administrators/
+ $_url = preg_replace('#'._APP_MAIN_DIR.'#', '', $_SERVER['REQUEST_URI'],1);
$_tmp = explode('?', $_url);
$_url = $_tmp[0];
+
if ($_url = explode('/', $_url))
{
+
foreach ($_url as $tag)
{