table{width:100%}table td,table th{border:1px solid #dedede}'; echo '

Testing Server

'; echo self::success('BASE_PATH: '.BASE_PATH.''); echo self::success('PHP: '.phpversion().''); $v = Deprecation::dump_settings()['version']; if ($v) { echo self::success('SilverStipe version: '.$v.''); } else { echo self::success('SilverStipe version unknown: ' .(file_exists(BASE_PATH.'/framework') ? '3.x.x' : '4.x.x') .''); } echo self::success('Memory limit: '.ini_get('memory_limit').''); if (is_writable(TEMP_FOLDER)) { echo self::success('TMP (cache) dir '.TEMP_FOLDER.' dir is writable.'); } else { echo self::error('TMP (cache) dir '.TEMP_FOLDER.' dir is no writable!'); } echo '

Testing Uploads

'; $maxUpload = ini_get('upload_max_filesize'); $maxPost = ini_get('post_max_size'); echo self::success('PHP max upload size: '.$maxUpload); echo self::success('PHP max post size: '.$maxPost); echo self::success('So calculated max upload size: '.self::formatBytes(min( self::memstring2bytes($maxUpload), self::memstring2bytes($maxPost) ))); $defaultSizes = Config::inst()->get(Upload_Validator::class, 'default_max_file_size'); if ($defaultSizes) { if (!is_array($defaultSizes)) { echo self::error('default_max_file_size miss-configuration, plz fix'); var_dump($defaultSizes); die(); } echo '

Configured limits:

' .''; foreach ($defaultSizes as $k => $size) { echo ''; } echo '
FileSize limit
'.$k.''.$size.'
'; } if (is_writable(ASSETS_DIR)) { echo self::success('Assets dir '.ASSETS_DIR.' dir is writable.'); } else { echo self::error('Assets dir '.ASSETS_DIR.' dir is no writable!'); } if (function_exists('imagewebp')) { echo self::success('WebP is available'); } else { echo self::error('WebP is not available'); } die(); } public static function formatBytes($size, $precision = 2) { $base = log($size, 1024); $suffixes = array('', 'K', 'M', 'G', 'T'); return round(pow(1024, $base - floor($base)), $precision) . $suffixes[(string)floor($base)]; } public static function error($text) { return 'ERROR: '.$text.'
'; } public static function success($text) { return 'SUCCESS: '.$text.'
'; } public static function warning($text) { return 'WARNING: '.$text.'
'; } public static function renderValidation($result) { echo '

'; $msgs = $result->getMessages(); foreach ($msgs as $msg) { echo self::error($msg['fieldName'].': '.$msg['message']); } echo '

'; } public static function memstring2bytes($memString) { // Remove non-unit characters from the size $unit = preg_replace('/[^bkmgtpezy]/i', '', $memString); // Remove non-numeric characters from the size $size = preg_replace('/[^0-9\.]/', '', $memString); if ($unit) { // Find the position of the unit in the ordered string which is the power // of magnitude to multiply a kilobyte by return round($size * pow(1024, stripos('bkmgtpezy', $unit[0]))); } return round($size); } }