Exceptions
5 days ago
apache.php
5 days ago
apcu.php
5 days ago
array.php
5 days ago
bzip2.php
5 days ago
calendar.php
5 days ago
classobj.php
5 days ago
com.php
5 days ago
cubrid.php
5 days ago
curl.php
5 days ago
datetime.php
5 days ago
dir.php
5 days ago
eio.php
5 days ago
errorfunc.php
5 days ago
exec.php
5 days ago
fileinfo.php
5 days ago
filesystem.php
5 days ago
filter.php
5 days ago
fpm.php
5 days ago
ftp.php
5 days ago
funchand.php
5 days ago
functionsList.php
5 days ago
gmp.php
5 days ago
gnupg.php
5 days ago
hash.php
5 days ago
ibase.php
5 days ago
ibmDb2.php
5 days ago
iconv.php
5 days ago
image.php
5 days ago
imap.php
5 days ago
info.php
5 days ago
ingres-ii.php
5 days ago
inotify.php
5 days ago
json.php
5 days ago
ldap.php
5 days ago
libxml.php
5 days ago
lzf.php
5 days ago
mailparse.php
5 days ago
mbstring.php
5 days ago
misc.php
5 days ago
msql.php
5 days ago
mysql.php
5 days ago
mysqli.php
5 days ago
mysqlndMs.php
5 days ago
mysqlndQc.php
5 days ago
network.php
5 days ago
oci8.php
5 days ago
opcache.php
5 days ago
openssl.php
5 days ago
outcontrol.php
5 days ago
password.php
5 days ago
pcntl.php
5 days ago
pcre.php
5 days ago
pdf.php
5 days ago
pgsql.php
5 days ago
posix.php
5 days ago
ps.php
5 days ago
pspell.php
5 days ago
readline.php
5 days ago
rpminfo.php
5 days ago
rrd.php
5 days ago
sem.php
5 days ago
session.php
5 days ago
shmop.php
5 days ago
simplexml.php
5 days ago
sockets.php
5 days ago
sodium.php
5 days ago
solr.php
5 days ago
spl.php
5 days ago
sqlsrv.php
5 days ago
ssdeep.php
5 days ago
ssh2.php
5 days ago
stream.php
5 days ago
strings.php
5 days ago
swoole.php
5 days ago
uodbc.php
5 days ago
uopz.php
5 days ago
url.php
5 days ago
var.php
5 days ago
xdiff.php
5 days ago
xml.php
5 days ago
xmlrpc.php
5 days ago
yaml.php
5 days ago
yaz.php
5 days ago
zip.php
5 days ago
zlib.php
5 days ago
info.php
483 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ProfilePressVendor\Safe; |
| 4 | |
| 5 | use ProfilePressVendor\Safe\Exceptions\InfoException; |
| 6 | /** |
| 7 | * Sets the process title visible in tools such as top and |
| 8 | * ps. This function is available only in |
| 9 | * CLI mode. |
| 10 | * |
| 11 | * @param string $title The new title. |
| 12 | * @throws InfoException |
| 13 | * |
| 14 | */ |
| 15 | function cli_set_process_title(string $title): void |
| 16 | { |
| 17 | error_clear_last(); |
| 18 | $result = \cli_set_process_title($title); |
| 19 | if ($result === \false) { |
| 20 | throw InfoException::createFromPhpError(); |
| 21 | } |
| 22 | } |
| 23 | /** |
| 24 | * Loads the PHP extension given by the parameter |
| 25 | * library. |
| 26 | * |
| 27 | * Use extension_loaded to test whether a given |
| 28 | * extension is already available or not. This works on both built-in |
| 29 | * extensions and dynamically loaded ones (either through php.ini or |
| 30 | * dl). |
| 31 | * |
| 32 | * @param string $library This parameter is only the filename of the |
| 33 | * extension to load which also depends on your platform. For example, |
| 34 | * the sockets extension (if compiled |
| 35 | * as a shared module, not the default!) would be called |
| 36 | * sockets.so on Unix platforms whereas it is called |
| 37 | * php_sockets.dll on the Windows platform. |
| 38 | * |
| 39 | * The directory where the extension is loaded from depends on your |
| 40 | * platform: |
| 41 | * |
| 42 | * Windows - If not explicitly set in the php.ini, the extension is |
| 43 | * loaded from C:\php5\ by default. |
| 44 | * |
| 45 | * Unix - If not explicitly set in the php.ini, the default extension |
| 46 | * directory depends on |
| 47 | * |
| 48 | * |
| 49 | * |
| 50 | * whether PHP has been built with --enable-debug |
| 51 | * or not |
| 52 | * |
| 53 | * |
| 54 | * |
| 55 | * |
| 56 | * whether PHP has been built with (experimental) ZTS (Zend Thread Safety) |
| 57 | * support or not |
| 58 | * |
| 59 | * |
| 60 | * |
| 61 | * |
| 62 | * the current internal ZEND_MODULE_API_NO (Zend |
| 63 | * internal module API number, which is basically the date on which a |
| 64 | * major module API change happened, e.g. 20010901) |
| 65 | * |
| 66 | * |
| 67 | * |
| 68 | * Taking into account the above, the directory then defaults to |
| 69 | * <install-dir>/lib/php/extensions/ <debug-or-not>-<zts-or-not>-ZEND_MODULE_API_NO, |
| 70 | * e.g. |
| 71 | * /usr/local/php/lib/php/extensions/debug-non-zts-20010901 |
| 72 | * or |
| 73 | * /usr/local/php/lib/php/extensions/no-debug-zts-20010901. |
| 74 | * @throws InfoException |
| 75 | * |
| 76 | */ |
| 77 | function dl(string $library): void |
| 78 | { |
| 79 | error_clear_last(); |
| 80 | $result = \dl($library); |
| 81 | if ($result === \false) { |
| 82 | throw InfoException::createFromPhpError(); |
| 83 | } |
| 84 | } |
| 85 | /** |
| 86 | * Gets the time of the last modification of the main script of execution. |
| 87 | * |
| 88 | * If you're interested in getting the last modification time |
| 89 | * of a different file, consider using filemtime. |
| 90 | * |
| 91 | * @return int Returns the time of the last modification of the current |
| 92 | * page. The value returned is a Unix timestamp, suitable for |
| 93 | * feeding to date. |
| 94 | * @throws InfoException |
| 95 | * |
| 96 | */ |
| 97 | function getlastmod(): int |
| 98 | { |
| 99 | error_clear_last(); |
| 100 | $result = \getlastmod(); |
| 101 | if ($result === \false) { |
| 102 | throw InfoException::createFromPhpError(); |
| 103 | } |
| 104 | return $result; |
| 105 | } |
| 106 | /** |
| 107 | * |
| 108 | * |
| 109 | * @return int Returns the group ID of the current script. |
| 110 | * @throws InfoException |
| 111 | * |
| 112 | */ |
| 113 | function getmygid(): int |
| 114 | { |
| 115 | error_clear_last(); |
| 116 | $result = \getmygid(); |
| 117 | if ($result === \false) { |
| 118 | throw InfoException::createFromPhpError(); |
| 119 | } |
| 120 | return $result; |
| 121 | } |
| 122 | /** |
| 123 | * Gets the inode of the current script. |
| 124 | * |
| 125 | * @return int Returns the current script's inode as an integer. |
| 126 | * @throws InfoException |
| 127 | * |
| 128 | */ |
| 129 | function getmyinode(): int |
| 130 | { |
| 131 | error_clear_last(); |
| 132 | $result = \getmyinode(); |
| 133 | if ($result === \false) { |
| 134 | throw InfoException::createFromPhpError(); |
| 135 | } |
| 136 | return $result; |
| 137 | } |
| 138 | /** |
| 139 | * Gets the current PHP process ID. |
| 140 | * |
| 141 | * @return int Returns the current PHP process ID. |
| 142 | * @throws InfoException |
| 143 | * |
| 144 | */ |
| 145 | function getmypid(): int |
| 146 | { |
| 147 | error_clear_last(); |
| 148 | $result = \getmypid(); |
| 149 | if ($result === \false) { |
| 150 | throw InfoException::createFromPhpError(); |
| 151 | } |
| 152 | return $result; |
| 153 | } |
| 154 | /** |
| 155 | * |
| 156 | * |
| 157 | * @return int Returns the user ID of the current script. |
| 158 | * @throws InfoException |
| 159 | * |
| 160 | */ |
| 161 | function getmyuid(): int |
| 162 | { |
| 163 | error_clear_last(); |
| 164 | $result = \getmyuid(); |
| 165 | if ($result === \false) { |
| 166 | throw InfoException::createFromPhpError(); |
| 167 | } |
| 168 | return $result; |
| 169 | } |
| 170 | /** |
| 171 | * Parses options passed to the script. |
| 172 | * |
| 173 | * @param string $options |
| 174 | * @param array $longopts |
| 175 | * @param int|null $optind |
| 176 | * @return array|array|array This function will return an array of option / argument pairs. |
| 177 | * @throws InfoException |
| 178 | * |
| 179 | */ |
| 180 | function getopt(string $options, array $longopts = null, ?int &$optind = null): array |
| 181 | { |
| 182 | error_clear_last(); |
| 183 | if ($optind !== null) { |
| 184 | $result = \getopt($options, $longopts, $optind); |
| 185 | } elseif ($longopts !== null) { |
| 186 | $result = \getopt($options, $longopts); |
| 187 | } else { |
| 188 | $result = \getopt($options); |
| 189 | } |
| 190 | if ($result === \false) { |
| 191 | throw InfoException::createFromPhpError(); |
| 192 | } |
| 193 | return $result; |
| 194 | } |
| 195 | /** |
| 196 | * Returns the value of the configuration option on success. |
| 197 | * |
| 198 | * @param string $varname The configuration option name. |
| 199 | * @return string Returns the value of the configuration option as a string on success, or an |
| 200 | * empty string for null values. Returns FALSE if the |
| 201 | * configuration option doesn't exist. |
| 202 | * @throws InfoException |
| 203 | * |
| 204 | */ |
| 205 | function ini_get(string $varname): string |
| 206 | { |
| 207 | error_clear_last(); |
| 208 | $result = \ini_get($varname); |
| 209 | if ($result === \false) { |
| 210 | throw InfoException::createFromPhpError(); |
| 211 | } |
| 212 | return $result; |
| 213 | } |
| 214 | /** |
| 215 | * Sets the value of the given configuration option. The configuration option |
| 216 | * will keep this new value during the script's execution, and will be restored |
| 217 | * at the script's ending. |
| 218 | * |
| 219 | * @param string $varname Not all the available options can be changed using |
| 220 | * ini_set. There is a list of all available options |
| 221 | * in the appendix. |
| 222 | * @param string|int|float|bool $newvalue The new value for the option. |
| 223 | * @return string Returns the old value on success, FALSE on failure. |
| 224 | * @throws InfoException |
| 225 | * |
| 226 | */ |
| 227 | function ini_set(string $varname, $newvalue): string |
| 228 | { |
| 229 | error_clear_last(); |
| 230 | $result = \ini_set($varname, $newvalue); |
| 231 | if ($result === \false) { |
| 232 | throw InfoException::createFromPhpError(); |
| 233 | } |
| 234 | return $result; |
| 235 | } |
| 236 | /** |
| 237 | * This function prints out the credits listing the PHP developers, |
| 238 | * modules, etc. It generates the appropriate HTML codes to insert |
| 239 | * the information in a page. |
| 240 | * |
| 241 | * @param int $flag To generate a custom credits page, you may want to use the |
| 242 | * flag parameter. |
| 243 | * |
| 244 | * |
| 245 | * Pre-defined phpcredits flags |
| 246 | * |
| 247 | * |
| 248 | * |
| 249 | * name |
| 250 | * description |
| 251 | * |
| 252 | * |
| 253 | * |
| 254 | * |
| 255 | * CREDITS_ALL |
| 256 | * |
| 257 | * All the credits, equivalent to using: CREDITS_DOCS + |
| 258 | * CREDITS_GENERAL + CREDITS_GROUP + |
| 259 | * CREDITS_MODULES + CREDITS_FULLPAGE. |
| 260 | * It generates a complete stand-alone HTML page with the appropriate tags. |
| 261 | * |
| 262 | * |
| 263 | * |
| 264 | * CREDITS_DOCS |
| 265 | * The credits for the documentation team |
| 266 | * |
| 267 | * |
| 268 | * CREDITS_FULLPAGE |
| 269 | * |
| 270 | * Usually used in combination with the other flags. Indicates |
| 271 | * that a complete stand-alone HTML page needs to be |
| 272 | * printed including the information indicated by the other |
| 273 | * flags. |
| 274 | * |
| 275 | * |
| 276 | * |
| 277 | * CREDITS_GENERAL |
| 278 | * |
| 279 | * General credits: Language design and concept, PHP authors |
| 280 | * and SAPI module. |
| 281 | * |
| 282 | * |
| 283 | * |
| 284 | * CREDITS_GROUP |
| 285 | * A list of the core developers |
| 286 | * |
| 287 | * |
| 288 | * CREDITS_MODULES |
| 289 | * |
| 290 | * A list of the extension modules for PHP, and their authors |
| 291 | * |
| 292 | * |
| 293 | * |
| 294 | * CREDITS_SAPI |
| 295 | * |
| 296 | * A list of the server API modules for PHP, and their authors |
| 297 | * |
| 298 | * |
| 299 | * |
| 300 | * |
| 301 | * |
| 302 | * @throws InfoException |
| 303 | * |
| 304 | */ |
| 305 | function phpcredits(int $flag = \CREDITS_ALL): void |
| 306 | { |
| 307 | error_clear_last(); |
| 308 | $result = \phpcredits($flag); |
| 309 | if ($result === \false) { |
| 310 | throw InfoException::createFromPhpError(); |
| 311 | } |
| 312 | } |
| 313 | /** |
| 314 | * Outputs a large amount of information about the current state of PHP. |
| 315 | * This includes information about PHP compilation options and extensions, |
| 316 | * the PHP version, server information and environment (if compiled as a |
| 317 | * module), the PHP environment, OS version information, paths, master and |
| 318 | * local values of configuration options, HTTP headers, and the PHP License. |
| 319 | * |
| 320 | * Because every system is setup differently, phpinfo is |
| 321 | * commonly used to check configuration settings and for available |
| 322 | * predefined variables |
| 323 | * on a given system. |
| 324 | * |
| 325 | * phpinfo is also a valuable debugging tool as it |
| 326 | * contains all EGPCS (Environment, GET, POST, Cookie, Server) data. |
| 327 | * |
| 328 | * @param int $what The output may be customized by passing one or more of the |
| 329 | * following constants bitwise values summed |
| 330 | * together in the optional what parameter. |
| 331 | * One can also combine the respective constants or bitwise values |
| 332 | * together with the bitwise or operator. |
| 333 | * |
| 334 | * |
| 335 | * phpinfo options |
| 336 | * |
| 337 | * |
| 338 | * |
| 339 | * Name (constant) |
| 340 | * Value |
| 341 | * Description |
| 342 | * |
| 343 | * |
| 344 | * |
| 345 | * |
| 346 | * INFO_GENERAL |
| 347 | * 1 |
| 348 | * |
| 349 | * The configuration line, php.ini location, build date, Web |
| 350 | * Server, System and more. |
| 351 | * |
| 352 | * |
| 353 | * |
| 354 | * INFO_CREDITS |
| 355 | * 2 |
| 356 | * |
| 357 | * PHP Credits. See also phpcredits. |
| 358 | * |
| 359 | * |
| 360 | * |
| 361 | * INFO_CONFIGURATION |
| 362 | * 4 |
| 363 | * |
| 364 | * Current Local and Master values for PHP directives. See |
| 365 | * also ini_get. |
| 366 | * |
| 367 | * |
| 368 | * |
| 369 | * INFO_MODULES |
| 370 | * 8 |
| 371 | * |
| 372 | * Loaded modules and their respective settings. See also |
| 373 | * get_loaded_extensions. |
| 374 | * |
| 375 | * |
| 376 | * |
| 377 | * INFO_ENVIRONMENT |
| 378 | * 16 |
| 379 | * |
| 380 | * Environment Variable information that's also available in |
| 381 | * $_ENV. |
| 382 | * |
| 383 | * |
| 384 | * |
| 385 | * INFO_VARIABLES |
| 386 | * 32 |
| 387 | * |
| 388 | * Shows all |
| 389 | * predefined variables from EGPCS (Environment, GET, |
| 390 | * POST, Cookie, Server). |
| 391 | * |
| 392 | * |
| 393 | * |
| 394 | * INFO_LICENSE |
| 395 | * 64 |
| 396 | * |
| 397 | * PHP License information. See also the license FAQ. |
| 398 | * |
| 399 | * |
| 400 | * |
| 401 | * INFO_ALL |
| 402 | * -1 |
| 403 | * |
| 404 | * Shows all of the above. |
| 405 | * |
| 406 | * |
| 407 | * |
| 408 | * |
| 409 | * |
| 410 | * @throws InfoException |
| 411 | * |
| 412 | */ |
| 413 | function phpinfo(int $what = \INFO_ALL): void |
| 414 | { |
| 415 | error_clear_last(); |
| 416 | $result = \phpinfo($what); |
| 417 | if ($result === \false) { |
| 418 | throw InfoException::createFromPhpError(); |
| 419 | } |
| 420 | } |
| 421 | /** |
| 422 | * Adds setting to the server environment. The |
| 423 | * environment variable will only exist for the duration of the current |
| 424 | * request. At the end of the request the environment is restored to its |
| 425 | * original state. |
| 426 | * |
| 427 | * @param string $setting The setting, like "FOO=BAR" |
| 428 | * @throws InfoException |
| 429 | * |
| 430 | */ |
| 431 | function putenv(string $setting): void |
| 432 | { |
| 433 | error_clear_last(); |
| 434 | $result = \putenv($setting); |
| 435 | if ($result === \false) { |
| 436 | throw InfoException::createFromPhpError(); |
| 437 | } |
| 438 | } |
| 439 | /** |
| 440 | * Sets the include_path |
| 441 | * configuration option for the duration of the script. |
| 442 | * |
| 443 | * @param string $new_include_path The new value for the include_path |
| 444 | * @return string Returns the old include_path on |
| 445 | * success. |
| 446 | * @throws InfoException |
| 447 | * |
| 448 | */ |
| 449 | function set_include_path(string $new_include_path): string |
| 450 | { |
| 451 | error_clear_last(); |
| 452 | $result = \set_include_path($new_include_path); |
| 453 | if ($result === \false) { |
| 454 | throw InfoException::createFromPhpError(); |
| 455 | } |
| 456 | return $result; |
| 457 | } |
| 458 | /** |
| 459 | * Set the number of seconds a script is allowed to run. If this is reached, |
| 460 | * the script returns a fatal error. The default limit is 30 seconds or, if |
| 461 | * it exists, the max_execution_time value defined in the |
| 462 | * php.ini. |
| 463 | * |
| 464 | * When called, set_time_limit restarts the timeout |
| 465 | * counter from zero. In other words, if the timeout is the default 30 |
| 466 | * seconds, and 25 seconds into script execution a call such as |
| 467 | * set_time_limit(20) is made, the script will run for a |
| 468 | * total of 45 seconds before timing out. |
| 469 | * |
| 470 | * @param int $seconds The maximum execution time, in seconds. If set to zero, no time limit |
| 471 | * is imposed. |
| 472 | * @throws InfoException |
| 473 | * |
| 474 | */ |
| 475 | function set_time_limit(int $seconds): void |
| 476 | { |
| 477 | error_clear_last(); |
| 478 | $result = \set_time_limit($seconds); |
| 479 | if ($result === \false) { |
| 480 | throw InfoException::createFromPhpError(); |
| 481 | } |
| 482 | } |
| 483 |