Class response

Description

THE RESPONSE CLASS

This object is a container for all things to do with the response which we will send back to the requester (the client browser). It is a descendant of the webpage class, and before that, the session and the user classes.

If you use the Phplib framework then a response object is automatically instantiated for you. This object is assigned to the global variable called $RESPONSE. The framework also sets up the response parameters, and then calls the activate() method.

Located in /response-defs.php (line 216)

user
   |
   --session
      |
      --webstream
         |
         --webpage
            |
            --response
Variable Summary
Method Summary
 response response ()
 void add_database (string $dbtype, string $name, [string $user = ""], [string $passwd = ""], [string $host = ""], [integer $port = ""], [string $enc = "UNICODE"], [string $datestyle = "ISO"], [boolean $default = false])
 void add_language (integer $langid)
 void allowed_groups (string $allowed_groups)
 void card ([string $title = ""], [string $template = "main"], [string $theme = ""], [string $stylesheet = ""], [string $dtd = ""])
 void crash ([integer $code = false], [string $msg = ""])
 void enable_response_timer ([boolean $mode = false])
 void forget (string $varnames)
 void globalise ([string $varnames = ""], [string $sources = "env,get,post,cookie,server"])
 void globalise_all ()
 void InPersistentHostsList (string $hostname)
 void on_authentication_fail ([mixed $option = AUTHFAIL_GUEST], [mixed $redirect = ""])
 void page ([string $title = ""], [string $template = "main"], [string $theme = ""], [string $stylesheet = ""], [string $dtd = ""])
 void register (string $varnames, [string $sources = "env,get,post,cookie,server"])
 void remember (string $varnames)
 resource select_database ([mixed $db_name = ""], string $dbname)
 void set_authentication_type ([integer $authtype = HTTP_AUTHENTICATION])
 void set_blocked_ips ([mixed $ips = ""], [string $delim = ","], mixed $hosts)
 void set_buffering_mode ([mixed $mode = BUFFERED], bool $buffering)
 void set_compression_minsize (integer $size)
 void set_compression_type ([integer $type = NO_COMPRESSION])
 void set_dtd (array $DTD)
 void set_encoding ([string $charset = ""], [string $content_type = ""])
 void set_http_host ([string $http_host = ""])
 void set_keep ([boolean $keep_enabled = true])
 void set_metadata_mode ([bool $mode = METADATA_ENABLED])
 void set_microsites_mode ([bool $mode = MICROSITES_ENABLED])
 void set_multilang ([boolean $mode = true])
 void set_page_expirysecs ([integer $secs = -1])
 void set_persistent_hosts ([mixed $hosts = ""], [string $delim = ","])
Variables
mixed $accept = "" (line 229)

The browser accept string, as submitted by user-agent

mixed $accept_encoding = "" (line 231)

The browser accept-encoding string

mixed $accept_language = "" (line 233)

The browser accept-language string

mixed $auth_fail_option (line 286)

Option to take on auth failure

mixed $auth_fail_redirect (line 289)

URL to redirect to on auth failure

mixed $auth_type (line 283)

Type of authentication in effect

mixed $browser (line 219)

The make of browser

mixed $browser_type = BROWSER_TYPE_HTML (line 223)

The type of browser requesting this response

mixed $browser_version = 0 (line 221)

The version of browser requesting this response

mixed $buffering_mode = BUFFERED (line 268)

Buffering option to use

mixed $cachecontrol (line 301)

Cache control directive, usually passed on URL

mixed $charset = "ISO-8859-1" (line 241)

Charset for this page

mixed $compression_minsize (line 277)

Minimum size in bytes before invoking compression

mixed $compression_type (line 274)

Compression type to use for response content

mixed $datasource (line 247)

Datasources associated with this response

mixed $debugger (line 280)

The debugger for this response

mixed $DTD (line 310)

Array of DTD specifiers for this response. @see set_dtd()

mixed $globals (line 298)

Globals object. Manages the global vars in this response

mixed $http_host (line 257)

The host of this website ie. 'foo.thingy.co.nz'

mixed $keep (line 295)

Our keep. Keeps variables alive in session

mixed $keep_enabled = KEEP_ENABLED (line 292)

Our keep enabled flag (default enabled)

mixed $languages = array() (line 239)

