program cgicount C- C- Instructions - C- C- Fill in the blank in the "open" statement below, then save and C- compile this program with "f77". Rename the output executable C- file to some name ending in ".cgi" in one's web area; C- for example, "example.cgi". This output executable should be C- given "chmod 4711" file permissions to be able to access the C- counter file (see the comments below) with the user's own C- privileges (but not be able to do anything else --> there C- are NO input arguments used). C- C- Inside the HTML web page file to be counted, add a line C- C- where "xxx", "yyy" and "example.cgi" are replaced by the C- appropriate values for the URL of the executable program file. C- The HTML file should have "chmod 755" file permissions. C- C- If you want the counter to count, but not to display anything C- on the called page, comment out the last one of the three C- "print *" lines in the main body of the program (i.e., not C- counting the error messages; the first two "print *" lines C- are always required as the minimal return of a CGI program). C- The owner of the page can check the statistics from a login C- session on the server (just look at the counter file) or from C- a browser (if the counter file is in a web-accessible area C- on the server system, it can be called with the appropriate C- URL). C- integer*4 icount, ierrnum C- C- Write CGI output header to stdout C- print *, 'Content-type: text/plain' print *, ' ' C- C- open counter file with appropriate options C- C- * Fill in the file=" " blank with the real file name C- as seen on the system (not a URL) for the _counter_ file. C- C- To make things a little easier, name the counter file the C- same as the HTML web page file + the suffix ".counter"; C- this is not necessary - any file name will do. C- C- For example, suppose the web page we are counting accesses C- to is /home/username/www/example.html; the counter file would C- be /home/username/www/example.html.counter, which should be C- created, initialized by entering the numeral "0", and then C- saved and set up with "chmod 644" permissions. C- C- In this example case, since the counter file is in the C- web-accessible "www" subdirectory of user "username", it C- can be separately looked at from a web browser using URL C- "http://servername/~username/example.html.counter", just C- as any other file in that subdirectory could. C- C- If you don't want the counter file to be separately C- viewable on the web, put it someplace outside the set of C- subdirectories that the web server may display items from. C- The CGI program file doing the counting has to be in a sub- C- directory which is not only web-accessible, but from which C- the web server configuration allows CGI programs to run. C- open (unit=4, & file=" ", & access='sequential',status='old',action='readwrite', & iostat=ierrnum,err=9901) C- C- read current contents of counter file and write to stdout C- read (unit=4,fmt='(i)',err=9911,end=9921,iostat=ierrnum) icount print *, icount+1 C- C- rewind counter file to prepare to write new count into it C- rewind (unit=4,err=9931,iostat=ierrnum) C- C- write new count into counter file C- write (unit=4,fmt='(i)',err=9941,iostat=ierrnum) icount+1 C- C- close counter file and exit program C- close(unit=4) go to 9999 C- C- I/O error printouts to stdout C- 9901 continue print *, 'Unknown-code-0=',ierrnum go to 9999 9911 continue print *, 'Unknown-code-1=',ierrnum go to 9999 9921 continue print *, 'Unknown-code-2=',ierrnum go to 9999 9931 continue print *, 'Unknown-code-3=',ierrnum go to 9999 9941 continue print *, 'Unknown-code-4=',ierrnum go to 9999 C- C- program exit C- 9999 continue stop end