Beispiel #1
0
 public function testCrypt()
 {
     $key = 'le password';
     $text = 'foo bar';
     $crypt = new Box_Crypt();
     $encoded = $crypt->encrypt($text, $key);
     $decoded = $crypt->decrypt($encoded, $key);
     $this->assertEquals($text, $decoded);
 }
Beispiel #2
0
    if ($log_to_db) {
        $activity_service = $di['mod_service']('activity');
        $writer2 = new Box_LogDb($activity_service);
        if ($di['auth']->isAdminLoggedIn()) {
            $admin = $di['loggedin_admin'];
            $log->setEventItem('admin_id', $admin->id);
        } elseif ($di['auth']->isClientLoggedIn()) {
            $client = $di['loggedin_client'];
            $log->setEventItem('client_id', $client->id);
        }
        $log->addWriter($writer2);
    }
    return $log;
};
$di['crypt'] = function () use($di) {
    $crypt = new Box_Crypt();
    $crypt->setDi($di);
    return $crypt;
};
$di['pdo'] = function () use($di) {
    $c = $di['config']['db'];
    $pdo = new PDO($c['type'] . ':host=' . $c['host'] . ';dbname=' . $c['name'], $c['user'], $c['password'], array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC));
    if (isset($c['debug']) && $c['debug']) {
        $pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('Box_DbLoggedPDOStatement'));
    }
    if ($c['type'] == 'mysql') {
        $pdo->exec('SET NAMES "utf8"');
        $pdo->exec('SET CHARACTER SET utf8');
        $pdo->exec('SET CHARACTER_SET_CONNECTION = utf8');
        $pdo->exec('SET CHARACTER_SET_DATABASE = utf8');
        $pdo->exec('SET character_set_results = utf8');