diff --git a/phpgwapi/inc/class.datetime.inc.php b/phpgwapi/inc/class.datetime.inc.php index 15684ade59..0073136473 100755 --- a/phpgwapi/inc/class.datetime.inc.php +++ b/phpgwapi/inc/class.datetime.inc.php @@ -53,76 +53,109 @@ function datetime() { $this->tz_offset = 3600 * intval($GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']); -// echo ''."\n"; + print_debug('datetime::datetime::gmtnow',$this->gmtnow); $error_occured = True; // If we already have a GMT time, no need to do this again. - if(!$this->gmtnow && !@isset($GLOBALS['phpgw_info']['server']['tz_offset'])) + if(!$this->gmtnow) { -// echo ''."\n"; - $error_occured = False; - if(!@is_object($GLOBALS['phpgw']->network)) + if(isset($GLOBALS['phpgw_info']['server']['tz_offset'])) { - $GLOBALS['phpgw']->network = createobject('phpgwapi.network'); + $this->gmtnow = time() - (intval($GLOBALS['phpgw_info']['server']['tz_offset']) * 3600); } - $server_time = time(); - if($GLOBALS['phpgw']->network->open_port('129.6.15.28',13,15)) + else { - $line = $GLOBALS['phpgw']->network->bs_read_port(64); - // Value returned is 52384 02-04-20 13:55:29 50 0 0 9.2 UTC(NIST) * - $GLOBALS['phpgw']->network->close_port(); - - $array = explode(' ',$line); - - if ($array[5] == 4) - { - $error_occured = True; - } - else - { - $date = explode('-',$array[1]); - $time = explode(':',$array[2]); - $this->gmtnow = mktime(intval($time[0]),intval($time[1]),intval($time[2]),intval($date[1]),intval($date[2]),intval($date[0]) + 2000); - } + $this->gmtnow = $this->getbestguess(); } } - elseif(isset($GLOBALS['phpgw_info']['server']['tz_offset'])) + $this->users_localtime = $this->gmtnow + $this->tz_offset; + } + + function getntpoffset() + { + $error_occured = False; + if(!@is_object($GLOBALS['phpgw']->network)) { -// echo ''."\n"; - $error_occured = False; - $this->gmtnow = time() - (intval($GLOBALS['phpgw_info']['server']['tz_offset']) * 3600); + $GLOBALS['phpgw']->network = createobject('phpgwapi.network'); + } + $server_time = time(); + + if($GLOBALS['phpgw']->network->open_port('129.6.15.28',13,5)) + { + $line = $GLOBALS['phpgw']->network->bs_read_port(64); + $GLOBALS['phpgw']->network->close_port(); + + $array = explode(' ',$line); + // host: 129.6.15.28 + // Value returned is 52384 02-04-20 13:55:29 50 0 0 9.2 UTC(NIST) * + print_debug('Server datetime',time()); + print_debug('Temporary NTP datetime',$line); + if ($array[5] == 4) + { + $error_occured = True; + } + else + { + $date = explode('-',$array[1]); + $time = explode(':',$array[2]); + $this->gmtnow = mktime(intval($time[0]),intval($time[1]),intval($time[2]),intval($date[1]),intval($date[2]),intval($date[0]) + 2000); + print_debug('Temporary RFC epoch',$this->gmtnow); + print_debug('GMT',date('Ymd H:i:s',$this->gmtnow)); + } } else { $error_occured = True; } - - if($error_occured) + + if($error_occured == True) { -// echo ''."\n"; - $server_time = time(); - // Calculate GMT time... - // If DST, add 1 hour... - // - (date('I') == 1?3600:0) - $this->gmtnow = $this->convert_rfc_to_epoch(gmdate('D, d M Y H:i:s',$server_time).' GMT'); + return $this->getbestguess(); } - - if(!@isset($GLOBALS['phpgw_info']['server']['tz_offset'])) + else { - $GLOBALS['phpgw_info']['server']['tz_offset'] = (($server_time - $this->gmtnow) / 3600); - if(@isset($GLOBALS['phpgw_info']['server']['cache_phpgw_info'])) - { - $cache_query = "DELETE FROM phpgw_app_sessions WHERE sessionid='0' and loginid='0' and app='phpgwapi' and location='config'"; - $GLOBALS['phpgw']->db->query($cache_query,__LINE__,__FILE__); - $cache_query = 'INSERT INTO phpgw_app_sessions(sessionid,loginid,app,location,content) VALUES(' - . "'0','0','phpgwapi','config','".addslashes(serialize($GLOBALS['phpgw_info']['server']))."')"; - $GLOBALS['phpgw']->db->query($cache_query,__LINE__,__FILE__); - } + return intval(($server_time - $this->gmtnow) / 3600); } - $this->users_localtime = $this->gmtnow - $this->tz_offset; -// echo ''."\n"; -// echo ''."\n"; -// echo ''."\n"; + } + + function gethttpoffset() + { + $error_occured = False; + if(!@is_object($GLOBALS['phpgw']->network)) + { + $GLOBALS['phpgw']->network = createobject('phpgwapi.network'); + } + $server_time = time(); + + $filename = 'http://132.163.4.213/timezone.cgi?GMT'; + $file = $GLOBALS['phpgw']->network->gethttpsocketfile($filename); + if(!$file) + { + return $this->getbestguess(); + } + $time = strip_tags($file[55]); + $date = strip_tags($file[56]); + + print_debug('GMT DateTime',$date.' '.$time); + $dt_array = explode(' ',$date); + $temp_datetime = $dt_array[0].' '.substr($dt_array[2],0,-1).' '.substr($dt_array[1],0,3).' '.$dt_array[3].' '.$time.' GMT'; + print_debug('Reformulated GMT DateTime',$temp_datetime); + $this->gmtnow = $this->convert_rfc_to_epoch($temp_datetime); + print_debug('this->gmtnow',$this->gmtnow); + print_debug('server time',$server_time); + print_debug('server DateTime',date('D, d M Y H:i:s',$server_time)); + return intval(($server_time - $this->gmtnow) / 3600); + } + + function getbestguess() + { + print_debug('datetime::datetime::debug: Inside getting from local server'); + $server_time = time(); + // Calculate GMT time... + // If DST, add 1 hour... + // - (date('I') == 1?3600:0) + $this->gmtnow = $this->convert_rfc_to_epoch(gmdate('D, d M Y H:i:s',$server_time).' GMT'); + return intval(($server_time - $this->gmtnow) / 3600); } function convert_rfc_to_epoch($date_str) diff --git a/phpgwapi/templates/default/config.tpl b/phpgwapi/templates/default/config.tpl index 3bf01e62a8..a642bf6a6c 100644 --- a/phpgwapi/templates/default/config.tpl +++ b/phpgwapi/templates/default/config.tpl @@ -75,6 +75,17 @@ + + {lang_Datetime_port.
If_using_port_13,_please_set_firewall_rules_appropriately_before_submitting_this_page.
(Port:_13_/_Host:_129.6.15.28)} + + + + + {lang_Enter_your_HTTP_proxy_server}: diff --git a/setup/config.php b/setup/config.php index f2279ef2cf..41a1bbc764 100644 --- a/setup/config.php +++ b/setup/config.php @@ -77,6 +77,23 @@ $newsettings = get_var('newsettings',Array('POST')); if(@get_var('submit',Array('POST')) && @$newsettings) { + $datetime = CreateObject('phpgwapi.datetime'); + switch (intval($newsettings['daytime_port'])) + { + case 13: + $newsettings['tz_offset'] = $datetime->getntpoffset(); + break; + case 80: + $newsettings['tz_offset'] = $datetime->gethttpoffset(); + break; + default: + $newsettings['tz_offset'] = $datetime->getbestguess(); + break; + } + unset($datetime); + + print_debug('TZ_OFFSET',$newsettings['tz_offset']); + $GLOBALS['phpgw_setup']->db->transaction_begin(); /* This is only temp: */ $GLOBALS['phpgw_setup']->db->query("DELETE FROM $configtbl WHERE config_name='useframes'"); diff --git a/setup/lang/phpgw_en.lang b/setup/lang/phpgw_en.lang index 6b0ffa8beb..568d818800 100644 --- a/setup/lang/phpgw_en.lang +++ b/setup/lang/phpgw_en.lang @@ -1,3 +1,6 @@ +00 (disable) setup en 00 (disable) +13 (ntp) setup en 13 (ntp) +80 (http) setup en 80 (http) (account deletion in SQL Only) setup en (account deletion in SQL Only)
Import has been completed! Click here to return to setup
setup en
Import has been completed! Click here to return to setup
actions setup en Actions @@ -60,6 +63,7 @@ create your header.inc.php setup en Create your header.inc.php creating tables setup en Creating Tables current version setup en Current Version currently installed languages: x
setup en Currently installed languages: %1
+datetime port.
If using port 13, please set firewall rules appropriately before submitting this page.
(Port: 13 / Host: 129.6.15.28) setup en Datetime port.
If using port 13, please set firewall rules appropriately before submitting this page.
(Port: 13 / Host: 129.6.15.28) db host setup en DB Host db name setup en DB Name db password setup en DB Password @@ -137,6 +141,7 @@ ldap Default shell (e.g. /bin/bash) setup en LDAP Default shell (e.g. /bin/bash) ldap account import/export setup en LDAP account import/export ldap accounts configuration setup en LDAP Accounts Configuration ldap accounts context setup en LDAP accounts context +ldap config setup en LDAP Config ldap encryption type setup en LDAP encryption type ldap export users setup en LDAP export users ldap groups context setup en LDAP groups context