Skip to content

Commit

Permalink
Merge pull request #2 from nguyenanhung/v2.x
Browse files Browse the repository at this point in the history
Update Project at Fri Aug 18 12:24:23 +07 2023
  • Loading branch information
nguyenanhung committed Aug 18, 2023
2 parents 6cfccb8 + 7f6dddd commit 5f118a3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions helpers/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
* @copyright: 713uk13m <dev@nguyenanhung.com>
* @time : 09/24/2021 26:08
*/
function register_error_handler($errno, $errstr, $errfile, $errline): bool
function register_error_handler($errno, $errstr, $errfile, $errline)
{
if (($errno & error_reporting()) > 0) {
throw new ErrorException($errstr, 500, $errno, $errfile, $errline);
} else {
return false;
}

return false;
}
}
if (!function_exists('php_basic_firewall')) {
Expand Down
26 changes: 13 additions & 13 deletions src/CheckSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ public function setPhpMinVersion(string $phpMinVersion): CheckSystem
public function checkPhpVersion(): array
{
$minVersion = $this->phpMinVersion;
$operator = '>=';
$operator = '>=';

$message = 'Current PHP Version: ' . PHP_VERSION . ' - Suggest PHP Version ' . $operator . ' ' . $minVersion;

if (version_compare(PHP_VERSION, $minVersion, $operator)) {
$code = true;
$code = true;
$status = 'OK';
} else {
$code = false;
$code = false;
$status = 'NOK';
}

Expand Down Expand Up @@ -125,7 +125,7 @@ public function phpVersion()
*/
public function connectUsePhpTelnet(string $hostname = '', $port = ''): array
{
$message = 'Connection to server ' . $hostname . ':' . $port . '';
$message = 'Connection to server ' . $hostname . ':' . $port;
try {
$socket = fsockopen($hostname, $port);
if ($socket) {
Expand Down Expand Up @@ -178,7 +178,7 @@ public function phpTelnet(string $hostname = '', $port = '')
public function checkExtensionRequirement(string $extension = ''): array
{
$message = 'Requirement Extension: ' . $extension;
$code = extension_loaded($extension);
$code = extension_loaded($extension);

return array(
'code' => $code,
Expand Down Expand Up @@ -218,25 +218,25 @@ public function checkFilePermission(string $filename = '', string $mode = 'read'
{
$message = 'File ' . $filename;
if (!file_exists($filename)) {
$code = false;
$code = false;
$status = 'File ' . $filename . ' not exists';
} else {
$mode = strtolower($mode);
$mode = mb_strtolower($mode);
switch ($mode) {
case "read":
$code = is_readable($filename);
$code = is_readable($filename);
$status = $code === true ? 'Read OK' : 'Read NOK';
break;
case "write":
$code = is_writable($filename);
$code = is_writable($filename);
$status = $code === true ? 'Write OK' : 'Write NOK';
break;
case "executable":
$code = is_executable($filename);
$code = is_executable($filename);
$status = $code === true ? 'Executable OK' : 'Executable NOK';
break;
default:
$code = false;
$code = false;
$status = 'NOK';
}
}
Expand Down Expand Up @@ -311,14 +311,14 @@ public function checkConnectDatabaseWithPDO(string $host = '', $port = '', strin
{
try {
$dsnString = "mysql:host=$host;port=$port;dbname=$database";
$conn = new PDO($dsnString, $username, $password);
$conn = new PDO($dsnString, $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$result = array(
'code' => true,
'message' => "Connected successfully to Database : " . $dsnString . " with username: " . $username . " and your input password"
);
$conn = null;
$conn = null;
} catch (PDOException $e) {
$result = array(
'code' => false,
Expand Down

0 comments on commit 5f118a3

Please sign in to comment.