Javascript/PHP: Insta Create Javascript Vars via PHP
Posted: Fri Mar 19, 2004 2:20 pm
Ok...
I really only need to know whether my idea is possible. I will try to figure out HOW to make it happen once I know what the general consensus is.
I build an HTML page.
I create a *.js file to use in it.
In HTML I add the <script> tags to reference the *.js file.
The page is visited by someone.
The page gets loaded.
The javascript is referenced.
All vars in the *.js file are loaded and now available.
Everything is great.
However, ANYONE can visit my *.js file if they are savvy enough.
I know that PHP can create and delete files.
Is it POSSIBLE to do the following:
I build a PHP file that will create a webpage.
I create a BLANK *.js file (or maybe don't create one at all).
I write PHP to put together the variables I want to reference.
The page is visited by someone.
The page gets loaded.
The PHP creates a (or opens the blank one) *.js file.
It drops all the vars in that I want it to.
The webpage just created references the NEWLY create or edited*.js file.
All vars in the *.js file are loaded and now available.
The PHP then deletes or empties the *.js file.
???
I am trying to generate javascript vars without giving the user a way to peek. I want to put together a game but don't want to generate the js vars in a place that the user can just by hitting VIEW SOURCE... ugh!
Any help would be appreciated...
I really only need to know whether my idea is possible. I will try to figure out HOW to make it happen once I know what the general consensus is.
I build an HTML page.
I create a *.js file to use in it.
In HTML I add the <script> tags to reference the *.js file.
The page is visited by someone.
The page gets loaded.
The javascript is referenced.
All vars in the *.js file are loaded and now available.
Everything is great.
However, ANYONE can visit my *.js file if they are savvy enough.
I know that PHP can create and delete files.
Is it POSSIBLE to do the following:
I build a PHP file that will create a webpage.
I create a BLANK *.js file (or maybe don't create one at all).
I write PHP to put together the variables I want to reference.
The page is visited by someone.
The page gets loaded.
The PHP creates a (or opens the blank one) *.js file.
It drops all the vars in that I want it to.
The webpage just created references the NEWLY create or edited*.js file.
All vars in the *.js file are loaded and now available.
The PHP then deletes or empties the *.js file.
???
I am trying to generate javascript vars without giving the user a way to peek. I want to put together a game but don't want to generate the js vars in a place that the user can just by hitting VIEW SOURCE... ugh!
Any help would be appreciated...