Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
Commit Sun May 19 12:27:45 2019
Browse files Browse the repository at this point in the history
  • Loading branch information
SupianIDz committed May 19, 2019
1 parent 054dd92 commit ed43a2b
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 27 deletions.
15 changes: 0 additions & 15 deletions app/Config/Logger.php

This file was deleted.

2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Expand Up @@ -18,5 +18,5 @@

class Kernel extends CLIKernel
{
// for now i have no idea for this section
// for now I don't have an idea for this section
}
2 changes: 1 addition & 1 deletion app/HTTP/Controller/Controller.php
Expand Up @@ -18,5 +18,5 @@

class Controller extends BaseController
{
//
// for now I don't have an idea for this section
}
2 changes: 1 addition & 1 deletion server.php
Expand Up @@ -16,7 +16,7 @@
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);

/**
/*
* This file allows us to emulate Apache's "mod_rewrite" functionality from the
* built-in PHP web server. This provides a convenient way to test a Octopy
* application without having installed a "real" web server software here.
Expand Down
31 changes: 28 additions & 3 deletions system/Exception/ExceptionHandler.php
Expand Up @@ -50,7 +50,7 @@ public function console(Throwable $exception)
$vars = $this->vars($exception);

$color = new Color;
dd($exception->getMessage());

$output = "\n";
$output .= $color->apply('b:red', ' ' . $vars['exception'] . ' ');
$output .= $color->apply('c:white', ' : ');
Expand All @@ -64,7 +64,32 @@ public function console(Throwable $exception)
$output .= "\n";

if (is_file($vars['file']) && is_readable($vars['file'])) {
$output .= $this->app['syntax']->highlight($vars['file'], $vars['line'], 3, 3);
$output .= $this->app['syntax']->highlight($vars['file'], $vars['line'], 2, 2);
$output .= "\n";
}

if (!empty($vars['trace'])) {
$output .= $color->apply('c:red', 'Stacktrace :');
$output .= "\n";

foreach ($vars['trace'] as $no => $trace) {
$no++;
$output .= $color->apply('c:lightgray', " $no. ");

if (isset($trace['file'])) {
$output .= $color->apply('c:green', $trace['file']);
$output .= $color->apply('c:lightgray', ' ');
$output .= $color->apply('c:lightgray', $trace['line']);
} elseif (isset($trace['class'])) {
$output .= $color->apply('c:green', $trace['class']);
$output .= $color->apply('c:lightgray', '::');
$output .= $color->apply('c:lightgray', $trace['function']);
$output .= $color->apply('c:lightgray', '(...)');
}

$output .= "\n";
}
} else {
$output .= "\n";
}

Expand Down Expand Up @@ -108,7 +133,7 @@ private function vars(Throwable $exception):array
'file' => $exception->getFile(),
'line' => $exception->getLine(),
'trace' => $exception->getTrace(),
'message' => $exception->getMessage(),
'message' => head(explode("\n", $exception->getMessage())),
'exception' => last(explode(BS, get_class($exception))),
];
}
Expand Down
14 changes: 11 additions & 3 deletions system/Provider/AutoloadServiceProvider.php
Expand Up @@ -14,6 +14,8 @@

namespace Octopy\Provider;

use Octopy\Encryption\Exception\DecryptException;

class AutoloadServiceProvider extends ServiceProvider
{
/**
Expand All @@ -29,9 +31,15 @@ public function register()
$autoload .= '46AE3E009A9883E4F2C38542E300A16D';

if (file_exists($autoload)) {
$this->app['autoload']->classmap(
$this->app['encrypter']->decrypt(file_get_contents($autoload))
);
try {
$this->app['autoload']->classmap(
$this->app['encrypter']->decrypt(file_get_contents($autoload))
);
} catch (DecryptException $exception) {
if (! $this->app->console()) {
throw new DecryptException('The MAC is invalid, please re-run autoload cache command.');
}
}
}

if ($composer = $this->app['config']['app.composer']) {
Expand Down
6 changes: 6 additions & 0 deletions system/Provider/EncryptionServiceProvider.php
Expand Up @@ -24,6 +24,12 @@ class EncryptionServiceProvider extends ServiceProvider
*/
public function register()
{
if (empty(env('APP_KEY'))) {
$this->app['config']->set('app', array_merge($this->app['config']['app'], [
'key' => 'base64:F8EDudSAuRK08KoAtb3otCzYQ9yzF+KlpaN12H/vQAw='
]));
}

$key = $this->key(
$config = $this->app['config']['app']
);
Expand Down
14 changes: 11 additions & 3 deletions system/Provider/RouteServiceProvider.php
Expand Up @@ -14,6 +14,8 @@

namespace Octopy\Provider;

use Octopy\Encryption\Exception\DecryptException;

class RouteServiceProvider extends ServiceProvider
{
/**
Expand All @@ -30,9 +32,15 @@ public function boot()
$cache .= '9C46408A3BC655C68505C57A11D6C4EE';

if (file_exists($cache)) {
$this->app['router']->load(
$this->app['encrypter']->decrypt(file_get_contents($cache))
);
try {
$this->app['router']->load(
$this->app['encrypter']->decrypt(file_get_contents($cache))
);
} catch (DecryptException $exception) {
if (! $this->app->console()) {
throw new DecryptException('The MAC is invalid, please re-run route cache command.');
}
}
} else {
if (method_exists($this, 'map')) {
$this->map();
Expand Down

0 comments on commit ed43a2b

Please sign in to comment.