I've now determined what would be a good basis for using a 'standard' structure.
Standard would be a minimal website used by most of my projects here, but it is not part of the base so that other developers do not have to use it at all.
This allows for more development flexibility while still providing a common default.
Most of the reservation example program code was moved into standard, including sql code.
require_once('common/base/classes/base_session.php');
require_once('common/base/classes/base_ldap.php');
-/**
- * A class for managing roles.
- *
- * Roles defined here are general top-level roles used for separating database activity.
- * The intentions here is to keep the roles as simple and as few as possible while allowing considerable flexibility.
- * This should cut down on the complexity of the database access control.
- *
- * Additional granularity may be supplied via PHP access checks or by extending this class.
- *
- * Roles:
- * - None: no access to anything.
- * - Public: access to only public information (users who are not logged in have this, such as anonymous).
- * - System: account is a machine and should not be a human (such as with cron jobs).
- * - User: account is a user and that user is logged in.
- * - Requester: account is for requesting something, generally via some sort of form.
- * - Drafter: account is for making templates, drafts, ideas, etc.. (this is a lesser form of "editer").
- * - Editer: account is for editors who add/manage/create content.
- * - Reviewer: account is for users who review something (such as a user who approves content for publishing).
- * - Insurer: account is for users who deal with insurance related information.
- * - Financer: account is for users who deal with financial related information.
- * - Publisher: account is for users who perform publishing (marking content available and complete).
- * - Auditor: account is for users who perform auditing. This account has read access to almost all data on the system.
- * - Manager: account is for users who manager the entire system. This is a non-technical administration account.
- * - Administer: account is for users who have full administrative access to the system. This is a technical administration account and supercedes Manager.
- */
-class c_base_roles extends c_base_return {
- const NONE = 0;
- const PUBLIC = 1;
- const SYSTEM = 2;
- const USER = 3;
- const REQUESTER = 4;
- const DRAFTER = 5;
- const EDITOR = 6;
- const REVIEWER = 7;
- const INSURER = 8;
- const FINANCER = 9;
- const PUBLISHER = 10;
- const AUDITOR = 11;
- const MANAGER = 12;
- const ADMINISTER = 13;
-
- private $public;
- private $system;
- private $user;
- private $requester;
- private $drafter;
- private $editer;
- private $reviewer;
- private $insurer;
- private $financer;
- private $publisher;
- private $auditor;
- private $manager;
- private $administer;
-
- /**
- * Class constructor.
- */
- public function __construct() {
- parent::__construct();
-
- $this->public = TRUE;
- $this->system = FALSE;
- $this->user = FALSE;
- $this->requester = FALSE;
- $this->drafter = FALSE;
- $this->editer = FALSE;
- $this->reviewer = FALSE;
- $this->financer = FALSE;
- $this->insurer = FALSE;
- $this->publisher = FALSE;
- $this->auditor = FALSE;
- $this->manager = FALSE;
- $this->administer = FALSE;
- }
-
- /**
- * Class destructor.
- */
- public function __destruct() {
- unset($this->public);
- unset($this->system);
- unset($this->user);
- unset($this->requester);
- unset($this->drafter);
- unset($this->editer);
- unset($this->reviewer);
- unset($this->financer);
- unset($this->insurer);
- unset($this->publisher);
- unset($this->auditor);
- unset($this->manager);
- unset($this->administer);
-
- parent::__destruct();
- }
-
- /**
- * @see: t_base_return_value::p_s_new()
- */
- public static function s_new($value) {
- return self::p_s_new($value, __CLASS__);
- }
-
- /**
- * @see: t_base_return_value::p_s_value()
- */
- public static function s_value($return) {
- return self::p_s_value($return, __CLASS__);
- }
-
- /**
- * @see: t_base_return_value_exact::p_s_value_exact()
- */
- public static function s_value_exact($return) {
- return self::p_s_value_exact($return, __CLASS__, array());
- }
-
- /**
- * Assign a role.
- *
- * When role is set to NONE, and value is TRUE, then all roles are set to FALSE.
- * When role is set to NONE and value is FALSE, nothing happens.
- *
- * @param int $role
- * The role id to assign.
- * @param bool $value
- * Set the role value to TRUE/FALSE.
- *
- * @return c_base_return_status
- * TRUE on success, FALSE otherwise.
- * FALSE with error bit set is returned on error.
- */
- public function set_role($role, $value) {
- if (!is_int($role)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'role', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- if (!is_bool($value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'value', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- if ($role === self::NONE) {
- if ($value) {
- $this->public = FALSE;
- $this->system = FALSE;
- $this->user = FALSE;
- $this->requester = FALSE;
- $this->drafter = FALSE;
- $this->editer = FALSE;
- $this->reviewer = FALSE;
- $this->publisher = FALSE;
- $this->auditor = FALSE;
- $this->manager = FALSE;
- $this->administer = FALSE;
- }
- }
- elseif ($role === self::PUBLIC) {
- $this->public = $value;
- }
- elseif ($role === self::SYSTEM) {
- $this->system = $value;
- }
- elseif ($role === self::USER) {
- $this->user = $value;
- }
- elseif ($role === self::REQUESTER) {
- $this->requester = $value;
- }
- elseif ($role === self::DRAFTER) {
- $this->drafter = $value;
- }
- elseif ($role === self::EDITOR) {
- $this->editer = $value;
- }
- elseif ($role === self::REVIEWER) {
- $this->reviewer = $value;
- }
- elseif ($role === self::FINANCER) {
- $this->financer = $value;
- }
- elseif ($role === self::INSURER) {
- $this->insurer = $value;
- }
- elseif ($role === self::PUBLISHER) {
- $this->publisher = $value;
- }
- elseif ($role === self::AUDITOR) {
- $this->auditor = $value;
- }
- elseif ($role === self::MANAGER) {
- $this->manager = $value;
- }
- elseif ($role === self::ADMINISTER) {
- $this->administer = $value;
- }
- else {
- return new c_base_return_false();
- }
-
- return new c_base_return_true();
- }
-
- /**
- * Get the current status of the specified role.
- *
- * When role is set to NONE, TRUE is returned when all values are set to FALSE.
- * When role is set to NONE, FALSE is returned when any values are set to TRUE.
- *
- * @param int $role
- * The role id to get the value of.
- *
- * @return c_base_return_status
- * TRUE on enabled, FALSE on disabled.
- * FALSE with error bit set is returned on error.
- */
- public function get_role($role) {
- if (!is_int($role)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'role', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- if ($role === self::NONE) {
- if (!($this->public || $this->system || $this->user || $this->requester || $this->drafter || $this->editer || $this->reviewer || $this->publisher || $this->auditor || $this->manager || $this->administer)) {
- return new c_base_return_true();
- }
- }
- elseif ($role === self::PUBLIC) {
- if ($this->public) {
- return new c_base_return_true();
- }
- }
- elseif ($role === self::SYSTEM) {
- if ($this->system) {
- return new c_base_return_true();
- }
- }
- elseif ($role === self::USER) {
- if ($this->user) {
- return new c_base_return_true();
- }
- }
- elseif ($role === self::REQUESTER) {
- if ($this->requester) {
- return new c_base_return_true();
- }
- }
- elseif ($role === self::DRAFTER) {
- if ($this->drafter) {
- return new c_base_return_true();
- }
- }
- elseif ($role === self::EDITOR) {
- if ($this->editer) {
- return new c_base_return_true();
- }
- }
- elseif ($role === self::REVIEWER) {
- if ($this->reviewer) {
- return new c_base_return_true();
- }
- }
- elseif ($role === self::FINANCER) {
- if ($this->financer) {
- return new c_base_return_true();
- }
- }
- elseif ($role === self::INSURER) {
- if ($this->insurer) {
- return new c_base_return_true();
- }
- }
- elseif ($role === self::PUBLISHER) {
- if ($this->publisher) {
- return new c_base_return_true();
- }
- }
- elseif ($role === self::AUDITOR) {
- if ($this->auditor) {
- return new c_base_return_true();
- }
- }
- elseif ($role === self::MANAGER) {
- if ($this->manager) {
- return new c_base_return_true();
- }
- }
- elseif ($role === self::ADMINISTER) {
- if ($this->administer) {
- return new c_base_return_true();
- }
- }
-
- return new c_base_return_false();
- }
-
- /**
- * Get an array of all currently assigned roles.
- *
- * @return c_base_return_array
- * An array of roles are returned.
- * An array with error bit set is returned on error.
- */
- public function get_roles() {
- $roles = array();
-
- if ($this->public) {
- $roles[self::PUBLIC] = self::PUBLIC;
- }
-
- if ($this->system) {
- $roles[self::SYSTEM] = self::SYSTEM;
- }
-
- if ($this->user) {
- $roles[self::USER] = self::USER;
- }
-
- if ($this->requester) {
- $roles[self::REQUESTER] = self::REQUESTER;
- }
-
- if ($this->drafter) {
- $roles[self::DRAFTER] = self::DRAFTER;
- }
-
- if ($this->editer) {
- $roles[self::EDITOR] = self::EDITOR;
- }
-
- if ($this->reviewer) {
- $roles[self::REVIEWER] = self::REVIEWER;
- }
-
- if ($this->financer) {
- $roles[self::FINANCER] = self::FINANCER;
- }
-
- if ($this->insurer) {
- $roles[self::INSURER] = self::INSURER;
- }
-
- if ($this->publisher) {
- $roles[self::PUBLISHER] = self::PUBLISHER;
- }
-
- if ($this->auditor) {
- $roles[self::AUDITOR] = self::AUDITOR;
- }
-
- if ($this->manager) {
- $roles[self::MANAGER] = self::MANAGER;
- }
-
- if ($this->administer) {
- $roles[self::ADMINISTER] = self::ADMINISTER;
- }
-
- return c_base_return_array::s_new($roles);
- }
-}
*/
public static function s_is_valid($charset) {
if (!is_int($charset)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'charset', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'charset', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public static function s_to_string($charset) {
if (!is_int($charset)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'charset', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'charset', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
return c_base_return_string::s_new('ISO-8859-16');
}
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '::' . __FUNCTION__), i_base_error_messages::FUNCTION_FAILURE));
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '::' . __FUNCTION__), i_base_error_messages::FUNCTION_FAILURE));
return c_base_return_error::s_false($error);
}
}
*
* @see: https://www.w3.org/TR/html5/
*/
-
-// include required files.
-require_once('common/base/classes/base_error.php');
-require_once('common/base/classes/base_return.php');
-require_once('common/base/classes/base_markup.php');
* @file
* Provides a class for managing cookies.
*/
-
-// include required files.
require_once('common/base/classes/base_error.php');
require_once('common/base/classes/base_return.php');
const SAME_SITE_STRICT = 2;
- private $name;
- private $secure;
- private $max_age;
- private $expires;
- private $path;
- private $domain;
- private $http_only;
- private $first_only;
- private $host_only;
- private $same_site;
- private $json_encode_depth;
+ protected $name;
+ protected $secure;
+ protected $max_age;
+ protected $expires;
+ protected $path;
+ protected $domain;
+ protected $http_only;
+ protected $first_only;
+ protected $host_only;
+ protected $same_site;
+ protected $json_encode_depth;
/**
*/
public function set_name($name) {
if (!is_string($name) || empty($name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (mb_strlen($name) == 0 || preg_match('/^(\w|-)+$/iu', $name) != 1) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'name', ':expected_format' => '. Alphanumeric and dash characters only', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'name', ':{expected_format}' => '. Alphanumeric and dash characters only', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
*/
public function set_secure($secure) {
if (!is_bool($secure)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'secure', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'secure', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$expires = (int) $expires;
if ($expires < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'expires', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'expires', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
else {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'expires', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'expires', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
$max_age = (int) $max_age;
if ($max_age < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'max_age', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'max_age', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
else {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'max_age', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'max_age', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
*/
public function set_path($path) {
if (!is_string($path) || empty($path)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'path', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'path', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$parsed = parse_url($path, PHP_URL_PATH);
if ($parsed === FALSE) {
unset($parsed);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'parse_url'), i_base_error_messages::OPERATION_FAILURE));
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'parse_url'), i_base_error_messages::OPERATION_FAILURE));
return c_base_return_error::s_false($error);
}
*/
public function set_domain($domain) {
if (!is_string($domain) || empty($domain)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'domain', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'domain', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$parsed = parse_url('stub://' . $domain, PHP_URL_HOST);
if ($parsed === FALSE) {
unset($parsed);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'parse_url', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'parse_url', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function set_http_only($http_only) {
if (!is_bool($http_only)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'http_only', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'http_only', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_first_only($first_only) {
if (!is_bool($first_only)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'first_only', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'first_only', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_host_only($host_only) {
if (!is_bool($host_only)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'host_only', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'host_only', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_same_site($same_site) {
if (!is_int($same_site)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'same_site', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'same_site', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$this->same_site = $same_site;
break;
default:
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'same_site', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'same_site', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function get_cookie($checksum = TRUE) {
if (!is_bool($checksum)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'checksum', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'checksum', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (is_null($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->value', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
*/
public function set_json_encode_depth($json_encode_depth) {
if (!is_int($json_encode_depth) || $json_encode_depth < 1) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'json_encode_depth', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'json_encode_depth', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function do_push($checksum = TRUE, $force = FALSE) {
if (!is_bool($checksum)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'checksum', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'checksum', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($force)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'force', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'force', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (is_null($this->name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
if (is_null($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->value', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
unset($json);
if ($data === FALSE) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'json_decode', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'json_decode', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function validate() {
if (!is_array($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->data')), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->data')), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
}
unset($checksum);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->p_build_checksum', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->p_build_checksum', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
if (is_null($this->value['checksum'])) {
unset($this->value['checksum']);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->p_build_checksum', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->p_build_checksum', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
}
$json = json_encode($this->value, 0, $this->json_encode_depth);
if ($json === FALSE) {
unset($json);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'json_encode', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'json_encode', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*
* @see: http://php.net/manual/en/features.persistent-connections.php
*/
-
-// include required files.
require_once('common/base/classes/base_warning.php');
require_once('common/base/classes/base_error.php');
require_once('common/base/classes/base_return.php');
*
* @see: http://php.net/manual/en/function.pg-pconnect.php
*/
-class c_base_connection_string extends c_base_return_string {
+class c_base_database_connection_string extends c_base_return_string {
const DATA_CLEAR_TEXT_LENGTH = 4096;
- private $host;
- private $host_addr;
- private $port;
- private $database;
- private $user;
- private $password;
- private $connect_timeout;
- private $options;
- private $ssl_mode;
- private $service;
+ protected $host;
+ protected $host_addr;
+ protected $port;
+ protected $database;
+ protected $user;
+ protected $password;
+ protected $connect_timeout;
+ protected $options;
+ protected $ssl_mode;
+ protected $service;
/**
* Class destructor.
*/
public function set_host($host) {
if (!is_string($host)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'host', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'host', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_host_addr($host_addr) {
if (!is_string($host_addr)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'host_addr', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'host_addr', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (is_string($port) && is_numeric($port)) {
$port = (int) $port;
if ($port < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'port', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'port', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
else {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'port', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'port', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
*/
public function set_database($database) {
if (!is_string($database)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'database', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'database', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_user($user) {
if (!is_string($user)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'user', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'user', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_password($password) {
if (!is_null($password) && !is_string($password)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'password', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'password', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (is_string($connect_timeout) && is_numeric($connect_timeout)) {
$connect_timeout = (int) $connect_timeout;
if ($connect_timeout < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'connect_timeout', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'connect_timeout', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
else {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'connect_timeout', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'connect_timeout', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
*/
public function set_options($options) {
if (!is_string($options)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'options', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'options', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_ssl_mode($ssl_mode) {
if (!is_string($ssl_mode)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'ssl_mode', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'ssl_mode', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_service($service) {
if (!is_string($service)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'service', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'service', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$this->do_disconnect();
}
- if (is_object($this->connection_string) && $this->connection_string instanceof c_base_connection_string) {
+ if (is_object($this->connection_string) && $this->connection_string instanceof c_base_database_connection_string) {
$this->connection_string->clear();
}
*/
public function set_session($session) {
if (!is_object($session) || !($session instanceof c_base_session)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'session', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'session', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
/**
* Assign a connection string to the database.
*
- * @param c_base_connection_string $connection_string
+ * @param c_base_database_connection_string $connection_string
* An already processed and configured connection string object.
*
* @return c_base_return_status
* FALSE with the error bit set is returned on error.
*/
public function set_connection_string($connection_string) {
- if (!is_object($connection_string) || !($connection_string instanceof c_base_connection_string)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'connection_string', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ if (!is_object($connection_string) || !($connection_string instanceof c_base_database_connection_string)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'connection_string', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
- $this->connection_string = $connection_string;
+ $this->connection_string = clone($connection_string);
$this->connection_string->build();
return new c_base_return_true();
/**
* Returns the connection string.
*
- * @return c_base_connection_string
+ * @return c_base_database_connection_string
* A connection string object on success.
* The error bit set is on error.
*/
public function get_connection_string() {
- if (!is_object($this->connection_string) || !($this->connection_string instanceof c_base_connection_string)) {
- $this->connection_string = new c_base_connection_string();
+ if (!is_object($this->connection_string) || !($this->connection_string instanceof c_base_database_connection_string)) {
+ $this->connection_string = new c_base_database_connection_string();
}
- return $this->connection_string;
+ return clone($this->connection_string);
}
/**
*/
public function set_persistent($persistent) {
if (!is_bool($persistent)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'persistent', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'persistent', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_asynchronous($asynchronous) {
if (!is_bool($asynchronous)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'asynchronous', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'asynchronous', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function do_connect($force = FALSE) {
if (!is_bool($force)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'force', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'force', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (is_null($this->connection_string)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'connection_string', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'connection_string', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (is_resource($this->database)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'database', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_UNECESSARY);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'database', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_UNECESSARY);
return c_base_return_error::s_true($error);
}
}
unset($warnings);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $this->connection_string->get_database()->get_value_exact(), ':failure_reasons' => $failure_reasons, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_CONNECTION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $this->connection_string->get_database()->get_value_exact(), ':{failure_reasons}' => $failure_reasons, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_CONNECTION_FAILURE);
unset($failure_reasons);
return c_base_return_error::s_false($error);
*/
public function do_disconnect() {
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
return new c_base_return_true();
}
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_close', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_close', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function do_flush() {
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
}
if ($result === FALSE) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_flush', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_flush', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function is_busy() {
if (!$this->asynchronous) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->asynchronous', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->asynchronous', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
*/
public function get_parameter_status($name) {
if (!is_string($name) || empty($name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$result = pg_parameter_status($this->database, $name);
if ($result === FALSE) {
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_parameter_status', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_parameter_status', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function do_poll() {
if (!$this->asynchronous) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->database', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->database', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
*/
public function do_reset() {
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
return new c_base_return_true();
}
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_connection_reset', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_connection_reset', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function do_ping() {
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
return new c_base_return_false();
}
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::FUNCTION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::FUNCTION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function escape_literal($literal) {
if (!is_string($literal)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'literal', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'literal', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
*/
public function escape_bytea($bytea) {
if (!is_string($bytea)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'bytea', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'bytea', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
*/
public function escape_identifier($identifier) {
if (!is_string($identifier)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'identifier', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'identifier', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
*/
public function unescape_bytea($bytea) {
if (!is_string($bytea)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'bytea', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'bytea', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
*/
public function set_client_encoding($encoding) {
if (!is_string($encoding)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'encoding', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'encoding', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
return new c_base_return_true();
}
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_set_client_encoding', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_set_client_encoding', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function get_client_encoding() {
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
if ($encoding === FALSE) {
unset($encoding);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_client_encoding', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_client_encoding', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function consume_input() {
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
return new c_base_return_true();
}
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_consume_input', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_consume_input', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function do_convert($table, $array, $options = 0) {
if (!is_string($table) || empty($table)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'table', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'table', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_array($array)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'array', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'array', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($options)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'options', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'options', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
$converted = pg_connect_status($this->database, $table, $array, $options);
if ($converted === FALSE) {
unset($converted);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_connect_status', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_connect_status', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function do_execute($name, $parameters = array()) {
if (!is_string($name) || empty($name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_array($parameters)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'parameters', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'parameters', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
}
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => ($this->asynchronous ? 'pg_send_execute' : 'pg_execute'), ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => ($this->asynchronous ? 'pg_send_execute' : 'pg_execute'), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
* Any bytea field must not be used as a parameter.
* Instead, use pg_escape_bytea() or a large object function.
*
- * @return c_base_database_result|c_base_return_status
- * Query resource is returned on success, FALSE otherwise.
+ * @return c_base_database_result
+ * Query resource is returned on success.
+ * Query resource with the error bit set is returned on error.
*
* @see: self::execute()
* @see: self::prepare()
*/
public function do_query($query, $parameters = array()) {
if (!is_string($query) || empty($query)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'query', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'query', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+
+ $result = new c_base_database_result();
+ $result->set_error($error);
+ unset($error);
+
+ return $result;
}
if (!is_array($parameters)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'parameters', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'parameters', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+
+ $result = new c_base_database_result();
+ $result->set_error($error);
+ unset($error);
+
+ return $result;
}
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
- unset($database);
- return c_base_return_error::s_false($error);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+
+ $result = new c_base_database_result();
+ $result->set_error($error);
+ unset($error);
+
+ return $result;
}
if ($this->asynchronous) {
if ($this->asynchronous) {
if (empty($parameters)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_send_query', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_send_query', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
}
else {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_send_query_params', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_send_query_params', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
}
}
else {
if (empty($parameters)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_query', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_query', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
}
else {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_query_params', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_query_params', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
}
}
- return c_base_return_error::s_false($error);
+ $result = new c_base_database_result();
+ $result->set_error($error);
+ unset($error);
+
+ return $result;
}
/**
* @param string $query
* The query statement to execute.
*
- * @return c_base_database_result|c_base_return_status
- * Query resource is returned on success, FALSE otherwise.
+ * @return c_base_database_result
+ * Query resource is returned on success.
+ * Query resource with error bit set is returned on error.
*
* @see: self::execute()
* @see: self::query()
*/
public function do_prepare($name, $query) {
if (!is_string($name) || empty($name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+
+ $result = new c_base_database_result();
+ $result->set_error($error);
+ unset($error);
+
+ return $result;
}
if (!is_string($query) || empty($query)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'query', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'query', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+
+ $result = new c_base_database_result();
+ $result->set_error($error);
+ unset($error);
+
+ return $result;
}
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
- return c_base_return_error::s_false($error);
+
+ $result = new c_base_database_result();
+ $result->set_error($error);
+ unset($error);
+
+ return $result;
}
if ($this->asynchronous) {
}
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => ($this->asynchronous ? 'pg_send_prepare' :'pg_prepare'), ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
- return c_base_return_error::s_false($error);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => ($this->asynchronous ? 'pg_send_prepare' :'pg_prepare'), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+
+ $result = new c_base_database_result();
+ $result->set_error($error);
+ unset($error);
+
+ return $result;
}
/**
*
* This is only useful when a query is asynchronous.
*
- * @return c_base_database_result|c_base_return_status
+ * @return c_base_database_result
* A database result is returned on success.
- * FALSE with the error bit set is returned on error.
- * When asynchronous is not enabled, FALSE is returned without an error flag set.
+ * A database result with the error bit set is returned on error.
*/
public function get_result() {
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
- return c_base_return_error::s_false($error);
+
+ $result = new c_base_database_result();
+ $result->set_error($error);
+ unset($error);
+
+ return $result;
}
if (!$this->asynchronous) {
- return new c_base_return_false();
+ return new c_base_database_result();
}
$result = pg_get_result($this->database);
}
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_get_result', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
- return c_base_return_error::s_false($error);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_get_result', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+
+ $result = new c_base_database_result();
+ $result->set_error($error);
+ unset($error);
+
+ return $result;
}
/**
*/
public function do_cancel() {
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
return new c_base_return_true();
}
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_cancel_query', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_cancel_query', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function do_insert($table, $values, $options = NULL) {
if (!is_string($table) || empty($table)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'table', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'table', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_array($values)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'values', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'values', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($options) && !is_int($options)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'options', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'options', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
}
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_insert', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_insert', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
function do_update($table, $values, $conditions, $options = NULL) {
if (!is_string($table) || empty($table)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'table', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'table', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_array($values)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'values', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'values', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_array($conditions)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'conditions', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'conditions', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($options) && !is_int($options)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'options', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'options', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
}
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_update', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_update', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
function do_select($table, $conditions, $options = NULL) {
if (!is_string($table) || empty($table)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'table', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'table', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_array($conditions)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'conditions', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'conditions', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($options) && !is_int($options)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'options', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'options', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
}
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_select', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_select', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
function do_delete($table, $conditions, $options = NULL) {
if (!is_string($table) || empty($table)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'table', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'table', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_array($conditions)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'conditions', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'conditions', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($options) && !is_int($options)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'options', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'options', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
}
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_select', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_select', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function get_meta_data($table, $extended = FALSE) {
if (!is_string($table) || empty($table)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'table', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'table', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($extended)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'extended', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'extended', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
if ($result === FALSE) {
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_meta_data', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_meta_data', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function set_error_verbosity($verbosity) {
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
if (!is_int($verbosity)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'verbosity', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'verbosity', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function get_last_error() {
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
if ($result === FALSE) {
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_last_error', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_last_error', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function get_last_notice() {
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
if ($result === FALSE) {
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_last_notice', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_last_notice', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function get_transaction_status() {
if (!is_resource($this->database)) {
- $database = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
+ $database = ($this->connection_string instanceof c_base_database_connection_string) ? $this->connection_string->get_database()->get_value_exact() : '';
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_name}' => $database, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
unset($database);
return c_base_return_error::s_false($error);
}
if ($result === FALSE) {
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_transaction_status', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_transaction_status', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function fetch_all_columns($column) {
if (!is_resource($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
return c_base_return_error::s_false($error);
}
if (!is_int($column) || $column < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'column', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'column', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$result = pg_fetch_all_columns($this->value, $column);
if ($result === FALSE) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_fetch_all_columns', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_fetch_all_columns', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function fetch_all() {
if (!is_resource($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
return c_base_return_error::s_false($error);
}
$result = pg_fetch_all($this->value);
if ($result === FALSE) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_fetch_all', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_fetch_all', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function fetch_array($row = NULL, $type = PGSQL_ASSOC) {
if (!is_resource($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
return c_base_return_error::s_false($error);
}
if (!is_null($row) && (!is_int($row) || $row < 0)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'row', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'row', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($type)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$result = pg_fetch_array($this->value, $row, $type);
if ($result === FALSE) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_fetch_array', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_fetch_array', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function fetch_object($row = NULL, $class = NULL, $parameters = NULL) {
if (!is_resource($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
return c_base_return_error::s_false($error);
}
if (!is_null($row) && (!is_int($row) || $row < 0)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'row', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'row', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($class) && !is_string($class)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'class', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'class', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($parameters) && !is_array($parameters)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'parameters', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'parameters', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
if ($result === FALSE) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_fetch_object', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_fetch_object', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function fetch_result($row, $column) {
if (!is_resource($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
return c_base_return_error::s_false($error);
}
if (!is_null($row) && (!is_int($row) || $row < 0)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'row', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'row', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($column) && !is_string($column) || is_int($column) && $column < 0 || is_string($column) && empty($column)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'column', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'column', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
- if (!is_null($row)) {
- $result = pg_fetch_result($this->value, $row, $column);
+ if (is_null($row)) {
+ $result = pg_fetch_result($this->value, $column);
}
else {
- $result = pg_fetch_result($this->value, $column);
+ $result = pg_fetch_result($this->value, $row, $column);
}
if ($result === FALSE) {
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_fetch_result', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_fetch_result', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function fetch_row($row = NULL) {
if (!is_resource($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
return c_base_return_error::s_false($error);
}
if (!is_null($row) && (!is_int($row) || $row < 0)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'row', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'row', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
- $result = pg_fetch_row($this->value, $row);
+ if (is_null($row)) {
+ $result = pg_fetch_row($this->value);
+ }
+ else {
+ $result = pg_fetch_row($this->value, $row);
+ }
+
if ($result === FALSE) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_fetch_row', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_fetch_row', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function error($code = NULL) {
if (!is_resource($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
return c_base_return_error::s_false($error);
}
if (!is_null($code) && !is_int($code)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'code', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'code', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function affected_rows() {
if (!is_resource($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
return c_base_return_error::s_false($error);
}
*/
public function number_of_rows() {
if (!is_resource($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
return c_base_return_error::s_false($error);
}
$result = pg_num_rows($this->value);
if ($result < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_num_rows', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_num_rows', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function number_of_columns() {
if (!is_resource($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
return c_base_return_error::s_false($error);
}
$result = pg_num_fields($this->value);
if ($result < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_num_fields', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_num_fields', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function field_name($number) {
if (!is_resource($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
return c_base_return_error::s_false($error);
}
if (!is_int($number) || $number < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'number', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'number', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$result = pg_field_name($this->value, $number);
if ($result === FALSE) {
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_field_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_field_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function field_number($name) {
if (!is_resource($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
return c_base_return_error::s_false($error);
}
if (!is_string($name) || mb_strlen($name) == 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$result = pg_field_number($this->value, $name);
if ($result < 0) {
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_field_number', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_field_number', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function field_length($row, $name_or_number) {
if (!is_resource($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
return c_base_return_error::s_false($error);
}
if (!is_null($row) && (!is_int($row) || $row < 0)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'row', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'row', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($name_or_number) && !(is_string($name_or_number) && mb_strlen($name) > 0)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'name_or_number', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'name_or_number', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($result === FALSE) {
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_field_prtlen', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_field_prtlen', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function field_bytes($column) {
if (!is_resource($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
return c_base_return_error::s_false($error);
}
if (!is_int($column) || $column < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'column', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'column', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$result = pg_size($this->value, $column);
if ($result === FALSE) {
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_size', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_size', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function field_table($column, $oid = FALSE) {
if (!is_resource($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
return c_base_return_error::s_false($error);
}
if (!is_int($column) || $column < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'column', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'column', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($oid)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'oid', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'oid', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$result = pg_field_table($this->value, $column, $oid);
if ($result === FALSE) {
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_field_table', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_field_table', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function field_type_oid($column) {
if (!is_resource($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
return c_base_return_error::s_false($error);
}
if (!is_int($column) || $column < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'column', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'column', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$result = pg_field_type_oid($this->value, $column);
if ($result === FALSE) {
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_field_type_oid', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_field_type_oid', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function last_oid() {
if (!is_resource($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
return c_base_return_error::s_false($error);
}
$result = pg_last_oid($this->database);
if ($result === FALSE) {
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_last_oid', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_last_oid', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function field_type($column) {
if (!is_resource($this->value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_RESOURCE);
return c_base_return_error::s_false($error);
}
if (!is_int($column) || $column < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'column', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'column', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$result = pg_field_type($this->value, $column);
if ($result === FALSE) {
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'pg_field_type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'pg_field_type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
return new c_base_return_true();
}
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::FUNCTION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::FUNCTION_FAILURE);
return c_base_return_error::s_false($error);
}
}
*/
public function import($import) {
if (!is_string($import) || empty($import)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'import', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'import', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$decoded = json_decode($import, TRUE);
if (!is_array($decoded) || empty($decoded)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'json_decode', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'json_decode', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
// everything else has to be re-created on import for security reasons.
$encoded = json_encode($this->value);
if (!is_string($encoded)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'json_encode', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'json_encode', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
* @file
* Provides a class for performing debugging.
*/
-
-// include required files.
require_once('common/base/classes/base_error.php');
require_once('common/base/classes/base_return.php');
* A generic class for performing debugging.
*/
class c_base_debug extends c_base_return {
- private static $s_debugging = FALSE;
+ protected static $s_debugging = FALSE;
- private $time_start;
- private $time_stop;
+ protected $time_start;
+ protected $time_stop;
- private $memory_usage_start;
- private $memory_usage_stop;
- private $memory_usage_peak;
- private $memory_allocated_start;
- private $memory_allocated_stop;
- private $memory_allocated_peak;
+ protected $memory_usage_start;
+ protected $memory_usage_stop;
+ protected $memory_usage_peak;
+ protected $memory_allocated_start;
+ protected $memory_allocated_stop;
+ protected $memory_allocated_peak;
/**
*/
public static function s_set_debugging($debug) {
if (!is_bool($debug)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'debug', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'debug', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
if (!is_bool($milliseconds)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'milliseconds', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'milliseconds', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (is_null($this->time_start) || is_null($this->time_stop)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->time_stop', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->time_stop', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
}
if (!is_int($option) || $option < 1 || $option > 3) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'option', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'option', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($megabytes)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'megabytes', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'megabytes', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($option == 1) {
if (is_null($this->memory_usage_peak)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->memory_usage_peak', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->memory_usage_peak', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
}
elseif ($option == 2) {
if (is_null($this->time_stop)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->time_stop', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->time_stop', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
}
else {
if (is_null($this->time_start)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->time_start', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->time_start', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
if (is_null($this->time_stop)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->time_stop', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->time_stop', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
const ERROR_BACKTRACE_ARGUMENTS = FALSE;
// provide a language to fallback to if none is set.
- const LANGUAGE_CLASS_DEFAULT = 'c_base_language_us_only';
+ const LANGUAGE_CLASS_DEFAULT = 'c_base_languages_us_only';
// reserved path groups: array(97, 99, 100, 102, 109, 115, 116, 120, 121).
const RESERVED_PATH_GROUP = array(c_base_ascii::LOWER_A, c_base_ascii::LOWER_C, c_base_ascii::LOWER_D, c_base_ascii::LOWER_F, c_base_ascii::LOWER_M, c_base_ascii::LOWER_S, c_base_ascii::LOWER_T, c_base_ascii::LOWER_U, c_base_ascii::LOWER_X);
private static $s_timezone = NULL;
// Represents the default language class in use.
- // This must be a class that implements: i_base_language.
+ // This must be a class that implements: i_base_languages.
// In most cases, this should be expected to be defined.
private static $s_languages = NULL;
* FALSE with error bit set is returned on error.
*/
public static function s_set_timezone($timezone) {
- if (!($timezone instanceof i_base_language)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'timezone', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ if (!($timezone instanceof i_base_languages)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'timezone', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
/**
* Set the default language.
*
- * @param i_base_language $languages
- * Must be a class that implements i_base_language.
+ * @param i_base_languages $languages
+ * Must be a class that implements i_base_languages.
*
* @return c_base_return_status
* TRUE on success.
* FALSE with error bit set is returned on error.
*
- * @see: i_base_language()
+ * @see: i_base_languages()
*/
public static function s_set_languages($languages) {
- if (!($languages instanceof i_base_language)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'languages', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ if (!($languages instanceof i_base_languages)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'languages', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public static function s_get_date($string, $timestamp = NULL) {
if (!is_string($string)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'string', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'string', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
if (!is_null($timestamp) && !is_float($timestamp) && !is_int($timestamp)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'timestamp', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'timestamp', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
unset($microseconds);
if (!($date instanceof DateTime)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'date', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'date', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
$formatted = $date->format($string);
if (!is_string($formatted)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'date->format', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'date->format', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
*/
public static function s_get_timestamp($string, $timestamp = NULL) {
if (!is_string($string)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'string', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'string', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(0.0, 'c_base_return_float', $error);
}
if (!is_null($timestamp) && !is_float($timestamp) && !is_int($timestamp)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'timestamp', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'timestamp', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(0.0, 'c_base_return_float', $error);
}
$now = self::s_get_timestamp_session()->get_value_exact();
$microseconds = (int) (($now - ((int) $now)) * 1000000);
- $date = new date('Y/m/d h:i:s', (int) $now) . '.' . $microseconds . date(' P', (int) $now);
+ $date = new DateTime(date('Y/m/d h:i:s', (int) $now) . '.' . $microseconds . date(' P', (int) $now));
unset($now);
}
else {
unset($microseconds);
if (!($date instanceof DateTime)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'date', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'date', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_value(0.0, 'c_base_return_float', $error);
}
$resulting_timestamp = $date->getTimestamp();
if (!is_int($resulting_timestamp)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'date->get_timestamp', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'date->get_timestamp', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_value(0.0, 'c_base_return_float', $error);
}
/**
* Get the currently assigned language class.
*
- * @return i_base_language
- * A class that implements i_base_language.
+ * @return i_base_languages
+ * A class that implements i_base_languages.
*
- * @see: i_base_language
+ * @see: i_base_languages
*/
public static function s_get_languages() {
if (is_null(self::$s_languages)) {
* @return string
* A string representing the class of the language.
*
- * @see: i_base_language
+ * @see: i_base_languages
*/
public static function s_get_languages_class() {
if (is_null(self::$s_languages)) {
* @file
* Provides a class for managing e-mail related functionality.
*/
-
-// include required files.
require_once('common/base/classes/base_error.php');
require_once('common/base/classes/base_return.php');
require_once('common/base/classes/base_ascii.php');
-require_once('common/base/classes/base_utf8.php');
require_once('common/base/classes/base_rfc_string.php');
/**
const POSTGRESQL_CONNECTION_FAILURE = 14;
const POSTGRESQL_NO_CONNECTION = 15;
const POSTGRESQL_NO_RESOURCE = 16;
- const SOCKET_FAILURE = 17;
- const ACCESS_DENIED = 18;
- const ACCESS_DENIED_UNAVAILABLE = 19;
- const ACCESS_DENIED_USER = 20;
- const ACCESS_DENIED_ADMINISTRATION = 21;
+ const POSTGRESQL_ERROR = 17;
+ const SOCKET_FAILURE = 18;
+ const ACCESS_DENIED = 19;
+ const ACCESS_DENIED_UNAVAILABLE = 20;
+ const ACCESS_DENIED_USER = 21;
+ const ACCESS_DENIED_ADMINISTRATION = 22;
/**
* @param bool $arguments
* (optional) When TRUE, argument placeholders are added.
* When FALSE, no placeholders are provided.
- * All placeholders should begin with a single colon ':'.
+ * All placeholders should begin with a single colon ':' and be wrapped within '{}', such that 'example' placeholder is ':{example}'.
* @param bool $function_name
* (optional) When TRUE, the function name is included with the message.
* When FALSE, no funciton name is provided.
static function s_get_message($code, $arguments = TRUE, $function_name = FALSE) {
$function_name_string = NULL;
if ($function_name) {
- $function_name_string = ' while calling :function_name';
+ $function_name_string = ' while calling :{function_name}';
}
if ($code === self::INVALID_ARGUMENT) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('An invalid argument, :argument_name, has been specified' . $function_name_string . '.');
+ return c_base_return_string::s_new('An invalid argument, :{argument_name}, has been specified' . $function_name_string . '.');
}
else {
return c_base_return_string::s_new('An invalid argument has been specified' . $function_name_string . '.');
}
elseif ($code === self::INVALID_FORMAT) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The argument, :format_name, has an invalid format' . $function_name_string . '.:expected_format');
+ return c_base_return_string::s_new('The argument, :{format_name}, has an invalid format' . $function_name_string . '.:{expected_format}');
}
else {
return c_base_return_string::s_new('An invalid format has been specified.');
}
elseif ($code === self::INVALID_VARIABLE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The variable, :variable_name, is invalid' . $function_name_string . '.');
+ return c_base_return_string::s_new('The variable, :{variable_name}, is invalid' . $function_name_string . '.');
}
else {
return c_base_return_string::s_new('An invalid variable has been specified.');
}
elseif ($code === self::OPERATION_FAILURE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('Failed to perform operation, :operation_name' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
+ return c_base_return_string::s_new('Failed to perform operation, :{operation_name}' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
}
else {
return c_base_return_string::s_new('Failed to perform operation.');
}
elseif ($code === self::OPERATION_UNECESSARY) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('Did not perform unnecessary operation, :operation_name' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
+ return c_base_return_string::s_new('Did not perform unnecessary operation, :{operation_name}' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
}
else {
return c_base_return_string::s_new('Did not perform unnecessary operation.');
}
elseif ($code === self::FUNCTION_FAILURE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The function, :function_name, has failed execution.');
+ return c_base_return_string::s_new('The function, :{function_name}, has failed execution.');
}
else {
return c_base_return_string::s_new('A function has failed execution.');
}
elseif ($code === self::NOT_FOUND_ARRAY_INDEX) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The index, :index_name, was not found in the array, :array_name' . $function_name_string . '.');
+ return c_base_return_string::s_new('The index, :index_name, was not found in the array, :{array_name}' . $function_name_string . '.');
}
else {
return c_base_return_string::s_new('Failed to find index within specified array.');
}
elseif ($code === self::NOT_FOUND_FILE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The file, :file_name, was not found or cannot be accessed' . $function_name_string . '.');
+ return c_base_return_string::s_new('The file, :{file_name}, was not found or cannot be accessed' . $function_name_string . '.');
}
else {
return c_base_return_string::s_new('File not found or cannot be accessed.');
}
elseif ($code === self::NOT_FOUND_DIRECTORY) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The directory, :directory_name, was not found or cannot be accessed' . $function_name_string . '.');
+ return c_base_return_string::s_new('The directory, :{directory_name}, was not found or cannot be accessed' . $function_name_string . '.');
}
else {
return c_base_return_string::s_new('File not found or cannot be accessed.');
}
elseif ($code === self::NO_CONNECTION) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The resource, :resource_name, is not connected' . $function_name_string . '.');
+ return c_base_return_string::s_new('The resource, :{resource_name}, is not connected' . $function_name_string . '.');
}
else {
return c_base_return_string::s_new('The resource is not connected.');
}
elseif ($code === self::NO_SUPPORT) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The functionality, :functionality_name, is currently not supported.' . $function_name_string . '.');
+ return c_base_return_string::s_new('The functionality, :{functionality_name}, is currently not supported.' . $function_name_string . '.');
}
else {
return c_base_return_string::s_new('The requested functionality is not supported.');
}
elseif ($code === self::POSTGRESQL_CONNECTION_FAILURE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('Failed to connect to the database, :database_name, reasons: :failure_reasons' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
+ return c_base_return_string::s_new('Failed to connect to the database, :{database_name}, reasons: :{failure_reasons}' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
}
else {
return c_base_return_string::s_new('Failed to connect to the database.');
}
elseif ($code === self::POSTGRESQL_NO_CONNECTION) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The database, :database_name, is not connected' . $function_name_string . '.');
+ return c_base_return_string::s_new('The database, :{database_name}, is not connected' . $function_name_string . '.');
}
else {
return c_base_return_string::s_new('The database is not connected.');
return c_base_return_string::s_new('No database resource is available.');
}
}
+ elseif ($code === self::POSTGRESQL_ERROR) {
+ if ($arguments === TRUE) {
+ return c_base_return_string::s_new('Database query error: :{database_error_message}' . $function_name_string . '.');
+ }
+ else {
+ return c_base_return_string::s_new('Failed to perform database query.');
+ }
+ }
elseif ($code === self::SOCKET_FAILURE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('Failed to perform socket operation, :operation_name, socket error (:socket_error) \':socket_error_message\'' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
+ return c_base_return_string::s_new('Failed to perform socket operation, :{operation_name}, socket error (:{socket_error}) \':{socket_error_message}\'' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
}
else {
return c_base_return_string::s_new('Failed to perform socket operation.');
}
elseif ($code === self::ACCESS_DENIED) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('Access is denied, :operation_name' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
+ return c_base_return_string::s_new('Access is denied, :{operation_name}' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
}
else {
return c_base_return_string::s_new('Access is denied.');
}
elseif ($code === self::ACCESS_DENIED_UNAVAILABLE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('Access is denied due to unavailability, :operation_name ' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
+ return c_base_return_string::s_new('Access is denied due to unavailability, :{operation_name} ' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
}
else {
return c_base_return_string::s_new('Access is denied due to unavailability.');
}
elseif ($code === self::ACCESS_DENIED_USER) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('Access is denied for user :name_machine_user (:id_user), :operation_name ' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
+ return c_base_return_string::s_new('Access is denied for user :name_machine_user (:{id_user}), :{operation_name} ' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
}
else {
return c_base_return_string::s_new('Access is denied for user.');
}
elseif ($code === self::ACCESS_DENIED_ADMINISTRATION) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('Access is denied for administrative reasons, :operation_name ' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
+ return c_base_return_string::s_new('Access is denied for administrative reasons, :{operation_name} ' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
}
else {
return c_base_return_string::s_new('Access is denied for administrative reasons.');
static function s_get_message($code, $arguments = TRUE, $function_name = FALSE) {
$function_name_string = NULL;
if ($function_name) {
- $function_name_string = ' :function_name を呼び出している間';
+ $function_name_string = ' :{function_name} を呼び出している間';
}
if ($code === self::INVALID_ARGUMENT) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('無効な引数 :argument_name が指定されています' . $function_name_string . '。');
+ return c_base_return_string::s_new('無効な引数 :{argument_name} が指定されています' . $function_name_string . '。');
}
else {
return c_base_return_string::s_new('無効な引数が指定されています' . $function_name_string . '。');
}
elseif ($code === self::INVALID_FORMAT) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('引数 :format_name の形式が無効です' . $function_name_string . '。:expected_format');
+ return c_base_return_string::s_new('引数 :{format_name} の形式が無効です' . $function_name_string . '。:{expected_format}');
}
else {
return c_base_return_string::s_new('無効な形式が指定されています。');
}
elseif ($code === self::INVALID_VARIABLE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('変数 :variable_name は無効です' . $function_name_string . '。');
+ return c_base_return_string::s_new('変数 :{variable_name} は無効です' . $function_name_string . '。');
}
else {
return c_base_return_string::s_new('無効な変数が指定されています。');
}
elseif ($code === self::OPERATION_FAILURE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('操作の実行に失敗しました :operation_name' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('操作の実行に失敗しました :{operation_name}' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
}
else {
return c_base_return_string::s_new('操作を実行できませんでした。');
}
elseif ($code === self::OPERATION_UNECESSARY) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('不要な操作を実行しませんでした :operation_name' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('不要な操作を実行しませんでした :{operation_name}' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
}
else {
return c_base_return_string::s_new('不要な操作を実行しませんでした。');
}
elseif ($code === self::FUNCTION_FAILURE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('関数 :function_name は実行に失敗しました。');
+ return c_base_return_string::s_new('関数 :{function_name} は実行に失敗しました。');
}
else {
return c_base_return_string::s_new('関数の実行に失敗しました。');
}
elseif ($code === self::NOT_FOUND_ARRAY_INDEX) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('配列 :index_name に索引 :array_name が見つかりませんでした。' . $function_name_string . '。');
+ return c_base_return_string::s_new('配列 :index_name に索引 :{array_name} が見つかりませんでした。' . $function_name_string . '。');
}
else {
return c_base_return_string::s_new('指定された配列内のインデックスの検索に失敗しました。');
}
elseif ($code === self::NOT_FOUND_FILE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('ファイル :file_name が見つかりませんでした、またはアクセスできません' . $function_name_string . '。');
+ return c_base_return_string::s_new('ファイル :{file_name} が見つかりませんでした、またはアクセスできません' . $function_name_string . '。');
}
else {
return c_base_return_string::s_new('ファイルが見つからないか、アクセスできません。');
}
elseif ($code === self::NOT_FOUND_DIRECTORY) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('ディレクトリ :directory_name が見つかりませんでした、またはアクセスできません' . $function_name_string . '。');
+ return c_base_return_string::s_new('ディレクトリ :{directory_name} が見つかりませんでした、またはアクセスできません' . $function_name_string . '。');
}
else {
return c_base_return_string::s_new('ファイルが見つからないか、アクセスできません。');
}
elseif ($code === self::NO_CONNECTION) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('リソース :resource_name は接続されていません' . $function_name_string . '。');
+ return c_base_return_string::s_new('リソース :{resource_name} は接続されていません' . $function_name_string . '。');
}
else {
return c_base_return_string::s_new('リソースが接続されていません。');
}
elseif ($code === self::NO_SUPPORT) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('機能 :functionality_name は現在サポートされていません。' . $function_name_string . '。');
+ return c_base_return_string::s_new('機能 :{functionality_name} は現在サポートされていません。' . $function_name_string . '。');
}
else {
return c_base_return_string::s_new('要求された機能はサポートされていません。');
}
elseif ($code === self::POSTGRESQL_CONNECTION_FAILURE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('データベースへの接続に失敗しました。 :database_name' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('データベースへの接続に失敗しました。 :{database_name}' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
}
else {
return c_base_return_string::s_new('データベースに接続できませんでした。');
}
elseif ($code === self::POSTGRESQL_NO_CONNECTION) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('データベース :database_name は接続されていません' . $function_name_string . '。');
+ return c_base_return_string::s_new('データベース :{database_name} は接続されていません' . $function_name_string . '。');
}
else {
return c_base_return_string::s_new('データベースが接続されていません。');
}
elseif ($code === self::SOCKET_FAILURE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('ソケット操作の実行に失敗しました。 :operation_name 、ソケットエラー(:socket_error) \':socket_error_message\'' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('ソケット操作の実行に失敗しました。 :{operation_name} 、ソケットエラー(:{socket_error} \':{socket_error_message}\'' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
}
else {
return c_base_return_string::s_new('ソケット操作を実行できませんでした。');
}
elseif ($code === self::ACCESS_DENIED) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('アクセスが拒否されました。 :operation_name' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('アクセスが拒否されました。 :{operation_name}' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
}
else {
return c_base_return_string::s_new('アクセスは拒否されました。');
}
elseif ($code === self::ACCESS_DENIED_UNAVAILABLE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('利用できないためアクセスが拒否されましたが、 :operation_name ' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('利用できないためアクセスが拒否されましたが、 :{operation_name} ' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
}
else {
return c_base_return_string::s_new('利用できないためアクセスが拒否されました。');
}
elseif ($code === self::ACCESS_DENIED_USER) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('ユーザーのアクセスが拒否されました :name_machine_user (:id_user), :operation_name ' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('ユーザーのアクセスが拒否されました :name_machine_user (:{id_user}), :{operation_name} ' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
}
else {
return c_base_return_string::s_new('ユーザーのアクセスが拒否されました。');
}
elseif ($code === self::ACCESS_DENIED_ADMINISTRATION) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('管理上の理由でアクセスが拒否されました, :operation_name ' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('管理上の理由でアクセスが拒否されました, :{operation_name} ' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
}
else {
return c_base_return_string::s_new('管理上の理由からアクセスが拒否されました。');
* @file
* Provides a class for managing forms.
*/
-
-// include required files.
require_once('common/base/classes/base_error.php');
require_once('common/base/classes/base_return.php');
-
/**
* A class for form problems.
*
* @todo: come up with a list of problem codes and add a problem id variable.
*/
class c_base_form_problem extends c_base_return_string {
- private $fields;
- private $arguments;
+ protected $fields;
+ protected $arguments;
/**
}
if (!is_string($field_name) || empty($field_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'field_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'field_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function unset_field($field_name) {
if (!is_string($field_name) && !empty($field_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'field_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'field_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_argument($index, $value) {
if (!is_string($index) && !empty($index)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'index', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'index', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_string($value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'value', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function get_argument($index) {
if (!is_string($index) && !empty($index)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'index', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'index', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*
* @see: https://www.w3.org/TR/html5/
*/
-
-// include required files.
require_once('common/base/classes/base_error.php');
require_once('common/base/classes/base_return.php');
require_once('common/base/classes/base_markup.php');
* @todo: add support for non-standard tag attributes, which will just be a string or NULL.
*/
class c_base_html extends c_base_return {
- private $id;
- private $attributes;
- private $attributes_body;
- private $type;
- private $method;
- private $headers;
- private $body;
+ protected $id;
+ protected $attributes;
+ protected $attributes_body;
+ protected $type;
+ protected $method;
+ protected $headers;
+ protected $body;
/**
* Class constructor.
*/
public static function sanitize_css($text, $partial = FALSE) {
if (!is_string($text)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
if (!is_bool($partial)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'partial', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'partial', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
}
unset($sanitized);
- $error = c_base_error::s_log(' ' . $response['error']['message'], array('arguments' => array(':operation_name' => 'preg_replace', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(' ' . $response['error']['message'], array('arguments' => array(':{operation_name}' => 'preg_replace', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
*/
public function set_id($id) {
if (!is_int($id)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'id', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_attribute($attribute, $value) {
if (!is_int($attribute)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'attribute', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'attribute', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_attribute_body($attribute, $value) {
if (!is_int($attribute)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'attribute', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'attribute', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function get_attribute($attribute) {
if (!is_int($attribute)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'attribute', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'attribute', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function get_attribute_body($attribute) {
if (!is_int($attribute)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'attribute', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'attribute', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_tag($tag, $delta = NULL) {
if (!($tag instanceof c_base_markup_tag)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'tag', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'tag', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($delta) && !is_int($delta)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'delta', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'delta', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function get_tag($delta) {
if (!is_int($delta)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'delta', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'delta', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
* (optional) A position in the page to assign the header.
* If NULL, then the header is appended.
*
- * @return c_base_return_status
- * TRUE on success, FALSE otherwise.
+ * @return c_base_return_int|c_base_return_status
+ * An integer representing the delta of where the header was added.
* FALSE with error bit set is returned on error.
*/
public function set_header($header, $delta = NULL) {
if (!($header instanceof c_base_markup_tag)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'header', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'header', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($delta) && !is_int($delta)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'delta', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'delta', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
if (is_null($delta)) {
+ $at = count($this->headers);
$this->headers[] = $header;
}
else {
+ $at = $delta;
$this->headers[$delta] = $header;
}
- return new c_base_return_true();
+
+ return c_base_return_int::s_new($at);
}
/**
*/
public function get_header($delta) {
if (!is_int($delta)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'delta', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'delta', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
* @file
* Provides a class for managing the HTTP protocol.
*/
-
-// include required files.
require_once('common/base/classes/base_error.php');
require_once('common/base/classes/base_return.php');
require_once('common/base/classes/base_charset.php');
require_once('common/base/classes/base_rfc_string.php');
require_once('common/base/classes/base_utf8.php');
-require_once('common/base/classes/base_email.php');
require_once('common/base/classes/base_languages.php');
require_once('common/base/classes/base_http_status.php');
require_once('common/base/classes/base_cookie.php');
// fallbacks/failsafes
const FALLBACK_PROTOCOL = 'HTTP/1.1';
- private $headers;
- private $headers_sent;
- private $request;
- private $request_time;
- private $response;
+ protected $headers;
+ protected $headers_sent;
+ protected $request;
+ protected $request_time;
+ protected $response;
- private $request_uri_relative;
- private $request_uri_query;
+ protected $request_uri_relative;
+ protected $request_uri_query;
- private $content;
- private $content_is_file;
- private $buffer_enabled;
+ protected $content;
+ protected $content_is_file;
+ protected $buffer_enabled;
- private $languages;
+ protected $languages;
/**
* Class constructor.
*/
public function get_request($header_name = NULL, $delta = NULL) {
if (!is_null($header_name) && !is_int($header_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'header_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'header_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($delta) && !is_int($delta) && !is_string($delta)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'delta', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'delta', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
if (!array_key_exists($header_name, $this->request)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => $header_name, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => $header_name, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_false($error);
}
return c_base_return_value::s_new($this->request[$header_name]['data'][$delta]);
}
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => $delta, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => $delta, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_false($error);
}
*/
public function get_request_uri_relative($base_path, $with_query = FALSE) {
if (!is_string($base_path)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'base_path', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'base_path', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
if (!is_bool($with_query)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'with_query', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'with_query', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
*/
public function get_response($header_name = NULL, $delta = NULL) {
if (!is_null($header_name) && !is_int($header_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'header_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'header_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($delta) && !is_int($delta) && !is_string($delta)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'delta', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'delta', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
if (!array_key_exists($header_name, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => $header_name, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => $header_name, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_false($error);
}
return c_base_return_value::s_new($this->response[$header_name][$delta]);
}
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => $delta, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => $delta, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_false($error);
}
*
* The languages class provides a list of supported languages.
*
- * @param string|i_base_language $class_name
- * A string name representing an object that is a sub-class of i_base_language.
+ * @param string|i_base_languages $class_name
+ * A string name representing an object that is a sub-class of i_base_languages.
* Or a language class object.
*
* @return c_base_return_status
* FALSE with error bit set is returned on error.
*/
public function set_languages($class_name) {
- if (!(is_string($class_name) && is_subclass_of('i_base_language', $class_name)) || !(is_object($class_name) && $class_name instanceof i_base_language)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'class_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ if (!(is_string($class_name) && is_subclass_of('i_base_languages', $class_name)) || !(is_object($class_name) && $class_name instanceof i_base_languages)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'class_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
/**
* Get the language class object currently assigned to this class.
*
- * @return i_base_language
+ * @return i_base_languages
* The language class object.
*/
public function get_languages() {
* Because multiple languages may be returned, this does not explicitly define the langugae headers.
*
* @param array $supported_languages
- * An array of supported languages as defined in i_base_language.
+ * An array of supported languages as defined in i_base_languages.
*
* @return c_base_return_int
- * An integer representing the language code as defined in i_base_language.
+ * An integer representing the language code as defined in i_base_languages.
* 0 with the error bit set is returned on error.
- * An integer representing the language code as defined in i_base_language with the error bit set is returned on error.
+ * An integer representing the language code as defined in i_base_languages with the error bit set is returned on error.
*/
public function select_language($supported_languages) {
if (!is_array($supported_languages) || empty($supported_languages)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'supported_languages', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'supported_languages', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(0, 'c_base_return_int', $error);
}
if (isset($this->request[self::REQUEST_ACCEPT_LANGUAGE]['data']) && is_array($this->request[self::REQUEST_ACCEPT_LANGUAGE]['data'])) {
if (isset($this->request[self::REQUEST_ACCEPT_LANGUAGE]['invalid']) && $this->request[self::REQUEST_ACCEPT_LANGUAGE]['invalid']) {;
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'supported_languages', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'supported_languages', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value($language_chosen, 'c_base_return_int', $error);
}
*/
public function set_response_access_control_allow_origin($uri) {
if (!is_string($uri)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'uri', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'uri', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($text['invalid']) {
unset($text);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->pr_rfc_string_prepare', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->pr_rfc_string_prepare', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
if ($parsed['invalid']) {
unset($parsed);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'uri', ':expected_format' => NULL, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'uri', ':{expected_format}' => NULL, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
unset($parsed['invalid']);
*/
public function set_response_access_control_allow_credentials($allow_credentials) {
if (!is_bool($allow_credentials)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'allowed_credentials', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'allowed_credentials', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_access_control_expose_headers($header_name, $append = TRUE) {
if (!is_string($header_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'header_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'header_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'append', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($prepared_token === FALSE) {
unset($prepared_token);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->p_prepare_token', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->p_prepare_token', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function set_response_access_control_max_age($seconds) {
if (!is_int($seconds) && !is_float($seconds)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'seconds', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'seconds', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_access_control_allow_methods($method, $append = TRUE) {
if (!is_int($method)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'method', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'method', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'append', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
break;
default:
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'method', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'method', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_access_control_allow_headers($header_name, $append = TRUE) {
if (!is_string($header_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'header_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'header_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'append', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($prepared_token === FALSE) {
unset($prepared_token);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->p_prepare_token', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->p_prepare_token', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function set_response_accept_patch($media_type, $append = TRUE) {
if (!is_string($media_type)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'media_type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'media_type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'append', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($text['invalid']) {
unset($text);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->pr_rfc_string_prepare', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->pr_rfc_string_prepare', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
if ($parsed['invalid']) {
unset($parsed);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'media type', ':expected_format' => '1*(tchar) "/" 1*(tchar) *(*(wsp) ";" *(wsp) 1*(1*(tchar) *(wsp) "=" *(wsp) 1*(tchar) / (quoted-string)))', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'media type', ':{expected_format}' => '1*(tchar) "/" 1*(tchar) *(*(wsp) ";" *(wsp) 1*(1*(tchar) *(wsp) "=" *(wsp) 1*(tchar) / (quoted-string)))', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
unset($parsed['invalid']);
*/
public function set_response_accept_ranges($ranges) {
if (!is_string($ranges)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'ranges', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'ranges', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($prepared_token === FALSE) {
unset($prepared_token);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->p_prepare_token', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->p_prepare_token', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function set_response_age($seconds) {
if (!is_int($seconds)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'seconds', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'seconds', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_allow($allow, $append = TRUE) {
if (!is_int($allow)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'allow', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'allow', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'append', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
case self::HTTP_METHOD_DEBUG:
break;
default:
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'allow', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'allow', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_cache_control($directive_name, $directive_value = NULL, $append = TRUE) {
if (!is_int($directive_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'directive_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'directive_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($directive_value) && !is_string($directive_value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'directive_value', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'directive_value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'append', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
break;
default:
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'directive_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'directive_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($text['invalid']) {
unset($text);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->pr_rfc_string_prepare', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->pr_rfc_string_prepare', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
if ($parsed['invalid']) {
unset($parsed);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'directive value', ':expected_format' => '1*(tchar) *("=" 1*(1*(tchar) / quoted-string) *(*(wsp) "," *(wsp) 1*(tchar) *("=" 1*(1*(tchar) / quoted-string))', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'directive value', ':{expected_format}' => '1*(tchar) *("=" 1*(1*(tchar) / quoted-string) *(*(wsp) "," *(wsp) 1*(tchar) *("=" 1*(1*(tchar) / quoted-string))', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
unset($parsed);
*/
public function set_response_connection($connection_option, $append = TRUE) {
if (!is_string($connection_option)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'connection_option', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'connection_option', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'append', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($prepared_token === FALSE) {
unset($prepared_token);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->p_prepare_token', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->p_prepare_token', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function set_response_content($content, $append = TRUE, $is_file = FALSE) {
if (!is_string($content)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'content', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'content', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'append', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($is_file)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'is_file', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'is_file', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_content_disposition($type, $parameter_name = NULL, $parameter_value = NULL, $append = TRUE) {
if (!is_null($type) && !is_string($type)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($parameter_name) && !is_string($parameter_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'parameter_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'parameter_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($parameter_value) && !is_string($parameter_value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'parameter_value', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'parameter_value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'append', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($prepared_token === FALSE) {
unset($prepared_token);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'content disposition type', ':expected_format' => '1*(tchar)', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'content disposition type', ':{expected_format}' => '1*(tchar)', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
if (empty($prepared_token)) {
unset($prepared_token);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
if ($prepared_parameter_name === FALSE) {
unset($prepared_parameter_name);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'content disposition parameter name', ':expected_format' => '1*(tchar)', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'content disposition parameter name', ':{expected_format}' => '1*(tchar)', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
if (empty($prepared_parameter_name)) {
unset($prepared_parameter_name);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'parameter_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'parameter_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
if ($text['invalid']) {
unset($text);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->pr_rfc_string_prepare', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->pr_rfc_string_prepare', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
unset($parsed_parameter_value);
unset($prepared_token);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'disposition parameter value', ':expected_format' => '1*(tchar) / 1*(quoted-string)', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'disposition parameter value', ':{expected_format}' => '1*(tchar) / 1*(quoted-string)', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
unset($parsed_parameter_value['invalid']);
if (is_null($type)) {
unset($prepared_token);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_content_encoding($encoding, $append = TRUE) {
if (!is_int($encoding)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'encoding', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'encoding', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'append', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
case self::ENCODING_PG:
break;
default:
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'encoding', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'encoding', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_content_language($language = NULL, $append = TRUE) {
if (!is_null($language) && !is_int($language)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'language', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'language', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'append', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($default instanceof c_base_return_false) {
unset($default);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->languages->s_get_default_id', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->languages->s_get_default_id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
}
else {
if ($this->languages->s_get_names_by_id($language) instanceof c_base_return_false) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->languages->s_get_names_by_id', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->languages->s_get_names_by_id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function set_response_content_length($length = NULL, $force = FALSE) {
if (!is_null($length) && !is_int($length) || $length < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'length', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'length', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($force)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'force', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'force', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!file_exists($filename)) {
unset($filename);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':file_name' => $filename, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_FILE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{file_name}' => $filename, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_FILE);
return c_base_return_error::s_false($error);
}
*/
public function set_response_content_range($start, $stop, $total) {
if (!is_int($start) && $start !== FALSE) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'start', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'start', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($stop) && $stop !== FALSE) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'stop', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'stop', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($total) && $total !== FALSE) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'total', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'total', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
// unsatisfiable requires a total to be specified.
if (($start === FALSE || $stop === FALSE) && $total === FALSE) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'total', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'total', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$result = c_base_mime::s_get_names_by_id($content_type);
if ($result instanceof c_base_return_false) {
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'content_type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'content_type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
unset($result);
}
elseif (!is_string($content_type)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'content_type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'content_type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
else {
$result = c_base_mime::s_identify($content_type, TRUE);
if ($result instanceof c_base_return_false) {
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'content_type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'content_type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!c_base_charset::s_is_valid($charset)) {
unset($content_type_string);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'charset', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'charset', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
if (!is_int($timestamp) && !is_float($timestamp)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'timestamp', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'timestamp', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
if (!is_int($timestamp) && !is_float($timestamp)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'timestamp', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'timestamp', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_etag($entity_tag = NULL, $weak = FALSE) {
if (!is_null($entity_tag) && !is_string($entity_tag) && $entity_tag !== FALSE) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'entity_tag', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'entity_tag', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
unset($hash);
unset($response);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':file_name' => $filename, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_FILE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{file_name}' => $filename, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_FILE);
return c_base_return_error::s_false($error);
}
unset($hash);
unset($response);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':file_name' => $filename, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_FILE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{file_name}' => $filename, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_FILE);
return c_base_return_error::s_false($error);
}
}
*/
public function set_response_expires($timestamp) {
if (!is_int($timestamp) && !is_float($timestamp)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'timestamp', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'timestamp', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_last_modified($timestamp) {
if (!is_int($timestamp) && !is_float($timestamp)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'timestamp', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'timestamp', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_link($uri, $parameter_name = NULL, $parameter_value = NULL, $append = TRUE) {
if (!is_string($uri)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'uri', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'uri', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($parameter_name) && !is_string($parameter_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'parameter_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'parameter_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($parameter_value) && !is_string($parameter_value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'parameter_value', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'parameter_value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'append', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($text['invalid']) {
unset($text);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->pr_rfc_string_prepare', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->pr_rfc_string_prepare', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
if ($parsed_uri['invalid']) {
unset($parsed_uri);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'link uri', ':expected_format' => '(uri)', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'link uri', ':{expected_format}' => '(uri)', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
unset($parsed_uri['invalid']);
if ($prepared_parameter_name === FALSE) {
unset($prepared_parameter_name);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'link parameter name', ':expected_format' => '1*(tchar)', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'link parameter name', ':{expected_format}' => '1*(tchar)', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
if (empty($prepared_parameter_name)) {
unset($prepared_parameter_name);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'parameter_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'parameter_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
unset($text);
unset($parsed_uri);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->pr_rfc_string_prepare', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->pr_rfc_string_prepare', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
unset($parsed_parameter_value);
unset($prepared_token);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'content disposition parameter value', ':expected_format' => '1*(tchar) / 1*(quoted-string)', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'content disposition parameter value', ':{expected_format}' => '1*(tchar) / 1*(quoted-string)', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
unset($parsed_parameter_value['invalid']);
*/
public function set_response_location($uri) {
if (!is_string($uri) && !is_array($uri)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'uri', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'uri', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
unset($parts);
unset($combined);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'URI or URL', ':expected_format' => 'URI or URL', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'URI or URL', ':{expected_format}' => 'URI or URL', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
unset($combined);
if ($text['invalid']) {
unset($text);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->pr_rfc_string_prepare', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->pr_rfc_string_prepare', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
if ($parsed['invalid']) {
unset($parsed);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'uri', ':expected_format' => NULL, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'uri', ':{expected_format}' => NULL, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
unset($parsed['invalid']);
*/
public function set_response_pragma($parameter_name, $parameter_value = NULL, $append = TRUE) {
if (!is_string($parameter_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'parameter_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'parameter_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($parameter_value) && !is_string($parameter_value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'parameter_value', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'parameter_value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'append', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($prepared_parameter_name === FALSE) {
unset($prepared_parameter_name);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'pragma parameter name', ':expected_format' => '1*(tchar)', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'pragma parameter name', ':{expected_format}' => '1*(tchar)', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
if (empty($prepared_parameter_name)) {
unset($prepared_parameter_name);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'parameter_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'parameter_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
if ($text['invalid']) {
unset($text);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->pr_rfc_string_prepare', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->pr_rfc_string_prepare', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
unset($parsed_parameter_value);
unset($prepared_token);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'pragma parameter value', ':expected_format' => '1*(tchar) / 1*(quoted-string)', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'pragma parameter value', ':{expected_format}' => '1*(tchar) / 1*(quoted-string)', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
unset($parsed_parameter_value['invalid']);
public function set_response_proxy_authenticate($value) {
// @todo: self::RESPONSE_PROXY_AUTHENTICATE
- $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response proxy authenticate', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{functionality_name}' => 'http response proxy authenticate', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
return c_base_return_error::s_false($error);
}
public function set_response_public_key_pins($value) {
// @todo: self::RESPONSE_PUBLIC_KEY_PINS
- $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response public key pins', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{functionality_name}' => 'http response public key pins', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
return c_base_return_error::s_false($error);
}
public function set_response_refresh($value) {
// @todo: self::RESPONSE_REFRESH
- $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response refresh', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{functionality_name}' => 'http response refresh', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_retry_after($date, $seconds = FALSE) {
if (!is_int($date)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'date', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'date', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($seconds)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'seconds', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'seconds', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
public function set_response_server($value) {
// @todo: self::RESPONSE_SERVER
- $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response server', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{functionality_name}' => 'http response server', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_set_cookie($cookie, $append = TRUE) {
if (!($cookie instanceof c_base_cookie)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'cookie', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'cookie', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'append', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_status($code) {
if (!is_int($code)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'code', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'code', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
public function set_response_strict_transport_security($value) {
// @todo: self::RESPONSE_STRICT_SECURITY_TRANSPORT
- $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response strict transport security', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{functionality_name}' => 'http response strict transport security', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
return c_base_return_error::s_false($error);
}
public function set_response_trailer($value) {
// @todo: self::RESPONSE_TRAILER
- $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response trailer', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{functionality_name}' => 'http response trailer', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
return c_base_return_error::s_false($error);
}
// @todo: self::RESPONSE_TRANSFER_ENCODING
- $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response transfer encoding', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{functionality_name}' => 'http response transfer encoding', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
return c_base_return_error::s_false($error);
}
public function set_response_upgrade($value) {
// @todo: self::RESPONSE_UPGRADE
- $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response upgrade', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{functionality_name}' => 'http response upgrade', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_vary($header_name, $append = TRUE) {
if (!is_string($header_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'header_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'header_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'append', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$prepared_token = $this->p_prepare_token($header_name, FALSE);
if ($prepared_token === FALSE) {
unset($prepared_token);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->p_prepare_token', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->p_prepare_token', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
public function set_response_warning($value) {
// @todo: self::RESPONSE_WARNING
- $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response warning', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{functionality_name}' => 'http response warning', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
return c_base_return_error::s_false($error);
}
public function set_response_www_authenticate($value) {
// @todo: self::RESPONSE_WWW_AUTHENTICATE
- $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response www authenticate', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{functionality_name}' => 'http response www authenticate', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_protocol($protocol) {
if (!is_string($protocol)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'protocol', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'protocol', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_content_security_policy($policy_name, $policy_value, $append = TRUE) {
if (!is_string($policy_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'policy_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'policy_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_string($policy_value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'policy_value', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'policy_value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'append', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($text['invalid']) {
unset($text);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->pr_rfc_string_prepare', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->pr_rfc_string_prepare', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
unset($parsed_policy_name);
unset($prepared_token);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'policy name', ':expected_format' => '1*((alpha) | (digit) | '-')', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'policy name', ':{expected_format}' => '1*((alpha) | (digit) | '-')', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
unset($parsed_policy_name['invalid']);
if ($text['invalid']) {
unset($text);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->pr_rfc_string_prepare', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->pr_rfc_string_prepare', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
unset($parsed_policy_value);
unset($prepared_token);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'policy value', ':expected_format' => '1*(vchar, except \';\' and \',\')', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'policy value', ':{expected_format}' => '1*(vchar, except \';\' and \',\')', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
unset($parsed_policy_value['invalid']);
*/
public function set_response_x_content_type_options($no_sniff) {
if (!is_bool($no_sniff)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'no_sniff', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'no_sniff', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_x_ua_compatible($browser_name, $compatible_version) {
if (!is_string($parameter_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'parameter_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'parameter_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($compatible_version) && !is_string($compatible_version)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'compatible_version', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'compatible_version', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($prepared_browser_name === FALSE) {
unset($prepared_browser_name);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'browser name', ':expected_format' => '1*(tchar)', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'browser name', ':{expected_format}' => '1*(tchar)', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
if (empty($prepared_browser_name)) {
unset($prepared_browser_name);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'browser_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'browser_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($prepared_compatible_version === FALSE) {
unset($prepared_compatible_version);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'browser name', ':expected_format' => '1*(tchar)', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'browser name', ':{expected_format}' => '1*(tchar)', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
if (empty($prepared_compatible_version)) {
unset($prepared_compatible_version);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'compatible_version', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'compatible_version', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_checksum_header($action = self::CHECKSUM_ACTION_AUTO, $what = NULL, $type = NULL, $checksum = NULL) {
if (!is_int($action)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'action', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'action', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($action != self::CHECKSUM_ACTION_NONE && $action != self::CHECKSUM_ACTION_AUTO && $action != self::CHECKSUM_ACTION_MANUAL) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'action', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'action', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($action == self::CHECKSUM_ACTION_MANUAL) {
if (!is_int($what)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'what', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'what', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($type)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_string($checksum)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'checksum', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'checksum', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($what != self::CHECKSUM_WHAT_PARTIAL && $what != self::CHECKSUM_WHAT_FULL) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'what', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'what', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
case CHECKSUM_PG:
break;
default:
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
else {
if (!is_null($what) && !is_int($what)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'what', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'what', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($type) && !is_int($type)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($action) && !is_int($action)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'action', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'action', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_checksum_headers($header_name, $append = TRUE) {
if (!is_string($header_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'header_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'header_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'append', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$prepared_token = $this->p_prepare_token($header_name);
if ($prepared_token === FALSE) {
unset($prepared_token);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->p_prepare_token', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->p_prepare_token', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function set_response_checksum_content($action = self::CHECKSUM_ACTION_AUTO, $what = NULL, $type = NULL, $checksum = NULL) {
if (!is_int($action)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'action', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'action', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($action != self::CHECKSUM_ACTION_NONE && $action != self::CHECKSUM_ACTION_AUTO && $action != self::CHECKSUM_ACTION_MANUAL) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'action', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'action', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($action == self::CHECKSUM_ACTION_MANUAL) {
if (!is_int($what)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'what', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'what', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($type)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_string($checksum)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'checksum', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'checksum', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($what != self::CHECKSUM_WHAT_PARTIAL && $what != self::CHECKSUM_WHAT_FULL) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'what', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'what', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
case CHECKSUM_PG:
break;
default:
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
else {
if (!is_null($what) && !is_int($what)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'what', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'what', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($type) && !is_int($type)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($action)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'action', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'action', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_response_content_revision($revision) {
if (!is_int($revision)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'revision', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'revision', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function unset_response_value($response_id) {
if (!is_int($response_id)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'response_id', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'response_id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function get_response_access_control_allow_origin() {
if (!array_key_exists(self::RESPONSE_ACCESS_CONTROL_ALLOW_ORIGIN, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCESS_CONTROL_ALLOW_ORIGIN, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCESS_CONTROL_ALLOW_ORIGIN, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_access_control_allow_credentials() {
if (!array_key_exists(self::RESPONSE_ACCESS_CONTROL_ALLOW_CREDENTIALS, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCESS_CONTROL_ALLOW_CREDENTIALS, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCESS_CONTROL_ALLOW_CREDENTIALS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(FALSE, 'c_base_return_bool', $error);
}
*/
public function get_response_access_control_expose_headers() {
if (!array_key_exists(self::RESPONSE_ACCESS_CONTROL_EXPOSE_HEADERS, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCESS_CONTROL_EXPOSE_HEADERS, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCESS_CONTROL_EXPOSE_HEADERS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_access_control_max_age() {
if (!array_key_exists(self::RESPONSE_ACCESS_CONTROL_MAX_AGE, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCESS_CONTROL_MAX_AGE, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCESS_CONTROL_MAX_AGE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(0, 'c_base_return_int', $error);
}
*/
public function get_response_access_control_allow_methods() {
if (!array_key_exists(self::RESPONSE_ACCESS_CONTROL_ALLOW_METHODS, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCESS_CONTROL_ALLOW_METHODS, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCESS_CONTROL_ALLOW_METHODS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_access_control_allow_headers() {
if (!array_key_exists(self::RESPONSE_ACCESS_CONTROL_ALLOW_HEADERS, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCESS_CONTROL_ALLOW_HEADERS, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCESS_CONTROL_ALLOW_HEADERS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_accept_patch() {
if (!array_key_exists(self::RESPONSE_ACCEPT_PATCH, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCEPT_PATCH, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCEPT_PATCH, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_accept_ranges() {
if (!array_key_exists(self::RESPONSE_ACCEPT_RANGES, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCEPT_RANGES, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCEPT_RANGES, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
*/
public function get_response_age() {
if (!array_key_exists(self::RESPONSE_AGE, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_AGE, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_AGE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(0, 'c_base_return_int', $error);
}
*/
public function get_response_allow() {
if (!array_key_exists(self::RESPONSE_ALLOW, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ALLOW, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ALLOW, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_cache_control() {
if (!array_key_exists(self::RESPONSE_CACHE_CONTROL, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CACHE_CONTROL, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CACHE_CONTROL, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_connection() {
if (!array_key_exists(self::RESPONSE_CONNECTION, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONNECTION, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONNECTION, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_content_disposition() {
if (!array_key_exists(self::RESPONSE_CONTENT_DISPOSITION, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_DISPOSITION, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_DISPOSITION, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_content_encoding() {
if (!array_key_exists(self::RESPONSE_CONTENT_ENCODING, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_ENCODING, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_ENCODING, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_content_language() {
if (!array_key_exists(self::RESPONSE_CONTENT_LANGUAGE, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_LANGUAGE, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_LANGUAGE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_content_length() {
if (!array_key_exists(self::RESPONSE_CONTENT_LENGTH, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_LENGTH, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_LENGTH, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(0, 'c_base_return_int', $error);
}
*/
public function get_response_content_range() {
if (!array_key_exists(self::RESPONSE_CONTENT_RANGE, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_RANGE, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_RANGE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_content_type() {
if (!array_key_exists(self::RESPONSE_CONTENT_TYPE, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_TYPE, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_TYPE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_date() {
if (!array_key_exists(self::RESPONSE_DATE, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_DATE, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_DATE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(0.0, 'c_base_return_float', $error);
}
*/
public function get_response_date_actual() {
if (!array_key_exists(self::RESPONSE_DATE_ACTUAL, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_DATE_ACTUAL, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_DATE_ACTUAL, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(0.0, 'c_base_return_float', $error);
}
*/
public function get_response_etag() {
if (!array_key_exists(self::RESPONSE_ETAG, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ETAG, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ETAG, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_expires() {
if (!array_key_exists(self::RESPONSE_EXPIRES, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_EXPIRES, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_EXPIRES, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(0.0, 'c_base_return_float', $error);
}
*/
public function get_response_last_modified() {
if (!array_key_exists(self::RESPONSE_LAST_MODIFIED, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_LAST_MODIFIED, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_LAST_MODIFIED, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(0.0, 'c_base_return_float', $error);
}
*/
public function get_response_link() {
if (!array_key_exists(self::RESPONSE_LINK, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_LINK, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_LINK, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_location() {
if (!array_key_exists(self::RESPONSE_LOCATION, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_LOCATION, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_LOCATION, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_pragma() {
if (!array_key_exists(self::RESPONSE_PRAGMA, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_PRAGMA, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_PRAGMA, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_proxy_authenticate() {
if (!array_key_exists(self::RESPONSE_PROXY_AUTHENTICATE, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_PROXY_AUTHENTICATE, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_PROXY_AUTHENTICATE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_false($error);
}
// @todo
- $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response proxy authenticate', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{functionality_name}' => 'http response proxy authenticate', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
return c_base_return_error::s_false($error);
}
*/
public function get_response_public_key_pins() {
if (!array_key_exists(self::RESPONSE_PUBLIC_KEY_PINS, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_PUBLIC_KEY_PINS, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_PUBLIC_KEY_PINS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_false($error);
}
// @todo
- $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response public key pins', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{functionality_name}' => 'http response public key pins', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
return c_base_return_error::s_false($error);
}
*/
public function get_response_refresh() {
if (!array_key_exists(self::RESPONSE_REFRESH, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_REFRESH, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_REFRESH, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_false($error);
}
// @todo
- $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response refresh', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{functionality_name}' => 'http response refresh', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
return c_base_return_error::s_false($error);
}
*/
public function get_response_retry_after() {
if (!array_key_exists(self::RESPONSE_RETRY_AFTER, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_RETRY_AFTER, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_RETRY_AFTER, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_set_cookie() {
if (!array_key_exists(self::RESPONSE_SET_COOKIE, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_SET_COOKIE, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_SET_COOKIE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_cookie', $error);
}
*/
public function get_response_server() {
if (!array_key_exists(self::RESPONSE_SERVER, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_SERVER, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_SERVER, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_false($error);
}
// @todo
- $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response server', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{functionality_name}' => 'http response server', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
return c_base_return_error::s_false($error);
}
*/
public function get_response_status() {
if (!array_key_exists(self::RESPONSE_STATUS, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_STATUS, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_STATUS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(0, 'c_base_return_int', $error);
}
*/
public function get_response_strict_transport_security() {
if (!array_key_exists(self::RESPONSE_STRICT_TRANSPORT_SECURITY, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_STRICT_TRANSPORT_SECURITY, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_STRICT_TRANSPORT_SECURITY, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
// @todo
- $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response strict transport security', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{functionality_name}' => 'http response strict transport security', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
return c_base_return_error::s_false($error);
}
*/
public function get_response_trailer() {
if (!array_key_exists(self::RESPONSE_TRAILER, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_TRAILER, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_TRAILER, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_false($error);
}
// @todo
- $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response trailer', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{functionality_name}' => 'http response trailer', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
return c_base_return_error::s_false($error);
}
*/
public function get_response_transfer_encoding() {
if (!array_key_exists(self::RESPONSE_TRANSFER_ENCODING, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_TRANSFER_ENCODING, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_TRANSFER_ENCODING, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_false($error);
}
// @todo
- $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response transfer encoding', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{functionality_name}' => 'http response transfer encoding', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
return c_base_return_error::s_false($error);
}
*/
public function get_response_upgrade() {
if (!array_key_exists(self::RESPONSE_UPGRADE, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_UPGRADE, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_UPGRADE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_false($error);
}
// @todo
- $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response upgrade', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{functionality_name}' => 'http response upgrade', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
return c_base_return_error::s_false($error);
}
*/
public function get_response_vary() {
if (!array_key_exists(self::RESPONSE_VARY, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_VARY, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_VARY, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_warning() {
if (!array_key_exists(self::RESPONSE_WARNING, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_WARNING, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_WARNING, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_false($error);
}
// @todo
- $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response warning', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{functionality_name}' => 'http response warning', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
return c_base_return_error::s_false($error);
}
*/
public function get_response_www_authenticate() {
if (!array_key_exists(self::RESPONSE_WWW_AUTHENTICATE, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_WWW_AUTHENTICATE, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_WWW_AUTHENTICATE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_false($error);
}
// @todo
- $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response www authenticate', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{functionality_name}' => 'http response www authenticate', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
return c_base_return_error::s_false($error);
}
*/
public function get_response_protocol() {
if (!array_key_exists(self::RESPONSE_PROTOCOL, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_PROTOCOL, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_PROTOCOL, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
*/
public function get_response_content_security_policy() {
if (!array_key_exists(self::RESPONSE_CONTENT_SECURITY_POLICY, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_SECURITY_POLICY, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_SECURITY_POLICY, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_x_content_type_options() {
if (!array_key_exists(self::RESPONSE_X_CONTENT_TYPE_OPTIONS, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_X_CONTENT_TYPE_OPTIONS, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_X_CONTENT_TYPE_OPTIONS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(FALSE, 'c_base_return_bool', $error);
}
*/
public function get_response_x_ua_compatible() {
if (!array_key_exists(self::RESPONSE_X_UA_COMPATIBLE, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_X_UA_COMPATIBLE, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_X_UA_COMPATIBLE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_checksum_header() {
if (!array_key_exists(self::RESPONSE_CHECKSUM_HEADER, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CHECKSUM_HEADER, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CHECKSUM_HEADER, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_checksum_headers() {
if (!array_key_exists(self::RESPONSE_CHECKSUM_HEADERS, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CHECKSUM_HEADERS, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CHECKSUM_HEADERS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_checksum_content() {
if (!array_key_exists(self::RESPONSE_CHECKSUM_CONTENT, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CHECKSUM_CONTENT, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CHECKSUM_CONTENT, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public function get_response_content_revision() {
if (!array_key_exists(self::RESPONSE_CONTENT_REVISION, $this->response)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_REVISION, ':array_name' => 'this->response', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_REVISION, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_value(0, 'c_base_return_int', $error);
}
*/
public function send_response_headers($shuffle = TRUE) {
if (!is_bool($shuffle)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'shuffle', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'shuffle', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($this->headers_sent || headers_sent()) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'headers_sent()', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_UNECESSARY);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'headers_sent()', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_UNECESSARY);
return c_base_return_error::s_false($error);
}
*/
public function encode_response_content($compression = NULL, $max_filesize = NULL) {
if (!is_null($compression) && !is_int($compression)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'compression', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'compression', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($max_filesize) && !(is_int($max_filesize) && $max_filesize > 0)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'max_filesize', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'max_filesize', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
unset($filename);
unset($content);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':file_name' => $filename, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_FILE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{file_name}' => $filename, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_FILE);
return c_base_return_error::s_false($error);
}
unset($filename);
unset($content);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':file_name' => $filename, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_FILE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{file_name}' => $filename, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_FILE);
return c_base_return_error::s_false($error);
}
if (!file_exists($filename)) {
unset($filename);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':file_name' => $filename, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_FILE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{file_name}' => $filename, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_FILE);
return c_base_return_error::s_false($error);
}
if ($opened_file === FALSE) {
unset($filename);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':file_name' => $filename, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_FILE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{file_name}' => $filename, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_FILE);
return c_base_return_error::s_false($error);
}
*/
public function sanitize_path($path) {
if (!is_string($path)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'path', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'path', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
unset($algorithm);
unset($use_hash);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':file_name' => $filename, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_FILE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{file_name}' => $filename, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_FILE);
return c_base_return_error::s_false($error);
}
* @file
* Provides a class for managing the HTTP protocol status codes.
*/
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
/**
* A generic class for managing the HTTP protocol status codes.
*/
public static function to_text($status) {
if (!is_int($status)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'status', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'status', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
* @file
* Provides a class for managing the different supported languages.
*/
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
/**
* A generic interface for managing the different supported languages.
*
* @see: http://www.loc.gov/standards/iso639-2/php/code_list.php
*/
-interface i_base_language {
+interface i_base_languages {
const NONE = 0;
const AFAR = 1; // aar, aa
const ABKHAZIAN = 2; // abk, ab
*
* @see: http://www.loc.gov/standards/iso639-2/php/code_list.php
*/
-final class c_base_language_us_only implements i_base_language {
+final class c_base_languages_us_only implements i_base_languages {
private static $s_aliases = array(
self::ENGLISH_US => array('en-us'),
*/
public static function s_get_names_by_id($id) {
if (!is_int($id) && !is_numeric($id)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'id', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public static function s_get_names_by_alias($alias) {
if (!is_string($alias)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'alias', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'alias', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public static function s_get_id_by_name($name) {
if (!is_string($name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(0, 'c_base_return_int', $error);
}
*/
public static function s_get_id_by_alias($alias) {
if (!is_string($alias)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'alias', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'alias', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(0, 'c_base_return_int', $error);
}
*/
public static function s_get_aliases_by_id($id) {
if (!is_int($id) && !is_numeric($id)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'id', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public static function s_get_aliases_by_name($name) {
if (!is_string($name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*
* @see: http://www.loc.gov/standards/iso639-2/php/code_list.php
*/
-final class c_base_language_limited implements i_base_language {
+final class c_base_languages_limited implements i_base_languages {
private static $s_aliases = array(
self::ENGLISH_US => array('en-us'),
*/
public static function s_get_names_by_id($id) {
if (!is_int($id) && !is_numeric($id)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'id', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public static function s_get_names_by_alias($alias) {
if (!is_string($alias)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'alias', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'alias', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public static function s_get_id_by_name($name) {
if (!is_string($name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(0, 'c_base_return_int', $error);
}
*/
public static function s_get_id_by_alias($alias) {
if (!is_string($alias)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'alias', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'alias', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(0, 'c_base_return_int', $error);
}
*/
public static function s_get_aliases_by_id($id) {
if (!is_int($id) && !is_numeric($id)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'id', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public static function s_get_aliases_by_name($name) {
if (!is_string($name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*
* @see: http://www.loc.gov/standards/iso639-2/php/code_list.php
*/
-final class c_base_language_all implements i_base_language {
+final class c_base_languages_all implements i_base_languages {
private static $s_aliases = array(
self::ENGLISH_US => array('en-us'),
*/
public static function s_get_names_by_id($id) {
if (!is_int($id) && !is_numeric($id)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'id', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public static function s_get_names_by_alias($alias) {
if (!is_string($alias)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'alias', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'alias', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public static function s_get_id_by_name($name) {
if (!is_string($name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(0, 'c_base_return_int', $error);
}
*/
public static function s_get_id_by_alias($alias) {
if (!is_string($alias)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'alias', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'alias', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(0, 'c_base_return_int', $error);
}
*/
public static function s_get_aliases_by_id($id) {
if (!is_int($id) && !is_numeric($id)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'id', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public static function s_get_aliases_by_name($name) {
if (!is_string($name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*
* This is initially designed just to select/read from the ldap and not meant to modify or manage ldap databases.
*/
-
-// include required files.
require_once('common/base/classes/base_error.php');
require_once('common/base/classes/base_return.php');
* A class for managing ldap connections.
*/
class c_base_ldap extends c_base_return {
- private $ldap;
- private $name;
+ protected $ldap;
+ protected $name;
- private $bind_name;
- private $bind_password;
+ protected $bind_name;
+ protected $bind_password;
/**
*/
public function set_name($name) {
if (!is_string($name) || empty($name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$parsed = parse_url($name, PHP_URL_HOST);
if ($parsed === FALSE) {
unset($parsed);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'parse_url', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'parse_url', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function set_bind_name($name) {
if (!is_null($name) && (!is_string($name) || empty($name))) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_bind_password($password) {
if (!is_null($password) && (!is_string($password) || empty($password))) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'password', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'password', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function do_connect() {
if (is_null($this->name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->ldap)) {
$this->ldap = NULL;
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'ldap_connect', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'ldap_connect', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
}
unset($bound);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::FUNCTION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::FUNCTION_FAILURE);
return c_base_return_error::s_false($error);
}
}
unset($unbound);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'ldap_unbind', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'ldap_unbind', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function do_search($directory_name, $filter, $attributes, $attributes_only = FALSE, $entry_limit = 0, $time_limit = 0, $dereference = LDAP_DEREF_NEVER) {
if (!is_resource($this->ldap)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':resource_name' => 'this->ldap', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{resource_name}' => 'this->ldap', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
return c_base_return_error::s_false($error);
}
if (!is_string($directory_name) || !is_string($filter)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'directory_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'directory_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_array($attributes)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'attributes', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'attributes', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($entry_limit) || $entry_limit < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'entry_limit', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'entry_limit', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($time_limit) || $time_limit < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'time_limit', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'time_limit', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($dereference)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'dereference', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'dereference', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
unset($found);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'ldap_search', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'ldap_search', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function do_list($directory_name, $filter, $attributes, $attributes_only = FALSE, $entry_limit = 0, $time_limit = 0, $dereference = LDAP_DEREF_NEVER) {
if (!is_resource($this->ldap)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':resource_name' => 'this->ldap', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{resource_name}' => 'this->ldap', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
return c_base_return_error::s_false($error);
}
if (!is_string($directory_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'directory_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'directory_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_string($filter)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'filter', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'filter', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_array($attributes)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'attributes', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'attributes', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($entry_limit) || $entry_limit < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'entry_limit', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'entry_limit', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($time_limit) || $time_limit < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'time_limit', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'time_limit', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($dereference)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'dereference', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'dereference', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
unset($found);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'ldap_list', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'ldap_list', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function do_read($directory_name, $filter, $attributes, $attributes_only = FALSE, $entry_limit = 0, $time_limit = 0, $dereference = LDAP_DEREF_NEVER) {
if (!is_resource($this->ldap)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':resource_name' => 'this->ldap', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{resource_name}' => 'this->ldap', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
return c_base_return_error::s_false($error);
}
if (!is_string($directory_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'directory_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'directory_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_string($filter)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'filter', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'filter', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_array($attributes)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'attributes', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'attributes', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($entry_limit) || $entry_limit < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'entry_limit', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'entry_limit', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($time_limit) || $time_limit < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'time_limit', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'time_limit', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($dereference)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'dereference', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'dereference', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
unset($found);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'ldap_read', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'ldap_read', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function do_compare($directory_name, $attribute, $value) {
if (!is_resource($this->ldap)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':resource_name' => 'this->ldap', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{resource_name}' => 'this->ldap', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
return c_base_return_error::s_false($error);
}
if (!is_string($directory_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'directory_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'directory_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_string($attribute)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'attibute', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'attibute', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_string($value)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'value', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($result === -1) {
unset($result);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'ldap_compare', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'ldap_compare', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function get_error_message() {
if (!is_resource($this->ldap)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':resource_name' => 'this->ldap', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{resource_name}' => 'this->ldap', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
return c_base_return_error::s_false($error);
}
*/
public function get_error_number() {
if (!is_resource($this->ldap)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':resource_name' => 'this->ldap', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{resource_name}' => 'this->ldap', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
return c_base_return_error::s_false($error);
}
*/
public function get_option($option) {
if (!is_resource($this->ldap)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':resource_name' => 'this->ldap', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{resource_name}' => 'this->ldap', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
return c_base_return_error::s_false($error);
}
if (!is_int($option)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'option', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'option', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$value = NULL;
if (ldap_get_option($this->ldap, $option, $value) === FALSE) {
unset($value);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'ldap_get_option', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'ldap_get_option', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function set_ldap($ldap) {
if (!is_resource($ldap)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'ldap', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'ldap', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function get_count() {
if (!is_resource($ldap)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':resource_name' => 'this->ldap', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{resource_name}' => 'this->ldap', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
return c_base_return_error::s_false($error);
}
$total = ldap_count_entries($this->ldap, $this->value);
if ($total === FALSE) {
unset($total);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'ldap_count_entries', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'ldap_count_entries', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function load_entry_first() {
if (!is_resource($this->ldap)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':resource_name' => 'this->ldap', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{resource_name}' => 'this->ldap', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
return c_base_return_error::s_false($error);
}
$first = ldap_first_entry($this->ldap, $this->value);
if ($first === FALSE) {
unset($first);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'ldap_first_entry', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'ldap_first_entry', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function load_entry_next() {
if (!is_resource($this->ldap)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':resource_name' => 'this->ldap', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{resource_name}' => 'this->ldap', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
return c_base_return_error::s_false($error);
}
// the entry must first be loaded by self::load_entry_first().
if (!is_null($this->entry)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->entry', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->entry', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
*/
public function get_entry_all() {
if (!is_resource($this->ldap)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':resource_name' => 'this->ldap', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{resource_name}' => 'this->ldap', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
return c_base_return_error::s_false($error);
}
if ($entries === FALSE) {
unset($entries);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'ldap_get_entries', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'ldap_get_entries', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function get_attribute_first() {
if (!is_resource($this->ldap)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':resource_name' => 'this->ldap', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{resource_name}' => 'this->ldap', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->entry)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->entry', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->entry', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
if ($attribute === FALSE) {
unset($attribute);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'ldap_first_attribute', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'ldap_first_attribute', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function get_attribute_next() {
if (!is_resource($this->ldap)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':resource_name' => 'this->ldap', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{resource_name}' => 'this->ldap', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->entry)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->entry', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->entry', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
if ($attribute === FALSE) {
unset($attribute);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'ldap_next_attribute', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'ldap_next_attribute', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function get_attribute_all() {
if (!is_resource($this->ldap)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':resource_name' => 'this->ldap', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{resource_name}' => 'this->ldap', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->entry)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->entry', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->entry', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
if ($attributes === FALSE) {
unset($attributes);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'ldap_get_attributes', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'ldap_get_attributes', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function get_directory_name() {
if (!is_resource($this->ldap)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':resource_name' => 'this->ldap', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{resource_name}' => 'this->ldap', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->entry)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->entry', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->entry', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
if ($directory_name === FALSE) {
unset($directory_name);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'ldap_get_dn', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'ldap_get_dn', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function get_values($attribute, $binary = FALSE) {
if (!is_resource($this->ldap)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':resource_name' => 'this->ldap', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{resource_name}' => 'this->ldap', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->entry)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->entry', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->entry', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
if (!is_string($attribute)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'attribute', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'attribute', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($binary)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'binary', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'binary', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_array($values)) {
unset($values);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => ($binary ? 'ldap_get_values_len' : 'ldap_get_values'), ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => ($binary ? 'ldap_get_values_len' : 'ldap_get_values'), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function do_sort($attribute) {
if (!is_resource($this->ldap)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':resource_name' => 'this->ldap', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{resource_name}' => 'this->ldap', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_CONNECTION);
return c_base_return_error::s_false($error);
}
if (!is_string($attribute)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'attribute', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'attribute', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($status === FALSE) {
unset($status);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'ldap_sort', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'ldap_sort', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
unset($status);
return new c_base_return_true();
}
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'ldap_free_result', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'ldap_free_result', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
}
* @file
* Provides a class for managing the logs.
*/
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
/**
* A generic class for managing the logs.
const SEVERITY_CRITICAL = 6; // this is a big problem.
const SEVERITY_EMERGENCY = 7; // this is the most serious type of problem.
- private $type;
- private $data;
+ protected $type;
+ protected $data;
/**
*/
public function set_type($type) {
if (!is_int($type) || $type < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function get_data_jsonized($options = 0, $depth = 512) {
if (!is_int($options)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'options', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'options', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($depth) || $depth < 1) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'depth', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'depth', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($encoded === FALSE) {
unset($encoded);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'json_encode', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'json_encode', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
protected function pr_set_data($key, $value) {
if (is_int($key)) {
if ($key < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'key', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'key', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
elseif (!is_string($key)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'value', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
protected function pr_get_data($key) {
if (is_int($key)) {
if ($key < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'key', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'key', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
elseif (!is_string($key)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'key', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'key', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!array_key_exists($key, $this->data)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => $key, ':array_name' => 'this->data', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => $key, ':{array_name}' => 'this->data', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_false($error);
}
* @file
* Provides a class for html markup.
*/
-
-// include required files.
require_once('common/base/classes/base_error.php');
require_once('common/base/classes/base_return.php');
require_once('common/base/classes/base_mime.php');
require_once('common/base/classes/base_charset.php');
-require_once('common/base/classes/base_languages.php');
require_once('common/base/classes/base_rfc_string.php');
/**
const ATTRIBUTE_HIDDEN = 64; // TRUE/FALSE
const ATTRIBUTE_HIGH = 65; // number
const ATTRIBUTE_HREF = 66; // text
- const ATTRIBUTE_HREF_LANGUAGE = 67; // i_base_language
+ const ATTRIBUTE_HREF_LANGUAGE = 67; // i_base_languages
const ATTRIBUTE_HREF_NO = 68; // text
const ATTRIBUTE_HTTP_EQUIV = 69; // text
const ATTRIBUTE_ICON = 70; // text
const ATTRIBUTE_KEY_TYPE = 76; // text: rsa, dsa, ec
const ATTRIBUTE_KIND = 77; // text
const ATTRIBUTE_LABEL = 78; // text
- const ATTRIBUTE_LANGUAGE = 79; // i_base_language, int
+ const ATTRIBUTE_LANGUAGE = 79; // i_base_languages, int
const ATTRIBUTE_LENGTH_ADJUST = 80; // text
const ATTRIBUTE_LIST = 81; // text, datalist_id
const ATTRIBUTE_LOCAL = 82; // text
const ATTRIBUTE_SORTED = 231; // text
const ATTRIBUTE_SOURCE = 232; // text: url
const ATTRIBUTE_SOURCE_DOCUMENT = 233; // text
- const ATTRIBUTE_SOURCE_LANGUAGE = 234; // i_base_language
+ const ATTRIBUTE_SOURCE_LANGUAGE = 234; // i_base_languages
const ATTRIBUTE_SOURCE_SET = 235; // text
const ATTRIBUTE_SPAN = 236; // text
const ATTRIBUTE_SPELLCHECK = 237; // TRUE/FALSE
*/
public function set_attribute($attribute, $value) {
if (!is_int($attribute)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'attribute', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'attribute', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function get_attribute($attribute) {
if (!is_int($attribute)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'attribute', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'attribute', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
switch ($attribute) {
case c_base_markup_attributes::ATTRIBUTE_NONE:
// should not be possible, so consider this an error (when attribute is set to NONE, the entire attributes array is unset).
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
case c_base_markup_attributes::ATTRIBUTE_ABBR:
*/
public function check_attribute($attribute, $sanitize = FALSE, $type = NULL, $sub_type = NULL, $options = array()) {
if (!is_int($attribute)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'attribute', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'attribute', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($sanitize)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'sanitize', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'sanitize', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($type)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($sub_type) && !is_int($sub_type) && !is_string($sub_type)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'sub_type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'sub_type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_array($options)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'options', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'options', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_tag($tag, $index = NULL) {
if (!($tag instanceof c_base_markup_tag)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'tag', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'tag', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($index) && (!is_int($index) && $index < 0)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'index', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'index', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function unset_tag($index) {
if (!is_null($index) && (!is_int($index) && $index < 0)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'index', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'index', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function get_tag($index) {
if (!is_int($index) && $index < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'index', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'index', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_text($text) {
if (!is_string($text)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_type($type) {
if (!is_int($type)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$value = (string) $this->attributes[$attribute];
}
else {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'value attribute', ':expected_format' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'value attribute', ':{expected_format}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
$this->attributes[$attribute] = NULL;
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'value attribute', ':expected_format' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'value attribute', ':{expected_format}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
if ($sanitize) {
return c_base_return_error::s_true($error);
if ($invalid) {
unset($invalid);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'value attribute', ':expected_format' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'value attribute', ':{expected_format}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
if ($changed) {
unset($changed);
return c_base_return_error::s_true($error);
*/
protected function pr_check_attribute_as_numeric($attribute, $sanitize = TRUE) {
if (!is_numeric($this->attributes[$attribute])) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'value attribute', ':expected_format' => 'number', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'value attribute', ':{expected_format}' => 'number', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
* @file
* Provides a class for managing mime-type information.
*/
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
/**
* A generic class for managing mime-type information.
*/
static function s_get_names_by_id($id, $category = NULL) {
if (!is_int($id) && !is_numeric($id)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'id', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
else {
if (!is_int($category)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'category', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'category', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
static function s_identify($mime, $lowercase = FALSE) {
if (!is_string($mime)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'mime', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'mime', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($lowercase)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'lowercase', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'lowercase', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
* Then, for very specific cases, users should then be granted the ability to create path aliases.
* However, aliases should not be able to override pre-define paths or the performance gains are lost by requiring loading of the aliases before each static path.
*/
-
-// include required files.
require_once('common/base/classes/base_error.php');
require_once('common/base/classes/base_return.php');
-require_once('common/base/classes/base_ascii.php');
require_once('common/base/classes/base_utf8.php');
require_once('common/base/classes/base_http.php');
-require_once('common/base/classes/base_http_status.php');
-require_once('common/base/classes/base_markup.php');
-require_once('common/base/classes/base_html.php');
require_once('common/base/classes/base_cookie.php');
/**
*/
public function set_id_group($id_group) {
if (!is_int($id_group) || $id_group < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'id_group', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'id_group', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_field_destination($field_destination) {
if (!is_string($field_destination) && !is_array($field_destination)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'field_destination', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'field_destination', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_field_response_code($field_response_code) {
if (!is_int($field_response_code)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'field_response_code', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'field_response_code', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_date_created($date_created) {
if (!is_float($date_created) && !is_int($date_created)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'date_created', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'date_created', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_date_changed($date_changed) {
if (!is_float($date_changed) && !is_int($date_changed)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'date_changed', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'date_changed', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_date_locked($date_locked) {
if (!is_float($date_locked) && !is_int($date_locked)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'date_locked', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'date_locked', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_include_name($name) {
if (!is_string($name) && !is_null($name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_allowed_method($method, $append = TRUE) {
if (!is_int($method)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'method', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'method', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'append', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_allowed_methods($methods) {
if (!is_array($methods)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'methods', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'methods', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_sanitize_html($flags = NULL, $encoding = NULL) {
if (!is_null($flags) && !is_int($flags)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'flags', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'flags', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($encoding) && !is_string($encoding)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'encoding', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'encoding', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function is_content($is_content = NULL) {
if (!is_null($is_content) && !is_bool($is_content)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'is_content', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'is_content', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function is_alias($is_alias = NULL) {
if (!is_null($is_alias) && !is_bool($is_alias)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'is_alias', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'is_alias', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function is_redirect($is_redirect = NULL) {
if (!is_null($is_redirect) && !is_bool($is_redirect)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'is_redirect', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'is_redirect', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function is_private($is_private = NULL) {
if (!is_null($is_private) && !is_bool($is_private)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'is_private', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'is_private', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function is_locked($is_locked = NULL) {
if (!is_null($is_locked) && !is_bool($is_locked)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'is_locked', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'is_locked', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function is_root($is_root = NULL) {
if (!is_null($is_root) && !is_bool($is_root)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'is_root', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'is_root', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$executed = new c_base_path_executed();
if (!($http instanceof c_base_http)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'http', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'http', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
$executed->set_error($error);
unset($error);
}
elseif (!($database instanceof c_base_database)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'database', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'database', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
$executed->set_error($error);
unset($error);
}
elseif (!($session instanceof c_base_session)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'session', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'session', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
$executed->set_error($error);
unset($error);
}
elseif (!is_array($settings)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'settings', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'settings', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
$executed->set_error($error);
unset($error);
}
+ if ($this->is_redirect) {
+ $http->set_response_location($this->field_destination);
+ $http->set_response_status($this->field_response_code);
+ }
+
return $executed;
}
*/
protected function pr_sanitize($id, $type, $type_sub = NULL) {
if (!is_string($id) && mb_strlen($id) > 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'id', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(NULL, 'c_base_return_null', $error);
}
if (!is_int($type)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(NULL, 'c_base_return_null', $error);
}
* The $cookies is meant to hold any HTTP cookies to be processed after the execution.
* The $output is meant to hold the output for any non-HTML content in the event that HTML is not to be renderred..
*
- * @see: c_base_path
+ * @see: c_base_path()
*/
class c_base_path_executed extends c_base_return_array {
private $cookies = NULL;
*/
public function set_cookies($cookie, $append = TRUE) {
if (!($cookie instanceof c_base_cookie)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'cookie', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'cookie', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'append', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_output($output) {
if (!is_null($output) && !($output instanceof c_base_return)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'output', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'output', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
return $this->output;
}
}
-
-/**
- * Provides a collection of possible paths for selection and execution.
- *
- * This utilizes some very basic path based optimizations.
- * First, the path group is optimized (an ordinal representing one of: NULL, a-z, A-Z, or 0-9).
- * Second, the first character of the path string (expects utf-8).
- * Third, the paths are exploded and searched based on all their sub-parts.
- */
-class c_base_paths extends c_base_return {
- private $paths = NULL;
- private $root = NULL;
-
-
- /**
- * Class constructor.
- */
- public function __construct() {
- parent::__construct();
-
- $this->paths = array();
- $this->root = NULL;
- }
-
- /**
- * Class destructor.
- */
- public function __destruct() {
- unset($this->paths);
- unset($this->root);
-
- parent::__destruct();
- }
-
- /**
- * @see: t_base_return_value::p_s_new()
- */
- public static function s_new($value) {
- return self::p_s_new($value, __CLASS__);
- }
-
- /**
- * @see: t_base_return_value::p_s_value()
- */
- public static function s_value($return) {
- return self::p_s_value($return, __CLASS__);
- }
-
- /**
- * @see: t_base_return_value_exact::p_s_value_exact()
- */
- public static function s_value_exact($return) {
- return self::p_s_value_exact($return, __CLASS__, array());
- }
-
- /**
- * Assign a specific path handler.
- *
- * Duplicate paths overwrite previous paths.
- *
- * @todo: should redirect and alias booleans be added as parameters?
- *
- * @pram string $directory
- * The first part of the file path
- * @pram string $path
- * The url path in which the handler applies to.
- * @param string $handler
- * The name of an implementation of c_base_path.
- * @param string|null $directory
- * (optional) The prefix path (relative to the PHP includes) to include that contains the requested path.
- * When not NULL, both $directory and $name must not be NULL.
- * @param string|null $name
- * (optional) The suffix path (relative to the PHP includes) to include that contains the requested path.
- * When not NULL, both $directory and $name must not be NULL.
- * @param array|null $allowed_methods
- * (optional) An array of ids of allowed methods.
- * When NULL, this value is ignored.
- *
- * @return c_base_return_status
- * TRUE is returned on success.
- * FALSE with error bit set is returned on error.
- */
- public function set_path($path, $handler, $include_directory = NULL, $include_name = NULL, $allowed_methods = NULL) {
- if (!is_string($path)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'path', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- if (!is_string($handler)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'handler', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- if ((!is_null($include_directory) || (is_null($include_directory) && !is_null($include_name))) && !is_string($include_directory)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'include_directory', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- if ((!is_null($include_name) || (is_null($include_name) && !is_null($include_directory))) && !is_string($include_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'include_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
-
- // get allowed methods
- $path_object = new c_base_path();
- if (is_null($allowed_methods)) {
- $methods = $path_object->get_allowed_methods()->get_value_exact();
- if (!is_array($methods)) {
- $methods = array();
- }
- }
- else {
- $methods = $allowed_methods;
- }
-
-
- if (mb_strlen($path) == 0) {
- unset($path_object);
- $this->root = array('handler' => $handler, 'include_directory' => $include_directory, 'include_name' => $include_name, 'is_root' => TRUE, 'methods' => $methods);
- return new c_base_return_true();
- }
-
- if (!is_null($allowed_methods) && !is_array($allowed_methods)) {
- unset($path_object);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'allowed_methods', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- $valid_path = $path_object->set_value($path);
- if (!$valid_path) {
- unset($path_object);
- unset($valid_path);
-
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'path', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
- unset($valid_path);
-
- $path_string = $path_object->get_value_exact();
- unset($path_object);
-
- // assign each path part to the path
- $path_parts = explode('/', $path_string);
- unset($path_string);
-
-
- // load the path group, if available.
- $id_group = 0;
- if (mb_strlen($path_parts[0]) == 1) {
- $ordinal = ord($path_parts[0]);
- if (in_array($ordinal, c_base_defaults_global::RESERVED_PATH_GROUP)) {
- $id_group = $ordinal;
- }
- unset($ordinal);
- unset($path_parts[0]);
- }
-
- if (!is_array($this->paths)) {
- $this->paths = array();
- }
-
- if (!array_key_exists($id_group, $this->paths)) {
- $this->paths[$id_group] = array();
- }
-
- $path_tree = &$this->paths[$id_group];
-
- $depth_current = 1;
- $depth_total = count($path_parts);
-
- // make sure the first path exists.
- $path_part = array_shift($path_parts);
- if (!array_key_exists($path_part, $path_tree)) {
- $path_tree[$path_part] = array(
- 'paths' => array(),
- 'include_directory' => NULL,
- 'include_name' => NULL,
- 'handler' => NULL,
- 'methods' => array(),
- );
- }
-
- $path_tree = &$path_tree[$path_part];
- if ($depth_current == $depth_total) {
- $path_tree['include_directory'] = $include_directory;
- $path_tree['include_name'] = $include_name;
- $path_tree['handler'] = $handler;
- $path_tree['methods'] = $methods;
- }
- else {
- foreach ($path_parts as $path_part) {
- if (!isset($path_tree['paths'][$path_part])) {
- $path_tree['paths'][$path_part] = array(
- 'paths' => array(),
- 'include_directory' => NULL,
- 'include_name' => NULL,
- 'handler' => NULL,
- 'methods' => array(),
- );
- }
-
- $path_tree = &$path_tree['paths'][$path_part];
- $depth_current++;
-
- if ($depth_current == $depth_total) {
- $path_tree['include_directory'] = $include_directory;
- $path_tree['include_name'] = $include_name;
- $path_tree['handler'] = $handler;
- $path_tree['methods'] = $methods;
- break;
- }
- }
- }
- unset($path_part);
- unset($path_parts);
- unset($depth_current);
- unset($depth_total);
-
- return new c_base_return_true();
- }
-
- /**
- * Gets a path object for the specified path.
- *
- * @param string|null $path_string
- * The URL path without any path arguments.
- * This does not accept wildcards.
- * Set to NULL or an empty string for the root path.
- *
- * @return c_base_return_array|c_base_return_int|c_base_return_null
- * An array containing:
- * - 'include_directory': the prefix path of the file to include that contains the handler class implementation.
- * - 'include_name': the suffix path of the file to include that contains the handler class implementation.
- * - 'handler': the name of the handler class.
- * - 'redirect': if specified, then a redirect path (instead of include/handler).
- * - 'code': if redirect is specified, then the http response code associated with the redirect.
- * Wildcards are matched after all non-wildcards.
- * NULL is returned if not found.
- * FALSE with error bit set is returned on error.
- *
- * @see: self::set_login()
- * @see: self::process_path()
- */
- public function find_path($path_string) {
- if (!is_null($path_string) && !is_string($path_string)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'path_string', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- if (is_null($path_string) || mb_strlen($path_string) == 0) {
- if (is_array($this->root)) {
- return c_base_return_array::s_new($this->root);
- }
-
- return new c_base_return_null();
- }
-
-
- // sanitize the url path.
- $path = new c_base_path();
- if (!$path->set_value($path_string)) {
- unset($path);
-
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'path_string', ':expected_format' => 'Valid URL path', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
- return c_base_return_error::s_false($error);
- }
-
- $sanitized = $path->get_value_exact();
- unset($path);
-
- // if the sanitized path is different from the original, then send a url redirect.
- if (strcmp($path_string, $sanitized) != 0 && $path_string != '/' . $sanitized) {
- return c_base_return_array::s_new(array('redirect' => $sanitized, 'code' => c_base_http_status::MOVED_PERMANENTLY));
- }
-
- $path_parts = explode('/', $sanitized);
- unset($sanitized);
-
-
- // load the path group, if available.
- $id_group = 0;
- if (mb_strlen($path_parts[0]) == 1) {
- $ordinal = ord($path_parts[0]);
- if (in_array($ordinal, c_base_defaults_global::RESERVED_PATH_GROUP)) {
- $id_group = $ordinal;
- }
- unset($ordinal);
- unset($path_parts[0]);
- }
-
-
- $depth_current = 1;
- $depth_total = count($path_parts);
- $found = NULL;
- $path_tree = &$this->paths[$id_group];
-
- // @fixme: the current design needs to handle multiple possible wildcard paths when searching (such as '/a/b/c/%', '/a/%/c', where '/a/b/c/%' would prevent '/a/%/c' from ever matching).
- $path_part = array_shift($path_parts);
- if (array_key_exists($path_part, $path_tree) || array_key_exists('%', $path_tree)) {
- if (array_key_exists($path_part, $path_tree)) {
- $path_tree = &$path_tree[$path_part];
- }
- else {
- $path_tree = &$path_tree['%'];
- }
-
- if ($depth_current == $depth_total) {
- $found = array(
- 'include_directory' => $path_tree['include_directory'],
- 'include_name' => $path_tree['include_name'],
- 'handler' => $path_tree['handler'],
- 'methods' => $path_tree['methods'],
- );
- }
- else {
- foreach ($path_parts as $path_part) {
- if (array_key_exists($path_part, $path_tree['paths'])) {
- $path_tree = &$path_tree['paths'][$path_part];
- $depth_current++;
- }
- elseif (array_key_exists('%', $path_tree['paths'])) {
- $path_tree = &$path_tree['paths']['%'];
- $depth_current++;
- }
- else {
- break;
- }
-
- if ($depth_current == $depth_total) {
- $found = array(
- 'include_directory' => $path_tree['include_directory'],
- 'include_name' => $path_tree['include_name'],
- 'handler' => $path_tree['handler'],
- 'methods' => $path_tree['methods'],
- );
- break;
- }
- }
- }
- }
- unset($path_part);
- unset($path_parts);
- unset($depth_current);
- unset($depth_total);
- unset($path_tree);
-
- if (is_array($found) && !is_null($found['handler'])) {
- return c_base_return_array::s_new($found);
- }
- unset($found);
-
- return new c_base_return_null();
- }
-}
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides a class for managing hard coded and dynamic paths.
+ */
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+require_once('common/base/classes/base_http.php');
+require_once('common/base/classes/base_http_status.php');
+require_once('common/base/classes/base_path.php');
+
+/**
+ * Provides a collection of possible paths for selection and execution.
+ *
+ * This utilizes some very basic path based optimizations.
+ * First, the path group is optimized (an ordinal representing one of: NULL, a-z, A-Z, or 0-9).
+ * Second, the first character of the path string (expects utf-8).
+ * Third, the paths are exploded and searched based on all their sub-parts.
+ */
+class c_base_paths extends c_base_return {
+ private $paths = NULL;
+ private $root = NULL;
+
+
+ /**
+ * Class constructor.
+ */
+ public function __construct() {
+ parent::__construct();
+
+ $this->paths = array();
+ $this->root = NULL;
+ }
+
+ /**
+ * Class destructor.
+ */
+ public function __destruct() {
+ unset($this->paths);
+ unset($this->root);
+
+ parent::__destruct();
+ }
+
+ /**
+ * @see: t_base_return_value::p_s_new()
+ */
+ public static function s_new($value) {
+ return self::p_s_new($value, __CLASS__);
+ }
+
+ /**
+ * @see: t_base_return_value::p_s_value()
+ */
+ public static function s_value($return) {
+ return self::p_s_value($return, __CLASS__);
+ }
+
+ /**
+ * @see: t_base_return_value_exact::p_s_value_exact()
+ */
+ public static function s_value_exact($return) {
+ return self::p_s_value_exact($return, __CLASS__, array());
+ }
+
+ /**
+ * Assign a specific path handler.
+ *
+ * Duplicate paths overwrite previous paths.
+ *
+ * @todo: should redirect and alias booleans be added as parameters?
+ *
+ * @pram string $directory
+ * The first part of the file path
+ * @pram string $path
+ * The url path in which the handler applies to.
+ * @param string $handler
+ * The name of an implementation of c_base_path.
+ * @param string|null $directory
+ * (optional) The prefix path (relative to the PHP includes) to include that contains the requested path.
+ * When not NULL, both $directory and $name must not be NULL.
+ * @param string|null $name
+ * (optional) The suffix path (relative to the PHP includes) to include that contains the requested path.
+ * When not NULL, both $directory and $name must not be NULL.
+ * @param array|null $allowed_methods
+ * (optional) An array of ids of allowed methods.
+ * When NULL, this value is ignored.
+ *
+ * @return c_base_return_status
+ * TRUE is returned on success.
+ * FALSE with error bit set is returned on error.
+ */
+ public function add_path($path, $handler, $include_directory = NULL, $include_name = NULL, $allowed_methods = NULL) {
+ if (!is_string($path)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'path', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_string($handler)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'handler', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if ((!is_null($include_directory) || (is_null($include_directory) && !is_null($include_name))) && !is_string($include_directory)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'include_directory', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if ((!is_null($include_name) || (is_null($include_name) && !is_null($include_directory))) && !is_string($include_name)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'include_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+
+ // get allowed methods
+ $path_object = new c_base_path();
+ if (is_null($allowed_methods)) {
+ $methods = $path_object->get_allowed_methods()->get_value_exact();
+ if (!is_array($methods)) {
+ $methods = array();
+ }
+ }
+ else {
+ $methods = $allowed_methods;
+ }
+
+
+ if (mb_strlen($path) == 0) {
+ unset($path_object);
+ $this->root = array('handler' => $handler, 'include_directory' => $include_directory, 'include_name' => $include_name, 'is_root' => TRUE, 'methods' => $methods);
+ return new c_base_return_true();
+ }
+
+ if (!is_null($allowed_methods) && !is_array($allowed_methods)) {
+ unset($path_object);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'allowed_methods', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $valid_path = $path_object->set_value($path);
+ if (!$valid_path) {
+ unset($path_object);
+ unset($valid_path);
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'path', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+ unset($valid_path);
+
+ $path_string = $path_object->get_value_exact();
+ unset($path_object);
+
+ // assign each path part to the path
+ $path_parts = explode('/', $path_string);
+ unset($path_string);
+
+
+ // load the path group, if available.
+ $id_group = 0;
+ if (mb_strlen($path_parts[0]) == 1) {
+ $ordinal = ord($path_parts[0]);
+ if (in_array($ordinal, c_base_defaults_global::RESERVED_PATH_GROUP)) {
+ $id_group = $ordinal;
+ }
+ unset($ordinal);
+ unset($path_parts[0]);
+ }
+
+ if (!is_array($this->paths)) {
+ $this->paths = array();
+ }
+
+ if (!array_key_exists($id_group, $this->paths)) {
+ $this->paths[$id_group] = array();
+ }
+
+ $path_tree = &$this->paths[$id_group];
+
+ $depth_current = 1;
+ $depth_total = count($path_parts);
+
+ // make sure the first path exists.
+ $path_part = array_shift($path_parts);
+ if (!array_key_exists($path_part, $path_tree)) {
+ $path_tree[$path_part] = array(
+ 'paths' => array(),
+ 'include_directory' => NULL,
+ 'include_name' => NULL,
+ 'handler' => NULL,
+ 'methods' => array(),
+ );
+ }
+
+ $path_tree = &$path_tree[$path_part];
+ if ($depth_current == $depth_total) {
+ $path_tree['include_directory'] = $include_directory;
+ $path_tree['include_name'] = $include_name;
+ $path_tree['handler'] = $handler;
+ $path_tree['methods'] = $methods;
+ }
+ else {
+ foreach ($path_parts as $path_part) {
+ if (!isset($path_tree['paths'][$path_part])) {
+ $path_tree['paths'][$path_part] = array(
+ 'paths' => array(),
+ 'include_directory' => NULL,
+ 'include_name' => NULL,
+ 'handler' => NULL,
+ 'methods' => array(),
+ );
+ }
+
+ $path_tree = &$path_tree['paths'][$path_part];
+ $depth_current++;
+
+ if ($depth_current == $depth_total) {
+ $path_tree['include_directory'] = $include_directory;
+ $path_tree['include_name'] = $include_name;
+ $path_tree['handler'] = $handler;
+ $path_tree['methods'] = $methods;
+ break;
+ }
+ }
+ }
+ unset($path_part);
+ unset($path_parts);
+ unset($depth_current);
+ unset($depth_total);
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Gets a path object for the specified path.
+ *
+ * @param string|null $path_string
+ * The URL path without any path arguments.
+ * This does not accept wildcards.
+ * Set to NULL or an empty string for the root path.
+ *
+ * @return c_base_return_array|c_base_return_int|c_base_return_null
+ * An array containing:
+ * - 'include_directory': the prefix path of the file to include that contains the handler class implementation.
+ * - 'include_name': the suffix path of the file to include that contains the handler class implementation.
+ * - 'handler': the name of the handler class.
+ * - 'redirect': if specified, then a redirect path (instead of include/handler).
+ * - 'code': if redirect is specified, then the http response code associated with the redirect.
+ * Wildcards are matched after all non-wildcards.
+ * NULL is returned if not found.
+ * FALSE with error bit set is returned on error.
+ *
+ * @see: self::set_login()
+ * @see: self::process_path()
+ */
+ public function find_path($path_string) {
+ if (!is_null($path_string) && !is_string($path_string)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'path_string', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (is_null($path_string) || mb_strlen($path_string) == 0) {
+ if (is_array($this->root)) {
+ return c_base_return_array::s_new($this->root);
+ }
+
+ return new c_base_return_null();
+ }
+
+
+ // sanitize the url path.
+ $path = new c_base_path();
+ if (!$path->set_value($path_string)) {
+ unset($path);
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'path_string', ':{expected_format}' => 'Valid URL path', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $sanitized = $path->get_value_exact();
+ unset($path);
+
+ // if the sanitized path is different from the original, then send a url redirect.
+ if (strcmp($path_string, $sanitized) != 0 && $path_string != '/' . $sanitized) {
+ return c_base_return_array::s_new(array('redirect' => $sanitized, 'code' => c_base_http_status::MOVED_PERMANENTLY));
+ }
+
+ $path_parts = explode('/', $sanitized);
+ unset($sanitized);
+
+
+ // load the path group, if available.
+ $id_group = 0;
+ if (mb_strlen($path_parts[0]) == 1) {
+ $ordinal = ord($path_parts[0]);
+ if (in_array($ordinal, c_base_defaults_global::RESERVED_PATH_GROUP)) {
+ $id_group = $ordinal;
+ }
+ unset($ordinal);
+ unset($path_parts[0]);
+ }
+
+
+ $depth_current = 1;
+ $depth_total = count($path_parts);
+ $found = NULL;
+ $path_tree = &$this->paths[$id_group];
+
+ // @fixme: the current design needs to handle multiple possible wildcard paths when searching (such as '/a/b/c/%', '/a/%/c', where '/a/b/c/%' would prevent '/a/%/c' from ever matching).
+ $path_part = array_shift($path_parts);
+ if (is_array($path_tree) && (array_key_exists($path_part, $path_tree) || array_key_exists('%', $path_tree))) {
+ if (array_key_exists($path_part, $path_tree)) {
+ $path_tree = &$path_tree[$path_part];
+ }
+ else {
+ $path_tree = &$path_tree['%'];
+ }
+
+ if ($depth_current == $depth_total) {
+ $found = array(
+ 'include_directory' => $path_tree['include_directory'],
+ 'include_name' => $path_tree['include_name'],
+ 'handler' => $path_tree['handler'],
+ 'methods' => $path_tree['methods'],
+ 'id_group' => $id_group,
+ );
+ }
+ else {
+ foreach ($path_parts as $path_part) {
+ if (array_key_exists($path_part, $path_tree['paths'])) {
+ $path_tree = &$path_tree['paths'][$path_part];
+ $depth_current++;
+ }
+ elseif (array_key_exists('%', $path_tree['paths'])) {
+ $path_tree = &$path_tree['paths']['%'];
+ $depth_current++;
+ }
+ else {
+ break;
+ }
+
+ if ($depth_current == $depth_total) {
+ $found = array(
+ 'include_directory' => $path_tree['include_directory'],
+ 'include_name' => $path_tree['include_name'],
+ 'handler' => $path_tree['handler'],
+ 'methods' => $path_tree['methods'],
+ 'id_group' => $id_group,
+ );
+ break;
+ }
+ }
+ }
+ }
+ unset($path_part);
+ unset($path_parts);
+ unset($depth_current);
+ unset($depth_total);
+ unset($path_tree);
+
+ if (is_array($found) && !is_null($found['handler'])) {
+ return c_base_return_array::s_new($found);
+ }
+ unset($found);
+
+ return new c_base_return_null();
+ }
+}
* Functions defined in this class will return the normal TRUE/FALSE and not the class-based TRUE/FALSE as an exception to this rule.
* - This is done because this class defines those objects.
*/
-
-// include required files.
require_once('common/base/classes/base_error.php');
/**
}
/**
+ * Copy errors from one return type to another.
+ *
+ * Invalid parameters are silently ignored and no actions are performed.
+ *
+ * @param c_base_return $source
+ * The return value to copy errors from.
+ * @param c_base_return &$destination
+ * The return value to copy errors to.
+ */
+ public static function s_copy_errors($source, &$destination) {
+ if (!($source instanceof c_base_return) || !($destination instanceof c_base_return)) {
+ return;
+ }
+
+ $errors = $source->get_error()->get_value_exact();
+ if (is_array($errors)) {
+ foreach ($errors as $error) {
+ $destination->set_error($error);
+ }
+ unset($error);
+ }
+ unset($errors);
+ }
+
+ /**
* Assign the error code.
*
* @param null|c_base_error $error
* @file
* Provides a class for managing common rfc character testing cases.
*/
-
-// include required files.
require_once('common/base/classes/base_return.php');
require_once('common/base/classes/base_ascii.php');
require_once('common/base/classes/base_utf8.php');
* @file
* Provides a class for managing common rfc string testing cases.
*/
-
-// include required files.
+require_once('common/base/classes/base_return.php');
require_once('common/base/classes/base_ascii.php');
require_once('common/base/classes/base_utf8.php');
require_once('common/base/classes/base_rfc_char.php');
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides a class for managing system roles.
+ */
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+/**
+ * A class for managing roles.
+ *
+ * Roles defined here are general top-level roles used for separating database activity.
+ * The intentions here is to keep the roles as simple and as few as possible while allowing considerable flexibility.
+ * This should cut down on the complexity of the database access control.
+ *
+ * Additional granularity may be supplied via PHP access checks or by extending this class.
+ *
+ * Roles:
+ * - None: no access to anything.
+ * - Public: access to only public information (users who are not logged in have this, such as anonymous).
+ * - System: account is a machine and should not be a human (such as with cron jobs).
+ * - User: account is a user and that user is logged in.
+ * - Requester: account is for requesting something, generally via some sort of form.
+ * - Drafter: account is for making templates, drafts, ideas, etc.. (this is a lesser form of "editer").
+ * - Editer: account is for editors who add/manage/create content.
+ * - Reviewer: account is for users who review something (such as a user who approves content for publishing).
+ * - Insurer: account is for users who deal with insurance related information.
+ * - Financer: account is for users who deal with financial related information.
+ * - Publisher: account is for users who perform publishing (marking content available and complete).
+ * - Auditor: account is for users who perform auditing. This account has read access to almost all data on the system.
+ * - Manager: account is for users who manager the entire system. This is a non-technical administration account.
+ * - Administer: account is for users who have full administrative access to the system. This is a technical administration account and supercedes Manager.
+ */
+class c_base_roles extends c_base_return {
+ const NONE = 0;
+ const PUBLIC = 1;
+ const SYSTEM = 2;
+ const USER = 3;
+ const REQUESTER = 4;
+ const DRAFTER = 5;
+ const EDITOR = 6;
+ const REVIEWER = 7;
+ const FINANCER = 8;
+ const INSURER = 9;
+ const PUBLISHER = 10;
+ const AUDITOR = 11;
+ const MANAGER = 12;
+ const ADMINISTER = 13;
+
+ protected $public;
+ protected $system;
+ protected $user;
+ protected $requester;
+ protected $drafter;
+ protected $editer;
+ protected $reviewer;
+ protected $financer;
+ protected $insurer;
+ protected $publisher;
+ protected $auditor;
+ protected $manager;
+ protected $administer;
+
+ /**
+ * Class constructor.
+ */
+ public function __construct() {
+ parent::__construct();
+
+ $this->public = TRUE;
+ $this->system = FALSE;
+ $this->user = FALSE;
+ $this->requester = FALSE;
+ $this->drafter = FALSE;
+ $this->editer = FALSE;
+ $this->reviewer = FALSE;
+ $this->insurer = FALSE;
+ $this->financer = FALSE;
+ $this->publisher = FALSE;
+ $this->auditor = FALSE;
+ $this->manager = FALSE;
+ $this->administer = FALSE;
+ }
+
+ /**
+ * Class destructor.
+ */
+ public function __destruct() {
+ unset($this->public);
+ unset($this->system);
+ unset($this->user);
+ unset($this->requester);
+ unset($this->drafter);
+ unset($this->editer);
+ unset($this->reviewer);
+ unset($this->insurer);
+ unset($this->financer);
+ unset($this->publisher);
+ unset($this->auditor);
+ unset($this->manager);
+ unset($this->administer);
+
+ parent::__destruct();
+ }
+
+ /**
+ * @see: t_base_return_value::p_s_new()
+ */
+ public static function s_new($value) {
+ return self::p_s_new($value, __CLASS__);
+ }
+
+ /**
+ * @see: t_base_return_value::p_s_value()
+ */
+ public static function s_value($return) {
+ return self::p_s_value($return, __CLASS__);
+ }
+
+ /**
+ * @see: t_base_return_value_exact::p_s_value_exact()
+ */
+ public static function s_value_exact($return) {
+ return self::p_s_value_exact($return, __CLASS__, array());
+ }
+
+ /**
+ * Assign a role.
+ *
+ * When role is set to NONE, and value is TRUE, then all roles are set to FALSE.
+ * When role is set to NONE and value is FALSE, nothing happens.
+ *
+ * @param int $role
+ * The role id to assign.
+ * @param bool $value
+ * Set the role value to TRUE/FALSE.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with error bit set is returned on error.
+ */
+ public function set_role($role, $value) {
+ if (!is_int($role)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'role', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_bool($value)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if ($role === self::NONE) {
+ if ($value) {
+ $this->public = FALSE;
+ $this->system = FALSE;
+ $this->user = FALSE;
+ $this->requester = FALSE;
+ $this->drafter = FALSE;
+ $this->editer = FALSE;
+ $this->reviewer = FALSE;
+ $this->insurer = FALSE;
+ $this->financer = FALSE;
+ $this->publisher = FALSE;
+ $this->auditor = FALSE;
+ $this->manager = FALSE;
+ $this->administer = FALSE;
+ }
+ }
+ elseif ($role === self::PUBLIC) {
+ $this->public = $value;
+ }
+ elseif ($role === self::SYSTEM) {
+ $this->system = $value;
+ }
+ elseif ($role === self::USER) {
+ $this->user = $value;
+ }
+ elseif ($role === self::REQUESTER) {
+ $this->requester = $value;
+ }
+ elseif ($role === self::DRAFTER) {
+ $this->drafter = $value;
+ }
+ elseif ($role === self::EDITOR) {
+ $this->editer = $value;
+ }
+ elseif ($role === self::REVIEWER) {
+ $this->reviewer = $value;
+ }
+ elseif ($role === self::INSURER) {
+ $this->insurer = $value;
+ }
+ elseif ($role === self::FINANCER) {
+ $this->financer = $value;
+ }
+ elseif ($role === self::PUBLISHER) {
+ $this->publisher = $value;
+ }
+ elseif ($role === self::AUDITOR) {
+ $this->auditor = $value;
+ }
+ elseif ($role === self::MANAGER) {
+ $this->manager = $value;
+ }
+ elseif ($role === self::ADMINISTER) {
+ $this->administer = $value;
+ }
+ else {
+ return new c_base_return_false();
+ }
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Assign multiple roles.
+ *
+ * This unassigns all roles and assigns only the provided roles.
+ *
+ * @param array $roles
+ * An array of role ids to set to TRUE.
+ * All others are set to FALSE, including PUBLIC.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with error bit set is returned on error.
+ */
+ public function set_roles($roles) {
+ if (!is_array($roles)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'roles', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->public = FALSE;
+ $this->system = FALSE;
+ $this->user = FALSE;
+ $this->requester = FALSE;
+ $this->drafter = FALSE;
+ $this->editer = FALSE;
+ $this->reviewer = FALSE;
+ $this->insurer = FALSE;
+ $this->financer = FALSE;
+ $this->publisher = FALSE;
+ $this->auditor = FALSE;
+ $this->manager = FALSE;
+ $this->administer = FALSE;
+
+ foreach ($roles as $role) {
+ if ($role === self::PUBLIC) {
+ $this->public = TRUE;
+ }
+ elseif ($role === self::SYSTEM) {
+ $this->system = TRUE;
+ }
+ elseif ($role === self::USER) {
+ $this->user = TRUE;
+ }
+ elseif ($role === self::REQUESTER) {
+ $this->requester = TRUE;
+ }
+ elseif ($role === self::DRAFTER) {
+ $this->drafter = TRUE;
+ }
+ elseif ($role === self::EDITOR) {
+ $this->editer = TRUE;
+ }
+ elseif ($role === self::REVIEWER) {
+ $this->reviewer = TRUE;
+ }
+ elseif ($role === self::INSURER) {
+ $this->insurer = TRUE;
+ }
+ elseif ($role === self::FINANCER) {
+ $this->financer = TRUE;
+ }
+ elseif ($role === self::PUBLISHER) {
+ $this->publisher = TRUE;
+ }
+ elseif ($role === self::AUDITOR) {
+ $this->auditor = TRUE;
+ }
+ elseif ($role === self::MANAGER) {
+ $this->manager = TRUE;
+ }
+ elseif ($role === self::ADMINISTER) {
+ $this->administer = TRUE;
+ }
+ }
+ unset($role);
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the current status of the specified role.
+ *
+ * When role is set to NONE, TRUE is returned when all values are set to FALSE.
+ * When role is set to NONE, FALSE is returned when any values are set to TRUE.
+ *
+ * @param int $role
+ * The role id to get the value of.
+ *
+ * @return c_base_return_status
+ * TRUE on enabled, FALSE on disabled.
+ * FALSE is returned for unknown role ids.
+ * FALSE with error bit set is returned on error.
+ */
+ public function get_role($role) {
+ if (!is_int($role)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'role', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if ($role === self::NONE) {
+ if (!($this->public || $this->system || $this->user || $this->requester || $this->drafter || $this->editer || $this->reviewer || $this->publisher || $this->auditor || $this->manager || $this->administer)) {
+ return new c_base_return_true();
+ }
+ }
+ elseif ($role === self::PUBLIC) {
+ if ($this->public) {
+ return new c_base_return_true();
+ }
+ }
+ elseif ($role === self::SYSTEM) {
+ if ($this->system) {
+ return new c_base_return_true();
+ }
+ }
+ elseif ($role === self::USER) {
+ if ($this->user) {
+ return new c_base_return_true();
+ }
+ }
+ elseif ($role === self::REQUESTER) {
+ if ($this->requester) {
+ return new c_base_return_true();
+ }
+ }
+ elseif ($role === self::DRAFTER) {
+ if ($this->drafter) {
+ return new c_base_return_true();
+ }
+ }
+ elseif ($role === self::EDITOR) {
+ if ($this->editer) {
+ return new c_base_return_true();
+ }
+ }
+ elseif ($role === self::REVIEWER) {
+ if ($this->reviewer) {
+ return new c_base_return_true();
+ }
+ }
+ elseif ($role === self::FINANCER) {
+ if ($this->financer) {
+ return new c_base_return_true();
+ }
+ }
+ elseif ($role === self::INSURER) {
+ if ($this->insurer) {
+ return new c_base_return_true();
+ }
+ }
+ elseif ($role === self::PUBLISHER) {
+ if ($this->publisher) {
+ return new c_base_return_true();
+ }
+ }
+ elseif ($role === self::AUDITOR) {
+ if ($this->auditor) {
+ return new c_base_return_true();
+ }
+ }
+ elseif ($role === self::MANAGER) {
+ if ($this->manager) {
+ return new c_base_return_true();
+ }
+ }
+ elseif ($role === self::ADMINISTER) {
+ if ($this->administer) {
+ return new c_base_return_true();
+ }
+ }
+
+ return new c_base_return_false();
+ }
+
+ /**
+ * Get an array of all currently assigned roles.
+ *
+ * @return c_base_return_array
+ * An array of roles are returned.
+ * An array with error bit set is returned on error.
+ */
+ public function get_roles() {
+ $roles = array();
+
+ if ($this->public) {
+ $roles[self::PUBLIC] = self::PUBLIC;
+ }
+
+ if ($this->system) {
+ $roles[self::SYSTEM] = self::SYSTEM;
+ }
+
+ if ($this->user) {
+ $roles[self::USER] = self::USER;
+ }
+
+ if ($this->requester) {
+ $roles[self::REQUESTER] = self::REQUESTER;
+ }
+
+ if ($this->drafter) {
+ $roles[self::DRAFTER] = self::DRAFTER;
+ }
+
+ if ($this->editer) {
+ $roles[self::EDITOR] = self::EDITOR;
+ }
+
+ if ($this->reviewer) {
+ $roles[self::REVIEWER] = self::REVIEWER;
+ }
+
+ if ($this->financer) {
+ $roles[self::FINANCER] = self::FINANCER;
+ }
+
+ if ($this->insurer) {
+ $roles[self::INSURER] = self::INSURER;
+ }
+
+ if ($this->publisher) {
+ $roles[self::PUBLISHER] = self::PUBLISHER;
+ }
+
+ if ($this->auditor) {
+ $roles[self::AUDITOR] = self::AUDITOR;
+ }
+
+ if ($this->manager) {
+ $roles[self::MANAGER] = self::MANAGER;
+ }
+
+ if ($this->administer) {
+ $roles[self::ADMINISTER] = self::ADMINISTER;
+ }
+
+ return c_base_return_array::s_new($roles);
+ }
+}
* @file
* Provides a class for managing sessions.
*/
-
-// include required files.
require_once('common/base/classes/base_error.php');
require_once('common/base/classes/base_return.php');
require_once('common/base/classes/base_form.php');
*/
class c_base_session extends c_base_return {
const PACKET_MAX_LENGTH = 8192;
+
const SOCKET_PATH_PREFIX = '/programs/sockets/sessionize_accounts/';
const SOCKET_PATH_SUFFIX = '/sessions.socket';
+
const PASSWORD_CLEAR_TEXT_LENGTH = 2048;
- private $socket;
- private $socket_directory;
- private $socket_path;
- private $socket_timeout;
- private $socket_error;
+ // @todo: currently not implemented, but added as concepts.
+ #const SESSION_TYPE_NONE = 0;
+ #const SESSION_TYPE_SESSIONIZE = 1; // currently implemented behavior.
+ #const SESSION_TYPE_PHP = 2;
+ #const SESSION_TYPE_DATABASE = 3;
+
+ protected $socket;
+ protected $socket_directory;
+ protected $socket_path;
+ protected $socket_timeout;
+ protected $socket_error;
- private $system_name;
+ protected $system_name;
- private $cookie;
+ protected $cookie;
- private $name;
- private $host;
- private $password;
- private $session_id;
- private $settings;
+ protected $name;
+ protected $host;
+ protected $password;
+ protected $session_id;
+ protected $settings;
- private $timeout_expire;
- private $timeout_max;
+ protected $timeout_expire;
+ protected $timeout_max;
- private $problems;
+ protected $problems;
- private $logged_in;
+ protected $user_current;
+ protected $user_session;
+
+ protected $logged_in;
+ protected $expired;
/**
$this->problems = NULL;
+ $this->user_current = NULL;
+ $this->user_session = NULL;
+
$this->logged_in = FALSE;
+ $this->expired = FALSE;
}
/**
unset($this->problems);
+ unset($this->user_current);
+ unset($this->user_session);
+
unset($this->logged_in);
+ unset($this->expired);
parent::__destruct();
}
*/
public function set_socket_directory($socket_directory) {
if (!is_null($socket_directory) && (!is_string($socket_directory) || empty($socket_directory))) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'socket_directory', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'socket_directory', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
if (!is_dir($socket_directory)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':directory_name' => $socket_directory, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_DIRECTORY);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{directory_name}' => $socket_directory, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_DIRECTORY);
return c_base_return_error::s_false($error);
}
*/
public function set_cookie($cookie) {
if (!is_null($cookie) && !($cookie instanceof c_base_cookie)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'cookie', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'cookie', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_system_name($system_name) {
if (!is_null($system_name) && (!is_string($system_name) || empty($system_name))) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'system_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'system_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_name($name) {
if (!is_null($name) && (!is_string($name) || empty($name))) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
if (mb_strlen($name) == 0 || preg_match('/^(\w|-)+$/i', $name) != 1) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'name', ':expected_format' => '. Alphanumeric and dash characters only', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{format_name}' => 'name', ':{expected_format}' => '. Alphanumeric and dash characters only', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
return c_base_return_error::s_false($error);
}
*/
public function set_host($host) {
if (!is_null($host) && (!is_string($host) || empty($host))) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'host', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'host', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
if (mb_strlen($host) == 0 || ip2long($host) === FALSE) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'host', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'host', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_password($password) {
if (!is_null($password) && (!is_string($password) || empty($password))) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'password', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'password', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
// deny 0-length passwords.
if (mb_strlen($password) == 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'password', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'password', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_setting($delta, $setting) {
if (!is_int($delta) && !is_string($delta)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'delta', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'delta', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_settings($settings) {
if (!is_null($settings) && !is_array($settings)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'settings', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'settings', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_session_id($session_id) {
if (!is_null($session_id) && (!is_string($session_id) || empty($session_id))) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'session_id', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'session_id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
// deny 0-length session_id.
if (mb_strlen($session_id) == 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'session_id', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'session_id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_timeout_expire($timeout_expire) {
if (!is_null($timeout_expire) && !is_int($timeout_expire)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'timeout_expire', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'timeout_expire', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_timeout_max($timeout_max) {
if (!is_null($timeout_max) && !is_int($timeout_max)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'timeout_max', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'timeout_max', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_problems($problems) {
if (!is_null($problems) && !is_array($problems)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'problems', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'problems', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_socket_timeout($seconds, $microseconds = 0, $receive = TRUE) {
if (!is_null($seconds) && (!is_int($seconds) || $seconds < 0)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'seconds', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'seconds', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($microseconds) || $microseconds < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'microseconds', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'microseconds', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($receive)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'receive', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'receive', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
unset($result);
$this->socket_error = @socket_last_error($this->socket);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_set_option', ':socket_error' => $this->socket_error, ':socket_error_message' => @socket_strerror($this->socket_error), ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'socket_set_option', ':{socket_error}' => $this->socket_error, ':{socket_error_message}' => @socket_strerror($this->socket_error), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
return c_base_return_error::s_false($error);
}
unset($result);
unset($result);
$this->socket_error = @socket_last_error($this->socket);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_set_option', ':socket_error' => $this->socket_error, ':socket_error_message' => @socket_strerror($this->socket_error), ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'socket_set_option', ':{socket_error}' => $this->socket_error, ':{socket_error_message}' => @socket_strerror($this->socket_error), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
return c_base_return_error::s_false($error);
}
unset($result);
}
/**
- * Assigns the logged in session status.
+ * Assigns the current user object.
*
- * @param bool $logged_in
- * Set to TRUE to designate logged in.
- * Set to FALSE to designate logged out.
+ * @param c_base_users_user|null $user
+ * The current user object (generally populated from the database).
+ * If NULL, then the user object is removed.
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
* FALSE with the error bit set is returned on error.
+ */
+ public function set_user_current($user) {
+ if (!is_null($user) && !($user instanceof c_base_users_user)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'user', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (is_object($user)) {
+ $this->user_current = clone($user);
+ }
+ else {
+ $this->user_current = NULL;
+ }
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Assigns the current user object.
*
- * @see: c_base_session::save()
+ * @param c_base_users_user|null $user
+ * The current user object (generally populated from the database).
+ * If NULL, then the user object is removed.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*/
- public function set_logged_in($logged_in) {
- if (!is_bool($logged_in)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'logged_in', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ public function set_user_session($user) {
+ if (!is_null($user) && !($user instanceof c_base_users_user)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'user', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
- $this->logged_in = $logged_in;
+ if (is_object($user)) {
+ $this->user_session = clone($user);
+ }
+ else {
+ $this->user_session = NULL;
+ }
+
return new c_base_return_true();
}
*/
public function get_setting($delta) {
if (!is_int($delta) && !is_string($delta)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'delta', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'delta', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
}
if (!array_key_exists($delta, $this->settings)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => $delta, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => $delta, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX);
return c_base_return_error::s_false($error);
}
}
/**
- * Get the logged in status of the session.
+ * Get the current user object
*
- * @return c_base_return_status
- * TRUE if logged in.
- * FALSE if logged out.
+ * @return c_base_users_user|c_base_return_null
+ * The user object is returned on success.
+ * NULL is returned if there is no user object assigned.
+ * The error bit set is returned on error.
+ */
+ public function get_user_current() {
+ if (is_object($this->user_current)) {
+ return clone($this->user_current);
+ }
+
+ return new c_base_return_null();
+ }
+
+ /**
+ * Get the session user object
+ *
+ * @return c_base_users_user|c_base_return_null
+ * The user object is returned on success.
+ * NULL is returned if there is no user object assigned.
* The error bit set is returned on error.
*/
- public function get_logged_in() {
- if (!is_bool($this->logged_in)) {
- $this->logged_in = FALSE;
+ public function get_user_session() {
+ if (is_object($this->user_session)) {
+ return clone($this->user_session);
}
- if ($this->logged_in) {
+ return new c_base_return_null();
+ }
+
+ /**
+ * Get or Assign the is logged_in boolean setting.
+ *
+ * @param bool|null $is_logged_in
+ * When a boolean, this is assigned as the current is logged_in setting.
+ * When NULL, the current setting is returned.
+ *
+ * @return c_base_return_bool|c_base_return_status
+ * When $is_logged_in is NULL, is logged_in boolean setting on success.
+ * FALSE with error bit is set on error.
+ */
+ public function is_logged_in($is_logged_in = NULL) {
+ if (!is_null($is_logged_in) && !is_bool($is_logged_in)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'is_logged_in', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (is_null($is_logged_in)) {
+ if (!is_bool($this->logged_in)) {
+ $this->logged_in = FALSE;
+ }
+
+ if ($this->logged_in) {
+ return new c_base_return_true();
+ }
+
+ return new c_base_return_false();
+ }
+
+ $this->logged_in = $is_logged_in;
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get or Assign the is expired boolean setting.
+ *
+ * @param bool|null $is_expired
+ * When a boolean, this is assigned as the current is expired setting.
+ * When NULL, the current setting is returned.
+ *
+ * @return c_base_return_bool|c_base_return_status
+ * When $is_expired is NULL, is expired boolean setting on success.
+ * FALSE with error bit is set on error.
+ */
+ public function is_expired($is_expired = NULL) {
+ if (!is_null($is_expired) && !is_bool($is_expired)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'is_expired', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (is_null($is_expired)) {
+ if (!is_bool($this->expired)) {
+ $this->expired = FALSE;
+ }
+
+ if ($this->expired) {
+ return new c_base_return_true();
+ }
+
+ return new c_base_return_false();
+ }
+
+ $this->expired = $is_expired;
+ return new c_base_return_true();
+ }
+
+ /**
+ * Returns the connected status.
+ *
+ * This represents whether or not the self::do_connect() function was successfully called.
+ * The state of the connection should still be checked.
+ *
+ * @return c_base_return_status
+ * TRUE when connected, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function is_connected() {
+ if (is_resource($this->socket)) {
return new c_base_return_true();
}
*/
function do_connect() {
if (is_resource($this->socket)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->socket', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->socket', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
if (is_null($this->system_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->system_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->system_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
@socket_clear_error();
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_create', ':socket_error' => $this->socket_error, ':socket_error_message' => @socket_strerror($this->socket_error), ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'socket_create', ':{socket_error}' => $this->socket_error, ':{socket_error_message}' => @socket_strerror($this->socket_error), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
return c_base_return_error::s_false($error);
}
$this->do_disconnect();
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_connect', ':socket_error' => $this->socket_error, ':socket_error_message' => @socket_strerror($this->socket_error), ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'socket_connect', ':{socket_error}' => $this->socket_error, ':{socket_error_message}' => @socket_strerror($this->socket_error), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
return c_base_return_error::s_false($error);
}
unset($connected);
*/
public function do_disconnect() {
if (!is_resource($this->socket)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->socket', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->socket', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
}
/**
- * Returns the connected status.
- *
- * This represents whether or not the self::do_connect() function was successfully called.
- * The state of the connection should still be checked.
- *
- * @return c_base_return_status
- * TRUE when connected, FALSE otherwise.
- * FALSE with the error bit set is returned on error.
- */
- public function is_connected() {
- if (is_resource($this->socket)) {
- return new c_base_return_true();
- }
-
- return new c_base_return_false();
- }
-
- /**
* Loads the session information from an open socket.
*
* @return c_base_return_status
*/
public function do_pull() {
if (is_null($this->host)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->host', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->host', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
if (is_null($this->session_id)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->session_id', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->session_id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->socket)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->socket', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->socket', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
if (empty($response['result']) || !is_array($response['result'])) {
unset($response);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->p_transfer', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->p_transfer', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function do_push($interval_expire = NULL, $interval_max = NULL) {
if (is_null($this->name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
if (is_null($this->host)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->host', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->host', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
if (is_null($this->password)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->password', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->password', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->socket)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->socket', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->socket', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
if (!is_null($interval_expire) && (!is_int($interval_expire) || $interval_expire < 1)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'interval_expires', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'interval_expires', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($interval_max) && (!is_int($interval_max) || $interval_max < 1)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'interval_max', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'interval_max', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$response = c_base_return_array::s_value_exact($response);
if (isset($response['error']) && isset($response['error']['message']) && is_string($response['error']['message'])) {
- $error = c_base_error::s_log(' ' . $response['error']['message'], array('arguments' => array(':operation_name' => 'this->p_transfer', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(' ' . $response['error']['message'], array('arguments' => array(':{operation_name}' => 'this->p_transfer', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
unset($response);
return c_base_return_error::s_false($error);
elseif (empty($response['result']) || !is_array($response['result'])) {
unset($response);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->p_transfer', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->p_transfer', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public function do_terminate() {
if (is_null($this->host)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->host', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->host', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
if (is_null($this->session_id)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->session_id', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->session_id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
if (!is_resource($this->socket)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->socket', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->socket', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
if (empty($response['result']) || !is_array($response['result'])) {
unset($response);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->p_transfer', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->p_transfer', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
}
/**
- * Closes (terminates) a session from an open socket.
- *
- * Unlike self::do_disconnect(), this does not close the connection to the socket, it closes the session itself.
- *
- * This is used to terminate a session before the expiration date and time is reached.
- * Use this on logout operations.
+ * Send a flush command to the connected session.
*
* @return c_base_return_status
* TRUE on success, FALSE on failure.
* FALSE with the error bit set is returned on error.
- *
- * @see: self::do_connect()
- * @see: self::p_transfer()
*/
public function do_flush() {
if (!is_resource($this->socket)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->socket', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->socket', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
if (empty($response['result']) || !is_array($response['result'])) {
unset($response);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->p_transfer', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->p_transfer', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
$this->socket_error = @socket_last_error($this->socket);
@socket_clear_error($this->socket);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_write', ':socket_error' => $this->socket_error, ':socket_error_message' => @socket_strerror($this->socket_error), ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'socket_write', ':{socket_error}' => $this->socket_error, ':{socket_error_message}' => @socket_strerror($this->socket_error), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
return c_base_return_error::s_false($error);
}
elseif ($written == 0) {
unset($written);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_write', ':socket_error' => NULL, ':socket_error_message' => 'No bytes written.', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'socket_write', ':{socket_error}' => NULL, ':{socket_error_message}' => 'No bytes written.', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
return c_base_return_error::s_false($error);
}
unset($written);
$this->socket_error = @socket_last_error($this->socket);
@socket_clear_error($this->socket);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_read', ':socket_error' => $this->socket_error, ':socket_error_message' => @socket_strerror($this->socket_error), ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'socket_read', ':{socket_error}' => $this->socket_error, ':{socket_error_message}' => @socket_strerror($this->socket_error), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
return c_base_return_error::s_false($error);
}
unset($json);
if ($response === FALSE) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'json_decode', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'json_decode', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides a class for managing system roles.
+ */
+require_once('common/base/classes/base_return.php');
+
+/**
+ * A class for managing user accounts.
+ *
+ * This extends c_base_return_array such that the user 'settings' field are stored in $this->value.
+ */
+class c_base_users_user extends c_base_return_array {
+ protected $id;
+ protected $id_external;
+ protected $id_sort;
+
+ protected $name_machine;
+ protected $name_human;
+
+ protected $address_email;
+
+ protected $roles;
+
+ protected $is_private;
+ protected $is_locked;
+ protected $is_deleted;
+
+ protected $can_manage_roles;
+
+ protected $date_created;
+ protected $date_changed;
+ protected $date_synced;
+ protected $date_locked;
+ protected $date_deleted;
+
+ /**
+ * Class constructor.
+ */
+ public function __construct() {
+ parent::__construct();
+
+ $this->id = NULL;
+ $this->id_external = NULL;
+ $this->id_sort = NULL;
+
+ $this->name_machine = NULL;
+ $this->name_human = NULL;
+
+ $this->address_email = NULL;
+
+ $this->roles = new c_base_roles();
+
+ $this->is_private = NULL;
+ $this->is_locked = NULL;
+ $this->is_deleted = NULL;
+
+ $this->can_manage_roles = NULL;
+
+ $this->date_created = NULL;
+ $this->date_changed = NULL;
+ $this->date_synced = NULL;
+ $this->date_locked = NULL;
+ $this->date_deleted = NULL;
+ }
+
+ /**
+ * Class destructor.
+ */
+ public function __destruct() {
+ unset($this->id);
+ unset($this->id_external);
+ unset($this->id_sort);
+
+ unset($this->name_machine);
+ unset($this->name_human);
+
+ unset($this->address_email);
+
+ unset($this->roles);
+
+ unset($this->is_private);
+ unset($this->is_locked);
+ unset($this->is_deleted);
+
+ unset($this->can_manage_roles);
+
+ unset($this->date_created);
+ unset($this->date_changed);
+ unset($this->date_synced);
+ unset($this->date_locked);
+ unset($this->date_deleted);
+
+ parent::__destruct();
+ }
+
+ /**
+ * @see: t_base_return_value::p_s_new()
+ */
+ public static function s_new($value) {
+ return self::p_s_new($value, __CLASS__);
+ }
+
+ /**
+ * @see: t_base_return_value::p_s_value()
+ */
+ public static function s_value($return) {
+ return self::p_s_value($return, __CLASS__);
+ }
+
+ /**
+ * @see: t_base_return_value_exact::p_s_value_exact()
+ */
+ public static function s_value_exact($return) {
+ return self::p_s_value_exact($return, __CLASS__, array());
+ }
+
+ /**
+ * Wrapper to c_base_roles::set_role()
+ *
+ * @see: c_base_roles::set_role()
+ */
+ public function set_role($role, $value) {
+ return $this->roles->set_role($role, $value);
+ }
+
+ /**
+ * Wrapper to c_base_roles::get_role()
+ *
+ * @see: c_base_roles::get_role()
+ */
+ public function get_role($role) {
+ return $this->roles->get_role($role);
+ }
+
+ /**
+ * Wrapper to c_base_roles::get_roles()
+ *
+ * @see: c_base_roles::get_roles()
+ */
+ public function get_roles() {
+ return $this->roles->get_roles();
+ }
+
+ /**
+ * Load user account from the specified database.
+ *
+ * @param c_base_database &$databae
+ * The already processed and ready to use database object.
+ * @param int|string|null|TRUE $user_name_or_id
+ * (optional) If an integer, represents the user id.
+ * If a string, represents the machine name of the user.
+ * If NULL, loads the roles for the current user.
+ * If TRUE, then load the current session user.
+ * @param bool $administrative
+ * (optional) When TRUE, loads as an administrative account, which may have access more accounts.
+ * When FALSE, load using normal methods.
+ *
+ * @return c_base_return_status
+ * TRUE on success.
+ * FALSE if unable to find roles.
+ * FALSE with error bit set on error.
+ */
+ public function do_load(&$database, $user_name_or_id = NULL, $administrative = FALSE) {
+ return new c_base_return_false();
+ }
+}
* @file
* Provides UTF-8 support.
*/
-
-// include required files.
require_once('common/base/classes/base_error.php');
require_once('common/base/classes/base_return.php');
*/
public static function s_is_UTF_8($text) {
if (!is_string($text)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public static function s_character_to_ordinal($character) {
if (!is_string($character)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'character', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'character', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($ordinal === FALSE) {
unset($ordinal);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'self::p_s_character_to_ordinal', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'self::p_s_character_to_ordinal', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public static function s_ordinal_to_character($ordinal) {
if (!is_int($ordinal)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'ordinal', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'ordinal', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public static function s_length_string($text) {
if (!is_string($text)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(0, 'c_base_return_int', $error);
}
if ($length === FALSE) {
unset($length);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'self::p_s_length_string', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'self::p_s_length_string', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_value(0, 'c_base_return_int', $error);
}
*/
public static function s_clean($text, $remove_bom = FALSE) {
if (!is_string($text)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
if (!is_bool($remove_bom)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'remove_bom', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'remove_bom', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
if ($sanitized === FALSE) {
unset($sanitized);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'self::p_s_clean', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'self::p_s_clean', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
*/
public static function s_split($text, $split_length = 1) {
if (!is_string($text)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
if (!is_int($split_length)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'split_length', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'split_length', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
if ($split === FALSE) {
unset($split);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'self::p_s_split', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'self::p_s_split', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
*/
public static function s_character_size_list($text) {
if (!is_string($text)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
if ($size_list === FALSE) {
unset($size_list);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'self::p_s_character_size_list', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'self::p_s_character_size_list', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
*/
public static function s_character_max_width($text) {
if (!is_string($text)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(0, 'c_base_return_int', $error);
}
if ($size_list === FALSE) {
unset($size_list);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'self::p_s_character_size_list', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'self::p_s_character_size_list', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_value(0, 'c_base_return_int', $error);
}
*/
public static function s_encode_html_character($character) {
if (!is_string($character)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'character', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'character', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
if ($encoded === FALSE) {
unset($encoded);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'self::p_s_encode_html_character', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'self::p_s_encode_html_character', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
*/
public static function s_encode_html($text) {
if (!is_string($text)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
if ($split === FALSE) {
unset($split);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'self::p_s_split', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'self::p_s_split', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
*/
public static function s_substring($text, $start = 0, $length = NULL) {
if (!is_string($text)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
if (!is_int($start)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'start', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'start', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
if (!is_null($length) && !is_int($length)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'length', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'length', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
*/
public static function s_lowercase($text) {
if (!is_string($text)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
*/
public static function s_uppercase($text) {
if (!is_string($text)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
*/
public static function s_is_bom($text) {
if (!is_string($text)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public static function s_file_has_bom($file_path) {
if (!is_string($file_path)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'file_path', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'file_path', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!file_exists($file_path)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':file_name' => $file_path, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_FILE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{file_name}' => $file_path, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_FILE);
return c_base_return_error::s_false($error);
}
*/
public static function s_string_has_bom($text) {
if (!is_string($text)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public static function s_prepend_bom($text) {
if (!is_string($text)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public static function s_reverse($text) {
if (!is_string($text)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
if ($split === FALSE) {
unset($split);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'self::p_s_split', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'self::p_s_split', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_value('', 'c_base_return_string', $error);
}
*/
public static function s_position_string($haystack, $needle, $offset = 0) {
if (!is_string($haystack)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'haystack', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'haystack', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($needle) && !is_string($needle)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'needle', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'needle', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($offset) || $offset < 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'offset', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'offset', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public static function s_string_to_ordinals($text) {
if (!is_string($text) && !is_array($text)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public static function s_ordinals_to_string($ordinals) {
if (!is_array($ordinals)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'ordinals', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'ordinals', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
foreach ($ordinals as $ordinal) {
$character = self::p_s_ordinal_to_character($ordinal);
if ($character === FALSE) {
- $errors[] = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->p_s_ordinal_to_character', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $errors[] = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->p_s_ordinal_to_character', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
continue;
}
*/
public static function s_ordinals_to_string_array($ordinals) {
if (!is_array($ordinals)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'ordinals', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'ordinals', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_value(array(), 'c_base_return_array', $error);
}
foreach ($ordinals as $ordinal) {
$character = self::p_s_ordinal_to_character($ordinal);
if ($character === FALSE) {
- $errors[] = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->p_s_ordinal_to_character', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $errors[] = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'this->p_s_ordinal_to_character', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
continue;
}
*/
public static function s_ordinal_array_to_string($ordinals) {
if (!is_array($ordinals)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'ordinals', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'ordinals', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public static function s_ordinal_to_codepoint($ordinal) {
if (!is_int($ordinal)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'ordinal', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'ordinal', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($codepoint === FALSE) {
unset($codepoint);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'self::p_s_orginal_to_codepoint', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'self::p_s_orginal_to_codepoint', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
*/
public static function s_count_substrings($haystack, $needle, $offset = 0, $length = NULL) {
if (!is_string($haystack)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'haystack', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'haystack', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_string($needle)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'needle', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'needle', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($offset)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'offset', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'offset', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($length) && !is_int($length)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'length', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'length', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public static function s_is_ascii($text) {
if (!is_string($text)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public static function s_strip_tags($text, $allowable_tags = '') {
if (!is_string($text)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_string($allowable_tags)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'allowable_tags', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'allowable_tags', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if ($sanitized === FALSE) {
unset($sanitized);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'self::p_s_clean', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'self::p_s_clean', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
return c_base_return_error::s_false($error);
}
* @file
* Provides a class for managing PHP warnings.
*/
-
-// include required files.
require_once('common/base/classes/base_return.php');
/**
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides the standard database class.
+ */
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+require_once('common/base/classes/base_database.php');
+
+/**
+ * Standard implementation of c_base_database().
+ */
+class c_standard_database extends c_base_database {
+ const LOG_TYPE_NONE = 0;
+ const LOG_TYPE_LOGIN = 1;
+ const LOG_TYPE_LOGOUT = 2;
+ const LOG_TYPE_CREATE_USER = 3;
+ const LOG_TYPE_LOGIN_FAILIRE = 4;
+
+ /**
+ * Write a log to the database, associated with the current user.
+ */
+ public function do_log_user($log_type, $response_code, $data = array()) {
+ if (!is_int($log_type)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'log_type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_int($response_code)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'response_code', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $query_string = 'insert into v_log_users_self_insert (log_title, log_type, log_severity, request_client, response_code, log_details)';
+ $query_string .= ' values ($1, $2, $3, ($4, $5, $6), $7, $8); ';
+
+ $query_parameters = array();
+ $query_parameters[3] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0';
+ $query_parameters[4] = isset($_SERVER['REMOTE_PORT']) ? $_SERVER['REMOTE_PORT'] : 0;
+ $query_parameters[5] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '' ;
+ $query_parameters[6] = $response_code;
+
+ if ($log_type === self::LOG_TYPE_LOGIN) {
+ $expires = NULL;
+ if (isset($data['expires']) && is_int($data['expires'])) {
+ $expires = $data['expires'];
+ }
+
+ $query_parameters[0] = "Logging in to the system.";
+ $query_parameters[1] = 17;
+ $query_parameters[2] = 1;
+ $query_parameters[7] = json_encode(array('expires' => $expires));
+
+ unset($expires);
+ }
+ elseif ($log_type === self::LOG_TYPE_LOGOUT) {
+ $query_parameters[0] = "Logging out of the system.";
+ $query_parameters[1] = 18;
+ $query_parameters[2] = 1;
+ $query_parameters[7] = NULL;
+ }
+ elseif ($log_type === self::LOG_TYPE_CREATE) {
+ $query_parameters[0] = "Created the user account.";
+ $query_parameters[1] = 27;
+ $query_parameters[2] = 1;
+ $query_parameters[7] = NULL;
+ }
+ elseif ($log_type === self::LOG_TYPE_LOGIN_FAILURE) {
+ $user_name = NULL;
+ if (isset($data['user_name']) && is_string($data['user_name'])) {
+ $user_name = $data['user_name'];
+ }
+
+ $query_parameters[0] = "Failed to login as the user '" . $user_name . "'.";
+ $query_parameters[1] = 17;
+ $query_parameters[2] = 2;
+ $query_parameters[7] = json_encode(array('user_name' => $user_name));
+
+ unset($user_name);
+ }
+ else {
+ return new c_base_return_false();
+ }
+
+ ksort($query_parameters);
+
+ $query_result = $this->do_query($query_string, $query_parameters);
+ unset($query_string);
+ unset($query_parameters);
+
+ if (c_base_return::s_has_error($query_result)) {
+ $last_error = $this->get_last_error()->get_value_exact();
+
+ $false = c_base_return_error::s_false($query_result->get_error());
+ if (!empty($last_error)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_error_message}' => $last_error, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_ERROR);
+ $false->set_error($error);
+ }
+ unset($last_error);
+
+ return $false;
+ }
+
+ return new c_base_return_true();
+ }
+}
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides the standard site index class.
+ */
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+require_once('common/base/classes/base_users.php');
+require_once('common/base/classes/base_cookie.php');
+require_once('common/base/classes/base_http.php');
+require_once('common/base/classes/base_http_status.php');
+require_once('common/base/classes/base_session.php');
+require_once('common/base/classes/base_paths.php');
+require_once('common/base/classes/base_languages.php');
+
+require_once('common/standard/classes/standard_paths.php');
+require_once('common/standard/classes/standard_users.php');
+require_once('common/standard/classes/standard_database.php');
+
+/**
+ * The standard class for use in index.php or equivalent.
+ */
+class c_standard_index extends c_base_return {
+ protected const HTTP_RESPONSE_PROTOCOL = 'HTTP/1.1';
+
+ protected $settings;
+
+ protected $http;
+ protected $session;
+ protected $database;
+
+ protected $languages_selected; // primary language of the document.
+ protected $lanaguages_all; // all languages used in the document.
+
+ protected $paths;
+ protected $processed; // unrenderred output.
+ protected $output; // renderred output.
+
+ private $original_output_buffering;
+
+ /**
+ * Class constructor.
+ */
+ public function __construct() {
+ parent::__construct();
+
+ $this->settings = array();
+
+ // database information
+ $this->settings['database_host'] = '127.0.0.1';
+ $this->settings['database_port'] = 5432;
+ $this->settings['database_name'] = NULL;
+ $this->settings['database_user_public'] = NULL;
+ $this->settings['database_timeout'] = 4;
+ $this->settings['database_ssl_mode'] = 'disable';
+ $this->settings['database_create_account_host'] = '127.0.0.1';
+ $this->settings['database_create_account_port'] = 5433;
+
+ // cookie/session information
+ $this->settings['cookie_name'] = NULL;
+ $this->settings['cookie_path'] = '/';
+ $this->settings['cookie_domain'] = '.localhost';
+ $this->settings['cookie_http_only'] = FALSE; // setting this to false will allow javascript to access this cookie, such as for ajax.
+ $this->settings['cookie_host_only'] = TRUE;
+ $this->settings['cookie_same_site'] = c_base_cookie::SAME_SITE_STRICT;
+ $this->settings['cookie_secure'] = TRUE;
+ $this->settings['session_socket'] = '/programs/sockets/sessionize_accounts/';
+ $this->settings['session_system'] = 'standard';
+ $this->settings['session_expire'] = 600; // 10 minutes
+ $this->settings['session_max'] = 1800; // 30 minutes
+
+ // ldap information
+ $this->settings['ldap_server'] = NULL; // 'ldaps://127.0.0.1:1636/';
+ $this->settings['ldap_bind_name'] = NULL;
+ $this->settings['ldap_bind_password'] = NULL;
+ $this->settings['ldap_base_dn'] = '';
+ $this->settings['ldap_fields'] = array();
+
+ // base settings
+ $this->settings['base_scheme'] = 'https';
+ $this->settings['base_host'] = 'localhost';
+ $this->settings['base_path'] = $this->settings['cookie_path']; // must end in a trailing slash.
+
+ if (!isset($_SERVER["HTTPS"])) {
+ $this->settings['base_scheme'] = 'http';
+ }
+
+ // The HTML tag <p>, represents a paragraph.
+ // However, many sites, services, and developers incorrectly use it to represent text.
+ // The definition of the word 'paragraph' contradicts this current usage of the HTML tag <p>.
+ // It is also important to note that many browsers will alter the content of the <p> tag to remove blocks of any kind, such as <ul>.
+ // The <span> tag does not seem to have this issue.
+ // Therefore, the use of HTML <p> tag is consider non-safe and likely to cause problems with formatting (because client browsers alter the HTML).
+ // This provides a way to still use <p> tags despite the implementation, usage, and context flaws.
+ $this->settings['standards_issue-use_p_tags'] = FALSE;
+
+ $this->http = new c_base_http();
+ $this->session = new c_base_session();
+ $this->database = new c_standard_database();
+
+ $this->languages_selected = NULL;
+ $this->languages_all = NULL;
+
+ $this->paths = NULL;
+ $this->processed = NULL;
+ $this->output = NULL;
+
+ $this->original_output_buffering = NULL;
+ }
+
+ /**
+ * Class destructor.
+ */
+ public function __destruct() {
+ unset($this->settings);
+
+ unset($this->user_current);
+ unset($this->user_session);
+
+ unset($this->http);
+ unset($this->session);
+ unset($this->database);
+
+ unset($this->languages_selected);
+ unset($this->languages_all);
+
+ unset($this->paths);
+ unset($this->processed);
+ unset($this->output);
+
+ unset($this->original_output_buffering);
+
+ parent::__destruct();
+ }
+
+ /**
+ * @see: t_base_return_value::p_s_new()
+ */
+ public static function s_new($value) {
+ return self::p_s_new($value, __CLASS__);
+ }
+
+ /**
+ * @see: t_base_return_value::p_s_value()
+ */
+ public static function s_value($return) {
+ return self::p_s_value($return, __CLASS__);
+ }
+
+ /**
+ * @see: t_base_return_value_exact::p_s_value_exact()
+ */
+ public static function s_value_exact($return) {
+ return self::p_s_value_exact($return, __CLASS__, array());
+ }
+
+ /**
+ * Initialize the default database settings.
+ *
+ * @param c_base_database &$database
+ * The database object.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with error bit set is returned on error.
+ */
+ public static function s_do_initialize_database(&$database) {
+ if (!($database instanceof c_base_database)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'database', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $database->do_query('set bytea_output to hex;');
+ $database->do_query('set search_path to s_administers,s_managers,s_auditors,s_publishers,s_insurers,s_financers,s_reviewers,s_editors,s_drafters,s_requesters,s_users,public;');
+ $database->do_query('set datestyle to us;');
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Initialize any globals as expected by this class.
+ *
+ * This is not intended to be called within this class because global should be global.
+ * This, or something like this, should instead be called within the appropriate index.php file.
+ *
+ * This is also not necessary given that the c_base_defaults_global is intended to be defined and included by the developer instead of being included by default.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with error bit set is returned on error.
+ */
+ public function do_initialize_globals() {
+ c_base_defaults_global::s_get_timestamp_session(TRUE);
+
+ $class = c_base_defaults_global::LANGUAGE_CLASS_DEFAULT;
+ c_base_defaults_global::s_set_languages(new $class());
+ unset($class);
+
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Execution the standard index.
+ *
+ * This should effectively be the 'main' function.
+ *
+ * @param string $paths_handler
+ * (optional) The name of a class that is an instance of c_base_paths.
+ * You must pre-load the class file before calling this function.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with error bit set is returned on error.
+ */
+ public function do_execute($paths_handler = 'c_standard_paths') {
+ if (!is_string($paths_handler) || strlen($paths_handler) == 0 || !class_exists($paths_handler) || !($paths_handler instanceof c_base_paths)) {
+ $paths_handler = 'c_standard_paths';
+ }
+
+ $this->pr_do_set_up();
+
+ $this->pr_do_receive_request();
+ gc_collect_cycles();
+
+ $this->pr_do_process_sessions();
+ gc_collect_cycles();
+
+ $this->pr_do_process_request($paths_handler);
+ gc_collect_cycles();
+
+ $this->pr_do_render_theme();
+ gc_collect_cycles();
+
+ $this->pr_do_build_response();
+ gc_collect_cycles();
+
+ $this->pr_do_send_response();
+ gc_collect_cycles();
+
+ $this->pr_do_break_down();
+ gc_collect_cycles();
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Perform any initial setup operations.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with error bit set is returned on error.
+ */
+ protected function pr_do_set_up() {
+ // turn off any op-caching (this is done for testing and will likely be commented out or removed in production).
+ ini_set('opcache.enable', FALSE);
+ ini_set('opcache.enable_cli', FALSE);
+
+ // disable output buffering.
+ $this->original_output_buffering = ini_get('output_buffering');
+ ini_set('output_buffering', FALSE);
+
+ $this->do_initialize_globals();
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Load and sanitize the request.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with error bit set is returned on error.
+ */
+ protected function pr_do_receive_request() {
+ $this->http->do_load_request();
+
+ // Assign a default response protocol.
+ $this->http->set_response_protocol(self::HTTP_RESPONSE_PROTOCOL);
+
+ // Assign a default response status (expected to be overridden by path handlers).
+ $this->http->set_response_status(c_base_http_status::OK);
+
+ // get the current language and assign the default, using us-english as a failsafe language.
+ $this->languages_all = c_base_defaults_global::s_get_languages()::s_get_ids()->get_value_exact();
+ if (is_array($this->languages_all) && !empty($this->languages_all)) {
+ $this->languages_selected = $this->http->select_language($this->languages_all)->get_value_exact();
+ }
+ else {
+ $this->languages_selected = i_base_languages::ENGLISH_US;
+ $this->languages_all = array(i_base_languages::ENGLISH_US => i_base_languages::ENGLISH_US, i_base_languages::ENGLISH => i_base_languages::ENGLISH);
+ }
+
+ // select the primary language.
+ $this->http->set_response_content_language($this->languages_selected, FALSE);
+
+ // this website is primarily us-english, also set this as an additional language because multi-lingual support is not 100% guaranteed.
+ if ($this->languages_selected != i_base_languages::ENGLISH_US) {
+ $this->http->set_response_content_language(i_base_languages::ENGLISH_US);
+ }
+
+ if ($this->languages_selected != i_base_languages::ENGLISH) {
+ $this->http->set_response_content_language(i_base_languages::ENGLISH);
+ }
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Load an process the sessions and session cookies.
+ *
+ * This processes existing connections, it does not create new ones.
+ *
+ * The database is generally not connected to here for performance reasons.
+ * Static content may not need database connections and so avoid connecting to the database when unnecessary.
+ * This means that user account information is not expected to be loaded into the session via this function.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * TRUE with error bit set is returned if no session cookie is defined.
+ * FALSE with error bit set is returned on error.
+ */
+ protected function pr_do_process_sessions() {
+ $cookie_login = $this->http->get_request(c_base_http::REQUEST_COOKIE, $this->settings['cookie_name']);
+
+ $no_session = FALSE;
+ if (!($cookie_login instanceof c_base_cookie)) {
+ $cookie_login = new c_base_cookie();
+
+ $no_session = TRUE;
+ }
+
+ // create a session object regardless of login session cookie.
+ $this->session = new c_base_session();
+ $this->session->set_socket_directory($this->settings['session_socket']);
+ $this->session->set_system_name($this->settings['session_system']);
+
+ // the requester should not have any control over specifying/changing these settings, so overwrite whatever is defined by the request cookie.
+ $cookie_login->set_name($this->settings['cookie_name']);
+ $cookie_login->set_path($this->settings['cookie_path']);
+ $cookie_login->set_domain($this->settings['cookie_domain']);
+ $cookie_login->set_http_only($this->settings['cookie_http_only']);
+ $cookie_login->set_host_only($this->settings['cookie_host_only']);
+ $cookie_login->set_same_site($this->settings['cookie_same_site']);
+ $cookie_login->set_secure($this->settings['cookie_secure']);
+
+ if (empty($_SERVER['REMOTE_ADDR'])) {
+ $this->session->set_host('0.0.0.0');
+ }
+ else {
+ $this->session->set_host($_SERVER['REMOTE_ADDR']);
+ }
+
+ // no session cookie has been defined, so there is no existing session to load.
+ if ($no_session) {
+ unset($cookie_login);
+ unset($no_session);
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{session_name}' => $this->settings['cookie_name'], ':{function_name}' => __FUNCTION__)), i_base_error_messages::NO_SESSION);
+ return c_base_return_error::s_true($error);
+ }
+ unset($no_session);
+
+ $cookie_data = $cookie_login->get_value_exact();
+ if (!($cookie_login->validate() instanceof c_base_return_true) || empty($cookie_data['session_id'])) {
+ $cookie_login->set_expires(-1);
+ $cookie_login->set_max_age(-1);
+ $this->session->set_cookie($cookie_login);
+ unset($cookie_login);
+
+ // cookie_login failed validation or the cookie contains no session id.
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{session_name}' => $this->settings['cookie_name'], ':{function_name}' => __FUNCTION__)), i_base_error_messages::SESSION_INVALID);
+
+ // also set the error on the session object.
+ $this->session->set_error($error);
+
+ $this->session->set_session_id(NULL);
+ $this->session->is_logged_in(FALSE);
+
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->session->set_session_id($cookie_data['session_id']);
+
+
+ // connect to the session using the given session id.
+ $session_connection = $this->session->do_connect();
+ if (c_base_return::s_has_error($session_connection)) {
+ // @todo: process the specific error conditions.
+ // some errors the cookie should be deleted and others it should remain untouched.
+
+ // also set the error on the session object.
+ $this->session->set_error($session_connection->get_error());
+ unset($session_connection);
+
+ $this->session->set_session_id(NULL);
+ $this->session->is_logged_in(FALSE);
+
+ return c_base_return_error::s_false($error);
+ }
+ unset($session_connection);
+
+ $session_loaded = $this->session->do_pull();
+ $this->session->do_disconnect();
+
+ if (c_base_return::s_has_error($session_loaded)) {
+ // @todo: process the specific error conditions.
+ // some errors the cookie should be deleted and others it should remain untouched.
+
+ // also set the error on the session object.
+ $this->session->set_error($session_loaded->get_error());
+ unset($session_loaded);
+
+ $this->session->set_session_id(NULL);
+ $this->session->is_logged_in(FALSE);
+
+ return c_base_return_error::s_false($error);
+ }
+
+ // if either the session name or password is undefined for any reason, then consider the session invalid and expire it.
+ if (is_null($this->session->get_name()->get_value()) || is_null($this->session->get_password()->get_value())) {
+ $cookie_login->set_expires(-1);
+ $cookie_login->set_max_age(-1);
+ $this->session->set_cookie($cookie_login);
+ unset($cookie_login);
+
+ $this->session->set_session_id(NULL);
+ $this->session->is_logged_in(FALSE);
+
+ return new c_base_return_true();
+ }
+
+ $this->session->is_logged_in(TRUE);
+ unset($session_loaded);
+
+ // check to see if the session timeout has been extended and if so, then update the cookie.
+ $session_expire = $this->session->get_timeout_expire()->get_value_exact();
+
+ // if the session is expired, do not extend it and expire it along with the cookie.
+ // by setting the is expired flag, special pages and login prompts can be presented to tell the user that their session is expired.
+ $session_difference = $session_expire - time();
+ if ($session_difference <= 0) {
+ unset($cookie_login);
+
+ $this->session->is_logged_in(FALSE);
+ $this->session->is_expired(TRUE);
+
+ return new c_base_return_true();
+ }
+
+ if ($session_expire > $cookie_data['expire']) {
+ $cookie_data['expire'] = gmdate("D, d-M-Y H:i:s T", $session_expire);
+ $cookie_login->set_value($cookie_data);
+ $cookie_login->set_expires($session_expire);
+ }
+ unset($session_expire);
+
+ $this->session->set_cookie($cookie_login);
+ unset($cookie_login);
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Connect to the database, loading any relevant information.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with error bit set is returned on error.
+ */
+ protected function pr_do_database_connect() {
+ if ($this->session->is_logged_in()->get_value_exact()) {
+ $user_name = $this->session->get_name()->get_value();
+ $password = $this->session->get_password()->get_value();
+ }
+ else {
+ $user_name = $this->settings['database_user_public'];
+ $password = NULL;
+ }
+
+ if (!is_string($user_name) || strlen($user_name) < 0) {
+ return new c_base_return_false();
+ }
+
+
+ // prepare the connection string.
+ $connection_string = new c_base_database_connection_string();
+ $connection_string->set_host($this->settings['database_host']);
+ $connection_string->set_port($this->settings['database_port']);
+ $connection_string->set_database($this->settings['database_name']);
+
+ $connection_string->set_user($user_name);
+ if (!is_null($password)) {
+ $connection_string->set_password($password);
+ }
+
+ $connection_string->set_ssl_mode($this->settings['database_ssl_mode']);
+ $connection_string->set_connect_timeout($this->settings['database_timeout']);
+
+ $this->database->set_connection_string($connection_string);
+ unset($connection_string);
+
+
+ // open a database connection
+ $result = $this->database->do_connect();
+ if (c_base_return::s_has_error($result)) {
+ return c_base_return_error::s_false($result->get_error());
+ }
+ unset($result);
+
+ self::s_do_initialize_database($this->database);
+
+
+ // load database session information.
+ $user_current = new c_standard_users_user();
+ if ($user_current->do_load($this->database) instanceof c_base_return_true) {
+ $this->session->set_user_current($user_current);
+ }
+ unset($user_current);
+
+ $user_session = new c_standard_users_user();
+ if ($user_session->do_load($this->database, TRUE) instanceof c_base_return_true) {
+ $this->session->set_user_current($user_session);
+ }
+ unset($user_session);
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Disconnect from the database.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with error bit set is returned on error.
+ */
+ protected function pr_do_database_disconnect() {
+ if ($this->database instanceof c_base_database && $this->database->is_connected()->get_value_exact()) {
+ $this->database->do_disconnect();
+ }
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Process the request.
+ *
+ * @param string $paths_handler
+ * The name of a class that is an instance of c_standard_paths.
+ * You must pre-load the class file before calling this function.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with error bit set is returned on error.
+ */
+ protected function pr_do_process_request($paths_handler) {
+ // @todo: handle database connection error and then call $paths_handler() to handle the appropriate errors.
+ $connected = $this->pr_do_database_connect();
+
+ // require $paths_handler to be a valid instance of c_base_paths.
+ // if it is not, then use the standard so that some sort of error handling can be performed..
+ if ($paths_handler instanceof c_standard_paths) {
+ $paths = new $paths_handler();
+ }
+ else {
+ $paths = new c_standard_paths();
+ }
+
+ if (c_base_return::s_has_error($connected)) {
+ unset($connected);
+
+ $executed = $paths->get_handler_server_error($this->http, $this->database, $this->session, $this->settings);
+ }
+ else {
+ unset($connected);
+
+ $executed = $paths->do_process_path($this->http, $this->database, $this->session, $this->settings);
+ }
+ unset($paths);
+
+ $this->processed = $executed->get_output();
+ unset($executed);
+
+ $this->pr_do_database_disconnect();
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Render any themes as the output.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with error bit set is returned on error.
+ */
+ protected function pr_do_render_theme() {
+ // @fixme: this needs to support more output types than just html.
+ $theme = new c_theme_html();
+ $theme->set_html($this->processed);
+ $theme->set_http($this->http);
+ $theme->render_markup();
+
+ $this->output = $theme->get_markup()->get_value_exact();
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Build the response for the client.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with error bit set is returned on error.
+ */
+ protected function pr_do_build_response() {
+ $this->http->set_response_checksum_header(c_base_http::CHECKSUM_ACTION_AUTO);
+ $this->http->set_response_content($this->output);
+
+
+
+
+ // send the session cookie if a session id is specified.
+ $session_id = $this->session->get_session_id()->get_value_exact();
+ if (!empty($session_id)) {
+ $cookie_login = $this->session->get_cookie();
+
+ if ($cookie_login instanceof c_base_cookie) {
+ $this->http->set_response_set_cookie($cookie_login);
+ }
+ unset($cookie_login);
+ }
+ unset($session_id);
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Send the response to the client.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with error bit set is returned on error.
+ */
+ protected function pr_do_send_response() {
+ // get current http header method, which may determine which headers to set or not set.
+ $method = $this->http->get_request(c_base_http::REQUEST_METHOD)->get_value_exact();
+ if (isset($method['data']) && is_int($method['data'])) {
+ $method = $method['data'];
+ }
+ else {
+ $method = c_base_http::HTTP_METHOD_NONE;
+ }
+
+ // add headers
+ $this->http->set_response_date();
+ $this->http->set_response_content_type('text/html');
+ #$this->http->set_response_etag();
+ #$this->http->set_response_last_modified(strtotime('now'));
+ #$this->http->set_response_expires(strtotime('+30 minutes'));
+ $this->http->set_response_pragma('no-cache');
+ $this->http->set_response_vary('Host');
+ $this->http->set_response_vary('User-Agent');
+ $this->http->set_response_vary('Accept');
+ $this->http->set_response_vary('Accept-Language');
+ #$this->http->set_response_warning('1234 This site is under active development.');
+
+
+ // finalize the content prior to sending headers to ensure header accuracy.
+ $this->http->encode_response_content();
+
+ // http head method responses do not sent content.
+ if ($method === c_base_http::HTTP_METHOD_HEAD) {
+ $this->http->set_response_content('', FALSE);
+ }
+
+
+ // manually disable output buffering (if enabled) when transfer headers and content.
+ #$old_output_buffering = ini_get('output_buffering');
+ #ini_set('output_buffering', 'off');
+
+
+ // when the headers are sent, checksums are created, so at this point all error output should be stored and not sent.
+ $this->http->send_response_headers(TRUE);
+
+
+ // once the header are sent, send the content.
+ $this->http->send_response_content();
+
+
+ #ini_set('output_buffering', $old_output_buffering);
+ #unset($old_output_buffering);
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Terminate any active database connections.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with error bit set is returned on error.
+ */
+ protected function pr_do_unload_database() {
+ if ($this->database->is_connected()) {
+ $this->database->do_disconnect();
+ }
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Perform any final break-down operations.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with error bit set is returned on error.
+ */
+ protected function pr_do_break_down() {
+ if (!is_null($this->original_output_buffering)) {
+ ini_set('output_buffering', $this->original_output_buffering);
+ }
+
+ // make sure the database is disconnected.
+ $this->pr_do_database_disconnect();
+
+ return new c_base_return_true();
+ }
+}
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides the standard site index class.
+ */
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+require_once('common/base/classes/base_paths.php');
+require_once('common/base/classes/base_markup.php');
+
+/**
+ * Provides standard extensions to base paths.
+ */
+class c_standard_path extends c_base_path {
+ protected const CSS_BASE = 'standard-';
+ protected const CSS_NAME = 'content-wrapper';
+
+ protected const CSS_AS_TITLE = 'as-title';
+ protected const CSS_AS_TEXT = 'as-text';
+ protected const CSS_AS_TEXT_BLOCK = 'as-text-block';
+ protected const CSS_AS_PARAGRAPH = 'as-paragraph';
+ protected const CSS_AS_PARAGRAPH_BLOCK = 'as-paragraph-block';
+
+ protected const CSS_IS_JAVASCRIPT_ENABLED = 'javascript-enabled';
+ protected const CSS_IS_JAVASCRIPT_DISABLED = 'javascript-disabled';
+ protected const CSS_IS_CONTENT_TYPE = 'is-html_5
+ ';
+ protected const CSS_DATE_YEAR = 'date-year-';
+ protected const CSS_DATE_MONTH = 'date-month-';
+ protected const CSS_DATE_WEEK_DAY = 'date-week_day-';
+ protected const CSS_DATE_DAY = 'date-day-';
+ protected const CSS_DATE_HOUR = 'date-hour-';
+ protected const CSS_DATE_MINUTE = 'date-minute-';
+ protected const CSS_DATE_SECOND = 'date-second-';
+
+ protected const CSS_PATH_PART = 'path-part-';
+ protected const CSS_PATH_FULL = 'path-full-';
+
+ protected $use_p_tags = NULL;
+ protected $base_path = NULL;
+ protected $user_name = NULL;
+
+
+ /**
+ * Class constructor.
+ */
+ public function __construct() {
+ parent::__construct();
+
+ $this->use_p_tags = FALSE;
+ $this->base_path = '';
+ $this->user_name = '';
+ }
+
+ /**
+ * Class destructor.
+ */
+ public function __destruct() {
+ unset($this->use_p_tags);
+ unset($this->base_path);
+ unset($this->user_name);
+
+ parent::__destruct();
+ }
+
+ /**
+ * Load any default settings.
+ *
+ * @param array $settings
+ * The array containing all of the settings to parse.
+ */
+ protected function pr_assign_defaults($settings) {
+ if (isset($settings['standards_issue-use_p_tags']) && is_bool($settings['standards_issue-use_p_tags'])) {
+ $this->use_p_tags = $settings['standards_issue-use_p_tags'];
+ }
+
+ if (isset($settings['base_path']) && is_string($settings['base_path'])) {
+ $this->base_path = $settings['base_path'];
+ }
+
+ if (isset($settings['database_user']) && is_string($settings['database_user'])) {
+ $this->user_name = $settings['database_user'];
+ }
+ }
+
+ /**
+ * Creates the standard wrapper.
+ *
+ * @return c_base_markup_tag
+ * The generated markup tag.
+ */
+ protected function pr_create_tag_wrapper() {
+ return c_theme_html::s_create_tag(c_base_markup_tag::TYPE_SECTION, self::CSS_BASE . self::CSS_NAME, array(self::CSS_BASE . self::CSS_NAME, self::CSS_NAME));
+ }
+
+ /**
+ * Creates the standard break tag.
+ *
+ * @return c_base_markup_tag
+ * The generated markup tag.
+ */
+ protected function pr_create_tag_break() {
+ return c_theme_html::s_create_tag(c_base_markup_tag::TYPE_BREAK);
+ }
+
+ /**
+ * Creates the standard title.
+ *
+ * @param int|string $text
+ * The text or the text code to use.
+ * @param array $arguments
+ * (optional) An array of arguments to convert into text.
+ *
+ * @return c_base_markup_tag
+ * The generated markup tag.
+ */
+ protected function pr_create_tag_title($text, $arguments = array()) {
+ if (is_int($text)) {
+ return c_theme_html::s_create_tag(c_base_markup_tag::TYPE_H1, NULL, array(self::CSS_AS_TITLE), $this->pr_get_text($text, $arguments));
+ }
+
+ return c_theme_html::s_create_tag(c_base_markup_tag::TYPE_H1, NULL, array(self::CSS_AS_TITLE), $text);
+ }
+
+ /**
+ * Creates the standard text.
+ *
+ * @param int|string $text
+ * The text or the text code to use.
+ * @param array $arguments
+ * (optional) An array of arguments to convert into text.
+ *
+ * @return c_base_markup_tag
+ * The generated markup tag.
+ */
+ protected function pr_create_tag_text($text, $arguments = array()) {
+ $type = c_base_markup_tag::TYPE_SPAN;
+ if ($this->use_p_tags) {
+ $type = c_base_markup_tag::TYPE_PARAGRAPH;
+ }
+
+ if (is_int($text)) {
+ return c_theme_html::s_create_tag($type, NULL, array(self::CSS_AS_TEXT), $this->pr_get_text($text, $arguments));
+ }
+
+ return c_theme_html::s_create_tag($type, NULL, array(self::CSS_AS_TEXT), $text);
+ }
+
+ /**
+ * Creates the standard paragraph.
+ *
+ * @param int|string $text
+ * The text or the text code to use.
+ * @param array $arguments
+ * (optional) An array of arguments to convert into text.
+ *
+ * @return c_base_markup_tag
+ * The generated markup tag.
+ */
+ protected function pr_create_tag_paragraph($text, $arguments = array()) {
+ $type = c_base_markup_tag::TYPE_SPAN;
+ if ($this->use_p_tags) {
+ $type = c_base_markup_tag::TYPE_PARAGRAPH;
+ }
+
+ if (is_int($text)) {
+ return c_theme_html::s_create_tag($type, NULL, array(self::CSS_AS_PARAGRAPH), $this->pr_get_text($text, $arguments));
+ }
+
+ return c_theme_html::s_create_tag($type, NULL, array(self::CSS_AS_PARAGRAPH), $text);
+ }
+
+ /**
+ * Creates the standard text, wrapped in a block.
+ *
+ * @param int|string|null $text
+ * The text or the text code to use.
+ * If NULL, only the block is created.
+ * @param array $arguments
+ * (optional) An array of arguments to convert into text.
+ *
+ * @return c_base_markup_tag
+ * The generated markup tag.
+ */
+ protected function pr_create_tag_text_block($text, $arguments = array()) {
+ $block = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, NULL, array(self::CSS_AS_TEXT_BLOCK));
+
+ if (!is_null($text)) {
+ $type = c_base_markup_tag::TYPE_SPAN;
+ if ($this->use_p_tags) {
+ $type = c_base_markup_tag::TYPE_PARAGRAPH;
+ }
+
+ if (is_int($text)) {
+ $tag = c_theme_html::s_create_tag($type, NULL, array(self::CSS_AS_TEXT), $this->pr_get_text($text, $arguments));
+ }
+ else {
+ $tag = c_theme_html::s_create_tag($type, NULL, array(self::CSS_AS_TEXT), $text);
+ }
+ unset($type);
+
+ $block->set_tag($tag);
+ unset($tag);
+ }
+
+ return $block;
+ }
+
+ /**
+ * Creates the standard text, wrapped in a block.
+ *
+ * @param int|string|null $text
+ * The text or the text code to use.
+ * If NULL, only the block is created.
+ * @param array $arguments
+ * (optional) An array of arguments to convert into text.
+ *
+ * @return c_base_markup_tag
+ * The generated markup tag.
+ */
+ protected function pr_create_tag_paragraph_block($text, $arguments = array()) {
+ $block = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, NULL, array(self::CSS_AS_PARAGRAPH_BLOCK));
+
+ if (!is_null($text)) {
+ $type = c_base_markup_tag::TYPE_SPAN;
+ if ($this->use_p_tags) {
+ $type = c_base_markup_tag::TYPE_PARAGRAPH;
+ }
+
+ if (is_int($text)) {
+ $tag = c_theme_html::s_create_tag($type, NULL, array(self::CSS_AS_PARAGRAPH_BLOCK), $this->pr_get_text($text, $arguments));
+ }
+ else {
+ $tag = c_theme_html::s_create_tag($type, NULL, array(self::CSS_AS_PARAGRAPH_BLOCK), $text);
+ }
+ unset($type);
+
+ $block->set_tag($tag);
+ unset($tag);
+ }
+
+ return $block;
+ }
+
+ /**
+ * Load the title text associated with this page.
+ *
+ * This is provided here as a means for a language class to override with a custom language for the title.
+ *
+ * @param array $arguments
+ * (optional) An array of arguments to convert into text.
+ *
+ * @return string|null
+ * A string is returned as the custom title.
+ * NULL is returned to enforce default title.
+ */
+ protected function pr_get_title($arguments = array()) {
+ return NULL;
+ }
+
+ /**
+ * Load text for a supported language.
+ *
+ * @param int $index
+ * A number representing which block of text to return.
+ * @param array $arguments
+ * (optional) An array of arguments to convert into text.
+ */
+ protected function pr_get_text($code, $arguments = array()) {
+ return '';
+ }
+
+ /**
+ * Create a new HTML markup class with default settings populated.
+ *
+ * @param c_base_http $http
+ * The entire HTTP information to allow for the execution to access anything that is necessary.
+ * @param c_base_database $database
+ * The database object, which is usually used by form and ajax paths.
+ * @param c_base_session &$session
+ * The current session.
+ * @param array $settings
+ * An array of additional settings that are usually site-specific.
+ *
+ * @return c_base_html
+ * The generated html is returned on success.
+ * The generated html with error bit set is returned on error.
+ */
+ protected function pr_create_html(&$http, &$database, &$session, $settings) {
+ $title = $this->pr_get_title();
+
+ $html = new c_base_html();
+
+ $request_uri = $http->get_request(c_base_http::REQUEST_URI)->get_value_exact();
+ if (isset($request_uri['data']) && is_string($request_uri['data'])) {
+ $request_uri = $request_uri['data'];
+ unset($request_uri['current']);
+ unset($request_uri['invalid']);
+
+ $request_path = $http->get_request_uri_relative($settings['base_path'])->get_value_exact();
+ }
+ else {
+ $request_uri = array(
+ 'scheme' => $settings['base_scheme'],
+ 'authority' => $settings['base_host'],
+ 'path' => $settings['base_path'],
+ 'query' => NULL,
+ 'fragment' => NULL,
+ 'url' => TRUE,
+ );
+
+ $request_path = '/';
+ }
+
+ // add date/time classes.
+ $instance = c_base_defaults_global::s_get_timestamp_session()->get_value_exact();
+ $class[] = self::CSS_DATE_YEAR . $html->sanitize_css(date('Y', $instance))->get_value_exact();
+ $class[] = self::CSS_DATE_MONTH . $html->sanitize_css(strtolower(date('F', $instance)))->get_value_exact();
+ $class[] = self::CSS_DATE_WEEK_DAY . $html->sanitize_css(strtolower(date('l', $instance)))->get_value_exact();
+ $class[] = self::CSS_DATE_DAY . $html->sanitize_css(date('d', $instance))->get_value_exact();
+ $class[] = self::CSS_DATE_HOUR . $html->sanitize_css(date('H', $instance))->get_value_exact();
+ $class[] = self::CSS_DATE_MINUTE . $html->sanitize_css(date('m', $instance))->get_value_exact();
+ $class[] = self::CSS_DATE_SECOND . $html->sanitize_css(date('s', $instance))->get_value_exact();
+ unset($instance);
+
+ // add path classes
+ $path = $http->get_request_uri_relative($request_uri['path'])->get_value_exact();
+ $path_parts = explode('/', $path);
+
+ if (is_array($path_parts)) {
+ $sanitized = NULL;
+ $delta = 0;
+ foreach ($path_parts as $path_part) {
+ $sanitized_part = $html->sanitize_css($path_part, TRUE)->get_value_exact();
+ $sanitized .= '-' . $sanitized_part;
+
+ $class[] = self::CSS_PATH_PART . $delta . '-' . $html->sanitize_css($sanitized_part)->get_value_exact();
+ $delta++;
+ }
+ unset($path_part);
+ unset($sanitized_part);
+
+ $class[] = self::CSS_PATH_FULL . $html->sanitize_css(substr($sanitized, 1))->get_value_exact();
+ unset($sanitized);
+ }
+ unset($path_parts);
+
+ $html->set_attribute_body(c_base_markup_attributes::ATTRIBUTE_CLASS, $class);
+ unset($class);
+
+
+ // assign id attribute
+ #$html->set_attribute(c_base_markup_attributes::ATTRIBUTE_ID, 'example-system');
+ #$html->set_attribute_body(c_base_markup_attributes::ATTRIBUTE_ID, 'example-system-body');
+
+
+ // assign language attribute.
+ $language = i_base_languages::ENGLISH_US;
+ $languages = $http->get_response_content_language()->get_value_exact();
+ if (is_array($languages) && !empty($languages)) {
+ $language = reset($languages);
+ }
+
+ $html->set_attribute(c_base_markup_attributes::ATTRIBUTE_LANGUAGE, $language);
+ unset($language);
+
+
+ // assign default direction attribute (@todo: this needs to come from the language attribute (when possible)).
+ $html->set_attribute(c_base_markup_attributes::ATTRIBUTE_DIRECTION, 'ltr');
+
+
+ // assign title header tag (setting title tag at delta 0 so that it can easily be overriden as needed).
+ if (is_string($title)) {
+ $tag = new c_base_markup_tag();
+ $tag->set_type(c_base_markup_tag::TYPE_TITLE);
+ $tag->set_text($title);
+ $html->set_header($tag, 0);
+ unset($tag);
+ }
+
+
+ // assign base header tag
+ if (isset($request_uri['path']) && is_string($request_uri['path']) && mb_strlen($request_uri['scheme']) > 0) {
+ $href = '';
+ if (isset($request_uri['scheme']) && is_string($request_uri['scheme']) && mb_strlen($request_uri['scheme']) > 0) {
+ if (isset($request_uri['authority']) && is_string($request_uri['authority']) && mb_strlen($request_uri['authority']) > 0) {
+ $href .= $request_uri['scheme'] . '://' . $request_uri['authority'];
+ }
+ }
+
+ $href .= $request_uri['path'];
+
+ $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_BASE);
+ $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $href);
+ $html->set_header($tag);
+ unset($tag);
+ unset($href);
+ }
+
+
+ // assign http-equiv header tag
+ $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
+ $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HTTP_EQUIV, 'Content-Type');
+ $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, 'text/html; charset=utf-8');
+ $html->set_header($tag);
+ unset($tag);
+
+
+ // assign charset header tag
+ $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
+ $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CHARACTER_SET, c_base_charset::UTF_8);
+ $html->set_header($tag);
+ unset($tag);
+
+
+ // assign canonical header tag
+ $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
+ $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical');
+ $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $request_uri['scheme'] . '://' . $request_path);
+ $html->set_header($tag);
+ unset($tag);
+
+
+ // assign shortlink header tag
+ $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
+ $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'shortlink');
+ $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $request_path);
+ $html->set_header($tag);
+ unset($tag);
+
+ unset($request_path);
+ unset($request_uri);
+
+
+ // assign distribution header tag
+ $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
+ $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_NAME, 'distribution');
+ $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, 'web');
+ $html->set_header($tag);
+ unset($tag);
+
+
+ // assign robots header tag
+ $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
+ $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_NAME, 'robots');
+ $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, 'INDEX,FOLLOW');
+ $html->set_header($tag);
+ unset($tag);
+
+
+ // assign viewport header tag
+ $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
+ $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_NAME, 'viewport');
+ $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, 'width=device-width, initial-scale=1');
+ $html->set_header($tag);
+ unset($tag);
+
+
+ // assign content http-equiv header tag
+ $aliases = array();
+ if (is_array($languages) && !empty($languages)) {
+ // assign the primary language.
+ $language_aliases = c_base_defaults_global::s_get_languages()::s_get_aliases_by_id(reset($languages))->get_value_exact();
+ if (is_array($language_aliases) && !empty($language_aliases)) {
+ $html->set_attribute(c_base_markup_attributes::ATTRIBUTE_LANGUAGE, reset($language_aliases));
+ }
+ unset($language_aliases);
+
+ foreach ($languages as $language) {
+ $language_aliases = c_base_defaults_global::s_get_languages()::s_get_aliases_by_id($language)->get_value_exact();
+ if (is_array($language_aliases) && !empty($language_aliases)) {
+ $aliases[] = array_pop($language_aliases);
+ }
+ unset($language_aliases);
+ }
+ unset($language);
+ }
+ unset($languages);
+
+ if (!empty($aliases)) {
+ $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
+ $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HTTP_EQUIV, 'content-language');
+ $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, implode(', ', $aliases));
+ $html->set_header($tag);
+ unset($tag);
+ }
+ unset($aliases);
+
+
+ // provide a custom javascript for detecting if javascript is enabled and storing in a css class name.
+ $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_SCRIPT);
+ $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_TYPE, c_base_mime::TYPE_TEXT_JS);
+
+ $javascript = 'function f_standard_paths_hmtl_javascript_detection() {';
+ $javascript .= 'document.body.removeAttribute(\'onLoad\');';
+ $javascript .= 'document.body.className = document.body.className.replace(/\b' . self::CSS_IS_JAVASCRIPT_DISABLED . '\b/i, \'' . self::CSS_IS_JAVASCRIPT_ENABLED . '\');';
+ $javascript .= '}';
+ $tag->set_text($javascript);
+ unset($javascript);
+
+ $html->set_header($tag);
+ $html->set_attribute_body(c_base_markup_attributes::ATTRIBUTE_ON_LOAD, 'f_standard_paths_hmtl_javascript_detection();');
+ unset($tag);
+
+ return $html;
+ }
+}
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides the standard site index class.
+ */
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+require_once('common/base/classes/base_paths.php');
+
+require_once('common/standard/classes/standard_path.php');
+
+/**
+ * The standard class for use in index.php or equivalent.
+ */
+class c_standard_paths extends c_base_return {
+ protected const PATH_LOGIN = 'common/standard/paths/u/';
+ protected const PATH_LOGOUT = 'common/standard/paths/u/';
+ protected const PATH_ACCESS_DENIED = 'common/standard/internal/';
+ protected const PATH_NOT_FOUND = 'common/standard/internal/';
+ protected const PATH_BAD_METHOD = 'common/standard/internal/';
+ protected const PATH_SERVER_ERROR = 'common/standard/internal/';
+ protected const PATH_OPTIONS_METHOD = 'common/standard/internal/';
+ protected const PATH_DASHBOARD_USER = 'common/standard/paths/u/';
+ protected const PATH_DASHBOARD_MANAGEMENT = 'common/standard/paths/m/';
+ protected const PATH_DASHBOARD_ADMINISTER = 'common/standard/paths/a/';
+ protected const PATH_INDEX = 'common/standard/internal/';
+
+ protected const NAME_LOGIN = 'login';
+ protected const NAME_LOGOUT = 'logout';
+ protected const NAME_ACCESS_DENIED = 'access_denied';
+ protected const NAME_NOT_FOUND = 'not_found';
+ protected const NAME_BAD_METHOD = 'bad_method';
+ protected const NAME_SERVER_ERROR = 'server_error';
+ protected const NAME_OPTIONS_METHOD = 'options';
+ protected const NAME_DASHBOARD_USER = 'dashboard';
+ protected const NAME_DASHBOARD_MANAGEMENT = 'dashboard';
+ protected const NAME_DASHBOARD_ADMINISTER = 'dashboard';
+ protected const NAME_INDEX = 'index';
+
+ protected const HANDLER_LOGIN = 'c_standard_path_user_login';
+ protected const HANDLER_LOGOUT = 'c_standard_path_user_logout';
+ protected const HANDLER_NOT_FOUND = 'c_standard_path_not_found';
+ protected const HANDLER_ACCESS_DENIED = 'c_standard_path_access_denied';
+ protected const HANDLER_BAD_METHOD = 'c_standard_path_bad_method';
+ protected const HANDLER_SERVER_ERROR = 'c_standard_path_server_error';
+ protected const HANDLER_OPTIONS_METHOD = 'c_standard_path_options_method';
+ protected const HANDLER_USER_DASHBOARD = 'c_standard_path_user_dashboard';
+ protected const HANDLER_MANAGEMENT_DASHBOARD = 'c_standard_path_management_dashboard';
+ protected const HANDLER_ADMINISTER_DASHBOARD = 'c_standard_path_administer_dashboard';
+ protected const HANDLER_INDEX = 'c_standard_path_index';
+
+ protected const URI_LOGIN = '/u/login';
+ protected const URI_LOGOUT = '/u/logout';
+ protected const URI_DASHBOARD_USER = '/u/dashboard';
+ protected const URI_DASHBOARD_MANAGEMENT = '/m/dashboard';
+ protected const URI_DASHBOARD_ADMINISTER = '/a/dashboard';
+
+ protected const SCRIPT_EXTENSION = '.php';
+
+ // a class name to prepend to css classes or id attributes.
+ protected const CSS_BASE = 'standard-';
+
+ protected $handler;
+ protected $paths;
+
+ protected $http;
+ protected $database;
+ protected $session;
+ protected $settings;
+
+ protected $alias;
+
+ protected $output;
+
+ /**
+ * Class constructor.
+ */
+ public function __construct() {
+ parent::__construct();
+
+ $this->handler = NULL;
+ $this->paths = array();
+
+ $this->http = NULL;
+ $this->database = NULL;
+ $this->session = NULL;
+ $this->settings = NULL;
+
+ $this->alias = NULL;
+
+ $this->output = NULL;
+ }
+
+ /**
+ * Class destructor.
+ */
+ public function __destruct() {
+ unset($this->handler);
+ unset($this->paths);
+
+ unset($this->http);
+ unset($this->database);
+ unset($this->session);
+ unset($this->settings);
+
+ unset($this->alias);
+
+ unset($this->output);
+
+ parent::__destruct();
+ }
+
+ /**
+ * @see: t_base_return_value::p_s_new()
+ */
+ public static function s_new($value) {
+ return self::p_s_new($value, __CLASS__);
+ }
+
+ /**
+ * @see: t_base_return_value::p_s_value()
+ */
+ public static function s_value($return) {
+ return self::p_s_value($return, __CLASS__);
+ }
+
+ /**
+ * @see: t_base_return_value_exact::p_s_value_exact()
+ */
+ public static function s_value_exact($return) {
+ return self::p_s_value_exact($return, __CLASS__, array());
+ }
+
+ /**
+ * Load and return the login handler.
+ *
+ * @return c_base_path
+ * A path object.
+ */
+ public function get_handler_login() {
+ return $this->pr_include_path(self::PATH_LOGIN, self::NAME_LOGIN, self::HANDLER_LOGIN);
+ }
+
+ /**
+ * Load and return the logout handler.
+ *
+ * @return c_base_path
+ * A path object.
+ */
+ public function get_handler_logout() {
+ return $this->pr_include_path(self::PATH_LOGOUT, self::NAME_LOGOUT, self::HANDLER_LOGOUT);
+ }
+
+ /**
+ * Load and return the not found handler.
+ *
+ * @return c_base_path
+ * A path object.
+ */
+ public function get_handler_not_found() {
+ return $this->pr_include_path(self::PATH_NOT_FOUND, self::NAME_NOT_FOUND, self::HANDLER_NOT_FOUND);
+ }
+
+ /**
+ * Load and return the access denied handler.
+ *
+ * @return c_base_path
+ * A path object.
+ */
+ public function get_handler_access_denied() {
+ return $this->pr_include_path(self::PATH_ACCESS_DENIED, self::NAME_ACCESS_DENIED, self::HANDLER_ACCESS_DENIED);
+ }
+
+ /**
+ * Load and return the not found handler.
+ *
+ * @return c_base_path
+ * A path object.
+ */
+ public function get_handler_bad_method() {
+ return $this->pr_include_path(self::PATH_BAD_METHOD, self::NAME_BAD_METHOD, self::HANDLER_BAD_METHOD);
+ }
+
+ /**
+ * Load and return the internal server error handler.
+ *
+ * @return c_base_path
+ * A path object.
+ */
+ public function get_handler_server_error() {
+ return $this->pr_include_path(self::PATH_SERVER_ERROR, self::NAME_SERVER_ERROR, self::HANDLER_SERVER_ERROR);
+ }
+
+ /**
+ * Load and return the options method handler.
+ *
+ * @return c_base_path
+ * A path object.
+ */
+ public function get_handler_options_method() {
+ return $this->pr_include_path(self::PATH_OPTIONS_METHOD, self::NAME_OPTIONS_METHOD, self::HANDLER_OPTIONS_METHOD);
+ }
+
+ /**
+ * Load and return the index handler.
+ *
+ * @return c_base_path
+ * A path object.
+ */
+ public function get_handler_index() {
+ return $this->pr_include_path(self::PATH_INDEX, self::NAME_INDEX, self::HANDLER_INDEX);
+ }
+
+ /**
+ * Process request path and determine what to do.
+ *
+ * @param c_base_http &$http
+ * The HTTP settings.
+ * @param c_base_database &database
+ * The current database.
+ * @param c_base_session &$session
+ * The current session.
+ * @param c_base_html &$html
+ * The html page object.
+ * @param array $settings
+ * The system settings array.
+ *
+ * @return c_base_path_executed
+ * The execution results.
+ * The execution results with the error bit set on error.
+ */
+ public function do_process_path(&$http, &$database, &$session, $settings) {
+ // @todo: these parameter errors might need a custom service unavailable and system log support.
+ if (!($http instanceof c_base_http)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'http', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_value(array(), 'c_base_path_executed', $error);
+ }
+
+ if (!($database instanceof c_base_database)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'database', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_value(array(), 'c_base_path_executed', $error);
+ }
+
+ if (!($session instanceof c_base_session)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'session', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_value(array(), 'c_base_path_executed', $error);
+ }
+
+ if (!is_array($settings)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'settings', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_value(array(), 'c_base_path_executed', $error);
+ }
+
+ if (!($session instanceof c_base_session)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'session', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_value(array(), 'c_base_path_executed', $error);
+ }
+
+ $this->http = &$http;
+ $this->database = &$database;
+ $this->session = &$session;
+ $this->settings = $settings;
+
+ $this->output = NULL;
+
+ $this->pr_get_language_alias();
+
+ // require HTTPS for access to any part of this website.
+ if (!isset($_SERVER["HTTPS"])) {
+ // @todo: redirect to https version of requested uri.
+ $failure_path = $this->get_handler_not_found();
+
+ return $failure_path->do_execute($this->http, $this->database, $this->session, $this->settings);
+ }
+
+
+ // load all available paths.
+ $this->pr_paths_create();
+
+
+ // load the http method.
+ $method = $this->http->get_request(c_base_http::REQUEST_METHOD)->get_value_exact();
+ if (isset($method['data']) && is_int($method['data'])) {
+ $method = $method['data'];
+ }
+ else {
+ $method = c_base_http::HTTP_METHOD_NONE;
+ }
+
+
+ // find the path
+ $path = $this->http->get_request_uri_relative($settings['base_path'])->get_value_exact();
+ $handler_settings = $this->paths->find_path($path)->get_value();
+ unset($path);
+
+ if (!is_array($handler_settings)) {
+ // for all invalid pages, report bad method if not HTTP GET or HTTP POST.
+ if ($method !== c_base_http::HTTP_METHOD_GET && $method !== c_base_http::HTTP_METHOD_POST) {
+ unset($method);
+
+ $failure_path = $this->get_handler_bad_method();
+
+ return $failure_path->do_execute($this->http, $this->database, $this->session, $this->settings);
+ }
+ unset($method);
+
+ $not_found = $this->get_handler_not_found();
+ return $not_found->do_execute($this->http, $this->database, $this->session, $this->settings);
+ }
+
+ // validate allowed methods.
+ if (isset($handler_settings['methods']) && is_array($handler_settings['methods'])) {
+ if (!array_key_exists($method, $handler_settings['methods'])) {
+ unset($method);
+
+ $failure_path = $this->get_handler_bad_method();
+
+ return $failure_path->do_execute($this->http, $this->database, $this->session, $this->settings);
+ }
+ }
+
+
+ // HTTP OPTIONS method does not process the page, only returns available methods.
+ if ($method === c_base_http::HTTP_METHOD_OPTIONS) {
+ unset($method);
+
+ $options_method_path = $this->get_handler_options_method();
+
+ if (isset($handler_settings['methods']) && is_array($handler_settings['methods'])) {
+ $options_method_path->set_allowed_methods($handler_settings['methods']);
+ }
+ else {
+ $options_method_path->set_allowed_methods(array());
+ }
+
+ return $options_method_path->do_execute($this->http, $this->database, $this->session, $this->settings);
+ }
+
+
+ if (array_key_exists('redirect', $handler_settings)) {
+ unset($method);
+
+ // successfully logged in.
+ if (!is_string($handler_settings['redirect'])) {
+ $handler_settings['redirect'] = '';
+ }
+
+ if (!isset($handler_settings['code']) || !is_int($handler_settings['code'])) {
+ $handler_settings['code'] = c_base_http_status::MOVED_PERMANENTLY;
+ }
+
+ $redirect = c_standard_path::s_create_redirect($handler_settings['redirect'], $handler_settings['code'], FALSE);
+ return $redirect->do_execute($this->http, $this->database, $this->session, $this->settings);
+ }
+ else {
+ if (!empty($handler_settings['include_name']) && is_string($handler_settings['include_name'])) {
+ require_once($handler_settings['include_directory'] . $handler_settings['include_name'] . self::SCRIPT_EXTENSION);
+ }
+
+ // execute path handler, using custom-language if defined.
+ if (empty($handler_settings['handler'])) {
+ return $this->get_handler_server_error()->do_execute($this->http, $this->database, $this->session, $this->settings);
+ }
+ elseif (is_string($this->alias)) {
+ @include_once($handler_settings['include_directory'] . $this->alias . '/' . $handler_settings['include_name']);
+
+ $handler_class = $handler_settings['handler'] . '_' . $this->alias;
+ if (class_exists($handler_class)) {
+ $this->handler = new $handler_class();
+
+ unset($handler_class);
+ }
+ else {
+ unset($handler_class);
+
+ // attempt to fallback to default handler if the language-specific handler class is not found.
+ if (!class_exists($handler_settings['handler'])) {
+ return $this->get_handler_server_error()->do_execute($this->http, $this->database, $this->session, $this->settings);
+ }
+ else {
+ $this->handler = new $handler_settings['handler']();
+ }
+ }
+ }
+ else {
+ if (class_exists($handler_settings['handler'])) {
+ $this->handler = new $handler_settings['handler']();
+ }
+ else {
+ return $this->get_handler_server_error()->do_execute($this->http, $this->database, $this->session, $this->settings);
+ }
+ }
+
+ if (isset($handler_settings['is_root']) && $handler_settings['is_root']) {
+ $this->handler->is_root(TRUE);
+ }
+
+ if (isset($handler_settings['id_group'])) {
+ $this->handler->set_id_group($handler_settings['id_group']);
+ }
+ }
+ unset($handler_settings);
+
+
+ return $this->pr_paths_normal($method);
+ }
+
+ /**
+ * Creates and returns a list of all available paths.
+ *
+ * Add/modify paths here as desired.
+ *
+ * @return c_base_paths
+ * The generated paths object.
+ */
+ protected function pr_paths_create() {
+ $this->paths = new c_base_paths();
+
+ // set root path to be the user dashboard.
+ $this->paths->add_path('', self::HANDLER_INDEX, self::PATH_INDEX, self::NAME_INDEX);
+
+ // create login/logout paths
+ $this->paths->add_path(self::URI_LOGIN, self::HANDLER_LOGIN, self::PATH_LOGIN, self::NAME_LOGIN);
+ $this->paths->add_path(self::URI_LOGOUT, self::HANDLER_LOGOUT, self::PATH_LOGOUT, self::NAME_LOGOUT);
+
+ // dashboards
+ $this->paths->add_path(self::URI_DASHBOARD_USER, self::HANDLER_USER_DASHBOARD, self::PATH_DASHBOARD_USER, self::NAME_DASHBOARD_USER);
+ $this->paths->add_path(self::URI_DASHBOARD_MANAGEMENT, self::HANDLER_MANAGEMENT_DASHBOARD, self::PATH_DASHBOARD_MANAGEMENT, self::NAME_DASHBOARD_MANAGEMENT);
+ $this->paths->add_path(self::URI_DASHBOARD_ADMINISTER, self::HANDLER_ADMINISTER_DASHBOARD, self::PATH_DASHBOARD_ADMINISTER, self::NAME_DASHBOARD_ADMINISTER);
+ }
+
+ /**
+ * Process request paths and determine what to do.
+ *
+ * @param int $method
+ * The id of the HTTP request method.
+ *
+ * @return c_base_path_executed
+ * The execution results.
+ * The execution results with the error bit set on error.
+ */
+ protected function pr_paths_normal($method) {
+ $id_group = $this->handler->get_id_group()->get_value_exact();
+
+ // regardless of path-specific settings, the following paths always require login credentials to access.
+ if ($id_group === c_base_ascii::LOWER_A || $id_group === c_base_ascii::LOWER_M || $id_group === c_base_ascii::LOWER_U) {
+ $this->handler->is_private(TRUE);
+ }
+
+
+ if (class_exists('c_standard_path_user_login') && $this->handler instanceof c_standard_path_user_login) {
+ unset($id_group);
+ return $this->handler->do_execute($this->http, $this->database, $this->session, $this->settings);
+ }
+ elseif (class_exists('c_standard_path_user_logout') && $this->handler instanceof c_standard_path_user_logout) {
+ // if the user is not logged in. then provide a page not found for logout path.
+ if (!$this->session->is_logged_in()->get_value_exact()) {
+ unset($id_group);
+ return $this->get_handler_not_found()->do_execute($this->http, $this->database, $this->session, $this->settings);
+ }
+ }
+
+
+ // if the request is private, make sure the user is logged in.
+ if ($id_group === c_base_ascii::LOWER_A || $id_group === c_base_ascii::LOWER_M || $id_group === c_base_ascii::LOWER_U || $this->handler->is_private()->get_value_exact()) {
+ if ($this->session->is_logged_in()->get_value_exact()) {
+ unset($id_group);
+ return $this->handler->do_execute($this->http, $this->database, $this->session, $this->settings);
+ }
+ elseif ($this->handler->is_root()->get_value_exact()) {
+ unset($id_group);
+
+ $this->http->set_response_status(c_base_http_status::FORBIDDEN);
+
+ $login_path = $this->get_handler_login();
+ return $login_path->do_execute($this->http, $this->database, $this->session, $this->settings);
+ }
+ else {
+ // some special case paths always provide login prompt along with access denied.
+ if ($id_group === c_base_ascii::LOWER_A || $id_group === c_base_ascii::LOWER_M || $id_group === c_base_ascii::LOWER_U) {
+ unset($id_group);
+
+ $this->http->set_response_status(c_base_http_status::FORBIDDEN);
+
+ $login_path = $this->get_handler_login();
+ return $login_path->do_execute($this->http, $this->database, $this->session, $this->settings);
+ }
+ }
+ }
+ else {
+ unset($id_group);
+ return $this->handler->do_execute($this->http, $this->database, $this->session, $this->settings);
+ }
+
+ // return access denied or page not found depending on path and privacy settings.
+ if ($id_group === c_base_ascii::LOWER_C || $id_group === c_base_ascii::LOWER_D || $id_group === c_base_ascii::LOWER_T || $id_group === c_base_ascii::LOWER_X || $id_group === c_base_ascii::LOWER_F) {
+ // these always return not found for these paths.
+ $failsafe_path = $this->get_handler_not_found();
+ }
+ elseif ($this->handler->is_private()->get_value_exact() && $id_group !== c_base_ascii::NULL) {
+ // non private, and non-special case paths should return access denied as per normal behavior.
+ $failsafe_path = $this->get_handler_access_denied();
+ }
+ else {
+ // all other case, return not found.
+ $failsafe_path = $this->get_handler_not_found();
+ }
+ unset($id_group);
+
+ return $failsafe_path->do_execute($this->http, $this->database, $this->session, $this->settings);
+ }
+
+ /**
+ * Process request path form paths and determine what to do.
+ *
+ * @return c_base_path_executed
+ * The execution results.
+ * The execution results with the error bit set on error.
+ */
+ protected function pr_paths_forms() {
+ // @todo
+
+ // always return not found, do not inform user if the access is denied.
+ $failsafe_path = $this->get_handler_not_found();
+
+ return $failsafe_path->do_execute($this->http, $this->database, $this->session, $this->settings);
+ }
+
+ /**
+ * Process request path ajax paths and determine what to do.
+ *
+ * @return c_base_path_executed
+ * The execution results.
+ * The execution results with the error bit set on error.
+ */
+ protected function pr_paths_ajax() {
+ // @todo
+
+ // always return not found, do not inform user if the access is denied.
+ $failsafe_path = $this->get_handler_not_found();
+
+ return $failsafe_path->do_execute($this->http, $this->database, $this->session, $this->settings);
+ }
+
+ /**
+ * Load and save the current preferred language alias.
+ *
+ * This will be stored in $this->alias.
+ */
+ protected function pr_get_language_alias() {
+ $aliases = array();
+ $languages = $this->http->get_response_content_language()->get_value_exact();
+ if (is_array($languages) && !empty($languages)) {
+ $language = reset($languages);
+
+ // us-english is the default, so do not attempt to include any external files.
+ if ($language === i_base_languages::ENGLISH_US || $language === i_base_languages::ENGLISH) {
+ unset($language);
+ unset($aliases);
+ unset($languages);
+
+ $this->alias = NULL;
+ return;
+ }
+
+ $aliases = c_base_defaults_global::s_get_languages()::s_get_aliases_by_id($language)->get_value_exact();
+ }
+ unset($language);
+
+ // use default if no aliases are found.
+ if (empty($aliases)) {
+ unset($aliases);
+ unset($languages);
+
+ $this->alias = NULL;
+ return;
+ }
+
+ $this->alias = end($aliases);
+ }
+
+ /**
+ * Will include a custom language path if one exists.
+ *
+ * The default language files ends in "${path}${name}.php".
+ * All other language files end in "${path}${language_alias}/${name}.php".
+ *
+ * The default class is the provided class name.
+ * All other languages use the provided class name with '_${language_alias}' appended.
+ *
+ * For example (using path='my_file'), us english is the default, so that would load the file 'my_file.php'.
+ * japanese language load the file 'my_file-ja.php'.
+ *
+ * @param string $path
+ * The path to the include file, without the file name.
+ * @param string $name
+ * The file name of the PHP file, without the '.php' extension.
+ * @param string $class
+ * The name of the class, that is an instance of c_base_path, to execute.
+ *
+ * @return c_base_path
+ * The created c_base_path object.
+ */
+ protected function pr_include_path($path, $name, $class) {
+ require_once($path . $name . self::SCRIPT_EXTENSION);
+
+ // use default if no aliases are found.
+ if (is_null($this->alias)) {
+ return new $class();
+ }
+
+ // use include_once instead of require_require to allow for failsafe behavior.
+ @include_once($path . $this->alias . '/' . $name . self::SCRIPT_EXTENSION);
+
+ $language_class = $class . '_' . $this->alias;
+ if (class_exists($language_class)) {
+ return new $language_class();
+ }
+ unset($language_class);
+
+ // if unable to find, fallback to original class
+ return new $class();
+ }
+}
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides a class for managing system roles.
+ */
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+require_once('common/base/classes/base_roles.php');
+require_once('common/base/classes/base_database.php');
+
+/**
+ * Standard implementation of c_base_users_user().
+ */
+class c_standard_users_user extends c_base_users_user {
+
+ /**
+ * Class constructor.
+ */
+ public function __construct() {
+ parent::__construct();
+
+ }
+
+ /**
+ * Class destructor.
+ */
+ public function __destruct() {
+
+ parent::__destruct();
+ }
+
+ /**
+ * @see: t_base_return_value::p_s_new()
+ */
+ public static function s_new($value) {
+ return self::p_s_new($value, __CLASS__);
+ }
+
+ /**
+ * @see: t_base_return_value::p_s_value()
+ */
+ public static function s_value($return) {
+ return self::p_s_value($return, __CLASS__);
+ }
+
+ /**
+ * @see: t_base_return_value_exact::p_s_value_exact()
+ */
+ public static function s_value_exact($return) {
+ return self::p_s_value_exact($return, __CLASS__, array());
+ }
+
+ /**
+ * @see: c_base_users_user::do_load()
+ */
+ public function do_load(&$database, $user_name_or_id = NULL, $administrative = FALSE) {
+ if (!($database instanceof c_base_database)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'database', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_null($user_name_or_id) && !is_int($user_name_or_id) && $user_name_or_id !== TRUE && !is_string($user_name_or_id)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'user_name_or_id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_bool($administrative)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'administrative', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $query_string = 'select id, id_external, id_sort, name_machine, name_human, address_email, is_public, is_system, is_requester, is_drafter, is_editor, is_reviewer, is_insurer, is_financer, is_publisher, is_auditor, is_manager, is_administer, is_private, is_locked, is_deleted, can_manage_roles, date_created, date_changed, date_synced, date_locked, date_deleted, settings ';
+ $query_arguments = array();
+
+ if (is_null($user_name_or_id)) {
+ $query_string .= 'from v_users_self';
+ }
+ elseif ($user_name_or_id === TRUE) {
+ $query_string .= 'from v_users_self_session';
+ }
+ else {
+ if ($use_table) {
+ $query_string .= 'from s_tables.t_users ';
+ }
+ else {
+ $query_string .= 'from v_users ';
+ }
+
+ $query_string .= 'where ';
+
+ if (is_int($user_name_or_id)) {
+ $query_string .= 'id = :{id} ';
+ $query_arguments[':{id}'] = $user_name_or_id;
+ }
+ else {
+ $query_string .= 'name_machine = :{name_machine} ';
+ $query_arguments[':{name_machine}'] = $user_name_or_id;
+ }
+ }
+
+ $query_result = $database->do_query($query_string, $query_arguments);
+ unset($query_string);
+ unset($query_arguments);
+
+ if (c_base_return::s_has_error($query_result)) {
+ $false = c_base_return_error::s_false($query_result->get_error());
+
+ $last_error = $database->get_last_error()->get_value_exact();
+ if (!empty($last_error)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_error_message}' => $last_error, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_ERROR);
+ $false->set_error($error);
+ }
+ unset($last_error);
+
+ return $false;
+ }
+
+ // @todo: this processes special postgresql datatypes.
+ // write custom handling functions and classes to handle things such as the 't' and 'f' for boolean types.
+ $columns = $query_result->fetch_row()->get_value();
+
+ if (is_array($columns) && !empty($columns)) {
+ $this->roles = new c_base_roles();
+
+ $this->id = (int) $columns[0];
+ $this->id_external = (int) $columns[1];
+ $this->id_sort = (int) $columns[2];
+
+ $this->name_machine = (string) $columns[3];
+ $this->name_human = (string) $columns[4];
+
+ // @todo: write functions for managing special postgresql types, such as this (possibly using special class types).
+ $this->address_email = array(
+ 'name' => NULL,
+ 'domain' => NULL,
+ 'private' => TRUE,
+ );
+
+ $address_email = (string) $columns[5];
+ if (!empty($address_email)) {
+ $address_email = mb_substr($address_email, 1);
+ $address_email = mb_substr($address_email, 0, mb_strlen($address_email) - 1);
+ $address_email_parts = explode(',', $address_email);
+ unset($address_email);
+
+ if (count($address_email_parts) == 3) {
+ $this->address_email = array(
+ 'name' => $address_email_parts[0],
+ 'domain' => $address_email_parts[1],
+ 'private' => TRUE,
+ );
+
+ if ($address_email_parts[2] == 'f') {
+ $this->address_email['private'] = FALSE;
+ }
+ }
+ unset($address_email_parts);
+ }
+
+ if ($columns[6] == 't') {
+ $this->roles->set_role(c_base_roles::PUBLIC, TRUE);
+ }
+ else {
+ $this->roles->set_role(c_base_roles::PUBLIC, FALSE);
+ }
+
+ if ($columns[7] == 't') {
+ $this->roles->set_role(c_base_roles::SYSTEM, TRUE);
+ }
+ else {
+ $this->roles->set_role(c_base_roles::SYSTEM, FALSE);
+ }
+
+ if ($columns[8] == 't') {
+ $this->roles->set_role(c_base_roles::REQUESTER, TRUE);
+ }
+ else {
+ $this->roles->set_role(c_base_roles::REQUESTER, FALSE);
+ }
+
+ if ($columns[9] == 't') {
+ $this->roles->set_role(c_base_roles::DRAFTER, TRUE);
+ }
+ else {
+ $this->roles->set_role(c_base_roles::DRAFTER, FALSE);
+ }
+
+ if ($columns[10] == 't') {
+ $this->roles->set_role(c_base_roles::EDITOR, TRUE);
+ }
+ else {
+ $this->roles->set_role(c_base_roles::EDITOR, FALSE);
+ }
+
+ if ($columns[11] == 't') {
+ $this->roles->set_role(c_base_roles::REVIEWER, TRUE);
+ }
+ else {
+ $this->roles->set_role(c_base_roles::REVIEWER, FALSE);
+ }
+
+ if ($columns[12] == 't') {
+ $this->roles->set_role(c_base_roles::FINANCER, TRUE);
+ }
+ else {
+ $this->roles->set_role(c_base_roles::FINANCER, FALSE);
+ }
+
+ if ($columns[13] == 't') {
+ $this->roles->set_role(c_base_roles::INSURER, TRUE);
+ }
+ else {
+ $this->roles->set_role(c_base_roles::INSURER, FALSE);
+ }
+
+ if ($columns[14] == 't') {
+ $this->roles->set_role(c_base_roles::PUBLISHER, TRUE);
+ }
+ else {
+ $this->roles->set_role(c_base_roles::PUBLISHER, FALSE);
+ }
+
+ if ($columns[15] == 't') {
+ $this->roles->set_role(c_base_roles::AUDITOR, TRUE);
+ }
+ else {
+ $this->roles->set_role(c_base_roles::AUDITOR, FALSE);
+ }
+
+ if ($columns[16] == 't') {
+ $this->roles->set_role(c_base_roles::MANAGER, TRUE);
+ }
+ else {
+ $this->roles->set_role(c_base_roles::MANAGER, FALSE);
+ }
+
+ if ($columns[17] == 't') {
+ $this->roles->set_role(c_base_roles::ADMINISTER, TRUE);
+ }
+ else {
+ $this->roles->set_role(c_base_roles::ADMINISTER, FALSE);
+ }
+
+ if ($columns[18] == 't') {
+ $this->is_private = TRUE;
+ }
+ else {
+ $this->is_private = FALSE;
+ }
+
+ if ($columns[19] == 't') {
+ $this->is_locked = TRUE;
+ }
+ else {
+ $this->is_locked = FALSE;
+ }
+
+ if ($columns[20] == 't') {
+ $this->is_deleted = TRUE;
+ }
+ else {
+ $this->is_deleted = FALSE;
+ }
+
+ if ($columns[21] == 't') {
+ $this->can_manage_roles = TRUE;
+ }
+ else {
+ $this->can_manage_roles = FALSE;
+ }
+
+ $this->date_created = c_base_defaults_global::s_get_timestamp($columns[22])->get_value_exact();
+ $this->date_changed = c_base_defaults_global::s_get_timestamp($columns[23])->get_value_exact();
+ $this->date_synced = c_base_defaults_global::s_get_timestamp($columns[24])->get_value_exact();
+ $this->date_locked = c_base_defaults_global::s_get_timestamp($columns[25])->get_value_exact();
+ $this->date_deleted = c_base_defaults_global::s_get_timestamp($columns[26])->get_value_exact();
+
+ if (isset($columns[27])) {
+ $this->settings = json_decode($columns[27], TRUE);
+ }
+ else {
+ $this->settings = array();
+ }
+ }
+ unset($columns);
+
+ return new c_base_return_true();
+ }
+}
require_once('common/base/classes/base_return.php');
require_once('common/base/classes/base_http_status.php');
+require_once('common/standard/classes/standard_path.php');
+
require_once('common/theme/classes/theme_html.php');
-class c_reservation_path_access_denied extends c_reservation_path {
+class c_standard_path_access_denied extends c_standard_path {
+
/**
* Implements do_execute().
*/
require_once('common/base/classes/base_return.php');
require_once('common/base/classes/base_http_status.php');
+require_once('common/standard/classes/standard_path.php');
+
require_once('common/theme/classes/theme_html.php');
-class c_reservation_path_bad_method extends c_reservation_path {
+class c_standard_path_bad_method extends c_standard_path {
+
/**
* Implements do_execute().
*/
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides path handler for the site index.
+ */
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+require_once('common/base/classes/base_path.php');
+
+require_once('common/standard/classes/standard_path.php');
+
+require_once('common/theme/classes/theme_html.php');
+
+class c_standard_path_index extends c_standard_path {
+
+ /**
+ * Implements do_execute().
+ */
+ public function do_execute(&$http, &$database, &$session, $settings = array()) {
+ // the parent function performs validation on the parameters.
+ $executed = parent::do_execute($http, $database, $session, $settings);
+ if (c_base_return::s_has_error($executed)) {
+ return $executed;
+ }
+
+ $this->pr_assign_defaults($settings);
+
+ $wrapper = $this->pr_create_tag_wrapper();
+ $wrapper->set_tag($this->pr_create_tag_title(0));
+ $wrapper->set_tag($this->pr_create_tag_text_block(1));
+
+
+ // initialize the content as HTML.
+ $html = $this->pr_create_html($http, $database, $session, $settings);
+ $html->set_tag($wrapper);
+ unset($wrapper);
+
+ $executed->set_output($html);
+ unset($html);
+
+ return $executed;
+ }
+
+ /**
+ * Implements pr_get_text().
+ */
+ protected function pr_get_text($code, $arguments = array()) {
+ switch ($code) {
+ case 0:
+ $string = 'Standard System';
+ break;
+ case 1:
+ $string = 'This is the standard system index page.';
+ break;
+ }
+
+ if (!empty($arguments)) {
+ $this->pr_process_replacements($string, $arguments);
+ }
+
+ return $string;
+ }
+}
*/
/**
- * Implements c_reservation_path_access_denied().
+ * Implements c_standard_path_access_denied().
*/
-final class c_reservation_path_access_denied_ja extends c_reservation_path_access_denied {
+final class c_standard_path_access_denied_ja extends c_standard_path_access_denied {
/**
* Implements pr_get_title().
*/
/**
- * Implements c_reservation_path_bad_method().
+ * Implements c_standard_path_bad_method().
*/
-final class c_reservation_path_bad_method_ja extends c_reservation_path_bad_method {
+final class c_standard_path_bad_method_ja extends c_standard_path_bad_method {
/**
* Implements pr_get_title().
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides path handler for the index page.
+ */
+
+/**
+ * Implements c_standard_path_index().
+ */
+final class c_standard_path_index_ja extends c_standard_path_index {
+
+ /**
+ * Implements pr_get_title().
+ */
+ protected function pr_get_title($arguments = array()) {
+ return '予約システム';
+ }
+
+ /**
+ * Implements pr_get_text().
+ */
+ protected function pr_get_text($code, $arguments = array()) {
+ $string = '';
+ switch ($code) {
+ case 0:
+ $string = '標準システム';
+ break;
+ case 1:
+ $string = 'これは標準のシステムインデックスページです。';
+ break;
+ }
+
+ if (!empty($arguments)) {
+ $this->pr_process_replacements($string, $arguments);
+ }
+
+ return $string;
+ }
+}
*/
/**
- * Implements c_reservation_path_not_found().
+ * Implements c_standard_path_not_found().
*/
-final class c_reservation_path_not_found_ja extends c_reservation_path_not_found {
+final class c_standard_path_not_found_ja extends c_standard_path_not_found {
/**
* Implements pr_get_title().
*/
/**
- * Implements c_reservation_path_server_error().
+ * Implements c_standard_path_server_error().
*/
-final class c_reservation_path_server_error_ja extends c_reservation_path_server_error {
+final class c_standard_path_server_error_ja extends c_standard_path_server_error {
/**
* Implements pr_get_title().
require_once('common/base/classes/base_return.php');
require_once('common/base/classes/base_http_status.php');
+require_once('common/standard/classes/standard_path.php');
+
require_once('common/theme/classes/theme_html.php');
-class c_reservation_path_not_found extends c_reservation_path {
+class c_standard_path_not_found extends c_standard_path {
+
/**
* Implements do_execute().
*/
require_once('common/base/classes/base_return.php');
+require_once('common/standard/classes/standard_path.php');
+
/**
* Provide the HTTP options response.
*
* This does not provide any content body.
*/
-final class c_reservation_path_options_method extends c_reservation_path {
+final class c_standard_path_options_method extends c_standard_path {
/**
* Implements do_execute().
require_once('common/base/classes/base_return.php');
require_once('common/base/classes/base_http_status.php');
+require_once('common/standard/classes/standard_path.php');
+
require_once('common/theme/classes/theme_html.php');
-class c_reservation_path_server_error extends c_reservation_path {
+class c_standard_path_server_error extends c_standard_path {
+
/**
* Implements do_execute().
*/
require_once('common/base/classes/base_return.php');
require_once('common/base/classes/base_path.php');
+require_once('common/standard/classes/standard_path.php');
+
require_once('common/theme/classes/theme_html.php');
-class c_reservation_path_user_dashboard extends c_reservation_path {
+class c_standard_path_user_dashboard extends c_standard_path {
/**
* Implements do_execute().
$wrapper->set_tag($this->pr_create_tag_text_block(1));
$roles = array();
- $roles_object = $session->get_setting('roles');
- if ($roles_object instanceof c_base_roles) {
- $roles = $roles_object->get_roles()->get_value_exact();
+ $current_user = $session->get_user_current();
+ #$session_user = $session->get_user_session();
+
+
+ $roles = array();
+ if ($current_user instanceof c_base_users) {
+ $roles = $current_user->get_roles();
}
- unset($roles_object);
$wrapper->set_tag($this->pr_create_tag_text_block($this->pr_get_text(2, array('@{user}' => $this->user_name))));
*/
/**
- * Implements c_reservation_path_user_dashboard().
+ * Implements c_standard_path_user_dashboard().
*/
-class c_reservation_path_user_dashboard_ja extends c_reservation_path_user_dashboard {
+class c_standard_path_user_dashboard_ja extends c_standard_path_user_dashboard {
/**
* Implements pr_get_text().
/**
- * Implements c_reservation_path_user_login().
+ * Implements c_standard_path_user_login().
*/
-class c_reservation_path_user_login_ja extends c_reservation_path_user_login {
+class c_standard_path_user_login_ja extends c_standard_path_user_login {
/**
* Implements pr_get_text().
case 9:
$string = 'あなたは既にログインしています。';
break;
+ case 10:
+ $string = 'ログインできません。間違ったユーザー名またはパスワードが指定されています。';
+ break;
}
if (!empty($arguments)) {
/**
- * Implements c_reservation_path_user_logout().
+ * Implements c_standard_path_user_logout().
*/
-class c_reservation_path_user_logout_ja extends c_reservation_path_user_logout {
+class c_standard_path_user_logout_ja extends c_standard_path_user_logout {
/**
* Implements pr_get_text().
require_once('common/base/classes/base_path.php');
require_once('common/base/classes/base_http_status.php');
require_once('common/base/classes/base_cookie.php');
+require_once('common/base/classes/base_ldap.php');
+
+require_once('common/standard/classes/standard_index.php');
+require_once('common/standard/classes/standard_path.php');
+require_once('common/standard/classes/standard_users.php');
require_once('common/theme/classes/theme_html.php');
*
* This listens on: /u/login
*/
-class c_reservation_path_user_login extends c_reservation_path {
- private const PATH_REDIRECTS = 'program/reservation/reservation_redirects.php';
+class c_standard_path_user_login extends c_standard_path {
+ protected const USER_PUBLIC = 'u_standard_public';
+
+ protected const PATH_LOGOUT = 'u/logout';
+ protected const PATH_DASHBOARD = 'u/dashboard';
/**
* Implements do_execute().
$html = $this->pr_create_html($http, $database, $session, $settings);
$wrapper = $this->pr_create_tag_wrapper();
- $logged_in = $session->get_logged_in()->get_value_exact();
+ $logged_in = $session->is_logged_in()->get_value_exact();
if ($logged_in) {
$method = $this->pr_get_method($http);
$href = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_A);
$href->set_text($this->pr_get_text(6));
- $href->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $this->base_path . 'u/logout');
+ $href->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $this->base_path . self::PATH_LOGOUT);
$block->set_tag($href);
unset($href);
// perform login if session information is provided.
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
- $login_result = $this->p_do_login($database, $session, $settings);
-
- if ($login_result instanceof c_base_return_array) {
- $problems = $login_result->get_value_exact();
+ $login_result = $this->pr_do_login($http, $database, $session, $settings);
- foreach ($problems as $problem) {
+ if (is_array($login_result)) {
+ foreach ($login_result as $problem) {
$fields = $problem->get_fields();
if ($fields instanceof c_base_return_array) {
foreach ($fields->get_value_exact() as $field) {
$problem_messages[] = $problem->get_value_exact();
}
unset($problem);
- unset($problems);
}
- elseif ($login_result instanceof c_base_return_true) {
+ elseif ($login_result === TRUE) {
// successfully logged in.
- require_once(self::PATH_REDIRECTS);
-
$request_uri = $http->get_request(c_base_http::REQUEST_URI)->get_value_exact();
if (isset($request_uri['data']) && is_array($request_uri['data'])) {
$destination = $request_uri['data'];
$destination['path'] = $settings['base_path'] . 'u/dashboard';
// note: by using a SEE OTHER redirect, the client knows to make a GET request and that the redirect is temporary.
- $redirect = c_reservation_path_redirect::s_create_redirect($destination, c_base_http_status::SEE_OTHER, FALSE);
+ $redirect = c_standard_path::s_create_redirect($destination, c_base_http_status::SEE_OTHER, FALSE);
unset($destination);
return $redirect->do_execute($http, $database, $session, $settings);
}
-
unset($login_result);
if (!empty($problem_messages)) {
/**
* Validate and Perform the login.
*
+ * @param c_base_http &$http
+ * The HTTP settings.
* @param c_base_database &$database
* The database object.
* @param c_base_session &$session
* @param array $settings
* The system settings array.
*
- * @return c_base_return_array|c_base_return_status
+ * @return array|bool
* TRUE on success.
* An array of problems on failure.
*/
- private function p_do_login(&$database, &$session, $settings) {
+ protected function pr_do_login(&$http, &$database, &$session, $settings) {
$problems = array();
- if (empty($_POST['login_form-username'])) {
- $problems[] = c_base_form_problem::s_create_error('login_form-username', 'No valid username has been supplied.');
+ if (empty($_POST['login_form-username']) || !is_string($_POST['login_form-username'])) {
+ $problems[] = c_base_form_problem::s_create_error('login_form-username', self::pr_get_text(10));
}
- elseif ($_POST['login_form-username'] == 'u_reservation_public') {
+ elseif ($_POST['login_form-username'] == self::USER_PUBLIC) {
// explicitly deny access to internal user accounts
- $problems[] = c_base_form_problem::s_create_error('login_form-username', 'Unable to login, an incorrect user name or password has been specified.');
+ $problems[] = c_base_form_problem::s_create_error('login_form-username', self::pr_get_text(10));
}
- if (empty($_POST['login_form-password'])) {
- $problems[] = c_base_form_problem::s_create_error('login_form-password', 'No valid password has been supplied.');
+ if (empty($_POST['login_form-password']) || !is_string($_POST['login_form-username'])) {
+ $problems[] = c_base_form_problem::s_create_error('login_form-password', self::pr_get_text(10));
}
// return current list of problems before continuing to login attempt with credentials.
if (!empty($problems)) {
- return c_base_return_array::s_new($problems);
+ return $problems;
}
- $session->set_name($_POST['login_form-username']);
- $session->set_password($_POST['login_form-password']);
+ // disconnect from the database and assign a new database string.
+ if ($database->is_connected() instanceof c_base_return_true) {
+ $database->do_disconnect();
+ }
+
+ $connection_string = $database->get_connection_string();
+ $connection_string->set_user($_POST['login_form-username']);
+ $connection_string->set_password($_POST['login_form-password']);
+
+ $database->set_connection_string($connection_string);
+ unset($connection_string);
- // the database string must be rebuilt using the new username and password.
- reservation_database_string($database, $settings, $_POST['login_form-username'], $_POST['login_form-password']);
$access_denied = FALSE;
$error_messages = array();
- $connected = reservation_database_connect($database);
+
+ $connected = $database->do_connect();
if (c_base_return::s_has_error($connected)) {
// try to determine what the warning is.
// this is not very accurate/efficient, but scanning the string appears to be the only way to identify the error.
$errors = $connected->get_error();
- // @todo: walk through all errors instead of just checking the first.
+ // @todo: walk through all errors instead of just getting only the first.
$error = reset($errors);
unset($errors);
$details = $error->get_details();
unset($error);
- if (isset($details['arguments'][':failure_reasons'][0]['message'])) {
+ if (isset($details['arguments'][':{failure_reasons}'][0]['message'])) {
// in the case where the database cannot be connected to, do not attempt to ensure user account.
- if (preg_match('/could not connect to server: connection refused/i', $details['arguments'][':failure_reasons'][0]['message']) > 0) {
+ if (preg_match('/could not connect to server: connection refused/i', $details['arguments'][':{failure_reasons}'][0]['message']) > 0) {
// @todo: separate messages for admin users and public users.
- #foreach ($details['arguments'][':failure_reasons'] as $error_message) {
+ #foreach ($details['arguments'][':{failure_reasons}'] as $error_message) {
# $error_messages[] = $error_message;
#}
#unset($error_message);
unset($details);
$problems[] = c_base_form_problem::s_create_error(NULL, 'Unable to login, cannot connect to the database.');
- return c_base_return_array::s_new($problems);
+ return $problems;
}
- elseif (preg_match('/no pg_hba\.conf entry for host/i', $details['arguments'][':failure_reasons'][0]['message']) > 0) {
+ elseif (preg_match('/no pg_hba\.conf entry for host/i', $details['arguments'][':{failure_reasons}'][0]['message']) > 0) {
// the account either does note exist or is not authorized.
// it is a pity that postgresql doesn't differentiate the two.
$access_denied = TRUE;
}
else {
- $problems[] = c_base_form_problem::s_create_error(NULL, 'Unable to login, reason: ' . $details['arguments'][':failure_reasons'][0]['message'] . '.');
+ $problems[] = c_base_form_problem::s_create_error(NULL, 'Unable to login, reason: ' . $details['arguments'][':{failure_reasons}'][0]['message'] . '.');
unset($details);
- return c_base_return_array::s_new($problems);
+ return $problems;
}
}
unset($details);
if ($access_denied) {
// it is possible the user name might not exist, so try to auto-create the username if the username does not exist.
- $ensure_result = reservation_ensure_user_account($settings, $_POST['login_form-username']);
+ $ensure_result = $this->pr_do_ensure_user_account($settings, $_POST['login_form-username']);
if ($ensure_result instanceof c_base_return_int) {
$ensure_result = $ensure_result->get_value_exact();
$connected = new c_base_return_false();
if ($ensure_result === 0) {
// try again now that the system has attempted to ensure the user account exists.
- $connected = reservation_database_connect($database);
+ $connected = $database->do_connect();
if ($connected instanceof c_base_return_true) {
- // @todo: add log entry.
- #set_log_user($database, 'create_user');
+ c_standard_index::s_do_initialize_database($database);
+
+ if ($database instanceof c_standard_database) {
+ $database->do_log_user(c_standard_database::LOG_TYPE_CREATE_USER, c_base_http_status::OK, array('user_name' => $_POST['login_form-username']));
+ $database->do_log_user(c_standard_database::LOG_TYPE_LOGIN, c_base_http_status::OK, array('expires' => $session->get_timeout_expire()->get_value_exact()));
+ }
}
}
elseif ($ensure_result === 1) {
// user name not found in ldap database.
}
elseif ($ensure_result === 4) {
- // 4 = failed to connect to the database.
+ // failed to connect to the database.
}
elseif ($ensure_result === 5) {
- // 5 = error returned while executing the SQL command.
+ // error returned while executing the SQL command.
}
elseif ($ensure_result === 6) {
- // 6 = error occured while reading input from the user (such as via recv()).
+ // error occured while reading input from the user (such as via recv()).
}
elseif ($ensure_result === 7) {
- // 7 = error occured while writing input from the user (such as via send()).
+ // error occured while writing input from the user (such as via send()).
}
elseif ($ensure_result === 8) {
- // 8 = the received packet is invalid, such as wrong length.
+ // the received packet is invalid, such as wrong length.
}
elseif ($ensure_result === 9) {
- // 10 = connection timed out when reading or writing.
+ // connection timed out when reading or writing.
}
elseif ($ensure_result === 10) {
- // 10 = the connection is being forced closed.
+ // the connection is being forced closed.
}
elseif ($ensure_result === 11) {
- // 11 = the connection is closing because the service is quitting.
+ // the connection is closing because the service is quitting.
}
}
unset($ensure_result);
}
}
+ else {
+ c_standard_index::s_do_initialize_database($database);
+
+ if ($database instanceof c_standard_database) {
+ $database->do_log_user(c_standard_database::LOG_TYPE_LOGIN, c_base_http_status::OK, array('expires' => $session->get_timeout_expire()->get_value_exact()));
+ }
+ }
if (c_base_return::s_has_error($connected) || $connected instanceof c_base_return_false) {
- // @todo: rewrite this function to handle multiple errors.
+ // @todo: rewrite this to handle multiple errors.
if ($access_denied) {
- $problems[] = c_base_form_problem::s_create_error('login_form-username', 'Unable to login, an incorrect user or password has been specified.');
+ $problems[] = c_base_form_problem::s_create_error('login_form-username', self::pr_get_text(10));
}
else {
$errors = $connected->get_error();
unset($error);
// @todo: not just database errors, but also session create errors need to be checked.
- if (isset($details['arguments'][':failure_reasons'][0]['message']) && is_string($details['arguments'][':failure_reasons'][0]['message'])) {
- $problems[] = c_base_form_problem::s_create_error(NULL, 'Unable to login, ' . $details['arguments'][':failure_reasons'][0]['message']);
+ if (isset($details['arguments'][':{failure_reasons}'][0]['message']) && is_string($details['arguments'][':{failure_reasons}'][0]['message'])) {
+ $problems[] = c_base_form_problem::s_create_error(NULL, 'Unable to login, ' . $details['arguments'][':{failure_reasons}'][0]['message']);
}
else {
// here the reason for failure is unknown.
- $problems[] = c_base_form_problem::s_create_error(NULL, 'Unable to login,');
+ $problems[] = c_base_form_problem::s_create_error(NULL, 'Unable to login.');
}
unset($details);
}
return new c_base_return_false();
}
- return c_base_return_array::s_new($problems);
+ return $problems;
}
unset($access_denied);
- // @todo: add log entry.
- #set_log_user($database, 'login');
-
// @todo: load and store custom settings (loaded from the database and/or ldap).
#$session->set_settings($user_data);
+ $session->set_name($_POST['login_form-username']);
+ $session->set_password($_POST['login_form-password']);
+
// the session needs to be opened and the data needs to be saved on successful login.
$result = $session->do_connect();
if (c_base_return::s_has_error($result)) {
unset($socket_error);
}
else {
- $ldap = reservation_database_load_ldap_data($settings, $_POST['login_form-username'])->get_value();
- if ($ldap instanceof c_base_return_false || !is_array($ldap)) {
- $ldap = array(
- 'data' => NULL,
- );
- }
-
- if (isset($ldap['status']) && $ldap['status'] instanceof c_base_return_false) {
+ $ldap = $this->pr_load_ldap_data($settings, $_POST['login_form-username']);
+ if (!$ldap['status']) {
$problems[] = c_base_form_problem::s_create_error('login_form-username', 'Failed to retrieve ldap information for specified user.');
}
- $user_data = reservation_database_get_user_data($database, $_POST['login_form-username'], $ldap['data'])->get_value();
-
- // @todo: get and use user id from $user_data.
-
$pushed = $session->do_push($settings['session_expire'], $settings['session_max']);
$session->do_disconnect();
- reservation_get_current_roles($database, $session, $settings);
-
- $cookie_login = NULL;
if (c_base_return::s_has_error($pushed)) {
$socket_error = $session->get_error_socket();
if ($socket_error instanceof c_base_return_int) {
}
else {
$session_expire = $session->get_timeout_expire()->get_value_exact();
- $cookie_login = $session->get_cookie();
- }
- if ($cookie_login instanceof c_base_cookie) {
+ $cookie_login = new c_base_cookie();
+ $cookie_login->set_name($settings['cookie_name']);
+ $cookie_login->set_path($settings['cookie_path']);
+ $cookie_login->set_domain($settings['cookie_domain']);
+ $cookie_login->set_http_only($settings['cookie_http_only']);
+ $cookie_login->set_host_only($settings['cookie_host_only']);
+ $cookie_login->set_same_site($settings['cookie_same_site']);
+ $cookie_login->set_secure($settings['cookie_secure']);
$cookie_login->set_expires($session_expire);
$cookie_login->set_max_age(NULL);
- if ($pushed instanceof c_base_return_true) {
- $data = array(
- 'session_id' => $session->get_session_id()->get_value_exact(),
- 'expire' => gmdate("D, d-M-Y H:i:s T", $session_expire), // unnecessary, but provided for debug purposes.
- );
+ $data = array(
+ 'session_id' => $session->get_session_id()->get_value_exact(),
+ 'expire' => gmdate("D, d-M-Y H:i:s T", $session_expire), // unnecessary, but provided for debug purposes.
+ );
- $cookie_login->set_value($data);
- $session->set_cookie($cookie_login);
- }
+ $cookie_login->set_value($data);
+ $session->set_cookie($cookie_login);
+
+ unset($cookie_login);
}
- unset($cookie_login);
unset($session_expire);
unset($pushed);
}
if (empty($problems)) {
unset($problems);
- return new c_base_return_true();
+
+ $session->is_logged_in(TRUE);
+
+ // load database session information.
+ $user_current = new c_standard_users_user();
+ if ($user_current->do_load($database) instanceof c_base_return_true) {
+ $session->set_user_current($user_current);
+ }
+ unset($user_current);
+
+ $user_session = new c_standard_users_user();
+ if ($user_session->do_load($database, TRUE) instanceof c_base_return_true) {
+ $session->set_user_current($user_session);
+ }
+ unset($user_session);
+
+ return TRUE;
+ }
+
+ return $problems;
+ }
+
+ /**
+ * Loads LDAP information for the given user (if available).
+ *
+ * @param array $settings
+ * System settings array.
+ * @param string $user_name
+ * The user name to load
+ *
+ * @return array|bool
+ * An array of ldap data associated with the given user.
+ * The array structure is:
+ * 'title': a Title for any error that occured.
+ * 'message': The detailed ldap error message.
+ * 'status': c_base_return_true if there were no problems and c_base_return_false if there were problems.
+ * 'data': Any ldap data found for the given user name.
+ */
+ protected function pr_load_ldap_data($settings, $user_name) {
+ $return_data = array(
+ 'title' => NULL,
+ 'message' => NULL,
+ 'status' => TRUE,
+ 'data' => NULL,
+ );
+
+
+ // ldap support is disabled if ldap_server is set to NULL (or is not a string).
+ if (!isset($settings['ldap_server']) || !is_string($settings['ldap_server'])) {
+ return $return_data;
+ }
+
+
+ $ldap = new c_base_ldap();
+ $ldap->set_name($settings['ldap_server']);
+
+ if (isset($settings['ldap_bind_name']) && is_string($settings['ldap_bind_name'])) {
+ $ldap->set_bind_name($settings['ldap_bind_name']);
+ }
+
+ if (isset($settings['ldap_bind_password']) && is_string($settings['ldap_bind_password'])) {
+ $ldap->set_bind_password($settings['ldap_bind_password']);
+ }
+
+ $connected = $ldap->do_connect();
+ if (c_base_return::s_has_error($connected)) {
+ $message = $ldap->get_error_message();
+
+ $return_data['title'] = 'Connection Failed';
+ $return_data['message'] = $message->get_value_exact();
+ $return_data['status'] = FALSE;
+ unset($message);
+
+ return c_base_return_array::s_new($return_data);
+ }
+
+ $read = $ldap->do_search($settings['ldap_base_dn'], '(uid=' . $user_name . ')', $settings['ldap_fields']);
+ if (c_base_return::s_has_error($read)) {
+ $message = $ldap->get_error_message();
+
+ $return_data['title'] = 'Search Failed';
+ $return_data['message'] = $message->get_value_exact();
+ $return_data['status'] = FALSE;
+ unset($message);
+
+ $ldap->do_disconnect();
+
+ return c_base_return_array::s_new($return_data);
}
- return c_base_return_array::s_new($problems);
+ $entries = $read->get_entry_all();
+ if ($entries instanceof c_base_return_array) {
+ $entries = $entries->get_value();
+ }
+ else {
+ $entries = array();
+ }
+
+ if ($entries['count'] > 0) {
+ $return_data['data'] = array(
+ 'uid' => $user_name,
+ );
+
+ foreach ($settings['ldap_fields'] as $ldap_field) {
+ $return_data['data'][$ldap_field] = $entries[0][$ldap_field][0];
+ }
+ unset($ldap_field);
+ }
+ else {
+ $return_data['title'] = 'Username Not Found';
+ $return_data['message'] = 'The user \'' . $user_name . '\' was not found.';
+ $return_data['status'] = FALSE;
+ }
+ unset($entries);
+
+ return $return_data;
+ }
+
+ /**
+ * Attempt to auto-create a postgresql user account if it does not already exist.
+ *
+ * @param array $settings
+ * System settings.
+ * @param string $username
+ * The name of the postgresql account to auto-create.
+ *
+ * @return c_base_return_int|c_base_return_status
+ * An integer is returned, whose codes represent the transaction result.
+ * FALSE with error bit set is returned on error.
+ */
+ protected function pr_do_ensure_user_account($settings, $user_name) {
+ if (!is_array($settings)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'settings', ':{function_name}' => __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_string($user_name)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'user_name', ':{function_name}' => __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
+ if (!is_resource($socket)) {
+ unset($socket);
+
+ $socket_error = @socket_last_error();
+ @socket_clear_error();
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'socket_create', ':{socket_error}' => $socket_error, ':{socket_error_message}' => @socket_strerror($socket_error), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
+ unset($socket_error);
+
+ return c_base_return_error::s_false($error);
+ }
+
+ $connected = @socket_connect($socket, $settings['database_create_account_host'], $settings['database_create_account_port']);
+ if ($connected === FALSE) {
+ $socket_error = @socket_last_error($socket);
+
+ @socket_close($socket);
+ @socket_clear_error();
+
+ unset($socket);
+ unset($connected);
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'socket_connect', ':{socket_error}' => $socket_error, ':{socket_error_message}' => @socket_strerror($socket_error), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
+ unset($socket_error);
+
+ return c_base_return_error::s_false($error);
+ }
+
+ $packet_size_target = 63;
+ $packet_size_client = 1;
+
+ $name_length = strlen(trim($user_name));
+ $difference = $packet_size_target - $name_length;
+
+ if ($difference > 0) {
+ // the packet expects a packet to be NULL terminated or at most $packet_size_target.
+ $packet = pack('a' . $name_length . 'x' . $difference, trim($user_name));
+ }
+ else {
+ $packet = pack('a' . $name_length, $user_name);
+ }
+
+ $written = @socket_write($socket, $packet, $packet_size_target);
+
+ unset($packet);
+ unset($packet_size_target);
+ unset($name_length);
+ unset($difference);
+
+ if ($written === FALSE) {
+ unset($written);
+ unset($packet_size_client);
+
+ $socket_error = @socket_last_error($socket);
+
+ @socket_close($socket);
+ @socket_clear_error();
+
+ unset($socket);
+ unset($connected);
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'socket_write', ':{socket_error}' => $socket_error, ':{socket_error_message}' => @socket_strerror($this->socket_error), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
+ unset($socket_error);
+
+ return c_base_return_error::s_false($error);
+ }
+ unset($written);
+
+ $response = @socket_read($socket, $packet_size_client);
+ if ($response === FALSE) {
+ unset($response);
+ unset($packet_size_client);
+
+ $socket_error = @socket_last_error($socket);
+
+ @socket_close($socket);
+ @socket_clear_error();
+
+ unset($socket);
+ unset($connected);
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'socket_read', ':{socket_error}' => $socket_error, ':{socket_error_message}' => @socket_strerror($this->socket_error), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
+ unset($socket_error);
+
+ return c_base_return_error::s_false($error);
+ }
+
+ @socket_close($socket);
+ unset($socket);
+ unset($packet_size_client);
+
+ if (!is_string($response) || strlen($response) == 0) {
+ unset($response);
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'socket_read', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ return c_base_return_error::s_false($error);
+ }
+
+ // an integer is expected to be returned by the socket.
+ $response_packet = unpack('C', $response);
+ $response_value = (int) $response_packet[1];
+
+ unset($response);
+
+ // response codes as defined in the c source file:
+ // 0 = no problems detected.
+ // 1 = invalid user name, bad characters, or name too long.
+ // 2 = failed to connect to the ldap server and could not query the ldap name.
+ // 3 = user name not found in ldap database.
+ // 4 = failed to connect to the database.
+ // 5 = error returned while executing the SQL command.
+ // 6 = error occured while reading input from the user (such as via recv()).
+ // 7 = error occured while writing input from the user (such as via send()).
+ // 8 = the received packet is invalid, such as wrong length.
+ // 9 = connection timed out when reading or writing.
+ // 10 = the connection is being forced closed.
+ // 11 = the connection is closing because the service is quitting.
+ return c_base_return_int::s_new($response_value);
}
/**
case 9:
$string = 'You are already logged in.';
break;
+ case 10:
+ $string = 'Unable to login, an incorrect user name or password has been specified.';
+ break;
}
if (!empty($arguments)) {
require_once('common/base/classes/base_http_status.php');
require_once('common/base/classes/base_cookie.php');
+require_once('common/standard/classes/standard_path.php');
+require_once('common/standard/classes/standard_database.php');
+
require_once('common/theme/classes/theme_html.php');
/**
*
* This listens on: /u/logout
*/
-class c_reservation_path_user_logout extends c_reservation_path {
+class c_standard_path_user_logout extends c_standard_path {
/**
* Implements do_execute().
return $executed;
}
- $this->pr_assign_defaults($settings);
-
- $result = $this->p_do_logout($database, $session, $settings);
+ $this->pr_do_logout($http, $database, $session, $settings);
$wrapper = $this->pr_create_tag_wrapper();
$wrapper->set_tag($this->pr_create_tag_title(0));
/**
* Logout of the session.
*
+ * @param c_base_http &$http
+ * The HTTP settings.
* @param c_base_database &$database
* The database object.
* @param c_base_session &$session
* @param array $settings
* The system settings array.
*
- * @return c_base_return_array|c_base_return_status
+ * @return array|bool
* TRUE on success.
* An array of problems on failure.
*/
- private function p_do_logout(&$database, &$session, $settings) {
- if (!$database->is_connected()->get_value_exact()) {
- $connected = reservation_database_connect($database);
- if (c_base_return::s_has_error($connected)) {
- unset($connected);
- unset($already_connected);
- return FALSE;
+ protected function pr_do_logout(&$http, &$database, &$session, $settings) {
+ $http_status = $http->get_response_status()->get_value_exact();
+ if (!is_int($http_status)) {
+ $http_status = c_base_http_status::OK;
+ }
+
+
+ // disconnect from the database.
+ if ($database->is_connected() instanceof c_base_return_true) {
+ if ($database instanceof c_standard_database) {
+ $database->do_log_user(c_standard_database::LOG_TYPE_LOGOUT, $http_status);
}
- unset($connected);
+
+ $database->do_disconnect();
}
+ unset($http_status);
- // @todo: write to database logout log entry.
+ $connection_string = $database->get_connection_string();
+ $connection_string->set_user('');
+ $connection_string->set_password(NULL);
- $cookie_login = $session->get_cookie();
+ if (isset($settings['database_user_public']) && is_string($settings['database_user_public'])) {
+ $connection_string->set_user($settings['database_user_public']);
+ }
+
+ $database->set_connection_string($connection_string);
+ unset($connection_string);
- $database->do_disconnect();
+
+ // disconnect from the session.
$session->do_terminate();
$session->do_disconnect();
- $session->set_logged_in(FALSE);
+ $session->is_logged_in(FALSE);
+ $session->set_user_current(NULL);
+ $session->set_user_session(NULL);
- // remove username and password from database string.
- reservation_database_string($database, $settings);
// delete the login cookie.
+ $cookie_login = $session->get_cookie();
if ($cookie_login instanceof c_base_cookie) {
$cookie_login->set_expires(-1);
$cookie_login->set_max_age(-1);
*/
public function change_element($element, $type) {
if (!($element instanceof DOMNode)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'element', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'element', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_string($type) || empty($type)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function change_elements($type_old, $type_new) {
if (!is_string($type_old) || strlen($type_old) == 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'type_old', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type_old', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_string($type_new) || strlen($type_empty) == 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'type_empty', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type_empty', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!($this->content instanceof DOMNode)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->content', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->content', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
*/
public function remove_element($element, $preserve_children = TRUE) {
if (!($element instanceof DOMNode)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'element', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'element', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($preserve_children)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'preserve_children', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'preserve_children', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function remove_elements($type, $preserve_children = TRUE) {
if (!is_string($type) || strlen($type) == 0) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_bool($preserve_children)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'preserve_children', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'preserve_children', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!($this->content instanceof DOMNode)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->content', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->content', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
*/
public static function s_create_tag($type, $id = NULL, $classes = NULL, $text = NULL) {
if (!is_null($id) && !is_string($id)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'id', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_int($type)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($classes) && !is_array($classes)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'classes', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'classes', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
if (!is_null($text) && !is_string($text)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'text', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
$result = $tag->set_type($type);
if ($result instanceof c_base_return_false) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
*/
public function set_html($html) {
if (!($html instanceof c_base_html)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'html', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'html', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
- $this->html = $html;
+ $this->html = clone($html);
return new c_base_return_true();
}
$this->html = new c_base_html();
}
- return $this->html;
+ return clone($this->html);
}
/**
*/
public function render_markup() {
if (!($this->html instanceof c_base_html)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->html', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{variable_name}' => 'this->html', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_false($error);
}
*/
public function set_http($http) {
if (!($http instanceof c_base_http)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'http', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'http', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
- $this->http = $http;
+ $this->http = clone($http);
return new c_base_return_true();
}
$this->http = new c_base_http();
}
- return $this->http;
+ return clone($this->http);
}
/**
*/
public function set_max_recursion_depth($max_recursion_depth) {
if (!is_int($max_recursion_depth)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'max_recursion_depth', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'max_recursion_depth', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
grant select,usage on s_tables.se_associations_id to r_reservation_manager;
grant usage on s_tables.se_associations_id to r_reservation_requester, r_reservation_reviewer;
-/* @todo: should associations allow names that begin with numbers?
+/* @todo: should associations allow names that begin with numbers? */
/* Note: id_sort is not needed when directly validating against id or name_machine because both of those are already an index. */
create index i_associations_id_sort_a on s_tables.t_associations (id_sort) with (fillfactor = 100) where id_sort = 97;
create index i_associations_id_sort_b on s_tables.t_associations (id_sort) with (fillfactor = 100) where id_sort = 98;
/*** provide current user access to their own information ***/
create view s_users.v_associations_self with (security_barrier=true) as
- with this_user as (select id from s_users.v_users_locked_not_self),
+ with this_user as (select id from public.v_users_self_locked_not),
allowed_groups as (select id from s_users.v_groups_self)
select id, id_manager, id_coordinator, id_group, id_sort, name_machine, name_human, is_approved, is_cancelled, is_denied, is_troubled, is_locked, date_created, date_changed, date_synced, date_approved, date_cancelled, date_denied, date_troubled, date_locked, field_affiliation, field_classification from s_tables.t_associations
where not is_deleted and (id_manager in (select * from this_user) or id_group in (select * from allowed_groups));
/*** provide current user access to associations who they are assigned as the manager of ***/
create view s_users.v_associations_manage with (security_barrier=true) as
- with this_user as (select id from s_users.v_users_locked_not_self)
+ with this_user as (select id from public.v_users_self_locked_not)
select id, id_creator, id_coordinator, id_group, id_sort, name_machine, name_human, is_approved, is_cancelled, is_denied, is_troubled, is_locked, date_created, date_changed, date_synced, date_approved, date_cancelled, date_denied, date_troubled, date_locked, field_affiliation, field_classification from s_tables.t_associations
where not is_deleted and id_manager in (select * from this_user);
/*** provide current user access to associations who they are assigned as the coordinator of ***/
create view s_users.v_associations_coordinate with (security_barrier=true) as
- with this_user as (select id from s_users.v_users_locked_not_self)
+ with this_user as (select id from public.v_users_self_locked_not)
select id, id_creator, id_manager, id_group, id_sort, name_machine, name_human, is_approved, is_cancelled, is_denied, is_troubled, is_locked, date_created, date_changed, date_synced, date_approved, date_cancelled, date_denied, date_troubled, date_locked, field_affiliation, field_classification from s_tables.t_associations
where not is_deleted and id_coordinator in (select * from this_user);
/** provide current user access to insert their own associations (with them as the manager) **/
create view s_users.v_associations_self_insert with (security_barrier=true) as
select id_manager, id_group, id_coordinator, name_machine, name_human, field_affiliation, field_classification from s_tables.t_associations
- where not is_deleted and id_manager in (select id from s_users.v_users_locked_not_self)
+ where not is_deleted and id_manager in (select id from public.v_users_self_locked_not)
with check option;
grant insert on s_users.v_associations_self_insert to r_reservation_requester, r_reservation_reviewer;
/** provide current user access to update associations they manager **/
create view s_users.v_associations_self_update with (security_barrier=true) as
select id_manager, id_group, id_coordinator, name_machine, name_human, date_changed, field_affiliation, field_classification from s_tables.t_associations
- where not is_deleted and id_manager in (select id from s_users.v_users_locked_not_self)
+ where not is_deleted and id_manager in (select id from public.v_users_self_locked_not)
with check option;
grant update on s_users.v_associations_self_update to r_reservation_requester, r_reservation_reviewer;
/** If the data is meant to be private, then have the public account use the system user with ssl connections **/
create role u_reservation_public inherit login;
+grant r_reservation_public to u_reservation_public;
+
/** These are the roles and role group the database should use for system activity (such as executing cron-jobs). **/
create role u_reservation_system inherit login;
/*** provide group managers access to manage their groups ***/
create view s_users.v_groups_manage_self with (security_barrier=true) as
- with this_user as (select id from s_users.v_users_locked_not_self)
+ with this_user as (select id from public.v_users_self_locked_not)
select id, id_external, name_machine, name_human, is_locked, is_composite, is_user, can_manage_paths, settings from s_tables.t_groups
where not is_deleted and id_manager in (select * from this_user);
create view s_users.v_groups_manage_update with (security_barrier=true) as
select id, id_external, name_machine, name_human, is_locked, is_composite, is_user, can_manage_paths, settings from s_tables.t_groups
- where not is_deleted and id_manager in (select id from s_users.v_users_locked_not_self)
+ where not is_deleted and id_manager in (select id from public.v_users_self_locked_not)
with check option;
grant update on s_users.v_groups_manage_update to r_reservation, r_reservation_system;
/*** provide current user access to their own information ***/
create view s_users.v_groups_self with (security_barrier=true) as
- with allowed_groups as (select id_group from s_tables.t_group_users where not is_deleted and not is_locked and id_user in (select id from s_users.v_users_locked_not_self))
+ with allowed_groups as (select id_group from s_tables.t_group_users where not is_deleted and not is_locked and id_user in (select id from public.v_users_self_locked_not))
select id, id_external, id_manager, name_machine, name_human, is_locked, is_composite, date_created, date_changed, date_synced, can_manage_paths, settings from s_tables.t_groups
where not is_deleted and id in (select * from allowed_groups);
/*** provide group managers access to manage users assigned to their groups (any user id less than 1000 is reserved/special case, prohibit those). ***/
create view s_users.v_group_users_manage with (security_barrier=true) as
- with managed_groups as (select id from s_tables.t_groups where not is_deleted and id_manager in (select id from s_users.v_users_locked_not_self)),
+ with managed_groups as (select id from s_tables.t_groups where not is_deleted and id_manager in (select id from public.v_users_self_locked_not)),
available_users as (select id from s_tables.t_users where not is_deleted and not is_locked and not is_system and not is_public)
select id_user, id_group, is_locked from s_tables.t_group_users
where not is_deleted and id_group in (select * from managed_groups) and id_user in (select * from available_users);
create view s_users.v_group_users_manage_insert with (security_barrier=true) as
select id_user, id_group from s_tables.t_group_users
- where not is_deleted and id_group in (select id from s_users.v_groups_manage_self) and id_group in (select id_group from s_tables.t_group_users where not is_deleted and not is_locked and id_user in (select id from s_users.v_users_locked_not_self)) and id_user in (select id from s_tables.t_users where not is_deleted and not is_locked and not is_system and not is_public)
+ where not is_deleted and id_group in (select id from s_users.v_groups_manage_self) and id_group in (select id_group from s_tables.t_group_users where not is_deleted and not is_locked and id_user in (select id from public.v_users_self_locked_not)) and id_user in (select id from s_tables.t_users where not is_deleted and not is_locked and not is_system and not is_public)
with check option;
grant insert on s_users.v_group_users_manage_insert to r_reservation, r_reservation_system;
create view s_users.v_group_users_manage_update with (security_barrier=true) as
select id_user, id_group from s_tables.t_group_users
- where not is_deleted and id_group in (select id from s_users.v_groups_manage_self) and id_group in (select id_group from s_tables.t_group_users where not is_deleted and not is_locked and id_user in (select id from s_users.v_users_locked_not_self)) and id_user in (select id from s_tables.t_users where not is_deleted and not is_locked and not is_system and not is_public)
+ where not is_deleted and id_group in (select id from s_users.v_groups_manage_self) and id_group in (select id_group from s_tables.t_group_users where not is_deleted and not is_locked and id_user in (select id from public.v_users_self_locked_not)) and id_user in (select id from s_tables.t_users where not is_deleted and not is_locked and not is_system and not is_public)
with check option;
grant update on s_users.v_group_users_manage_update to r_reservation, r_reservation_system;
/*** provide current user access to their own information ***/
create view s_users.v_signatures_self with (security_barrier=true) as
- with this_user as (select id from s_users.v_users_locked_not_self)
+ with this_user as (select id from public.v_users_self_locked_not)
select id, id_type, id_request, date_created, field_fingerprint, field_signature from s_tables.t_signatures
where not is_deleted and id_creator in (select * from this_user);
/** provide current user access to insert their own associations **/
create view s_users.v_signatures_self_insert with (security_barrier=true) as
select id, id_type, id_creator, id_request, field_fingerprint, field_signature from s_tables.t_signatures
- where not is_deleted and id_creator in (select id from s_users.v_users_locked_not_self)
+ where not is_deleted and id_creator in (select id from public.v_users_self_locked_not)
with check option;
grant insert on s_users.v_signatures_self_insert to r_reservation, r_reservation_system;
/** only allow select and insert for users when user id is current user **/
create view s_users.v_log_groups_self with (security_barrier=true) as
- with this_user as (select id from s_users.v_users_locked_not_self)
+ with this_user as (select id from public.v_users_self_locked_not)
select id, id_user, id_group, log_type, log_details, log_date from s_tables.t_log_groups
where id_user in (select * from this_user);
create view s_users.v_log_groups_self_insert with (security_barrier=true) as
select id_group, log_type, log_details from s_tables.t_log_groups
- where id_user in (select id from s_users.v_users_locked_not_self) and id_group in (select id from s_users.v_groups_self where not is_locked)
+ where id_user in (select id from public.v_users_self_locked_not) and id_group in (select id from s_users.v_groups_self where not is_locked)
with check option;
grant insert on s_users.v_log_groups_self_insert to r_reservation, r_reservation_system;
/** only allow select and insert for users when user id is current user **/
create view s_users.v_log_group_users_self with (security_barrier=true) as
- with this_user as (select id from s_users.v_users_locked_not_self),
+ with this_user as (select id from public.v_users_self_locked_not),
allowed_groups as (select id from s_users.v_groups_self where not is_locked)
select id, id_user, id_group, log_type, log_date from s_tables.t_log_group_users
where id_user in (select * from this_user) or id_group in (select * from allowed_groups);
create view s_users.v_log_group_users_self_insert with (security_barrier=true) as
select id_group, log_type from s_tables.t_log_group_users
- where id_user in (select id from s_users.v_users_locked_not_self) and id_group in (select id from s_users.v_groups_self where not is_locked)
+ where id_user in (select id from public.v_users_self_locked_not) and id_group in (select id from s_users.v_groups_self where not is_locked)
with check option;
grant insert on s_users.v_log_group_users_self_insert to r_reservation, r_reservation_system;
/** only allow select, insert, and delete for users when user id is current user **/
create view s_users.v_log_problems_users_self with (security_barrier=true) as
- with this_user as (select id from s_users.v_users_locked_not_self)
+ with this_user as (select id from public.v_users_self_locked_not)
select id_problem, date_created, date_changed, log_details from s_tables.t_log_problems_users
where id_user in (select * from this_user);
create view s_users.v_log_problems_users_self_insert with (security_barrier=true) as
select id_problem, date_changed, log_details from s_tables.t_log_problems_users
- where id_user in (select id from s_users.v_users_locked_not_self)
+ where id_user in (select id from public.v_users_self_locked_not)
with check option;
grant insert on s_users.v_log_problems_users_self_insert to r_reservation, r_reservation_system;
create view s_users.v_log_problems_users_self_delete with (security_barrier=true) as
select id_problem from s_tables.t_log_problems_users
- where id_user in (select id from s_users.v_users_locked_not_self)
+ where id_user in (select id from public.v_users_self_locked_not)
with check option;
grant delete on s_users.v_log_problems_users_self_delete to r_reservation, r_reservation_system;
/** only allow select and insert for users when user id is current user **/
create view s_users.v_log_users_self with (security_barrier=true) as
- with this_user as (select id from s_users.v_users_locked_not_self)
+ with this_user as (select id from public.v_users_self_locked_not)
select id, id_user, log_title, log_type, log_severity, log_details, log_date, request_client, response_code from s_tables.t_log_users
where id_user in (select * from this_user);
create view s_users.v_log_users_self_insert with (security_barrier=true) as
select log_title, log_type, log_severity, log_details, request_client, response_code from s_tables.t_log_users
- where id_user in (select id from s_users.v_users_locked_not_self)
+ where id_user in (select id from public.v_users_self_locked_not)
with check option;
grant insert on s_users.v_log_users_self_insert to r_reservation, r_reservation_system;
/** only allow select and insert for users when user id is current user **/
create view s_users.v_log_user_activity_self with (security_barrier=true) as
- with this_user as (select id from s_users.v_users_locked_not_self)
+ with this_user as (select id from public.v_users_self_locked_not)
select id, id_user, request_path, request_arguments, request_date, request_client, request_headers, response_headers, response_code from s_tables.t_log_user_activity
where id_user in (select * from this_user);
create view s_users.v_log_user_activity_self_insert with (security_barrier=true) as
select request_path, request_arguments, request_client, request_headers, response_headers, response_code from s_tables.t_log_user_activity
- where id_user in (select id from s_users.v_users_locked_not_self)
+ where id_user in (select id from public.v_users_self_locked_not)
with check option;
grant insert on s_users.v_log_user_activity_self_insert to r_reservation, r_reservation_system;
/** public users should be able to insert, but should never be able to view the logs that they insert. **/
create view public.v_log_user_activity_self_insert with (security_barrier=true) as
select request_path, request_arguments, request_client, request_headers, response_headers, response_code from s_tables.t_log_user_activity
- where id_user in (select id from public.v_users_locked_not_self)
+ where id_user in (select id from public.v_users_self_locked_not)
with check option;
grant insert on public.v_log_user_activity_self_insert to r_reservation_public;
/*** provide current user access to their own information (system users are not allowed to update their account) ***/
create view s_users.v_users_self with (security_barrier=true) as
- select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, can_manage_roles, date_created, date_changed, date_synced, date_locked, settings from s_tables.t_users
+ select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, is_deleted, can_manage_roles, date_created, date_changed, date_synced, date_locked, null::timestamp as date_deleted, settings from s_tables.t_users
where not is_deleted and (name_machine)::text = (current_user)::text;
grant select on s_users.v_users_self to r_reservation, r_reservation_system;
-create view s_users.v_users_self_session with (security_barrier=true) as
- select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, can_manage_roles, date_created, date_changed, date_synced, date_locked, settings from s_tables.t_users
- where not is_deleted and (name_machine)::text = (session_user)::text;
-
-grant select on s_users.v_users_self_session to r_reservation, r_reservation_system;
-
create view public.v_users_self_session with (security_barrier=true) as
- with postgres_roles as (select pr.rolname from pg_auth_members pam inner join pg_roles pr on (pam.roleid = pr.oid) inner join pg_roles pr_u on (pam.member = pr_u.oid) where pr_u.rolname = current_user and pr.rolname = 'r_reservation_public')
- select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, can_manage_roles, date_created, date_changed, date_synced, date_locked, settings from s_tables.t_users
- where not is_deleted and (name_machine)::text = (session_user)::text and 'r_reservation_public' in (select * from postgres_roles);
+ select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, is_deleted, can_manage_roles, date_created, date_changed, date_synced, date_locked, null::timestamp as date_deleted, settings from s_tables.t_users
+ where not is_deleted and (name_machine)::text = (session_user)::text;
-grant select on public.v_users_self_session to r_reservation_public;
+grant select on public.v_users_self_session to r_reservation, r_reservation_system, r_reservation_public;
-create view s_users.v_users_locked_not_self with (security_barrier=true) as
- select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, can_manage_roles, date_created, date_changed, date_synced, date_locked, settings from s_tables.t_users
+create view public.v_users_self_locked_not with (security_barrier=true) as
+ select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, is_deleted, can_manage_roles, date_created, date_changed, date_synced, date_locked, null::timestamp as date_deleted, settings from s_tables.t_users
where not is_deleted and not is_locked and (name_machine)::text = (current_user)::text;
-grant select on s_users.v_users_locked_not_self to r_reservation, r_reservation_system;
-
-create view public.v_users_locked_not_self with (security_barrier=true) as
- with postgres_roles as (select pr.rolname from pg_auth_members pam inner join pg_roles pr on (pam.roleid = pr.oid) inner join pg_roles pr_u on (pam.member = pr_u.oid) where pr_u.rolname = current_user and pr.rolname = 'r_reservation_public')
- select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, can_manage_roles, date_created, date_changed, date_synced, date_locked, settings from s_tables.t_users
- where not is_deleted and not is_locked and (name_machine)::text = (current_user)::text and 'r_reservation_public' in (select * from postgres_roles);
-
-grant select on public.v_users_locked_not_self to r_reservation_public;
-
-create view s_users.v_users_can_manage_roles with (security_barrier=true) as
- with this_user_can_manage_roles as (select id from s_users.v_users_locked_not_self where can_manage_roles)
- select id_sort, name_human, address_email from s_tables.t_users
- where not is_deleted and not is_locked and not is_system and not is_public and (name_machine)::text = (current_user)::text and id in (select * from this_user_can_manage_roles);
-
-grant select on s_users.v_users_can_manage_roles to r_reservation, r_reservation_system;
+grant select on public.v_users_self_locked_not to r_reservation, r_reservation_system, r_reservation_public;
create view s_users.v_users_self_insert with (security_barrier=true) as
select id_external, name_human, address_email, is_private, settings from s_tables.t_users
/**** anonymous user has uid = 1 ****/
create view public.v_users_self with (security_barrier=true) as
- select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, date_created, date_changed, date_synced, date_locked, settings from s_tables.t_users
+ select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, is_deleted, can_manage_roles, date_created, date_changed, date_synced, date_locked, null::timestamp as date_deleted, settings from s_tables.t_users
where not is_deleted and id = 1;
grant select on public.v_users_self to r_reservation_public, r_reservation, r_reservation_system;
/*** provide public user information ***/
create view public.v_users with (security_barrier=true) as
- select id, null::bigint as id_external, id_sort, name_machine, name_human, null::public.ct_email as address_email, null::bool as is_administer, null::bool as is_manager, null::bool as is_auditor, null::bool as is_publisher, null::bool as is_insurer, null::bool as is_financer, null::bool as is_reviewer, null::bool as is_editor, null::bool as is_drafter, null::bool as is_requester, is_system, is_public, null::bool as is_locked, null::bool as is_private, null::bool as can_manage_roles, null::timestamp as date_created, null::timestamp as date_changed, null::timestamp as date_synced, null::timestamp as date_locked, null::json as settings from s_tables.t_users
+ select id, null::bigint as id_external, id_sort, name_machine, name_human, null::public.ct_email as address_email, null::bool as is_administer, null::bool as is_manager, null::bool as is_auditor, null::bool as is_publisher, null::bool as is_insurer, null::bool as is_financer, null::bool as is_reviewer, null::bool as is_editor, null::bool as is_drafter, null::bool as is_requester, is_system, is_public, null::bool as is_locked, is_private, is_deleted, null::bool as can_manage_roles, null::timestamp as date_created, null::timestamp as date_changed, null::timestamp as date_synced, null::timestamp as date_locked, null::timestamp as date_deleted, null::json as settings from s_tables.t_users
where (not is_deleted and not is_private) or (not is_deleted and (name_machine)::text = (current_user)::text);
grant select on public.v_users to r_reservation, r_reservation_public, r_reservation_system;
/*** provide e-mail address as public information only if it is explicitly allowed ***/
create view public.v_users_email with (security_barrier=true) as
- select id, null::bigint as id_external, id_sort, name_machine, name_human, address_email, null::bool as is_administer, null::bool as is_manager, null::bool as is_auditor, null::bool as is_publisher, null::bool as is_insurer, null::bool as is_financer, null::bool as is_reviewer, null::bool as is_editor, null::bool as is_drafter, null::bool as is_requester, is_system, is_public, null::bool as is_locked, null::bool as is_private, null::bool as can_manage_roles, null::timestamp as date_created, null::timestamp as date_changed, null::timestamp as date_synced, null::timestamp as date_locked, null::json as settings from s_tables.t_users
+ select id, null::bigint as id_external, id_sort, name_machine, name_human, address_email, null::bool as is_administer, null::bool as is_manager, null::bool as is_auditor, null::bool as is_publisher, null::bool as is_insurer, null::bool as is_financer, null::bool as is_reviewer, null::bool as is_editor, null::bool as is_drafter, null::bool as is_requester, is_system, is_public, null::bool as is_locked, is_private, is_deleted, null::bool as can_manage_roles, null::timestamp as date_created, null::timestamp as date_changed, null::timestamp as date_synced, null::timestamp as date_locked, null::timestamp as date_deleted, null::json as settings from s_tables.t_users
where (not is_deleted and not is_private and not (address_email).private) or (not is_deleted and (name_machine)::text = (current_user)::text);
grant select on public.v_users_email to r_reservation, r_reservation_public, r_reservation_system;
--- /dev/null
+standard-first
+standard-main
+standard-users
+standard-groups
+standard-types
+standard-paths
+standard-log_types
+standard-log_groups
+standard-log_problems
+standard-log_users
+standard-statistics
+standard-last
--- /dev/null
+/** Standardized SQL Structure - Files **/
+/** This depends on: reservation-users.sql, reservation-types.sql **/
+start transaction;
+
+
+
+/** Custom database specific settings (do this on every connection made) **/
+set bytea_output to hex;
+set search_path to s_administers,s_managers,s_auditors,s_publishers,s_insurers,s_financers,s_reviewers,s_editors,s_drafters,s_requesters,s_users,public;
+set datestyle to us;
+
+
+
+create table s_tables.t_files (
+ id bigint not null,
+ id_creator bigint not null,
+ id_creator_session bigint not null,
+ id_type bigint not null,
+ id_group bigint,
+
+ name_machine varchar(128) not null,
+ name_human varchar(256) not null,
+
+ is_private boolean default true not null,
+ is_locked boolean default false not null,
+ is_deleted boolean default false not null,
+ is_system boolean default false not null,
+ is_user boolean default false not null,
+
+ field_data bytea not null,
+
+ date_created timestamp default localtimestamp not null,
+ date_changed timestamp default localtimestamp not null,
+ date_locked timestamp,
+ date_deleted timestamp,
+
+ constraint cp_files primary key (id),
+
+ constraint cu_files_name_machine unique (name_machine),
+ constraint cu_files_field_path unique (field_path),
+
+ constraint cc_files_id check (id > 0),
+ constraint cc_files_name_machine check (name_machine ~ '[A-Za-z]\w*'),
+
+ constraint cf_files_id_creator foreign key (id_creator) references s_tables.t_users (id) on delete cascade on update cascade,
+ constraint cf_files_id_creator_session foreign key (id_creator_session) references s_tables.t_users (id) on delete cascade on update cascade,
+ constraint cf_files_id_type foreign key (id_type) references s_tables.t_file_types (id) on delete restrict on update cascade,
+ constraint cf_files_id_group foreign key (id_group) references s_tables.t_groups (id) on delete restrict on update cascade
+);
+
+create sequence s_tables.se_files_id owned by s_tables.t_files.id;
+alter table s_tables.t_files alter column id set default nextval('s_tables.se_files_id'::regclass);
+
+grant select,insert,update on s_tables.t_files to r_standard_administer;
+grant select on s_tables.t_files to r_standard_manager, r_standard_auditor;
+grant select,usage on s_tables.se_files_id to r_standard_administer;
+grant usage on s_tables.se_files_id to r_standard, r_standard_system;
+
+create index i_files_deleted_not on s_tables.t_files (id)
+ where not is_deleted;
+
+create index i_files_private_not on s_tables.t_files (id)
+ where not is_deleted and not is_private;
+
+create index i_files_locked_not on s_tables.t_files (id)
+ where not is_deleted and not is_locked;
+
+create index i_files_public on s_tables.t_files (id)
+ where not is_deleted and not is_locked and not is_private;
+
+
+create view s_users.v_files with (security_barrier=true) as
+ with allowed_groups as (select id from s_users.v_groups_self)
+ select id, id_type, id_group, name_machine, name_human, is_private, date_created, date_changed from s_tables.t_files
+ where not is_deleted and (not is_locked or id_group in (select * from allowed_groups)) and (not is_private or (is_private and id_group in (select * from allowed_groups)));
+
+grant select on s_users.v_files to r_standard, r_standard_system;
+
+create view public.v_files with (security_barrier=true) as
+ select id, id_type, NULL::bigint as id_group, name_machine, name_human, NULL::bool as is_private, NULL::bool as date_created, NULL::bool as date_changed from s_tables.t_files
+ where not is_deleted and not is_locked and not is_private;
+
+grant select on public.v_path_types to r_standard, r_standard_public, r_standard_system;
+
+
+create trigger tr_files_date_changed_deleted_or_locked
+ before update on s_tables.t_files
+ for each row execute procedure s_administers.f_common_update_date_changed_deleted_or_locked();
+
+create trigger tr_files_enforce_creator_and_session_ids
+ before insert on s_tables.t_files
+ for each row execute procedure s_administers.f_common_enforce_creator_and_session_ids();
+
+
+
+commit transaction;
--- /dev/null
+/** First time or one time execution stuff **/
+/** Things here must be run first and cannot be run a second time due to their nature. **/
+/** For example, tablespaces need only be created 1x and then any database on the system can use them **/
+/** Be sure to replace reservation_ and reservation- with the prefix that is specific to your database. **/
+/** This script creates the database (at or near the end of the script). **/
+
+
+
+/** Create the roles**/
+create role r_standard inherit nologin;
+create role r_standard_administer inherit nologin;
+create role r_standard_manager inherit nologin;
+create role r_standard_auditor inherit nologin;
+create role r_standard_publisher inherit nologin;
+create role r_standard_insurer inherit nologin;
+create role r_standard_financer inherit nologin;
+create role r_standard_reviewer inherit nologin;
+create role r_standard_editor inherit nologin;
+create role r_standard_drafter inherit nologin;
+create role r_standard_requester inherit nologin;
+create role r_standard_system inherit nologin;
+create role r_standard_public inherit nologin;
+
+/* special use roles neither to be assigned directly nor are they added to the t_users table. */
+create role u_standard_revision_requests inherit nologin;
+create role u_standard_statistics_update inherit nologin;
+create role u_standard_logger inherit nologin;
+create role u_standard_groups_handler inherit nologin;
+create role u_standard_grant_roles inherit nologin;
+
+
+grant r_standard to u_standard_grant_roles with admin option;
+grant r_standard_administer to u_standard_grant_roles with admin option;
+grant r_standard_manager to u_standard_grant_roles with admin option;
+grant r_standard_auditor to u_standard_grant_roles with admin option;
+grant r_standard_publisher to u_standard_grant_roles with admin option;
+grant r_standard_insurer to u_standard_grant_roles with admin option;
+grant r_standard_financer to u_standard_grant_roles with admin option;
+grant r_standard_reviewer to u_standard_grant_roles with admin option;
+grant r_standard_editor to u_standard_grant_roles with admin option;
+grant r_standard_drafter to u_standard_grant_roles with admin option;
+grant r_standard_requester to u_standard_grant_roles with admin option;
+grant r_standard_system to u_standard_grant_roles with admin option;
+grant r_standard_public to u_standard_grant_roles with admin option;
+
+
+/** This is the role and role group the database should use for anonymous traffic. I further suggest setting up pg_hba.conf to allow non-ssl connections (increase performance as public information is still public). **/
+/** If the data is meant to be private, then have the public account use the system user with ssl connections **/
+create role u_standard_public inherit login;
+
+grant r_standard_public to u_standard_public;
+
+
+/** These are the roles and role group the database should use for system activity (such as executing cron-jobs). **/
+create role u_standard_system inherit login;
+create role u_standard_system_administer inherit login;
+create role u_standard_system_manager inherit login;
+create role u_standard_system_auditor inherit login;
+create role u_standard_system_publisher inherit login;
+create role u_standard_system_insurer inherit login;
+create role u_standard_system_financer inherit login;
+create role u_standard_system_reviewer inherit login;
+create role u_standard_system_editor inherit login;
+create role u_standard_system_drafter inherit login;
+create role u_standard_system_requester inherit login;
+create role u_standard_system_public inherit login;
+
+
+
+/** Create and connect to the database **/
+create database standard;
+
+\c standard ;
+
+
+/** Custom database specific settings (do this on every connection made) **/
+set bytea_output to hex;
+set search_path to s_administers,s_managers,s_auditors,s_publishers,s_insurers,s_financers,s_reviewers,s_editors,s_drafters,s_requesters,s_users,public;
+set datestyle to us;
+
+
+/* Make sure public is never allowed to create tables! */
+revoke create on schema public from public;
--- /dev/null
+/** Standardized SQL Structure - Groups */
+/** This depends on: reservation-users.sql **/
+start transaction;
+
+
+
+/** Custom database specific settings (do this on every connection made) **/
+set bytea_output to hex;
+set search_path to s_administers,s_managers,s_auditors,s_publishers,s_insurers,s_financers,s_reviewers,s_editors,s_drafters,s_requesters,s_users,public;
+set datestyle to us;
+
+
+/* Note about composite groups (is_composite)
+ Instead of having an array of multiple groups assigned to one entity or having a table of group and entity associates, use a group that logically represents multiple groups.
+ For example, if I want to add both group_1 and group_2 to entity_a, then I can create group_3 and put all users from group_1 and group_2 in it.
+ @todo: I will likely need to create a composite groups table to manage the relations between a composite group and its non-composites for management purposes.
+
+ @todo: with this composite groups design, I can get rid of the user to groups table and need users only to be assigned to a single (composite) group.
+ the current flaw with this design may be with access control in creating or auto-creating composite groups.
+*/
+
+/** Groups **/
+create table s_tables.t_groups (
+ id bigint not null,
+ id_external bigint,
+ id_manager bigint,
+
+ id_sort smallint default 0,
+
+ name_machine varchar(128) not null,
+ name_human varchar(256) not null,
+
+ is_locked boolean default false not null,
+ is_deleted boolean default false not null,
+ is_composite boolean default false not null,
+ is_user boolean default false not null,
+
+ can_manage_paths boolean default false not null,
+
+ date_created timestamp default localtimestamp not null,
+ date_changed timestamp default localtimestamp not null,
+ date_synced timestamp default localtimestamp not null,
+ date_locked timestamp,
+ date_deleted timestamp,
+
+ settings json,
+
+ constraint cp_groups primary key (id),
+
+ constraint cc_groups_id check (id > 0),
+ constraint cc_groups_id_external check (id_external >= -1),
+ constraint cc_groups_name_machine check (name_machine ~ '[A-Za-z]\w*'),
+
+ constraint cu_groups_id_external unique (id_external),
+ constraint cu_groups_name_machine unique (name_machine),
+
+ constraint cf_groups_manager foreign key (id_manager) references s_tables.t_users (id) on delete restrict on update cascade
+);
+
+create sequence s_tables.se_groups_id owned by s_tables.t_groups.id;
+alter table s_tables.t_groups alter column id set default nextval('s_tables.se_groups_id'::regclass);
+
+grant select,insert,update on s_tables.t_groups to r_standard_manager, u_standard_groups_handler;
+grant select on s_tables.t_groups to r_standard_auditor;
+grant select,usage on s_tables.se_groups_id to r_standard_manager;
+grant usage on s_tables.se_groups_id to r_standard, r_standard_system, u_standard_groups_handler;
+
+/* Note: id_sort is not needed when directly validating against id or name_machine because both of those are already an index. */
+create index i_groups_id_sort_a on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 97;
+create index i_groups_id_sort_b on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 98;
+create index i_groups_id_sort_c on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 99;
+create index i_groups_id_sort_d on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 100;
+create index i_groups_id_sort_e on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 101;
+create index i_groups_id_sort_f on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 102;
+create index i_groups_id_sort_g on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 103;
+create index i_groups_id_sort_h on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 104;
+create index i_groups_id_sort_i on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 105;
+create index i_groups_id_sort_j on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 106;
+create index i_groups_id_sort_k on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 107;
+create index i_groups_id_sort_l on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 108;
+create index i_groups_id_sort_m on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 109;
+create index i_groups_id_sort_n on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 110;
+create index i_groups_id_sort_o on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 111;
+create index i_groups_id_sort_p on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 112;
+create index i_groups_id_sort_q on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 113;
+create index i_groups_id_sort_r on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 114;
+create index i_groups_id_sort_s on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 115;
+create index i_groups_id_sort_t on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 116;
+create index i_groups_id_sort_u on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 117;
+create index i_groups_id_sort_v on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 118;
+create index i_groups_id_sort_w on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 119;
+create index i_groups_id_sort_x on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 120;
+create index i_groups_id_sort_y on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 121;
+create index i_groups_id_sort_z on s_tables.t_groups (id_sort) with (fillfactor = 100) where id_sort = 122;
+
+/* only allow one user group per user. */
+create unique index i_groups_one_user_group on s_tables.t_groups (id_manager) where is_user;
+
+
+/*** provide group managers access to manage their groups ***/
+create view s_users.v_groups_manage_self with (security_barrier=true) as
+ with this_user as (select id from public.v_users_self_locked_not)
+ select id, id_external, name_machine, name_human, is_locked, is_composite, is_user, can_manage_paths, settings from s_tables.t_groups
+ where not is_deleted and id_manager in (select * from this_user);
+
+grant select on s_users.v_groups_manage_self to r_standard, r_standard_system;
+
+create view s_users.v_groups_manage_update with (security_barrier=true) as
+ select id, id_external, name_machine, name_human, is_locked, is_composite, is_user, can_manage_paths, settings from s_tables.t_groups
+ where not is_deleted and id_manager in (select id from public.v_users_self_locked_not)
+ with check option;
+
+grant update on s_users.v_groups_manage_update to r_standard, r_standard_system;
+
+
+/** each user shall have their own group.
+ Note: this violates the naming standard where group name should be first, such as 'group_kday' instead of 'kday_group'.
+ This is done specifically because of the id_sort index optimization.
+ name_machine is used instad of name_human for the group human name because name_machine is guaranteed to exist.
+**/
+create function s_administers.f_groups_group_user_insert() returns trigger security definer as $$
+ begin
+ insert into s_tables.t_groups (id_manager, name_machine, name_human, is_user) values (new.id, new.name_machine || '_user', 'User: ' || new.name_machine, true);
+
+ return null;
+ end;
+$$ language plpgsql;
+
+alter function s_administers.f_groups_group_user_insert () owner to u_standard_groups_handler;
+
+create function s_administers.f_groups_group_user_update() returns trigger security definer as $$
+ begin
+ if (old.name_machine <> new.name_machine) then
+ update s_tables.t_groups set name_machine = new.name_machine || '_user', name_human = 'User: ' || new.name_machine, is_locked = new.is_locked, is_deleted = new.is_deleted where id_manager = new.id and is_user;
+ elseif (old.is_deleted <> new.is_deleted) then
+ update s_tables.t_groups set is_locked = new.is_locked, is_deleted = new.is_deleted where id_manager = new.id and is_user;
+ elseif (old.is_locked <> new.is_locked) then
+ update s_tables.t_groups set is_locked = new.is_locked where id_manager = new.id and is_user;
+ end if;
+
+ return null;
+ end;
+$$ language plpgsql;
+
+alter function s_administers.f_groups_group_user_update () owner to u_standard_groups_handler;
+
+
+create trigger tr_groups_group_user_insert
+ after insert on s_tables.t_users
+ for each row execute procedure s_administers.f_groups_group_user_insert();
+
+create trigger tr_groups_group_user_update
+ after update on s_tables.t_users
+ for each row execute procedure s_administers.f_groups_group_user_update();
+
+
+/** Groups to Users Association **/
+create table s_tables.t_group_users (
+ id_user bigint not null,
+ id_group bigint not null,
+
+ date_created timestamp default localtimestamp not null,
+ date_changed timestamp default localtimestamp not null,
+ date_locked timestamp,
+ date_deleted timestamp,
+
+ is_locked boolean default false not null,
+ is_deleted boolean default false not null,
+
+ constraint cp_group_users unique (id_user, id_group),
+
+ constraint cf_group_users_user foreign key (id_user) references s_tables.t_users (id) on delete restrict on update cascade,
+
+ constraint cf_group_users_group foreign key (id_group) references s_tables.t_groups (id) on delete restrict on update cascade
+);
+
+grant select,insert,update on s_tables.t_groups to r_standard_manager;
+grant select on s_tables.t_groups to r_standard_auditor;
+
+
+/*** provide current user access to their own information ***/
+create view s_users.v_groups_self with (security_barrier=true) as
+ with allowed_groups as (select id_group from s_tables.t_group_users where not is_deleted and not is_locked and id_user in (select id from public.v_users_self_locked_not))
+ select id, id_external, id_manager, name_machine, name_human, is_locked, is_composite, date_created, date_changed, date_synced, can_manage_paths, settings from s_tables.t_groups
+ where not is_deleted and id in (select * from allowed_groups);
+
+grant select on s_users.v_groups_self to r_standard, r_standard_system;
+
+/*** provide group managers access to manage users assigned to their groups (any user id less than 1000 is reserved/special case, prohibit those). ***/
+create view s_users.v_group_users_manage with (security_barrier=true) as
+ with managed_groups as (select id from s_tables.t_groups where not is_deleted and id_manager in (select id from public.v_users_self_locked_not)),
+ available_users as (select id from s_tables.t_users where not is_deleted and not is_locked and not is_system and not is_public)
+ select id_user, id_group, is_locked from s_tables.t_group_users
+ where not is_deleted and id_group in (select * from managed_groups) and id_user in (select * from available_users);
+
+grant select on s_users.v_group_users_manage to r_standard, r_standard_system;
+
+create view s_users.v_group_users_manage_insert with (security_barrier=true) as
+ select id_user, id_group from s_tables.t_group_users
+ where not is_deleted and id_group in (select id from s_users.v_groups_manage_self) and id_group in (select id_group from s_tables.t_group_users where not is_deleted and not is_locked and id_user in (select id from public.v_users_self_locked_not)) and id_user in (select id from s_tables.t_users where not is_deleted and not is_locked and not is_system and not is_public)
+ with check option;
+
+grant insert on s_users.v_group_users_manage_insert to r_standard, r_standard_system;
+
+create view s_users.v_group_users_manage_update with (security_barrier=true) as
+ select id_user, id_group from s_tables.t_group_users
+ where not is_deleted and id_group in (select id from s_users.v_groups_manage_self) and id_group in (select id_group from s_tables.t_group_users where not is_deleted and not is_locked and id_user in (select id from public.v_users_self_locked_not)) and id_user in (select id from s_tables.t_users where not is_deleted and not is_locked and not is_system and not is_public)
+ with check option;
+
+grant update on s_users.v_group_users_manage_update to r_standard, r_standard_system;
+
+
+create trigger tr_groups_users_date_changed_deleted_or_locked
+ before update on s_tables.t_group_users
+ for each row execute procedure s_administers.f_common_update_date_changed_deleted_or_locked();
+
+
+
+/** Groups Composites **/
+create table s_tables.t_group_composites (
+ id_composite bigint not null,
+ id_group bigint not null,
+
+ date_created timestamp default localtimestamp not null,
+ date_changed timestamp default localtimestamp not null,
+ date_locked timestamp,
+ date_deleted timestamp,
+
+ is_locked boolean default false not null,
+ is_deleted boolean default false not null,
+
+ constraint cu_group_composites_id unique (id_composite, id_group),
+
+ constraint cf_group_composites_composite foreign key (id_composite) references s_tables.t_groups (id) on delete restrict on update cascade,
+ constraint cf_group_composites_group foreign key (id_group) references s_tables.t_groups (id) on delete restrict on update cascade
+);
+
+grant select,insert,update,delete on s_tables.t_groups to r_standard_manager;
+grant select on s_tables.t_groups to r_standard_auditor;
+
+
+/*** provide group managers access to manage composite groups. ***/
+create view s_users.v_group_composites with (security_barrier=true) as
+ with allowed_groups as (select id from s_users.v_groups_self where not is_locked),
+ managed_groups as (select id from s_users.v_groups_manage_self where not is_locked)
+ select id_composite, id_group, is_locked from s_tables.t_group_composites
+ where not is_deleted and id_group in (select * from managed_groups) or id_group in (select * from allowed_groups);
+
+grant select on s_users.v_group_composites to r_standard, r_standard_system;
+
+create view s_users.v_group_composites_manage_insert with (security_barrier=true) as
+ select id_user, id_group from s_tables.t_group_users
+ where not is_deleted and id_group in (select id_group from s_users.v_group_users_manage where not is_locked)
+ with check option;
+
+grant insert on s_users.v_group_composites_manage_insert to r_standard, r_standard_system;
+
+create view s_users.v_group_composites_manage_update with (security_barrier=true) as
+ select id_user, id_group from s_tables.t_group_users
+ where not is_deleted and id_group in (select id_group from s_users.v_group_users_manage where not is_locked)
+ with check option;
+
+grant update on s_users.v_group_composites_manage_update to r_standard, r_standard_system;
+
+
+create trigger tr_groups_date_changed_deleted_or_locked
+ before update on s_tables.t_group_composites
+ for each row execute procedure s_administers.f_common_update_date_changed_deleted_or_locked();
+
+
+
+commit transaction;
--- /dev/null
+/** Standardized SQL Structure - Last */
+/** This depends on: everything (run this absolutely last) **/
+
+/** The purpose of this is to add all initial data after all appropriate triggers are defined. ***/
+start transaction;
+
+
+
+/*** start the sequence count at 1000 to allow for < 1000 to be reserved for special uses ***/
+alter sequence s_tables.se_log_types_id start 1000;
+alter sequence s_tables.se_log_types_id restart;
+
+
+/** create well known types that can then be user for indexes (all new types added should be considered for custom indexing). **/
+insert into s_tables.t_log_types (id, name_machine, name_human) values (0, 'none', 'None');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (1, 'php', 'PHP');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (2, 'theme', 'Theme');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (3, 'cache', 'Cache');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (4, 'javascript', 'Javascript');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (5, 'ajax', 'AJAX');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (6, 'sql', 'SQL');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (7, 'form', 'Form');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (8, 'form_validate', 'Form Validation');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (9, 'form_submit', 'Form Submit');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (10, 'load', 'Load');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (11, 'save', 'Save');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (12, 'render', 'Render');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (13, 'client', 'Client');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (14, 'add', 'Add');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (15, 'create', 'Create');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (16, 'change', 'Change');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (17, 'delete', 'Delete');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (18, 'redirect', 'Redirect');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (19, 'login', 'Login');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (20, 'logout', 'Logout');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (21, 'session', 'Session');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (22, 'database', 'Database');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (23, 'not_found', 'Not Found');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (24, 'access_denied', 'Access Denied');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (25, 'removed', 'Removed');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (26, 'locked', 'Locked');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (27, 'timeout', 'Timeout');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (28, 'expire', 'Expiration');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (29, 'user', 'User');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (30, 'error', 'Error');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (31, 'content', 'Content');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (32, 'workflow', 'Workflow');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (33, 'draft', 'Draft');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (34, 'clone', 'Clone');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (35, 'publish', 'Publish');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (36, 'revert', 'Revert');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (37, 'validate', 'Validate');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (38, 'approve', 'Approve');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (39, 'password', 'Password');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (40, 'revision', 'Revision');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (41, 'search', 'Search');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (42, 'access', 'Access');
+insert into s_tables.t_log_types (id, name_machine, name_human) values (43, 'unknown', 'Unknown');
+
+
+
+/** create well known types that can then be user for indexes (all new types added should be considered for custom indexing). **/
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (0, '0', 'Undefined');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (1, '1', 'Invalid');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (2, '2', 'Unknown');
+
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (100, '100', 'Continue');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (101, '101', 'Switching Protocols');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (102, '102', 'Processing');
+
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (200, '200', 'OK');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (201, '201', 'Created');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (202, '202', 'Accepted');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (203, '203', 'Non-Authoritative Information');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (204, '204', 'No Content');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (205, '205', 'Reset Content');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (206, '206', 'Partial Content');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (207, '207', 'Multi-Status');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (208, '208', 'Already Reported');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (226, '226', 'IM used');
+
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (300, '300', 'Multiple Choices');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (301, '301', 'Moved Permanently');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (302, '302', 'Found');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (303, '303', 'See Other');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (304, '304', 'Not Modified');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (305, '305', 'Use Proxy');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (306, '306', 'Switch Proxy');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (307, '307', 'Temporary Redirect');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (308, '308', 'Permanent Redirect');
+
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (400, '400', 'Bad Request');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (401, '401', 'Unauthorized');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (402, '402', 'Payment Required');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (403, '403', 'Forbidden');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (404, '404', 'Not Found');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (405, '405', 'Method Not Allowed');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (406, '406', 'Not Acceptable');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (407, '407', 'Proxy Authentication Required');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (408, '408', 'Request Timeout');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (409, '409', 'Conflict');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (410, '410', 'Gone');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (411, '411', 'Length Required');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (412, '412', 'Precondition Failed');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (413, '413', 'Payload Too Large');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (414, '414', 'Request-URI Too Long');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (415, '415', 'Unsupported Media Type');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (416, '416', 'Requested Range Not Satisfiable');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (417, '417', 'Expectation Failed');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (422, '422', 'Misdirected Request');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (423, '423', 'Locked');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (424, '424', 'Failed Dependency');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (426, '426', 'Upgrade Required');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (428, '428', 'Precondition Required');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (429, '429', 'Too Many Requests');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (431, '431', 'Request Header Fields Too Large');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (451, '451', 'Unavailable For Legal Reasons');
+
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (500, '500', 'Internal Server Error');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (501, '501', 'Not Implemented');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (502, '502', 'Bad Gateway');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (503, '503', 'Service Unavailable');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (504, '504', 'Gateway Timeout');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (505, '505', 'HTTP Version Not Supported');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (506, '506', 'Variant Also Negotiates');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (507, '507', 'Insufficient Storage');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (508, '508', 'Loop Detected');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (510, '510', 'Not Extended');
+insert into s_tables.t_type_http_status_codes (id, name_machine, name_human) values (511, '511', 'Network Authentication Required');
+
+
+/*** start the sequence count at 1000 to allow for < 1000 to be reserved for special uses ***/
+alter sequence s_tables.se_log_type_severity_levels_id start 1000;
+alter sequence s_tables.se_log_type_severity_levels_id restart;
+
+
+/** create well known types that can then be user for indexes (all new types added should be considered for custom indexing). **/
+insert into s_tables.t_log_type_severity_levels (id, name_machine, name_human) values (0, 'none', 'None');
+insert into s_tables.t_log_type_severity_levels (id, name_machine, name_human) values (1, 'information', 'Information');
+insert into s_tables.t_log_type_severity_levels (id, name_machine, name_human) values (2, 'notice', 'Notice');
+insert into s_tables.t_log_type_severity_levels (id, name_machine, name_human) values (3, 'debug', 'Debug');
+insert into s_tables.t_log_type_severity_levels (id, name_machine, name_human) values (4, 'warning', 'Warning');
+insert into s_tables.t_log_type_severity_levels (id, name_machine, name_human) values (5, 'error', 'Error');
+insert into s_tables.t_log_type_severity_levels (id, name_machine, name_human) values (6, 'alert', 'Alert');
+insert into s_tables.t_log_type_severity_levels (id, name_machine, name_human) values (7, 'critical', 'Critical');
+insert into s_tables.t_log_type_severity_levels (id, name_machine, name_human) values (8, 'emergency', 'Emergency');
+
+
+
+insert into s_tables.t_type_mime_categorys (id, name_machine, name_human) values (0, 'none', 'None');
+insert into s_tables.t_type_mime_categorys (id, name_machine, name_human) values (1, 'unknown', 'Unknown');
+insert into s_tables.t_type_mime_categorys (id, name_machine, name_human, field_category) values (2, 'provided', 'Provided', '*');
+insert into s_tables.t_type_mime_categorys (id, name_machine, name_human, field_category) values (3, 'stream', 'Stream', 'application');
+insert into s_tables.t_type_mime_categorys (id, name_machine, name_human, field_category) values (4, 'multipart', 'Multipart', 'multipart');
+insert into s_tables.t_type_mime_categorys (id, name_machine, name_human, field_category) values (5, 'text', 'Text', 'text');
+insert into s_tables.t_type_mime_categorys (id, name_machine, name_human, field_category) values (6, 'image', 'Image', 'image');
+insert into s_tables.t_type_mime_categorys (id, name_machine, name_human, field_category) values (7, 'audio', 'Audio', 'audio');
+insert into s_tables.t_type_mime_categorys (id, name_machine, name_human, field_category) values (8, 'video', 'Video', 'video');
+insert into s_tables.t_type_mime_categorys (id, name_machine, name_human, field_category) values (9, 'document', 'Document', 'application');
+insert into s_tables.t_type_mime_categorys (id, name_machine, name_human, field_category) values (10, 'container', 'Container', 'application');
+insert into s_tables.t_type_mime_categorys (id, name_machine, name_human, field_category) values (11, 'application', 'Application', 'application');
+
+
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human) values (0, 0, 'none', 'None');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human) values (1, 1, 'unknown', 'Unknown');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (2, 2, 'provided', 'Provided', NULL, '*/*');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (2, 2, 'provided_text', 'Provided Text', NULL, 'text/*');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (2, 2, 'provided_image', 'Provided Image', NULL, 'image/*');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (2, 2, 'provided_audio', 'Provided Audio', NULL, 'audio/*');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (2, 2, 'provided_video', 'Provided Video', NULL, 'video/*');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (2, 2, 'provided_application', 'Provided Application', NULL, 'application/*');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (3, 3, 'stream', 'Stream', 'octect-stream', 'application/octect-stream');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (4, 4, 'multipart', 'Form Data', 'form-data', 'multipart/form-data');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (5, 11, 'application', 'URL Data', 'x-www-form-urlencoded', 'application/x-www-form-urlencoded');
+
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (1000, 5, 'text', 'Text', NULL, 'text/*');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (1001, 5, 'text_plain', 'Plain Text', 'txt', 'text/plain');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (1002, 5, 'text_html', 'HTML', 'html', 'text/html');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (1003, 5, 'text_rss', 'RSS', 'rss', 'text/rss');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (1003, 5, 'text_rss_xml', 'RSS+XML', 'rss', 'text/rss+xml');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (1003, 5, 'text_rdf_xml', 'RDF+XML', 'rss', 'text/rdf+xml');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (1003, 5, 'text_atom_xml', 'ATOM+XML', 'rss', 'text/atom+xml');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (1004, 5, 'text_ical', 'iCalendar', 'ics', 'text/calendar');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (1005, 5, 'text_csv', 'CSV', 'csv', 'text/csv');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (1006, 5, 'text_xml', 'XML', 'xml', 'text/xml');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (1007, 5, 'text_css', 'CSS', 'css', 'text/css');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (1008, 5, 'text_js', 'Javascript', 'js', 'text/js');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (1008, 5, 'text_js', 'Javascript', 'js', 'application/js');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (1009, 5, 'text_json', 'JSON', 'json', 'text/json');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (1010, 5, 'text_rich', 'Rich Text', 'rtf', 'text/rich');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (1011, 5, 'text_xhtml', 'XHTML', 'xhtml', 'text/xhtml');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (1012, 5, 'text_ps', 'Postscript', 'ps', 'text/ps');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (1013, 5, 'text_fss', 'FSS', 'setting', 'text/fss');
+
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (2000, 6, 'image', 'Image', NULL, 'image/*');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (2001, 6, 'image_png', 'PNG', 'png', 'image/png');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (2002, 6, 'image_gif', 'GIF', 'gif', 'image/gif');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (2003, 6, 'image_jpg', 'JPEG', 'jpg', 'image/jpg');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (2003, 6, 'image_jpg', 'JPEG', 'jpeg', 'image/jpg');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (2003, 6, 'image_jpg', 'JPEG', 'jpx', 'image/jpg');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (2004, 6, 'image_bmp', 'Bitmap', 'bmp', 'image/bmp');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (2005, 6, 'image_svg', 'SVG', 'svg', 'image/svg');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (2006, 6, 'image_tiff', 'Tiff', 'tiff', 'image/tiff');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (2006, 6, 'image_tiff', 'Tiff', 'tiff', 'image/tiff-fx');
+
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (3000, 7, 'audio', 'Audio', NULL, 'audio/*');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (3001, 7, 'audio_wav', 'Wave', 'wav', 'audio/wav');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (3002, 7, 'audio_ogg', 'OGG', 'ogg', 'audio/ogg');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (3003, 7, 'audio_speex', 'Speex', 'spx', 'audio/speex');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (3004, 7, 'audio_flac', 'FLAC', 'flac', 'audio/flac');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (3005, 7, 'audio_mp3', 'MP3', 'mp3', 'audio/mpeg');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (3005, 7, 'audio_mp1', 'MP1', 'mp1', 'audio/mpeg');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (3005, 7, 'audio_mp2', 'MP2', 'mp2', 'audio/mpeg');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (3006, 7, 'audio_mp4', 'MP4', 'mp4', 'audio/mp4');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (3007, 7, 'audio_midi', 'SVG', 'svg', 'audio/svg');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (3008, 7, 'audio_basic', 'Audio', 'au', 'audio/basic');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (3008, 7, 'audio_basic', 'Audio', 'snd', 'audio/basic');
+
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (4000, 8, 'video', 'Video', NULL, 'video/*');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (4001, 8, 'video_mpeg', 'MPEG', 'mp4', 'video/mp4');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (4001, 8, 'video_mpeg', 'MPEG', 'mpg', 'video/mp4');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (4002, 8, 'video_ogg', 'OGG', 'ogg', 'video/ogg');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (4003, 8, 'video_h264', 'H264', 'h264', 'video/h264');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (4003, 8, 'video_x264', 'X264', 'x264', 'video/x264');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (4004, 8, 'video_quicktine', 'Quicktime', 'qt', 'video/qt');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (4005, 8, 'video_dv', 'Digital Video', 'dv', 'video/dv');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (4006, 8, 'video_jpeg', 'Motion JPEG', 'jpg', 'video/jpeg');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (4006, 8, 'video_webm', 'Tiff', 'tiff', 'video/tiff-fx');
+
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (5000, 9, 'document', 'Document', NULL, 'application/*');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (5001, 9, 'document_libre_chart', 'LibreOffice Chart', 'odc', 'application/vnd.oasis.opendocument.chart');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (5002, 9, 'document_libre_formula', 'LibreOffice Formula', 'odf', 'application/vnd.oasis.opendocument.formula');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (5003, 9, 'document_libre_graphic', 'LibreOffice Graphic', 'odg', 'application/vnd.oasis.opendocument.graphics');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (5004, 9, 'document_libre_presentation', 'LibreOffice Presentation', 'odp', 'application/vnd.oasis.opendocument.presentation');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (5005, 9, 'document_libre_spreadsheet', 'LibreOffice Spreadsheet', 'ods', 'application/vnd.oasis.opendocument.spreadsheet');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (5006, 9, 'document_libre_text', 'LibreOffice Text', 'odt', 'application/vnd.oasis.opendocument.text');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (5007, 9, 'document_libre_html', 'LibreOffice HTML', 'odh', 'application/vnd.oasis.opendocument.text-web');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (5008, 9, 'document_pdf', 'PDF', 'pdf', 'application/pdf');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (5009, 9, 'document_abi_word', 'Abiword Text', 'abw', 'application/abiword-compressed');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (5010, 9, 'document_ms_word', 'Microsoft Word', 'docx', 'application/msword');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (5010, 9, 'document_ms_word', 'Microsoft Word', 'doc', 'application/msword');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (5011, 9, 'document_ms_excel', 'Microsoft Excel', 'xlsx', 'application/ms-excel');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (5011, 9, 'document_ms_excel', 'Microsoft Excel', 'xls', 'application/ms-excel');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (5012, 9, 'document_ms_powerpoint', 'Microsoft Powerpoint', 'pptx', 'application/ms-powerpoint');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (5012, 9, 'document_ms_powerpoint', 'Microsoft Powerpoint', 'ppt', 'application/ms-powerpoint');
+
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (6000, 10, 'container', 'Container', NULL, 'application/*');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (6001, 10, 'container_tar', 'Tar', 'tar', 'application/tar');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (6002, 10, 'container_cpio', 'CPIO', 'cpio', 'application/cpio');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (6003, 10, 'container_java', 'Java', 'jar', 'application/java');
+
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (7000, 11, 'application', 'Application', NULL, 'application/*');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (7001, 11, 'application_ocsp_request', 'OCSP Request', NULL, 'application/ocsp-request');
+insert into s_tables.t_type_mime_types (id, id_category, name_machine, name_human, field_extension, field_mime) values (7002, 11, 'application_ocsp_response', 'OCSP Response', NULL, 'application/ocsp-response');
+
+
+
+/** create all of the known codes, initializing them to 0. **/
+insert into s_tables.t_statistics_http_status_codes (code) values (0);
+insert into s_tables.t_statistics_http_status_codes (code) values (1);
+insert into s_tables.t_statistics_http_status_codes (code) values (2);
+
+insert into s_tables.t_statistics_http_status_codes (code) values (100);
+insert into s_tables.t_statistics_http_status_codes (code) values (101);
+insert into s_tables.t_statistics_http_status_codes (code) values (102);
+
+insert into s_tables.t_statistics_http_status_codes (code) values (200);
+insert into s_tables.t_statistics_http_status_codes (code) values (201);
+insert into s_tables.t_statistics_http_status_codes (code) values (202);
+insert into s_tables.t_statistics_http_status_codes (code) values (203);
+insert into s_tables.t_statistics_http_status_codes (code) values (204);
+insert into s_tables.t_statistics_http_status_codes (code) values (205);
+insert into s_tables.t_statistics_http_status_codes (code) values (206);
+insert into s_tables.t_statistics_http_status_codes (code) values (207);
+insert into s_tables.t_statistics_http_status_codes (code) values (208);
+insert into s_tables.t_statistics_http_status_codes (code) values (226);
+
+insert into s_tables.t_statistics_http_status_codes (code) values (300);
+insert into s_tables.t_statistics_http_status_codes (code) values (301);
+insert into s_tables.t_statistics_http_status_codes (code) values (302);
+insert into s_tables.t_statistics_http_status_codes (code) values (303);
+insert into s_tables.t_statistics_http_status_codes (code) values (304);
+insert into s_tables.t_statistics_http_status_codes (code) values (305);
+insert into s_tables.t_statistics_http_status_codes (code) values (306);
+insert into s_tables.t_statistics_http_status_codes (code) values (307);
+insert into s_tables.t_statistics_http_status_codes (code) values (308);
+
+insert into s_tables.t_statistics_http_status_codes (code) values (400);
+insert into s_tables.t_statistics_http_status_codes (code) values (401);
+insert into s_tables.t_statistics_http_status_codes (code) values (402);
+insert into s_tables.t_statistics_http_status_codes (code) values (403);
+insert into s_tables.t_statistics_http_status_codes (code) values (404);
+insert into s_tables.t_statistics_http_status_codes (code) values (405);
+insert into s_tables.t_statistics_http_status_codes (code) values (406);
+insert into s_tables.t_statistics_http_status_codes (code) values (407);
+insert into s_tables.t_statistics_http_status_codes (code) values (408);
+insert into s_tables.t_statistics_http_status_codes (code) values (409);
+insert into s_tables.t_statistics_http_status_codes (code) values (410);
+insert into s_tables.t_statistics_http_status_codes (code) values (411);
+insert into s_tables.t_statistics_http_status_codes (code) values (412);
+insert into s_tables.t_statistics_http_status_codes (code) values (413);
+insert into s_tables.t_statistics_http_status_codes (code) values (414);
+insert into s_tables.t_statistics_http_status_codes (code) values (415);
+insert into s_tables.t_statistics_http_status_codes (code) values (416);
+insert into s_tables.t_statistics_http_status_codes (code) values (417);
+insert into s_tables.t_statistics_http_status_codes (code) values (422);
+insert into s_tables.t_statistics_http_status_codes (code) values (423);
+insert into s_tables.t_statistics_http_status_codes (code) values (424);
+insert into s_tables.t_statistics_http_status_codes (code) values (426);
+insert into s_tables.t_statistics_http_status_codes (code) values (428);
+insert into s_tables.t_statistics_http_status_codes (code) values (429);
+insert into s_tables.t_statistics_http_status_codes (code) values (431);
+insert into s_tables.t_statistics_http_status_codes (code) values (451);
+
+insert into s_tables.t_statistics_http_status_codes (code) values (500);
+insert into s_tables.t_statistics_http_status_codes (code) values (501);
+insert into s_tables.t_statistics_http_status_codes (code) values (502);
+insert into s_tables.t_statistics_http_status_codes (code) values (503);
+insert into s_tables.t_statistics_http_status_codes (code) values (504);
+insert into s_tables.t_statistics_http_status_codes (code) values (505);
+insert into s_tables.t_statistics_http_status_codes (code) values (506);
+insert into s_tables.t_statistics_http_status_codes (code) values (507);
+insert into s_tables.t_statistics_http_status_codes (code) values (508);
+insert into s_tables.t_statistics_http_status_codes (code) values (510);
+insert into s_tables.t_statistics_http_status_codes (code) values (511);
+
+
+
+/*** start the sequence count at 1000 to allow for < 1000 to be reserved for special uses ***/
+alter sequence s_tables.se_users_id start 1000;
+alter sequence s_tables.se_users_id restart;
+
+
+/*** create hard-coded/internal user ids ***/
+insert into s_tables.t_users (id, name_machine, name_human, is_private, is_system, is_administer) values (3, 'u_standard_system_administer', (null, 'System', null, 'Administer', null, 'System (Administer)'), false, true, true);
+insert into s_tables.t_users (id, name_machine, name_human, is_private, is_system, is_manager) values (4, 'u_standard_system_manager', (null, 'System', null, 'Manager', null, 'System (Manager)'), false, true, true);
+insert into s_tables.t_users (id, name_machine, name_human, is_private, is_system, is_auditor) values (5, 'u_standard_system_auditor', (null, 'System', null, 'Auditor', null, 'System (Auditor)'), false, true, true);
+insert into s_tables.t_users (id, name_machine, name_human, is_private, is_system, is_publisher) values (6, 'u_standard_system_publisher', (null, 'System', null, 'Publisher', null, 'System (Publisher)'), false, true, true);
+insert into s_tables.t_users (id, name_machine, name_human, is_private, is_system, is_insurer) values (7, 'u_standard_system_insurer', (null, 'System', null, 'Insurer', null, 'System (Insurer)'), false, true, true);
+insert into s_tables.t_users (id, name_machine, name_human, is_private, is_system, is_financer) values (8, 'u_standard_system_financer', (null, 'System', null, 'Financer', null, 'System (Financer)'), false, true, true);
+insert into s_tables.t_users (id, name_machine, name_human, is_private, is_system, is_reviewer) values (9, 'u_standard_system_reviewer', (null, 'System', null, 'Reviewer', null, 'System (Reviewer)'), false, true, true);
+insert into s_tables.t_users (id, name_machine, name_human, is_private, is_system, is_editor) values (10, 'u_standard_system_editor', (null, 'System', null, 'Editor', null, 'System (Editor)'), false, true, true);
+insert into s_tables.t_users (id, name_machine, name_human, is_private, is_system, is_drafter) values (11, 'u_standard_system_drafter', (null, 'System', null, 'Drafter', null, 'System (Drafter)'), false, true, true);
+insert into s_tables.t_users (id, name_machine, name_human, is_private, is_system, is_requester) values (12, 'u_standard_system_requester', (null, 'System', null, 'Requester', null, 'System (Requester)'), false, true, true);
+insert into s_tables.t_users (id, name_machine, name_human, is_private, is_system, is_public) values (13, 'u_standard_system_public', (null, 'System', null, 'Public', null, 'System (Public)'), false, true, true);
+insert into s_tables.t_users (id, name_machine, name_human, is_private, is_system) values (14, 'u_standard_system', (null, 'System', null, 'System', null, 'System'), false, true);
+
+
+
+commit;
--- /dev/null
+/** Standardized SQL Structure - Logs - Groups */
+/** This depends on: reservation-groups.sql **/
+start transaction;
+
+
+
+/** Custom database specific settings (do this on every connection made) **/
+set bytea_output to hex;
+set search_path to s_administers,s_managers,s_auditors,s_publishers,s_insurers,s_financers,s_reviewers,s_editors,s_drafters,s_requesters,s_users,public;
+set datestyle to us;
+
+
+
+/*** provide group activity logging ***/
+create table s_tables.t_log_groups (
+ id bigint not null,
+ id_user bigint not null,
+ id_user_session bigint not null,
+ id_group bigint not null,
+
+ log_type bigint not null,
+ log_details json,
+ log_date timestamp default localtimestamp not null,
+
+ constraint cp_log_groups primary key (id),
+
+ constraint cc_log_groups_id check (id > 0),
+
+ constraint cf_log_groups_id_user foreign key (id_user) references s_tables.t_users (id) on delete restrict on update cascade,
+ constraint cf_log_groups_id_user_session foreign key (id_user_session) references s_tables.t_users (id) on delete restrict on update cascade,
+ constraint cf_log_groups_id_group foreign key (id_group) references s_tables.t_groups (id) on delete restrict on update cascade,
+ constraint cf_log_groups_log_type foreign key (log_type) references s_tables.t_log_types (id) on delete restrict on update cascade
+);
+
+create sequence s_tables.se_log_groups_id owned by s_tables.t_log_groups.id;
+alter table s_tables.t_log_groups alter column id set default nextval('s_tables.se_log_groups_id'::regclass);
+
+grant select,usage on s_tables.se_log_groups_id to r_standard_manager, r_standard_auditor;
+grant usage on s_tables.se_log_groups_id to r_standard, r_standard_system;
+
+
+/** only allow select and insert for users when user id is current user **/
+create view s_users.v_log_groups_self with (security_barrier=true) as
+ with this_user as (select id from public.v_users_self_locked_not)
+ select id, id_user, id_group, log_type, log_details, log_date from s_tables.t_log_groups
+ where id_user in (select * from this_user);
+
+grant select on s_users.v_log_groups_self to r_standard, r_standard_system;
+
+create view s_users.v_log_groups_self_insert with (security_barrier=true) as
+ select id_group, log_type, log_details from s_tables.t_log_groups
+ where id_user in (select id from public.v_users_self_locked_not) and id_group in (select id from s_users.v_groups_self where not is_locked)
+ with check option;
+
+grant insert on s_users.v_log_groups_self_insert to r_standard, r_standard_system;
+
+
+create trigger tr_log_groups_date_changed_deleted_or_locked
+ before update on s_tables.t_log_groups
+ for each row execute procedure s_administers.f_common_update_date_changed_deleted_or_locked();
+
+create trigger tr_log_groups_enforce_user_and_session_ids
+ before insert on s_tables.t_log_groups
+ for each row execute procedure s_administers.f_common_enforce_user_and_session_ids();
+
+
+
+/*** provide group user activity logging ***/
+create table s_tables.t_log_group_users (
+ id bigint not null,
+ id_user bigint not null,
+ id_user_session bigint not null,
+ id_group bigint not null,
+
+ log_type bigint not null,
+ log_date timestamp default localtimestamp not null,
+
+ constraint cp_log_group_users primary key (id),
+
+ constraint cc_log_group_users_id check (id > 0),
+
+ constraint cf_log_group_users_id_user foreign key (id_user) references s_tables.t_users (id) on delete restrict on update cascade,
+ constraint cf_log_group_users_id_user_session foreign key (id_user_session) references s_tables.t_users (id) on delete restrict on update cascade,
+ constraint cf_log_group_users_id_group foreign key (id_group) references s_tables.t_groups (id) on delete restrict on update cascade,
+ constraint cf_log_group_users_log_type foreign key (log_type) references s_tables.t_log_types (id) on delete restrict on update cascade
+);
+
+create sequence s_tables.se_log_group_users_id owned by s_tables.t_log_group_users.id;
+alter table s_tables.t_log_group_users alter column id set default nextval('s_tables.se_log_group_users_id'::regclass);
+
+grant select,usage on s_tables.se_log_group_users_id to r_standard_manager, r_standard_auditor;
+grant usage on s_tables.se_log_group_users_id to r_standard, r_standard_system;
+
+
+/** only allow select and insert for users when user id is current user **/
+create view s_users.v_log_group_users_self with (security_barrier=true) as
+ with this_user as (select id from public.v_users_self_locked_not),
+ allowed_groups as (select id from s_users.v_groups_self where not is_locked)
+ select id, id_user, id_group, log_type, log_date from s_tables.t_log_group_users
+ where id_user in (select * from this_user) or id_group in (select * from allowed_groups);
+
+grant select on s_users.v_log_group_users_self to r_standard, r_standard_system;
+
+create view s_users.v_log_group_users_self_insert with (security_barrier=true) as
+ select id_group, log_type from s_tables.t_log_group_users
+ where id_user in (select id from public.v_users_self_locked_not) and id_group in (select id from s_users.v_groups_self where not is_locked)
+ with check option;
+
+grant insert on s_users.v_log_group_users_self_insert to r_standard, r_standard_system;
+
+
+create trigger tr_log_group_users_date_changed_deleted_or_locked
+ before update on s_tables.t_log_group_users
+ for each row execute procedure s_administers.f_common_update_date_changed_deleted_or_locked();
+
+create trigger tr_log_group_users_enforce_user_and_session_ids
+ before insert on s_tables.t_log_group_users
+ for each row execute procedure s_administers.f_common_enforce_user_and_session_ids();
+
+
+
+commit transaction;
--- /dev/null
+/** Standardized SQL Structure - Logs - Problems */
+/** This depends on: reservation-users.sql **/
+/* The problem logs are intended for temporary reporting of problems and are meant to allow permanent deletion. */
+start transaction;
+
+
+
+/** Custom database specific settings (do this on every connection made) **/
+set bytea_output to hex;
+set search_path to s_administers,s_managers,s_auditors,s_publishers,s_insurers,s_financers,s_reviewers,s_editors,s_drafters,s_requesters,s_users,public;
+set datestyle to us;
+
+
+
+/** Provide a log of problems, which are defined by the software. **/
+create table s_tables.t_log_problems (
+ id bigint not null,
+
+ name_machine varchar(128) not null,
+ name_human varchar(256) not null,
+
+ date_created timestamp default localtimestamp not null,
+ date_changed timestamp default localtimestamp not null,
+
+ constraint cp_log_problems primary key (id),
+
+ constraint cc_log_problems_id check (id > 0),
+
+ constraint cu_log_problems_name_machine unique (name_machine)
+);
+
+create sequence s_tables.se_log_problems_id owned by s_tables.t_log_problems.id;
+alter table s_tables.t_log_problems alter column id set default nextval('s_tables.se_log_problems_id'::regclass);
+
+grant select,insert,update,delete on s_tables.t_log_problems to r_standard_manager;
+grant select on s_tables.t_log_problems to r_standard_auditor;
+grant select,usage on s_tables.se_log_problems_id to r_standard_manager;
+grant usage on s_tables.se_log_problems_id to r_standard, r_standard_system;
+
+
+
+/** Provide a log of problems, associated with a given user. **/
+create table s_tables.t_log_problems_users (
+ id_problem bigint not null,
+ id_user bigint not null,
+ id_user_session bigint not null,
+
+ date_created timestamp default localtimestamp not null,
+ date_changed timestamp default localtimestamp not null,
+
+ log_details json,
+
+ constraint cp_log_problems_users primary key (id_problem, id_user),
+
+ constraint cf_log_problems_users_id_problem foreign key (id_problem) references s_tables.t_log_problems (id) on delete restrict on update cascade,
+ constraint cf_log_problems_users_id_user foreign key (id_user) references s_tables.t_users (id) on delete restrict on update cascade,
+ constraint cf_log_problems_users_id_user_session foreign key (id_user_session) references s_tables.t_users (id) on delete restrict on update cascade
+);
+
+grant select,insert,update,delete on s_tables.t_log_problems_users to r_standard_manager;
+grant select on s_tables.t_log_problems_users to r_standard_auditor;
+
+
+/** only allow select, insert, and delete for users when user id is current user **/
+create view s_users.v_log_problems_users_self with (security_barrier=true) as
+ with this_user as (select id from public.v_users_self_locked_not)
+ select id_problem, date_created, date_changed, log_details from s_tables.t_log_problems_users
+ where id_user in (select * from this_user);
+
+grant select on s_users.v_log_problems_users_self to r_standard, r_standard_system;
+
+
+create view s_users.v_log_problems_users_self_insert with (security_barrier=true) as
+ select id_problem, date_changed, log_details from s_tables.t_log_problems_users
+ where id_user in (select id from public.v_users_self_locked_not)
+ with check option;
+
+grant insert on s_users.v_log_problems_users_self_insert to r_standard, r_standard_system;
+
+
+create view s_users.v_log_problems_users_self_delete with (security_barrier=true) as
+ select id_problem from s_tables.t_log_problems_users
+ where id_user in (select id from public.v_users_self_locked_not)
+ with check option;
+
+grant delete on s_users.v_log_problems_users_self_delete to r_standard, r_standard_system;
+
+
+/** automatically delete problems deleted from the table s_tables.t_log_problems_users **/
+create function s_tables.f_log_problems_users_delete() returns trigger security definer as $$
+ begin
+ if (tg_op = 'DELETE') then
+ delete from s_tables.t_log_problems where id = old.id_problem;
+ return old;
+ end if;
+
+ return null;
+ end;
+$$ language plpgsql;
+
+alter function s_tables.f_log_problems_users_delete () owner to u_standard_logger;
+
+create trigger tr_log_problems_users_delete
+ after delete on s_tables.t_log_problems_users
+ for each row execute procedure s_tables.f_log_problems_users_delete();
+
+create trigger tr_log_problems_enforce_user_and_session_ids
+ before insert on s_tables.t_log_problems
+ for each row execute procedure s_administers.f_common_enforce_user_and_session_ids();
+
+
+
+commit transaction;
--- /dev/null
+/** Standardized SQL Structure - Logs - Types */
+/** This depends on: reservation-users.sql **/
+start transaction;
+
+
+
+/** Custom database specific settings (do this on every connection made) **/
+set bytea_output to hex;
+set search_path to s_administers,s_managers,s_auditors,s_publishers,s_insurers,s_financers,s_reviewers,s_editors,s_drafters,s_requesters,s_users,public;
+set datestyle to us;
+
+
+
+/*** provide log type id and names ***/
+create table s_tables.t_log_types (
+ id bigint not null,
+
+ name_machine varchar(128) not null,
+ name_human varchar(256) not null,
+
+ is_locked boolean default false not null,
+ is_deleted boolean default false not null,
+
+ date_created timestamp default localtimestamp not null,
+ date_changed timestamp default localtimestamp not null,
+ date_deleted timestamp,
+
+ constraint cp_log_types primary key (id),
+
+ constraint cu_log_types_user unique (name_machine),
+
+ constraint cc_log_types_id check (id >= 0)
+);
+
+create sequence s_tables.se_log_types_id owned by s_tables.t_log_types.id;
+alter table s_tables.t_log_types alter column id set default nextval('s_tables.se_log_types_id'::regclass);
+
+grant select,insert,update on s_tables.t_log_types to r_standard_administer;
+grant select on s_tables.t_log_types to r_standard_manager, r_standard_auditor;
+grant select,usage on s_tables.se_log_types_id to r_standard_administer;
+
+create index i_log_types_deleted_not on s_tables.t_log_types (id)
+ where not is_deleted;
+
+create index i_log_types_public on s_tables.t_log_types (id)
+ where not is_deleted and not is_locked;
+
+create view public.v_log_types with (security_barrier=true) as
+ select id, name_machine, name_human from s_tables.t_log_types
+ where not is_deleted and not is_locked;
+
+grant select on public.v_log_types to r_standard, r_standard_public, r_standard_system;
+
+
+create trigger tr_log_types_date_changed_deleted_or_locked
+ before update on s_tables.t_log_types
+ for each row execute procedure s_administers.f_common_update_date_changed_deleted_or_locked();
+
+
+
+/*** provide log severity level id and names ***/
+create table s_tables.t_log_type_severity_levels (
+ id bigint not null,
+ name_machine varchar(128) not null,
+ name_human varchar(256) not null,
+
+ is_locked boolean default false not null,
+ is_deleted boolean default false not null,
+
+ date_created timestamp default localtimestamp not null,
+ date_changed timestamp default localtimestamp not null,
+ date_locked timestamp,
+ date_deleted timestamp,
+
+ constraint cp_log_type_severity_levels primary key (id),
+
+ constraint cu_log_type_severity_levels_user unique (name_machine),
+
+ constraint cc_log_type_severity_levels_id check (id >= 0)
+);
+
+create sequence s_tables.se_log_type_severity_levels_id owned by s_tables.t_log_type_severity_levels.id;
+alter table s_tables.t_log_type_severity_levels alter column id set default nextval('s_tables.se_log_type_severity_levels_id'::regclass);
+
+grant select,insert,update on s_tables.t_log_type_severity_levels to r_standard_administer;
+grant select on s_tables.t_log_type_severity_levels to r_standard_manager, r_standard_auditor;
+grant select,usage on s_tables.se_log_type_severity_levels_id to r_standard_administer;
+
+create view s_users.v_log_type_severity_levels with (security_barrier=true) as
+ select id, name_machine, name_human from s_tables.t_log_type_severity_levels
+ where not is_deleted;
+
+grant select on s_users.v_log_type_severity_levels to r_standard, r_standard_public, r_standard_system;
+
+
+create trigger tr_log_type_severity_levels_date_changed_deleted_or_locked
+ before update on s_tables.t_log_type_severity_levels
+ for each row execute procedure s_administers.f_common_update_date_changed_deleted_or_locked();
+
+
+
+commit transaction;
--- /dev/null
+/** Standardized SQL Structure - Logs */
+/** This depends on: reservation-users.sql, reservation-types.sql **/
+start transaction;
+
+
+
+/** Custom database specific settings (do this on every connection made) **/
+set bytea_output to hex;
+set search_path to s_administers,s_managers,s_auditors,s_publishers,s_insurers,s_financers,s_reviewers,s_editors,s_drafters,s_requesters,s_users,public;
+set datestyle to us;
+
+
+
+/*** provide user activity logging ***/
+create table s_tables.t_log_users (
+ id bigint not null,
+ id_user bigint not null,
+ id_user_session bigint not null,
+
+ log_title varchar(512) not null,
+ log_type bigint not null,
+ log_severity bigint not null,
+ log_details json,
+ log_date timestamp default localtimestamp not null,
+
+ request_client public.ct_client not null,
+ response_code smallint not null default 0,
+
+ constraint cp_log_users primary key (id),
+
+ constraint cc_log_users_id check (id > 0),
+ constraint cc_log_users_log_severity check (log_severity > 0),
+
+ constraint cf_log_users_id_user foreign key (id_user) references s_tables.t_users (id) on delete restrict on update cascade,
+ constraint cf_log_users_id_user_session foreign key (id_user_session) references s_tables.t_users (id) on delete restrict on update cascade,
+ constraint cf_log_users_log_type foreign key (log_type) references s_tables.t_log_types (id) on delete restrict on update cascade,
+ constraint cf_log_users_log_severity foreign key (log_severity) references s_tables.t_log_type_severity_levels (id) on delete restrict on update cascade,
+ constraint cf_log_users_response_code foreign key (response_code) references s_tables.t_type_http_status_codes (id) on delete restrict on update cascade
+);
+
+create sequence s_tables.se_log_users_id owned by s_tables.t_log_users.id;
+alter table s_tables.t_log_users alter column id set default nextval('s_tables.se_log_users_id'::regclass);
+
+grant select on s_tables.t_log_users to r_standard_manager, r_standard_auditor;
+grant select,usage on s_tables.se_log_users_id to r_standard_administer;
+grant usage on s_tables.se_log_users_id to r_standard, r_standard_public, r_standard_system;
+
+create index i_log_users_type_php on s_tables.t_log_users (id)
+ where log_type = 1;
+
+create index i_log_users_type_theme on s_tables.t_log_users (id)
+ where log_type = 2;
+
+create index i_log_users_type_cache on s_tables.t_log_users (id)
+ where log_type = 3;
+
+create index i_log_users_type_javascript on s_tables.t_log_users (id)
+ where log_type = 4;
+
+create index i_log_users_type_ajax on s_tables.t_log_users (id)
+ where log_type = 5;
+
+create index i_log_users_type_sql on s_tables.t_log_users (id)
+ where log_type = 6;
+
+create index i_log_users_type_redirect on s_tables.t_log_users (id)
+ where log_type = 16;
+
+create index i_log_users_type_login on s_tables.t_log_users (id)
+ where log_type = 17;
+
+create index i_log_users_type_logout on s_tables.t_log_users (id)
+ where log_type = 18;
+
+create index i_log_users_type_user on s_tables.t_log_users (id)
+ where log_type = 27;
+
+create index i_log_users_type_error on s_tables.t_log_users (id)
+ where log_type = 28;
+
+create index i_log_users_type_content on s_tables.t_log_users (id)
+ where log_type = 29;
+
+create index i_log_users_type_workflow on s_tables.t_log_users (id)
+ where log_type = 30;
+
+create index i_log_users_type_search on s_tables.t_log_users (id)
+ where log_type = 39;
+
+create index i_log_users_response_code_200 on s_tables.t_log_users (id)
+ where response_code = 200;
+
+create index i_log_users_response_code_403 on s_tables.t_log_users (id)
+ where response_code = 403;
+
+create index i_log_users_response_code_404 on s_tables.t_log_users (id)
+ where response_code = 404;
+
+create index i_log_users_response_code_410 on s_tables.t_log_users (id)
+ where response_code = 410;
+
+create index i_log_users_response_code_500 on s_tables.t_log_users (id)
+ where response_code = 500;
+
+create index i_log_users_response_code_503 on s_tables.t_log_users (id)
+ where response_code = 503;
+
+create index i_log_users_response_code_normal on s_tables.t_log_users (id)
+ where response_code in (200, 201, 202, 304);
+
+create index i_log_users_response_code_redirects on s_tables.t_log_users (id)
+ where response_code in (301, 302, 303, 307, 308);
+
+create index i_log_users_response_code_notable on s_tables.t_log_users (id)
+ where response_code in (400, 403, 404, 410, 500, 503);
+
+
+/** only allow select and insert for users when user id is current user **/
+create view s_users.v_log_users_self with (security_barrier=true) as
+ with this_user as (select id from public.v_users_self_locked_not)
+ select id, id_user, log_title, log_type, log_severity, log_details, log_date, request_client, response_code from s_tables.t_log_users
+ where id_user in (select * from this_user);
+
+grant select on s_users.v_log_users_self to r_standard, r_standard_system;
+
+create view s_users.v_log_users_self_insert with (security_barrier=true) as
+ select log_title, log_type, log_severity, log_details, request_client, response_code from s_tables.t_log_users
+ where id_user in (select id from public.v_users_self_locked_not)
+ with check option;
+
+grant insert on s_users.v_log_users_self_insert to r_standard, r_standard_system;
+
+
+/** public users should be able to insert, but should never be able to view the logs that they insert. **/
+create view public.v_log_users_self_insert with (security_barrier=true) as
+ select log_title, log_type, log_severity, log_details, request_client, response_code from s_tables.t_log_users
+ where 'r_standard_public' in (select pr.rolname from pg_auth_members pam inner join pg_roles pr on (pam.roleid = pr.oid) inner join pg_roles pr_u on (pam.member = pr_u.oid) where pr_u.rolname = current_user and pr.rolname = 'r_standard_public')
+ with check option;
+
+grant insert on public.v_log_users_self_insert to r_standard_public;
+
+
+create trigger tr_log_users_enforce_user_and_session_ids
+ before insert on s_tables.t_log_users
+ for each row execute procedure s_administers.f_common_enforce_user_and_session_ids();
+
+
+
+/*** provide access activity logging ***/
+create table s_tables.t_log_user_activity (
+ id bigint not null,
+ id_user bigint not null,
+ id_user_session bigint not null,
+
+ request_path varchar(512) not null,
+ request_arguments varchar(512) not null,
+ request_date timestamp default localtimestamp not null,
+ request_client public.ct_client not null,
+ request_headers json,
+
+ response_headers json,
+ response_code smallint not null default 0,
+
+ constraint cp_log_user_activity primary key (id),
+
+ constraint cc_log_user_activity_id check (id > 0),
+
+ constraint cf_log_user_activity_id_user foreign key (id_user) references s_tables.t_users (id) on delete restrict on update cascade,
+ constraint cf_log_user_activity_id_user_session foreign key (id_user_session) references s_tables.t_users (id) on delete restrict on update cascade,
+ constraint cf_log_user_activity_response_code foreign key (response_code) references s_tables.t_type_http_status_codes (id) on delete restrict on update cascade
+);
+
+create sequence s_tables.se_log_user_activity_id owned by s_tables.t_log_user_activity.id;
+alter table s_tables.t_log_user_activity alter column id set default nextval('s_tables.se_log_user_activity_id'::regclass);
+
+grant select on s_tables.t_log_user_activity to r_standard_manager, r_standard_auditor;
+grant select,usage on s_tables.se_log_user_activity_id to r_standard_administer;
+grant usage on s_tables.se_log_user_activity_id to r_standard, r_standard_public, r_standard_system;
+
+create index i_log_user_activity_response_code_4xx on s_tables.t_log_user_activity (id)
+ where response_code >= 400 and response_code < 500;
+
+create index i_log_user_activity_response_code_403 on s_tables.t_log_user_activity (id)
+ where response_code = 403;
+
+create index i_log_user_activity_response_code_404 on s_tables.t_log_user_activity (id)
+ where response_code = 404;
+
+create index i_log_user_activity_response_code_410 on s_tables.t_log_user_activity (id)
+ where response_code = 410;
+
+create index i_log_user_activity_response_code_5xx on s_tables.t_log_user_activity (id)
+ where response_code >= 500 and response_code < 600;
+
+create index i_log_user_activity_response_code_500 on s_tables.t_log_user_activity (id)
+ where response_code = 500;
+
+create index i_log_user_activity_response_code_503 on s_tables.t_log_user_activity (id)
+ where response_code = 503;
+
+create index i_log_user_activity_response_code_notable on s_tables.t_log_user_activity (id)
+ where response_code in (403, 404, 410, 500, 503);
+
+
+
+/** only allow select and insert for users when user id is current user **/
+create view s_users.v_log_user_activity_self with (security_barrier=true) as
+ with this_user as (select id from public.v_users_self_locked_not)
+ select id, id_user, request_path, request_arguments, request_date, request_client, request_headers, response_headers, response_code from s_tables.t_log_user_activity
+ where id_user in (select * from this_user);
+
+grant select on s_users.v_log_user_activity_self to r_standard, r_standard_system;
+
+create view s_users.v_log_user_activity_self_insert with (security_barrier=true) as
+ select request_path, request_arguments, request_client, request_headers, response_headers, response_code from s_tables.t_log_user_activity
+ where id_user in (select id from public.v_users_self_locked_not)
+ with check option;
+
+grant insert on s_users.v_log_user_activity_self_insert to r_standard, r_standard_system;
+
+
+/** public users should be able to insert, but should never be able to view the logs that they insert. **/
+create view public.v_log_user_activity_self_insert with (security_barrier=true) as
+ select request_path, request_arguments, request_client, request_headers, response_headers, response_code from s_tables.t_log_user_activity
+ where id_user in (select id from public.v_users_self_locked_not)
+ with check option;
+
+grant insert on public.v_log_user_activity_self_insert to r_standard_public;
+
+
+create trigger tr_log_user_activity_enforce_user_and_session_ids
+ before insert on s_tables.t_log_user_activity
+ for each row execute procedure s_administers.f_common_enforce_user_and_session_ids();
+
+
+
+commit transaction;
--- /dev/null
+/** Standardized SQL Structure - Main */
+/** This depends on: reservation-first.sql **/
+/* @todo: add restrictions to even managers and administers so that ALL users access via views to allow for disabling any account (even an admin).
+ only the postgresql/root account may access tables directly.
+ This requires changing permissions and adding the appropriate s_administers and s_managers tables.
+*/
+start transaction;
+
+
+
+/** Custom database specific settings (do this on every connection made) **/
+set bytea_output to hex;
+set search_path to s_administers,s_managers,s_auditors,s_publishers,s_insurers,s_financers,s_reviewers,s_editors,s_drafters,s_requesters,s_users,public;
+set datestyle to us;
+
+
+
+/** Schemas **/
+create schema s_administers authorization postgres;
+create schema s_managers authorization postgres;
+create schema s_auditors authorization postgres;
+create schema s_publishers authorization postgres;
+create schema s_insurers authorization postgres;
+create schema s_financers authorization postgres;
+create schema s_reviewers authorization postgres;
+create schema s_editors authorization postgres;
+create schema s_drafters authorization postgres;
+create schema s_requesters authorization postgres;
+create schema s_users authorization postgres;
+create schema s_tables authorization postgres;
+
+grant usage on schema s_administers to r_standard_administer;
+grant usage on schema s_managers to r_standard_manager;
+grant usage on schema s_auditors to r_standard_auditor;
+grant usage on schema s_publishers to r_standard_publisher;
+grant usage on schema s_insurers to r_standard_insurer;
+grant usage on schema s_financers to r_standard_financer;
+grant usage on schema s_reviewers to r_standard_reviewer;
+grant usage on schema s_editors to r_standard_editor;
+grant usage on schema s_drafters to r_standard_drafter;
+grant usage on schema s_requesters to r_standard_requester;
+grant usage on schema s_users to r_standard;
+
+grant usage on schema s_tables to u_standard_revision_requests, u_standard_statistics_update, u_standard_logger, u_standard_groups_handler;
+
+
+/** Composite Types **/
+create type public.ct_name_person as (
+ prefix varchar(32),
+ first varchar(64),
+ middle varchar(64),
+ last varchar(64),
+ suffix varchar(32),
+ complete varchar(256)
+);
+
+create type public.ct_client as (
+ ip inet,
+ port int,
+ agent varchar(256)
+);
+
+create type public.ct_email as (
+ name varchar(128),
+ domain varchar(128),
+ private boolean
+);
+
+create type public.ct_text as (
+ content text,
+ context bigint
+);
+
+create type public.ct_location as (
+ building bigint,
+ room bigint[]
+);
+
+create type public.ct_date as (
+ date timestamp,
+ time_start timestamp,
+ time_stop timestamp
+);
+
+create type public.ct_date_context as (
+ date timestamp,
+ time_start timestamp,
+ time_stop timestamp,
+ context bigint
+);
+
+create type public.ct_phone_number as (
+ country smallint,
+ area smallint,
+ number smallint,
+ extension smallint
+);
+
+create type public.ct_phone_number_context as (
+ country smallint,
+ area smallint,
+ number smallint,
+ extension smallint,
+ context bigint
+);
+
+create type public.ct_money_context as (
+ money money,
+ context bigint
+);
+
+create type public.ct_field_fees as (
+ needed bool,
+ quantity bigint,
+ days bigint,
+ hours bigint,
+ amount money
+);
+
+create type public.ct_field_used_with_contact as (
+ used bool,
+ email text,
+ name text,
+ phone public.ct_phone_number
+);
+
+create type public.ct_field_needed_with_total as (
+ needed bool,
+ total bigint
+);
+
+create type public.ct_field_needed_with_details as (
+ needed bool,
+ details text
+);
+
+create type public.ct_field_used_with_details as (
+ used bool,
+ details text
+);
+
+create type public.ct_field_used_with_designer as (
+ used bool,
+ designer text
+);
+
+create type public.ct_field_served_with_caterer as (
+ served bool,
+ caterer text
+);
+
+create type public.ct_field_generated_with_types as (
+ generated bool,
+ types bigint[]
+);
+
+create type public.ct_field_needed_with_types as (
+ needed bool,
+ types bigint[]
+);
+
+create type public.ct_field_needed_with_types_and_microphone as (
+ needed bool,
+ types bigint[],
+ microphone bigint
+);
+
+create type public.ct_field_insurance as (
+ needed bool,
+ provided bool
+);
+
+
+
+/** Common Functions **/
+/* User ID and Session User ID Functions */
+create function s_administers.f_common_enforce_user_and_session_ids() returns trigger as $$
+ begin
+ new.id_user = (select id from v_users_self);
+ new.id_user_session = (select id from v_users_self_session);
+ return new;
+ end;
+$$ language plpgsql;
+
+create function s_administers.f_common_enforce_creator_and_session_ids() returns trigger as $$
+ begin
+ new.id_creator = (select id from v_users_self);
+ new.id_creator_session = (select id from v_users_self_session);
+ return new;
+ end;
+$$ language plpgsql;
+
+
+/* Date Change Functions */
+create function s_administers.f_common_update_date_deleted() returns trigger as $$
+ begin
+ if (old.is_deleted = false and new.is_deleted = true) then
+ new.date_deleted = localtimestamp;
+ elseif (old.is_deleted = true and new.is_deleted = false) then
+ new.date_deleted = localtimestamp;
+ end if;
+
+ return new;
+ end;
+$$ language plpgsql;
+
+create function s_administers.f_common_update_date_changed_or_deleted() returns trigger as $$
+ begin
+ new.date_changed = localtimestamp;
+
+ if (old.is_deleted = false and new.is_deleted = true) then
+ new.date_deleted = localtimestamp;
+ elseif (old.is_deleted = true and new.is_deleted = false) then
+ new.date_deleted = localtimestamp;
+ end if;
+
+ return new;
+ end;
+$$ language plpgsql;
+
+create function s_administers.f_common_update_date_changed_or_locked() returns trigger as $$
+ begin
+ new.date_changed = localtimestamp;
+
+ if (old.is_locked = false and new.is_locked = true) then
+ new.date_locked = localtimestamp;
+ elseif (old.is_locked = true and new.is_locked = false) then
+ new.date_locked = localtimestamp;
+ end if;
+
+ return new;
+ end;
+$$ language plpgsql;
+
+create function s_administers.f_common_update_date_changed_deleted_or_locked() returns trigger as $$
+ begin
+ new.date_changed = localtimestamp;
+
+ if (old.is_deleted = false and new.is_deleted = true) then
+ new.date_deleted = localtimestamp;
+ elseif (old.is_deleted = true and new.is_deleted = false) then
+ new.date_deleted = localtimestamp;
+ end if;
+
+ if (old.is_locked = false and new.is_locked = true) then
+ new.date_locked = localtimestamp;
+ elseif (old.is_locked = true and new.is_locked = false) then
+ new.date_locked = localtimestamp;
+ end if;
+
+ return new;
+ end;
+$$ language plpgsql;
+
+create function s_administers.f_common_update_date_changed_deleted_cancelled_or_locked() returns trigger as $$
+ begin
+ new.date_changed = localtimestamp;
+
+ if (old.is_deleted = false and new.is_deleted = true) then
+ new.date_deleted = localtimestamp;
+ elseif (old.is_deleted = true and new.is_deleted = false) then
+ new.date_deleted = localtimestamp;
+ end if;
+
+ if (old.is_locked = false and new.is_locked = true) then
+ new.date_locked = localtimestamp;
+ elseif (old.is_locked = true and new.is_locked = false) then
+ new.date_locked = localtimestamp;
+ end if;
+
+ if (old.is_cancelled = false and new.is_cancelled = true) then
+ new.date_cancelled = localtimestamp;
+ elseif (old.is_cancelled = true and new.is_cancelled = false) then
+ new.date_cancelled = localtimestamp;
+ end if;
+
+ return new;
+ end;
+$$ language plpgsql;
+
+
+/* Revision Increment Functions */
+create function s_administers.f_common_increment_revision() returns trigger as $$
+ begin
+ new.id_revision = old.id_revision + 1;
+ return new;
+ end;
+$$ language plpgsql;
+
+create function s_administers.f_common_increment_revision_update_date_changed_or_deleted() returns trigger as $$
+ begin
+ new.date_changed = localtimestamp;
+
+ if (old.is_deleted = false and new.is_deleted = true) then
+ new.date_deleted = localtimestamp;
+ elseif (old.is_deleted = true and new.is_deleted = false) then
+ new.date_deleted = localtimestamp;
+ end if;
+
+ new.id_revision = old.id_revision + 1;
+
+ return new;
+ end;
+$$ language plpgsql;
+
+create function s_administers.f_common_increment_revision_update_date_changed_deleted_or_locked() returns trigger as $$
+ begin
+ new.date_changed = localtimestamp;
+
+ if (old.is_deleted = false and new.is_deleted = true) then
+ new.date_deleted = localtimestamp;
+ elseif (old.is_deleted = true and new.is_deleted = false) then
+ new.date_deleted = localtimestamp;
+ end if;
+
+ if (old.is_locked = false and new.is_locked = true) then
+ new.date_locked = localtimestamp;
+ elseif (old.is_locked = true and new.is_locked = false) then
+ new.date_locked = localtimestamp;
+ end if;
+
+ new.id_revision = old.id_revision + 1;
+
+ return new;
+ end;
+$$ language plpgsql;
+
+commit transaction;
--- /dev/null
+/** Standardized SQL Structure - Content **/
+/** This depends on: reservation-groups.sql, reservation-types.sql **/
+start transaction;
+
+
+
+/** Custom database specific settings (do this on every connection made) **/
+set bytea_output to hex;
+set search_path to s_administers,s_managers,s_auditors,s_publishers,s_insurers,s_financers,s_reviewers,s_editors,s_drafters,s_requesters,s_users,public;
+set datestyle to us;
+
+
+
+/* @todo: come up with a design for dynamic path management via users/managers (as opposed to hardcoded paths in source). */
+/*** provide paths table (@todo: this is added as a stub and needs to be finished) ***/
+create table s_tables.t_paths (
+ id bigint not null,
+ id_creator bigint not null,
+ id_creator_session bigint not null,
+ id_group bigint,
+ id_sort smallint default 0,
+
+ name_machine varchar(128) not null,
+ name_human varchar(256) not null,
+
+ is_content boolean default true not null,
+ is_alias boolean default false not null,
+ is_redirect boolean default false not null,
+ is_coded boolean default false not null,
+ is_dynamic boolean default true not null,
+ is_user boolean default false not null,
+ is_private boolean default true not null,
+ is_locked boolean default false not null,
+ is_deleted boolean default false not null,
+
+ field_path varchar(256) not null,
+ field_destination varchar(256),
+ field_response_code smallint,
+
+ date_created timestamp default localtimestamp not null,
+ date_changed timestamp default localtimestamp not null,
+ date_locked timestamp,
+ date_deleted timestamp,
+
+ constraint cp_paths primary key (id),
+
+ constraint cu_paths_name_machine unique (name_machine),
+ constraint cu_paths_field_path unique (field_path),
+
+ constraint cc_paths_id check (id > 0),
+ constraint cc_paths_name_machine check (name_machine ~ '[A-Za-z]\w*'),
+ constraint cc_paths_one_of_content_alias_redirect check ((is_content and not (is_alias or is_redirect)) or (is_alias and not (is_content or is_redirect))),
+
+ constraint cf_paths_id_creator foreign key (id_creator) references s_tables.t_users (id) on delete cascade on update cascade,
+ constraint cf_paths_id_creator_session foreign key (id_creator_session) references s_tables.t_users (id) on delete cascade on update cascade,
+ constraint cf_paths_id_group foreign key (id_group) references s_tables.t_groups (id) on delete restrict on update cascade,
+ constraint cf_paths_field_response_code foreign key (field_response_code) references s_tables.t_type_http_status_codes (id) on delete restrict on update cascade
+);
+
+create sequence s_tables.se_paths_id owned by s_tables.t_paths.id;
+alter table s_tables.t_paths alter column id set default nextval('s_tables.se_paths_id'::regclass);
+
+grant select,insert,update on s_tables.t_paths to r_standard_administer;
+grant select on s_tables.t_paths to r_standard_manager, r_standard_auditor;
+grant select,usage on s_tables.se_paths_id to r_standard_administer;
+grant usage on s_tables.se_paths_id to r_standard, r_standard_system;
+
+create index i_paths_deleted_not on s_tables.t_paths (id)
+ where not is_deleted;
+
+create index i_paths_private_not on s_tables.t_paths (id)
+ where not is_deleted and not is_private;
+
+create index i_paths_locked_not on s_tables.t_paths (id)
+ where not is_deleted and not is_locked;
+
+create index i_paths_public on s_tables.t_paths (id)
+ where not is_deleted and not is_locked and not is_private;
+
+create index i_paths_content on s_tables.t_paths (id)
+ where not is_deleted and is_content;
+
+create index i_paths_alias on s_tables.t_paths (id)
+ where not is_deleted and is_alias;
+
+create index i_paths_redirect on s_tables.t_paths (id)
+ where not is_deleted and is_redirect;
+
+/* Note: id sort here is intended for paths that do not have group paths, like '/a/hello', and '/b/world', where 'a' and 'b' are group paths, respectively. */
+/* however, NULL (id_sort = 0) is effectively for all group paths. */
+create index i_paths_id_sort_null on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 0;
+create index i_paths_id_sort_0 on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 48;
+create index i_paths_id_sort_1 on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 49;
+create index i_paths_id_sort_2 on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 50;
+create index i_paths_id_sort_3 on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 51;
+create index i_paths_id_sort_4 on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 52;
+create index i_paths_id_sort_5 on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 53;
+create index i_paths_id_sort_6 on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 54;
+create index i_paths_id_sort_7 on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 55;
+create index i_paths_id_sort_8 on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 56;
+create index i_paths_id_sort_9 on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 57;
+create index i_paths_id_sort_a on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 97;
+create index i_paths_id_sort_b on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 98;
+create index i_paths_id_sort_c on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 99;
+create index i_paths_id_sort_d on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 100;
+create index i_paths_id_sort_e on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 101;
+create index i_paths_id_sort_f on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 102;
+create index i_paths_id_sort_g on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 103;
+create index i_paths_id_sort_h on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 104;
+create index i_paths_id_sort_i on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 105;
+create index i_paths_id_sort_j on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 106;
+create index i_paths_id_sort_k on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 107;
+create index i_paths_id_sort_l on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 108;
+create index i_paths_id_sort_m on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 109;
+create index i_paths_id_sort_n on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 110;
+create index i_paths_id_sort_o on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 111;
+create index i_paths_id_sort_p on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 112;
+create index i_paths_id_sort_q on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 113;
+create index i_paths_id_sort_r on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 114;
+create index i_paths_id_sort_s on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 115;
+create index i_paths_id_sort_t on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 116;
+create index i_paths_id_sort_u on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 117;
+create index i_paths_id_sort_v on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 118;
+create index i_paths_id_sort_w on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 119;
+create index i_paths_id_sort_x on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 120;
+create index i_paths_id_sort_y on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 121;
+create index i_paths_id_sort_z on s_tables.t_paths (id_sort) with (fillfactor = 100) where id_sort = 122;
+
+
+/* @todo: provide management functionality for managers (for all user content) and users (for groups they belong to with appropriate can_manage role). */
+create view s_users.v_paths with (security_barrier=true) as
+ with allowed_groups as (select id from s_users.v_groups_self)
+ select id, id_group, name_machine, name_human, is_content, is_alias, is_redirect, is_coded, is_dynamic, is_locked, is_private, field_path, field_destination, field_response_code, date_created, date_changed, date_locked from s_tables.t_paths
+ where not is_deleted and (not is_locked or not is_private or id_group in (select * from allowed_groups));
+
+grant select on s_users.v_paths to r_standard, r_standard_system;
+
+create view public.v_paths with (security_barrier=true) as
+ select id, NULL::bigint as id_group, name_machine, name_human, is_content, is_alias, is_redirect, is_coded, is_dynamic, FALSE as is_locked, FALSE as is_private, field_path, field_destination, field_response_code, NULL::bool as date_created, NULL::bool as date_changed, NULL::bool as date_locked from s_tables.t_paths
+ where not is_deleted and not is_locked and not is_private;
+
+grant select on public.v_paths to r_standard_public;
+
+
+create trigger tr_paths_date_changed_deleted_or_locked
+ before update on s_tables.t_paths
+ for each row execute procedure s_administers.f_common_update_date_changed_deleted_or_locked();
+
+create trigger tr_paths_enforce_creator_and_session_ids
+ before insert on s_tables.t_paths
+ for each row execute procedure s_administers.f_common_enforce_creator_and_session_ids();
+
+
+
+commit transaction;
--- /dev/null
+/** Standardized SQL Structure - Statistics **/
+/** This depends on: reservation-log_users.sql **/
+start transaction;
+
+
+
+/** Custom database specific settings (do this on every connection made) **/
+set bytea_output to hex;
+set search_path to s_administers,s_managers,s_auditors,s_publishers,s_insurers,s_financers,s_reviewers,s_editors,s_drafters,s_requesters,s_users,public;
+set datestyle to us;
+
+
+
+/** Provide status code statistics **/
+create table s_tables.t_statistics_http_status_codes (
+ code smallint not null,
+ count bigint not null default 0,
+
+ is_deleted boolean default false not null,
+
+ date_created timestamp default localtimestamp not null,
+ date_changed timestamp default localtimestamp not null,
+ date_deleted timestamp,
+
+ constraint cp_statistics_http_status_codes primary key (code),
+
+ constraint cc_statistics_http_status_codes_count check (count >= 0),
+
+ constraint cf_statistics_http_status_codes_code foreign key (code) references s_tables.t_type_http_status_codes (id) on delete restrict on update cascade
+);
+
+grant select,insert,update on s_tables.t_statistics_http_status_codes to r_standard_manager, u_standard_statistics_update;
+grant select on s_tables.t_statistics_http_status_codes to r_standard_auditor;
+
+
+/** create an auto-update trigger. set the role to r_standard_manager so that the function runs as that role when using "SECURITY DEFINER". The r_standard_manager must also have the appropriate create privileges. **/
+create function s_tables.f_statistics_http_status_codes_insert() returns trigger security definer as $$
+ begin
+ if (tg_op = 'INSERT') then
+ update s_tables.t_statistics_http_status_codes set count = (select count + 1 as count from s_tables.t_statistics_http_status_codes where code = new.response_code) where code = new.response_code;
+ if not found then
+ insert into s_tables.t_statistics_http_status_codes (code, count) values (new.response_code, 1);
+ if not found then return null; end if;
+ end if;
+
+ return new;
+ end if;
+
+ return null;
+ end;
+$$ language plpgsql;
+
+alter function s_tables.f_statistics_http_status_codes_insert () owner to u_standard_statistics_update;
+
+create trigger tr_log_user_activity_insert_statistics_http_status_codes
+ after insert on s_tables.t_log_user_activity
+ for each row execute procedure s_tables.f_statistics_http_status_codes_insert();
+
+create trigger tr_log_users_insert_statistics_http_status_codes
+ after insert on s_tables.t_log_users
+ for each row execute procedure s_tables.f_statistics_http_status_codes_insert();
+
+create trigger tr_statistics_http_status_codes_date_deleted
+ before update on s_tables.t_statistics_http_status_codes
+ for each row execute procedure s_administers.f_common_update_date_deleted();
+
+
+
+/** Provide request path statistics **/
+create table s_tables.t_statistics_request_path (
+ path varchar(512) not null,
+ count bigint not null default 0,
+
+ is_deleted boolean default false not null,
+
+ date_created timestamp default localtimestamp not null,
+ date_changed timestamp default localtimestamp not null,
+ date_deleted timestamp,
+
+ constraint cp_statistics_request_path primary key (path),
+
+ constraint cc_statistics_request_path_count check (count >= 0)
+);
+
+grant select on s_tables.t_statistics_request_path to r_standard_manager, r_standard_auditor;
+
+
+/** permissions prevent this from working as desired, so for now open up these stats to the following users (via a view) **/
+/* @todo: review this and try to restrict what accounts can access and set request_path in the same way s_tables.f_statistics_http_status_codes_insert() is handled. */
+create view s_users.v_statistics_request_path with (security_barrier=true) as
+ select path, count from s_tables.t_statistics_request_path
+ with check option;
+
+grant select,insert,update on s_users.v_statistics_request_path to r_standard, r_standard_system;
+
+
+create view public.v_statistics_request_path with (security_barrier=true) as
+ select path, count from s_tables.t_statistics_request_path
+ with check option;
+
+grant select,insert,update on public.v_statistics_request_path to r_standard_public;
+
+
+/** create an auto-update trigger **/
+create function s_tables.f_statistics_request_path_insert() returns trigger as $$
+ begin
+ if (tg_op = 'INSERT') then
+ update v_statistics_request_path set count = (select count + 1 as count from v_statistics_request_path where path = new.request_path) where path = new.request_path;
+ if not found then
+ insert into v_statistics_request_path (path, count) values (new.request_path, 1);
+ if not found then return null; end if;
+ end if;
+
+ return new;
+ end if;
+
+ return null;
+ end;
+$$ language plpgsql;
+
+create trigger tr_statistics_request_path_insert
+ after insert on s_tables.t_statistics_request_path
+ for each row execute procedure s_tables.f_statistics_request_path_insert();
+
+create trigger tr_statistics_request_path_date_deleted
+ before update on s_tables.t_statistics_request_path
+ for each row execute procedure s_administers.f_common_update_date_deleted();
+
+
+
+commit transaction;
--- /dev/null
+/** Standardized SQL Structure - Logs - Types */
+/** This depends on: reservation-main.sql **/
+start transaction;
+
+
+
+/** Custom database specific settings (do this on every connection made) **/
+set bytea_output to hex;
+set search_path to s_administers,s_managers,s_auditors,s_publishers,s_insurers,s_financers,s_reviewers,s_editors,s_drafters,s_requesters,s_users,public;
+set datestyle to us;
+
+
+
+/*** provide HTTP status codes ***/
+create table s_tables.t_type_http_status_codes (
+ id smallint not null,
+
+ name_machine varchar(128) not null,
+ name_human varchar(256) not null,
+
+ is_locked boolean default false not null,
+ is_deleted boolean default false not null,
+
+ date_created timestamp default localtimestamp not null,
+ date_changed timestamp default localtimestamp not null,
+ date_locked timestamp,
+ date_deleted timestamp,
+
+ constraint cp_log_type_http_status_codes primary key (id),
+
+ constraint cu_log_type_http_status_codes_user unique (name_machine),
+
+ constraint cc_log_type_http_status_codes_id check (id >= 0 and id < 600)
+);
+
+create sequence s_tables.se_log_type_http_status_codes_id owned by s_tables.t_type_http_status_codes.id;
+alter table s_tables.t_type_http_status_codes alter column id set default nextval('s_tables.se_log_type_http_status_codes_id'::regclass);
+
+grant select,insert,update on s_tables.t_type_http_status_codes to r_standard_administer;
+grant select on s_tables.t_type_http_status_codes to r_standard_manager, r_standard_auditor;
+grant select,usage on s_tables.se_log_type_http_status_codes_id to r_standard_administer;
+
+create view public.v_log_type_http_status_codes with (security_barrier=true) as
+ select id, name_machine, name_human from s_tables.t_type_http_status_codes;
+
+grant select on public.v_log_type_http_status_codes to r_standard, r_standard_public, r_standard_system;
+
+
+create trigger tr_log_type_http_status_codes_date_changed_deleted_or_locked
+ before update on s_tables.t_type_http_status_codes
+ for each row execute procedure s_administers.f_common_update_date_changed_deleted_or_locked();
+
+
+
+/*** provide mime type category id and names ***/
+create table s_tables.t_type_mime_categorys (
+ id bigint not null,
+
+ name_machine varchar(128) not null,
+ name_human varchar(256) not null,
+
+ is_locked boolean default false not null,
+ is_deleted boolean default false not null,
+
+ date_created timestamp default localtimestamp not null,
+ date_changed timestamp default localtimestamp not null,
+ date_locked timestamp,
+ date_deleted timestamp,
+
+ field_category varchar(64),
+
+ constraint cp_types_mime_categorys primary key (id),
+
+ constraint cu_types_mime_categorys_name_machine unique (name_machine),
+
+ constraint cc_types_mime_categorys_id check (id > -1),
+ constraint cc_types_mime_categorys_name_machine check (name_machine ~ '[A-Za-z]\w*')
+);
+
+grant select,insert,update on s_tables.t_type_mime_categorys to r_standard_administer;
+
+create view public.v_types_mime_categorys with (security_barrier=true) as
+ select id, name_machine, name_human, is_locked from s_tables.t_type_mime_categorys
+ where not is_deleted;
+
+grant select on public.v_types_mime_categorys to r_standard, r_standard_public, r_standard_system;
+
+grant select,insert,update on s_tables.t_type_mime_categorys to r_standard_administer;
+
+
+create view public.v_types_mime_categorys_locked_not with (security_barrier=true) as
+ select id, name_machine, name_human, field_category from s_tables.t_type_mime_categorys
+ where not is_deleted and not is_locked;
+
+grant select on public.v_types_mime_categorys_locked_not to r_standard, r_standard_public, r_standard_system;
+
+
+create trigger tr_types_mime_categorys_date_changed_deleted_or_locked
+ before update on s_tables.t_type_mime_categorys
+ for each row execute procedure s_administers.f_common_update_date_changed_deleted_or_locked();
+
+
+
+/*** provide mime type ids and names ***/
+create table s_tables.t_type_mime_types (
+ id bigint not null,
+ id_category bigint not null,
+
+ name_machine varchar(128) not null,
+ name_human varchar(256) not null,
+
+ is_locked boolean default false not null,
+ is_deleted boolean default false not null,
+
+ date_created timestamp default localtimestamp not null,
+ date_changed timestamp default localtimestamp not null,
+ date_locked timestamp,
+ date_deleted timestamp,
+
+ field_extension varchar(64),
+ field_mime varchar(128),
+
+ constraint cc_types_mime_types_id check (id > -1),
+
+ constraint cu_types_mime_types_mime_type unique (id, id_category, field_extension, field_mime),
+
+ constraint cf_types_mime_types_id foreign key (id_category) references s_tables.t_type_mime_categorys (id) on delete restrict on update cascade
+);
+
+grant select,insert,update on s_tables.t_type_mime_types to r_standard_administer;
+
+create view public.v_types_mime_types with (security_barrier=true) as
+ select id, id_category, name_machine, name_human, field_extension, field_mime, is_locked from s_tables.t_type_mime_types
+ where not is_deleted;
+
+grant select on public.v_types_mime_types to r_standard, r_standard_public, r_standard_system;
+
+create view public.v_types_mime_types_locked_not with (security_barrier=true) as
+ select id, id_category, name_machine, name_human, field_extension, field_mime, is_locked from s_tables.t_type_mime_types
+ where not is_deleted and not is_locked;
+
+grant select on public.v_types_mime_types to r_standard, r_standard_public, r_standard_system;
+
+
+create trigger tr_types_mime_types_date_changed_deleted_or_locked
+ before update on s_tables.t_type_mime_types
+ for each row execute procedure s_administers.f_common_update_date_changed_deleted_or_locked();
+
+
+
+commit transaction;
--- /dev/null
+/** Standardized SQL Structure - Users */
+/** This depends on: reservation-main.sql **/
+start transaction;
+
+
+
+/** Custom database specific settings (do this on every connection made) **/
+set bytea_output to hex;
+set search_path to s_administers,s_managers,s_auditors,s_publishers,s_insurers,s_financers,s_reviewers,s_editors,s_drafters,s_requesters,s_users,public;
+set datestyle to us;
+
+
+
+/** Users **/
+/* Note: is_public and is_private have two different contexts, is_public refers to the r_standard_public role and is_private refers to making certain user fields public/private within the system to a certain degree. */
+create table s_tables.t_users (
+ id bigint not null,
+ id_external bigint,
+
+ id_sort smallint default 0,
+
+ name_machine varchar(128) not null,
+ name_human public.ct_name_person default (null, null, null, null, null, null) not null,
+
+ address_email public.ct_email default (null, null, true) not null,
+
+ is_administer boolean default false not null,
+ is_manager boolean default false not null,
+ is_auditor boolean default false not null,
+ is_publisher boolean default false not null,
+ is_insurer boolean default false not null,
+ is_financer boolean default false not null,
+ is_reviewer boolean default false not null,
+ is_editor boolean default false not null,
+ is_drafter boolean default false not null,
+ is_requester boolean default false not null,
+ is_system boolean default false not null,
+ is_public boolean default false not null,
+ is_locked boolean default false not null,
+ is_private boolean default true not null,
+ is_deleted boolean default false not null,
+
+ can_manage_roles boolean default false not null,
+
+ date_created timestamp default localtimestamp not null,
+ date_changed timestamp default localtimestamp not null,
+ date_synced timestamp default localtimestamp not null,
+ date_locked timestamp,
+ date_deleted timestamp,
+
+ settings json,
+
+ constraint cp_users primary key (id),
+
+ constraint cc_users_id check (id > 0),
+ constraint cc_users_id_external check (id_external >= -1),
+
+ constraint cu_users_id_external unique (id_external),
+ constraint cu_users_name_machine unique (name_machine)
+);
+
+create sequence s_tables.se_users_id owned by s_tables.t_users.id;
+alter table s_tables.t_users alter column id set default nextval('s_tables.se_users_id'::regclass);
+
+grant select,insert,update on s_tables.t_users to r_standard_administer;
+grant select on s_tables.t_users to r_standard_auditor;
+grant select,usage on s_tables.se_users_id to r_standard_administer;
+grant usage on s_tables.se_users_id to r_standard, r_standard_system;
+
+create index i_users_deleted_not on s_tables.t_users (id)
+ where not is_deleted;
+
+create index i_users_private_not on s_tables.t_users (id)
+ where not is_deleted and not is_private;
+
+create index i_users_locked_not on s_tables.t_users (id)
+ where not is_deleted and not is_locked;
+
+create index i_users_private_email_not on s_tables.t_users (id)
+ where not is_deleted and not is_private and not (address_email).private;
+
+
+/* Note: id_sort is not needed when directly validating against id or name_machine because both of those are already an index. */
+create index i_users_id_sort_a on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 97;
+create index i_users_id_sort_b on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 98;
+create index i_users_id_sort_c on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 99;
+create index i_users_id_sort_d on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 100;
+create index i_users_id_sort_e on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 101;
+create index i_users_id_sort_f on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 102;
+create index i_users_id_sort_g on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 103;
+create index i_users_id_sort_h on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 104;
+create index i_users_id_sort_i on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 105;
+create index i_users_id_sort_j on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 106;
+create index i_users_id_sort_k on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 107;
+create index i_users_id_sort_l on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 108;
+create index i_users_id_sort_m on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 109;
+create index i_users_id_sort_n on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 110;
+create index i_users_id_sort_o on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 111;
+create index i_users_id_sort_p on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 112;
+create index i_users_id_sort_q on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 113;
+create index i_users_id_sort_r on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 114;
+create index i_users_id_sort_s on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 115;
+create index i_users_id_sort_t on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 116;
+create index i_users_id_sort_u on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 117;
+create index i_users_id_sort_v on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 118;
+create index i_users_id_sort_w on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 119;
+create index i_users_id_sort_x on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 120;
+create index i_users_id_sort_y on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 121;
+create index i_users_id_sort_z on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 122;
+
+
+
+/*** provide current user access to their own information (system users are not allowed to update their account) ***/
+create view s_users.v_users_self with (security_barrier=true) as
+ select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, is_deleted, can_manage_roles, date_created, date_changed, date_synced, date_locked, null::timestamp as date_deleted, settings from s_tables.t_users
+ where not is_deleted and (name_machine)::text = (current_user)::text;
+
+grant select on s_users.v_users_self to r_standard, r_standard_system;
+
+create view public.v_users_self_session with (security_barrier=true) as
+ select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, is_deleted, can_manage_roles, date_created, date_changed, date_synced, date_locked, null::timestamp as date_deleted, settings from s_tables.t_users
+ where not is_deleted and (name_machine)::text = (session_user)::text;
+
+grant select on public.v_users_self_session to r_standard, r_standard_system, r_standard_public;
+
+create view public.v_users_self_locked_not with (security_barrier=true) as
+ select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, is_deleted, can_manage_roles, date_created, date_changed, date_synced, date_locked, null::timestamp as date_deleted, settings from s_tables.t_users
+ where not is_deleted and not is_locked and (name_machine)::text = (current_user)::text;
+
+grant select on public.v_users_self_locked_not to r_standard, r_standard_system, r_standard_public;
+
+create view s_users.v_users_self_insert with (security_barrier=true) as
+ select id_external, name_human, address_email, is_private, settings from s_tables.t_users
+ where not is_deleted and not is_locked and not is_system and not is_public and (name_machine)::text = (current_user)::text
+ with check option;
+
+grant insert on s_users.v_users_self_insert to r_standard, r_standard_system;
+
+create view s_users.v_users_self_update with (security_barrier=true) as
+ select address_email, is_private, settings from s_tables.t_users
+ where not is_deleted and not is_locked and not is_system and not is_public and (name_machine)::text = (current_user)::text
+ with check option;
+
+grant update on s_users.v_users_self_update to r_standard, r_standard_system;
+
+
+/**** anonymous user has uid = 1 ****/
+create view public.v_users_self with (security_barrier=true) as
+ select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, is_deleted, date_created, date_changed, date_synced, date_locked, null::timestamp as date_deleted, settings from s_tables.t_users
+ where not is_deleted and id = 1;
+
+grant select on public.v_users_self to r_standard_public, r_standard, r_standard_system;
+
+
+/*** provide public user information ***/
+create view public.v_users with (security_barrier=true) as
+ select id, null::bigint as id_external, id_sort, name_machine, name_human, null::public.ct_email as address_email, null::bool as is_administer, null::bool as is_manager, null::bool as is_auditor, null::bool as is_publisher, null::bool as is_insurer, null::bool as is_financer, null::bool as is_reviewer, null::bool as is_editor, null::bool as is_drafter, null::bool as is_requester, is_system, is_public, null::bool as is_locked, is_private, is_deleted, null::bool as can_manage_roles, null::timestamp as date_created, null::timestamp as date_changed, null::timestamp as date_synced, null::timestamp as date_locked, null::timestamp as date_deleted, null::json as settings from s_tables.t_users
+ where (not is_deleted and not is_private) or (not is_deleted and (name_machine)::text = (current_user)::text);
+
+grant select on public.v_users to r_standard, r_standard_public, r_standard_system;
+
+
+/*** provide e-mail address as public information only if it is explicitly allowed ***/
+create view public.v_users_email with (security_barrier=true) as
+ select id, null::bigint as id_external, id_sort, name_machine, name_human, address_email, null::bool as is_administer, null::bool as is_manager, null::bool as is_auditor, null::bool as is_publisher, null::bool as is_insurer, null::bool as is_financer, null::bool as is_reviewer, null::bool as is_editor, null::bool as is_drafter, null::bool as is_requester, is_system, is_public, null::bool as is_locked, is_private, is_deleted, null::bool as can_manage_roles, null::timestamp as date_created, null::timestamp as date_changed, null::timestamp as date_synced, null::timestamp as date_locked, null::timestamp as date_deleted, null::json as settings from s_tables.t_users
+ where (not is_deleted and not is_private and not (address_email).private) or (not is_deleted and (name_machine)::text = (current_user)::text);
+
+grant select on public.v_users_email to r_standard, r_standard_public, r_standard_system;
+
+
+/*** provide managers with the ability to modify accounts ***/
+create view s_managers.v_users with (security_barrier=true) as
+ select * from s_tables.t_users
+ where not is_deleted;
+
+grant select on s_managers.v_users to r_standard_manager;
+
+create view s_managers.v_users_insert with (security_barrier=true) as
+ select id, id_external, name_machine, name_human, address_email, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_locked, is_private, can_manage_roles, settings from s_tables.t_users
+ with check option;
+
+grant insert on s_managers.v_users_insert to r_standard_manager;
+
+create view s_managers.v_users_update with (security_barrier=true) as
+ select id, id_external, name_machine, name_human, address_email, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_locked, is_private, can_manage_roles, settings from s_tables.t_users
+ where not is_deleted
+ with check option;
+
+grant update on s_managers.v_users_update to r_standard_manager;
+
+create view s_managers.v_users_deleted with (security_barrier=true) as
+ select id, id_external, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_locked, is_private, can_manage_roles, date_created, date_changed, date_synced, date_locked, settings from s_tables.t_users
+ where is_deleted;
+
+grant select on s_managers.v_users to r_standard_manager;
+
+
+/** Create Materialized views for table based on history (maybe current day should be a view and previous days should be a materialized view that is updated by cron?) **/
+create materialized view s_administers.m_users_date_created_this_day as select * from s_tables.t_users where date_trunc('day', date_created) = date_trunc('day', current_timestamp);
+create materialized view s_administers.m_users_date_created_previous_day as select * from s_tables.t_users where date_trunc('day', date_created) = date_trunc('day', current_timestamp) - interval '1 day';
+create materialized view s_administers.m_users_date_created_previous_month as select * from s_tables.t_users where date_trunc('month', date_created) = date_trunc('month', current_timestamp) - interval '1 month';
+create materialized view s_administers.m_users_date_created_previous_year as select * from s_tables.t_users where date_trunc('year', date_created) = date_trunc('year', current_timestamp) - interval '1 year';
+
+create materialized view s_administers.m_users_date_changed_this_day as select * from s_tables.t_users where date_trunc('day', date_changed) = date_trunc('day', current_timestamp);
+create materialized view s_administers.m_users_date_changed_previous_day as select * from s_tables.t_users where date_trunc('day', date_changed) = date_trunc('day', current_timestamp) - interval '1 day';
+create materialized view s_administers.m_users_date_changed_previous_month as select * from s_tables.t_users where date_trunc('month', date_changed) = date_trunc('month', current_timestamp) - interval '1 month';
+create materialized view s_administers.m_users_date_changed_previous_year as select * from s_tables.t_users where date_trunc('year', date_changed) = date_trunc('year', current_timestamp) - interval '1 year';
+
+create materialized view s_administers.m_users_date_synced_this_day as select * from s_tables.t_users where date_trunc('day', date_synced) = date_trunc('day', current_timestamp);
+create materialized view s_administers.m_users_date_synced_previous_day as select * from s_tables.t_users where date_trunc('day', date_synced) = date_trunc('day', current_timestamp) - interval '1 day';
+create materialized view s_administers.m_users_date_synced_previous_month as select * from s_tables.t_users where date_trunc('month', date_synced) = date_trunc('month', current_timestamp) - interval '1 month';
+create materialized view s_administers.m_users_date_synced_previous_year as select * from s_tables.t_users where date_trunc('year', date_synced) = date_trunc('year', current_timestamp) - interval '1 year';
+
+alter materialized view s_administers.m_users_date_created_this_day owner to r_standard_administer;
+alter materialized view s_administers.m_users_date_created_previous_day owner to r_standard_administer;
+alter materialized view s_administers.m_users_date_created_previous_month owner to r_standard_administer;
+alter materialized view s_administers.m_users_date_created_previous_year owner to r_standard_administer;
+
+alter materialized view s_administers.m_users_date_changed_this_day owner to r_standard_administer;
+alter materialized view s_administers.m_users_date_changed_previous_day owner to r_standard_administer;
+alter materialized view s_administers.m_users_date_changed_previous_month owner to r_standard_administer;
+alter materialized view s_administers.m_users_date_changed_previous_year owner to r_standard_administer;
+
+alter materialized view s_administers.m_users_date_synced_this_day owner to r_standard_administer;
+alter materialized view s_administers.m_users_date_synced_previous_day owner to r_standard_administer;
+alter materialized view s_administers.m_users_date_synced_previous_month owner to r_standard_administer;
+alter materialized view s_administers.m_users_date_synced_previous_year owner to r_standard_administer;
+
+grant select on s_administers.m_users_date_created_this_day to r_standard_manager;
+grant select on s_administers.m_users_date_created_previous_day to r_standard_manager;
+grant select on s_administers.m_users_date_created_previous_month to r_standard_manager;
+grant select on s_administers.m_users_date_created_previous_year to r_standard_manager;
+
+grant select on s_administers.m_users_date_changed_this_day to r_standard_manager;
+grant select on s_administers.m_users_date_changed_previous_day to r_standard_manager;
+grant select on s_administers.m_users_date_changed_previous_month to r_standard_manager;
+grant select on s_administers.m_users_date_changed_previous_year to r_standard_manager;
+
+grant select on s_administers.m_users_date_synced_this_day to r_standard_manager;
+grant select on s_administers.m_users_date_synced_previous_day to r_standard_manager;
+grant select on s_administers.m_users_date_synced_previous_month to r_standard_manager;
+grant select on s_administers.m_users_date_synced_previous_year to r_standard_manager;
+
+grant select on s_administers.m_users_date_created_this_day to r_standard_manager;
+grant select on s_administers.m_users_date_created_previous_day to r_standard_manager;
+grant select on s_administers.m_users_date_created_previous_month to r_standard_manager;
+grant select on s_administers.m_users_date_created_previous_year to r_standard_manager;
+
+
+create function s_administers.f_users_insert_actions() returns trigger as $$
+ begin
+ if (new.name_machine is null) then
+ new.name_machine = current_user;
+ end if;
+
+ new.id_sort = ascii(new.name_machine);
+
+ return new;
+ end;
+$$ language plpgsql;
+
+create function s_administers.f_users_update_actions() returns trigger as $$
+ begin
+ new.date_changed = localtimestamp;
+
+ if (old.is_deleted = false and new.is_deleted = true) then
+ new.date_deleted = localtimestamp;
+ elseif (old.is_deleted = true and new.is_deleted = false) then
+ new.date_deleted = localtimestamp;
+ end if;
+
+ if (old.is_locked = false and new.is_locked = true) then
+ new.date_locked = localtimestamp;
+ elseif (old.is_locked = true and new.is_locked = false) then
+ new.date_locked = localtimestamp;
+ end if;
+
+ if (new.id_sort <> ascii(new.name_machine)) then
+ new.id_sort = ascii(new.name_machine);
+ end if;
+
+ return new;
+ end;
+$$ language plpgsql;
+
+
+/* attempt to auto-manage postgresql reservation roles with the reservation database user roles. */
+/* user ids 1 and 2 are explicitly reserved for anonymous/public and the database postgresql accounts. */
+/* postgresql does not seem to support variables for the user with grant and revoke, therefore the execute statement is used to perform the query. */
+/* @fixme: the name_machine must be forcibly sanitized to be alphanumeric, -, or _ in all cases. */
+create function s_administers.f_users_insert_as_administer() returns trigger security definer as $$
+ declare
+ name_machine constant text default quote_ident(new.name_machine);
+ begin
+ if (new.id = 1 or new.id = 2) then
+ return null;
+ end if;
+
+ set client_min_messages to error;
+
+ if (new.is_locked or new.is_deleted) then
+ if (new.is_deleted) then
+ execute 'revoke r_standard from ' || name_machine;
+ execute 'revoke r_standard_system from ' || name_machine;
+ execute 'revoke r_standard_public from ' || name_machine;
+ elseif (new.is_public) then
+ execute 'grant r_standard_public to ' || name_machine;
+ elseif (new.is_system) then
+ execute 'grant r_standard_system to ' || name_machine;
+ elseif (new.is_requester or new.is_drafter or new.is_editor or new.is_reviewer or new.is_financer or new.is_insurer or new.is_publisher or new.is_auditor or new.is_manager or new.is_administer) then
+ execute 'grant r_standard to ' || name_machine;
+ end if;
+
+ execute 'revoke r_standard_administer from ' || name_machine;
+ execute 'revoke r_standard_manager from ' || name_machine;
+ execute 'revoke r_standard_auditor from ' || name_machine;
+ execute 'revoke r_standard_publisher from ' || name_machine;
+ execute 'revoke r_standard_financer from ' || name_machine;
+ execute 'revoke r_standard_insurer from ' || name_machine;
+ execute 'revoke r_standard_reviewer from ' || name_machine;
+ execute 'revoke r_standard_editor from ' || name_machine;
+ execute 'revoke r_standard_drafter from ' || name_machine;
+ execute 'revoke r_standard_requester from ' || name_machine;
+ elseif (new.is_public) then
+ execute 'grant r_standard_public to ' || name_machine;
+ execute 'revoke r_standard from ' || name_machine;
+
+ if (new.is_system) then
+ execute 'grant r_standard_system to ' || name_machine;
+ else
+ execute 'revoke r_standard_system from ' || name_machine;
+ end if;
+
+ execute 'revoke r_standard_administer from ' || name_machine;
+ execute 'revoke r_standard_manager from ' || name_machine;
+ execute 'revoke r_standard_auditor from ' || name_machine;
+ execute 'revoke r_standard_publisher from ' || name_machine;
+ execute 'revoke r_standard_financer from ' || name_machine;
+ execute 'revoke r_standard_insurer from ' || name_machine;
+ execute 'revoke r_standard_reviewer from ' || name_machine;
+ execute 'revoke r_standard_editor from ' || name_machine;
+ execute 'revoke r_standard_drafter from ' || name_machine;
+ execute 'revoke r_standard_requester from ' || name_machine;
+ else
+ if (new.is_system) then
+ execute 'grant r_standard_system to ' || name_machine;
+
+ execute 'revoke r_standard from ' || name_machine;
+ execute 'revoke r_standard_public from ' || name_machine;
+ elseif (new.is_requester or new.is_drafter or new.is_editor or new.is_reviewer or new.is_financer or new.is_insurer or new.is_publisher or new.is_auditor or new.is_manager or new.is_administer) then
+ execute 'grant r_standard to ' || name_machine;
+
+ execute 'revoke r_standard_system from ' || name_machine;
+ execute 'revoke r_standard_public from ' || name_machine;
+ end if;
+
+ if (new.is_administer) then
+ execute 'grant r_standard_administer to ' || name_machine;
+ end if;
+
+ if (new.is_manager) then
+ execute 'grant r_standard_manager to ' || name_machine;
+ end if;
+
+ if (new.is_auditor) then
+ execute 'grant r_standard_auditor to ' || name_machine;
+ end if;
+
+ if (new.is_publisher) then
+ execute 'grant r_standard_publisher to ' || name_machine;
+ end if;
+
+ if (new.is_insurer) then
+ execute 'grant r_standard_insurer to ' || name_machine;
+ end if;
+
+ if (new.is_financer) then
+ execute 'grant r_standard_financer to ' || name_machine;
+ end if;
+
+ if (new.is_reviewer) then
+ execute 'grant r_standard_reviewer to ' || name_machine;
+ end if;
+
+ if (new.is_editor) then
+ execute 'grant r_standard_editor to ' || name_machine;
+ end if;
+
+ if (new.is_drafter) then
+ execute 'grant r_standard_drafter to ' || name_machine;
+ end if;
+
+ if (new.is_requester) then
+ execute 'grant r_standard_requester to ' || name_machine;
+ end if;
+ end if;
+
+ reset client_min_messages;
+
+ return null;
+ end;
+$$ language plpgsql;
+
+alter function s_administers.f_users_insert_as_administer() owner to u_standard_grant_roles;
+
+
+create function s_administers.f_users_update_as_administer() returns trigger security definer as $$
+ declare
+ name_machine constant text default quote_ident(new.name_machine);
+ begin
+ if (new.id = 1 or new.id = 2) then
+ return null;
+ end if;
+
+ set client_min_messages to error;
+
+ if (old.is_locked <> new.is_locked or old.is_deleted <> new.is_deleted) then
+ if (old.is_deleted <> new.is_deleted) then
+ if (new.is_deleted) then
+ execute 'revoke r_standard from ' || name_machine;
+ execute 'revoke r_standard_system from ' || name_machine;
+ execute 'revoke r_standard_public from ' || name_machine;
+ else
+ if (new.is_public) then
+ execute 'grant r_standard_public to ' || name_machine;
+ elseif (new.is_system) then
+ execute 'grant r_standard_system to ' || name_machine;
+ elseif (new.is_requester or new.is_drafter or new.is_editor or new.is_reviewer or new.is_financer or new.is_insurer or new.is_publisher or new.is_auditor or new.is_manager or new.is_administer) then
+ execute 'grant r_standard to ' || name_machine;
+ end if;
+ end if;
+ end if;
+
+ if (new.is_locked or new.is_deleted) then
+ execute 'revoke r_standard_administer from ' || name_machine;
+ execute 'revoke r_standard_manager from ' || name_machine;
+ execute 'revoke r_standard_auditor from ' || name_machine;
+ execute 'revoke r_standard_publisher from ' || name_machine;
+ execute 'revoke r_standard_financer from ' || name_machine;
+ execute 'revoke r_standard_insurer from ' || name_machine;
+ execute 'revoke r_standard_reviewer from ' || name_machine;
+ execute 'revoke r_standard_editor from ' || name_machine;
+ execute 'revoke r_standard_drafter from ' || name_machine;
+ execute 'revoke r_standard_requester from ' || name_machine;
+ execute 'revoke r_standard_system from ' || name_machine;
+ execute 'revoke r_standard_public from ' || name_machine;
+ elseif (new.is_public) then
+ execute 'grant r_standard_public to ' || name_machine;
+
+ if (new.is_system) then
+ execute 'grant r_standard_system to ' || name_machine;
+ end if;
+ else
+ if (new.is_administer) then
+ execute 'grant r_standard_administer to ' || name_machine;
+ end if;
+
+ if (new.is_manager) then
+ execute 'grant r_standard_manager to ' || name_machine;
+ end if;
+
+ if (new.is_auditor) then
+ execute 'grant r_standard_auditor to ' || name_machine;
+ end if;
+
+ if (new.is_publisher) then
+ execute 'grant r_standard_publisher to ' || name_machine;
+ end if;
+
+ if (new.is_financer) then
+ execute 'grant r_standard_financer to ' || name_machine;
+ end if;
+
+ if (new.is_insurer) then
+ execute 'grant r_standard_insurer to ' || name_machine;
+ end if;
+
+ if (new.is_reviewer) then
+ execute 'grant r_standard_reviewer to ' || name_machine;
+ end if;
+
+ if (new.is_editor) then
+ execute 'grant r_standard_editor to ' || name_machine;
+ end if;
+
+ if (new.is_drafter) then
+ execute 'grant r_standard_drafter to ' || name_machine;
+ end if;
+
+ if (new.is_requester) then
+ execute 'grant r_standard_requester to ' || name_machine;
+ end if;
+
+ if (new.is_system) then
+ execute 'grant r_standard_system to ' || name_machine;
+ end if;
+ end if;
+ elseif (old.is_public <> new.is_public and new.is_public) then
+ execute 'grant r_standard_public to ' || name_machine;
+
+ execute 'revoke r_standard_administer from ' || name_machine;
+ execute 'revoke r_standard_manager from ' || name_machine;
+ execute 'revoke r_standard_auditor from ' || name_machine;
+ execute 'revoke r_standard_publisher from ' || name_machine;
+ execute 'revoke r_standard_financer from ' || name_machine;
+ execute 'revoke r_standard_insurer from ' || name_machine;
+ execute 'revoke r_standard_reviewer from ' || name_machine;
+ execute 'revoke r_standard_editor from ' || name_machine;
+ execute 'revoke r_standard_drafter from ' || name_machine;
+ execute 'revoke r_standard_requester from ' || name_machine;
+
+ if (old.is_system <> new.is_system) then
+ if (new.is_system) then
+ execute 'grant r_standard_system to ' || name_machine;
+ else
+ execute 'revoke r_standard_system from ' || name_machine;
+ end if;
+ end if;
+ else
+ if (old.is_public <> new.is_public) then
+ execute 'revoke r_standard_public from ' || name_machine;
+ end if;
+
+ if (old.is_system <> new.is_system) then
+ if (new.is_system) then
+ execute 'grant r_standard_system to ' || name_machine;
+ else
+ execute 'revoke r_standard_system from ' || name_machine;
+ end if;
+ elseif (not new.is_system) then
+ if (new.is_requester or new.is_drafter or new.is_editor or new.is_reviewer or new.is_financer or new.is_insurer or new.is_publisher or new.is_auditor or new.is_manager or new.is_administer) then
+ execute 'grant r_standard to ' || name_machine;
+ end if;
+ end if;
+
+ if (old.is_administer <> new.is_administer) then
+ if (new.is_administer) then
+ execute 'grant r_standard_administer to ' || name_machine;
+ else
+ execute 'revoke r_standard_administer from ' || name_machine;
+ end if;
+ end if;
+
+ if (old.is_manager <> new.is_manager) then
+ if (new.is_manager) then
+ execute 'grant r_standard_manager to ' || name_machine;
+ else
+ execute 'revoke r_standard_manager from ' || name_machine;
+ end if;
+ end if;
+
+ if (old.is_auditor <> new.is_auditor) then
+ if (new.is_auditor) then
+ execute 'grant r_standard_auditor to ' || name_machine;
+ else
+ execute 'revoke r_standard_auditor from ' || name_machine;
+ end if;
+ end if;
+
+ if (old.is_publisher <> new.is_publisher) then
+ if (new.is_publisher) then
+ execute 'grant r_standard_publisher to ' || name_machine;
+ else
+ execute 'revoke r_standard_publisher from ' || name_machine;
+ end if;
+ end if;
+
+ if (old.is_insurer <> new.is_insurer) then
+ if (new.is_insurer) then
+ execute 'grant r_standard_insurer to ' || name_machine;
+ else
+ execute 'revoke r_standard_insurer from ' || name_machine;
+ end if;
+ end if;
+
+ if (old.is_financer <> new.is_financer) then
+ if (new.is_financer) then
+ execute 'grant r_standard_financer to ' || name_machine;
+ else
+ execute 'revoke r_standard_financer from ' || name_machine;
+ end if;
+ end if;
+
+ if (old.is_reviewer <> new.is_reviewer) then
+ if (new.is_reviewer) then
+ execute 'grant r_standard_reviewer to ' || name_machine;
+ else
+ execute 'revoke r_standard_reviewer from ' || name_machine;
+ end if;
+ end if;
+
+ if (old.is_editor <> new.is_editor) then
+ if (new.is_editor) then
+ execute 'grant r_standard_editor to ' || name_machine;
+ else
+ execute 'revoke r_standard_editor from ' || name_machine;
+ end if;
+ end if;
+
+ if (old.is_drafter <> new.is_drafter) then
+ if (new.is_drafter) then
+ execute 'grant r_standard_drafter to ' || name_machine;
+ else
+ execute 'revoke r_standard_drafter from ' || name_machine;
+ end if;
+ end if;
+
+ if (old.is_requester <> new.is_requester) then
+ if (new.is_requester) then
+ execute 'grant r_standard_requester to ' || name_machine;
+ else
+ execute 'revoke r_standard_requester from ' || name_machine;
+ end if;
+ end if;
+ end if;
+
+ reset client_min_messages;
+
+ return null;
+ end;
+$$ language plpgsql;
+
+alter function s_administers.f_users_update_as_administer() owner to u_standard_grant_roles;
+
+create function s_administers.f_users_update_materialized_views() returns trigger security definer as $$
+ begin
+
+ refresh materialized view s_administers.m_users_date_created_this_day;
+ refresh materialized view s_administers.m_users_date_changed_this_day;
+ refresh materialized view s_administers.m_users_date_synced_this_day;
+
+ return null;
+ end;
+$$ language plpgsql;
+
+alter function s_administers.f_users_update_materialized_views() owner to r_standard_administer;
+
+create trigger tr_users_insert_actions
+ before insert on s_tables.t_users
+ for each row execute procedure s_administers.f_users_insert_actions();
+
+create trigger tr_users_update_actions
+ before update on s_tables.t_users
+ for each row execute procedure s_administers.f_users_update_actions();
+
+create trigger tr_users_insert_as_administer
+ after insert on s_tables.t_users
+ for each row execute procedure s_administers.f_users_insert_as_administer();
+
+create trigger tr_users_update_as_administer
+ after update on s_tables.t_users
+ for each row execute procedure s_administers.f_users_update_as_administer();
+
+create trigger tr_users_update_materialized_views
+ after insert or update on s_tables.t_users
+ for each statement execute procedure s_administers.f_users_update_materialized_views();
+
+/** Special Cases: manually add the postgresql and public users first before any logging triggers are defined (because some of them depend on this table recursively! **/
+insert into s_tables.t_users (id, name_machine, name_human, is_private, is_public) values (1, 'u_standard_public', (null, 'Unknown', null, null, null, 'Unknown'), false, true);
+insert into s_tables.t_users (id, name_machine, name_human, is_private, is_system) values (2, 'postgres', (null, 'Database', null, 'Administer', null, 'Database (Administer)'), true, true);
+
+
+
+commit transaction;
ini_set('output_buffering', FALSE);
// default supported languages.
- c_base_defaults_global::s_set_languages(new c_base_language_limited());
+ c_base_defaults_global::s_set_languages(new c_base_languages_limited());
}
function program_load_session(&$data_program) {
$database->set_session($session);
}
- $connection_string = new c_base_connection_string();
+ $connection_string = new c_base_database_connection_string();
$connection_string->set_host('127.0.0.1');
$connection_string->set_port(5432);
$connection_string->set_database('example');
function process_received_headers(&$stuff) {
// default supported languages.
- c_base_defaults_global::s_set_languages(new c_base_language_limited());
+ c_base_defaults_global::s_set_languages(new c_base_languages_limited());
$stuff['http'] = new c_base_http();
$stuff['http']->do_load_request();
// test error message handling using english or japanese.
$supported_languages = array(
- i_base_language::ENGLISH_US => 'c_base_error_messages_english',
- i_base_language::ENGLISH => 'c_base_error_messages_english',
- i_base_language::JAPANESE => 'c_base_error_messages_japanese',
+ i_base_languages::ENGLISH_US => 'c_base_error_messages_english',
+ i_base_languages::ENGLISH => 'c_base_error_messages_english',
+ i_base_languages::JAPANESE => 'c_base_error_messages_japanese',
);
- $stuff['http']->set_response_content_language(i_base_language::ENGLISH_US);
- $stuff['http']->set_response_content_language(i_base_language::ENGLISH);
+ $stuff['http']->set_response_content_language(i_base_languages::ENGLISH_US);
+ $stuff['http']->set_response_content_language(i_base_languages::ENGLISH);
- $language_chosen = i_base_language::ENGLISH_US;
+ $language_chosen = i_base_languages::ENGLISH_US;
$languages_accepted = $stuff['http']->get_request(c_base_http::REQUEST_ACCEPT_LANGUAGE)->get_value();
if (isset($languages_accepted['data']['weight']) && is_array($languages_accepted['data']['weight'])) {
foreach ($languages_accepted['data']['weight'] as $weight => $language) {
}
unset($languages_accepted);
- if ($language_chosen === i_base_language::ENGLISH || $language_chosen === i_base_language::ENGLISH_US) {
+ if ($language_chosen === i_base_languages::ENGLISH || $language_chosen === i_base_languages::ENGLISH_US) {
require_once('common/base/classes/base_error_messages_english.php');
}
- elseif ($language_chosen === i_base_language::JAPANESE) {
+ elseif ($language_chosen === i_base_languages::JAPANESE) {
require_once('common/base/classes/base_error_messages_japanese.php');
- $stuff['http']->set_response_content_language(i_base_language::JAPANESE);
+ $stuff['http']->set_response_content_language(i_base_languages::JAPANESE);
}
$stuff['error_messages'] = new $supported_languages[$language_chosen];
// disclaimer: I used translate.google.com to generate the languages and provided only the default translation (expect translation errors).
$test_strings = array(
- i_base_language::ENGLISH_US => 'This is a test using your browser default language. Currently english (default), spanish, japanese, and russian are tested.',
- i_base_language::ENGLISH => 'This is a test using your browser default language. Currently english (default), spanish, japanese, and russian are tested.',
- i_base_language::JAPANESE => 'これは、ブラウザのデフォルト言語を使用したテストです。 現在、英語(デフォルト)、スペイン語、日本語、ロシア語がテストされています。',
- i_base_language::RUSSIAN => 'Это тест с помощью браузера по умолчанию язык. В настоящее время английский (по умолчанию), испанский, японский и русский тестируются.',
- i_base_language::SPANISH => 'Se trata de una prueba que utiliza el idioma predeterminado de su navegador. Actualmente se ponen a prueba el inglés (predeterminado), el español, el japonés y el ruso.',
+ i_base_languages::ENGLISH_US => 'This is a test using your browser default language. Currently english (default), spanish, japanese, and russian are tested.',
+ i_base_languages::ENGLISH => 'This is a test using your browser default language. Currently english (default), spanish, japanese, and russian are tested.',
+ i_base_languages::JAPANESE => 'これは、ブラウザのデフォルト言語を使用したテストです。 現在、英語(デフォルト)、スペイン語、日本語、ロシア語がテストされています。',
+ i_base_languages::RUSSIAN => 'Это тест с помощью браузера по умолчанию язык. В настоящее время английский (по умолчанию), испанский, японский и русский тестируются.',
+ i_base_languages::SPANISH => 'Se trata de una prueba que utiliza el idioma predeterminado de su navegador. Actualmente se ponen a prueba el inglés (predeterminado), el español, el japonés y el ruso.',
);
- $language_chosen = i_base_language::ENGLISH;
+ $language_chosen = i_base_languages::ENGLISH;
$languages_accepted = $stuff['http']->get_request(c_base_http::REQUEST_ACCEPT_LANGUAGE)->get_value();
if (isset($languages_accepted['data']['weight']) && is_array($languages_accepted['data']['weight'])) {
foreach ($languages_accepted['data']['weight'] as $weight => $language) {
}
function assign_database_string(&$database, $username, $password) {
- $connection_string = new c_base_connection_string();
+ $connection_string = new c_base_database_connection_string();
$connection_string->set_host('127.0.0.1');
$connection_string->set_port(5432);
$connection_string->set_database('reservation');
@socket_clear_error();
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_create', ':socket_error' => $socket_error, ':socket_error_message' => @socket_strerror($socket_error), ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'socket_create', ':{socket_error}' => $socket_error, ':{socket_error_message}' => @socket_strerror($socket_error), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
unset($socket_error);
return c_base_return_error::s_false($error);
@socket_close($socket);
unset($socket);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_connect', ':socket_error' => $socket_error, ':socket_error_message' => @socket_strerror($socket_error), ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'socket_connect', ':{socket_error}' => $socket_error, ':{socket_error_message}' => @socket_strerror($socket_error), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
unset($socket_error);
return c_base_return_error::s_false($error);
@socket_close($socket);
unset($socket);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_write', ':socket_error' => $socket_error, ':socket_error_message' => @socket_strerror($socket_error), ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'socket_write', ':{socket_error}' => $socket_error, ':{socket_error_message}' => @socket_strerror($socket_error), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
unset($socket_error);
return c_base_return_error::s_false($error);
@socket_close($socket);
unset($socket);
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_read', ':socket_error' => $socket_error, ':socket_error_message' => @socket_strerror($socket_error), ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'socket_read', ':{socket_error}' => $socket_error, ':{socket_error_message}' => @socket_strerror($socket_error), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
unset($socket_error);
return c_base_return_error::s_false($error);
// assign custom include path.
set_include_path('/var/git/koopa');
-// load the global defaults file (this file is not included by default but is required by all).
-// replace this with your own as you see fit.
-require_once('common/base/classes/base_defaults_global.php');
+// load the project-specific global defaults file.
+require_once('program/reservation/reservation_defaults_global.php');
-require_once('common/base/classes/base_http.php');
-require_once('common/base/classes/base_http_status.php');
-require_once('common/base/classes/base_cookie.php');
-require_once('common/base/classes/base_ldap.php');
-require_once('common/base/classes/base_markup.php');
-require_once('common/base/classes/base_html.php');
-require_once('common/base/classes/base_charset.php');
-require_once('common/base/classes/base_database.php');
-require_once('common/base/classes/base_languages.php');
+require_once('common/standard/classes/standard_index.php');
-require_once('program/reservation/reservation_database.php');
-require_once('program/reservation/reservation_session.php');
-require_once('program/reservation/reservation_paths.php');
/**
- * Load all custom settings.
- *
- * @return array
- * Custom settings.
+ * The standard class for use in index.php or equivalent.
*/
-function reservation_load_settings() {
- ini_set('opcache.enable', FALSE);
- ini_set('opcache.enable_cli', FALSE);
+class c_reservation_index extends c_standard_index {
- // only enable output buffering during the output stage, keep it disabled until then.
- ini_set('output_buffering', FALSE);
+ /**
+ * Class constructor.
+ */
+ public function __construct() {
+ parent::__construct();
- $settings = array();
+ $this->settings['database_name'] = 'reservation';
+ $this->settings['database_user_public'] = 'u_reservation_public';
- // database information
- $settings['database_host'] = '127.0.0.1';
- $settings['database_port'] = 5432;
- $settings['database_name'] = 'reservation';
- $settings['database_user'] = 'u_reservation_public';
- $settings['database_password'] = NULL;
- $settings['database_timeout'] = 4;
- #$settings['database_ssl_mode'] = 'require';
- $settings['database_ssl_mode'] = 'disable';
- $settings['database_create_account_host'] = '127.0.0.1';
- $settings['database_create_account_port'] = 5433;
+ $this->settings['database_name'] = 'reservation';
+ $this->settings['database_user'] = 'u_reservation_public';
- // cookie/session information
- $settings['cookie_name'] = 'reservation-session';
- $settings['cookie_path'] = '/';
- $settings['cookie_domain'] = '.localhost';
- $settings['cookie_http_only'] = FALSE; // setting this to false will allow javascript to access this cookie, such as for ajax.
- $settings['cookie_host_only'] = TRUE;
- $settings['cookie_same_site'] = c_base_cookie::SAME_SITE_STRICT;
- $settings['session_socket'] = '/program/sockets/sessionize_accounts/';
- $settings['session_system'] = 'reservation';
- $settings['session_expire'] = 600; // 10 minutes
- $settings['session_max'] = 1800; // 30 minutes
+ $this->settings['session_system'] = 'reservation';
- // ldap information
- $settings['ldap_server'] = NULL; // 'ldaps://127.0.0.1:1636/';
- $settings['ldap_base_dn'] = '';
- $settings['ldap_fields'] = array();
-
- // base settings
- $settings['base_scheme'] = 'https';
- $settings['base_host'] = 'localhost';
- $settings['base_path'] = $settings['cookie_path']; // must end in a trailing slash.
-
- if (!isset($_SERVER["HTTPS"])) {
- $settings['base_scheme'] = 'http';
- }
-
- // The HTML tag <p>, represents a paragraph.
- // However, many sites, services, and developers incorrectly use it to represent text.
- // The definition of the word 'paragraph' contradicts this current usage of the HTML tag <p>.
- // It is also important to note that many browsers will alter the content of the <p> tag to remove blocks of any kind, such as <ul>.
- // The <span> tag does not seem to have this issue.
- // Therefore, the use of HTML <p> tag is consider non-safe and likely to cause problems with formatting (because client browsers alter the HTML).
- // This provides a way to still use <p> tags despite the implementation, usage, and context flaws.
- $settings['standard_issue-use_p_tags'] = FALSE;
-
- // default supported languages.
- c_base_defaults_global::s_set_languages(new c_base_language_limited());
-
- // default time related settings.
- c_base_defaults_global::s_get_timestamp_session(TRUE);
- c_base_defaults_global::s_set_timezone('America/Chicago');
-
-
- return $settings;
-}
-
-/**
- * Process HTTP request.
- *
- * @return c_base_http
- * Processed and loaded request.
- */
-function reservation_receive_request() {
- $http = new c_base_http();
- $http->do_load_request();
-
- // Assign a default response protocol.
- $http->set_response_protocol('HTTP/1.1');
-
- // Assign a default response status (expected to be overridden by path handlers).
- $http->set_response_status(c_base_http_status::OK);
-
- // get the current language and assign the default.
- $languages = c_base_defaults_global::s_get_languages()::s_get_ids()->get_value_exact();
- if (!is_array($languages) || empty($languages)) {
- $languages = array(i_base_language::ENGLISH_US => i_base_language::ENGLISH_US, i_base_language::ENGLISH => i_base_language::ENGLISH);
- }
-
- $selected = $http->select_language($languages)->get_value_exact();
-
- // select the primary language.
- $http->set_response_content_language($selected, FALSE);
-
- // this website is primary us-english (and therefore english), also set this as an additional language because multi-lingual support is not 100% guaranteed.
- if ($selected != i_base_language::ENGLISH_US) {
- $http->set_response_content_language(i_base_language::ENGLISH_US);
- }
-
- if ($selected != i_base_language::ENGLISH) {
- $http->set_response_content_language(i_base_language::ENGLISH);
- }
- unset($selected);
-
- return $http;
-}
-
-/**
- * Send HTTP response.
- *
- * @param c_base_http $http
- * Http object.
- */
-function reservation_send_response($http) {
- // get current http header method, which may determine which headers to set or not set.
- $method = $http->get_request(c_base_http::REQUEST_METHOD)->get_value_exact();
- if (isset($method['data']) && is_int($method['data'])) {
- $method = $method['data'];
- }
- else {
- $method = c_base_http::HTTP_METHOD_NONE;
- }
-
- // add headers
- $http->set_response_date();
- $http->set_response_content_type('text/html');
- #$http->set_response_etag();
- #$http->set_response_last_modified(strtotime('now'));
- #$http->set_response_expires(strtotime('+30 minutes'));
- $http->set_response_pragma('no-cache');
- $http->set_response_vary('Host');
- $http->set_response_vary('User-Agent');
- $http->set_response_vary('Accept');
- $http->set_response_vary('Accept-Language');
- #$http->set_response_warning('1234 This site is under active development.');
-
-
- // finalize the content prior to sending headers to ensure header accuracy.
- $http->encode_response_content();
-
- // http head method responses do not sent content.
- if ($method === c_base_http::HTTP_METHOD_HEAD) {
- $http->set_response_content('', FALSE);
- }
-
-
- // manually disable output buffering (if enabled) when transfer headers and content.
- $old_output_buffering = ini_get('output_buffering');
- ini_set('output_buffering', 'off');
-
-
- // when the headers are sent, checksums are created, so at this point all error output should be stored and not sent.
- $http->send_response_headers(TRUE);
-
-
- // once the header are sent, send the content.
- $http->send_response_content();
-
-
- ini_set('output_buffering', $old_output_buffering);
- unset($old_output_buffering);
-}
-
-/**
- * Process page request.
- *
- * @param c_base_http &$http
- * Http object.
- * @param c_base_database &$databbase
- * The database object.
- * @param array &$settings
- * System settings
- * @param c_base_session &$session
- * Session information.
- *
- * @return c_base_return
- * The generated html is returned on success.
- * The generated text is returned on success.
- * This does not set the error bit on error.
- */
-function reservation_process_request(&$http, &$database, &$session, &$settings) {
- $session_user = $session->get_name()->get_value_exact();
- if (is_null($session_user)) {
- $session->set_logged_in(FALSE);
-
- // @todo: delete old cookies, if they expire.
- $cookie_login = $session->get_cookie();
-
- // @fixme: shouldn't this check be in the session management code?
- // the session should already be logged into at this point.
- // if the session id exists, but no user id is defined, then the session is no longer valid, so delete the invalid cookie.
- if (!empty($session->get_session_id()->get_value_exact())) {
- $cookie_login->set_expires(-1);
- $cookie_login->set_max_age(-1);
- $session->set_cookie($cookie_login);
- unset($cookie_login);
-
- $session->set_session_id(NULL);
- }
- }
- else {
- $user_name = $session->get_name()->get_value();
- $password = $session->get_password()->get_value();
-
- if (is_null($user_name) || is_null($password)) {
- unset($user_name);
- unset($password);
-
- $session->set_logged_in(FALSE);
- }
- else {
- $session->set_logged_in(TRUE);
- reservation_database_string($database, $settings, $user_name, $password);
-
- unset($user_name);
- unset($password);
- }
- }
-
- $paths = new c_reservation_paths();
- $executed = $paths->reservation_process_path($http, $database, $session, $settings);
- unset($paths);
-
- return $executed->get_output();
-}
-
-/**
- * Render the theme.
- *
- * @param c_base_http $http
- * Http object.
- * @param c_base_return $output
- * The HTML object.
- */
-function reservation_render_theme($http, $output) {
- $theme = new c_theme_html();
- $theme->set_html($output); // @fixme: this needs to be changed from set_html() to set_output() to handle more types of content.
- $theme->set_http($http);
- $theme->render_markup();
-
- return $theme->get_markup();
-}
-
-/**
- * Build the HTTP response.
- *
- * @param c_base_http &$http
- * Http object.
- * @param c_base_session &$session
- * Session information.
- * @param string $output
- * The output string.
- * Can be any string, such as HTML markup.
- */
-function reservation_build_response(&$http, &$session, $output) {
- $http->set_response_checksum_header(c_base_http::CHECKSUM_ACTION_AUTO);
- $http->set_response_content($output);
-
-
- // send the session cookie if a session id is specified.
- $session_id = $session->get_session_id()->get_value_exact();
- if (!empty($session_id)) {
- $cookie_login = $session->get_cookie();
-
- if ($cookie_login instanceof c_base_cookie) {
- $http->set_response_set_cookie($cookie_login);
- }
- unset($cookie_login);
+ $this->settings['cookie_name'] = 'reservation-session';
}
- unset($session_id);
-
- return new c_base_return_true();
-}
-
-/**
- * Main Program Function
- *
- * note: Future designs will likely include content caching.
- * There are different designs based on the type of content that can be used for caching.
- * The following are some common generic areas to cache:
- * - design 1 (public content): 3, 4. 5 (cache handling happens between 2 and 3).
- * - design 2 (database bypass): 4 (4 is to be replaced with cache handling).
- * - design 3 (theme bypass): 4. 5 (4 is to be replaced with cache handling).
- * - design 4 (full private cache): 4. 5, 6* (should still handling login access, only (vary) headers are to be changed in 6).
- * - design 5 (full public cache): 3, 4. 5, 6* (should still handling login access, only (vary) headers are to be changed in 6).
- *
- * It is also recommended that some placeholders are added to the css body to provide dynamic css class names, even on cached content.
- */
-function reservation_main() {
- // 1: local settings:
- $settings = reservation_load_settings();
- gc_collect_cycles();
-
-
- // 2: receive request information.
- $http = reservation_receive_request();
- gc_collect_cycles();
-
-
- // 3: process session information
- $session = reservation_process_sessions($http, $settings);
- gc_collect_cycles();
-
-
- // 4: perform actions, process work.
- $database = new c_base_database();
- $output = reservation_process_request($http, $database, $session, $settings);
-
- if ($database->is_connected() instanceof c_base_return_true) {
- $database->do_disconnect();
- }
- unset($database);
- gc_collect_cycles();
-
-
- // 5: build or finalize theme.
- if (($output instanceof c_base_return_null)) {
- $output = '';
- }
- else {
- $output = reservation_render_theme($http, $output)->get_value_exact();
- }
- gc_collect_cycles();
-
-
- // 6: build response information.
- reservation_build_response($http, $session, $output);
- unset($output);
- gc_collect_cycles();
-
-
- // 7: send HTTP response.
- reservation_send_response($http);
- gc_collect_cycles();
-
- unset($settings);
- unset($http);
- unset($session);
- gc_collect_cycles();
}
-reservation_main();
+$index = new c_reservation_index();
+$index->do_execute();
+unset($index);
+++ /dev/null
-<?php
-/**
- * @file
- * Provides reservation build functions beyond what is found in index.php.
- */
-require_once('common/base/classes/base_error.php');
-require_once('common/base/classes/base_return.php');
-require_once('common/base/classes/base_html.php');
-
-require_once('common/theme/classes/theme_html.php');
-
-class c_reservation_build {
- /**
- * Create a new HTML markup class with default settings populated.
- *
- * @param c_base_http &$http
- * Http object.
- * @param c_base_database &$databbase
- * The database object.
- * @param c_base_session &$session
- * Session information.
- * @param array $settings
- * System settings
- * @param string|null $title
- * (optional) A string to be used as the page title header.
- * Set to NULL to use default language.
- *
- * @return c_base_html
- * The generated html is returned on success.
- * The generated html with error bit set is returned on error.
- */
- public static function s_create_html(&$http, &$database, &$session, $settings, $title = NULL) {
- if (!is_string($title)) {
- $title = NULL;
- }
-
- $html = new c_base_html();
-
- // assign class attribute
- $class = array(
- 'reservation',
- 'no-script',
- 'is-html5',
- );
-
- $html->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, $class);
- unset($class);
-
-
- // assign id attribute
- $html->set_attribute(c_base_markup_attributes::ATTRIBUTE_ID, 'reservation-system');
-
-
- // assign default language attribute.
- $html->set_attribute(c_base_markup_attributes::ATTRIBUTE_LANGUAGE, i_base_language::ENGLISH_US);
-
-
- // assign default direction attribute
- $html->set_attribute(c_base_markup_attributes::ATTRIBUTE_DIRECTION, 'ltr');
-
-
- // assign title header tag (setting title tag at delta 0 so that it can easily be overriden as needed).
- $tag = new c_base_markup_tag();
- $tag->set_type(c_base_markup_tag::TYPE_TITLE);
-
- if (is_string($title)) {
- $tag->set_text($title);
- }
- else {
- $tag->set_text('Reservation System');
- }
-
- $html->set_header($tag, 0);
- unset($tag);
-
-
- // assign base header tag
- if (isset($settings['base_path']) && is_string($settings['base_path']) && mb_strlen($settings['base_scheme']) > 0) {
- $href = '';
- if (isset($settings['base_scheme']) && is_string($settings['base_scheme']) && mb_strlen($settings['base_scheme']) > 0) {
- if (isset($settings['base_host']) && is_string($settings['base_host']) && mb_strlen($settings['base_host']) > 0) {
- $href .= $settings['base_scheme'] . '://' . $settings['base_host'];
- }
- }
-
- $href .= $settings['base_path'];
-
- $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_BASE);
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $href);
- $html->set_header($tag);
- unset($tag);
- unset($href);
- }
-
-
- // assign http-equiv header tag
- $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HTTP_EQUIV, 'Content-Type');
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, 'text/html; charset=utf-8');
- $html->set_header($tag);
- unset($tag);
-
-
- // assign charset header tag
- $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CHARACTER_SET, c_base_charset::UTF_8);
- $html->set_header($tag);
- unset($tag);
-
-
- // assign canonical header tag
- #$tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
- #$tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical');
- #$tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, 'http://localhost/');
- #$html->set_header($tag);
- #unset($tag);
-
-
- // assign shortlink header tag
- #$tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
- #$tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'shortlink');
- #$tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, '/');
- #$html->set_header($tag);
- #unset($tag);
-
-
- // assign description header tag
- $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_NAME, 'description');
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, 'A reservation/scheduling system.');
- $html->set_header($tag);
- unset($tag);
-
-
- // assign distribution header tag
- $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_NAME, 'distribution');
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, 'web');
- $html->set_header($tag);
- unset($tag);
-
-
- // assign robots header tag
- $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_NAME, 'robots');
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, 'INDEX,FOLLOW');
- $html->set_header($tag);
- unset($tag);
-
-
- // assign expires header tag
- #$tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
- #$tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HTTP_EQUIV, 'expires');
- #$tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, c_base_defaults_global::s_get_date('r', strtotime('+30 minutes'))->get_value_exact());
- #$html->set_header($tag);
- #unset($tag);
-
-
- // assign viewport header tag
- $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_NAME, 'viewport');
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, 'width=device-width, initial-scale=1');
- $html->set_header($tag);
- unset($tag);
-
-
- // assign content http-equiv header tag
- $aliases = array();
- $languages = $http->get_response_content_language()->get_value_exact();
- if (is_array($languages) && !empty($languages)) {
- // assign the primary language.
- $language_aliases = c_base_defaults_global::s_get_languages()::s_get_aliases_by_id(reset($languages))->get_value_exact();
- if (is_array($language_aliases) && !empty($language_aliases)) {
- $html->set_attribute(c_base_markup_attributes::ATTRIBUTE_LANGUAGE, reset($language_aliases));
- }
- unset($language_aliases);
-
- foreach ($languages as $language) {
- $language_aliases = c_base_defaults_global::s_get_languages()::s_get_aliases_by_id($language)->get_value_exact();
- if (is_array($language_aliases) && !empty($language_aliases)) {
- $aliases[] = array_pop($language_aliases);
- }
- unset($language_aliases);
- }
- unset($language);
- }
- unset($languages);
-
- if (!empty($aliases)) {
- $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HTTP_EQUIV, 'content-language');
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, implode(', ', $aliases));
- $html->set_header($tag);
- unset($tag);
- }
- unset($aliases);
-
- return $html;
- }
-}
+++ /dev/null
-<?php
-/**
- * @file
- * Provides reservation database functions.
- */
-require_once('common/base/classes/base_error.php');
-require_once('common/base/classes/base_return.php');
-require_once('common/base/classes/base_session.php');
-require_once('common/base/classes/base_database.php');
-require_once('common/base/classes/base_access.php');
-
- /**
- * Build the database connection string.
- *
- * @param c_base_database &$database
- * The database to connect to.
- * @param array $settings
- * Custom settings.
- * @param string|null $username
- * The username string.
- * If NULL, then the global username is used.
- * @param string|null $password
- * The password string.
- * If NULL, then the global password is used.
- *
- * @return c_base_return_status
- * TRUE on success, FALSE otherwise.
- * FALSE with error bit set on error.
- */
-function reservation_database_string(&$database, $settings, $user_name = NULL, $password = NULL) {
- if (!($database instanceof c_base_database)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'database', ':function_name' => __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- if (!is_array($settings)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'settings', ':function_name' => __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- if (!is_null($user_name) && !is_string($user_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'user_name', ':function_name' => __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- if (!is_null($password) && !is_string($password)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'password', ':function_name' => __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- $connection_string = new c_base_connection_string();
- $connection_string->set_host($settings['database_host']);
- $connection_string->set_port($settings['database_port']);
- $connection_string->set_database($settings['database_name']);
-
- if (is_null($user_name)) {
- $connection_string->set_user($settings['database_user']);
-
- if (!is_null($settings['database_password'])) {
- $connection_string->set_password($settings['database_password']);
- }
- }
- else {
- $connection_string->set_user($user_name);
-
- if (!is_null($password)) {
- $connection_string->set_password($password);
- }
- }
-
- $connection_string->set_ssl_mode($settings['database_ssl_mode']);
- $connection_string->set_connect_timeout($settings['database_timeout']);
-
- $database->set_connection_string($connection_string);
- unset($connection_string);
-
- return new c_base_return_true();
-}
-
-/**
- * Connect the database and configure default settings.
- *
- * @param c_base_database &$database
- * The database to connect to.
- *
- * @return c_base_return_status
- * TRUE on success, FALSE otherwise.
- * FALSE with error bit set on error.
- */
-function reservation_database_connect(&$database) {
- if (!($database instanceof c_base_database)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'database', ':function_name' => __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- $status = $database->do_connect();
- if (!($status instanceof c_base_return_true)) {
- return $status;
- }
- unset($status);
-
- // configure default settings.
- $database->do_query('set bytea_output to hex;');
- $database->do_query('set search_path to s_administers,s_managers,s_auditors,s_publishers,s_insurers,s_financers,s_reviewers,s_editors,s_drafters,s_requesters,s_users,public;');
- $database->do_query('set datestyle to us;');
-
- return new c_base_return_true();
-}
-
-/**
- * Load the user data.
- *
- * This is necessary to load and process session data.
- *
- * @param c_base_database &$database
- * The database to connect to.
- * @param string $user_name
- * The name of the user to load.
- * @param array|null $ldap_data
- * (optional) An array of ldap data (if available).
- * This is used to auto-populate user information in the database when an account is auto-created.
- *
- * @return c_base_return_array|c_base_return_status
- * An array of user data is returned on success.
- * FALSE with error bit set on error.
- */
-function reservation_database_get_user_data(&$database, $user_name, $ldap_data = NULL) {
- if (!($database instanceof c_base_database)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'database', ':function_name' => __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- if (!is_string($user_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'user_name', ':function_name' => __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- if (!is_null($ldap_data) && !is_array($ldap_data)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'ldap_data', ':function_name' => __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- $parameters = array(
- $user_name,
- );
-
- $query_result = $database->do_query('select id, id_sort, id_external, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, date_created, date_changed, date_synced, date_locked, settings from v_users_self where id_sort = ascii($1) and name_machine = $1', $parameters);
- unset($parameters);
-
- if (c_base_return::s_has_error($query_result)) {
- return reservation_error_get_query('database->do_query(select from v_users_self)', __FUNCTION__, $query_result);
- }
-
- if ($query_result instanceof c_base_database_result && $query_result->number_of_rows()->get_value_exact() > 0) {
- $result = $query_result->fetch_row();
- unset($query_result);
-
- if (c_base_return::s_has_error($result)) {
- return reservation_error_get_query('database->do_query(select from v_users_self)', __FUNCTION__, $result);
- }
-
- $result_array = $result->get_value();
- unset($result);
-
- if (is_array($result_array) && !empty($result_array)) {
- $user_data = array();
- $user_data['id'] = $result_array[0];
- $user_data['id_sort'] = $result_array[1];
- $user_data['id_external'] = $result_array[2];
- $user_data['name_machine'] = $result_array[3];
- $user_data['name_human'] = $result_array[4];
- $user_data['address_email'] = $result_array[5];
- $user_data['is_administer'] = $result_array[6];
- $user_data['is_manager'] = $result_array[7];
- $user_data['is_auditor'] = $result_array[8];
- $user_data['is_publisher'] = $result_array[9];
- $user_data['is_financer'] = $result_array[10];
- $user_data['is_reviewer'] = $result_array[11];
- $user_data['is_editor'] = $result_array[12];
- $user_data['is_drafter'] = $result_array[13];
- $user_data['is_requester'] = $result_array[14];
- $user_data['is_system'] = $result_array[15];
- $user_data['is_public'] = $result_array[16];
- $user_data['is_locked'] = $result_array[17];
- $user_data['is_private'] = $result_array[18];
- $user_data['date_created'] = $result_array[19];
- $user_data['date_changed'] = $result_array[20];
- $user_data['date_synced'] = $result_array[21];
- $user_data['date_locked'] = $result_array[22];
- $user_data['settings'] = json_decode($result_array[23], TRUE);
-
- unset($result_array);
- return c_base_return_array::s_new($user_data);
- }
- unset($result_array);
- }
- unset($query_result);
-
- // at this ppint the user account likely does not exist in the database, so create it using any ldap information if available.
- if (is_null($ldap_data)) {
- $query_result = $database->do_query('insert into v_users_self_insert (name_human.first) values (null)');
-
- if (c_base_return::s_has_error($query_result)) {
- return reservation_error_get_query('database->do_query(insert into v_users_self_insert)', __FUNCTION__, $query_result);
- }
- }
- else {
- $email = explode('@', $ldap_data['mail']);
- $parameters = array(
- $ldap_data['givenname'],
- $ldap_data['sn'],
- $ldap_data['cn'],
- $email[0],
- $email[1],
- $ldap_data['employeenumber'],
- );
-
- $query_result = $database->do_query('insert into v_users_self_insert (name_human.first, name_human.last, name_human.complete, address_email, id_external) values ($1, $2, $3, ($4, $5, TRUE), $6)', $parameters);
-
- if (c_base_return::s_has_error($query_result)) {
- return reservation_error_get_query('database->do_query(insert into v_users_self_insert)', __FUNCTION__, $query_result);
- }
- }
- unset($query_result);
-
-
- // try loading the user information again now that the user information exists in the database.
- $parameters = array(
- $user_name,
- );
-
- $query_result = $database->do_query('select id, id_sort, id_external, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, date_created, date_changed, date_synced, date_locked, settings from v_users_self where id_sort = ascii($1) and name_machine = $1', $parameters);
- unset($parameters);
-
- if (c_base_return::s_has_error($query_result)) {
- return reservation_error_get_query('database->do_query(select from v_users_self)', __FUNCTION__, $query_result);
- }
-
- if ($query_result instanceof c_base_database_result && $query_result->number_of_rows()->get_value_exact() > 0) {
- $result = $query_result->fetch_row();
- unset($query_result);
-
- if (c_base_return::s_has_error($result)) {
- return reservation_error_get_query('database->do_query(select from v_users_self)', __FUNCTION__, $result);
- }
-
- $result_array = $result->get_value();
- unset($result);
-
- if (is_array($result_array) && !empty($result_array)) {
- $user_data = array();
- $user_data['id'] = $result_array[0];
- $user_data['id_sort'] = $result_array[1];
- $user_data['id_external'] = $result_array[2];
- $user_data['name_machine'] = $result_array[3];
- $user_data['name_human'] = $result_array[4];
- $user_data['address_email'] = $result_array[5];
- $user_data['is_administer'] = $result_array[6];
- $user_data['is_manager'] = $result_array[7];
- $user_data['is_auditor'] = $result_array[8];
- $user_data['is_publisher'] = $result_array[9];
- $user_data['is_financer'] = $result_array[10];
- $user_data['is_reviewer'] = $result_array[11];
- $user_data['is_editor'] = $result_array[12];
- $user_data['is_drafter'] = $result_array[13];
- $user_data['is_requester'] = $result_array[14];
- $user_data['is_system'] = $result_array[15];
- $user_data['is_public'] = $result_array[16];
- $user_data['is_locked'] = $result_array[17];
- $user_data['is_private'] = $result_array[18];
- $user_data['date_created'] = $result_array[19];
- $user_data['date_changed'] = $result_array[20];
- $user_data['date_synced'] = $result_array[21];
- $user_data['date_locked'] = $result_array[22];
- $user_data['settings'] = json_decode($result_array[23], TRUE);
-
- unset($result_array);
- return c_base_return_array::s_new($user_data);
- }
- unset($result_array);
- }
- unset($query_result);
-
-
- return c_base_return_array::s_new(array());
-}
-
-/**
- * Loads LDAP information for the given user (if available).
- *
- * @param array $settings
- * System settings array.
- * @param string $user_name
- * The user name to load
- *
- * @return c_base_return_array|c_base_return_status
- * An array of ldap data associated with the given user.
- * This array may contain error information if there were connection problems to the ldap database.
- * The array structure is:
- * 'title': a Title for any error that occured.
- * 'message': The detailed ldap error message.
- * 'status': c_base_return_true if there were no problems and c_base_return_false if there were problems.
- * 'data': Any ldap data found for the given user name.
- * FALSE with the error bit set is returned on error.
- */
-function reservation_database_load_ldap_data($settings, $user_name) {
- if (!is_array($settings)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'settings', ':function_name' => __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- if (!is_string($user_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'user_name', ':function_name' => __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- $return_data = array(
- 'title' => NULL,
- 'message' => NULL,
- 'status' => new c_base_return_true(),
- 'data' => NULL,
- );
-
-
- // ldap support is disabled if ldap_server is set to NULL.
- if (is_null($settings['ldap_server'])) {
- return c_base_return_array::s_new($return_data);
- }
-
-
- $ldap = new c_base_ldap();
- $ldap->set_name($settings['ldap_server']);
- #$ldap->set_bind_name('');
- #$ldap->set_bind_password('');
- $connected = $ldap->do_connect();
- if (c_base_return::s_has_error($connected)) {
- $message = $ldap->get_error_message();
-
- $return_data['title'] = 'Connection Failed';
- $return_data['message'] = $message->get_value_exact();
- $return_data['status'] = new c_base_return_false();
- unset($message);
-
- return c_base_return_array::s_new($return_data);
- }
-
- $read = $ldap->do_search($settings['ldap_base_dn'], '(uid=' . $user_name . ')', $settings['ldap_fields']);
- if (c_base_return::s_has_error($read)) {
- $message = $ldap->get_error_message();
-
- $return_data['title'] = 'Search Failed';
- $return_data['message'] = $message->get_value_exact();
- $return_data['status'] = new c_base_return_false();
- unset($message);
-
- $ldap->do_disconnect();
-
- return c_base_return_array::s_new($return_data);
- }
-
- $entries = $read->get_entry_all();
- if ($entries instanceof c_base_return_array) {
- $entries = $entries->get_value();
- }
- else {
- $entries = array();
- }
-
- if ($entries['count'] > 0) {
- $return_data['data'] = array(
- 'uid' => $user_name,
- );
-
- foreach ($settings['ldap_fields'] as $ldap_field) {
- $return_data['data'][$ldap_field] = $entries[0][$ldap_field][0];
- }
- unset($ldap_field);
- }
- else {
- $return_data['title'] = 'Username Not Found';
- $return_data['message'] = 'The user \'' . $user_name . '\' was not found.';
- $return_data['status'] = new c_base_return_false();
- }
- unset($entries);
-
- return c_base_return_array::s_new($return_data);
-}
-
-/**
- * Get all roles assigned to the current user.
- *
- * @todo: this might be unecessary as it may be automated via the user view table and sql triggers.
- * @todo: review and update or delete this function as necessary.
- *
- * @param c_base_database &$database
- * The database object.
- * @param c_base_session &$session
- * The current session.
- * @param array $settings
- * The system settings array.
- *
- * @return c_base_return_status
- * TRUE on success, FALSE otherwise.
- * FALSE with error bit set is returned on error.
- */
-function reservation_get_current_roles(&$database, &$session, $settings) {
- $pre_connected = TRUE;
- $connected = $database->is_connected();
- if ($connected instanceof c_base_return_false) {
- $pre_connected = FALSE;
- $connected = reservation_database_connect($database);
- }
-
- $roles = new c_base_roles();
-
-
- // if there is no session, then assume that this is a public account.
- if (empty($session->get_session_id()->get_value_exact())) {
- unset($pre_connected);
-
- $roles->set_role(c_base_roles::PUBLIC, TRUE);
- $session->set_setting('roles', $roles);
- unset($roles);
-
- return new c_base_return_true();
- }
-
-
- // if unable to connect to database to retrieve other roles, just return the ppublic role.
- if ($connected instanceof c_base_return_false) {
- unset($pre_connected);
-
- $roles->set_role(c_base_roles::PUBLIC, TRUE);
- $session->set_setting('roles', $roles);
- unset($roles);
-
- $connection_string = $database->get_connection_string();
- $database_name = ($connection_string instanceof c_base_connection_string) ? $connection_string->get_database()->get_value_exact() : '';
- unset($connection_string);
-
- $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $database_name, ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_NO_CONNECTION);
- unset($database_name);
-
- return c_base_return_error::s_false($error);
- }
- unset($connected);
-
-
- // assign default roles.
- $roles->set_role(c_base_roles::PUBLIC, FALSE);
- $roles->set_role(c_base_roles::USER, TRUE);
-
-
- // load all postgresql roles.
- $result = $database->do_query('SELECT role_name FROM information_schema.enabled_roles');
- if ($result instanceof c_base_database_result) {
- $rows = $result->fetch_all()->get_value_exact();
-
- foreach ($rows as $row) {
- if (!array_key_exists('role_name', $row)) {
- continue;
- }
-
- switch ($row['role_name']) {
- case 'r_' . $settings['database_name'] . '_requester':
- $roles->set_role(c_base_roles::REQUESTER, TRUE);
- break;
- case 'r_' . $settings['database_name'] . '_drafter':
- $roles->set_role(c_base_roles::DRAFTER, TRUE);
- break;
- case 'r_' . $settings['database_name'] . '_editor':
- $roles->set_role(c_base_roles::EDITOR, TRUE);
- break;
- case 'r_' . $settings['database_name'] . '_reviewer':
- $roles->set_role(c_base_roles::REVIEWER, TRUE);
- break;
- case 'r_' . $settings['database_name'] . '_financer':
- $roles->set_role(c_base_roles::FINANCER, TRUE);
- break;
- case 'r_' . $settings['database_name'] . '_insurer':
- $roles->set_role(c_base_roles::INSURER, TRUE);
- break;
- case 'r_' . $settings['database_name'] . '_publisher':
- $roles->set_role(c_base_roles::PUBLISHER, TRUE);
- break;
- case 'r_' . $settings['database_name'] . '_auditor':
- $roles->set_role(c_base_roles::AUDITOR, TRUE);
- break;
- case 'r_' . $settings['database_name'] . '_manager':
- $roles->set_role(c_base_roles::MANAGER, TRUE);
- break;
- case 'r_' . $settings['database_name'] . '_administer':
- $roles->set_role(c_base_roles::ADMINISTER, TRUE);
- break;
- }
- }
- unset($row);
- unset($rows);
- }
- unset($result);
-
- if (!$pre_connected) {
- $database->do_disconnect();
- }
- unset($pre_connected);
-
- $session->set_setting('roles', $roles);
- unset($roles);
-
- return new c_base_return_true();
-}
-
-/**
- * Builds a return object for a query.
- *
- * This functions is provided to simplify the return of specific code.
- * Error handling is not performed, instead simple failsafes are used.
- *
- * @param string $operation_name
- * The name of the operation, which is generally something like: database->do_query.
- * @param string $function_name
- * The name of the function.
- * The caller should usually use __FUNCTION__ here.
- * @param c_base_return $result
- * The query return result.
- *
- * @return c_base_error
- * A generated oepration failure error.
- */
-function reservation_error_get_query($operation_name, $function_name, $result) {
- if (!is_string($operation_name)) {
- $operation_name = '';
- }
-
- if (!is_string($function_name)) {
- $function_name = '';
- }
-
- $failure = new c_base_return_false();
- $found_errors = FALSE;
- if ($result instanceof c_base_return) {
- $errors = $result->get_error();
- if (is_array($errors)) {
- $found_errors = TRUE;
-
- foreach ($errors as $error) {
- $failure->set_error($error);
- }
- unset($error);
- }
- unset($errors);
- }
-
- if (!$found_errors) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => $operation_name, ':function_name' => $function_name)), i_base_error_messages::OPERATION_FAILURE);
- $failure->set_error($error);
- unset($error);
- }
- unset($found_errors);
-
- return $failure;
-}
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides a class for provided global defaults.
+ *
+ * This is not indended to be included by default and is not included by default.
+ *
+ * The purpose here is to grant project developers full control over defaults through a single file.
+ * All php source files in this project should be assumed to depend on this.
+ *
+ * However, no files in this project should include this file manually.
+ * Instead, the caller must include this in their index.php (or equivalent) before including any other files.
+ * This should grant the caller control over which file to select.
+ *
+ * It is recommended to set PHP precision setting to at least 16 for microtime values.
+ */
+
+
+/**
+ * A collection of global settings for use by the entire project.
+ *
+ * This is intended to be modified by the developers or site developers of a project.
+ *
+ * Warning: Any variables defined here (due to being global) must be considered not thread-safe.
+ * Be sure to handle carefully when using threads.
+ * It is recommended to process and pre-set as much of this as possible before starting threads.
+ */
+class c_base_defaults_global {
+ // set to NULL for auto, TRUE to always enable backtrace on error, and FALSE to always disable backtrace on error.
+ const ERROR_BACKTRACE_ALWAYS = NULL;
+
+ // set to NULL for auto, TRUE to enable backtrace for parameter-type errors, and FALSE to disable.
+ // this is overriden when ERROR_BACKTRACE_ALWAYS is not NULL.
+ const ERROR_BACKTRACE_ARGUMENTS = FALSE;
+
+ // provide a language to fallback to if none is set.
+ const LANGUAGE_CLASS_DEFAULT = 'c_base_languages_limited';
+
+ // reserved path groups: array(97, 99, 100, 102, 109, 115, 116, 120, 121).
+ const RESERVED_PATH_GROUP = array(c_base_ascii::LOWER_A, c_base_ascii::LOWER_C, c_base_ascii::LOWER_D, c_base_ascii::LOWER_F, c_base_ascii::LOWER_M, c_base_ascii::LOWER_S, c_base_ascii::LOWER_T, c_base_ascii::LOWER_U, c_base_ascii::LOWER_X);
+
+
+ // Represents the current timestamp of this PHP process/session, see: self::s_get_timestamp_session().
+ private static $s_timestamp_session = NULL;
+
+ // Represents the default timezone in use by this project.
+ // This value is not used for timestamps, instead, all timestamps are processed as UTC to prevent issues.
+ // When NULL, the default is assumed to be UTC.
+ private static $s_timezone = 'America/Chicago';
+
+ // Represents the default language class in use.
+ // This must be a class that implements: i_base_languages.
+ // In most cases, this should be expected to be defined.
+ private static $s_languages = NULL;
+
+
+ /**
+ * Set the default timezone.
+ *
+ * @param string $timezone
+ * The timezone string.
+ *
+ * @return c_base_return_status
+ * TRUE on success.
+ * FALSE with error bit set is returned on error.
+ */
+ public static function s_set_timezone($timezone) {
+ if (!($timezone instanceof i_base_languages)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'timezone', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ self::$s_timezone = $timezone;
+ return new c_base_return_true();
+ }
+
+ /**
+ * Set the default language.
+ *
+ * @param i_base_languages $languages
+ * Must be a class that implements i_base_languages.
+ *
+ * @return c_base_return_status
+ * TRUE on success.
+ * FALSE with error bit set is returned on error.
+ *
+ * @see: i_base_languages()
+ */
+ public static function s_set_languages($languages) {
+ if (!($languages instanceof i_base_languages)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'languages', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ self::$s_languages = $languages;
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get a date string, relative to UTC, with support for milliseconds and microseconds.
+ *
+ * Use this in place of date() to ensure consistent timestamps in UTC format, with microseconds.
+ *
+ * To support specific locales, strftime() should still be used.
+ *
+ * @param string $string
+ * The date string to get the timestamp of.
+ * @param int|float|null $timestamp
+ * (optional) If not NULL, a unix timestamp representing the timestamp to get the date string of.
+ * If NULL, the current session time is used.
+ * Timestamp is expected to be in UTC.
+ *
+ * @return c_base_return_string
+ * A date and time string in the format specified by $string.
+ * An empty string with the error bit set is returned on error.
+ *
+ * @see: date()
+ * @see: strftime()
+ */
+ public static function s_get_date($string, $timestamp = NULL) {
+ if (!is_string($string)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'string', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_value('', 'c_base_return_string', $error);
+ }
+
+ if (!is_null($timestamp) && !is_float($timestamp) && !is_int($timestamp)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'timestamp', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_value('', 'c_base_return_string', $error);
+ }
+
+ if (!is_null(self::$s_timezone)) {
+ date_default_timezone_set('UTC');
+ }
+
+ // To ensure support for microseconds (and milliseconds), datetime must be initialized woth microseconds.
+ if (is_null($timestamp)) {
+ $now = self::s_get_timestamp_session()->get_value_exact();
+ $microseconds = (int) (($now - ((int) $now)) * 1000000);
+
+ $date = new DateTime(date('Y/m/d h:i:s', (int) $now) . '.' . $microseconds . date(' P', (int) $now));
+ unset($now);
+ }
+ else {
+ if (is_float($timestamp)) {
+ $microseconds = (int) (($timestamp - ((int) $timestamp)) * 1000000);
+ }
+ else {
+ $microseconds = 0;
+ }
+
+ $date = new DateTime(date('Y/m/d h:i:s', (int) $timestamp) . '.' . $microseconds . date(' P', (int) $timestamp));
+ }
+ unset($microseconds);
+
+ if (!($date instanceof DateTime)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'date', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ return c_base_return_error::s_value('', 'c_base_return_string', $error);
+ }
+
+ if (!is_null(self::$s_timezone)) {
+ date_default_timezone_set(self::$s_timezone);
+ }
+
+ $formatted = $date->format($string);
+ if (!is_string($formatted)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'date->format', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ return c_base_return_error::s_value('', 'c_base_return_string', $error);
+ }
+
+ return c_base_return_string::s_new($formatted);
+ }
+
+ /**
+ * Get a timestamp, relative to UTC, with support for milliseconds and microseconds.
+ *
+ * Use this in place of strtotime() to ensure consistent timestamps in UTC format, with microseconds.
+ *
+ * @param string $string
+ * The time string to get the timestamp of (relative to $timestmap if specified).
+ * @param int|float|null $timestamp
+ * (optional) If not NULL, a unix timestamp representing the timestamp to get the date string of.
+ * If NULL, the current session time is used.
+ * Timestamp is expected to be in UTC.
+ *
+ * @return c_base_return_float
+ * A timestamp in floating format.
+ * 0.0 with error bit set is returned on error.
+ *
+ * @see: strtotime()
+ */
+ public static function s_get_timestamp($string, $timestamp = NULL) {
+ if (!is_string($string)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'string', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_value(0.0, 'c_base_return_float', $error);
+ }
+
+ if (!is_null($timestamp) && !is_float($timestamp) && !is_int($timestamp)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'timestamp', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_value(0.0, 'c_base_return_float', $error);
+ }
+
+ if (!is_null(self::$s_timezone)) {
+ date_default_timezone_set('UTC');
+ }
+
+ // To ensure support for microseconds (and milliseconds), datetime must be initialized woth microseconds.
+ if (is_null($timestamp)) {
+ $now = self::s_get_timestamp_session()->get_value_exact();
+ $microseconds = (int) (($now - ((int) $now)) * 1000000);
+
+ $date = new DateTime(date('Y/m/d h:i:s', (int) $now) . '.' . $microseconds . date(' P', (int) $now));
+ unset($now);
+ }
+ else {
+ if (is_float($timestamp)) {
+ $microseconds = (int) (($timestamp - ((int) $timestamp)) * 1000000);
+ }
+ else {
+ $microseconds = 0;
+ }
+
+ $date = new DateTime(date('Y/m/d h:i:s', (int) $timestamp) . '.' . $microseconds . date(' P', (int) $timestamp));
+ }
+ unset($microseconds);
+
+ if (!($date instanceof DateTime)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'date', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ return c_base_return_error::s_value(0.0, 'c_base_return_float', $error);
+ }
+
+ $resulting_timestamp = $date->getTimestamp();
+ if (!is_int($resulting_timestamp) && !is_float($resulting_timestamp)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'date->get_timestamp', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ return c_base_return_error::s_value(0.0, 'c_base_return_float', $error);
+ }
+
+ $resulting_timestamp = (float) $resulting_timestamp + (float) $date->format('0.u');
+
+ if (!is_null(self::$s_timezone)) {
+ date_default_timezone_set(self::$s_timezone);
+ }
+
+ return c_base_return_float::s_new($resulting_timestamp);
+ }
+
+ /**
+ * Get the current microtime, relative to UTC.
+ *
+ * @return float
+ * A timestamp in floating format.
+ */
+ public static function s_get_timestamp_current() {
+ if (is_null(self::$s_timezone)) {
+ // this assumes UTC, when timezone is NULL.
+ return c_base_return_float::s_new(microtime(TRUE));
+ }
+
+ date_default_timezone_set('UTC');
+
+ $now = microtime(TRUE);
+ date_default_timezone_set(self::$s_timezone);
+
+ return c_base_return_float::s_new($now);
+ }
+
+ /**
+ * Get the current timestamp of the session, relative to UTC.
+ *
+ * @param bool $use_request_time
+ * (optional) Set to TRUE to attempt to use REQUEST_TIME_FLOAT or REQUEST_TIME where available.
+ * Set to FALSE to use microtime()
+ * The REQUEST_TIME_FLOAT and REQUEST_TIME, the timestamp cannot be guaranteed to be relative to UTC.
+ * It is recommended to always set this to FALSE.
+ *
+ * @return float|int
+ * A timestamp in floating format (for higher precision), where possible.
+ * Otherwise a timestamp in integer format is returned.
+ */
+ public static function s_get_timestamp_session($use_request_time = FALSE) {
+ if (is_null(self::$s_timestamp_session)) {
+ if (isset($_SERVER['REQUEST_TIME_FLOAT']) && is_float($_SERVER['REQUEST_TIME_FLOAT'])) {
+ // find and process potentially useful additional environment variables.
+ if (array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) {
+ self::$s_timestamp_session = $_SERVER['REQUEST_TIME_FLOAT'];
+ }
+ elseif (array_key_exists('REQUEST_TIME', $_SERVER)) {
+ self::$s_timestamp_session = $_SERVER['REQUEST_TIME'];
+ }
+ }
+
+ if (is_null(self::$s_timestamp_session)) {
+ self::$s_timestamp_session = self::s_get_timestamp_current();
+ }
+ }
+
+ if (is_float(self::$s_timestamp_session)) {
+ return c_base_return_float::s_new(self::$s_timestamp_session);
+ }
+
+ return c_base_return_int::s_new(self::$s_timestamp_session);
+ }
+
+ /**
+ * Get the currently assigned language class.
+ *
+ * @return i_base_languages
+ * A class that implements i_base_languages.
+ *
+ * @see: i_base_languages
+ */
+ public static function s_get_languages() {
+ if (is_null(self::$s_languages)) {
+ $class = self::LANGUAGE_CLASS_DEFAULT;
+ self::$s_languages = new $class();
+ unset($class);
+ }
+
+ return self::$s_languages;
+ }
+
+ /**
+ * Get the name of the currently assigned language class.
+ *
+ * @return string
+ * A string representing the class of the language.
+ *
+ * @see: i_base_languages
+ */
+ public static function s_get_languages_class() {
+ if (is_null(self::$s_languages)) {
+ $class = self::LANGUAGE_CLASS_DEFAULT;
+ self::$s_languages = new $class();
+ return c_base_return_string::s_new($class);
+ }
+
+ $class = get_class($this->s_languages);
+ return c_base_return_string::s_new($class);
+ }
+}
+++ /dev/null
-<?php
-/**
- * @file
- * Provides reservation session functions.
- */
-require_once('common/base/classes/base_error.php');
-require_once('common/base/classes/base_return.php');
-require_once('common/base/classes/base_markup.php');
-require_once('common/base/classes/base_http.php');
-require_once('common/base/classes/base_ascii.php');
-require_once('common/base/classes/base_path.php');
-require_once('common/base/classes/base_mime.php');
-
-require_once('common/theme/classes/theme_html.php');
-
-require_once('program/reservation/reservation_database.php');
-require_once('program/reservation/reservation_session.php');
-
-class c_reservation_paths {
- // paths to common files (not url paths).
- private const PATH_LOGIN = 'program/reservation/paths/u/';
- private const PATH_LOGOUT = 'program/reservation/paths/u/';
- private const PATH_ACCESS_DENIED = 'program/reservation/internal/';
- private const PATH_NOT_FOUND = 'program/reservation/internal/';
- private const PATH_BAD_METHOD = 'program/reservation/internal/';
- private const PATH_SERVER_ERROR = 'program/reservation/internal/';
- private const PATH_OPTIONS_METHOD = 'program/reservation/internal/';
- private const PATH_REDIRECTS = 'program/reservation/';
- private const PATH_DASHBOARD_USER = 'program/reservation/paths/u/';
- private const PATH_DASHBOARD_MANAGEMENT = 'program/reservation/paths/m/';
- private const PATH_DASHBOARD_ADMINISTER = 'program/reservation/paths/a/';
-
- private const NAME_LOGIN = 'login';
- private const NAME_LOGOUT = 'logout';
- private const NAME_ACCESS_DENIED = 'access_denied';
- private const NAME_NOT_FOUND = 'not_found';
- private const NAME_BAD_METHOD = 'bad_method';
- private const NAME_SERVER_ERROR = 'server_error';
- private const NAME_OPTIONS_METHOD = 'options';
- private const NAME_REDIRECTS = 'reservation_redirects';
- private const NAME_DASHBOARD_USER = 'dashboard';
- private const NAME_DASHBOARD_MANAGEMENT = 'dashboard';
- private const NAME_DASHBOARD_ADMINISTER = 'dashboard';
-
- private const SCRIPT_EXTENSION = '.php';
-
- // a class name to prepend to css classes or id attributes.
- const CSS_BASE = 'reservation-';
-
- private $http = NULL;
- private $database = NULL;
- private $settings = NULL;
- private $session = NULL;
- private $output = NULL;
-
- private $paths = NULL;
- private $path = NULL;
-
- private $alias = NULL;
-
- /**
- * Class constructor.
- */
- public function __construct() {
- $this->http = NULL;
- $this->database = NULL;
- $this->settings = NULL;
- $this->session = NULL;
- $this->output = NULL;
-
- $this->paths = NULL;
- $this->path = NULL;
-
- $this->alias = NULL;
- }
-
- /**
- * Class destructor.
- */
- public function __destruct() {
- unset($this->http);
- unset($this->settings);
- unset($this->session);
- unset($this->output);
-
- unset($this->paths);
- unset($this->path);
-
- unset($this->alias);
- }
-
- /**
- * Process request path and determine what to do.
- *
- * @param c_base_http &$http
- * The HTTP settings.
- * @param c_base_database &database
- * The current database.
- * @param c_base_session &$session
- * The current session.
- * @param c_base_html &$html
- * The html page object.
- * @param array $settings
- * The system settings array.
- *
- * @return c_base_path_executed
- * The execution results.
- * The execution results with the error bit set on error.
- */
- public function reservation_process_path(&$http, &$database, &$session, $settings) {
- // @todo: these parameter errors might need a custom service unavailable and system log support.
- if (!($http instanceof c_base_http)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'http', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_value(array(), 'c_base_path_executed', $error);
- }
-
- if (!($database instanceof c_base_database)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'database', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_value(array(), 'c_base_path_executed', $error);
- }
-
- if (!($session instanceof c_base_session)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'session', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_value(array(), 'c_base_path_executed', $error);
- }
-
- if (!is_array($settings)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'settings', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_value(array(), 'c_base_path_executed', $error);
- }
-
- $this->http = &$http;
- $this->database = &$database;
- $this->settings = $settings;
- $this->session = &$session;
- $this->output = NULL;
-
- $this->p_get_language_alias();
-
- // require HTTPS for access to any part of this website.
- if (!isset($_SERVER["HTTPS"])) {
- // @todo: redirect to https version of requested uri.
- $failure_path = $this->p_get_path_not_found();
-
- return $failure_path->do_execute($this->http, $this->database, $this->session, $this->settings);
- }
-
-
- // load all available paths.
- $this->p_paths_create();
-
-
- // load the http method.
- $method = $this->http->get_request(c_base_http::REQUEST_METHOD)->get_value_exact();
- if (isset($method['data']) && is_int($method['data'])) {
- $method = $method['data'];
- }
- else {
- $method = c_base_http::HTTP_METHOD_NONE;
- }
-
-
- // find the path
- $path = $this->http->get_request_uri_relative($settings['base_path'])->get_value_exact();
- $handler_settings = $this->paths->find_path($path)->get_value();
- unset($path);
-
- if (!is_array($handler_settings)) {
- // for all invalid pages, report bad method if not HTTP GET or HTTP POST.
- if ($method !== c_base_http::HTTP_METHOD_GET && $method !== c_base_http::HTTP_METHOD_POST) {
- unset($method);
-
- $failure_path = $this->p_get_path_bad_method();
-
- return $failure_path->do_execute($this->http, $this->database, $this->session, $this->settings);
- }
- unset($method);
-
- $not_found = $this->p_get_path_not_found();
- return $not_found->do_execute($this->http, $this->database, $this->session, $this->settings);
- }
-
- // validate allowed methods.
- if (isset($handler_settings['methods']) && is_array($handler_settings['methods'])) {
- if (!array_key_exists($method, $handler_settings['methods'])) {
- unset($method);
-
- $failure_path = $this->p_get_path_bad_method();
-
- return $failure_path->do_execute($this->http, $this->database, $this->session, $this->settings);
- }
- }
-
-
- // HTTP OPTIONS method does not process the page, only returns available methods.
- if ($method === c_base_http::HTTP_METHOD_OPTIONS) {
- unset($method);
-
- $options_method_path = $this->p_get_path_options_method();
-
- if (isset($handler_settings['methods']) && is_array($handler_settings['methods'])) {
- $options_method_path->set_allowed_methods($handler_settings['methods']);
- }
- else {
- $options_method_path->set_allowed_methods(array());
- }
-
- return $options_method_path->do_execute($this->http, $this->database, $this->session, $this->settings);
- }
-
-
- if (array_key_exists('redirect', $handler_settings)) {
- unset($method);
-
- // successfully logged in.
- require_once(self::PATH_REDIRECTS . self::NAME_REDIRECTS . self::SCRIPT_EXTENSION);
-
- if (!is_string($handler_settings['redirect'])) {
- $handler_settings['redirect'] = '';
- }
-
- if (!isset($handler_settings['code']) || !is_int($handler_settings['code'])) {
- $handler_settings['code'] = c_base_http_status::MOVED_PERMANENTLY;
- }
-
- $redirect = c_reservation_path_redirect::s_create_redirect($handler_settings['redirect'], $handler_settings['code'], FALSE);
- return $redirect->do_execute($this->http, $this->database, $this->session, $this->settings);
- }
- else {
- if (!empty($handler_settings['include_name']) && is_string($handler_settings['include_name'])) {
- require_once($handler_settings['include_directory'] . $handler_settings['include_name'] . self::SCRIPT_EXTENSION);
- }
-
- // execute path handler, using custom-language if defined.
- if (empty($handler_settings['handler'])) {
- return $this->p_get_path_server_error()->do_execute($this->http, $this->database, $this->session, $this->settings);
- }
- elseif (is_string($this->alias)) {
- @include_once($handler_settings['include_directory'] . $this->alias . '/' . $handler_settings['include_name']);
-
- $handler_class = $handler_settings['handler'] . '_' . $this->alias;
- if (class_exists($handler_class)) {
- $this->path = new $handler_class();
-
- unset($handler_class);
- }
- else {
- unset($handler_class);
-
- // attempt to fallback to default handler if the language-specific handler class is not found.
- if (!class_exists($handler_settings['handler'])) {
- return $this->p_get_path_server_error()->do_execute($this->http, $this->database, $this->session, $this->settings);
- }
- else {
- $this->path = new $handler_settings['handler']();
- }
- }
- }
- else {
- if (class_exists($handler_settings['handler'])) {
- $this->path = new $handler_settings['handler']();
- }
- else {
- return $this->p_get_path_server_error()->do_execute($this->http, $this->database, $this->session, $this->settings);
- }
- }
-
- if (isset($handler_settings['is_root']) && $handler_settings['is_root']) {
- $this->path->is_root(TRUE);
- }
- }
- unset($handler_settings);
-
- return $this->p_paths_normal($method);
- }
-
- /**
- * Creates and returns a list of all available paths.
- *
- * Add/modify paths here as desired.
- *
- * @return c_base_paths
- * The generated paths object.
- */
- private function p_paths_create() {
- $this->paths = new c_base_paths();
-
- // set root path to be the user dashboard.
- $this->paths->set_path('', 'c_reservation_path_user_dashboard', self::PATH_DASHBOARD_USER, self::NAME_DASHBOARD_USER);
-
- // create login/logout paths
- $this->paths->set_path('/u/login', 'c_reservation_path_user_login', self::PATH_LOGIN, self::NAME_LOGIN);
- $this->paths->set_path('/u/logout', 'c_reservation_path_user_logout', self::PATH_LOGOUT, self::NAME_LOGOUT);
-
- // dashboards
- $this->paths->set_path('/u/dashboard', 'c_reservation_path_user_dashboard', self::PATH_DASHBOARD_USER, self::NAME_DASHBOARD_USER);
- #$this->paths->set_path('/m/dashboard', 'c_reservation_path_management_dashboard', self::PATH_DASHBOARD_MANAGEMENT, self::NAME_DASHBOARD_MANAGEMENT);
- #$this->paths->set_path('/a/dashboard', 'c_reservation_path_administer_dashboard', self::PATH_DASHBOARD_ADMINISTER, self::NAME_DASHBOARD_ADMINISTER);
- }
-
- /**
- * Process request paths and determine what to do.
- *
- * @param int $method
- * The id of the HTTP request method.
- *
- * @return c_base_path_executed
- * The execution results.
- * The execution results with the error bit set on error.
- */
- private function p_paths_normal($method) {
- $id_group = $this->path->get_id_group()->get_value_exact();
-
- // regardless of path-specific settings, the following paths always require login credentials to access.
- if ($id_group === c_base_ascii::LOWER_A || $id_group === c_base_ascii::LOWER_M || $id_group === c_base_ascii::LOWER_U) {
- $this->path->is_private(TRUE);
- }
-
- if ($this->path instanceof c_reservation_path_user_login) {
- unset($id_group);
- return $this->path->do_execute($this->http, $this->database, $this->session, $this->settings);
- }
- elseif ($this->path instanceof c_reservation_path_user_logout) {
- // if the user is not logged in. then provide a page not found for logout path.
- if (!$this->session->get_logged_in()->get_value_exact()) {
- return $this->p_get_path_not_found()->do_execute($this->http, $this->database, $this->session, $this->settings);
- }
- }
- elseif ($this->path instanceof c_reservation_path_user_dashboard && $id_group === 0) {
- // the user dashboard is setup as the site root.
- // when path is root, there is no id_group, so explicitly assign the group.
- $id_group = c_base_ascii::LOWER_U;
-
- // @todo: do this for other dashboards as well (manager, and administer).
- }
-
-
- // if the request is private, make sure the user is logged in.
- if ($id_group === c_base_ascii::LOWER_A || $id_group === c_base_ascii::LOWER_M || $id_group === c_base_ascii::LOWER_U || $this->path->is_private()->get_value_exact()) {
- if ($this->session->get_logged_in()->get_value_exact()) {
- unset($id_group);
- return $this->path->do_execute($this->http, $this->database, $this->session, $this->settings);
- }
- elseif ($this->path->is_root()->get_value_exact()) {
- unset($id_group);
-
- $this->http->set_response_status(c_base_http_status::FORBIDDEN);
-
- $login_path = $this->p_get_path_login();
- return $login_path->do_execute($this->http, $this->database, $this->session, $this->settings);
- }
- else {
- // some special case paths always provide login prompt along with access denied.
- if ($id_group === c_base_ascii::LOWER_A || $id_group === c_base_ascii::LOWER_M || $id_group === c_base_ascii::LOWER_U) {
- unset($id_group);
-
- $this->http->set_response_status(c_base_http_status::FORBIDDEN);
-
- $login_path = $this->p_get_path_login();
- return $login_path->do_execute($this->http, $this->database, $this->session, $this->settings);
- }
- }
- }
- else {
- unset($id_group);
- return $this->path->do_execute($this->http, $this->database, $this->session, $this->settings);
- }
-
- // return access denied or page not found depending on path and privacy settings.
- if ($id_group === c_base_ascii::LOWER_C || $id_group === c_base_ascii::LOWER_D || $id_group === c_base_ascii::LOWER_T || $id_group === c_base_ascii::LOWER_X || $id_group === c_base_ascii::LOWER_F) {
- // these always return not found for these paths.
- $failsafe_path = $this->p_get_path_not_found();
- }
- elseif ($this->path->is_private()->get_value_exact() && $id_group !== c_base_ascii::NULL) {
- // non private, and non-special case paths should return access denied as per normal behavior.
- $failsafe_path = $this->p_get_path_access_denied();
- }
- else {
- // all other case, return not found.
- $failsafe_path = $this->p_get_path_not_found();
- }
- unset($id_group);
-
- return $failsafe_path->do_execute($this->http, $this->database, $this->session, $this->settings);
- }
-
- /**
- * Process request path form paths and determine what to do.
- *
- * @return c_base_path_executed
- * The execution results.
- * The execution results with the error bit set on error.
- */
- private function p_paths_forms() {
- // @todo
-
- // always return not found, do not inform user if the access is denied.
- $failsafe_path = $this->p_get_path_not_found();
-
- return $failsafe_path->do_execute($this->http, $this->database, $this->session, $this->settings);
- }
-
- /**
- * Process request path ajax paths and determine what to do.
- *
- * @return c_base_path_executed
- * The execution results.
- * The execution results with the error bit set on error.
- */
- private function p_paths_ajax() {
- // @todo
-
- // always return not found, do not inform user if the access is denied.
- $failsafe_path = $this->p_get_path_not_found();
-
- return $failsafe_path->do_execute($this->http, $this->database, $this->session, $this->settings);
- }
-
- /**
- * Load and return the login path.
- */
- private function p_get_path_login() {
- return $this->p_include_path(self::PATH_LOGIN, self::NAME_LOGIN, 'c_reservation_path_user_login');
- }
-
- /**
- * Load and return the logout path.
- */
- private function p_get_path_logout() {
- return $this->p_include_path(self::PATH_LOGOUT, self::NAME_LOGOUT, 'c_reservation_path_user_logout');
- }
-
- /**
- * Load and return the access denied path.
- */
- private function p_get_path_access_denied() {
- return $this->p_include_path(self::PATH_ACCESS_DENIED, self::NAME_ACCESS_DENIED, 'c_reservation_path_access_denied');
- }
-
- /**
- * Load and return the not found path.
- */
- private function p_get_path_not_found() {
- return $this->p_include_path(self::PATH_NOT_FOUND, self::NAME_NOT_FOUND, 'c_reservation_path_not_found');
- }
-
- /**
- * Load and return the not found path.
- */
- private function p_get_path_bad_method() {
- return $this->p_include_path(self::PATH_BAD_METHOD, self::NAME_BAD_METHOD, 'c_reservation_path_bad_method');
- }
-
- /**
- * Load and return the internal server error path.
- */
- private function p_get_path_server_error() {
- return $this->p_include_path(self::PATH_SERVER_ERROR, self::NAME_SERVER_ERROR, 'c_reservation_path_server_error');
- }
-
- /**
- * Load and return the internal server error path.
- */
- private function p_get_path_options_method() {
- return $this->p_include_path(self::PATH_OPTIONS_METHOD, self::NAME_OPTIONS_METHOD, 'c_reservation_path_options_method');
- }
-
- /**
- * Load and save the current preferred language alias.
- *
- * This will be stored in $this->alias.
- */
- private function p_get_language_alias() {
- $aliases = array();
- $languages = $this->http->get_response_content_language()->get_value_exact();
- if (is_array($languages) && !empty($languages)) {
- $language = reset($languages);
-
- // us-english is the default, so do not attempt to include any external files.
- if ($language == i_base_language::ENGLISH_US || $language == i_base_language::ENGLISH) {
- unset($language);
- unset($aliases);
- unset($languages);
-
- $this->alias = NULL;
- return;
- }
-
- $aliases = c_base_defaults_global::s_get_languages()::s_get_aliases_by_id($language)->get_value_exact();
- }
- unset($language);
-
- // use default if no aliases are found.
- if (empty($aliases)) {
- unset($aliases);
- unset($languages);
-
- $this->alias = NULL;
- return;
- }
-
- $this->alias = end($aliases);
- }
-
- /**
- * Will include a custom language path if one exists.
- *
- * The default language files ends in "${path}${name}.php".
- * All other language files end in "${path}${language_alias}/${name}.php".
- *
- * The default class is the provided class name.
- * All other languages use the provided class name with '_${language_alias}' appended.
- *
- * For example (using path='my_file'), us english is the default, so that would load the file 'my_file.php'.
- * japanese language load the file 'my_file-ja.php'.
- *
- * @param string $path
- * The path to the include file, without the file name.
- * @param string $name
- * The file name of the PHP file, without the '.php' extension.
- * @param string $class
- * The name of the class, that is an instance of c_base_path, to execute.
- *
- * @return c_base_path
- * The created c_base_path object.
- */
- private function p_include_path($path, $name, $class) {
- require_once($path . $name . self::SCRIPT_EXTENSION);
-
- // use default if no aliases are found.
- if (is_null($this->alias)) {
- return new $class();
- }
-
- // use include_once instead of require_require to allow for failsafe behavior.
- @include_once($path . $this->alias . '/' . $name . self::SCRIPT_EXTENSION);
-
- $language_class = $class . '_' . $this->alias;
- if (class_exists($language_class)) {
- return new $language_class();
- }
- unset($language_class);
-
- // if unable to find, fallback to original class
- return new $class();
- }
-}
-
-/**
- * Provides reservation-specific path functionality.
- */
-class c_reservation_path extends c_base_path {
- protected $use_p_tags = NULL;
- protected $base_path = NULL;
- protected $user_name = NULL;
-
-
- /**
- * Class constructor.
- */
- public function __construct() {
- parent::__construct();
-
- $this->use_p_tags = FALSE;
- $this->base_path = '';
- $this->user_name = '';
- }
-
- /**
- * Class destructor.
- */
- public function __destruct() {
- unset($this->use_p_tags);
- unset($this->base_path);
- unset($this->user_name);
-
- parent::__destruct();
- }
-
- /**
- * Load any default settings.
- *
- * Very validation is performed.
- *
- * @param array $settings
- * The array containing all of the settings to parse.
- */
- protected function pr_assign_defaults($settings) {
- if (isset($settings['standard_issue-use_p_tags']) && is_bool($settings['standard_issue-use_p_tags'])) {
- $this->use_p_tags = $settings['standard_issue-use_p_tags'];
- }
-
- if (isset($settings['base_path']) && is_string($settings['base_path'])) {
- $this->base_path = $settings['base_path'];
- }
-
- if (isset($settings['database_user']) && is_string($settings['database_user'])) {
- $this->user_name = $settings['database_user'];
- }
- }
-
- /**
- * Creates the standard wrapper.
- *
- * @return c_base_markup_tag
- * The generated markup tag.
- */
- protected function pr_create_tag_wrapper() {
- return c_theme_html::s_create_tag(c_base_markup_tag::TYPE_SECTION, c_reservation_paths::CSS_BASE . c_reservation_paths::CSS_BASE . 'content-wrapper', array(c_reservation_paths::CSS_BASE . 'content-wrapper', 'content-wrapper'));
- }
-
- /**
- * Creates the standard break tag.
- *
- * @return c_base_markup_tag
- * The generated markup tag.
- */
- protected function pr_create_tag_break() {
- return c_theme_html::s_create_tag(c_base_markup_tag::TYPE_BREAK);
- }
-
- /**
- * Creates the standard title.
- *
- * @param int|string $text
- * The text or the text code to use.
- * @param array $arguments
- * (optional) An array of arguments to convert into text.
- *
- * @return c_base_markup_tag
- * The generated markup tag.
- */
- protected function pr_create_tag_title($text, $arguments = array()) {
- if (is_int($text)) {
- return c_theme_html::s_create_tag(c_base_markup_tag::TYPE_H1, NULL, array('as-title'), $this->pr_get_text($text, $arguments));
- }
-
- return c_theme_html::s_create_tag(c_base_markup_tag::TYPE_H1, NULL, array('as-title'), $text);
- }
-
- /**
- * Creates the standard text.
- *
- * @param int|string $text
- * The text or the text code to use.
- * @param array $arguments
- * (optional) An array of arguments to convert into text.
- *
- * @return c_base_markup_tag
- * The generated markup tag.
- */
- protected function pr_create_tag_text($text, $arguments = array()) {
- $type = c_base_markup_tag::TYPE_SPAN;
- if ($this->use_p_tags) {
- $type = c_base_markup_tag::TYPE_PARAGRAPH;
- }
-
- if (is_int($text)) {
- return c_theme_html::s_create_tag($type, NULL, array('as-text'), $this->pr_get_text($text, $arguments));
- }
-
- return c_theme_html::s_create_tag($type, NULL, array('as-text'), $text);
- }
-
- /**
- * Creates the standard paragraph.
- *
- * @param int|string $text
- * The text or the text code to use.
- * @param array $arguments
- * (optional) An array of arguments to convert into text.
- *
- * @return c_base_markup_tag
- * The generated markup tag.
- */
- protected function pr_create_tag_paragraph($text, $arguments = array()) {
- $type = c_base_markup_tag::TYPE_SPAN;
- if ($this->use_p_tags) {
- $type = c_base_markup_tag::TYPE_PARAGRAPH;
- }
-
- if (is_int($text)) {
- return c_theme_html::s_create_tag($type, NULL, array('as-paragraph'), $this->pr_get_text($text, $arguments));
- }
-
- return c_theme_html::s_create_tag($type, NULL, array('as-paragraph'), $text);
- }
-
- /**
- * Creates the standard text, wrapped in a block.
- *
- * @param int|string|null $text
- * The text or the text code to use.
- * If NULL, only the block is created.
- * @param array $arguments
- * (optional) An array of arguments to convert into text.
- *
- * @return c_base_markup_tag
- * The generated markup tag.
- */
- protected function pr_create_tag_text_block($text, $arguments = array()) {
- $block = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, NULL, array('as-text-block'));
-
- if (!is_null($text)) {
- $type = c_base_markup_tag::TYPE_SPAN;
- if ($this->use_p_tags) {
- $type = c_base_markup_tag::TYPE_PARAGRAPH;
- }
-
- if (is_int($text)) {
- $tag = c_theme_html::s_create_tag($type, NULL, array('as-text'), $this->pr_get_text($text, $arguments));
- }
- else {
- $tag = c_theme_html::s_create_tag($type, NULL, array('as-text'), $text);
- }
- unset($type);
-
- $block->set_tag($tag);
- unset($tag);
- }
-
- return $block;
- }
-
- /**
- * Creates the standard text, wrapped in a block.
- *
- * @param int|string|null $text
- * The text or the text code to use.
- * If NULL, only the block is created.
- * @param array $arguments
- * (optional) An array of arguments to convert into text.
- *
- * @return c_base_markup_tag
- * The generated markup tag.
- */
- protected function pr_create_tag_paragraph_block($text, $arguments = array()) {
- $block = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, NULL, array('as-paragraph-block'));
-
- if (!is_null($text)) {
- $type = c_base_markup_tag::TYPE_SPAN;
- if ($this->use_p_tags) {
- $type = c_base_markup_tag::TYPE_PARAGRAPH;
- }
-
- if (is_int($text)) {
- $tag = c_theme_html::s_create_tag($type, NULL, array('as-paragraph'), $this->pr_get_text($text, $arguments));
- }
- else {
- $tag = c_theme_html::s_create_tag($type, NULL, array('as-paragraph'), $text);
- }
- unset($type);
-
- $block->set_tag($tag);
- unset($tag);
- }
-
- return $block;
- }
-
- /**
- * Load the title text associated with this page.
- *
- * This is provided here as a means for a language class to override with a custom language for the title.
- *
- * @param array $arguments
- * (optional) An array of arguments to convert into text.
- *
- * @return string|null
- * A string is returned as the custom title.
- * NULL is returned to enforce default title.
- */
- protected function pr_get_title($arguments = array()) {
- return NULL;
- }
-
- /**
- * Load text for a supported language.
- *
- * @param int $index
- * A number representing which block of text to return.
- * @param array $arguments
- * (optional) An array of arguments to convert into text.
- */
- protected function pr_get_text($code, $arguments = array()) {
- return '';
- }
-
- /**
- * Create a new HTML markup class with default settings populated.
- *
- * @param c_base_http $http
- * The entire HTTP information to allow for the execution to access anything that is necessary.
- * @param c_base_database $database
- * The database object, which is usually used by form and ajax paths.
- * @param c_base_session &$session
- * The current session.
- * @param array $settings
- * An array of additional settings that are usually site-specific.
- *
- * @return c_base_html
- * The generated html is returned on success.
- * The generated html with error bit set is returned on error.
- */
- protected function pr_create_html(&$http, &$database, &$session, $settings) {
- $title = $this->pr_get_title();
-
- $html = new c_base_html();
-
-
- // assign class attributes
- $class = array(
- 'reservation',
- 'javascript-disabled',
- 'is-html5',
- );
-
- // add date/time classes.
- $instance = c_base_defaults_global::s_get_timestamp_session()->get_value_exact();
- $class[] = 'date-year-' . $html->sanitize_css(date('Y', $instance))->get_value_exact();
- $class[] = 'date-month-' . $html->sanitize_css(strtolower(date('F', $instance)))->get_value_exact();
- $class[] = 'date-week_day-' . $html->sanitize_css(strtolower(date('l', $instance)))->get_value_exact();
- $class[] = 'date-day-' . $html->sanitize_css(date('d', $instance))->get_value_exact();
- $class[] = 'time-hour-' . $html->sanitize_css(date('H', $instance))->get_value_exact();
- $class[] = 'time-minute-' . $html->sanitize_css(date('m', $instance))->get_value_exact();
- $class[] = 'time-second-' . $html->sanitize_css(date('s', $instance))->get_value_exact();
- unset($instance);
-
- // add path classes
- $path = $http->get_request_uri_relative($settings['base_path'])->get_value_exact();
- $path_parts = explode('/', $path);
-
- if (is_array($path_parts)) {
- $sanitized = NULL;
- $delta = 0;
- foreach ($path_parts as $path_part) {
- $sanitized_part = $html->sanitize_css($path_part, TRUE)->get_value_exact();
- $sanitized .= '-' . $sanitized_part;
-
- $class[] = 'path-part-' . $delta . '-' . $html->sanitize_css($sanitized_part)->get_value_exact();
- $delta++;
- }
- unset($path_part);
- unset($sanitized_part);
-
- $class[] = 'path-full-' . $html->sanitize_css(substr($sanitized, 1))->get_value_exact();
- unset($sanitized);
- }
- unset($path_parts);
-
- $html->set_attribute_body(c_base_markup_attributes::ATTRIBUTE_CLASS, $class);
- unset($class);
-
-
- // assign id attribute
- $html->set_attribute(c_base_markup_attributes::ATTRIBUTE_ID, 'reservation-system');
- $html->set_attribute_body(c_base_markup_attributes::ATTRIBUTE_ID, 'reservation-system-body');
-
-
- // assign language attribute.
- $language = i_base_language::ENGLISH_US;
- $languages = $http->get_response_content_language()->get_value_exact();
- if (is_array($languages) && !empty($languages)) {
- $language = reset($languages);
- }
-
- $html->set_attribute(c_base_markup_attributes::ATTRIBUTE_LANGUAGE, $language);
- unset($language);
-
-
- // assign default direction attribute
- $html->set_attribute(c_base_markup_attributes::ATTRIBUTE_DIRECTION, 'ltr');
-
-
- // assign title header tag (setting title tag at delta 0 so that it can easily be overriden as needed).
- $tag = new c_base_markup_tag();
- $tag->set_type(c_base_markup_tag::TYPE_TITLE);
-
- if (is_string($title)) {
- $tag->set_text($title);
- }
- else {
- $tag->set_text('Reservation System');
- }
-
- $html->set_header($tag, 0);
- unset($tag);
-
-
- // assign base header tag
- if (isset($this->settings['base_path']) && is_string($this->settings['base_path']) && mb_strlen($this->settings['base_scheme']) > 0) {
- $href = '';
- if (isset($this->settings['base_scheme']) && is_string($this->settings['base_scheme']) && mb_strlen($this->settings['base_scheme']) > 0) {
- if (isset($this->settings['base_host']) && is_string($this->settings['base_host']) && mb_strlen($this->settings['base_host']) > 0) {
- $href .= $this->settings['base_scheme'] . '://' . $this->settings['base_host'];
- }
- }
-
- $href .= $this->settings['base_path'];
-
- $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_BASE);
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $href);
- $html->set_header($tag);
- unset($tag);
- unset($href);
- }
-
-
- // assign http-equiv header tag
- $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HTTP_EQUIV, 'Content-Type');
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, 'text/html; charset=utf-8');
- $html->set_header($tag);
- unset($tag);
-
-
- // assign charset header tag
- $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CHARACTER_SET, c_base_charset::UTF_8);
- $html->set_header($tag);
- unset($tag);
-
-
- // assign canonical header tag
- #$tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
- #$tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical');
- #$tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, 'http://localhost/');
- #$html->set_header($tag);
- #unset($tag);
-
-
- // assign shortlink header tag
- #$tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
- #$tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'shortlink');
- #$tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, '/');
- #$html->set_header($tag);
- #unset($tag);
-
-
- // assign description header tag
- $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_NAME, 'description');
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, 'A reservation/scheduling system.');
- $html->set_header($tag);
- unset($tag);
-
-
- // assign distribution header tag
- $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_NAME, 'distribution');
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, 'web');
- $html->set_header($tag);
- unset($tag);
-
-
- // assign robots header tag
- $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_NAME, 'robots');
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, 'INDEX,FOLLOW');
- $html->set_header($tag);
- unset($tag);
-
-
- // assign expires header tag
- #$tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
- #$tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HTTP_EQUIV, 'expires');
- #$tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, c_base_defaults_global::s_get_date('r', strtotime('+30 minutes'))->get_value_exact());
- #$html->set_header($tag);
- #unset($tag);
-
-
- // assign viewport header tag
- $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_NAME, 'viewport');
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, 'width=device-width, initial-scale=1');
- $html->set_header($tag);
- unset($tag);
-
-
- // assign content http-equiv header tag
- $aliases = array();
- if (is_array($languages) && !empty($languages)) {
- // assign the primary language.
- $language_aliases = c_base_defaults_global::s_get_languages()::s_get_aliases_by_id(reset($languages))->get_value_exact();
- if (is_array($language_aliases) && !empty($language_aliases)) {
- $html->set_attribute(c_base_markup_attributes::ATTRIBUTE_LANGUAGE, reset($language_aliases));
- }
- unset($language_aliases);
-
- foreach ($languages as $language) {
- $language_aliases = c_base_defaults_global::s_get_languages()::s_get_aliases_by_id($language)->get_value_exact();
- if (is_array($language_aliases) && !empty($language_aliases)) {
- $aliases[] = array_pop($language_aliases);
- }
- unset($language_aliases);
- }
- unset($language);
- }
- unset($languages);
-
- if (!empty($aliases)) {
- $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META);
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HTTP_EQUIV, 'content-language');
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, implode(', ', $aliases));
- $html->set_header($tag);
- unset($tag);
- }
- unset($aliases);
-
-
- // provide a custom javascript for detecting if javascript is enabled and storing in a css class name.
- $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_SCRIPT);
- $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_TYPE, c_base_mime::TYPE_TEXT_JS);
-
- $javascript = 'function f_reservation_hmtl_javascript_detection() {';
- $javascript .= 'document.body.removeAttribute(\'onLoad\');';
- $javascript .= 'document.body.className = document.body.className.replace(/\bjavascript-disabled\b/i, \'javascript-enabled\');';
- $javascript .= '}';
- $tag->set_text($javascript);
- unset($javascript);
-
- $html->set_header($tag);
- $html->set_attribute_body(c_base_markup_attributes::ATTRIBUTE_ON_LOAD, 'f_reservation_hmtl_javascript_detection();');
- unset($tag);
-
- return $html;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * @file
- * Provides reservation redirect classes.
- */
-require_once('common/base/classes/base_error.php');
-require_once('common/base/classes/base_return.php');
-require_once('common/base/classes/base_path.php');
-require_once('common/base/classes/base_http.php');
-require_once('common/base/classes/base_http_status.php');
-
-require_once('common/theme/classes/theme_html.php');
-
-/**
- * Handles redirects to a specified destination.
- */
-final class c_reservation_path_redirect extends c_base_path {
- const PREFIX_ID = '';
- const PREFIX_CLASS = 'reservation-';
-
- /**
- * Create a redirect path.
- *
- * Defaults are silently forced on invalid parameters.
- *
- * @param string $field_destination
- * A destination URL to redirect to.
- * @param int $response_code
- * The HTTP code to use when performing the redirect.
- * Should be one of 3xx error code integers.
- * @param int $field_response_code
- * The redirect response code.
- * Should be a 3xx url code.
- * Usually one of:
- * - 300 (Multiple Choices):
- * - 301 (Moved Permanently):
- * - 303 (See Other):
- * This is not assigned on parameter error.
- * @param bool $is_private
- * (optional) When TRUE, path is considered private and requires specific access privileges.
- * When FALSE, the path is accessible without any access privileges.
- * Default setting is assigned on parameter error.
- *
- * @return c_base_markup_tag|c_base_return_status
- * A newly created tag is returned on success.
- * FALSE with the error bit set is returned on error.
- */
- public static function s_create_redirect($field_destination, $field_response_code, $is_private = TRUE) {
- $class = __CLASS__;
- $path = new $class();
- unset($class);
-
- // @todo: store all errors on return.
- $errors = array();
-
- if (is_string($field_destination) || is_array($field_destination)) {
- $path->set_field_destination($field_destination);
- }
-
- if (is_int($field_response_code)) {
- $path->set_field_response_code($field_response_code);
- }
-
- if (is_bool($is_private)) {
- $path->is_private($is_private);
- }
- else {
- $path->is_private(TRUE);
- }
-
- $path->is_redirect(TRUE);
-
- $timestamp_session = c_base_defaults_global::s_get_timestamp_session();
- $path->set_date_created($timestamp_session);
- $path->set_date_changed($timestamp_session);
- unset($timestamp_session);
-
- return $path;
- }
-
- /**
- * Implements do_execute().
- */
- public function do_execute(&$http, &$database, &$session, $settings = array()) {
- // the parent function performs validation on the parameters.
- $executed = parent::do_execute($http, $database, $session, $settings);
- if (c_base_return::s_has_error($executed)) {
- return $executed;
- }
-
- $http->set_response_location($this->field_destination);
- $http->set_response_status($this->field_response_code);
-
- return $executed;
- }
-}
+++ /dev/null
-<?php
-/**
- * @file
- * Provides reservation session functions.
- */
-require_once('common/base/classes/base_error.php');
-require_once('common/base/classes/base_return.php');
-require_once('common/base/classes/base_http.php');
-require_once('common/base/classes/base_session.php');
-require_once('common/base/classes/base_cookie.php');
-
-require_once('program/reservation/reservation_database.php');
-
-
-/**
- * Process session information.
- *
- * @param c_base_http &$http
- * Http object.
- * @param array &$settings
- * System settings.
- *
- * @param c_base_session
- * Session information is returned on success.
- * Session information with error bit set is returned on error.
- */
-function reservation_process_sessions(&$http, &$settings) {
- $cookie_login = $http->get_request(c_base_http::REQUEST_COOKIE, $settings['cookie_name']);
-
- $no_session = FALSE;
- if (!($cookie_login instanceof c_base_cookie)) {
- $cookie_login = new c_base_cookie();
-
- $no_session = TRUE;
- }
-
- // create a session object regardless of login session cookie.
- $session = new c_base_session();
- $session->set_socket_directory($settings['session_socket']);
- $session->set_system_name($settings['session_system']);
-
- // the requester should not have any control over specifying/changing these settings, so overwrite whatever is defined by the request cookie.
- $cookie_login->set_name($settings['cookie_name']);
- $cookie_login->set_path($settings['cookie_path']);
- $cookie_login->set_domain($settings['cookie_domain']);
- $cookie_login->set_http_only($settings['cookie_http_only']);
- $cookie_login->set_host_only($settings['cookie_host_only']);
- $cookie_login->set_same_site($settings['cookie_same_site']);
- $cookie_login->set_secure(TRUE);
-
- if (empty($_SERVER['REMOTE_ADDR'])) {
- $session->set_host('0.0.0.0');
- }
- else {
- $session->set_host($_SERVER['REMOTE_ADDR']);
- }
-
- // no session cookie has been defined, so there is no existing session to load.
- if ($no_session) {
- $session->set_cookie($cookie_login);
- unset($cookie_login);
- unset($no_session);
-
- $error = c_base_error::s_log(NULL, array('arguments' => array(':session_name' => $settings['cookie_name'], ':function_name' => __FUNCTION__)), i_base_error_messages::NO_SESSION);
- $session->set_error($error);
- unset($error);
-
- return $session;
- }
- unset($no_session);
-
- $cookie_data = $cookie_login->get_value_exact();
- if (!($cookie_login->validate() instanceof c_base_return_true) || empty($cookie_data['session_id'])) {
- $session->set_cookie($cookie_login);
- unset($cookie_login);
-
- // cookie_login failed validation or the cookie contains no session id.
- $error = c_base_error::s_log(NULL, array('arguments' => array(':session_name' => $settings['cookie_name'], ':function_name' => __FUNCTION__)), i_base_error_messages::SESSION_INVALID);
- $session->set_error($error);
- unset($error);
-
- return $session;
- }
-
- $session->set_session_id($cookie_data['session_id']);
-
-
- // connect to the session using the given session id.
- $session_connection = $session->do_connect();
- if (c_base_return::s_has_error($session_connection)) {
- $session->set_cookie($cookie_login);
- unset($cookie_login);
-
- $session->set_error($session_connection->get_error());
- unset($error);
-
- return $session;
- }
-
- $result = $session->do_pull();
- $session->do_disconnect();
-
- if ($result instanceof c_base_return_true) {
- $user_name = $session->get_name()->get_value();
- $password = $session->get_password()->get_value();
-
- if (is_string($user_name) && is_string($password)) {
- $settings['database_user'] = $user_name;
- $settings['database_password'] = $password;
- }
-
- $session->set_logged_in(TRUE);
- }
-
-
- // check to see if the session timeout has been extended and if so, then update the cookie.
- $session_expire = $session->get_timeout_expire()->get_value_exact();
- $session_seconds = $session_expire - time();
- if ($session_seconds == 0) {
- $session_seconds = -1;
- }
-
- if ($session_expire > $cookie_data['expire']) {
- $cookie_data['expire'] = gmdate("D, d-M-Y H:i:s T", $session_expire);
- $cookie_login->set_value($cookie_data);
- $cookie_login->set_expires($session_expire);
- }
-
- $session->set_cookie($cookie_login);
- unset($cookie_login);
-
- return $session;
-}
-
-/**
- * Attempt to auto-create a postgresql account.
- *
- * @param array $settings
- * System settings.
- * @param string $username
- * The name of the postgresql account to auto-create.
- *
- * @return c_base_return_int|c_base_return_status
- * An integer is returned, whose codes represent the transaction result.
- * FALSE with error bit set is returned on error.
- */
-function reservation_ensure_user_account($settings, $user_name) {
- if (!is_array($settings)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'settings', ':function_name' => __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- if (!is_string($user_name)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'user_name', ':function_name' => __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- $socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
- if (!is_resource($socket)) {
- unset($socket);
-
- $socket_error = @socket_last_error();
- @socket_clear_error();
-
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_create', ':socket_error' => $socket_error, ':socket_error_message' => @socket_strerror($socket_error), ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
- unset($socket_error);
-
- return c_base_return_error::s_false($error);
- }
-
- $connected = @socket_connect($socket, $settings['database_create_account_host'], $settings['database_create_account_port']);
- if ($connected === FALSE) {
- $socket_error = @socket_last_error($socket);
-
- @socket_close($socket);
- @socket_clear_error();
-
- unset($socket);
- unset($connected);
-
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_connect', ':socket_error' => $socket_error, ':socket_error_message' => @socket_strerror($socket_error), ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
- unset($socket_error);
-
- return c_base_return_error::s_false($error);
- }
-
- $packet_size_target = 63;
- $packet_size_client = 1;
-
- $name_length = strlen(trim($user_name));
- $difference = $packet_size_target - $name_length;
-
- if ($difference > 0) {
- // the packet expects a packet to be NULL terminated or at most $packet_size_target.
- $packet = pack('a' . $name_length . 'x' . $difference, trim($user_name));
- }
- else {
- $packet = pack('a' . $name_length, $user_name);
- }
-
- $written = @socket_write($socket, $packet, $packet_size_target);
-
- unset($packet);
- unset($packet_size_target);
- unset($name_length);
- unset($difference);
-
- if ($written === FALSE) {
- unset($written);
- unset($packet_size_client);
-
- $socket_error = @socket_last_error($socket);
-
- @socket_close($socket);
- @socket_clear_error();
-
- unset($socket);
- unset($connected);
-
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_write', ':socket_error' => $socket_error, ':socket_error_message' => @socket_strerror($this->socket_error), ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
- unset($socket_error);
-
- return c_base_return_error::s_false($error);
- }
- unset($written);
-
- $response = @socket_read($socket, $packet_size_client);
- if ($response === FALSE) {
- unset($response);
- unset($packet_size_client);
-
- $socket_error = @socket_last_error($socket);
-
- @socket_close($socket);
- @socket_clear_error();
-
- unset($socket);
- unset($connected);
-
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_read', ':socket_error' => $socket_error, ':socket_error_message' => @socket_strerror($this->socket_error), ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::SOCKET_FAILURE);
- unset($socket_error);
-
- return c_base_return_error::s_false($error);
- }
-
- @socket_close($socket);
- unset($socket);
- unset($packet_size_client);
-
- if (!is_string($response) || strlen($response) == 0) {
- unset($response);
-
- $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_read', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
- return c_base_return_error::s_false($error);
- }
-
- // an integer is expected to be returned by the socket.
- $response_packet = unpack('C', $response);
- $response_value = (int) $response_packet[1];
-
- unset($response);
-
- // response codes as defined in the c source file:
- // 0 = no problems detected.
- // 1 = invalid user name, bad characters, or name too long.
- // 2 = failed to connect to the ldap server and could not query the ldap name.
- // 3 = user name not found in ldap database.
- // 4 = failed to connect to the database.
- // 5 = error returned while executing the SQL command.
- // 6 = error occured while reading input from the user (such as via recv()).
- // 7 = error occured while writing input from the user (such as via send()).
- // 8 = the received packet is invalid, such as wrong length.
- // 9 = connection timed out when reading or writing.
- // 10 = the connection is being forced closed.
- // 11 = the connection is closing because the service is quitting.
- return c_base_return_int::s_new($response_value);
-}
+++ /dev/null
-<?php
-/**
- * @file
- * Provides handler for common theme functionality.
- */
-
-require_once('common/base/classes/base_error.php');
-require_once('common/base/classes/base_return.php');
-
-require_once('common/theme/classes/theme_html.php');
-
-
-class c_reservation_theme_html extends c_theme_html {
-}