equal
deleted
inserted
replaced
199 function yubikey_verify_timestamp($timestamp) |
199 function yubikey_verify_timestamp($timestamp) |
200 { |
200 { |
201 $tolerance = intval(getConfig('yubikey_api_ts_tolerance', 150)); |
201 $tolerance = intval(getConfig('yubikey_api_ts_tolerance', 150)); |
202 |
202 |
203 $now = time(); |
203 $now = time(); |
204 $timestamp = preg_replace('/Z[0-9]{3,5}$/', '', $timestamp); |
204 $timestamp_seconds = yk_strtotime($timestamp); |
205 $timestamp_seconds = strtotime($timestamp); |
205 |
206 |
206 if ( !$timestamp || !$now || !$timestamp_seconds ) |
207 if ( !$timestamp || !$now ) |
|
208 { |
207 { |
209 return false; |
208 return false; |
210 } |
209 } |
211 |
210 |
212 if ( ( $timestamp_seconds + $tolerance ) > $now && ( $timestamp_seconds - $tolerance ) < $now ) |
211 if ( ( $timestamp_seconds + $tolerance ) > $now && ( $timestamp_seconds - $tolerance ) < $now ) |
215 } |
214 } |
216 |
215 |
217 return false; |
216 return false; |
218 } |
217 } |
219 |
218 |
|
219 function yk_strtotime($timestamp) |
|
220 { |
|
221 if ( !preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z[0-9]+)$/', $timestamp, $match) ) |
|
222 return 0; |
|
223 |
|
224 $hour = intval($match[4]); |
|
225 $minute = intval($match[5]); |
|
226 $second = intval($match[6]); |
|
227 $month = intval($match[2]); |
|
228 $day = intval($match[3]); |
|
229 $year = intval($match[1]); |
|
230 |
|
231 return gmmktime($hour, $minute, $second, $month, $day, $year); |
|
232 } |
220 |
233 |
221 $plugins->attachHook('compile_template', 'yubikey_attach_headers($this);'); |
234 $plugins->attachHook('compile_template', 'yubikey_attach_headers($this);'); |
222 |
235 |
223 function yubikey_attach_headers(&$template) |
236 function yubikey_attach_headers(&$template) |
224 { |
237 { |