diff --git a/phppsinfo.php b/phppsinfo.php index 7e05b7a..aeaffb4 100644 --- a/phppsinfo.php +++ b/phppsinfo.php @@ -1,5 +1,9 @@ true, 'expose_php' => false, 'file_uploads' => true, - 'max_input_vars' => 5000, + 'max_input_vars' => 10000, 'memory_limit' => '256M', 'post_max_size' => '128M', 'register_argc_argv' => false, @@ -145,13 +149,15 @@ public function __construct($login = self::DEFAULT_LOGIN, $password = self::DEFA */ public function checkAuth() { - if (PHP_SAPI === 'cli' || + if ( + PHP_SAPI === 'cli' || empty($this->login) ) { return; } - if (!isset($_SERVER['PHP_AUTH_USER']) || + if ( + !isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_PW'] != $this->password || $_SERVER['PHP_AUTH_USER'] != $this->login ) { @@ -162,6 +168,64 @@ public function checkAuth() } } + /** + * Get versions php by PS version + */ + public function updateVersionsPHPByPSVersion() + { + $version = _PS_VERSION_; + + if (substr($version, 0, 1) === "1") { + $version = substr($version, 0, 5); + } else { + $version = substr($version, 0, 1); + } + + switch ($version) { + case '1.6.1': + $this->requirements['versions']['php'] = "5.2"; + $this->recommended['versions']['php'] = "7.1"; + break; + case '1.7.0': + case '1.7.1': + case '1.7.2': + case '1.7.3': + $this->requirements['versions']['php'] = "5.4"; + $this->recommended['versions']['php'] = "7.1"; + break; + case '1.7.4': + $this->requirements['versions']['php'] = "5.6"; + $this->recommended['versions']['php'] = "7.1"; + break; + case '1.7.5': + case '1.7.6': + $this->requirements['versions']['php'] = "5.6"; + $this->recommended['versions']['php'] = "7.2"; + break; + case '1.7.7': + $this->requirements['versions']['php'] = "7.1"; + $this->recommended['versions']['php'] = "7.3"; + break; + case '1.7.8': + $this->requirements['versions']['php'] = "7.1"; + $this->recommended['versions']['php'] = "7.4"; + break; + case '8': + $this->requirements['versions']['php'] = "7.2"; + $this->recommended['versions']['php'] = "8.1"; + break; + case '9': + $this->requirements['versions']['php'] = "8.1"; + $this->recommended['versions']['php'] = "8.4"; + break; + + default: + $this->requirements['versions']['php'] = "5.5"; + $this->recommended['versions']['php'] = "5.6"; + break; + } + } + /** * Get versions data * @@ -169,25 +233,38 @@ public function checkAuth() */ public function getVersions() { + $data = [ 'Web server' => [$this->getWebServer()], 'PHP Type' => [ strpos(PHP_SAPI, 'cgi') !== false ? - 'CGI with Apache Worker or another webserver' : - (strpos(PHP_SAPI, 'litespeed') !== false ? 'Litespeed (Better performance)' : 'Apache Module (low performance)') - ], - ]; + 'CGI with Apache Worker or another webserver' : (strpos(PHP_SAPI, 'litespeed') !== false ? 'Litespeed (Better performance)' : 'Apache Module (low performance)') + ], + ]; + + if (file_exists(dirname(__FILE__) . '/config/config.inc.php')) { + $this->updateVersionsPHPByPSVersion(); + $data = array_merge( + ['Prestashop version' => [_PS_VERSION_]], + $data + ); + } + + $phpServerVersionRewrite = str_replace('.', ',', substr(PHP_VERSION, 0, 3)); + $phpRequiredVersionRewrite = str_replace('.', ',', $this->requirements['versions']['php']); + $phpRecommandedVersionRewrite = str_replace('.', ',', $this->recommended['versions']['php']); $data['PHP Version'] = [ $this->requirements['versions']['php'], $this->recommended['versions']['php'], PHP_VERSION, - version_compare(PHP_VERSION, $this->recommended['versions']['php'], '>=') ? - self::TYPE_OK : ( - version_compare(PHP_VERSION, $this->requirements['versions']['php'], '>=') ? - self::TYPE_WARNING : - self::TYPE_ERROR - ) + version_compare($phpServerVersionRewrite, $phpRecommandedVersionRewrite, '>=') ? + (version_compare($phpServerVersionRewrite, $phpRecommandedVersionRewrite, '==') ? + self::TYPE_OK : self::TYPE_ERROR) : ( + version_compare($phpServerVersionRewrite, $phpRequiredVersionRewrite, '>=') ? + self::TYPE_WARNING : + self::TYPE_ERROR + ) ]; if (!extension_loaded('mysqli') || !is_callable('mysqli_connect')) { @@ -381,7 +458,7 @@ public function toBytes($value) $value = trim($value); $val = (int) $value; - switch (strtolower($value[strlen($value)-1])) { + switch (strtolower($value[strlen($value) - 1])) { case 'g': $val *= 1024; // continue @@ -517,85 +594,139 @@ protected function commandExists($command) ?> - - - - - - - - PHP PrestaShop Info - - - - - - - -
-
-
-

General information & PHP/MySQL Version

-
- - - - - - - - - - - getVersions() as $label => $data) : ?> - - - - - - - - - - - - - - - -
#RequiredRecommendedCurrent
toString($data[0]) ?>
toString($data[0]) ?>toString($data[1]) ?>toString($data[2]) ?>
-
- -

PHP Configuration

-
- - - - - - - - - - - getPhpConfig() as $label => $data) : ?> + + + + + + + + PHP PrestaShop Info + + + + + + + +
+
+
+

General information & PHP/MySQL Version

+
+
#RequiredRecommendedCurrent
+ + + + + + + + + + getVersions() as $label => $data) : ?> + + + + + + - - -
#RequiredRecommendedCurrent
toString($data[0]) ?>
toString($data[0]) ?> toString($data[1]) ?> toString($data[2]) ?>
-
+ + + + +
+ +

PHP Configuration

+ +
+ + + + + + + + + + + getPhpConfig() as $label => $data) : ?> + + + + + + + + +
#RequiredRecommendedCurrent
toString($data[0]) ?>toString($data[1]) ?>toString($data[2]) ?>
+
+ +

PHP Extensions

+ +
+ + + + + + + + + + + getPhpExtensions() as $label => $data) : ?> + + + + + + + + +
#RequiredRecommendedCurrent
toString($data[0]) ?>toString($data[1]) ?>toString($data[2]) ?>
+
+ +

Directories

+ +
+ + + + + + + + + getDirectories() as $label => $data) : ?> + + + + + + + + + + +
#Is Writable
Directory not existstoString($data[0]) ?>
+
-

PHP Extensions

+ getServerModules()) > 0): ?> +

Apache Modules

@@ -608,7 +739,7 @@ protected function commandExists($command) - getPhpExtensions() as $label => $data) : ?> + getServerModules() as $label => $data) : ?> @@ -619,64 +750,14 @@ protected function commandExists($command)
toString($data[0]) ?>
- -

Directories

- -
- - - - - - - - - getDirectories() as $label => $data) : ?> - - - - - - - - - - -
#Is Writable
Directory not existstoString($data[0]) ?>
-
- - getServerModules()) > 0): ?> -

Apache Modules

- -
- - - - - - - - - - - getServerModules() as $label => $data) : ?> - - - - - - - - -
#RequiredRecommendedCurrent
toString($data[0]) ?>toString($data[1]) ?>toString($data[2]) ?>
-
- - -
+ + + + + + - - - + \ No newline at end of file