Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit 075e184

Browse files
committed
Update PHP Facebook SDK
1 parent 77fb74b commit 075e184

File tree

84 files changed

+9948
-7803
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+9948
-7803
lines changed

rainloop/v/0.0.0/app/handle.php

Lines changed: 103 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,103 @@
1-
<?php
2-
3-
if (!\defined('RAINLOOP_APP_LIBRARIES_PATH'))
4-
{
5-
\define('RAINLOOP_APP_PATH', \rtrim(\realpath(__DIR__), '\\/').'/');
6-
\define('RAINLOOP_APP_LIBRARIES_PATH', RAINLOOP_APP_PATH.'libraries/');
7-
\define('RAINLOOP_MB_SUPPORTED', \function_exists('mb_strtoupper'));
8-
9-
\define('RAINLOOP_INCLUDE_AS_API_DEF', isset($_ENV['RAINLOOP_INCLUDE_AS_API']) && $_ENV['RAINLOOP_INCLUDE_AS_API']);
10-
11-
if (!defined('RL_BACKWARD_CAPABILITY'))
12-
{
13-
\define('RL_BACKWARD_CAPABILITY', true);
14-
include_once RAINLOOP_APP_LIBRARIES_PATH.'RainLoop/Common/BackwardCapability/Account.php';
15-
}
16-
17-
/**
18-
* @param string $sClassName
19-
*
20-
* @return mixed
21-
*/
22-
function rainLoopSplAutoloadNamespaces()
23-
{
24-
return RAINLOOP_INCLUDE_AS_API_DEF ? array('RainLoop', 'Predis') :
25-
array('RainLoop', 'Facebook', 'GuzzleHttp', 'PHPThumb', 'Predis', 'SabreForRainLoop', 'Imagine', 'Detection');
26-
}
27-
28-
/**
29-
* @param string $sClassName
30-
*
31-
* @return mixed
32-
*/
33-
function rainLoopSplAutoloadRegisterFunction($sClassName)
34-
{
35-
if ($sClassName && '\\' === $sClassName[0])
36-
{
37-
$sClassName = \substr($sClassName, 1);
38-
}
39-
40-
foreach (rainLoopSplAutoloadNamespaces() as $sNamespaceName)
41-
{
42-
if (0 === \strpos($sClassName, $sNamespaceName.'\\'))
43-
{
44-
$sPrefix = '';
45-
if ('Detection' === $sNamespaceName)
46-
{
47-
$sPrefix = 'Mobile_Detect/namespaced/';
48-
}
49-
50-
if ('SabreForRainLoop' === $sNamespaceName && !RAINLOOP_MB_SUPPORTED && !defined('RL_MB_FIXED'))
51-
{
52-
\define('RL_MB_FIXED', true);
53-
include_once RAINLOOP_APP_LIBRARIES_PATH.'RainLoop/Common/MbStringFix.php';
54-
}
55-
56-
return include RAINLOOP_APP_LIBRARIES_PATH.$sPrefix.\strtr($sClassName, '\\', '/').'.php';
57-
}
58-
}
59-
60-
return false;
61-
}
62-
63-
\spl_autoload_register('rainLoopSplAutoloadRegisterFunction', false);
64-
}
65-
66-
if (\class_exists('RainLoop\Api'))
67-
{
68-
if (!\class_exists('MailSo\Version', false))
69-
{
70-
include APP_VERSION_ROOT_PATH.'app/libraries/MailSo/MailSo.php';
71-
}
72-
73-
if (!\function_exists('spyc_load_file'))
74-
{
75-
include APP_VERSION_ROOT_PATH.'app/libraries/spyc/Spyc.php';
76-
}
77-
78-
if (\class_exists('MailSo\Version'))
79-
{
80-
if (RAINLOOP_INCLUDE_AS_API_DEF)
81-
{
82-
if (!\defined('APP_API_STARTED'))
83-
{
84-
\define('APP_API_STARTED', true);
85-
86-
\RainLoop\Api::Handle();
87-
}
88-
}
89-
else if (!\defined('APP_STARTED'))
90-
{
91-
\define('APP_STARTED', true);
92-
93-
\RainLoop\Api::Handle();
94-
\RainLoop\Service::Handle();
95-
96-
\RainLoop\Api::ExitOnEnd();
97-
}
98-
}
99-
}
100-
else if (\function_exists('rainLoopSplAutoloadRegisterFunction'))
101-
{
102-
\spl_autoload_unregister('rainLoopSplAutoloadRegisterFunction');
103-
}
1+
<?php
2+
3+
if (!\defined('RAINLOOP_APP_LIBRARIES_PATH'))
4+
{
5+
\define('RAINLOOP_APP_PATH', \rtrim(\realpath(__DIR__), '\\/').'/');
6+
\define('RAINLOOP_APP_LIBRARIES_PATH', RAINLOOP_APP_PATH.'libraries/');
7+
\define('RAINLOOP_MB_SUPPORTED', \function_exists('mb_strtoupper'));
8+
9+
\define('RAINLOOP_INCLUDE_AS_API_DEF', isset($_ENV['RAINLOOP_INCLUDE_AS_API']) && $_ENV['RAINLOOP_INCLUDE_AS_API']);
10+
11+
if (!defined('RL_BACKWARD_CAPABILITY'))
12+
{
13+
\define('RL_BACKWARD_CAPABILITY', true);
14+
include_once RAINLOOP_APP_LIBRARIES_PATH.'RainLoop/Common/BackwardCapability/Account.php';
15+
}
16+
17+
/**
18+
* @param string $sClassName
19+
*
20+
* @return mixed
21+
*/
22+
function rainLoopSplAutoloadNamespaces()
23+
{
24+
return RAINLOOP_INCLUDE_AS_API_DEF ? array('RainLoop', 'Predis') :
25+
array('RainLoop', 'Facebook', 'GuzzleHttp', 'PHPThumb', 'Predis', 'SabreForRainLoop', 'Imagine', 'Detection');
26+
}
27+
28+
/**
29+
* @param string $sClassName
30+
*
31+
* @return mixed
32+
*/
33+
function rainLoopSplAutoloadRegisterFunction($sClassName)
34+
{
35+
if ($sClassName && '\\' === $sClassName[0])
36+
{
37+
$sClassName = \substr($sClassName, 1);
38+
}
39+
40+
foreach (rainLoopSplAutoloadNamespaces() as $sNamespaceName)
41+
{
42+
if (0 === \strpos($sClassName, $sNamespaceName.'\\'))
43+
{
44+
$sPrefix = '';
45+
if ('Detection' === $sNamespaceName)
46+
{
47+
$sPrefix = 'Mobile_Detect/namespaced/';
48+
}
49+
50+
if ('SabreForRainLoop' === $sNamespaceName && !RAINLOOP_MB_SUPPORTED && !defined('RL_MB_FIXED'))
51+
{
52+
\define('RL_MB_FIXED', true);
53+
include_once RAINLOOP_APP_LIBRARIES_PATH.'RainLoop/Common/MbStringFix.php';
54+
}
55+
56+
return include RAINLOOP_APP_LIBRARIES_PATH.$sPrefix.\strtr($sClassName, '\\', '/').'.php';
57+
}
58+
}
59+
60+
return false;
61+
}
62+
63+
\spl_autoload_register('rainLoopSplAutoloadRegisterFunction', false);
64+
}
65+
66+
if (\class_exists('RainLoop\Api'))
67+
{
68+
if (!\class_exists('MailSo\Version', false))
69+
{
70+
include APP_VERSION_ROOT_PATH.'app/libraries/MailSo/MailSo.php';
71+
}
72+
73+
if (!\function_exists('spyc_load_file'))
74+
{
75+
include APP_VERSION_ROOT_PATH.'app/libraries/spyc/Spyc.php';
76+
}
77+
78+
if (\class_exists('MailSo\Version'))
79+
{
80+
if (RAINLOOP_INCLUDE_AS_API_DEF)
81+
{
82+
if (!\defined('APP_API_STARTED'))
83+
{
84+
\define('APP_API_STARTED', true);
85+
86+
\RainLoop\Api::Handle();
87+
}
88+
}
89+
else if (!\defined('APP_STARTED'))
90+
{
91+
\define('APP_STARTED', true);
92+
93+
\RainLoop\Api::Handle();
94+
\RainLoop\Service::Handle();
95+
96+
\RainLoop\Api::ExitOnEnd();
97+
}
98+
}
99+
}
100+
else if (\function_exists('rainLoopSplAutoloadRegisterFunction'))
101+
{
102+
\spl_autoload_unregister('rainLoopSplAutoloadRegisterFunction');
103+
}
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
<?php
2+
/**
3+
* Copyright 2014 Facebook, Inc.
4+
*
5+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
6+
* use, copy, modify, and distribute this software in source code or binary
7+
* form for use in connection with the web services and APIs provided by
8+
* Facebook.
9+
*
10+
* As with any software that integrates with the Facebook platform, your use
11+
* of this software is subject to the Facebook Developer Principles and
12+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
13+
* shall be included in all copies or substantial portions of the software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21+
* DEALINGS IN THE SOFTWARE.
22+
*
23+
*/
24+
namespace Facebook\Authentication;
25+
26+
/**
27+
* Class AccessToken
28+
*
29+
* @package Facebook
30+
*/
31+
class AccessToken
32+
{
33+
/**
34+
* The access token value.
35+
*
36+
* @var string
37+
*/
38+
protected $value = '';
39+
40+
/**
41+
* Date when token expires.
42+
*
43+
* @var \DateTime|null
44+
*/
45+
protected $expiresAt;
46+
47+
/**
48+
* Create a new access token entity.
49+
*
50+
* @param string $accessToken
51+
* @param int $expiresAt
52+
*/
53+
public function __construct($accessToken, $expiresAt = 0)
54+
{
55+
$this->value = $accessToken;
56+
if ($expiresAt) {
57+
$this->setExpiresAtFromTimeStamp($expiresAt);
58+
}
59+
}
60+
61+
/**
62+
* Generate an app secret proof to sign a request to Graph.
63+
*
64+
* @param string $appSecret The app secret.
65+
*
66+
* @return string
67+
*/
68+
public function getAppSecretProof($appSecret)
69+
{
70+
return hash_hmac('sha256', $this->value, $appSecret);
71+
}
72+
73+
/**
74+
* Getter for expiresAt.
75+
*
76+
* @return \DateTime|null
77+
*/
78+
public function getExpiresAt()
79+
{
80+
return $this->expiresAt;
81+
}
82+
83+
/**
84+
* Determines whether or not this is an app access token.
85+
*
86+
* @return bool
87+
*/
88+
public function isAppAccessToken()
89+
{
90+
return strpos($this->value, '|') !== false;
91+
}
92+
93+
/**
94+
* Determines whether or not this is a long-lived token.
95+
*
96+
* @return bool
97+
*/
98+
public function isLongLived()
99+
{
100+
if ($this->expiresAt) {
101+
return $this->expiresAt->getTimestamp() > time() + (60 * 60 * 2);
102+
}
103+
104+
if ($this->isAppAccessToken()) {
105+
return true;
106+
}
107+
108+
return false;
109+
}
110+
111+
/**
112+
* Checks the expiration of the access token.
113+
*
114+
* @return boolean|null
115+
*/
116+
public function isExpired()
117+
{
118+
if ($this->getExpiresAt() instanceof \DateTime) {
119+
return $this->getExpiresAt()->getTimestamp() < time();
120+
}
121+
122+
if ($this->isAppAccessToken()) {
123+
return false;
124+
}
125+
126+
return null;
127+
}
128+
129+
/**
130+
* Returns the access token as a string.
131+
*
132+
* @return string
133+
*/
134+
public function getValue()
135+
{
136+
return $this->value;
137+
}
138+
139+
/**
140+
* Returns the access token as a string.
141+
*
142+
* @return string
143+
*/
144+
public function __toString()
145+
{
146+
return $this->getValue();
147+
}
148+
149+
/**
150+
* Setter for expires_at.
151+
*
152+
* @param int $timeStamp
153+
*/
154+
protected function setExpiresAtFromTimeStamp($timeStamp)
155+
{
156+
$dt = new \DateTime();
157+
$dt->setTimestamp($timeStamp);
158+
$this->expiresAt = $dt;
159+
}
160+
}

0 commit comments

Comments
 (0)