IDs of all languages contained in this page

mixed $mbstring_avail = false (line 245)

Whether we have multi-byte string fns available

mixed $metadata_mode = METADATA_DISABLED (line 249)

Metadata edit/generation mode we are in

mixed $microsites_mode = MICROSITES_DISABLED (line 251)

Microsites edit/generation mode we are in

mixed $microsite_detected (line 253)

Name of the microsite detected, or undefined

mixed $multilang = false (line 237)

Whether we are in multi-language mode or not, If this is true then

mixed $page_expiry_secs = -1 (line 307)

Dynamic page expiry in seconds. Time to allow a dynamic page to

mixed $page_id (line 243)

Page ID - key to ax_sitepage record

mixed $persistent_hosts = array() (line 271)

Array of hosts we wish to connect persistently to

mixed $remote_address = "" (line 227)

The remote IP address

mixed $requested (line 261)

Path to the requested script/page

mixed $requested_query (line 263)

Query string (if any) supplied to requested page

mixed $site_docroot (line 259)

Path to the site document root

mixed $site_url (line 255)

The URL of this website

mixed $timer (line 312)

Reponse timer

mixed $user_agent = "" (line 225)

The user-agent

Inherited Variables

Inherited from webpage

webpage::$body
webpage::$foot
webpage::$generated
webpage::$head
webpage::$pluginset
webpage::$template
webpage::$templatefile
webpage::$theme

Inherited from webstream

webstream::$buffered
webstream::$cached
webstream::$cache_expiry
webstream::$cache_path
webstream::$cache_regen
webstream::$content
webstream::$replacement

Inherited from session

session::$cookiename
session::$db_backed
session::$error_message
session::$guest_browser_lifetime
session::$last_logintime
session::$lifetime
session::$logins_exceeded_msg
session::$logins_exceeded_option
session::$logins_exceeded_redirect
session::$login_type
session::$session_id
session::$session_record
session::$session_track_logins

Inherited from user

user::$authentication_method
user::$auth_code
user::$email
user::$enabled
user::$first_name
user::$group_info
user::$group_names
user::$hasgroups
user::$hasIPlist
user::$honorific_prefix
user::$IP
user::$last_name
user::$limit_logins
user::$locked
user::$mid_names
user::$name
user::$passwd_alphanum_mixed
user::$passwd_apply_stopwords
user::$passwd_char_uniqueness
user::$passwd_delay_ms
user::$passwd_encryption
user::$passwd_expiry_days
user::$passwd_expiry_ts
user::$passwd_failures
user::$passwd_forever
user::$passwd_history
user::$passwd_history_cycle
user::$passwd_max_attempts
user::$passwd_min_chars
user::$password
user::$remote_auth_dbname
user::$remote_auth_fields
user::$remote_auth_source
user::$remote_auth_tablename
user::$total_logins
user::$userid
user::$user_groups_cnt
user::$user_record
user::$user_type
user::$valid
Methods
Constructor response (line 324)

Constructor Create a new response.

One of these objects must be created to respond to each request from the user agent for a webpage. This object manages that response and is a central marshalling point for all data and functions associated with that process. A response object is automatically created for you at the bottom of this module, and is assigned to the global variable $RESPONSE.

response response ()
add_database (line 1284)

Add database Add a new database to the list of datasources which are going to be used to serve this response. The dbtype and the name are the only mandatory parameters.

void add_database (string $dbtype, string $name, [string $user = ""], [string $passwd = ""], [string $host = ""], [integer $port = ""], [string $enc = "UNICODE"], [string $datestyle = "ISO"], [boolean $default = false])
  • string $dbtype: The type of database eg: 'postgres', 'mssql' etc.
  • string $name: The name of the database
  • string $user: Name of a user who can access the database
  • string $passwd: The password the user can access the database with
  • string $host: The hostname of the machine running the database (TCP/IP)
  • integer $port: The port number of the database server
  • string $enc: The database character encoding (eg. 'US_ASCII', 'UNICODE')
  • string $datestyle: The database date style (eg. 'ISO')
  • boolean $default: True if the database is the default database
add_language (line 975)

Adds another language for the current webpage. Webpages might contain content in multiple languages, hence the need for a list.

