示例#1
0
 protected function public_core()
 {
     $this->template = 'inme_public/stats';
     $this->page_title = $this->empresa->nombrecorto;
     $this->page_description = 'Portal de noticias colaborativo, para los que huyen de la mafia de menéame.' . ' Exploramos la web para mostrarte los temas de actualidad.';
     $this->buscar = '';
     $fsvar = new fs_var();
     $this->analytics = $fsvar->simple_get('inme_analytics');
     $this->modrewrite = $fsvar->simple_get('inme_modrewrite');
     if (isset($_GET['ok_cookies'])) {
         setcookie('ok_cookies', 'TRUE', time() + FS_COOKIES_EXPIRE, '/');
         $fslog = new fs_log();
         $fslog->tipo = 'cookies';
         $fslog->detalle = 'Se han aceptado las cookies';
         $fslog->ip = $_SERVER['REMOTE_ADDR'];
         $fslog->save();
     }
 }
示例#2
0
 private function new_log_msg($msg = FALSE, $tipo = 'caja', $alerta = FALSE)
 {
     if ($msg) {
         $fslog = new fs_log();
         $fslog->tipo = $tipo;
         $fslog->detalle = $msg;
         $fslog->ip = $_SERVER['REMOTE_ADDR'];
         $fslog->alerta = $alerta;
         if ($this->user) {
             $fslog->usuario = $this->user->nick;
         }
         $fslog->save();
     }
 }
 private function modificar_serie()
 {
     $serie = $this->serie->get($_POST['codserie']);
     if (!$serie) {
         $serie = new serie();
         $serie->codserie = $_POST['codserie'];
     }
     $serie->descripcion = $_POST['descripcion'];
     $serie->siniva = isset($_POST['siniva']);
     $serie->irpf = floatval($_POST['irpf']);
     if ($this->num_personalizada) {
         if ($_POST['codejercicio'] != $serie->codejercicio or $_POST['numfactura'] != $serie->numfactura) {
             if ($this->user->admin) {
                 if ($this->hay_facturas_venta($serie->codserie)) {
                     $this->new_error_msg('Ya hay facturas con esta serie, no puedes cambiar la numeración inicial.');
                 } else {
                     $serie->codejercicio = NULL;
                     $serie->numfactura = 1;
                     if ($_POST['codejercicio'] != '') {
                         $serie->codejercicio = $_POST['codejercicio'];
                         $serie->numfactura = intval($_POST['numfactura']);
                         /// anotamos el cambio en el log
                         $fslog = new fs_log();
                         $fslog->alerta = TRUE;
                         $fslog->detalle = 'Se ha cambiado la numeración inicial de la serie ' . $serie->codserie . ' para el ejercicio ' . $serie->codejercicio . '. Nuevo número inicial: ' . $serie->numfactura;
                         $fslog->ip = $this->user->last_ip;
                         $fslog->usuario = $this->user->nick;
                         $fslog->tipo = 'serie';
                         $fslog->save();
                     }
                 }
             } else {
                 $this->new_error_msg("La numeración de facturas es una cosa delicada," . " solamente un administrador puede hacer cambios.", 'serie', TRUE);
             }
         }
     }
     if ($serie->save()) {
         $this->new_message('Datos guardados correctamente.');
     } else {
         $this->new_error_msg("¡Imposible guardar " . FS_SERIE . "!");
     }
 }
