Subversion Repositories oidplus

Compare Revisions

Regard whitespace Rev 1468 → Rev 1469

/trunk/includes/classes/OIDplusAuthUtils.class.php
276,10 → 276,10
} else if (strpos($passwordData, '$') !== false) {
// Version 2: SHA3-512 with salt
list($salt, $hash) = explode('$', $passwordData, 2);
$ok = hash_equals(sha3_512($salt.$password, true), base64_decode($hash));
$ok = hash_equals(base64_decode($hash), sha3_512($salt.$password, true));
} else {
// Version 1: SHA3-512 without salt
$ok = hash_equals(sha3_512($password, true), base64_decode($passwordData));
$ok = hash_equals(base64_decode($passwordData), sha3_512($password, true));
}
if ($ok) return true;
}
/trunk/plugins/viathinksoft/adminPages/902_systemfile_check/checksums.json
Cannot display: file marked as a binary type.
svn:mime-type = application/json
/trunk/vendor/cacert.pem
1,7 → 1,7
##
## Bundle of CA Root Certificates
##
## Certificate data from Mozilla as of: Tue Dec 12 04:12:04 2023 GMT
## Certificate data from Mozilla as of: Mon Mar 11 15:25:27 2024 GMT
##
## This is a bundle of X.509 certificates of public Certificate Authorities
## (CA). These were automatically extracted from Mozilla's root certificates
14,7 → 14,7
## Just configure this file as the SSLCACertificateFile.
##
## Conversion done with mk-ca-bundle.pl version 1.29.
## SHA256: 1970dd65858925d68498d2356aea6d03f764422523c5887deca8ce3ba9e1f845
## SHA256: 4d96bd539f4719e9ace493757afbe4a23ee8579de1c97fbebc50bba3c12e8c1e
##
 
 
3532,3 → 3532,50
iRM9HcEARwmWmjgb3bHPDcK0RPOWlc4yOo80nOAXx17Org3bhzjlP1v9mxnhMUF6cKojawHhRUzN
lM47ni3niAIi9G7oyOzWPPO5std3eqx7
-----END CERTIFICATE-----
 
Telekom Security TLS ECC Root 2020
==================================
-----BEGIN CERTIFICATE-----
MIICQjCCAcmgAwIBAgIQNjqWjMlcsljN0AFdxeVXADAKBggqhkjOPQQDAzBjMQswCQYDVQQGEwJE
RTEnMCUGA1UECgweRGV1dHNjaGUgVGVsZWtvbSBTZWN1cml0eSBHbWJIMSswKQYDVQQDDCJUZWxl
a29tIFNlY3VyaXR5IFRMUyBFQ0MgUm9vdCAyMDIwMB4XDTIwMDgyNTA3NDgyMFoXDTQ1MDgyNTIz
NTk1OVowYzELMAkGA1UEBhMCREUxJzAlBgNVBAoMHkRldXRzY2hlIFRlbGVrb20gU2VjdXJpdHkg
R21iSDErMCkGA1UEAwwiVGVsZWtvbSBTZWN1cml0eSBUTFMgRUNDIFJvb3QgMjAyMDB2MBAGByqG
SM49AgEGBSuBBAAiA2IABM6//leov9Wq9xCazbzREaK9Z0LMkOsVGJDZos0MKiXrPk/OtdKPD/M1
2kOLAoC+b1EkHQ9rK8qfwm9QMuU3ILYg/4gND21Ju9sGpIeQkpT0CdDPf8iAC8GXs7s1J8nCG6NC
MEAwHQYDVR0OBBYEFONyzG6VmUex5rNhTNHLq+O6zd6fMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P
AQH/BAQDAgEGMAoGCCqGSM49BAMDA2cAMGQCMHVSi7ekEE+uShCLsoRbQuHmKjYC2qBuGT8lv9pZ
Mo7k+5Dck2TOrbRBR2Diz6fLHgIwN0GMZt9Ba9aDAEH9L1r3ULRn0SyocddDypwnJJGDSA3PzfdU
ga/sf+Rn27iQ7t0l
-----END CERTIFICATE-----
 
