Skip to content

Commit

Permalink
Timezone fixes and float casts (#2586)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvz authored and euantorano committed Jan 8, 2017
1 parent e40dc00 commit 1561c2d
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 20 deletions.
4 changes: 2 additions & 2 deletions admin/modules/user/mass_mail.php
Expand Up @@ -82,7 +82,7 @@
$html_personalisation = substr($html_personalisation, 0, -2)."');\n// --></script>\n";
$text_personalisation = substr($text_personalisation, 0, -2)."');\n// --></script>\n";

$localized_time_offset = $mybb->user['timezone']*3600 + $mybb->user['dst']*3600;
$localized_time_offset = (float)$mybb->user['timezone']*3600 + $mybb->user['dst']*3600;

// All done here
if($mybb->request_method == "post")
Expand Down Expand Up @@ -615,7 +615,7 @@ function insertText(value, textarea)

$plugins->run_hooks("admin_user_mass_email_send_start");

$localized_time_offset = $mybb->user['timezone']*3600 + $mybb->user['dst']*3600;
$localized_time_offset = (float)$mybb->user['timezone']*3600 + $mybb->user['dst']*3600;

if($mybb->input['step'] == 4)
{
Expand Down
4 changes: 2 additions & 2 deletions admin/modules/user/users.php
Expand Up @@ -1024,11 +1024,11 @@
$reg_date = my_date('relative', $user['regdate']);
if($user['dst'] == 1)
{
$timezone = $user['timezone']+1;
$timezone = (float)$user['timezone']+1;
}
else
{
$timezone = $user['timezone'];
$timezone = (float)$user['timezone'];
}
$local_date = gmdate($mybb->settings['dateformat'], TIME_NOW + ($timezone * 3600));
$local_time = gmdate($mybb->settings['timeformat'], TIME_NOW + ($timezone * 3600));
Expand Down
9 changes: 5 additions & 4 deletions calendar.php
Expand Up @@ -799,6 +799,7 @@
}

$event['name'] = htmlspecialchars_uni($event['name']);
$event['timezone'] = (float)$event['timezone'];

add_breadcrumb(htmlspecialchars_uni($calendar['name']), get_calendar_link($calendar['cid']));
add_breadcrumb($event['name'], get_event_link($event['eid']));
Expand Down Expand Up @@ -1536,11 +1537,11 @@

if($event['ignoretimezone'] == 0)
{
$offset = $event['timezone'];
$offset = (float)$event['timezone'];
}
else
{
$offset = $mybb->user['timezone'];
$offset = (float)$mybb->user['timezone'];
}

$event['starttime_user'] = $event['starttime']+$offset*3600;
Expand Down Expand Up @@ -1875,11 +1876,11 @@

if($event['ignoretimezone'] == 0)
{
$offset = $event['timezone'];
$offset = (float)$event['timezone'];
}
else
{
$offset = $mybb->user['timezone'];
$offset = (float)$mybb->user['timezone'];
}

$event['starttime_user'] = $event['starttime']+$offset*3600;
Expand Down
2 changes: 1 addition & 1 deletion global.php
Expand Up @@ -924,7 +924,7 @@
$auto_dst_detection = '';
if($mybb->user['uid'] > 0 && $mybb->user['dstcorrection'] == 2)
{
$timezone = $mybb->user['timezone'] + $mybb->user['dst'];
$timezone = (float)$mybb->user['timezone'] + $mybb->user['dst'];
eval('$auto_dst_detection = "'.$templates->get('global_dst_detection').'";');
}

Expand Down
2 changes: 2 additions & 0 deletions inc/datahandlers/user.php
Expand Up @@ -917,6 +917,8 @@ function verify_checkfields()
*/
function verify_timezone()
{
global $mybb;

$user = &$this->data;

$timezones = get_supported_timezones();
Expand Down
6 changes: 3 additions & 3 deletions inc/functions.php
Expand Up @@ -343,17 +343,17 @@ function my_date($format, $stamp=0, $offset="", $ty=1, $adodb=false)
{
if(isset($mybb->user['uid']) && $mybb->user['uid'] != 0 && array_key_exists("timezone", $mybb->user))
{
$offset = $mybb->user['timezone'];
$offset = (float)$mybb->user['timezone'];
$dstcorrection = $mybb->user['dst'];
}
elseif(defined("IN_ADMINCP"))
{
$offset = $mybbadmin['timezone'];
$offset = (float)$mybbadmin['timezone'];
$dstcorrection = $mybbadmin['dst'];
}
else
{
$offset = $mybb->settings['timezoneoffset'];
$offset = (float)$mybb->settings['timezoneoffset'];
$dstcorrection = $mybb->settings['dstcorrection'];
}

Expand Down
4 changes: 2 additions & 2 deletions inc/functions_calendar.php
Expand Up @@ -452,11 +452,11 @@ function get_events($calendar, $start, $end, $unapproved=0, $private=1)
{
if($event['ignoretimezone'] == 0)
{
$offset = $event['timezone'];
$offset = (float)$event['timezone'];
}
else
{
$offset = $mybb->user['timezone'];
$offset = (float)$mybb->user['timezone'];
}
$event['starttime_user'] = $event['starttime']+($offset*3600);

Expand Down
4 changes: 3 additions & 1 deletion member.php
Expand Up @@ -2184,7 +2184,9 @@
eval("\$awaybit = \"".$templates->get("member_profile_away")."\";");
}
}


$memprofile['timezone'] = (float)$memprofile['timezone'];

if($memprofile['dst'] == 1)
{
$memprofile['timezone']++;
Expand Down
10 changes: 5 additions & 5 deletions modcp.php
Expand Up @@ -1119,7 +1119,7 @@
$mybb->input['starttime_month'] = '01';
}

$localized_time_offset = $mybb->user['timezone']*3600 + $mybb->user['dst']*3600;
$localized_time_offset = (float)$mybb->user['timezone']*3600 + $mybb->user['dst']*3600;

$startdate = gmmktime((int)$startdate[0], (int)$startdate[1], 0, $mybb->get_input('starttime_month', MyBB::INPUT_INT), $mybb->get_input('starttime_day', MyBB::INPUT_INT), $mybb->get_input('starttime_year', MyBB::INPUT_INT)) -$localized_time_offset;
if(!checkdate($mybb->get_input('starttime_month', MyBB::INPUT_INT), $mybb->get_input('starttime_day', MyBB::INPUT_INT), $mybb->get_input('starttime_year', MyBB::INPUT_INT)) || $startdate < 0 || $startdate == false)
Expand Down Expand Up @@ -1261,7 +1261,7 @@
}
else
{
$localized_time = TIME_NOW + $mybb->user['timezone']*3600 + $mybb->user['dst']*3600;
$localized_time = TIME_NOW + (float)$mybb->user['timezone']*3600 + $mybb->user['dst']*3600;

$starttime_time = gmdate($mybb->settings['timeformat'], $localized_time);
$endtime_time = gmdate($mybb->settings['timeformat'], $localized_time);
Expand Down Expand Up @@ -1492,7 +1492,7 @@
$mybb->input['starttime_month'] = '01';
}

$localized_time_offset = TIME_NOW + $mybb->user['timezone']*3600 + $mybb->user['dst']*3600;
$localized_time_offset = TIME_NOW + (float)$mybb->user['timezone']*3600 + $mybb->user['dst']*3600;

$startdate = gmmktime((int)$startdate[0], (int)$startdate[1], 0, $mybb->get_input('starttime_month', MyBB::INPUT_INT), $mybb->get_input('starttime_day', MyBB::INPUT_INT), $mybb->get_input('starttime_year', MyBB::INPUT_INT)) - $localized_time_offset;
if(!checkdate($mybb->get_input('starttime_month', MyBB::INPUT_INT), $mybb->get_input('starttime_day', MyBB::INPUT_INT), $mybb->get_input('starttime_year', MyBB::INPUT_INT)) || $startdate < 0 || $startdate == false)
Expand Down Expand Up @@ -1666,8 +1666,8 @@
}
else
{
$localized_time_startdate = $announcement['startdate'] + $mybb->user['timezone']*3600 + $mybb->user['dst']*3600;
$localized_time_enddate = $announcement['enddate'] + $mybb->user['timezone']*3600 + $mybb->user['dst']*3600;
$localized_time_startdate = $announcement['startdate'] + (float)$mybb->user['timezone']*3600 + $mybb->user['dst']*3600;
$localized_time_enddate = $announcement['enddate'] + (float)$mybb->user['timezone']*3600 + $mybb->user['dst']*3600;

$starttime_time = gmdate($mybb->settings['timeformat'], $localized_time_startdate);
$endtime_time = gmdate($mybb->settings['timeformat'], $localized_time_enddate);
Expand Down

0 comments on commit 1561c2d

Please sign in to comment.