Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bakeiro committed Dec 7, 2020
1 parent d2a60b3 commit 0d69ddd
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 57 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"@solve-lint"
],
"lint": [
"phpcs --encoding=utf-8 -n -s --colors --standard=PSR1,PSR12,PEAR --exclude=PEAR.Commenting.ClassComment,PEAR.Commenting.FileComment,PEAR.Commenting.FunctionComment --ignore=node_modules/*,system/composer/*,public/* ./ "
"phpcs --encoding=utf-8 -n -s --colors --standard=PSR1,PSR12 --ignore=node_modules/*,system/composer/*,public/* ./ "
],
"fix-lint": [
"phpcbf --encoding=utf-8 -n --colors --standard=PSR1,PSR12,PEAR --exclude=PEAR.Commenting.ClassComment,PEAR.Commenting.FileComment --ignore=node_modules/*,system/composer/*,public/* ./"
"phpcbf --encoding=utf-8 -n --colors --standard=PSR1,PSR12 --ignore=node_modules/*,system/composer/*,public/* ./"
]
},
"authors": [
Expand Down
2 changes: 1 addition & 1 deletion src/product/controller/productController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Default's controller, this shows the demo pages when you run for first time
* this project
*/
class productController extends Controller
class ProductController extends Controller
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/welcome/controller/welcomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Default's controller, this shows the demo pages when you run for first time
* this project
*/
class welcomeController extends Controller
class WelcomeController extends Controller
{
/**
* First sample page, returns welcome template
Expand Down
12 changes: 6 additions & 6 deletions system/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@
set_exception_handler(array($logger,"myExceptionHandler"));

// XSS, scape characters, SQL Injection
$util->array_walk_recursive_referential($_GET, array($util, "preventXSS"));
$util->array_walk_recursive_referential($_GET, "trim");
$util->array_walk_recursive_referential($_GET, array($util, "escape"));
$util->arrayWalkRecursiveReferential($_GET, array($util, "preventXSS"));
$util->arrayWalkRecursiveReferential($_GET, "trim");
$util->arrayWalkRecursiveReferential($_GET, array($util, "escape"));

$util->array_walk_recursive_referential($_POST, array($util, "preventXSS"));
$util->array_walk_recursive_referential($_POST, "trim");
$util->array_walk_recursive_referential($_POST, array($util, "escape"));
$util->arrayWalkRecursiveReferential($_POST, array($util, "preventXSS"));
$util->arrayWalkRecursiveReferential($_POST, "trim");
$util->arrayWalkRecursiveReferential($_POST, array($util, "escape"));

// Add container entries
$container = new Container();
Expand Down
40 changes: 20 additions & 20 deletions system/library/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
*/
class Database
{
private $connection;
private $host;
private $user;
private $db_name;
private $pass;
private $console; // used for debug
private $_connection;
private $_host;
private $_user;
private $_db_name;
private $_pass;
private $_console; // used for debug

public function __construct($host, $user, $db_name, $pass, $console)
{
$this->host = $host;
$this->user = $user;
$this->db_name = $db_name;
$this->pass = $pass;
$this->console = $console;
$this->_host = $host;
$this->_user = $user;
$this->_db_name = $db_name;
$this->_pass = $pass;
$this->_console = $console;
}

/**
Expand All @@ -33,9 +33,9 @@ public function __construct($host, $user, $db_name, $pass, $console)
*/
public function query(string $sql_query, array $params = array())
{
$this->console->addQuery($sql_query);
$this->_console->addQuery($sql_query);

$smtp = $this->connection->prepare($sql_query);
$smtp = $this->_connection->prepare($sql_query);
$smtp->setFetchMode(\PDO::FETCH_ASSOC);
$query = $smtp->execute($params);

Expand All @@ -55,7 +55,7 @@ public function query(string $sql_query, array $params = array())
}

if (strpos($sql_query, "INSERT INTO") !== false) {
$data = $this->connection->lastInsertId();
$data = $this->_connection->lastInsertId();
}
}

Expand All @@ -67,7 +67,7 @@ public function query(string $sql_query, array $params = array())
*/
public function getLastId(): int
{
return $this->connection->lastInsertId();
return $this->_connection->lastInsertId();
}

/**
Expand All @@ -76,16 +76,16 @@ public function getLastId(): int
public function initialize(): void
{
try {
$temp_connection = new \PDO("mysql:host=" . $this->host . ";port=3306;dbname=" . $this->db_name, $this->user, $this->pass);
$temp_connection = new \PDO("mysql:host=" . $this->_host . ";port=3306;dbname=" . $this->_db_name, $this->_user, $this->_pass);
$temp_connection->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false); // true prepare statements

$temp_connection->exec("SET NAMES 'utf8'");
$temp_connection->exec("SET CHARACTER SET utf8");
$temp_connection->exec("SET CHARACTER_SET_CONNECTION=utf8");

$this->connection = $temp_connection;
$this->_connection = $temp_connection;
} catch (\Throwable $th) {
$this->console->addDebugInfo("Error loading database");
$this->_console->addDebugInfo("Error loading database");
}
}

Expand All @@ -96,7 +96,7 @@ public function destruct(): void
{
//More info about this here: https://php.net/pdo.connections
//KILL CONNECTION_ID()
$this->connection->query('SELECT pg_terminate_backend(pg_backend_pid());');
$this->connection = null;
$this->_connection->query('SELECT pg_terminate_backend(pg_backend_pid());');
$this->_connection = null;
}
}
50 changes: 25 additions & 25 deletions system/library/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ class Logger
{
public $error_handle;

private $error_log_path;
private $notice_log_path;
private $warning_log_path;
private $unknown_errors_log_path;
private $console;
private $_error_log_path;
private $_notice_log_path;
private $_warning_log_path;
private $_unknown_errors_log_path;
private $_console;

/**
* Sets the Logger constructor
*/
public function __construct($error_log_path, $notice_log_path, $warning_log_path, $unknown_errors_log_path, $console)
{
$this->error_log_path = $error_log_path;
$this->notice_log_path = $notice_log_path;
$this->warning_log_path = $warning_log_path;
$this->unknown_errors_log_path = $unknown_errors_log_path;
$this->console = $console;
$this->_error_log_path = $error_log_path;
$this->_notice_log_path = $notice_log_path;
$this->_warning_log_path = $warning_log_path;
$this->_unknown_errors_log_path = $unknown_errors_log_path;
$this->_console = $console;
}

/**
Expand Down Expand Up @@ -80,10 +80,10 @@ public function myExceptionHandler(object $exception): void
{
$exception_message = $exception->getMessage();

$this->console->addError($exception_message);
$this->_console->addError($exception_message);

$this->checkLogFile($this->error_log_path);
error_log($exception_message . "\n", 3, $this->error_log_path);
$this->checkLogFile($this->_error_log_path);
error_log($exception_message . "\n", 3, $this->_error_log_path);

die($exception_message);
}
Expand All @@ -95,9 +95,9 @@ public function myExceptionHandler(object $exception): void
*/
public function noticeHandler(string $error_string): void
{
$this->console->addWarning($error_string);
$this->checkLogFile($this->notice_log_path);
error_log($error_string . "\n", 3, $this->notice_log_path);
$this->_console->addWarning($error_string);
$this->checkLogFile($this->_notice_log_path);
error_log($error_string . "\n", 3, $this->_notice_log_path);
}

/**
Expand All @@ -107,9 +107,9 @@ public function noticeHandler(string $error_string): void
*/
public function warningHandler(string $error_string): void
{
$this->console->addWarning($error_string);
$this->checkLogFile($this->warning_log_path);
error_log($error_string . "\n", 3, $this->warning_log_path);
$this->_console->addWarning($error_string);
$this->checkLogFile($this->_warning_log_path);
error_log($error_string . "\n", 3, $this->_warning_log_path);
}

/**
Expand All @@ -119,9 +119,9 @@ public function warningHandler(string $error_string): void
*/
public function errorHandler(string $error_string): void
{
$this->console->addError($error_string);
$this->checkLogFile($this->error_log_path);
error_log($error_string . "\n", 3, $this->error_log_path);
$this->_console->addError($error_string);
$this->checkLogFile($this->_error_log_path);
error_log($error_string . "\n", 3, $this->_error_log_path);
}

/**
Expand All @@ -131,9 +131,9 @@ public function errorHandler(string $error_string): void
*/
public function unknownErrorHandler(string $error_string): void
{
$this->console->addError($error_string);
$this->checkLogFile($this->unknown_errors_log_path);
error_log($error_string . "\n", 3, $this->unknown_errors_log_path);
$this->_console->addError($error_string);
$this->checkLogFile($this->_unknown_errors_log_path);
error_log($error_string . "\n", 3, $this->_unknown_errors_log_path);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions system/library/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ public function checkPostCSRFToken(): void
* @param $parameters An optional array of the additional parameters to be appended to the function
*
* Example usage to alter $array to get the second, third and fourth character from each value
* array_walk_recursive_referential($array, "substr", array("1","3"));
* arrayWalkRecursiveReferential($array, "substr", array("1","3"));
*/
public function array_walk_recursive_referential(&$array, $function, $parameters = array()): void
public function arrayWalkRecursiveReferential(&$array, $function, $parameters = array()): void
{
$reference_function = function (&$value, $key, $userdata): void {
$parameters = array_merge(array($value), $userdata[1]);
Expand Down

0 comments on commit 0d69ddd

Please sign in to comment.