Welcome to our forums...

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Forum Statistics

  • Forum Members:
  • Total Threads:
  • Total Posts: 3
There are 1 users currently browsing forums.
PHP Scripting PHP is a scripting language for rapid web-development. It's a popular and powerful, OOP-capable language that is used by professionals. Discuss PHP here.

Reply
  #1  
Old 04-18-2009
Damien Gray's Avatar
Graduate Student
 
Join Date: Jul 2008
Location: New York
Age: 17
Posts: 440
Rep Power: 2
Damien Gray is on a distinguished road
How would I do it?

For example, if index.php?subtopic=register is called, in includes register.php and outputs $main_content?

Basically, whatever is called is included, and how would I make it secure?

Edit: Is this secure enough?

PHP Code:
if($_GET['page'] != null) {
    
$page $_GET['page'] . ".php";
    if (
file_exists($page)) {
        include(
$page);
            echo 
$main_content;
    } else {
        echo 
"That page does not exist";
}

Reply With Quote
  #2  
Old 05-10-2009
[PHP]
 
Join Date: May 2009
Posts: 3
Rep Power: 0
MohammadReza is on a distinguished road
Re: How would I do it?

Hi,

Now its more secure :

PHP Code:
if($_GET['page'] != null) {
    
//-------- Filtering the name of page option
    
$words = array("/""..");
    
$page $_GET['page'];
    
$filtered str_replace($words""$page);
    
$page $page ".php";
    if (
file_exists($page)) {
        include(
$page);
            echo 
$main_content;
    } else {
        echo 
"That page does not exist";
}

Regards,
Mohammad Reza
Reply With Quote
  #3  
Old 06-28-2009
Toddler
 
Join Date: Jun 2009
Posts: 5
Rep Power: 0
Brenden is on a distinguished road
Re: How would I do it?

It would be better still to have an array of accepted page names, and make sure that $page is one of them before including it.
Reply With Quote


Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 On
Pingbacks are On
Refbacks are On