PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.5.1
Defender Security – Malware Scanner, Login Security & Firewall v5.5.1
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / vendor / thecodingmachine / safe / generated / misc.php

misc.php in Defender Security – Malware Scanner, Login Security & Firewall 5.5.1, at vendor/thecodingmachine/safe/generated/misc.php

465 lines 11.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Safe;
4
5 use Safe\Exceptions\MiscException;
6
7 /**
8 * Defines a named constant at runtime.
9 *
10 * @param string $name The name of the constant.
11 *
12 * It is possible to define constants with reserved or
13 * even invalid names, whose value can (only) be retrieved with
14 * constant. However, doing so is not recommended.
15 * @param mixed $value The value of the constant. In PHP 5, value must
16 * be a scalar value (integer,
17 * float, string, boolean, or
18 * NULL). In PHP 7, array values are also accepted.
19 *
20 * While it is possible to define resource constants, it is
21 * not recommended and may cause unpredictable behavior.
22 * @param bool $case_insensitive If set to TRUE, the constant will be defined case-insensitive.
23 * The default behavior is case-sensitive; i.e.
24 * CONSTANT and Constant represent
25 * different values.
26 *
27 * Case-insensitive constants are stored as lower-case.
28 * @throws MiscException
29 *
30 */
31 function define(string $name, $value, bool $case_insensitive = false): void
32 {
33 error_clear_last();
34 $result = \define($name, $value, $case_insensitive);
35 if ($result === false) {
36 throw MiscException::createFromPhpError();
37 }
38 }
39
40
41 /**
42 * Prints out or returns a syntax highlighted version of the code contained
43 * in filename using the colors defined in the
44 * built-in syntax highlighter for PHP.
45 *
46 * Many servers are configured to automatically highlight files
47 * with a phps extension. For example,
48 * example.phps when viewed will show the
49 * syntax highlighted source of the file. To enable this, add this
50 * line to the httpd.conf:
51 *
52 * @param string $filename Path to the PHP file to be highlighted.
53 * @param bool $return Set this parameter to TRUE to make this function return the
54 * highlighted code.
55 * @return string|bool If return is set to TRUE, returns the highlighted
56 * code as a string instead of printing it out. Otherwise, it will return
57 * TRUE on success, FALSE on failure.
58 * @throws MiscException
59 *
60 */
61 function highlight_file(string $filename, bool $return = false)
62 {
63 error_clear_last();
64 $result = \highlight_file($filename, $return);
65 if ($result === false) {
66 throw MiscException::createFromPhpError();
67 }
68 return $result;
69 }
70
71
72 /**
73 *
74 *
75 * @param string $str The PHP code to be highlighted. This should include the opening tag.
76 * @param bool $return Set this parameter to TRUE to make this function return the
77 * highlighted code.
78 * @return string|bool If return is set to TRUE, returns the highlighted
79 * code as a string instead of printing it out. Otherwise, it will return
80 * TRUE on success, FALSE on failure.
81 * @throws MiscException
82 *
83 */
84 function highlight_string(string $str, bool $return = false)
85 {
86 error_clear_last();
87 $result = \highlight_string($str, $return);
88 if ($result === false) {
89 throw MiscException::createFromPhpError();
90 }
91 return $result;
92 }
93
94
95 /**
96 * Pack given arguments into a binary string according to
97 * format.
98 *
99 * The idea for this function was taken from Perl and all formatting codes
100 * work the same as in Perl. However, there are some formatting codes that are
101 * missing such as Perl's "u" format code.
102 *
103 * Note that the distinction between signed and unsigned values only
104 * affects the function unpack, where as
105 * function pack gives the same result for
106 * signed and unsigned format codes.
107 *
108 * @param string $format The format string consists of format codes
109 * followed by an optional repeater argument. The repeater argument can
110 * be either an integer value or * for repeating to
111 * the end of the input data. For a, A, h, H the repeat count specifies
112 * how many characters of one data argument are taken, for @ it is the
113 * absolute position where to put the next data, for everything else the
114 * repeat count specifies how many data arguments are consumed and packed
115 * into the resulting binary string.
116 *
117 * Currently implemented formats are:
118 *
119 * pack format characters
120 *
121 *
122 *
123 * Code
124 * Description
125 *
126 *
127 *
128 *
129 * a
130 * NUL-padded string
131 *
132 *
133 * A
134 * SPACE-padded string
135 *
136 * h
137 * Hex string, low nibble first
138 *
139 * H
140 * Hex string, high nibble first
141 * csigned char
142 *
143 * C
144 * unsigned char
145 *
146 * s
147 * signed short (always 16 bit, machine byte order)
148 *
149 *
150 * S
151 * unsigned short (always 16 bit, machine byte order)
152 *
153 *
154 * n
155 * unsigned short (always 16 bit, big endian byte order)
156 *
157 *
158 * v
159 * unsigned short (always 16 bit, little endian byte order)
160 *
161 *
162 * i
163 * signed integer (machine dependent size and byte order)
164 *
165 *
166 * I
167 * unsigned integer (machine dependent size and byte order)
168 *
169 *
170 * l
171 * signed long (always 32 bit, machine byte order)
172 *
173 *
174 * L
175 * unsigned long (always 32 bit, machine byte order)
176 *
177 *
178 * N
179 * unsigned long (always 32 bit, big endian byte order)
180 *
181 *
182 * V
183 * unsigned long (always 32 bit, little endian byte order)
184 *
185 *
186 * q
187 * signed long long (always 64 bit, machine byte order)
188 *
189 *
190 * Q
191 * unsigned long long (always 64 bit, machine byte order)
192 *
193 *
194 * J
195 * unsigned long long (always 64 bit, big endian byte order)
196 *
197 *
198 * P
199 * unsigned long long (always 64 bit, little endian byte order)
200 *
201 *
202 * f
203 * float (machine dependent size and representation)
204 *
205 *
206 * g
207 * float (machine dependent size, little endian byte order)
208 *
209 *
210 * G
211 * float (machine dependent size, big endian byte order)
212 *
213 *
214 * d
215 * double (machine dependent size and representation)
216 *
217 *
218 * e
219 * double (machine dependent size, little endian byte order)
220 *
221 *
222 * E
223 * double (machine dependent size, big endian byte order)
224 *
225 *
226 * x
227 * NUL byte
228 *
229 *
230 * X
231 * Back up one byte
232 *
233 *
234 * Z
235 * NUL-padded string (new in PHP 5.5)
236 *
237 *
238 * @
239 * NUL-fill to absolute position
240 *
241 *
242 *
243 *
244 * @param mixed $params
245 * @return string Returns a binary string containing data.
246 * @throws MiscException
247 *
248 */
249 function pack(string $format, ...$params): string
250 {
251 error_clear_last();
252 if ($params !== []) {
253 $result = \pack($format, ...$params);
254 } else {
255 $result = \pack($format);
256 }
257 if ($result === false) {
258 throw MiscException::createFromPhpError();
259 }
260 return $result;
261 }
262
263
264 /**
265 * Convert string from one codepage to another.
266 *
267 * @param int|string $in_codepage The codepage of the subject string.
268 * Either the codepage name or identifier.
269 * @param int|string $out_codepage The codepage to convert the subject string to.
270 * Either the codepage name or identifier.
271 * @param string $subject The string to convert.
272 * @return string The subject string converted to
273 * out_codepage.
274 * @throws MiscException
275 *
276 */
277 function sapi_windows_cp_conv($in_codepage, $out_codepage, string $subject): string
278 {
279 error_clear_last();
280 $result = \sapi_windows_cp_conv($in_codepage, $out_codepage, $subject);
281 if ($result === null) {
282 throw MiscException::createFromPhpError();
283 }
284 return $result;
285 }
286
287
288 /**
289 * Set the codepage of the current process.
290 *
291 * @param int $cp A codepage identifier.
292 * @throws MiscException
293 *
294 */
295 function sapi_windows_cp_set(int $cp): void
296 {
297 error_clear_last();
298 $result = \sapi_windows_cp_set($cp);
299 if ($result === false) {
300 throw MiscException::createFromPhpError();
301 }
302 }
303
304
305 /**
306 * Sends a CTRL event to another process in the same process group.
307 *
308 * @param int $event The CTRL even to send;
309 * either PHP_WINDOWS_EVENT_CTRL_C
310 * or PHP_WINDOWS_EVENT_CTRL_BREAK.
311 * @param int $pid The ID of the process to which to send the event to. If 0
312 * is given, the event is sent to all processes of the process group.
313 * @throws MiscException
314 *
315 */
316 function sapi_windows_generate_ctrl_event(int $event, int $pid = 0): void
317 {
318 error_clear_last();
319 $result = \sapi_windows_generate_ctrl_event($event, $pid);
320 if ($result === false) {
321 throw MiscException::createFromPhpError();
322 }
323 }
324
325
326 /**
327 * If enable is omitted, the function returns TRUE if the stream stream has VT100 control codes enabled, FALSE otherwise.
328 *
329 * If enable is specified, the function will try to enable or disable the VT100 features of the stream stream.
330 * If the feature has been successfully enabled (or disabled).
331 *
332 * At startup, PHP tries to enable the VT100 feature of the STDOUT/STDERR streams. By the way, if those streams are redirected to a file, the VT100 features may not be enabled.
333 *
334 * If VT100 support is enabled, it is possible to use control sequences as they are known from the VT100 terminal.
335 * They allow the modification of the terminal's output. On Windows these sequences are called Console Virtual Terminal Sequences.
336 *
337 * @param resource $stream The stream on which the function will operate.
338 * @param bool $enable If specified, the VT100 feature will be enabled (if TRUE) or disabled (if FALSE).
339 * @throws MiscException
340 *
341 */
342 function sapi_windows_vt100_support($stream, bool $enable = null): void
343 {
344 error_clear_last();
345 if ($enable !== null) {
346 $result = \sapi_windows_vt100_support($stream, $enable);
347 } else {
348 $result = \sapi_windows_vt100_support($stream);
349 }
350 if ($result === false) {
351 throw MiscException::createFromPhpError();
352 }
353 }
354
355
356 /**
357 *
358 *
359 * @param int $seconds Halt time in seconds.
360 * @return int Returns zero on success.
361 *
362 * If the call was interrupted by a signal, sleep returns
363 * a non-zero value. On Windows, this value will always be
364 * 192 (the value of the
365 * WAIT_IO_COMPLETION constant within the Windows API).
366 * On other platforms, the return value will be the number of seconds left to
367 * sleep.
368 * @throws MiscException
369 *
370 */
371 function sleep(int $seconds): int
372 {
373 error_clear_last();
374 $result = \sleep($seconds);
375 if ($result === false) {
376 throw MiscException::createFromPhpError();
377 }
378 return $result;
379 }
380
381
382 /**
383 * Delays program execution for the given number of
384 * seconds and nanoseconds.
385 *
386 * @param int $seconds Must be a non-negative integer.
387 * @param int $nanoseconds Must be a non-negative integer less than 1 billion.
388 * @return array{0:int,1:int}|bool Returns TRUE on success.
389 *
390 * If the delay was interrupted by a signal, an associative array will be
391 * returned with the components:
392 *
393 *
394 *
395 * seconds - number of seconds remaining in
396 * the delay
397 *
398 *
399 *
400 *
401 * nanoseconds - number of nanoseconds
402 * remaining in the delay
403 *
404 *
405 *
406 * @throws MiscException
407 *
408 */
409 function time_nanosleep(int $seconds, int $nanoseconds)
410 {
411 error_clear_last();
412 $result = \time_nanosleep($seconds, $nanoseconds);
413 if ($result === false) {
414 throw MiscException::createFromPhpError();
415 }
416 return $result;
417 }
418
419
420 /**
421 * Makes the script sleep until the specified
422 * timestamp.
423 *
424 * @param float $timestamp The timestamp when the script should wake.
425 * @throws MiscException
426 *
427 */
428 function time_sleep_until(float $timestamp): void
429 {
430 error_clear_last();
431 $result = \time_sleep_until($timestamp);
432 if ($result === false) {
433 throw MiscException::createFromPhpError();
434 }
435 }
436
437
438 /**
439 * Unpacks from a binary string into an array according to the given
440 * format.
441 *
442 * The unpacked data is stored in an associative array. To
443 * accomplish this you have to name the different format codes and
444 * separate them by a slash /. If a repeater argument is present,
445 * then each of the array keys will have a sequence number behind
446 * the given name.
447 *
448 * @param string $format See pack for an explanation of the format codes.
449 * @param string $data The packed data.
450 * @param int $offset The offset to begin unpacking from.
451 * @return array Returns an associative array containing unpacked elements of binary
452 * string.
453 * @throws MiscException
454 *
455 */
456 function unpack(string $format, string $data, int $offset = 0): array
457 {
458 error_clear_last();
459 $result = \unpack($format, $data, $offset);
460 if ($result === false) {
461 throw MiscException::createFromPhpError();
462 }
463 return $result;
464 }
465