public function __construct()
 {
     $view = new View();
     $view->show('header.php', array('title' => 'Home'));
     $view->show('home.php');
     $view->show('footer.php');
 }
 private function bierenOverzicht()
 {
     $bierenModel = new Bieren_model();
     $bieren = $bierenModel->bieren();
     $view = new View();
     $view->show('header.php', array('title' => 'Overzicht van de bieren'));
     $view->show('bieren_overview.php', array('bieren' => $bieren['data']));
     $view->show('footer.php');
 }
 private function bierenIndividueel($id)
 {
     $bierenModel = new Bieren_model();
     $bier = $bierenModel->bieren($id);
     $view = new View();
     $view->show('header.php', array('title' => ''));
     $view->show('bieren_individueel.php', array('bier' => $bier['data'][0]));
     $view->show('footer.php');
 }
 public function showIndex()
 {
     $data['title'] = 'Overzicht van MVC: step 3';
     View::show('header', $data);
     View::show('index-body');
     View::show('footer');
 }
Exemple #5
0
 protected function show($response = null) {
     parent::show($response);
     header("Content-Type: text/javascript");
     echo "<script type='text/javascript'>";
     echo "var ".$this->getOperation()." = ".json_encode($response);
     echo "</script>";
 }
Exemple #6
0
 function index()
 {
     $contacts_model = new ContactsModel();
     $contacts = $contacts_model->get_contacts();
     // var_dump($contacts);die;
     $view = new View();
     $view->set_file_name('contacts');
     $params = array('contacts' => $contacts);
     $view->show($params);
 }
Exemple #7
0
 function index()
 {
     $bio_model = new BioModel();
     $bio = $bio_model->get_bio();
     // var_dump($bio);die;
     $view = new View();
     $view->set_file_name('bio');
     $params = array('bio' => $bio);
     $view->show($params);
 }
Exemple #8
0
 function index()
 {
     $photo_model = new PhotoModel();
     $photo = $photo_model->get_photo();
     //        var_dump($photo);die;
     $view = new View();
     $view->set_file_name('photo');
     $params = array('photo' => $photo);
     $view->show($params);
 }
Exemple #9
0
 function index()
 {
     $video_model = new VideoModel();
     $video = $video_model->get_video();
     //        var_dump($video);die;
     $view = new View();
     $view->set_file_name('video');
     $params = array('video' => $video);
     $view->show($params);
 }
Exemple #10
0
 function news_one_show($id = null)
 {
     $one_news_model = new NewsModel();
     $one_news = $one_news_model->get_one_news($id);
     //        var_dump($news);die;
     $view = new View();
     $view->set_file_name('admin_news_one');
     $params = array('news' => $one_news);
     $view->show($params);
 }
Exemple #11
0
 public function show($response) {
     parent::show($response);
     header("Content-Type: text/javascript");        
     $p = filter_input(INPUT_GET, $this->query_variable ,FILTER_SANITIZE_STRING);
     if ( (!is_null($p)) && ($p!=false)  ) {
         echo "if (typeof ".$p." === 'function' ) $p( ".json_encode($response, $this->json_encode_options)." ); else console.log('Function ".$p." not found.'); ";
     } else {
         $this->setError("Jsonp function is requered", 3004);            
     }
 }
 public function showArtikel($id)
 {
     # Haal data op op basis van het ID dat in de url staak (=de hook)
     $articleData = $this->model->getArticle($id);
     # Prepare data voor in body
     $data['artikel'] = $articleData['data'][0];
     # Zet title in head
     $data['title'] = $data['artikel']['titel'];
     View::show('header', $data);
     View::show('artikel-enkel-body', $data);
     View::show('footer');
 }
Exemple #13
0
 public function show($response) {
     parent::show($response);
     if (file_exists( $this->phpfile )) {            
         $_VIEW = array();
         $_VIEW["OPERATION"] = $this->getOperation();
         $_VIEW["RESPONSE"] = $response;
         $_VIEW["ATTRIBUTES"] = $this->attributes;
         $GLOBALS["_VIEW"] = $_VIEW;
         include $this->phpfile;            
     } else {    
         $this->setError("PHP ".$this->phpfile." file not found", 3003);              
     } 
 }
