2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************/
16 * OAuth Utility functions
21 if (!defined('AT_INCLUDE_PATH')) exit;
26 * This function checks whether the given URL is accessible.
29 * @return true if accessible, otherwise, false
32 public static function isAccessible($URL)
34 if (!@file_get_contents($URL))
40 * This function checks whether the last access token for the current user
41 * is expired. If not, return it, otherwise, return empty.
44 * @return the access token if it's not expired, otherwise, empty.
47 public static function getUnexpiredAccessToken()
52 unix_timestamp(now()) now_timestamp,
54 unix_timestamp(addtime(oct.assign_date, sec_to_time(ocs.expire_threshold))) expire_timestamp
55 FROM ".TABLE_PREFIX."oauth_client_servers ocs, ".TABLE_PREFIX."oauth_client_tokens oct
56 WHERE ocs.oauth_server_id=oct.oauth_server_id
57 AND oct.member_id=".$_SESSION['member_id']."
58 AND oct.token_type='access'
59 ORDER BY oct.assign_date DESC";
61 $result = mysql_query($sql, $db);
63 if (mysql_num_rows($result) == 0) {
68 $row = mysql_fetch_assoc($result);
70 if ($row['expire_threshold'] == 0 || $row['now_timestamp'] < $row['expire_timestamp']) {