Did I miss commiting this?

This commit is contained in:
skeeter 2002-08-13 23:39:39 +00:00
parent 3d75437142
commit 89ebd8ea8a
4 changed files with 117 additions and 51 deletions

View File

@ -53,27 +53,43 @@
function datetime()
{
$this->tz_offset = 3600 * intval($GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']);
// echo '<!-- datetime::datetime::gmtnow = '.$this->gmtnow.' -->'."\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)
{
if(isset($GLOBALS['phpgw_info']['server']['tz_offset']))
{
$this->gmtnow = time() - (intval($GLOBALS['phpgw_info']['server']['tz_offset']) * 3600);
}
else
{
$this->gmtnow = $this->getbestguess();
}
}
$this->users_localtime = $this->gmtnow + $this->tz_offset;
}
function getntpoffset()
{
// echo '<!-- datetime::datetime::debug: Inside network time -->'."\n";
$error_occured = False;
if(!@is_object($GLOBALS['phpgw']->network))
{
$GLOBALS['phpgw']->network = createobject('phpgwapi.network');
}
$server_time = time();
if($GLOBALS['phpgw']->network->open_port('129.6.15.28',13,15))
if($GLOBALS['phpgw']->network->open_port('129.6.15.28',13,5))
{
$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);
// 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;
@ -83,46 +99,63 @@
$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));
}
}
}
elseif(isset($GLOBALS['phpgw_info']['server']['tz_offset']))
{
// echo '<!-- datetime::datetime::debug: Inside server already set -->'."\n";
$error_occured = False;
$this->gmtnow = time() - (intval($GLOBALS['phpgw_info']['server']['tz_offset']) * 3600);
}
else
{
$error_occured = True;
}
if($error_occured)
if($error_occured == True)
{
// echo '<!-- datetime::datetime::debug: Inside getting from local server -->'."\n";
return $this->getbestguess();
}
else
{
return intval(($server_time - $this->gmtnow) / 3600);
}
}
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');
}
if(!@isset($GLOBALS['phpgw_info']['server']['tz_offset']))
{
$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__);
}
}
$this->users_localtime = $this->gmtnow - $this->tz_offset;
// echo '<!-- datetime::datetime::tz_offset = '.$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'].' -->'."\n";
// echo '<!-- datetime::datetime::server:tz_offset = '.$GLOBALS['phpgw_info']['server']['tz_offset'].' -->'."\n";
// echo '<!-- datetime::datetime::gmtnow = '.$this->gmtnow.' -->'."\n";
return intval(($server_time - $this->gmtnow) / 3600);
}
function convert_rfc_to_epoch($date_str)

View File

@ -75,6 +75,17 @@
</td>
</tr>
<tr bgcolor="{row_off}">
<td>{lang_Datetime_port.<br>If_using_port_13,_please_set_firewall_rules_appropriately_before_submitting_this_page.<br>(Port:_13_/_Host:_129.6.15.28)}</td>
<td>
<select name="newsettings[daytime_port]">
<option value="00"{selected_daytime_port_00}>{lang_00_(disable)}</option>
<option value="13"{selected_daytime_port_13}>{lang_13_(ntp)}</option>
<option value="80"{selected_daytime_port_80}>{lang_80_(http)}</option>
</select>
</td>
</tr>
<tr bgcolor="{row_off}">
<td>{lang_Enter_your_HTTP_proxy_server}:</td>
<td><input name="newsettings[httpproxy_server]" value="{value_httpproxy_server}"></td>

View File

@ -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'");

View File

@ -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)
<br><center>Import has been completed! Click <a href="index.php">here</a> to return to setup </center> setup en <br><center>Import has been completed! Click <a href="index.php">here</a> to return to setup </center>
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 <br> setup en Currently installed languages: %1 <br>
datetime port.<br>If using port 13, please set firewall rules appropriately before submitting this page.<br>(Port: 13 / Host: 129.6.15.28) setup en Datetime port.<br>If using port 13, please set firewall rules appropriately before submitting this page.<br>(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