Exemple #14
0
 private function edit()
 {
     Base::requireAdmin();
     if (!isset($_POST['page']) && !isset($_POST['draft'])) {
         // Preparations for View
         View::set('page', $this->page);
         View::show('page/edit');
     }
     // Token
     $this->page->title = $_POST['title'];
     // Filter
     $this->page->slug = Base::slug($_POST['title']);
     $this->page->html = $_POST['html'];
     $this->page->published = isset($_POST['page']);
     $this->page->save();
     // Successfully edited
     Base::redirect('/page/' . $this->page->slug, 'Page successfully edited');
 }
 private function explore()
 {
     // Get some tags to show as options
     $tags = Tag::select('name')->limit(30)->findArray();
     View::set('tags', $tags);
     // No tags selected
     if (empty($_GET['t']) || !Validate::tags($_GET['t'])) {
         $rows = Playlist::join('user', 'user_id = u.id', 'u')->selectMany('playlist.*', 'username')->where('published', 1)->paginate();
         Base::eagerLoadingPlaylistTags($rows);
         View::set('playlists', $rows);
         View::show('explore');
     }
     // Separate tags by spaces
     $tags = trim($_GET['t']);
     $tags = explode('/', $tags, 4);
     $tags = array_slice($tags, 0, 3);
     // Url for selected tags
     $selectedTagsUrl = implode('/', $tags);
     // Beautifys the title Tags
     $selectedTags = array();
     foreach ($tags as $key => $item) {
         // Removes empty tags
         if (empty($item)) {
             unset($tags[$key]);
             continue;
         }
         $aux = array();
         $aux['name'] = $item;
         // When one clicked will remove that tag from the query
         unset($tags[$key]);
         $aux['href'] = '/' . implode('/', $tags);
         $tags[$key] = $item;
         $selectedTags[] = $aux;
     }
     $playlists = Playlist::filter('byTags', $tags)->join('user', 'p.user_id = u.id', 'u')->selectMany('p.*', 'username');
     $count = $playlists->countDistinct('p.id');
     $playlists = $playlists->groupBy('p.id')->paginate($count);
     Base::eagerLoadingPlaylistTags($playlists);
     // View preparations
     View::set('playlists', $playlists);
     View::set('selectedTags', $selectedTags);
     View::set('selectedTagsUrl', $selectedTagsUrl);
     View::show('explore');
 }
 public function __construct()
 {
     if (!isset($_GET['q'])) {
         View::error('search/search');
     }
     // Allows algorithm to process search input
     $this->query = Base::searchQuery($_GET['q']);
     if (!$this->query) {
         View::error('search/search');
     }
     // Set search query in view
     View::set('search_query', str_replace('%', ' ', $this->query));
     if (SECOND_PARAMETER === 'playlists' || SECOND_PARAMETER === 'users' || SECOND_PARAMETER === 'tracks') {
         $func = SECOND_PARAMETER;
         $this->{$func}();
         View::set('page_title', ucfirst($func));
         View::show('search/' . $func);
     }
     $this->search();
     View::set('page_title', 'Search');
     View::show('search/search');
 }
