Skip to content

Commit 27ecbf3

Browse files
authored
Merge pull request #539 from XGProyect/xgp-3.4
XGP 3.4
2 parents 5b00b65 + 9f69217 commit 27ecbf3

File tree

2,322 files changed

+137395
-36015
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,322 files changed

+137395
-36015
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public/compiles/*
1414
storage/backups/*.sql
1515
storage/cache/*.html
1616
storage/logs/*.txt
17+
**/errors/*.html
1718

1819
#
1920
# tests
@@ -42,5 +43,5 @@ nbproject/
4243
#
4344
# composer
4445
#
45-
vendor
46+
/vendor
4647
composer.lock

.php-cs-fixer.php

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php
2+
3+
return (new PhpCsFixer\Config())
4+
->setRules([
5+
'@PSR12' => true,
6+
'array_indentation' => true,
7+
'array_syntax' => ['syntax' => 'short'],
8+
'combine_consecutive_unsets' => true,
9+
'class_attributes_separation' => ['elements' => ['method' => 'one', ]],
10+
'multiline_whitespace_before_semicolons' => false,
11+
'single_quote' => true,
12+
13+
'binary_operator_spaces' => [
14+
'operators' => [
15+
// '=>' => 'align',
16+
// '=' => 'align'
17+
]
18+
],
19+
// 'blank_line_after_opening_tag' => true,
20+
// 'blank_line_before_statement' => true,
21+
'braces' => [
22+
'allow_single_line_closure' => true,
23+
],
24+
// 'cast_spaces' => true,
25+
// 'class_definition' => array('singleLine' => true),
26+
'concat_space' => ['spacing' => 'one'],
27+
'declare_equal_normalize' => true,
28+
'function_typehint_space' => true,
29+
'single_line_comment_style' => ['comment_types' => ['hash']],
30+
'include' => true,
31+
'lowercase_cast' => true,
32+
// 'native_function_casing' => true,
33+
// 'new_with_braces' => true,
34+
// 'no_blank_lines_after_class_opening' => true,
35+
// 'no_blank_lines_after_phpdoc' => true,
36+
// 'no_blank_lines_before_namespace' => true,
37+
// 'no_empty_comment' => true,
38+
// 'no_empty_phpdoc' => true,
39+
// 'no_empty_statement' => true,
40+
'no_extra_blank_lines' => [
41+
'tokens' => [
42+
'curly_brace_block',
43+
'extra',
44+
// 'parenthesis_brace_block',
45+
// 'square_brace_block',
46+
'throw',
47+
'use',
48+
]
49+
],
50+
// 'no_leading_import_slash' => true,
51+
// 'no_leading_namespace_whitespace' => true,
52+
// 'no_mixed_echo_print' => array('use' => 'echo'),
53+
// 'no_multiline_whitespace_around_double_arrow' => true,
54+
// 'no_short_bool_cast' => true,
55+
// 'no_singleline_whitespace_before_semicolons' => true,
56+
'no_spaces_around_offset' => true,
57+
// 'no_trailing_comma_in_list_call' => true,
58+
// 'no_trailing_comma_in_singleline_array' => true,
59+
// 'no_unneeded_control_parentheses' => true,
60+
'no_unused_imports' => true,
61+
'no_whitespace_before_comma_in_array' => true,
62+
'no_whitespace_in_blank_line' => true,
63+
// 'normalize_index_brace' => true,
64+
'object_operator_without_whitespace' => true,
65+
// 'php_unit_fqcn_annotation' => true,
66+
// 'phpdoc_align' => true,
67+
// 'phpdoc_annotation_without_dot' => true,
68+
// 'phpdoc_indent' => true,
69+
// 'phpdoc_inline_tag' => true,
70+
// 'phpdoc_no_access' => true,
71+
// 'phpdoc_no_alias_tag' => true,
72+
// 'phpdoc_no_empty_return' => true,
73+
// 'phpdoc_no_package' => true,
74+
// 'phpdoc_no_useless_inheritdoc' => true,
75+
// 'phpdoc_return_self_reference' => true,
76+
// 'phpdoc_scalar' => true,
77+
// 'phpdoc_separation' => true,
78+
// 'phpdoc_single_line_var_spacing' => true,
79+
// 'phpdoc_summary' => true,
80+
// 'phpdoc_to_comment' => true,
81+
// 'phpdoc_trim' => true,
82+
// 'phpdoc_types' => true,
83+
// 'phpdoc_var_without_name' => true,
84+
// 'increment_style' => true,
85+
// 'return_type_declaration' => true,
86+
// 'self_accessor' => true,
87+
// 'short_scalar_cast' => true,
88+
// 'single_blank_line_before_namespace' => true,
89+
// 'single_class_element_per_statement' => true,
90+
// 'space_after_semicolon' => true,
91+
// 'standardize_not_equals' => true,
92+
'ternary_operator_spaces' => true,
93+
// 'trailing_comma_in_multiline' => ['elements' => ['arrays']],
94+
'trim_array_spaces' => true,
95+
'unary_operator_spaces' => true,
96+
'whitespace_after_comma_in_array' => true,
97+
'space_after_semicolon' => true,
98+
// 'single_blank_line_at_eof' => false
99+
])
100+
// ->setIndent("\t")
101+
->setLineEnding("\n")
102+
;

app/Core/BaseController.php

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@
44

55
namespace App\Core;
66

7-
use App\Core\Objects;
8-
use App\Core\Template;
97
use App\Libraries\Page;
108
use App\Libraries\Users;
119
use CiLang;
12-
use Exception;
1310

1411
abstract class BaseController
1512
{
@@ -35,30 +32,8 @@ public function __construct()
3532
/**
3633
* @param string|array $languageFile
3734
*/
38-
public function loadLang($languageFile): void
35+
protected function loadLang($languageFile): void
3936
{
40-
try {
41-
// require langugage library
42-
$langPath = XGP_ROOT . LIB_PATH . 'Ci' . DIRECTORY_SEPARATOR . 'CiLang.php';
43-
44-
if (!file_exists($langPath)) {
45-
// not found
46-
throw new Exception('Language file "' . $languageFile . '" not defined');
47-
return;
48-
}
49-
50-
// required by the library
51-
if (!defined('BASEPATH')) {
52-
define('BASEPATH', XGP_ROOT . RESOURCES_PATH);
53-
}
54-
55-
// use CI library
56-
require_once $langPath;
57-
58-
$this->langs = new CiLang();
59-
$this->langs->load($languageFile, DEFAULT_LANG);
60-
} catch (Exception $e) {
61-
die('Fatal error: ' . $e->getMessage());
62-
}
37+
$this->langs = (new Language())->loadLang($languageFile, true);
6338
}
6439
}

