Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a file accessible to scripts but not users

Tags:

php

I have uploaded scripts to users servers. I don't want others to access this script through the browser, However, I want a script to be able to access it.

Placing the file outside of the public_html is not an option here,because it really needs to be in the public_html. Any ideas??? thanks.

like image 660
karto Avatar asked May 25 '11 18:05

karto


2 Answers

Put some variable before the include so you know where it is being called:

index.php:

$open = true;
include 'open.php';

open.php:

<?php
   if(isset($open) && $open){
      //do what it is supposed to do 
   }
   else {
      header("HTTP/1.1 403 Forbidden");
      exit;
   }
?>
like image 64
Naftali Avatar answered Sep 27 '22 15:09

Naftali


If by scripts you mean server-side, you can add a .htaccess file in the folder concerned:

deny from all

If however by script you mean client-side, then ultimately you can't.

like image 25
Félix Saparelli Avatar answered Sep 27 '22 15:09

Félix Saparelli