Directory/file Locations

liunx

Guest
Straightforward background: I'm using FrontPage 2000, and writing the JavaScript I need directly into the HTML panel. There's no problem with this :-)<br /><br />But, since there are certain functions I use on every page, I'd like to include some basic functions rather than repeat the function.<br /><br />I can create the file (say, 'commonfunctions.js'). The question is, where do I put it? I'd prefer it not be directly openable or viewable by others. I'd also like to be able to refer to it with a relative path if possible, or at least, not something so hard-coded I'm going to regret it.<br /><br />If life were really nice :-), I'd be able to use it from subdomains as well as my main domain. (I don't have a subdomain yet, but I'm thinking ahead.)<br /><br />Also looking ahead, would PHP standard functions go in the same directory as the JavaScript ones? (or at least off the same top-level location?)<br /><br />And for a final question (this one is more FP specific), where do I put them on my own machine so that I can run them during development as well as having them available at production?<br /><br />Thanks!<br />--Beth<!--content-->
Gads, Woman! <a href="http://www.online-learning-info.com/" target="_blank">University of Phoenix Online</a><br /> <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/laugh.gif" style="vertical-align:middle" emoid=":lol:" border="0" alt="laugh.gif" /> <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/laugh.gif" style="vertical-align:middle" emoid=":lol:" border="0" alt="laugh.gif" /> <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/laugh.gif" style="vertical-align:middle" emoid=":lol:" border="0" alt="laugh.gif" /> <br /><br />Lianna<!--content-->
<!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->I can create the file (say, 'commonfunctions.js'). The question is, where do I put it? I'd prefer it not be directly openable or viewable by others. I'd also like to be able to refer to it with a relative path if possible, or at least, not something so hard-coded I'm going to regret it.<!--QuoteEnd--></div><!--QuoteEEnd-->You can't really hide JavaScript code from the viewers of your site. The code is executed by the web browser, so it has to be downloaded to their machine. Even if you could keep them from viewing the .js file on the server, they could always pull it out of the browser cache and look at it. The best place to put JS include files in either in your public_html or a subdirectoy of public_html.<br /><br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->Also looking ahead, would PHP standard functions go in the same directory as the JavaScript ones? (or at least off the same top-level location?)<!--QuoteEnd--></div><!--QuoteEEnd--><br />PHP include files should definitely be kept in a directoy that is not publicly viewable; i.e., outside of public_html. Since PHP runs on the server, and can access files on the server, allowing people to view your PHP code can pose a security risk.<br />You could create a directory for your PHP include files at the same level as public_html. For example, /home/user_name/php. Then put a line like this in your .htaccess file:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->php_value include_path .:/home/user_name/php<!--c2--></div><!--ec2--><br /><br />This adds the directory to PHP's include path, so you don't have to reference the file by it's absolute path. Take a look at the <a href="http://www.php.net/manual/en/" target="_blank">PHP Manual</a> for more information. <br /><br />HTH<br /><br />Rob<!--content-->
Please don't send me back to school! Please! <br /><br />These aren't really coding questions--they really are "where do I put the files on my host" question. <br /><br />How about if I rephrase my primary question, since I swear it's quite simple:<br /><br />My website, of course, is under the 'www' directory.<br />If I want to create a directory to store my common JS files so that they can be included by files within my www web, where would i create that 'common' directory? Does it go under 'www', or under the top level?<br /><br />(These are the kind of stupid questions that come up when moving from a defined-production environment)<br /><br />--Beth<!--content-->
It goes under <!-- w --><a class="postlink" href="http://www">www</a><!-- w -->. /><br />Rob<!--content-->
 
Back
Top