From bf40cd862fbc35617dd70f234b4d76a88d166ee6 Mon Sep 17 00:00:00 2001 From: darock Date: Tue, 21 Jan 2020 19:03:11 +0200 Subject: [PATCH 01/10] YML required index added --- resources/lang/en/modules.php | 1 + resources/lang/ro/modules.php | 1 + .../views/admin/core/modules/partials/changelog.blade.php | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/resources/lang/en/modules.php b/resources/lang/en/modules.php index a8223a4..3bbf99c 100644 --- a/resources/lang/en/modules.php +++ b/resources/lang/en/modules.php @@ -16,4 +16,5 @@ 'added' => 'Added', 'changed' => 'Changed', 'removed' => 'Removed', + 'required' => 'Action required', ]; diff --git a/resources/lang/ro/modules.php b/resources/lang/ro/modules.php index 8b4a346..3943240 100644 --- a/resources/lang/ro/modules.php +++ b/resources/lang/ro/modules.php @@ -16,4 +16,5 @@ 'added' => 'Adaugari', 'changed' => 'Modificari', 'removed' => 'Stergeri', + 'required' => 'Necesita actiuni', ]; diff --git a/resources/views/admin/core/modules/partials/changelog.blade.php b/resources/views/admin/core/modules/partials/changelog.blade.php index ee70783..3ee99cc 100644 --- a/resources/views/admin/core/modules/partials/changelog.blade.php +++ b/resources/views/admin/core/modules/partials/changelog.blade.php @@ -34,6 +34,14 @@ 'data' => $info['removed'] ]) + + @include('admin.core.modules.partials.changelog-part', [ + 'title' => trans('modules.required'), + 'label' => 'info', + 'color' => 'orange', + 'data' => $info['required'] + ]) + From 085c9e3dd26a53679837e2ef8e082cef4532518a Mon Sep 17 00:00:00 2001 From: darock Date: Wed, 22 Jan 2020 19:00:32 +0200 Subject: [PATCH 02/10] Disable mod for catalog --- opencart-module/2.x/opencore.ocmod.zip | Bin 11351 -> 11464 bytes .../catalog/controller/startup/opencore.php | 8 +++ opencart-module/3.x/opencore.ocmod.zip | Bin 11279 -> 11357 bytes .../catalog/controller/startup/opencore.php | 8 +++ support/Opencart/OcCore.php | 53 +++--------------- support/Resources/opencore.ocmod.xml | 7 ++- 6 files changed, 27 insertions(+), 49 deletions(-) diff --git a/opencart-module/2.x/opencore.ocmod.zip b/opencart-module/2.x/opencore.ocmod.zip index f2463e86972120be67094bb007f479528d9106df..37ede5ee860435e9172733f1e767c8add496e574 100644 GIT binary patch delta 6303 zcmbVQ2UL?ww++38A|SojAS%5nU4%$L0qG!Bs`TE2aFLF{2O?lll-@)FQWX(Iklv&U zQlukD2^}8Ac*Xa>d;j&wTFji}>^5J;W^1QLlGzX&k1g5e)@)o)FTlLaVE$atM& zBM6!vci0?Pt{w_bq_U}ee#sH%dXbRLrFe0xtFj?m%VHk!T=oE!M`d+hLVWVJW#fUR z=F*>q*dT>-6#Cy|;k zQ@dJe8|ZoJxkUUm8oP@*uy>NAsVTd@9lO5R#-Ed}OR~1n5b_)pO0b9CW)=SHt}GiJ zuWp1;Gjk5E3%&+nu9|dZe#o}4;xOb^a$_w1t!rK`Z{&61K4LGgNzKf=(Gby1aI0EL zAnq^7CPqFTxa+5GIq3zXCSFr3mb|a|l;r#@eUZ5n>;{hal_&Q-5E7lS*+^M>#*YSA zM7ddj2;yq%f|jnm+U>jQO?T5&5^^ogXml;H zlt>~Ix#UXw0xofD`A%p!M_ndKZptm3#B|r7m&A6myJJ7!zTT&1?7s=hma@B{lDNC=5cCf^gFTYH4V~3tarNKKMS3qG$3#z(L zRnb&>*#AK@@3o6U&?kkwcc@wQBBWt8uNNr;Q#tS%cS?)(t=m%(6vu+Jy>f_SivD~B z?kkv013#RkUrz!qDj3OM>78Clys&_krY@o_TmM&f)0(i@`P_(P)8t~AkS6P7cLA6D zrPSKJNsZ4`ZQ9119K+KuNBf8F?JrvS35~qgZ4G!|{Ys(b<{|yLPW~F)WT)YlUXLrP zPs|RZ*%MZ+$49*P5wW5}lb2BR`1cCS=5-zI>=1tNjvho*QfwIBz|AfBnLArXvi9lK z{cu3_Lv;VJy_y5;$+GHWs@}t3p?q$B9d=aeu* zLk|kt*Dh1FGG$nMnegFF7p)JP5vLKgCcOyuk*s5IY=sJb?%oi^EqRa{8|>?p^>`|o zNt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Zb|!>{}Sz< z-#t%j=X07-T`rF@LIoA08D{)vGZ3Ego))*LoQZvv3i+Ih23d3s2*Ma*WWkKj?xNFL zcK#o2092#uZvfyw0*N~- diff --git a/opencart-module/2.x/upload/catalog/controller/startup/opencore.php b/opencart-module/2.x/upload/catalog/controller/startup/opencore.php index 6f82042..88d8600 100644 --- a/opencart-module/2.x/upload/catalog/controller/startup/opencore.php +++ b/opencart-module/2.x/upload/catalog/controller/startup/opencore.php @@ -27,6 +27,14 @@ class ControllerStartupOpencore extends Startup */ function before_controller($route, &$data, &$output = false) { + /** + * In case we want to disable OpenCore for catalog + * OPENCORE_DISABLED constant must be defined in config.php + */ + if(defined('OPENCORE_DISABLED')) { + return null; + } + /* if (self::$booted) { return false; } */ diff --git a/opencart-module/3.x/opencore.ocmod.zip b/opencart-module/3.x/opencore.ocmod.zip index fc0cf6897208e90d49986d486dbb88fce704d1b7..ed70fd3dc0c2d47a901b58259e868fee1058363e 100644 GIT binary patch delta 7103 zcma)AWmuG3*PbDTp`>Bx8jx;~5RjCR?v|DgX$C>0a|l5}T2hfNY3URJ3F#1|L6Gz# z&iEeu&h@@$=Es^f*Sha#?R)KK?TFU?s*R~EkBEd0xcrzuPRgM=t zuoyOSfQ&CcGbtO3TT-x_Hi3l{wml!y+M%5X&gASCsgk202$}+@)C7CC3mTNzV2U!8 zl+r5Nh8iUFZb;2?k05(bY-Z}h(qL`^T&4q=N_-Kvwy1IaaZsJcEXG%yrUPj7Er#!* zUTn1T-CgmVN!z?->ou64CfUT5=*-IRC)RSeRRy($cTK)R#R$o*LDMc4t2_cJn=+L} zvL^mC54I?vNJRslpw%31sS11KIIXpiky=x^I)Oc=;~#g0gh=X!r8^R7$i`OoSZL%x zElt;k5_F5(u%Uu@AN)ZMZrIdqg>@9IRL>7rP1;vUmXOps8a9i3D|1D|&qxt^E0MSg zMs3E(4|m{BZ*Wb*qxW<{n3?bj}d{!V3?!Y&gU~l zIP$6lA&_YQ$L(fTf9jQnDjL@@!=vt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dM}&P4tUZpcF;;%RQit6^h153Or?@ zJ00*W^~&j+4oc|{Z5LLe(oy=?!2e>#G~mLlD8%1(RKuWXd4Hx}*ip8AVFy~kWz1hA zU$TSb(mA~kT<0LWbiMshJUG8jP>QM%|Hgz~V#b^@=`JzrK3*_Uiemp8ll2m_=aeY` zqa-{$pBqY1ygxZ-ZC@}46pe%mFk>eLB&euG{w!X`FvZNXTb=j_Gy6 zk%*HF&F~-4=_QB*7;_RyznIlcKTAgGQ|F80Kj(3}S6uR)@X~rXff7zSX?ljE^Yx(A zw)bLv|Hh%d#L)qKxoClFT=>$T94}ZXMKS-4b-5~sowBY=^VM8%P>SOHY0&>{*ihB| utfuyya#&BhH+*1(37_YU_{HvI`28|hO$ih0G#Es8`Wr+50y)v09sL*lhuYu( diff --git a/opencart-module/3.x/upload/catalog/controller/startup/opencore.php b/opencart-module/3.x/upload/catalog/controller/startup/opencore.php index 6f82042..88d8600 100644 --- a/opencart-module/3.x/upload/catalog/controller/startup/opencore.php +++ b/opencart-module/3.x/upload/catalog/controller/startup/opencore.php @@ -27,6 +27,14 @@ class ControllerStartupOpencore extends Startup */ function before_controller($route, &$data, &$output = false) { + /** + * In case we want to disable OpenCore for catalog + * OPENCORE_DISABLED constant must be defined in config.php + */ + if(defined('OPENCORE_DISABLED')) { + return null; + } + /* if (self::$booted) { return false; } */ diff --git a/support/Opencart/OcCore.php b/support/Opencart/OcCore.php index 8e68c55..16d6ac5 100644 --- a/support/Opencart/OcCore.php +++ b/support/Opencart/OcCore.php @@ -11,29 +11,12 @@ trait OcCore { - /*public $registry; - - public function setInstance($registry) - { - $this->registry = $registry; - return $this->registry; - } - - public function __get($key) - { - return $this->registry->get($key); - } - - public static function getInstance() + public function removeIndexAndRouteParam($url) { - if ($this->registry === NULL) { - throw new Exception('Oc Registry Instance Could not be loaded'); + if (defined('OPENCORE_DISABLED')) { + return $url; } - return $this->registry; - }*/ - public function removeIndexAndRouteParam($url) - { if (strstr($url, 'index.php?route=')) { $url = str_replace('index.php?route=common/home', '', $url); //replace home url for catalog $url = str_replace('&', '&', $url); @@ -53,6 +36,9 @@ public function routeCatalogSeoUrl() */ if (!$this->config->get('smp_is_install')) { + if (defined('OPENCORE_DISABLED')) { + return true; + } /** * check if not found, maybe the page exists in Laravel system */ @@ -66,7 +52,7 @@ public function routeCatalogSeoUrl() public function isRouted($route) { - return !empty($this->request->has_route[$route]); + return !defined('OPENCORE_DISABLED') && !empty($this->request->has_route[$route]); } public function getTokenStr() @@ -111,29 +97,4 @@ public function removePermissions($path, $permissions = ['access', 'modify']) $this->model_user_user_group->removePermission($this->user->getGroupId(), $permission, $path); } } - - function getWorkingFolder() - { - return !defined('HTTPS_CATALOG') ? 'catalog' : 'admin'; - } - - function getCurrentLanguage($load_fallback) - { - if ($this->getWorkingFolder() == 'admin') { - $lang = $this->config->get('config_admin_language'); - } else { - $lang = isset($this->session->data['language']) ? basename($this->session->data['language']) : $this->config->get('config_language'); - } - - return $load_fallback ? 'en-gb' : ($lang ?: $this->getCurrentLanguage(true)); - } - - public function getOcControllers($controllers = [], $args = []) - { - foreach ($controllers as $key => $controller) { - $this->setData($key, $this->getOcController($controller, $args)); - } - - return $this; - } } diff --git a/support/Resources/opencore.ocmod.xml b/support/Resources/opencore.ocmod.xml index 2d162fd..5dd3225 100644 --- a/support/Resources/opencore.ocmod.xml +++ b/support/Resources/opencore.ocmod.xml @@ -11,7 +11,8 @@ @@ -103,7 +104,7 @@ use OpenCore\Support\OpenCart\OcCore; @@ -118,7 +119,7 @@ use OpenCore\Support\OpenCart\OcCore; - + From 41c668eff9074f9b84ee6f97f2cff288061f3c3f Mon Sep 17 00:00:00 2001 From: darock Date: Wed, 22 Jan 2020 19:01:02 +0200 Subject: [PATCH 03/10] Module management cache bug fix --- app/Http/Controllers/Admin/Core/ModulesController.php | 11 +++++++++++ modules/Example/module.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Admin/Core/ModulesController.php b/app/Http/Controllers/Admin/Core/ModulesController.php index a61957f..6a9d285 100644 --- a/app/Http/Controllers/Admin/Core/ModulesController.php +++ b/app/Http/Controllers/Admin/Core/ModulesController.php @@ -1,4 +1,11 @@ removePermission($userGroupId, 'access', $path); $model_user_user_group->removePermission($userGroupId, 'modify', $path); + Artisan::call('cache:clear'); + return redirect()->route('admin::core.modules.show', [$module->getLowerName()]) ->with('success', trans('modules.disabled')); } @@ -106,6 +115,8 @@ public function enable(Module $module) $model_user_user_group->addPermission($userGroupId, 'access', $path); $model_user_user_group->addPermission($userGroupId, 'modify', $path); + Artisan::call('cache:clear'); + return redirect()->route('admin::core.modules.show', [$module->getLowerName()])->with( 'success', trans('modules.enabled') diff --git a/modules/Example/module.json b/modules/Example/module.json index 7d49a5c..c847174 100644 --- a/modules/Example/module.json +++ b/modules/Example/module.json @@ -4,7 +4,7 @@ "description": "Example module", "keywords": [], "version": "1.0.0", - "active": 1, + "active": 0, "order": 1000, "links": { "example::admin.index": "Example Form" From 6d9c299a1909764217a7b4f9250d5a9813addda9 Mon Sep 17 00:00:00 2001 From: darock Date: Wed, 22 Jan 2020 19:01:48 +0200 Subject: [PATCH 04/10] OpenCart Debug mode added --- Framework.php | 52 ++++++++++++++++++++++------ app/Exceptions/Handler.php | 44 +++++++++++++++++++++++ app/Providers/AppServiceProvider.php | 29 ++++++++++++---- composer.json | 8 +++-- config/opencore.php | 16 ++++++++- support/OcLoader.php | 44 +++++++++++++++++++++++ support/Opencart/Startup.php | 35 +++++++++++++------ 7 files changed, 197 insertions(+), 31 deletions(-) create mode 100644 support/OcLoader.php diff --git a/Framework.php b/Framework.php index 70cccb9..cfc48ca 100644 --- a/Framework.php +++ b/Framework.php @@ -9,6 +9,8 @@ namespace OpenCore; +use Exception; + define('LARAVEL_START', microtime(true)); /* @@ -31,17 +33,30 @@ class Framework private $response; private $request = null; private $kernel; - private $get_routes; private $registry; - private $route; - private $output; + public $route; + public $output; + public $routes_session; + + public const NOT_FOUND = 0; + public const FOUND = 1; public function __construct() { $this->app = require __DIR__ . '/bootstrap/app.php'; $this->kernel = $this->app->make(\Illuminate\Contracts\Http\Kernel::class); + + $this->app->singleton('OcLoader', function () { + $OcLoader = new \OpenCore\Support\OcLoader(); + /** + * set loaded true in order to know the request was done through OpenCart + */ + $OcLoader->set('loaded', true); + + return $OcLoader; + }); } /** @@ -61,6 +76,8 @@ public function initiate($registry, $route, &$output) $this->registry = $registry; $this->route = $route; $this->output = $output; + + $this->routes_session[] = $route; } /** @@ -70,7 +87,7 @@ public function getResponse() { $this->response->sendHeaders(); - $content = $this->response->getContent(); + $content = $this->response; $this->kernel->terminate($this->request, $this->response); @@ -128,18 +145,33 @@ public function checkRoute() /** * TODO: find a better way to check all available routes */ - if (!isset($this->get_routes)) { - $response = $this->kernel->handle($request = \Illuminate\Http\Request::capture()); + if (!$this->app->OcLoader->get('routes')) { + $request = \Illuminate\Http\Request::capture(); + + /** + * Force returning an empty response + */ + $this->app->OcLoader->flash('check-routes', true); + + $response = $this->kernel->handle($request); $this->kernel->terminate($request, $response); - $this->get_routes = $this->app->router->getRoutes(); - }; + $this->app->OcLoader->set('routes', $this->app->router->getRoutes()); + + } try { - return (bool) $this->get_routes->match($this->request)->uri(); + $routes = $this->app->OcLoader->get('routes'); + + if ((bool) $routes->match($this->request)->uri()) { + return self::FOUND; + } else { + return self::NOT_FOUND; + } + } catch (\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $e) { - return false; + return self::NOT_FOUND; } } diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 043cad6..3ca7e6a 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -4,6 +4,7 @@ use Exception; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; +use Illuminate\Support\Facades\Config; class Handler extends ExceptionHandler { @@ -46,6 +47,49 @@ public function report(Exception $exception) */ public function render($request, Exception $exception) { + if ($exception instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) { + /** + * Ignore 404 Error in case of route check + */ + + if (app('OcLoader')->get('check-routes')) { + /* disable debug bar */ + $debugBar = (Config::get('app.debug') && \App::environment('local')); + if ($debugBar) { + app('debugbar')->disable(); + } + /* return blank response */ + $response = response(''); + + /* re-enable debug but for next response */ + if ($debugBar) { + app('debugbar')->enable(); + } + return $response; + } + } + + if (app('OcLoader')->get('loaded') && Config::get('app.debug') && Config::get('opencore.debug_opencart')) { + /** + * In case of an error throw by OpenCart we will clear the output and display just the error itself + * Also we will delete the last route_session from cache + */ + + $cache = \OpenCore\Framework::getInstance()->getRegistry('cache'); + + $appBaseName = basename(DIR_APPLICATION); + $allowed_routes = $cache->get('opencore_routes.' . $appBaseName); + + foreach(\OpenCore\Framework::getInstance()->routes_session as $route_session) { + if(isset($allowed_routes[$route_session])) { + unset($allowed_routes[$route_session]); + } + } + $cache->set('opencore_routes.' . $appBaseName, $allowed_routes, time() + 3600); + + ob_clean(); + } + return parent::render($request, $exception); } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 4b63967..ad7981b 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -18,17 +18,27 @@ class AppServiceProvider extends ServiceProvider */ public function register() { + /** + * Initiate loader in case the request is not done throught OpenCart + * and in order to avoid futher errors throwing + */ + if (!$this->app->bound('OcLoader')) { + $this->app->bind('OcLoader', function () { + return new \OpenCore\Support\OcLoader(); + }); + } + app('router')->bind('module', function ($module) { return app(RepositoryInterface::class)->find($module); }); - $this->app->bind('OcCore', function () { - return new OcCore(); - }); - - /* if ($this->app->environment() === 'local') { - $this->app->register('\Barryvdh\Debugbar\ServiceProvider'); - } */ + /** + * Loading Barryvdh Debug bar + * must be on local and APP_DEBUG = true + */ + if (\App::environment('local')) { + $this->app->register(\Barryvdh\Debugbar\ServiceProvider::class); + } } /** @@ -44,6 +54,7 @@ public function boot() if (class_exists('\OpenCore\Framework')) { $this->app->singleton('db.connector.mysql', '\OpenCore\Support\MySqlSharedConnector'); } + /** * Rewrite admin routes in order to contain the Token query param * corrects assets url @@ -57,6 +68,10 @@ public function boot() */ Schema::defaultStringLength(191); + $this->app->bind('OcCore', function () { + return new OcCore(); + }); + /** * set language based on OpenCart language session * if there is an instance of OpenCart ready diff --git a/composer.json b/composer.json index 582157c..9c1a47f 100644 --- a/composer.json +++ b/composer.json @@ -21,14 +21,15 @@ "laravelcollective/html": "~5.0" }, "require-dev": { + "arcanedev/log-viewer": "^4.7", + "barryvdh/laravel-debugbar": "^3.2", "beyondcode/laravel-dump-server": "^1.0", + "facade/ignition": "^1.0", "filp/whoops": "^2.0", "fzaninotto/faker": "^1.4", "mockery/mockery": "^1.0", "nunomaduro/collision": "^3.0", "phpunit/phpunit": "^7.5", - "facade/ignition": "^1.0", - "arcanedev/log-viewer": "^4.7", "studio/laravel-totem": "^5.3" }, "config": { @@ -45,7 +46,8 @@ "intervention/image", "rachidlaasri/laravel-installer", "arcanedev/log-viewer", - "studio/laravel-totem" + "studio/laravel-totem", + "barryvdh/laravel-debugbar" ] } }, diff --git a/config/opencore.php b/config/opencore.php index e705e62..3387747 100644 --- a/config/opencore.php +++ b/config/opencore.php @@ -1,6 +1,19 @@ env('OPENCORE_DEBUG_OPENCART', false), + /* |-------------------------------------------------------------------------- | These are the core modules that should NOT be disabled under any circumstance @@ -9,10 +22,11 @@ 'coreModules' => [ 'core' ], + /* |-------------------------------------------------------------------------- | Date format |-------------------------------------------------------------------------- */ - 'dateformat' => 'd.m.Y H:i:s', + 'dateformat' => env('OPENCORE_DATEFORMAT', 'd.m.Y H:i:s'), ]; diff --git a/support/OcLoader.php b/support/OcLoader.php new file mode 100644 index 0000000..fe9ff86 --- /dev/null +++ b/support/OcLoader.php @@ -0,0 +1,44 @@ +flash[$name] = true; + + $this->set($name, $val); + } + + function set($name, $val = true) + { + $this->unsetFlash($name); + + $this->loaded[$name] = $val; + } + + function get($name) + { + $this->unsetFlash($name); + + return $this->loaded[$name] ?? null; + } + + private function unsetFlash($name) + { + if (isset($this->flash[$name])) { + unset($this->flash[$name]); + } + } +} diff --git a/support/Opencart/Startup.php b/support/Opencart/Startup.php index 8b37436..35e732c 100644 --- a/support/Opencart/Startup.php +++ b/support/Opencart/Startup.php @@ -17,7 +17,6 @@ define('OPENCORE_VERSION', '1.2.1'); } -require_once __DIR__ . '/../../vendor/autoload.php'; require_once __DIR__ . '/../../Framework.php'; use Opencore\Framework; @@ -28,7 +27,7 @@ class Startup extends \Controller private $route; private $data; - private $routes_cache_time = 3600; //1 hour expiration time + public $routes_cache_time = 3600; //1 hour expiration time private $default_allowed_routes = [ 'admin/core/home', @@ -70,7 +69,15 @@ public function executeIfRouteExists($route, &$data, &$output = false) $this->route = rawurldecode($this->route); if ($this->checkOpenCoreRoute()) { - $response = $this->response(); + $response = $this->response()->getContent(); + + /** + * set content type of the response received + */ + $contentType = $this->response()->headers->all('content-type'); + if (!empty($contentType[0])) { + $this->response->addHeader('Content-Type: ' . $contentType[0]); + } if ($output === false) { /** @@ -117,8 +124,9 @@ public function checkOpenCoreRoute() $allowed_routes = $cache->get('opencore_routes.' . $appBaseName); //separate for admin & catalog to avoid large cache files } + $force = false; if (in_array($this->route, $this->default_allowed_routes)) { - $allowed_routes[$this->route] = true; + $force = true; } if (isset($allowed_routes[$this->route]) && $allowed_routes[$this->route] == false) { @@ -126,23 +134,30 @@ public function checkOpenCoreRoute() } else { Framework::getInstance()->initiate(self::$_registry, $this->route, $output); - if (!empty($allowed_routes[$this->route])) { + if (!empty($allowed_routes[$this->route]) || $force) { Framework::getInstance()->initiateRouteRequest(); - } elseif (Framework::getInstance()->checkRoute()) { - $allowed_routes[$this->route] = true; } else { - $allowed_routes[$this->route] = false; + $checkRoute = Framework::getInstance()->checkRoute(); + + switch ($checkRoute) { + case Framework::FOUND: + $allowed_routes[$this->route] = true; + break; + case Framework::NOT_FOUND: + $allowed_routes[$this->route] = false; + break; + } } } /** * Cache OpenCore allowed routes for faster rendering */ - if ($this->routes_cache_time) { + if ($this->routes_cache_time && !$force) { $cache->set('opencore_routes.' . $appBaseName, $allowed_routes, time() + $this->routes_cache_time); } - if ($allowed_routes[$this->route]) { + if (!empty($allowed_routes[$this->route]) || $force) { return Framework::getInstance()->handle(); } From c93c67b7311284cbc703c51a79c82fab709a3a2d Mon Sep 17 00:00:00 2001 From: darock Date: Thu, 23 Jan 2020 14:19:09 +0200 Subject: [PATCH 05/10] New entities added --- support/Entities/Cart.php | 21 +++++++++++++++++++++ support/Entities/Language.php | 13 +++++++++++++ support/Entities/Order.php | 10 ++++++++++ support/Entities/Product.php | 21 +++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 support/Entities/Cart.php create mode 100644 support/Entities/Language.php create mode 100644 support/Entities/Product.php diff --git a/support/Entities/Cart.php b/support/Entities/Cart.php new file mode 100644 index 0000000..1419052 --- /dev/null +++ b/support/Entities/Cart.php @@ -0,0 +1,21 @@ +firstname} {$this->lastname}")); + } } diff --git a/support/Entities/Product.php b/support/Entities/Product.php new file mode 100644 index 0000000..35c96f6 --- /dev/null +++ b/support/Entities/Product.php @@ -0,0 +1,21 @@ + Date: Thu, 23 Jan 2020 14:19:34 +0200 Subject: [PATCH 06/10] SettingRepository update --- support/Repositories/SettingRepository.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/support/Repositories/SettingRepository.php b/support/Repositories/SettingRepository.php index e6a142c..d23cdb0 100644 --- a/support/Repositories/SettingRepository.php +++ b/support/Repositories/SettingRepository.php @@ -6,10 +6,21 @@ class SettingRepository { + private $settings; + + public function __construct() + { + $settings = Setting::select(['key', 'value', 'serialized'])->get(); + foreach ($settings as $setting) { + if ($setting->serialized) { + $this->settings[$setting->key] = json_decode($setting->value); + } else { + $this->settings[$setting->key] = $setting->value; + } + } + } public function get($key) { - $setting = Setting::select(['value', 'serialized'])->where('key', $key)->first(); - - return $setting->serialized ? json_decode($setting->value) : $setting->value; + return $this->settings[$key] ?? null; } } From c4e4ddc09b67cdb69b05c8117ff1be46005ef657 Mon Sep 17 00:00:00 2001 From: DaRock Date: Thu, 23 Jan 2020 20:31:09 +0200 Subject: [PATCH 07/10] opencore:register-routes - artisan command added --- .../Commands/RegisterRoutesCommand.php | 113 ++++++++++++++++++ app/Console/Kernel.php | 3 +- ...20_01_23_190536_create_opencore_routes.php | 37 ++++++ support/Entities/OpencoreRoute.php | 22 ++++ 4 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 app/Console/Commands/RegisterRoutesCommand.php create mode 100644 database/migrations/2020_01_23_190536_create_opencore_routes.php create mode 100644 support/Entities/OpencoreRoute.php diff --git a/app/Console/Commands/RegisterRoutesCommand.php b/app/Console/Commands/RegisterRoutesCommand.php new file mode 100644 index 0000000..44c2c74 --- /dev/null +++ b/app/Console/Commands/RegisterRoutesCommand.php @@ -0,0 +1,113 @@ +router = $router; + } + + /** + * Execute the console command. + * + * @return void + */ + public function handle() + { + if (empty($this->router->getRoutes())) { + $this->deleteAllRoutes(); + + return $this->error("Your application doesn't have any routes."); + } + + $this->registerRoutes(); + + return $this->info("Your route have been registered."); + } + + /** + * Register all routes into database + * + * @return void + */ + protected function registerRoutes() + { + $registeredRoutes = OpencoreRoute::get()->pluck('id', 'unique_key')->toArray(); + + $keep = []; + $routes = $this->router->getRoutes(); + foreach ($routes as $route) { + foreach ($route->methods() as $method) { + if (!in_array($method, $this->ignore_methods)) { + $data = [ + 'method' => $method, + 'uri' => $route->uri(), + 'name' => $route->getName() + ]; + + $key = implode('', $data); + + $id = $registeredRoutes[$key] ?? null; + if (is_null($id)) { + $id = OpencoreRoute::insertGetId($data); + } + $keep[] = $id; + } + } + } + + OpencoreRoute::whereNotIn('id', $keep)->delete(); + } + + /** + * Delete all routes from database + * + * @return void + */ + protected function deleteAllRoutes() + { + OpencoreRoute::truncate(); + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index a8c5158..509eb8a 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -4,6 +4,7 @@ use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; +use App\Console\Commands\RegisterRoutesCommand; class Kernel extends ConsoleKernel { @@ -13,7 +14,7 @@ class Kernel extends ConsoleKernel * @var array */ protected $commands = [ - // + RegisterRoutesCommand::class ]; /** diff --git a/database/migrations/2020_01_23_190536_create_opencore_routes.php b/database/migrations/2020_01_23_190536_create_opencore_routes.php new file mode 100644 index 0000000..85ca24a --- /dev/null +++ b/database/migrations/2020_01_23_190536_create_opencore_routes.php @@ -0,0 +1,37 @@ +bigIncrements('id'); + $table->string('method', 10); + $table->string('uri', 191); + $table->string('name', 100)->nullable(); + $table->tinyInteger('status')->default(1); + $table->timestamps(); + + $table->unique(['method', 'uri', 'name'], 'method_uri_name'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('opencore_routes'); + } +} diff --git a/support/Entities/OpencoreRoute.php b/support/Entities/OpencoreRoute.php new file mode 100644 index 0000000..6da4d94 --- /dev/null +++ b/support/Entities/OpencoreRoute.php @@ -0,0 +1,22 @@ +method . $this->uri . $this->name; + } +} From de35fda90d2ccc1f31d2c75b635f0f778e4d061b Mon Sep 17 00:00:00 2001 From: DaRock Date: Fri, 24 Jan 2020 12:36:29 +0200 Subject: [PATCH 08/10] Routes management section added --- README.md | 1 + .../Commands/RegisterRoutesCommand.php | 6 ++ .../Admin/Core/ModulesController.php | 4 +- .../{ => System}/ClearCacheController.php | 7 +- .../Core/System/RegisterRoutesController.php | 54 +++++++++++++ .../{ => System}/RequirementsController.php | 4 +- config/opencore.php | 11 +++ resources/lang/en/general.php | 10 ++- resources/lang/en/modules.php | 4 - resources/lang/en/system.php | 18 +++++ resources/lang/ro/general.php | 10 ++- resources/lang/ro/modules.php | 4 - resources/lang/ro/system.php | 18 +++++ .../views/admin/core/modules/index.blade.php | 2 +- .../views/admin/core/modules/show.blade.php | 4 +- .../core/{ => system}/requirements.blade.php | 0 .../views/admin/core/system/routes.blade.php | 76 +++++++++++++++++++ resources/views/admin/layouts/app.blade.php | 19 +++-- routes/admin.php | 13 +++- support/Opencart/Startup.php | 8 +- 20 files changed, 235 insertions(+), 38 deletions(-) rename app/Http/Controllers/Admin/Core/{ => System}/ClearCacheController.php (71%) create mode 100644 app/Http/Controllers/Admin/Core/System/RegisterRoutesController.php rename app/Http/Controllers/Admin/Core/{ => System}/RequirementsController.php (88%) create mode 100644 resources/lang/en/system.php create mode 100644 resources/lang/ro/system.php rename resources/views/admin/core/{ => system}/requirements.blade.php (100%) create mode 100644 resources/views/admin/core/system/routes.blade.php diff --git a/README.md b/README.md index 6e9142d..8386269 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ MIT license. Please see the [license file](LICENSE) for more information. ## TODO +* force paginator->appends to automatically add token/user_token param for admin requests only * when enabling a module the permission must be added automatically for the user who made the action * Example & Developer modules should be disabled by default * display jobs & failed_jobs lists in developer module diff --git a/app/Console/Commands/RegisterRoutesCommand.php b/app/Console/Commands/RegisterRoutesCommand.php index 44c2c74..81ecb91 100644 --- a/app/Console/Commands/RegisterRoutesCommand.php +++ b/app/Console/Commands/RegisterRoutesCommand.php @@ -1,4 +1,10 @@ route('admin::core.modules.show', [$module->getLowerName()]) - ->with('success', trans('modules.disabled')); + ->with('success', trans('general.status.disabled')); } /** @@ -119,7 +119,7 @@ public function enable(Module $module) return redirect()->route('admin::core.modules.show', [$module->getLowerName()])->with( 'success', - trans('modules.enabled') + trans('general.status.enabled') ); } diff --git a/app/Http/Controllers/Admin/Core/ClearCacheController.php b/app/Http/Controllers/Admin/Core/System/ClearCacheController.php similarity index 71% rename from app/Http/Controllers/Admin/Core/ClearCacheController.php rename to app/Http/Controllers/Admin/Core/System/ClearCacheController.php index 1e7fd26..440f62e 100644 --- a/app/Http/Controllers/Admin/Core/ClearCacheController.php +++ b/app/Http/Controllers/Admin/Core/System/ClearCacheController.php @@ -7,7 +7,7 @@ * */ -namespace App\Http\Controllers\Admin\Core; +namespace App\Http\Controllers\Admin\Core\System; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Artisan; @@ -21,8 +21,7 @@ function index() Artisan::call('config:clear'); Artisan::call('view:clear'); - return redirect() - ->route('admin::core.home') - ->with('success', trans('general.cache.cleared')); + return redirect(url()->previous()) + ->with('success', trans('system.cache.cleared')); } } diff --git a/app/Http/Controllers/Admin/Core/System/RegisterRoutesController.php b/app/Http/Controllers/Admin/Core/System/RegisterRoutesController.php new file mode 100644 index 0000000..afba8cc --- /dev/null +++ b/app/Http/Controllers/Admin/Core/System/RegisterRoutesController.php @@ -0,0 +1,54 @@ +orderBy('method') + ->paginate(config('opencore.paginate.admin')) + ->appends(request()->except('route')); + + return view('admin.core.system.routes', compact('routes')); + } + + function enable(int $id) + { + $route = OpencoreRoute::findOrFail($id); + $route->status = 1; + $route->save(); + + return redirect(url()->previous()) + ->with('success', trans('system.routes.enabled')); + } + + function disable(int $id) + { + $route = OpencoreRoute::findOrFail($id); + $route->status = 0; + $route->save(); + + return redirect(url()->previous()) + ->with('success', trans('system.routes.disabled')); + } + + function register() + { + Artisan::call('opencore:register-routes'); + + return redirect(url()->previous()) + ->with('success', trans('system.routes.registered')); + } +} diff --git a/app/Http/Controllers/Admin/Core/RequirementsController.php b/app/Http/Controllers/Admin/Core/System/RequirementsController.php similarity index 88% rename from app/Http/Controllers/Admin/Core/RequirementsController.php rename to app/Http/Controllers/Admin/Core/System/RequirementsController.php index b822cc0..9fae5c7 100644 --- a/app/Http/Controllers/Admin/Core/RequirementsController.php +++ b/app/Http/Controllers/Admin/Core/System/RequirementsController.php @@ -7,7 +7,7 @@ * */ -namespace App\Http\Controllers\Admin\Core; +namespace App\Http\Controllers\Admin\Core\System; use App\Http\Controllers\Controller; use RachidLaasri\LaravelInstaller\Helpers\RequirementsChecker; @@ -54,6 +54,6 @@ public function index() $cronpath = realpath(basename(__DIR__ . '/../')) . '/core/artisan'; - return view('admin.core.requirements', compact('requirements', 'phpSupportInfo', 'permissions', 'cronpath')); + return view('admin.core.system.requirements', compact('requirements', 'phpSupportInfo', 'permissions', 'cronpath')); } } diff --git a/config/opencore.php b/config/opencore.php index 3387747..1660dd4 100644 --- a/config/opencore.php +++ b/config/opencore.php @@ -29,4 +29,15 @@ |-------------------------------------------------------------------------- */ 'dateformat' => env('OPENCORE_DATEFORMAT', 'd.m.Y H:i:s'), + + /* + |-------------------------------------------------------------------------- + | Pagination + |-------------------------------------------------------------------------- + */ + + 'paginate' => [ + 'admin' => 25, + 'catalog' => 20 + ] ]; diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index 1626573..5162d92 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -3,10 +3,11 @@ return [ 'menu' => [ 'toggle' => 'Menu', - 'requirements' => 'System Requirements', 'modules' => 'Modules', 'modules_management' => 'Modules Management', 'system' => 'System', + 'routes' => 'Routes', + 'requirements' => 'System Requirements', 'clear_cache' => 'Clear Cache', ], 'home' => [ @@ -16,8 +17,11 @@ 'cron' => [ 'info' => 'Don\'t forget to add the folowing cronjob on your hosting control panel (cPanel)' ], - 'cache' => [ - 'cleared' => 'Cache cleared!' + 'status' => [ + 'enable' => 'Enable', + 'disable' => 'Disable', + 'enabled' => 'Enabled', + 'disabled' => 'Disabled', ], 'powered_by' => 'Powered by', 'error_title' => 'Whoops! Something went wrong!', diff --git a/resources/lang/en/modules.php b/resources/lang/en/modules.php index 3bbf99c..9aa0de8 100644 --- a/resources/lang/en/modules.php +++ b/resources/lang/en/modules.php @@ -5,11 +5,7 @@ 'details' => 'Module Details', 'name' => 'Name', 'version' => 'Version', - 'enabled' => 'Enabled', - 'disabled' => 'Disabled', 'disabled_error' => 'Module cannot be disabled', - 'enable' => 'Enable', - 'disable' => 'Disable', 'publish_assets' => 'Publish Assets', 'update' => 'Update', 'changelog' => 'Changelog', diff --git a/resources/lang/en/system.php b/resources/lang/en/system.php new file mode 100644 index 0000000..b3ac125 --- /dev/null +++ b/resources/lang/en/system.php @@ -0,0 +1,18 @@ + [ + 'title' => 'Routes List', + 'method' => 'Method', + 'uri' => 'Uri', + 'name' => 'Name', + 'action' => 'Action', + 'enabled' => 'Route has been enabled', + 'disabled' => 'Route has been disabled', + 'register' => 'Register Routes', + 'registered' => 'The routes have been registered!' + ], + 'cache' => [ + 'cleared' => 'Cache cleared!' + ], +]; diff --git a/resources/lang/ro/general.php b/resources/lang/ro/general.php index 0e64f24..dedb8a9 100644 --- a/resources/lang/ro/general.php +++ b/resources/lang/ro/general.php @@ -3,10 +3,11 @@ return [ 'menu' => [ 'toggle' => 'Meniu', - 'requirements' => 'Cerinte sistem', 'modules' => 'Module', 'modules_management' => 'Management Module', 'system' => 'Sistem', + 'routes' => 'Rute', + 'requirements' => 'Cerinte sistem', 'clear_cache' => 'Sterge Cache', ], 'home' => [ @@ -16,8 +17,11 @@ 'cron' => [ 'info' => 'Nu uitati sa adaugati urmatoarea comanda pentru cronjob in panoul de control al serverului de hosting (cPanel)' ], - 'cache' => [ - 'cleared' => 'Cache-ul a fost sters!' + 'status' => [ + 'enable' => 'Activeaza', + 'disable' => 'Dezactiveaza', + 'enabled' => 'Activat', + 'disabled' => 'Dezactivat', ], 'powered_by' => 'Powered by', 'error_title' => 'Opa! Am intampinat probleme!', diff --git a/resources/lang/ro/modules.php b/resources/lang/ro/modules.php index 3943240..1084dbf 100644 --- a/resources/lang/ro/modules.php +++ b/resources/lang/ro/modules.php @@ -5,11 +5,7 @@ 'details' => 'Detalii Modul', 'name' => 'Denumire', 'version' => 'Versiune', - 'enabled' => 'Activat', - 'disabled' => 'Dezactivat', 'disabled_error' => 'Modulul nu poate fi dezactivat', - 'enable' => 'Activati', - 'disable' => 'Dezactivati', 'publish_assets' => 'Publica Asset-uri', 'update' => 'Update', 'changelog' => 'Changelog', diff --git a/resources/lang/ro/system.php b/resources/lang/ro/system.php new file mode 100644 index 0000000..3a90493 --- /dev/null +++ b/resources/lang/ro/system.php @@ -0,0 +1,18 @@ + [ + 'title' => 'Lista Rute', + 'method' => 'Metoda', + 'uri' => 'Uri', + 'name' => 'Denumire', + 'action' => 'Actiune', + 'enabled' => 'Ruta a fost activata', + 'disabled' => 'Ruta a fost dezactivata', + 'register' => 'Inregistreaza Rute', + 'registered' => 'Rutele au fost inregistrate!' + ], + 'cache' => [ + 'cleared' => 'Cache-ul a fost sters!' + ] +]; diff --git a/resources/views/admin/core/modules/index.blade.php b/resources/views/admin/core/modules/index.blade.php index 33f462c..6842b35 100644 --- a/resources/views/admin/core/modules/index.blade.php +++ b/resources/views/admin/core/modules/index.blade.php @@ -46,7 +46,7 @@ - {{ $module->enabled() ? trans('modules.enabled') : trans('modules.disabled') }} + {{ $module->enabled() ? trans('general.status.enabled') : trans('general.status.disabled') }} diff --git a/resources/views/admin/core/modules/show.blade.php b/resources/views/admin/core/modules/show.blade.php index c89845e..f1b65c5 100644 --- a/resources/views/admin/core/modules/show.blade.php +++ b/resources/views/admin/core/modules/show.blade.php @@ -42,9 +42,9 @@ enabled() ? 'alert-danger' : 'alert-success' ?> {!! Form::open(['route' => ["admin::core.modules.$status", $module->getName()], 'method' => 'post']) !!} {!! Form::close() !!} diff --git a/resources/views/admin/core/requirements.blade.php b/resources/views/admin/core/system/requirements.blade.php similarity index 100% rename from resources/views/admin/core/requirements.blade.php rename to resources/views/admin/core/system/requirements.blade.php diff --git a/resources/views/admin/core/system/routes.blade.php b/resources/views/admin/core/system/routes.blade.php new file mode 100644 index 0000000..ba753c2 --- /dev/null +++ b/resources/views/admin/core/system/routes.blade.php @@ -0,0 +1,76 @@ +@extends('admin.layouts.app') + +@section('meta.title') + {{ trans('system.routes.title') }} +@endsection + +@section('container') +