void add_language (integer $langid)
  • integer $langid: The new language ID to add for the webpage
allowed_groups (line 1347)

Allowed groups This defines the allowed user-groups for this response, otherwise they get an error page returned. The list of allowed groups should be a comma-delimited string.

NB: We look for globals $admin_auth_code, and $auth_code and if available, use these for authorisation.

void allowed_groups (string $allowed_groups)
  • string $allowed_groups: Comma-delimited list of allowed groups
card (line 675)

Set up the Wap page (card) attributes for our response. This is the exact equivalent to the page() method above, but for WAP phones instead.

void card ([string $title = ""], [string $template = "main"], [string $theme = ""], [string $stylesheet = ""], [string $dtd = ""])
  • string $title: Card title string
  • string $template: Template for this WML card
  • string $theme: Theme to apply. This is for branding purposes
  • string $stylesheet: Name of stylesheet to use eg: 'sitestyle.css'
  • string $dtd: Override the DTD specifier for WML page
check_group_membership (line 1397)

Check group membership

This check whether the user requesting the page fulfils any group membership requirements. These are optionally expressed as the presence of 'ax_sitepage_group' records. A set of these records represents a set of groups that the user must be member of at least one of, to have access to the page.

void check_group_membership ()
crash (line 1423)

Crash the response with message A fatal error ocurred. We die with a message to the system log and to the user. Code supplied is optional.

void crash ([integer $code = false], [string $msg = ""])
  • integer $code: The HTTP/1.0 code to use
  • string $msg: The message to display and log
enable_response_timer (line 540)

Set the response timer up. Set it ticking.

void enable_response_timer ([boolean $mode = false])
  • boolean $mode: If true then enable the response timer.
forget (line 1097)

Forget kept variables by name. The named variables will have been passed to the remember() function beforehand, and this method causes them to be forgotten.

void forget (string $varnames)
  • string $varnames: Comma-delimited list of variable names to forget
globalise (line 1053)

Globalise specific vars

void globalise ([string $varnames = ""], [string $sources = "env,get,post,cookie,server"])
  • string $varnames: Comma-delimited list of variable names to globalise
  • string $sources: Comma-delimited list of allowed sources for values
globalise_all (line 1044)

Set globalise all

Flag that we should globalise all vars from anywhere. This is the same as setting 'register_globals = On' in php.ini. It gives backward compatibility with that setting, if you find that it has been set to 'Off' and this breaks your code. NB: This only takes effect when the session is activated with the activate() method of this class.

void globalise_all ()
InPersistentHostsList (line 1327)

Is host in peristent list

Returns true if the given host is in our list of persistent hosts, else returns false. The persistent hosts list we hold will general contain partial hostnames. We therefore check to see if this partial name occurs anywhere in the given hostname.

void InPersistentHostsList (string $hostname)
  • string $hostname: The name of the host to check
on_authentication_fail (line 1251)

Set authentication failure option

This sets the option for when authentication fails due to invalid username/password. Options are: AUTHFAIL_DIE_MSG Die, with 'not authorised' message AUTHFAIL_DIE_SILENT Die silently AUTHFAIL_REDIRECT Re-direct to alternate URL AUTHFAIL_GUEST Welcome the user as a guest (the default)

void on_authentication_fail ([mixed $option = AUTHFAIL_GUEST], [mixed $redirect = ""])
page (line 644)

Set up the page attributes for our response. This is an important call, and should be made just after including response-defs.php in your source code. It sets up the page title, the template file which defines the page structure, the theme and stylesheet.

void page ([string $title = ""], [string $template = "main"], [string $theme = ""], [string $stylesheet = ""], [string $dtd = ""])
  • string $title: Webpage title string
  • string $template: Template for this webpage
  • string $theme: Theme to apply. This is for branding purposes
  • string $stylesheet: Name of stylesheet to use eg: 'sitestyle.css'
  • string $dtd: Override the DTD specifier for page
register (line 1063)

Register vars Register given variables for globalisation.

void register (string $varnames, [string $sources = "env,get,post,cookie,server"])
  • string $varnames: Comma-delimited list of variable names to globalise
  • string $sources: Comma-delimited list of allowed sources for values
remember (line 1085)

Remember variables by name, across page requests using our keep functionality. This utilises Php session handling to maintain the value of variables named here. Pass a list of vars as a string delimited by a comma.

void remember (string $varnames)
  • string $varnames: Comma-delimited list of variable names to keep
select_database (line 1309)

Selects a database to use This will connect it if it isn't already connected. Calling this with no database name will select the default one. Returns the database unique identifier, or false if none was selected.

The named database must have been already defined. @see add_database()

resource select_database ([mixed $db_name = ""], string $dbname)
  • string $dbname: The name of the database to select
set_authentication_type (line 1238)

Set website authentication

Set the authentication option for the website. Note that although there is NO_AUTHENTICATION, this has no real effect and is mainly there so you can indicate your intent not to bother with authentication. If no username/password is passed then the system will always log the session as a "guest" anyway, regardless of this setting. Options are: NO_AUTHENTICATION Redundant case, no authentication HTTP_AUTHENTICATION User sees a browser username/password popup FORM_AUTHENTICATION Custom form fields $tbxUsername/$tbxPassword

void set_authentication_type ([integer $authtype = HTTP_AUTHENTICATION])
  • integer $authtype: Authentication option type
set_blocked_ips (line 1133)

define a blocked IP list.

Set the list of IP addresses which are persona non grata for our site. This might be a list of problem IPs which are hacking, for example. Note that this method may not return, since the IP checking is done immediately, and if the REMOTE_ADDR accessing the site right now is found to match a blocked IP, then we crash and burn the response.

void set_blocked_ips ([mixed $ips = ""], [string $delim = ","], mixed $hosts)
  • mixed $hosts: Array or delimited list of host names to connect persistently to
  • string $delim: Optional delimiter, defaults to a comma
set_buffering_mode (line 1174)

Set buffering option

Set the webstream buffering option. Usually we want to buffer the webpage output to do cool things with the content right up until we send it. If you select NO_BUFFERING, then output won't be buffered and you will probably be processing it yourself. If in doubt, leave it as BUFFERING, the default. Possible options.. BUFFERED Output webstream uses Php buffering (default) UNBUFFERED No buffering of output webstream

void set_buffering_mode ([mixed $mode = BUFFERED], bool $buffering)
  • bool $buffering: Buffering option: NO_BUFFERING, or BUFFERING
set_compression_minsize (line 1222)

Set compression threshold Set the threshold size of content before we use compression.

void set_compression_minsize (integer $size)
  • integer $size: Pagesize in bytes below which we will not compress
set_compression_type (line 1158)

Set compression type

Set the compression type to use for content delivery. Options are: NO_COMPRESSION Normal delivery of content BUILTIN_COMPRESSION Builtin PHP compression (Requires Php >= v4.04) CUSTOM_COMPRESSION Compression provided by the library

void set_compression_type ([integer $type = NO_COMPRESSION])
  • integer $type: Compression type: NO_COMPRESSION, BUILTIN_COMPRESSION, CUSTOM_COMPRESSION
set_dtd (line 627)

Set the DTDs array for all possible content types for this webpage.

The array is associative, with content type as the key, and the DTD specifier as the value. Currently we only support two content types: "html" and "wml".

void set_dtd (array $DTD)
  • array $DTD: Array of DTD specifiers per content type
set_encoding (line 996)

Sets the content-type header characterset encoding, and (optionally)

allows you to override the content type itself although it should be set for you automatically, so you should only need to provide the second parameter for special purposes. This method will send the content-type: header to the user agent (browser). It can be called any number of times before send() is called.

void set_encoding ([string $charset = ""], [string $content_type = ""])
  • string $charset: The character encoding to use for the webpage
  • string $content_type: The content type (defaults to proper one for browser)
set_http_host (line 1262)

Set the hostname of the machine serving this Axyl website. This is usually the same as that in the global $HTTP_HOST variable.

void set_http_host ([string $http_host = ""])
  • string $http_host: The hostname of the machine serving this website
set_keep (line 1074)

Set keep enable status. If the keep is enabled then there is access to the remember() and forget() methods to control persistent vars using Php session handling functions.

void set_keep ([boolean $keep_enabled = true])
  • boolean $keep_enabled: If true then the keep methods are enabled
set_metadata_mode (line 1187)

Set metadata mode

This setting determines whether Axyl will implement the metadata enhancements that it has. If true, content-managed layouts will get an extra button 'META', which enables page metadata to be edited Also, when page generation takes place, metadata elements will be procuced in the output.

void set_metadata_mode ([bool $mode = METADATA_ENABLED])
  • bool $mode: Metadata enable mode, true or false
set_microsites_mode (line 1200)

Set microsites mode

This setting determines whether Axyl will implement the microsites enhancements that it has. If true, then users with content manager privileges will be able to create and maintain "microsites" within the current Axyl website framework. These are essentially simple themes, using Axyl themeing.

void set_microsites_mode ([bool $mode = MICROSITES_ENABLED])
  • bool $mode: Microsites feature enable mode, true or false
set_multilang (line 966)

Sets the status of the multi-language flag 'multilang'. If this flag is true then multi-language facilities are enabled. This allows the setting of tags to indicate webpage language(s), and for inputting different character encodings via form elements etc.

void set_multilang ([boolean $mode = true])
  • boolean $mode: Whether we should set multi-language mode
set_page_expirysecs (line 1213)

Set page expiry in seconds. This affects all of the pages returned by Axyl.

Normally this is left at -1, which causes the system to tell the user browser to NOT cache the webpage, and revalidate every time. This is the usual case for a dynamic website where content is always changing. If set to a positive value, the user browser will (probably) keep the page cached for this time.

void set_page_expirysecs ([integer $secs = -1])
  • integer $secs: Time to allow website pages to live in the user browser.
set_persistent_hosts (line 1111)

Define persistent hosts list.

Set the list of hosts recognition strings to connect to with persistent database connections. You can pass either an array of strings or a single string containing a delimited list of hosts.

void set_persistent_hosts ([mixed $hosts = ""], [string $delim = ","])
  • mixed $hosts: Array or delimited list of host names to connect persistently to
  • string $delim: Optional delimiter, defaults to a comma

Inherited Methods

Inherited From webpage

 webpage::webpage()
 webpage::add()
 webpage::add_named_script()
 webpage::add_script()
 webpage::add_scriptsrc()
 webpage::assign_DTD()
 webpage::generate()
 webpage::get_stylesheets()
 webpage::inline_end()
 webpage::inline_start()
 webpage::insert_metatag()
 webpage::plugin()
 webpage::plugin_inline()
 webpage::plugin_replace()
 webpage::render()
 webpage::send()
 webpage::set_metatag()
 webpage::set_onload()
 webpage::set_style()
 webpage::set_stylesheet()
 webpage::set_template()
 webpage::set_theme()
 webpage::set_title()

Inherited From webstream

 webstream::webstream()
 webstream::add_content()
 webstream::cache()
 webstream::close_webstream()
 webstream::discard()
 webstream::length()
 webstream::open_webstream()
 webstream::replace()
 webstream::replace_content()
 webstream::reset_webstream()
 webstream::send_errorcode_and_die()
 webstream::send_error_and_die()
 webstream::send_to_browser()
 webstream::send_to_file()
 webstream::webpage_content()

Inherited From session

 session::session()
 session::delete_cookie()
 session::identify_user()
 session::on_logins_exceeded()
 session::recover()
 session::session_clear()
 session::session_create()
 session::session_delete()
 session::session_valid()
 session::set_cookie()
 session::set_cookiename()
 session::set_guest_browser_lifetime()
 session::set_lifetime()
 session::set_sessiontype()
 session::set_session_track_logins()

Inherited From user

 user::user()
 user::authenticate()
 user::authenticate_authid()
 user::authenticate_ipaddress()
 user::authenticate_password()
 user::authenticate_userid()
 user::friendlyName()
 user::generate_password()
 user::get_auth_code()
 user::get_groups()
 user::get_user_by_auth_code()
 user::get_user_by_id()
 user::get_user_by_ip()
 user::group_ids_list()
 user::group_names_list()
 user::ismemberof_group()
 user::ismemberof_group_in()
 user::ismemberof_group_with_id()
 user::isvalid()
 user::password_expired()
 user::push_password_history()
 user::save_password_data()
 user::set_password()
 user::set_password_expiry()
 user::set_remote_authentication()
 user::set_security_profile()
 user::valid_password()

Documentation generated by phpDocumentor 1.3.0RC3