SubroutinesStarting with ZXTM 5.0, TrafficScriptTM has gained the ability to create new subroutines to reduce code duplication inside a TrafficScript rule. For example:
sub securityerror( $url )
{
log.error( $url . " failed a security check from " .
request.getremoteip() );
http.sendresponse( "403 Permission denied", "text/html",
"Permission Denied", "" );
}
if( request.getremoteip() == "1.2.3.4" ) {
securityerror( http.getrawurl() );
} else if( string.startswith( http.getpath(), "/secure" ) ) {
securityerror( http.getrawurl() );
}
Data can be returned from a subroutine using the 'return' statement, additionally $1 -> $9 are available as global variables. When using subroutines there are some points to be aware of:
Crispin Flowerday
[Zeus Dev Team] 13 June 2008
|
Recent Articles
Other Resources
|


