/*if (file_exists(__DIR__."/db.sqlite")) { copy(__DIR__."/db.sqlite", __DIR__."/backup/".date("Y-m-d_H-i-s-").substr(microtime(TRUE)-time(), 2, 4).".sqlite"); } $connection = new \Nette\Database\Connection('sqlite:' . __DIR__ . '/db.sqlite'); \Nette\Database\Helpers::loadFromFile($connection, __DIR__ . '/db.structure.sqlite.sql'); /************************************ MySQL *************************************/ $connection = new \Nette\Database\Connection('mysql:host=localhost;dbname=njlogparser', 'nette', 'nette'); \Nette\Database\Helpers::loadFromFile($connection, __DIR__ . '/db.structure.mysql.sql'); if (!defined('STDIN')) { echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head>' . '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Nette Jabber Log Parser</title></head><body><code><pre>'; } $parser = new Parser($connection); $parser->originalDataDir = __DIR__ . "/data"; //$parser->debug = TRUE; $factory = new \Nette\Http\RequestFactory(); $factory->setEncoding('UTF-8'); $req = $factory->createHttpRequest(); if (($date = $req->getQuery('date', NULL)) || ($date = isset($argv[1]) ? $argv[1] : NULL)) { $parser->parseDate($date, TRUE); } else { $parser->parse(10); } echo "\n\n"; $sec = $time = Debugger::timer(); $hours = (int) ($sec / 3600); $sec -= $hours * 3600; $mins = (int) ($sec / 60); $sec -= $mins * 60; $sec = (int) $sec; echo "Total Time: " . round($time * 1000, 2) . "ms " . str_pad($hours, 2, 0, STR_PAD_LEFT) . ":" . str_pad($mins, 2, 0, STR_PAD_LEFT) . ":" . str_pad($sec, 2, 0, STR_PAD_LEFT) . "." . round(($time - $sec) * 1000) . "\n"; echo "Memory: " . round(memory_get_usage() / 1024, 2) . "KB (Real Memory: " . round(memory_get_usage(TRUE) / 1024, 2) . "KB)\n";
'warning' => "warning", ), 'database' => array( 'driver' => "pdo_mysql", 'memory' => TRUE, ), ); $container->addService('cacheStorage', 'Nette\Caching\Storages\DevNullStorage'); $container->addService('templateCacheStorage', function(Nette\DI\Container $container) { return $container->cacheStorage; }); $container->addService('user', 'NellaTests\Mocks\User'); $container->addService('httpRequest', function() { $factory = new Nette\Http\RequestFactory; $factory->setEncoding('UTF-8'); return $factory->createHttpRequest(); }); $container->addService('httpResponse', 'Nette\Http\Response'); $container->addService('components', 'Nella\Application\UI\ComponentContainer'); $container->addService('macros', 'Nella\Latte\Macros'); $container->addService('model', function() { $context = new \Nella\Doctrine\Container; $context->addService('entityManager', \Doctrine\Tests\Mocks\EntityManagerMock::create( new \Doctrine\DBAL\Connection(array(), new \Doctrine\DBAL\Driver\PDOSqlite\Driver) )); return $context; }); $container->addService('latteEngine', 'Nella\Latte\Engine'); // Set DI Container Nette\Environment::setContext($container);