Jump to content

Archived

This topic is now archived and is closed to further replies.

Baving

File Restriction

Recommended Posts

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.

Share this post


Link to post
Share on other sites
you can have the "admin/blah.php" file look like this:

[code]<?php

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

//rest of the file here

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

?>[/code]


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

[code]<?php

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

?>[/code]



Hope it helps :)

Orio.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
I always thort even if a varable had nothink in it that it is set anyway am i right sorry to but in.

Share this post


Link to post
Share on other sites
[quote author=redarrow link=topic=108795.msg438079#msg438079 date=1158767770]
I always thort even if a varable had nothink in it that it is set anyway am i right sorry to but in.
[/quote]

[code]$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).[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.