Telekom Security TLS RSA Root 2023
==================================
-----BEGIN CERTIFICATE-----
MIIFszCCA5ugAwIBAgIQIZxULej27HF3+k7ow3BXlzANBgkqhkiG9w0BAQwFADBjMQswCQYDVQQG
EwJERTEnMCUGA1UECgweRGV1dHNjaGUgVGVsZWtvbSBTZWN1cml0eSBHbWJIMSswKQYDVQQDDCJU
ZWxla29tIFNlY3VyaXR5IFRMUyBSU0EgUm9vdCAyMDIzMB4XDTIzMDMyODEyMTY0NVoXDTQ4MDMy
NzIzNTk1OVowYzELMAkGA1UEBhMCREUxJzAlBgNVBAoMHkRldXRzY2hlIFRlbGVrb20gU2VjdXJp
dHkgR21iSDErMCkGA1UEAwwiVGVsZWtvbSBTZWN1cml0eSBUTFMgUlNBIFJvb3QgMjAyMzCCAiIw
DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAO01oYGA88tKaVvC+1GDrib94W7zgRJ9cUD/h3VC
KSHtgVIs3xLBGYSJwb3FKNXVS2xE1kzbB5ZKVXrKNoIENqil/Cf2SfHVcp6R+SPWcHu79ZvB7JPP
GeplfohwoHP89v+1VmLhc2o0mD6CuKyVU/QBoCcHcqMAU6DksquDOFczJZSfvkgdmOGjup5czQRx
UX11eKvzWarE4GC+j4NSuHUaQTXtvPM6Y+mpFEXX5lLRbtLevOP1Czvm4MS9Q2QTps70mDdsipWo
l8hHD/BeEIvnHRz+sTugBTNoBUGCwQMrAcjnj02r6LX2zWtEtefdi+zqJbQAIldNsLGyMcEWzv/9
FIS3R/qy8XDe24tsNlikfLMR0cN3f1+2JeANxdKz+bi4d9s3cXFH42AYTyS2dTd4uaNir73Jco4v
zLuu2+QVUhkHM/tqty1LkCiCc/4YizWN26cEar7qwU02OxY2kTLvtkCJkUPg8qKrBC7m8kwOFjQg
rIfBLX7JZkcXFBGk8/ehJImr2BrIoVyxo/eMbcgByU/J7MT8rFEz0ciD0cmfHdRHNCk+y7AO+oML
KFjlKdw/fKifybYKu6boRhYPluV75Gp6SG12mAWl3G0eQh5C2hrgUve1g8Aae3g1LDj1H/1Joy7S
WWO/gLCMk3PLNaaZlSJhZQNg+y+TS/qanIA7AgMBAAGjYzBhMA4GA1UdDwEB/wQEAwIBBjAdBgNV
HQ4EFgQUtqeXgj10hZv3PJ+TmpV5dVKMbUcwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBS2
p5eCPXSFm/c8n5OalXl1UoxtRzANBgkqhkiG9w0BAQwFAAOCAgEAqMxhpr51nhVQpGv7qHBFfLp+
sVr8WyP6Cnf4mHGCDG3gXkaqk/QeoMPhk9tLrbKmXauw1GLLXrtm9S3ul0A8Yute1hTWjOKWi0Fp
kzXmuZlrYrShF2Y0pmtjxrlO8iLpWA1WQdH6DErwM807u20hOq6OcrXDSvvpfeWxm4bu4uB9tPcy
/SKE8YXJN3nptT+/XOR0so8RYgDdGGah2XsjX/GO1WfoVNpbOms2b/mBsTNHM3dA+VKq3dSDz4V4
mZqTuXNnQkYRIer+CqkbGmVps4+uFrb2S1ayLfmlyOw7YqPta9BO1UAJpB+Y1zqlklkg5LB9zVtz
aL1txKITDmcZuI1CfmwMmm6gJC3VRRvcxAIU/oVbZZfKTpBQCHpCNfnqwmbU+AGuHrS+w6jv/naa
oqYfRvaE7fzbzsQCzndILIyy7MMAo+wsVRjBfhnu4S/yrYObnqsZ38aKL4x35bcF7DvB7L6Gs4a8
wPfc5+pbrrLMtTWGS9DiP7bY+A4A7l3j941Y/8+LN+ljX273CXE2whJdV/LItM3z7gLfEdxquVeE
HVlNjM7IDiPCtyaaEBRx/pOyiriA8A4QntOoUAw3gi/q4Iqd4Sw5/7W0cwDk90imc6y/st53BIe0
o82bNSQ3+pCTE4FCxpgmdTdmQRCsu/WU48IxK63nI1bMNSWSs1A=
-----END CERTIFICATE-----
/trunk/vendor/composer/installed.json
350,12 → 350,12
"source": {
"type": "git",
"url": "https://github.com/danielmarschall/php_utils.git",
"reference": "72ab7919215ff4d377c3b489f170d150c1a0a240"
"reference": "3f42fc2c9ad7fef67dad4917c454e6799d0fd274"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/danielmarschall/php_utils/zipball/72ab7919215ff4d377c3b489f170d150c1a0a240",
"reference": "72ab7919215ff4d377c3b489f170d150c1a0a240",
"url": "https://api.github.com/repos/danielmarschall/php_utils/zipball/3f42fc2c9ad7fef67dad4917c454e6799d0fd274",
"reference": "3f42fc2c9ad7fef67dad4917c454e6799d0fd274",
"shasum": ""
},
"require": {
362,7 → 362,7
"ext-zlib": "*",
"php": ">=7.0"
},
"time": "2024-02-05T01:31:39+00:00",
"time": "2024-03-13T17:00:11+00:00",
"default-branch": true,
"type": "library",
"installation-source": "dist",
392,18 → 392,18
"source": {
"type": "git",
"url": "https://github.com/danielmarschall/uuid_mac_utils.git",
"reference": "e632024d5a60b0b038c321f23569607ea0897908"
"reference": "4936898473ce09a5fd06e47d33c582365d0c3b38"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/danielmarschall/uuid_mac_utils/zipball/e632024d5a60b0b038c321f23569607ea0897908",
"reference": "e632024d5a60b0b038c321f23569607ea0897908",
"url": "https://api.github.com/repos/danielmarschall/uuid_mac_utils/zipball/4936898473ce09a5fd06e47d33c582365d0c3b38",
"reference": "4936898473ce09a5fd06e47d33c582365d0c3b38",
"shasum": ""
},
"require": {
"php": ">=7.0"
},
"time": "2023-11-18T19:46:37+00:00",
"time": "2024-03-09T20:36:07+00:00",
"default-branch": true,
"type": "library",
"installation-source": "dist",
579,17 → 579,17
},
{
"name": "matthiasmullie/minify",
"version": "1.3.71",
"version_normalized": "1.3.71.0",
"version": "1.3.72",
"version_normalized": "1.3.72.0",
"source": {
"type": "git",
"url": "https://github.com/matthiasmullie/minify.git",
"reference": "ae42a47d7fecc1fbb7277b2f2d84c37a33edc3b1"
"reference": "531fdeef1911ffe27a53f8a19c297648c78f757e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/matthiasmullie/minify/zipball/ae42a47d7fecc1fbb7277b2f2d84c37a33edc3b1",
"reference": "ae42a47d7fecc1fbb7277b2f2d84c37a33edc3b1",
"url": "https://api.github.com/repos/matthiasmullie/minify/zipball/531fdeef1911ffe27a53f8a19c297648c78f757e",
"reference": "531fdeef1911ffe27a53f8a19c297648c78f757e",
"shasum": ""
},
"require": {
606,7 → 606,7
"suggest": {
"psr/cache-implementation": "Cache implementation to use with Minify::cache"
},
"time": "2023-04-25T20:33:03+00:00",
"time": "2024-03-13T12:02:00+00:00",
"bin": [
"bin/minifycss",
"bin/minifyjs"
641,7 → 641,7
],
"support": {
"issues": "https://github.com/matthiasmullie/minify/issues",
"source": "https://github.com/matthiasmullie/minify/tree/1.3.71"
"source": "https://github.com/matthiasmullie/minify/tree/1.3.72"
},
"funding": [
{
/trunk/vendor/composer/installed.php
84,7 → 84,7
'danielmarschall/php_utils' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '72ab7919215ff4d377c3b489f170d150c1a0a240',
'reference' => '3f42fc2c9ad7fef67dad4917c454e6799d0fd274',
'type' => 'library',
'install_path' => __DIR__ . '/../danielmarschall/php_utils',
'aliases' => array(
95,7 → 95,7
'danielmarschall/uuid_mac_utils' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => 'e632024d5a60b0b038c321f23569607ea0897908',
'reference' => '4936898473ce09a5fd06e47d33c582365d0c3b38',
'type' => 'library',
'install_path' => __DIR__ . '/../danielmarschall/uuid_mac_utils',
'aliases' => array(
151,9 → 151,9
'dev_requirement' => false,
),
'matthiasmullie/minify' => array(
'pretty_version' => '1.3.71',
'version' => '1.3.71.0',
'reference' => 'ae42a47d7fecc1fbb7277b2f2d84c37a33edc3b1',
'pretty_version' => '1.3.72',
'version' => '1.3.72.0',
'reference' => '531fdeef1911ffe27a53f8a19c297648c78f757e',
'type' => 'library',
'install_path' => __DIR__ . '/../matthiasmullie/minify',
'aliases' => array(),
/trunk/vendor/danielmarschall/php_utils/decode_jwt_token.inc.php
58,7 → 58,7
case 'HS':
$hash = @hash_hmac($php_algo, $msg, $key, true);
if (!$hash) break; // if the hash algo is not available, we just accept the JWT
if (!hash_equals($signature, $hash)) return false;
if (!hash_equals($hash, $signature)) return false;
break;
case 'PS':
// This feature is new and not yet available in php-jwt
/trunk/vendor/danielmarschall/php_utils/vts_crypt.inc.php
228,10 → 228,10
// Create a VTS MCF 1.0 hash based on the parameters of $hash and the password $password
$calc_authkey_1 = vts_crypt_hash($algo, $password, $bin_salt, $ver, $mode, $iterations);
 
// We rewrite the MCF to make sure that they match (if params have the wrong order)
// We re-encode the MCF to make sure that it can be compared with the VTS MCF 1.0 (correct sorting of params etc.)
$calc_authkey_2 = crypt_modular_format_encode($id, $bin_salt, $bin_hash, $params);
 
return hash_equals($calc_authkey_1, $calc_authkey_2);
return hash_equals($calc_authkey_2, $calc_authkey_1);
} else {
throw new Exception("Invalid VTS crypt version, expect 1.");
}
/trunk/vendor/danielmarschall/uuid_mac_utils/includes/uuid_utils.inc.php
2,8 → 2,8
 
/*
* UUID utils for PHP
* Copyright 2011 - 2023 Daniel Marschall, ViaThinkSoft
* Version 2023-11-18
* Copyright 2011 - 2024 Daniel Marschall, ViaThinkSoft
* Version 2024-03-09
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
833,6 → 833,102
break;
}
 
// START: HickelSOFT UUID
 
// Block 5
$signature = substr($uuid,20,12);
if (strtolower($signature) == '5ce32bd83b96') {
// HickelSOFT "SQL Server sortable UUID in C#"
// Version 2: Resolution of 1 milliseconds, random part of 18 bits, UTC time, UUIDv8 conform.
// Example: 2088dc33-000d-8045-87e8-5ce32bd83b96
// Block 4
$unused2bits = hexdec(substr($uuid,16,1)) & 0x3;
$year = hexdec(substr($uuid,17,3));
// Block 3
$dayOfYear = hexdec(substr($uuid,13,3)); // 1..366
$day = (($dayOfYear < 1) || ($dayOfYear > 366)) ? "XX" : intval(getDateFromDay($year, $dayOfYear)->format('d'));
$month = (($dayOfYear < 1) || ($dayOfYear > 366)) ? "XX" : intval(getDateFromDay($year, $dayOfYear)->format('m'));
// Block 2
$minuteOfDay = hexdec(substr($uuid,8,4)); // 1..1440
$minutes = (($minuteOfDay < 1) || ($minuteOfDay > 1440)) ? "XX" : ($minuteOfDay-1) % 60;
$hours = (($minuteOfDay < 1) || ($minuteOfDay > 1440)) ? "XX" : (int)floor(($minuteOfDay-1) / 60);
// Block 1
$rnd16bits = substr($uuid,0,4);
$millisecond8bits = hexdec(substr($uuid,4,2));
$milliseconds = round($millisecond8bits / 255 * 999);
$seconds = hexdec(substr($uuid,6,2));
// Verbose info
$utc_time =
str_pad("$year",4,'0',STR_PAD_LEFT).'-'.
str_pad("$month",2,'0',STR_PAD_LEFT).'-'.
str_pad("$day",2,'0',STR_PAD_LEFT).' '.
str_pad("$hours",2,'0',STR_PAD_LEFT).':'.
str_pad("$minutes",2,'0',STR_PAD_LEFT).':'.
str_pad("$seconds",2,'0',STR_PAD_LEFT)."'".
str_pad("$milliseconds",2,'0',STR_PAD_LEFT);
if (strpos($utc_time,'X') === false) {
$deviation = "(deviation -2ms..2ms)";
echo "\n<u>Interpretation of <a href=\"https://gist.github.com/danielmarschall/7fafd270a3bc107d38e8449ce7420c25\">HickelSOFT \"SQL Server Sortable Custom UUID\", Version 2</a></u>\n\n";
echo sprintf("%-32s %s\n", "Random 16 bits:", "[0x$rnd16bits] 0b".str_pad("".base_convert($rnd16bits, 16, 2), 16, '0', STR_PAD_LEFT));
echo sprintf("%-32s %s\n", "Milliseconds:", "[0x".substr($uuid,4,2)."] $milliseconds $deviation");
echo sprintf("%-32s %s\n", "Seconds:", "[0x".substr($uuid,6,2)."] $seconds");
echo sprintf("%-32s %s\n", "Minute of day:", "[0x".substr($uuid,8,4)."] $minuteOfDay (".str_pad("$hours",2,'0',STR_PAD_LEFT).":".str_pad("$minutes",2,'0',STR_PAD_LEFT).")");
echo sprintf("%-32s %s\n", "Day of year:", "[0x".substr($uuid,13,3)."] $dayOfYear (Day=$day, Month=$month)");
echo sprintf("%-32s %s\n", "Unused 2 bits:", "[$unused2bits] 0b".str_pad("".base_convert("$unused2bits", 16, 2), 2, '0', STR_PAD_LEFT));
echo sprintf("%-32s %s\n", "Year:", "[0x".substr($uuid,17,3)."] $year");
echo sprintf("%-32s %s\n", "Signature:", "[0x".substr($uuid,20,12)."] HickelSOFT \"SQL Server Sortable Custom UUID\", Version 2 (very likely)");
echo sprintf("%-32s %s\n", "UTC Date Time:", "$utc_time $deviation");
}
} else if (strtolower($signature) == '000000000000') {
// HickelSOFT "SQL Server sortable UUID in C#"
// Version 1: Resolution of 1 milliseconds, random part of 16 bits, local timezone, NOT UUIDv8 conform.
// Example: ff38da51-1301-0903-2420-000000000000
// Block 4
$year = substr($uuid,18,2) . substr($uuid,16,2);
$year = (!is_numeric($year) || ($year < 2000) || ($year > 2999)) ? "XXXX" : $year = intval($year);
// Block 3
$day = substr($uuid,12,2);
$day = (!is_numeric($day) || ($day < 0) || ($day >= 60)) ? "XX" : intval($day);
$month = substr($uuid,14,2);
$month = (!is_numeric($month) || ($month < 0) || ($month >= 60)) ? "XX" : intval($month);
// Block 2
$minutes = substr($uuid,8,2);
$minutes = (!is_numeric($minutes) || ($minutes < 0) || ($minutes >= 60)) ? "XX" : intval($minutes);
$hours = substr($uuid,10,2);
$hours = (!is_numeric($hours) || ($hours < 0) || ($hours >= 60)) ? "XX" : intval($hours);
// Block 1
$rnd16bits = substr($uuid,0,4);
$millisecond8bits = hexdec(substr($uuid,4,2));
$milliseconds = round($millisecond8bits / 255 * 999);
$seconds = substr($uuid,6,2);
$seconds = (!is_numeric($seconds) || ($seconds < 0) || ($seconds >= 60)) ? "XX" : intval($seconds);
// Verbose info
$local_time =
str_pad("$year",4,'0',STR_PAD_LEFT).'-'.
str_pad("$month",2,'0',STR_PAD_LEFT).'-'.
str_pad("$day",2,'0',STR_PAD_LEFT).' '.
str_pad("$hours",2,'0',STR_PAD_LEFT).':'.
str_pad("$minutes",2,'0',STR_PAD_LEFT).':'.
str_pad("$seconds",2,'0',STR_PAD_LEFT)."'".
str_pad("$milliseconds",2,'0',STR_PAD_LEFT);
if (strpos($local_time,'X') === false) {
$deviation = "(deviation -4ms..0ms)";
echo "\n<u>Interpretation of <a href=\"https://gist.github.com/danielmarschall/7fafd270a3bc107d38e8449ce7420c25\">HickelSOFT \"SQL Server Sortable Custom UUID\", Version 1</a></u>\n\n";
echo sprintf("%-32s %s\n", "Random 16 bits:", "[0x$rnd16bits] 0b".str_pad(base_convert($rnd16bits, 16, 2), 16, '0', STR_PAD_LEFT));
echo sprintf("%-32s %s\n", "Milliseconds:", "[0x".substr($uuid,4,2)."] $milliseconds $deviation");
echo sprintf("%-32s %s\n", "Seconds:", "[0x".substr($uuid,6,2)."] $seconds");
echo sprintf("%-32s %s\n", "Minutes:", "[0x".substr($uuid,8,2)."] $minutes");
echo sprintf("%-32s %s\n", "Hours:", "[0x".substr($uuid,10,2)."] $hours");
echo sprintf("%-32s %s\n", "Day:", "[0x".substr($uuid,12,2)."] $day");
echo sprintf("%-32s %s\n", "Month:", "[0x".substr($uuid,14,2)."] $month");
echo sprintf("%-32s %s\n", "Year:", "[0x".substr($uuid,16,4)."] $year");
echo sprintf("%-32s %s\n", "Signature:", "[0x".substr($uuid,20,12)."] HickelSOFT \"SQL Server Sortable Custom UUID\", Version 1 (maybe)");
echo sprintf("%-32s %s\n", "Generator's Local Date Time:", "$local_time $deviation");
}
}
 
// END: HickelSOFT UUID
 
if (!$echo) {
$out = ob_get_contents();
ob_end_clean();
871,13 → 967,13
} else if ((count($ary) == 14) && (strpos($oid, '1.2.840.113556.1.8000.2554.') === 0)) {
// Microsoft UUID-to-OID
// Example: {53c08bb6-b2eb-5038-bf28-ad41a08c50ef} = 1.2.840.113556.1.8000.2554.21440.35766.45803.20536.48936.11354528.9195759
$a = $ary[7];
$b = $ary[8];
$c = $ary[9];
$d = $ary[10];
$e = $ary[11];
$f = $ary[12];
$g = $ary[13];
$a = intval($ary[7]);
$b = intval($ary[8]);
$c = intval($ary[9]);
$d = intval($ary[10]);
$e = intval($ary[11]);
$f = intval($ary[12]);
$g = intval($ary[13]);
return dechex($a).dechex($b).'-'.dechex($c).'-'.dechex($d).'-'.dechex($e).'-'.dechex($f).dechex($g);
} else if ((count($ary) == 10) && (strpos($oid, '1.3.6.1.4.1.54392.1.') === 0)) {
// Waterjuice UUID-to-OID 2x64 Bits
1454,6 → 1550,77
substr($hash, 20, 12);
}
 
/**
* The sorting of SQL Server is rather confusing and incompatible with UUIDv6 and UUIDv7.
* Therefore this method generates UUID which are sortable by SQL Server.
* Version 1: Resolution of 1 milliseconds, random part of 16 bits, local timezone, 48 zero bits "signature", NOT UUIDv8 conform.
* Version 2: Resolution of 1 milliseconds, random part of 16 bits, UTC time, 48 bit random "signature", UUIDv8 conform.
* C# implementation: https://gist.github.com/danielmarschall/7fafd270a3bc107d38e8449ce7420c25
* PHP implementation: https://github.com/danielmarschall/uuid_mac_utils/blob/master/includes/uuid_utils.inc.php
*
* @param int $hickelUuidVersion (optional)
* @param DateTime $dt (optional)
* @return string The UUID
*/
function gen_uuid_v8_sqlserver_sortable(int $hickelUuidVersion = 2, DateTime $dt = null): string {
// The sorting in SQL Server is like this:
 
if ($dt == null) $dt = new DateTime();
 
// First Sort block 5, nibbles from left to right (i.e. 000000000001 < 000000000010 < ... < 010000000000 < 100000000000)
if ($hickelUuidVersion == 1) {
$block5 = "000000000000";
} else if ($hickelUuidVersion == 2) {
$block5 = "5ce32bd83b96";
} else {
throw new Exception("Invalid version");
}
 
// Then: Sort block 4, nibbles from left to right
if ($hickelUuidVersion == 1) {
$year = $dt->format('Y');
$block4 = substr($year, 2, 2).substr($year, 0, 2); // Example: 0x2420 = 2024
} else {
$variant = 0x8; // First nibble needs to be 0b10_ (0x8-0xB) for "RFC 4122bis". We use it to store 2 more random bits.
$unused2bits = 0; // Cannot be used for random, because it would affect the sorting
$year = $dt->format('Y');
$block4 = sprintf('%01x%03x', $variant + ($unused2bits & 0x3), $year);
}
 
// Then: Sort block 3, bytes from right to left (i.e. 0100 < 1000 < 0001 < 0010)
if ($hickelUuidVersion == 1) {
$block3 = $dt->format('dm');
} else {
$uuidVersion = 8; // First nibble needs to be "8" for "UUIDv8 = Custom UUID"
$dayOfYear = intval($dt->format('z')) + 1; /* 1..366 */
$block3 = sprintf('%01x%03x', $uuidVersion, $dayOfYear);
}
 
// Then: Sort block 2, bytes from right to left
if ($hickelUuidVersion == 1) {
$block2 = $dt->format('ih');
} else {
$minuteOfDay = (intval($dt->format('i')) + intval($dt->format('h')) * 60) + 1; // 1..1440
$block2 = sprintf('%04x', $minuteOfDay);
}
 
// Then: Sort block 1, bytes from right to left
if ($hickelUuidVersion == 1) {
$millisecond8bits = ceil(($dt->format('v') / 999) * 255); // deviation -4ms..0ms
$rnd16bits = _random_int(0x0000, 0xFFFF-1);
$block1 = sprintf('%04x%02x', $rnd16bits, $millisecond8bits).$dt->format('s');
} else {
$millisecond8bits = round(($dt->format('v') / 999) * 255); // deviation -2ms..2ms
$rnd16bits = _random_int(0x0000, 0xFFFF);
$block1 = sprintf('%04x%02x%02x', $rnd16bits, $millisecond8bits, $dt->format('s'));
}
 
$sleep_ms = (int)ceil(999 / 255); // Make sure that "millisecond" is not repeated on this system
if (time_nanosleep(0,$sleep_ms*1000*1000) !== true) usleep($sleep_ms*1000);
 
return strtolower("$block1-$block2-$block3-$block4-$block5");
}
 
# --------------------------------------
 
// http://php.net/manual/de/function.hex2bin.php#113057
1496,3 → 1663,16
$bin = $sponge->squeeze($outputLength);
return $binary ? $bin : bin2hex($bin);
}
 
/**
* Converts the day of year of a year into a DateTime object
* @param int $year The year
* @param int $dayOfYear The day of year (value 1 till 365 or 1 till 366 for leap years)
* @return \DateTime The resulting date
*/
function getDateFromDay(int $year, int $dayOfYear): \DateTime {
// Note: "Y z" and "z Y" make a difference for leap years (last tested with PHP 8.0.3)
$date = \DateTime::createFromFormat('Y z', strval($year) . ' ' . strval($dayOfYear-1));
return $date;
}
 
/trunk/vendor/licenses
14,10 → 14,10
danielmarschall/oidconverter dev-master cd036ff Apache-2.0
danielmarschall/php-sha3 9999999-dev 5605bd5 MIT
danielmarschall/php-sha3 dev-master 5605bd5 MIT
danielmarschall/php_utils 9999999-dev 72ab791 Apache-2.0
danielmarschall/php_utils dev-master 72ab791 Apache-2.0
danielmarschall/uuid_mac_utils 9999999-dev e632024 Apache-2.0
danielmarschall/uuid_mac_utils dev-master e632024 Apache-2.0
danielmarschall/php_utils 9999999-dev 3f42fc2 Apache-2.0
danielmarschall/php_utils dev-master 3f42fc2 Apache-2.0
danielmarschall/uuid_mac_utils 9999999-dev 4936898 Apache-2.0
danielmarschall/uuid_mac_utils dev-master 4936898 Apache-2.0
danielmarschall/vnag 9999999-dev ba9c0ed Apache-2.0
danielmarschall/vnag dev-master ba9c0ed Apache-2.0
dcodeio/bcrypt.js master master BSD-3-Clause, MIT
24,7 → 24,7
emn178/js-sha3 master master MIT
firebase/php-jwt v5.5.1 BSD-3-Clause
gedmarc/layout master master GPL-3.0-or-later, MIT
matthiasmullie/minify 1.3.71 MIT
matthiasmullie/minify 1.3.72 MIT
matthiasmullie/path-converter 1.1.3 MIT
paragonie/constant_time_encoding v2.6.3 MIT
paragonie/random_compat v9.99.100 MIT
/trunk/vendor/matthiasmullie/minify/src/CSS.php
106,8 → 106,8
/**
* Combine CSS from import statements.
*
* Import statements will be loaded and their content merged into the original
* file, to save HTTP requests.
* \@import's will be loaded and their content merged into the original file,
* to save HTTP requests.
*
* @param string $source The file to combine imports for
* @param string $content The CSS content to combine imports for
316,7 → 316,9
$css = $this->replace($css);
 
$css = $this->stripWhitespace($css);
$css = $this->shortenColors($css);
$css = $this->convertLegacyColors($css);
$css = $this->cleanupModernColors($css);
$css = $this->shortenHEXColors($css);
$css = $this->shortenZeroes($css);
$css = $this->shortenFontWeights($css);
$css = $this->stripEmptyTags($css);
480,59 → 482,84
}
 
/**
* Shorthand hex color codes.
* #FF0000 -> #F00.
* Shorthand HEX color codes.
* #FF0000FF -> #f00 -> red
* #FF00FF00 -> transparent.
*
* @param string $content The CSS content to shorten the hex color codes for
* @param string $content The CSS content to shorten the HEX color codes for
*
* @return string
*/
protected function shortenColors($content)
protected function shortenHexColors($content)
{
$content = preg_replace('/(?<=[: ])#([0-9a-z])\\1([0-9a-z])\\2([0-9a-z])\\3(?:([0-9a-z])\\4)?(?=[; }])/i', '#$1$2$3$4', $content);
// shorten repeating patterns within HEX ..
$content = preg_replace('/(?<=[: ])#([0-9a-f])\\1([0-9a-f])\\2([0-9a-f])\\3(?:([0-9a-f])\\4)?(?=[; }])/i', '#$1$2$3$4', $content);
 
// remove alpha channel if it's pointless...
$content = preg_replace('/(?<=[: ])#([0-9a-z]{6})ff?(?=[; }])/i', '#$1', $content);
$content = preg_replace('/(?<=[: ])#([0-9a-z]{3})f?(?=[; }])/i', '#$1', $content);
// remove alpha channel if it's pointless ..
$content = preg_replace('/(?<=[: ])#([0-9a-f]{6})ff(?=[; }])/i', '#$1', $content);
$content = preg_replace('/(?<=[: ])#([0-9a-f]{3})f(?=[; }])/i', '#$1', $content);
 
// replace `transparent` with shortcut ..
$content = preg_replace('/(?<=[: ])#[0-9a-f]{6}00(?=[; }])/i', '#fff0', $content);
 
$colors = array(
// make these more readable
'#00f' => 'blue',
'#dc143c' => 'crimson',
'#0ff' => 'cyan',
'#8b0000' => 'darkred',
'#696969' => 'dimgray',
'#ff69b4' => 'hotpink',
'#0f0' => 'lime',
'#fdf5e6' => 'oldlace',
'#87ceeb' => 'skyblue',
'#d8bfd8' => 'thistle',
// we can shorten some even more by replacing them with their color name
'#F0FFFF' => 'azure',
'#F5F5DC' => 'beige',
'#A52A2A' => 'brown',
'#FF7F50' => 'coral',
'#FFD700' => 'gold',
'#f0ffff' => 'azure',
'#f5f5dc' => 'beige',
'#ffe4c4' => 'bisque',
'#a52a2a' => 'brown',
'#ff7f50' => 'coral',
'#ffd700' => 'gold',
'#808080' => 'gray',
'#008000' => 'green',
'#4B0082' => 'indigo',
'#FFFFF0' => 'ivory',
'#F0E68C' => 'khaki',
'#FAF0E6' => 'linen',
'#4b0082' => 'indigo',
'#fffff0' => 'ivory',
'#f0e68c' => 'khaki',
'#faf0e6' => 'linen',
'#800000' => 'maroon',
'#000080' => 'navy',
'#808000' => 'olive',
'#CD853F' => 'peru',
'#FFC0CB' => 'pink',
'#DDA0DD' => 'plum',
'#ffa500' => 'orange',
'#da70d6' => 'orchid',
'#cd853f' => 'peru',
'#ffc0cb' => 'pink',
'#dda0dd' => 'plum',
'#800080' => 'purple',
'#F00' => 'red',
'#FA8072' => 'salmon',
'#A0522D' => 'sienna',
'#C0C0C0' => 'silver',
'#FFFAFA' => 'snow',
'#D2B48C' => 'tan',
'#FF6347' => 'tomato',
'#EE82EE' => 'violet',
'#F5DEB3' => 'wheat',
'#f00' => 'red',
'#fa8072' => 'salmon',
'#a0522d' => 'sienna',
'#c0c0c0' => 'silver',
'#fffafa' => 'snow',
'#d2b48c' => 'tan',
'#008080' => 'teal',
'#ff6347' => 'tomato',
'#ee82ee' => 'violet',
'#f5deb3' => 'wheat',
// or the other way around
'WHITE' => '#fff',
'BLACK' => '#000',
'black' => '#000',
'fuchsia' => '#f0f',
'magenta' => '#f0f',
'white' => '#fff',
'yellow' => '#ff0',
// and also `transparent`
'transparent' => '#fff0',
);
 
return preg_replace_callback(
'/(?<=[: ])(' . implode('|', array_keys($colors)) . ')(?=[; }])/i',
function ($match) use ($colors) {
return $colors[strtoupper($match[0])];
return $colors[strtolower($match[0])];
},
$content
);
539,6 → 566,69
}
 
/**
* Convert RGB|HSL color codes.
* rgb(255,0,0,.5) -> rgb(255 0 0 / .5).
* rgb(255,0,0) -> #f00.
*
* @param string $content The CSS content to shorten the RGB color codes for
*
* @return string
*/
protected function convertLegacyColors($content)
{
/*
https://drafts.csswg.org/css-color/#color-syntax-legacy
https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb
https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl
*/
 
// convert legacy color syntax
$content = preg_replace('/(rgb|hsl)a?\(([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^\s\)]+)\)/i', '$1($2 $3 $4 / $5)', $content);
$content = preg_replace('/(rgb|hsl)a?\(([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\)/i', '$1($2 $3 $4)', $content);
 
// convert `rgb` to `hex`
$dec = '([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])'; // [000-255] THX @ https://www.regular-expressions.info/numericranges.html
 
return preg_replace_callback(
"/rgb\($dec $dec $dec\)/i",
function ($match) {
return sprintf('#%02x%02x%02x', $match[1], $match[2], $match[3]);
},
$content
);
}
 
/**
* Cleanup RGB|HSL|HWB|LCH|LAB
* rgb(255 0 0 / 1) -> rgb(255 0 0).
* rgb(255 0 0 / 0) -> transparent.
*
* @param string $content The CSS content to cleanup HSL|HWB|LCH|LAB
*
* @return string
*/
protected function cleanupModernColors($content)
{
/*
https://drafts.csswg.org/css-color/#color-syntax-modern
https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hwb
https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lch
https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lab
https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/oklch
https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/oklab
*/
$tag = '(rgb|hsl|hwb|(?:(?:ok)?(?:lch|lab)))';
 
// remove alpha channel if it's pointless ..
$content = preg_replace('/' . $tag . '\(([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+\/\s+1(?:[\.\d]*|00%)?\)/i', '$1($2 $3 $4)', $content);
 
// replace `transparent` with shortcut ..
$content = preg_replace('/' . $tag . '\([^\s]+\s+[^\s]+\s+[^\s]+\s+\/\s+0(?:[\.0%]*)?\)/i', '#fff0', $content);
 
return $content;
}
 
/**
* Shorten CSS font weights.
*
* @param string $content The CSS content to shorten the font weights for
/trunk/vendor/matthiasmullie/minify/src/JS.php
122,9 → 122,6
*/
protected $operatorsAfter = array();
 
/**
* {@inheritdoc}
*/
public function __construct()
{
call_user_func_array(array('\\MatthiasMullie\Minify\\Minify', '__construct'), func_get_args());
/trunk/vendor/matthiasmullie/minify/src/Minify.php
494,15 → 494,21
$parsed = parse_url($path);
if (
// file is elsewhere
isset($parsed['host']) ||
isset($parsed['host'])
// file responds to queries (may change, or need to bypass cache)
isset($parsed['query'])
|| isset($parsed['query'])
) {
return false;
}
 
try {
return strlen($path) < PHP_MAXPATHLEN && @is_file($path) && is_readable($path);
}
// catch openbasedir exceptions which are not caught by @ on is_file()
catch (\Exception $e) {
return false;
}
}
 
/**
* Attempts to open file specified by $path for writing.
534,9 → 540,9
protected function writeToFile($handler, $content, $path = '')
{
if (
!is_resource($handler) ||
($result = @fwrite($handler, $content)) === false ||
($result < strlen($content))
!is_resource($handler)
|| ($result = @fwrite($handler, $content)) === false
|| ($result < strlen($content))
) {
throw new IOException('The file "' . $path . '" could not be written to. Check your disk space and file permissions.');
}