diff options
| -rw-r--r-- | admin_media.php | 6 | ||||
| -rw-r--r-- | admin_users.php | 2 | ||||
| -rw-r--r-- | editnews.php | 6 | ||||
| -rw-r--r-- | includes/functions/functions.php | 4 | ||||
| -rw-r--r-- | includes/functions/functions_date.php | 10 | ||||
| -rw-r--r-- | includes/reportheader.php | 2 | ||||
| -rw-r--r-- | includes/session.php | 15 | ||||
| -rw-r--r-- | library/WT/Report/Base.php | 2 | ||||
| -rw-r--r-- | library/WT/Stats.php | 10 | ||||
| -rw-r--r-- | login.php | 5 | ||||
| -rw-r--r-- | mediafirewall.php | 2 | ||||
| -rw-r--r-- | message.php | 6 | ||||
| -rw-r--r-- | modules_v3/gedcom_news/module.php | 3 | ||||
| -rw-r--r-- | modules_v3/html/module.php | 4 | ||||
| -rw-r--r-- | modules_v3/lightbox/module.php | 2 | ||||
| -rw-r--r-- | modules_v3/review_changes/module.php | 4 | ||||
| -rw-r--r-- | modules_v3/sitemap/module.php | 8 | ||||
| -rw-r--r-- | themes/_administration/header.php | 2 |
18 files changed, 42 insertions, 51 deletions
diff --git a/admin_media.php b/admin_media.php index 33aeb26e62..76f1ffcd0e 100644 --- a/admin_media.php +++ b/admin_media.php @@ -121,7 +121,7 @@ function move_files($path, $protect) { $timelimit=WT_Site::preference('MAX_EXECUTION_TIME'); if ($dir=@opendir($path)) { while (($element=readdir($dir))!== false) { - $exectime = time() - $starttime; + $exectime = WT_TIMESTAMP - $starttime; if (($timelimit != 0) && ($timelimit - $exectime) < 3) { // bail now to ensure nothing is lost echo "<div class=\"error\">".WT_I18N::translate('The execution time limit was reached. Try the command again to move the rest of the files.')."</div>"; @@ -183,7 +183,7 @@ function set_perms($path) { $timelimit=WT_Site::preference('MAX_EXECUTION_TIME'); if ($dir=@opendir($path)) { while (($element=readdir($dir))!== false) { - $exectime = time() - $starttime; + $exectime = WT_TIMESTAMP - $starttime; if (($timelimit != 0) && ($timelimit - $exectime) < 3) { // bail now to ensure nothing is lost echo "<div class=\"error\">".WT_I18N::translate('The execution time limit was reached. Try the command again on a smaller directory.')."</div>"; @@ -220,7 +220,7 @@ function set_perms($path) { } // global var used by recursive functions -$starttime = time(); +$starttime = WT_TIMESTAMP; $operation_count = 0; // TODO Determine source and validation requirements for these variables diff --git a/admin_users.php b/admin_users.php index e831dbd87b..cce1b6985a 100644 --- a/admin_users.php +++ b/admin_users.php @@ -161,7 +161,7 @@ case 'loadrows': } // $aData[9] is the sortable last-login timestamp if ($aData[9]) { - $aData[10]=format_timestamp($aData[9]).'<br>'.WT_I18N::time_ago(time() - $aData[9]); + $aData[10]=format_timestamp($aData[9]).'<br>'.WT_I18N::time_ago(WT_TIMESTAMP - $aData[9]); } else { $aData[10]=WT_I18N::translate('Never'); } diff --git a/editnews.php b/editnews.php index c9e41e2568..fe7cc8ee5a 100644 --- a/editnews.php +++ b/editnews.php @@ -50,7 +50,7 @@ case 'compose': $news = array(); $news['user_id'] = $user_id; $news['gedcom_id'] = $gedcom_id; - $news['date'] = time(); + $news['date'] = WT_TIMESTAMP; $news['title'] = ''; $news['text'] = ''; } @@ -85,9 +85,9 @@ case 'save': } $message['user_id'] = $user_id; $message['gedcom_id'] = $gedcom_id; - $message['date']=time(); + $message['date'] = WT_TIMESTAMP; $message['title'] = $title; - $message['text'] = $text; + $message['text'] = $text; addNews($message); $controller->addInlineJavascript('window.opener.location.reload();window.close();'); break; diff --git a/includes/functions/functions.php b/includes/functions/functions.php index 77b1bf80e2..f5d82d9871 100644 --- a/includes/functions/functions.php +++ b/includes/functions/functions.php @@ -170,13 +170,13 @@ function fetch_remote_file($host, $path, $timeout=3) { // installation statistics which can be found at http://svn.webtrees.net/statistics.html function fetch_latest_version() { $last_update_timestamp=WT_Site::preference('LATEST_WT_VERSION_TIMESTAMP'); - if ($last_update_timestamp < time()-24*60*60) { + if ($last_update_timestamp < WT_TIMESTAMP - 24*60*60) { $row=WT_DB::prepare("SHOW VARIABLES LIKE 'version'")->fetchOneRow(); $params='?w='.WT_VERSION.WT_VERSION_RELEASE.'&p='.PHP_VERSION.'&m='.$row->value.'&o='.(DIRECTORY_SEPARATOR=='/'?'u':'w'); $latest_version_txt=fetch_remote_file('svn.webtrees.net', '/build/latest-version.txt'.$params); if ($latest_version_txt) { WT_Site::preference('LATEST_WT_VERSION', $latest_version_txt); - WT_Site::preference('LATEST_WT_VERSION_TIMESTAMP', time()); + WT_Site::preference('LATEST_WT_VERSION_TIMESTAMP', WT_TIMESTAMP); return $latest_version_txt; } else { // Cannot connect to server - use cached version (if we have one) diff --git a/includes/functions/functions_date.php b/includes/functions/functions_date.php index a1645bfb22..61b14c883f 100644 --- a/includes/functions/functions_date.php +++ b/includes/functions/functions_date.php @@ -133,13 +133,3 @@ function format_timestamp($time) { function timestamp_to_gedcom_date($time) { return new WT_Date(strtoupper(date('j M Y', $time))); } - -//////////////////////////////////////////////////////////////////////////////// -// Get the current timestamp of the client, not the server -//////////////////////////////////////////////////////////////////////////////// -function client_time() { - global $WT_SESSION; - return time()-$WT_SESSION->timediff; -} - -?> diff --git a/includes/reportheader.php b/includes/reportheader.php index f2fcf3c07d..b11dadb011 100644 --- a/includes/reportheader.php +++ b/includes/reportheader.php @@ -190,7 +190,7 @@ function InputSHandler($attrs) { if ($match[1]=="-") { $plus = -1; } - $input["default"] = date("d M Y", time()+$plus*60*60*24*$match[2]); + $input["default"] = date("d M Y", WT_TIMESTAMP + $plus*60*60*24*$match[2]); } else { $input["default"] = $attrs["default"]; } diff --git a/includes/session.php b/includes/session.php index e7de97c8e5..407684f517 100644 --- a/includes/session.php +++ b/includes/session.php @@ -361,7 +361,7 @@ if (!$SEARCH_SPIDER && !$WT_SESSION->initiated) { } // Who are we? -define('WT_USER_ID', getUserId()); +define('WT_USER_ID', getUserId()); define('WT_USER_NAME', getUserName()); define('WT_USER_IS_ADMIN', userIsAdmin (WT_USER_ID)); define('WT_USER_AUTO_ACCEPT', userAutoAccept(WT_USER_ID)); @@ -418,8 +418,11 @@ if (empty($WEBTREES_EMAIL)) { // Use the server date to calculate privacy, etc. // Use the client date to show ages, etc. -define('WT_SERVER_JD', 2440588+(int)(time()/86400)); -define('WT_CLIENT_JD', 2440588+(int)(client_time()/86400)); +define('WT_TIMESTAMP', time()); +define('WT_CLIENT_TIMESTAMP', WT_TIMESTAMP - $WT_SESSION->timediff); + +define('WT_SERVER_JD', 2440588 + (int)(WT_TIMESTAMP /86400)); +define('WT_CLIENT_JD', 2440588 + (int)(WT_CLIENT_TIMESTAMP/86400)); // Application configuration data - things that aren't (yet?) user-editable require WT_ROOT.'includes/config_data.php'; @@ -479,9 +482,9 @@ if ($REQUIRE_AUTHENTICATION && !WT_USER_ID && !in_array(WT_SCRIPT_NAME, array('l if (WT_USER_ID) { //-- update the login time every 5 minutes - if (time()-$WT_SESSION->activity_time > 300) { - set_user_setting(WT_USER_ID, 'sessiontime', time()); - $WT_SESSION->activity_time = time(); + if (WT_TIMESTAMP-$WT_SESSION->activity_time > 300) { + set_user_setting(WT_USER_ID, 'sessiontime', WT_TIMESTAMP); + $WT_SESSION->activity_time = WT_TIMESTAMP; } } diff --git a/library/WT/Report/Base.php b/library/WT/Report/Base.php index fd0ca914cf..50f5fa4929 100644 --- a/library/WT/Report/Base.php +++ b/library/WT/Report/Base.php @@ -1619,7 +1619,7 @@ function CellEHandler() { function NowSHandler() { global $currentElement; - $g = timestamp_to_gedcom_date(client_time()); + $g = timestamp_to_gedcom_date(WT_CLIENT_TIMESTAMP); $currentElement->addText($g->Display()); } diff --git a/library/WT/Stats.php b/library/WT/Stats.php index aa89618a2d..7c005af08c 100644 --- a/library/WT/Stats.php +++ b/library/WT/Stats.php @@ -3843,17 +3843,17 @@ class WT_Stats { // Date & Time // /////////////////////////////////////////////////////////////////////////////// - static function serverDate () { return timestamp_to_gedcom_date(time())->Display(false);} + static function serverDate () { return timestamp_to_gedcom_date(WT_TIMESTAMP)->Display(false);} static function serverTime () { return date('g:i a');} static function serverTime24 () { return date('G:i');} static function serverTimezone () { return date('T');} - static function browserDate () { return timestamp_to_gedcom_date(client_time())->Display(false);} + static function browserDate () { return timestamp_to_gedcom_date(WT_CLIENT_TIMESTAMP)->Display(false);} - static function browserTime () { return date('g:i a', client_time());} - static function browserTime24 () { return date('G:i', client_time());} - static function browserTimezone() { return date('T', client_time());} + static function browserTime () { return date('g:i a', WT_CLIENT_TIMESTAMP);} + static function browserTime24 () { return date('G:i', WT_CLIENT_TIMESTAMP);} + static function browserTimezone() { return date('T', WT_CLIENT_TIMESTAMP);} /////////////////////////////////////////////////////////////////////////////// // Tools // @@ -83,11 +83,10 @@ default: default: // Success if ($usertime) { - $WT_SESSION->usertime=@strtotime($usertime); + $WT_SESSION->timediff=WT_TIMESTAMP - strtotime($usertime); } else { - $WT_SESSION->usertime=time(); + $WT_SESSION->timediff=0; } - $WT_SESSION->timediff=time()-$WT_SESSION->usertime; $WT_SESSION->locale =get_user_setting($user_id, 'language'); $WT_SESSION->theme_dir=get_user_setting($user_id, 'theme'); diff --git a/mediafirewall.php b/mediafirewall.php index 7b53556919..06b796a333 100644 --- a/mediafirewall.php +++ b/mediafirewall.php @@ -390,7 +390,7 @@ $filetime = $controller->record->getFiletime($which); $filetimeHeader = gmdate("D, d M Y H:i:s", $filetime).' GMT'; $expireOffset = 3600 * 24; // tell browser to cache this image for 24 hours if (safe_GET('cb')) $expireOffset = $expireOffset * 7; // if cb parameter was sent, cache for 7 days -$expireHeader = gmdate("D, d M Y H:i:s", time() + $expireOffset) . " GMT"; +$expireHeader = gmdate("D, d M Y H:i:s", WT_TIMESTAMP + $expireOffset) . " GMT"; $type = isImageTypeSupported($imgsize['ext']); $usewatermark = false; diff --git a/message.php b/message.php index 86f79366c9..601544b75c 100644 --- a/message.php +++ b/message.php @@ -170,11 +170,11 @@ case 'send': $sixmos = 60*60*24*30*6; //-- timestamp for six months foreach (get_all_users() as $user_id=>$user_name) { // SEE Bug [ 1827547 ] Message to inactive users sent to newcomers - if (get_user_setting($user_id,'sessiontime')>0 && (time() - get_user_setting($user_id, 'sessiontime') > $sixmos)) { + if (get_user_setting($user_id,'sessiontime')>0 && (WT_TIMESTAMP - get_user_setting($user_id, 'sessiontime') > $sixmos)) { $toarray[$user_id] = $user_name; } //-- not verified by registration past 6 months - else if (!get_user_setting($user_id, 'verified_by_admin') && (time() - get_user_setting($user_id, 'reg_timestamp') > $sixmos)) { + else if (!get_user_setting($user_id, 'verified_by_admin') && (WT_TIMESTAMP - get_user_setting($user_id, 'reg_timestamp') > $sixmos)) { $toarray[$user_id] = $user_name; } } @@ -190,7 +190,7 @@ case 'send': } $message['subject'] = $subject; $message['body'] = $body; - $message['created'] = time(); + $message['created'] = WT_TIMESTAMP; $message['method'] = $method; $message['url'] = $url; if ($i>0) $message['no_from'] = true; diff --git a/modules_v3/gedcom_news/module.php b/modules_v3/gedcom_news/module.php index 0efec34bbd..8ea7481098 100644 --- a/modules_v3/gedcom_news/module.php +++ b/modules_v3/gedcom_news/module.php @@ -95,7 +95,6 @@ class gedcom_news_WT_Module extends WT_Module implements WT_Module_Block { $content .= WT_I18N::translate('No News articles have been submitted.').'<br>'; } $c = 0; - $td = time(); foreach ($usernews as $news) { if ($limit=='count') { if ($c >= $flag) { @@ -104,7 +103,7 @@ class gedcom_news_WT_Module extends WT_Module implements WT_Module_Block { $c++; } if ($limit=='date') { - if ((int)(($td - $news['date']) / 86400) > $flag) { + if ((int)((WT_TIMESTAMP - $news['date']) / 86400) > $flag) { break; } } diff --git a/modules_v3/html/module.php b/modules_v3/html/module.php index 97b1f22bea..26222b087c 100644 --- a/modules_v3/html/module.php +++ b/modules_v3/html/module.php @@ -106,7 +106,7 @@ class html_WT_Module extends WT_Module implements WT_Module_Block { $content = $html; if (get_block_setting($block_id, 'show_timestamp', false)) { - $content.='<br>'.format_timestamp(get_block_setting($block_id, 'timestamp', time())); + $content.='<br>'.format_timestamp(get_block_setting($block_id, 'timestamp', WT_TIMESTAMP)); } if ($template) { @@ -315,7 +315,7 @@ class html_WT_Module extends WT_Module implements WT_Module_Block { echo WT_I18N::translate('Show the date and time of update'); echo '</td><td class="optionbox">'; echo edit_field_yes_no('show_timestamp', $show_timestamp); - echo '<input type="hidden" name="timestamp" value="'.time().'">'; + echo '<input type="hidden" name="timestamp" value="', WT_TIMESTAMP, '">'; echo '</td></tr>'; $languages=get_block_setting($block_id, 'languages'); diff --git a/modules_v3/lightbox/module.php b/modules_v3/lightbox/module.php index f743307b2c..5891af7f8a 100644 --- a/modules_v3/lightbox/module.php +++ b/modules_v3/lightbox/module.php @@ -48,7 +48,7 @@ class lightbox_WT_Module extends WT_Module implements WT_Module_Config, WT_Modul case 'js': // tell browser to cache this javascript for 5 minutes $expireOffset = 60 * 5; - $expireHeader = gmdate("D, d M Y H:i:s", time() + $expireOffset) . " GMT"; + $expireHeader = gmdate("D, d M Y H:i:s", WT_TIMESTAMP + $expireOffset) . " GMT"; header('Content-type: application/javascript'); header('Cache-control:'); header('Pragma:'); diff --git a/modules_v3/review_changes/module.php b/modules_v3/review_changes/module.php index 74920c9ee0..d02615e361 100644 --- a/modules_v3/review_changes/module.php +++ b/modules_v3/review_changes/module.php @@ -64,8 +64,8 @@ class review_changes_WT_Module extends WT_Module implements WT_Module_Block { if ($changes) { //-- if the time difference from the last email is greater than 24 hours then send out another email $LAST_CHANGE_EMAIL=WT_Site::preference('LAST_CHANGE_EMAIL'); - if (time()-$LAST_CHANGE_EMAIL > (60*60*24*$days)) { - $LAST_CHANGE_EMAIL = time(); + if (WT_TIMESTAMP - $LAST_CHANGE_EMAIL > (60*60*24*$days)) { + $LAST_CHANGE_EMAIL = WT_TIMESTAMP; WT_Site::preference('LAST_CHANGE_EMAIL', $LAST_CHANGE_EMAIL); if ($sendmail=="yes") { // Which users have pending changes? diff --git a/modules_v3/sitemap/module.php b/modules_v3/sitemap/module.php index 4bd8670cd8..5956dc10fa 100644 --- a/modules_v3/sitemap/module.php +++ b/modules_v3/sitemap/module.php @@ -71,7 +71,7 @@ class sitemap_WT_Module extends WT_Module implements WT_Module_Config { private function generate_index() { // Check the cache $timestamp=get_module_setting($this->getName(), 'sitemap.timestamp'); - if ($timestamp > time()-self::CACHE_LIFE) { + if ($timestamp > WT_TIMESTAMP - self::CACHE_LIFE) { $data=get_module_setting($this->getName(), 'sitemap.xml'); } else { $data=''; @@ -115,7 +115,7 @@ class sitemap_WT_Module extends WT_Module implements WT_Module_Config { $data='<'.'?xml version="1.0" encoding="UTF-8" ?'.'>'.PHP_EOL.'<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'.PHP_EOL.$data.'</sitemapindex>'.PHP_EOL; // Cache this data set_module_setting($this->getName(), 'sitemap.xml', $data); - set_module_setting($this->getName(), 'sitemap.timestamp', time()); + set_module_setting($this->getName(), 'sitemap.timestamp', WT_TIMESTAMP); } header('Content-Type: application/xml'); header('Content-Length: '.strlen($data)); @@ -126,7 +126,7 @@ class sitemap_WT_Module extends WT_Module implements WT_Module_Config { private function generate_file($ged_id, $rec_type, $volume) { // Check the cache $timestamp=get_module_setting($this->getName(), 'sitemap-'.$ged_id.'-'.$rec_type.'-'.$volume.'.timestamp'); - if ($timestamp > time()-self::CACHE_LIFE) { + if ($timestamp > WT_TIMESTAMP - self::CACHE_LIFE) { $data=get_module_setting($this->getName(), 'sitemap-'.$ged_id.'-'.$rec_type.'-'.$volume.'.xml'); } else { $data=''; @@ -222,7 +222,7 @@ class sitemap_WT_Module extends WT_Module implements WT_Module_Config { $data='<'.'?xml version="1.0" encoding="UTF-8" ?'.'>'.PHP_EOL.'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">'.PHP_EOL.$data.'</urlset>'.PHP_EOL; // Cache this data set_module_setting($this->getName(), 'sitemap-'.$ged_id.'-'.$rec_type.'-'.$volume.'.xml', $data); - set_module_setting($this->getName(), 'sitemap-'.$ged_id.'-'.$rec_type.'-'.$volume.'.timestamp', time()); + set_module_setting($this->getName(), 'sitemap-'.$ged_id.'-'.$rec_type.'-'.$volume.'.timestamp', WT_TIMESTAMP); } header('Content-Type: application/xml'); header('Content-Length: '.strlen($data)); diff --git a/themes/_administration/header.php b/themes/_administration/header.php index ead2b42fd3..0074e42f3f 100644 --- a/themes/_administration/header.php +++ b/themes/_administration/header.php @@ -67,7 +67,7 @@ echo '<div id="info">', WT_WEBTREES, ' ', WT_VERSION_TEXT, '<br>', - WT_I18N::translate('Current Server Time:'), ' ', format_timestamp(time()), + WT_I18N::translate('Current Server Time:'), ' ', format_timestamp(WT_TIMESTAMP), '</div>', '</div>', // Side menu |
