PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
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 / lib / packages / Safe / generated / network.php

network.php in Defender Security – Malware Scanner, Login Security & Firewall 6.3.0, at lib/packages/Safe/generated/network.php

641 lines 14.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WP_DEFENDER_VENDOR\Safe;
4
5 use WP_DEFENDER_VENDOR\Safe\Exceptions\NetworkException;
6
7 /**
8 * closelog closes the descriptor being used to write to
9 * the system logger. The use of closelog is optional.
10 *
11 * @throws NetworkException
12 *
13 */
14 function closelog(): void
15 {
16 error_clear_last();
17 $result = \closelog();
18 if ($result === false) {
19 throw NetworkException::createFromPhpError();
20 }
21 }
22
23
24 /**
25 * Fetch DNS Resource Records associated with the given
26 * hostname.
27 *
28 * @param string $hostname hostname should be a valid DNS hostname such
29 * as "www.example.com". Reverse lookups can be generated
30 * using in-addr.arpa notation, but
31 * gethostbyaddr is more suitable for
32 * the majority of reverse lookups.
33 *
34 * Per DNS standards, email addresses are given in user.host format (for
35 * example: hostmaster.example.com as opposed to hostmaster@example.com),
36 * be sure to check this value and modify if necessary before using it
37 * with a functions such as mail.
38 * @param int $type By default, dns_get_record will search for any
39 * resource records associated with hostname.
40 * To limit the query, specify the optional type
41 * parameter. May be any one of the following:
42 * DNS_A, DNS_CNAME,
43 * DNS_HINFO, DNS_CAA,
44 * DNS_MX, DNS_NS,
45 * DNS_PTR, DNS_SOA,
46 * DNS_TXT, DNS_AAAA,
47 * DNS_SRV, DNS_NAPTR,
48 * DNS_A6, DNS_ALL
49 * or DNS_ANY.
50 *
51 * Because of eccentricities in the performance of libresolv
52 * between platforms, DNS_ANY will not
53 * always return every record, the slower DNS_ALL
54 * will collect all records more reliably.
55 *
56 * DNS_CAA is not supported on Windows.
57 * @param array|null $authns Passed by reference and, if given, will be populated with Resource
58 * Records for the Authoritative Name Servers.
59 * @param array|null $addtl Passed by reference and, if given, will be populated with any
60 * Additional Records.
61 * @param bool $raw The type will be interpreted as a raw DNS type ID
62 * (the DNS_* constants cannot be used).
63 * The return value will contain a data key, which needs
64 * to be manually parsed.
65 * @return array This function returns an array of associative arrays. Each associative array contains
66 * at minimum the following keys:
67 *
68 * Basic DNS attributes
69 *
70 *
71 *
72 * Attribute
73 * Meaning
74 *
75 *
76 *
77 *
78 * host
79 *
80 * The record in the DNS namespace to which the rest of the associated data refers.
81 *
82 *
83 *
84 * class
85 *
86 * dns_get_record only returns Internet class records and as
87 * such this parameter will always return IN.
88 *
89 *
90 *
91 * type
92 *
93 * String containing the record type. Additional attributes will also be contained
94 * in the resulting array dependant on the value of type. See table below.
95 *
96 *
97 *
98 * ttl
99 *
100 * "Time To Live" remaining for this record. This will not equal
101 * the record's original ttl, but will rather equal the original ttl minus whatever
102 * length of time has passed since the authoritative name server was queried.
103 *
104 *
105 *
106 *
107 *
108 *
109 *
110 * Other keys in associative arrays dependant on 'type'
111 *
112 *
113 *
114 * Type
115 * Extra Columns
116 *
117 *
118 *
119 *
120 * A
121 *
122 * ip: An IPv4 addresses in dotted decimal notation.
123 *
124 *
125 *
126 * MX
127 *
128 * pri: Priority of mail exchanger.
129 * Lower numbers indicate greater priority.
130 * target: FQDN of the mail exchanger.
131 * See also dns_get_mx.
132 *
133 *
134 *
135 * CNAME
136 *
137 * target: FQDN of location in DNS namespace to which
138 * the record is aliased.
139 *
140 *
141 *
142 * NS
143 *
144 * target: FQDN of the name server which is authoritative
145 * for this hostname.
146 *
147 *
148 *
149 * PTR
150 *
151 * target: Location within the DNS namespace to which
152 * this record points.
153 *
154 *
155 *
156 * TXT
157 *
158 * txt: Arbitrary string data associated with this record.
159 *
160 *
161 *
162 * HINFO
163 *
164 * cpu: IANA number designating the CPU of the machine
165 * referenced by this record.
166 * os: IANA number designating the Operating System on
167 * the machine referenced by this record.
168 * See IANA's Operating System
169 * Names for the meaning of these values.
170 *
171 *
172 *
173 * CAA
174 *
175 * flags: A one-byte bitfield; currently only bit 0 is defined,
176 * meaning 'critical'; other bits are reserved and should be ignored.
177 * tag: The CAA tag name (alphanumeric ASCII string).
178 * value: The CAA tag value (binary string, may use subformats).
179 * For additional information see: RFC 6844
180 *
181 *
182 *
183 * SOA
184 *
185 * mname: FQDN of the machine from which the resource
186 * records originated.
187 * rname: Email address of the administrative contact
188 * for this domain.
189 * serial: Serial # of this revision of the requested
190 * domain.
191 * refresh: Refresh interval (seconds) secondary name
192 * servers should use when updating remote copies of this domain.
193 * retry: Length of time (seconds) to wait after a
194 * failed refresh before making a second attempt.
195 * expire: Maximum length of time (seconds) a secondary
196 * DNS server should retain remote copies of the zone data without a
197 * successful refresh before discarding.
198 * minimum-ttl: Minimum length of time (seconds) a
199 * client can continue to use a DNS resolution before it should request
200 * a new resolution from the server. Can be overridden by individual
201 * resource records.
202 *
203 *
204 *
205 * AAAA
206 *
207 * ipv6: IPv6 address
208 *
209 *
210 *
211 * A6(PHP &gt;= 5.1.0)
212 *
213 * masklen: Length (in bits) to inherit from the target
214 * specified by chain.
215 * ipv6: Address for this specific record to merge with
216 * chain.
217 * chain: Parent record to merge with
218 * ipv6 data.
219 *
220 *
221 *
222 * SRV
223 *
224 * pri: (Priority) lowest priorities should be used first.
225 * weight: Ranking to weight which of commonly prioritized
226 * targets should be chosen at random.
227 * target and port: hostname and port
228 * where the requested service can be found.
229 * For additional information see: RFC 2782
230 *
231 *
232 *
233 * NAPTR
234 *
235 * order and pref: Equivalent to
236 * pri and weight above.
237 * flags, services, regex,
238 * and replacement: Parameters as defined by
239 * RFC 2915.
240 *
241 *
242 *
243 *
244 *
245 * @throws NetworkException
246 *
247 */
248 function dns_get_record(string $hostname, int $type = DNS_ANY, ?array &$authns = null, ?array &$addtl = null, bool $raw = false): array
249 {
250 error_clear_last();
251 $result = \dns_get_record($hostname, $type, $authns, $addtl, $raw);
252 if ($result === false) {
253 throw NetworkException::createFromPhpError();
254 }
255 return $result;
256 }
257
258
259 /**
260 * Initiates a socket connection to the resource specified by
261 * hostname.
262 *
263 * PHP supports targets in the Internet and Unix domains as described in
264 * . A list of supported transports can also be
265 * retrieved using stream_get_transports.
266 *
267 * The socket will by default be opened in blocking mode. You can
268 * switch it to non-blocking mode by using
269 * stream_set_blocking.
270 *
271 * The function stream_socket_client is similar but
272 * provides a richer set of options, including non-blocking connection and the
273 * ability to provide a stream context.
274 *
275 * @param string $hostname If OpenSSL support is
276 * installed, you may prefix the hostname
277 * with either ssl:// or tls:// to
278 * use an SSL or TLS client connection over TCP/IP to connect to the
279 * remote host.
280 * @param int $port The port number. This can be omitted and skipped with
281 * -1 for transports that do not use ports, such as
282 * unix://.
283 * @param int|null $errno If provided, holds the system level error number that occurred in the
284 * system-level connect() call.
285 *
286 * If the value returned in errno is
287 * 0 and the function returned FALSE, it is an
288 * indication that the error occurred before the
289 * connect() call. This is most likely due to a
290 * problem initializing the socket.
291 * @param string|null $errstr The error message as a string.
292 * @param float|null $timeout The connection timeout, in seconds.
293 *
294 * If you need to set a timeout for reading/writing data over the
295 * socket, use stream_set_timeout, as the
296 * timeout parameter to
297 * fsockopen only applies while connecting the
298 * socket.
299 *
300 * @return resource fsockopen returns a file pointer which may be used
301 * together with the other file functions (such as
302 * fgets, fgetss,
303 * fwrite, fclose, and
304 * feof). If the call fails, it will return FALSE
305 * @throws NetworkException
306 *
307 */
308 function fsockopen(string $hostname, int $port = -1, ?int &$errno = null, ?string &$errstr = null, ?float $timeout = null)
309 {
310 error_clear_last();
311 if ($timeout !== null) {
312 $result = \fsockopen($hostname, $port, $errno, $errstr, $timeout);
313 } else {
314 $result = \fsockopen($hostname, $port, $errno, $errstr);
315 }
316 if ($result === false) {
317 throw NetworkException::createFromPhpError();
318 }
319 return $result;
320 }
321
322
323 /**
324 * gethostname gets the standard host name for
325 * the local machine.
326 *
327 * @return string Returns a string with the hostname on success, otherwise FALSE is
328 * returned.
329 * @throws NetworkException
330 *
331 */
332 function gethostname(): string
333 {
334 error_clear_last();
335 $result = \gethostname();
336 if ($result === false) {
337 throw NetworkException::createFromPhpError();
338 }
339 return $result;
340 }
341
342
343 /**
344 * getprotobyname returns the protocol number
345 * associated with the protocol name as per
346 * /etc/protocols.
347 *
348 * @param string $name The protocol name.
349 * @return int Returns the protocol number.
350 * @throws NetworkException
351 *
352 */
353 function getprotobyname(string $name): int
354 {
355 error_clear_last();
356 $result = \getprotobyname($name);
357 if ($result === false) {
358 throw NetworkException::createFromPhpError();
359 }
360 return $result;
361 }
362
363
364 /**
365 * getprotobynumber returns the protocol name
366 * associated with protocol number as per
367 * /etc/protocols.
368 *
369 * @param int $number The protocol number.
370 * @return string Returns the protocol name as a string.
371 * @throws NetworkException
372 *
373 */
374 function getprotobynumber(int $number): string
375 {
376 error_clear_last();
377 $result = \getprotobynumber($number);
378 if ($result === false) {
379 throw NetworkException::createFromPhpError();
380 }
381 return $result;
382 }
383
384
385 /**
386 * Registers a function that will be called when PHP starts sending output.
387 *
388 * The callback is executed just after PHP prepares all
389 * headers to be sent, and before any other output is sent, creating a window
390 * to manipulate the outgoing headers before being sent.
391 *
392 * @param callable $callback Function called just before the headers are sent. It gets no parameters
393 * and the return value is ignored.
394 * @throws NetworkException
395 *
396 */
397 function header_register_callback(callable $callback): void
398 {
399 error_clear_last();
400 $result = \header_register_callback($callback);
401 if ($result === false) {
402 throw NetworkException::createFromPhpError();
403 }
404 }
405
406
407 /**
408 *
409 *
410 * @param string $in_addr A 32bit IPv4, or 128bit IPv6 address.
411 * @return string Returns a string representation of the address.
412 * @throws NetworkException
413 *
414 */
415 function inet_ntop(string $in_addr): string
416 {
417 error_clear_last();
418 $result = \inet_ntop($in_addr);
419 if ($result === false) {
420 throw NetworkException::createFromPhpError();
421 }
422 return $result;
423 }
424
425
426 /**
427 * openlog opens a connection to the system
428 * logger for a program.
429 *
430 * The use of openlog is optional. It
431 * will automatically be called by syslog if
432 * necessary, in which case ident will default
433 * to FALSE.
434 *
435 * @param string $ident The string ident is added to each message.
436 * @param int $option The option argument is used to indicate
437 * what logging options will be used when generating a log message.
438 *
439 * openlog Options
440 *
441 *
442 *
443 * Constant
444 * Description
445 *
446 *
447 *
448 *
449 * LOG_CONS
450 *
451 * if there is an error while sending data to the system logger,
452 * write directly to the system console
453 *
454 *
455 *
456 * LOG_NDELAY
457 *
458 * open the connection to the logger immediately
459 *
460 *
461 *
462 * LOG_ODELAY
463 *
464 * (default) delay opening the connection until the first
465 * message is logged
466 *
467 *
468 *
469 * LOG_PERROR
470 * print log message also to standard error
471 *
472 *
473 * LOG_PID
474 * include PID with each message
475 *
476 *
477 *
478 *
479 * You can use one or more of these options. When using multiple options
480 * you need to OR them, i.e. to open the connection
481 * immediately, write to the console and include the PID in each message,
482 * you will use: LOG_CONS | LOG_NDELAY | LOG_PID
483 * @param int $facility The facility argument is used to specify what
484 * type of program is logging the message. This allows you to specify
485 * (in your machine's syslog configuration) how messages coming from
486 * different facilities will be handled.
487 *
488 * openlog Facilities
489 *
490 *
491 *
492 * Constant
493 * Description
494 *
495 *
496 *
497 *
498 * LOG_AUTH
499 *
500 * security/authorization messages (use
501 * LOG_AUTHPRIV instead
502 * in systems where that constant is defined)
503 *
504 *
505 *
506 * LOG_AUTHPRIV
507 * security/authorization messages (private)
508 *
509 *
510 * LOG_CRON
511 * clock daemon (cron and at)
512 *
513 *
514 * LOG_DAEMON
515 * other system daemons
516 *
517 *
518 * LOG_KERN
519 * kernel messages
520 *
521 *
522 * LOG_LOCAL0 ... LOG_LOCAL7
523 * reserved for local use, these are not available in Windows
524 *
525 *
526 * LOG_LPR
527 * line printer subsystem
528 *
529 *
530 * LOG_MAIL
531 * mail subsystem
532 *
533 *
534 * LOG_NEWS
535 * USENET news subsystem
536 *
537 *
538 * LOG_SYSLOG
539 * messages generated internally by syslogd
540 *
541 *
542 * LOG_USER
543 * generic user-level messages
544 *
545 *
546 * LOG_UUCP
547 * UUCP subsystem
548 *
549 *
550 *
551 *
552 *
553 * LOG_USER is the only valid log type under Windows
554 * operating systems
555 * @throws NetworkException
556 *
557 */
558 function openlog(string $ident, int $option, int $facility): void
559 {
560 error_clear_last();
561 $result = \openlog($ident, $option, $facility);
562 if ($result === false) {
563 throw NetworkException::createFromPhpError();
564 }
565 }
566
567
568 /**
569 * syslog generates a log message that will be
570 * distributed by the system logger.
571 *
572 * For information on setting up a user defined log handler, see the
573 * syslog.conf
574 * 5 Unix manual page. More
575 * information on the syslog facilities and option can be found in the man
576 * pages for syslog
577 * 3 on Unix machines.
578 *
579 * @param int $priority priority is a combination of the facility and
580 * the level. Possible values are:
581 *
582 * syslog Priorities (in descending order)
583 *
584 *
585 *
586 * Constant
587 * Description
588 *
589 *
590 *
591 *
592 * LOG_EMERG
593 * system is unusable
594 *
595 *
596 * LOG_ALERT
597 * action must be taken immediately
598 *
599 *
600 * LOG_CRIT
601 * critical conditions
602 *
603 *
604 * LOG_ERR
605 * error conditions
606 *
607 *
608 * LOG_WARNING
609 * warning conditions
610 *
611 *
612 * LOG_NOTICE
613 * normal, but significant, condition
614 *
615 *
616 * LOG_INFO
617 * informational message
618 *
619 *
620 * LOG_DEBUG
621 * debug-level message
622 *
623 *
624 *
625 *
626 * @param string $message The message to send, except that the two characters
627 * %m will be replaced by the error message string
628 * (strerror) corresponding to the present value of
629 * errno.
630 * @throws NetworkException
631 *
632 */
633 function syslog(int $priority, string $message): void
634 {
635 error_clear_last();
636 $result = \syslog($priority, $message);
637 if ($result === false) {
638 throw NetworkException::createFromPhpError();
639 }
640 }
641