|
-
April 29th, 2009, 12:20 PM
#1
Redirect hiding URL
Hi 
I'm pretty out of ideas in this matter. What I want is to somehow redirect from a controller php class to a php page without altering the url. I'm not a pro in php and maybe missing something. In Java it's done pretty easily using RequestDispatcher, but I know that in php the API is rather limited for this kind of functionality.
My controller model:
- each page contains an eXec parameter that carries a key for path forward so I know what class to execute and where to go go next;
- the controller contains an array with keys and class constructors, session validation, etc. and header() in the end;
- each class extends an interface to inherit the same function which is overloaded in each class where some data processing is made before loading next page;
Just to make myself clear, here are the files examples:
main controller:
PHP Code:
<?php //MAIN CONTROLLER >> require_once("classes/AppInterface.php"); require_once("classes/app_Null.php"); require_once("classes/app_Exit.php"); require_once("classes/app_Login.php"); //...
session_start(); $eXec = isset($_REQUEST["eXec"])?$_REQUEST["eXec"]:"app_logout"; if(isset($_SESSION["sid"]) && $_SESSION["sid"]==1){ $eXec = "app_logout"; }
$nextA = array( "web_indexp" => new AppNull("login.php"), "app_logout" => new AppExit("login.php"), "app_ulogin" => new AppLogin("usher_search.php") //... );
$appc = isset($nextA[$eXec])?$nextA[$eXec]:$nextA["app_logout"]; $_SESSION["cPage"] = $appc->execF($_REQUEST);
header("Location: pagex.php"); ?>
interface:
PHP Code:
<?php interface AppInterface{ public function execF($req); } ?>
a processing command class example:
PHP Code:
<?php class AppNull implements AppInterface{ private $nextPage; public function AppNull($eXec){ $this->nextPage = $eXec; } public function execF($req){ return $this->nextPage; } } ?>
pagex.php standart container:
PHP Code:
<?php session_start(); include("includes/header.php"); include("includes/title.php"); include("pages/".$_SESSION["cPage"]); include("includes/footer.php"); ?>
What I hate is "mySite/pagex.php" part, I just want ti see "mySite"
I do not want to radically change the flow model so I have to find some solution that just slightly alters it.
Any ideas?
Wanna install linux on a vacuum cleaner. Could anyone tell me which distro sucks better?
I had a nightmare last night. I was dreaming that I’m 64-bit and my blanket is 32-bit and I couldn’t cover myself with it, so I’ve spent the whole night freezing. And in the morning I find that my blanket just had fallen off the bed. =S (from: bash.org.ru)
//always looking for job opportunities in AU/NZ/US/CA/Europe :P
willCodeForFood(Arrays.asList("Java","PHP","C++","bash","Assembler","XML","XHTML","CSS","JS","PL/SQL"));
USE [code] TAGS! Read this FAQ if you are new here. If this post was helpful, please rate it!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|