TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-16-2007, 12:06 AM   #1 (permalink)
The Acquainted
 
Join Date: Sep 2007
Posts: 126
Thanks: 4
Sam Granger is on a distinguished road
Default Do not allow direct access to php file.

Hey guys!

I have an index.php file with some includes. How do I allow index.php to include the files, but when you try and view the included files outside of index.php, you get an error?

Looking forward to suggestions on how to achieve this! :)
Sam Granger is offline  
Reply With Quote
Old 10-16-2007, 12:29 AM   #2 (permalink)
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 360
Thanks: 24
Haris is on a distinguished road
Default

Example code?
Haris is offline  
Reply With Quote
Old 10-16-2007, 02:39 AM   #3 (permalink)
The Acquainted
 
obolus's Avatar
 
Join Date: Oct 2007
Location: florida
Posts: 110
Thanks: 36
obolus is on a distinguished road
Default

Try this...


Put into page that is including external php page:
PHP Code:
<?php
// Def Constant
define'parentFile' );

// Load Functions
include('includedfile.php');
?>
Put this into the 'includedfile.php' page:
PHP Code:
<?php
/**
* Check For Constant.
*/
defined'parentFile' ) or die( 'oh noes' );
?>
Pretty basic way of doing it. Works though.

Last edited by obolus : 10-16-2007 at 02:41 AM. Reason: bleh
obolus is offline  
Reply With Quote
Old 10-16-2007, 08:29 AM   #4 (permalink)
The Acquainted
 
Join Date: Sep 2007
Posts: 126
Thanks: 4
Sam Granger is on a distinguished road
Default

Quote:
Originally Posted by obolus View Post
Try this...


Put into page that is including external php page:
PHP Code:
<?php
// Def Constant
define'parentFile' );

// Load Functions
include('includedfile.php');
?>
Put this into the 'includedfile.php' page:
PHP Code:
<?php
/**
* Check For Constant.
*/
defined'parentFile' ) or die( 'oh noes' );
?>
Pretty basic way of doing it. Works though.
Thanks, will give that a go. :)
Sam Granger is offline  
Reply With Quote
Old 10-17-2007, 12:48 PM   #5 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

But if they view index.php, and then views the includedfile.php after, the const is already defined.. so they will be able to view it after if they view index.php first.. true?
Tanax is offline  
Reply With Quote
Old 10-17-2007, 03:35 PM   #6 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

False. The constants are defined and only available at runtime, not across different page loads.
Salathe is offline  
Reply With Quote
Old 10-17-2007, 03:49 PM   #7 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

okey, thanks! :D
Tanax is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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


All times are GMT. The time now is 04:59 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design