<===

ProNotes

2026-01-17 07:30:18
#!/usr/bin/env php
<?php
// php-cli-info.php

function where_to_change(string $name): string
{
    switch ($name) {
        case 'upload_max_filesize':
        case 'post_max_size':
        case 'max_file_uploads':
        case 'file_uploads':
        case 'max_execution_time':
        case 'max_input_time':
        case 'memory_limit':
            return 'php.ini / .user.ini / .htaccess / httpd.conf / ini_set()';
        case 'display_errors':
        case 'error_reporting':
            return 'php.ini / ini_set()';
        case 'LimitRequestBody':
            return 'httpd.conf / vhost / <Directory> / .htaccess';
        default:
            return 'см. доку';
    }
}

function normalizeSize(string $val): int {
    $val = trim($val);
    if ($val === '' || $val === '-1') return -1;

    $unit = strtolower(substr($val, -1));
    $num  = (float)$val;

    if ($unit === 'g') return (int)($num * 1024 * 1024 * 1024);
    if ($unit === 'm') return (int)($num * 1024 * 1024);
    if ($unit === 'k') return (int)($num * 1024);
    return (int)$num;
}

echo "PHP: " . PHP_VERSION . " | SAPI: " . php_sapi_name() . PHP_EOL;
echo "php.ini: " . php_ini_loaded_file() . PHP_EOL . PHP_EOL;

$opts = [
    'max_execution_time',
    'max_input_time',
    'memory_limit',
    'file_uploads',
    'upload_max_filesize',
    'post_max_size',
    'max_file_uploads',
    'display_errors',
    'error_reporting',
];

echo "=== PHP settings ===" . PHP_EOL;
foreach ($opts as $name) {
    $val = ini_get($name);
    echo str_pad($name, 22)
        . " = " . str_pad((string)$val, 12)
        . " | " . where_to_change($name)
        . PHP_EOL;
}
echo PHP_EOL;

$uploadMax  = normalizeSize(ini_get('upload_max_filesize'));
$postMax    = normalizeSize(ini_get('post_max_size'));
$memory     = normalizeSize(ini_get('memory_limit'));
$limits     = array_filter([$uploadMax, $postMax, $memory], function($v){ return $v > 0; });
$effective  = empty($limits) ? -1 : min($limits);

echo "Effective PHP upload limit: "
   . ($effective < 0 ? "no limit" : $effective . " bytes")
   . PHP_EOL . PHP_EOL;

echo "=== HTTPD (Apache) note ===" . PHP_EOL;
echo "LimitRequestBody: " . where_to_change('LimitRequestBody') . PHP_EOL;
echo "mod_php: php_value/php_admin_value upload_max_filesize, post_max_size в vhost/.htaccess" . PHP_EOL;
← Previous Next →
Back to list