diff options
Diffstat (limited to 'application')
-rw-r--r-- | application/ApplicationUtils.php | 15 | ||||
-rw-r--r-- | application/PageBuilder.php | 9 | ||||
-rw-r--r-- | application/Updater.php | 4 |
3 files changed, 24 insertions, 4 deletions
diff --git a/application/ApplicationUtils.php b/application/ApplicationUtils.php index 123cc0b3..5643f4a0 100644 --- a/application/ApplicationUtils.php +++ b/application/ApplicationUtils.php | |||
@@ -221,4 +221,19 @@ class ApplicationUtils | |||
221 | 221 | ||
222 | return $errors; | 222 | return $errors; |
223 | } | 223 | } |
224 | |||
225 | /** | ||
226 | * Returns a salted hash representing the current Shaarli version. | ||
227 | * | ||
228 | * Useful for assets browser cache. | ||
229 | * | ||
230 | * @param string $currentVersion of Shaarli | ||
231 | * @param string $salt User personal salt, also used for the authentication | ||
232 | * | ||
233 | * @return string version hash | ||
234 | */ | ||
235 | public static function getVersionHash($currentVersion, $salt) | ||
236 | { | ||
237 | return hash_hmac('sha256', $currentVersion, $salt); | ||
238 | } | ||
224 | } | 239 | } |
diff --git a/application/PageBuilder.php b/application/PageBuilder.php index 7a42400d..291860ad 100644 --- a/application/PageBuilder.php +++ b/application/PageBuilder.php | |||
@@ -49,7 +49,7 @@ class PageBuilder | |||
49 | 49 | ||
50 | try { | 50 | try { |
51 | $version = ApplicationUtils::checkUpdate( | 51 | $version = ApplicationUtils::checkUpdate( |
52 | shaarli_version, | 52 | SHAARLI_VERSION, |
53 | $this->conf->get('resource.update_check'), | 53 | $this->conf->get('resource.update_check'), |
54 | $this->conf->get('updates.check_updates_interval'), | 54 | $this->conf->get('updates.check_updates_interval'), |
55 | $this->conf->get('updates.check_updates'), | 55 | $this->conf->get('updates.check_updates'), |
@@ -75,7 +75,11 @@ class PageBuilder | |||
75 | } | 75 | } |
76 | $this->tpl->assign('searchcrits', $searchcrits); | 76 | $this->tpl->assign('searchcrits', $searchcrits); |
77 | $this->tpl->assign('source', index_url($_SERVER)); | 77 | $this->tpl->assign('source', index_url($_SERVER)); |
78 | $this->tpl->assign('version', shaarli_version); | 78 | $this->tpl->assign('version', SHAARLI_VERSION); |
79 | $this->tpl->assign( | ||
80 | 'version_hash', | ||
81 | ApplicationUtils::getVersionHash(SHAARLI_VERSION, $this->conf->get('credentials.salt')) | ||
82 | ); | ||
79 | $this->tpl->assign('scripturl', index_url($_SERVER)); | 83 | $this->tpl->assign('scripturl', index_url($_SERVER)); |
80 | $this->tpl->assign('privateonly', !empty($_SESSION['privateonly'])); // Show only private links? | 84 | $this->tpl->assign('privateonly', !empty($_SESSION['privateonly'])); // Show only private links? |
81 | $this->tpl->assign('untaggedonly', !empty($_SESSION['untaggedonly'])); | 85 | $this->tpl->assign('untaggedonly', !empty($_SESSION['untaggedonly'])); |
@@ -89,6 +93,7 @@ class PageBuilder | |||
89 | $this->tpl->assign('feed_type', $this->conf->get('feed.show_atom', true) !== false ? 'atom' : 'rss'); | 93 | $this->tpl->assign('feed_type', $this->conf->get('feed.show_atom', true) !== false ? 'atom' : 'rss'); |
90 | $this->tpl->assign('hide_timestamps', $this->conf->get('privacy.hide_timestamps', false)); | 94 | $this->tpl->assign('hide_timestamps', $this->conf->get('privacy.hide_timestamps', false)); |
91 | $this->tpl->assign('token', getToken($this->conf)); | 95 | $this->tpl->assign('token', getToken($this->conf)); |
96 | |||
92 | if ($this->linkDB !== null) { | 97 | if ($this->linkDB !== null) { |
93 | $this->tpl->assign('tags', $this->linkDB->linksCountPerTag()); | 98 | $this->tpl->assign('tags', $this->linkDB->linksCountPerTag()); |
94 | } | 99 | } |
diff --git a/application/Updater.php b/application/Updater.php index 40a15906..72b2def0 100644 --- a/application/Updater.php +++ b/application/Updater.php | |||
@@ -398,7 +398,7 @@ class Updater | |||
398 | */ | 398 | */ |
399 | public function updateMethodCheckUpdateRemoteBranch() | 399 | public function updateMethodCheckUpdateRemoteBranch() |
400 | { | 400 | { |
401 | if (shaarli_version === 'dev' || $this->conf->get('updates.check_updates_branch') === 'latest') { | 401 | if (SHAARLI_VERSION === 'dev' || $this->conf->get('updates.check_updates_branch') === 'latest') { |
402 | return true; | 402 | return true; |
403 | } | 403 | } |
404 | 404 | ||
@@ -413,7 +413,7 @@ class Updater | |||
413 | $latestMajor = $matches[1]; | 413 | $latestMajor = $matches[1]; |
414 | 414 | ||
415 | // Get current major version digit | 415 | // Get current major version digit |
416 | preg_match('/(\d+)\.\d+$/', shaarli_version, $matches); | 416 | preg_match('/(\d+)\.\d+$/', SHAARLI_VERSION, $matches); |
417 | $currentMajor = $matches[1]; | 417 | $currentMajor = $matches[1]; |
418 | 418 | ||
419 | if ($currentMajor === $latestMajor) { | 419 | if ($currentMajor === $latestMajor) { |