NeoWebScript NeoSoft
NeoWebScript
Search
Site Map

Download
Developers
User Info
New User FAQ
Tutorials
Script Library
Commands
Troubleshooting
Sysop Info
Sysop FAQ
Installation
Management
Troubleshooting
Resources
Credits
Disclaimer
NeoWebScript™ Extensions

Alphabetical listing of NeoWebScript™ Extensions

Commands Available By Function

HTML Web Server Internet Services
Counters Tracking Database
File Utility

HTML
backlink html
emit_standard_magellan_
search_link
neo_clock_to_rfc850_gmt
emit_standard_yahoo_link random_pick_html

Web Server
abort_page load_response
estimate_hits_per_hour neo_make_cookie
load_cookies save_mime_file
load_mime_response

Internet Services
open_outbound_mail remote_hostname
open_post_news

Counters
get_avg_nc incr_nc
get_init_nc incr_page_counter
get_nc make_nc_registry
get_real_nc register_nc

Tracking
log_message neotrack_report
neotrack

Database
dbdelkey dbfiles
dbexists dbkeys
dbfetch dbstore

File
access_data_file include_file
delete_data_file include_virtual
directory_listing list_data_files
filemv load_file
filerm load_virtual

Utility
cmdtrace md5
dump_environment parray
gm_timestr_822 set_header
import_keyvalue_pairs


