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
Stop include file being viewed directly?
Old 12-21-2005, 05:38 PM Stop include file being viewed directly?
Extreme Talker

Posts: 219
Location: UK, East Anglia
Trades: 0
How do i stop a file like include.php that i have included on every page being viewed directly (www.mysite.com/include.php)?

I have seen a tutorial before but i cannot find it now.
At the moment i am using:
PHP Code:
if ($_SERVER['PHP_SELF'] == "/include.php")
{
die;

But this can sometimes cause problems.
timsquash5 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-21-2005, 06:20 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
unless you have a link to it no one will ever know it exists or where it is in your site.
Includes are processed by the server and the url is never shown to the outside world.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-22-2005, 02:37 AM
Novice Talker

Posts: 4
Trades: 0
in the include.php script put this inside of the php tags before any of your other code
PHP Code:
 if (!defined('InMainScript')){ exit; } 
then in the scripts that you need to include the file put the below code just above your include statement
PHP Code:
  define("InMainScript"True); 

Last edited by prozente; 12-22-2005 at 02:40 AM..
prozente is offline
Reply With Quote
View Public Profile
 
Old 12-28-2005, 01:11 PM
Junior Talker

Posts: 2
Trades: 0
.php files are sent to the interpreter when they are requested in a browser, they will never be rendered to a browser under any circumstance I am aware of.

I just tried accessing a library include file in my server and it returned a blank page, not even any page source code to view. Another include file with a menu returned just the rendered html code, a bare list of links.

If anyone can view your php code directly, something is very wrong with your server, but I wouldn't worry about it. Try accessing your files directly yourself just to be sure.

Cheers,

Rob
scaiferw is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Stop include file being viewed directly?
 

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.13477 seconds with 12 queries