Jump to content

File Restriction


Baving

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.
Link to comment
https://forums.phpfreaks.com/topic/21416-file-restriction/
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.
Link to comment
https://forums.phpfreaks.com/topic/21416-file-restriction/#findComment-95416
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]
Link to comment
https://forums.phpfreaks.com/topic/21416-file-restriction/#findComment-95458
Share on other sites

Archived

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

×
×
  • Create New...

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.