]>
git.immae.eu Git - github/shaarli/Shaarli.git/blob - application/ApplicationUtils.php
3 * Shaarli (application) utilities
9 * Checks the PHP version to ensure Shaarli can run
11 * @param string $minVersion minimum PHP required version
12 * @param string $curVersion current PHP version (use PHP_VERSION)
14 * @throws Exception the PHP version is not supported
16 public static function checkPHPVersion($minVersion, $curVersion)
18 if (version_compare($curVersion, $minVersion) < 0) {
20 'Your PHP version is obsolete!'
21 .' Shaarli requires at least PHP '.$minVersion.', and thus cannot run.'
22 .' Your PHP version has known security vulnerabilities and should be'
23 .' updated as soon as possible.'
29 * Checks Shaarli has the proper access permissions to its resources
31 * @param array $globalConfig The $GLOBALS['config'] array
33 * @return array A list of the detected configuration issues
35 public static function checkResourcePermissions($globalConfig)
39 // Check script and template directories are readable
44 $globalConfig['RAINTPL_TPL']
46 if (! is_readable(realpath($path))) {
47 $errors[] = '"'.$path.'" directory is not readable';
51 // Check cache and data directories are readable and writeable
53 $globalConfig['CACHEDIR'],
54 $globalConfig['DATADIR'],
55 $globalConfig['PAGECACHE'],
56 $globalConfig['RAINTPL_TMP']
58 if (! is_readable(realpath($path))) {
59 $errors[] = '"'.$path.'" directory is not readable';
61 if (! is_writable(realpath($path))) {
62 $errors[] = '"'.$path.'" directory is not writable';
66 // Check configuration files are readable and writeable
68 $globalConfig['CONFIG_FILE'],
69 $globalConfig['DATASTORE'],
70 $globalConfig['IPBANS_FILENAME'],
71 $globalConfig['LOG_FILE'],
72 $globalConfig['UPDATECHECK_FILENAME']
74 if (! is_file(realpath($path))) {
75 # the file may not exist yet
79 if (! is_readable(realpath($path))) {
80 $errors[] = '"'.$path.'" file is not readable';
82 if (! is_writable(realpath($path))) {
83 $errors[] = '"'.$path.'" file is not writable';