From cab6defdfdbf7d49eeae39207a5c69a91d8f8478 Mon Sep 17 00:00:00 2001 From: n0nag0n Date: Wed, 9 Nov 2022 09:43:55 -0700 Subject: [PATCH] Updated codebase to be PHP8 ready without notices. --- .gitignore | 5 ++- bin/fatfree | 1 + composer.lock | 46 ++++++++++++--------- controllers/Init_Environment_Controller.php | 2 +- controllers/Manage_Composer_Controller.php | 25 +++++------ controllers/Route_Controller.php | 10 +++-- public/index.php | 3 ++ templates/config.ini | 2 +- templates/services.php | 6 +-- ui/config_check/index.htm | 6 +-- ui/init_environment/basic_config.htm | 26 ++++++------ ui/init_environment/directory_setup.htm | 26 ++++++------ ui/init_environment/jig.htm | 2 +- ui/init_environment/mysql.htm | 12 +++--- ui/init_environment/sqlite.htm | 2 +- ui/init_environment/title.htm | 2 +- ui/models/index.htm | 3 -- ui/plugins/_project.htm | 10 ++--- 18 files changed, 103 insertions(+), 86 deletions(-) diff --git a/.gitignore b/.gitignore index 28a52fd..ec52011 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ vendor/ tmp/ -log/ \ No newline at end of file +log/ +app/ +.vscode/ +.fatfree-devtools/ \ No newline at end of file diff --git a/bin/fatfree b/bin/fatfree index 7a5ee90..a759c9b 100755 --- a/bin/fatfree +++ b/bin/fatfree @@ -10,6 +10,7 @@ foreach([ __DIR__.'/../vendor/autoload.php', __DIR__.'/../../../autoload.php' ] define("DEVTOOLS_VERSION", '0.1.2'); + $fw = Base::instance(); $fw->DEBUG = 3; $fw->HALT = false; diff --git a/composer.lock b/composer.lock index 6465a1e..9e256e4 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "bcosca/fatfree-core", - "version": "3.7.2", + "version": "3.8.1", "source": { "type": "git", "url": "https://github.com/bcosca/fatfree-core.git", - "reference": "a0f7ecf456a2f1e099a9b6d7aedc22970be56030" + "reference": "f6ea45472f55a1ecabd4ced74cb56f0efd6af34e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bcosca/fatfree-core/zipball/a0f7ecf456a2f1e099a9b6d7aedc22970be56030", - "reference": "a0f7ecf456a2f1e099a9b6d7aedc22970be56030", + "url": "https://api.github.com/repos/bcosca/fatfree-core/zipball/f6ea45472f55a1ecabd4ced74cb56f0efd6af34e", + "reference": "f6ea45472f55a1ecabd4ced74cb56f0efd6af34e", "shasum": "" }, "require": { @@ -35,20 +35,24 @@ ], "description": "A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!", "homepage": "http://fatfreeframework.com/", - "time": "2020-05-28T16:14:27+00:00" + "support": { + "issues": "https://github.com/bcosca/fatfree-core/issues", + "source": "https://github.com/bcosca/fatfree-core/tree/3.8.1" + }, + "time": "2022-11-04T23:15:19+00:00" }, { "name": "ikkez/f3-flash", - "version": "1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/ikkez/f3-flash.git", - "reference": "3ba9ca1ddc80a54ff17a069c47c23e32d601c5d6" + "reference": "ebe20c4e35408f4b03211d946dfbafe375b385a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ikkez/f3-flash/zipball/3ba9ca1ddc80a54ff17a069c47c23e32d601c5d6", - "reference": "3ba9ca1ddc80a54ff17a069c47c23e32d601c5d6", + "url": "https://api.github.com/repos/ikkez/f3-flash/zipball/ebe20c4e35408f4b03211d946dfbafe375b385a1", + "reference": "ebe20c4e35408f4b03211d946dfbafe375b385a1", "shasum": "" }, "type": "library", @@ -62,14 +66,18 @@ "GPL-3.0" ], "description": "Add simple Flash Messages and Flash Keys to PHP Fat-Free Framework", - "homepage": "https://github.com/ikkez/f3-middleware", + "homepage": "https://github.com/ikkez/f3-flash", "keywords": [ "F3", "fatfree", "flash", "session" ], - "time": "2017-12-06T17:50:51+00:00" + "support": { + "issues": "https://github.com/ikkez/f3-flash/issues", + "source": "https://github.com/ikkez/f3-flash/tree/1.0.2" + }, + "time": "2020-12-13T08:43:57+00:00" }, { "name": "n0nag0n/fatfree-environment-check", @@ -113,16 +121,16 @@ }, { "name": "net-tools/composer-interface", - "version": "1.0.10", + "version": "1.0.15", "source": { "type": "git", "url": "https://github.com/net-tools/composer-interface.git", - "reference": "ff4eb8049a98392df9c7279ebee4e282d28a8088" + "reference": "079964b37399851763efbd3571205388829fd355" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/net-tools/composer-interface/zipball/ff4eb8049a98392df9c7279ebee4e282d28a8088", - "reference": "ff4eb8049a98392df9c7279ebee4e282d28a8088", + "url": "https://api.github.com/repos/net-tools/composer-interface/zipball/079964b37399851763efbd3571205388829fd355", + "reference": "079964b37399851763efbd3571205388829fd355", "shasum": "" }, "require": { @@ -136,16 +144,16 @@ "authors": [ { "name": "Pierre", - "email": "dev@net-tools.ovh", + "email": "dev@nettools.ovh", "role": "Developer" } ], "description": "PHP shell interface to Composer when SSH is not available on your host ", "support": { "issues": "https://github.com/net-tools/composer-interface/issues", - "source": "https://github.com/net-tools/composer-interface/tree/master" + "source": "https://github.com/net-tools/composer-interface/tree/1.0.15" }, - "time": "2017-11-08T12:55:51+00:00" + "time": "2022-03-08T16:48:51+00:00" } ], "packages-dev": [], @@ -156,5 +164,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.0.0" + "plugin-api-version": "2.3.0" } diff --git a/controllers/Init_Environment_Controller.php b/controllers/Init_Environment_Controller.php index bc6bdb9..69d2558 100644 --- a/controllers/Init_Environment_Controller.php +++ b/controllers/Init_Environment_Controller.php @@ -54,7 +54,7 @@ public function pageAction(\Base $fw, array $args = []): void { $project_config = new Project_Config($fw->DB); $project_config->load(); - $this->renderHtml($page_ui, [ 'config' => $project_config->cast(), 'PAGE_TITLE' => $page.' - Configure Environment' ] ); + $this->renderHtml($page_ui, [ 'config' => $project_config, 'PAGE_TITLE' => $page.' - Configure Environment' ] ); } public function update(\Base $fw): void { diff --git a/controllers/Manage_Composer_Controller.php b/controllers/Manage_Composer_Controller.php index 12f6d7b..e08fc41 100644 --- a/controllers/Manage_Composer_Controller.php +++ b/controllers/Manage_Composer_Controller.php @@ -16,6 +16,7 @@ public function indexAction(\Base $fw): void { } $root = rtrim($fw->PROJECT_BASE_DIR, '/'); + $ret = ''; try { // create config object and set composer home (here, the parent folder of document root, so that other composer projects may benefit from global caching) @@ -42,22 +43,21 @@ public function indexAction(\Base $fw): void { // create interface and set the composer project to be in folder PROJECT $composer = new \ComposerInterfaceAdapter($config, $root); + error_reporting(0); // global commands (not relative to a package or repository) - if ( $_REQUEST['composer'] ) + if ( !empty($_REQUEST['composer']) ) { $ret = $composer->{$_REQUEST['composer']}(); - + } // package commands - else if ( $_REQUEST['package_cmd'] && $_REQUEST['package'] ) + else if ( !empty($_REQUEST['package_cmd']) && !empty($_REQUEST['package']) ) { $ret = $composer->{'package_' . $_REQUEST['package_cmd']}($_REQUEST['package']); - // repositories commands - else if ( $_REQUEST['repository_cmd'] && $_REQUEST['url'] ) - switch ( $_REQUEST['repository_cmd'] ) - { + } else if ( !empty($_REQUEST['repository_cmd']) && !empty($_REQUEST['url']) ) { + switch ( $_REQUEST['repository_cmd'] ) { case 'add' : - if ( $_REQUEST['type'] ) + if ( !empty($_REQUEST['type']) ) $ret = $composer->repository_add($_REQUEST['type'], $_REQUEST['url']); break; @@ -66,16 +66,17 @@ public function indexAction(\Base $fw): void { break; } - // user command (not supported by this library) - else if ( $_REQUEST['cmd'] ) + } else if ( !empty($_REQUEST['cmd']) ) { $ret = $composer->command($_REQUEST['cmd']); + } } - catch(\Throwable $e) - { + catch(\Throwable $e) { $ret = $e->getMessage() . "\n---\nTrace : " . $e->getTraceAsString(); } + error_reporting(E_ALL); + if(file_exists($root . '/composer.json')) { $composer_file_contents = file_get_contents($root . '/composer.json'); } else { diff --git a/controllers/Route_Controller.php b/controllers/Route_Controller.php index 0123fd5..aec1afe 100644 --- a/controllers/Route_Controller.php +++ b/controllers/Route_Controller.php @@ -112,13 +112,17 @@ public function getRoutes(): array { $final_route = []; $final_route['method'] = $explode[0]; - $final_route['alias'] = end(preg_grep("/\@\w+\:/i", $explode)); - $final_route['route'] = end(preg_grep("~/.+~", $explode)); - $final_route['type'] = end(preg_grep("/\[.+\]/", $explode)); + $aliases_grep = preg_grep("/\@\w+\:/i", $explode); + $final_route['alias'] = end($aliases_grep); + $routes_grep = preg_grep("~/.+~", $explode); + $final_route['route'] = end($routes_grep); + $types_grep = preg_grep("/\[.+\]/", $explode); + $final_route['type'] = end($types_grep); $final_route['controller'] = $controller; $final_route['token'] = $line_token; $routes[] = $final_route; } + return $routes; } diff --git a/public/index.php b/public/index.php index 48f1247..e5c2a94 100644 --- a/public/index.php +++ b/public/index.php @@ -7,6 +7,9 @@ } $fw = Base::instance(); + +error_reporting(E_ALL); + $fw->config(__DIR__.'/../config/webtools_config.ini', true); $fw->set('flash', \Flash::instance()); diff --git a/templates/config.ini b/templates/config.ini index 6a5252a..9914700 100644 --- a/templates/config.ini +++ b/templates/config.ini @@ -13,7 +13,7 @@ TEMP = "../{{ @cnf_temp }}" UPLOADS = "../{{ @cnf_uploads }}" ; Removing the 'Fat-Free Framework' reference for security reasons PACKAGE = "" - + ; MySQL Database Configuration mysql.database = {{ @cnf_mysql_name }} mysql.host = {{ @cnf_mysql_host }} diff --git a/templates/services.php b/templates/services.php index 57e8783..404d40b 100644 --- a/templates/services.php +++ b/templates/services.php @@ -1,8 +1,8 @@ + // Setup Jig DB Connection $fw->set('DB', new \DB\Jig(PROJECT_DEVTOOLS_DATA_DIR, \DB\Jig::FORMAT_JSON ), 6000); - + // Setup MySQL DB Connection $fw->set('DB', new DB\SQL( 'mysql:host='.$fw->get('mysql.host').';port='.$fw->get('mysql.port').';dbname='.$fw->get('mysql.database').';charset='.$fw->get('mysql.charset'), @@ -15,7 +15,7 @@ ] ) )); - + // Setup SQLite DB Connection $fw->set('DB', new DB\SQL('sqlite:{{ @PROJECT_BASE_DIR }}{{ @cnf_sqlite }}')); diff --git a/ui/config_check/index.htm b/ui/config_check/index.htm index d1018e0..364f8fc 100644 --- a/ui/config_check/index.htm +++ b/ui/config_check/index.htm @@ -4,13 +4,13 @@
- +
- +
@@ -22,4 +22,4 @@
- \ No newline at end of file + \ No newline at end of file diff --git a/ui/init_environment/basic_config.htm b/ui/init_environment/basic_config.htm index 9667507..61f3323 100644 --- a/ui/init_environment/basic_config.htm +++ b/ui/init_environment/basic_config.htm @@ -5,53 +5,53 @@

Configuration

Config Files

- + You'll put things in here that are used in pretty much all requests of your project: database connection information, the name of your project, etc.
- + You'll define your routes (what happens when you type in a URL such as /about-us and what to do with it.
- + This file will hold routes for scripts you want to use for crons, one off scripts, etc. Ex: app/bin/cli generate list --force.
- +

Variable Configuration

- + The model, controller, task, and util directories will already be configured in the autoloader. Add any other files in here (relative to the public directory, or absolute path) separated by a semi-colon.
- + There are multiple values you can set here. Set to true to turn on file level caching (saved to the tmp/ directory). To specify a directory path use folder=/path/to/cache/. For memcached, use memcached=[host][:port=11211] (Ex: memcached=localhost:11233). For Redis use redis=[host][:port=6379][:username=null][:password=null]
- + Character Set to Use Within the App.
This is used to help prevent XSS attacks on your site. It is highly recommended to have this enabled.
@@ -59,7 +59,7 @@

Variable Configuration

It is helpful to halt execution after an error so the page doesn't fill up with a lot of error messages. @@ -67,7 +67,7 @@

Variable Configuration

« Back diff --git a/ui/init_environment/directory_setup.htm b/ui/init_environment/directory_setup.htm index cb1a79e..ad5df5b 100644 --- a/ui/init_environment/directory_setup.htm +++ b/ui/init_environment/directory_setup.htm @@ -8,7 +8,7 @@

Directory Setup

{{ @PROJECT_BASE_DIR }}
- + This is where you config files for database connections, routes, and other things will be setup. @@ -18,7 +18,7 @@

Directory Setup

{{ @PROJECT_BASE_DIR }}
- + Controllers are the "directors" of your web app. They handle requests from your users and process them. @@ -28,7 +28,7 @@

Directory Setup

{{ @PROJECT_BASE_DIR }}
- + Controllers are the "directors" of your web app. They handle requests from your users and process them. @@ -38,7 +38,7 @@

Directory Setup

{{ @PROJECT_BASE_DIR }}
- + A model basically represents a table in your database. It makes it very easy to add, modify, or delete new rows from your tables. @@ -48,7 +48,7 @@

Directory Setup

{{ @PROJECT_BASE_DIR }}
- + These are where all your HTML and template files will be stored. @@ -58,7 +58,7 @@

Directory Setup

{{ @PROJECT_BASE_DIR }}
- + Unit tests are vital to make sure that the parts of your system you want to work a certain way, work correctly that way. @@ -68,7 +68,7 @@

Directory Setup

{{ @PROJECT_BASE_DIR }}
- + This is the directory from where Apache/Nginx/Lighttpd etc will serve your content. It should only have 1 PHP file (index.php) and have your images, JavaScript, and CSS files as well. @@ -78,7 +78,7 @@

Directory Setup

{{ @PROJECT_BASE_DIR }}
- + Several executable files will be placed here to help with fleshing out your project better (test for unit tests, and cli for CLI scripts/crons). @@ -88,7 +88,7 @@

Directory Setup

{{ @PROJECT_BASE_DIR }}
- + This folder will hold any random classes you may have that help you with your project that you need to custom design (such as a custom email class to send emails, or a special way to format text, etc). @@ -98,7 +98,7 @@

Directory Setup

{{ @PROJECT_BASE_DIR }}
- + All your log files will be saved here. @@ -108,7 +108,7 @@

Directory Setup

{{ @PROJECT_BASE_DIR }}
- + All your log files will be saved here. @@ -118,7 +118,7 @@

Directory Setup

{{ @PROJECT_BASE_DIR }}
- + These are usually cached files from Fat-Free. @@ -128,7 +128,7 @@

Directory Setup

{{ @PROJECT_BASE_DIR }}
- + This is where Composer installs packages. diff --git a/ui/init_environment/jig.htm b/ui/init_environment/jig.htm index 511995c..6a04db5 100644 --- a/ui/init_environment/jig.htm +++ b/ui/init_environment/jig.htm @@ -8,7 +8,7 @@

Jig DB Setup

{{ @PROJECT_BASE_DIR }}
- + « Back diff --git a/ui/init_environment/mysql.htm b/ui/init_environment/mysql.htm index aa04d73..e6b1087 100644 --- a/ui/init_environment/mysql.htm +++ b/ui/init_environment/mysql.htm @@ -8,23 +8,23 @@

MySQL Database Connection Information

- +
- +
- +
- +
- +
@@ -32,7 +32,7 @@

MySQL Database Connection Information

- +
« Back diff --git a/ui/init_environment/sqlite.htm b/ui/init_environment/sqlite.htm index 4781f52..1470e3d 100644 --- a/ui/init_environment/sqlite.htm +++ b/ui/init_environment/sqlite.htm @@ -8,7 +8,7 @@

SQLite DB Setup

{{ @PROJECT_BASE_DIR }}
- + « Back diff --git a/ui/init_environment/title.htm b/ui/init_environment/title.htm index b40b524..34fb385 100644 --- a/ui/init_environment/title.htm +++ b/ui/init_environment/title.htm @@ -5,7 +5,7 @@

Environment Setup Page

General Settings

- + This is the title of the project you are working on. (Ex: Cool Todo App)
« Back diff --git a/ui/models/index.htm b/ui/models/index.htm index e50eb27..ec9ff71 100644 --- a/ui/models/index.htm +++ b/ui/models/index.htm @@ -10,9 +10,6 @@

Models

- {{ @model.base_name }} diff --git a/ui/plugins/_project.htm b/ui/plugins/_project.htm index 57fab70..f733588 100644 --- a/ui/plugins/_project.htm +++ b/ui/plugins/_project.htm @@ -1,8 +1,8 @@

{{ @project.title }}

{{ @project.description }}

-Github -Website - +Github +Website + @@ -12,8 +12,8 @@

{{ @project.title }}

- - + +