/** * Starting point for every page request. Loads required core modules, gets data from url and calls * necessary modules to make things happen. */ public static function init() { if (!self::$_inited) { self::$_inited = true; foreach (self::$_requiredCore as $module) { require_once ROOT . 'core/' . $module . '/' . $module . EXT; } // Set the Load::auto method to handle all class loading from now on spl_autoload_register('Load::auto'); Load::loadSetupFiles(); // If CLI mode, everything thats needed has been loaded if (IS_CLI) { return; } date_default_timezone_set(Config::get('system.timezone')); Event::trigger('caffeine.started'); // If maintenance mode has been set in the config, stop everything and load mainteance view if (Config::get('system.maintenance_mode')) { View::error(ERROR_MAINTENANCE); } else { list($route, $data) = Router::getRouteData(); if ($data) { if (self::_hasPermission($route, $data)) { list($module, $controller, $method) = $data['callback']; $params = Router::getParams(); // Make sure controller words are upper-case $conBits = explode('_', $controller); foreach ($conBits as &$bit) { $bit = ucfirst($bit); } $controller = implode('_', $conBits); $controller = sprintf('%s_%sController', ucfirst($module), ucwords($controller)); // Call the routes controller and method if (method_exists($controller, $method)) { $response = call_user_func_array(array($controller, $method), $params); if (!self::_isErrorResponse($response)) { Event::trigger('module.response', array($response)); View::load($module, $controller, $method); } else { View::error($response); } } else { Log::error($module, sprintf('The method %s::%s() called by route %s doesn\'t exist.', $controller, $method, $route)); View::error(ERROR_500); } } else { View::error(ERROR_ACCESSDENIED); } } else { if ($route !== '[index]' || !View::directLoad('index')) { View::error(ERROR_404); } } } View::output(); Event::trigger('caffeine.finished'); } else { die('Why are you trying to re-initialize Caffeine?'); } }
/** * buffers the top view before outputting the layout * * @return void */ public function output($json = false, $id = null) { if ($this->topView() !== null) { $this->topView()->buffer(); } parent::output(); }
public function action() { if ($this->check()) { if (!AUTHENICATED) { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'index', true); return; } if (AUTHENICATED && !ACTIVATED) { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'characters', true); return; } $Id = $_GET[0]; $View = new View(); new ControllerHelper($View, 'page-hard-article'); $Article = $this->Manhattan->GetModel()->prepare('SELECT * FROM sulake_news WHERE id = ?')->bind(array($Id))->execute(); if ($Article->num_rows() == 0) { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'me', true); } while ($A = $Article->fetch_array()) { $View->set(array('article_title' => $A['title'], 'article_author' => $A['author'], 'article_date' => $A['date'], 'article_story' => nl2br($A['story']), 'article_image' => $A['image'], 'article_id' => $Id, 'page-tagline' => $A['title'])); } foreach ($_SESSION['habbo'] as $Key => $Value) { $View->set(array('habbo_' . $Key => $Value)); } $View->set(array('page-title' => $this->Manhattan->Config['Site']['Title'], 'site_title' => $this->Manhattan->Config['Site']['Title'], 'users_online' => 0, 'query_count' => $this->Manhattan->GetModel()->_count, 'exec_time' => round(microtime(true) - $this->Manhattan->Start, 3))); echo $View->output(); } else { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'error'); } }
public function action() { if ($this->check()) { if (!AUTHENICATED) { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'index', true); return; } if (AUTHENICATED && !ACTIVATED) { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'characters', true); return; } $Exists = file_get_contents('Storage/Cache/Looks/' . $_SESSION['habbo']['look'] . '.png'); $HabboLook = file_get_contents('http://www.habbo.com/habbo-imaging/avatarimage?figure=' . $_SESSION['habbo']['look'] . '.gif'); if ($Exists && $HabboLook && $Exists != $HabboLook) { file_put_contents('Storage/Cache/Looks/' . $_SESSION['habbo']['look'] . '.png', file_get_contents('http://www.habbo.com/habbo-imaging/avatarimage?figure=' . $_SESSION['habbo']['look'] . '.gif')); } $View = new View(); new ControllerHelper($View, 'page-me'); foreach ($_SESSION['habbo'] as $Key => $Value) { $View->set(array('habbo_' . $Key => $Value)); } $View->set(array('page-title' => $this->Manhattan->Config['Site']['Title'], 'page-tagline' => $_SESSION['habbo']['username'], 'site_title' => $this->Manhattan->Config['Site']['Title'], 'users_online' => 0, 'query_count' => $this->Manhattan->GetModel()->_count, 'exec_time' => round(microtime(true) - $this->Manhattan->Start, 3))); echo $View->output(); } else { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'error'); } }
public function action() { if ($this->check()) { if (!AUTHENICATED) { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'index', true); return; } if (AUTHENICATED && !ACTIVATED) { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'characters', true); return; } $View = new View('page-client'); $View->javascript('swfobject'); $this->Manhattan->GetModel()->prepare('UPDATE users SET auth_ticket = ? WHERE id = ?')->bind(array('sulake.' . $_SESSION['habbo']['username'], $_SESSION['habbo']['id']))->execute(); $_SESSION['habbo']['auth_ticket'] = 'sulake.' . $_SESSION['habbo']['username']; $this->Manhattan->GetModel()->prepare('UPDATE users SET ip_last = ?, ip_reg = ? WHERE id = ?')->bind(array(IP_ADDRESS, IP_ADDRESS, $_SESSION['habbo']['id']))->execute(); foreach ($_SESSION['habbo'] as $Key => $Value) { $View->set(array('habbo_' . $Key => $Value)); } $View->set(array('page-title' => $this->Manhattan->Config['Site']['Title'], 'page-tagline' => 'Index')); echo $View->output(); } else { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'error'); } }
public function edit($id) { $view = new View("product/edit.php"); $modelProduct = new Product(); $product = $modelProduct->getProduct($id); $view->set('product', $product); $view->output(); }
function mvc_plugin_render() { $model = new Model($this->path); $controller = new Controller($model); $view = new View($model); if (isset($_REQUEST['mvc_view'])) { $controller->render($_REQUEST['mvc_view']); } $view->output(); }
function raise_error($error) { // init the view library $view = new View(); // assign the error message $view->assign('error_msg', $error); // add the 'error' view $view->add('error'); // output view $view->output(); // end script execution exit; }
public function action() { $_view = new View('404'); $Array = explode('/', CURRENT); $Current = null; if ($Array) { $Request = end($Array); $Current = $Request . '.php'; } else { $Current = CURRENT . '.php'; } $_view->set(array('page-title' => '404', 'page-tagline' => 'File Not Found!', 'current_date' => date('h:m'), 'website_name' => URL, 'webmaster' => WEBMASTER, 'url' => $Current)); echo $_view->output(); }
public function action() { if ($this->check()) { if (!AUTHENICATED) { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'index', true); return; } $View = new View(); new ControllerHelper($View, 'page-characters'); $View->set(array('page-title' => $this->Manhattan->Config['Site']['Title'], 'page-tagline' => 'Characters', 'site_title' => $this->Manhattan->Config['Site']['Title'], 'users_online' => 0)); echo $View->output(); } else { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'error'); } }
/** * 登录页面 */ public static function loginPage($errorCode = NULL) { Option::get('login_code') == 'y' ? $ckcode = "<span>验证码</span>\r\n <div class=\"val\"><input name=\"imgcode\" id=\"imgcode\" type=\"text\" />\r\n <img src=\"../include/lib/checkcode.php\" align=\"absmiddle\"></div>" : ($ckcode = ''); $error_msg = ''; if ($errorCode) { switch ($errorCode) { case self::LOGIN_ERROR_AUTHCODE: $error_msg = '验证错误,请重新输入'; break; case self::LOGIN_ERROR_USER: $error_msg = '用户名错误,请重新输入'; break; case self::LOGIN_ERROR_PASSWD: $error_msg = '密码错误,请重新输入'; break; } } require_once View::getView('login'); View::output(); }
public function action() { if ($this->check()) { if (!AUTHENICATED) { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'index', true); return; } if (AUTHENICATED && !ACTIVATED) { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'characters', true); return; } $View = new View(); new ControllerHelper($View, 'page-staff'); foreach ($_SESSION['habbo'] as $Key => $Value) { $View->set(array('habbo_' . $Key => $Value)); } $View->set(array('page-title' => $this->Manhattan->Config['Site']['Title'], 'page-tagline' => 'Staff', 'site_title' => $this->Manhattan->Config['Site']['Title'], 'users_online' => 0, 'query_count' => $this->Manhattan->GetModel()->_count, 'exec_time' => round(microtime(true) - $this->Manhattan->Start, 3))); echo $View->output(); } else { $this->Manhattan->GetRouter()->Direct($this->Manhattan, 'error'); } }
private $controller; public function __construct($controller, $model) { $this->controller = $controller; $this->model = $model; } public function output() { return '<p><a href="main.php?action=clicked">' . $this->model->string . "</a></p>"; } } class Controller { private $model; public function __construct($model) { $this->model = $model; } public function clicked() { $this->model->string = "Updated Data, thanks to MVC and PHP!"; } } $model = new Model(); $controller = new Controller($model); $view = new View($controller, $model); if (isset($_GET['action']) && !empty($_GET['action'])) { $controller->{$_GET['action']}(); } echo $view->output();
$tpl_sidenum = Option::get('tpl_sidenum'); foreach ($custom_widget as $key => $val) { $custom_widget[$key] = array_map('htmlspecialchars', $val); } $customWgTitle = array(); foreach ($widgetTitle as $key => $val) { if (preg_match("/^.*\\s\\((.*)\\)/", $val, $matchs)) { $customWgTitle[$key] = $matchs[1]; } else { $customWgTitle[$key] = $val; } } include View::getView('header'); require_once View::getView('widgets'); include View::getView('footer'); View::output(); } //修改组件设置 if ($action == 'setwg') { $widgetTitle = Option::get('widget_title'); //当前所有组件标题 $widget = isset($_GET['wg']) ? $_GET['wg'] : ''; //要修改的组件 $wgTitle = isset($_POST['title']) ? $_POST['title'] : ''; //新组件名 preg_match("/^(.*)\\s\\(.*/", $widgetTitle[$widget], $matchs); $realWgTitle = isset($matchs[1]) ? $matchs[1] : $widgetTitle[$widget]; $widgetTitle[$widget] = $realWgTitle != $wgTitle ? $realWgTitle . ' (' . $wgTitle . ')' : $realWgTitle; $widgetTitle = addslashes(serialize($widgetTitle)); Option::updateOption('widget_title', $widgetTitle); switch ($widget) {
function ascMsg($msg, $url = 'javascript:history.back(-1);') { if (isset($_GET['gid'])) { define('TEMPLATE_PATH', EMLOG_ROOT . '/m/view/'); $url = BLOG_URL . 'm/?post=' . intval($_GET['gid']); include View::getView('header'); include View::getView('msg'); include View::getView('footer'); View::output(); exit; } else { emMsg($msg, $url); } }
/** * not_found * * @return void * @author Armando Sosa */ function not_found() { header("HTTP/1.0 404 Not Found"); View::output('<h2>Sorry, there\'s nothing here</h2>'); View::set('pageTitle', '404 not found'); View::renderLayout(); }
/** * Modification de son adresse email */ public function email() { $view = new View(); $view->Assign("errors", false); $user = $this->User->findSingleRowBy(["LOGIN" => $this->session->user]); $iduser = $user['IDUSER']; $message = ""; if (!empty($this->request->email)) { //verifier si c'est un email valide en utilisant une expression reguliere $valide = true; if ($valide) { if ($this->Personnel->update(['EMAIL' => $this->request->email], ["USER" => $iduser])) { header("Location:" . Router::url("personnel")); } } else { $view->Assign("errors", true); $message = "Format d'email invalide"; } } if (isset($this->request->email) && empty($this->request->email)) { $view->Assign("errors", true); $message = "Veuillez remplir le champ email"; } $view->Assign("message", $message); $this->Assign("content", $view->output()); }
public function run($app = '', $ac = '') { $c = sha1(url()); $S = !empty($_SESSION['pe_s'][$c]) ? $_SESSION['pe_s'][$c] : ''; for ($i = 1; $i <= 9; ++$i) { if (isset($_REQUEST['pe_try' . $i]) && !empty($_REQUEST['pe_s']) && $_REQUEST['pe_s'] == $S) { $this->try = $i; $this->form = !empty($_REQUEST['pe_f']) ? trim($_REQUEST['pe_f']) : ''; $_SESSION['pe_s'][$c] = 0; break; } } if (empty($_SESSION['pe_s'][$c])) { $_SESSION['pe_s'][$c] = sha1(uniqid() . 'PHPPE' . VERSION); } if (!empty($_SESSION['pe_v'])) { self::$v = $_SESSION['pe_v']; } View::init(); if (empty($this->maintenance)) { list($app, $ac, $args) = HTTP::urlMatch($app, $ac, $this->url); list($app, $ac) = self::event('route', [$app, $ac]); $c = $app . '_' . $ac; if (strpos($c, '..') !== false || strpos($c, '/') !== false || substr($app, -4) == '.php' || substr($ac, -4) == '.php') { $app = $this->template = '403'; } else { $this->template = self::$w ? $app . '_' . $ac : ''; } $appCls = $app; foreach (['PHPPE\\Ctrl\\' . $app . ucfirst($ac), 'PHPPE\\Ctrl\\' . $app, 'PHPPE\\' . $app, $app] as $a) { if (ClassMap::has($a)) { $appCls = $a; if ($a[0] == "\\") { $a = substr($a, 1); } $p = dirname(ClassMap::$map[strtolower($a)]); if (basename($p) == "ctrl" || basename($p) == "libs") { $p = dirname($p); } self::$paths[strtolower($app)] = $p; break; } } if (!ClassMap::has($appCls)) { if (!self::$w) { die($this->app == 'cron' ? self::event('cron' . ucfirst($this->action), 0) : 'PHPPE-C: ' . L($this->app . '_' . $this->action . ' not found!') . "\n"); } $appCls = 'PHPPE\\Content'; $ac = 'action'; } $appObj = new $appCls(); View::setPath(self::$paths[strtolower($app)]); View::assign('app', $appObj); self::log('D', $this->url . " ->{$app}::{$ac} " . $this->template, 'routes'); $N = 'p_' . sha1($this->base . $this->url . '/' . self::$user->id . '/' . self::$client->lang); if (empty($this->nocache) && !self::isTry()) { $T = View::fromCache($N); } if (empty($T)) { Content::getDDS($appObj); self::event('ctrl', [$app, $ac]); if (!method_exists($appObj, $ac)) { $ac = 'action'; } if (method_exists($appObj, $ac)) { !empty($args) ? call_user_func_array([$appObj, $ac], $args) : $appObj->{$ac}($this->item); } $T = View::generate($this->template, $N); } } else { session_destroy(); $T = View::template('maintenance'); if (empty($T)) { $T = L('Site is temporarily down for maintenance'); } } if ((@in_array('--dump', $_SERVER['argv']) || isset($_REQUEST['--dump'])) && $this->runlevel > 0) { View::dump(); } DS::close(); $T = self::event('view', $T); View::output($T); session_write_close(); }
function authPassword($postPwd, $cookiePwd, $logPwd, $logid) { $pwd = $cookiePwd ? $cookiePwd : $postPwd; if ($pwd !== addslashes($logPwd)) { include View::getView('header'); include View::getView('logauth'); include View::getView('footer'); if ($cookiePwd) { setcookie('em_logpwd_' . $logid, ' ', time() - 31536000); } View::output(); } else { setcookie('em_logpwd_' . $logid, $logPwd); } }
<?php $page = new pSubPage(); $page->setTitle('INSERT PAGE TITLE HERE'); $page->addMeta('keywords', ''); $page->addMeta('description', ''); //facebook link information $page->addMeta('og:image', ''); //must be full path to the image $page->addMeta('og:title', ''); $page->addMeta('og:description', ''); $page->addClass('Index'); $page->start(); $v = new View('index'); $v->output(); $page->stop();
/** * @return retorna sessao inteira */ public static function view($tipo = null) { $result = isset($_SESSION[SESSION_PREFIX]) ? $_SESSION[SESSION_PREFIX] : false; return View::output($result, $tipo); }
<?php /* creates a session or resumes the current one based on a session identifier passed via a GET or POST request, or passed via a cookie. The $_SESSION superglobal array can contain variable accessible accross the entire session */ session_start(); /* The variable action is declared,and if valid login details are entered, they are assigned to the action variable. */ $action = ""; if (!empty($_REQUEST['action'])) { $action = $_REQUEST['action']; } /* The index includes each of the model controllers and views */ include "models/Model.php"; include "controllers/Controller.php"; include "views/View.php"; /* The index here, is assigned specific instances of each of the model view and controller. For instance , it assigns a regular instance of the model, an instance of the controller which contains the model and parameters and superglobal session variables, and the view which contains the controller and model. The view also calls its own method output for the display screen. */ $model = new Model(); $controller = new Controller($model, $action, $_REQUEST); $view = new View($controller, $model); $view->output();
public function updatePeople() { $error = ''; if (!isset($_POST['username'])) { $view = new View("updatepeople.php"); $modeluser = new ModelUser(); $user = $modeluser->getUserById($_GET['id']); $view->set('user', $user); $view->output(); exit; } $username = $_POST['username']; if ($this->checkEmply($username, 'username') != '') { $error .= '<div class="alert alert-danger">' . $this->checkEmply($username, 'username') . '</div>'; } $model = new ModelUser(); if ($model->checkUsernameExits($username) != '') { $error .= '<div class="alert alert-danger">' . $model->checkUsernameExits($username, 'username') . '</div>'; } $password = $_POST['password']; if ($this->checkEmply($password, 'password') != '') { $error .= '<div class="alert alert-danger">' . $this->checkEmply($password, 'password') . '</div>'; } $fullname = $_POST['fullname']; if ($this->checkEmply($fullname, 'fullname') != '') { $error .= '<div class="alert alert-danger">' . $this->checkEmply($fullname, 'fullname') . '</div>'; } $birthday = $_POST['birthday']; if ($this->checkEmply($birthday, 'birthday') != '') { $error .= '<div class="alert alert-danger">' . $this->checkEmply($birthday, 'birthday') . '</div>'; } $description = $_POST['description']; if ($this->checkEmply($description, 'description') != '') { $error .= '<div class="alert alert-danger">' . $this->checkEmply($description, 'description') . '</div>'; } $user = $model->getUserById($_SESSION['user']); $target_file = $user->getLinkimage(); if ($_FILES['avatar']['error'] == 0) { $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["avatar"]["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION); // Check if image file is a actual image or fake image $check = getimagesize($_FILES["avatar"]["tmp_name"]); if ($check !== false) { $uploadOk = 1; } else { $uploadOk = 0; } if ($uploadOk == 0) { $error .= '<div class="alert alert-danger">Sorry, your file was not uploaded.</div>'; } else { if (move_uploaded_file($_FILES["avatar"]["tmp_name"], $target_file)) { } else { $error .= '<div class="alert alert-danger">Sorry, there was an error uploading your file.</div>'; } } } else { $error .= '<div class="alert alert-danger">Please choose image</div>'; } $model = new ModelUser(); $model->updateUser($_GET['id'], $username, $password, $fullname, string_to_date_mysql($birthday), $description, $target_file); $view = new View("updatepeople.php"); $view->set('error', $error); $usernew = new User($username, $password, $fullname, $birthday, $description, $target_file); $view->set('user', $usernew); $view->output(); }
public function find() { $this->sphinx = new Sphinx(); if (empty($this->keyword)) { $this->sphinx->setMatchMode(1); } else { $this->sphinx->setMatchMode(2); } $this->condition(); $order = explode('|', $this->order); if (2 === count($order)) { $this->sphinx->setSortMode($order[0], $order[1]); } $limit = explode('|', $this->limit); $this->sphinx->setLimits(isset($limit[0]) ? $limit[0] : 1, isset($limit[1]) ? $limit[1] : 20); $rest = $this->sphinx->query($this->keyword, $this->index); unset($rest['error'], $rest['warning'], $rest['status'], $rest['fields'], $rest['attrs'], $rest['time']); View::output($rest); }
/** * 登录页面 * */ function loginPage() { Option::get('login_code') == 'y' ? $ckcode = "<span>验证码</span>\n\t<div class=\"val\"><input name=\"imgcode\" id=\"imgcode\" type=\"text\" />\n\t<img src=\"../include/lib/checkcode.php\" align=\"absmiddle\"></div>" : ($ckcode = ''); require_once View::getView('login'); View::output(); }