app/Core/Common.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66

77
use App\Core\Enumerators\SwitchIntEnumerator as SwitchInt;
88
use App\Core\Enumerators\UserRanksEnumerator as UserRanks;
9-
use App\Core\ErrorHandler;
10-
use App\Core\Language;
11-
use App\Core\Sessions;
129
use App\Helpers\StringsHelper;
1310
use App\Libraries\Functions;
1411
use App\Libraries\SecurePageLib;
@@ -40,7 +37,6 @@ class Common
4037
*/
4138
public function bootUp(string $app): void
4239
{
43-
4440
// overall loads
4541
$this->setErrorHandler();
4642
$this->isServerInstalled();

app/Core/Database.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ public function __construct()
3838
}
3939

4040
/**
41-
* Open connection
42-
*
43-
* @return void
41+
* @return mixed
4442
*/
4543
public function openConnection()
4644
{
@@ -83,7 +81,7 @@ public function tryConnection(string $host = '', string $user = '', string $pass
8381
}
8482

8583
// force utf8 to avoid weird characters
86-
$this->connection->set_charset("utf8");
84+
$this->connection->set_charset('utf8');
8785

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

334332
for ($j = 0; $j < $num_fields; $j++) {
335-
$row[$j] = addslashes($row[$j]);
336-
$row[$j] = str_replace("\n", "\\n", $row[$j]);
333+
$row[$j] = addslashes((string) $row[$j]);
334+
$row[$j] = str_replace("\n", '\\n', $row[$j]);
337335

338336
if (isset($row[$j])) {
339337
$return .= '"' . $row[$j] . '"';
@@ -365,10 +363,10 @@ public function backupDb($tables = '*')
365363
private function confirmQuery($result)
366364
{
367365
if (!$result) {
368-
$output = "Database query failed: " . $this->connection->error;
366+
$output = 'Database query failed: ' . $this->connection->error;
369367

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

373371
die($this->debug->error(-1, $output));
374372
}

app/Core/ErrorHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ private function createNewDebugObject(): void
2929

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

34-
if (error_reporting() === 0 || $displayErrors === "on") {
34+
if (error_reporting() === 0 || $displayErrors === 'on') {
3535
return false;
3636
}
3737

app/Core/Language.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ class Language
1010
private CiLang $langs;
1111

1212
/**
13-
* @param string|array $language_file
13+
* @param string|array $languageFile
1414
*
1515
* @return mixed
1616
*/
17-
public function loadLang($language_file, $return = false)
17+
public function loadLang($languageFile, bool $return = false)
1818
{
1919
try {
2020
// require langugage library
2121
$langPath = XGP_ROOT . LIB_PATH . 'Ci' . DIRECTORY_SEPARATOR . 'CiLang.php';
2222

2323
if (!file_exists($langPath)) {
2424
// not found
25-
throw new Exception('Language file "' . $language_file . '" not defined');
25+
throw new Exception('Language file "' . $languageFile . '" not defined');
2626
return;
2727
}
2828

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

3737
if ($return) {
3838
$lang = new CiLang();
39-
$lang->load($language_file, DEFAULT_LANG);
39+
$lang->load($languageFile, DEFAULT_LANG);
4040
return $lang;
4141
}
4242

4343
$this->langs = new CiLang();
44-
$this->langs->load($language_file, DEFAULT_LANG);
44+
$this->langs->load($languageFile, DEFAULT_LANG);
4545
} catch (Exception $e) {
4646
die('Fatal error: ' . $e->getMessage());
4747
}

app/Core/Model.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
namespace App\Core;
66

7-
use App\Core\Database;
8-
97
abstract class Model
108
{
119
protected Database $db;
@@ -15,19 +13,11 @@ public function __construct()
1513
$this->setNewDb();
1614
}
1715

18-
/**
19-
* Destructor
20-
*/
2116
public function __destruct()
2217
{
2318
$this->db->closeConnection();
2419
}
2520

26-
/**
27-
* Creates a new Database object
28-
*
29-
* @return void
30-
*/
3121
private function setNewDb(): void
3222
{
3323
$this->db = new Database();

app/Core/Sessions.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ public function __construct()
1414
$this->sessionsModel = new SessionsModel();
1515

1616
session_set_save_handler(
17-
[ & $this->sessionsModel, 'openConnection'],
18-
[ & $this->sessionsModel, 'closeConnection'],
19-
[ & $this->sessionsModel, 'getSessionDataById'],
20-
[ & $this->sessionsModel, 'insertNewSessionData'],
21-
[ & $this->sessionsModel, 'deleteSessionDataById'],
22-
[ & $this->sessionsModel, 'cleanSessionData']
17+
[&$this->sessionsModel, 'openConnection'],
18+
[&$this->sessionsModel, 'closeConnection'],
19+
[&$this->sessionsModel, 'getSessionDataById'],
20+
[&$this->sessionsModel, 'insertNewSessionData'],
21+
[&$this->sessionsModel, 'deleteSessionDataById'],
22+
[&$this->sessionsModel, 'cleanSessionData']
2323
);
2424

2525
if (session_id() == '') {

0 commit comments

Comments
 (0)