public static function Ret() { $class = __CLASS__; if (!self::$SINGLETON) { self::$SINGLETON = new $class(); } return self::$SINGLETON; }
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; }
function c() { $stk = new stack(); //Call to class "Stack" echo $stk->b(); }
} echo "Empty stack , nothing to pop"; } public function first() { return $this->stackArray[$this->index]; } public function last() { return $this->stackArray[0]; } public function GetElement($position) { if ($position <= $this->index + 1) { $arrayposition = $this->index + 1 - $position; return $this->stackArray[]; } echo "invalid position", "<br>"; } } $mystack = new stack(); $mystack->push(1); $mystack->push(4); $mystack->push(5); echo $mystack->first(), "<br>"; echo $mystack->last(); //$mystack->pop() //echo $mystack->pop(); echo $mystack->pop(); //$mystack->pop(); echo $mystack->GetElement();
/** * */ 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; }