这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions server-php/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CheckMyHTTPS API server Changelog

## 1.5.2 - 2024-01-24
- Add the possibility to handle POST requests
- Delete the dependance to composer

## 1.5.1 - 2022-01-27
- Add the possibility to specify an IP in the query

Expand Down
5 changes: 3 additions & 2 deletions server-php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ RUN chown www-data:www-data /var/tmp/cmh_cache/

COPY ./www /var/www/cmh_api/

COPY ./vendor-static.tar.gz /tmp/
RUN tar -xzf /tmp/vendor-static.tar.gz -C /var/www/cmh_api/ && rm -f /tmp/vendor.tar.gz
RUN apt-get update && apt-get install -y \
libicu-dev \
&& docker-php-ext-install intl
5 changes: 2 additions & 3 deletions server-php/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

**REQUIRMENTS**

* You need an HTTPS server with PHP and php-filter module
* You need an HTTPS server with PHP, the PHP class Normalizer (php-intl) and php-filter module
* You also need a TMPFS partition for the cache. Here is the process (Linux):
1. Add your administrator user to the group of your server. Example with an Apache server: `[root]# usermod -a -G apache administrator`
2. Change the gid of the administrator (valid during this session only): `[administrator]$ newgrp apache`
Expand All @@ -31,8 +31,7 @@ The cache is enabled by default, but you can turn it off by setting the variable
**INSTALLATION**

1. Copy the content of the `www` folder to your webroot.
2. Install dependencies with composer: `composer install` inside your webroot (else you can extract `vendor-static.tar.gz`).
3. Then configure your clients to use your own check server.
2. Then configure your clients to use your own check server.


### Scripted installation
Expand Down
17 changes: 0 additions & 17 deletions server-php/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,4 @@ if [ -n "$TMPDIR" ]; then
fi


(

cd $OUT;
COM=composer
composer || {
echo "installing composer"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
COM='php composer.phar'

}
echo "Installing composer deps"
$COM install
)

echo "All done"
Binary file removed server-php/vendor-static.tar.gz
Binary file not shown.
23 changes: 19 additions & 4 deletions server-php/www/api.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

include __DIR__ . '/vendor/autoload.php';

include __DIR__ . '/config.php';

define('INSTANCE_TITLE', 'CheckMyHTTPS API server');
Expand Down Expand Up @@ -57,6 +55,10 @@
if (isset($_GET['port'])) $request_port = $_GET['port'];
if (isset($_GET['ip'])) $request_ip = $_GET['ip'];

//error_log("AFFICHAGE DES VALEURS");
//error_log("Valeur host" . print_r($request_host, true) );
//error_log("Valeur ip" . print_r($request_ip, true) );


// Service requested by the user
$service = (object) [
Expand All @@ -68,7 +70,7 @@
// Parse host:port from URL
if ((isset($request_url)) && (!isset($request_host) && !isset($request_port)))
{
if ((!filter_var($request_url, FILTER_VALIDATE_URL)) && (!filter_var((new \Mso\IdnaConvert\IdnaConvert)->encode($request_url), FILTER_VALIDATE_URL)))
if ((!filter_var($request_url, FILTER_VALIDATE_URL)) && (!filter_var(unicodeToPunycode($request_url), FILTER_VALIDATE_URL)))
{
echo json_encode(hashAndEncrypt((object)['error' => 'INVALID_URL'], $sign));
exit();
Expand Down Expand Up @@ -100,7 +102,7 @@
else
{
// Convert IDNA 2008
$request_host = (new \Mso\IdnaConvert\IdnaConvert)->encode($request_host);
$request_host = unicodeToPunycode($request_host);

if (preg_match('/^[a-zA-Z0-9-_.]+$/', $request_host))
$service->host = $request_host;
Expand Down Expand Up @@ -449,4 +451,17 @@ function checkHostWhitelisted($host)
}
return false;
}

function unicodeToPunycode($input) {
$normalized = \Normalizer::normalize($input, \Normalizer::FORM_C);
$punycode = idn_to_ascii($normalized, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46);
return $punycode;
}

function punycodeToUnicode($input) {
$unicode = idn_to_utf8($input, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46);
$normalized = \Normalizer::normalize($unicode, \Normalizer::FORM_C);
return $normalized;
}

?>
7 changes: 0 additions & 7 deletions server-php/www/composer.json

This file was deleted.

68 changes: 0 additions & 68 deletions server-php/www/composer.lock

This file was deleted.