public function login()
 {
     if (Session::get("auth")) {
         header('Location: ' . URL . 'news/');
     } else {
         if (!empty($_POST)) {
             Security::escapa($_POST, $GLOBALS['clsDataClass']->getConnection());
         }
         $usuarios = Model::loadModel('admin', $GLOBALS['clsDataClass']);
         $user = $usuarios->getUserbyUser($_POST['user']);
         //Comprobamos si existe el usuario
         if ($user && count($user)) {
             if ($user[0]['loginPassword'] == $_POST['pass']) {
                 Session::set('id', $user[0]['id']);
                 Session::set('user', $user[0]["loginName"]);
                 Session::set('level', $user[0]["tipo_usuario"]);
                 Session::set('auth', true);
                 Session::set('messages', 'Bienvenido #USER#.', array('#USER#' => $user[0]['loginName']));
                 header('Location: ' . URL . 'news/');
             }
         } else {
             Session::set('errors', 'Usuario o contraseƱa incorrectos.');
             header('Location: ' . URL . 'admin/');
         }
     }
 }
 public function index()
 {
     $this->initializeTpl("pagina", "Home");
     $url = explode('-', $GLOBALS['params'][0]);
     $iddato = strtolower(array_shift($url));
     $post = Model::loadModel('page', $GLOBALS['clsDataClass']);
     $onlypost = $post->GetId($tabla = $this->post, $id = "id=" . $iddato);
     $this->_tpl->assign('id', $onlypost[0]["id"]);
     $this->_tpl->assign('title', $onlypost[0]["titulo"]);
     $this->_tpl->assign('date', $onlypost[0]["fecha"]);
     $this->_tpl->assign('text', $onlypost[0]["text"]);
     $this->_tpl->printToScreen();
 }
 /**
  * onLatLngGetting
  * @param Model $model
  * @return array | boolean
  */
 protected function onLatLngGetting(Model $model)
 {
     $curl = new \Ivory\HttpAdapter\CurlHttpAdapter();
     $geocoder = new \Geocoder\Provider\GoogleMaps($curl);
     $model->loadModel('Country');
     $aCountryOptions = $model->Country->options();
     $countryCode = $model->data['User']['live_country'];
     $countryName = isset($aCountryOptions[$countryCode]) ? $aCountryOptions[$countryCode] : $countryCode;
     $address = join(',', array($model->data['User']['live_address'], $model->data['User']['live_place'], $countryName));
     $result = $geocoder->geocode($address);
     if ($result) {
         return $result;
     }
     return false;
 }
 public function index()
 {
     $this->initializeTpl("pagina", "Home");
     $post = Model::loadModel('home', $GLOBALS['clsDataClass']);
     if ($allpost = $post->Getpostlimit()) {
         foreach ($allpost as $posty) {
             $this->_tpl->newBlock("post");
             $this->_tpl->assign('id', $posty["id"]);
             $this->_tpl->assign('title', $posty["titulo"]);
             $this->_tpl->assign('text', substr($posty["text"], 0, 200));
             $this->_tpl->assign('date', $posty["fecha"]);
             $this->_tpl->assign('slug', $posty["slug"]);
         }
     }
     $this->_tpl->printToScreen();
 }
 public function delete()
 {
     if (Session::get("auth")) {
         $post = Model::loadModel('news', $GLOBALS['clsDataClass']);
         if ($insert = $post->delete($tabla = $this->categorias_post_usuario, $parametros = "id_post=" . $GLOBALS['params'][0])) {
             if ($insert = $post->delete($tabla = $this->post, $parametros = "id=" . $GLOBALS['params'][0])) {
                 header('Location: ' . URL . 'news/');
             }
         }
     } else {
         header('Location: ' . URL . 'admin/');
     }
 }