Directory: /var/www/html/myframework/app Directory: /var/www/html/myframework/app/Controllers File: /var/www/html/myframework/app/Controllers/AboutUsController.php Content of /var/www/html/myframework/app/Controllers/AboutUsController.php: view('AboutUsView'); } public function show($id, $test) { echo $id.' - '.$test; die; } } File: /var/www/html/myframework/app/Controllers/HomeController.php Content of /var/www/html/myframework/app/Controllers/HomeController.php: db->query('SELECT * FROM `test`'); $data['data'] = $stmt->fetchAll(); $this->view('HomeView', $data); } } Directory: /var/www/html/myframework/app/Models File: /var/www/html/myframework/app/Models/ProductModel.php Content of /var/www/html/myframework/app/Models/ProductModel.php:
'.$__('jest').'

'; ?> File: /var/www/html/myframework/app/Views/Layout_Foot.php Content of /var/www/html/myframework/app/Views/Layout_Foot.php:
'.$__('jest').'

'; ?> File: /var/www/html/myframework/app/Views/Layout_Head.php Content of /var/www/html/myframework/app/Views/Layout_Head.php:
'.$__('jest').'

'; ?> Directory: /var/www/html/myframework/app/i18n File: /var/www/html/myframework/app/i18n/HomeView_pl.php Content of /var/www/html/myframework/app/i18n/HomeView_pl.php: 'a jak!' ]; File: /var/www/html/myframework/app/i18n/Layout_Global_pl.php Content of /var/www/html/myframework/app/i18n/Layout_Global_pl.php: 'a jak! LAYOUT GLOBAL!!' ]; File: /var/www/html/myframework/composer.json Content of /var/www/html/myframework/composer.json: { "autoload": { "psr-4": { "App\\Controllers\\": "app/Controllers/", "App\\Models\\": "app/Models/", "App\\Views\\": "app/Views/", "Core\\": "core/" } }, "require": { "geoip2/geoip2": "~2.0" } } File: /var/www/html/myframework/composer.lock Content of /var/www/html/myframework/composer.lock: { "_readme": [ "This file locks the dependencies of your project to a known state", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], "content-hash": "25737d43de99fb5d718029bd29d5374e", "packages": [ { "name": "composer/ca-bundle", "version": "1.3.5", "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", "reference": "74780ccf8c19d6acb8d65c5f39cd72110e132bbd" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/composer/ca-bundle/zipball/74780ccf8c19d6acb8d65c5f39cd72110e132bbd", "reference": "74780ccf8c19d6acb8d65c5f39cd72110e132bbd", "shasum": "" }, "require": { "ext-openssl": "*", "ext-pcre": "*", "php": "^5.3.2 || ^7.0 || ^8.0" }, "require-dev": { "phpstan/phpstan": "^0.12.55", "psr/log": "^1.0", "symfony/phpunit-bridge": "^4.2 || ^5", "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0 || ^6.0" }, "type": "library", "extra": { "branch-alias": { "dev-main": "1.x-dev" } }, "autoload": { "psr-4": { "Composer\\CaBundle\\": "src" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Jordi Boggiano", "email": "j.boggiano@seld.be", "homepage": "http://seld.be" } ], "description": "Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.", "keywords": [ "cabundle", "cacert", "certificate", "ssl", "tls" ], "funding": [ { "url": "https://packagist.com", "type": "custom" }, { "url": "https://github.com/composer", "type": "github" }, { "url": "https://tidelift.com/funding/github/packagist/composer/composer", "type": "tidelift" } ], "time": "2023-01-11T08:27:00+00:00" }, { "name": "geoip2/geoip2", "version": "v2.13.0", "source": { "type": "git", "url": "git@github.com:maxmind/GeoIP2-php.git", "reference": "6a41d8fbd6b90052bc34dff3b4252d0f88067b23" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/maxmind/GeoIP2-php/zipball/6a41d8fbd6b90052bc34dff3b4252d0f88067b23", "reference": "6a41d8fbd6b90052bc34dff3b4252d0f88067b23", "shasum": "" }, "require": { "ext-json": "*", "maxmind-db/reader": "~1.8", "maxmind/web-service-common": "~0.8", "php": ">=7.2" }, "require-dev": { "friendsofphp/php-cs-fixer": "3.*", "phpstan/phpstan": "*", "phpunit/phpunit": "^8.0 || ^9.0", "squizlabs/php_codesniffer": "3.*" }, "type": "library", "autoload": { "psr-4": { "GeoIp2\\": "src" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "Apache-2.0" ], "authors": [ { "name": "Gregory J. Oschwald", "email": "goschwald@maxmind.com", "homepage": "https://www.maxmind.com/" } ], "description": "MaxMind GeoIP2 PHP API", "homepage": "https://github.com/maxmind/GeoIP2-php", "keywords": [ "IP", "geoip", "geoip2", "geolocation", "maxmind" ], "time": "2022-08-05T20:32:58+00:00" }, { "name": "maxmind-db/reader", "version": "v1.11.0", "source": { "type": "git", "url": "https://github.com/maxmind/MaxMind-DB-Reader-php.git", "reference": "b1f3c0699525336d09cc5161a2861268d9f2ae5b" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/maxmind/MaxMind-DB-Reader-php/zipball/b1f3c0699525336d09cc5161a2861268d9f2ae5b", "reference": "b1f3c0699525336d09cc5161a2861268d9f2ae5b", "shasum": "" }, "require": { "php": ">=7.2" }, "conflict": { "ext-maxminddb": "<1.10.1,>=2.0.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "3.*", "php-coveralls/php-coveralls": "^2.1", "phpstan/phpstan": "*", "phpunit/phpcov": ">=6.0.0", "phpunit/phpunit": ">=8.0.0,<10.0.0", "squizlabs/php_codesniffer": "3.*" }, "suggest": { "ext-bcmath": "bcmath or gmp is required for decoding larger integers with the pure PHP decoder", "ext-gmp": "bcmath or gmp is required for decoding larger integers with the pure PHP decoder", "ext-maxminddb": "A C-based database decoder that provides significantly faster lookups" }, "type": "library", "autoload": { "psr-4": { "MaxMind\\Db\\": "src/MaxMind/Db" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "Apache-2.0" ], "authors": [ { "name": "Gregory J. Oschwald", "email": "goschwald@maxmind.com", "homepage": "https://www.maxmind.com/" } ], "description": "MaxMind DB Reader API", "homepage": "https://github.com/maxmind/MaxMind-DB-Reader-php", "keywords": [ "database", "geoip", "geoip2", "geolocation", "maxmind" ], "time": "2021-10-18T15:23:10+00:00" }, { "name": "maxmind/web-service-common", "version": "v0.9.0", "source": { "type": "git", "url": "https://github.com/maxmind/web-service-common-php.git", "reference": "4dc5a3e8df38aea4ca3b1096cee3a038094e9b53" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/maxmind/web-service-common-php/zipball/4dc5a3e8df38aea4ca3b1096cee3a038094e9b53", "reference": "4dc5a3e8df38aea4ca3b1096cee3a038094e9b53", "shasum": "" }, "require": { "composer/ca-bundle": "^1.0.3", "ext-curl": "*", "ext-json": "*", "php": ">=7.2" }, "require-dev": { "friendsofphp/php-cs-fixer": "3.*", "phpstan/phpstan": "*", "phpunit/phpunit": "^8.0 || ^9.0", "squizlabs/php_codesniffer": "3.*" }, "type": "library", "autoload": { "psr-4": { "MaxMind\\Exception\\": "src/Exception", "MaxMind\\WebService\\": "src/WebService" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "Apache-2.0" ], "authors": [ { "name": "Gregory Oschwald", "email": "goschwald@maxmind.com" } ], "description": "Internal MaxMind Web Service API", "homepage": "https://github.com/maxmind/web-service-common-php", "time": "2022-03-28T17:43:20+00:00" } ], "packages-dev": [], "aliases": [], "minimum-stability": "stable", "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": [], "platform-dev": [], "plugin-api-version": "1.1.0" } Directory: /var/www/html/myframework/core File: /var/www/html/myframework/core/Controller.php Content of /var/www/html/myframework/core/Controller.php: db = Database::getInstance()->getConnection(); } protected function view($viewName, $data = []) { $this->loadTranslations('Layout_Global'); $this->loadTranslations($viewName); $this->includeFile('Layout_Head'); $this->includeFile($viewName, $data); $this->includeFile('Layout_Foot'); } private function includeFile($viewName, $data = []) { $filePath = "../app/Views/{$viewName}.php"; if (file_exists($filePath)) { $data['__'] = $this->getTranslationFunction($viewName === 'Layout_Head' || $viewName === 'Layout_Foot' ? 'Layout_Global' : $viewName); extract($data); require_once $filePath; } else { throw new Exception("File {$filePath} not found"); } } private function getTranslationFunction($viewName) { return function($key) use ($viewName) { return $this->translations[$viewName][$key] ?? $key; }; } private function loadTranslations($viewName) { $language = 'pl'; $filePath = __DIR__ . "/../app/i18n/{$viewName}_{$language}.php"; if (file_exists($filePath)) { $this->translations[$viewName] = require $filePath; } else { $this->translations[$viewName] = []; } } } File: /var/www/html/myframework/core/Database.php Content of /var/www/html/myframework/core/Database.php: \PDO::ERRMODE_EXCEPTION, \PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC, \PDO::ATTR_EMULATE_PREPARES => false, ]; try { $this->connection = new \PDO($dsn, $user, $pass, $options); } catch (\PDOException $e) { throw new \PDOException($e->getMessage(), (int)$e->getCode()); } } public static function getInstance() { if (self::$instance == null) { self::$instance = new Database(); } return self::$instance; } public function getConnection() { return $this->connection; } } File: /var/www/html/myframework/core/ErrorHandler.php Content of /var/www/html/myframework/core/ErrorHandler.php: getCode(); $message = $exception->getMessage(); switch ($code) { case 403: $this->displayErrorPage($code, 'Dostęp zabroniony', $message); break; case 404: $this->displayErrorPage($code, 'Nie znaleziono strony', $message); break; default: $this->displayErrorPage(500, 'Wystąpił błąd serwera', $message); } } private function displayErrorPage($errorCode, $errorTitle, $errorMessage) { http_response_code($errorCode); require_once "../app/Views/ErrorView.php"; die(); } } File: /var/www/html/myframework/core/Router.php Content of /var/www/html/myframework/core/Router.php: addRoute('GET', $path, $controller); } public function post($path, $controller) { $this->addRoute('POST', $path, $controller); } protected function addRoute($method, $path, $controller) { $path = trim($path, '/'); $path = preg_replace('/\//', '\\/', $path); $path = preg_replace('/\:\w+/', '(\w+)', $path); $this->routes[$method][$path] = $controller; } public function direct($uri, $requestType) { $uri = trim($uri, '/'); foreach ($this->routes[$requestType] as $route => $controller) { if (preg_match('/^' . $route . '$/', $uri, $matches)) { array_shift($matches); return $this->callAction($controller, $matches); } } throw new Exception('No route defined for this URI.'); } protected function callAction($controller, $params) { list($controller, $action) = explode('@', $controller); $controller = "App\\Controllers\\{$controller}"; $controller = new $controller; if (! method_exists($controller, $action)) { throw new Exception( "{$controller} does not respond to the {$action} action." ); } return $controller->$action(...$params); } } Directory: /var/www/html/myframework/public File: /var/www/html/myframework/public/.htaccess Content of /var/www/html/myframework/public/.htaccess: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.+)$ index.php [QSA,L] File: /var/www/html/myframework/public/index.php Content of /var/www/html/myframework/public/index.php: direct($uri, $_SERVER['REQUEST_METHOD']); } catch (Exception $e) { // Obsługa błędów } File: /var/www/html/myframework/routes.php Content of /var/www/html/myframework/routes.php: get('', 'HomeController@index'); $router->get('products', 'ProductController@index'); $router->get('products/:id', 'ProductController@show'); $router->get('about_us', 'AboutUsController@index'); $router->get('about_us/:id/test/:test', 'AboutUsController@show');