Ejemplo n.º 1
0
 /**
  * Constructor
  *
  * @param      $template   \SP\Template con instancia de plantilla
  * @param null $page       El nombre de página para la clase del body
  * @param bool $initialize Si es una inicialización completa
  */
 public function __construct(\SP\Template $template = null, $page = null, $initialize = true)
 {
     parent::__construct($template);
     if ($initialize) {
         $this->view->assign('startTime', microtime());
         $this->view->addTemplate('header');
         $this->view->addTemplate('body-start');
         $this->view->assign('sk', SessionUtil::getSessionKey(true));
         $this->view->assign('appInfo', Util::getAppInfo());
         $this->view->assign('appVersion', Util::getVersionString());
         $this->view->assign('isDemoMode', Util::demoIsEnabled());
         $this->view->assign('page', $page);
         $this->view->assign('loggedIn', \SP\Init::isLoggedIn());
         $this->view->assign('logoIcon', Init::$WEBURI . '/imgs/logo.png');
         $this->view->assign('logoNoText', Init::$WEBURI . '/imgs/logo.svg');
         $this->view->assign('logo', Init::$WEBURI . '/imgs/logo_full.svg');
         $this->view->assign('httpsEnabled', Util::httpsEnabled());
         // Cargar la clave pública en la sesión
         SessionUtil::loadPublicKey();
         $this->getResourcesLinks();
         $this->setResponseHeaders();
     }
 }
Ejemplo n.º 2
0
/**
 * sysPass
 *
 * @author    nuxsmin
 * @link      http://syspass.org
 * @copyright 2012-2015 Rubén Domínguez nuxsmin@syspass.org
 *
 * This file is part of sysPass.
 *
 * sysPass is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * sysPass is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with sysPass.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
define('APP_ROOT', '.');
require APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
if (!\SP\Init::checkPostLoginActions()) {
    $controller = new SP\Controller\MainC(null, 'main');
    $controller->getMain();
    $controller->view();
}
Ejemplo n.º 3
0
 /**
  * Fall back to traditional autoload for old PHP versions
  *
  * @param string $classname The name of the class to load
  */
 function __autoload($classname)
 {
     \SP\Init::loadClass($classname);
 }
Ejemplo n.º 4
0
 /**
  * Realizar la conexión con la BBDD.
  * Esta función utiliza PDO para conectar con la base de datos.
  *
  * @throws SPException
  * @return \PDO
  */
 public function getConnection()
 {
     if (!$this->_db) {
         $isInstalled = Config::getValue('installed');
         $dbhost = Config::getValue('dbhost');
         $dbuser = Config::getValue('dbuser');
         $dbpass = Config::getValue('dbpass');
         $dbname = Config::getValue('dbname');
         $dbport = Config::getValue('dbport', 3306);
         if (empty($dbhost) || empty($dbuser) || empty($dbpass) || empty($dbname)) {
             if ($isInstalled) {
                 Init::initError(_('No es posible conectar con la BD'), _('Compruebe los datos de conexión'));
             } else {
                 throw new SPException(SPException::SP_CRITICAL, _('No es posible conectar con la BD'), _('Compruebe los datos de conexión'));
             }
         }
         try {
             $dsn = 'mysql:host=' . $dbhost . ';port=' . $dbport . ';dbname=' . $dbname . ';charset=utf8';
             //                $this->db = new PDO($dsn, $dbuser, $dbpass, array(PDO::ATTR_PERSISTENT => true));
             $this->_db = new PDO($dsn, $dbuser, $dbpass);
         } catch (\Exception $e) {
             if ($isInstalled) {
                 if ($e->getCode() === 1049) {
                     Config::setValue('installed', '0');
                 }
                 Init::initError(_('No es posible conectar con la BD'), 'Error ' . $e->getCode() . ': ' . $e->getMessage());
             } else {
                 throw new SPException(SPException::SP_CRITICAL, $e->getMessage(), $e->getCode());
             }
         }
     }
     $this->_db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
     $this->_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     return $this->_db;
 }
Ejemplo n.º 5
0
 * This file is part of sysPass.
 *
 * sysPass is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * sysPass is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with sysPass.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
define('CONFIG_FILE', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php');
define('MODEL_PATH', __DIR__);
define('CONTROLLER_PATH', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'web');
define('VIEW_PATH', __DIR__ . DIRECTORY_SEPARATOR . 'themes');
define('EXTENSIONS_PATH', __DIR__ . DIRECTORY_SEPARATOR . 'ext');
define('LOCALES_PATH', __DIR__ . DIRECTORY_SEPARATOR . 'locales');
define('DEBUG', false);
require MODEL_PATH . DIRECTORY_SEPARATOR . 'Init.class.php';
// Empezar a calcular el tiempo y memoria utilizados
$memInit = memory_get_usage();
$timeStart = \SP\Init::microtime_float();
// Inicializar sysPass
\SP\Init::start();