{{ trans('system.routes.title') }}

+ +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{{ trans('system.routes.method') }}{{ trans('routes.uri') }}{{ trans('system.routes.name') }}{{ trans('system.routes.action') }}
{{ $route->method }}{{ $route->uri }}{{ $route->name ?? '-' }} + status ? 'disable' : 'enable'; ?> + status ? 'alert-danger' : 'alert-success' ?> + {!! Form::open(['route' => ["admin::core.system.routes.{$status}", $route->id], 'method' => 'post']) !!} + + {!! Form::close() !!} +
{{ trans('system.routes.method') }}{{ trans('system.routes.uri') }}{{ trans('system.routes.name') }}{{ trans('system.routes.action') }}
+ +
+ +
+ {{ $routes->links() }} +
+
+
+
+@stop + +@section('inline.scripts') + +@endsection diff --git a/resources/views/admin/layouts/app.blade.php b/resources/views/admin/layouts/app.blade.php index 9d48ef6..86aa6e5 100644 --- a/resources/views/admin/layouts/app.blade.php +++ b/resources/views/admin/layouts/app.blade.php @@ -27,11 +27,6 @@ @endsection diff --git a/support/Opencart/Startup.php b/support/Opencart/Startup.php index 9dd6597..a0bd402 100644 --- a/support/Opencart/Startup.php +++ b/support/Opencart/Startup.php @@ -33,7 +33,7 @@ class Startup extends \Controller 'admin/core/home', 'admin/core/modules', 'admin/core/system/routes', - 'admin/core/system/register-routes', + 'admin/core/system/routes/register', 'admin/core/system/requirements', 'admin/core/system/clear-cache', ]; @@ -70,7 +70,17 @@ public function executeIfRouteExists($route, &$data, &$output = false) } $this->route = rawurldecode($this->route); + /** + * if is an Admin request add path to route + */ + $appBaseName = basename(DIR_APPLICATION); + if (defined('HTTPS_CATALOG') && !strstr($this->route, $appBaseName . '/')) { + $this->route = $appBaseName . '/' . $this->route; + } + if ($this->checkOpenCoreRoute()) { + Framework::getInstance()->handle(self::$_registry, $this->route, $output); + $response = $this->response()->getContent(); /** @@ -86,6 +96,7 @@ public function executeIfRouteExists($route, &$data, &$output = false) * means is a controller request which means we need to use default setOutput() */ $this->response->setOutput($response); + return true; } else { /** @@ -93,6 +104,7 @@ public function executeIfRouteExists($route, &$data, &$output = false) * Check system/engine/loader.php */ $output = $response; + return false; } } @@ -106,61 +118,48 @@ public function executeIfRouteExists($route, &$data, &$output = false) public function checkOpenCoreRoute() { /** - * if is an Admin request add path to route + * Check default allowed routes */ - $appBaseName = basename(DIR_APPLICATION); - if (defined('HTTPS_CATALOG') && !strstr($this->route, $appBaseName . '/')) { - $this->route = $appBaseName . '/' . $this->route; + if (in_array($this->route, $this->default_allowed_routes)) { + return true; } - /* - TODO: We should add a dynamic ignore list here which should be configurable in admin/core/settings - */ /** * force admin route in case the request comes from admin side */ $allowed_routes = []; - if ($this->routes_cache_time) { - $cache = self::$_registry->get('cache'); - $allowed_routes = $cache->get('opencore_routes.' . $appBaseName); //separate for admin & catalog to avoid large cache files - } - - $force = false; - if (in_array($this->route, $this->default_allowed_routes)) { - $force = true; - } + if (!$allowed_routes = $this->cache->get('opencore_routes')) { + $query = $this->db->query("SELECT method, uri FROM `opencore_routes` WHERE `status` = '1' ORDER BY uri"); - if (isset($allowed_routes[$this->route]) && $allowed_routes[$this->route] == false) { - return false; - } else { - Framework::getInstance()->initiate(self::$_registry, $this->route, $output); + if (!$query->num_rows) + return false; - if (!empty($allowed_routes[$this->route]) || $force) { - Framework::getInstance()->initiateRouteRequest(); - } else { - $checkRoute = Framework::getInstance()->checkRoute(); - - switch ($checkRoute) { - case Framework::FOUND: - $allowed_routes[$this->route] = true; - break; - case Framework::NOT_FOUND: - $allowed_routes[$this->route] = false; - break; - } + foreach ($query->rows as $route) { + $allowed_routes[$route['method']][] = $route['uri']; } - } - /** - * Cache OpenCore allowed routes for faster rendering - */ - if ($this->routes_cache_time && !$force) { - $cache->set('opencore_routes.' . $appBaseName, $allowed_routes, time() + $this->routes_cache_time); + /** + * Cache OpenCore allowed routes for faster rendering + */ + $this->cache->set('opencore_routes', $allowed_routes, time() + $this->routes_cache_time); } - if (!empty($allowed_routes[$this->route]) || $force) { - return Framework::getInstance()->handle(); + $requestMethod = $_SERVER['REQUEST_METHOD']; + if (!empty($allowed_routes[$requestMethod])) { + foreach ($allowed_routes[$requestMethod] as $route) { + if (preg_match_all('/\{(.*?)\??\}/', $route, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { + foreach ($matches[0] as $match) { + $remainingUri = substr($this->route, $match[1], strlen($this->route)); + $getSamePartFromRoute = strtok($remainingUri, '/'); + $route = substr_replace($route, $getSamePartFromRoute, $match[1], strlen($match[0])); + } + } + + if ($route === $this->route) { + return true; + } + } } return false; @@ -199,14 +198,4 @@ public static function getRegistry($type = '') return $registry; } - - /** - * Retrieves OpenCart variables defined when the controller was loaded - * - * @return object - */ - public function getOcVars() - { - return $this->data; - } } From d18802d3b24940a2a1c3b1a95a585674b7e25f52 Mon Sep 17 00:00:00 2001 From: DaRock Date: Sun, 26 Jan 2020 15:21:20 +0200 Subject: [PATCH 10/10] Small optimizations & Readme update --- README.md | 15 +++++++++++++-- config/app.php | 4 ++-- support/Opencart/Startup.php | 20 +++++++------------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 8386269..ffe0588 100644 --- a/README.md +++ b/README.md @@ -50,8 +50,8 @@ check Laravel requirements because they may differ depending on the used version 4. `cd core/` 5. `composer update` 6. `php artisan key:generate` -7. `php artisan migrate:install` -8. `php artisan migrate` +7. `php artisan migrate` +8. `php artisan opencore:register-routes` 9. copy OpenCart extension files from core/opencart-module/(2.x|3.x)/upload to you OpenCart root folder 10. go to OpenCart admin panel / extensions / extensions / modules, find OpenCore module and install it 11. click on the OpenCore icon from admin / left column / section "System Requirements" and make sure there's nothing marked with red @@ -59,6 +59,16 @@ check Laravel requirements because they may differ depending on the used version Enjoy! +## Update + +1. `cd core/` +2. `git update` +3. `composer update` +4. `php artisan migrate` +5. `php artisan opencore:register-routes` +6. copy OpenCart extension files from core/opencart-module/(2.x|3.x)/upload to you OpenCart root folder +7. Optional: go to OpenCart / extensions / modules, disable and then re-enable the OpenCore module + ## How does it works ? Let's take this file from OpenCart system: `/admin/controller/common/header.php` @@ -109,6 +119,7 @@ MIT license. Please see the [license file](LICENSE) for more information. ## TODO +* create a console command for faster instalation / update * force paginator->appends to automatically add token/user_token param for admin requests only * when enabling a module the permission must be added automatically for the user who made the action * Example & Developer modules should be disabled by default diff --git a/config/app.php b/config/app.php index 1fbae68..7a68ad7 100644 --- a/config/app.php +++ b/config/app.php @@ -170,7 +170,7 @@ * Application Service Providers... */ App\Providers\AppServiceProvider::class, - App\Providers\AuthServiceProvider::class, + //App\Providers\AuthServiceProvider::class, // App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, @@ -195,7 +195,7 @@ 'App' => Illuminate\Support\Facades\App::class, 'Arr' => Illuminate\Support\Arr::class, 'Artisan' => Illuminate\Support\Facades\Artisan::class, - 'Auth' => Illuminate\Support\Facades\Auth::class, + //'Auth' => Illuminate\Support\Facades\Auth::class, 'Blade' => Illuminate\Support\Facades\Blade::class, 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, 'Bus' => Illuminate\Support\Facades\Bus::class, diff --git a/support/Opencart/Startup.php b/support/Opencart/Startup.php index a0bd402..20e5686 100644 --- a/support/Opencart/Startup.php +++ b/support/Opencart/Startup.php @@ -147,6 +147,10 @@ public function checkOpenCoreRoute() $requestMethod = $_SERVER['REQUEST_METHOD']; if (!empty($allowed_routes[$requestMethod])) { + if (in_array($this->route, $allowed_routes[$requestMethod])) { + return true; + } + foreach ($allowed_routes[$requestMethod] as $route) { if (preg_match_all('/\{(.*?)\??\}/', $route, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { foreach ($matches[0] as $match) { @@ -154,10 +158,10 @@ public function checkOpenCoreRoute() $getSamePartFromRoute = strtok($remainingUri, '/'); $route = substr_replace($route, $getSamePartFromRoute, $match[1], strlen($match[0])); } - } - if ($route === $this->route) { - return true; + if ($route === $this->route) { + return true; + } } } } @@ -165,16 +169,6 @@ public function checkOpenCoreRoute() return false; } - /** - * Run function - * - * @execute Framewrok - */ - public function run() - { - Framework::getInstance()->run(); - } - /** * Framework Response function */