Php file outputting javascript for include as a JS file - need to restrict so its not opened in a browser window

Posted by Ali on Stack Overflow See other posts from Stack Overflow or by Ali
Published on 2011-01-04T06:32:52Z Indexed on 2011/01/04 6:53 UTC
Read the original article Hit count: 252

Filed under:
|
|

Hi guys, I'm storing configuration details in a database which I need to use in javascript. I'm accessing all this using php and instead of outputting all the details into inline javascript code on the main page I've instead created a php file that outputs content type javascript and refernce it in my main page as an external javascript file.

I want to set it up so that it can't be viewed in a browser window i.e :

<script type="text/javascript" src="phpFileThatDoesJS.php" ></script>

should work but typing www.mysite.com/phpFileThatDoesJS.php in the browser shouldn't

EDIT ==========

The thing is that I have to edit a script that for some oddball reason stores the username and password of a user in a javascript Object and outputs it within script tags. I have to set it up so that this is not viewable by a simple view source action. Thats why I thought of referencing it as an external javascript.

Isnt there any htaccess tricks that I could use?

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript