PHP Dispatch Method

  • webmattster
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Feb 09, 2004
  • Posts: 42
  • Status: Offline

Post September 30th, 2009, 6:15 am

Referring to the Dispatch Method from the PHP Security Consortium:

I believe I understand that PHP Dispatch method allows for all page requests to go through one page instead of having to have everything easily accessible to world, you only have one page accessible and all requests go through that page. Is that correct? Does that mean you have to put a lot of information in the dispatch.php file for each page so it knows where to forward to. I guess I don't really understand what this is supposed to do. Any help would be appreciated.

Thanks!
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post September 30th, 2009, 6:15 am

  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post September 30th, 2009, 6:39 am

Quote:
Does that mean you have to put a lot of information in the dispatch.php file for each page so it knows where to forward to.


Not at all.

If you have a modules directory and a well thought out naming scheme, you can write a universal dispatcher in roughly 10 short lines of code. (not including brace lines)

Assuming you've already screened $mode

PHP Code: [ Select ]
$manage_mode_file = ROOT_PATH . "/manage/$mode";
 
if(file_exists("$manage_mode_file.php") && file_exists("$manage_mode_file.html"))
{
   require_once("$manage_mode_file.php");
}
else
{
   require_once(ROOT_PATH . '/manage/index.php');
}
  1. $manage_mode_file = ROOT_PATH . "/manage/$mode";
  2.  
  3. if(file_exists("$manage_mode_file.php") && file_exists("$manage_mode_file.html"))
  4. {
  5.    require_once("$manage_mode_file.php");
  6. }
  7. else
  8. {
  9.    require_once(ROOT_PATH . '/manage/index.php');
  10. }
Strong with this one, the sudo is.
  • webmattster
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Feb 09, 2004
  • Posts: 42
  • Status: Offline

Post October 3rd, 2009, 7:45 pm

Thank you very much! This works perfect.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 193 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.