util::block_request (public)

 util::block_request -condition condition [ -target target ]

Defined in packages/acs-tcl/tcl/utilities-procs.tcl

Block a request from application-level Tcl code when a given condition evaluates to true. This proc is intended for use from pages, callbacks, or other code that runs after the OpenACS request processor has already accepted and initialized the request. It can be used to disallow selected requests, for example requests from bot pools on login pages or other application entry points. This proc is not suitable for rejecting requests that must be blocked before OpenACS request processing, canonical-host redirects, or page dispatch. For such cases, e.g. scanner probes for foreign application paths, use an early NaviServer filter such as ::util::reject_request_filter registered with ns_register_filter. If the condition is true and the connection is still active, the proc logs the request, returns a complaint page to the client, and aborts the script. Otherwise, it returns normally without producing output. Example:

    ::util::block_request -condition {[ns_conn pool] eq "bots"} -target bots

Switches:
-condition (required)
Tcl expression evaluated in the caller's scope. When the expression evaluates to true, the request is blocked.
-target (optional, defaults to "you")
Short description used in the message shown to the client.

Partial Call Graph (max 5 caller/called nodes):
packages/acs-subsite/lib/user-new.tcl packages/acs-subsite/ lib/user-new.tcl util::block_request util::block_request packages/acs-subsite/lib/user-new.tcl->util::block_request packages/acs-subsite/www/register/index.tcl packages/acs-subsite/ www/register/index.tcl packages/acs-subsite/www/register/index.tcl->util::block_request ad_return_complaint ad_return_complaint (public) util::block_request->ad_return_complaint ad_script_abort ad_script_abort (public) util::block_request->ad_script_abort util::request_info util::request_info (public) util::block_request->util::request_info

Testcases:
No testcase defined.
Source code:
    if {[ns_conn isconnected] && [uplevel 1 [list expr $condition]]} {
        ns_log notice "blocking request for condition $condition\n"  [util::request_info]
        ad_return_complaint 1 "page is not allowed for $target"
        ad_script_abort
    }
XQL Not present:
PostgreSQL, Oracle
Generic XQL file:
packages/acs-tcl/tcl/utilities-procs.xql

[ hide source ] | [ make this the default ]
Show another procedure: