Class webstream

Description

The webstream class

A class to manage buffering, cacheing, processing and output of the content to the user agent. This is the entity which manages the Php buffering mechanism, starting and stopping buffering and sending the buffer to the client's browser. It also manages any cacheing of the webpage. This class extends the session, since the whole point of the session is to output content back to the user agent.

Located in /webpage-defs.php (line 58)

user
   |
   --session
      |
      --webstream
Direct descendents
Class Description
 class webpage The webpage page class.
 class templated_webpage The templated webpage page class
Variable Summary
 mixed $buffered
 mixed $cached
 mixed $cache_path
 mixed $cache_regen
 mixed $content
 mixed $replacement
Method Summary
 webstream webstream ([string $initcontent = ""], [mixed $buffered = true])
 void add_content (mixed $content)
 void cache ($expirysecs $expirysecs)
 string close_webstream ()
 void discard ()
 void length ($expirysecs 0)
 void open_webstream ()
 void replace (string $tag, string $newstuff)
 void replace_content (string $newcontent)
 void reset_webstream ()
 void send_errorcode_and_die (integer $code)
 void send_error_and_die (string $heading, [string $msg = ""])
 void send_to_browser ()
 boolean send_to_file (string $name, [string $dir = ""])
 string webpage_content ()
Variables
mixed $buffered = true (line 60)

Whether to use Php buffering

mixed $cached = NOT_CACHED (line 66)

Page is cached or dynamic

mixed $cache_expiry = 0 (line 68)

Seconds expiry for cached webpages

mixed $cache_path = "" (line 70)

Path to use to save cached version of webpage

mixed $cache_regen = false (line 72)

If true, force regeneration of cached webpage

mixed $content = "" (line 62)

The content to send to browser

mixed $replacement (line 64)

Replacements to make in template

Inherited Variables

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 webstream (line 83)

Constructor

Create a new webstream object. When this object is created it always starts buffering with the ob_start() call. The Phplib system always uses the Php buffering mechanism. This allows us to process the output content and do 'clever things' right up to the point of sending it all to the user.

webstream webstream ([string $initcontent = ""], [mixed $buffered = true])
  • string $initcontent: Some intial content for the page
add_content (line 147)

Add new content to the webstream..

void add_content (mixed $content)
cache (line 167)

Cache this webpage Causes the current webpage to be regarded as a cached page.

This means we look for a file of the same name but with extension 'cached' in the $CACHEDIR directory, and check the modification time. If it isn't expired then we set the page content to that file, and send it. Otherwise we behave as if it is a normal dynamic Php page.

void cache ($expirysecs $expirysecs)
  • $expirysecs $expirysecs: integer Seconds before page cacheing expires
close_webstream (line 121)

Close the webstream. Return any current webpage content. Clear the current content. This method clears content, but leaves any replacement definitions untouched for further processing. It is designed to be called as part of the final webpage rendering process.

  • return: The current content, as it stands.
string close_webstream ()
discard (line 269)

Discard all webpage content For discarding the content so far with immediate effect.

void discard ()
length (line 228)

Length of output buffer

Returns the length of our output buffer. Be careful when this is called, since the buffer might not be filled by make_content() yet!

void length ($expirysecs 0)
  • $expirysecs 0: integer Seconds before page cacheing expires
open_webstream (line 98)

Start webstream output channel..

void open_webstream ()
replace (line 247)

Replace pattern in webpage content

Replaces multiple occurrences of the given tag (pattern) in the body content with the specified new stuff. NB: when you call this method the replacement isn't actually done there and then. It is simply flagged as something to be done just before all of the content is delivered to the user browser.

void replace (string $tag, string $newstuff)
  • string $tag: Pattern to replace in content
  • string $newstuff: Stuff to replace the tag with
replace_content (line 259)

Replace all webpage content For replacing the total contents of the buffer so far with a new content. Throw buffer away and start anew with immediate effect.

void replace_content (string $newcontent)
  • string $newcontent: Replacement webpage content
reset_webstream (line 141)

Reset the webstream. This method clears any current content, and also clears any stored replacement definitions. This resets the stream to the point at which it was created - a virgin webstream.

void reset_webstream ()
send_errorcode_and_die (line 460)

Send HTTP error code and die Generic function to abort and send an error code notification to the user. These are lookalike errors for generic ones like 404: Page not found etc. This function will not return.

void send_errorcode_and_die (integer $code)
  • integer $code: The HTTP error code to generate
send_error_and_die (line 442)

Send error and die Generic function to abort and send an error notification to the user instead. This function is a one-way trip to oblivion.

void send_error_and_die (string $heading, [string $msg = ""])
  • string $heading: The error heading or subject
  • string $msg: The detailed error message
send_to_browser (line 337)

Send content to user browser

Deliver the content to the browser. First check if the page is cached and if so whether we are going to update the cache. Next we get the current buffer and aply any compression required. Then we send the output on its way using the simple echo() function. NOTE: If the page is not cached then we always send headers which will make the user browser avoid cacheing it locally. This makes sure that our dynamic pages will always be requested by it.

void send_to_browser ()
send_to_file (line 402)

Send content to file Deliver the content to a given file.

Make our buffer content, and then deliver it to a file.

  • return: True if file was opened, else false
  • see: output_to_file()
  • see: make_content()
boolean send_to_file (string $name, [string $dir = ""])
  • string $name: The name of the file
  • string $dir: The directory the file is in
webpage_content (line 430)

Return webpage content Builds all of the webpage content and returns it to the caller.

  • return: All of the webpage content as it would be sent to the user browser
string webpage_content ()

Inherited Methods

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