Skip to content

Commit

Permalink
add warning if values are too low (#764)
Browse files Browse the repository at this point in the history
  • Loading branch information
ildyria authored Oct 23, 2020
1 parent e5273b3 commit 77ad51e
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions app/ControllerFunctions/Diagnostics/IniSettingsCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,49 @@

class IniSettingsCheck implements DiagnosticCheckInterface
{
/**
* Return true if the upload_max_filesize is bellow what we want.
*/
private function convert_size(string $size): int
{
$size = trim($size);
$last = strtolower($size[strlen($size) - 1]);
$size = intval($size);

switch ($last) {
case 'g':
$size *= 1024;
// no break
case 'm':
$size *= 1024;
// no break
case 'k':
$size *= 1024;
}

return $size;
}

public function check(array &$errors): void
{
// Check php.ini Settings
// Load settings
$settings = Configs::get();

if (
ini_get('max_execution_time') < 200
&& ini_set('upload_max_filesize', '20M') === false
$this->convert_size(ini_get('upload_max_filesize')) < $this->convert_size('30M')
) {
$errors[]
= 'Warning: You may experience problems when uploading a photo of large size. Take a look in the FAQ for details.';
}
if (
$this->convert_size(ini_get('post_max_size')) < $this->convert_size('100M')
) {
$errors[]
= 'Warning: You may experience problems when uploading a photos of large size. Take a look in the FAQ for details.';
}
if (
intval(ini_get('max_execution_time')) < 200
) {
$errors[]
= 'Warning: You may experience problems when uploading a large amount of photos. Take a look in the FAQ for details.';
Expand Down

0 comments on commit 77ad51e

Please sign in to comment.