Ray Ontko & Co.
Library
Services | Products | Library | Careers News | About Us | Contact Us | Search | Site Map

Interface for Calling SQR from the Web

Author: Eric Dimick Eastman (erice@ontko.com)
Files: cgi-lib.sqh sqr.pl
Download: cgi-lib.zip (21k) Inculdes all files shown on this page.
On-line Example Files for the example: example1.sh example1.sqr example2.sh example2.sqr

See the Instructions for installation.

cgi-lib.sqh

cgi-lib.sqh is a SQR library designed to allow SQR programs to accept their input from the Common Gateway Interface or CGI. It supports both the "GET" and "POST" methods.
Some of the procedures in cgi-lib.sqh:
ReadParse (:#num_vars)
Determines the method type used in the request and returns the parameters as an array of name-value pairs in the array CGI_Params. #num_vars returns number of parameters successfully parsed also stores this value in the global variable #g_cgi_Params
GetField ($key, :$value)
searches through the CGI_Params array and returns the value field where the name field equals $key. ReadParse must be called first. This is the primary way of getting CGI input.
PrintHeader
Shows the HTTP headers to set any cookies and tells the browser to expect and HTML document
Redirect($URL)
redirects the browser to the new URL. This will often be used when you want to show the browser the output of the report.
GetMethod (:$Method)
Returns the method (GET or POST) used in the CGI request. It is also useful for determining whether the SQR was called from a webserver or not.
GetRemoteAddress (:$address)
Returns the IP address of the client
MyURL (:$URL)
Returns the URL of the script
GetUser(:$username)
If the SQR is in an area that is password protected returns the authenticated username.
PrintVariables LOCAL
Nicely formats variables in the array CGI_Params and prints the HTML string.
ReadCookies(:#num_cookies)
Reads the cookies from the environment into the array CGI_Read_Cookies.
GetCookie($key, :$value)
searches through the CGI_Read_Cookies array and returns the value cookie where the name field equals $key. ReadCookies must be called first.
SetCookie($name, $value, $expires, $path, $domain, $secure)
Adds the cookie to the CGI_Set_Cookies array. This array will be read and the appropriate headers added when PrintHeader or Redirect is called.
  • $name and $value are required and self-explainitory; the rest are optioal and cryptic.
  • $expires is a date in the form [wdy, ]DD-Mon-YYYY HH:MM:SS GMT (in Greenwich Mean Time). If omitted the cookie will last for the current session of the browser.
  • $path is the start of the path within the webserver that will be sent the cookie A path of "/foo" will be sent when the URL "http://some.server.com/foobar.html" is requested. The default is to send the cookie to those URL's with the same path as the current one.
  • $domain matches the end of the domain name (i.e. ".server.com" matches some.server.com and another.server.com) The default is to only send the cookie back to the host it came from.
  • $secure if this = "secure" this cookie will only be sent over SSL
PrintCookies LOCAL
Nicely formats cookies in the array CGI_Read_Cookies and prints the HTML string.

sqr.pl

sqr.pl is a template for a Perl script that would be installed in the cgi directory used by your web server. It will parse the URL from which it is called to run the appropriate SQR program with the correct command line. An alternative to sqr.pl is to create a separate script for each SQR.

cgi-lib.sqh is freely distributable as long as the original copyright notice is kept.
For the legal language, see COPYING.TXT.

Comments, suggestions, bug reports are always welcomed. If you use cgi-lib.sqh and like it, send me a note.

Page maintainer: Eric Dimick Eastman (erice@ontko.com)

Top
Copyright © 1999, Ray Ontko & Co. Last updated: Friday, November 30, 2001
Careers Library Products Services Site Map Search Contact Us About Us News