mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-01 04:22:15 +08:00
This commit is contained in:
parent
4f5db79e27
commit
3bff3555a0
3 changed files with 122 additions and 47 deletions
|
@ -528,6 +528,13 @@ class ServiceActions
|
||||||
return 'Pong';
|
return 'Pong';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function ServiceTest() : string
|
||||||
|
{
|
||||||
|
$this->oHttp->ServerNoCache();
|
||||||
|
\SnappyMail\Integrity::test();
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Login with the \RainLoop\API::CreateUserSsoHash() generated hash
|
* Login with the \RainLoop\API::CreateUserSsoHash() generated hash
|
||||||
*/
|
*/
|
||||||
|
|
107
snappymail/v/0.0.0/app/libraries/snappymail/integrity.php
Normal file
107
snappymail/v/0.0.0/app/libraries/snappymail/integrity.php
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SnappyMail;
|
||||||
|
|
||||||
|
abstract class Integrity
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by https://webmail.tld/?/Test
|
||||||
|
*/
|
||||||
|
public static function test()
|
||||||
|
{
|
||||||
|
$result = static::phpVersion();
|
||||||
|
if ($result) {
|
||||||
|
echo '<p style="color: red">' . $result . '</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = static::phpExtensions();
|
||||||
|
if ($result) {
|
||||||
|
echo '<p>The following PHP extensions are not available in your PHP configuration!</p>';
|
||||||
|
echo '<ul><li>' . \implode('</li>li><li>', $result) . '</li></ul>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$uri = (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST']
|
||||||
|
. \RainLoop\Utils::WebVersionPath();
|
||||||
|
$HTTP = \SnappyMail\HTTP\Request::factory();
|
||||||
|
$files = [
|
||||||
|
// 'static/css/app.css',
|
||||||
|
// 'static/js/libs.js',
|
||||||
|
// 'static/js/app.js',
|
||||||
|
// 'static/js/openpgp.js',
|
||||||
|
'static/css/app.min.css',
|
||||||
|
'static/js/min/libs.min.js',
|
||||||
|
'static/js/min/app.min.js',
|
||||||
|
'static/js/min/openpgp.min.js'
|
||||||
|
];
|
||||||
|
foreach ($files as $file) {
|
||||||
|
echo "<h2>{$uri}{$file}</h2>";
|
||||||
|
$response = $HTTP->doRequest('HEAD', $uri . $file);
|
||||||
|
echo '<details><summary>Status: ' . $response->status . '</summary><pre>' . \print_r($response->headers, 1) . '</pre></details>';
|
||||||
|
$size = \filesize(APP_VERSION_ROOT_PATH.$file);
|
||||||
|
if ($size == intval($response->getHeader('content-length'))) {
|
||||||
|
echo 'content-length matches size ' . $size;
|
||||||
|
} else {
|
||||||
|
echo 'content-length mismatch, should be ' . $size;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
echo "<h3>encoding</h3>";
|
||||||
|
$response = $HTTP->doRequest('GET', $uri . $file, null, ['Accept-Encoding' => 'gzip, deflate, br']);
|
||||||
|
echo '<details><summary>Status: ' . $response->status . '</summary><pre>' . \print_r($response->headers, 1) . '</pre></details>';
|
||||||
|
*/
|
||||||
|
echo "<h3>gzip encoded</h3>";
|
||||||
|
$response = $HTTP->doRequest('HEAD', $uri . $file . '.gz');
|
||||||
|
echo '<details><summary>Status: ' . $response->status . '</summary><pre>' . \print_r($response->headers, 1) . '</pre></details>';
|
||||||
|
$size = \filesize(APP_VERSION_ROOT_PATH.$file . '.gz');
|
||||||
|
if ($size == intval($response->getHeader('content-length'))) {
|
||||||
|
echo 'content-length matches size ' . $size;
|
||||||
|
} else {
|
||||||
|
echo 'content-length mismatch, should be ' . $size;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "<h3>brotli encoded</h3>";
|
||||||
|
$response = $HTTP->doRequest('HEAD', $uri . $file . '.br');
|
||||||
|
echo '<details><summary>Status: ' . $response->status . '</summary><pre>' . \print_r($response->headers, 1) . '</pre></details>';
|
||||||
|
$size = \filesize(APP_VERSION_ROOT_PATH.$file . '.br');
|
||||||
|
if ($size == intval($response->getHeader('content-length'))) {
|
||||||
|
echo 'content-length matches size ' . $size;
|
||||||
|
} else {
|
||||||
|
echo 'content-length mismatch, should be ' . $size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function phpVersion()
|
||||||
|
{
|
||||||
|
if (PHP_VERSION_ID < 70400) {
|
||||||
|
return 'Your PHP version ('.PHP_VERSION.') is lower than the minimal required 7.4.0!';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function phpExtensions()
|
||||||
|
{
|
||||||
|
$aRequirements = array(
|
||||||
|
'mbstring' => extension_loaded('mbstring'),
|
||||||
|
'Zlib' => extension_loaded('zlib'),
|
||||||
|
// enabled by default:
|
||||||
|
'ctype' => extension_loaded('ctype'),
|
||||||
|
'json' => function_exists('json_decode'),
|
||||||
|
'libxml' => function_exists('libxml_use_internal_errors'),
|
||||||
|
'dom' => class_exists('DOMDocument')
|
||||||
|
// https://github.com/the-djmaze/snappymail/issues/392
|
||||||
|
// 'phar' => class_exists('PharData')
|
||||||
|
);
|
||||||
|
|
||||||
|
$aMissing = [];
|
||||||
|
if (in_array(false, $aRequirements)) {
|
||||||
|
foreach ($aRequirements as $sKey => $bValue) {
|
||||||
|
if (!$bValue) {
|
||||||
|
$aMissing[] = $sKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $aMissing;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,56 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (PHP_VERSION_ID < 70400) {
|
require_once __DIR__ . 'app/libraries/snappymail/integrity.php';
|
||||||
echo '<p style="color: red">';
|
|
||||||
echo '[301] Your PHP version ('.PHP_VERSION.') is lower than the minimal required 7.4.0!';
|
$result = \SnappyMail\Integrity::phpVersion();
|
||||||
echo '</p>';
|
if ($result) {
|
||||||
|
echo '<p style="color: red">[301] ' . $result . '</p>';
|
||||||
exit(301);
|
exit(301);
|
||||||
}
|
}
|
||||||
|
|
||||||
$aOptional = array(
|
$result = \SnappyMail\Integrity::phpExtensions();
|
||||||
'cURL' => extension_loaded('curl'),
|
if ($result) {
|
||||||
'exif' => extension_loaded('exif'),
|
|
||||||
'finfo' => class_exists('finfo'),
|
|
||||||
'gd' => extension_loaded('gd'),
|
|
||||||
'gnupg' => extension_loaded('gnupg'),
|
|
||||||
'gmagick' => extension_loaded('gmagick'),
|
|
||||||
'imagick' => extension_loaded('imagick'),
|
|
||||||
'iconv' => function_exists('iconv'),
|
|
||||||
'intl' => function_exists('idn_to_ascii'),
|
|
||||||
'ldap' => extension_loaded('ldap'),
|
|
||||||
'OpenSSL' => extension_loaded('openssl'),
|
|
||||||
'mysql' => extension_loaded('pdo_mysql'),
|
|
||||||
'pgsql' => extension_loaded('pdo_pgsql'),
|
|
||||||
'redis' => extension_loaded('redis'),
|
|
||||||
'Sodium' => extension_loaded('sodium'),
|
|
||||||
'sqlite' => extension_loaded('pdo_sqlite'),
|
|
||||||
'tidy' => extension_loaded('tidy'),
|
|
||||||
'uuid' => extension_loaded('uuid'),
|
|
||||||
'xxtea' => extension_loaded('xxtea'),
|
|
||||||
'zip' => extension_loaded('zip')
|
|
||||||
);
|
|
||||||
|
|
||||||
$aRequirements = array(
|
|
||||||
'mbstring' => extension_loaded('mbstring'),
|
|
||||||
'Zlib' => extension_loaded('zlib'),
|
|
||||||
// enabled by default:
|
|
||||||
'ctype' => extension_loaded('ctype'),
|
|
||||||
'json' => function_exists('json_decode'),
|
|
||||||
'libxml' => function_exists('libxml_use_internal_errors'),
|
|
||||||
'dom' => class_exists('DOMDocument')
|
|
||||||
// https://github.com/the-djmaze/snappymail/issues/392
|
|
||||||
// 'phar' => class_exists('PharData')
|
|
||||||
);
|
|
||||||
|
|
||||||
if (in_array(false, $aRequirements)) {
|
|
||||||
echo '<p>[302] The following PHP extensions are not available in your PHP configuration!</p>';
|
echo '<p>[302] The following PHP extensions are not available in your PHP configuration!</p>';
|
||||||
echo '<ul>';
|
echo '<ul><li>' . \implode('</li>li><li>', $result) . '</li></ul>';
|
||||||
foreach ($aRequirements as $sKey => $bValue) {
|
|
||||||
if (!$bValue) {
|
|
||||||
echo '<li>'.$sKey.'</li>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
echo '</ul>';
|
|
||||||
exit(302);
|
exit(302);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue