/* User Authentication Example - Requires version 2.06 or later. This hook is normally used in conjunction with an AccessControl hook (see the example in that section). */ parse arg parcel user = ServerReadText(parcel, "Request:/AuthenticateUser") pwd = ServerReadText(parcel, "Request:/AuthenticatePassword") /* Substitute your own user name lookup here: So instead of: if user = "joe" & pwd = "secret" then use your own code. */ if user = "joe" & pwd = "secret" then return "0" /* Authentication failed: either the user name or the password is invalid: Return code "3" tells PowerWeb that authentication failed. */ return "3";
Arguments In:
Arguments Out:Request:/Resource
The physical resource being accessed.
Request:/Protocol
The name of the protocol being used to access this resource.
Request:/Method
The protocol-specific method, such as GET or POST.
Request:/SubMethod
The protocol and method-specific sub-method, such as INCLUDE or EXEC.
Request:/AuthenticateUser
The authenticated user name.
Connect:/RemoteAddress
The remote client's IP address.
Connect:/RemoteHost
The remote client's machine host name, as determined by reverse domain name server lookup.
Rexx Example:Request:/StatusCode
The protocol-specific status code to return to the client if access is denied.
/* Access Control Example - Requires version 2.06 or later. This hook can be used in conjunction with a UserAuthentication hook (see the example in that section). */ parse arg parcel user = ServerReadText(parcel, "Request:/AuthenticateUser") page = ServerReadText(parcel, "Request:/Resource") /* Substitute your own resource lookup here: So instead of: if user = "joe" then use something like: call ServerWriteText parcel, "Config:/Semaphore/Global", "5000" rc = address sql 'if exists(select * from db..resources where name='user' and resource='page') return 1 else return 0' call ServerWriteText parcel, "Config:/Semaphore/Global", "-1" if rc = 1 then */ if user = "joe" /* & length(page) < 24 */ then return "0" /* Access control failed: tell user he/she is forbidden. Code 403 means access is denied to that user. This information will be displayed by the client's browser. Return code "3" tells PowerWeb that access control denied access. */ call ServerWriteText parcel, "Request:/StatusCode", "403" return "3";
Arguments In:
Arguments Out:Argument:/Resource
The physical name of the resource to be accessed after resource name translation.
Argument:/ContentType
The MIME type of the resource.
Argument:/ContentEncoding
The MIME encoding of the resource.
Custom applications can use this hook to perform tasks other than serving of documents or data files. Database searches, gateways to other systems and services, administration tasks, etc can all be performed by this hook.
The Guided Tour provides an example of using a CommandProcessing hook which filters ".CSV" files so that they are presented as HTML tables. This processing is invisible to the user, making it an ideal mechanism for implementing filters.
Arguments In: None.
Arguments Out: None.
Arguments In:
Arguments Out:Argument:/WebMacro
The name of the WebMacro to be interpreted.
Argument:/Attributes
The full text of the WebMacro to be interpreted, excluding the name. Attributes are typically space-delimited and are composed of "name=value" pairs where values can be contained in quotes.
Request:/Result
The processed output of the PowerWeb Macro should be appended to this variable. It will be automatically sent to the client's browser.
This hook is called whenever a new mail message has been delivered. It is an opportunity to manipulate the contents of the mail message (including any headers) prior to it being added to the queue for delivery.
Deliver
Arguments In:
Arguments Out: (none)Request:/Resource
The name of the file containing the text of the mail message.
This hook is called whenever a mail item is about to be delivered locally. If you return HOOK_NO_ACTION, normal mail delivery is attempted, whereas if you return HOOK_ERROR, mail delivery is postponed until the next queue processing scan. Returning HOOK_OK signals you have handled the mail delivery and PowerWeb need take no further action itself.
Receive
This hook is typically used to implement mailing list servers, such as a majordomo.
Arguments In:
Arguments Out: (none)Request:/Resource
The name of the file containing the text of the mail message.
Request:/AuthenticateUser
The name of the local user to whom mail is being delivered. This is always the name of a user, never a group, because groups have already been expanded by this stage.Rexx Example:
/* Test if a user id is one of the special mail list ids. If so, invoke the os2mail product, else perform normal delivery. */ parse arg parcel user = ServerReadText(parcel, "Request:/AuthenticateUser"); msg = ServerReadText(parcel, "Request:/Resource"); if (user = "majordomo") | isListID(user 'powerweb') then do call os2mail user msg /* mail delivered */ return "0"; end else do /* no action taken */ return "1"; end isListID: procedure parse upper arg username listname if username = listname then return 1; if username = listname'-REQUEST' then return 1; if username = listname'-DIGEST' then return 1; if username = listname'-OWNER' then return 1; if username = listname'-ERRORS' then return 1; return 0;
Arguments In:
Arguments Out:Argument:/Host
The name of the host machine to which delivery should be attempted.
Argument:/Host
The (potentially) revised name of the host to connect to to deliver the mail.
Arguments In:
Arguments Out:Argument:/Recipient
The user name and host of the recipient. Note that SMTP allows for surrounding angle brackets (such as "<user@host.com>"), as well as routing specifications (such as "@route1,@route2:user@host.com") so be sure your API hook can recognise all these valid formats.
Rexx Example:Argument:/Recipient
The (potentially) revised name of the recipient.
Request:/StatusCode
The SMTP status code to return to the client if access is denied. Don't change this value unless you are intimately familiar with the SMTP protocol.
Request:/StatusText
The SMTP status text to return to the client if access is denied. Don't change this value unless you are intimately familiar with the SMTP protocol.
/* Filter out all mail being forwarded externally from an unwanted incoming domain. */ parse arg parcel remote = ServerReadText(parcel, "Connection:/RemoteHost"); user = ServerReadText(parcel, "Argument:/Recipient"); email = getAddress(user); if pos('compusource.co.za', remote) = 0 then return "3"; /* user rejected - bad remote host delivering mail */ if pos('@mailbomb.', email) <> 0 then return "3"; /* user rejected - unwanted destination host */ /* user accepted */ return "0"; getAddress: procedure parse arg FullEMail if pos('<', FullEMail) = 0 then do FullEMail = translate(FullEMail, '<', '(') FullEMail = translate(FullEMail, '>', ')') end parse var FullEMail Prefix '<' MainName '>' Suffix if pos('@', MainName) <> 0 then return strip(MainName) if pos('@', Prefix) <> 0 then return strip(Prefix) if pos('@', Suffix) <> 0 then return strip(Suffix) return ''