Skip to content

Commit

Permalink
Cleaned up config files and stopped tracking them in version control
Browse files Browse the repository at this point in the history
  • Loading branch information
ekinhbayar authored and PeeHaa committed Oct 14, 2017
1 parent 5e1fad0 commit b752cd0
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/public/.htaccess
init.*.php
config.php
vendor
40 changes: 12 additions & 28 deletions init.example.php → config.sample.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Example file for settin up the environment specific configuration
* Example file for setting up the environment specific configuration
*
* Note: you probably don't want to use the configuration in your project
* directly, but instead you want to:
Expand All @@ -16,33 +16,11 @@
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 1.0.0
*/

namespace OpCacheGUI;

use OpCacheGUI\I18n\FileTranslator;
use OpCacheGUI\Network\Router;

/**
* Setup error reporting
*/
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('log_errors', 0);

/**
* Setup timezone
*/
ini_set('date.timezone', 'Europe/Amsterdam');

/**
* Setup the translator
*/
$translator = new FileTranslator(__DIR__ . '/texts', 'en');

/**
* Setup URI scheme (url rewrites [Router::URL_REWRITE] / query strings [Router::QUERY_STRING])
*/
$uriScheme = Router::URL_REWRITE;

/**
* Login credentials
*
Expand All @@ -60,10 +38,16 @@
*
* Multiple addresses or ranges can be defined
*/
$login = [
'username' => 'peehaa',
'password' => '$2y$14$kHoRlbxPF7Bf1903cDMTgeYBsFgF8aJA46LIH9Nsg4/ocDa9HTTbe',
'whitelist' => [
return [
'username' => 'peehaa',
'password' => '$2y$14$kHoRlbxPF7Bf1903cDMTgeYBsFgF8aJA46LIH9Nsg4/ocDa9HTTbe',
'whitelist' => [
'localhost',
],
'language' => 'en',
'timezone' => 'Europe/Amsterdam',
'error_reporting' => E_ALL,
'display_errors' => 'Off',
'log_errors' => 'On',
'uri_scheme' => Router::URL_REWRITE
];
52 changes: 42 additions & 10 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 1.0.0
*/
use OpCacheGUI\Format\Byte as ByteFormatter;
use OpCacheGUI\Storage\Session;
use OpCacheGUI\Auth\Ip;
use OpCacheGUI\Auth\User;
use OpCacheGUI\Security\Generator\Factory;
use OpCacheGUI\Security\CsrfToken;
use OpCacheGUI\Auth\User;
use OpCacheGUI\Storage\Session;
use OpCacheGUI\Network\Request;
use OpCacheGUI\Network\Router;
use OpCacheGUI\Network\RouteFactory;
use OpCacheGUI\Presentation\Url;
use OpCacheGUI\Presentation\Html;
use OpCacheGUI\Presentation\Json;
use OpCacheGUI\Network\Router;
use OpCacheGUI\Network\RouteFactory;
use OpCacheGUI\I18n\FileTranslator;
use OpCacheGUI\Format\Byte as ByteFormatter;

/**
* Bootstrap the library
Expand All @@ -30,7 +31,29 @@
/**
* Setup the environment
*/
require_once __DIR__ . '/init.deployment.php';
$configuration = require_once __DIR__ . '/config.php';

/**
* Setup error reporting
*/
error_reporting($configuration['error_reporting']);
ini_set('display_errors', $configuration['display_errors']);
ini_set('log_errors', $configuration['display_errors']);

/**
* Setup timezone
*/
ini_set('date.timezone', $configuration['timezone']);

/**
* Setup the translator
*/
$translator = new FileTranslator(__DIR__ . '/texts', $configuration['language']);

/**
* Setup URI scheme (url rewrites [Router::URL_REWRITE] / query strings [Router::QUERY_STRING])
*/
$uriScheme = $configuration['uri_scheme'];

/**
* Start the session
Expand Down Expand Up @@ -59,12 +82,12 @@
new \OpCacheGUI\Network\Ip\Range(),
new \OpCacheGUI\Network\Ip\Cidr(),
]);
$whitelist->buildWhitelist($login['whitelist']);
$whitelist->buildWhitelist($configuration['whitelist']);

/**
* Setup the authentication object
*/
$user = new User($sessionStorage, $login['username'], $login['password'], $whitelist);
$user = new User($sessionStorage, $configuration['username'], $configuration['password'], $whitelist);

/**
* Setup URL renderer
Expand Down Expand Up @@ -101,12 +124,21 @@
* Load the routes
*/
if (!extension_loaded('Zend OPcache') || opcache_get_status() === false) {
if (!in_array($router->getIdentifier(), ['error', 'mainjs', 'maincss', 'fontawesome-webfont_eot', 'fontawesome-webfont_woff', 'fontawesome-webfont_ttf', 'fontawesome-webfont_svg'], true)) {
if (!in_array($router->getIdentifier(), [
'error',
'mainjs',
'maincss',
'fontawesome-webfont_eot',
'fontawesome-webfont_woff',
'fontawesome-webfont_ttf',
'fontawesome-webfont_svg'
], true)
) {
header('Location: ' . $urlRenderer->get('error'));
exit;
}

$router->get('error', function() use ($htmlTemplate) {
$router->get('error', function () use ($htmlTemplate) {
return $htmlTemplate->render('error.phtml', [
'login' => true,
'title' => 'Error',
Expand Down
14 changes: 0 additions & 14 deletions init.deployment.php

This file was deleted.

0 comments on commit b752cd0

Please sign in to comment.