#50: Added a check to see if exec() is available to provide more OS-level information, or falls back to standard php_uname if not

This commit is contained in:
Andy Heathershaw 2017-09-29 20:15:24 +01:00
parent 435e47af17
commit c5e22c7a6e
2 changed files with 16 additions and 1 deletions

View File

@ -124,6 +124,12 @@ class MiscHelper
return MiscHelper::getEnvironmentSetting('APP_INSTALLED'); return MiscHelper::getEnvironmentSetting('APP_INSTALLED');
} }
public static function isExecEnabled()
{
$disabled = explode(',', ini_get('disable_functions'));
return !in_array('exec', $disabled);
}
/** /**
* Tests whether the provided URL belongs to the current application (i.e. both scheme and hostname match.) * Tests whether the provided URL belongs to the current application (i.e. both scheme and hostname match.)
* @param $url * @param $url

View File

@ -77,6 +77,15 @@ class DefaultController extends Controller
$metadataUpgradeNeeded = Photo::min('metadata_version') < PhotoService::METADATA_VERSION; $metadataUpgradeNeeded = Photo::min('metadata_version') < PhotoService::METADATA_VERSION;
// Default to a supported function call to get the OS version
$osVersion = sprintf('%s %s', php_uname('s'), php_uname('r'));
// If the exec() function is enabled, we can do a bit better
if (MiscHelper::isExecEnabled())
{
$osVersion = exec('lsb_release -ds 2>/dev/null || cat /etc/*release 2>/dev/null | head -n1 || uname -om');
}
return Theme::render('admin.index', [ return Theme::render('admin.index', [
'album_count' => $albumCount, 'album_count' => $albumCount,
'app_version' => config('app.version'), 'app_version' => config('app.version'),
@ -86,7 +95,7 @@ class DefaultController extends Controller
'metadata_upgrade_needed' => $metadataUpgradeNeeded, 'metadata_upgrade_needed' => $metadataUpgradeNeeded,
'photo_count' => $photoCount, 'photo_count' => $photoCount,
'php_version' => phpversion(), 'php_version' => phpversion(),
'os_version' => exec('lsb_release -ds 2>/dev/null || cat /etc/*release 2>/dev/null | head -n1 || uname -om'), 'os_version' => $osVersion,
'server_name' => gethostname(), 'server_name' => gethostname(),
'upload_file_size' => ini_get('upload_max_filesize'), 'upload_file_size' => ini_get('upload_max_filesize'),
'upload_max_limit' => ini_get('post_max_size'), 'upload_max_limit' => ini_get('post_max_size'),