diff options
Diffstat (limited to 'application/ApplicationUtils.php')
-rw-r--r-- | application/ApplicationUtils.php | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/application/ApplicationUtils.php b/application/ApplicationUtils.php index 85dcbeeb..911873a0 100644 --- a/application/ApplicationUtils.php +++ b/application/ApplicationUtils.php | |||
@@ -149,12 +149,13 @@ class ApplicationUtils | |||
149 | public static function checkPHPVersion($minVersion, $curVersion) | 149 | public static function checkPHPVersion($minVersion, $curVersion) |
150 | { | 150 | { |
151 | if (version_compare($curVersion, $minVersion) < 0) { | 151 | if (version_compare($curVersion, $minVersion) < 0) { |
152 | throw new Exception( | 152 | $msg = t( |
153 | 'Your PHP version is obsolete!' | 153 | 'Your PHP version is obsolete!' |
154 | .' Shaarli requires at least PHP '.$minVersion.', and thus cannot run.' | 154 | . ' Shaarli requires at least PHP %s, and thus cannot run.' |
155 | .' Your PHP version has known security vulnerabilities and should be' | 155 | . ' Your PHP version has known security vulnerabilities and should be' |
156 | .' updated as soon as possible.' | 156 | . ' updated as soon as possible.' |
157 | ); | 157 | ); |
158 | throw new Exception(sprintf($msg, $minVersion)); | ||
158 | } | 159 | } |
159 | } | 160 | } |
160 | 161 | ||
@@ -168,17 +169,18 @@ class ApplicationUtils | |||
168 | public static function checkResourcePermissions($conf) | 169 | public static function checkResourcePermissions($conf) |
169 | { | 170 | { |
170 | $errors = array(); | 171 | $errors = array(); |
172 | $rainTplDir = rtrim($conf->get('resource.raintpl_tpl'), '/'); | ||
171 | 173 | ||
172 | // Check script and template directories are readable | 174 | // Check script and template directories are readable |
173 | foreach (array( | 175 | foreach (array( |
174 | 'application', | 176 | 'application', |
175 | 'inc', | 177 | 'inc', |
176 | 'plugins', | 178 | 'plugins', |
177 | $conf->get('resource.raintpl_tpl'), | 179 | $rainTplDir, |
178 | $conf->get('resource.raintpl_tpl').'/'.$conf->get('resource.theme'), | 180 | $rainTplDir.'/'.$conf->get('resource.theme'), |
179 | ) as $path) { | 181 | ) as $path) { |
180 | if (! is_readable(realpath($path))) { | 182 | if (! is_readable(realpath($path))) { |
181 | $errors[] = '"'.$path.'" directory is not readable'; | 183 | $errors[] = '"'.$path.'" '. t('directory is not readable'); |
182 | } | 184 | } |
183 | } | 185 | } |
184 | 186 | ||
@@ -190,10 +192,10 @@ class ApplicationUtils | |||
190 | $conf->get('resource.raintpl_tmp'), | 192 | $conf->get('resource.raintpl_tmp'), |
191 | ) as $path) { | 193 | ) as $path) { |
192 | if (! is_readable(realpath($path))) { | 194 | if (! is_readable(realpath($path))) { |
193 | $errors[] = '"'.$path.'" directory is not readable'; | 195 | $errors[] = '"'.$path.'" '. t('directory is not readable'); |
194 | } | 196 | } |
195 | if (! is_writable(realpath($path))) { | 197 | if (! is_writable(realpath($path))) { |
196 | $errors[] = '"'.$path.'" directory is not writable'; | 198 | $errors[] = '"'.$path.'" '. t('directory is not writable'); |
197 | } | 199 | } |
198 | } | 200 | } |
199 | 201 | ||
@@ -211,13 +213,28 @@ class ApplicationUtils | |||
211 | } | 213 | } |
212 | 214 | ||
213 | if (! is_readable(realpath($path))) { | 215 | if (! is_readable(realpath($path))) { |
214 | $errors[] = '"'.$path.'" file is not readable'; | 216 | $errors[] = '"'.$path.'" '. t('file is not readable'); |
215 | } | 217 | } |
216 | if (! is_writable(realpath($path))) { | 218 | if (! is_writable(realpath($path))) { |
217 | $errors[] = '"'.$path.'" file is not writable'; | 219 | $errors[] = '"'.$path.'" '. t('file is not writable'); |
218 | } | 220 | } |
219 | } | 221 | } |
220 | 222 | ||
221 | return $errors; | 223 | return $errors; |
222 | } | 224 | } |
225 | |||
226 | /** | ||
227 | * Returns a salted hash representing the current Shaarli version. | ||
228 | * | ||
229 | * Useful for assets browser cache. | ||
230 | * | ||
231 | * @param string $currentVersion of Shaarli | ||
232 | * @param string $salt User personal salt, also used for the authentication | ||
233 | * | ||
234 | * @return string version hash | ||
235 | */ | ||
236 | public static function getVersionHash($currentVersion, $salt) | ||
237 | { | ||
238 | return hash_hmac('sha256', $currentVersion, $salt); | ||
239 | } | ||
223 | } | 240 | } |