示例#4
0
 /**
  * Gestiona el cierre de sesión
  */
 private function log_out()
 {
     setcookie('logkey', '', time() - FS_COOKIES_EXPIRE);
     $fslog = new fs_log();
     if (isset($_COOKIE['user'])) {
         $fslog->usuario = $_COOKIE['user'];
     }
     $fslog->tipo = 'login';
     $fslog->detalle = 'El usuario ha cerrado la sesión.';
     $fslog->ip = $_SERVER['REMOTE_ADDR'];
     $fslog->save();
 }
 protected function public_core()
 {
     $this->template = 'inme_public/editar_noticia';
     $this->page_description = 'Detalle de la noticia.';
     $this->buscar = '';
     $fsvar = new fs_var();
     $this->analytics = $fsvar->simple_get('inme_analytics');
     $this->modrewrite = $fsvar->simple_get('inme_modrewrite');
     if (isset($_GET['ok_cookies'])) {
         setcookie('ok_cookies', 'TRUE', time() + FS_COOKIES_EXPIRE, '/');
         $fslog = new fs_log();
         $fslog->tipo = 'cookies';
         $fslog->detalle = 'Se han aceptado las cookies';
         $fslog->ip = $_SERVER['REMOTE_ADDR'];
         $fslog->save();
     }
     $this->noticia = FALSE;
     $this->relacionada = FALSE;
     $this->temas = array();
     $noti0 = new inme_noticia_fuente();
     if (isset($_REQUEST['id'])) {
         $this->noticia = $noti0->get($_REQUEST['id']);
     } else {
         if (isset($_REQUEST['permalink'])) {
             $this->noticia = $noti0->get_by_permalink($_REQUEST['permalink']);
         }
     }
     if ($this->noticia) {
         $this->page_title = $this->noticia->titulo;
         $this->page_description = $this->true_text_break($this->noticia->resumen, 140);
         if (!is_null($this->noticia->id_relacionada)) {
             $this->relacionada = $noti0->get($this->noticia->id_relacionada);
         }
         $tema0 = new inme_tema();
         foreach ($this->noticia->keywords() as $key) {
             $tema = $tema0->get($key);
             if ($tema) {
                 if ($tema->activo) {
                     $this->temas[] = $tema;
                     /// si no hay una preview, usamos la de un tema
                     if ($tema->imagen and !$this->noticia->preview) {
                         $this->noticia->preview = $tema->imagen;
                         $this->noticia->save();
                     }
                 }
             } else {
                 $this->new_error_msg('Tema ' . $key . ' no encontrado.');
             }
         }
     } else {
         $this->new_error_msg('Noticia no encontrada.');
     }
 }
 /**
  * Gestiona el cierre de sesión
  */
 private function log_out($rmuser = FALSE)
 {
     $path = '/';
     if (isset($_SERVER['REQUEST_URI'])) {
         $aux = parse_url(str_replace('/index.php', '', $_SERVER['REQUEST_URI']));
         if (isset($aux['path'])) {
             $path = $aux['path'];
             if (substr($path, -1) != '/') {
                 $path .= '/';
             }
         }
     }
     /// borramos las cookies
     if (isset($_COOKIE['logkey'])) {
         setcookie('logkey', '', time() - FS_COOKIES_EXPIRE);
         setcookie('logkey', '', time() - FS_COOKIES_EXPIRE, $path);
         if ($path != '/') {
             setcookie('logkey', '', time() - FS_COOKIES_EXPIRE, '/');
         }
     }
     /// ¿Eliminamos la cookie del usuario?
     if ($rmuser and isset($_COOKIE['user'])) {
         setcookie('user', '', time() - FS_COOKIES_EXPIRE);
         setcookie('user', '', time() - FS_COOKIES_EXPIRE, $path);
     }
     /// guardamos el evento en el log
     $fslog = new fs_log();
     $fslog->tipo = 'login';
     $fslog->detalle = 'El usuario ha cerrado la sesión.';
     $fslog->ip = $_SERVER['REMOTE_ADDR'];
     if (isset($_COOKIE['user'])) {
         $fslog->usuario = $_COOKIE['user'];
     }
     $fslog->save();
 }
