inner page loading

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

inner page loading

Post by John Cartwright »

Code: Select all

<?
	
getpage($_GET["p"]);

		function getpage($page)
			{
				
// notice the $page00 its for security reasons so the user doesnt "guess" the filename

                        if ($page == "106")
				{
					$page = "home";
				}
				elseif ($page == "d6f"
				{
					$page = "roster";
				}
                                else
                                {
                                         $page = "home";
                                }
                                include $page."00.php";
		
				

				//if (empty($page))
					//{
					//$page = "home";
					//}
		
				//$page = $page.".php";
				//include $page;
                               
                                }

?>
Okay I'm trying to design a template for this clan which has the layout and depending on which variable is loaded... simple task.... but on my companies website of this gaming portal demo of this system we want it to be secure without having elseif isloaded load this page.. because it can get quite long..

i want to have something more or less like the commented version.. but is obviously not secure...

i was jus wondering what ways do you guys do it?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

something like this?

Code: Select all

<?php

function getPage($page)
{
  switch(strtolower($page))
  {
    case "d6f":
       $use = 'roster';
       break;

    case "106":
    default:
       $use = 'home';
       break;
  }

  $use .= '00.php';
  if(is_readable($use))
      include $use;
}

?>
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

No you misunderstand feyd :( , I want to get away from

if this

if that

because my links list is rather large...
Just wondering if anyone has other solutions on disguising the path...
while keeping the code short

( i know someone gonna say mod re-write but i can't )

thanks for the reply :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

well.. if you have some form of encoding that short form, you can reverse it.. Alternately, you could "register" the short for in a database (flat-file or sql, whatever) and "resolve" it...
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

that jus gave me the idea of base64_encode and decode..
tahnks: )
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

hmmmmmmmmmm base64 decode seems to go really slow...

is it jus me or what
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

shouldn't take long to run.. although it will almost always make more bytes than needed to encode a given string/bytestream... If you want short forms.. I'd go a database route to store what they are supposed to be..
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

i dont really understand what you mean
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

for which part?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

nvm feyd it was actually a piece of code on each page that was really slwoing down the site... not the base64 decryption... thanks for your help :)
Post Reply