/** * */ function breathe_shutdown_function() { $error = error_get_last(); if ($error !== null) { error::Ret()->Log('breathe_shutdown_function: ' . print_r($error, true)); } }
public function Run() { if (layout::Ret()->Ready() and $this->output) { $this->output .= layout::Ret()->Display(); error::Ret()->Warn("Output found from action - " . stack::Ret()->GetAction() . " - and layout - " . layout::Ret()->GetTemplate()); } elseif (layout::Ret()->Ready()) { $this->output = layout::Ret()->Display(); } return $this->output; }
public function Set($option) { // $this->Reset(array('selected')); $this->selected = array('home' => '', 'about' => ''); if (isset($this->selected[$option])) { $this->selected[$option] = ' class="selected"'; return $this; } else { error::Ret()->Log('Invalid menu option selected(' . $option . ')'); return null; } }
/** * * @param type $key * @param type $default * @param type $type * @return type */ public function Check($key, $default = null, $type = 'REQUEST') { switch (strtoupper($type)) { case "POST": return isset($_POST[$key]) ? $_POST[$key] : $default; break; case "GET": return isset($_GET[$key]) ? $_GET[$key] : $default; break; case "REQUEST": return isset($_REQUEST[$key]) ? $_REQUEST[$key] : $default; break; case "FILES": return isset($_FILES[$key]) ? $_FILES[$key] : $default; break; default: error::Ret()->Log('Invalid type( ' . $type . ')'); } }
/** * * @param string $table * @param array $params * @param string $type * @param array $wrappers * @return string */ protected function __Bind($table, $params, $type, $wrappers = array()) { $param_string_array = array(); foreach ($params as $field => $value) { $field_selector = $type == 'insert' ? '' : '`' . $table . '`.`' . $field . '` = '; $param_to_string_array = ''; if ($value === null) { $param_to_string_array = $field_selector . "''"; error::Ret()->Log('Null values should not be queried this way. Use "IS (NOT) NULL". This param was changed to \'\'.'); } else { if (is_int($value)) { $param_to_string_array = $field_selector . $value; } elseif (is_string($value)) { $param_to_string_array = $field_selector . "'" . $this->connection->real_escape_string($value) . "'"; } else { // TODO: objects error::Ret()->Log('Invalid param ' . $field . ' => ' . print_r($value, TRUE)); continue; } } if (isset($wrappers[$field])) { $param_to_string_array = $wrappers[$field]['begin'] . $param_to_string_array . $wrappers[$field]['end']; } $param_string_array[] = $param_to_string_array; } $query = ''; switch (strtolower($type)) { case 'where': $query = ' WHERE ' . implode(' AND ', $param_string_array); break; case 'update': $query = ' SET ' . implode(',', $param_string_array); break; case 'insert': $query = ' (`' . implode('`,`', array_keys($params)) . '`) VALUES (' . implode(',', $param_string_array) . ') '; // this makes the assumptions that the two arrays will stay in order break; default: error::Ret()->Log('Invalid input to protected function __Where ' . print_r(array('table' => $table, 'params' => $params, 'type' => $type))); } return $query; }
/** * */ public function Display() { switch ($this->type) { case 'smarty': if ($this->template === null) { error::Ret()->Log('Call to display without defining template' . print_r(array('stack' => stack::Ret(), 'debug_backtrace' => debug_backtrace()), true)); } else { $this->CallBack('display'); $this->smarty->assign('url_prefix', URL_PREFIX); $this->smarty->assign('config', config::Ret()); $this->smarty->assign('server_name', $_SERVER['SERVER_NAME']); $this->smarty->assign('http_referer', isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] !== '' ? $_SERVER['HTTP_REFERER'] : null); $this->smarty->assign('session', $_SESSION); $this->smarty->assign('utility', utility::Ret()); // die('<pre>' . print_r(array($_SESSION,debug_backtrace()),true)); $this->smarty->display($this->template); } break; default: error::Ret()->Log('Unable to Display(). Undefined type (' . $this->type . ')'); } }
/** * * @return boolean */ public function CheckPassword() { if ($this->id === null) { $u = stack::Ret()->Check('email', null, 'POST'); $p = stack::Ret()->Check('password', null, 'POST'); if ($u === NULL || $p === NULL) { return false; } $xss = stack::Ret()->Check('xss', null, 'POST'); if ($this->CheckXSS($xss)) { $pass = strtoupper(hash('sha1', SHA1_SALT . $p)); $sql_check_password = <<<SQL SELECT \tid FROM users WHERE \temail = :email \tAND password = SHA1(:password) ; SQL; // TODO: select remaining parameters database::Ret()->Query($sql_check_password, array(':email' => $u, ':password' => strtoupper(hash('sha1', SHA1_SALT . $p)))); if (database::Ret()->CheckQuery()) { $user = database::Ret()->Fetch(); $this->id = $user['id']; return $this->__CreateDatabaseSession(); } else { error::Ret()->Log('Query failed'); } } else { error::Ret()->Log('Failed XSS'); } } else { return true; } return false; }
/** * * @param type $key * @param type $value * @return boolean */ public function Define($key, $value) { $key = strtoupper($key); if (defined($key)) { error::Ret()->Log('key(' . $key . ') already defined with value(' . constant($key) . ') instead of (' . $value . ')'); return FALSE; } else { define($key, $value); return TRUE; } }