html

  • html string [tag]

    write string into the webpage being sent to the user. If tag is specified, it is emitted in its on-state in front, and its off state behind of, the string.

    html "Hi, my name is Ah Clem." h3

    ...will produce...

    <h3>Hi, my name is Ah Clem.</h3>

  • backlink [linktext] [nolinktext]

    Emit a hyperlink pointing to the referer URL, with linktext emitted as HTML text within the hyperlink. Emits nolinktext if there was no referer.

  • wrap string [maxlength] [option]

    Wraps a string of text to the maximum length specified and returns the string with endlines. The -html option can be specified if you want the string to be split and returned with <br> as the endline character, for use in html documents. Otherwise, it returns the string with the standard \n.

    wrap "This is a line I wish to wrap" 10

    ...will produce...

    This is a\nline I wish\nto wrap

    wrap "This is a line I wish to wrap" 10 -html

    ...will produce...

    This is a<br>line I wish<br>to wrap

  • incr_page_counter

    Increment a counter for this webpage and return the new count. (Automatically creates and zeros the counter if it doesn't already exist.)

  • random_pick_html list

    Randomly picks one of the elements in a list and emits that into the webpage being generated.

    <!--#neoscript return='random_pick_html {
    
        "This is one of the choices."
    
        "This is another one of the choices."
    
        "<b>This is a bold choice.</b>"
    
        "<img src=../mygif.gif> ...an image and some text."
    
    '-->

    If using code= instead of return=, use the html command to emit the result into the webpage.

webserver

  • abort_page

    Aborts NeoWebScript™ execution immediately. Does not emit any of the rest of the webpage to the requester. Remaining code in the script being executed will still be executed, so abort_page is typically immediately followed by return.

  • load_response [responseArrayName] [multiList]

    Load the CGI response into the global array response or the array named by responseArrayName

    If the same name is repeated in the post or query, response(__name) is set, and response(name) is converted to a list. Use [info exists response(__name)] to check if the array member is a straight value or a list.

    If multiple response is expected (as in <select multiple>), use multiList to force the array members of the response array to always be a list.

  • load_mime_response [responseVarName [uploadedDataVar]]

    In the event of a multipart/form-data response, the master interpreter creates a temporary directory to receive and decode the mime data. The posted-to file must use load_mime_response to access the mime data. responseVarName defaults to "response", and uploadedDataVar defaults to "filesUploaded". responseVarName is as in load_response.

    uploadedDataVar is the name of an array, indexed by field name, in which to place information about the files uploaded. The information stored in the array is a list as follows:

    • the temporary name of the file on disk
    • the name of the requested file (in the browser) (OS dependent, and may or may not be the full pathname).
    • content-length
    • content-type

    Note that an additional program, webunpack must be compiled to support file uploads.

  • save_mime_file fieldname datafilename

    Copy the mime file uploaded as field fieldname to the datafile datafilename. Once saved, the user can do with it as they will. Our general experience is that, to make good use of mime uploads, Supervisor mode should be enabled so that the web page can access a broader range of destinations.

  • neo_make_cookie cookieName cookieValue [-days expireInDays] [-hours expireInHours] [-minutes expireInMinutes] [-path urlPathCookieAppliesTo] [-domain domainCookieAppliesTo] [-secure 1|0]

    Return HTML to create a "cookie" which, if emitted to a browser that is cookie-capable, will cause the cookie to be included subject to defined restrictions.

    Example: neo_make_cookie email karl@neosoft.com -days 30 -path /myApp

    Create a cookie named email containing karl@neosoft.com that will be included in all HTTP requests from the browser we're responding to, for a period of 30 days, when the requests are "underneath" /myApp on this server, and the browser is cookie-enabled.

    For more information, see Persistent Client State HTTP Cookies at Netscape, and also Which Browsers Support Cookies at Digital.

    This only works with Netscape if it's emitted before any other HTML. It uses <meta http-equiv> to set the cookie, and won't work with browsers that don't support this.

  • load_cookies [cookieArrayName]

    Load the HTTP persistent data "cookies" into the global array cookies or the array named by cookieArrayName.

  • estimate_hits_per_hour

    Return a numeric estimate of the number of hits that will be served in the next hour. Works by seeking back approximately 1000 hits into the log file and sees how long ago it was, to extrapolate hits-per-hour. If there are fewer than 1000 hits in the access log file, it will return 0.

  • quote_string

    Quote a string by hex-encoding special characters. (Useful for passing HTML fragments as values for hidden fields in forms and stuff like that.)

  • unquote_string

    Unquote string by decoding hex-encoded characters.

storage

  • dbstore database key arrayName

    Store the contents of the array specified by arrayName into the database database, indexed by key, as key-value pairs. (This was formerly called array_to_props.)

  • dbfetch database key arrayName

    Fetch from database database into the array specified by arrayName the key-value pairs for the specified key, previously stored by dbstore (This was formerly called props_to_array.)

  • dbkeys database pattern

    Return a list of all of the keys in the database database matching pattern. Pattern is in the style of a Unix wildcard. In other words, if you were looking for a key starting with horace, the pattern would be horace*. To match horace anywhere in the string, *horace*.

  • dbdelkey database key

    Delete in database database the entry corresponding to key. If the entry isn't there or the datbase doesn't exist, returns 0, otherwise 1 (or an error).

  • dbexists database

    Returns 1 if database exists, 0 otherwise.

  • dbfiles

    Returns a list of the databases in the webpage owner's database directory.

direct file access extensions

  • access_data_file datafile

    access_data_file opens the specified datafile for reading and writing, creating it if its not there. Datafile name can consist of upper and lowercase letters and numbers only. No slashes, no periods, etc. The file can then be operated on in the normal manner by gets, puts, seek, tell, flush, close, etc.

  • delete_data_file datafile

    delete_data_file deletes a datafile. It is not an error to delete a datafile that is not there.

  • list_data_files

    returns a list of all of the user's datafiles.

data file manipulation

debugging

  • dump_environment

    Write all of the server's environment vars and values into webpage.

  • parray arrayName

    Dump the specified global arrays keys and values into webpage.

  • cmdtrace args

    The Extended Tcl command cmdtrace will work if supervisor mode is enabled for the directory.

date and time

Tcl has great date and time conversion routines. The
clock command can not only do time and date arithmetic and conversions from integer-seconds to dates in innumerable formats, it has a powerful date scanning engine that recognizes and processes most date formats automatically.

  • neo_clock_to_rfc850_gmt clock

    Returns the passed integer-since-1970 time formatted according to RFC-850, with the additional proviso that it be specified in GMT timezone only. (Because that's the way Netscape wanted it.)

    For example, neo_clock_to_rfc850_gmt 84236782 should produce "Fri, 01-Sep-72 18:06:22 GMT".

random numbers

Extended Tcl's random number functions are a handy addition to the server-side scripter's bag of tricks. random will get random numbers for you (well, pseudorandom...), and also provides control over the random number generator itself.

loading and including files

  • include_file fileName

    Copy the contents of the specified file into the webpage being generated. File must be in the same directory or somewhere beneath the current directory. If the filename matches the MIME type for a server side include, the server side include is still performed. If it also contains embedded NeoWebScript, the NeoWebScript is executed. If the owner of the current page and the page being included are the same, the code is executed within the same safe interpreter that's handling the current page. If the file is owned by someone else, it gets its own interpreter for its neoscript.

  • include_virtual virtualPath

    Copy the contents of the file named by the specified virtual path (rooted from the htdocs directory) into the webpage currently being generated.

    Matching MIME types and processing embedded requests proceeds as for include_file above.

  • load_file fileName

    Load and evaluate the NeoWebScript™ code contained in fileName. This is to support libraries of procs and shared code.

  • load_virtual virtualPath

    Load and evaluate the NeoWebScript™ code specified by the virtual path virtualPath. This also supports libraries of procs and shared code.

logging extensions

  • log_message loggingDatabase message

    The Neoscript programmer can log messages to a number of self-defined logging databases. When log_message is executed, the message is logged along with the server time (in integer-seconds format) and the remote hostname (or IP number, if hostname either was unavailable due to DNS problems or if Apache was compiled with MINIMAL_DNS selected) fetching the page.

    If you need something fancier you can always roll your own with access_data_file.

mail extensions

  • open_outbound_mail subject [to]

    This opens an email message and returns the filehandle for use with puts, etc, for the contents of the message body. The message always comes "from" the user name of the owner of the webpage file that's being interpreted, and the name of the server that did the serving. If to is not specified, the recipient is also set to be the user name of the owner of the webpage file.

news extensions

  • open_post_news -subject subject -newsgroups grouplist -distribution distribution

    This starts a news posting and returns the filehandle for use with puts, etc, for the contents of the message body. The message always comes "from" the user name of the owner of the webpage file that's being interpreted, and the name of the server that did the serving.

    When done writing the body of the news article, write a single line to the filehandle consisting only of a single period, then close the file.

    Note that for this to work you must have a news server within your domain named or aliased as news. For example, within neosoft.com, open_post_news will try to contact the news server at news.neosoft.com.

    This is an experimental capability that obviously needs work.

DNS extensions

  • remote_hostname [ip-address]

    This returns the hostname of the remote host if it can be determined. If the webserver is running with normal DNS, we return the hostname already looked up and stored in the environment. If it's running with minimal DNS, we perform a DNS lookup on the IP number to try to get the hostname. If we succeed, we return the hostname, otherwise we return the IP number.

    If ip-address is provided, then it attempts to resolve the given IP. Warning: resolution failures can take a long time and make a page callup slow.

Named Counters

  • make_nc_registry [max_counters] [comments]

    Executed one time only, to create the page owner's Named Counter Registry file (NCRegistry). Defaults to 20 counters in the registry. Maximum of 200 counters allowed.

  • register_nc counter_name [init_counts] [comments]

    Executed one time only for each Named Counter. This creates the counter and places it in the page owner's NCRegistry file. Name should be unique. Initial counts are distributed over the 5 browser classes as Mozilla 85%, Mosaic 5%, Lynx 2%, MIE 1% and Other 7%. Default initial counts is 0.

  • incr_nc counter_name [show] [browser] [val_type]

    Increment the indicated named counter. This increments the overall lifetime total, the browser's lifetime total and the daily browser total. Any value other than "show" in the show argument causes no value to be returned. If "show" is specified, the indicated value is returned by the incr_nc call. The default return value is the overall lifetime total. The caller may request only a specific browser (all, mozilla, mosaic, lynx, mie, other) in the browser argument. The caller may request only today's count value by specifying the val_type argument (lifetime, today).

    On the first incr_nc call of a new day, a new daily-count record is created automatically.

  • get_nc counter_name [browser] [val_type]

    Returns the current counter value. By default the overall lifetime count is returned. Caller may request a specific browser (all, mozilla, mosaic, lynx, mie, other). Caller may request lifetime of today's count only using val_type.

  • get_init_nc counter_name [browser]

    Returns the initial counts assigned to the counter when it was registered. By default the total value for all browsers is returned. Caller may request a specific browser (all, mozilla, mosaic, lynx, mie, other).

  • get_real_nc counter_name [browser]

    Returns the actual counts assigned to the counter (i.e. count-init_count). By default the total value for all browsers is returned. Caller may request a specific browser (all, mozilla, mosaic, lynx, mie, other).

  • get_avg_nc counter_name [browser]

    Returns the average daily counts assigned to the counter. The average is calculated by dividing the real counts by the number of days since the counter was registered. (NOTE: initial counts are not used to calculate the average.) By default the total value for all browsers is returned. Caller may request a specific browser (all, mozilla, mosaic, lynx, mie, other).

Convenience Links

  • emit_standard_yahoo_link

    Emit a link back to Yahoo in the manner that they ask.

  • emit_standard_magellan_search_link

    Emit a Magellan link with at-link searching.

Generic Routines

  • import_keyvalue_pairs arrayName string

    load the key-value pairs from string into array arrayName, as -element string.

    Example: import_keyvalue_pairs foo "-action paint -customer fred"

    Will set element action of array foo to paint and element customer to fred.

    The normal usage would be to get optional key-value pairs as arguments to a proc, as in:

    
    proc sell_item {customer item args} {
    
        import_keyvalue_pairs options $args
    
        .
    
        .
    
    }
    
    
    This will pull an arbitrary number of optional key-value pairs, read into the args list when the proc began execution (because of the special meaning Tcl attaches to this keyword in argument lists), and store the key-value pairs into the options array.

Administratively useful commands

As delivered, these commands are only available in the trusted/master interpreter:

  • gm_timestr_822 time

    Returns an RFC822 string representing of time which is in standard Unix time, ie. seconds from the start of the epoch, ie. Jan 1, 1970. Currently used only to generate the Expires header for server-cached images.

  • md5 string

    Returns an md5 digest of string.

  • set_header header-name header-value

    Used by the image processing routines to set output headers. Note that use of set_header is only effective while generating images, since otherwise the headers have already been transmitted by the time the user's Tcl code executes. This should change and be more globally available in a future release.

Tracking Visitors

  • neotrack [timeout] [filename]

    neotrack records information that may be used to determine a visitor's path through a site. NeoTrack uses IP number to distinguish between users. timeout is an optional specification of the number of minutes that the visitor can remain on the current page before we will assume that he has left the site. Default is 30 minutes. A dash, "-", may be used in this position if you wish to supply a filename argument but still wish to use the default timeout. filename - is an optional specification of the name of the file in which the visitor's path information is to be recorded. Default is NeoTrack (.db is implied and should not be specified). The neotrack command returns 1 if the page is served to a new visitor. Otherwise, 0 is returned.

  • neotrack_report key [filename]

    neotrack_report produces a report table that details a visitors path. For each page in the path, this command reports 1) the Refering address (if available), the current pages URI, 3) the time the current page was entered, 4) the time that the visitor spent on the page (not available for the last page in a path) and 5) the timeout assigned to the current page. You may write your orw proc to produce this or a similar report. This built in proc is provided only for convenience. You must suply the key required to access the visitor that you want reported. The key is formed as time_IP where time is the time (in seconds) that the visitor entered your site and IP is the visitor's IP number. The filename argument is an optional identification of the tracking data file from which the report is to be produced.