Jump to content


Photo

File Restriction


  • Please log in to reply
4 replies to this topic

#1 Baving

Baving
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 20 September 2006 - 02:45 PM

Is there any way in which php files can be disabled from being viewed from a browser but will still work if they are included on another file like include("admin/blah.php");

If you try and acess the folder or files within it you would get the page cannot be displayed message.

I have tried this CHMOD but can't seem to get it to work, so I am wondering if there is a script you can use.

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 20 September 2006 - 03:30 PM

you can have the "admin/blah.php" file look like this:

<?php

if(isset($admin_include_code) && $admin_include_code=="123"){

//rest of the file here

}else{
die("This file cannot be accessed directly.");
}

?>


And every time you want to include the file you do:

<?php

$admin_include_code="123";
include("admin/blah.php");

?>



Hope it helps :)

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 20 September 2006 - 03:33 PM

I usually define a constant, but the other will work fine too.

You do not have to first check if it is set, and then if the value is 123, since if the value is 123 then it is obviously set.

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 20 September 2006 - 03:56 PM

I always thort even if a varable had nothink in it that it is set anyway am i right sorry to but in.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 20 September 2006 - 04:02 PM

I always thort even if a varable had nothink in it that it is set anyway am i right sorry to but in.


$var = null;[/url] and [code]$var = '';[/code] and [code]$var = false;[/code] will be set (obviously variables that are not empty will be set too).





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users