From 75f7ee43cae689e385983ecb2e9c319d7bc7e439 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Wed, 20 Jul 2016 20:19:26 +0200 Subject: [PATCH] removed mktime calls --- lam/lib/modules/sambaSamAccount.inc | 13 ++++++------- lam/lib/modules/shadowAccount.inc | 11 ++++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lam/lib/modules/sambaSamAccount.inc b/lam/lib/modules/sambaSamAccount.inc index 8b553dd0..4be35ce6 100644 --- a/lam/lib/modules/sambaSamAccount.inc +++ b/lam/lib/modules/sambaSamAccount.inc @@ -1792,9 +1792,8 @@ class sambaSamAccount extends baseModule implements passwordService { } // expiration date if (isset($profile['sambaSamAccount_expire_day'][0]) && ($profile['sambaSamAccount_expire_day'][0] != "")) { - $date = mktime(0, 0, 0, intval($profile['sambaSamAccount_expire_mon'][0]), - intval($profile['sambaSamAccount_expire_day'][0]), intval($profile['sambaSamAccount_expire_yea'][0])); - $this->attributes['sambaKickoffTime'][0] = $date; + $date = DateTime::createFromFormat('j.n.Y', $profile['sambaSamAccount_expire_day'][0] . '.' . $profile['sambaSamAccount_expire_mon'][0] . '.' . $profile['sambaSamAccount_expire_yea'][0], getTimeZone()); + $this->attributes['sambaKickoffTime'][0] = $date->format('U'); } // domain -> change SID if (isset($this->attributes['sambaSID'][0])) { @@ -2108,8 +2107,8 @@ class sambaSamAccount extends baseModule implements passwordService { if ($rawAccounts[$i][$ids['sambaSamAccount_expireDate']] != "") { if (get_preg($rawAccounts[$i][$ids['sambaSamAccount_expireDate']], 'date')) { $parts = explode("-", $rawAccounts[$i][$ids['sambaSamAccount_expireDate']]); - $time = mktime(0, 0, 0, intval($parts[1]), intval($parts[0]), intval($parts[2])); - $partialAccounts[$i]['sambaKickoffTime'] = $time; + $date = DateTime::createFromFormat('j.n.Y', $parts[0] . '.' . $parts[1] . '.' . $parts[2], getTimeZone()); + $partialAccounts[$i]['sambaKickoffTime'] = $date->format('U'); } else { $errMsg = $this->messages['expireDate'][0]; @@ -2761,8 +2760,8 @@ class sambaSamAccount extends baseModule implements passwordService { unset($this->attributes['sambaKickoffTime']); return; } - $this->attributes['sambaKickoffTime'][0] = gmmktime(0, 0, 0, intval($month), intval($day), - intval($year)); + $date = DateTime::createFromFormat('j.n.Y', $day . '.' . $month . '.' . $year, getTimeZone()); + $this->attributes['sambaKickoffTime'][0] = $date->format('U'); } /** diff --git a/lam/lib/modules/shadowAccount.inc b/lam/lib/modules/shadowAccount.inc index 5cb58124..94eaedc2 100644 --- a/lam/lib/modules/shadowAccount.inc +++ b/lam/lib/modules/shadowAccount.inc @@ -614,7 +614,8 @@ class shadowAccount extends baseModule implements passwordService { if ($rawAccounts[$i][$ids['shadowAccount_expireDate']] != '') { if (get_preg($rawAccounts[$i][$ids['shadowAccount_expireDate']], 'date')) { $parts = explode('-', $rawAccounts[$i][$ids['shadowAccount_expireDate']]); - $partialAccounts[$i]['shadowExpire'][] = intval(mktime(0, 0, 0, intval($parts[1]), intval($parts[0]), intval($parts[2]))/3600/24); + $date = DateTime::createFromFormat('j.n.Y', $parts[0] . '.' . $parts[1] . '.' . $parts[2], new DateTimeZone('UTC')); + $partialAccounts[$i]['shadowExpire'][] = intval($date->format('U')/3600/24); } else { $errMsg = $this->messages['shadow_expireDate'][0]; @@ -713,8 +714,8 @@ class shadowAccount extends baseModule implements passwordService { unset($this->attributes['shadowExpire']); return; } - $this->attributes['shadowExpire'][0] = intval(gmmktime(0, 0, 0, intval($month), intval($day), - intval($year))/3600/24); + $date = DateTime::createFromFormat('j.n.Y', $day . '.' . $month . '.' . $year, new DateTimeZone('UTC')); + $this->attributes['shadowExpire'][0] = intval($date->format('U')/3600/24); } /** @@ -730,8 +731,8 @@ class shadowAccount extends baseModule implements passwordService { unset($this->attributes['shadowLastChange']); return; } - $this->attributes['shadowLastChange'][0] = intval(gmmktime(0, 0, 0, intval($month), intval($day), - intval($year))/3600/24); + $date = DateTime::createFromFormat('j.n.Y', $day . '.' . $month . '.' . $year, new DateTimeZone('UTC')); + $this->attributes['shadowLastChange'][0] = intval($date->format('U')/3600/24); } /**