Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
need some help with PHP varible stuff
Old 05-24-2005, 04:05 PM need some help with PHP varible stuff
Novice Talker

Posts: 9
Trades: 0
ok well on my website we use a basic php code that displays a page in on the layout decided by the inputted page name like

?page=contact
heres the code we use

Code:
<?php
$pool = @include($_GET['page'] . ".php");
if (!$pool) { include("news/show_news.php"); }
?>
and the danger of this is that apperntly someone can enter other url;s in the varible and do things like launch attacks and other un wanted things. i was told theres some kind of IF statement or something you can use to only make it display internal pages or only pages specified. but i dont know what this code is, any help is appreciated

~scoot
scoot is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-27-2005, 02:02 PM Map your pages
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Trades: 0
Scoot,

I am not aware of the code to which you are referring, but you could writ e something more secure for yourself. Create some random numbers -- let's say 57, 412, 3088, 5699

Then map each of those to a page. So in $_GET[page], you'll just pass a number and it provides you the security that user input cannot short-circuit your logic. Then:

PHP Code:

$pageNum 
$_GET[page];

if( ! empty (
$pageNum) )
{
    
$includeFile mapPg$pageNum );
    include( 
$includeFile );
}


function 
mapPg$v )
{
    
$page "";

    switch( 
$v )
    {
        case 
57:  $page "something1.php"; break;
        case 
412:  $page "something2.php"; break;
        case 
3088:  $page "something3.php"; break;
        case 
5699:  $page "something4.php"; break;
        default:  
$page "error.php"; break;
    }
    return 
$page;



__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Old 05-29-2005, 01:34 PM
Average Talker

Posts: 28
Trades: 0
I am not really sure why you would do it this way and not just store everything in arrays and call to it when needed based on $_POST['criteria']
techniner is offline
Reply With Quote
View Public Profile
 
Old 05-29-2005, 01:53 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Moved to the php board.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 05-30-2005, 01:53 PM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Trades: 0
Quote:
Originally Posted by techniner
I am not really sure why you would do it this way and not just store everything in arrays and call to it when needed based on $_POST['criteria']
tehniner,

This was just an idea that will require very little code change from the current mechanism but does provide some security from malicious code. Please post your code ideas as an alternative.
__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Reply     « Reply to need some help with PHP varible stuff
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.88111 seconds with 12 queries