Baving Posted September 20, 2006 Share Posted September 20, 2006 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. Quote Link to comment Share on other sites More sharing options...
Orio Posted September 20, 2006 Share Posted September 20, 2006 you can have the "admin/blah.php" file look like this:[code]<?phpif(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. Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted September 20, 2006 Share Posted September 20, 2006 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. Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 20, 2006 Share Posted September 20, 2006 I always thort even if a varable had nothink in it that it is set anyway am i right sorry to but in. Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted September 20, 2006 Share Posted September 20, 2006 [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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.