Skip to content

Commit

Permalink
Updated codebase to be PHP8 ready without notices.
Browse files Browse the repository at this point in the history
  • Loading branch information
n0nag0n committed Nov 9, 2022
1 parent 3980d0b commit cab6def
Show file tree
Hide file tree
Showing 18 changed files with 103 additions and 86 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
vendor/
tmp/
log/
log/
app/
.vscode/
.fatfree-devtools/
1 change: 1 addition & 0 deletions bin/fatfree
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
46 changes: 27 additions & 19 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion controllers/Init_Environment_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
25 changes: 13 additions & 12 deletions controllers/Manage_Composer_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;

Expand All @@ -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 {
Expand Down
10 changes: 7 additions & 3 deletions controllers/Route_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
3 changes: 3 additions & 0 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
}

$fw = Base::instance();

error_reporting(E_ALL);

$fw->config(__DIR__.'/../config/webtools_config.ini', true);

$fw->set('flash', \Flash::instance());
Expand Down
2 changes: 1 addition & 1 deletion templates/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ TEMP = "../{{ @cnf_temp }}"
UPLOADS = "../{{ @cnf_uploads }}"
; Removing the 'Fat-Free Framework' reference for security reasons
PACKAGE = ""
<check if="{{ @cnf_mysql_name }}">
<check if="{{ !empty(@cnf_mysql_name) }}">
; MySQL Database Configuration
mysql.database = {{ @cnf_mysql_name }}
mysql.host = {{ @cnf_mysql_host }}
Expand Down
6 changes: 3 additions & 3 deletions templates/services.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
<check if="{{ @cnf_jig }}">
<check if="{{ !empty(@cnf_jig) }}">
// Setup Jig DB Connection
$fw->set('DB', new \DB\Jig(PROJECT_DEVTOOLS_DATA_DIR, \DB\Jig::FORMAT_JSON ), 6000);
</check><check if="{{ @cnf_mysql_name }}">
</check><check if="{{ !empty(@cnf_mysql_name) }}">
// 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'),
Expand All @@ -15,7 +15,7 @@
]
)
));
</check><check if="{{ @cnf_sqlite }}">
</check><check if="{{ !empty(@cnf_sqlite) }}">
// Setup SQLite DB Connection
$fw->set('DB', new DB\SQL('sqlite:{{ @PROJECT_BASE_DIR }}{{ @cnf_sqlite }}'));
</check>
Expand Down
6 changes: 3 additions & 3 deletions ui/config_check/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<div class="col-sm-4">
<div class="form-group">
<label for="hostname">Hostname to Project URI</label>
<input type="text" name="hostname" class="form-control" id="hostname" placeholder="Ex: localhost" value="{{ @GET.hostname ?: 'localhost' }}" required>
<input type="text" name="hostname" class="form-control" id="hostname" placeholder="Ex: localhost" value="{{ @GET.hostname ?? 'localhost' }}" required>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label for="port">Port to Project URI</label>
<input type="text" name="port" class="form-control" id="port" placeholder="Ex: 8000" value="{{ @GET.port ?: 8080 }}" required>
<input type="text" name="port" class="form-control" id="port" placeholder="Ex: 8000" value="{{ @GET.port ?? 8080 }}" required>
</div>
</div>
<div class="col-sm-4 align-bottom">
Expand All @@ -22,4 +22,4 @@
</div>