示例#7
0
 private function picar()
 {
     $publicar = FALSE;
     /**
      * Si la última noticia publicada tiene menos de una hora,
      * no hace falta comprobar si hay que publicar algo.
      */
     foreach ($this->noticia->all(0, 'publicada DESC') as $noti) {
         if (strtotime($noti->publicada) > time() - 3600) {
             $publicar = FALSE;
             break;
         } else {
             $publicar = TRUE;
         }
     }
     if ($publicar) {
         /// marcamos noticias como publicadas
         $this->log[] = 'Seleccionando noticias para portada...';
         $seleccionadas = FALSE;
         foreach ($this->noticia->all(0, 'popularidad DESC') as $noti) {
             if (is_null($noti->publicada) and $noti->popularidad() > 1) {
                 $noti->publicada = date('d-m-Y H:i:s');
                 $this->preview_noticia($noti);
                 if ($noti->save()) {
                     $seleccionadas = TRUE;
                     $this->log[] = 'Se ha publicado la noticia: <a href="' . $noti->edit_url() . '" target="_blank">' . $noti->titulo . '</a> <span class="badge">' . $noti->popularidad() . '</span>';
                 } else {
                     $this->log[] = 'Error al publicar la noticia: ' . $noti->titulo;
                 }
             } else {
                 $noti->save();
             }
         }
         if (!$seleccionadas) {
             $this->log[] = 'Ninguna noticia seleccionada.';
             $publicar = FALSE;
         }
     }
     if (!$publicar) {
         /// buscamos noticias en las fuentes
         $fuente0 = new inme_fuente();
         $fuentes = $fuente0->all('fcomprobada ASC');
         if ($fuentes) {
             /// no leeremos fuentes que ya hayamos leido hace menos de media hora
             if (strtotime($fuentes[0]->fcomprobada) < time() - 1800) {
                 $this->leer_fuente($fuentes[0]);
             } else {
                 /// si no hay fuentes que leer, hacemos otras cosas
                 $this->log[] = 'Procesamos noticias...';
                 /// escogemos un punto aleatorio en la lista de noticias
                 $total = min(array(500, $this->total_noticias()));
                 $offset = mt_rand(0, max(array(0, $total)));
                 foreach ($this->noticia->all($offset) as $noti) {
                     $popularidad = $noti->popularidad();
                     switch (mt_rand(0, 3)) {
                         case 0:
                             $noti->tweets = max(array($noti->tweets, $this->tweet_count($noti->url)));
                             break;
                         case 1:
                             $noti->likes = max(array($noti->likes, $this->facebook_count($noti->url)));
                             break;
                         case 2:
                             $noti->meneos = max(array($noti->meneos, $this->meneame_count($noti->url)));
                             break;
                         default:
                             $this->preview_noticia($noti);
                             break;
                     }
                     if ($noti->save()) {
                         if ($noti->popularidad() > $popularidad) {
                             $this->log[] = '<a href="' . $noti->edit_url() . '" target="_blank">' . $noti->titulo . '</a> <b>+' . abs($noti->popularidad() - $popularidad) . '</b> popularidad.';
                         } else {
                             if ($noti->popularidad() < $popularidad) {
                                 $this->log[] = '<a href="' . $noti->edit_url() . '" target="_blank">' . $noti->titulo . '</a> <mark>-' . abs($noti->popularidad() - $popularidad) . '</mark> popularidad.';
                             }
                         }
                     } else {
                         $this->log[] = 'Error al actualizada la popularidad de la noticia: ' . $noti->titulo;
                     }
                 }
             }
         } else {
             $this->new_error_msg('No hay ninguna fuente que picar. <a href="index.php?page=inme_fuentes">Añade alguna</a>.');
         }
     }
     /// guardamos el log
     foreach ($this->log as $l) {
         $fslog = new fs_log();
         $fslog->tipo = 'picar';
         $fslog->detalle = $l;
         $fslog->ip = $_SERVER['REMOTE_ADDR'];
         if ($this->user) {
             $fslog->usuario = $this->user->nick;
         }
         $fslog->save();
     }
 }
示例#8
0
        $fs_default_items->set_codserie($empresa->codserie);
        /*
         * Ahora ejecutamos el cron de cada plugin que tenga cron y esté activado
         */
        foreach ($GLOBALS['plugins'] as $plugin) {
            if (file_exists('plugins/' . $plugin . '/cron.php')) {
                echo "\n***********************\nEjecutamos el cron.php del plugin " . $plugin . "\n";
                include 'plugins/' . $plugin . '/cron.php';
                echo "\n***********************";
            }
        }
        /// indicamos el fin en el log
        $fslog = new fs_log();
        $fslog->tipo = 'cron';
        $fslog->detalle = 'Terminada la ejecución del cron.';
        $fslog->save();
        /// Eliminamos la variable cron_lock puesto que ya hemos terminado
        $cron_vars['cron_lock'] = FALSE;
    }
    /// guardamos las variables
    $fsvar->array_save($cron_vars);
    foreach ($db->get_errors() as $err) {
        echo "\nERROR: " . $err . "\n";
    }
    $db->close();
} else {
    echo "¡Imposible conectar a la base de datos!\n";
    foreach ($db->get_errors() as $err) {
        echo $err . "\n";
    }
}