Exemplo n.º 1
0
 public function __construct()
 {
     $this->clients = new \SplObjectStorage();
     // Now connect to PS DB using Simplon on Composer
     $this->dbConn = new \Simplon\Mysql\Mysql('127.0.0.1', _DB_USER_, _DB_PASSWD_, _DB_NAME_);
     $log_file = 'wasabi.log';
     Analog::handler(\Analog\Handler\File::init($log_file));
 }
Exemplo n.º 2
0
 /**
  * Sets the Analog log handler.
  */
 public function handler($handler)
 {
     Analog::handler($handler);
 }
Exemplo n.º 3
0
<?php

require 'SplClassLoader.php';
$loader = new SplClassLoader('Analog', '../lib');
$loader->register();
use Analog\Analog;
$log = '';
Analog::handler(\Analog\Handler\Variable::init($log));
Analog::log('Test one');
Analog::log('Test two');
echo $log;
Exemplo n.º 4
0
} else {
    $log_dir = APP_DIR . '/logs/';
    if (defined('APP_LOGS')) {
        $log_dir = APP_LOGS;
    }
    if (!file_exists($log_dir)) {
        throw new \RuntimeException('Log directory (' . $log_dir . ') does not exists!');
    } else {
        if (!is_writeable($log_dir)) {
            throw new \RuntimeException('Log directory (' . $log_dir . ') is not writeable!');
        }
    }
    $log_file = $log_dir . 'viewer.log';
    $logger = \Analog\Handler\File::init($log_file);
}
Analog::handler(\Analog\Handler\LevelBuffer::init($logger, $log_lvl));
$conf = new Conf();
/** I18n stuff */
$lang = null;
$langs = array('en-US', 'fr-FR');
/** Try to detect user language */
if (function_exists('http_negotiate_language')) {
    $nego = http_negotiate_language($langs);
    switch (strtolower($nego)) {
        case 'en-us':
            $lang = 'en_US';
            break;
        case 'fr-fr':
            $lang = 'fr_FR.utf8';
            break;
    }
Exemplo n.º 5
0
    } else {
        if (!$installer || $installer && defined('GALETTE_LOGGER_CHECKED')) {
            //logs everything in galette log file
            if (!isset($logfile)) {
                //if no filename has been setetd (ie. from install), set default one
                $logfile = 'galette_run';
            }
            $log_path = GALETTE_LOGS_PATH . $logfile . '_' . $now->format('Y-m-d') . '.log';
            $galette_run_log = \Analog\Handler\File::init($log_path);
        } else {
            $galette_run_log = \Analog\Handler\Variable::init($galette_log_var);
        }
    }
    Core\Logs::cleanup();
}
Analog::handler(\Analog\Handler\Multi::init(array(Analog::URGENT => $galette_run_log, Analog::ALERT => $galette_run_log, Analog::CRITICAL => $galette_run_log, Analog::ERROR => $galette_run_log, Analog::WARNING => GALETTE_LOG_LVL >= Analog::WARNING ? $galette_run_log : $galette_null_log, Analog::NOTICE => GALETTE_LOG_LVL >= Analog::NOTICE ? $galette_run_log : $galette_null_log, Analog::INFO => GALETTE_LOG_LVL >= Analog::INFO ? $galette_run_log : $galette_null_log, Analog::DEBUG => GALETTE_LOG_LVL >= Analog::DEBUG ? $galette_debug_log : $galette_null_log)));
require_once GALETTE_ROOT . 'includes/functions.inc.php';
$session_name = null;
//since PREFIX_DB and NAME_DB are required to properly instanciate sessions,
// we have to check here if they're assigned
if ($installer || !defined('PREFIX_DB') || !defined('NAME_DB')) {
    $session_name = 'galette_install';
} else {
    $session_name = PREFIX_DB . '_' . NAME_DB;
}
$session =& $_SESSION['galette'][$session_name];
/**
 * Language instantiation
 */
if (isset($session['lang'])) {
    $i18n = unserialize($session['lang']);
Exemplo n.º 6
0
<?php

ini_set('date.timezone', 'America/Sao_Paulo');
require_once __DIR__ . '/../../vendor/autoload.php';
require_once __DIR__ . '/UserProvider.php';
$log_file = __DIR__ . '/../../tmp/logs.txt';
\Analog\Analog::handler(\Analog\Handler\File::init($log_file));
$connectionParams = array('driver' => 'pdo_mysql', 'host' => '127.0.0.1', 'dbname' => 'test', 'user' => 'root', 'password' => '', 'service' => true, 'charset' => 'UTF8', 'driverOptions' => array('charset' => 'UTF8'));
$connection = \Doctrine\DBAL\DriverManager::getConnection($connectionParams);
$storage = new \Paliari\Oauth2ServerFacade\Storage($connection, array('user_table' => 'usuarios'));
$oauth = new \Paliari\Oauth2ServerFacade\Oauth2Facade($storage);
$userProvider = new UserProvider($storage);
$oauth->setUserProvider($userProvider);
$oauth->setResourceHandler(function ($path, $user_id) use($storage) {
    if ('user/profile' == $path) {
        return $storage->getUser($user_id);
    }
    return compact('path', 'user_id');
});