Exemple #17
0
 /**
  * User registration page
  */
 private function register()
 {
     Base::requireNotLogged();
     if (!isset($_POST['register'])) {
         View::show('user/register');
     }
     $username = $_POST['username'];
     $password = $_POST['password'];
     $password2 = $_POST['password2'];
     $email = $_POST['email'];
     // Password errors
     if (!Validate::len($password, 4, 128)) {
         $error = 'Password must have more than 4 characters';
     } elseif ($password != $password2) {
         $error = 'Passwords don\'t match';
     } elseif (!Validate::captcha($_POST['captcha'])) {
         $error = 'Invalid captcha';
     } elseif (!Validate::len($username)) {
         $error = 'Username character count must be between 4 and 64';
     } elseif (!Validate::username($username)) {
         $error = 'Please only use letters, digits, dots and underscores in username';
     } elseif (method_exists($this, $username)) {
         $error = 'You cannot use that username';
     } elseif (User::where('username', $username)->findOne()) {
         $error = 'You cannot use that username';
     } elseif (!Validate::len($email)) {
         $error = 'Email character count must be between 4 and 64';
     } elseif (!Validate::email($email)) {
         $error = 'Please enter a valid email';
     } elseif (User::where('email', $email)->findOne()) {
         $error = 'You cannot use that email address';
     }
     if ($error) {
         View::set('error', $error);
         View::show('user/register');
     }
     $user = User::create();
     $user->username = $username;
     $user->password = Base::hashPassword($password);
     $user->email = $email;
     $user->reg_date = time();
     $user->avatar = Base::createIdenticon($username, 200);
     $user->admin = 0;
     $user->save();
     // Logs user in
     Session::login($user->id());
     Base::redirect('', "Welcome, {$user->username}! We're glad to know you");
 }
 static function main()
 {
     /**
      * Cargando librearias principales.
      */
     require LIBS . 'Config.php';
     //de configuracion
     require LIBS . 'View.php';
     //Mini motor de plantillas
     require 'config.php';
     //Archivo con configuraciones.
     /**
      * Cargando librearias de terceros
      */
     define('FPDF_FONTPATH', Libs . 'font/');
     require 'fpdf.php';
     /**
      * Cargando a los Controladores y Modelos Principales.
      * Controller ---> AppliactionPrincipal
      * Model -----> ApplicationBase
      */
     require LIBS . CONTROLLER_BASE . '.php';
     require LIBS . MODEL_BASE . '.php';
     /*
     		 		$controllerGeneral=$config->get('controllersFolder') . $config->get('controllerGeneral') . '.php';
      				$modelBase=$config->get('modelsFolder') . $config->get('modelBase') . '.php';
      				require $controllerGeneral;
      				require $modelBase;*/
     /**
      *Definiendo a nuestros controladores:
      */
     $controllerName = !empty($_REQUEST['controlador']) ? $_REQUEST['controlador'] . 'Controller' : 'indexController';
     $modelName = !empty($_REQUEST['controlador']) ? $_REQUEST['controlador'] . 'models' : '';
     $actionName = !empty($_REQUEST['accion']) ? $_REQUEST['accion'] : 'index';
     //		Formamos el nombre del Controlador o en su defecto, tomamos que es el IndexController
     //		if(!empty($_GET['controlador'])){
     //		      	$controllerName = $_GET['controlador'] . 'controller';
     //		      	$modelname=$_GET['controlador'].'models';
     //		      if(!empty($_GET['accion'])){
     //
     //		      	$actionName = $_GET['accion'];
     //				}else{
     //					$actionName = "index";
     //				}
     //		}
     //		else{
     //		     $controllerName = "indexcontroller";
     //		     $_GET['controlador']=$_GET['accion']="index";
     //		     $actionName = "index";
     //		}
     /**
      * Defino la ruta del controaldor y verifico si existe el fichero, luego lo cargo 
      */
     $controllerPath = CONTROLLERS . $controllerName . '.php';
     $modelPath = MODELS . $modelname . '.php';
     if (is_readable($controllerPath)) {
         require $controllerPath;
         is_readable($modelPath) ? require $modelPath : '';
         if (is_callable($controllerName, $actionName)) {
             /**
              * Verifico inicio de Sesion.
              */
             if ($_SESSION['Autenticado'] == true) {
                 $midir = opendir(MODELS);
                 while ($archivo = readdir($midir)) {
                     if (ereg("models.php", $archivo)) {
                         $models = MODELS . $archivo;
                         require_once $models;
                     }
                 }
                 closedir();
                 $controller = new $controllerName();
                 $controller->{$actionName}();
             } else {
                 require CONTROLLERS . 'actorController.php';
                 $controller = new actorcontroller();
                 $controller->login();
             }
         } else {
             $_REQUEST['error'] = true;
             $datos['mensaje'] = "Error :: Llamada a una accion : (" . $actionName . ") que no existe o esta vacia.";
             $datos['descripciom'] = "Por favor revisar la sintaxis o la existencia del metodo en la clase.";
             $vistaDefault = new View();
             $vistaDefault->show('error.php', $datos);
             return false;
         }
     } else {
         $datos['mensaje'] = "Error :: Llamada a un controlador : (" . $controllerName . ") que no existe.";
         $datos['descripciom'] = "Por favor revisar la sintaxis o la existencia del archivo en la carpeta de controladores.";
         $vistaDefault = new View();
         $vistaDefault->show('error.php', $datos);
         return false;
     }
     //				 $controllerPath = $config->get('controllersFolder') . $controllerName . '.php';
     //					//Incluimos el fichero que contiene nuestra clase controladora solicitada.
     //					if(is_file($controllerPath)){
     //					     require $controllerPath;
     //					}
     //					else{
     //						$datos['mensaje']="Error :: Llamada a un controlador : (".$controllerName.") que no existe.";
     //						$datos['descripciom']="Por favor revisar la sintaxis o la existencia del archivo en la carpeta de controladores.";
     //						$vistaDefault=New View();
     //						$vistaDefault->show('error.php', $datos);
     //						return false;
     //					}
     /*					$modelPath=$config->get('modelsFolder') . $modelname . '.php';
     					if(is_file($modelPath)){
     						require $modelPath;
     					}*/
     //					if (!is_callable(array($controllerName, $actionName))){
     //						$_REQUEST['error']=true;
     //						$datos['mensaje']="Error :: Llamada a una accion : (".$controllerName.") que no existe o esta vacia.";
     //						$datos['descripciom']="Por favor revisar la sintaxis o la existencia del archivo en la carpeta de controladores.";
     //						$vistaDefault=New View();
     //						$vistaDefault->show('error.php', $datos);
     //						return false;
     //					}else{
     //
     //						//Verifico inicios de SESION
     //						$ruta=$_GET['controlador']."/".$_GET['accion'];
     //						echo $ruta;
     //						switch ($ruta){
     //							case "actor/login":
     //							case "actor/salir":
     //							case "actor/valida":
     //							case "index/index":
     //								session_start();
     //								$_SESSION['Autenticado']=true;
     //								break;
     //						}
     //						session_start();
     //			      		if($_SESSION['Autenticado']){
     //
     //						//Cargo todos los modelos
     //							$midir=opendir($config->get('modelsFolder'));
     //						      while($archivo=readdir($midir))
     //						      {
     //								if(ereg("models.php",$archivo)){
     //						      		$models=$config->get('modelsFolder').$archivo;
     //						      		require_once($models);
     //								}
     //						      }
     //							closedir();
     //						//Fin de cargo todos los modelos
     //							$controller = new $controllerName();
     //							$controller->$actionName();
     //
     //						}else{
     //
     //								$datos['mensaje']="Error :: Acceso Incorrecto al Sistema";
     //								$datos['descripcion']="Debe autenticarse con las credenciales usuario y clave correctos antes de acceder al Sistema @Celestium";
     //								$vistaDefault=New View();
     //								$_REQUEST['error']=true;
     //								$vistaDefault->show('autenticate.php', $datos);
     //								return false;
     //						}
     //					}
 }
