Skip to content

Commit

Permalink
Merge pull request #539 from XGProyect/xgp-3.4
Browse files Browse the repository at this point in the history
XGP 3.4
  • Loading branch information
LucasKovacs authored Apr 28, 2023
2 parents 5b00b65 + 9f69217 commit 27ecbf3
Show file tree
Hide file tree
Showing 2,322 changed files with 137,395 additions and 36,015 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public/compiles/*
storage/backups/*.sql
storage/cache/*.html
storage/logs/*.txt
**/errors/*.html

#
# tests
Expand Down Expand Up @@ -42,5 +43,5 @@ nbproject/
#
# composer
#
vendor
/vendor
composer.lock
102 changes: 102 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?php

return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_unsets' => true,
'class_attributes_separation' => ['elements' => ['method' => 'one', ]],
'multiline_whitespace_before_semicolons' => false,
'single_quote' => true,

'binary_operator_spaces' => [
'operators' => [
// '=>' => 'align',
// '=' => 'align'
]
],
// 'blank_line_after_opening_tag' => true,
// 'blank_line_before_statement' => true,
'braces' => [
'allow_single_line_closure' => true,
],
// 'cast_spaces' => true,
// 'class_definition' => array('singleLine' => true),
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => true,
'function_typehint_space' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],
'include' => true,
'lowercase_cast' => true,
// 'native_function_casing' => true,
// 'new_with_braces' => true,
// 'no_blank_lines_after_class_opening' => true,
// 'no_blank_lines_after_phpdoc' => true,
// 'no_blank_lines_before_namespace' => true,
// 'no_empty_comment' => true,
// 'no_empty_phpdoc' => true,
// 'no_empty_statement' => true,
'no_extra_blank_lines' => [
'tokens' => [
'curly_brace_block',
'extra',
// 'parenthesis_brace_block',
// 'square_brace_block',
'throw',
'use',
]
],
// 'no_leading_import_slash' => true,
// 'no_leading_namespace_whitespace' => true,
// 'no_mixed_echo_print' => array('use' => 'echo'),
// 'no_multiline_whitespace_around_double_arrow' => true,
// 'no_short_bool_cast' => true,
// 'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_around_offset' => true,
// 'no_trailing_comma_in_list_call' => true,
// 'no_trailing_comma_in_singleline_array' => true,
// 'no_unneeded_control_parentheses' => true,
'no_unused_imports' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
// 'normalize_index_brace' => true,
'object_operator_without_whitespace' => true,
// 'php_unit_fqcn_annotation' => true,
// 'phpdoc_align' => true,
// 'phpdoc_annotation_without_dot' => true,
// 'phpdoc_indent' => true,
// 'phpdoc_inline_tag' => true,
// 'phpdoc_no_access' => true,
// 'phpdoc_no_alias_tag' => true,
// 'phpdoc_no_empty_return' => true,
// 'phpdoc_no_package' => true,
// 'phpdoc_no_useless_inheritdoc' => true,
// 'phpdoc_return_self_reference' => true,
// 'phpdoc_scalar' => true,
// 'phpdoc_separation' => true,
// 'phpdoc_single_line_var_spacing' => true,
// 'phpdoc_summary' => true,
// 'phpdoc_to_comment' => true,
// 'phpdoc_trim' => true,
// 'phpdoc_types' => true,
// 'phpdoc_var_without_name' => true,
// 'increment_style' => true,
// 'return_type_declaration' => true,
// 'self_accessor' => true,
// 'short_scalar_cast' => true,
// 'single_blank_line_before_namespace' => true,
// 'single_class_element_per_statement' => true,
// 'space_after_semicolon' => true,
// 'standardize_not_equals' => true,
'ternary_operator_spaces' => true,
// 'trailing_comma_in_multiline' => ['elements' => ['arrays']],
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'whitespace_after_comma_in_array' => true,
'space_after_semicolon' => true,
// 'single_blank_line_at_eof' => false
])
// ->setIndent("\t")
->setLineEnding("\n")
;
29 changes: 2 additions & 27 deletions app/Core/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@

namespace App\Core;

use App\Core\Objects;
use App\Core\Template;
use App\Libraries\Page;
use App\Libraries\Users;
use CiLang;
use Exception;

abstract class BaseController
{
Expand All @@ -35,30 +32,8 @@ public function __construct()
/**
* @param string|array $languageFile
*/
public function loadLang($languageFile): void
protected function loadLang($languageFile): void
{
try {
// require langugage library
$langPath = XGP_ROOT . LIB_PATH . 'Ci' . DIRECTORY_SEPARATOR . 'CiLang.php';

if (!file_exists($langPath)) {
// not found
throw new Exception('Language file "' . $languageFile . '" not defined');
return;
}

// required by the library
if (!defined('BASEPATH')) {
define('BASEPATH', XGP_ROOT . RESOURCES_PATH);
}

// use CI library
require_once $langPath;

$this->langs = new CiLang();
$this->langs->load($languageFile, DEFAULT_LANG);
} catch (Exception $e) {
die('Fatal error: ' . $e->getMessage());
}
$this->langs = (new Language())->loadLang($languageFile, true);
}
}
4 changes: 0 additions & 4 deletions app/Core/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

