I noticed that there are a lot of incomplete functions in the http class.
This, in particular, implements cookie support.
There is still a lot more incomplete code in the http class.
My initial error reporting work is done.
Expect major refactoring as I continue developing.
After some testing, I have foind the php-xz module to be lacking and defunct.
I also noticed that there are multiple relevant repositories to choose from (added both to documentation).
Numerous other changes.
*/
public function set_role($role, $value) {
if (!is_int($role)) {
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'role')), i_base_error_messages::INVALID_ARGUMENT);
+ $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)) {
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'value')), 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 ($role === self::NONE) {
*/
public function get_role($role) {
if (!is_int($role)) {
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'role')), i_base_error_messages::INVALID_ARGUMENT);
+ $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) {
*/
public static function s_is_valid($charset) {
if (!is_int($charset)) {
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'charset')), 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 ($charset < self::ASCII || $charset > self::ISO_8859_16) {
*/
public static function s_to_string($charset) {
if (!is_int($charset)) {
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'charset')), 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);
}
switch ($charset) {
return c_base_return_string::s_new('ISO-8859-16');
}
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => __CLASS__ . '::' . __FUNCTION__)), i_base_error_messages::OPERATION_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);
}
}
* This class overrides c_base_return_array() such that some of its return values are in a different form than expected.
* This will utilize c_base_return_* as return values.
*
+ * @todo: review this class, for some reason I decided to use c_base_return_array as this class supertype.
+ * Is that a good idea, because it feels a bit abusive?
+ *
* @see: http://us.php.net/manual/en/features.cookies.php
* @see: setcookie()
*/
class c_base_cookie extends c_base_return_array {
const DEFAULT_LIFETIME = 172800; // 48 hours
const DEFAULT_PATH = '/';
+ const DEFAULT_JSON_ENCODE_DEPTH = 512;
const CHECKSUM_ALGORITHM = 'sha256';
private $name;
private $http_only;
private $first_only;
private $data;
+ private $json_encode_depth;
/**
$this->http_only = FALSE;
$this->first_only = TRUE;
$this->data = array();
+ $this->json_encode_depth = self::DEFAULT_JSON_ENCODE_DEPTH;
$this->p_set_lifetime_default();
unset($this->http_only);
unset($this->first_only);
unset($this->data);
+ unset($this->json_encode_depth);
parent::__destruct();
}
*/
public function set_name($name) {
if (!is_string($name) || empty($name)) {
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'name')), 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) {
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'name')), 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);
}
$this->name = preg_replace('/(^\s+)|(\s+$)/us', '', rawurlencode($name));
*/
public function set_secure($secure) {
if (!is_bool($secure)) {
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'secure')), 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);
}
$this->secure = $secure;
$expires = (int) $expires;
if ($expires < 0) {
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'expires')), 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 {
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'expires')), 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) {
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'max_age')), 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 {
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'max_age')), 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)) {
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'path')), 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);
}
// sanitize the path string, only allowing the path portion of the url.
$parsed = parse_url($path, PHP_URL_PATH);
if ($parsed === FALSE) {
unset($parsed);
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'parse_url(path)')), 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);
}
$this->path = preg_replace('/(^\s+)|(\s+$)/us', '', $parsed);
*/
public function set_domain($domain) {
if (!is_string($domain) || empty($domain)) {
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'domain')), 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);
}
// sanitize the domain string, only allowing the host portion of the url.
$parsed = parse_url('stub://' . $domain, PHP_URL_HOST);
if ($parsed === FALSE) {
unset($parsed);
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'parse_url(stub://domain, PHP_URL_HOST)')), 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);
}
$this->domain = preg_replace('/(^\s+)|(\s+$)/us', '', $parsed);
*/
public function set_http_only($http_only) {
if (!is_bool($http_only)) {
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'http_only')), 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);
}
$this->http_only = $http_only;
*/
public function set_first_only($first_only) {
if (!is_bool($first_only)) {
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'first_only')), 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);
}
$this->first_only = $first_only;
* @param array $data
* Any value so long as it is an array.
* NULL is not allowed.
+ * FALSE with the error bit set is returned on error.
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
*/
public function set_data($data) {
if (!is_array($data)) {
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'data')), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'data', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
}
$this->data = $data;
/**
* Return the data.
*
- * @return c_base_return_array $data
+ * @return c_base_return_array
* The value array stored within this class.
* NULL may be returned if there is no defined valid array.
+ * FALSE with the error bit set is returned on error.
*/
public function get_data() {
if (!is_null($this->data) && !is_array($this->data)) {
}
/**
- * Save the cookie to the HTTP headers for sending to the client.
- *
- * This function sends an HTTP header and therefore should only be used when ready to send headers.
- *
- * Both name and value are required to be set before calling this function.
- *
- * The functions setcookie() and setrawcookie() do not provide advanced customization.
- * Instead of using those functions, use header() to directly generate the cookie.
+ * Generate and return a cookie string prepared for HTTP header usage.
*
* @param bool $checksum
- * When set to TRUE, the array will be converted to a json string and have a checksum created for it.
+ * (optional) When set to TRUE, the array will be converted to a json string and have a checksum created for it.
* This checksum value will then be placed inside the array and a final json string will be submitted.
*
- * Warning: any top-level key in the array with the name of 'checksum' will be lost when using this.
- *
- * @return c_base_return_status
- * TRUE on success, FALSE otherwise.
- *
- * @see: self::validate()
- * @see: setcookie()
- * @see: setrawcookie()
- * @see: header()
+ * @return c_base_return_string
+ * The value array stored within this class.
+ * NULL may be returned if there is no defined valid array.
+ * FALSE with the error bit set is returned on error.
*/
- public function do_push($checksum = TRUE) {
- if (is_null($this->name)) {
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'name')), i_base_error_messages::INVALID_ARGUMENT);
+ 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);
+ return c_base_return_error::s_false($error);
}
if (is_null($this->data)) {
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'data')), i_base_error_messages::INVALID_ARGUMENT);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->data', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ return c_base_return_error::s_false($error);
}
- if ($checksum) {
- unset($this->data['checksum']);
- $this->data['checksum'] = $this->p_build_checksum();
-
- if (is_null($this->data['checksum'])) {
- unset($this->data['checksum']);
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->p_build_checksum()')), i_base_error_messages::OPERATION_FAILURE);
- }
+ $cookie = $this->p_build_cookie($checksum);
+ if ($cookie instanceof c_base_return_false) {
+ return c_base_return_error::s_false($cookie->get_error());
}
- // @todo: consider adding support for assigning the json depth setting.
- $json = json_encode($this->data);
- if ($json === FALSE) {
- unset($json);
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'json_encode(this->data)')), i_base_error_messages::OPERATION_FAILURE);
- }
+ return $cookie;
+ }
- $data = rawurlencode(preg_replace('/(^\s+)|(\s+$)/us', '', $json));
- unset($json);
+ /**
+ * Assigns the default json encode depth to be used.
+ *
+ * Sets the maximum json encode depth used when processing cookie data via json_encode().
+ *
+ * @param int $json_encode_depth
+ * The json encode max depth.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
+ *
+ * @see: json_encode()
+ */
+ 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);
+ return c_base_return_error::s_false($error);
+ }
- //$result = setrawcookie($this->name, $data, $this->max_age, $this->path, $this->domain, $this->secure, $this->http_only);
- $cookie = 'Set-Cookie: ' . rawurlencode($this->name) . '=' . $data . ';';
+ $this->json_encode_depth = $json_encode_depth;
+ return new c_base_return_true();
+ }
- if (!is_null($this->domain)) {
- $cookie .= ' domain=' . $this->domain . ';';
- }
+ /**
+ * Returns the stored cookie json_encode_depth.
+ *
+ * @return c_base_return_int
+ * The cookie json_encode_depth string or NULL if undefined.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function get_json_encode_depth() {
+ return c_base_return_int::s_new($this->json_encode_depth);
+ }
- if (!is_null($this->path)) {
- $cookie .= ' path=' . $this->path . ';';
+ /**
+ * Save the cookie to the HTTP headers for sending to the client.
+ *
+ * This function sends an HTTP header and therefore should only be used when ready to send headers.
+ *
+ * @param bool $checksum
+ * (optional) When set to TRUE, the array will be converted to a json string and have a checksum created for it.
+ * This checksum value will then be placed inside the array and a final json string will be submitted.
+ *
+ * Warning: any top-level key in the array with the name of 'checksum' will be lost when using this.
+ * @param bool $force
+ * (optional) If TRUE, will send cookie header even if header_sent() returns TRUE.
+ * If FALSE, cookie headers are not sent when headers_sent() returns TRUE.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with error bit is returned on error.
+ * FALSE without error bit set is returned when the php headers have already been sent according to headers_sent().
+ *
+ * @see: header()
+ * @see: headers_sent().
+ */
+ 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);
+ return c_base_return_error::s_false($error);
}
- if (!is_null($this->max_age)) {
- $cookie .= ' max-age=' . $this->max_age . ';';
-
- // provide an expires for compatibility purposes if one is not specified.
- if (is_null($this->expires)) {
- $cookie .= ' expires=' . gmdate('D, d-M-Y H:i:s T', strtotime('+' . $this->max_age . ' seconds')) . ';';
- }
+ 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);
+ return c_base_return_error::s_false($error);
}
- if (!is_null($this->expires)) {
- $cookie .= ' expires=' . gmdate('D, d-M-Y H:i:s T', $this->expires) . ';';
+ 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);
+ return c_base_return_error::s_false($error);
}
- if ($this->secure) {
- $cookie .= ' secure;';
+ if (is_null($this->data)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->data', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ return c_base_return_error::s_false($error);
}
- if ($this->http_only) {
- $cookie .= ' httponly;';
+ $cookie = $this->p_build_cookie($checksum);
+ if ($cookie instanceof c_base_return_false) {
+ return c_base_return_error::s_false($cookie->get_error());
}
- if ($this->first_only) {
- $cookie .= ' first-party;';
+ if (headers_sent() && !$force) {
+ return new c_base_return_false();
}
- header($cookie, FALSE);
+ header($cookie->get_value_exact(), FALSE);
unset($cookie);
unset($data);
return new c_base_return_true();
}
-/**
- * Deletes the cookie by setting both the expires and max-age to -1.
- *
- * This does not need to be called when updating the cookie.
- *
- * @return c_base_return_status
- * TRUE on success, FALSE otherwise.
- *
- * @see: self::push()
- */
- public function delete() {
- $original_max_age = $this->max_age;
- $original_expires = $this->expires;
-
- $this->max_age = -1;
- $this->expires = -1;
-
- $result = $this->push(FALSE);
-
- $this->max_age = $original_max_age;
- $this->expires = $original_expires;
-
- unset($original_max_age);
- unset($original_expires);
-
- return $result;
- }
-
/**
* Retrieve the cookie from the HTTP headers sent by the client.
*
unset($json);
if ($data === FALSE) {
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'json_decode(json, TRUE)')), 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);
}
$this->data = $data;
}
/**
- * Assigns a default value for the expiration based on php's session.cookie_lifetime.
- */
- private function p_set_lifetime_default() {
- $lifetime = ini_get('session.cookie_lifetime');
- if ($lifetime <= 0) {
- $lifetime = self::DEFAULT_LIFETIME;
- }
-
- $this->max_age = $lifetime;
- unset($lifetime);
- }
-
- /**
* Validate a checksum key.
*
* This is only meaningful when called after self::do_pull() is used.
*/
public function validate() {
if (!is_array($this->data)) {
- return c_base_return_error::s_false(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);
}
if (!array_key_exists('checksum', $this->data)) {
}
/**
+ * Deletes the cookie by setting both the expires and max-age to -1.
+ *
+ * This does not need to be called when updating the cookie.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ *
+ * @see: self::push()
+ */
+ public function delete() {
+ $original_max_age = $this->max_age;
+ $original_expires = $this->expires;
+
+ $this->max_age = -1;
+ $this->expires = -1;
+
+ $result = $this->push(FALSE);
+
+ $this->max_age = $original_max_age;
+ $this->expires = $original_expires;
+
+ unset($original_max_age);
+ unset($original_expires);
+
+ return $result;
+ }
+
+ /**
* Builds a checksum of the data array.
*
* This does not assign the checksum to the array.
}
unset($checksum);
- return c_base_return_error::s_false(c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->p_build_checksum()')), 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);
+ }
+
+ /**
+ * Assigns a default value for the expiration based on php's session.cookie_lifetime.
+ */
+ private function p_set_lifetime_default() {
+ $lifetime = ini_get('session.cookie_lifetime');
+ if ($lifetime <= 0) {
+ $lifetime = self::DEFAULT_LIFETIME;
+ }
+
+ $this->max_age = $lifetime;
+ unset($lifetime);
}
/**
unset($this->data['checksum']);
}
- $json = json_encode($this->data);
+ $json = json_encode($this->data, 0, $this->json_encode_depth);
if ($json === FALSE) {
if ($has_checksum) {
$this->data['checksum'] = $checksum;
unset($has_checksum);
unset($checksum);
unset($json);
+
return NULL;
}
return $generated;
}
+
+ /**
+ * Build the cookie HTTP headers for sending to the client.
+ *
+ * This function sends an HTTP header and therefore should only be used when ready to send headers.
+ *
+ * Both name and value are required to be set before calling this function.
+ *
+ * The functions setcookie() and setrawcookie() do not provide advanced customization.
+ * Instead of using those functions, use header() to directly generate the cookie.
+ *
+ * @param bool $checksum
+ * (optional) When set to TRUE, the array will be converted to a json string and have a checksum created for it.
+ * This checksum value will then be placed inside the array and a final json string will be submitted.
+ *
+ * Warning: any top-level key in the array with the name of 'checksum' will be lost when using this.
+ *
+ * @return c_base_return_string|c_base_return_status
+ * A generated cookie string is returned on success.
+ * FALSE with error bit is returned on error.
+ * FALSE without error bit set is returned when the php headers have already been sent according to headers_sent().
+ *
+ * @see: self::validate()
+ * @see: setcookie()
+ * @see: setrawcookie()
+ * @see: header()
+ * @see: headers_sent().
+ */
+ private function p_build_cookie($checksum = TRUE) {
+ if ($checksum) {
+ unset($this->data['checksum']);
+ $this->data['checksum'] = $this->p_build_checksum();
+
+ if (is_null($this->data['checksum'])) {
+ unset($this->data['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);
+ return c_base_return_error::s_false($error);
+ }
+ }
+
+ $json = json_encode($this->data, 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);
+ return c_base_return_error::s_false($error);
+ }
+
+ $data = rawurlencode(preg_replace('/(^\s+)|(\s+$)/us', '', $json));
+ unset($json);
+
+ $cookie = 'Set-Cookie: ' . rawurlencode($this->name) . '=' . $data . ';';
+
+ if (!is_null($this->domain)) {
+ $cookie .= ' domain=' . $this->domain . ';';
+ }
+
+ if (!is_null($this->path)) {
+ $cookie .= ' path=' . $this->path . ';';
+ }
+
+ if (!is_null($this->max_age)) {
+ $cookie .= ' max-age=' . $this->max_age . ';';
+
+ // provide an expires for compatibility purposes if one is not specified.
+ if (is_null($this->expires)) {
+ $cookie .= ' expires=' . gmdate('D, d-M-Y H:i:s T', strtotime('+' . $this->max_age . ' seconds')) . ';';
+ }
+ }
+
+ if (!is_null($this->expires)) {
+ $cookie .= ' expires=' . gmdate('D, d-M-Y H:i:s T', $this->expires) . ';';
+ }
+
+ if ($this->secure) {
+ $cookie .= ' secure;';
+ }
+
+ if ($this->http_only) {
+ $cookie .= ' httponly;';
+ }
+
+ if ($this->first_only) {
+ $cookie .= ' first-party;';
+ }
+
+ return c_base_return_string::s_new($cookie);
+ }
}
private $host;
private $host_addr;
private $port;
- private $dbname;
+ private $database_name;
private $user;
private $password;
private $connect_timeout;
$this->host = NULL;
$this->host_addr = NULL;
$this->port = NULL;
- $this->dbname = NULL;
+ $this->database_name = NULL;
$this->user = NULL;
$this->password = NULL;
$this->connect_timeout = NULL;
unset($this->host);
unset($this->host_addr);
unset($this->port);
- unset($this->dbname);
+ unset($this->database_name);
unset($this->user);
unset($this->password);
unset($this->connect_timeout);
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*/
public function set_host($host) {
if (!is_string($host)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->host = $host;
*
* @return c_base_return_string
* The host information string.
+ * The error bit set is on error.
*/
public function get_host() {
if (!is_string($this->host)) {
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*/
public function set_host_addr($host_addr) {
if (!is_string($host_addr)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->host_addr = $host_addr;
*
* @return c_base_return_string
* The host address information string.
+ * The error bit set is on error.
*/
public function get_host_addr() {
if (!is_string($this->host_addr)) {
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*/
public function set_port($port) {
if (!is_int($port)) {
if (is_string($port) && is_numeric($port)) {
$port = (int) $port;
if ($port < 0) {
- return c_base_return_error::s_false();
+ $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 {
- return c_base_return_error::s_false();
+ $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);
}
}
* Returns the port number.
*
* @return c_base_return_int
- * The port number.
+ * The port number on success.
+ * The error bit set is on error.
*/
public function get_port() {
if (!is_int($this->port)) {
/**
* Assign database name.
*
- * @param string $dbname
+ * @param string $database_name
* The database name string.
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*/
- public function set_dbname($dbname) {
- if (!is_string($dbname)) {
- return c_base_return_error::s_false();
+ public function set_database_name($database_name) {
+ if (!is_string($database_name)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'database_name', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
}
- $this->dbname = $dbname;
+ $this->database_name = $database_name;
return new c_base_return_true();
}
* Returns the database name.
*
* @return c_base_return_string
- * The database name string.
+ * The database name string on success.
+ * The error bit set is on error.
*/
- public function get_dbname() {
- if (!is_string($this->dbname)) {
- $this->dbname = '';
+ public function get_database_name() {
+ if (!is_string($this->database_name)) {
+ $this->database_name = '';
}
- return c_base_return_string::s_new($this->dbname);
+ return c_base_return_string::s_new($this->database_name);
}
/**
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*/
public function set_user($user) {
if (!is_string($user)) {
- return c_base_return_error::s_false();
+ $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->user = $user;
* Returns the user name.
*
* @return c_base_return_string
- * The user name string.
+ * The user name string on success.
+ * The error bit set is on error.
*/
public function get_user() {
if (!is_string($this->user)) {
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*/
public function set_password($password) {
if (!is_null($password) && !is_string($password)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->password = $password;
/**
* Returns the password.
*
- * @return c_base_return_string|c_base_return_status
+ * @return c_base_return_string
* The password string.
* FALSE is returned if there is no assigned password.
+ * The error bit set is on error.
*/
public function get_password() {
if (is_null($this->password)) {
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*/
public function set_connect_timeout($connect_timeout) {
if (!is_int($connect_timeout)) {
if (is_string($connect_timeout) && is_numeric($connect_timeout)) {
$connect_timeout = (int) $connect_timeout;
if ($connect_timeout < 0) {
- return c_base_return_error::s_false();
+ $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 {
- return c_base_return_error::s_false();
+ $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);
}
}
*
* @return c_base_return_int
* The connect timeout number.
+ * The error bit set is on error.
*/
public function get_connect_timeout() {
if (!is_int($this->connect_timeout)) {
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*/
public function set_options($options) {
if (!is_string($options)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->options = $options;
* Returns the options information.
*
* @return c_base_return_string
- * The options information string.
+ * The options information string on success.
+ * The error bit set is on error.
*/
public function get_options() {
if (!is_string($this->options)) {
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*/
public function set_ssl_mode($ssl_mode) {
if (!is_string($ssl_mode)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->ssl_mode = $ssl_mode;
*
* @return c_base_return_string
* The ssl mode information string.
+ * The error bit set is on error.
*/
public function get_ssl_mode() {
if (!is_string($this->ssl_mode)) {
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*/
public function set_service($service) {
if (!is_string($service)) {
- return c_base_return_error::s_false();
+ $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->service = $service;
*
* @return c_base_return_string
* The service information string.
+ * The error bit set is on error.
*/
public function get_service() {
if (!is_string($this->service)) {
$this->value .= ' port=' . $this->p_escape_string($this->port);
}
- if (!empty($this->dbname)) {
- $this->value .= ' dbname=' . $this->p_escape_string($this->dbname);
+ if (!empty($this->database_name)) {
+ $this->value .= ' database_name=' . $this->p_escape_string($this->database_name);
}
if (!empty($this->user)) {
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*/
public function set_session($session) {
if (!is_object($session) || !($session instanceof c_base_session)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->session = $session;
* Returns the session information.
*
* @return c_base_session_return
+ * A session object on success.
+ * The error bit set is on error.
*/
public function get_session() {
if (!is_object($session) || !($session instanceof c_base_session)) {
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
+ * 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)) {
- return c_base_return_error::s_false();
+ $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->build();
+
return new c_base_return_true();
}
/**
* Returns the connection string.
*
- * @return c_base_connection_string_return
+ * @return c_base_connection_string
+ * A connection string object on success.
+ * The error bit set is on error.
*/
public function get_connection_string() {
- if (!is_object($connection_string) || !($connection_string instanceof c_base_connection_string)) {
+ if (!is_object($this->connection_string) || !($this->connection_string instanceof c_base_connection_string)) {
$this->connection_string = new c_base_connection_string();
}
* TRUE to enable a persistent connection, FALSE otherwise.
*
* @param c_base_return_status
- * TRUE on success, FALSE otherwise
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*/
public function set_persistent($persistent) {
if (!is_bool($persistent)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->persistent = $persistent;
*
* @return c_base_return_status
* TRUE on enabled, FALSE on disabled.
+ * The error bit set is on error.
*/
public function get_persistent() {
if (!is_bool($this->persistent)) {
* TRUE to enable a asynchronous connection, FALSE otherwise.
*
* @param c_base_return_status
- * TRUE on success, FALSE otherwise
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*/
public function set_asynchronous($asynchronous) {
if (!is_bool($asynchronous)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->asynchronous = $asynchronous;
*
* @return c_base_return_status
* TRUE on enabled, FALSE on disabled.
+ * The error bit set is on error.
*/
public function get_asynchronous() {
if (!is_bool($this->asynchronous)) {
* TRUE on success, FALSE otherwise
* c_base_return_true is returned if the database is connected.
* c_base_return_false is returned if the database is disconnected.
- * The error flag is set if there is a problem.
- * If the database is already connected when this is called, c_base_return_true is returned with the error flag set.
+ * FALSE with the error bit set is returned on error.
+ * If the database is already connected when this is called, c_base_return_true is returned with the error bit set.
*
* @see: pg_connect()
*/
public function do_connect($force = FALSE) {
if (!is_bool($force)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_true();
+ $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);
}
$type = 0;
unset($type);
if ($database === FALSE) {
unset($database);
- return c_base_return_error::s_false();
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':database_name' => $this->connection_string->get_database_name()->get_value_exact(), ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_CONNECTION_FAILURE);
+ return c_base_return_error::s_false($error);
}
$this->database = $database;
* If there is open large object resource on the connection, do not close the connection before closing all large object resources.
*
* @param c_base_return_status
- * TRUE on success, FALSE otherwise
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*
* @see: pg_close()
*/
public function do_disconnect() {
if (!is_resource($this->database)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
if (pg_close($this->database)) {
return new c_base_return_true();
}
- return c_base_return_error::s_false();
+ $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);
}
/**
*
* @return c_base_return_status
* TRUE on success, FALSE on partial flush.
- * FALSE with error flag set on error.
+ * FALSE with the error bit set is returned on error.
*
* @see: pg_flush()
*/
public function do_flush() {
if (!is_resource($this->database)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
$result = pg_flush($this->database);
}
if ($result === FALSE) {
- return c_base_return_error::s_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);
+ return c_base_return_error::s_false($error);
}
return new c_base_return_false();
*
* @return c_base_return_status
* TRUE on connected, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*/
public function is_connected() {
if ($this->connected === TRUE && pg_connection_status($this->database) === PGSQL_CONNECTION_OK) {
*/
public function is_busy() {
if (!$this->asynchronous) {
- return c_base_return_error::s_false();
+ $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);
}
if (pg_connection_busy($this->database)) {
*
* @return c_base_return_status|c_base_return_string
* String containing the status or FALSE on failure.
+ * FALSE with the error bit set is returned on error.
*
* @see: pg_parameter_status()
*/
public function get_parameter_status($name) {
if (!is_string($name) || empty($name)) {
- return c_base_return_error::s_false();
+ $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);
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_string::s_new($result);
*
* This is used for asynchronous connections.
*
- * @return c_base_return_int
+ * @return c_base_return_int|c_base_return_status
* The integer is returned on success or failure.
* The failure flag will be set accordingly.
+ * FALSE with the error bit set is returned on error.
*
* @see: pg_connect_poll()
*/
public function do_poll() {
if (!$this->asynchronous) {
- return c_base_return_error::value(0, 'c_base_return_int');
+ $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);
}
return c_base_return_int::s_value_exact(pg_connect_poll($this->database));
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*
* @see: pg_connection_reset()
*/
public function do_reset() {
if (!is_resource($this->database)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
if (pg_connection_reset($this->database)) {
return new c_base_return_true();
}
- return c_base_return_error::s_false();
+ $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);
}
/**
*
* @return c_base_return_int
* PGSQL_CONNECTION_OK or PGSQL_CONNECTION_BAD.
+ * The error bit set is on error.
*
* @see: pg_connection_status()
*/
*/
public function do_ping() {
if (!is_resource($this->database)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
if (pg_status($this->database) === PGSQL_CONNECTION_OK) {
return new c_base_return_false();
}
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
return c_base_return_string::s_value_exact(pg_escape_literal($this->database, $literal));
*/
public function escape_bytea($bytea) {
if (!is_string($bytea)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
return c_base_return_string::s_value_exact(pg_escape_bytea($this->database, $bytea));
*/
public function escape_identifier($identifier) {
if (!is_string($identifier)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
return c_base_return_string::s_value_exact(pg_escape_identifier($this->database, $identifier));
*/
public function unescape_bytea($bytea) {
if (!is_string($bytea)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
return c_base_return_string::s_value_exact(pg_unescape_bytea($this->database, $bytea));
*/
public function set_client_encoding($encoding) {
if (!is_string($encoding)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
// this function has a strange return status.
return new c_base_return_true();
}
- return c_base_return_error::s_false();
+ $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);
}
/**
*
* @return c_base_return_string|c_base_return_status
* The string to be returned.
- * FALSE is returned on error
+ * FALSE with the error bit set is returned on error.
*
* @see: pg_client_encoding()
*/
public function get_client_encoding() {
if (!is_resource($this->database)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
$encoding = pg_client_encoding($this->database);
if ($encoding === FALSE) {
unset($encoding);
- return c_base_return_error::s_false();
+
+ $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);
}
return c_base_return_string::s_value_exact($encoding);
*/
public function consume_input() {
if (!is_resource($this->database)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
if (pg_consume_input($this->database)) {
return new c_base_return_true();
}
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
$converted = pg_connect_status($this->database, $table, $array, $options);
if ($converted === FALSE) {
unset($converted);
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_array::s_value_exact($converted);
*/
public function do_execute($name, $parameters = array()) {
if (!is_string($name) || empty($name)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
if ($this->asynchronous) {
}
unset($result);
- return c_base_return_error::s_false();
+ $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);
}
/**
*/
public function do_query($query, $parameters = array()) {
if (!is_string($query) || empty($query)) {
- return c_base_return_error::s_false();
+ $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);
}
if (!is_array($parameters)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
if ($this->asynchronous) {
}
unset($result);
- return c_base_return_error::s_false();
+ 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);
+ }
+ 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);
+ }
+ }
+ 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);
+ }
+ 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);
+ }
+ }
+
+ return c_base_return_error::s_false($error);
}
/**
* @see: pg_prepare()
* @see: pg_send_prepare()
*/
- public function do_prepare($name) {
+ public function do_prepare($name, $query) {
if (!is_string($name) || empty($name)) {
- return c_base_return_error::s_false();
+ $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_string($query) || empty($query)) {
- return c_base_return_error::s_false();
- }
-
- if (!is_array($parameters)) {
- return c_base_return_error::s_false();
+ $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);
}
if (!is_resource($this->database)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
if ($this->asynchronous) {
}
unset($result);
- return c_base_return_error::s_false();
+ $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);
}
/**
*
* @return c_base_database_result|c_base_return_status
* A database result is returned on success.
- * FALSE is returned on failure.
+ * FALSE with the error bit set is returned on error.
* When asynchronous is not enabled, FALSE is returned without an error flag set.
*/
public function get_result() {
if (!is_resource($this->database)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
if (!$this->asynchronous) {
}
unset($result);
- return c_base_return_error::s_false();
+ $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);
}
/**
*/
public function do_cancel() {
if (!is_resource($this->database)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
if (!$this->asynchronous) {
return new c_base_return_true();
}
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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($values) || !is_int($options)) {
- return c_base_return_error::s_false();
+ 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);
+ return c_base_return_error::s_false($error);
}
if (!is_resource($this->database)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
$this->p_handle_asynchronous_options_parameter($options);
}
unset($result);
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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($values) || !is_int($options)) {
- return c_base_return_error::s_false();
+ 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);
+ return c_base_return_error::s_false($error);
}
if (!is_resource($this->database)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
$this->p_handle_asynchronous_options_parameter($options);
}
unset($result);
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ 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);
+ return c_base_return_error::s_false($error);
}
- if (!is_array($conditions)) {
- return c_base_return_error::s_false();
+ 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);
+ return c_base_return_error::s_false($error);
}
if (!is_resource($this->database)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
$this->p_handle_asynchronous_options_parameter($options);
}
unset($result);
- return c_base_return_error::s_false();
+ $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);
}
/**
*
* @see: pg_delete()
*/
- function do_delete() {
- if (!is_string($table) || empty($table)) {
- return c_base_return_error::s_false();
+ 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);
+ return c_base_return_error::s_false($error);
}
- if (!is_array($values)) {
- return c_base_return_error::s_false();
+ 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);
+ return c_base_return_error::s_false($error);
}
- if (!is_array($conditions)) {
- return c_base_return_error::s_false();
+ 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);
+ return c_base_return_error::s_false($error);
}
if (!is_resource($this->database)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
$this->p_handle_asynchronous_options_parameter($options);
}
unset($result);
- return c_base_return_error::s_false();
+ $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);
}
/**
* TRUE for extended additional information, FALSE for normal additional information.
*
* @return c_base_return_status|c_base_return_array
- * An array containing the additional information or FALSE on error.
+ * An array containing the additional information.
+ * FALSE with the error bit set is returned on error.
*
* @see: pg_meta_data()
*/
public function get_meta_data($table, $extended = FALSE) {
if (!is_string($table) || empty($table)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
$result = pg_meta_data($this->database, $table, $extended);
if ($result === FALSE) {
unset($result);
- return c_base_return_error::s_false();
+
+ $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);
}
return c_base_return_array::s_new($result);
*/
public function set_error_verbosity($verbosity) {
if (!is_resource($this->database)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
if (!is_int($verbosity)) {
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_string::s_new(pg_set_error_verbosity($this->database, $verbosity));
*
* @return c_base_return_status|c_base_return_string
* Message string on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*
* @see: pg_last_error()
*/
public function get_last_error() {
if (!is_resource($this->database)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
$result = pg_last_error($this->database);
if ($result === FALSE) {
unset($result);
- return c_base_return_error::s_false();
+
+ $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);
}
return c_base_return_string::s_new($result);
*
* @return c_base_return_status|c_base_return_string
* Message string on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*
* @see: pg_last_notice()
*/
public function get_last_notice() {
if (!is_resource($this->database)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
$result = pg_last_notice($this->database);
if ($result === FALSE) {
unset($result);
- return c_base_return_error::s_false();
+
+ $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);
}
return c_base_return_string::s_new($result);
* - PGSQL_TRANSACTION_INERROR: idle, in a failed transaction block.
* - PGSQL_TRANSACTION_UNKNOWN: invalid connection.
* - PGSQL_TRANSACTION_ACTIVE: query sent to server, but not yet completed.
+ * FALSE with the error bit set is returned on error.
*
* @see: pg_transaction_status()
*/
public function get_transaction_status() {
if (!is_resource($this->database)) {
- return c_base_return_error::s_false();
+ $database_name = ($this->connection_string instanceof c_base_connection_string) ? $this->connection_string->get_database_name()->get_value_exact() : '';
+ $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);
}
$result = pg_transaction_status($this->database);
if ($result === FALSE) {
unset($result);
- return c_base_return_error::s_false();
+
+ $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);
}
return c_base_return_string::s_new($result);
* Fetch all columns in result set.
*
* This is not fetching all columns in the result set as in all column names.
- * Instead it is fetch all values from every row that belongs to a single column.
+ * Instead it will fetch all values from every row that belongs to a single column.
*
* This would be more aptly named something like fetch_all_column_rows($column).
* But even that is not the best of names.
*/
public function fetch_all_columns($column) {
if (!is_resource($this->value)) {
- return c_base_return_error::s_false();
+ $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);
+ 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);
+ return c_base_return_error::s_false($error);
}
+
+ return c_base_return_array::s_new($result);
}
/**
*/
public function fetch_all() {
if (!is_resource($this->value)) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_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);
+ return c_base_return_error::s_false($error);
}
return c_base_return_array::s_new($result);
*/
public function fetch_array($row = NULL, $type = PGSQL_ASSOC) {
if (!is_resource($this->value)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
+ return c_base_return_error::s_false($error);
}
- $result = pg_fetch_array($this->value, $row, $column);
+ $result = pg_fetch_array($this->value, $row, $type);
if ($result === FALSE) {
- return c_base_return_error::s_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);
+ return c_base_return_error::s_false($error);
}
return c_base_return_array::s_new($result);
*/
public function fetch_object($row = NULL, $class = NULL, $parameters = NULL) {
if (!is_resource($this->value)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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_string($class) && !empty($class)) {
}
if ($result === FALSE) {
- return c_base_return_error::s_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);
+ return c_base_return_error::s_false($error);
}
return c_base_return_object::s_new($result);
*/
public function fetch_result($row, $column) {
if (!is_resource($this->value)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ 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);
+ return c_base_return_error::s_false($error);
}
- if (!is_int($row) && !is_string($row) || is_int($row) && $row < 0 || is_string($row) && empty($row)) {
- return c_base_return_error::s_false();
+ 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);
+ return c_base_return_error::s_false($error);
}
if (!is_null($row)) {
if ($result === FALSE) {
unset($result);
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_value::s_new($result);
*/
public function fetch_row($row = NULL) {
if (!is_resource($this->value)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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 ($result === FALSE) {
- return c_base_return_error::s_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);
+ return c_base_return_error::s_false($error);
}
return c_base_return_value::s_new($result);
*/
public function error($code = NULL) {
if (!is_resource($this->value)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
if (is_null($code)) {
*/
public function affected_rows() {
if (!is_resource($this->value)) {
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_int::s_new(pg_affected_rows($this->value));
*
* @return c_base_return_status|c_base_return_int
* The number of rows or FALSE on failure.
+ * FALSE with the error bit set is returned on error.
*
* @see: pg_num_rows()
*/
public function number_of_rows() {
if (!is_resource($this->value)) {
- return new c_base_return_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_int::s_new($result);
*
* @return c_base_return_status|c_base_return_int
* The number of rows or FALSE on failure.
+ * FALSE with the error bit set is returned on error.
*
* @see: pg_num_fields()
*/
public function number_of_columns() {
if (!is_resource($this->value)) {
- return new c_base_return_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_int::s_new($result);
*
* @return c_base_return_status|c_base_return_string
* The name of the field or FALSE on error.
+ * FALSE with the error bit set is returned on error.
*
* @see: pg_field_name()
*/
public function field_name($number) {
if (!is_resource($this->value)) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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);
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_string::s_new($result);
*
* @return c_base_return_status|c_base_return_int
* The number of the field or FALSE on error.
+ * FALSE with the error bit set is returned on error.
*
* @see: pg_field_num()
*/
public function field_number($name) {
if (!is_resource($this->value)) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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);
}
// this returnes -1 on error and >= 0 on success, so translate the codes appropriately.
$result = pg_field_number($this->value, $name);
if ($result < 0) {
unset($result);
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_int::s_new($result);
*
* @return c_base_return_status|c_base_return_int
* The printed length of the 'field' or FALSE on error.
+ * FALSE with the error bit set is returned on error.
*
* @see: self::field_bytes()
* @see: pg_field_prtlen()
*/
public function field_length($row, $name_or_number) {
if (!is_resource($this->value)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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 (is_null($row)) {
if ($result === FALSE) {
unset($result);
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_int::s_new($result);
* @return c_base_return_status|c_base_return_int
* The size of the column or FALSE on error.
* The returned size may be -1, in which case means the size is variable.
+ * FALSE with the error bit set is returned on error.
*
* @see: self::field_length()
* @see: pg_field_size()
*/
public function field_bytes($column) {
if (!is_resource($this->value)) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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);
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_int::s_new($result);
* @return c_base_return_status|c_base_return_int|c_base_return_string
* The name of the table that the given column belongs to or FALSE on error.
* If oid is set to TRUE, then the oid.
+ * FALSE with the error bit set is returned on error.
*
* @see: pg_field_table()
* @see: http://www.postgresql.org/docs/current/static/datatype-oid.html
*/
public function field_table($column, $oid = FALSE) {
if (!is_resource($this->value)) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
- return c_base_return_error::s_false();
+ $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);
}
if ($oid) {
*
* @return c_base_return_status|c_base_return_int
* The oid of the requested column to or FALSE on error.
+ * FALSE with the error bit set is returned on error.
*
* @see: pg_field_type_oid()
* @see: http://www.postgresql.org/docs/current/static/datatype-oid.html
*/
public function field_type_oid($column) {
if (!is_resource($this->value)) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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);
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_int::s_new($result);
*
* @return c_base_return_status|c_base_return_string
* A string containing the oid assigned to the most recently inserted row on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*
* @see: pg_last_oid()
* @see: pg_result_status()
*/
public function last_oid() {
if (!is_resource($this->value)) {
- return c_base_return_error::s_false();
+ $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);
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_string::s_new($result);
*
* @return c_base_return_status|c_base_return_int
* The oid of the requested column to or FALSE on error.
+ * FALSE with the error bit set is returned on error.
*
* @see: pg_field_type()
*/
public function field_type($column) {
if (!is_resource($this->value)) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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);
- return c_base_return_error::s_false();
+ $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 c_base_return_string::s_new($result);
*
* @return c_base_return_status
* TRUE is returned on success, FALSE is returned if nothing to free.
- * FALSE with the error flag set is returned on error.
+ * FALSE with the error bit set is returned on error.
*
* @see: pg_free_result()
*/
return new c_base_return_true();
}
- return c_base_return_error::s_false();
+ $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);
}
}
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
*/
public function import($import) {
if (!is_string($import) || empty($import)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_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);
+ return c_base_return_error::s_false($error);
}
$this->p_initialize();
* @return c_base_return_status|c_base_return_string
* FALSE is returned when there is no content to export.
* Otherwise, a json encoded string is returned.
+ * FALSE with the error bit set is returned on error.
*/
public function export() {
if ($this->count_table == 0 || empty($this->value)) {
// everything else has to be re-created on import for security reasons.
$encoded = json_encode($this->value);
if (!is_string($encoded)) {
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_string::s_new($encoded);
*/
public static function s_set_debugging($debug) {
if (!is_bool($debug)) {
- return c_base_return_error::s_false();
+ $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);
}
self::$ps_debugging = $debug;
}
if (!is_bool($milliseconds)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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 ($milliseconds) {
return new c_base_return_false();
}
- if (!is_int($option) || $option < 1 || $option > 3 || !is_bool($megabytes)) {
- return c_base_return_error::s_false();
+ 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);
+ 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);
+ return c_base_return_error::s_false($error);
}
if ($option == 1) {
if (is_null($this->memory_usage_peak)) {
- return c_base_return_error::s_false();
+ $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);
}
if ($megabytes) {
}
elseif ($option == 2) {
if (is_null($this->time_stop)) {
- return c_base_return_error::s_false();
+ $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 ($megabytes) {
return c_base_return_int::s_new($this->memory_usage_stop);
}
else {
- if (is_null($this->time_start) || is_null($this->time_stop)) {
- return c_base_return_error::s_false();
+ 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);
+ 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);
+ return c_base_return_error::s_false($error);
}
if ($megabytes) {
* Therefore, it is an exception case to the use of base_return classes as a return value and must instead return raw/native PHP values.
*
* This provides a custom facility for syslog/openlog calls so that a 'none' facility can be supported.
+ *
+ * @todo: I either need to create a global/static (aka: non-threadsafe) class for assigning error settings OR I need to add a variable to each class object to assign error settings (uses more resources).
+ * This needs to be done so that stuff like debug_backtrace() is called only once and is only called if needed.
*/
class c_base_error {
const SEVERITY_NONE = 0;
private $backtrace;
private $code;
private $ignore_arguments;
+ private $backtrace_performed;
/**
$this->backtrace = array();
$this->code = NULL;
$this->ignore_arguments = TRUE;
+ $this->backtrace_performed = FALSE;
}
/**
unset($this->backtrace);
unset($this->code);
unset($this->ignore_arguments);
+ unset($this->backtrace_performed);
}
/**
if (is_string($message)) {
$entry->set_message($message);
}
- elseif (is_null($this->message)) {
+ elseif (is_null($message)) {
$entry->set_message('');
}
if (is_array($details)) {
$entry->set_details($details);
}
- elseif (is_null($this->details)) {
+ elseif (is_null($details)) {
$entry->set_details(array());
}
if (is_int($code)) {
$entry->set_code($code);
}
- elseif (is_null($this->message)) {
+ elseif (is_null($message)) {
$entry->set_code(0);
}
if (is_int($severity) && $severity >= self::SEVERITY_EMERGENCY && $severity < self::SEVERITY_UNKNOWN) {
$entry->set_severity($severity);
}
- elseif (is_null($this->message)) {
+ elseif (is_null($severity)) {
$entry->set_severity(self::SEVERITY_ERROR);
}
}
// build the backtrace, but ignore this function call when generating.
- $this->set_backtrace(1);
+ $entry->set_backtrace(1);
return $entry;
}
$this->backtrace = $backtrace;
}
unset($backtrace);
+
+ $this->backtrace_performed = TRUE;
}
}
* @see: http://www.loc.gov/standards/iso639-2/php/code_list.php
*/
interface i_base_error_messages {
- const NONE = 0;
- const ARGUMENT_INVALID = 1;
- const OPERATION_FAILURE = 2;
- const INVALID_FORMAT = 3;
- const INVALID_VARIABLE = 4;
+ const NONE = 0;
+ const INVALID_ARGUMENT = 1;
+ const INVALID_FORMAT = 2;
+ const INVALID_VARIABLE = 3;
+ const OPERATION_FAILURE = 4;
+ const OPERATION_UNECESSARY = 5;
+ const FUNCTION_FAILURE = 6;
+ const NOT_FOUND_ARRAY_INDEX = 7;
+ const NOT_FOUND_DIRECTORY = 8;
+ const NOT_FOUND_FILE = 9;
+ const NO_CONNECTION = 10;
+ const NO_SUPPORT = 11;
+ const POSTGRESQL_CONNECTION_FAILURE = 12;
+ const POSTGRESQL_NO_CONNECTION = 13;
+ const POSTGRESQL_NO_RESOURCE = 14;
/**
* (optional) When TRUE, argument placeholders are added.
* When FALSE, no placeholders are provided.
* All placeholders should begin with a single colon ':'.
+ * @param bool $function_name
+ * (optional) When TRUE, the function name is included with the message.
+ * When FALSE, no funciton name is provided.
+ *
+ * @return c_base_return_string
+ * A processed string is returned on success.
+ * FALSE with error bit set is returned on error.
*/
- static function s_get_message($code, $arguments = TRUE) {
- if ($code === self::ARGUMENT_INVALID) {
+ 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';
+ }
+
+ 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 . '.');
+ }
+ 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');
+ }
+ else {
+ return c_base_return_string::s_new('An invalid format has been specified.');
+ }
+ }
+ elseif ($code === self::INVALID_VARIABLE) {
if ($arguments === TRUE) {
- return 'An invalid argument, :argument_name, has been specified.';
+ return c_base_return_string::s_new('The variable, :variable_name, is invalid' . $function_name_string . '.');
}
else {
- return 'An invalid argument has been specified.';
+ return c_base_return_string::s_new('An invalid variable has been specified.');
}
}
elseif ($code === self::OPERATION_FAILURE) {
if ($arguments === TRUE) {
- return 'Failed to perform operation: :operation_name.';
+ return c_base_return_string::s_new('Failed to perform operation, :operation_name' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
}
else {
- return 'Failed to perform operation.';
+ return c_base_return_string::s_new('Failed to perform operation.');
}
}
- elseif ($code === self::INVALID_FORMAT) {
+ elseif ($code === self::OPERATION_UNECESSARY) {
if ($arguments === TRUE) {
- return 'The argument, :format_name, has an invalid format.';
+ return c_base_return_string::s_new('Did not perform unecessary operation, :operation_name' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
}
else {
- return 'An invalid format has been specified.';
+ return c_base_return_string::s_new('Did not perform unecessary operation.');
}
}
- elseif ($code === self::INVALID_VARIABLE) {
+ elseif ($code === self::FUNCTION_FAILURE) {
+ if ($arguments === TRUE) {
+ 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 . '.');
+ }
+ 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 . '.');
+ }
+ 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, :direction_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 . '.');
+ }
+ 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 . '.');
+ }
+ 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' . (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 . '.');
+ }
+ else {
+ return c_base_return_string::s_new('The database is not connected.');
+ }
+ }
+ elseif ($code === self::POSTGRESQL_NO_RESOURCE) {
if ($arguments === TRUE) {
- return 'The variable, :variable_name, is invalid.';
+ return c_base_return_string::s_new('No database resource is available' . $function_name_string . '.');
}
else {
- return 'An invalid variable has been specified.';
+ return c_base_return_string::s_new('No database resource is available.');
}
}
- return '';
+ return c_base_return_string::s_new('');
}
}
*/
public function set_id($id) {
if (!is_int($id)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->id = $id;
*/
public function set_attribute($attribute, $value) {
if (!is_int($attribute)) {
- return c_base_return_error::s_false();
+ $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);
}
return $this->p_set_attribute($attribute, $value);
*/
public function set_attribute_body($attribute, $value) {
if (!is_int($attribute)) {
- return c_base_return_error::s_false();
+ $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);
}
return $this->p_set_attribute($attribute, $value, TRUE);
*/
public function get_attribute($attribute) {
if (!is_int($attribute)) {
- return c_base_return_error::s_false();
+ $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);
}
return $this->p_get_attribute($attribute);
*/
public function get_attribute_body($attribute) {
if (!is_int($attribute)) {
- return c_base_return_error::s_false();
+ $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);
}
return $this->p_get_attribute($attribute, TRUE);
*/
public function set_tag($tag, $delta = NULL) {
if (!($tag instanceof c_base_markup_tag)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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_array($this->body)) {
*/
public function get_tag($delta) {
if (!is_int($delta)) {
- return c_base_return_error::s_false();
+ $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->body)) {
*/
public function set_header($header, $delta = NULL) {
if (!($header instanceof c_base_markup_tag)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
// only certain header types are allowed.
*/
public function get_header($delta) {
if (!is_int($delta)) {
- return c_base_return_error::s_false();
+ $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->headers)) {
switch ($attribute) {
case c_base_markup_attributes::ATTRIBUTE_NONE:
- // should not be possible, so consider this an error (attributes set to NONE are actually unset from the array).
- return c_base_return_error::s_false();
+ return new c_base_return_null();
case c_base_markup_attributes::ATTRIBUTE_ABBR:
case c_base_markup_attributes::ATTRIBUTE_ACCESS_KEY:
}
if (!is_int($header_name) || !array_key_exists($header_name, $this->request)) {
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_array::s_new($this->request[$header_name]);
*/
public function set_language_class($class_name) {
if (!is_string($class_name) || !is_subclass_of('i_base_language', $class_name) ) {
- return c_base_return_error::s_false();
+ $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);
}
$this->language_class = $class_name;
*/
public function set_response_access_control_allow_origin($uri) {
if (!is_string($uri)) {
- return c_base_return_error::s_false();
+ $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 ($uri == c_base_ascii::ASTERISK) {
$parsed = $this->p_parse_uri($uri);
if ($parsed['invalid']) {
unset($parsed);
- return c_base_return_error::s_false();
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->p_parse_uri', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ 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)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->response[self::RESPONSE_ACCESS_CONTROL_ALLOW_CREDENTIALS] = $allow_credentials;
*/
public function set_response_access_control_expose_headers($header_name, $append = TRUE) {
if (!is_string($header_name)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
$parsed = $this->p_prepare_token($header_name);
if ($parsed === FALSE) {
unset($parsed);
- return c_base_return_error::s_false();
+
+ $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);
}
if ($append) {
+ if (!isset($this->response[self::RESPONSE_ACCESS_CONTROL_EXPOSE_HEADERS]) || !is_array($this->response[self::RESPONSE_ACCESS_CONTROL_EXPOSE_HEADERS])) {
+ $this->response[self::RESPONSE_ACCESS_CONTROL_EXPOSE_HEADERS] = array();
+ }
+
$this->response[self::RESPONSE_ACCESS_CONTROL_EXPOSE_HEADERS][$parsed] = $parsed;
}
else {
*/
public function set_response_access_control_max_age($timestamp) {
if (!is_int($timestamp) && !is_float($timestamp)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->response[self::RESPONSE_ACCESS_CONTROL_MAX_AGE] = $timestamp;
* @see: https://en.wikipedia.org/wiki/Cross-origin_resource_sharing
*/
public function set_response_access_control_allow_methods($method, $append = TRUE) {
- if (!is_int($uri)) {
- return c_base_return_error::s_false();
+ 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);
+ return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- return c_base_return_error::s_false();
+ $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 ($append) {
+ if (!isset($this->response[self::RESPONSE_ACCESS_CONTROL_ALLOW_METHODS]) || !is_array($this->response[self::RESPONSE_ACCESS_CONTROL_ALLOW_METHODS])) {
+ $this->response[self::RESPONSE_ACCESS_CONTROL_ALLOW_METHODS] = array();
+ }
+
$this->response[self::RESPONSE_ACCESS_CONTROL_ALLOW_METHODS][$method] = $method;
}
else {
*/
public function set_response_access_control_allow_headers($header_name, $append = TRUE) {
if (!is_string($header_name)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
$parsed = $this->p_prepare_token($header_name);
if ($parsed === FALSE) {
unset($parsed);
- return c_base_return_error::s_false();
+
+ $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);
}
if ($append) {
+ if (!isset($this->response[self::RESPONSE_ACCESS_CONTROL_ALLOW_HEADERS]) || !is_array($this->response[self::RESPONSE_ACCESS_CONTROL_ALLOW_HEADERS])) {
+ $this->response[self::RESPONSE_ACCESS_CONTROL_ALLOW_HEADERS] = array();
+ }
+
$this->response[self::RESPONSE_ACCESS_CONTROL_ALLOW_HEADERS][$parsed] = $parsed;
}
else {
*/
public function set_response_accept_patch($media_type, $append = TRUE) {
if (!is_string($media_type)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
$text = $this->pr_rfc_string_prepare($media_type);
if ($text['invalid']) {
unset($text);
- return c_base_return_error::s_false();
+ $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);
}
$parsed = $this->pr_rfc_string_is_media_type($text['ordinals'], $text['characters']);
if ($parsed['invalid']) {
unset($parsed);
- return c_base_return_error::s_false();
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->pr_rfc_string_is_media_type', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ return c_base_return_error::s_false($error);
}
unset($parsed['invalid']);
unset($parsed['current']);
if ($append) {
+ if (!isset($this->response[self::RESPONSE_ACCEPT_PATCH]) || !is_array($this->response[self::RESPONSE_ACCEPT_PATCH])) {
+ $this->response[self::RESPONSE_ACCEPT_PATCH] = array();
+ }
+
$this->response[self::RESPONSE_ACCEPT_PATCH][] = $parsed;
}
else {
*/
public function set_response_accept_ranges($ranges) {
if (!is_string($ranges)) {
- return c_base_return_error::s_false();
+ $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);
}
$parsed = $this->p_prepare_token($ranges);
if ($parsed === FALSE) {
unset($parsed);
- return c_base_return_error::s_false();
+
+ $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);
}
$this->response[self::RESPONSE_ACCEPT_RANGES] = $parsed;
*/
public function set_response_age($seconds) {
if (!is_int($seconds)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->response[self::RESPONSE_AGE] = $seconds;
*/
public function set_response_allow($allow, $append = TRUE) {
if (!is_int($allow)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
switch ($allow) {
case self::HTTP_METHOD_DEBUG:
break;
default:
- return c_base_return_error::s_false();
+ $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 ($allow == self::HTTP_METHOD_NONE) {
}
if ($append) {
+ if (!isset($this->response[self::RESPONSE_ALLOW]) || !is_array($this->response[self::RESPONSE_ALLOW])) {
+ $this->response[self::RESPONSE_ALLOW] = array();
+ }
+
$this->response[self::RESPONSE_ALLOW][$allow] = $allow;
}
else {
*/
public function set_response_cache_control($directive_name, $directive_value = NULL, $append = TRUE) {
if (!is_int($directive_name)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
switch($directive_name) {
break;
default:
- return c_base_return_error::s_false();
+ $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);
}
$parsed_directive_value = NULL;
if ($text['invalid']) {
unset($text);
- return c_base_return_error::s_false();
+ $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);
}
$parsed = $this->pr_rfc_string_is_token_quoted($text['ordinals'], $text['characters']);
if ($parsed['invalid']) {
unset($parsed);
- return c_base_return_error::s_false();
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->pr_rfc_string_is_token_quoted', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ return c_base_return_error::s_false($error);
}
unset($parsed);
}
if ($append) {
+ if (!isset($this->response[self::RESPONSE_CACHE_CONTROL]) || !is_array($this->response[self::RESPONSE_CACHE_CONTROL])) {
+ $this->response[self::RESPONSE_CACHE_CONTROL] = array();
+ }
+
$this->response[self::RESPONSE_CACHE_CONTROL][$directive_name] = $directive_value;
}
else {
/**
* Assign HTTP response header: connection.
*
- * @param string $header_name
- * The header name to assign as a connection-specific field.
+ * @param string $connection_option
+ * The connection option to assign as a connection-specific field.
* These header fields apply only to the immediate client.
* The header name format is:
* - 1*(tchar)
*
* @see: https://tools.ietf.org/html/rfc7230#section-6.1
*/
- public function set_response_connection($header_name, $append = TRUE) {
- if (!is_string($header_name)) {
- return c_base_return_error::s_false();
+ 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);
+ return c_base_return_error::s_false($error);
}
if (!is_bool($append)) {
- return c_base_return_error::s_false();
+ $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);
}
- $parsed = $this->p_prepare_token($header_name);
+ $parsed = $this->p_prepare_token($connection_option);
if ($parsed === FALSE) {
unset($parsed);
- return c_base_return_error::s_false();
+
+ $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);
}
if ($append) {
+ if (!isset($this->response[self::RESPONSE_CONNECTION]) || !is_array($this->response[self::RESPONSE_CONNECTION])) {
+ $this->response[self::RESPONSE_CONNECTION] = array();
+ }
+
$this->response[self::RESPONSE_CONNECTION][$parsed] = $parsed;
}
else {
*/
public function set_response_content($content, $append = TRUE, $is_file = FALSE) {
if (!is_string($content)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
if ($append) {
*/
public function set_response_content_disposition($disposition) {
// @todo
- return new c_base_return_false();
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response content disposition', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ return c_base_return_error::s_false($error);
}
/**
*
* @param int $encoding
* The encoding to assign to the specified header.
- * @param bool $append
- * (optional) If TRUE, then append the header name.
- * If FALSE, then assign the header name.
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
* @see: https://tools.ietf.org/html/rfc7231#section-3.1.2.2
* @see: https://tools.ietf.org/html/rfc7230#section-3.3.1
*/
- public function set_response_content_encoding($encoding, $append = TRUE) {
+ public function set_response_content_encoding($encoding) {
if (!is_int($encoding)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
switch ($encoding) {
case self::ENCODING_PG:
break;
default:
- return c_base_return_error::s_false();
+ $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);
}
$this->response[self::RESPONSE_CONTENT_ENCODING] = $encoding;
*/
public function set_response_content_language($language = NULL) {
if (!is_null($language) && !is_int($language)) {
- return c_base_return_error::s_false();
+ $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_null($language)) {
if (!is_object($this->language_class) || !($this->language_class instanceof i_base_language)) {
- return c_base_return_error::s_false();
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->language_class', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_VARIABLE);
+ return c_base_return_error::s_false($error);
}
$default = $this->language_class->s_get_default_id();
if ($default instanceof c_base_return_false) {
unset($default);
- return c_base_return_error::s_false();
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->language_class->s_get_default_id', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ return c_base_return_error::s_false($error);
}
$this->response[self::RESPONSE_CONTENT_LANGUAGE] = $default;
}
else {
if ($language_class->s_get_names_by_id($language) instanceof c_base_return_false) {
- return c_base_return_error::s_false();
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'language_class->s_get_names_by_id', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ return c_base_return_error::s_false($error);
}
$this->response[self::RESPONSE_CONTENT_LANGUAGE] = $language;
*/
public function set_response_content_length($length = NULL) {
if (!is_null($length) && !is_int($length) || $length < 0) {
- return c_base_return_error::s_false();
+ $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);
}
// From the RFC: "A sender MUST NOT send a Content-Length header field in any message that contains a Transfer-Encoding header field."
foreach ($this->content as $filename) {
if (!file_exists($filename)) {
unset($filename);
- // @todo: provide a file not found error.
- return c_base_return_error::s_false();
+
+ $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);
}
$this->response[self::RESPONSE_CONTENT_LENGTH] += filesize($filename);
*/
public function set_response_content_range($value) {
// @todo
- return new c_base_return_false();
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response content range', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ return c_base_return_error::s_false($error);
}
/**
*/
public function set_response_content_type($content_type, $charset = c_base_charset::UTF_8) {
if (!is_string($content_type)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
// perform a very basic syntax check.
if (strpos($content_type, ';')) {
- return c_base_return_error::s_false();
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':format_name' => 'content_type', ':expected_format' => '. Semi-colons are not allowed.', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_FORMAT);
+ return c_base_return_error::s_false($error);
}
$content_type_part = mb_split('/', $content_type);
if (count($content_type_part) != 2) {
unset($content_type_part);
- return c_base_return_error::s_false();
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'mb_split', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ return c_base_return_error::s_false($error);
}
unset($content_type_part);
}
if (!is_int($timestamp) && !is_float($timestamp)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->response[self::RESPONSE_DATE] = $timestamp;
}
if (!is_int($timestamp) && !is_float($timestamp)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->response[self::RESPONSE_DATE_ACTUAL] = $timestamp;
*/
public function set_response_etag($entity_tag = NULL, $weak = FALSE) {
if (!is_null($entity_tag) && !is_string($entity_tag) && $entity_tag !== FALSE) {
- return c_base_return_error::s_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);
+ return c_base_return_error::s_false($error);
}
$response = array(
unset($hash);
unset($response);
- // @todo: report file not found or other related errors.
- return c_base_return_error::s_false();
+ $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);
}
$success = hash_update_file($hash, $filename);
unset($hash);
unset($response);
- // @todo: report failure to hash file.
- return c_base_return_error::s_false();
+ $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);
*/
public function set_response_expires($timestamp) {
if (!is_int($timestamp) && !is_float($timestamp)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->response[self::RESPONSE_EXPIRES] = $timestamp;
*/
public function set_response_last_modified($timestamp) {
if (!is_int($timestamp) && !is_float($timestamp)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->response[self::RESPONSE_LAST_MODIFIED] = $timestamp;
*/
public function set_response_link($uri) {
if (!is_string($uri)) {
- return c_base_return_error::s_false();
+ $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);
}
#$parsed = $this->p_parse_uri($uri);
// @todo
- return new c_base_return_false();
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response link', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ return c_base_return_error::s_false($error);
}
/**
*/
public function set_response_location($uri) {
if (!is_string($uri)) {
- return c_base_return_error::s_false();
+ $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);
}
$parsed = $this->p_parse_uri($uri);
if ($parsed['invalid']) {
unset($parsed);
- return c_base_return_error::s_false();
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'this->p_parse_uri', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ return c_base_return_error::s_false($error);
}
unset($parsed['invalid']);
*/
public function set_response_pragma($value) {
// @todo
- return new c_base_return_false();
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response pragma', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ return c_base_return_error::s_false($error);
}
/**
*/
public function set_response_proxy_authenticate($value) {
// @todo
- return new c_base_return_false();
+
+ $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
- return new c_base_return_false();
+
+ $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
- return new c_base_return_false();
+
+ $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);
}
/**
* @see: https://tools.ietf.org/html/rfc7231#section-7.1.3
*/
public function set_response_retry_after($date, $seconds = FALSE) {
- if (!is_int($date) || !is_float($timestamp)) {
- return c_base_return_error::s_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);
+ return c_base_return_error::s_false($error);
}
if (!is_bool($seconds)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->response[self::RESPONSE_RETRY_AFTER] = array(
*/
public function set_response_server($value) {
// @todo
- return new c_base_return_false();
+
+ $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);
}
/**
- * Assign HTTP response header: set_cookie.
+ * Assign HTTP response header: set-cookie.
*
- * @param ?? $value
- * The value to assign to the specified header.
+ * @param c_base_cookie $cookie
+ * The cookie object to assign as a cookie.
+ * These header fields apply only to the immediate client.
+ * The header name format is:
+ * - 1*(tchar)
+ * @param bool $append
+ * (optional) If TRUE, then append the header name.
+ * If FALSE, then assign the header name.
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
* FALSE with error bit set is returned on error.
+ *
+ * @see: https://tools.ietf.org/html/rfc6265
*/
- public function set_response_set_cookie($value) {
- // @todo
- return new c_base_return_false();
+ 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);
+ 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);
+ return c_base_return_error::s_false($error);
+ }
+
+ $cookie_name = $cookie->get_name()->get_value_exact();
+ if ($append) {
+ if (!isset($this->response[self::RESPONSE_SET_COOKIE]) || !is_array($this->response[self::RESPONSE_SET_COOKIE])) {
+ $this->response[self::RESPONSE_SET_COOKIE] = array();
+ }
+
+ $this->response[self::RESPONSE_SET_COOKIE][$cookie_name] = $cookie;
+ }
+ else {
+ $this->response[self::RESPONSE_SET_COOKIE] = array($cookie_name => $cookie);
+ }
+ unset($cookie_name);
+
+ return new c_base_return_true();
}
/**
*/
public function set_response_status($code) {
if (!is_int($code)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->response[self::RESPONSE_STATUS] = $code;
*/
public function set_response_strict_transport_security($value) {
// @todo
- return new c_base_return_false();
+
+ $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
- return new c_base_return_false();
+
+ $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);
}
/**
// RESPONSE_TRANSFER_ENCODING
// @todo
- return new c_base_return_false();
+
+ $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
- return new c_base_return_false();
+
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
+ return c_base_return_error::s_false($error);
}
$parsed = $this->p_prepare_token($header_name);
if ($parsed === FALSE) {
unset($parsed);
- return c_base_return_error::s_false();
+ $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);
}
if ($append) {
+ if (!isset($this->response[self::RESPONSE_VARY]) || !is_array($this->response[self::RESPONSE_VARY])) {
+ $this->response[self::RESPONSE_VARY] = array();
+ }
+
$this->response[self::RESPONSE_VARY][$parsed] = $parsed;
}
else {
*/
public function set_response_warning($value) {
// @todo
- return new c_base_return_false();
+
+ $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
- return new c_base_return_false();
+
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->response[self::RESPONSE_PROTOCOL] = $protocol;
*/
public function set_response_content_security_policy($value) {
// @todo
- return new c_base_return_false();
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response content security policy', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ return c_base_return_error::s_false($error);
}
/**
*/
public function set_response_x_content_type_options($value) {
// @todo
- return new c_base_return_false();
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response content type options', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ return c_base_return_error::s_false($error);
}
/**
*/
public function set_response_x_ua_compatible($value) {
// @todo
- return new c_base_return_false();
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response ua compatible', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ 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)) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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) || !is_int($type) || !is_string($checksum)) {
- return c_base_return_error::s_false();
+ 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);
+ 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);
+ 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);
+ return c_base_return_error::s_false($error);
}
if ($what != self::CHECKSUM_WHAT_PARTIAL && $what != self::CHECKSUM_WHAT_FULL) {
- return c_base_return_error::s_false();
+ $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);
}
switch ($type) {
case CHECKSUM_PG:
break;
default:
- return c_base_return_error::s_false();
+ $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);
}
$this->response[self::RESPONSE_CHECKSUM_HEADER] = array(
);
}
else {
- if (!is_null($what) || !is_null($type) || !is_null($checksum)) {
- return c_base_return_error::s_false();
+ 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);
+ 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);
+ 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);
+ return c_base_return_error::s_false($error);
}
$this->response[self::RESPONSE_CHECKSUM_HEADER] = array(
*/
public function set_response_checksum_headers($header_name, $append = TRUE) {
if (!is_string($header_name)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
$parsed = $this->p_prepare_token($header_name);
if ($parsed === FALSE) {
unset($parsed);
- return c_base_return_error::s_false();
+ $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);
}
if ($append) {
+ if (!isset($this->response[self::RESPONSE_CHECKSUM_HEADERS]) || !is_array($this->response[self::RESPONSE_CHECKSUM_HEADERS])) {
+ $this->response[self::RESPONSE_CHECKSUM_HEADERS] = array();
+ }
+
$this->response[self::RESPONSE_CHECKSUM_HEADERS][$parsed] = $parsed;
}
else {
*/
public function set_response_checksum_content($action = self::CHECKSUM_ACTION_AUTO, $what = NULL, $type = NULL, $checksum = NULL) {
if (!is_int($action)) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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) || !is_int($type) || !is_string($checksum)) {
- return c_base_return_error::s_false();
+ 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);
+ 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);
+ 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);
+ return c_base_return_error::s_false($error);
}
if ($what != self::CHECKSUM_WHAT_PARTIAL && $what != self::CHECKSUM_WHAT_FULL) {
- return c_base_return_error::s_false();
+ $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);
}
switch ($type) {
case CHECKSUM_PG:
break;
default:
- return c_base_return_error::s_false();
+ $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);
}
$this->response[self::RESPONSE_CHECKSUM_CONTENT] = array(
);
}
else {
- if (!is_null($what) || !is_null($type) || !is_null($checksum)) {
- return c_base_return_error::s_false();
+ 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);
+ 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);
+ 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);
+ return c_base_return_error::s_false($error);
}
$this->response[self::RESPONSE_CHECKSUM_CONTENT] = array(
*/
public function set_response_content_revision($revision) {
if (!is_int($revision)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->response[self::RESPONSE_CONTENT_REVISION] = $revision;
*/
public function unset_response_value($response_id) {
if (!is_int($response_id)) {
- return c_base_return_error::s_false();
+ $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);
}
if (array_key_exists($response_id, $this->response)) {
* @todo: I only glanced at the documentation (which was incomplete on wikipedia).
* More work is likely needed to be done with this and its structure is subject to change.
*
- * @return c_base_return_array|bool
+ * @return c_base_return_array|c_base_return_status
* A decoded uri split into its different parts inside an array.
* This array also contains a key called 'wildcard' which may be either TRUE or FALSE.
* FALSE with error bit set is returned on error, including when the key is not defined.
*/
public function get_response_access_control_allow_origin() {
if (!array_key_exists(self::RESPONSE_ACCESS_CONTROL_ALLOW_ORIGIN, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_array::s_new($this->response[self::RESPONSE_ACCESS_CONTROL_ALLOW_ORIGIN]);
*/
public function get_response_access_control_allow_credentials() {
if (!array_key_exists(self::RESPONSE_ACCESS_CONTROL_ALLOW_CREDENTIALS, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_bool::s_new($this->response[self::RESPONSE_ACCESS_CONTROL_ALLOW_CREDENTIALS]);
*/
public function get_response_access_control_expose_headers() {
if (!array_key_exists(self::RESPONSE_ACCESS_CONTROL_EXPOSE_HEADERS, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_array::s_new($this->response[self::RESPONSE_ACCESS_CONTROL_EXPOSE_HEADERS]);
*/
public function get_response_access_control_max_age() {
if (!array_key_exists(self::RESPONSE_ACCESS_CONTROL_MAX_AGE, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_int::s_new($this->response[self::RESPONSE_ACCESS_CONTROL_MAX_AGE]);
* @todo: I only glanced at the documentation (which was incomplete on wikipedia).
* More work is likely needed to be done with this and its structure is subject to change.
*
- * @return c_base_return_array|bool
+ * @return c_base_return_array|c_base_return_status
* FALSE with error bit set is returned on error, including when the key is not defined.
*
* @see: https://en.wikipedia.org/wiki/Cross-origin_resource_sharing
*/
public function get_response_access_control_allow_methods() {
if (!array_key_exists(self::RESPONSE_ACCESS_CONTROL_ALLOW_METHODS, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_array::s_new($this->response[self::RESPONSE_ACCESS_CONTROL_ALLOW_METHODS]);
*/
public function get_response_access_control_allow_headers() {
if (!array_key_exists(self::RESPONSE_ACCESS_CONTROL_ALLOW_HEADERS, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_array::s_new($this->response[self::RESPONSE_ACCESS_CONTROL_ALLOW_HEADERS]);
*/
public function get_response_accept_patch() {
if (!array_key_exists(self::RESPONSE_ACCEPT_PATCH, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_array::s_new($this->response[self::RESPONSE_ACCEPT_PATCH]);
*/
public function get_response_accept_ranges() {
if (!array_key_exists(self::RESPONSE_ACCEPT_RANGES, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_string::s_new($this->response[self::RESPONSE_ACCEPT_RANGES]);
*/
public function get_response_age() {
if (!array_key_exists(self::RESPONSE_AGE, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_int::s_new($this->response[self::RESPONSE_AGE]);
*/
public function get_response_allow() {
if (!array_key_exists(self::RESPONSE_ALLOW, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_array::s_new($this->response[self::RESPONSE_ALLOW]);
*/
public function get_response_cache_control() {
if (!array_key_exists(self::RESPONSE_CACHE_CONTROL, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_array::s_new($this->response[self::RESPONSE_CACHE_CONTROL]);
/**
* Obtain HTTP response header: connection.
*
- * @return c_base_return_array|bool
+ * @return c_base_return_array|c_base_return_status
* An array of header names assigned to the connection header.
* The header name format is:
* - 1*(tchar)
*/
public function get_response_connection() {
if (!array_key_exists(self::RESPONSE_CONNECTION, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_array::s_new($this->response[self::RESPONSE_CONNECTION]);
*/
public function get_response_content_disposition() {
if (!array_key_exists(self::RESPONSE_CONTENT_DISPOSITION, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
// @todo
- return c_base_return_error::s_false();
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response content disposition', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ return c_base_return_error::s_false($error);
}
/**
*/
public function get_response_content_encoding() {
if (!array_key_exists(self::RESPONSE_CONTENT_ENCODING, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_int::s_new($this->response[self::RESPONSE_CONTENT_ENCODING]);
*/
public function get_response_content_language() {
if (!array_key_exists(self::RESPONSE_CONTENT_LANGUAGE, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_int::s_new($this->response[self::RESPONSE_CONTENT_LANGUAGE]);
*/
public function get_response_content_length() {
if (!array_key_exists(self::RESPONSE_CONTENT_LENGTH, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_int::s_new($this->response[self::RESPONSE_CONTENT_LENGTH]);
*/
public function get_response_content_range() {
if (!array_key_exists(self::RESPONSE_CONTENT_RANGE, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
// @todo
- return c_base_return_error::s_false();
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response content range', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ return c_base_return_error::s_false($error);
}
/**
*/
public function get_response_content_type() {
if (!array_key_exists(self::RESPONSE_CONTENT_TYPE, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_array::s_new($this->response[self::RESPONSE_CONTENT_TYPE]);
*/
public function get_response_date() {
if (!array_key_exists(self::RESPONSE_DATE, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
if (is_float($this->response[self::RESPONSE_DATE])) {
*/
public function get_response_date_actual() {
if (!array_key_exists(self::RESPONSE_DATE_ACTUAL, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
if (is_float($this->response[self::RESPONSE_DATE_ACTUAL])) {
*/
public function get_response_etag() {
if (!array_key_exists(self::RESPONSE_ETAG, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_array::s_new($this->response[self::RESPONSE_ETAG]);
*/
public function get_response_expires() {
if (!array_key_exists(self::RESPONSE_EXPIRES, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
if (is_float($this->response[self::RESPONSE_EXPIRES])) {
*/
public function get_response_last_modified() {
if (!array_key_exists(self::RESPONSE_LAST_MODIFIED, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
if (is_float($this->response[self::RESPONSE_LAST_MODIFIED])) {
*/
public function get_response_link() {
if (!array_key_exists(self::RESPONSE_LINK, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
// @todo
- return c_base_return_error::s_false();
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response link', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ return c_base_return_error::s_false($error);
}
/**
*/
public function get_response_location() {
if (!array_key_exists(self::RESPONSE_LOCATION, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_string::s_new($this->response[self::RESPONSE_LOCATION]);
*/
public function get_response_pragma() {
if (!array_key_exists(self::RESPONSE_PRAGMA, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
// @todo
- return c_base_return_error::s_false();
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response pragma', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ return c_base_return_error::s_false($error);
}
/**
*/
public function get_response_proxy_authenticate() {
if (!array_key_exists(self::RESPONSE_PROXY_AUTHENTICATE, $this->response)) {
- return c_base_return_error::s_false();
+ $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
- return c_base_return_error::s_false();
+
+ $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)) {
- return c_base_return_error::s_false();
+ $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
- return c_base_return_error::s_false();
+
+ $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)) {
- return c_base_return_error::s_false();
+ $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
- return c_base_return_error::s_false();
+
+ $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)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_array::s_new($this->response[self::RESPONSE_RETRY_AFTER]);
}
/**
- * Obtain HTTP response header: server.
+ * Obtain HTTP response header: set-cookie.
*
- * @return ??|c_base_return_status
+ * @return c_base_cookie|c_base_return_status
* FALSE with error bit set is returned on error, including when the key is not defined.
*
- * @see: https://tools.ietf.org/html/rfc7231#section-7.4.2
+ * @see: https://tools.ietf.org/html/rfc6265
*/
- public function get_response_server() {
- if (!array_key_exists(self::RESPONSE_SERVER, $this->response)) {
- return c_base_return_error::s_false();
+ 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);
+ return c_base_return_error::s_false($error);
}
- // @todo
- return c_base_return_error::s_false();
+ return $this->response[self::RESPONSE_SET_COOKIE];
}
/**
- * Obtain HTTP response header: get_cookie.
- *
- * @todo: cookie might needs special handling because PHP handles it in a different way from other headers.
+ * Obtain HTTP response header: server.
*
* @return ??|c_base_return_status
* FALSE with error bit set is returned on error, including when the key is not defined.
+ *
+ * @see: https://tools.ietf.org/html/rfc7231#section-7.4.2
*/
- public function get_response_cookie() {
- if (!array_key_exists(self::RESPONSE_COOKIE, $this->response)) {
- return c_base_return_error::s_false();
+ 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);
+ return c_base_return_error::s_false($error);
}
// @todo
- return c_base_return_error::s_false();
+
+ $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)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_int::s_new($this->response[self::RESPONSE_STATUS]);
*/
public function get_response_strict_transport_security() {
if (!array_key_exists(self::RESPONSE_STRICT_TRANSPORT_SECURITY, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
// @todo
- return c_base_return_error::s_false();
+
+ $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)) {
- return c_base_return_error::s_false();
+ $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
- return c_base_return_error::s_false();
+
+ $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)) {
- return c_base_return_error::s_false();
+ $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
- return c_base_return_error::s_false();
+
+ $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)) {
- return c_base_return_error::s_false();
+ $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
- return c_base_return_error::s_false();
+
+ $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)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_array::s_new($this->response[self::RESPONSE_VARY]);
*/
public function get_response_warning() {
if (!array_key_exists(self::RESPONSE_WARNING, $this->response)) {
- return c_base_return_error::s_false();
+ $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
- return c_base_return_error::s_false();
+
+ $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)) {
- return c_base_return_error::s_false();
+ $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
- return c_base_return_error::s_false();
+
+ $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)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_string::s_new($this->response[self::RESPONSE_PROTOCOL]);
*/
public function get_response_content_security_policy() {
if (!array_key_exists(self::RESPONSE_X_CONTENT_SECURITY_POLICY, $this->response)) {
- return c_base_return_error::s_false();
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_X_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_false($error);
}
// @todo
- return c_base_return_error::s_false();
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response content security policy', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ return c_base_return_error::s_false($error);
}
/**
*/
public function get_response_x_content_type_options() {
if (!array_key_exists(self::RESPONSE_X_CONTENT_TYPE_OPTIONS, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
// @todo
- return c_base_return_error::s_false();
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response content type options', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ return c_base_return_error::s_false($error);
}
/**
*/
public function get_response_x_ua_compatible() {
if (!array_key_exists(self::RESPONSE_X_UA_COMPATIBLE, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
// @todo
- return c_base_return_error::s_false();
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':functionality_name' => 'http response ua compatible', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NO_SUPPORT);
+ return c_base_return_error::s_false($error);
}
/**
*/
public function get_response_checksum_header() {
if (!array_key_exists(self::RESPONSE_CHECKSUM_HEADER, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_array::s_new($this->response[self::RESPONSE_CHECKSUM_HEADERS]);
*/
public function get_response_checksum_headers() {
if (!array_key_exists(self::RESPONSE_CHECKSUM_HEADERS, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_array::s_new($this->response[self::RESPONSE_CHECKSUM_HEADERS]);
*/
public function get_response_checksum_content() {
if (!array_key_exists(self::RESPONSE_CHECKSUM_CONTENT, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_array::s_new($this->response[self::RESPONSE_CHECKSUM_CONTENT]);
*/
public function get_response_content_revision() {
if (!array_key_exists(self::RESPONSE_CONTENT_REVISION, $this->response)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
return c_base_return_int::s_new($this->response[self::RESPONSE_CONTENT_REVISION]);
*/
public function send_response_headers($shuffle = TRUE) {
if (!is_bool($shuffle)) {
- return c_base_return_error::s_false();
- }
-
- if ($this->headers_sent) {
- return c_base_return_false;
+ $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 (headers_sent()) {
- return c_base_return_error::s_false();
+ 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);
+ return c_base_return_error::s_false($error);
}
$header_id_to_names = $this->p_get_header_response_mapping(TRUE);
$this->p_prepare_header_response_refresh($header_output);
$this->p_prepare_header_response_retry_after($header_output);
$this->p_prepare_header_response_server($header_output);
-
- // @todo: how is cookie going to be handled?
-
+ $this->p_prepare_header_response_set_cookie($header_output);
$this->p_prepare_header_response_strict_transport_security($header_output);
$this->p_prepare_header_response_trailer($header_output);
$this->p_prepare_header_response_transfer_encoding($header_output);
// send header output.
foreach ($headers as $header_id => $header_name) {
if (array_key_exists($header_id, $header_output)) {
- header($header_output[$header_id]);
+ if (is_array($header_output[$header_id])) {
+ foreach ($header_output[$header_id] as $sub_header) {
+ header($sub_header);
+ }
+ unset($sub_header);
+ }
+ else {
+ header($header_output[$header_id]);
+ }
}
}
unset($output);
*/
public function encode_response_content($compression = NULL, $max_filesize = NULL) {
if (!is_null($compression) && !is_int($compression)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
$encoding = $this->p_determine_response_encoding();
unset($encoding);
unset($filename);
unset($content);
- // @todo: provide a warning about missing files.
- return c_base_return_error::s_false();
+
+ $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);
}
$content .= file_get_contents($filename);
unset($encoding);
unset($filename);
unset($content);
- // @todo: provide a warning about missing files.
- return c_base_return_error::s_false();
+
+ $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);
}
$content_length += filesize($filename);
foreach ($this->content as $filename) {
if (!file_exists($filename)) {
unset($filename);
- // @todo: provide a warning about missing files.
- return c_base_return_error::s_false();
+
+ $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);
}
$opened_file = fopen($filename, 'rb');
if ($opened_file === FALSE) {
unset($filename);
- // @todo: provide a warning about unable to open file.
- return c_base_return_error::s_false();
+
+ $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);
}
fpassthru($opened_file);
return;
}
- $parsed = pr_rfc_string_is_digit($text['ordinals'], $text['characters']);
+ $parsed = $this->pr_rfc_string_is_digit($text['ordinals'], $text['characters']);
unset($text);
if ($parsed['invalid']) {
}
/**
+ * Prepare HTTP response header: set-cookie.
+ *
+ * @param array $header_output
+ * The header output array to make changes to.
+ *
+ * @see: https://tools.ietf.org/html/rfc6265
+ */
+ private function p_prepare_header_response_set_cookie(&$header_output) {
+ if (!array_key_exists(self::RESPONSE_SET_COOKIE, $this->response) || !is_array($this->response[self::RESPONSE_SET_COOKIE])) {
+ return;
+ }
+
+ $header_output[self::RESPONSE_SET_COOKIE] = array();
+ foreach ($this->response[self::RESPONSE_SET_COOKIE] as $cookie) {
+ if (!($cookie instanceof c_base_cookie)) {
+ continue;
+ }
+
+ $cookie_string = $cookie->get_cookie();
+ if ($cookie_string instanceof c_base_return_string) {
+ $header_output[self::RESPONSE_SET_COOKIE][] = $cookie_string->get_value_exact();
+ }
+ unset($cookie_string);
+ }
+ unset($cookie);
+ }
+
+ /**
* Prepare HTTP response header: server.
*
* @param array $header_output
unset($algorithm);
unset($use_hash);
- // @todo: report file not found or other related errors.
- return c_base_return_error::s_false();
+ $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);
}
$success = hash_update_file($hash, $filename);
* (optional) Determine how the content-length HTTP header is to be calculated:
* - FALSE = do not calculate the content length.
* - TRUE = calculate and store the content length.
+ *
+ * @return bool
+ * TRUE if content was encoded.
+ * FALSE otherwise.
+ *
+ * @see: https://github.com/adsr/php-lzo
+ * @see: http://www.oberhumer.com/opensource/lzo/
+ * @see: http://content.gpwiki.org/index.php/LZO
+ * @see: https://github.com/payden/php-xz
+ * @see: https://github.com/choden/php-xz
*/
private function p_encode_content($content, $encoding, $compression = NULL, $calculate_content_length = TRUE) {
if ($encoding == self::ENCODING_GZIP) {
$this->response[self::RESPONSE_CONTENT_LENGTH] = strlen($this->content);
}
+ return TRUE;
}
elseif ($encoding == self::ENCODING_DEFLATE) {
if (is_null($compression) || $compression < -1) {
if ($calculate_content_length) {
$this->response[self::RESPONSE_CONTENT_LENGTH] = strlen($this->content);
}
+
+ return TRUE;
}
elseif ($encoding == self::ENCODING_BZIP) {
if (is_null($compression) || $compression < -1) {
if ($calculate_content_length) {
$this->response[self::RESPONSE_CONTENT_LENGTH] = strlen($this->content);
}
+
+ return TRUE;
}
elseif ($encoding == self::ENCODING_LZO) {
switch ($compression) {
if ($calculate_content_length) {
$this->response[self::RESPONSE_CONTENT_LENGTH] = strlen($this->content);
}
+
+ return TRUE;
}
elseif ($encoding == self::ENCODING_XZ) {
- // @todo, see: https://github.com/payden/php-xz
+ // @fixme: php-xz module is currently not working.
}
elseif ($encoding == self::ENCODING_EXI) {
// @todo, maybe? (cannot seem to find a php library at this time)
// @todo, using ascii armor on entire body.
// should be a header field containing the public key.
}
+
+ return FALSE;
}
}
+
/**
* A return class whose value is represented as a generic c_base_markup_tag_return.
*/
*/
public static function to_text($status) {
if (!is_int($status)) {
- return c_base_return_error::s_false();
+ $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);
}
$string = "";
*/
static function s_get_names_by_id($id) {
if (!is_int($id) && !is_numeric($id)) {
- return c_base_return_error::s_false();
+ $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 (array_key_exists($id, self::$s_names)) {
*/
static function s_get_names_by_alias($alias) {
if (!is_int($id) && !is_numeric($id)) {
- return c_base_return_error::s_false();
+ $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 (array_key_exists($id, self::$s_aliases)) {
*/
static function s_get_id_by_name($name) {
if (!is_string($name)) {
- return c_base_return_error::s_false();
+ $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 (array_key_exists($name, self::$s_ids)) {
*/
static function s_get_id_by_alias($alias) {
if (!is_string($alias)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
if (array_key_exists($alias, self::$s_ids)) {
*/
static function s_get_aliases_by_id($id) {
if (!is_int($id) && !is_numeric($id)) {
- return c_base_return_error::s_false();
+ $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 (array_key_exists($id, self::$s_aliases)) {
*/
static function s_get_aliases_by_name($name) {
if (!is_string($name)) {
- return c_base_return_error::s_false();
+ $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 (array_key_exists($name, self::$s_aliases)) {
*/
static function s_get_names_by_id($id) {
if (!is_int($id) && !is_numeric($id)) {
- return c_base_return_error::s_false();
+ $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 (array_key_exists($id, self::$s_names)) {
*/
static function s_get_names_by_alias($alias) {
if (!is_int($id) && !is_numeric($id)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
if (array_key_exists($id, self::$s_aliases)) {
*/
static function s_get_id_by_name($name) {
if (!is_string($name)) {
- return c_base_return_error::s_false();
+ $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 (array_key_exists($name, self::$s_ids)) {
*/
static function s_get_id_by_alias($alias) {
if (!is_string($alias)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
if (array_key_exists($alias, self::$s_ids)) {
*/
static function s_get_aliases_by_id($id) {
if (!is_int($id) && !is_numeric($id)) {
- return c_base_return_error::s_false();
+ $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 (array_key_exists($id, self::$s_aliases)) {
*/
static function s_get_aliases_by_name($name) {
if (!is_string($name)) {
- return c_base_return_error::s_false();
+ $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 (array_key_exists($name, self::$s_aliases)) {
*/
static function s_get_names_by_id($id) {
if (!is_int($id) && !is_numeric($id)) {
- return c_base_return_error::s_false();
+ $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 (array_key_exists($id, self::$s_names)) {
*/
static function s_get_names_by_alias($alias) {
if (!is_int($id) && !is_numeric($id)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
if (array_key_exists($id, self::$s_aliases)) {
*/
static function s_get_id_by_name($name) {
if (!is_string($name)) {
- return c_base_return_error::s_false();
+ $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 (array_key_exists($name, self::$s_ids)) {
*/
static function s_get_id_by_alias($alias) {
if (!is_string($alias)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
if (array_key_exists($alias, self::$s_ids)) {
*/
static function s_get_aliases_by_id($id) {
if (!is_int($id) && !is_numeric($id)) {
- return c_base_return_error::s_false();
+ $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 (array_key_exists($id, self::$s_aliases)) {
*/
static function s_get_aliases_by_name($name) {
if (!is_string($name)) {
- return c_base_return_error::s_false();
+ $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 (array_key_exists($name, self::$s_aliases)) {
*/
public function set_name($name) {
if (!is_string($name) || empty($name)) {
- return c_base_return_error::s_false();
+ $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);
}
// sanitize the name string.
$parsed = parse_url($name, PHP_URL_HOST);
if ($parsed === FALSE) {
unset($parsed);
- return c_base_return_error::s_false();
+ $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);
}
$this->name = preg_replace('/(^\s+)|(\s+$)/us', '', $parsed);
*/
public function set_bind_name($name) {
if (!is_null($name) && (!is_string($name) || empty($name))) {
- return c_base_return_error::s_false();
+ $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);
}
$this->bind_name = $name;
*/
public function set_bind_password($password) {
if (!is_null($password) && (!is_string($password) || empty($password))) {
- return c_base_return_error::s_false();
+ $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);
}
$this->bind_password = $password;
*/
public function do_connect() {
if (is_null($this->name)) {
- return c_base_return_error::s_false();
+ $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);
}
// already prepared, just return true.
$this->ldap = ldap_connect($this->name);
if (!is_resource($this->ldap)) {
$this->ldap = NULL;
- return c_base_return_error::s_false();
+
+ $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);
}
$bound = ldap_bind($this->ldap, $this->bind_name, $this->bind_password);
}
unset($bound);
- return c_base_return_error::s_false();
+ $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);
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
// To prevent flooding the logs, prepend @ to prevent errors from being printed as described by the PHP documentation.
}
unset($found);
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ 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);
+ 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);
+ return c_base_return_error::s_false($error);
}
if (!is_array($attributes)) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
// To prevent flooding the logs, prepend @ to prevent errors from being printed as described by the PHP documentation.
}
unset($found);
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ 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);
+ 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);
+ return c_base_return_error::s_false($error);
}
if (!is_array($attributes)) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
// To prevent flooding the logs, prepend @ to prevent errors from being printed as described by the PHP documentation.
}
unset($found);
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
+ 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);
+ return c_base_return_error::s_false($error);
}
- if (!is_string($directory_name) || !is_string($attribute) || !is_string($value)) {
- return c_base_return_error::s_false();
+ 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);
+ return c_base_return_error::s_false($error);
}
$result = ldap_compare($this->ldap, $domain, $attribute, $value);
if ($result === -1) {
unset($result);
- return c_base_return_error::s_false();
+
+ $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);
}
if ($result === TRUE) {
*/
public function get_error_message() {
if (!is_resource($this->ldap)) {
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_string::s_new(ldap_error($this->ldap));
*/
public function get_error_number() {
if (!is_resource($this->ldap)) {
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_string::s_new(ldap_errno($this->ldap));
*/
public function get_option($option) {
if (!is_resource($this->ldap)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
- return c_base_return_error::s_false();
+ $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);
}
if ($option == LDAP_OPT_DEREF || $option == LDAP_OPT_SIZELIMIT || $option == LDAP_OPT_TIMELIMIT || $option == LDAP_OPT_NETWORK_TIMEOUT || $option == LDAP_OPT_PROTOCOL_VERSION || $option == LDAP_OPT_ERROR_NUMBER) {
*/
public function set_ldap($ldap) {
if (!is_resource($ldap)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->ldap = $ldap;
*/
public function get_count() {
if (!is_resource($ldap)) {
- return c_base_return_error::s_false();
+ $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);
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_int::s_new($total);
*/
public function load_entry_first() {
if (!is_resource($this->ldap)) {
- return c_base_return_error::s_false();
+ $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);
- return c_base_return_error::s_false();
+ $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);
}
$this->entry = $first;
*/
public function load_entry_next() {
if (!is_resource($this->ldap)) {
- return c_base_return_error::s_false();
+ $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 is false when there are no entries remaining.
// the entry must first be loaded by self::load_entry_first().
if (!is_null($this->entry)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->entry = ldap_next_entry($this->ldap, $this->value);
*/
public function get_entry_all() {
if (!is_resource($this->ldap)) {
- return c_base_return_error::s_false();
+ $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);
}
$entries = ldap_get_entries($this->ldap, $this->value);
if ($entries === FALSE) {
unset($entries);
- return c_base_return_error::s_false();
+
+ $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);
}
return c_base_return_array::s_new($entries);
*/
public function get_attribute_first() {
if (!is_resource($this->ldap)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
$attribute = ldap_first_attribute($this->ldap, $this->entry);
if ($attribute === FALSE) {
unset($attribute);
- return c_base_return_error::s_false();
+
+ $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);
}
return c_base_return_string::s_new($attribute);
*/
public function get_attribute_next() {
if (!is_resource($this->ldap)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
$attribute = ldap_next_attribute($this->ldap, $this->entry);
if ($attribute === FALSE) {
unset($attribute);
- return c_base_return_error::s_false();
+
+ $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);
}
return c_base_return_string::s_new($attribute);
*/
public function get_attribute_all() {
if (!is_resource($this->ldap)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
$attributes = ldap_get_attributes($this->ldap, $this->entry);
if ($attributes === FALSE) {
unset($attributes);
- return c_base_return_error::s_false();
+
+ $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);
}
return c_base_return_array::s_new($attributes);
*/
public function get_directory_name() {
if (!is_resource($this->ldap)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
$directory_name = ldap_get_dn($this->ldap, $this->entry);
if ($directory_name === FALSE) {
unset($directory_name);
- return c_base_return_error::s_false();
+
+ $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);
}
return c_base_return_string::s_new($directory_name);
*/
public function get_values($attribute, $binary = FALSE) {
if (!is_resource($this->ldap)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
+ return c_base_return_error::s_false($error);
}
if ($binary) {
if (!is_array($values)) {
unset($values);
- return c_base_return_error::s_false();
+
+ $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);
}
return c_base_return_array::s_new($values);
*/
public function do_sort($attribute) {
if (!is_resource($this->ldap)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
$status = ldap_sort($this->ldap, $this->value, $attribute);
if ($status === FALSE) {
unset($status);
- return c_base_return_error::s_false();
+
+ $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 c_base_return_status
* TRUE is returned on success, FALSE is returned if nothing to free.
- * FALSE with the error flag set is returned on error.
+ * FALSE with the error bit set is returned on error.
*
* @see: ldap_free_result()
*/
return new c_base_return_true();
}
- return c_base_return_error::s_false();
+ $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);
}
}
*/
public function set_type($type) {
if (!is_int($type) || $type < 0) {
- return c_base_return_error::s_false();
+ $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);
}
$this->type = $type;
*/
public function get_data_jsonized($options = 0, $depth = 512) {
if (!is_int($options)) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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);
}
$encoded = json_encode($this->data, $options, $depth)
if ($encoded === FALSE) {
unset($encoded);
- return c_base_return_error::s_false();
+
+ $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);
}
return c_base_return_string::s_new($encoded);
protected function pr_set_data($key, $value) {
if (is_int($key)) {
if ($key < 0) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->data[$key] = $value;
protected function pr_get_data($key) {
if (is_int($key)) {
if ($key < 0) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_value::s_new($this->data[$key]);
* @param $value
* The value of the attribute.
* The actual value type is specific to each attribute type.
- * May be set to NULL to unassign/remove any given attribute.
+ * Set to NULL to unassign/remove any given attribute.
+ * Set to c_base_markup_attributes::ATTRIBUTE_NONE to remove all attribute values.
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
*/
public function set_attribute($attribute, $value) {
if (!is_int($attribute)) {
- return c_base_return_error::s_false();
+ $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_null($value)) {
switch ($attribute) {
case c_base_markup_attributes::ATTRIBUTE_NONE:
+ // when attribute none is specified, the entire attributes array is to be reset.
+ unset($this->attributes);
+ $this->attributes = array();
return new c_base_return_true();
case c_base_markup_attributes::ATTRIBUTE_ABBR:
*/
public function get_attribute($attribute) {
if (!is_int($attribute)) {
- return c_base_return_error::s_false();
+ $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 (!isset($this->attributes) && !is_array($this->attributes)) {
if (array_key_exists($attribute, $this->attributes)) {
switch ($attribute) {
case c_base_markup_attributes::ATTRIBUTE_NONE:
- // should not be possible, so consider this an error (attributes set to NONE are actually unset from the array).
- return c_base_return_error::s_false();
+ // 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);
+ return c_base_return_error::s_false($error);
case c_base_markup_attributes::ATTRIBUTE_ABBR:
case c_base_markup_attributes::ATTRIBUTE_ACCESS_KEY:
*/
public function set_tag($tag, $index = NULL) {
if (!($tag instanceof c_base_markup_tag)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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_array($this->tags)) {
*/
public function unset_tag($index) {
if (!is_null($index) && (!is_int($index) && $index < 0)) {
- return c_base_return_error::s_false();
+ $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_array($this->tags)) {
*/
public function get_tag($index) {
if (!is_int($index) && $index < 0) {
- return c_base_return_error::s_false();
+ $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 (!array_key_exists($index, $this->tags)) {
*/
public function set_text($text) {
if (!is_string($text)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->text = $text;
*/
public function set_type($type) {
if (!is_int($type)) {
- return c_base_return_error::s_false();
+ $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);
}
switch ($type) {
*/
static function s_get_names_by_id($id, $category = NULL) {
if (!is_int($id) && !is_numeric($id)) {
- return c_base_return_error::s_false();
+ $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_null($category)) {
}
else {
if (!is_int($category)) {
- return c_base_return_error::s_false();
+ $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);
}
if ($category == self::CATEGORY_PROVIDED) {
*/
static function s_identify($mime, $lowercase = FALSE) {
if (!is_string($mime)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
if ($lowercase) {
* @require class c_base_error
*/
class c_base_return {
- private $error;
+ private $errors;
/**
* Class constructor.
*/
public function __construct() {
- $this->error = NULL;
+ $this->errors = array();
}
/**
* Class destructor.
*/
public function __destruct() {
- unset($this->error);
+ unset($this->errors);
}
/**
*
* @param null|c_base_error $error
* The error code class defining what the error is.
- * Setting this to NULL will clear the error flag.
+ * Setting this to NULL will clear all errors.
+ * @param null|int $delta
+ * (optional) When an integer, the error is assigned an explicit position in the errors array.
+ * When NULL, the error is appended to the errors array.
*
* @return bool
* TRUE on success, FALSE otherwise.
*/
- public function set_error($error) {
+ public function set_error($error, $delta = NULL) {
if (!is_null($error) && !($error instanceof c_base_error)) {
return FALSE;
}
- $this->error = $error;
+ if (is_null($error)) {
+ $this->errors = array();
+ return TRUE;
+ }
+
+ if (!is_array($this->errors)) {
+ $this->errors = array();
+ }
+
+ if (is_null($delta)) {
+ $this->errors[] = $error;
+ }
+ elseif (is_int($delta) && $delta >= 0) {
+ $this->errors[$delta] = $error;
+ }
+ else {
+ return FALSE;
+ }
+
return TRUE;
}
/**
* Return the error code.
*
- * @return null|c_base_error
- * @todo: finish this once c_base_error is implemented.
+ * @param null|int $delta
+ * (optional) When an integer, the error assigned at the specified position in the errors array is returned.
+ * When NULL, the entire array of errors is retuned.
+ *
+ * @return null|array|c_base_error
+ * When $delta is an integer, an error object is returned.
+ * An array of errors are returned when $delta is NULL.
+ * NULL is returned when there is no error or there is no error at the specified delta.
*/
- public function get_error() {
- if (!($this->error instanceof c_base_error)) {
- $this->error = NULL;
+ public function get_error($delta = NULL) {
+ if (!is_array($this->errors)) {
+ $this->errors = array();
+ }
+
+ if (is_null($delta)) {
+ return $this->errors;
}
- return $this->error;
+ if (array_key_exists($delta, $this->errors)) {
+ if ($this->errors[$delta] instanceof c_base_error) {
+ return $this->errors[$delta];
+ }
+ }
+
+ return NULL;
}
/**
*
* This is similar to get_error(), but should instead be used to to check to see if there is an error and not check what the error is set to.
*
+ * @param null|int $delta
+ * (optional) When an integer, the error assigned at the specified position in the errors array is checked.
+ * When NULL, the entire errors array is checked for any error.
+ *
* @return bool
- * TRUE if an error is assigned and FALSE if no error is assigned.
+ * TRUE if any error is assigned and FALSE if no errors are assigned.
*
* @see: get_error()
*/
- public function has_error() {
+ public function has_error($delta = NULL) {
+ if (is_int($delta) && array_key_exists($delta, $this->errors)) {
+ return ($this->errors[$delta]) instanceof c_base_error;
+ }
+
// when there is no error flag assigned, its value should be NULL so a simple existence check should be all that is needed.
- return $this->error instanceof c_base_error;
+ return !empty($this->errors);
}
/**
/**
* Creates a return boolean TRUE with the error value populated.
*
- * @param c_base_error|null $error
+ * @param c_base_error|array|null $error
* (optional) a custom error.
+ * Can be an array of c_base_error for returning multiple errors.
+ * When NULL, no errors are defined.
*
* @return c_base_return_true
* A c_base_return_true object with the error value populated.
$object_return->set_error($object_error);
unset($object_error);
}
+ elseif (is_array($error)) {
+ foreach ($error as $delta => $value) {
+ $object_return->set_error($error, $delta);
+ }
+ unset($delta);
+ unset($value);
+ }
else {
$object_return->set_error($error);
}
/**
* Creates a return boolean TRUE with the error value populated.
*
- * @param c_base_error|null $error
+ * @param c_base_error|array|null $error
* (optional) a custom error setting.
+ * Can be an array of c_base_error for returning multiple errors.
+ * When NULL, no errors are defined.
*
* @return c_base_return_false
* A c_base_return_true object with the error value populated.
$object_return->set_error($object_error);
unset($object_error);
}
+ elseif (is_array($error)) {
+ foreach ($error as $delta => $value) {
+ $object_return->set_error($error, $delta);
+ }
+ unset($delta);
+ unset($value);
+ }
else {
$object_return->set_error($error);
}
* A custom class name.
* @param c_base_error|null $error
* (optional) a custom error setting.
+ * Can be an array of c_base_error for returning multiple errors.
+ * When NULL, no errors are defined.
*
* @return c_base_return_false|c_base_return_value
* A c_base_return_value object is returned with the error value populated
$object_return->set_error($object_error);
unset($object_error);
}
+ elseif (is_array($error)) {
+ foreach ($error as $delta => $value) {
+ $object_return->set_error($error, $delta);
+ }
+ unset($delta);
+ unset($value);
+ }
else {
$object_return->set_error($error);
}
unset($ordinals);
$characters = c_base_utf8::s_ordinals_to_string_array($result['ordinals']);
- if ($characters instanceof c_base_return_error) {
+ if ($characters instanceof c_base_return_false) {
unset($characters);
$result['invalid'] = TRUE;
return $result;
);
$ordinals = c_base_utf8::s_string_to_ordinals($text);
- if ($ordinals instanceof c_base_return_error) {
+ if ($ordinals instanceof c_base_return_false) {
unset($ordinals);
$result['invalid'] = TRUE;
return $result;
$comment_last = FALSE;
$quote_closed = FALSE;
for (; $result['current'] < $stop; $result['current']++) {
+ if (!array_key_exists($result['current'], $ordinals) || !array_key_exists($result['current'], $characters)) {
+ // @fixme: should error be reported? do some debugging with this.
+ $result['invalid'] = TRUE;
+ break;
+ }
+
$code = $ordinals[$result['current']];
if ($code == c_base_ascii::SLASH_BACKWARD) {
}
for (; $result['current'] < $stop; $result['current']++) {
+ if (!array_key_exists($result['current'], $ordinals) || !array_key_exists($result['current'], $characters)) {
+ // @fixme: should error be reported? do some debugging with this.
+ $result['invalid'] = TRUE;
+ break;
+ }
+
$code = $ordinals[$result['current']];
if ($code == c_base_ascii::QUOTE_DOUBLE) {
}
for (; $result['current'] < $stop; $result['current']++) {
+ if (!array_key_exists($result['current'], $ordinals) || !array_key_exists($result['current'], $characters)) {
+ // @fixme: should error be reported? do some debugging with this.
+ $result['invalid'] = TRUE;
+ break;
+ }
+
$code = $ordinals[$result['current']];
if (!$this->pr_rfc_char_is_digit($code)) {
}
for (; $result['current'] < $stop; $result['current']++) {
+ if (!array_key_exists($result['current'], $ordinals) || !array_key_exists($result['current'], $characters)) {
+ // @fixme: should error be reported? do some debugging with this.
+ $result['invalid'] = TRUE;
+ $result['invalid'] = TRUE;
+ break;
+ }
+
$code = $ordinals[$result['current']];
if (!$this->pr_rfc_char_is_tchar($code)) {
}
for (; $result['current'] < $stop; $result['current']++) {
+ if (!array_key_exists($result['current'], $ordinals) || !array_key_exists($result['current'], $characters)) {
+ // @fixme: should error be reported? do some debugging with this.
+ $result['invalid'] = TRUE;
+ break;
+ }
+
$code = $ordinals[$result['current']];
if (!$this->pr_rfc_char_is_tchar68($code)) {
$not_quoted = FALSE;
for (; $result['current'] < $stop; $result['current']++) {
+ if (!array_key_exists($result['current'], $ordinals) || !array_key_exists($result['current'], $characters)) {
+ // @fixme: should error be reported? do some debugging with this.
+ $result['invalid'] = TRUE;
+ break;
+ }
+
$code = $ordinals[$result['current']];
if ($code == c_base_ascii::QUOTE_DOUBLE) {
}
for (; $result['current'] < $stop; $result['current']++) {
+ if (!array_key_exists($result['current'], $ordinals) || !array_key_exists($result['current'], $characters)) {
+ // @fixme: should error be reported? do some debugging with this.
+ $result['invalid'] = TRUE;
+ break;
+ }
+
$code = $ordinals[$result['current']];
if (!$this->pr_rfc_char_is_digit($code)) {
}
for (; $result['current'] < $stop; $result['current']++) {
+ if (!array_key_exists($result['current'], $ordinals) || !array_key_exists($result['current'], $characters)) {
+ // @fixme: should error be reported? do some debugging with this.
+ $result['invalid'] = TRUE;
+ break;
+ }
+
$code = $ordinals[$result['current']];
if (!$this->pr_rfc_char_is_digit($code)) {
}
for (; $result['current'] < $stop; $result['current']++) {
+ if (!array_key_exists($result['current'], $ordinals) || !array_key_exists($result['current'], $characters)) {
+ // @fixme: should error be reported? do some debugging with this.
+ $result['invalid'] = TRUE;
+ break;
+ }
+
$code = $ordinals[$result['current']];
if (!$this->pr_rfc_char_is_vchar($code) && !$this->pr_rfc_char_is_wsp($code)) {
}
for (; $result['current'] < $stop; $result['current']++) {
+ if (!array_key_exists($result['current'], $ordinals) || !array_key_exists($result['current'], $characters)) {
+ // @fixme: should error be reported? do some debugging with this.
+ $result['invalid'] = TRUE;
+ break;
+ }
+
$code = $ordinals[$result['current']];
if (!$this->pr_rfc_char_is_text($code)) {
}
for (; $result['current'] < $stop; $result['current']++) {
+ if (!array_key_exists($result['current'], $ordinals) || !array_key_exists($result['current'], $characters)) {
+ // @fixme: should error be reported? do some debugging with this.
+ $result['invalid'] = TRUE;
+ break;
+ }
+
$code = $ordinals[$result['current']];
if (!$this->pr_rfc_char_is_atext($code)) {
}
for (; $result['current'] < $stop; $result['current']++) {
+ if (!array_key_exists($result['current'], $ordinals) || !array_key_exists($result['current'], $characters)) {
+ // @fixme: should error be reported? do some debugging with this.
+ $result['invalid'] = TRUE;
+ break;
+ }
+
$code = $ordinals[$result['current']];
if (!$this->pr_rfc_char_is_dtext($code)) {
}
for (; $result['current'] < $stop; $result['current']++) {
+ if (!array_key_exists($result['current'], $ordinals) || !array_key_exists($result['current'], $characters)) {
+ // @fixme: should error be reported? do some debugging with this.
+ $result['invalid'] = TRUE;
+ break;
+ }
+
$code = $ordinals[$result['current']];
if (!$this->pr_rfc_char_is_qtext($code)) {
*/
public function set_system_name($system_name) {
if (!is_string($system_name) || empty($system_name)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->system_name = basename($system_name);
*/
public function set_name($name) {
if (!is_string($name) || empty($name)) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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);
}
$this->name = $name;
*/
public function set_id_user($id_user) {
if ((is_int($id_user) && $id_user < 0) || !is_int($id_user) && (!is_string($id_user) || !(is_numeric($id_user) && (int) $id_user >= 0))) {
- return c_base_return_error::s_false();
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':argument_name' => 'id_user', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
}
$this->id_user = (int) $id_user;
*/
public function set_host($host) {
if (!is_string($host) || empty($host)) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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);
}
$this->host = $host;
*/
public function set_password($password) {
if (!is_null($password) && (!is_string($password) || empty($password))) {
- return c_base_return_error::s_false();
+ $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_null($password)) {
// deny 0-length passwords.
if (mb_strlen($password) == 0) {
- return c_base_return_error::s_false();
+ $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);
}
$this->password = $password;
*/
public function set_settings($settings) {
if (!is_array($settings)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->settings = $settings;
*/
public function set_session_id($session_id) {
if (!is_string($session_id) || empty($session_id)) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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);
}
$this->session_id = $session_id;
*/
public function set_timeout_expire($timeout_expire) {
if (!is_int($timeout_expire)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->timeout_expire = $timeout_expire;
*/
public function set_timeout_max($timeout_max) {
if (!is_int($timeout_max)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->timeout_max = $timeout_max;
*/
public function set_socket_timeout($seconds, $microseconds = 0, $receive = TRUE) {
if (!is_int($seconds) || $seconds < 0) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
if (!is_array($this->socket_timeout)) {
*/
public function get_error_socket() {
if (!is_resource($this->socket)) {
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_int::s_new(@socket_last_error($this->socket));
*/
public function clear_error_socket() {
if (!is_resource($this->socket)) {
- return c_base_return_error::s_false();
+ $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);
}
@socket_clear_error($this->socket);
* @see: c_base_session::do_disconnect()
*/
function do_connect() {
- if (is_resource($this->socket) || is_null($this->system_name)) {
- return c_base_return_error::s_false();
+ 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);
+ 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);
+ return c_base_return_error::s_false($error);
}
$this->socket = socket_create(AF_UNIX, SOCK_STREAM, 0);
if ($this->socket === FALSE) {
$this->do_disconnect();
- return c_base_return_error::s_false();
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_create', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ return c_base_return_error::s_false($error);
}
$connected = @socket_connect($this->socket, $this->socket_path, 0);
if ($connected === FALSE) {
unset($connected);
-
$this->do_disconnect();
- return c_base_return_error::s_false();
+
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_connect', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ return c_base_return_error::s_false($error);
}
unset($connected);
*/
public function do_disconnect() {
if (!is_resource($this->socket)) {
- return c_base_return_error::s_false();
+ $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);
}
@socket_close($this->socket);
* @see: c_base_session::p_transfer()
*/
public function do_pull() {
- if (is_null($this->host) || is_null($this->session_id)) {
- return c_base_return_error::s_false();
+ 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);
+ 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);
+ return c_base_return_error::s_false($error);
}
if (!is_resource($this->socket) || @socket_last_error($this->socket) != 0) {
- return c_base_return_error::s_false();
+ $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);
}
$response = $this->p_transfer(array('ip' => $this->host, 'session_id' => $this->session_id));
if (empty($response['result']) || !is_array($response['result'])) {
unset($response);
- return c_base_return_error::s_false();
+ $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->name = NULL;
* @see: c_base_session::p_transfer()
*/
public function do_push($interval_expire = NULL, $interval_max = NULL) {
- if (is_null($this->name) || is_null($this->id_user) || is_null($this->host) || is_null($this->password)) {
- return c_base_return_error::s_false();
+ 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);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (is_null($this->id_user)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':variable_name' => 'this->id_user', ':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);
+ 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);
+ return c_base_return_error::s_false($error);
}
if (!is_resource($this->socket) || @socket_last_error($this->socket) != 0) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
// settings is allowed to be undefined, so send it as an empty array.
$response = $this->p_transfer(array('name' => $this->name, 'id_user' => $this->id_user, 'ip' => $this->host, 'password' => $this->password, 'expire' => $interval_expire, 'max' => $interval_max, 'settings' => $this->settings));
if (c_base_return::s_has_error($response)) {
- return c_base_return_error::s_false();
+ return c_base_return_error::s_false($response->get_error(0));
}
$response = c_base_return_array::s_value_exact($response);
if (empty($response['result']) || !is_array($response['result'])) {
unset($response);
- return c_base_return_error::s_false();
+ $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->session_id = NULL;
* @see: self::p_transfer()
*/
public function do_terminate() {
- if (is_null($this->host) || is_null($this->session_id)) {
- return c_base_return_error::s_false();
+ 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);
+ 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);
+ return c_base_return_error::s_false($error);
}
if (!is_resource($this->socket) || @socket_last_error($this->socket) != 0) {
- return c_base_return_error::s_false();
+ $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);
}
$response = $this->p_transfer(array('ip' => $this->host, 'session_id' => $this->session_id, 'close' => TRUE));
if (c_base_return::s_has_error($response)) {
- return $response->get_error();
+ return c_base_return_error::s_false($response->get_error(0));
}
$response = c_base_return_array::s_value_exact($response);
if (empty($response['result']) || !is_array($response['result'])) {
unset($response);
- return c_base_return_error::s_false();
+ $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);
}
if (!is_null($this->password)) {
*/
public function do_flush() {
if (!is_resource($this->socket) || @socket_last_error($this->socket) != 0) {
- return c_base_return_error::s_false();
+ $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);
}
$response = $this->p_transfer(array('flush' => TRUE));
if (empty($response['result']) || !is_array($response['result'])) {
unset($response);
- return c_base_return_error::s_false();
+ $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);
}
unset($response);
$json = json_encode($request);
- $written = socket_write($this->socket, $json);
+ $written = @socket_write($this->socket, $json);
unset($json);
if ($written === FALSE || $written == 0) {
unset($written);
- return c_base_return_error::s_false();
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_write', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ return c_base_return_error::s_false($error);
}
unset($written);
- $json = socket_read($this->socket, self::PACKET_MAX_LENGTH);
+ $json = @socket_read($this->socket, self::PACKET_MAX_LENGTH);
if (!is_string($json) || mb_strlen($json) == 0) {
unset($json);
- return c_base_return_error::s_false();
+ $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);
}
$response = json_decode($json, TRUE);
}
if ($response === FALSE) {
- return c_base_return_error::s_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);
+ return c_base_return_error::s_false($error);
}
return c_base_return_array::s_new($response);
*/
public static function s_is_UTF_8($text) {
if (!is_string($text)) {
- return c_base_return_error::s_false();
+ $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 (mb_check_encoding($text, self::UTF_8)) {
*/
public static function s_character_to_ordinal($character) {
if (!is_string($character)) {
- return c_base_return_error::s_false();
+ $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);
}
$ordinal = self::p_s_character_to_ordinal($character);
if ($ordinal === FALSE) {
unset($ordinal);
- return c_base_return_error::s_false();
+
+ $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);
}
return c_base_return_int::s_new($ordinal);
*/
public static function s_ordinal_to_character($ordinal) {
if (!is_int($ordinal)) {
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_string::s_new(self::p_s_ordinal_to_character($ordinal));
*/
public static function s_length_string($text) {
if (!is_string($text)) {
- return c_base_return_error::s_false();
+ $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);
}
$length = self::p_s_length_string($text);
if ($length === FALSE) {
unset($length);
- return c_base_return_error::s_false();
+
+ $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_false($error);
}
return c_base_return_int::s_new($length);
*/
public static function s_clean($text, $remove_bom = FALSE) {
if (!is_string($text)) {
- return c_base_return_error::s_false();
+ $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_bool($remove_bom)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
$sanitized = self::p_s_clean($text);
if ($sanitized === FALSE) {
unset($sanitized);
- return c_base_return_error::s_false();
+
+ $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);
}
return c_base_return_string::s_new($sanitized);
*/
public static function s_split($text, $split_length = 1) {
if (!is_string($text)) {
- return c_base_return_error::s_false();
+ $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_int($split_length)) {
- return c_base_return_error::s_false();
+ $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_false($error);
}
$split = self::p_s_split($text, $split_length);
if ($split === FALSE) {
unset($split);
- return c_base_return_error::s_false();
+
+ $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_false($error);
}
return c_base_return_array::s_new($split);
*/
public static function s_character_size_list($text) {
if (!is_string($text)) {
- return c_base_return_error::s_false();
+ $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);
}
$size_list = self::p_s_character_size_list($text);
if ($size_list === FALSE) {
unset($size_list);
- return c_base_return_error::s_false();
+
+ $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_false($error);
}
return c_base_return_array::s_new($size_list);
*/
public static function s_character_max_width($text) {
if (!is_string($text)) {
- return c_base_return_error::s_false();
+ $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);
}
$size_list = self::p_s_character_size_list($text);
if ($size_list === FALSE) {
unset($size_list);
- return c_base_return_error::s_false();
+
+ $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_false($error);
}
return c_base_return_int::s_new(max($size_list));
*/
public static function s_encode_html_character($character) {
if (!is_string($character)) {
- return c_base_return_error::s_false();
+ $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);
}
$encoded = self::p_s_encode_html_character($character);
if ($encoded === FALSE) {
unset($encoded);
- return c_base_return_error::s_false();
+
+ $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_false($error);
}
return c_base_return_string::s_new($encoded);
*/
public static function s_encode_html($text) {
if (!is_string($text)) {
- return c_base_return_error::s_false();
+ $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);
}
$split = self::p_s_split($text);
if ($split === FALSE) {
unset($split);
- return c_base_return_error::s_false();
+
+ $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_false($error);
}
$new_array = array();
*/
public static function s_substring($text, $start = 0, $length = NULL) {
if (!is_string($text)) {
- return c_base_return_error::s_false();
+ $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_int($start)) {
- return c_base_return_error::s_false();
+ $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_null($length) && !is_int($length)) {
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_string::s_new(self::p_s_substring($text, $start, $length));
*/
public static function s_is_bom($text) {
if (!is_string($text)) {
- return c_base_return_error::s_false();
+ $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 (self::p_s_is_bom($text)) {
*/
public static function s_file_has_bom($file_path) {
if (!is_string($file_path)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
if (self::p_s_is_bom(file_get_contents($file_path, 0, NULL, -1, 3))) {
*/
public static function s_string_has_bom($text) {
if (!is_string($text)) {
- return c_base_return_error::s_false();
+ $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 (self::p_s_is_bom(substr($text, 0, 3))) {
*/
public static function s_prepend_bom($text) {
if (!is_string($text)) {
- return c_base_return_error::s_false();
+ $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 (!s_is_bom(substr($text, 0, 3))) {
*/
public static function s_reverse($text) {
if (!is_string($text)) {
- return c_base_return_error::s_false();
+ $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);
}
$split = self::p_s_split($text);
if ($split === FALSE) {
unset($split);
- return c_base_return_error::s_false();
+
+ $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_false($error);
}
return c_base_return_string::s_new(implode(array_reverse($split)));
*/
public static function s_position_string($haystack, $needle, $offset = 0) {
if (!is_string($haystack)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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);
}
$search_for = $needle;
*/
public static function s_string_to_ordinals($text) {
if (!is_string($text) && !is_array($text)) {
- return c_base_return_error::s_false();
+ $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);
}
return c_base_return_array::s_new(self::p_s_string_to_ordinals($text));
* An array of Unicode code points.
*
* @return c_base_return_string|c_base_return_status
- * A string represnting the ordinals array.
+ * A string representing the ordinals array.
+ * A string representing the ordinals array with error bit set is returned on error for non-critical string-processing errors.
* FALSE with error bit set is returned on error.
*/
public static function s_ordinals_to_string($ordinals) {
if (!is_array($ordinals)) {
- return c_base_return_error::s_false();
+ $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);
}
+ $errors = array();
$string = '';
foreach ($ordinals as $ordinal) {
$character = self::p_s_ordinal_to_character($ordinal);
if ($character === FALSE) {
- // @todo: generate a warning or error of some sort.
+ $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;
}
unset($ordinal);
unset($character);
- return c_base_return_string::s_new($string);
+ if (empty($errors)) {
+ unset($errors);
+
+ return c_base_return_string::s_new($string);
+ }
+
+ $return_string = c_base_return_string::s_new($string);
+ foreach ($errors as $error) {
+ $return_string->set_error($error);
+ }
+ unset($errors);
+ unset($error);
+
+ return $return_string;
}
/**
*/
public static function s_ordinals_to_string_array($ordinals) {
if (!is_array($ordinals)) {
- return c_base_return_error::s_false();
+ $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);
}
+ $errors = array();
$array = array();
foreach ($ordinals as $ordinal) {
$character = self::p_s_ordinal_to_character($ordinal);
if ($character === FALSE) {
- // @todo: generate a warning or error of some sort.
+ $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;
}
unset($ordinal);
unset($character);
- return c_base_return_array::s_new($array);
+ if (empty($errors)) {
+ unset($errors);
+
+ return c_base_return_array::s_new($array);
+ }
+
+ $return_array = c_base_return_array::s_new($array);
+ foreach ($errors as $error) {
+ $return_array->set_error($error);
+ }
+ unset($errors);
+ unset($error);
+
+ return $return_array;
}
/**
*/
public static function s_ordinal_array_to_string($ordinals) {
if (!is_array($ordinals)) {
- return c_base_return_error::s_false();
+ $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);
}
$array = array();
*/
public static function s_ordinal_to_codepoint($ordinal) {
if (!is_int($ordinal)) {
- return c_base_return_error::s_false();
+ $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);
}
$codepoint = self::p_s_ordinal_to_codepoint($ordinal);
if ($codepoint === FALSE) {
unset($codepoint);
- return c_base_return_error::s_false();
+
+ $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);
}
return c_base_return_int::s_new($codepoint);
*/
public static function s_count_substrings($haystack, $needle, $offset = 0, $length = NULL) {
if (!is_string($haystack)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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 ($offset || $length) {
*/
public static function s_is_ascii($text) {
if (!is_string($text)) {
- return c_base_return_error::s_false();
+ $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 (preg_match('/[\x80-\xff]/', $text)) {
*/
public static function s_strip_tags($text, $allowable_tags = '') {
if (!is_string($text)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
// clean broken UTF_8.
$sanitized = self::p_s_clean($text);
if ($sanitized === FALSE) {
unset($sanitized);
- return c_base_return_error::s_false();
+
+ $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);
}
return c_base_return_string::s_new(strip_tags($sanitized, $allowable_tags));
*/
public function change_element($element, $type) {
if (!($element instanceof DOMNode)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
return c_them_return_dom_node::s_new($this->pr_change_element($element, $type));
*/
public function change_elements($type_old, $type_new) {
if (!is_string($type_old) || strlen($type_old) == 0) {
- return c_base_return_error::s_false();
+ $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) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
return $this->pr_change_elements($type_old, $type_new, $this->content);
*/
public function remove_element($element, $preserve_children = TRUE) {
if (!($element instanceof DOMNode)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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->pr_remove_element($element, $preserve_children)) {
*/
public function remove_elements($type, $preserve_children = TRUE) {
if (!is_string($type) || strlen($type) == 0) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
if ($this->pr_remove_elements($type, $this->content, $preserve_children)) {
*/
public static function s_create_tag($type, $id = NULL, $classes = NULL) {
if (!is_null($id) && !is_string($id)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
$tag = new c_base_markup_tag();
$result = $tag->set_type($type);
if ($result instanceof c_base_return_false) {
- return c_base_return_error::s_false();
+ $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($id)) {
*/
public function set_html($html) {
if (!($html instanceof c_base_html)) {
- return c_base_return_error::s_false();
+ $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;
*/
public function render_markup() {
if (!($this->html instanceof c_base_html)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->markup = '<html' . $this->p_render_markup_attributes_global() . $this->p_render_markup_attributes_event_handler() . '>';
*/
public function set_http($http) {
if (!($http instanceof c_base_http)) {
- return c_base_return_error::s_false();
+ $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;
*/
public function set_max_recursion_depth($max_recursion_depth) {
if (!is_int($max_recursion_depth)) {
- return c_base_return_error::s_false();
+ $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);
}
$this->max_recursion_depth = $max_recursion_depth;
- see: http://www.oberhumer.com/opensource/lzo/
- This must be added to the PHP source code during compile time.
-php-xz:
+php-xz: (currently not required because code is defunct.)
+- see: https://github.com/payden/php-xz
- see: https://github.com/chobie/php-xz
- This must be added to the PHP source code during compile time.
$settings['session_max'] = 1800; // 30 minutes
// ldap information
- $settings['ldap_server'] = 'ldaps://ldap.example.com:1636/';
+ $settings['ldap_server'] = 'ldaps://127.0.0.1:1636/';
$settings['ldap_base_dn'] = 'ou=users,ou=People';
$settings['ldap_fields'] = array('mail', 'gecos', 'givenname', 'cn', 'sn', 'employeenumber');
*
* @param c_base_http $http
* Http object.
- * @param c_base_cookie $cookie
- * Cookie object.
*/
- function reservation_send_response($http, $cookie) {
+ function reservation_send_response($http) {
$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();
- $cookie->do_push();
flush();
// once the header are sent, send the content.
* System settings
* @param c_base_session &$session
* Session information.
- * @param c_base_cookie &$cookie
- * Session cookie.
+ * @param c_base_cookie &$cookie_login
+ * Session login cookie.
*/
- function reservation_process_request(&$http, &$database, &$settings, &$session, &$cookie) {
+ function reservation_process_request(&$http, &$database, &$settings, &$session, &$cookie_login) {
$html = new c_base_html();
elseif ($session === FALSE) {
// check to see if user has filled out the login form.
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['form_id']) && $_POST['form_id'] == 'login_form') {
- $problems = reservation_attempt_login($database, $settings, $session, $cookie);
+ $problems = reservation_attempt_login($database, $settings, $session, $cookie_login);
if ($problems instanceof c_base_return_false) {
// @todo: render default page.
// 3: process session information
- $cookie = new c_base_cookie();
- $session = reservation_process_sessions($settings, $cookie)->get_value_exact();
+ $cookie_login = new c_base_cookie();
+ $session = reservation_process_sessions($settings, $cookie_login)->get_value_exact();
gc_collect_cycles();
// 4: perform actions, process work.
$database = new c_base_database();
- $html = reservation_process_request($http, $database, $settings, $session, $cookie)->get_value();
+ $html = reservation_process_request($http, $database, $settings, $session, $cookie_login)->get_value();
if (!($html instanceof c_base_html)) {
$html = new c_base_html();
}
// 6: build response information.
$http->set_response_content($markup);
+ $http->set_response_set_cookie($cookie_login);
unset($markup);
+ unset($cookie_login);
gc_collect_cycles();
// 7: send HTTP response.
- reservation_send_response($http, $cookie);
+ reservation_send_response($http);
gc_collect_cycles();
unset($settings);
unset($http);
unset($session);
- unset($cookie);
- unset($database);
gc_collect_cycles();
}
*/
function reservation_database_string(&$database, $settings) {
if (!($database instanceof c_base_database)) {
- return c_base_return_error::s_false();
+ $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);
}
$connection_string = new c_base_connection_string();
$connection_string->set_host($settings['database_host']);
$connection_string->set_port($settings['database_port']);
- $connection_string->set_dbname($settings['database_name']);
+ $connection_string->set_database_name($settings['database_name']);
$connection_string->set_user($settings['database_user']);
if (!is_null($settings['database_password'])) {
*/
function reservation_database_connect(&$database) {
if (!($database instanceof c_base_database)) {
- return c_base_return_error::s_false();
+ $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();
*/
function reservation_database_get_user_data(&$database, $user_name, $ldap_data = NULL) {
if (!($database instanceof c_base_database)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
}
$user_data = array(
*/
function reservation_database_load_ldap_data($settings, $user_name) {
if (!is_array($settings)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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(
* The system settings array.
* @param c_base_session &$session
* The current session.
- * @param c_base_cookie &$cookie
- * Session cookie.
+ * @param c_base_cookie &$cookie_login
+ * Session login cookie.
*
* @return c_base_return_array|c_base_return_status
* FALSE on success.
* An array of problems on failure.
* FALSE with error bit set is returned on error.
*/
-function reservation_attempt_login(&$database, &$settings, &$session, &$cookie) {
+function reservation_attempt_login(&$database, &$settings, &$session, &$cookie_login) {
$problems = array();
if (empty($_POST['login_form-username'])) {
$problems[] = array(
$session->do_disconnect();
$session_expire = $session->get_timeout_expire()->get_value_exact();
- $cookie->set_expires($session_expire);
- $cookie->set_max_age(NULL);
+ $cookie_login->set_expires($session_expire);
+ $cookie_login->set_max_age(NULL);
if ($result 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), // unecessary, but provided for debug purposes.
);
- $cookie->set_data($data);
+ $cookie_login->set_data($data);
}
unset($result);
unset($session_expire);
*
* @param array &$settings
* System settings.
- * @param c_base_cookie &$cookie
- * Cookie setting.
+ * @param c_base_cookie &$cookie_login
+ * A login cookie object.
*
* @param c_base_return_status|c_base_session
* Session information is returned on success.
* FALSE is returned when no session is defined.
* FALSE with error bit set is returned on error.
*/
- function reservation_process_sessions(&$settings, &$cookie) {
- // cookie is used to determine whether or not the user is logged in.
- $cookie->set_name($settings['cookie_name']);
- $cookie->set_path($settings['cookie_path']);
- $cookie->set_domain($settings['cookie_domain']);
- $cookie->set_secure(TRUE);
-
- $pulled = $cookie->do_pull();
+ function reservation_process_sessions(&$settings, &$cookie_login) {
+ $cookie_login->set_name($settings['cookie_name']);
+ $cookie_login->set_path($settings['cookie_path']);
+ $cookie_login->set_domain($settings['cookie_domain']);
+ $cookie_login->set_secure(TRUE);
+
+ $pulled = $cookie_login->do_pull();
if ($pulled instanceof c_base_return_true) {
- $cookie_data = $cookie->get_data()->get_value_exact();
+ $cookie_data = $cookie_login->get_data()->get_value_exact();
- if (!($cookie->validate() instanceof c_base_return_true) || empty($cookie_data['session_id'])) {
- // cookie failed validation or the cookie contains no session id.
+ if (!($cookie_login->validate() instanceof c_base_return_true) || empty($cookie_data['session_id'])) {
+ // cookie_login failed validation or the cookie contains no session id.
return new c_base_return_false();
}
}
if ($session_expire > $cookie_data['expire']) {
$cookie_data['expire'] = gmdate("D, d-M-Y H:i:s T", $session_expire);
- $cookie->set_data($value);
- $cookie->set_expires($session_expire);
+ $cookie_login->set_data($value);
+ $cookie_login->set_expires($session_expire);
}
return c_base_session_return::s_new($session);
*/
function reservation_ensure_user_account($settings, $user_name) {
if (!is_array($settings)) {
- return c_base_return_error::s_false();
+ $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)) {
- return c_base_return_error::s_false();
+ $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);
socket_close($socket);
unset($socket);
- return c_base_return_error::s_false();
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_create', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ return c_base_return_error::s_false($error);
}
$connected = @socket_connect($socket, $settings['database_create_account_host'], $settings['database_create_account_port']);
unset($socket);
unset($connected);
- return c_base_return_error::s_false();
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_connect', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ return c_base_return_error::s_false($error);
}
$packet_size_target = 63;
unset($socket);
unset($packet_size_client);
- return c_base_return_error::s_false();
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':operation_name' => 'socket_write', ':function_name' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE);
+ return c_base_return_error::s_false($error);
}
unset($written);
if (!is_string($response) || strlen($response) == 0) {
unset($response);
- return c_base_return_error::s_false();
+ $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.