'.htmlspecialchars($message, ENT_QUOTES | ENT_HTML5, 'UTF-8').'
'."\n");
115 | }
116 |
117 | public static function set_stylesheet(string $stylesheet): void
118 | {
119 | self::$stylesheet = $stylesheet;
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/urlparts.php:
--------------------------------------------------------------------------------
1 |
5 | */
6 |
7 | /**
8 | * Trait with code handling URL validation and disassembly. Returns null if a
9 | * URL fails the syntax check. Returns an array with the URL parts on success.
10 | * Missing parts are represented by an empty string, a missing port part by
11 | * (int) 0.
12 | *
13 | * For reference: RFC 3986, RFC 1034 section 3.5, RFC 1123 section 2.1
14 | *
15 | * Additional notes:
16 | * - The scheme should either be http or https. For URLs without a scheme, http
17 | * is assumed.
18 | * - User part in authority is not recognized and will not validate.
19 | * - IPv6 addresses will not validate.
20 | * - Square brackets must be percent encoded.
21 | * - Apply various normalizations.
22 | */
23 | trait urlparts
24 | {
25 | private string $regexp = '';
26 |
27 | private function get_urlparts(string $url): ?array
28 | {
29 | /**
30 | * Assemble the regular expression if not already done so.
31 | */
32 | if ($this->regexp === '') {
33 | $scheme = '((?