use App\Core\Enumerators\SwitchIntEnumerator as SwitchInt;
use App\Core\Enumerators\UserRanksEnumerator as UserRanks;
use App\Core\ErrorHandler;
use App\Core\Language;
use App\Core\Sessions;
use App\Helpers\StringsHelper;
use App\Libraries\Functions;
use App\Libraries\SecurePageLib;
Expand Down Expand Up @@ -40,7 +37,6 @@ class Common
*/
public function bootUp(string $app): void
{

// overall loads
$this->setErrorHandler();
$this->isServerInstalled();
Expand Down
14 changes: 6 additions & 8 deletions app/Core/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ public function __construct()
}

/**
* Open connection
*
* @return void
* @return mixed
*/
public function openConnection()
{
Expand Down Expand Up @@ -83,7 +81,7 @@ public function tryConnection(string $host = '', string $user = '', string $pass
}

// force utf8 to avoid weird characters
$this->connection->set_charset("utf8");
$this->connection->set_charset('utf8');

return true;
} catch (Exception $e) {
Expand Down Expand Up @@ -332,8 +330,8 @@ public function backupDb($tables = '*')
$return .= 'INSERT INTO ' . $table . ' VALUES(';

for ($j = 0; $j < $num_fields; $j++) {
$row[$j] = addslashes($row[$j]);
$row[$j] = str_replace("\n", "\\n", $row[$j]);
$row[$j] = addslashes((string) $row[$j]);
$row[$j] = str_replace("\n", '\\n', $row[$j]);

if (isset($row[$j])) {
$return .= '"' . $row[$j] . '"';
Expand Down Expand Up @@ -365,10 +363,10 @@ public function backupDb($tables = '*')
private function confirmQuery($result)
{
if (!$result) {
$output = "Database query failed: " . $this->connection->error;
$output = 'Database query failed: ' . $this->connection->error;

// uncomment below line when you want to debug your last query
$output .= " Last SQL Query: " . $this->last_query;
$output .= ' Last SQL Query: ' . $this->last_query;

die($this->debug->error(-1, $output));
}
Expand Down
4 changes: 2 additions & 2 deletions app/Core/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ private function createNewDebugObject(): void

final public function errorHandler(int $code, string $description, string $file, int $line): bool
{
$displayErrors = strtolower(ini_get("display_errors"));
$displayErrors = strtolower(ini_get('display_errors'));

if (error_reporting() === 0 || $displayErrors === "on") {
if (error_reporting() === 0 || $displayErrors === 'on') {
return false;
}

Expand Down
10 changes: 5 additions & 5 deletions app/Core/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ class Language
private CiLang $langs;

/**
* @param string|array $language_file
* @param string|array $languageFile
*
* @return mixed
*/
public function loadLang($language_file, $return = false)
public function loadLang($languageFile, bool $return = false)
{
try {
// require langugage library
$langPath = XGP_ROOT . LIB_PATH . 'Ci' . DIRECTORY_SEPARATOR . 'CiLang.php';

if (!file_exists($langPath)) {
// not found
throw new Exception('Language file "' . $language_file . '" not defined');
throw new Exception('Language file "' . $languageFile . '" not defined');
return;
}

Expand All @@ -36,12 +36,12 @@ public function loadLang($language_file, $return = false)

if ($return) {
$lang = new CiLang();
$lang->load($language_file, DEFAULT_LANG);
$lang->load($languageFile, DEFAULT_LANG);
return $lang;
}

$this->langs = new CiLang();
$this->langs->load($language_file, DEFAULT_LANG);
$this->langs->load($languageFile, DEFAULT_LANG);
} catch (Exception $e) {
die('Fatal error: ' . $e->getMessage());
}
Expand Down
10 changes: 0 additions & 10 deletions app/Core/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace App\Core;

use App\Core\Database;

abstract class Model
{
protected Database $db;
Expand All @@ -15,19 +13,11 @@ public function __construct()
$this->setNewDb();
}

/**
* Destructor
*/
public function __destruct()
{
$this->db->closeConnection();
}

/**
* Creates a new Database object
*
* @return void
*/
private function setNewDb(): void
{
$this->db = new Database();
Expand Down
12 changes: 6 additions & 6 deletions app/Core/Sessions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public function __construct()
$this->sessionsModel = new SessionsModel();

session_set_save_handler(
[ & $this->sessionsModel, 'openConnection'],
[ & $this->sessionsModel, 'closeConnection'],
[ & $this->sessionsModel, 'getSessionDataById'],
[ & $this->sessionsModel, 'insertNewSessionData'],
[ & $this->sessionsModel, 'deleteSessionDataById'],
[ & $this->sessionsModel, 'cleanSessionData']
[&$this->sessionsModel, 'openConnection'],
[&$this->sessionsModel, 'closeConnection'],
[&$this->sessionsModel, 'getSessionDataById'],
[&$this->sessionsModel, 'insertNewSessionData'],
[&$this->sessionsModel, 'deleteSessionDataById'],
[&$this->sessionsModel, 'cleanSessionData']
);

if (session_id() == '') {
Expand Down
Loading

0 comments on commit 27ecbf3

Please sign in to comment.