aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2016-08-09 21:06:02 +0200
committerAndreas Gohr <andi@splitbrain.org>2016-08-09 21:06:02 +0200
commitd6c7b502a6fc7d9ed97c8e4be017dec347fb916a (patch)
tree90109fd0f4c58c2371a31a941d7730656930d06e
parent3eb8980bccc4529357f84465d1a6873232fe938d (diff)
downloaddokuwiki-d6c7b502a6fc7d9ed97c8e4be017dec347fb916a.tar.gz
dokuwiki-d6c7b502a6fc7d9ed97c8e4be017dec347fb916a.zip
Check the server has a sensible time
DokuWiki assumes that the server's time is correct. Especially page revisions and cache handling depend on correct time. If that's not the case it can lead to problems later (as mentioned in #1644). This patch adds a very simple time check using the Date response header from the DokuWiki server to our do=check mechanism.
-rw-r--r--inc/infoutils.php39
1 files changed, 31 insertions, 8 deletions
diff --git a/inc/infoutils.php b/inc/infoutils.php
index fe312d13f..a124e2c95 100644
--- a/inc/infoutils.php
+++ b/inc/infoutils.php
@@ -60,7 +60,7 @@ function getVersionData(){
//import version string
if(file_exists(DOKU_INC.'VERSION')){
//official release
- $version['date'] = trim(io_readfile(DOKU_INC.'VERSION'));
+ $version['date'] = trim(io_readFile(DOKU_INC.'VERSION'));
$version['type'] = 'Release';
}elseif(is_dir(DOKU_INC.'.git')){
$version['type'] = 'Git';
@@ -249,18 +249,41 @@ function check(){
}
}
- if ($index_corrupted)
- msg('The search index is corrupted. It might produce wrong results and most
+ if($index_corrupted) {
+ msg(
+ 'The search index is corrupted. It might produce wrong results and most
probably needs to be rebuilt. See
<a href="http://www.dokuwiki.org/faq:searchindex">faq:searchindex</a>
- for ways to rebuild the search index.', -1);
- elseif (!empty($lengths))
+ for ways to rebuild the search index.', -1
+ );
+ } elseif(!empty($lengths)) {
msg('The search index seems to be working', 1);
- else
- msg('The search index is empty. See
+ } else {
+ msg(
+ 'The search index is empty. See
<a href="http://www.dokuwiki.org/faq:searchindex">faq:searchindex</a>
for help on how to fix the search index. If the default indexer
- isn\'t used or the wiki is actually empty this is normal.');
+ isn\'t used or the wiki is actually empty this is normal.'
+ );
+ }
+
+ // rough time check
+ $http = new DokuHTTPClient();
+ $http->max_redirect = 0;
+ $http->timeout = 3;
+ $http->sendRequest('http://www.dokuwiki.org', '', 'HEAD');
+ $now = time();
+ if(isset($http->resp_headers['date'])) {
+ $time = strtotime($http->resp_headers['date']);
+ $diff = $time - $now;
+
+ if(abs($diff) < 4) {
+ msg("Server time seems to be okay. Diff: {$diff}s", 1);
+ } else {
+ msg("Your server's clock seems to be out of sync! Consider configuring a sync with a NTP server. Diff: {$diff}s");
+ }
+ }
+
}
/**