PHP Dispatch Method

  • webmattster
  • Beginner
  • Beginner
  • webmattster
  • Posts: 42

Post 3+ Months Ago

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!
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

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. }
  • webmattster
  • Beginner
  • Beginner
  • webmattster
  • Posts: 42

Post 3+ Months Ago

Thank you very much! This works perfect.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 73 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.