Whenever you access a server administration document, you are subject to user authentication. If you haven't previously accessed an admin document then accessing the administration main menu will cause you to be prompted for your administration user name and password. Most browsers will cache your most recently used name and password, so if you are not prompted, it means your browser authenticated you automatically.
This default Document Root configuration allows any user to retrieve documents within the document root directory tree, using either HTTP or FTP, but blocks access to executable programs.
There are other template configurations provided to allow users to append to form databases (the guided tour will demonstrate these later), or for admin authenticated users to create new documents on the server, amongst others.
An API extension can be global, specific to a given service, or specific to a given resource (such as all documents matching a specific wildcard pattern). The browser-based configuration utilities let you associate an API extension with whatever you wish, without having to manually edit complex operating system specific initialisation files.
This example shows you how you can define a custom viewer for database files. These files are protected by access control and authentication, so you need to know your user name:
Your User Name is "tourist" and your Password is "guide". See this authentication by pointing to the directory of comma-separated-variable files and then choose one of them to see the database as an HTML table.
This kind of transparent dynamic document translation is impossible with CGI.
You can view the C source code for the API extension which performs the dynamic translation.
You can also read the WebScript and WebHook Reference Manuals for more detail.
For example, through simple status queries, it is easy to determine the following:
With PowerWeb Macros, you can query the value of any server configuration setting, status variable, form input field, or in fact all server data structures. For example, the code to display the number of current connections was simply:
Number of Requests Serviced: Current Number of Connections: This Document's Size: This Document was Last Modified:
<!--#echo var=Server:/Stats/Clients -->You can also use Web Macros for conditional text. For example, the next paragraph will either read "You are the only user", or it will read "There are nn current users on the server".
There are current users on the server. You are the only user.
The HTML to achieve this is:
<!--#if @Server:/Stats/Clients > 1 -->There are many more PowerWeb Macro features, some of which you will see highlighted later on during this tour. You can also read the PowerWeb Macro Reference Manual for more detail.
<b>There are <!--#echo var=Server:/Stats/Clients--> current users on the server.</b>
<!--#else -->
<b>You are the only user.</b>
<!--#endif -->
If your browser supports "Server-Push" (such as Netscape 1.1 or later), view a dynamic series of documents displayed using a Rexx module. If you see a message "There is no viewer registered for this type of file..." then your browser does not support server push.
The WebScript C Interface is very simple to use. The common Hello World example, here is written in C (view the source code of function "TourDirect").
A more sophisticated example of the WebScript Interface is given by the function "TourTree" (in the same module) which displays a tree view of the settings of your server. For example, /example/bin/tour!TourTree displays your configuration whereas /example/bin/tour!TourTree?Request:/ displays details of your current HTTP request.
Click on these links to see the same functionality available via WebPerl with /example/perl-bin/Sample!Tree?Request:/ and WebRexx with /example/rexx-bin/tree.cmd?Request:/. Note that with Perl you may experience a slight delay while Perl is loaded and compiles the module.
You can use the language with which you are most familiar or which is best suited to your solution - PowerWeb provides compatibility and equivalent functionality across all languages, making prototyping and rapid application development a reality.
If you would like to contribute your own examples, please upload them with FTP to the site "www.compusource.co.za" in the "/incoming" directory, for others to share.
It is not recommended that you use CGI for new development because PowerWeb Server++ WebMacros and WebScripts offer a far superior solution for almost all purposes, including support for multiple languages such as C, Rexx and Perl.
Rexx CGI Example:
Click here to see the output of a batch program that was invoked by PowerWeb through CGI when you clicked on the hyperlink. You can also use Web Macros within CGI, as demonstrated here.
Look at the files "\powerweb\cgi-bin\showcgi.cmd" and "\powerweb\cgi-bin\showcgi2.cmd" to examine the source code.
Perl CGI Example:
Click here to see the output of a Perl program that was invoked by PowerWeb through CGI when you clicked on the hyperlink. You must have Perl version 5.002 installed on your server for this CGI example to work, and the Perl executable must be named "perl.exe" and be on your PATH.
Look at the file "\powerweb\cgi-bin\showperl.cmd" to examine the source code.
Point your browser here to show one of two documents based on whether you are using an IBM Web browser.
Here is the HTML source code:
<!--#if @Request:/Header/In/User-Agent ? "IBM" -->Of course, there are many other reasons to show documents conditionally. For example, you could show a user different documents according to the data entry content of a form. A good example of this is the PowerWeb installation and enrolment which transparently shows different documents according to your current registration status.
<!--#include file=ibm.htm -->
<!--#else -->
<!--#include file=other.htm -->
<!--#/if -->
PowerWeb does not require you to decode the form field arguments or to scan for them within the query string. They are split apart and decoded and placed into the standard Request:/Argument object variable directory for you to manipulate further.
Example 1, using the /$form Command to Process a Form
If you are feeling hungry, order a Power Pizza now. This example shows automated storage of your order details into a database file, calling an external calculation routine with an API extension, and conditional document display. You can use our earlier API extension for viewing database files to take a look at the order database, but only after you have ordered a pizza. Remember your username is "tourist" and password is "guide".
This example showed PowerWeb saving the data in CSV format, however you are also able to save submitted forms in both STF and ArgList format.
You can read the PowerWeb Command Reference Manual for more detail.
Example 2, using Rexx to Process a Form
Point here to display a form which allows you to produce a customised filtered directory listing of documents on your server. The source code can be found in the file "\powerweb\system\rexx-bin\dirlist.cmd".
You can read the PowerWeb API Reference Manual for more detail.
Example 3, using Web Macros to Process a Form
Point here to display a form which echoes back your input. The source code can be found in the files "\powerweb\system\tour\EchoForm.htm" and "\powerweb\system\tour\EchoProc.htm".
You can read the PowerWeb Macro Reference Manual for more detail.
Click here to go to the main menu of the Administration and Configuration utility. If you haven't changed the default password yet, then this screen lets you change the admin password.
On
&style=gif&file=digital2.gif&charset=time&dir=/icons/digits -->
at
&style=gif&file=digital1.gif&charset=time&dir=/icons/digits -->
you are visitor number
and there are
&style=gif&file=meter3.gif&charset=digits&dir=/icons/digits -->
current connections.
or in text format:
On at you are visitor number and there are current connections.
To achieve this, we inserted a Web Macro into this page. This is what it looks like:
On <!--#config timefmt="%d-%m-%Y" --> <img src=/$font?text=<!--#flastmod timezone=local now -->&style=gif&file=digital2.gif&charset=time&dir=/icons/digits --> at <!--#config timefmt="%H:%M:%S" --> <img src=/$font?text=<!--#flastmod timezone=local now -->&style=gif&file=digital1.gif&charset=time&dir=/icons/digits --> you are visitor number <!--#counter style=gif digits=toyblock.gif--> and there are <img src=/$font?text=<!--#echo var=Server:/Stats/Clients -->&style=gif&file=meter3.gif&charset=digits&dir=/icons/digits --> current connections.Have a look at the Counter Documentation which includes a Gallery of Counter Styles packaged with PowerWeb.
You can choose which documents have attached page access counters, and see a summary view of the number of accesses of your documents. The summary view will be empty if you have not specified any documents to track.
The counters work regardless of whether the user has graphics switched on or not (unlike most other counter implementations) and are very fast with almost zero performance impact (achieved through usage of an API hook which eliminates the CGI overhead of common add-on solutions).
If you are running multiple services, such as HTTP and POP3, then each service can be monitored separately, all from the same Web browser interface.
For example, take a look at the current connections on your own server.
By clicking here you can view the recent activity in the audit log and the error log. Go here instead for more complete management of the logs, including rotating or truncating the logs.