</form>
<iframe src="http://{{ @GET.hostname ?: 'localhost' }}:{{ @GET.port ?: 8080 }}/environment-check" border="0" style="width:100%;border:0;height:2000px;"></iframe>
<iframe src="http://{{ @GET.hostname ?? 'localhost' }}:{{ @GET.port ?? 8080 }}/environment-check" border="0" style="width:100%;border:0;height:2000px;"></iframe>
26 changes: 13 additions & 13 deletions ui/init_environment/basic_config.htm
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,69 @@ <h1>Configuration</h1>
<h2>Config Files</h2>
<div class="form-group">
<label for="general_config">General Config</label>
<input type="text" name="general_config" class="form-control" id="general_config" value="{{ @config.general_config ?: 'config.ini' }}" required>
<input type="text" name="general_config" class="form-control" id="general_config" value="{{ @config.general_config ?? 'config.ini' }}" required>
<small class="form-text text-muted">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.</small>
</div>
<div class="form-group">
<label for="routes">Routes</label>
<input type="text" name="routes" class="form-control" id="routes" value="{{ @config.routes ?: 'routes.ini' }}" required>
<input type="text" name="routes" class="form-control" id="routes" value="{{ @config.routes ?? 'routes.ini' }}" required>
<small class="form-text text-muted">You'll define your routes (what happens when you type in a URL such as <code>/about-us</code> and what to do with it.</small>
</div>
<div class="form-group">
<label for="cli_routes">CLI Routes</label>
<input type="text" name="cli_routes" class="form-control" id="cli_routes" value="{{ @config.cli_routes ?: 'cli_routes.ini' }}" required>
<input type="text" name="cli_routes" class="form-control" id="cli_routes" value="{{ @config.cli_routes ?? 'cli_routes.ini' }}" required>
<small class="form-text text-muted">This file will hold routes for scripts you want to use for crons, one off scripts, etc. Ex: <code>app/bin/cli generate list --force</code>.</small>
</div>
<div class="form-group">
<label for="services">Services</label>
<input type="text" name="services" class="form-control" id="services" value="{{ @config.services ?: 'services.php' }}" required>
<input type="text" name="services" class="form-control" id="services" value="{{ @config.services ?? 'services.php' }}" required>
</div>
<h2>Variable Configuration</h2>
<div class="form-group">
<label for="autoload">AUTOLOAD</label>
<input type="text" name="autoload" class="form-control" id="autoload" value="{{ @config.autoload }}">
<input type="text" name="autoload" class="form-control" id="autoload" value="{{ @config.autoload ?? '' }}">
<small class="form-text text-muted">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.</small>
</div>
<div class="form-group">
<label for="cache">CACHE</label>
<input type="text" name="cache" class="form-control" id="cache" value="{{ @config.cache ?: 'false' }}">
<input type="text" name="cache" class="form-control" id="cache" value="{{ @config.cache ?? 'false' }}">
<small class="form-text text-muted">There are multiple values you can set here. Set to <code>true</code> to turn on file level caching (saved to the <code>tmp/</code> directory). To specify a directory path use <code>folder=/path/to/cache/</code>. For memcached, use <code>memcached=[host][:port=11211]</code> (Ex: <code>memcached=localhost:11233</code>). For Redis use <code>redis=[host][:port=6379][:username=null][:password=null]</code></small>
</div>
<div class="form-group">
<label for="debug">DEBUG</label>
<select name="debug" class="form-control" id="debug">
<option value="3" {{ @config.debug === '3' ? 'selected' : '' }}>3 - Logs detailed info of the objects as well. (Recommended for Developement)</option>
<option value="2" {{ @config.debug === '2' ? 'selected' : '' }}>2 - Logs classes and functions as well.</option>
<option value="1" {{ @config.debug === '1' ? 'selected' : '' }}>1 - Logs files and lines.</option>
<option value="3" {{ !empty(@config.debug) && @config.debug === '3' ? 'selected' : '' }}>3 - Logs detailed info of the objects as well. (Recommended for Developement)</option>
<option value="2" {{ !empty(@config.debug) && @config.debug === '2' ? 'selected' : '' }}>2 - Logs classes and functions as well.</option>
<option value="1" {{ !empty(@config.debug) && @config.debug === '1' ? 'selected' : '' }}>1 - Logs files and lines.</option>
<option value="0">0 - Suppresses logs of the stack trace (Recommended for Production).</option>
</select>
</div>
<div class="form-group">
<label for="encoding">ENCODING</label>
<input type="text" name="encoding" class="form-control" id="encoding" value="{{ @config.encoding ?: 'UTF-8' }}">
<input type="text" name="encoding" class="form-control" id="encoding" value="{{ @config.encoding ?? 'UTF-8' }}">
<small class="form-text text-muted">Character Set to Use Within the App.</small>
</div>
<div class="form-group">
<label for="escape">ESCAPE</label>
<select name="escape" class="form-control" id="escape">
<option value="1">Yes - Autoescape Template Variables (highly recommended)</option>
<option value="0" {{ @config.escape === '0' ? 'selected' : '' }}>No - Don't Escape Template Variables</option>
<option value="0" {{ !empty(@config.escape) && @config.escape === '0' ? 'selected' : '' }}>No - Don't Escape Template Variables</option>
</select>
<small class="form-text text-muted">This is used to help prevent XSS attacks on your site. It is highly recommended to have this enabled.</small>
</div>
<div class="form-group">
<label for="halt">HALT</label>
<select name="halt" class="form-control" id="halt">
<option value="1">Yes - Stop Execution After a Non-Fatal Error.</option>
<option value="0" {{ @config.halt === '0' ? 'selected' : '' }}>No - Continue Executing</option>
<option value="0" {{ !empty(@config.halt) && @config.halt === '0' ? 'selected' : '' }}>No - Continue Executing</option>
</select>
<small class="form-text text-muted">It is helpful to halt execution after an error so the page doesn't fill up with a lot of error messages.</small>
</div>
<div class="form-group">
<label for="highlight">HIGHLIGHT</label>
<select name="highlight" class="form-control" id="highlight">
<option value="1">Yes - Use Syntax Highlighting in Stack Traces.</option>
<option value="0" {{ @config.highlight === '0' ? 'selected' : '' }}>No - Do Not Use Syntax Highlighting</option>
<option value="0" {{ !empty(@config.highlight) && @config.highlight === '0' ? 'selected' : '' }}>No - Do Not Use Syntax Highlighting</option>
</select>
</div>
<a href="/init-environment/directory-setup" class="btn btn-primary mb-5">&laquo; Back</a>
Expand Down
Loading

0 comments on commit cab6def

Please sign in to comment.