proggR Posted July 12, 2008 Share Posted July 12, 2008 Is there anyway to tell where exactly a file is being accessed from? I want to see if I can block access directly to certain files through the URL but allow that file to be accessed and used by certain pages within my site. Is there anyway to see where its being accessed from so I can use some sort of if/else block to prevent anyone from directly accessing the file either entirely or without authorization? Link to comment https://forums.phpfreaks.com/topic/114447-solved-question-about-validation/ Share on other sites More sharing options...
JasonLewis Posted July 13, 2008 Share Posted July 13, 2008 You can check if it is being accessed directly by using something like: I am assuming you are including pages like ?page=folder/page.php or something like that. So in the index.php page that has this include script, above the include scripts you would have a variable like so: $direct_linking = false; //we set it to false, because they are NOT direct linking Then in your files that you include, so in page.php you would have this: if($direct_linking || $direct_linking == ""){ //they are viewing this file directly! die("You do not have permission to view this file."); }else{ //show page } There would be more ways to do this though. Link to comment https://forums.phpfreaks.com/topic/114447-solved-question-about-validation/#findComment-588701 Share on other sites More sharing options...
proggR Posted July 14, 2008 Author Share Posted July 14, 2008 Thanks Is there anyway to do that on a folder level? Like deny access to the entire folder in the same way, instead of file by file? Luckily I haven't started posting content so its not a HUGE deal but if I could get around that it'd be great. Especially since some of the files I'm talking about will be text files and won't have scripting. Link to comment https://forums.phpfreaks.com/topic/114447-solved-question-about-validation/#findComment-589555 Share on other sites More sharing options...
MasterACE14 Posted July 14, 2008 Share Posted July 14, 2008 ht.access for the more important files? Link to comment https://forums.phpfreaks.com/topic/114447-solved-question-about-validation/#findComment-589561 Share on other sites More sharing options...
JasonLewis Posted July 14, 2008 Share Posted July 14, 2008 You can password protect directories with cPanel if you have it, or .htaccess would do it as well I would think. Link to comment https://forums.phpfreaks.com/topic/114447-solved-question-about-validation/#findComment-589583 Share on other sites More sharing options...
proggR Posted July 14, 2008 Author Share Posted July 14, 2008 Yah I still have to look into .htaccess because I do have a few files that I want password protected and hidden. I'll look into what it can do for folders too. Thanks What is cPanel btw? No doubt I could google it and find a plethora of information but I've heard of it a lot lately and was wondering if someone could sum it up. *edit* nvm I looked it up. It looks pretty sweet. I might look into that, but I'll look into .htaccess either way. Thanks Link to comment https://forums.phpfreaks.com/topic/114447-solved-question-about-validation/#findComment-589590 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.