 |
|
 |
 |
 |
  | You can use JSDB with apache with a cgi-bin handler. The following changes are required in the httpd.conf. For the sample, we suppose that the documents are in /var/www/htdocs and the jsdb executable in /usr/bin.
http.conf … The server accepts all requests from port 80. Listen 80 … The server hides his version. ServerTokens ProductOnly ServerSignature Off … Where the documents are. DocumentRoot "/var/www/htdocs" … Deny all for all by default. <Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all </Directory> … Allows the use of jsdb script (CGI) in the document directory. <Directory "/var/www/htdocs"> Options Indexes FollowSymLinks ExecCGI AllowOverride None Order allow,deny Allow from all </Directory> … Deny access to the CGI directory (where I store the sessions ID and my CGI.js script) <Directory /var/www/htdocs/CGI> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all </Directory> … Deny access to the TMP directory (where I store my templates) <Directory /var/www/htdocs/TMP> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all </Directory> … Looks for default document if none specified. <IfModule dir_module> DirectoryIndex index.html index.pl index.js </IfModule> … <IfModule mime_module> … Declares the handler to allow the use of jsdb AddHandler cgi-script .js … </IfModule>
Apache need to access to the directories CGI and TMP (change the rights and the owner to the right user). If you want jus try this you can make a ‘chmod 777’ on them.
The first line of the script contains the command to launch for this script. The script begin to load the libray (CGI.js) and create a new CGI object. You can access to the form arguments with get/set. If you want to access to the session data (identified by the cookies) use _get/_set. If you want to save the session data, use save. The write method load a template (index.htm) and replace all %<variable>% patterns by the value of the variable (if knowed as a form argument). Use ‘%%’ to add a ‘%’ character.
Index.js #!/usr/bin/jsdb
// CGI JSDB Library // All rights reserved, Jean-Marc QUERE 2008 // quere.jmarc@free.fr // load('CGI/CGI.js');
var cgi=new CGI(); cgi._set('date',new Date().toUTCString()); cgi.set('date',cgi._get('date')); cgi.write('TMP/index.htm'); cgi.save();
|
 |
 |
|


 |
 |
 |