public function index() { $data['title'] = "Sistema de Administración de Aerolíneas"; $data['page'] = "page3"; if (!is_null(filter_input(INPUT_POST, 'insertar'))) { $matricula = $_POST['matricula']; $asientos = $_POST['asientos']; $id_aerolinea = $_POST['id_aerolinea']; $datos = array('ASIENTOS' => $matricula, 'MATRICULA' => $asientos, 'AEROLINEA_ID' => $id_aerolinea); $this->_model->insertar_avion($datos); Url::redirect("aviones?aer=1"); } elseif (!is_null(filter_input(INPUT_POST, 'eliminar'))) { $id_aerolinea = $_POST['id_avion']; $where = array('avion_id' => $id_aerolinea); $this->_model->eliminar_avion($where); } elseif (!is_null(filter_input(INPUT_POST, 'editar'))) { $matricula = $_POST['matricula']; $asientos = $_POST['asientos']; $id_aerolinea = $_POST['id_aerolinea']; $id_avion = $_POST['id_avion']; $datos = array('ASIENTOS' => $matricula, 'MATRICULA' => $asientos, 'AEROLINEA_ID' => $id_aerolinea); $where = array('avion_id' => $id_avion); $this->_model->actualizar_avion($datos, $where); } $data['aerolineas'] = $this->_model->obtener_aerolineas(); $data['aviones'] = $this->_model->obtener_aviones(); View::renderTemplate('header', $data); View::render('aviones/aviones', $data); View::renderTemplate('footer', $data); }
public function login() { Hooks::addHook('js', 'Controllers\\auth@js'); Hooks::addHook('css', 'Controllers\\auth@css'); $error = 'hi'; $success = 'hi'; if (Session::get('loggedin')) { Url::redirect(); } if (isset($_POST['submit'])) { $username = $_POST['username']; $password = $_POST['password']; //validation if (Password::verify($password, $this->_model->getHash($username)) == false) { $error[] = 'Wrong username or password'; } //if validation has passed carry on if (!$error) { Session::set('loggedin', true); Session::set('username', $username); Session::set('memberID', $this->_model->getID($username)); $data = array('lastLogin' => date('Y-m-d G:i:s')); $where = array('memberID' => $this->_model->getID($username)); $this->_model->update($data, $where); $error = 'hi'; Url::redirect(); } } $data['title'] = 'Login'; View::rendertemplate('header', $data); View::render('auth/login', $data, $error, $success); View::rendertemplate('footer', $data); }
public function login() { if (Session::get('loggedin')) { Url::redirect('admin'); } $model = new \Models\Admin\Auth(); $data['title'] = 'Login'; if (isset($_POST['submit'])) { $username = $_POST['member_username']; $password = $_POST['member_password']; if (Password::verify($_POST['member_password'], $model->getHash($_POST['member_username'])) == 0) { $error[] = 'Wrong username of password'; } else { $data['user_infos'] = $model->get_user_infos($_POST['member_username']); Session::set('member_id', $data['user_infos'][0]->member_id); Session::set('member_username', $username); Session::set('member_password', '' . $password . ''); Session::set('loggedin', true); Url::redirect('admin'); } } View::renderadmintemplate('loginheader', $data); View::render('admin/login', $data, $error); View::renderadmintemplate('footer', $data); }
public function index() { $data['title'] = $this->language->get('Voorwaarden'); View::renderTemplate('header', $data); View::render('home/voorwaarden', $data); View::renderTemplate('footer', $data); }
public function index() { $data['title'] = 'Admin'; View::renderadmintemplate('header', $data); View::render('admin/admin', $data); View::renderadmintemplate('footer', $data); }
public function index() { // editable if admin privileges $admin_privilege = false; if (isset($_SESSION['user_info'])) { if ($_SESSION['user_info']->privilege >= 5) { // admin privilege level $admin_privilege = true; } } // get parents $parents = $this->db->getParents(); $data["info"] = array(); // get children foreach ($parents as $parent) { $buffer = array($parent); // get title $children = $this->db->getChildren($parent); foreach ($children as $child) { array_push($buffer, $child); } array_push($data["info"], $buffer); } // display information $data['title'] = 'Task'; View::renderTemplate('header', $data); View::render('task/task', $data); View::renderTemplate('footer', $data); }
public function admin($name) { $users = Users::getAll(); View::set("users", $users); View::set("title", "Custom MVC"); View::render("admin"); }
/** * Define Index page title and load template files */ public function index() { $data['title'] = 'Creepers'; View::renderTemplate('header', $data); View::render('home', $data); View::renderTemplate('footer', $data); }
public function indexAction() { $page = !(int) Route::param('page') ? 1 : (int) Route::param('page'); // Seo $this->_seo['h1'] = 'Карта сайта'; $this->_seo['title'] = 'Карта сайта'; $this->_seo['keywords'] = 'Карта сайта'; $this->_seo['description'] = 'Карта сайта'; $this->setBreadcrumbs('Карта сайта'); // Get pages $result = DB::select()->from('content')->where('status', '=', 1)->order_by('sort')->as_object()->execute(); $pages = array(); foreach ($result as $obj) { $pages[$obj->parent_id][] = $obj; } // Get catalog groups $result = DB::select()->from('catalog_tree')->where('status', '=', 1)->order_by('sort')->as_object()->execute(); $groups = array(); foreach ($result as $obj) { $groups[$obj->parent_id][] = $obj; } // Get catalog groups $brands = DB::select()->from('brands')->where('status', '=', 1)->order_by('sort')->as_object()->execute(); // Get news $news = DB::select()->from('news')->where('status', '=', 1)->order_by('date', 'DESC')->as_object()->execute(); // Get articles $articles = DB::select()->from('articles')->where('status', '=', 1)->order_by('id', 'DESC')->as_object()->execute(); // Render page $this->_content = View::tpl(array('pages' => $pages, 'groups' => $groups, 'news' => $news, 'articles' => $articles, 'brands' => $brands), 'Sitemap/Index'); }
/** * Load controller * * @param array $cmv array('controller' => '', 'method' => '', 'vars' => array()) */ private function loadController($cmv) { //if we have nothing to do, then quit if (empty($cmv) or empty($cmv['controller']) or empty($cmv['method'])) { trigger_error('Not call controller->method', E_USER_ERROR); exit; } if (!is_array($cmv['controller'])) { $cmv['controller'] = array($cmv['controller']); } self::$controller = implode("\\", $cmv['controller']); self::$method = $cmv['method']; $this->view->setView(self::$controller . DS . self::$method); //add controllers folder to begin and uppercase first letter class name array_unshift($cmv['controller'], 'controllers'); end($cmv['controller']); $cmv['controller'][key($cmv['controller'])] = ucfirst($cmv['controller'][key($cmv['controller'])]); $cmv['controller'] = "\\" . implode("\\", $cmv['controller']); $controller = new $cmv['controller']($this->config, $this->router, $this->view); if (method_exists($controller, 'beforeMethod')) { Debug::timer('beforeMethod'); $controller->beforeMethod(); Debug::timer('beforeMethod'); } if (is_callable(array($controller, $cmv['method']), true)) { Debug::timer('Controller logic'); call_user_func_array(array($controller, $cmv['method']), $cmv['vars']); Debug::timer('Controller logic'); } if (method_exists($controller, 'afterMethod')) { Debug::timer('afterMethod'); $controller->afterMethod(); Debug::timer('afterMethod'); } }
/** * Define Index page title and load template files */ public function index() { $data['title'] = "Mini IMDB"; View::renderTemplate('header', $data); View::render('movies/homepage', $data); View::renderTemplate('footer', $data); }
function index() { View::setHeaderTag('title', 'Home'); View::render('header'); View::render('index/index'); View::render('footer'); }
/** * User login */ public function userLogin($app_info) { $data['id'] = $app_info->app_id; $data['version'] = $app_info->app_version; $data['dir'] = DIR; View::render('login', $data); }
/** * @param $view * @param null $params * * @return View */ public function view($view, $params = null) { $params['Config'] = new Config(); $params['Date'] = new Carbon(); $params['Utils'] = new Utils(); View::render($view, $params); }
public function file() { $fileID = array_keys($_GET); $fileID = str_replace('files/', '', $fileID[0]); $fileInfo = $this->_files->getFileInfo($fileID); if (empty($fileInfo)) { header("{$_SERVER['SERVER_PROTOCOL']} 404 Not Found"); $data['title'] = '404'; $data['error'] = "Страница не найдена."; View::render('Error/404'); die; } $data['title'] = $fileInfo['file_name']; $data['fileinfo'] = $fileInfo; if ($data['fileinfo']['file_type'] == 'image/jpg' || $data['fileinfo']['file_type'] == 'image/gif' || $data['fileinfo']['file_type'] == 'image/png') { $data['imageinfo'] = getimagesize($_SERVER['DOCUMENT_ROOT'] . '/uploads/' . $data['fileinfo']['server_name']); } if ($data['fileinfo']['file_type'] == 'image/jpg' || $data['fileinfo']['file_type'] == 'image/tiff') { $data['imageinfo']['saved'] = exif_read_data($_SERVER['DOCUMENT_ROOT'] . '/uploads/' . $data['fileinfo']['server_name']); } $fileType = array_shift(explode('/', $data['fileinfo']['file_type'])); if ($fileType == 'video' || $fileType == 'audio') { $getID3 = new GetId3(); $data['mediainfo'] = $getID3->setEncoding('UTF-8')->analyze($_SERVER['DOCUMENT_ROOT'] . '/uploads/' . $data['fileinfo']['server_name']); } $data['comments'] = $this->_files->getAllComments($fileID); $data['token'] = $this->makeToken(); View::renderTemplate('header', $data); View::render('files/file', $data); View::renderTemplate('footer', $data); }
public function indexAction() { $posts = new Posts(); $posts->getAll(); $view = View::init(); echo $view->render('pages/posts/all.twig', ['title' => 'Блог', 'posts' => $posts->getAll()]); }
public function index() { $data['title'] = "Sistema de Administración de Aerolíneas"; $data['page'] = "page2"; if (!is_null(filter_input(INPUT_POST, 'insertar'))) { $nombre = $_POST['nombre']; $responsable = $_POST['responsable']; $numero = $_POST['numero']; $email = $_POST['correo']; $datos = array('NOMBRE' => $nombre, 'NOMBRE_RESPONSABLE' => $responsable, 'AVIONES' => $numero, 'EMAIL' => $email); $this->_model->insertar_aerolinea($datos); Url::redirect("aerolineas?aer=1"); } elseif (!is_null(filter_input(INPUT_POST, 'eliminar'))) { $id_aerolinea = $_POST['id_aerolinea']; $where = array('aerolinea_id' => $id_aerolinea); $this->_model->eliminar_aerolinea($where); } elseif (!is_null(filter_input(INPUT_POST, 'editar'))) { $nombre = $_POST['nombre']; $responsable = $_POST['responsable']; $numero = $_POST['numero']; $email = $_POST['correo']; $id_aerolinea = $_POST['id_aerolinea']; $data = array('NOMBRE' => $nombre, 'NOMBRE_RESPONSABLE' => $responsable, 'AVIONES' => $numero, 'EMAIL' => $email); $where = array('aerolinea_id' => $id_aerolinea); $this->_model->actualizar_aerolinea($data, $where); } $data['aerolineas'] = $this->_model->obtener_aerolineas(); $data['aviones'] = $this->_model->obtener_aviones(); View::renderTemplate('header', $data); View::render('aerolineas/aerolineas', $data); View::renderTemplate('footer', $data); }
public function login() { if (Session::get('loggedin')) { Url::redirect('admin-panel'); } $data['title'] = 'Login'; if (isset($_POST['submit'])) { $correo = $_POST['correo']; $password = $_POST['password']; if ($correo == '' || !isset($correo)) { $data['error'][0] = 'Correo es un campo obligatorio'; } if ($password == '' || !isset($password)) { $data['error'][1] = 'Password es un campo obligatorio'; } if (Password::verify($password, $this->_model->getHash($correo)) == false) { $data['error'][2] = 'Correo o password incorrectos'; } if (!$data['error']) { $data['usuario'] = $this->_model->getUsuario($correo); Session::set('loggedin', true); Session::set('idUsuario', $data[usuario][0]->idUsuario); Session::set('nombre', $data[usuario][0]->nombre); Session::set('apellidoPaterno', $data[usuario][0]->apellidoPaterno); $dataUsuario = array('fechaConexion' => date("Y-m-d H:i:s")); $where = array('correo' => $correo); $this->_model->updateUsuario($dataUsuario, $where); Url::redirect('admin-panel'); } } View::renderTemplate('header', $data); View::render('Auth/Login', $data); View::renderTemplate('footer', $data); }
public function index() { $data['title'] = "Inicio"; View::renderTemplate('header', $data); View::render('inicio/inicio', $data); View::renderTemplate('footer', $data); }
public function innerAction() { $this->_template = 'CatalogItemsWithoutFilter'; $page = !(int) Route::param('page') ? 1 : (int) Route::param('page'); // Check for existance $brand = DB::select()->from('brands')->where('alias', '=', Route::param('alias'))->where('status', '=', 1)->as_object()->execute()->current(); if (!$brand) { return Config::error(); } // Seo $this->_seo['h1'] = $brand->h1; $this->_seo['title'] = $brand->title; $this->_seo['keywords'] = $brand->keywords; $this->_seo['description'] = $brand->description; $this->setBreadcrumbs($brand->name); // Get count items per page $limit = (int) Arr::get($_GET, 'per_page') ? (int) Arr::get($_GET, 'per_page') : Config::get('limit'); // Get sort type $sort = in_array(Arr::get($_GET, 'sort'), array('name', 'created_at', 'cost')) ? Arr::get($_GET, 'sort') : 'sort'; $type = in_array(strtolower(Arr::get($_GET, 'type')), array('asc', 'desc')) ? strtoupper(Arr::get($_GET, 'type')) : 'ASC'; // Get popular items $result = DB::select(array('catalog_images.image', 'image'), 'catalog.*')->from('catalog')->join('catalog_images', 'LEFT')->on('catalog_images.catalog_id', '=', 'catalog.id')->on('catalog_images.main', '=', DB::expr('1'))->where('catalog.brand_id', '=', $brand->id)->where('catalog.status', '=', 1)->order_by('catalog.' . $sort, $type)->limit($limit)->offset(($page - 1) * $limit)->as_object()->execute(); // Set description of the brand to show it above the sort part Config::set('brand_description', View::tpl(array('brand' => $brand), 'Brands/Inner')); // Count of parent groups $count = DB::select(array(DB::expr('COUNT(catalog.id)'), 'count'))->from('catalog')->where('brand_id', '=', $brand->id)->where('status', '=', 1)->as_object()->execute()->current()->count; // Generate pagination $pager = Pager::factory($page, $count, $limit)->create(); // Render template $this->_content = View::tpl(array('result' => $result, 'pager' => $pager), 'Catalog/ItemsList'); }
public function index() { if (!isset($_GET['code'])) { header("Location: ../sign-in/index"); exit; } $testActivation = \Models\User::getUsernameByActivationCode($_GET['code']); if (!isset($testActivation['username'])) { echo \Core\View::make('header', ['title' => 'Activation unsuccessful']); echo \Core\View::make('activation.bad'); echo \Core\View::make('footer'); } else { $date = date('Y-m-d H:i:s'); $user = \Models\User::setUserActivatedAt($date, $_GET['code']); if (isset($user['id'])) { $subject = 'Welcome'; $body = "Congratulations. Your account is activated."; $result = Mailer::send($user['email'], $subject, $body); if ($result == 'Message has been sent') { echo \Core\View::make('header'); echo \Core\View::make('activation.good', ['title' => 'Activation successful']); echo \Core\View::make('footer'); } } } }
public function developers() { $data['title'] = $this->language->get('Developerteam'); View::renderTemplate('header', $data); View::render('home/developers', $data); View::renderTemplate('footer', $data); }
public function index() { if (!Session::get('loggedin')) { Url::redirect('login'); } if (isset($_POST['submit']) && $_FILES['fileToUpload']['size'] > 0) { $name = !isset($_POST['productName']) || trim($_POST['productName']) == '' ? '' : $_POST['productName']; $price = !isset($_POST['productPrice']) || trim($_POST['productPrice']) == '' ? 0 : floatval($_POST['productPrice']); $description = !isset($_POST['productDescription']) || trim($_POST['productDescription']) == '' ? '' : $_POST['productDescription']; $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION); // Check if image file is a actual image or fake image if (isset($_POST["submit"])) { $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if ($check !== false) { //echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { //echo "File is not an image."; $uploadOk = 0; } } // Check if file already exists if (file_exists($target_file)) { $error = "Sorry, file already exists." . $error; $uploadOk = 0; } // Check file size if ($_FILES["fileToUpload"]["size"] > 500000) { $error = "Sorry, your file is too large." . $error; $uploadOk = 0; } // Allow certain file formats if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") { $error = "Sorry, only JPG, JPEG, PNG & GIF files are allowed." . $error; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { $error = "Sorry, your file was not uploaded." . $error; // if everything is ok, try to upload file } else { //if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], str_replace(' ','-',strtolower($target_file)))) { //echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; $product['product'] = array('name' => $name, 'price' => $price, 'description' => $description, 'lastUpdate' => date('Y-m-d G:i:s')); $product['image'] = array('image' => file_get_contents($_FILES['fileToUpload']['tmp_name']), 'size' => $_FILES["fileToUpload"]["size"], 'type' => $imageFileType); $this->_model->insertProduct($product); //unlink(str_replace(' ','-',strtolower($target_file))); } } Hooks::addHook('js', 'Controllers\\menu@indexJS'); Hooks::addHook('css', 'Controllers\\menu@indexCss'); $data['title'] = 'index'; $data['username'] = Session::get('username'); View::rendertemplate('header', $data); View::render('menu/index', $data, $error); View::rendertemplate('footer', $data); }
public function register() { if (Session::get('logged')) { Url::redirect(); } $data['title'] = 'הרשמה'; if (isset($_POST['submit'])) { $username = $_POST['username']; $password = $_POST['password']; $email = $_POST['email']; if ($username == '') { $error[] = 'שם משתמש הוא שדה נדרש'; } if ($this->_model->get_user($username)) { $error[] = 'שם המשתמש תפוס, בעסה'; } if ($password == '') { $error[] = 'צריך סיסמא כדי להירשם, אחרת כל אחד יוכל להיכנס במקומך...'; } if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $error[] = 'כדי להירשם צריך מייל, למקרה ששכחת את הסיסמא'; } if (!$error) { $postdata = array('user_name' => $username, 'user_password' => Password::make($password), 'user_email' => $email); $this->_model->add_user($postdata); $this->login_user($username); // Session::set('message','User Added'); Url::redirect(); } } View::renderTemplate('header', $data); View::render('register', $data, $error); View::renderTemplate('footer', $data); }
public function index() { $data = array(); View::renderTemplate("NewPortalHeader", $data, 'MetroTemplate'); View::render("portal/Portal", $data); View::renderTemplate("footer", $data, 'MetroTemplate'); }
public function index() { $data['subtitle'] = 'Welcome'; View::render('site/php/header', $data); View::render('site/php/home'); View::render('site/php/footer'); }
public function index() { $data['title'] = "Contact"; View::renderTemplate('header', $data); View::render('contact/index', $data); View::renderTemplate('footer', $data); }
function index($error = '404') { $data = array(); switch ($error) { case '500': $data['headers'] = 'HTTP/1.0 500 Internal Server Error'; $data['title'] = 'Error 500'; $data['message'] = "Internal Server Error. Probably we did something wrong."; break; case '404': default: $data['headers'] = 'HTTP/1.0 404 Not Found'; $data['title'] = 'Error 404'; $data['message'] = "Not found. There is nothing here."; break; } if (!SEND_JSON) { $keywords = 'error, ' . $error; View::setHeaderTag('title', $data['title']); View::setHeaderTag('keywords', $keywords); View::setHeaderTag('description', $data['message']); View::render('header', array(), $data['headers']); View::render('error/index', $data); View::render('footer'); } else { Json::echoJson($data); } }
public function index() { header("HTTP/1.0 404 Not Found"); $data['title'] = '404'; $data['error'] = $this->error; View::render('error/404', $data); }
public function index() { $cache = new \Helpers\SimpleCache(); $forecastApi = json_decode($cache->get_data('forecast', 'http://www.prevision-meteo.ch/services/json/colmar'), TRUE); $data["title"] = "Prévisions"; $data['csrf_token'] = Csrf::makeToken(); $data["tempMin+1"] = $forecastApi["fcst_day_1"]["tmin"]; $data["tempMax+1"] = $forecastApi["fcst_day_1"]["tmax"]; $data["tempMin+2"] = $forecastApi["fcst_day_2"]["tmin"]; $data["tempMax+2"] = $forecastApi["fcst_day_2"]["tmax"]; $data["tempMin+3"] = $forecastApi["fcst_day_3"]["tmin"]; $data["tempMax+3"] = $forecastApi["fcst_day_3"]["tmax"]; $data["tempMin+4"] = $forecastApi["fcst_day_4"]["tmin"]; $data["tempMax+4"] = $forecastApi["fcst_day_4"]["tmax"]; $data["resume+1"] = $forecastApi["fcst_day_1"]["condition"]; $data["resume+2"] = $forecastApi["fcst_day_2"]["condition"]; $data["resume+3"] = $forecastApi["fcst_day_3"]["condition"]; $data["resume+4"] = $forecastApi["fcst_day_4"]["condition"]; $data["icon+1"] = $forecastApi["fcst_day_1"]["icon"]; $data["icon+2"] = $forecastApi["fcst_day_2"]["icon"]; $data["icon+3"] = $forecastApi["fcst_day_3"]["icon"]; $data["icon+4"] = $forecastApi["fcst_day_4"]["icon"]; $data['javascript'] = array('AjaxControllers/Forecast/forecast'); View::renderTemplate('header', $data); View::render('forecast/index', $data); View::renderTemplate('footer', $data); }