Exemple #19
0
<?php

error_reporting(E_ALL);
ini_set("display_errors", "1");
//ini_set ("include_path", "/var/www/vkonverte/vkonverte.com.ua/mvc");
require_once 'mvc/include.php';
require_once 'mvc/Context.php';
$context = new Context();
require_once 'mvc/View.php';
$view = new View();
$view->context = $context;
$view->show();
 public function showIndex()
 {
     View::show('header');
     View::show('index-body');
     View::show('footer');
 }
 public function edit()
 {
     try {
         // define view
         $view = new View("editar_registro.html");
         $view->addFile("TOPO", "topo.html");
         $vData = new DateTime(str_replace("/", "-", $_GET["_token"]));
         // preenche view com dados do profissional
         $oProf = new Profissional();
         $oProf = Sessao::getObject("oProf");
         $vTitulo = ":: EDITAR REGISTRO DE PONTO :: " . $oProf->getMatricula() . " - " . $oProf->getNome() . " :: " . $oProf->getFuncao();
         $view->setValue("TITULO", $vTitulo);
         // preenche view com dados do registro
         $oRegistro = new Registro();
         $oRegistro = $this->model->getByDate($oProf, $vData->format("d-m-Y"));
         $view->setValue("DATA", $vData->format("d-m-Y"));
         $view->setValue("DIASEMANA", Data::getDiaSemana($vData));
         if ($oRegistro) {
             $view->setValue("ENTRADA", $oRegistro->getEntradaManha());
             $view->setValue("ALMOCO", $oRegistro->getSaidaManha());
             $view->setValue("RETORNO", $oRegistro->getEntradaTarde());
             $view->setValue("SAIDA", $oRegistro->getSaidaTarde());
         }
         // carrega selects de ocorrencia
         $oOcorrencia = new Ocorrencia();
         $vOcorrencia = $oOcorrencia->getAll();
         foreach ($vOcorrencia as $row) {
             $view->setValue("CODIGO", $row->getCodigo());
             $view->setValue("DESCRICAO", $row->getDescricao());
             $view->parseBlock("BLOCK_OCORRENCIA1", true);
             $view->parseBlock("BLOCK_OCORRENCIA2", true);
             $view->parseBlock("BLOCK_OCORRENCIA3", true);
             $view->parseBlock("BLOCK_OCORRENCIA4", true);
         }
         // exibe view
         $view->addFile("FOOTER", "rodape.html");
         $view->show();
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }
 /**
  * Edit a playlist
  */
 private function edit()
 {
     Base::requireLogged();
     if (LOGGED !== $this->playlist->user_id) {
         Base::requireAdmin();
     }
     // Set page title
     View::set('page_title', 'Edit playlist');
     // Set playlist
     $playlist = $this->playlist->asArray();
     $playlist['tracks'] = $this->playlist->tracks();
     $tags = $this->playlist->tags();
     if ($tags) {
         $playlist['tags'] = implode(', ', $tags);
     }
     View::set('playlist', $playlist);
     // Not submitted
     if (!isset($_POST['playlist']) && !isset($_POST['draft'])) {
         View::show('playlist/edit');
     }
     /**
      * Add playlist title and playlist description
      */
     if (!Validate::len($_POST['title'], 2, 64)) {
         $error = 'Playlist title must be between 2 and 64 chars';
     } elseif (!Validate::len($_POST['description'], 0, 512)) {
         $error = 'Playlist description must be lesser than 512 chars';
     }
     if ($error) {
         View::error('playlist/edit', $error);
     }
     // Raw HTML may enter the db but it's automatically
     // encoded at output by Mustache
     $this->playlist->title = $_POST['title'];
     $this->playlist->description = $_POST['description'];
     /**
      * Uploads cover image
      */
     if (!empty($_FILES['cover']) && $_FILES['cover']['size'] > 0) {
         Base::uploadImage($_FILES['cover'], $cover, $error);
         if ($error) {
             View::error('playlist/edit', $error);
         }
         $this->playlist->cover = $cover;
     }
     /**
      * Inserts tags into database
      */
     if (!empty($_POST['tags'])) {
         // Separates tags by commas
         $tags = strtolower($_POST['tags']);
         $tags = explode(',', $tags, 6);
         // Tag limit
         $tags = array_slice($tags, 0, 5);
         // Filter tags
         foreach ($tags as $k => &$tag) {
             if (!ADMIN && $tag === 'staff') {
                 continue;
             }
             $tag = preg_replace('/[^a-z]+/', ' ', $tag);
             $tag = trim($tag, ' ');
             // Tag must have at least 2 chars
             // And it must be lesser than 32 chars
             if (!Validate::len($tag, 1, 32)) {
                 unset($tags[$k]);
             }
         }
         if (!empty($tags)) {
             // Remove tags from PlaylistTag
             PlaylistTag::where('playlist_id', $this->playlist->id)->deleteMany();
             // Insert tags
             $sql = str_repeat(',(?)', count($tags));
             $sql[0] = ' ';
             Tag::rawExecute("INSERT IGNORE INTO tag(name) VALUES {$sql}", $tags);
             // Get inserted tags ids and point them to the new playlist
             $tags = Tag::select('id')->whereIn('name', $tags)->findMany();
             foreach ($tags as $tag) {
                 $link = PlaylistTag::create();
                 $link->playlist_id = $this->playlist->id;
                 $link->tag_id = $tag->id;
                 $link->save();
             }
         }
     }
     // Published status
     $this->playlist->published = isset($_POST['playlist']);
     /**
      * Add tracks into db
      */
     if (!isset($_POST['tracks'])) {
         $error = 'You can\'t publish without any tracks';
         $this->playlist->published = 0;
     } else {
         if (is_array($_POST['tracks'])) {
             $max = Base::$g['playlist_max_tracks'];
             $min = Base::$g['playlist_min_tracks'];
             $tracks = $_POST['tracks'];
             if (!isset($tracks[$min - 1])) {
                 $error = "You can't publish without at least {$min} tracks";
                 $this->playlist->published = 0;
             } elseif (isset($track[$max])) {
                 $error = "You can't have more than {$max} tracks in a playlist";
                 $tracks = array_slice($tracks, 0, $max);
             }
             /**
              * Check for haxing
              */
             foreach ($tracks as $k => &$item) {
                 $item = Validate::int($item);
                 if ($item === false) {
                     unset($tracks[$k]);
                 }
             }
             // Also get duration
             $row = Track::whereIn('id', $tracks)->selectExpr('COUNT(id)', 'count')->selectExpr('SUM(duration)', 'duration')->findOne();
             if ($row->count != count(array_unique($tracks))) {
                 View::error('playlist/edit', 'Massive error 2. Contact the admin');
             }
             // Store duration in minutes
             $this->playlist->tracks_count = $row->count;
             $this->playlist->duration = $row->duration / 60;
             // Delete the ones already in
             PlaylistTrack::where('playlist_id', $this->playlist->id)->deleteMany();
             // Add new ones
             foreach ($tracks as $track) {
                 $table = PlaylistTrack::create();
                 $table->playlist_id = $this->playlist->id;
                 $table->track_id = $track;
                 $table->save();
             }
         } else {
             View::error('playlist/edit', 'Massive error. Contact the admin');
         }
     }
     /**
      * Update playlist in database
      */
     $this->playlist->save();
     $msg = $error ?: 'Playlist succesfully edited';
     Base::redirect('/' . $this->playlist->id, $msg);
 }
Exemple #23
0
 private function oops()
 {
     // Log link referers
     View::show('oops');
 }
 /**
  * User settings
  */
 private function settings()
 {
     Base::requireLogged();
     if (LOGGED !== $this->user->id) {
         Base::requireAdmin();
     }
     if (!isset($_POST['usr']) && !isset($_POST['avatar']) && !isset($_POST['pwd'])) {
         View::show('profile/settings');
     }
     // Username or email change
     if (isset($_POST['usr'])) {
     } elseif (isset($_POST['avatar'])) {
         Base::uploadImage($_FILES['avatar'], $avatar, $error);
         if ($error) {
             View::error('profile/settings', $error);
         }
         $this->user->avatar = $avatar;
         $this->user->save();
         View::set('success', 'Avatar successfully changed');
         View::set('user', $this->user->asArray());
         // Actualized user
         View::show('profile/settings');
     } elseif (isset($_POST['password'])) {
         $currentPwd = $_POST['current_pwd'];
         $password = $_POST['password'];
         $password2 = $_POST['password2'];
         if (!Base::checkPassword($currentPwd, $this->user->password)) {
             $error = 'You misspelled your current password';
             // Need help? Forgot pwd
         } elseif (!Validate::len($password, 4, 128)) {
             $error = 'Password must have more than 4 characters';
         } elseif ($password != $password2) {
             $error = 'Passwords don\'t match';
         }
         if ($error) {
             View::error('profile/settings', $error);
         }
         $this->user->password = Base::hashPassword($password);
         $this->user->save();
         View::set('success', 'Password successfully changed');
         View::show('profile/settings');
     }
 }
Exemple #25
0
 public function show($response) {
     parent::show($response);
     header('Content-Type: application/json;  charset=utf-8');
     echo json_encode($response, $this->json_encode_options);
 }
Exemple #26
0
 public function show($templateFile = null)
 {
     View::show($templateFile);
 }
Exemple #27
0
 public function index()
 {
     $view = new View();
     $view->set_file_name('Index');
     $view->show();
 }
Exemple #28
0
 /**
  * Cargador dinámico de controladores
  * @return nothing
  */
 private static function route()
 {
     // Controlador
     if (isset($_GET[self::ROUTING_CONTROLLER_VARIABLE])) {
         self::$target_routing['controller'] = $_GET[self::ROUTING_CONTROLLER_VARIABLE];
     } else {
         self::$target_routing['controller'] = self::$default_routing['controller'];
     }
     // Método
     if (isset($_GET[self::ROUTING_METHOD_VARIABLE])) {
         self::$target_routing['method'] = $_GET[self::ROUTING_METHOD_VARIABLE];
     } else {
         self::$target_routing['method'] = self::$default_routing['method'];
     }
     // Índice
     if (isset($_GET[self::ROUTING_VALUE_VARIABLE])) {
         self::$target_routing['value'] = (int) $_GET[self::ROUTING_VALUE_VARIABLE];
     }
     // Índice string para buscadores y otros
     if (isset($_GET[self::ROUTING_VALUE_VARIABLE])) {
         self::$target_routing['value_str'] = $_GET[self::ROUTING_VALUE_VARIABLE];
     }
     // Página
     if (isset($_GET[self::ROUTING_PAGENUMBER_VARIABLE])) {
         self::$target_routing['page'] = (int) $_GET[self::ROUTING_PAGENUMBER_VARIABLE];
     }
     if (self::is_valid_route(self::$target_routing['controller'], self::$target_routing['method']) === false) {
         // El problema es sólo el método.
         if (self::$error === self::ROUTING_ERROR_METHOD) {
             // redireccionamos al controlador que tenía ese método
             self::$target_routing['method'] = self::$default_routing['method'];
         } else {
             self::$target_routing = self::$error_routes;
         }
     }
     self::call_controller();
     // Renderizado final.
     View::show();
 }
 /**
  * Manage ads
  */
 private function manage_ads()
 {
     if (isset($_POST['ads'])) {
         // Token
         $option = ORM::forTable('options');
         $advert = array('advert_playlist', 'advert_user', 'advert_search');
         foreach ($advert as $item) {
             $option = $option->where('name', $item)->findOne();
             $option->value = $_POST[$item];
             $option->save();
             Base::$g[$item] = $_POST[$item];
         }
         View::set('success', 'Successfully set');
     }
     View::show('admin/manage_ads');
 }
Exemple #30
0
 static function main()
 {
     /**
      * Cargando librearias principales.
      */
     require LIBS . 'Config.php';
     //de configuracion
     require LIBS . 'View.php';
     //Mini motor de plantillas
     require 'config.php';
     //Archivo con configuraciones.
     define('FPDF_FONTPATH', LIBS . 'font/');
     require 'fpdf.php';
     /**
      * Cargando a los Controladores y Modelos Principales.
      */
     require LIBS . CONTROLLER_BASE . '.php';
     require LIBS . MODEL_BASE . '.php';
     /**
      *Definiendo a nuestros controladores:
      */
     $controllerName = !empty($_REQUEST['controlador']) ? $_REQUEST['controlador'] . 'controller' : 'indexcontroller';
     $modelName = !empty($_REQUEST['controlador']) ? $_REQUEST['controlador'] . 'models' : '';
     $actionName = !empty($_REQUEST['accion']) ? $_REQUEST['accion'] : 'index';
     /**
      * Defino la ruta del controaldor y verifico si existe el fichero, luego lo cargo 
      */
     $controllerPath = CONTROLLERS . $controllerName . '.php';
     $modelPath = MODELS . $modelname . '.php';
     if (is_readable($controllerPath)) {
         require $controllerPath;
         is_readable($modelPath) ? require $modelPath : '';
         if (is_callable($controllerName, $actionName)) {
             session_start();
             if ($_SESSION['Autenticado'] == true || $actionName == 'valida') {
                 $midir = opendir(MODELS);
                 while ($archivo = readdir($midir)) {
                     if (ereg("models.php", $archivo)) {
                         $models = MODELS . $archivo;
                         require_once $models;
                     }
                 }
                 closedir();
                 $controller = new $controllerName();
                 $controller->{$actionName}();
             } else {
                 require_once CONTROLLERS . 'actorcontroller.php';
                 $controller = new actorcontroller();
                 $controller->login();
             }
         } else {
             $datos['mensaje'] = "Error :: Llamada a una accion : (" . $actionName . ") que no existe o esta vacia.";
             $datos['descripciom'] = "Por favor revisar la sintaxis o la existencia del metodo en la clase.";
             $vistaDefault = new View();
             $vistaDefault->show('error.php', $datos);
             return false;
         }
     } else {
         $datos['mensaje'] = "Error :: Llamada a un controlador : (" . $controllerName . ") que no existe.";
         $datos['descripciom'] = "Por favor revisar la sintaxis o la existencia del archivo en la carpeta de controladores.";
         $vistaDefault = new View();
         $vistaDefault->show('error.php', $datos);
         return false;
     }
 }