Compare commits
283 Commits
marijn-but
...
technischr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6690a8930 | ||
|
|
12d5e00731 | ||
|
|
eb8eb5bf03 | ||
|
|
b497538652 | ||
|
|
6ad1c0edf5 | ||
|
|
96f421d088 | ||
|
|
7955509cb2 | ||
|
|
dbfe10f84b | ||
|
|
022893aca2 | ||
|
|
89cff4da8c | ||
|
|
fb6b392a42 | ||
|
|
fc07027405 | ||
|
|
b7a6fae4d9 | ||
|
|
7f31575bfc | ||
|
|
d87d0b7295 | ||
|
|
7566a756f6 | ||
|
|
f10d9c14a1 | ||
|
|
9b89058484 | ||
|
|
61fa0c3781 | ||
|
|
2b98480587 | ||
|
|
a643ee19b9 | ||
|
|
fcfa6ed9ba | ||
|
|
700e27e5e3 | ||
|
|
bccb813e92 | ||
|
|
dc69fb493c | ||
|
|
8e81cec843 | ||
|
|
fcd58857c0 | ||
|
|
152d72d3d8 | ||
|
|
a9c27583e4 | ||
|
|
3ca7536cc2 | ||
|
|
69b0b24176 | ||
|
|
2b893fc283 | ||
|
|
04365c4f05 | ||
|
|
7fdf9ad329 | ||
|
|
58bb89f9b4 | ||
|
|
77448d98ba | ||
|
|
6a9e36cea2 | ||
|
|
6aee603a64 | ||
|
|
e414a1633e | ||
|
|
3c79d86abd | ||
|
|
028c2373c1 | ||
|
|
fb9d070d6a | ||
|
|
e3ad9c4590 | ||
|
|
3397253010 | ||
|
|
52a4822477 | ||
|
|
c0a64e9ffd | ||
|
|
64a3b13adf | ||
|
|
b16dc1d4b7 | ||
|
|
8e98001217 | ||
|
|
83f75e0282 | ||
|
|
b41a365b60 | ||
|
|
6a7bb4670b | ||
|
|
7236a8ba35 | ||
|
|
4d40bb6042 | ||
|
|
d6c2fab617 | ||
|
|
93200d27c2 | ||
|
|
78e96d5a74 | ||
|
|
646e6dde48 | ||
|
|
44408ee429 | ||
|
|
9ca212570d | ||
|
|
164eb2dde6 | ||
|
|
2dd7dd8140 | ||
|
|
794b5ab294 | ||
|
|
2a37b9c64d | ||
|
|
dfdf72daf4 | ||
|
|
1c9c88e030 | ||
|
|
eb12b6ba7d | ||
|
|
6b13db9c4f | ||
|
|
c14a2770bd | ||
|
|
e85a685b0f | ||
|
|
f67dd019c4 | ||
|
|
f26097f55f | ||
|
|
2e71942fdf | ||
|
|
582d347bcb | ||
|
|
03481f5888 | ||
|
|
d5d9d5857a | ||
|
|
dee483e946 | ||
|
|
c7d47cf446 | ||
|
|
4dc3b4f651 | ||
|
|
3579fe0cd5 | ||
|
|
a6b6d6d747 | ||
|
|
6983aa06a2 | ||
|
|
8dfa31696c | ||
|
|
ce53b6e9e4 | ||
|
|
bc7cbb0fb7 | ||
|
|
422e2d1308 | ||
|
|
6e6bbf8d92 | ||
|
|
a0e77491a2 | ||
|
|
e464f5bca2 | ||
|
|
3140242b4f | ||
|
|
0b6ca72dfc | ||
|
|
6831994ede | ||
|
|
bb56679885 | ||
|
|
b0a8ceafc3 | ||
|
|
54b56da445 | ||
|
|
183a98a339 | ||
|
|
941296802f | ||
|
|
aa12e29948 | ||
|
|
1acad8e765 | ||
|
|
44ff3a4cab | ||
|
|
dd017d8885 | ||
|
|
282875c6a2 | ||
|
|
c840b28495 | ||
|
|
f1b5a7fe95 | ||
|
|
e8c76bef5b | ||
|
|
25957c6c78 | ||
|
|
20b951cad2 | ||
|
|
792f346b12 | ||
|
|
54ddb78453 | ||
|
|
9a36dea592 | ||
|
|
578ad34020 | ||
|
|
f3df682af5 | ||
|
|
c8450f3cb3 | ||
|
|
b30ef0d0cf | ||
|
|
877637fcc9 | ||
|
|
89c8c35b4a | ||
|
|
c1a7ccc076 | ||
|
|
b24fed57d9 | ||
|
|
da30b9101c | ||
|
|
dd2113b234 | ||
|
|
3f960cc091 | ||
|
|
08f668859c | ||
|
|
b12eaced4a | ||
|
|
16b1f93968 | ||
|
|
753c596056 | ||
|
|
8da1469ca9 | ||
|
|
f7f442ce75 | ||
|
|
c8c81ae730 | ||
|
|
a57465189a | ||
|
|
dc51ac5964 | ||
|
|
be9fa6d2c1 | ||
|
|
7e2c20e244 | ||
|
|
dd6b41783a | ||
|
|
e9eeeaf110 | ||
|
|
2651e0fb2b | ||
|
|
5e9629eddd | ||
|
|
d356468554 | ||
|
|
ce6a751630 | ||
|
|
609f350cd3 | ||
|
|
07c3b07eb3 | ||
|
|
f27b9ec6b4 | ||
|
|
bf1df4d2d4 | ||
|
|
3b542e0878 | ||
|
|
82c2eaccb3 | ||
|
|
cbff973b63 | ||
|
|
c2d8521cdd | ||
|
|
23904caf69 | ||
|
|
f1bfc89e6a | ||
|
|
f32e0ca382 | ||
|
|
d89e672990 | ||
|
|
032e25b044 | ||
|
|
7073995534 | ||
|
|
637a26ba33 | ||
|
|
dbdb12cca0 | ||
|
|
70b7734e8b | ||
|
|
c1fc022658 | ||
|
|
5c1208460f | ||
|
|
59fc65e27a | ||
|
|
0c324b9095 | ||
|
|
ee204d78a7 | ||
|
|
cdfbcc0168 | ||
|
|
bf87d20985 | ||
|
|
96f70e1a11 | ||
|
|
e75df42bd8 | ||
|
|
b66c108f4e | ||
|
|
f4b2fee290 | ||
|
|
a60a9b6594 | ||
|
|
feb64002f5 | ||
|
|
33a640329b | ||
|
|
59b0b00304 | ||
|
|
51cc736aca | ||
|
|
1a53d01747 | ||
|
|
e24960c319 | ||
|
|
cf964ec8d6 | ||
|
|
b89a575039 | ||
|
|
91aca6baa7 | ||
|
|
3ebacd6251 | ||
|
|
423c2fd771 | ||
|
|
58e5f200fa | ||
|
|
47eed5514a | ||
|
|
78e85c2939 | ||
|
|
44f86a4fbb | ||
|
|
7b7f0b2c64 | ||
|
|
328f0665f3 | ||
|
|
8fb8df075f | ||
|
|
6a882bf78d | ||
|
|
95ee91748f | ||
|
|
30d403ae7b | ||
|
|
2242feda21 | ||
|
|
2ece9e1c63 | ||
|
|
4ebdd378a6 | ||
|
|
09dac78eb4 | ||
|
|
e1ca3c52ed | ||
|
|
f7bf80d789 | ||
|
|
4c5ea08614 | ||
|
|
9046b397a1 | ||
|
|
91fae80326 | ||
|
|
f06de1e88d | ||
|
|
b161596d67 | ||
|
|
ded314f4d6 | ||
|
|
0b035c0583 | ||
|
|
cc08ebec3c | ||
|
|
1b2a1a5180 | ||
|
|
977757b2d3 | ||
|
|
6a43402c66 | ||
|
|
95570c49d4 | ||
|
|
9ff256429d | ||
|
|
c23b8bd8e5 | ||
|
|
e840def733 | ||
|
|
db333b6e98 | ||
|
|
30d1ef40f4 | ||
|
|
13c575179d | ||
|
|
aa48092d27 | ||
|
|
7f755bfd2c | ||
|
|
727d418c8d | ||
|
|
185874d23f | ||
|
|
827be40646 | ||
|
|
93ddefa42f | ||
|
|
d19639d1c3 | ||
|
|
d2c7f0787b | ||
|
|
1402a3ea07 | ||
|
|
981e34c950 | ||
|
|
022620a375 | ||
|
|
28f31d749b | ||
|
|
17600adbf1 | ||
|
|
f7da87596a | ||
|
|
7efd062f98 | ||
|
|
fddbd0ca87 | ||
|
|
37d83169c6 | ||
|
|
d19038cb1c | ||
|
|
12ed710369 | ||
|
|
3de4e1387f | ||
|
|
7bf8a16cf0 | ||
|
|
cbfce6f698 | ||
|
|
7144d700e4 | ||
|
|
ec56dbe578 | ||
|
|
b8f662f825 | ||
|
|
de03d8799a | ||
|
|
b9fc016f7d | ||
|
|
70957015ce | ||
|
|
f9f1e2bf17 | ||
|
|
4b6fe1d202 | ||
|
|
fd055e8355 | ||
|
|
0b705df09a | ||
|
|
c48227e258 | ||
|
|
7a19fea5f9 | ||
|
|
887c773463 | ||
|
|
4967ab6ea0 | ||
|
|
6314494177 | ||
|
|
86b97cc186 | ||
|
|
4b3d7967fb | ||
|
|
d44ddf2793 | ||
|
|
9e89307bf9 | ||
|
|
dc11830c80 | ||
|
|
8403ff0a17 | ||
|
|
dbb23922d8 | ||
|
|
a88483ae47 | ||
|
|
ee6b55bd91 | ||
|
|
08c3d73377 | ||
|
|
c1359920e0 | ||
|
|
4579b98eb8 | ||
|
|
62a2b32c95 | ||
|
|
f6051ee14f | ||
|
|
96003b1bdc | ||
|
|
c4a0367fef | ||
|
|
c4e4508b53 | ||
|
|
d7e84ee138 | ||
|
|
7eec0cfa2a | ||
|
|
348b66c08c | ||
|
|
37aa073fc1 | ||
|
|
119c82e110 | ||
|
|
b6d166bdea | ||
|
|
8c4c4a59fd | ||
|
|
58ce5f1e75 | ||
|
|
80f7c24641 | ||
|
|
f82dd73b7d | ||
|
|
648c2d26e4 | ||
|
|
2ff23ae668 | ||
|
|
ac83bb750b | ||
|
|
e6f5044a9a | ||
|
|
449b500636 | ||
|
|
af11297fad | ||
|
|
21ff896d65 |
20
readme.md
Normal file
20
readme.md
Normal file
@@ -0,0 +1,20 @@
|
||||
#MyHyvesbook+
|
||||
## Samenstelling van Groep
|
||||
- Lars van Hijfte (11291680)
|
||||
- Hendrik Huang (11342374)
|
||||
- Marijn Jansen (11166932)
|
||||
- Kevin Nobel (11319801)
|
||||
- Joey Lai (11057122)
|
||||
|
||||
## URL naar website
|
||||
[MyHyvesbook+](https://myhyvesbookplus.nl/)
|
||||
|
||||
## Inloggegevens
|
||||
Username `NakijkAdmin`
|
||||
Password `HgzCVGHh7fdR`
|
||||
|
||||
## Site draaiend krijgen op een server
|
||||
De map `public` moet de `root`-folder zijn van de website.
|
||||
Een map daarboven moeten de `queries` en `views` geplaatst worden.
|
||||
De gegevens om met de database te verbinden staan in `/var/mysql_config.xml`.
|
||||
De map `uploads` (en alles daarin) in de `public`-folder is eigendom van `www-data` zodat de server hier naar kan schrijven.
|
||||
@@ -1,7 +1,7 @@
|
||||
Options +FollowSymLinks
|
||||
RewriteEngine On
|
||||
|
||||
ErrorDocument 404 /error404.jpg
|
||||
ErrorDocument 404 /error/404.php
|
||||
|
||||
RewriteCond %{SCRIPT_FILENAME} !-d
|
||||
RewriteCond %{SCRIPT_FILENAME} !-f
|
||||
|
||||
31
website/public/API/adminChangeUser.php
Normal file
31
website/public/API/adminChangeUser.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/checkInput.php");
|
||||
require_once ("../../queries/group_page.php");
|
||||
require_once ("../../queries/user.php");
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
(getRoleByID($_SESSION["userID"]) == 'admin' ||
|
||||
getRoleByID($_SESSION["userID"]) == 'owner')) {
|
||||
$userinfo = getRoleByID($_SESSION['userID']);
|
||||
|
||||
if (isset($_POST["actions"]) && isset($_POST["userID"])) {
|
||||
changeUserStatusByID($_POST["userID"], $_POST["actions"]);
|
||||
} else if (isset($_POST["actions"]) && isset($_POST["groupID"])) {
|
||||
changeGroupStatusByID($_POST["groupID"], $_POST["actions"]);
|
||||
} else if (isset($_POST["batchactions"]) && isset($_POST["checkbox-user"])) {
|
||||
if ($userinfo == 'owner') {
|
||||
changeMultipleUserStatusByID($_POST["checkbox-user"], $_POST["batchactions"]);
|
||||
} else {
|
||||
changeMultipleUserStatusByIDAdmin($_POST["checkbox-user"], $_POST["batchactions"]);
|
||||
}
|
||||
} else if (isset($_POST["groupbatchactions"]) && isset($_POST["checkbox-group"])) {
|
||||
changeMultipleGroupStatusByID($_POST["checkbox-group"], $_POST["groupbatchactions"]);
|
||||
} else if (isset($_POST['bancommentuserID']) && isset($_POST['bancommenttext'])) {
|
||||
editBanCommentByID($_POST['bancommentuserID'], $_POST['bancommenttext']);
|
||||
}
|
||||
} else {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
}
|
||||
44
website/public/API/adminPageNumber.php
Normal file
44
website/public/API/adminPageNumber.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/checkInput.php");
|
||||
require_once ("../../queries/user.php");
|
||||
require_once ("../../queries/group_page.php");
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
(getRoleByID($_SESSION["userID"]) == 'admin' ||
|
||||
getRoleByID($_SESSION["userID"]) == 'owner')) {
|
||||
$search = "";
|
||||
if (isset($_POST["search"])) {
|
||||
$search = test_input($_POST["search"]);
|
||||
}
|
||||
|
||||
$pagetype = "user";
|
||||
if (isset($_POST['pagetype'])) {
|
||||
$pagetype = test_input($_POST['pagetype']);
|
||||
}
|
||||
|
||||
$status = array();
|
||||
if (isset($_POST['status'])) {
|
||||
$status = $_POST["status"];
|
||||
}
|
||||
|
||||
$groupstatus = array();
|
||||
if (isset($_POST['groupstatus'])) {
|
||||
$groupstatus = $_POST["groupstatus"];
|
||||
}
|
||||
|
||||
$entries = 20;
|
||||
$currentpage = 1;
|
||||
if (isset($_POST['currentpage'])) {
|
||||
$currentpage = (int) test_input($_POST["currentpage"]);
|
||||
}
|
||||
|
||||
$offset = (int) $currentpage * $entries - $entries;
|
||||
|
||||
include ("../../views/adminpanel-page.php");
|
||||
} else {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
}
|
||||
50
website/public/API/adminSearchUsers.php
Normal file
50
website/public/API/adminSearchUsers.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/checkInput.php");
|
||||
require_once ("../../queries/user.php");
|
||||
require_once ("../../queries/group_page.php");
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
(getRoleByID($_SESSION["userID"]) == 'admin' ||
|
||||
getRoleByID($_SESSION["userID"]) == 'owner')) {
|
||||
$offset = 0;
|
||||
$entries = 20;
|
||||
if (isset($_POST["currentpage"])) {
|
||||
$offset = (int)test_input($_POST["currentpage"]) * $entries - $entries;
|
||||
}
|
||||
|
||||
$search = "";
|
||||
if (isset($_POST["search"])) {
|
||||
$search = test_input($_POST["search"]);
|
||||
}
|
||||
|
||||
$pagetype = "user";
|
||||
if (isset($_POST['pagetype'])) {
|
||||
$pagetype = test_input($_POST['pagetype']);
|
||||
}
|
||||
|
||||
$status = array();
|
||||
if (isset($_POST['status'])) {
|
||||
$status = $_POST["status"];
|
||||
}
|
||||
|
||||
$groupstatus = array();
|
||||
if (isset($_POST['groupstatus'])) {
|
||||
$groupstatus = $_POST["groupstatus"];
|
||||
}
|
||||
|
||||
$userinfo = getRoleByID($_SESSION['userID']);
|
||||
|
||||
if ($pagetype == "user") {
|
||||
include("../../views/adminpanel-table.php");
|
||||
} else if ($pagetype == "group") {
|
||||
include("../../views/adminpanel-grouptable.php");
|
||||
} else {
|
||||
echo "Search failed!";
|
||||
}
|
||||
} else {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
}
|
||||
20
website/public/API/deletePost.php
Normal file
20
website/public/API/deletePost.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
require_once "../../queries/post.php";
|
||||
require_once "../../queries/user.php";
|
||||
|
||||
if (isset($_SESSION["userID"]) and
|
||||
getRoleByID($_SESSION["userID"]) != 'frozen' and
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
|
||||
if (empty($_POST["postID"]) or empty($_SESSION["userID"])) {
|
||||
header('HTTP/1.1 500 Non enough arguments');
|
||||
}
|
||||
|
||||
deletePost($_POST["postID"], $_SESSION["userID"]);
|
||||
return;
|
||||
|
||||
} else {
|
||||
echo "frozen";
|
||||
}
|
||||
34
website/public/API/editFriendship.php
Normal file
34
website/public/API/editFriendship.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/friendship.php");
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'frozen' &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
if (empty($_POST["usr"]) OR empty($_POST["action"]) OR !in_array($_POST["action"], array("request", "accept", "delete"))) {
|
||||
header('HTTP/1.1 500 Non enough arguments');
|
||||
}
|
||||
|
||||
$friendship_status = getFriendshipStatus($_POST["usr"]);
|
||||
|
||||
if ($_POST["action"] == "request" AND $friendship_status == 0) {
|
||||
if (!requestFriendship($_POST["usr"])) {
|
||||
header('HTTP/1.1 500 Query (request) failed');
|
||||
}
|
||||
} else if ($_POST["action"] == "delete" AND in_array($friendship_status, array(1, 2, 3))) {
|
||||
if (!removeFriendship($_POST["usr"])) {
|
||||
header('HTTP/1.1 500 Query (delete) failed');
|
||||
}
|
||||
} else if ($_POST["action"] == "accept" AND $friendship_status == 3) {
|
||||
if (!acceptFriendship($_POST["usr"])) {
|
||||
header('HTTP/1.1 500 Query (accept) failed');
|
||||
}
|
||||
} else {
|
||||
header('HTTP/1.1 500 Not the right friendship status');
|
||||
}
|
||||
} else {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
}
|
||||
40
website/public/API/editMembership.php
Normal file
40
website/public/API/editMembership.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
if(empty($_POST["grp"]) or empty($_POST["role"])) {
|
||||
header('HTTP/1.1 500 Non enough arguments');
|
||||
}
|
||||
|
||||
if(in_array($_POST["role"], array('request', 'member', 'banned', 'mod', 'admin'))) {
|
||||
header('HTTP/1.1 500 Wrong argument given for role');
|
||||
}
|
||||
|
||||
require_once ("../../queries/group_member.php");
|
||||
require_once ("../../queries/group_page.php");
|
||||
require_once ("../../queries/group_member.php");
|
||||
|
||||
$currentRole = selectGroupRole($_POST["grp"]);
|
||||
$groupStatus = selectGroupStatus($_POST["grp"]);
|
||||
echo "role: $currentRole status: $groupStatus ";
|
||||
|
||||
if($_POST["role"] == 'request' and $currentRole == 'none') {
|
||||
if($groupStatus = 'public') {
|
||||
// Add member to public group
|
||||
addMember($_POST["grp"], $_SESSION["userID"], 'member');
|
||||
echo "ADDED";
|
||||
} else if($groupStatus = 'membersonly') {
|
||||
// Send request to members only group
|
||||
addMember($_POST["grp"], $_SESSION["userID"], 'request');
|
||||
} else {
|
||||
// Can't invite yourself to hidden groups
|
||||
header('HTTP/1.1 500 This group is hidden');
|
||||
}
|
||||
header('HTTP/1.1 200');
|
||||
} else if($_POST["role"] == 'none' and $currentRole != 'none') {
|
||||
// Remove yourself from a group
|
||||
deleteMember($_POST["grp"], $_SESSION["userID"]);
|
||||
} else {
|
||||
echo "failure";
|
||||
header('HTTP/1.1 500 Wrong argument given for role');
|
||||
}
|
||||
30
website/public/API/getFriendshipStatus.php
Normal file
30
website/public/API/getFriendshipStatus.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
# -2: Query failed.
|
||||
# -1: user1 and 2 are the same user
|
||||
# 0 : no record found
|
||||
# 1 : confirmed
|
||||
# 2 : user1 sent request (you)
|
||||
# 3 : user2 sent request (other)
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/friendship.php");
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
if (empty($_POST["usr"])) {
|
||||
header('HTTP/1.1 500 Non enough arguments');
|
||||
}
|
||||
|
||||
$friendship_status = getFriendshipStatus($_POST["usr"]);
|
||||
|
||||
if ($friendship_status == -2) {
|
||||
header('HTTP/1.1 500 Query failed');
|
||||
}
|
||||
|
||||
echo $friendship_status;
|
||||
} else {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
}
|
||||
12
website/public/API/getGrouprole.php
Normal file
12
website/public/API/getGrouprole.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
if(empty($_POST["grp"])) {
|
||||
header('HTTP/1.1 500 Non enough arguments');
|
||||
}
|
||||
|
||||
require_once("../../queries/group_page.php");
|
||||
|
||||
echo selectGroupRole($_POST["grp"]);
|
||||
|
||||
37
website/public/API/getPosts.php
Normal file
37
website/public/API/getPosts.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
if(!isset($_POST["offset"]) or !isset($_POST["limit"])) {
|
||||
header('HTTP/1.1 500 Not enough arguments');
|
||||
}
|
||||
if(!isset($_POST["usr"]) and !isset($_POST["grp"])) {
|
||||
header('HTTP/1.1 500 Not enough arguments');
|
||||
}
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/post.php");
|
||||
require_once ("../../queries/nicetime.php");
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
if(empty($_POST["usr"])) {
|
||||
$posts = selectSomePosts(0, $_POST["grp"], $_POST["offset"], $_POST["limit"]);
|
||||
} else {
|
||||
$posts = selectSomePosts($_POST["usr"], 0, $_POST["offset"], $_POST["limit"]);
|
||||
}
|
||||
|
||||
if(!$posts) {
|
||||
echo false;
|
||||
} else {
|
||||
$results = $posts->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
for($i = 0; $i < sizeof($results); $i++) {
|
||||
$results[$i]["nicetime"] = nicetime($results[$i]["creationdate"]);
|
||||
}
|
||||
|
||||
echo json_encode($results);
|
||||
}
|
||||
} else {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
}
|
||||
14
website/public/API/loadChatNotifications.php
Normal file
14
website/public/API/loadChatNotifications.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/private_message.php");
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
echo selectAllUnreadChat();
|
||||
} else {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
}
|
||||
15
website/public/API/loadFriendRequest.php
Normal file
15
website/public/API/loadFriendRequest.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/friendship.php");
|
||||
require_once ("../../queries/user.php");
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'frozen' &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
echo selectAllFriendRequests();
|
||||
} else {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
}
|
||||
26
website/public/API/loadFriends.php
Normal file
26
website/public/API/loadFriends.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/checkInput.php");
|
||||
require_once ("../../queries/friendship.php");
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
if (isset($_SESSION["userID"])) {
|
||||
if (isset($_POST["limit"])) {
|
||||
echo selectLimitedFriends($_SESSION["userID"], (int)test_input($_POST["limit"]));
|
||||
} else if (isset($_GET["limit"])) {
|
||||
echo selectLimitedFriends($_SESSION["userID"], (int)test_input($_GET["limit"]));
|
||||
} else {
|
||||
echo selectFriends($_SESSION["userID"]);
|
||||
}
|
||||
} else {
|
||||
echo "[]";
|
||||
}
|
||||
} else {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
}
|
||||
|
||||
20
website/public/API/loadGroups.php
Normal file
20
website/public/API/loadGroups.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/checkInput.php");
|
||||
require_once ("../../queries/group_member.php");
|
||||
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
if (isset($_POST["limit"])) {
|
||||
echo selectLimitedGroupsFromUser($_SESSION["userID"], (int)test_input($_POST["limit"]));
|
||||
} else {
|
||||
echo selectAllGroupsFromUser($_SESSION["userID"]);
|
||||
}
|
||||
} else {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
}
|
||||
@@ -5,9 +5,18 @@ session_start();
|
||||
require_once("../../queries/connect.php");
|
||||
require_once("../../queries/private_message.php");
|
||||
require_once("../../queries/checkInput.php");
|
||||
require_once("../../queries/friendship.php");
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
if (isset($_POST["lastID"]) && $_POST["lastID"] != "") {
|
||||
echo getNewChatMessages(test_input($_POST["lastID"]), test_input($_POST["destination"]));
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
if (isset($_POST["lastID"]) && $_POST["lastID"] != "") {
|
||||
setLastVisited(test_input($_POST["destination"]));
|
||||
echo getNewChatMessages(test_input($_POST["lastID"]), test_input($_POST["destination"]));
|
||||
} else {
|
||||
setLastVisited(test_input($_POST["destination"]));
|
||||
echo getOldChatMessages(test_input($_POST["destination"]));
|
||||
}
|
||||
} else {
|
||||
echo getOldChatMessages(test_input($_POST["destination"]));
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/friendship.php");
|
||||
|
||||
echo selectAllFriendRequests();
|
||||
21
website/public/API/loadPost.php
Normal file
21
website/public/API/loadPost.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once("../../queries/connect.php");
|
||||
require_once("../../queries/post.php");
|
||||
require_once("../../queries/checkInput.php");
|
||||
require_once("../../queries/nicetime.php");
|
||||
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
if (isset($_GET['postID'])) {
|
||||
include("../../views/post-view.php");
|
||||
} else {
|
||||
echo "Kan de post niet laden";
|
||||
}
|
||||
} else {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
}
|
||||
37
website/public/API/postComment.php
Normal file
37
website/public/API/postComment.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once("../../queries/post.php");
|
||||
require_once("../../queries/connect.php");
|
||||
require_once("../../queries/checkInput.php");
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'frozen' &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
if ($_POST['button'] == 'reaction') {
|
||||
if (empty($_POST['newcomment-content'])) {
|
||||
echo 0;
|
||||
} else {
|
||||
if (makeComment($_POST['postID'],
|
||||
$_SESSION['userID'],
|
||||
test_input($_POST['newcomment-content']))) {
|
||||
echo 1;
|
||||
} else {
|
||||
echo 0;
|
||||
}
|
||||
}
|
||||
} else if ($_POST['button'] == 'nietslecht') {
|
||||
if (makeNietSlecht($_POST["postID"], $_SESSION["userID"])) {
|
||||
echo 1;
|
||||
} else {
|
||||
echo 0;
|
||||
}
|
||||
} else {
|
||||
echo 0;
|
||||
}
|
||||
} else {
|
||||
echo "frozen";
|
||||
}
|
||||
48
website/public/API/postPost.php
Normal file
48
website/public/API/postPost.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once("../../queries/post.php");
|
||||
require_once("../../queries/group_page.php");
|
||||
require_once("../../queries/connect.php");
|
||||
require_once("../../queries/checkInput.php");
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'frozen' &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
|
||||
if (empty($_POST["title"]) or
|
||||
empty($_POST["content"]) or
|
||||
empty($_SESSION["userID"])
|
||||
) {
|
||||
header('HTTP/1.1 500 Non enough arguments');
|
||||
}
|
||||
|
||||
if (empty($_POST["group"])) {
|
||||
// User Post
|
||||
makePost(
|
||||
$_SESSION["userID"],
|
||||
null,
|
||||
test_input($_POST["title"]),
|
||||
test_input($_POST["content"])
|
||||
);
|
||||
} else {
|
||||
// Group Post
|
||||
|
||||
// Check if the user is an admin or mod of the group.
|
||||
if (!in_array(selectGroupRole($_POST["group"]), array('mod', 'admin'))) {
|
||||
header('HTTP/1.1 500 Non enough rights');
|
||||
return;
|
||||
}
|
||||
|
||||
makePost(
|
||||
$_SESSION["userID"],
|
||||
$_POST["group"],
|
||||
test_input($_POST["title"]),
|
||||
test_input($_POST["content"])
|
||||
);
|
||||
}
|
||||
} else {
|
||||
echo "frozen";
|
||||
}
|
||||
35
website/public/API/searchGroups.php
Normal file
35
website/public/API/searchGroups.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/checkInput.php");
|
||||
require_once ("../../queries/group_member.php");
|
||||
require_once ("../../queries/group_page.php");
|
||||
require_once ("../../queries/user.php");
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
|
||||
$n = 0;
|
||||
if (isset($_POST["n"])) {
|
||||
$n = (int)test_input($_POST["n"]);
|
||||
}
|
||||
$m = 20;
|
||||
if (isset($_POST["m"])) {
|
||||
$m = (int)test_input($_POST["m"]);
|
||||
}
|
||||
$search = "";
|
||||
if (isset($_POST["search"])) {
|
||||
$search = test_input($_POST["search"]);
|
||||
}
|
||||
|
||||
if (isset($_POST["filter"]) && $_POST["filter"] == "personal") {
|
||||
echo searchSomeOwnGroups($n, $m, $search);
|
||||
} else {
|
||||
echo searchSomeGroups($n, $m, $search);
|
||||
}
|
||||
} else {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
}
|
||||
47
website/public/API/searchPageNumber.php
Normal file
47
website/public/API/searchPageNumber.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/checkInput.php");
|
||||
require_once ("../../queries/user.php");
|
||||
require_once ("../../queries/group_page.php");
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
|
||||
$user_perpage = $group_perpage = 20;
|
||||
|
||||
$user_currentpage = $group_currentpage = 1;
|
||||
if (isset($_POST['user-pageselect'])) {
|
||||
$user_currentpage = test_input($_POST['user-pageselect']);
|
||||
}
|
||||
if (isset($_POST['group-pageselect'])) {
|
||||
$group_currentpage = test_input($_POST['group-pageselect']);
|
||||
}
|
||||
|
||||
$user_n = $user_currentpage * $user_perpage - $user_perpage;
|
||||
$group_n = $group_currentpage * $group_perpage - $group_perpage;
|
||||
|
||||
$search = "";
|
||||
if (isset($_POST['search'])) {
|
||||
$search = test_input($_POST['search']);
|
||||
}
|
||||
|
||||
$user_count = countSomeUsers($search)->fetchColumn();
|
||||
$group_count = countSomeGroups($search)->fetchColumn();
|
||||
|
||||
$filter = "all";
|
||||
if (isset($_POST['filter'])) {
|
||||
$filter = test_input($_POST['filter']);
|
||||
}
|
||||
|
||||
$option = "user";
|
||||
if (isset($_POST['option'])) {
|
||||
$option = test_input($_POST['option']);
|
||||
}
|
||||
|
||||
include("../../views/searchPageNumber.php");
|
||||
} else {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
}
|
||||
35
website/public/API/searchUsers.php
Normal file
35
website/public/API/searchUsers.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/checkInput.php");
|
||||
require_once ("../../queries/friendship.php");
|
||||
require_once ("../../queries/user.php");
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
|
||||
$n = 0;
|
||||
$m = 20;
|
||||
|
||||
$page = 1;
|
||||
if (isset($_POST["user-pageselect"])) {
|
||||
$page = (int)test_input($_POST['user-pageselect']);
|
||||
}
|
||||
|
||||
$n = ($page - 1) * $m;
|
||||
|
||||
$search = "";
|
||||
if (isset($_POST["search"])) {
|
||||
$search = test_input($_POST["search"]);
|
||||
}
|
||||
|
||||
if (isset($_POST["filter"]) && $_POST["filter"] == "personal") {
|
||||
echo searchSomeFriends($n, $m, $search);
|
||||
} else {
|
||||
echo searchSomeUsers($n, $m, $search);
|
||||
}
|
||||
} else {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
}
|
||||
@@ -4,14 +4,22 @@ session_start();
|
||||
require_once("../../queries/connect.php");
|
||||
require_once("../../queries/private_message.php");
|
||||
require_once("../../queries/checkInput.php");
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
if (!empty(test_input($_POST["destination"])) &&
|
||||
!empty(test_input($_POST["content"]))) {
|
||||
if (sendMessage(test_input($_POST["destination"]), test_input($_POST["content"]))) {
|
||||
echo 1;
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'frozen' &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
if (!empty(test_input($_POST["destination"])) &&
|
||||
!empty(test_input($_POST["content"]))
|
||||
) {
|
||||
if (sendMessage(test_input($_POST["destination"]), test_input($_POST["content"]))) {
|
||||
echo 1;
|
||||
} else {
|
||||
echo 0;
|
||||
}
|
||||
} else {
|
||||
echo 0;
|
||||
}
|
||||
} else {
|
||||
echo 0;
|
||||
echo "frozen";
|
||||
}
|
||||
@@ -1,10 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<?php include("../views/head.php"); ?>
|
||||
<?php
|
||||
require_once ("../queries/user.php");
|
||||
require_once ("../queries/group_page.php");
|
||||
require_once ("../views/head.php"); ?>
|
||||
<style>
|
||||
@import url("styles/adminpanel.css");
|
||||
</style>
|
||||
<script src="js/admin.js" charset="utf-8"></script>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
@@ -12,6 +16,15 @@
|
||||
* This view adds the main layout over the screen.
|
||||
* Header and menu.
|
||||
*/
|
||||
include_once ("../queries/user.php");
|
||||
|
||||
// auth
|
||||
$role = getRoleByID($_SESSION['userID']);
|
||||
|
||||
if ($role != 'admin' AND $role != 'owner') {
|
||||
header("location:profile.php");
|
||||
}
|
||||
|
||||
include("../views/main.php");
|
||||
|
||||
/* Add your view files here. */
|
||||
|
||||
90
website/public/bits/friend-item.php
Normal file
90
website/public/bits/friend-item.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
include_once ("../../queries/friendship.php");
|
||||
|
||||
if (isset($_POST["action"])) {
|
||||
$action = $_POST["action"];
|
||||
} else {
|
||||
$action = "profile.php";
|
||||
}
|
||||
|
||||
if (isset($_POST["actionType"])) {
|
||||
$actionType = $_POST["actionType"];
|
||||
} else {
|
||||
$actionType = "GET";
|
||||
}
|
||||
|
||||
$friends = json_decode($_POST["friends"]);
|
||||
|
||||
foreach($friends as $i => $friend) {
|
||||
$friendshipStatus = getFriendshipStatus($friend->userID);
|
||||
?>
|
||||
<li class='friend-item'>
|
||||
<form action='<?= $action ?>' method='<?= $actionType ?>'>
|
||||
<button type='submit'
|
||||
name='username'
|
||||
value='<?php
|
||||
if (isset($friend->username)) {
|
||||
echo $friend->username;
|
||||
} else if (isset($friend->content)) {
|
||||
echo $friend->userID;
|
||||
}
|
||||
?>'>
|
||||
<div class='friend'>
|
||||
<img alt='PF' class='profile-picture <?= $friend->onlinestatus ?>' src='<?= $friend->profilepicture ?>'/>
|
||||
<div class='friend-name'>
|
||||
<?= $friend->fullname ?><br/>
|
||||
<span style='color: #666'><?php
|
||||
if (isset($friend->username)) {
|
||||
echo $friend->username;
|
||||
} else if (isset($friend->content)) {
|
||||
echo $friend->content;
|
||||
}
|
||||
?></span>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
</form>
|
||||
<?php
|
||||
if ($friendshipStatus > 1) {
|
||||
if ($friendshipStatus == 2) {
|
||||
$denyName = "Annuleer";
|
||||
} else {
|
||||
$denyName = "Weiger";
|
||||
}
|
||||
?>
|
||||
<div class='notification-options'>
|
||||
<?php
|
||||
if ($friendshipStatus == 3) {
|
||||
?>
|
||||
<button name='accept'
|
||||
onclick="editFriendship('<?= $friend->userID ?>', 'accept')"
|
||||
class='accept-notification'
|
||||
value='1'>
|
||||
<i class='fa fa-check'></i>Accepteer
|
||||
</button>
|
||||
<?php
|
||||
}
|
||||
|
||||
?>
|
||||
<input type='hidden' name='userID' value='' />
|
||||
<button name='delete'
|
||||
onclick="editFriendship('<?= $friend->userID ?>', 'delete')"
|
||||
class='deny-notification'
|
||||
value='1'>
|
||||
<i class='fa fa-times'></i> <?= $denyName ?>
|
||||
</button>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
24
website/public/bits/group-item.php
Normal file
24
website/public/bits/group-item.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
include_once ("../../queries/group_member.php");
|
||||
|
||||
$groups = json_decode($_POST["groups"]);
|
||||
|
||||
foreach($groups as $i => $group) {
|
||||
?>
|
||||
<li class='group-item'>
|
||||
<form action='group.php' method='get'>
|
||||
<button type='submit'
|
||||
name='groupname'
|
||||
value='<?= $group->name ?>'>
|
||||
<div class='group'>
|
||||
<img alt='PF' class='group-picture' src='<?= $group->picture ?>'/>
|
||||
<?= $group->name ?>
|
||||
</div>
|
||||
</button>
|
||||
</form>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
49
website/public/emailconfirm.php
Normal file
49
website/public/emailconfirm.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
include_once("../queries/connect.php");
|
||||
include_once("../views/messagepage.php");
|
||||
if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) {
|
||||
$checkHash = prepareQuery("
|
||||
SELECT
|
||||
`email`,
|
||||
`role`
|
||||
FROM
|
||||
`user`
|
||||
WHERE
|
||||
`userID` = :userID
|
||||
");
|
||||
$checkHash->bindParam(":userID", $_GET["u"]);
|
||||
$checkHash->execute();
|
||||
$result = $checkHash->fetch();
|
||||
$email = $result["email"];
|
||||
$role = $result["role"];
|
||||
if ($role == "unconfirmed") {
|
||||
doActivate($email);
|
||||
} else {
|
||||
messagePage("Ongeldige link.");
|
||||
}
|
||||
|
||||
} else {
|
||||
messagePage("Ongeldige link.");
|
||||
}
|
||||
|
||||
function doActivate(string $email) {
|
||||
if (password_verify($email, $_GET["h"])) {
|
||||
$confirmUser = prepareQuery("
|
||||
UPDATE
|
||||
`user`
|
||||
SET
|
||||
`role` = :role
|
||||
WHERE
|
||||
`userID` = :userID
|
||||
");
|
||||
$confirmUser->bindValue(":role", "user");
|
||||
$confirmUser->bindParam(":userID", $_GET["u"]);
|
||||
$confirmUser->execute();
|
||||
if ($confirmUser->rowCount()) {
|
||||
messagePage("Email bevestigd <br />
|
||||
<a href='index.php'>Klik hier om terug te gaan naar de login pagina.</a>");
|
||||
}
|
||||
} else {
|
||||
messagePage("Ongeldige link.");
|
||||
}
|
||||
}
|
||||
9
website/public/error/404.php
Normal file
9
website/public/error/404.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
require_once "../../views/messagepage.php";
|
||||
|
||||
messagePage("
|
||||
<div class='error-page'>
|
||||
<h1>404</h1>
|
||||
<h4>Verkeerde link...</h4><br />
|
||||
<img height='25%' width='25%' src='../img/zelda.png'>
|
||||
</div>");
|
||||
71
website/public/fb-callback.php
Normal file
71
website/public/fb-callback.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
$fb = new Facebook\Facebook([
|
||||
'app_id' => $appID, // Replace {app-id} with your app id
|
||||
'app_secret' => $appSecret,
|
||||
'default_graph_version' => 'v2.2',
|
||||
]);
|
||||
|
||||
$helper = $fb->getRedirectLoginHelper();
|
||||
|
||||
try {
|
||||
$accessToken = $helper->getAccessToken();
|
||||
} catch(Facebook\Exceptions\FacebookResponseException $e) {
|
||||
// When Graph returns an error
|
||||
echo 'Graph returned an error: ' . $e->getMessage();
|
||||
exit;
|
||||
} catch(Facebook\Exceptions\FacebookSDKException $e) {
|
||||
// When validation fails or other local issues
|
||||
echo 'Facebook SDK returned an error: ' . $e->getMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
if (! isset($accessToken)) {
|
||||
if ($helper->getError()) {
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
echo "Error: " . $helper->getError() . "\n";
|
||||
echo "Error Code: " . $helper->getErrorCode() . "\n";
|
||||
echo "Error Reason: " . $helper->getErrorReason() . "\n";
|
||||
echo "Error Description: " . $helper->getErrorDescription() . "\n";
|
||||
} else {
|
||||
header('HTTP/1.0 400 Bad Request');
|
||||
echo 'Bad request';
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
// Logged in
|
||||
echo '<h3>Access Token</h3>';
|
||||
var_dump($accessToken->getValue());
|
||||
|
||||
// The OAuth 2.0 client handler helps us manage access tokens
|
||||
$oAuth2Client = $fb->getOAuth2Client();
|
||||
|
||||
// Get the access token metadata from /debug_token
|
||||
$tokenMetadata = $oAuth2Client->debugToken($accessToken);
|
||||
echo '<h3>Metadata</h3>';
|
||||
var_dump($tokenMetadata);
|
||||
|
||||
// Validation (these will throw FacebookSDKException's when they fail)
|
||||
$tokenMetadata->validateAppId($appID); // Replace {app-id} with your app id
|
||||
// If you know the user ID this access token belongs to, you can validate it here
|
||||
//$tokenMetadata->validateUserId('123');
|
||||
$tokenMetadata->validateExpiration();
|
||||
|
||||
if (! $accessToken->isLongLived()) {
|
||||
// Exchanges a short-lived access token for a long-lived one
|
||||
try {
|
||||
$accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
|
||||
} catch (Facebook\Exceptions\FacebookSDKException $e) {
|
||||
echo "<p>Error getting long-lived access token: " . $helper->getMessage() . "</p>\n\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
echo '<h3>Long-lived</h3>';
|
||||
var_dump($accessToken->getValue());
|
||||
}
|
||||
|
||||
$_SESSION['fb_access_token'] = (string) $accessToken;
|
||||
|
||||
// User is logged in with a long-lived access token.
|
||||
// You can redirect them to a members-only page.
|
||||
//header('Location: https://example.com/members.php');
|
||||
68
website/public/fbRegister.php
Normal file
68
website/public/fbRegister.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
try{
|
||||
$fbUsername = str_replace(' ', '', test_input(($_POST["fbUsername"])));
|
||||
checkInputChoice($fbUsername, "fbUsername");
|
||||
} catch(usernameException $e){
|
||||
$fbCorrect = false;
|
||||
$fbUsernameErr = $e->getMessage();
|
||||
}
|
||||
|
||||
try{
|
||||
$fbPassword = str_replace(' ', '', test_input(($_POST["fbPassword"])));
|
||||
checkInputChoice($fbPassword, "longerEight");
|
||||
matchfbPassword();
|
||||
} catch(passwordException $e){
|
||||
$fbCorrect = false;
|
||||
$fbPasswordErr = $e->getMessage();
|
||||
} catch(fbConfirmPasswordException $e){
|
||||
$fbCorrect = false;
|
||||
$fbConfirmpasswordErr = $e->getMessage();
|
||||
}
|
||||
|
||||
try{
|
||||
$fbName = test_input(($_POST["fbName"]));
|
||||
checkInputChoice($fbName, "lettersAndSpaces");
|
||||
} catch(lettersAndSpacesException $e){
|
||||
$fbCorrect = false;
|
||||
}
|
||||
|
||||
try {
|
||||
$fbSurname = test_input(($_POST["fbSurname"]));
|
||||
checkInputChoice($fbSurname, "lettersAndSpaces");
|
||||
}
|
||||
catch(lettersAndSpacesException $e){
|
||||
$fbCorrect = false;
|
||||
}
|
||||
|
||||
try {
|
||||
$fbDay_date = test_input(($_POST["fbDay_date"]));
|
||||
$fbMonth_date = test_input(($_POST["fbMonth_date"]));
|
||||
$fbYear_date = test_input(($_POST["fbYear_date"]));
|
||||
$fbBday = $fbYear_date . "-" . $fbMonth_date . "-" . $fbDay_date;
|
||||
checkInputChoice($fbBday, "bday");
|
||||
} catch (bdayException $e) {
|
||||
$fbBdayErr = $e->getMessage();
|
||||
$fbCorrect = false;
|
||||
}
|
||||
|
||||
try{
|
||||
$fbEmail = test_input(($_POST["fbEmail"]));
|
||||
checkInputChoice($fbEmail, "fbEmail");
|
||||
} catch(emailException $e){
|
||||
$fbCorrect = false;
|
||||
$fbEmailErr = $e->getMessage();
|
||||
|
||||
}
|
||||
|
||||
$fbUserID = test_input(($_POST["fbUserID"]));
|
||||
|
||||
try {
|
||||
fbRegisterCheck($fbCorrect);
|
||||
} catch(registerException $e){
|
||||
echo "<script>
|
||||
window.onload = function() {
|
||||
$('#fbModal').show();
|
||||
}
|
||||
</script>";
|
||||
$fbRegisterErr = $e->getMessage();
|
||||
}
|
||||
@@ -4,10 +4,23 @@
|
||||
<?php include("../views/head.php"); ?>
|
||||
<style>
|
||||
@import url("styles/profile.css");
|
||||
@import url("styles/post-popup.css");
|
||||
@import url('https://fonts.googleapis.com/css?family=Anton');
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
|
||||
include_once("../queries/group_page.php");
|
||||
|
||||
$group = selectGroupByName($_GET["groupname"]);
|
||||
$members = selectGroupMembers(2);
|
||||
|
||||
?>
|
||||
<script>alert("<?= $members[0] ?>");</script>
|
||||
<script>alert("<?= $members[1] ?>");</script>
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This view adds the main layout over the screen.
|
||||
* Header, menu, footer.
|
||||
@@ -19,6 +32,26 @@ include("../views/group.php");
|
||||
|
||||
/* This adds the footer. */
|
||||
include("../views/footer.php");
|
||||
|
||||
$masonry_mode = 0;
|
||||
if ($group["role"] == "mod" OR $group["role"] == "admin") {
|
||||
$masonry_mode = 2;
|
||||
}
|
||||
?>
|
||||
|
||||
<script src="js/masonry.js"></script>
|
||||
<script src="js/groupButtons.js"></script>
|
||||
<script src="js/post.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
userID = 0;
|
||||
groupID = <?= $group["groupID"] ?>;
|
||||
|
||||
placeGroupButtons();
|
||||
|
||||
masonry(<?= $masonry_mode ?>);
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
BIN
website/public/img/avatar-standard.png
Normal file
BIN
website/public/img/avatar-standard.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 98 KiB |
BIN
website/public/img/nietslecht_small.png
Normal file
BIN
website/public/img/nietslecht_small.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 24 KiB |
BIN
website/public/img/zelda.png
Normal file
BIN
website/public/img/zelda.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 147 KiB |
@@ -1,5 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0; url=login.php" />
|
||||
</head>
|
||||
</html>
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
if (isset($_SESSION["userID"])) {
|
||||
header("Location: profile.php");
|
||||
} else {
|
||||
header("Location: login.php");
|
||||
}
|
||||
@@ -1,44 +1,107 @@
|
||||
window.onload = function() {
|
||||
$(window).on("load", function () {
|
||||
changeFilter();
|
||||
};
|
||||
searchFromOne();
|
||||
|
||||
function checkAll(allbox) {
|
||||
var checkboxes = document.getElementsByClassName('checkbox-list');
|
||||
$(".admin-searchinput").keyup(function(){
|
||||
searchFromOne();
|
||||
});
|
||||
// all inputs and labels directly under admin filter and groupfilter
|
||||
$("#admin-filter, #admin-groupfilter > input, label").change(function(){
|
||||
searchFromOne();
|
||||
});
|
||||
$("#pagetype").change(function(){
|
||||
searchFromOne();
|
||||
});
|
||||
|
||||
for (var i = 0; i < checkboxes.length; i++) {
|
||||
if (checkboxes[i].type == 'checkbox') {
|
||||
checkboxes[i].checked = allbox.checked;
|
||||
}
|
||||
}
|
||||
/* Update hidden input to be equal to submit pressed,
|
||||
because serialize doesn't take submit values. */
|
||||
$('#admin-batchform > button').click(function () {
|
||||
$('#batchinput').prop('value', $(this).prop('value'));
|
||||
});
|
||||
|
||||
$('#admin-groupbatchform > button').click(function () {
|
||||
$('#groupbatchinput').prop('value', $(this).prop('value'));
|
||||
});
|
||||
});
|
||||
|
||||
function checkAll() {
|
||||
$('.checkbox-list').each(function () {
|
||||
$(this).prop('checked', $('#checkall').prop('checked'));
|
||||
});
|
||||
}
|
||||
|
||||
function checkCheckAll(allbox) {
|
||||
var checkboxes = document.getElementsByClassName('checkbox-list');
|
||||
function checkCheckAll() {
|
||||
var checked = true;
|
||||
|
||||
for (var i = 0; i < checkboxes.length; i++) {
|
||||
if (checkboxes[i].type == 'checkbox') {
|
||||
if (checkboxes[i].checked == false) {
|
||||
checked = false;
|
||||
break;
|
||||
}
|
||||
$('.checkbox-list').each(function () {
|
||||
if ($(this).prop('checked') == false) {
|
||||
checked = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
allbox.checked = checked;
|
||||
});
|
||||
|
||||
$('#checkall').prop('checked', checked);
|
||||
}
|
||||
|
||||
function changeFilter() {
|
||||
if (document.getElementById('group').checked) {
|
||||
if ($('#pagetype').find(":selected").val() == "group") {
|
||||
document.getElementById('admin-filter').style.display = 'none';
|
||||
document.getElementById('admin-groupfilter').style.display = 'inline-block';
|
||||
|
||||
document.getElementById('admin-batchactions').style.display = 'none';
|
||||
document.getElementById('admin-groupbatchactions').style.display = 'inline-block';
|
||||
document.getElementById('admin-batchform').style.display = 'none';
|
||||
document.getElementById('admin-groupbatchform').style.display = 'inline-block';
|
||||
} else {
|
||||
document.getElementById('admin-filter').style.display = 'inline-block';
|
||||
document.getElementById('admin-groupfilter').style.display = 'none';
|
||||
|
||||
document.getElementById('admin-batchactions').style.display = 'inline-block';
|
||||
document.getElementById('admin-groupbatchactions').style.display = 'none';
|
||||
document.getElementById('admin-batchform').style.display = 'inline-block';
|
||||
document.getElementById('admin-groupbatchform').style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function searchFromOne() {
|
||||
$('#currentpage').prop('value', 1);
|
||||
adminSearch();
|
||||
}
|
||||
|
||||
function adminSearch() {
|
||||
$.post(
|
||||
"API/adminSearchUsers.php",
|
||||
$("#admin-searchform").serialize()
|
||||
).done(function (data) {
|
||||
$("#usertable").html(data);
|
||||
updatePageN();
|
||||
})
|
||||
}
|
||||
|
||||
function adminUpdate(form) {
|
||||
$.post(
|
||||
"API/adminChangeUser.php",
|
||||
$(form).serialize()
|
||||
).done(function () {
|
||||
adminSearch();
|
||||
})
|
||||
}
|
||||
|
||||
function updatePageN() {
|
||||
$.post(
|
||||
"API/adminPageNumber.php",
|
||||
$("#admin-searchform").serialize()
|
||||
).done(function (data) {
|
||||
$("#admin-pageinfo").html(data);
|
||||
})
|
||||
}
|
||||
|
||||
function toggleBancomment(button) {
|
||||
$(button).siblings("div").toggle();
|
||||
$(button).toggle();
|
||||
}
|
||||
|
||||
function editComment(form) {
|
||||
$.post(
|
||||
"API/adminChangeUser.php",
|
||||
$(form).serialize()
|
||||
).done(function (data) {
|
||||
adminSearch();
|
||||
});
|
||||
}
|
||||
@@ -1,23 +1,31 @@
|
||||
var previousDate = new Date("1970-01-01 00:00:00");
|
||||
var previousTime = "00:00";
|
||||
var gettingMessages = false;
|
||||
var previousType = "robot";
|
||||
|
||||
$(document).ready(function() {
|
||||
loadMessages();
|
||||
setInterval(loadMessages, 1000);
|
||||
sayEmpty();
|
||||
$(".chat-field").hide();
|
||||
});
|
||||
|
||||
function loadMessages() {
|
||||
$.post(
|
||||
"API/loadMessages.php",
|
||||
$("#lastIDForm").serialize()
|
||||
).done(function(data) {
|
||||
if (data && data != "[]") {
|
||||
messages = JSON.parse(data);
|
||||
addMessages(messages);
|
||||
$("#lastID").val(messages[messages.length - 1].messageID);
|
||||
$("#chat-history").scrollTop($("#chat-history")[0].scrollHeight);
|
||||
}
|
||||
});
|
||||
|
||||
setTimeout(loadMessages, 1000);
|
||||
if (!gettingMessages) {
|
||||
gettingMessages = true;
|
||||
$.post(
|
||||
"API/loadMessages.php",
|
||||
$("#lastIDForm").serialize()
|
||||
).done(function (data) {
|
||||
if (data && data != "[]") {
|
||||
messages = JSON.parse(data);
|
||||
addMessages(messages);
|
||||
$("#lastID").val(messages[messages.length - 1].messageID);
|
||||
}
|
||||
gettingMessages = false;
|
||||
});
|
||||
} else {
|
||||
setTimeout(loadMessages, 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,38 +33,81 @@ function sendMessage() {
|
||||
$.post(
|
||||
"API/sendMessage.php",
|
||||
$("#sendMessageForm").serialize()
|
||||
);
|
||||
).done(function(response) {
|
||||
if (response == "frozen") {
|
||||
alert("Je account is bevroren, dus je kan niet chat berichten versturen. Contacteer een admin als je denkt dat dit onjuist is.");
|
||||
}
|
||||
});
|
||||
|
||||
$("#newContent").val("");
|
||||
loadMessages();
|
||||
}
|
||||
|
||||
function addMessages(messages) {
|
||||
for(i in messages) {
|
||||
var messagesText = "";
|
||||
for(var i in messages) {
|
||||
// Initialize message variables
|
||||
var thisDate = new Date(messages[i].creationdate.replace(/ /,"T"));
|
||||
var thisTime = thisDate.getHours() + ":" + thisDate.getMinutes();
|
||||
var type;
|
||||
thisDate.setHours(0,0,0,0);
|
||||
|
||||
if (messages[i].destination == $(".destinationID").val()) {
|
||||
type = "chat-message-self";
|
||||
} else {
|
||||
type = "chat-message-other";
|
||||
}
|
||||
if (i == 0) {
|
||||
previousDate = thisDate;
|
||||
messagesText += '\
|
||||
<div class="day-message"> \
|
||||
<div class="day-message-content">\
|
||||
' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\
|
||||
</div> \
|
||||
</div>';
|
||||
messagesText += '<div class="chat-message"><div class="' + type + '">';
|
||||
} else if (type != previousType || thisTime != previousTime || thisDate.getTime() > previousDate.getTime()) {
|
||||
messagesText += '<div class="chat-time">\
|
||||
' + thisTime + '\
|
||||
</div></div></div>';
|
||||
|
||||
$("#chat-history").append('\
|
||||
<div class="chat-message"> \
|
||||
<div class="' + type + '">\
|
||||
' + messages[i].content + '\
|
||||
</div> \
|
||||
</div>\
|
||||
');
|
||||
previousTime = thisTime;
|
||||
previousType = type;
|
||||
if (thisDate > previousDate) {
|
||||
previousDate = thisDate;
|
||||
messagesText += '\
|
||||
<div class="day-message"> \
|
||||
<div class="day-message-content">\
|
||||
' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\
|
||||
</div> \
|
||||
</div>';
|
||||
}
|
||||
|
||||
messagesText += '<div class="chat-message"><div class="' + type + '">';
|
||||
}
|
||||
messagesText += fancyText(messages[i].content) + "<br />";
|
||||
}
|
||||
|
||||
// Close the last message
|
||||
messagesText += '<div class="chat-time">\
|
||||
' + thisTime + '\
|
||||
</div></div></div>';
|
||||
|
||||
$("#chat-history").append(messagesText);
|
||||
|
||||
$("#chat-history").scrollTop($("#chat-history")[0].scrollHeight - $('#chat-history')[0].clientHeight);
|
||||
}
|
||||
|
||||
function switchUser(userID) {
|
||||
previousDate = new Date("1970-01-01 00:00:00");
|
||||
$(".chat-field").show();
|
||||
$(".destinationID").val(userID);
|
||||
$("#chat-history").html("");
|
||||
$("#lastID").val("");
|
||||
$(".chat-left .friend-item").removeClass("active-friend-chat");
|
||||
$(".chat-left #friend-item-" + userID).addClass("active-friend-chat");
|
||||
$("#chat-recent-panel .friend-item").removeClass("active-friend-chat");
|
||||
$("#friend-item-" + userID).addClass("active-friend-chat");
|
||||
}
|
||||
|
||||
function sayEmpty() {
|
||||
$("#chat-history").html("Begin nu met chatten!");
|
||||
$("#chat-history").html("Probeer ook eens foto's en video's te sturen");
|
||||
}
|
||||
70
website/public/js/friendButtons.js
Normal file
70
website/public/js/friendButtons.js
Normal file
@@ -0,0 +1,70 @@
|
||||
function placeFriendButtons() {
|
||||
$.post("API/getFriendshipStatus.php", { usr: userID })
|
||||
.done(function(data) {
|
||||
var friendshipStatus = data;
|
||||
var $buttonContainer = $("div.friend-button-container");
|
||||
$("#start-profile-chat").hide();
|
||||
$buttonContainer.html("");
|
||||
var value1 = "";
|
||||
var class1 = "empty-button";
|
||||
var icon1 = "";
|
||||
var text1 = "";
|
||||
|
||||
var value2 = "";
|
||||
var class2 = "empty-button";
|
||||
var icon2 = "";
|
||||
var text2 = "";
|
||||
|
||||
switch (friendshipStatus) {
|
||||
case "0":
|
||||
value1 = "request";
|
||||
class1 = "green";
|
||||
text1 = "Bevriend";
|
||||
icon1 = "fa-handshake-o";
|
||||
break;
|
||||
case "1":
|
||||
value1 = userID;
|
||||
class1 = "green";
|
||||
text1 = "Chat";
|
||||
icon1 = "fa-comment-o";
|
||||
value2 = "delete";
|
||||
class2 = "red";
|
||||
text2 = "Verwijder";
|
||||
icon2 = "fa-times";
|
||||
break;
|
||||
case "2":
|
||||
value1 = "delete";
|
||||
class1 = "red";
|
||||
text1 = "Trek verzoek in";
|
||||
icon1 = "fa-cross";
|
||||
break;
|
||||
case "3":
|
||||
value1 = "accept";
|
||||
class1 = "green";
|
||||
text1 = "Accepteer";
|
||||
icon1 = "fa-check";
|
||||
value2 = "delete";
|
||||
class2 = "red";
|
||||
text2 = "Weiger";
|
||||
icon2 = "fa-times";
|
||||
break;
|
||||
}
|
||||
|
||||
$buttonContainer.append(
|
||||
"<button class='"+ class1 +" friend-button' value='"+ value1 +"'>" +
|
||||
"<i class='fa "+ icon1 +"'></i> " + text1 +
|
||||
"</button>");
|
||||
$buttonContainer.append(
|
||||
"<button class='"+ class2 +" friend-button' value='"+ value2 +"'>" +
|
||||
"<i class='fa "+ icon2 +"'></i> " + text2 +
|
||||
"</button>");
|
||||
|
||||
|
||||
$buttonContainer.children().click(function() {
|
||||
if (isNaN(this.value))
|
||||
editFriendship(userID, this.value);
|
||||
else if (this.value != "")
|
||||
window.location.href = "chat.php?username=" + this.value;
|
||||
});
|
||||
});
|
||||
}
|
||||
34
website/public/js/groupButtons.js
Normal file
34
website/public/js/groupButtons.js
Normal file
@@ -0,0 +1,34 @@
|
||||
function placeGroupButtons() {
|
||||
$.post("API/getGrouprole.php", { grp: groupID })
|
||||
.done(function(data) {
|
||||
var $buttonContainer = $("div.group-button-container");
|
||||
|
||||
if(data == 'none') {
|
||||
$buttonContainer.append(
|
||||
"<button class='green group-button' value='request'>" +
|
||||
"<i class='fa fa-plus'></i> Voeg toe" +
|
||||
"</button>");
|
||||
} else if(data == 'request') {
|
||||
$buttonContainer.append(
|
||||
"<button class='red group-button' value='none'>" +
|
||||
"<i class='fa fa-times'></i> Trek verzoek in" +
|
||||
"</button>");
|
||||
} else {
|
||||
$buttonContainer.append(
|
||||
"<button class='red group-button' value='none'>" +
|
||||
"<i class='fa fa-times'></i> Verlaat groep" +
|
||||
"</button>");
|
||||
}
|
||||
|
||||
$buttonContainer.children().click(function() {
|
||||
$.post("API/editMembership.php", { grp: groupID, role: this.value })
|
||||
.done(function() {
|
||||
$buttonContainer.children().remove();
|
||||
placeGroupButtons();
|
||||
updateMenus();
|
||||
}).fail(function() {
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
@@ -1,33 +1,55 @@
|
||||
$(document).ready(function() {
|
||||
// Hide notification center.
|
||||
$("#profile-menu-popup").hide();
|
||||
// Toggle menu
|
||||
$("#own-profile-picture, #open-notifications").click(function() {
|
||||
if ($("#notification-center").css('display') == "none") {
|
||||
// Make the menu visible and move the content to the left.
|
||||
$(".modal").width("calc(100% - 512px)");
|
||||
$(".content").css("margin-right", "256px");
|
||||
$("#notification-center").css("right", "0px");
|
||||
$("#notification-center").css("display", "block");
|
||||
$("#contact-menu").css("display", "block");
|
||||
|
||||
// $("#own-profile-picture").click(function() {
|
||||
// $("#profile-menu-popup").toggle();
|
||||
// $("#profile-hello-popup").toggle();
|
||||
// });
|
||||
|
||||
$("#own-profile-picture").click(function() {
|
||||
if($("#notification-center").css('right') == "-256px") {
|
||||
$(".content").animate({
|
||||
marginRight: "256px"
|
||||
}, 500);
|
||||
$(".chat-right").animate({
|
||||
width: "100%"
|
||||
}, 500);
|
||||
$("#notification-center").animate({
|
||||
right: "0px"
|
||||
}, 500);
|
||||
// Add cookie so the menu stays open on other pages
|
||||
if (window.innerWidth > 1080) {
|
||||
$("#chat-history").css("margin-right", "266px");
|
||||
$("#chat-history").css("width", "calc(100% - 512px - 75px)");
|
||||
document.cookie = "menu=open; path=/";
|
||||
} else {
|
||||
document.cookie = "menu=closed; path=/";
|
||||
}
|
||||
} else {
|
||||
$(".chat-right").animate({
|
||||
width: "100%"
|
||||
}, 500);
|
||||
$(".content").animate({
|
||||
marginRight: "0px"
|
||||
}, 500);
|
||||
$("#notification-center").animate({
|
||||
right: "-256px"
|
||||
}, 500);
|
||||
$(".modal").width("calc(100% - 256px)");
|
||||
$(".content").css("margin-right", "0px");
|
||||
$("#notification-center").css("display", "none");
|
||||
|
||||
if (window.innerWidth > 1080) {
|
||||
$("#chat-history").css("margin-right", "10px");
|
||||
$("#chat-history").css("width", "calc(100% - 256px - 85px)");
|
||||
} else {
|
||||
// Make the menu invisible and move the content to the right.
|
||||
$("#contact-menu").css("display", "none");
|
||||
}
|
||||
|
||||
// Change menu cookie to close
|
||||
document.cookie = "menu=closed; path=/";
|
||||
}
|
||||
});
|
||||
|
||||
if (getCookie("menu") == "open") {
|
||||
// Make the menu visible and move the content to the left.
|
||||
$(".modal").width("calc(100% - 512px)");
|
||||
$(".content").css("margin-right", "256px");
|
||||
$("#notification-center").css("right", "0px");
|
||||
$("#notification-center").css("display", "block");
|
||||
$("#contact-menu").css("display", "block");
|
||||
|
||||
// Add cookie so the menu stays open on other pages
|
||||
if (window.innerWidth > 1080) {
|
||||
$("#chat-history").css("margin-right", "266px");
|
||||
$("#chat-history").width("calc(100% - 587px)");
|
||||
document.cookie = "menu=open; path=/";
|
||||
} else {
|
||||
document.cookie = "menu=closed; path=/";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
97
website/public/js/main.js
Normal file
97
website/public/js/main.js
Normal file
@@ -0,0 +1,97 @@
|
||||
var days = ["zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag"];
|
||||
var months = ["januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"]
|
||||
|
||||
function fancyText(text) {
|
||||
// Add links, images, gifs and (youtube) video's.
|
||||
var regex = /(https?:\/\/.[^ <>"]*)/ig;
|
||||
text = text.replace(regex, function(link) {
|
||||
// Add images
|
||||
if (link.match(/(https?:\/\/.[^ ]*\.(?:png|jpg|jpeg|gif))/ig)) {
|
||||
return "<img alt='" + link + "' src='" + link + "' />";
|
||||
}
|
||||
// Add mp4 video's
|
||||
else if (link.match(/(https?:\/\/.[^ ]*\.(?:mp4))/ig)) {
|
||||
return "<video width='100%'>" +
|
||||
"<source src='"+ link +"' type='video/mp4'>" +
|
||||
"<b>Je browser ondersteund geen video</b>" +
|
||||
"</video><button class='gray' onclick='$(this).prev().get(0).play();'>Speel af</button>";
|
||||
}
|
||||
// Add ogg video's
|
||||
else if (link.match(/(https?:\/\/.[^ ]*\.(?:ogg))/ig)) {
|
||||
return "<video width='100%'>" +
|
||||
"<source src='"+ link +"' type='video/ogg'>" +
|
||||
"<b>Je browser ondersteund geen video</b>" +
|
||||
"</video><button onclick='$(this).prev().get(0).play();'>Speel af</button>";
|
||||
}
|
||||
// Add youtube video's
|
||||
else if (link.match(/(https?:\/\/.(www.)?youtube|youtu.be)*watch/ig)) {
|
||||
return '<iframe width="100%"' +
|
||||
' src="https://www.youtube.com/embed/' + link.substr(link.length - 11) +
|
||||
'" frameborder="0" allowfullscreen></iframe>';
|
||||
}
|
||||
// Add links
|
||||
else {
|
||||
return "<a href='" + link + "'>" + link + "</a>";
|
||||
}
|
||||
});
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
function getCookie(key) {
|
||||
cookies = document.cookie.split("; ");
|
||||
for (var i in cookies) {
|
||||
cookie = cookies[i].split("=");
|
||||
if (cookie[0] == key) {
|
||||
return cookie[1];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function editFriendship(userID, value) {
|
||||
$.post("API/editFriendship.php", { usr: userID, action: value })
|
||||
.done(function() {
|
||||
placeFriendButtons();
|
||||
updateMenus();
|
||||
});
|
||||
}
|
||||
|
||||
function showFriends(friends, list) {
|
||||
if(friends && friends != "[]") {
|
||||
$(list).load("bits/friend-item.php", {
|
||||
"friends": friends
|
||||
});
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function showFriendsPlus(friends, list, limit, action, actionType) {
|
||||
if(friends && friends != "[]") {
|
||||
$(list).load("bits/friend-item.php", {
|
||||
"friends": friends,
|
||||
"limit": limit,
|
||||
"action": action,
|
||||
"actionType": actionType
|
||||
});
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function showGroups(groups, list) {
|
||||
if(groups && groups != "[]") {
|
||||
$(list).load("bits/group-item.php", {
|
||||
"groups": groups
|
||||
});
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,76 +1,189 @@
|
||||
margin = 20;
|
||||
|
||||
$(window).on("load", function() {
|
||||
console.log("LOADED");
|
||||
container = $("div.posts");
|
||||
posts = container.children();
|
||||
posts.remove();
|
||||
// scrolling modal taken from http://stackoverflow.com/questions/10476632/how-to-scroll-the-page-when-a-modal-dialog-is-longer-than-the-screen
|
||||
function scrollbarMargin(width, overflow) {
|
||||
$('body').css({
|
||||
marginRight: width,
|
||||
overflow: overflow
|
||||
});
|
||||
$('.profile-menu').css({
|
||||
marginRight: width
|
||||
});
|
||||
}
|
||||
|
||||
column = $('<div class="column"></div>').append(posts);
|
||||
container.append(column);
|
||||
function requestPost(postID) {
|
||||
$(".modal").show();
|
||||
|
||||
mansonry();
|
||||
mansonry();
|
||||
$.get("API/loadPost.php", { postID : postID }).done(function(data) {
|
||||
$('.modal-default').hide();
|
||||
var scrollBarWidth = window.innerWidth - document.body.offsetWidth;
|
||||
scrollbarMargin(scrollBarWidth, 'hidden');
|
||||
$('#modal-response').show();
|
||||
$('#modal-response').html(fancyText(data));
|
||||
});
|
||||
}
|
||||
|
||||
function postPost() {
|
||||
title = $("input.newpost[name='title']").val();
|
||||
content = $("textarea.newpost[name='content']").val();
|
||||
|
||||
if (masonryMode == 2) {
|
||||
$.post("API/postPost.php", { title: title,
|
||||
content : content,
|
||||
group : groupID })
|
||||
.done(function() {
|
||||
masonry(masonryMode);
|
||||
});
|
||||
} else {
|
||||
$.post("API/postPost.php", { title: title,
|
||||
content : content })
|
||||
.done(function() {
|
||||
masonry(masonryMode);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
var masonryMode = 0;
|
||||
var windowWidth;
|
||||
var columnCount;
|
||||
var columns;
|
||||
var postLimit;
|
||||
var postAmount = 0;
|
||||
var noposts = false;
|
||||
|
||||
$(document).ready(function () {
|
||||
windowWidth = $(window).width();
|
||||
columnCount = Math.floor($(".posts").width() / 250);
|
||||
columns = new Array(columnCount);
|
||||
postLimit = columnCount * 7;
|
||||
});
|
||||
|
||||
$(window).on("load", function() {
|
||||
$(".modal-close").click(function (){closeModal()});
|
||||
|
||||
// http://stackoverflow.com/questions/9439725/javascript-how-to-detect-if-browser-window-is-scrolled-to-bottom
|
||||
window.onscroll = function(ev) {
|
||||
if($(window).scrollTop() + $(window).height() == $(document).height() ) {
|
||||
loadMorePosts(userID, groupID, postAmount, postLimit);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
function closeModal() {
|
||||
$(".modal").hide();
|
||||
scrollbarMargin(0, 'auto');
|
||||
$('#modal-response').hide();
|
||||
$('.modal-default').show();
|
||||
}
|
||||
|
||||
$(window).resize(function() {
|
||||
clearTimeout(window.resizedFinished);
|
||||
window.resizeFinished = setTimeout(function() {
|
||||
mansonry();
|
||||
if ($(window).width() != windowWidth) {
|
||||
windowWidth = $(window).width();
|
||||
|
||||
if (columnCount != Math.floor($(".posts").width() / 250)) {
|
||||
columnCount = Math.floor($(".posts").width() / 250);
|
||||
masonry(masonryMode);
|
||||
}
|
||||
}
|
||||
}, 250);
|
||||
});
|
||||
|
||||
function mansonry() {
|
||||
var $container = $(".posts");
|
||||
|
||||
columnCount = Math.floor($(".posts").width() / 250);
|
||||
console.log("columns: " + columnCount);
|
||||
function masonry(mode) {
|
||||
masonryMode = mode;
|
||||
$container.children().remove();
|
||||
|
||||
/*
|
||||
* Initialise columns.
|
||||
*/
|
||||
var columns = new Array(columnCount);
|
||||
|
||||
for (i = 0; i < columnCount; i++) {
|
||||
columns[i] = [0, []];
|
||||
console.log(columns[i]);
|
||||
$column = $("<div class=\"column\">");
|
||||
$column.width(100/columnCount + "%");
|
||||
$container.append($column);
|
||||
columns[i] = [0, $column];
|
||||
}
|
||||
|
||||
if(mode > 0) {
|
||||
$postInput = $("<div class=\"post platform\">");
|
||||
$form = $("<form class=\"newpost\" action=\"API/postPost.php\" method=\"post\" onsubmit=\"postPost(); return false;\">");
|
||||
$postInput.append($form);
|
||||
|
||||
if(mode == 2) {
|
||||
$form.append($("<input class=\"newpost\" type=\"hidden\" name=\"group\" value=\"" + groupID + "\">"));
|
||||
}
|
||||
|
||||
$form.append($("<input class=\"newpost\" name=\"title\" placeholder=\"Titel\" type=\"text\">"));
|
||||
$form.append($("<textarea class=\"newpost\" name=\"content\" placeholder=\"Schrijf een berichtje...\" maxlength='1000'></textarea><span></span>"));
|
||||
$form.append($("<input value=\"Plaats!\" type=\"submit\">"));
|
||||
columns[0][1].append($postInput);
|
||||
|
||||
columns[0][0] = $postInput.height() + margin;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function will find the column with the shortest height.
|
||||
*/
|
||||
function getShortestColumn(columns) {
|
||||
column = columns[0];
|
||||
|
||||
for (i = 1; i < columnCount; i++) {
|
||||
if (column[0] > columns[i][0]) {
|
||||
column = columns[i];
|
||||
}
|
||||
}
|
||||
|
||||
return column;
|
||||
}
|
||||
|
||||
/*
|
||||
* Rearange the objects.
|
||||
* Get the posts from the server.
|
||||
*/
|
||||
j = 0;
|
||||
posts.each(function(i) {
|
||||
post = posts[i];
|
||||
shortestColumn = getShortestColumn(columns);
|
||||
shortestColumn[0] = shortestColumn[0] + $(post).height() + margin;
|
||||
shortestColumn[1].push(post);
|
||||
|
||||
});
|
||||
|
||||
container.children().remove();
|
||||
/*
|
||||
* Display the objects again in the correct order.
|
||||
*/
|
||||
for (i = 0; i < columnCount; i++) {
|
||||
column = $('<div class="column"></div>').append(columns[i][1]);
|
||||
console.log(column);
|
||||
container.append(column);
|
||||
|
||||
}
|
||||
|
||||
$("div.posts div.column").width(100/columnCount + "%");
|
||||
loadMorePosts(userID, groupID, 0, postLimit);
|
||||
}
|
||||
|
||||
function getShortestColumn(columns) {
|
||||
column = columns[0];
|
||||
|
||||
for (i = 1; i < columnCount; i++) {
|
||||
if (column[0] > columns[i][0]) {
|
||||
column = columns[i];
|
||||
}
|
||||
}
|
||||
return column;
|
||||
}
|
||||
|
||||
function loadMorePosts(uID, gID, offset, limit) {
|
||||
if (noposts) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(uID, gID, offset, limit);
|
||||
|
||||
|
||||
$.post("API/getPosts.php", { usr : uID,
|
||||
grp : gID,
|
||||
offset : offset,
|
||||
limit : limit})
|
||||
.done(function(data) {
|
||||
if (!data) {
|
||||
$('.noposts').show();
|
||||
noposts = true;
|
||||
return;
|
||||
}
|
||||
|
||||
posts = JSON.parse(data);
|
||||
|
||||
/*
|
||||
* Rearange the objects.
|
||||
*/
|
||||
$.each(posts, function() {
|
||||
$post = $("<div class=\"post platform\" onclick=\"requestPost(\'"+this['postID']+"\')\">");
|
||||
$post.append($("<h2>").html(this["title"]));
|
||||
$post.append($("<p>").html(fancyText(this["content"])));
|
||||
$post.append($("<p class=\"subscript\">").text(this["nicetime"]));
|
||||
$post.append($("<p class=\"subscript\">").text("comments: " + this["comments"] + ", niet slechts: " + this["niet_slechts"]));
|
||||
|
||||
shortestColumn = getShortestColumn(columns);
|
||||
shortestColumn[1].append($post);
|
||||
shortestColumn[0] = shortestColumn[0] + $post.height() + margin;
|
||||
});
|
||||
});
|
||||
|
||||
postAmount += limit;
|
||||
}
|
||||
@@ -1,39 +1,126 @@
|
||||
var menuFriendsData;
|
||||
var menuGroupsData;
|
||||
var notificationMessagesData;
|
||||
var notificationRequestsData;
|
||||
var updatingMenus = 0;
|
||||
|
||||
// On document load, load menus and loops loading menus every 10 seconds.
|
||||
$(document).ready(function() {
|
||||
$(".extra-menu-items").hide();
|
||||
$("#menu-back").hide();
|
||||
|
||||
// Show more friends
|
||||
$("#more-friends-click").click(function() {
|
||||
// Show only friends
|
||||
$("#groups-menu-section").slideUp();
|
||||
$("#friends-menu-section li").show();
|
||||
|
||||
// Change buttons
|
||||
$("#more-friends-click").hide();
|
||||
$("#menu-back").show();
|
||||
});
|
||||
|
||||
// Show more groups
|
||||
$("#more-groups-click").click(function() {
|
||||
// Show only groups
|
||||
$("#friends-menu-section").slideUp();
|
||||
$("#groups-menu-section li").show();
|
||||
|
||||
// Change buttons
|
||||
$("#more-groups-click").hide();
|
||||
$("#menu-back").show();
|
||||
});
|
||||
|
||||
// Go back
|
||||
$("#menu-back").click(function() {
|
||||
// Show overview of friends and groups
|
||||
$("#friends-menu-section").slideDown();
|
||||
$("#groups-menu-section").slideDown();
|
||||
$(".extra-menu-items").hide();
|
||||
|
||||
// Change buttons
|
||||
$("#menu-back").hide();
|
||||
$("#more-groups-click").show();
|
||||
$("#more-friends-click").show();
|
||||
});
|
||||
updateMenus();
|
||||
setInterval(updateMenus, 10000);
|
||||
});
|
||||
|
||||
|
||||
// Update the menu and notification items.
|
||||
function updateMenus() {
|
||||
if (updatingMenus <= 0) {
|
||||
loadMenuFriends(5);
|
||||
loadNotificationFriends();
|
||||
loadUnreadMessages();
|
||||
loadMenuGroups();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get the friends and insert them in the menu.
|
||||
function loadMenuFriends(limit) {
|
||||
updatingMenus ++;
|
||||
$.post(
|
||||
"API/loadFriends.php",
|
||||
{
|
||||
limit: 5
|
||||
}
|
||||
).done(function(data) {
|
||||
if (data == "" || data == "[]") {
|
||||
$("#friends-menu-section").hide();
|
||||
} else {
|
||||
$("#friends-menu-section").show();
|
||||
}
|
||||
if (menuFriendsData != data) {
|
||||
menuFriendsData = data;
|
||||
if (!showFriends(data, "#menu-friends-list", 5, "profile.php", "GET", limit)) {
|
||||
$("#friends-menu-section").hide();
|
||||
}
|
||||
}
|
||||
}).fail(function() {
|
||||
$("#friends-menu-section").hide();
|
||||
}).always(function() {
|
||||
updatingMenus --;
|
||||
});
|
||||
}
|
||||
|
||||
// Get the groups and insert them in the menu.
|
||||
function loadMenuGroups() {
|
||||
updatingMenus ++;
|
||||
$.post(
|
||||
"API/loadGroups.php",
|
||||
{
|
||||
limit: 5
|
||||
}
|
||||
).done(function(data) {
|
||||
|
||||
if (data == "" || data == "[]") {
|
||||
$("#groups-menu-section").hide();
|
||||
} else {
|
||||
$("#groups-menu-section").show();
|
||||
}
|
||||
if (menuGroupsData != data) {
|
||||
menuGroupsData = data;
|
||||
if (!showGroups(data, "#menu-groups-list")) {
|
||||
$("#groups-menu-section").hide();
|
||||
}
|
||||
}
|
||||
}).fail(function() {
|
||||
$("#groups-menu-section").hide();
|
||||
}).always(function() {
|
||||
updatingMenus --;
|
||||
});
|
||||
}
|
||||
|
||||
// Get the friends requests and insert them in the notification center.
|
||||
function loadNotificationFriends() {
|
||||
updatingMenus ++;
|
||||
$.post(
|
||||
"API/loadFriendRequest.php"
|
||||
).done(function(data) {
|
||||
if (data == "" || data == "[]") {
|
||||
$("#friend-request-section").hide();
|
||||
} else {
|
||||
$("#friend-request-section").show();
|
||||
}
|
||||
if (notificationRequestsData != data) {
|
||||
notificationRequestsData = data;
|
||||
if (!showFriendsPlus(data, "#friend-requests-list", 5, "profile.php", "GET")) {
|
||||
$("#friend-request-section").hide();
|
||||
}
|
||||
}
|
||||
}).fail(function() {
|
||||
$("#friend-request-section").hide();
|
||||
}).always(function() {
|
||||
updatingMenus --;
|
||||
});
|
||||
}
|
||||
|
||||
// Get the unread messages and insert them in the notification center.
|
||||
function loadUnreadMessages() {
|
||||
updatingMenus ++;
|
||||
$.post(
|
||||
"API/loadChatNotifications.php"
|
||||
).done(function(data) {
|
||||
if (data == "" || data == "[]") {
|
||||
$("#unread-messages-section").hide();
|
||||
} else {
|
||||
$("#unread-messages-section").show();
|
||||
}
|
||||
if (notificationMessagesData != data) {
|
||||
notificationMessagesData = data;
|
||||
if (!showFriendsPlus(data, "#unread-chat-list", 5, "chat.php", "GET")) {
|
||||
$("#unread-messages-section").hide();
|
||||
}
|
||||
}
|
||||
}).fail(function() {
|
||||
$("#unread-messages-section").hide();
|
||||
}).always(function() {
|
||||
updatingMenus --;
|
||||
});
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
function showNotifications(notifications, id) {
|
||||
$("#friendrequestslist").html("");
|
||||
for (i in notifications) {
|
||||
$("#friendrequestslist").append(" \
|
||||
<li class='friend-item $extraItem'> \
|
||||
<form action='profile.php' method='get'> \
|
||||
<button type='submit' \
|
||||
name='username' \
|
||||
value='"+ notifications[i].username +"'> \
|
||||
<div class='friend'> \
|
||||
<img alt='PF' class='profile-picture' src='"+ notifications[i].profilepicture +"'/> \
|
||||
"+ notifications[i].username +" \
|
||||
</div> \
|
||||
</button> \
|
||||
</form> \
|
||||
</li> \
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
function loadNotifications() {
|
||||
$.post(
|
||||
"API/loadNotifications.php"
|
||||
).done(function(data) {
|
||||
if (data && data != "[]") {
|
||||
showNotifications(JSON.parse(data), "friendrequestslist");
|
||||
}
|
||||
});
|
||||
|
||||
setTimeout(loadNotifications, 10000);
|
||||
}
|
||||
|
||||
loadNotifications();
|
||||
|
||||
39
website/public/js/post.js
Normal file
39
website/public/js/post.js
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
function postComment(buttonValue) {
|
||||
formData = $("#newcommentform").serializeArray();
|
||||
formData.push({name: "button", value: buttonValue});
|
||||
$.post(
|
||||
"API/postComment.php",
|
||||
formData
|
||||
).done(function (response) {
|
||||
if (response == "frozen") {
|
||||
alert("Je account is bevroren, dus je kan geen comments plaatsen of \"niet slechten\". Contacteer een admin als je denkt dat dit onjuist is.");
|
||||
}
|
||||
});
|
||||
|
||||
$("#newcomment").val("");
|
||||
|
||||
//reload post
|
||||
$.get(
|
||||
"API/loadPost.php",
|
||||
$("#newcommentform").serialize()
|
||||
).done(function (data) {
|
||||
$('#modal-response').html(fancyText(data));
|
||||
});
|
||||
}
|
||||
|
||||
function deletePost(postID) {
|
||||
var formData = [{name: "postID", value: postID}];
|
||||
$.post(
|
||||
"API/deletePost.php",
|
||||
formData
|
||||
).done(function (response) {
|
||||
if (response == "frozen") {
|
||||
alert("Je account is bevroren, dus je kan geen posts verwijderen. Contacteer een admin als je denkt dat dit onjuist is.");
|
||||
}
|
||||
});
|
||||
closeModal();
|
||||
masonry(masonryMode);
|
||||
|
||||
|
||||
}
|
||||
0
website/public/js/profile.js
Normal file
0
website/public/js/profile.js
Normal file
@@ -1,8 +1,23 @@
|
||||
function checkLoggedIn() {
|
||||
if (confirm("You are already logged in!\nDo you want to logout?\nPress ok to logout.") == true) {
|
||||
if (confirm("U bent al ingelogd!\nWilt u uitloggen?\nKlik ok om uit te loggen.") == true) {
|
||||
window.location.href = "logout.php";
|
||||
} else {
|
||||
window.location.href = "profile.php";
|
||||
}
|
||||
document.getElementById("demo").innerHTML = x;
|
||||
}
|
||||
|
||||
function emailAlert(){
|
||||
alert("Bevestigingsemail is gestuurd!\n");
|
||||
}
|
||||
|
||||
function bannedAlert(){
|
||||
alert("Uw account is geband!");
|
||||
}
|
||||
|
||||
function frozenAlert(){
|
||||
alert("Uw account is bevroren!\n");
|
||||
}
|
||||
|
||||
function emailNotConfirmed(){
|
||||
alert("Uw account is nog niet bevestigd!\nEr is een nieuwe email gestuurd om uw account te bevestigen");
|
||||
}
|
||||
|
||||
41
website/public/js/search.js
Normal file
41
website/public/js/search.js
Normal file
@@ -0,0 +1,41 @@
|
||||
$(window).on('load', function () {
|
||||
pageNumber();
|
||||
});
|
||||
|
||||
function searchUsers() {
|
||||
$.post(
|
||||
"API/searchUsers.php",
|
||||
$('#search-form').serialize()
|
||||
).done(function(data) {
|
||||
if (!showFriends(data, "#search-users-list", 0, "profile.php", "GET")) {
|
||||
$("#search-users-list").text("Niemand gevonden");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function searchGroups() {
|
||||
$.post(
|
||||
"API/searchGroups.php",
|
||||
$('#search-form').serialize()
|
||||
).done(function(data) {
|
||||
if (!showGroups(data, "#search-groups-list")) {
|
||||
$("#search-groups-list").text("Geen groepen gevonden");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function pageNumber() {
|
||||
var input = input2 = $('#search-form').serialize();
|
||||
$.post(
|
||||
"API/searchPageNumber.php",
|
||||
input + "&option=user"
|
||||
).done(function (data) {
|
||||
$('#user-pageselect').html(data);
|
||||
});
|
||||
$.post(
|
||||
"API/searchPageNumber.php",
|
||||
input2 + "&option=group"
|
||||
).done(function (data) {
|
||||
$('#group-pageselect').html(data);
|
||||
});
|
||||
}
|
||||
@@ -5,45 +5,23 @@
|
||||
require_once("../queries/connect.php");
|
||||
include_once("../queries/login.php");
|
||||
include_once("../queries/checkInput.php");
|
||||
include_once("../queries/emailconfirm.php");
|
||||
include_once("../queries/requestpassword.php");
|
||||
include_once("../queries/register.php");
|
||||
require_once("../queries/Facebook/autoload.php");
|
||||
|
||||
?>
|
||||
<body>
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
// Checks if there's an user already logged in
|
||||
if(isset($_SESSION["userID"])){
|
||||
echo "<script>
|
||||
window.onload=checkLoggedIn();
|
||||
</script>";
|
||||
}
|
||||
|
||||
// Define variables and set to empty values
|
||||
$uname = $psw ="";
|
||||
$loginErr ="";
|
||||
|
||||
// Trying to login
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// Empty username or password field
|
||||
if (empty($_POST["uname"]) || empty($_POST["psw"])) {
|
||||
$loginErr = "Gebruikersnaam of wachtwoord is niet ingevuld";
|
||||
|
||||
}
|
||||
else {
|
||||
$uname = strtolower(test_input($_POST["uname"]));
|
||||
$psw = test_input($_POST["psw"]);
|
||||
$hash = getUser()["password"];
|
||||
$userid = getUser()["userID"];
|
||||
|
||||
// If there's an account, go to the profile page
|
||||
if(password_verify($psw, $hash)) {
|
||||
$_SESSION["userID"] = $userid;
|
||||
header("location: profile.php");
|
||||
|
||||
} else {
|
||||
$loginErr = "Inloggegevens zijn niet correct";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
include("../views/homeLoginRegister.php");
|
||||
|
||||
/* This view adds login view */
|
||||
include("../views/login-view.php");
|
||||
|
||||
@@ -1,15 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<?php
|
||||
include("../views/login_head.php");
|
||||
require_once("../queries/connect.php");
|
||||
include_once("../queries/login.php");
|
||||
?>
|
||||
<body>
|
||||
<?php
|
||||
session_start();
|
||||
unset($_SESSION["userID"]);
|
||||
header("Location: login.php");
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
session_start();
|
||||
session_destroy();
|
||||
header("Location: login.php");
|
||||
@@ -2,16 +2,22 @@
|
||||
<html>
|
||||
<head>
|
||||
<?php include("../views/head.php"); ?>
|
||||
<script src="/js/masonry.js"></script>
|
||||
|
||||
<script src="js/masonry.js"></script>
|
||||
<script src="js/post.js"></script>
|
||||
<style>
|
||||
@import url("styles/profile.css");
|
||||
@import url("styles/post-popup.css");
|
||||
@import url('https://fonts.googleapis.com/css?family=Anton');
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
include("../queries/user.php");
|
||||
include("../queries/friendship.php");
|
||||
include("../queries/nicetime.php");
|
||||
include_once("../queries/user.php");
|
||||
include_once("../queries/friendship.php");
|
||||
include_once("../queries/nicetime.php");
|
||||
include_once("../queries/post.php");
|
||||
include_once("../queries/calcAge.php");
|
||||
|
||||
if(empty($_GET["username"])) {
|
||||
$userID = $_SESSION["userID"];
|
||||
@@ -19,10 +25,18 @@ if(empty($_GET["username"])) {
|
||||
$userID = getUserID($_GET["username"]);
|
||||
}
|
||||
|
||||
$user = selectUser($userID);
|
||||
$user = selectUser($_SESSION["userID"], $userID);
|
||||
$profile_friends = selectAllFriends($userID);
|
||||
$profile_groups = selectAllUserGroups($userID);
|
||||
$posts = selectAllUserPosts($userID);
|
||||
|
||||
|
||||
if ($userID == $_SESSION["userID"]) {
|
||||
$friendship_status = -1;
|
||||
$masonry_mode = 1;
|
||||
} else {
|
||||
$friendship_status = $user["friend_status"];
|
||||
$masonry_mode = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* This view adds the main layout over the screen.
|
||||
@@ -36,5 +50,17 @@ include("../views/profile.php");
|
||||
/* This adds the footer. */
|
||||
include("../views/footer.php");
|
||||
?>
|
||||
|
||||
<script src="js/friendButtons.js"></script>
|
||||
<script src="js/masonry.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
userID = <?= $userID ?>;
|
||||
groupID = 0;
|
||||
placeFriendButtons();
|
||||
|
||||
masonry(<?= $masonry_mode ?>);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
116
website/public/register(stash).php
Normal file
116
website/public/register(stash).php
Normal file
@@ -0,0 +1,116 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<?php
|
||||
include("../views/login_head.php");
|
||||
require_once("../queries/connect.php");
|
||||
include_once("../queries/register.php");
|
||||
include_once("../queries/checkInput.php");
|
||||
include_once("../queries/emailconfirm.php");
|
||||
?>
|
||||
<body>
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
if(isset($_SESSION["userID"])){
|
||||
header("location: login.php");
|
||||
}
|
||||
// define variables and set to empty values
|
||||
$name = $surname = $bday = $username = $password = $confirmpassword = $location = $housenumber = $email = $confirmEmail = $captcha = $ip = "";
|
||||
$genericErr = $nameErr = $surnameErr = $bdayErr = $usernameErr = $passwordErr = $confirmpasswordErr = $locationErr = $housenumberErr = $emailErr = $confirmEmailErr = $captchaErr = "";
|
||||
$correct = true;
|
||||
$day_date = "dag";
|
||||
$month_date = "maand";
|
||||
$year_date = "jaar";
|
||||
|
||||
// Trying to register an account
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
try {
|
||||
$name = test_input(($_POST["name"]));
|
||||
checkInputChoice($name, "lettersAndSpaces");
|
||||
} catch(lettersAndSpacesException $e){
|
||||
$correct = false;
|
||||
$nameErr = $e->getMessage();
|
||||
}
|
||||
|
||||
try {
|
||||
$surname = test_input(($_POST["surname"]));
|
||||
checkInputChoice($surname, "lettersAndSpaces");
|
||||
}
|
||||
catch(lettersAndSpacesException $e){
|
||||
$correct = false;
|
||||
$surnameErr = $e->getMessage();
|
||||
}
|
||||
|
||||
try{
|
||||
$day_date = test_input(($_POST["day_date"]));
|
||||
$month_date = test_input(($_POST["month_date"]));
|
||||
$year_date = test_input(($_POST["year_date"]));
|
||||
$bday = $year_date . "-" . $month_date . "-" . $day_date;
|
||||
checkInputChoice($bday, "bday");
|
||||
} catch(bdayException $e){
|
||||
$correct = false;
|
||||
$bdayErr = $e->getMessage();
|
||||
}
|
||||
|
||||
try{
|
||||
$username = str_replace(' ', '', test_input(($_POST["username"])));
|
||||
checkInputChoice($username, "username");
|
||||
} catch(usernameException $e){
|
||||
$correct = false;
|
||||
$usernameErr = $e->getMessage();
|
||||
}
|
||||
|
||||
try{
|
||||
$password = str_replace(' ', '', test_input(($_POST["password"])));
|
||||
checkInputChoice($password, "longerEight");
|
||||
matchPassword();
|
||||
} catch(passwordException $e){
|
||||
$correct = false;
|
||||
$passwordErr = $e->getMessage();
|
||||
} catch(confirmPasswordException $e){
|
||||
$correct = false;
|
||||
$confirmPasswordErr = $e->getMessage();
|
||||
}
|
||||
|
||||
try{
|
||||
$location = test_input(($_POST["location"]));
|
||||
checkInputChoice($location, "lettersAndSpaces");
|
||||
} catch(lettersAndSpacesException $e){
|
||||
$correct = false;
|
||||
$locationErr = $e->getMessage();
|
||||
}
|
||||
|
||||
try{
|
||||
$email = test_input(($_POST["email"]));
|
||||
checkInputChoice($email, "email");
|
||||
$confirmEmail = test_input(($_POST["confirmEmail"]));
|
||||
matchEmail();
|
||||
} catch(emailException $e){
|
||||
$correct = false;
|
||||
$emailErr = $e->getMessage();
|
||||
} catch(confirmEmailException $e){
|
||||
$correct = false;
|
||||
$confirmEmailErr = $e->getMessage();
|
||||
}
|
||||
|
||||
try{
|
||||
$captcha = $_POST['g-recaptcha-response'];
|
||||
checkCaptcha($captcha);
|
||||
} catch(captchaException $e){
|
||||
$correct = false;
|
||||
$captchaErr = $e->getMessage();
|
||||
}
|
||||
|
||||
try {
|
||||
getIp();
|
||||
registerCheck($correct);
|
||||
sendConfirmEmailUsername($username);
|
||||
} catch(registerException $e){
|
||||
$genericErr = $e->getMessage();
|
||||
}
|
||||
}
|
||||
/* This view adds register view */
|
||||
include("../views/register-view.php");
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,45 +1,91 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<?php
|
||||
include("../views/login_head.php");
|
||||
require_once("../queries/connect.php");
|
||||
include_once("../queries/register.php");
|
||||
include_once("../queries/checkInput.php");
|
||||
?>
|
||||
<body>
|
||||
<?php
|
||||
session_start();
|
||||
if(isset($_SESSION["userID"])){
|
||||
header("location: profile.php");
|
||||
|
||||
try {
|
||||
$name = test_input(($_POST["name"]));
|
||||
checkInputChoice($name, "lettersAndSpaces");
|
||||
} catch(lettersAndSpacesException $e){
|
||||
$correct = false;
|
||||
$nameErr = $e->getMessage();
|
||||
}
|
||||
// define variables and set to empty values
|
||||
$name = $surname = $bday = $username = $password = $confirmpassword = $location = $housenumber = $email = "";
|
||||
$genericErr = $nameErr = $surnameErr = $bdayErr = $usernameErr = $passwordErr = $confirmpasswordErr = $locationErr = $housenumberErr = $emailErr = "";
|
||||
$correct = true;
|
||||
|
||||
// Trying to register an account
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
checkInputChoice("name", "lettersAndSpace");
|
||||
checkInputChoice("surname", "lettersAndSpace");
|
||||
try {
|
||||
$surname = test_input(($_POST["surname"]));
|
||||
checkInputChoice($surname, "lettersAndSpaces");
|
||||
}
|
||||
catch(lettersAndSpacesException $e){
|
||||
$correct = false;
|
||||
$surnameErr = $e->getMessage();
|
||||
}
|
||||
|
||||
if (empty($_POST["bday"])) {
|
||||
$bdayErr = "Geboortedatum is verplicht!";
|
||||
$correct = false;
|
||||
try{
|
||||
$day_date = test_input(($_POST["day_date"]));
|
||||
$month_date = test_input(($_POST["month_date"]));
|
||||
$year_date = test_input(($_POST["year_date"]));
|
||||
$bday = $year_date . "-" . $month_date . "-" . $day_date;
|
||||
checkInputChoice($bday, "bday");
|
||||
} catch(bdayException $e){
|
||||
$correct = false;
|
||||
$bdayErr = $e->getMessage();
|
||||
}
|
||||
|
||||
} else {
|
||||
$bday = test_input($_POST["bday"]);
|
||||
}
|
||||
try{
|
||||
$username = str_replace(' ', '', test_input(($_POST["username"])));
|
||||
checkInputChoice($username, "username");
|
||||
} catch(usernameException $e){
|
||||
$correct = false;
|
||||
$usernameErr = $e->getMessage();
|
||||
}
|
||||
|
||||
checkInputChoice("username", "username");
|
||||
checkInputChoice("password", "longerEight");
|
||||
checkInputChoice("confirmpassword", "");
|
||||
try{
|
||||
$password = str_replace(' ', '', test_input(($_POST["password"])));
|
||||
checkInputChoice($password, "longerEight");
|
||||
matchPassword();
|
||||
checkInputChoice("location", "lettersAndSpace");
|
||||
checkInputChoice("email", "email");
|
||||
registerCheck();
|
||||
} catch(passwordException $e){
|
||||
$correct = false;
|
||||
$passwordErr = $e->getMessage();
|
||||
} catch(confirmPasswordException $e){
|
||||
$correct = false;
|
||||
$confirmPasswordErr = $e->getMessage();
|
||||
}
|
||||
|
||||
try{
|
||||
$location = test_input(($_POST["location"]));
|
||||
checkInputChoice($location, "");
|
||||
} catch(lettersAndSpacesException $e){
|
||||
$correct = false;
|
||||
$locationErr = $e->getMessage();
|
||||
}
|
||||
|
||||
try{
|
||||
$email = test_input(($_POST["email"]));
|
||||
checkInputChoice($email, "email");
|
||||
$confirmEmail = test_input(($_POST["confirmEmail"]));
|
||||
matchEmail();
|
||||
} catch(emailException $e){
|
||||
$correct = false;
|
||||
$emailErr = $e->getMessage();
|
||||
} catch(confirmEmailException $e){
|
||||
$correct = false;
|
||||
$confirmEmailErr = $e->getMessage();
|
||||
}
|
||||
|
||||
try{
|
||||
$captcha = $_POST['g-recaptcha-response'];
|
||||
checkCaptcha($captcha);
|
||||
} catch(captchaException $e){
|
||||
$correct = false;
|
||||
$captchaErr = $e->getMessage();
|
||||
}
|
||||
|
||||
try {
|
||||
getIp();
|
||||
registerCheck($correct);
|
||||
sendConfirmEmail(getUserID()["userID"]);
|
||||
} catch(registerException $e){
|
||||
echo "<script>
|
||||
window.onload = function() {
|
||||
$('#registerModal').show();
|
||||
}
|
||||
</script>";
|
||||
$genericErr = $e->getMessage();
|
||||
}
|
||||
/* This view adds register view */
|
||||
include("../views/register-view.php");
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
57
website/public/resetpassword.php
Normal file
57
website/public/resetpassword.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
include_once("../queries/connect.php");
|
||||
include_once("../views/messagepage.php");
|
||||
include_once("../views/resetpassword.php");
|
||||
if ($_SERVER["REQUEST_METHOD"] == "GET") {
|
||||
if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) {
|
||||
if (verifyLink($_GET["u"], $_GET["h"])) {
|
||||
messagePage(passwordResetFields());
|
||||
} else {
|
||||
messagePage("Wachtwoorden komen niet overeen.");
|
||||
}
|
||||
} else {
|
||||
messagePage("Ongeldige links");
|
||||
}
|
||||
} elseif ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
if (verifyLink($_POST["u"], $_POST["h"])) {
|
||||
if ($_POST["password"] == $_POST["password-confirm"]) {
|
||||
changePassword();
|
||||
messagePage("Wachtwoord gewijzigd");
|
||||
} else {
|
||||
messagePage("Ongeldige link");
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
messagePage("Ongeldige link");
|
||||
|
||||
}
|
||||
|
||||
function changePassword() {
|
||||
$stmt = prepareQuery("
|
||||
UPDATE
|
||||
`user`
|
||||
SET
|
||||
`password` = :password
|
||||
WHERE
|
||||
`userID` = :userID
|
||||
");
|
||||
$stmt->bindValue(":password", password_hash($_POST["password"], PASSWORD_DEFAULT));
|
||||
$stmt->bindParam(":userID", $_POST["u"]);
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
function verifyLink(int $userID, string $hash) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
`password`
|
||||
FROM
|
||||
`user`
|
||||
WHERE
|
||||
`userID` = :userID
|
||||
");
|
||||
$stmt->bindParam(":userID", $userID);
|
||||
$stmt->execute();
|
||||
$password = $stmt->fetch()["password"];
|
||||
return password_verify($password, $hash);
|
||||
}
|
||||
@@ -9,6 +9,8 @@
|
||||
<style>
|
||||
@import url("styles/search.css");
|
||||
</style>
|
||||
|
||||
<script src="js/search.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<?php
|
||||
include("../views/head.php");
|
||||
include_once("../views/head.php");
|
||||
include_once("../queries/connect.php");
|
||||
include_once("../queries/settings.php");
|
||||
?>
|
||||
@@ -12,27 +12,31 @@
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
|
||||
include("../views/main.php");
|
||||
$notImplemented = new settingsMessage("angry", "Deze functie werkt nog niet :(");
|
||||
|
||||
$alertClass;
|
||||
$alertMessage;
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
switch ($_POST["form"]) {
|
||||
case "profile":
|
||||
$result = updateSettings();
|
||||
break;
|
||||
case "password":
|
||||
$result = changePassword();
|
||||
break;
|
||||
case "email":
|
||||
$result = changeEmail();
|
||||
break;
|
||||
case "picture":
|
||||
updateProfilePicture();
|
||||
$result = new settingsMessage("happy", "Deze melding doet nog niks nuttigs.");
|
||||
break;
|
||||
try {
|
||||
switch ($_POST["form"]) {
|
||||
case "profile":
|
||||
updateSettings();
|
||||
break;
|
||||
case "password":
|
||||
changePassword();
|
||||
break;
|
||||
case "email":
|
||||
changeEmail();
|
||||
break;
|
||||
case "picture":
|
||||
updateAvatar();
|
||||
break;
|
||||
|
||||
}
|
||||
} catch (AlertMessage $w) {
|
||||
$alertClass = $w->getClass();
|
||||
$alertMessage = $w->getMessage();
|
||||
}
|
||||
}
|
||||
include("../views/main.php");
|
||||
|
||||
include("../views/settings-view.php");
|
||||
|
||||
|
||||
3
website/public/styles/adminbutton.css
Normal file
3
website/public/styles/adminbutton.css
Normal file
@@ -0,0 +1,3 @@
|
||||
#quick-links i {
|
||||
font-size: 32px;
|
||||
}
|
||||
@@ -1,78 +1,39 @@
|
||||
.admin-panel {
|
||||
margin: auto;
|
||||
min-width: 800px;
|
||||
}
|
||||
|
||||
.admin-title {
|
||||
margin: 10px;
|
||||
padding-bottom: 5px;
|
||||
border-bottom: 4px solid #FBC02D;
|
||||
}
|
||||
|
||||
.admin-panel input[type="radio"], input[type="checkbox"] {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.admin-batchactions, .admin-groupbatchactions {
|
||||
display: inline-block;
|
||||
padding: 8px;
|
||||
vertical-align: top;
|
||||
border-radius: 10px;
|
||||
border: 4px solid #FBC02D;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
|
||||
vertical-align: middle;
|
||||
height: 28px;
|
||||
margin: 2px;
|
||||
}
|
||||
|
||||
.admin-searchform {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.admin-searchbar {
|
||||
display: inline-block;
|
||||
margin: 10px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.admin-searchinput {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.admin-filter, .admin-filtertype, .admin-groupfilter {
|
||||
display: inline-block;
|
||||
margin: 10px;
|
||||
vertical-align: top;
|
||||
margin-right: 50px;
|
||||
margin-left: 50px;
|
||||
}
|
||||
|
||||
.admin-filter, .admin-groupfilter {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.admin-users {
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.admin-userheading {
|
||||
width: auto;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.admin-pageui {
|
||||
text-align: right;
|
||||
float: right;
|
||||
width: auto;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.usertitle {
|
||||
width: 150px;
|
||||
.admin-pageui {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.admin-pageselector {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.admin-users {
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
.usertable {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.usertable .table-checkbox {width: 20px}
|
||||
.usertable .table-username {width: 150px}
|
||||
.usertable .table-status {width: 100px}
|
||||
.usertable .table-action {width: 200px}
|
||||
@@ -82,10 +43,18 @@
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
.usertable tr {
|
||||
.usertable th, tr {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.usertable tr:hover {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.bancommentedit {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.bancommentform input[type="text"] {
|
||||
width: 80%;
|
||||
}
|
||||
@@ -1,39 +1,76 @@
|
||||
|
||||
body {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Overall chat-screen */
|
||||
.chat {
|
||||
position: fixed;
|
||||
|
||||
top: 80px;
|
||||
left: 256px;
|
||||
padding: 15px 0;
|
||||
width: calc(100% - 256px);
|
||||
height: calc(100% - 120px);
|
||||
display: inline-flex;
|
||||
|
||||
padding: 20px 0;
|
||||
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.chat-left {
|
||||
#chat-recent-panel {
|
||||
width: 256px;
|
||||
height: calc(100% - 100px);
|
||||
margin: 0 10px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.chat-right {
|
||||
width: calc(100% - 256px - 40px);
|
||||
height: calc(100% - 80px);
|
||||
margin-right: 10px;
|
||||
display: inline-block;
|
||||
float: left;
|
||||
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
/* Chat history. */
|
||||
.chat-history {
|
||||
#chat-history {
|
||||
overflow-y: auto;
|
||||
height: 100%;
|
||||
overflow-x: hidden;
|
||||
|
||||
width: calc(100% - 256px - 85px);
|
||||
height: calc(100% - 80px);
|
||||
margin-right: 10px;
|
||||
|
||||
padding: 10px;
|
||||
|
||||
display: inline-block;
|
||||
float: right;
|
||||
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
/* Chat-message takes the whole width of the chat area */
|
||||
.day-message {
|
||||
width: 100%;
|
||||
min-height: 40px;
|
||||
padding: 10px 0;
|
||||
clear: both;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.day-message-content {
|
||||
width: auto;
|
||||
padding: 10px;
|
||||
|
||||
background-color: #F8F8F8;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.chat-message {
|
||||
width: 100%;
|
||||
min-height: 40px;
|
||||
padding-top: 10px;
|
||||
padding: 10px 0;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.chat-message::after {
|
||||
content: '';
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
@@ -46,20 +83,21 @@
|
||||
.chat-message-self {
|
||||
float: right;
|
||||
margin-right: 10px;
|
||||
background-color: darkgreen;
|
||||
color: white;
|
||||
background-color: #FBC02D;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.chat-message-other {
|
||||
float: left;
|
||||
margin-left: 10px;
|
||||
background-color: aquamarine;
|
||||
background-color: #4CAF50;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Chat reply field */
|
||||
|
||||
.chat-field {
|
||||
width: 100%;
|
||||
width: calc(100% - 10px);
|
||||
display: table;
|
||||
}
|
||||
|
||||
@@ -77,7 +115,6 @@
|
||||
width: 100%;
|
||||
border: none;
|
||||
border-radius: 10px 0 0 10px;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
|
||||
}
|
||||
|
||||
.chat-field input[type="submit"] {
|
||||
@@ -87,10 +124,45 @@
|
||||
color: white;
|
||||
padding: 5px 10px;
|
||||
border-radius: 0 10px 10px 0;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
|
||||
}
|
||||
|
||||
.active-friend-chat {
|
||||
background: aquamarine;
|
||||
color: #333;
|
||||
background: #4CAF50;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.chat-message img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.chat-message a {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.chat-time {
|
||||
color: #666666;
|
||||
font-size: 12px;
|
||||
margin-bottom: -3px;
|
||||
}
|
||||
|
||||
.chat-message-other .chat-time {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1080px) {
|
||||
.chat-message-self, .chat-message-other {
|
||||
max-width: 75%;
|
||||
}
|
||||
.chat {
|
||||
left: 0;
|
||||
width: 100%;
|
||||
}
|
||||
#chat-recent-panel {
|
||||
left: 0;
|
||||
width: 320px;
|
||||
}
|
||||
#chat-history {
|
||||
left: 50%;
|
||||
width: calc(100% - 390px);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
footer {
|
||||
width: calc(100% - 256px);
|
||||
margin-left: 256px;
|
||||
width: 100%;
|
||||
|
||||
background-color: rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ header {
|
||||
height: 80px;
|
||||
width: 100%;
|
||||
|
||||
color: white;
|
||||
color: #FFF;
|
||||
font-weight: bold;
|
||||
letter-spacing: 1px;
|
||||
background-color: #FBC02D;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
|
||||
}
|
||||
@@ -24,7 +26,8 @@ header {
|
||||
}
|
||||
|
||||
#header-search {
|
||||
padding-left: 42px;
|
||||
margin: 24px 0 24px 32px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +44,16 @@ header div {
|
||||
width: 64px;
|
||||
}
|
||||
|
||||
#own-profile-picture {
|
||||
#own-profile-picture, #open-notifications {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#open-notifications {
|
||||
padding: 20px 20px 20px 0px;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1080px) {
|
||||
#header-logo {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,32 @@
|
||||
a.button {
|
||||
background-color: #C8CABD;
|
||||
border-radius: 10px;
|
||||
border-radius: 5px;
|
||||
color: black;
|
||||
cursor: pointer;
|
||||
height: 50%;
|
||||
margin: 8px 0;
|
||||
padding: 14px 20px;
|
||||
width: 25%;
|
||||
padding: 8px 20px;
|
||||
font-family: Arial;
|
||||
font-size: 16px;
|
||||
font-size: 22px;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
|
||||
|
||||
}
|
||||
|
||||
a.fbButton {
|
||||
background-color: #3B5998;
|
||||
border-radius: 5px;
|
||||
color: black;
|
||||
cursor: pointer;
|
||||
padding: 8px 20px;
|
||||
font-family: Arial;
|
||||
font-size: 22px;
|
||||
color: white;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
|
||||
|
||||
}
|
||||
|
||||
/* Body */
|
||||
body {
|
||||
height: 900px;
|
||||
background-color: #C8CABD;
|
||||
height: 100%;
|
||||
background-color: #FBC02D;
|
||||
/*background-image: url(http://play.pokemonshowdown.com/fx/client-bg-shaymin.jpg);
|
||||
background-size: cover;
|
||||
background-attachment: fixed;*/
|
||||
@@ -24,23 +36,6 @@ body {
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
|
||||
/* The Close Button */
|
||||
.close {
|
||||
/* Position it in the top right corner outside of the modal */
|
||||
color: white;
|
||||
font-size: 100px;
|
||||
font-weight: bold;
|
||||
position: absolute;
|
||||
right: 25px;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
/* Close button on hover */
|
||||
.close:hover,
|
||||
.close:focus {
|
||||
color: red;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* inlogform */
|
||||
form {
|
||||
@@ -48,10 +43,13 @@ form {
|
||||
border-radius: 12px;
|
||||
height: 80%;
|
||||
margin: auto;
|
||||
width: 70%;
|
||||
overflow-y:auto;
|
||||
width: 600px;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* inlog titel */
|
||||
h1 {
|
||||
padding: 8px;
|
||||
@@ -61,87 +59,76 @@ h1 {
|
||||
|
||||
/* registreer titel*/
|
||||
h2 {
|
||||
padding: 16px;
|
||||
padding: 8px;
|
||||
text-align: left;
|
||||
font-size: 2.0em;
|
||||
}
|
||||
|
||||
h3 {
|
||||
padding: 8px;
|
||||
text-align: center;
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
input[type=text], input[type=password], input[type=email], input[type="date"] {
|
||||
box-sizing: border-box;
|
||||
border-color: #C8CABD;
|
||||
display: inline-block;
|
||||
height: 60%;
|
||||
padding: 8px 20px;
|
||||
margin: 4px 0;
|
||||
width: 70%;
|
||||
}
|
||||
/*
|
||||
input[type=text], input[type=password], input[type=email], input[type="date"] {
|
||||
border: 0px;
|
||||
border-bottom: 4px solid lightgray;
|
||||
border-radius: 0px;
|
||||
}*/
|
||||
|
||||
button[type=submit] {
|
||||
background-color: #C8CABD;
|
||||
color: black ;
|
||||
cursor: pointer;
|
||||
font-family: Arial;
|
||||
font-size: 16px;
|
||||
width: 50%;
|
||||
padding: 8px 10px;
|
||||
margin: 4px 0;
|
||||
width: 55%;
|
||||
}
|
||||
|
||||
.middle{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.center{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: #C8CABD;
|
||||
border-radius: 5px;
|
||||
color: black;
|
||||
cursor: pointer;
|
||||
height: 50%;
|
||||
padding: 8px 20px;
|
||||
margin: 5px;
|
||||
font-family: Arial;
|
||||
font-size: 22px;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
|
||||
|
||||
}
|
||||
|
||||
.error {
|
||||
font-family: Arial;
|
||||
font-size: 15px;
|
||||
color: red;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.left-arrow {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
background-color: #C8CABD;
|
||||
height: 30px;
|
||||
width: 90px;
|
||||
padding: 3px 3px 3px 0px;
|
||||
text-align: center;
|
||||
border-radius: 0px 10px 10px 0px;
|
||||
font-size: 24px;
|
||||
|
||||
}
|
||||
.left-arrow:after {
|
||||
content: '';
|
||||
display: block;
|
||||
position: absolute;
|
||||
right: 100%;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
border-top: 15px solid transparent;
|
||||
border-right: 20px solid #C8CABD;
|
||||
border-bottom: 15px solid transparent;
|
||||
border-left: 0px solid transparent;
|
||||
}
|
||||
|
||||
/* padding voor registreer container */
|
||||
.login_containerregister {
|
||||
padding: 16px;
|
||||
padding: 8px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* padding voor login_containers */
|
||||
.login_containerlogin {
|
||||
padding:25px;
|
||||
padding:8px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* padding voor foutmelding login */
|
||||
.login_containerfault {
|
||||
padding: 16px;
|
||||
padding: 4px;
|
||||
text-align: center;
|
||||
color: red;
|
||||
}
|
||||
@@ -159,24 +146,90 @@ label {
|
||||
background-repeat: repeat-x;
|
||||
background-attachment: fixed;*/
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
|
||||
height: 550px;
|
||||
margin: 34px auto;
|
||||
height: 400px;
|
||||
margin: 16px auto;
|
||||
overflow-y: auto;
|
||||
padding: 20px;
|
||||
width: 50%;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
/*.platform {
|
||||
width: 40%;
|
||||
margin: 34px auto;
|
||||
}*/
|
||||
|
||||
@-webkit-keyframes animatezoom {
|
||||
from {-webkit-transform: scale(0)}
|
||||
to {-webkit-transform: scale(1)}
|
||||
select{
|
||||
width: 18%;
|
||||
}
|
||||
|
||||
ul {
|
||||
font-family: Arial;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
/* The Modal (background) */
|
||||
.modal {
|
||||
display: none; /* Hidden by default */
|
||||
position: fixed; /* Stay in place */
|
||||
z-index: 1; /* Sit on top */
|
||||
padding-top: 75px; /* Location of the box */
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%; /* Full width */
|
||||
height: 100%; /* Full height */
|
||||
overflow: hidden; /* Enable scroll if needed */
|
||||
background-color: rgb(0,0,0); /* Fallback color */
|
||||
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
|
||||
}
|
||||
|
||||
/* Modal Content */
|
||||
.modal-content {
|
||||
position: relative;
|
||||
background-color: #FFFFFF;
|
||||
margin: auto;
|
||||
padding: 0;
|
||||
border: 1px solid #888;
|
||||
width: 600px;
|
||||
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
|
||||
-webkit-animation-name: animatetop;
|
||||
-webkit-animation-duration: 0.4s;
|
||||
animation-name: animatetop;
|
||||
animation-duration: 0.4s
|
||||
}
|
||||
|
||||
/* Add Animation */
|
||||
@-webkit-keyframes animatetop {
|
||||
from {top:-300px; opacity:0}
|
||||
to {top:0; opacity:1}
|
||||
}
|
||||
|
||||
@keyframes animatetop {
|
||||
from {top:-300px; opacity:0}
|
||||
to {top:0; opacity:1}
|
||||
}
|
||||
|
||||
/* The Close Button */
|
||||
.close {
|
||||
color: white;
|
||||
float: right;
|
||||
font-size: 36px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.close:hover,
|
||||
.close:focus {
|
||||
color: #000;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
padding: 4px 16px;
|
||||
background-color: #FBC02D;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
padding: 2px 16px;
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
padding: 2px 8px;
|
||||
background-color: #FBC02D;
|
||||
color: black;
|
||||
}
|
||||
|
||||
@@ -92,21 +92,30 @@ p {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.online {
|
||||
border: #4CAF50 solid 3px;
|
||||
}
|
||||
|
||||
.offline {
|
||||
border: #666666 solid 3px;
|
||||
}
|
||||
|
||||
.group-picture {
|
||||
border-radius: 5px;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.item-box, .item-box-full-width {
|
||||
margin: 20px 0 0 0;
|
||||
padding: 25px;
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
|
||||
.item-box {
|
||||
width: calc(50% - 60px);
|
||||
width: calc(33% - 50px);
|
||||
display: inline-table;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 900px) {
|
||||
@media only screen and (max-width: 1400px) {
|
||||
.item-box {
|
||||
width: calc(100% - 50px);
|
||||
}
|
||||
@@ -166,6 +175,7 @@ textarea {
|
||||
|
||||
textarea:hover, input:hover, select:hover {
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 1px 1px rgba(0,0,0,0.12);
|
||||
}
|
||||
|
||||
textarea:focus, input:focus, select:focus {
|
||||
@@ -174,6 +184,19 @@ textarea:focus, input:focus, select:focus {
|
||||
}
|
||||
|
||||
/* All buttons */
|
||||
button.red {
|
||||
background-color: firebrick;
|
||||
}
|
||||
|
||||
button.green {
|
||||
background-color: forestgreen;
|
||||
}
|
||||
|
||||
button.gray{
|
||||
background-color: #FFF;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
button,
|
||||
input[type="submit"],
|
||||
input[type="reset"] {
|
||||
@@ -214,6 +237,7 @@ td {
|
||||
|
||||
/* Custom title box, appears instantaneously */
|
||||
a[data-title]:hover,
|
||||
i[data-title]:hover,
|
||||
img[data-title]:hover,
|
||||
span[data-title]:hover,
|
||||
div[data-title]:hover {
|
||||
@@ -221,6 +245,7 @@ div[data-title]:hover {
|
||||
}
|
||||
|
||||
a[data-title]:hover:after,
|
||||
i[data-title]:hover:after,
|
||||
img[data-title]:hover:after,
|
||||
span[data-title]:hover:after,
|
||||
div[data-title]:hover:after {
|
||||
@@ -241,3 +266,58 @@ div[data-title]:hover:after {
|
||||
line-height: normal;
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
|
||||
.friend-item, .group-item {
|
||||
cursor: pointer;
|
||||
transition-duration: 250ms;
|
||||
}
|
||||
|
||||
.friend-item button, .group-item button {
|
||||
background: none;
|
||||
color: inherit;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.friend-item:hover, .group-item:hover {
|
||||
background: #FBC02D;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
|
||||
}
|
||||
|
||||
.friend-name {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
}
|
||||
::-webkit-scrollbar-track {
|
||||
background: none;
|
||||
}
|
||||
::-webkit-scrollbar-thumb {
|
||||
-webkit-border-radius: 20px;
|
||||
border-radius: 20px;
|
||||
background: #4CAF50;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1080px) {
|
||||
body {
|
||||
font-size: 28px!important;
|
||||
}
|
||||
button, input, select {
|
||||
font-size: 28px;
|
||||
height: 42px;
|
||||
}
|
||||
textarea {
|
||||
font-size: 28px;
|
||||
}
|
||||
input[type="checkbox"], input[type="radio"] {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,16 +5,16 @@
|
||||
|
||||
left: 0;
|
||||
top: 80px;
|
||||
height: calc(100% - 80px);
|
||||
width: 256px;
|
||||
height: calc(100% - 120px);
|
||||
width: 236px;
|
||||
|
||||
background-color: #EEE;
|
||||
/*box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);*/
|
||||
padding: 20px 10px;
|
||||
}
|
||||
|
||||
.menu section {
|
||||
margin: 0 5px 10px 5px;
|
||||
background-color: white;
|
||||
margin-bottom: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #FFFFFF;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
.nav-list li {
|
||||
padding: 5px 20px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.more-item {
|
||||
@@ -33,28 +34,9 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.friend-item, .group-item {
|
||||
cursor: pointer;
|
||||
transition-duration: 250ms;
|
||||
}
|
||||
|
||||
.friend-item:hover, .group-item:hover {
|
||||
background: #FBC02D;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.menu button {
|
||||
background: none;
|
||||
color: inherit;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#notification-center {
|
||||
left: auto;
|
||||
width: 256px;
|
||||
width: 236px;
|
||||
right: -256px;
|
||||
}
|
||||
|
||||
@@ -67,4 +49,55 @@
|
||||
color: #4CAF50;
|
||||
font-size: 42px;
|
||||
padding: 7px;
|
||||
transition-duration: 250ms;
|
||||
}
|
||||
|
||||
#quick-links i:hover {
|
||||
color: #FBC02D;
|
||||
}
|
||||
|
||||
.notification-options {
|
||||
width: 100%;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.notification-options button {
|
||||
display: inline-block;
|
||||
padding: 5px 20px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.accept-notification:hover {
|
||||
color: #4CAF50;
|
||||
}
|
||||
|
||||
.deny-notification:hover {
|
||||
color: firebrick;
|
||||
}
|
||||
|
||||
.friend-item:hover .notification-options {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.menu button {
|
||||
background: none;
|
||||
color: inherit;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1080px) {
|
||||
#contact-menu, #notification-center {
|
||||
display: none;
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
width: calc(50% - 20px);
|
||||
}
|
||||
.content {
|
||||
margin-left: 0;
|
||||
}
|
||||
#quick-links i {
|
||||
font-size: 48px!important;
|
||||
}
|
||||
}
|
||||
28
website/public/styles/message-page.css
Normal file
28
website/public/styles/message-page.css
Normal file
@@ -0,0 +1,28 @@
|
||||
body {
|
||||
background-color: #FBC02D;
|
||||
}
|
||||
|
||||
.password-change {
|
||||
height: 100%;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.top-logo {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.item-box {
|
||||
margin: 30px auto auto;
|
||||
display: block;
|
||||
}
|
||||
.top-logo img {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.error-page {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.error-page img {
|
||||
vertical-align: middle;
|
||||
}
|
||||
47
website/public/styles/mobilefriendly.css
Normal file
47
website/public/styles/mobilefriendly.css
Normal file
@@ -0,0 +1,47 @@
|
||||
/* MAIN */
|
||||
body {
|
||||
font-size: 28px!important;
|
||||
}
|
||||
button {
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
/* HEADER */
|
||||
#header-logo {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* PROFILE */
|
||||
.post-box {
|
||||
width: calc(100% - 65px);
|
||||
}
|
||||
|
||||
/* MENU */
|
||||
#contact-menu, #notification-center {
|
||||
display: none;
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
width: calc(50% - 20px);
|
||||
}
|
||||
.content {
|
||||
margin-left: 0;
|
||||
}
|
||||
#quick-links i {
|
||||
font-size: 48px!important;
|
||||
}
|
||||
|
||||
/* CHAT */
|
||||
.chat-message-self, .chat-message-other {
|
||||
max-width: 75%;
|
||||
}
|
||||
.chat {
|
||||
left: 0;
|
||||
width: 100%;
|
||||
}
|
||||
#chat-recent-panel {
|
||||
left: 0;
|
||||
width: 320px;
|
||||
}
|
||||
#chat-history {
|
||||
left: 50%;
|
||||
width: calc(100% - 390px);
|
||||
}
|
||||
103
website/public/styles/post-popup.css
Normal file
103
website/public/styles/post-popup.css
Normal file
@@ -0,0 +1,103 @@
|
||||
/* modal based on: http://www.w3schools.com/howto/howto_css_modals.asp */
|
||||
|
||||
.modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 80px;
|
||||
left: 256px;
|
||||
width: calc(100% - 256px); /* Full width */
|
||||
height: calc(100% - 80px); /* Full height */
|
||||
background-color: rgb(0,0,0); /* Fallback color */
|
||||
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
/* Modal Content/Box */
|
||||
.modal-content {
|
||||
margin: 50px auto;
|
||||
width: 70%; /* Could be more or less, depending on screen size */
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
color: #aaa;
|
||||
float: right;
|
||||
font-size: 28px;
|
||||
font-weight: bold;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.modal-close:hover,
|
||||
.modal-close:focus {
|
||||
color: black;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.modal-content img {
|
||||
max-height: 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.post-header h4 {
|
||||
font-size: 20pt;
|
||||
}
|
||||
|
||||
.post-content {
|
||||
margin: 30px auto;
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
.commentfield {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.commentfield textarea {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.comment {
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
border-top: 1px solid #4CAF50;
|
||||
}
|
||||
|
||||
.commentinfo {
|
||||
font-size: 10pt;
|
||||
}
|
||||
|
||||
.commentcontent {
|
||||
margin: 5px auto;
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
.nietslecht-text {
|
||||
font-family: Impact, Anton, sans-serif;
|
||||
text-shadow: -1px 0 1px black, 0 1px 1px black, 1px 0 1px black, 0 -1px 1px black;
|
||||
}
|
||||
|
||||
.nietslecht {
|
||||
}
|
||||
|
||||
.nietslecht img {
|
||||
vertical-align: middle;
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
}
|
||||
|
||||
.deleteButton {
|
||||
background-color: firebrick;
|
||||
|
||||
}
|
||||
|
||||
.deleteButton i {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.deleteButton:hover span {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.deleteButton span {
|
||||
display: none;
|
||||
}
|
||||
@@ -1,15 +1,74 @@
|
||||
.profile-box {
|
||||
min-height: 150px;
|
||||
padding: 25px;
|
||||
background-color: #FFFFFF;
|
||||
/* New */
|
||||
|
||||
.user-box {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.profile-box .profile-picture, .profile-box .group-picture {
|
||||
.status-buttons-container {
|
||||
position: relative;
|
||||
float: left;
|
||||
width: 200px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.friend-button-container {
|
||||
position: relative;
|
||||
float: right;
|
||||
width: 200px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.friend-button-container button, .status-buttons-container button, .group-button-container button {
|
||||
display: block;
|
||||
|
||||
margin: 7px 0;
|
||||
width: 200px;
|
||||
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.group-button-container button {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.empty-button {
|
||||
background: none;
|
||||
cursor: auto;
|
||||
}
|
||||
.empty-button:active {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.profile-info {
|
||||
display: inline-block;
|
||||
|
||||
min-width: 250px;
|
||||
width: auto;
|
||||
padding-top: 30px;
|
||||
}
|
||||
|
||||
.main-picture {
|
||||
position: relative;
|
||||
border-width: 5px;
|
||||
|
||||
display: inline-block;
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
margin: 0 20px 20px 0;
|
||||
margin-bottom: -45px;
|
||||
|
||||
object-fit: cover;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.group-picture {
|
||||
border: none;
|
||||
margin-bottom: 0;
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
|
||||
/* Old */
|
||||
|
||||
.profile-box h1.profile-username {
|
||||
padding-top: 50px;
|
||||
}
|
||||
@@ -18,24 +77,20 @@
|
||||
}
|
||||
|
||||
div.posts {
|
||||
padding-top: 20px;
|
||||
width: calc(100% + 20px);
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
div.posts div.post {
|
||||
display: block;
|
||||
margin: 20px 0 0 0;
|
||||
padding: 10px;
|
||||
width: calc(100% - 40px);
|
||||
cursor: pointer;
|
||||
transition-duration: 250ms;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
div.posts div.post:hover {
|
||||
/*margin: 15px 0 0 -5px;*/
|
||||
/*padding: 15px;*/
|
||||
/*z-index: 20;*/
|
||||
box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
|
||||
}
|
||||
|
||||
@@ -62,6 +117,17 @@ div.posts .post form textarea.newpost {
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.post .post-date {
|
||||
float: right;
|
||||
color: #aaaaaa;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.noposts {
|
||||
display: none;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1500px) {
|
||||
.post-box {
|
||||
width: calc(50% - 68px);
|
||||
@@ -69,28 +135,12 @@ div.posts .post form textarea.newpost {
|
||||
}
|
||||
|
||||
/* mobile */
|
||||
@media only screen and (max-width: 1000px) {
|
||||
@media only screen and (max-width: 1080px) {
|
||||
.post-box {
|
||||
width: calc(100% - 65px);
|
||||
}
|
||||
}
|
||||
|
||||
.post .post-date {
|
||||
float: right;
|
||||
color: #aaaaaa;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.profile-button {
|
||||
float: right;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #4CAF50;
|
||||
color: #FFFFFF;
|
||||
transition-duration: 250ms;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.profile-button:hover {
|
||||
box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
|
||||
.modal {
|
||||
left: 0!important;
|
||||
width: 100%!important;
|
||||
}
|
||||
}
|
||||
@@ -15,3 +15,15 @@
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.user-pageselect, .searchleft h4, .group-pageselect, .searchright h4 {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.user-pageselect, .group-pageselect {
|
||||
float: right;
|
||||
}
|
||||
|
||||
li.search-item:hover{
|
||||
background-color: #FBC02D;
|
||||
}
|
||||
160
website/queries/Facebook/Authentication/AccessToken.php
Normal file
160
website/queries/Facebook/Authentication/AccessToken.php
Normal file
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\Authentication;
|
||||
|
||||
/**
|
||||
* Class AccessToken
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class AccessToken
|
||||
{
|
||||
/**
|
||||
* The access token value.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $value = '';
|
||||
|
||||
/**
|
||||
* Date when token expires.
|
||||
*
|
||||
* @var \DateTime|null
|
||||
*/
|
||||
protected $expiresAt;
|
||||
|
||||
/**
|
||||
* Create a new access token entity.
|
||||
*
|
||||
* @param string $accessToken
|
||||
* @param int $expiresAt
|
||||
*/
|
||||
public function __construct($accessToken, $expiresAt = 0)
|
||||
{
|
||||
$this->value = $accessToken;
|
||||
if ($expiresAt) {
|
||||
$this->setExpiresAtFromTimeStamp($expiresAt);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an app secret proof to sign a request to Graph.
|
||||
*
|
||||
* @param string $appSecret The app secret.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAppSecretProof($appSecret)
|
||||
{
|
||||
return hash_hmac('sha256', $this->value, $appSecret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for expiresAt.
|
||||
*
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getExpiresAt()
|
||||
{
|
||||
return $this->expiresAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether or not this is an app access token.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAppAccessToken()
|
||||
{
|
||||
return strpos($this->value, '|') !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether or not this is a long-lived token.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isLongLived()
|
||||
{
|
||||
if ($this->expiresAt) {
|
||||
return $this->expiresAt->getTimestamp() > time() + (60 * 60 * 2);
|
||||
}
|
||||
|
||||
if ($this->isAppAccessToken()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the expiration of the access token.
|
||||
*
|
||||
* @return boolean|null
|
||||
*/
|
||||
public function isExpired()
|
||||
{
|
||||
if ($this->getExpiresAt() instanceof \DateTime) {
|
||||
return $this->getExpiresAt()->getTimestamp() < time();
|
||||
}
|
||||
|
||||
if ($this->isAppAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the access token as a string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the access token as a string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for expires_at.
|
||||
*
|
||||
* @param int $timeStamp
|
||||
*/
|
||||
protected function setExpiresAtFromTimeStamp($timeStamp)
|
||||
{
|
||||
$dt = new \DateTime();
|
||||
$dt->setTimestamp($timeStamp);
|
||||
$this->expiresAt = $dt;
|
||||
}
|
||||
}
|
||||
390
website/queries/Facebook/Authentication/AccessTokenMetadata.php
Normal file
390
website/queries/Facebook/Authentication/AccessTokenMetadata.php
Normal file
@@ -0,0 +1,390 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\Authentication;
|
||||
|
||||
use Facebook\Exceptions\FacebookSDKException;
|
||||
|
||||
/**
|
||||
* Class AccessTokenMetadata
|
||||
*
|
||||
* Represents metadata from an access token.
|
||||
*
|
||||
* @package Facebook
|
||||
* @see https://developers.facebook.com/docs/graph-api/reference/debug_token
|
||||
*/
|
||||
class AccessTokenMetadata
|
||||
{
|
||||
/**
|
||||
* The access token metadata.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $metadata = [];
|
||||
|
||||
/**
|
||||
* Properties that should be cast as DateTime objects.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $dateProperties = ['expires_at', 'issued_at'];
|
||||
|
||||
/**
|
||||
* @param array $metadata
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function __construct(array $metadata)
|
||||
{
|
||||
if (!isset($metadata['data'])) {
|
||||
throw new FacebookSDKException('Unexpected debug token response data.', 401);
|
||||
}
|
||||
|
||||
$this->metadata = $metadata['data'];
|
||||
|
||||
$this->castTimestampsToDateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value from the metadata.
|
||||
*
|
||||
* @param string $field The property to retrieve.
|
||||
* @param mixed $default The default to return if the property doesn't exist.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getField($field, $default = null)
|
||||
{
|
||||
if (isset($this->metadata[$field])) {
|
||||
return $this->metadata[$field];
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value from the metadata.
|
||||
*
|
||||
* @param string $field The property to retrieve.
|
||||
* @param mixed $default The default to return if the property doesn't exist.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @deprecated 5.0.0 getProperty() has been renamed to getField()
|
||||
* @todo v6: Remove this method
|
||||
*/
|
||||
public function getProperty($field, $default = null)
|
||||
{
|
||||
return $this->getField($field, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value from a child property in the metadata.
|
||||
*
|
||||
* @param string $parentField The parent property.
|
||||
* @param string $field The property to retrieve.
|
||||
* @param mixed $default The default to return if the property doesn't exist.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getChildProperty($parentField, $field, $default = null)
|
||||
{
|
||||
if (!isset($this->metadata[$parentField])) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
if (!isset($this->metadata[$parentField][$field])) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return $this->metadata[$parentField][$field];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value from the error metadata.
|
||||
*
|
||||
* @param string $field The property to retrieve.
|
||||
* @param mixed $default The default to return if the property doesn't exist.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getErrorProperty($field, $default = null)
|
||||
{
|
||||
return $this->getChildProperty('error', $field, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value from the "metadata" metadata. *Brain explodes*
|
||||
*
|
||||
* @param string $field The property to retrieve.
|
||||
* @param mixed $default The default to return if the property doesn't exist.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMetadataProperty($field, $default = null)
|
||||
{
|
||||
return $this->getChildProperty('metadata', $field, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the application this access token is for.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAppId()
|
||||
{
|
||||
return $this->getField('app_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Name of the application this access token is for.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getApplication()
|
||||
{
|
||||
return $this->getField('application');
|
||||
}
|
||||
|
||||
/**
|
||||
* Any error that a request to the graph api
|
||||
* would return due to the access token.
|
||||
*
|
||||
* @return bool|null
|
||||
*/
|
||||
public function isError()
|
||||
{
|
||||
return $this->getField('error') !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The error code for the error.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getErrorCode()
|
||||
{
|
||||
return $this->getErrorProperty('code');
|
||||
}
|
||||
|
||||
/**
|
||||
* The error message for the error.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getErrorMessage()
|
||||
{
|
||||
return $this->getErrorProperty('message');
|
||||
}
|
||||
|
||||
/**
|
||||
* The error subcode for the error.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getErrorSubcode()
|
||||
{
|
||||
return $this->getErrorProperty('subcode');
|
||||
}
|
||||
|
||||
/**
|
||||
* DateTime when this access token expires.
|
||||
*
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getExpiresAt()
|
||||
{
|
||||
return $this->getField('expires_at');
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the access token is still valid or not.
|
||||
*
|
||||
* @return boolean|null
|
||||
*/
|
||||
public function getIsValid()
|
||||
{
|
||||
return $this->getField('is_valid');
|
||||
}
|
||||
|
||||
/**
|
||||
* DateTime when this access token was issued.
|
||||
*
|
||||
* Note that the issued_at field is not returned
|
||||
* for short-lived access tokens.
|
||||
*
|
||||
* @see https://developers.facebook.com/docs/facebook-login/access-tokens#debug
|
||||
*
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getIssuedAt()
|
||||
{
|
||||
return $this->getField('issued_at');
|
||||
}
|
||||
|
||||
/**
|
||||
* General metadata associated with the access token.
|
||||
* Can contain data like 'sso', 'auth_type', 'auth_nonce'.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function getMetadata()
|
||||
{
|
||||
return $this->getField('metadata');
|
||||
}
|
||||
|
||||
/**
|
||||
* The 'sso' child property from the 'metadata' parent property.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSso()
|
||||
{
|
||||
return $this->getMetadataProperty('sso');
|
||||
}
|
||||
|
||||
/**
|
||||
* The 'auth_type' child property from the 'metadata' parent property.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAuthType()
|
||||
{
|
||||
return $this->getMetadataProperty('auth_type');
|
||||
}
|
||||
|
||||
/**
|
||||
* The 'auth_nonce' child property from the 'metadata' parent property.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAuthNonce()
|
||||
{
|
||||
return $this->getMetadataProperty('auth_nonce');
|
||||
}
|
||||
|
||||
/**
|
||||
* For impersonated access tokens, the ID of
|
||||
* the page this token contains.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getProfileId()
|
||||
{
|
||||
return $this->getField('profile_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* List of permissions that the user has granted for
|
||||
* the app in this access token.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getScopes()
|
||||
{
|
||||
return $this->getField('scopes');
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the user this access token is for.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUserId()
|
||||
{
|
||||
return $this->getField('user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures the app ID from the access token
|
||||
* metadata is what we expect.
|
||||
*
|
||||
* @param string $appId
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function validateAppId($appId)
|
||||
{
|
||||
if ($this->getAppId() !== $appId) {
|
||||
throw new FacebookSDKException('Access token metadata contains unexpected app ID.', 401);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures the user ID from the access token
|
||||
* metadata is what we expect.
|
||||
*
|
||||
* @param string $userId
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function validateUserId($userId)
|
||||
{
|
||||
if ($this->getUserId() !== $userId) {
|
||||
throw new FacebookSDKException('Access token metadata contains unexpected user ID.', 401);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures the access token has not expired yet.
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function validateExpiration()
|
||||
{
|
||||
if (!$this->getExpiresAt() instanceof \DateTime) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->getExpiresAt()->getTimestamp() < time()) {
|
||||
throw new FacebookSDKException('Inspection of access token metadata shows that the access token has expired.', 401);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a unix timestamp into a DateTime entity.
|
||||
*
|
||||
* @param int $timestamp
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
private function convertTimestampToDateTime($timestamp)
|
||||
{
|
||||
$dt = new \DateTime();
|
||||
$dt->setTimestamp($timestamp);
|
||||
|
||||
return $dt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts the unix timestamps as DateTime entities.
|
||||
*/
|
||||
private function castTimestampsToDateTime()
|
||||
{
|
||||
foreach (static::$dateProperties as $key) {
|
||||
if (isset($this->metadata[$key])) {
|
||||
$this->metadata[$key] = $this->convertTimestampToDateTime($this->metadata[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
292
website/queries/Facebook/Authentication/OAuth2Client.php
Normal file
292
website/queries/Facebook/Authentication/OAuth2Client.php
Normal file
@@ -0,0 +1,292 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\Authentication;
|
||||
|
||||
use Facebook\Facebook;
|
||||
use Facebook\FacebookApp;
|
||||
use Facebook\FacebookRequest;
|
||||
use Facebook\FacebookResponse;
|
||||
use Facebook\FacebookClient;
|
||||
use Facebook\Exceptions\FacebookResponseException;
|
||||
use Facebook\Exceptions\FacebookSDKException;
|
||||
|
||||
/**
|
||||
* Class OAuth2Client
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class OAuth2Client
|
||||
{
|
||||
/**
|
||||
* @const string The base authorization URL.
|
||||
*/
|
||||
const BASE_AUTHORIZATION_URL = 'https://www.facebook.com';
|
||||
|
||||
/**
|
||||
* The FacebookApp entity.
|
||||
*
|
||||
* @var FacebookApp
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* The Facebook client.
|
||||
*
|
||||
* @var FacebookClient
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* The version of the Graph API to use.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $graphVersion;
|
||||
|
||||
/**
|
||||
* The last request sent to Graph.
|
||||
*
|
||||
* @var FacebookRequest|null
|
||||
*/
|
||||
protected $lastRequest;
|
||||
|
||||
/**
|
||||
* @param FacebookApp $app
|
||||
* @param FacebookClient $client
|
||||
* @param string|null $graphVersion The version of the Graph API to use.
|
||||
*/
|
||||
public function __construct(FacebookApp $app, FacebookClient $client, $graphVersion = null)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->client = $client;
|
||||
$this->graphVersion = $graphVersion ?: Facebook::DEFAULT_GRAPH_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last FacebookRequest that was sent.
|
||||
* Useful for debugging and testing.
|
||||
*
|
||||
* @return FacebookRequest|null
|
||||
*/
|
||||
public function getLastRequest()
|
||||
{
|
||||
return $this->lastRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the metadata associated with the access token.
|
||||
*
|
||||
* @param AccessToken|string $accessToken The access token to debug.
|
||||
*
|
||||
* @return AccessTokenMetadata
|
||||
*/
|
||||
public function debugToken($accessToken)
|
||||
{
|
||||
$accessToken = $accessToken instanceof AccessToken ? $accessToken->getValue() : $accessToken;
|
||||
$params = ['input_token' => $accessToken];
|
||||
|
||||
$this->lastRequest = new FacebookRequest(
|
||||
$this->app,
|
||||
$this->app->getAccessToken(),
|
||||
'GET',
|
||||
'/debug_token',
|
||||
$params,
|
||||
null,
|
||||
$this->graphVersion
|
||||
);
|
||||
$response = $this->client->sendRequest($this->lastRequest);
|
||||
$metadata = $response->getDecodedBody();
|
||||
|
||||
return new AccessTokenMetadata($metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an authorization URL to begin the process of authenticating a user.
|
||||
*
|
||||
* @param string $redirectUrl The callback URL to redirect to.
|
||||
* @param array $scope An array of permissions to request.
|
||||
* @param string $state The CSPRNG-generated CSRF value.
|
||||
* @param array $params An array of parameters to generate URL.
|
||||
* @param string $separator The separator to use in http_build_query().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthorizationUrl($redirectUrl, $state, array $scope = [], array $params = [], $separator = '&')
|
||||
{
|
||||
$params += [
|
||||
'client_id' => $this->app->getId(),
|
||||
'state' => $state,
|
||||
'response_type' => 'code',
|
||||
'sdk' => 'php-sdk-' . Facebook::VERSION,
|
||||
'redirect_uri' => $redirectUrl,
|
||||
'scope' => implode(',', $scope)
|
||||
];
|
||||
|
||||
return static::BASE_AUTHORIZATION_URL . '/' . $this->graphVersion . '/dialog/oauth?' . http_build_query($params, null, $separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a valid access token from a code.
|
||||
*
|
||||
* @param string $code
|
||||
* @param string $redirectUri
|
||||
*
|
||||
* @return AccessToken
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function getAccessTokenFromCode($code, $redirectUri = '')
|
||||
{
|
||||
$params = [
|
||||
'code' => $code,
|
||||
'redirect_uri' => $redirectUri,
|
||||
];
|
||||
|
||||
return $this->requestAnAccessToken($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exchanges a short-lived access token with a long-lived access token.
|
||||
*
|
||||
* @param AccessToken|string $accessToken
|
||||
*
|
||||
* @return AccessToken
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function getLongLivedAccessToken($accessToken)
|
||||
{
|
||||
$accessToken = $accessToken instanceof AccessToken ? $accessToken->getValue() : $accessToken;
|
||||
$params = [
|
||||
'grant_type' => 'fb_exchange_token',
|
||||
'fb_exchange_token' => $accessToken,
|
||||
];
|
||||
|
||||
return $this->requestAnAccessToken($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a valid code from an access token.
|
||||
*
|
||||
* @param AccessToken|string $accessToken
|
||||
* @param string $redirectUri
|
||||
*
|
||||
* @return AccessToken
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function getCodeFromLongLivedAccessToken($accessToken, $redirectUri = '')
|
||||
{
|
||||
$params = [
|
||||
'redirect_uri' => $redirectUri,
|
||||
];
|
||||
|
||||
$response = $this->sendRequestWithClientParams('/oauth/client_code', $params, $accessToken);
|
||||
$data = $response->getDecodedBody();
|
||||
|
||||
if (!isset($data['code'])) {
|
||||
throw new FacebookSDKException('Code was not returned from Graph.', 401);
|
||||
}
|
||||
|
||||
return $data['code'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a request to the OAuth endpoint.
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return AccessToken
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
protected function requestAnAccessToken(array $params)
|
||||
{
|
||||
$response = $this->sendRequestWithClientParams('/oauth/access_token', $params);
|
||||
$data = $response->getDecodedBody();
|
||||
|
||||
if (!isset($data['access_token'])) {
|
||||
throw new FacebookSDKException('Access token was not returned from Graph.', 401);
|
||||
}
|
||||
|
||||
// Graph returns two different key names for expiration time
|
||||
// on the same endpoint. Doh! :/
|
||||
$expiresAt = 0;
|
||||
if (isset($data['expires'])) {
|
||||
// For exchanging a short lived token with a long lived token.
|
||||
// The expiration time in seconds will be returned as "expires".
|
||||
$expiresAt = time() + $data['expires'];
|
||||
} elseif (isset($data['expires_in'])) {
|
||||
// For exchanging a code for a short lived access token.
|
||||
// The expiration time in seconds will be returned as "expires_in".
|
||||
// See: https://developers.facebook.com/docs/facebook-login/access-tokens#long-via-code
|
||||
$expiresAt = time() + $data['expires_in'];
|
||||
}
|
||||
|
||||
return new AccessToken($data['access_token'], $expiresAt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a request to Graph with an app access token.
|
||||
*
|
||||
* @param string $endpoint
|
||||
* @param array $params
|
||||
* @param string|null $accessToken
|
||||
*
|
||||
* @return FacebookResponse
|
||||
*
|
||||
* @throws FacebookResponseException
|
||||
*/
|
||||
protected function sendRequestWithClientParams($endpoint, array $params, $accessToken = null)
|
||||
{
|
||||
$params += $this->getClientParams();
|
||||
|
||||
$accessToken = $accessToken ?: $this->app->getAccessToken();
|
||||
|
||||
$this->lastRequest = new FacebookRequest(
|
||||
$this->app,
|
||||
$accessToken,
|
||||
'GET',
|
||||
$endpoint,
|
||||
$params,
|
||||
null,
|
||||
$this->graphVersion
|
||||
);
|
||||
|
||||
return $this->client->sendRequest($this->lastRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the client_* params for OAuth requests.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getClientParams()
|
||||
{
|
||||
return [
|
||||
'client_id' => $this->app->getId(),
|
||||
'client_secret' => $this->app->getSecret(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\Exceptions;
|
||||
|
||||
/**
|
||||
* Class FacebookAuthenticationException
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class FacebookAuthenticationException extends FacebookSDKException
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\Exceptions;
|
||||
|
||||
/**
|
||||
* Class FacebookAuthorizationException
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class FacebookAuthorizationException extends FacebookSDKException
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\Exceptions;
|
||||
|
||||
/**
|
||||
* Class FacebookClientException
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class FacebookClientException extends FacebookSDKException
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\Exceptions;
|
||||
|
||||
/**
|
||||
* Class FacebookOtherException
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class FacebookOtherException extends FacebookSDKException
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\Exceptions;
|
||||
|
||||
use Facebook\FacebookResponse;
|
||||
|
||||
/**
|
||||
* Class FacebookResponseException
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class FacebookResponseException extends FacebookSDKException
|
||||
{
|
||||
/**
|
||||
* @var FacebookResponse The response that threw the exception.
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* @var array Decoded response.
|
||||
*/
|
||||
protected $responseData;
|
||||
|
||||
/**
|
||||
* Creates a FacebookResponseException.
|
||||
*
|
||||
* @param FacebookResponse $response The response that threw the exception.
|
||||
* @param FacebookSDKException $previousException The more detailed exception.
|
||||
*/
|
||||
public function __construct(FacebookResponse $response, FacebookSDKException $previousException = null)
|
||||
{
|
||||
$this->response = $response;
|
||||
$this->responseData = $response->getDecodedBody();
|
||||
|
||||
$errorMessage = $this->get('message', 'Unknown error from Graph.');
|
||||
$errorCode = $this->get('code', -1);
|
||||
|
||||
parent::__construct($errorMessage, $errorCode, $previousException);
|
||||
}
|
||||
|
||||
/**
|
||||
* A factory for creating the appropriate exception based on the response from Graph.
|
||||
*
|
||||
* @param FacebookResponse $response The response that threw the exception.
|
||||
*
|
||||
* @return FacebookResponseException
|
||||
*/
|
||||
public static function create(FacebookResponse $response)
|
||||
{
|
||||
$data = $response->getDecodedBody();
|
||||
|
||||
if (!isset($data['error']['code']) && isset($data['code'])) {
|
||||
$data = ['error' => $data];
|
||||
}
|
||||
|
||||
$code = isset($data['error']['code']) ? $data['error']['code'] : null;
|
||||
$message = isset($data['error']['message']) ? $data['error']['message'] : 'Unknown error from Graph.';
|
||||
|
||||
$previousException = null;
|
||||
|
||||
if (isset($data['error']['error_subcode'])) {
|
||||
switch ($data['error']['error_subcode']) {
|
||||
// Other authentication issues
|
||||
case 458:
|
||||
case 459:
|
||||
case 460:
|
||||
case 463:
|
||||
case 464:
|
||||
case 467:
|
||||
return new static($response, new FacebookAuthenticationException($message, $code));
|
||||
}
|
||||
}
|
||||
|
||||
switch ($code) {
|
||||
// Login status or token expired, revoked, or invalid
|
||||
case 100:
|
||||
case 102:
|
||||
case 190:
|
||||
return new static($response, new FacebookAuthenticationException($message, $code));
|
||||
|
||||
// Server issue, possible downtime
|
||||
case 1:
|
||||
case 2:
|
||||
return new static($response, new FacebookServerException($message, $code));
|
||||
|
||||
// API Throttling
|
||||
case 4:
|
||||
case 17:
|
||||
case 341:
|
||||
return new static($response, new FacebookThrottleException($message, $code));
|
||||
|
||||
// Duplicate Post
|
||||
case 506:
|
||||
return new static($response, new FacebookClientException($message, $code));
|
||||
}
|
||||
|
||||
// Missing Permissions
|
||||
if ($code == 10 || ($code >= 200 && $code <= 299)) {
|
||||
return new static($response, new FacebookAuthorizationException($message, $code));
|
||||
}
|
||||
|
||||
// OAuth authentication error
|
||||
if (isset($data['error']['type']) && $data['error']['type'] === 'OAuthException') {
|
||||
return new static($response, new FacebookAuthenticationException($message, $code));
|
||||
}
|
||||
|
||||
// All others
|
||||
return new static($response, new FacebookOtherException($message, $code));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks isset and returns that or a default value.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function get($key, $default = null)
|
||||
{
|
||||
if (isset($this->responseData['error'][$key])) {
|
||||
return $this->responseData['error'][$key];
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTTP status code
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHttpStatusCode()
|
||||
{
|
||||
return $this->response->getHttpStatusCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sub-error code
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSubErrorCode()
|
||||
{
|
||||
return $this->get('error_subcode', -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the error type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorType()
|
||||
{
|
||||
return $this->get('type', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw response used to create the exception.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRawResponse()
|
||||
{
|
||||
return $this->response->getBody();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the decoded response used to create the exception.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getResponseData()
|
||||
{
|
||||
return $this->responseData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the response entity used to create the exception.
|
||||
*
|
||||
* @return FacebookResponse
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
}
|
||||
33
website/queries/Facebook/Exceptions/FacebookSDKException.php
Normal file
33
website/queries/Facebook/Exceptions/FacebookSDKException.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\Exceptions;
|
||||
|
||||
/**
|
||||
* Class FacebookSDKException
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class FacebookSDKException extends \Exception
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\Exceptions;
|
||||
|
||||
/**
|
||||
* Class FacebookServerException
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class FacebookServerException extends FacebookSDKException
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\Exceptions;
|
||||
|
||||
/**
|
||||
* Class FacebookThrottleException
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class FacebookThrottleException extends FacebookSDKException
|
||||
{
|
||||
}
|
||||
589
website/queries/Facebook/Facebook.php
Normal file
589
website/queries/Facebook/Facebook.php
Normal file
@@ -0,0 +1,589 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook;
|
||||
|
||||
use Facebook\Authentication\AccessToken;
|
||||
use Facebook\Authentication\OAuth2Client;
|
||||
use Facebook\FileUpload\FacebookFile;
|
||||
use Facebook\FileUpload\FacebookVideo;
|
||||
use Facebook\GraphNodes\GraphEdge;
|
||||
use Facebook\Url\UrlDetectionInterface;
|
||||
use Facebook\Url\FacebookUrlDetectionHandler;
|
||||
use Facebook\PseudoRandomString\PseudoRandomStringGeneratorInterface;
|
||||
use Facebook\PseudoRandomString\McryptPseudoRandomStringGenerator;
|
||||
use Facebook\PseudoRandomString\OpenSslPseudoRandomStringGenerator;
|
||||
use Facebook\PseudoRandomString\UrandomPseudoRandomStringGenerator;
|
||||
use Facebook\HttpClients\FacebookHttpClientInterface;
|
||||
use Facebook\HttpClients\FacebookCurlHttpClient;
|
||||
use Facebook\HttpClients\FacebookStreamHttpClient;
|
||||
use Facebook\HttpClients\FacebookGuzzleHttpClient;
|
||||
use Facebook\PersistentData\PersistentDataInterface;
|
||||
use Facebook\PersistentData\FacebookSessionPersistentDataHandler;
|
||||
use Facebook\PersistentData\FacebookMemoryPersistentDataHandler;
|
||||
use Facebook\Helpers\FacebookCanvasHelper;
|
||||
use Facebook\Helpers\FacebookJavaScriptHelper;
|
||||
use Facebook\Helpers\FacebookPageTabHelper;
|
||||
use Facebook\Helpers\FacebookRedirectLoginHelper;
|
||||
use Facebook\Exceptions\FacebookSDKException;
|
||||
|
||||
/**
|
||||
* Class Facebook
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class Facebook
|
||||
{
|
||||
/**
|
||||
* @const string Version number of the Facebook PHP SDK.
|
||||
*/
|
||||
const VERSION = '5.0.0';
|
||||
|
||||
/**
|
||||
* @const string Default Graph API version for requests.
|
||||
*/
|
||||
const DEFAULT_GRAPH_VERSION = 'v2.4';
|
||||
|
||||
/**
|
||||
* @const string The name of the environment variable that contains the app ID.
|
||||
*/
|
||||
const APP_ID_ENV_NAME = 'FACEBOOK_APP_ID';
|
||||
|
||||
/**
|
||||
* @const string The name of the environment variable that contains the app secret.
|
||||
*/
|
||||
const APP_SECRET_ENV_NAME = 'FACEBOOK_APP_SECRET';
|
||||
|
||||
/**
|
||||
* @var FacebookApp The FacebookApp entity.
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* @var FacebookClient The Facebook client service.
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @var OAuth2Client The OAuth 2.0 client service.
|
||||
*/
|
||||
protected $oAuth2Client;
|
||||
|
||||
/**
|
||||
* @var UrlDetectionInterface|null The URL detection handler.
|
||||
*/
|
||||
protected $urlDetectionHandler;
|
||||
|
||||
/**
|
||||
* @var PseudoRandomStringGeneratorInterface|null The cryptographically secure pseudo-random string generator.
|
||||
*/
|
||||
protected $pseudoRandomStringGenerator;
|
||||
|
||||
/**
|
||||
* @var AccessToken|null The default access token to use with requests.
|
||||
*/
|
||||
protected $defaultAccessToken;
|
||||
|
||||
/**
|
||||
* @var string|null The default Graph version we want to use.
|
||||
*/
|
||||
protected $defaultGraphVersion;
|
||||
|
||||
/**
|
||||
* @var PersistentDataInterface|null The persistent data handler.
|
||||
*/
|
||||
protected $persistentDataHandler;
|
||||
|
||||
/**
|
||||
* @var FacebookResponse|FacebookBatchResponse|null Stores the last request made to Graph.
|
||||
*/
|
||||
protected $lastResponse;
|
||||
|
||||
/**
|
||||
* Instantiates a new Facebook super-class object.
|
||||
*
|
||||
* @param array $config
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function __construct(array $config = [])
|
||||
{
|
||||
$appId = isset($config['app_id']) ? $config['app_id'] : getenv(static::APP_ID_ENV_NAME);
|
||||
if (!$appId) {
|
||||
throw new FacebookSDKException('Required "app_id" key not supplied in config and could not find fallback environment variable "' . static::APP_ID_ENV_NAME . '"');
|
||||
}
|
||||
|
||||
$appSecret = isset($config['app_secret']) ? $config['app_secret'] : getenv(static::APP_SECRET_ENV_NAME);
|
||||
if (!$appSecret) {
|
||||
throw new FacebookSDKException('Required "app_secret" key not supplied in config and could not find fallback environment variable "' . static::APP_SECRET_ENV_NAME . '"');
|
||||
}
|
||||
|
||||
$this->app = new FacebookApp($appId, $appSecret);
|
||||
|
||||
$httpClientHandler = null;
|
||||
if (isset($config['http_client_handler'])) {
|
||||
if ($config['http_client_handler'] instanceof FacebookHttpClientInterface) {
|
||||
$httpClientHandler = $config['http_client_handler'];
|
||||
} elseif ($config['http_client_handler'] === 'curl') {
|
||||
$httpClientHandler = new FacebookCurlHttpClient();
|
||||
} elseif ($config['http_client_handler'] === 'stream') {
|
||||
$httpClientHandler = new FacebookStreamHttpClient();
|
||||
} elseif ($config['http_client_handler'] === 'guzzle') {
|
||||
$httpClientHandler = new FacebookGuzzleHttpClient();
|
||||
} else {
|
||||
throw new \InvalidArgumentException('The http_client_handler must be set to "curl", "stream", "guzzle", or be an instance of Facebook\HttpClients\FacebookHttpClientInterface');
|
||||
}
|
||||
}
|
||||
|
||||
$enableBeta = isset($config['enable_beta_mode']) && $config['enable_beta_mode'] === true;
|
||||
$this->client = new FacebookClient($httpClientHandler, $enableBeta);
|
||||
|
||||
if (isset($config['url_detection_handler'])) {
|
||||
if ($config['url_detection_handler'] instanceof UrlDetectionInterface) {
|
||||
$this->urlDetectionHandler = $config['url_detection_handler'];
|
||||
} else {
|
||||
throw new \InvalidArgumentException('The url_detection_handler must be an instance of Facebook\Url\UrlDetectionInterface');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($config['pseudo_random_string_generator'])) {
|
||||
if ($config['pseudo_random_string_generator'] instanceof PseudoRandomStringGeneratorInterface) {
|
||||
$this->pseudoRandomStringGenerator = $config['pseudo_random_string_generator'];
|
||||
} elseif ($config['pseudo_random_string_generator'] === 'mcrypt') {
|
||||
$this->pseudoRandomStringGenerator = new McryptPseudoRandomStringGenerator();
|
||||
} elseif ($config['pseudo_random_string_generator'] === 'openssl') {
|
||||
$this->pseudoRandomStringGenerator = new OpenSslPseudoRandomStringGenerator();
|
||||
} elseif ($config['pseudo_random_string_generator'] === 'urandom') {
|
||||
$this->pseudoRandomStringGenerator = new UrandomPseudoRandomStringGenerator();
|
||||
} else {
|
||||
throw new \InvalidArgumentException('The pseudo_random_string_generator must be set to "mcrypt", "openssl", or "urandom", or be an instance of Facebook\PseudoRandomString\PseudoRandomStringGeneratorInterface');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($config['persistent_data_handler'])) {
|
||||
if ($config['persistent_data_handler'] instanceof PersistentDataInterface) {
|
||||
$this->persistentDataHandler = $config['persistent_data_handler'];
|
||||
} elseif ($config['persistent_data_handler'] === 'session') {
|
||||
$this->persistentDataHandler = new FacebookSessionPersistentDataHandler();
|
||||
} elseif ($config['persistent_data_handler'] === 'memory') {
|
||||
$this->persistentDataHandler = new FacebookMemoryPersistentDataHandler();
|
||||
} else {
|
||||
throw new \InvalidArgumentException('The persistent_data_handler must be set to "session", "memory", or be an instance of Facebook\PersistentData\PersistentDataInterface');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($config['default_access_token'])) {
|
||||
$this->setDefaultAccessToken($config['default_access_token']);
|
||||
}
|
||||
|
||||
if (isset($config['default_graph_version'])) {
|
||||
$this->defaultGraphVersion = $config['default_graph_version'];
|
||||
} else {
|
||||
// @todo v6: Throw an InvalidArgumentException if "default_graph_version" is not set
|
||||
$this->defaultGraphVersion = static::DEFAULT_GRAPH_VERSION;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the FacebookApp entity.
|
||||
*
|
||||
* @return FacebookApp
|
||||
*/
|
||||
public function getApp()
|
||||
{
|
||||
return $this->app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the FacebookClient service.
|
||||
*
|
||||
* @return FacebookClient
|
||||
*/
|
||||
public function getClient()
|
||||
{
|
||||
return $this->client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the OAuth 2.0 client service.
|
||||
*
|
||||
* @return OAuth2Client
|
||||
*/
|
||||
public function getOAuth2Client()
|
||||
{
|
||||
if (!$this->oAuth2Client instanceof OAuth2Client) {
|
||||
$app = $this->getApp();
|
||||
$client = $this->getClient();
|
||||
$this->oAuth2Client = new OAuth2Client($app, $client, $this->defaultGraphVersion);
|
||||
}
|
||||
|
||||
return $this->oAuth2Client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last response returned from Graph.
|
||||
*
|
||||
* @return FacebookResponse|FacebookBatchResponse|null
|
||||
*/
|
||||
public function getLastResponse()
|
||||
{
|
||||
return $this->lastResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL detection handler.
|
||||
*
|
||||
* @return UrlDetectionInterface
|
||||
*/
|
||||
public function getUrlDetectionHandler()
|
||||
{
|
||||
if (!$this->urlDetectionHandler instanceof UrlDetectionInterface) {
|
||||
$this->urlDetectionHandler = new FacebookUrlDetectionHandler();
|
||||
}
|
||||
|
||||
return $this->urlDetectionHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default AccessToken entity.
|
||||
*
|
||||
* @return AccessToken|null
|
||||
*/
|
||||
public function getDefaultAccessToken()
|
||||
{
|
||||
return $this->defaultAccessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default access token to use with requests.
|
||||
*
|
||||
* @param AccessToken|string $accessToken The access token to save.
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setDefaultAccessToken($accessToken)
|
||||
{
|
||||
if (is_string($accessToken)) {
|
||||
$this->defaultAccessToken = new AccessToken($accessToken);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($accessToken instanceof AccessToken) {
|
||||
$this->defaultAccessToken = $accessToken;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('The default access token must be of type "string" or Facebook\AccessToken');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default Graph version.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultGraphVersion()
|
||||
{
|
||||
return $this->defaultGraphVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the redirect login helper.
|
||||
*
|
||||
* @return FacebookRedirectLoginHelper
|
||||
*/
|
||||
public function getRedirectLoginHelper()
|
||||
{
|
||||
return new FacebookRedirectLoginHelper(
|
||||
$this->getOAuth2Client(),
|
||||
$this->persistentDataHandler,
|
||||
$this->urlDetectionHandler,
|
||||
$this->pseudoRandomStringGenerator
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the JavaScript helper.
|
||||
*
|
||||
* @return FacebookJavaScriptHelper
|
||||
*/
|
||||
public function getJavaScriptHelper()
|
||||
{
|
||||
return new FacebookJavaScriptHelper($this->app, $this->client, $this->defaultGraphVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the canvas helper.
|
||||
*
|
||||
* @return FacebookCanvasHelper
|
||||
*/
|
||||
public function getCanvasHelper()
|
||||
{
|
||||
return new FacebookCanvasHelper($this->app, $this->client, $this->defaultGraphVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the page tab helper.
|
||||
*
|
||||
* @return FacebookPageTabHelper
|
||||
*/
|
||||
public function getPageTabHelper()
|
||||
{
|
||||
return new FacebookPageTabHelper($this->app, $this->client, $this->defaultGraphVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a GET request to Graph and returns the result.
|
||||
*
|
||||
* @param string $endpoint
|
||||
* @param AccessToken|string|null $accessToken
|
||||
* @param string|null $eTag
|
||||
* @param string|null $graphVersion
|
||||
*
|
||||
* @return FacebookResponse
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function get($endpoint, $accessToken = null, $eTag = null, $graphVersion = null)
|
||||
{
|
||||
return $this->sendRequest(
|
||||
'GET',
|
||||
$endpoint,
|
||||
$params = [],
|
||||
$accessToken,
|
||||
$eTag,
|
||||
$graphVersion
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a POST request to Graph and returns the result.
|
||||
*
|
||||
* @param string $endpoint
|
||||
* @param array $params
|
||||
* @param AccessToken|string|null $accessToken
|
||||
* @param string|null $eTag
|
||||
* @param string|null $graphVersion
|
||||
*
|
||||
* @return FacebookResponse
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function post($endpoint, array $params = [], $accessToken = null, $eTag = null, $graphVersion = null)
|
||||
{
|
||||
return $this->sendRequest(
|
||||
'POST',
|
||||
$endpoint,
|
||||
$params,
|
||||
$accessToken,
|
||||
$eTag,
|
||||
$graphVersion
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a DELETE request to Graph and returns the result.
|
||||
*
|
||||
* @param string $endpoint
|
||||
* @param array $params
|
||||
* @param AccessToken|string|null $accessToken
|
||||
* @param string|null $eTag
|
||||
* @param string|null $graphVersion
|
||||
*
|
||||
* @return FacebookResponse
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function delete($endpoint, array $params = [], $accessToken = null, $eTag = null, $graphVersion = null)
|
||||
{
|
||||
return $this->sendRequest(
|
||||
'DELETE',
|
||||
$endpoint,
|
||||
$params,
|
||||
$accessToken,
|
||||
$eTag,
|
||||
$graphVersion
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a request to Graph for the next page of results.
|
||||
*
|
||||
* @param GraphEdge $graphEdge The GraphEdge to paginate over.
|
||||
*
|
||||
* @return GraphEdge|null
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function next(GraphEdge $graphEdge)
|
||||
{
|
||||
return $this->getPaginationResults($graphEdge, 'next');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a request to Graph for the previous page of results.
|
||||
*
|
||||
* @param GraphEdge $graphEdge The GraphEdge to paginate over.
|
||||
*
|
||||
* @return GraphEdge|null
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function previous(GraphEdge $graphEdge)
|
||||
{
|
||||
return $this->getPaginationResults($graphEdge, 'previous');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a request to Graph for the next page of results.
|
||||
*
|
||||
* @param GraphEdge $graphEdge The GraphEdge to paginate over.
|
||||
* @param string $direction The direction of the pagination: next|previous.
|
||||
*
|
||||
* @return GraphEdge|null
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function getPaginationResults(GraphEdge $graphEdge, $direction)
|
||||
{
|
||||
$paginationRequest = $graphEdge->getPaginationRequest($direction);
|
||||
if (!$paginationRequest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->lastResponse = $this->client->sendRequest($paginationRequest);
|
||||
|
||||
// Keep the same GraphNode subclass
|
||||
$subClassName = $graphEdge->getSubClassName();
|
||||
$graphEdge = $this->lastResponse->getGraphEdge($subClassName, false);
|
||||
|
||||
return count($graphEdge) > 0 ? $graphEdge : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a request to Graph and returns the result.
|
||||
*
|
||||
* @param string $method
|
||||
* @param string $endpoint
|
||||
* @param array $params
|
||||
* @param AccessToken|string|null $accessToken
|
||||
* @param string|null $eTag
|
||||
* @param string|null $graphVersion
|
||||
*
|
||||
* @return FacebookResponse
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function sendRequest($method, $endpoint, array $params = [], $accessToken = null, $eTag = null, $graphVersion = null)
|
||||
{
|
||||
$accessToken = $accessToken ?: $this->defaultAccessToken;
|
||||
$graphVersion = $graphVersion ?: $this->defaultGraphVersion;
|
||||
$request = $this->request($method, $endpoint, $params, $accessToken, $eTag, $graphVersion);
|
||||
|
||||
return $this->lastResponse = $this->client->sendRequest($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a batched request to Graph and returns the result.
|
||||
*
|
||||
* @param array $requests
|
||||
* @param AccessToken|string|null $accessToken
|
||||
* @param string|null $graphVersion
|
||||
*
|
||||
* @return FacebookBatchResponse
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function sendBatchRequest(array $requests, $accessToken = null, $graphVersion = null)
|
||||
{
|
||||
$accessToken = $accessToken ?: $this->defaultAccessToken;
|
||||
$graphVersion = $graphVersion ?: $this->defaultGraphVersion;
|
||||
$batchRequest = new FacebookBatchRequest(
|
||||
$this->app,
|
||||
$requests,
|
||||
$accessToken,
|
||||
$graphVersion
|
||||
);
|
||||
|
||||
return $this->lastResponse = $this->client->sendBatchRequest($batchRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new FacebookRequest entity.
|
||||
*
|
||||
* @param string $method
|
||||
* @param string $endpoint
|
||||
* @param array $params
|
||||
* @param AccessToken|string|null $accessToken
|
||||
* @param string|null $eTag
|
||||
* @param string|null $graphVersion
|
||||
*
|
||||
* @return FacebookRequest
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function request($method, $endpoint, array $params = [], $accessToken = null, $eTag = null, $graphVersion = null)
|
||||
{
|
||||
$accessToken = $accessToken ?: $this->defaultAccessToken;
|
||||
$graphVersion = $graphVersion ?: $this->defaultGraphVersion;
|
||||
|
||||
return new FacebookRequest(
|
||||
$this->app,
|
||||
$accessToken,
|
||||
$method,
|
||||
$endpoint,
|
||||
$params,
|
||||
$eTag,
|
||||
$graphVersion
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory to create FacebookFile's.
|
||||
*
|
||||
* @param string $pathToFile
|
||||
*
|
||||
* @return FacebookFile
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function fileToUpload($pathToFile)
|
||||
{
|
||||
return new FacebookFile($pathToFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory to create FacebookVideo's.
|
||||
*
|
||||
* @param string $pathToFile
|
||||
*
|
||||
* @return FacebookVideo
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function videoToUpload($pathToFile)
|
||||
{
|
||||
return new FacebookVideo($pathToFile);
|
||||
}
|
||||
}
|
||||
101
website/queries/Facebook/FacebookApp.php
Normal file
101
website/queries/Facebook/FacebookApp.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook;
|
||||
|
||||
use Facebook\Authentication\AccessToken;
|
||||
|
||||
class FacebookApp implements \Serializable
|
||||
{
|
||||
/**
|
||||
* @var string The app ID.
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @var string The app secret.
|
||||
*/
|
||||
protected $secret;
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @param string $secret
|
||||
*/
|
||||
public function __construct($id, $secret)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->secret = $secret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the app ID.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the app secret.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSecret()
|
||||
{
|
||||
return $this->secret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an app access token.
|
||||
*
|
||||
* @return AccessToken
|
||||
*/
|
||||
public function getAccessToken()
|
||||
{
|
||||
return new AccessToken($this->id . '|' . $this->secret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the FacebookApp entity as a string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
return serialize([$this->id, $this->secret]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unserializes a string as a FacebookApp entity.
|
||||
*
|
||||
* @param string $serialized
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
list($id, $secret) = unserialize($serialized);
|
||||
|
||||
$this->__construct($id, $secret);
|
||||
}
|
||||
}
|
||||
303
website/queries/Facebook/FacebookBatchRequest.php
Normal file
303
website/queries/Facebook/FacebookBatchRequest.php
Normal file
@@ -0,0 +1,303 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook;
|
||||
|
||||
use ArrayIterator;
|
||||
use IteratorAggregate;
|
||||
use ArrayAccess;
|
||||
use Facebook\Authentication\AccessToken;
|
||||
use Facebook\Exceptions\FacebookSDKException;
|
||||
|
||||
/**
|
||||
* Class BatchRequest
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class FacebookBatchRequest extends FacebookRequest implements IteratorAggregate, ArrayAccess
|
||||
{
|
||||
/**
|
||||
* @var array An array of FacebookRequest entities to send.
|
||||
*/
|
||||
protected $requests;
|
||||
|
||||
/**
|
||||
* @var array An array of files to upload.
|
||||
*/
|
||||
protected $attachedFiles;
|
||||
|
||||
/**
|
||||
* Creates a new Request entity.
|
||||
*
|
||||
* @param FacebookApp|null $app
|
||||
* @param array $requests
|
||||
* @param AccessToken|string|null $accessToken
|
||||
* @param string|null $graphVersion
|
||||
*/
|
||||
public function __construct(FacebookApp $app = null, array $requests = [], $accessToken = null, $graphVersion = null)
|
||||
{
|
||||
parent::__construct($app, $accessToken, 'POST', '', [], null, $graphVersion);
|
||||
|
||||
$this->add($requests);
|
||||
}
|
||||
|
||||
/**
|
||||
* A a new request to the array.
|
||||
*
|
||||
* @param FacebookRequest|array $request
|
||||
* @param string|null $name
|
||||
*
|
||||
* @return FacebookBatchRequest
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function add($request, $name = null)
|
||||
{
|
||||
if (is_array($request)) {
|
||||
foreach ($request as $key => $req) {
|
||||
$this->add($req, $key);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!$request instanceof FacebookRequest) {
|
||||
throw new \InvalidArgumentException('Argument for add() must be of type array or FacebookRequest.');
|
||||
}
|
||||
|
||||
$this->addFallbackDefaults($request);
|
||||
$requestToAdd = [
|
||||
'name' => $name,
|
||||
'request' => $request,
|
||||
];
|
||||
|
||||
// File uploads
|
||||
$attachedFiles = $this->extractFileAttachments($request);
|
||||
if ($attachedFiles) {
|
||||
$requestToAdd['attached_files'] = $attachedFiles;
|
||||
}
|
||||
$this->requests[] = $requestToAdd;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the FacebookApp and access token fall back when missing.
|
||||
*
|
||||
* @param FacebookRequest $request
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function addFallbackDefaults(FacebookRequest $request)
|
||||
{
|
||||
if (!$request->getApp()) {
|
||||
$app = $this->getApp();
|
||||
if (!$app) {
|
||||
throw new FacebookSDKException('Missing FacebookApp on FacebookRequest and no fallback detected on FacebookBatchRequest.');
|
||||
}
|
||||
$request->setApp($app);
|
||||
}
|
||||
|
||||
if (!$request->getAccessToken()) {
|
||||
$accessToken = $this->getAccessToken();
|
||||
if (!$accessToken) {
|
||||
throw new FacebookSDKException('Missing access token on FacebookRequest and no fallback detected on FacebookBatchRequest.');
|
||||
}
|
||||
$request->setAccessToken($accessToken);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the files from a request.
|
||||
*
|
||||
* @param FacebookRequest $request
|
||||
*
|
||||
* @return string|null
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function extractFileAttachments(FacebookRequest $request)
|
||||
{
|
||||
if (!$request->containsFileUploads()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$files = $request->getFiles();
|
||||
$fileNames = [];
|
||||
foreach ($files as $file) {
|
||||
$fileName = uniqid();
|
||||
$this->addFile($fileName, $file);
|
||||
$fileNames[] = $fileName;
|
||||
}
|
||||
|
||||
$request->resetFiles();
|
||||
|
||||
// @TODO Does Graph support multiple uploads on one endpoint?
|
||||
return implode(',', $fileNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the FacebookRequest entities.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRequests()
|
||||
{
|
||||
return $this->requests;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the requests to be sent as a batch request.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function prepareRequestsForBatch()
|
||||
{
|
||||
$this->validateBatchRequestCount();
|
||||
|
||||
$params = [
|
||||
'batch' => $this->convertRequestsToJson(),
|
||||
'include_headers' => true,
|
||||
];
|
||||
$this->setParams($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the requests into a JSON(P) string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function convertRequestsToJson()
|
||||
{
|
||||
$requests = [];
|
||||
foreach ($this->requests as $request) {
|
||||
$attachedFiles = isset($request['attached_files']) ? $request['attached_files'] : null;
|
||||
$requests[] = $this->requestEntityToBatchArray($request['request'], $request['name'], $attachedFiles);
|
||||
}
|
||||
|
||||
return json_encode($requests);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the request count before sending them as a batch.
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function validateBatchRequestCount()
|
||||
{
|
||||
$batchCount = count($this->requests);
|
||||
if ($batchCount === 0) {
|
||||
throw new FacebookSDKException('There are no batch requests to send.');
|
||||
} elseif ($batchCount > 50) {
|
||||
// Per: https://developers.facebook.com/docs/graph-api/making-multiple-requests#limits
|
||||
throw new FacebookSDKException('You cannot send more than 50 batch requests at a time.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Request entity into an array that is batch-friendly.
|
||||
*
|
||||
* @param FacebookRequest $request The request entity to convert.
|
||||
* @param string|null $requestName The name of the request.
|
||||
* @param string|null $attachedFiles Names of files associated with the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function requestEntityToBatchArray(FacebookRequest $request, $requestName = null, $attachedFiles = null)
|
||||
{
|
||||
$compiledHeaders = [];
|
||||
$headers = $request->getHeaders();
|
||||
foreach ($headers as $name => $value) {
|
||||
$compiledHeaders[] = $name . ': ' . $value;
|
||||
}
|
||||
|
||||
$batch = [
|
||||
'headers' => $compiledHeaders,
|
||||
'method' => $request->getMethod(),
|
||||
'relative_url' => $request->getUrl(),
|
||||
];
|
||||
|
||||
// Since file uploads are moved to the root request of a batch request,
|
||||
// the child requests will always be URL-encoded.
|
||||
$body = $request->getUrlEncodedBody()->getBody();
|
||||
if ($body) {
|
||||
$batch['body'] = $body;
|
||||
}
|
||||
|
||||
if (isset($requestName)) {
|
||||
$batch['name'] = $requestName;
|
||||
}
|
||||
|
||||
if (isset($attachedFiles)) {
|
||||
$batch['attached_files'] = $attachedFiles;
|
||||
}
|
||||
|
||||
// @TODO Add support for "omit_response_on_success"
|
||||
// @TODO Add support for "depends_on"
|
||||
// @TODO Add support for JSONP with "callback"
|
||||
|
||||
return $batch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an iterator for the items.
|
||||
*
|
||||
* @return ArrayIterator
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayIterator($this->requests);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
$this->add($value, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset($this->requests[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->requests[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return isset($this->requests[$offset]) ? $this->requests[$offset] : null;
|
||||
}
|
||||
}
|
||||
154
website/queries/Facebook/FacebookBatchResponse.php
Normal file
154
website/queries/Facebook/FacebookBatchResponse.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook;
|
||||
|
||||
use ArrayIterator;
|
||||
use IteratorAggregate;
|
||||
use ArrayAccess;
|
||||
|
||||
/**
|
||||
* Class FacebookBatchResponse
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class FacebookBatchResponse extends FacebookResponse implements IteratorAggregate, ArrayAccess
|
||||
{
|
||||
/**
|
||||
* @var FacebookBatchRequest The original entity that made the batch request.
|
||||
*/
|
||||
protected $batchRequest;
|
||||
|
||||
/**
|
||||
* @var array An array of FacebookResponse entities.
|
||||
*/
|
||||
protected $responses = [];
|
||||
|
||||
/**
|
||||
* Creates a new Response entity.
|
||||
*
|
||||
* @param FacebookBatchRequest $batchRequest
|
||||
* @param FacebookResponse $response
|
||||
*/
|
||||
public function __construct(FacebookBatchRequest $batchRequest, FacebookResponse $response)
|
||||
{
|
||||
$this->batchRequest = $batchRequest;
|
||||
|
||||
$request = $response->getRequest();
|
||||
$body = $response->getBody();
|
||||
$httpStatusCode = $response->getHttpStatusCode();
|
||||
$headers = $response->getHeaders();
|
||||
parent::__construct($request, $body, $httpStatusCode, $headers);
|
||||
|
||||
$responses = $response->getDecodedBody();
|
||||
$this->setResponses($responses);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of FacebookResponse entities.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getResponses()
|
||||
{
|
||||
return $this->responses;
|
||||
}
|
||||
|
||||
/**
|
||||
* The main batch response will be an array of requests so
|
||||
* we need to iterate over all the responses.
|
||||
*
|
||||
* @param array $responses
|
||||
*/
|
||||
public function setResponses(array $responses)
|
||||
{
|
||||
$this->responses = [];
|
||||
|
||||
foreach ($responses as $key => $graphResponse) {
|
||||
$this->addResponse($key, $graphResponse);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a response to the list.
|
||||
*
|
||||
* @param int $key
|
||||
* @param array|null $response
|
||||
*/
|
||||
public function addResponse($key, $response)
|
||||
{
|
||||
$originalRequestName = isset($this->batchRequest[$key]['name']) ? $this->batchRequest[$key]['name'] : $key;
|
||||
$originalRequest = isset($this->batchRequest[$key]['request']) ? $this->batchRequest[$key]['request'] : null;
|
||||
|
||||
$httpResponseBody = isset($response['body']) ? $response['body'] : null;
|
||||
$httpResponseCode = isset($response['code']) ? $response['code'] : null;
|
||||
$httpResponseHeaders = isset($response['headers']) ? $response['headers'] : [];
|
||||
|
||||
$this->responses[$originalRequestName] = new FacebookResponse(
|
||||
$originalRequest,
|
||||
$httpResponseBody,
|
||||
$httpResponseCode,
|
||||
$httpResponseHeaders
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayIterator($this->responses);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
$this->addResponse($offset, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset($this->responses[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->responses[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return isset($this->responses[$offset]) ? $this->responses[$offset] : null;
|
||||
}
|
||||
}
|
||||
250
website/queries/Facebook/FacebookClient.php
Normal file
250
website/queries/Facebook/FacebookClient.php
Normal file
@@ -0,0 +1,250 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook;
|
||||
|
||||
use Facebook\HttpClients\FacebookHttpClientInterface;
|
||||
use Facebook\HttpClients\FacebookCurlHttpClient;
|
||||
use Facebook\HttpClients\FacebookStreamHttpClient;
|
||||
use Facebook\Exceptions\FacebookSDKException;
|
||||
|
||||
/**
|
||||
* Class FacebookClient
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class FacebookClient
|
||||
{
|
||||
/**
|
||||
* @const string Production Graph API URL.
|
||||
*/
|
||||
const BASE_GRAPH_URL = 'https://graph.facebook.com';
|
||||
|
||||
/**
|
||||
* @const string Graph API URL for video uploads.
|
||||
*/
|
||||
const BASE_GRAPH_VIDEO_URL = 'https://graph-video.facebook.com';
|
||||
|
||||
/**
|
||||
* @const string Beta Graph API URL.
|
||||
*/
|
||||
const BASE_GRAPH_URL_BETA = 'https://graph.beta.facebook.com';
|
||||
|
||||
/**
|
||||
* @const string Beta Graph API URL for video uploads.
|
||||
*/
|
||||
const BASE_GRAPH_VIDEO_URL_BETA = 'https://graph-video.beta.facebook.com';
|
||||
|
||||
/**
|
||||
* @const int The timeout in seconds for a normal request.
|
||||
*/
|
||||
const DEFAULT_REQUEST_TIMEOUT = 60;
|
||||
|
||||
/**
|
||||
* @const int The timeout in seconds for a request that contains file uploads.
|
||||
*/
|
||||
const DEFAULT_FILE_UPLOAD_REQUEST_TIMEOUT = 3600;
|
||||
|
||||
/**
|
||||
* @const int The timeout in seconds for a request that contains video uploads.
|
||||
*/
|
||||
const DEFAULT_VIDEO_UPLOAD_REQUEST_TIMEOUT = 7200;
|
||||
|
||||
/**
|
||||
* @var bool Toggle to use Graph beta url.
|
||||
*/
|
||||
protected $enableBetaMode = false;
|
||||
|
||||
/**
|
||||
* @var FacebookHttpClientInterface HTTP client handler.
|
||||
*/
|
||||
protected $httpClientHandler;
|
||||
|
||||
/**
|
||||
* @var int The number of calls that have been made to Graph.
|
||||
*/
|
||||
public static $requestCount = 0;
|
||||
|
||||
/**
|
||||
* Instantiates a new FacebookClient object.
|
||||
*
|
||||
* @param FacebookHttpClientInterface|null $httpClientHandler
|
||||
* @param boolean $enableBeta
|
||||
*/
|
||||
public function __construct(FacebookHttpClientInterface $httpClientHandler = null, $enableBeta = false)
|
||||
{
|
||||
$this->httpClientHandler = $httpClientHandler ?: $this->detectHttpClientHandler();
|
||||
$this->enableBetaMode = $enableBeta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the HTTP client handler.
|
||||
*
|
||||
* @param FacebookHttpClientInterface $httpClientHandler
|
||||
*/
|
||||
public function setHttpClientHandler(FacebookHttpClientInterface $httpClientHandler)
|
||||
{
|
||||
$this->httpClientHandler = $httpClientHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTTP client handler.
|
||||
*
|
||||
* @return FacebookHttpClientInterface
|
||||
*/
|
||||
public function getHttpClientHandler()
|
||||
{
|
||||
return $this->httpClientHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects which HTTP client handler to use.
|
||||
*
|
||||
* @return FacebookHttpClientInterface
|
||||
*/
|
||||
public function detectHttpClientHandler()
|
||||
{
|
||||
return function_exists('curl_init') ? new FacebookCurlHttpClient() : new FacebookStreamHttpClient();
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle beta mode.
|
||||
*
|
||||
* @param boolean $betaMode
|
||||
*/
|
||||
public function enableBetaMode($betaMode = true)
|
||||
{
|
||||
$this->enableBetaMode = $betaMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base Graph URL.
|
||||
*
|
||||
* @param boolean $postToVideoUrl Post to the video API if videos are being uploaded.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBaseGraphUrl($postToVideoUrl = false)
|
||||
{
|
||||
if ($postToVideoUrl) {
|
||||
return $this->enableBetaMode ? static::BASE_GRAPH_VIDEO_URL_BETA : static::BASE_GRAPH_VIDEO_URL;
|
||||
}
|
||||
|
||||
return $this->enableBetaMode ? static::BASE_GRAPH_URL_BETA : static::BASE_GRAPH_URL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the request for sending to the client handler.
|
||||
*
|
||||
* @param FacebookRequest $request
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function prepareRequestMessage(FacebookRequest $request)
|
||||
{
|
||||
$postToVideoUrl = $request->containsVideoUploads();
|
||||
$url = $this->getBaseGraphUrl($postToVideoUrl) . $request->getUrl();
|
||||
|
||||
// If we're sending files they should be sent as multipart/form-data
|
||||
if ($request->containsFileUploads()) {
|
||||
$requestBody = $request->getMultipartBody();
|
||||
$request->setHeaders([
|
||||
'Content-Type' => 'multipart/form-data; boundary=' . $requestBody->getBoundary(),
|
||||
]);
|
||||
} else {
|
||||
$requestBody = $request->getUrlEncodedBody();
|
||||
$request->setHeaders([
|
||||
'Content-Type' => 'application/x-www-form-urlencoded',
|
||||
]);
|
||||
}
|
||||
|
||||
return [
|
||||
$url,
|
||||
$request->getMethod(),
|
||||
$request->getHeaders(),
|
||||
$requestBody->getBody(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the request to Graph and returns the result.
|
||||
*
|
||||
* @param FacebookRequest $request
|
||||
*
|
||||
* @return FacebookResponse
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function sendRequest(FacebookRequest $request)
|
||||
{
|
||||
if (get_class($request) === 'FacebookRequest') {
|
||||
$request->validateAccessToken();
|
||||
}
|
||||
|
||||
list($url, $method, $headers, $body) = $this->prepareRequestMessage($request);
|
||||
|
||||
// Since file uploads can take a while, we need to give more time for uploads
|
||||
$timeOut = static::DEFAULT_REQUEST_TIMEOUT;
|
||||
if ($request->containsFileUploads()) {
|
||||
$timeOut = static::DEFAULT_FILE_UPLOAD_REQUEST_TIMEOUT;
|
||||
} elseif ($request->containsVideoUploads()) {
|
||||
$timeOut = static::DEFAULT_VIDEO_UPLOAD_REQUEST_TIMEOUT;
|
||||
}
|
||||
|
||||
// Should throw `FacebookSDKException` exception on HTTP client error.
|
||||
// Don't catch to allow it to bubble up.
|
||||
$rawResponse = $this->httpClientHandler->send($url, $method, $body, $headers, $timeOut);
|
||||
|
||||
static::$requestCount++;
|
||||
|
||||
$returnResponse = new FacebookResponse(
|
||||
$request,
|
||||
$rawResponse->getBody(),
|
||||
$rawResponse->getHttpResponseCode(),
|
||||
$rawResponse->getHeaders()
|
||||
);
|
||||
|
||||
if ($returnResponse->isError()) {
|
||||
throw $returnResponse->getThrownException();
|
||||
}
|
||||
|
||||
return $returnResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a batched request to Graph and returns the result.
|
||||
*
|
||||
* @param FacebookBatchRequest $request
|
||||
*
|
||||
* @return FacebookBatchResponse
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function sendBatchRequest(FacebookBatchRequest $request)
|
||||
{
|
||||
$request->prepareRequestsForBatch();
|
||||
$facebookResponse = $this->sendRequest($request);
|
||||
|
||||
return new FacebookBatchResponse($request, $facebookResponse);
|
||||
}
|
||||
}
|
||||
536
website/queries/Facebook/FacebookRequest.php
Normal file
536
website/queries/Facebook/FacebookRequest.php
Normal file
@@ -0,0 +1,536 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook;
|
||||
|
||||
use Facebook\Authentication\AccessToken;
|
||||
use Facebook\Url\FacebookUrlManipulator;
|
||||
use Facebook\FileUpload\FacebookFile;
|
||||
use Facebook\FileUpload\FacebookVideo;
|
||||
use Facebook\Http\RequestBodyMultipart;
|
||||
use Facebook\Http\RequestBodyUrlEncoded;
|
||||
use Facebook\Exceptions\FacebookSDKException;
|
||||
|
||||
/**
|
||||
* Class Request
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class FacebookRequest
|
||||
{
|
||||
/**
|
||||
* @var FacebookApp The Facebook app entity.
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* @var string|null The access token to use for this request.
|
||||
*/
|
||||
protected $accessToken;
|
||||
|
||||
/**
|
||||
* @var string The HTTP method for this request.
|
||||
*/
|
||||
protected $method;
|
||||
|
||||
/**
|
||||
* @var string The Graph endpoint for this request.
|
||||
*/
|
||||
protected $endpoint;
|
||||
|
||||
/**
|
||||
* @var array The headers to send with this request.
|
||||
*/
|
||||
protected $headers = [];
|
||||
|
||||
/**
|
||||
* @var array The parameters to send with this request.
|
||||
*/
|
||||
protected $params = [];
|
||||
|
||||
/**
|
||||
* @var array The files to send with this request.
|
||||
*/
|
||||
protected $files = [];
|
||||
|
||||
/**
|
||||
* @var string ETag to send with this request.
|
||||
*/
|
||||
protected $eTag;
|
||||
|
||||
/**
|
||||
* @var string Graph version to use for this request.
|
||||
*/
|
||||
protected $graphVersion;
|
||||
|
||||
/**
|
||||
* Creates a new Request entity.
|
||||
*
|
||||
* @param FacebookApp|null $app
|
||||
* @param AccessToken|string|null $accessToken
|
||||
* @param string|null $method
|
||||
* @param string|null $endpoint
|
||||
* @param array|null $params
|
||||
* @param string|null $eTag
|
||||
* @param string|null $graphVersion
|
||||
*/
|
||||
public function __construct(FacebookApp $app = null, $accessToken = null, $method = null, $endpoint = null, array $params = [], $eTag = null, $graphVersion = null)
|
||||
{
|
||||
$this->setApp($app);
|
||||
$this->setAccessToken($accessToken);
|
||||
$this->setMethod($method);
|
||||
$this->setEndpoint($endpoint);
|
||||
$this->setParams($params);
|
||||
$this->setETag($eTag);
|
||||
$this->graphVersion = $graphVersion ?: Facebook::DEFAULT_GRAPH_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the access token for this request.
|
||||
*
|
||||
* @param AccessToken|string
|
||||
*
|
||||
* @return FacebookRequest
|
||||
*/
|
||||
public function setAccessToken($accessToken)
|
||||
{
|
||||
$this->accessToken = $accessToken;
|
||||
if ($accessToken instanceof AccessToken) {
|
||||
$this->accessToken = $accessToken->getValue();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the access token with one harvested from a URL or POST params.
|
||||
*
|
||||
* @param string $accessToken The access token.
|
||||
*
|
||||
* @return FacebookRequest
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function setAccessTokenFromParams($accessToken)
|
||||
{
|
||||
$existingAccessToken = $this->getAccessToken();
|
||||
if (!$existingAccessToken) {
|
||||
$this->setAccessToken($accessToken);
|
||||
} elseif ($accessToken !== $existingAccessToken) {
|
||||
throw new FacebookSDKException('Access token mismatch. The access token provided in the FacebookRequest and the one provided in the URL or POST params do not match.');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the access token for this request.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAccessToken()
|
||||
{
|
||||
return $this->accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the access token for this request an an AccessToken entity.
|
||||
*
|
||||
* @return AccessToken|null
|
||||
*/
|
||||
public function getAccessTokenEntity()
|
||||
{
|
||||
return $this->accessToken ? new AccessToken($this->accessToken) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the FacebookApp entity used for this request.
|
||||
*
|
||||
* @param FacebookApp|null $app
|
||||
*/
|
||||
public function setApp(FacebookApp $app = null)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the FacebookApp entity used for this request.
|
||||
*
|
||||
* @return FacebookApp
|
||||
*/
|
||||
public function getApp()
|
||||
{
|
||||
return $this->app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an app secret proof to sign this request.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAppSecretProof()
|
||||
{
|
||||
if (!$accessTokenEntity = $this->getAccessTokenEntity()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $accessTokenEntity->getAppSecretProof($this->app->getSecret());
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that an access token exists for this request.
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function validateAccessToken()
|
||||
{
|
||||
$accessToken = $this->getAccessToken();
|
||||
if (!$accessToken) {
|
||||
throw new FacebookSDKException('You must provide an access token.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the HTTP method for this request.
|
||||
*
|
||||
* @param string
|
||||
*
|
||||
* @return FacebookRequest
|
||||
*/
|
||||
public function setMethod($method)
|
||||
{
|
||||
$this->method = strtoupper($method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the HTTP method for this request.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return $this->method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that the HTTP method is set.
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function validateMethod()
|
||||
{
|
||||
if (!$this->method) {
|
||||
throw new FacebookSDKException('HTTP method not specified.');
|
||||
}
|
||||
|
||||
if (!in_array($this->method, ['GET', 'POST', 'DELETE'])) {
|
||||
throw new FacebookSDKException('Invalid HTTP method specified.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the endpoint for this request.
|
||||
*
|
||||
* @param string
|
||||
*
|
||||
* @return FacebookRequest
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function setEndpoint($endpoint)
|
||||
{
|
||||
// Harvest the access token from the endpoint to keep things in sync
|
||||
$params = FacebookUrlManipulator::getParamsAsArray($endpoint);
|
||||
if (isset($params['access_token'])) {
|
||||
$this->setAccessTokenFromParams($params['access_token']);
|
||||
}
|
||||
|
||||
// Clean the token & app secret proof from the endpoint.
|
||||
$filterParams = ['access_token', 'appsecret_proof'];
|
||||
$this->endpoint = FacebookUrlManipulator::removeParamsFromUrl($endpoint, $filterParams);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the HTTP method for this request.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEndpoint()
|
||||
{
|
||||
// For batch requests, this will be empty
|
||||
return $this->endpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate and return the headers for this request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getHeaders()
|
||||
{
|
||||
$headers = static::getDefaultHeaders();
|
||||
|
||||
if ($this->eTag) {
|
||||
$headers['If-None-Match'] = $this->eTag;
|
||||
}
|
||||
|
||||
return array_merge($this->headers, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the headers for this request.
|
||||
*
|
||||
* @param array $headers
|
||||
*/
|
||||
public function setHeaders(array $headers)
|
||||
{
|
||||
$this->headers = array_merge($this->headers, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the eTag value.
|
||||
*
|
||||
* @param string $eTag
|
||||
*/
|
||||
public function setETag($eTag)
|
||||
{
|
||||
$this->eTag = $eTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the params for this request.
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return FacebookRequest
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function setParams(array $params = [])
|
||||
{
|
||||
if (isset($params['access_token'])) {
|
||||
$this->setAccessTokenFromParams($params['access_token']);
|
||||
}
|
||||
|
||||
// Don't let these buggers slip in.
|
||||
unset($params['access_token'], $params['appsecret_proof']);
|
||||
|
||||
// @TODO Refactor code above with this
|
||||
//$params = $this->sanitizeAuthenticationParams($params);
|
||||
$params = $this->sanitizeFileParams($params);
|
||||
$this->dangerouslySetParams($params);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the params for this request without filtering them first.
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return FacebookRequest
|
||||
*/
|
||||
public function dangerouslySetParams(array $params = [])
|
||||
{
|
||||
$this->params = array_merge($this->params, $params);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate over the params and pull out the file uploads.
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sanitizeFileParams(array $params)
|
||||
{
|
||||
foreach ($params as $key => $value) {
|
||||
if ($value instanceof FacebookFile) {
|
||||
$this->addFile($key, $value);
|
||||
unset($params[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a file to be uploaded.
|
||||
*
|
||||
* @param string $key
|
||||
* @param FacebookFile $file
|
||||
*/
|
||||
public function addFile($key, FacebookFile $file)
|
||||
{
|
||||
$this->files[$key] = $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all the files from the upload queue.
|
||||
*/
|
||||
public function resetFiles()
|
||||
{
|
||||
$this->files = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of files to be uploaded.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFiles()
|
||||
{
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Let's us know if there is a file upload with this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function containsFileUploads()
|
||||
{
|
||||
return !empty($this->files);
|
||||
}
|
||||
|
||||
/**
|
||||
* Let's us know if there is a video upload with this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function containsVideoUploads()
|
||||
{
|
||||
foreach ($this->files as $file) {
|
||||
if ($file instanceof FacebookVideo) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the body of the request as multipart/form-data.
|
||||
*
|
||||
* @return RequestBodyMultipart
|
||||
*/
|
||||
public function getMultipartBody()
|
||||
{
|
||||
$params = $this->getPostParams();
|
||||
|
||||
return new RequestBodyMultipart($params, $this->files);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the body of the request as URL-encoded.
|
||||
*
|
||||
* @return RequestBodyUrlEncoded
|
||||
*/
|
||||
public function getUrlEncodedBody()
|
||||
{
|
||||
$params = $this->getPostParams();
|
||||
|
||||
return new RequestBodyUrlEncoded($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate and return the params for this request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getParams()
|
||||
{
|
||||
$params = $this->params;
|
||||
|
||||
$accessToken = $this->getAccessToken();
|
||||
if ($accessToken) {
|
||||
$params['access_token'] = $accessToken;
|
||||
$params['appsecret_proof'] = $this->getAppSecretProof();
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only return params on POST requests.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPostParams()
|
||||
{
|
||||
if ($this->getMethod() === 'POST') {
|
||||
return $this->getParams();
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* The graph version used for this request.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getGraphVersion()
|
||||
{
|
||||
return $this->graphVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate and return the URL for this request.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
$this->validateMethod();
|
||||
|
||||
$graphVersion = FacebookUrlManipulator::forceSlashPrefix($this->graphVersion);
|
||||
$endpoint = FacebookUrlManipulator::forceSlashPrefix($this->getEndpoint());
|
||||
|
||||
$url = $graphVersion . $endpoint;
|
||||
|
||||
if ($this->getMethod() !== 'POST') {
|
||||
$params = $this->getParams();
|
||||
$url = FacebookUrlManipulator::appendParamsToUrl($url, $params);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default headers that every request should use.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getDefaultHeaders()
|
||||
{
|
||||
return [
|
||||
'User-Agent' => 'fb-php-' . Facebook::VERSION,
|
||||
'Accept-Encoding' => '*',
|
||||
];
|
||||
}
|
||||
}
|
||||
410
website/queries/Facebook/FacebookResponse.php
Normal file
410
website/queries/Facebook/FacebookResponse.php
Normal file
@@ -0,0 +1,410 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook;
|
||||
|
||||
use Facebook\GraphNodes\GraphNodeFactory;
|
||||
use Facebook\Exceptions\FacebookResponseException;
|
||||
use Facebook\Exceptions\FacebookSDKException;
|
||||
|
||||
/**
|
||||
* Class FacebookResponse
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class FacebookResponse
|
||||
{
|
||||
/**
|
||||
* @var int The HTTP status code response from Graph.
|
||||
*/
|
||||
protected $httpStatusCode;
|
||||
|
||||
/**
|
||||
* @var array The headers returned from Graph.
|
||||
*/
|
||||
protected $headers;
|
||||
|
||||
/**
|
||||
* @var string The raw body of the response from Graph.
|
||||
*/
|
||||
protected $body;
|
||||
|
||||
/**
|
||||
* @var array The decoded body of the Graph response.
|
||||
*/
|
||||
protected $decodedBody = [];
|
||||
|
||||
/**
|
||||
* @var FacebookRequest The original request that returned this response.
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* @var FacebookSDKException The exception thrown by this request.
|
||||
*/
|
||||
protected $thrownException;
|
||||
|
||||
/**
|
||||
* Creates a new Response entity.
|
||||
*
|
||||
* @param FacebookRequest $request
|
||||
* @param string|null $body
|
||||
* @param int|null $httpStatusCode
|
||||
* @param array|null $headers
|
||||
*/
|
||||
public function __construct(FacebookRequest $request, $body = null, $httpStatusCode = null, array $headers = [])
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->body = $body;
|
||||
$this->httpStatusCode = $httpStatusCode;
|
||||
$this->headers = $headers;
|
||||
|
||||
$this->decodeBody();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original request that returned this response.
|
||||
*
|
||||
* @return FacebookRequest
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the FacebookApp entity used for this response.
|
||||
*
|
||||
* @return FacebookApp
|
||||
*/
|
||||
public function getApp()
|
||||
{
|
||||
return $this->request->getApp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the access token that was used for this response.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAccessToken()
|
||||
{
|
||||
return $this->request->getAccessToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the HTTP status code for this response.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHttpStatusCode()
|
||||
{
|
||||
return $this->httpStatusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the HTTP headers for this response.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getHeaders()
|
||||
{
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the raw body response.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBody()
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the decoded body response.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDecodedBody()
|
||||
{
|
||||
return $this->decodedBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the app secret proof that was used for this response.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAppSecretProof()
|
||||
{
|
||||
return $this->request->getAppSecretProof();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ETag associated with the response.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getETag()
|
||||
{
|
||||
return isset($this->headers['ETag']) ? $this->headers['ETag'] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the version of Graph that returned this response.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getGraphVersion()
|
||||
{
|
||||
return isset($this->headers['Facebook-API-Version']) ? $this->headers['Facebook-API-Version'] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if Graph returned an error message.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isError()
|
||||
{
|
||||
return isset($this->decodedBody['error']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws the exception.
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function throwException()
|
||||
{
|
||||
throw $this->thrownException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates an exception to be thrown later.
|
||||
*/
|
||||
public function makeException()
|
||||
{
|
||||
$this->thrownException = FacebookResponseException::create($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exception that was thrown for this request.
|
||||
*
|
||||
* @return FacebookSDKException|null
|
||||
*/
|
||||
public function getThrownException()
|
||||
{
|
||||
return $this->thrownException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the raw response into an array if possible.
|
||||
*
|
||||
* Graph will return 2 types of responses:
|
||||
* - JSON(P)
|
||||
* Most responses from Grpah are JSON(P)
|
||||
* - application/x-www-form-urlencoded key/value pairs
|
||||
* Happens on the `/oauth/access_token` endpoint when exchanging
|
||||
* a short-lived access token for a long-lived access token
|
||||
* - And sometimes nothing :/ but that'd be a bug.
|
||||
*/
|
||||
public function decodeBody()
|
||||
{
|
||||
$this->decodedBody = json_decode($this->body, true);
|
||||
|
||||
if ($this->decodedBody === null) {
|
||||
$this->decodedBody = [];
|
||||
parse_str($this->body, $this->decodedBody);
|
||||
} elseif (is_bool($this->decodedBody)) {
|
||||
// Backwards compatibility for Graph < 2.1.
|
||||
// Mimics 2.1 responses.
|
||||
// @TODO Remove this after Graph 2.0 is no longer supported
|
||||
$this->decodedBody = ['success' => $this->decodedBody];
|
||||
} elseif (is_numeric($this->decodedBody)) {
|
||||
$this->decodedBody = ['id' => $this->decodedBody];
|
||||
}
|
||||
|
||||
if (!is_array($this->decodedBody)) {
|
||||
$this->decodedBody = [];
|
||||
}
|
||||
|
||||
if ($this->isError()) {
|
||||
$this->makeException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a new GraphObject from response.
|
||||
*
|
||||
* @param string|null $subclassName The GraphNode sub class to cast to.
|
||||
*
|
||||
* @return \Facebook\GraphNodes\GraphObject
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*
|
||||
* @deprecated 5.0.0 getGraphObject() has been renamed to getGraphNode()
|
||||
* @todo v6: Remove this method
|
||||
*/
|
||||
public function getGraphObject($subclassName = null)
|
||||
{
|
||||
return $this->getGraphNode($subclassName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a new GraphNode from response.
|
||||
*
|
||||
* @param string|null $subclassName The GraphNode sub class to cast to.
|
||||
*
|
||||
* @return \Facebook\GraphNodes\GraphNode
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function getGraphNode($subclassName = null)
|
||||
{
|
||||
$factory = new GraphNodeFactory($this);
|
||||
|
||||
return $factory->makeGraphNode($subclassName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for creating a GraphAlbum collection.
|
||||
*
|
||||
* @return \Facebook\GraphNodes\GraphAlbum
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function getGraphAlbum()
|
||||
{
|
||||
$factory = new GraphNodeFactory($this);
|
||||
|
||||
return $factory->makeGraphAlbum();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for creating a GraphPage collection.
|
||||
*
|
||||
* @return \Facebook\GraphNodes\GraphPage
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function getGraphPage()
|
||||
{
|
||||
$factory = new GraphNodeFactory($this);
|
||||
|
||||
return $factory->makeGraphPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for creating a GraphSessionInfo collection.
|
||||
*
|
||||
* @return \Facebook\GraphNodes\GraphSessionInfo
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function getGraphSessionInfo()
|
||||
{
|
||||
$factory = new GraphNodeFactory($this);
|
||||
|
||||
return $factory->makeGraphSessionInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for creating a GraphUser collection.
|
||||
*
|
||||
* @return \Facebook\GraphNodes\GraphUser
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function getGraphUser()
|
||||
{
|
||||
$factory = new GraphNodeFactory($this);
|
||||
|
||||
return $factory->makeGraphUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for creating a GraphEvent collection.
|
||||
*
|
||||
* @return \Facebook\GraphNodes\GraphEvent
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function getGraphEvent()
|
||||
{
|
||||
$factory = new GraphNodeFactory($this);
|
||||
|
||||
return $factory->makeGraphEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for creating a GraphGroup collection.
|
||||
*
|
||||
* @return \Facebook\GraphNodes\GraphGroup
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function getGraphGroup()
|
||||
{
|
||||
$factory = new GraphNodeFactory($this);
|
||||
|
||||
return $factory->makeGraphGroup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a new GraphList from response.
|
||||
*
|
||||
* @param string|null $subclassName The GraphNode sub class to cast list items to.
|
||||
* @param boolean $auto_prefix Toggle to auto-prefix the subclass name.
|
||||
*
|
||||
* @return \Facebook\GraphNodes\GraphList
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*
|
||||
* @deprecated 5.0.0 getGraphList() has been renamed to getGraphEdge()
|
||||
* @todo v6: Remove this method
|
||||
*/
|
||||
public function getGraphList($subclassName = null, $auto_prefix = true)
|
||||
{
|
||||
return $this->getGraphEdge($subclassName, $auto_prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a new GraphEdge from response.
|
||||
*
|
||||
* @param string|null $subclassName The GraphNode sub class to cast list items to.
|
||||
* @param boolean $auto_prefix Toggle to auto-prefix the subclass name.
|
||||
*
|
||||
* @return \Facebook\GraphNodes\GraphEdge
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function getGraphEdge($subclassName = null, $auto_prefix = true)
|
||||
{
|
||||
$factory = new GraphNodeFactory($this);
|
||||
|
||||
return $factory->makeGraphEdge($subclassName, $auto_prefix);
|
||||
}
|
||||
}
|
||||
135
website/queries/Facebook/FileUpload/FacebookFile.php
Normal file
135
website/queries/Facebook/FileUpload/FacebookFile.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\FileUpload;
|
||||
|
||||
use Facebook\Exceptions\FacebookSDKException;
|
||||
|
||||
/**
|
||||
* Class FacebookFile
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class FacebookFile
|
||||
{
|
||||
/**
|
||||
* @var string The path to the file on the system.
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* @var resource The stream pointing to the file.
|
||||
*/
|
||||
protected $stream;
|
||||
|
||||
/**
|
||||
* Creates a new FacebookFile entity.
|
||||
*
|
||||
* @param string $filePath
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function __construct($filePath)
|
||||
{
|
||||
$this->path = $filePath;
|
||||
$this->open();
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the stream when destructed.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$this->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a stream for the file.
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function open()
|
||||
{
|
||||
if (!$this->isRemoteFile($this->path) && !is_readable($this->path)) {
|
||||
throw new FacebookSDKException('Failed to create FacebookFile entity. Unable to read resource: ' . $this->path . '.');
|
||||
}
|
||||
|
||||
$this->stream = fopen($this->path, 'r');
|
||||
|
||||
if (!$this->stream) {
|
||||
throw new FacebookSDKException('Failed to create FacebookFile entity. Unable to open resource: ' . $this->path . '.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the file stream.
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
if (is_resource($this->stream)) {
|
||||
fclose($this->stream);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the contents of the file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContents()
|
||||
{
|
||||
return stream_get_contents($this->stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFileName()
|
||||
{
|
||||
return basename($this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the mimetype of the file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMimetype()
|
||||
{
|
||||
return Mimetypes::getInstance()->fromFilename($this->path) ?: 'text/plain';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the path to the file is remote.
|
||||
*
|
||||
* @param string $pathToFile
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function isRemoteFile($pathToFile)
|
||||
{
|
||||
return preg_match('/^(https?|ftp):\/\/.*/', $pathToFile) === 1;
|
||||
}
|
||||
}
|
||||
33
website/queries/Facebook/FileUpload/FacebookVideo.php
Normal file
33
website/queries/Facebook/FileUpload/FacebookVideo.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\FileUpload;
|
||||
|
||||
/**
|
||||
* Class FacebookVideo
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class FacebookVideo extends FacebookFile
|
||||
{
|
||||
}
|
||||
987
website/queries/Facebook/FileUpload/Mimetypes.php
Normal file
987
website/queries/Facebook/FileUpload/Mimetypes.php
Normal file
@@ -0,0 +1,987 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\FileUpload;
|
||||
|
||||
/**
|
||||
* Provides mappings of file extensions to mimetypes
|
||||
*
|
||||
* Taken from Guzzle
|
||||
*
|
||||
* @see https://github.com/guzzle/guzzle/blob/master/src/Mimetypes.php
|
||||
*
|
||||
* @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types
|
||||
*/
|
||||
class Mimetypes
|
||||
{
|
||||
/** @var self */
|
||||
protected static $instance;
|
||||
|
||||
/** @var array Mapping of extension to mimetype */
|
||||
protected $mimetypes = [
|
||||
'3dml' => 'text/vnd.in3d.3dml',
|
||||
'3g2' => 'video/3gpp2',
|
||||
'3gp' => 'video/3gpp',
|
||||
'7z' => 'application/x-7z-compressed',
|
||||
'aab' => 'application/x-authorware-bin',
|
||||
'aac' => 'audio/x-aac',
|
||||
'aam' => 'application/x-authorware-map',
|
||||
'aas' => 'application/x-authorware-seg',
|
||||
'abw' => 'application/x-abiword',
|
||||
'ac' => 'application/pkix-attr-cert',
|
||||
'acc' => 'application/vnd.americandynamics.acc',
|
||||
'ace' => 'application/x-ace-compressed',
|
||||
'acu' => 'application/vnd.acucobol',
|
||||
'acutc' => 'application/vnd.acucorp',
|
||||
'adp' => 'audio/adpcm',
|
||||
'aep' => 'application/vnd.audiograph',
|
||||
'afm' => 'application/x-font-type1',
|
||||
'afp' => 'application/vnd.ibm.modcap',
|
||||
'ahead' => 'application/vnd.ahead.space',
|
||||
'ai' => 'application/postscript',
|
||||
'aif' => 'audio/x-aiff',
|
||||
'aifc' => 'audio/x-aiff',
|
||||
'aiff' => 'audio/x-aiff',
|
||||
'air' => 'application/vnd.adobe.air-application-installer-package+zip',
|
||||
'ait' => 'application/vnd.dvb.ait',
|
||||
'ami' => 'application/vnd.amiga.ami',
|
||||
'apk' => 'application/vnd.android.package-archive',
|
||||
'application' => 'application/x-ms-application',
|
||||
'apr' => 'application/vnd.lotus-approach',
|
||||
'asa' => 'text/plain',
|
||||
'asax' => 'application/octet-stream',
|
||||
'asc' => 'application/pgp-signature',
|
||||
'ascx' => 'text/plain',
|
||||
'asf' => 'video/x-ms-asf',
|
||||
'ashx' => 'text/plain',
|
||||
'asm' => 'text/x-asm',
|
||||
'asmx' => 'text/plain',
|
||||
'aso' => 'application/vnd.accpac.simply.aso',
|
||||
'asp' => 'text/plain',
|
||||
'aspx' => 'text/plain',
|
||||
'asx' => 'video/x-ms-asf',
|
||||
'atc' => 'application/vnd.acucorp',
|
||||
'atom' => 'application/atom+xml',
|
||||
'atomcat' => 'application/atomcat+xml',
|
||||
'atomsvc' => 'application/atomsvc+xml',
|
||||
'atx' => 'application/vnd.antix.game-component',
|
||||
'au' => 'audio/basic',
|
||||
'avi' => 'video/x-msvideo',
|
||||
'aw' => 'application/applixware',
|
||||
'axd' => 'text/plain',
|
||||
'azf' => 'application/vnd.airzip.filesecure.azf',
|
||||
'azs' => 'application/vnd.airzip.filesecure.azs',
|
||||
'azw' => 'application/vnd.amazon.ebook',
|
||||
'bat' => 'application/x-msdownload',
|
||||
'bcpio' => 'application/x-bcpio',
|
||||
'bdf' => 'application/x-font-bdf',
|
||||
'bdm' => 'application/vnd.syncml.dm+wbxml',
|
||||
'bed' => 'application/vnd.realvnc.bed',
|
||||
'bh2' => 'application/vnd.fujitsu.oasysprs',
|
||||
'bin' => 'application/octet-stream',
|
||||
'bmi' => 'application/vnd.bmi',
|
||||
'bmp' => 'image/bmp',
|
||||
'book' => 'application/vnd.framemaker',
|
||||
'box' => 'application/vnd.previewsystems.box',
|
||||
'boz' => 'application/x-bzip2',
|
||||
'bpk' => 'application/octet-stream',
|
||||
'btif' => 'image/prs.btif',
|
||||
'bz' => 'application/x-bzip',
|
||||
'bz2' => 'application/x-bzip2',
|
||||
'c' => 'text/x-c',
|
||||
'c11amc' => 'application/vnd.cluetrust.cartomobile-config',
|
||||
'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg',
|
||||
'c4d' => 'application/vnd.clonk.c4group',
|
||||
'c4f' => 'application/vnd.clonk.c4group',
|
||||
'c4g' => 'application/vnd.clonk.c4group',
|
||||
'c4p' => 'application/vnd.clonk.c4group',
|
||||
'c4u' => 'application/vnd.clonk.c4group',
|
||||
'cab' => 'application/vnd.ms-cab-compressed',
|
||||
'car' => 'application/vnd.curl.car',
|
||||
'cat' => 'application/vnd.ms-pki.seccat',
|
||||
'cc' => 'text/x-c',
|
||||
'cct' => 'application/x-director',
|
||||
'ccxml' => 'application/ccxml+xml',
|
||||
'cdbcmsg' => 'application/vnd.contact.cmsg',
|
||||
'cdf' => 'application/x-netcdf',
|
||||
'cdkey' => 'application/vnd.mediastation.cdkey',
|
||||
'cdmia' => 'application/cdmi-capability',
|
||||
'cdmic' => 'application/cdmi-container',
|
||||
'cdmid' => 'application/cdmi-domain',
|
||||
'cdmio' => 'application/cdmi-object',
|
||||
'cdmiq' => 'application/cdmi-queue',
|
||||
'cdx' => 'chemical/x-cdx',
|
||||
'cdxml' => 'application/vnd.chemdraw+xml',
|
||||
'cdy' => 'application/vnd.cinderella',
|
||||
'cer' => 'application/pkix-cert',
|
||||
'cfc' => 'application/x-coldfusion',
|
||||
'cfm' => 'application/x-coldfusion',
|
||||
'cgm' => 'image/cgm',
|
||||
'chat' => 'application/x-chat',
|
||||
'chm' => 'application/vnd.ms-htmlhelp',
|
||||
'chrt' => 'application/vnd.kde.kchart',
|
||||
'cif' => 'chemical/x-cif',
|
||||
'cii' => 'application/vnd.anser-web-certificate-issue-initiation',
|
||||
'cil' => 'application/vnd.ms-artgalry',
|
||||
'cla' => 'application/vnd.claymore',
|
||||
'class' => 'application/java-vm',
|
||||
'clkk' => 'application/vnd.crick.clicker.keyboard',
|
||||
'clkp' => 'application/vnd.crick.clicker.palette',
|
||||
'clkt' => 'application/vnd.crick.clicker.template',
|
||||
'clkw' => 'application/vnd.crick.clicker.wordbank',
|
||||
'clkx' => 'application/vnd.crick.clicker',
|
||||
'clp' => 'application/x-msclip',
|
||||
'cmc' => 'application/vnd.cosmocaller',
|
||||
'cmdf' => 'chemical/x-cmdf',
|
||||
'cml' => 'chemical/x-cml',
|
||||
'cmp' => 'application/vnd.yellowriver-custom-menu',
|
||||
'cmx' => 'image/x-cmx',
|
||||
'cod' => 'application/vnd.rim.cod',
|
||||
'com' => 'application/x-msdownload',
|
||||
'conf' => 'text/plain',
|
||||
'cpio' => 'application/x-cpio',
|
||||
'cpp' => 'text/x-c',
|
||||
'cpt' => 'application/mac-compactpro',
|
||||
'crd' => 'application/x-mscardfile',
|
||||
'crl' => 'application/pkix-crl',
|
||||
'crt' => 'application/x-x509-ca-cert',
|
||||
'cryptonote' => 'application/vnd.rig.cryptonote',
|
||||
'cs' => 'text/plain',
|
||||
'csh' => 'application/x-csh',
|
||||
'csml' => 'chemical/x-csml',
|
||||
'csp' => 'application/vnd.commonspace',
|
||||
'css' => 'text/css',
|
||||
'cst' => 'application/x-director',
|
||||
'csv' => 'text/csv',
|
||||
'cu' => 'application/cu-seeme',
|
||||
'curl' => 'text/vnd.curl',
|
||||
'cww' => 'application/prs.cww',
|
||||
'cxt' => 'application/x-director',
|
||||
'cxx' => 'text/x-c',
|
||||
'dae' => 'model/vnd.collada+xml',
|
||||
'daf' => 'application/vnd.mobius.daf',
|
||||
'dataless' => 'application/vnd.fdsn.seed',
|
||||
'davmount' => 'application/davmount+xml',
|
||||
'dcr' => 'application/x-director',
|
||||
'dcurl' => 'text/vnd.curl.dcurl',
|
||||
'dd2' => 'application/vnd.oma.dd2+xml',
|
||||
'ddd' => 'application/vnd.fujixerox.ddd',
|
||||
'deb' => 'application/x-debian-package',
|
||||
'def' => 'text/plain',
|
||||
'deploy' => 'application/octet-stream',
|
||||
'der' => 'application/x-x509-ca-cert',
|
||||
'dfac' => 'application/vnd.dreamfactory',
|
||||
'dic' => 'text/x-c',
|
||||
'dir' => 'application/x-director',
|
||||
'dis' => 'application/vnd.mobius.dis',
|
||||
'dist' => 'application/octet-stream',
|
||||
'distz' => 'application/octet-stream',
|
||||
'djv' => 'image/vnd.djvu',
|
||||
'djvu' => 'image/vnd.djvu',
|
||||
'dll' => 'application/x-msdownload',
|
||||
'dmg' => 'application/octet-stream',
|
||||
'dms' => 'application/octet-stream',
|
||||
'dna' => 'application/vnd.dna',
|
||||
'doc' => 'application/msword',
|
||||
'docm' => 'application/vnd.ms-word.document.macroenabled.12',
|
||||
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'dot' => 'application/msword',
|
||||
'dotm' => 'application/vnd.ms-word.template.macroenabled.12',
|
||||
'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
|
||||
'dp' => 'application/vnd.osgi.dp',
|
||||
'dpg' => 'application/vnd.dpgraph',
|
||||
'dra' => 'audio/vnd.dra',
|
||||
'dsc' => 'text/prs.lines.tag',
|
||||
'dssc' => 'application/dssc+der',
|
||||
'dtb' => 'application/x-dtbook+xml',
|
||||
'dtd' => 'application/xml-dtd',
|
||||
'dts' => 'audio/vnd.dts',
|
||||
'dtshd' => 'audio/vnd.dts.hd',
|
||||
'dump' => 'application/octet-stream',
|
||||
'dvi' => 'application/x-dvi',
|
||||
'dwf' => 'model/vnd.dwf',
|
||||
'dwg' => 'image/vnd.dwg',
|
||||
'dxf' => 'image/vnd.dxf',
|
||||
'dxp' => 'application/vnd.spotfire.dxp',
|
||||
'dxr' => 'application/x-director',
|
||||
'ecelp4800' => 'audio/vnd.nuera.ecelp4800',
|
||||
'ecelp7470' => 'audio/vnd.nuera.ecelp7470',
|
||||
'ecelp9600' => 'audio/vnd.nuera.ecelp9600',
|
||||
'ecma' => 'application/ecmascript',
|
||||
'edm' => 'application/vnd.novadigm.edm',
|
||||
'edx' => 'application/vnd.novadigm.edx',
|
||||
'efif' => 'application/vnd.picsel',
|
||||
'ei6' => 'application/vnd.pg.osasli',
|
||||
'elc' => 'application/octet-stream',
|
||||
'eml' => 'message/rfc822',
|
||||
'emma' => 'application/emma+xml',
|
||||
'eol' => 'audio/vnd.digital-winds',
|
||||
'eot' => 'application/vnd.ms-fontobject',
|
||||
'eps' => 'application/postscript',
|
||||
'epub' => 'application/epub+zip',
|
||||
'es3' => 'application/vnd.eszigno3+xml',
|
||||
'esf' => 'application/vnd.epson.esf',
|
||||
'et3' => 'application/vnd.eszigno3+xml',
|
||||
'etx' => 'text/x-setext',
|
||||
'exe' => 'application/x-msdownload',
|
||||
'exi' => 'application/exi',
|
||||
'ext' => 'application/vnd.novadigm.ext',
|
||||
'ez' => 'application/andrew-inset',
|
||||
'ez2' => 'application/vnd.ezpix-album',
|
||||
'ez3' => 'application/vnd.ezpix-package',
|
||||
'f' => 'text/x-fortran',
|
||||
'f4v' => 'video/x-f4v',
|
||||
'f77' => 'text/x-fortran',
|
||||
'f90' => 'text/x-fortran',
|
||||
'fbs' => 'image/vnd.fastbidsheet',
|
||||
'fcs' => 'application/vnd.isac.fcs',
|
||||
'fdf' => 'application/vnd.fdf',
|
||||
'fe_launch' => 'application/vnd.denovo.fcselayout-link',
|
||||
'fg5' => 'application/vnd.fujitsu.oasysgp',
|
||||
'fgd' => 'application/x-director',
|
||||
'fh' => 'image/x-freehand',
|
||||
'fh4' => 'image/x-freehand',
|
||||
'fh5' => 'image/x-freehand',
|
||||
'fh7' => 'image/x-freehand',
|
||||
'fhc' => 'image/x-freehand',
|
||||
'fig' => 'application/x-xfig',
|
||||
'fli' => 'video/x-fli',
|
||||
'flo' => 'application/vnd.micrografx.flo',
|
||||
'flv' => 'video/x-flv',
|
||||
'flw' => 'application/vnd.kde.kivio',
|
||||
'flx' => 'text/vnd.fmi.flexstor',
|
||||
'fly' => 'text/vnd.fly',
|
||||
'fm' => 'application/vnd.framemaker',
|
||||
'fnc' => 'application/vnd.frogans.fnc',
|
||||
'for' => 'text/x-fortran',
|
||||
'fpx' => 'image/vnd.fpx',
|
||||
'frame' => 'application/vnd.framemaker',
|
||||
'fsc' => 'application/vnd.fsc.weblaunch',
|
||||
'fst' => 'image/vnd.fst',
|
||||
'ftc' => 'application/vnd.fluxtime.clip',
|
||||
'fti' => 'application/vnd.anser-web-funds-transfer-initiation',
|
||||
'fvt' => 'video/vnd.fvt',
|
||||
'fxp' => 'application/vnd.adobe.fxp',
|
||||
'fxpl' => 'application/vnd.adobe.fxp',
|
||||
'fzs' => 'application/vnd.fuzzysheet',
|
||||
'g2w' => 'application/vnd.geoplan',
|
||||
'g3' => 'image/g3fax',
|
||||
'g3w' => 'application/vnd.geospace',
|
||||
'gac' => 'application/vnd.groove-account',
|
||||
'gdl' => 'model/vnd.gdl',
|
||||
'geo' => 'application/vnd.dynageo',
|
||||
'gex' => 'application/vnd.geometry-explorer',
|
||||
'ggb' => 'application/vnd.geogebra.file',
|
||||
'ggt' => 'application/vnd.geogebra.tool',
|
||||
'ghf' => 'application/vnd.groove-help',
|
||||
'gif' => 'image/gif',
|
||||
'gim' => 'application/vnd.groove-identity-message',
|
||||
'gmx' => 'application/vnd.gmx',
|
||||
'gnumeric' => 'application/x-gnumeric',
|
||||
'gph' => 'application/vnd.flographit',
|
||||
'gqf' => 'application/vnd.grafeq',
|
||||
'gqs' => 'application/vnd.grafeq',
|
||||
'gram' => 'application/srgs',
|
||||
'gre' => 'application/vnd.geometry-explorer',
|
||||
'grv' => 'application/vnd.groove-injector',
|
||||
'grxml' => 'application/srgs+xml',
|
||||
'gsf' => 'application/x-font-ghostscript',
|
||||
'gtar' => 'application/x-gtar',
|
||||
'gtm' => 'application/vnd.groove-tool-message',
|
||||
'gtw' => 'model/vnd.gtw',
|
||||
'gv' => 'text/vnd.graphviz',
|
||||
'gxt' => 'application/vnd.geonext',
|
||||
'h' => 'text/x-c',
|
||||
'h261' => 'video/h261',
|
||||
'h263' => 'video/h263',
|
||||
'h264' => 'video/h264',
|
||||
'hal' => 'application/vnd.hal+xml',
|
||||
'hbci' => 'application/vnd.hbci',
|
||||
'hdf' => 'application/x-hdf',
|
||||
'hh' => 'text/x-c',
|
||||
'hlp' => 'application/winhlp',
|
||||
'hpgl' => 'application/vnd.hp-hpgl',
|
||||
'hpid' => 'application/vnd.hp-hpid',
|
||||
'hps' => 'application/vnd.hp-hps',
|
||||
'hqx' => 'application/mac-binhex40',
|
||||
'hta' => 'application/octet-stream',
|
||||
'htc' => 'text/html',
|
||||
'htke' => 'application/vnd.kenameaapp',
|
||||
'htm' => 'text/html',
|
||||
'html' => 'text/html',
|
||||
'hvd' => 'application/vnd.yamaha.hv-dic',
|
||||
'hvp' => 'application/vnd.yamaha.hv-voice',
|
||||
'hvs' => 'application/vnd.yamaha.hv-script',
|
||||
'i2g' => 'application/vnd.intergeo',
|
||||
'icc' => 'application/vnd.iccprofile',
|
||||
'ice' => 'x-conference/x-cooltalk',
|
||||
'icm' => 'application/vnd.iccprofile',
|
||||
'ico' => 'image/x-icon',
|
||||
'ics' => 'text/calendar',
|
||||
'ief' => 'image/ief',
|
||||
'ifb' => 'text/calendar',
|
||||
'ifm' => 'application/vnd.shana.informed.formdata',
|
||||
'iges' => 'model/iges',
|
||||
'igl' => 'application/vnd.igloader',
|
||||
'igm' => 'application/vnd.insors.igm',
|
||||
'igs' => 'model/iges',
|
||||
'igx' => 'application/vnd.micrografx.igx',
|
||||
'iif' => 'application/vnd.shana.informed.interchange',
|
||||
'imp' => 'application/vnd.accpac.simply.imp',
|
||||
'ims' => 'application/vnd.ms-ims',
|
||||
'in' => 'text/plain',
|
||||
'ini' => 'text/plain',
|
||||
'ipfix' => 'application/ipfix',
|
||||
'ipk' => 'application/vnd.shana.informed.package',
|
||||
'irm' => 'application/vnd.ibm.rights-management',
|
||||
'irp' => 'application/vnd.irepository.package+xml',
|
||||
'iso' => 'application/octet-stream',
|
||||
'itp' => 'application/vnd.shana.informed.formtemplate',
|
||||
'ivp' => 'application/vnd.immervision-ivp',
|
||||
'ivu' => 'application/vnd.immervision-ivu',
|
||||
'jad' => 'text/vnd.sun.j2me.app-descriptor',
|
||||
'jam' => 'application/vnd.jam',
|
||||
'jar' => 'application/java-archive',
|
||||
'java' => 'text/x-java-source',
|
||||
'jisp' => 'application/vnd.jisp',
|
||||
'jlt' => 'application/vnd.hp-jlyt',
|
||||
'jnlp' => 'application/x-java-jnlp-file',
|
||||
'joda' => 'application/vnd.joost.joda-archive',
|
||||
'jpe' => 'image/jpeg',
|
||||
'jpeg' => 'image/jpeg',
|
||||
'jpg' => 'image/jpeg',
|
||||
'jpgm' => 'video/jpm',
|
||||
'jpgv' => 'video/jpeg',
|
||||
'jpm' => 'video/jpm',
|
||||
'js' => 'text/javascript',
|
||||
'json' => 'application/json',
|
||||
'kar' => 'audio/midi',
|
||||
'karbon' => 'application/vnd.kde.karbon',
|
||||
'kfo' => 'application/vnd.kde.kformula',
|
||||
'kia' => 'application/vnd.kidspiration',
|
||||
'kml' => 'application/vnd.google-earth.kml+xml',
|
||||
'kmz' => 'application/vnd.google-earth.kmz',
|
||||
'kne' => 'application/vnd.kinar',
|
||||
'knp' => 'application/vnd.kinar',
|
||||
'kon' => 'application/vnd.kde.kontour',
|
||||
'kpr' => 'application/vnd.kde.kpresenter',
|
||||
'kpt' => 'application/vnd.kde.kpresenter',
|
||||
'ksp' => 'application/vnd.kde.kspread',
|
||||
'ktr' => 'application/vnd.kahootz',
|
||||
'ktx' => 'image/ktx',
|
||||
'ktz' => 'application/vnd.kahootz',
|
||||
'kwd' => 'application/vnd.kde.kword',
|
||||
'kwt' => 'application/vnd.kde.kword',
|
||||
'lasxml' => 'application/vnd.las.las+xml',
|
||||
'latex' => 'application/x-latex',
|
||||
'lbd' => 'application/vnd.llamagraphics.life-balance.desktop',
|
||||
'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml',
|
||||
'les' => 'application/vnd.hhe.lesson-player',
|
||||
'lha' => 'application/octet-stream',
|
||||
'link66' => 'application/vnd.route66.link66+xml',
|
||||
'list' => 'text/plain',
|
||||
'list3820' => 'application/vnd.ibm.modcap',
|
||||
'listafp' => 'application/vnd.ibm.modcap',
|
||||
'log' => 'text/plain',
|
||||
'lostxml' => 'application/lost+xml',
|
||||
'lrf' => 'application/octet-stream',
|
||||
'lrm' => 'application/vnd.ms-lrm',
|
||||
'ltf' => 'application/vnd.frogans.ltf',
|
||||
'lvp' => 'audio/vnd.lucent.voice',
|
||||
'lwp' => 'application/vnd.lotus-wordpro',
|
||||
'lzh' => 'application/octet-stream',
|
||||
'm13' => 'application/x-msmediaview',
|
||||
'm14' => 'application/x-msmediaview',
|
||||
'm1v' => 'video/mpeg',
|
||||
'm21' => 'application/mp21',
|
||||
'm2a' => 'audio/mpeg',
|
||||
'm2v' => 'video/mpeg',
|
||||
'm3a' => 'audio/mpeg',
|
||||
'm3u' => 'audio/x-mpegurl',
|
||||
'm3u8' => 'application/vnd.apple.mpegurl',
|
||||
'm4a' => 'audio/mp4',
|
||||
'm4u' => 'video/vnd.mpegurl',
|
||||
'm4v' => 'video/mp4',
|
||||
'ma' => 'application/mathematica',
|
||||
'mads' => 'application/mads+xml',
|
||||
'mag' => 'application/vnd.ecowin.chart',
|
||||
'maker' => 'application/vnd.framemaker',
|
||||
'man' => 'text/troff',
|
||||
'mathml' => 'application/mathml+xml',
|
||||
'mb' => 'application/mathematica',
|
||||
'mbk' => 'application/vnd.mobius.mbk',
|
||||
'mbox' => 'application/mbox',
|
||||
'mc1' => 'application/vnd.medcalcdata',
|
||||
'mcd' => 'application/vnd.mcd',
|
||||
'mcurl' => 'text/vnd.curl.mcurl',
|
||||
'mdb' => 'application/x-msaccess',
|
||||
'mdi' => 'image/vnd.ms-modi',
|
||||
'me' => 'text/troff',
|
||||
'mesh' => 'model/mesh',
|
||||
'meta4' => 'application/metalink4+xml',
|
||||
'mets' => 'application/mets+xml',
|
||||
'mfm' => 'application/vnd.mfmp',
|
||||
'mgp' => 'application/vnd.osgeo.mapguide.package',
|
||||
'mgz' => 'application/vnd.proteus.magazine',
|
||||
'mid' => 'audio/midi',
|
||||
'midi' => 'audio/midi',
|
||||
'mif' => 'application/vnd.mif',
|
||||
'mime' => 'message/rfc822',
|
||||
'mj2' => 'video/mj2',
|
||||
'mjp2' => 'video/mj2',
|
||||
'mlp' => 'application/vnd.dolby.mlp',
|
||||
'mmd' => 'application/vnd.chipnuts.karaoke-mmd',
|
||||
'mmf' => 'application/vnd.smaf',
|
||||
'mmr' => 'image/vnd.fujixerox.edmics-mmr',
|
||||
'mny' => 'application/x-msmoney',
|
||||
'mobi' => 'application/x-mobipocket-ebook',
|
||||
'mods' => 'application/mods+xml',
|
||||
'mov' => 'video/quicktime',
|
||||
'movie' => 'video/x-sgi-movie',
|
||||
'mp2' => 'audio/mpeg',
|
||||
'mp21' => 'application/mp21',
|
||||
'mp2a' => 'audio/mpeg',
|
||||
'mp3' => 'audio/mpeg',
|
||||
'mp4' => 'video/mp4',
|
||||
'mp4a' => 'audio/mp4',
|
||||
'mp4s' => 'application/mp4',
|
||||
'mp4v' => 'video/mp4',
|
||||
'mpc' => 'application/vnd.mophun.certificate',
|
||||
'mpe' => 'video/mpeg',
|
||||
'mpeg' => 'video/mpeg',
|
||||
'mpg' => 'video/mpeg',
|
||||
'mpg4' => 'video/mp4',
|
||||
'mpga' => 'audio/mpeg',
|
||||
'mpkg' => 'application/vnd.apple.installer+xml',
|
||||
'mpm' => 'application/vnd.blueice.multipass',
|
||||
'mpn' => 'application/vnd.mophun.application',
|
||||
'mpp' => 'application/vnd.ms-project',
|
||||
'mpt' => 'application/vnd.ms-project',
|
||||
'mpy' => 'application/vnd.ibm.minipay',
|
||||
'mqy' => 'application/vnd.mobius.mqy',
|
||||
'mrc' => 'application/marc',
|
||||
'mrcx' => 'application/marcxml+xml',
|
||||
'ms' => 'text/troff',
|
||||
'mscml' => 'application/mediaservercontrol+xml',
|
||||
'mseed' => 'application/vnd.fdsn.mseed',
|
||||
'mseq' => 'application/vnd.mseq',
|
||||
'msf' => 'application/vnd.epson.msf',
|
||||
'msh' => 'model/mesh',
|
||||
'msi' => 'application/x-msdownload',
|
||||
'msl' => 'application/vnd.mobius.msl',
|
||||
'msty' => 'application/vnd.muvee.style',
|
||||
'mts' => 'model/vnd.mts',
|
||||
'mus' => 'application/vnd.musician',
|
||||
'musicxml' => 'application/vnd.recordare.musicxml+xml',
|
||||
'mvb' => 'application/x-msmediaview',
|
||||
'mwf' => 'application/vnd.mfer',
|
||||
'mxf' => 'application/mxf',
|
||||
'mxl' => 'application/vnd.recordare.musicxml',
|
||||
'mxml' => 'application/xv+xml',
|
||||
'mxs' => 'application/vnd.triscape.mxs',
|
||||
'mxu' => 'video/vnd.mpegurl',
|
||||
'n-gage' => 'application/vnd.nokia.n-gage.symbian.install',
|
||||
'n3' => 'text/n3',
|
||||
'nb' => 'application/mathematica',
|
||||
'nbp' => 'application/vnd.wolfram.player',
|
||||
'nc' => 'application/x-netcdf',
|
||||
'ncx' => 'application/x-dtbncx+xml',
|
||||
'ngdat' => 'application/vnd.nokia.n-gage.data',
|
||||
'nlu' => 'application/vnd.neurolanguage.nlu',
|
||||
'nml' => 'application/vnd.enliven',
|
||||
'nnd' => 'application/vnd.noblenet-directory',
|
||||
'nns' => 'application/vnd.noblenet-sealer',
|
||||
'nnw' => 'application/vnd.noblenet-web',
|
||||
'npx' => 'image/vnd.net-fpx',
|
||||
'nsf' => 'application/vnd.lotus-notes',
|
||||
'oa2' => 'application/vnd.fujitsu.oasys2',
|
||||
'oa3' => 'application/vnd.fujitsu.oasys3',
|
||||
'oas' => 'application/vnd.fujitsu.oasys',
|
||||
'obd' => 'application/x-msbinder',
|
||||
'oda' => 'application/oda',
|
||||
'odb' => 'application/vnd.oasis.opendocument.database',
|
||||
'odc' => 'application/vnd.oasis.opendocument.chart',
|
||||
'odf' => 'application/vnd.oasis.opendocument.formula',
|
||||
'odft' => 'application/vnd.oasis.opendocument.formula-template',
|
||||
'odg' => 'application/vnd.oasis.opendocument.graphics',
|
||||
'odi' => 'application/vnd.oasis.opendocument.image',
|
||||
'odm' => 'application/vnd.oasis.opendocument.text-master',
|
||||
'odp' => 'application/vnd.oasis.opendocument.presentation',
|
||||
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
|
||||
'odt' => 'application/vnd.oasis.opendocument.text',
|
||||
'oga' => 'audio/ogg',
|
||||
'ogg' => 'audio/ogg',
|
||||
'ogv' => 'video/ogg',
|
||||
'ogx' => 'application/ogg',
|
||||
'onepkg' => 'application/onenote',
|
||||
'onetmp' => 'application/onenote',
|
||||
'onetoc' => 'application/onenote',
|
||||
'onetoc2' => 'application/onenote',
|
||||
'opf' => 'application/oebps-package+xml',
|
||||
'oprc' => 'application/vnd.palm',
|
||||
'org' => 'application/vnd.lotus-organizer',
|
||||
'osf' => 'application/vnd.yamaha.openscoreformat',
|
||||
'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml',
|
||||
'otc' => 'application/vnd.oasis.opendocument.chart-template',
|
||||
'otf' => 'application/x-font-otf',
|
||||
'otg' => 'application/vnd.oasis.opendocument.graphics-template',
|
||||
'oth' => 'application/vnd.oasis.opendocument.text-web',
|
||||
'oti' => 'application/vnd.oasis.opendocument.image-template',
|
||||
'otp' => 'application/vnd.oasis.opendocument.presentation-template',
|
||||
'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
|
||||
'ott' => 'application/vnd.oasis.opendocument.text-template',
|
||||
'oxt' => 'application/vnd.openofficeorg.extension',
|
||||
'p' => 'text/x-pascal',
|
||||
'p10' => 'application/pkcs10',
|
||||
'p12' => 'application/x-pkcs12',
|
||||
'p7b' => 'application/x-pkcs7-certificates',
|
||||
'p7c' => 'application/pkcs7-mime',
|
||||
'p7m' => 'application/pkcs7-mime',
|
||||
'p7r' => 'application/x-pkcs7-certreqresp',
|
||||
'p7s' => 'application/pkcs7-signature',
|
||||
'p8' => 'application/pkcs8',
|
||||
'pas' => 'text/x-pascal',
|
||||
'paw' => 'application/vnd.pawaafile',
|
||||
'pbd' => 'application/vnd.powerbuilder6',
|
||||
'pbm' => 'image/x-portable-bitmap',
|
||||
'pcf' => 'application/x-font-pcf',
|
||||
'pcl' => 'application/vnd.hp-pcl',
|
||||
'pclxl' => 'application/vnd.hp-pclxl',
|
||||
'pct' => 'image/x-pict',
|
||||
'pcurl' => 'application/vnd.curl.pcurl',
|
||||
'pcx' => 'image/x-pcx',
|
||||
'pdb' => 'application/vnd.palm',
|
||||
'pdf' => 'application/pdf',
|
||||
'pfa' => 'application/x-font-type1',
|
||||
'pfb' => 'application/x-font-type1',
|
||||
'pfm' => 'application/x-font-type1',
|
||||
'pfr' => 'application/font-tdpfr',
|
||||
'pfx' => 'application/x-pkcs12',
|
||||
'pgm' => 'image/x-portable-graymap',
|
||||
'pgn' => 'application/x-chess-pgn',
|
||||
'pgp' => 'application/pgp-encrypted',
|
||||
'php' => 'text/x-php',
|
||||
'phps' => 'application/x-httpd-phps',
|
||||
'pic' => 'image/x-pict',
|
||||
'pkg' => 'application/octet-stream',
|
||||
'pki' => 'application/pkixcmp',
|
||||
'pkipath' => 'application/pkix-pkipath',
|
||||
'plb' => 'application/vnd.3gpp.pic-bw-large',
|
||||
'plc' => 'application/vnd.mobius.plc',
|
||||
'plf' => 'application/vnd.pocketlearn',
|
||||
'pls' => 'application/pls+xml',
|
||||
'pml' => 'application/vnd.ctc-posml',
|
||||
'png' => 'image/png',
|
||||
'pnm' => 'image/x-portable-anymap',
|
||||
'portpkg' => 'application/vnd.macports.portpkg',
|
||||
'pot' => 'application/vnd.ms-powerpoint',
|
||||
'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12',
|
||||
'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
|
||||
'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12',
|
||||
'ppd' => 'application/vnd.cups-ppd',
|
||||
'ppm' => 'image/x-portable-pixmap',
|
||||
'pps' => 'application/vnd.ms-powerpoint',
|
||||
'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
|
||||
'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
|
||||
'ppt' => 'application/vnd.ms-powerpoint',
|
||||
'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12',
|
||||
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
'pqa' => 'application/vnd.palm',
|
||||
'prc' => 'application/x-mobipocket-ebook',
|
||||
'pre' => 'application/vnd.lotus-freelance',
|
||||
'prf' => 'application/pics-rules',
|
||||
'ps' => 'application/postscript',
|
||||
'psb' => 'application/vnd.3gpp.pic-bw-small',
|
||||
'psd' => 'image/vnd.adobe.photoshop',
|
||||
'psf' => 'application/x-font-linux-psf',
|
||||
'pskcxml' => 'application/pskc+xml',
|
||||
'ptid' => 'application/vnd.pvi.ptid1',
|
||||
'pub' => 'application/x-mspublisher',
|
||||
'pvb' => 'application/vnd.3gpp.pic-bw-var',
|
||||
'pwn' => 'application/vnd.3m.post-it-notes',
|
||||
'pya' => 'audio/vnd.ms-playready.media.pya',
|
||||
'pyv' => 'video/vnd.ms-playready.media.pyv',
|
||||
'qam' => 'application/vnd.epson.quickanime',
|
||||
'qbo' => 'application/vnd.intu.qbo',
|
||||
'qfx' => 'application/vnd.intu.qfx',
|
||||
'qps' => 'application/vnd.publishare-delta-tree',
|
||||
'qt' => 'video/quicktime',
|
||||
'qwd' => 'application/vnd.quark.quarkxpress',
|
||||
'qwt' => 'application/vnd.quark.quarkxpress',
|
||||
'qxb' => 'application/vnd.quark.quarkxpress',
|
||||
'qxd' => 'application/vnd.quark.quarkxpress',
|
||||
'qxl' => 'application/vnd.quark.quarkxpress',
|
||||
'qxt' => 'application/vnd.quark.quarkxpress',
|
||||
'ra' => 'audio/x-pn-realaudio',
|
||||
'ram' => 'audio/x-pn-realaudio',
|
||||
'rar' => 'application/x-rar-compressed',
|
||||
'ras' => 'image/x-cmu-raster',
|
||||
'rb' => 'text/plain',
|
||||
'rcprofile' => 'application/vnd.ipunplugged.rcprofile',
|
||||
'rdf' => 'application/rdf+xml',
|
||||
'rdz' => 'application/vnd.data-vision.rdz',
|
||||
'rep' => 'application/vnd.businessobjects',
|
||||
'res' => 'application/x-dtbresource+xml',
|
||||
'resx' => 'text/xml',
|
||||
'rgb' => 'image/x-rgb',
|
||||
'rif' => 'application/reginfo+xml',
|
||||
'rip' => 'audio/vnd.rip',
|
||||
'rl' => 'application/resource-lists+xml',
|
||||
'rlc' => 'image/vnd.fujixerox.edmics-rlc',
|
||||
'rld' => 'application/resource-lists-diff+xml',
|
||||
'rm' => 'application/vnd.rn-realmedia',
|
||||
'rmi' => 'audio/midi',
|
||||
'rmp' => 'audio/x-pn-realaudio-plugin',
|
||||
'rms' => 'application/vnd.jcp.javame.midlet-rms',
|
||||
'rnc' => 'application/relax-ng-compact-syntax',
|
||||
'roff' => 'text/troff',
|
||||
'rp9' => 'application/vnd.cloanto.rp9',
|
||||
'rpss' => 'application/vnd.nokia.radio-presets',
|
||||
'rpst' => 'application/vnd.nokia.radio-preset',
|
||||
'rq' => 'application/sparql-query',
|
||||
'rs' => 'application/rls-services+xml',
|
||||
'rsd' => 'application/rsd+xml',
|
||||
'rss' => 'application/rss+xml',
|
||||
'rtf' => 'application/rtf',
|
||||
'rtx' => 'text/richtext',
|
||||
's' => 'text/x-asm',
|
||||
'saf' => 'application/vnd.yamaha.smaf-audio',
|
||||
'sbml' => 'application/sbml+xml',
|
||||
'sc' => 'application/vnd.ibm.secure-container',
|
||||
'scd' => 'application/x-msschedule',
|
||||
'scm' => 'application/vnd.lotus-screencam',
|
||||
'scq' => 'application/scvp-cv-request',
|
||||
'scs' => 'application/scvp-cv-response',
|
||||
'scurl' => 'text/vnd.curl.scurl',
|
||||
'sda' => 'application/vnd.stardivision.draw',
|
||||
'sdc' => 'application/vnd.stardivision.calc',
|
||||
'sdd' => 'application/vnd.stardivision.impress',
|
||||
'sdkd' => 'application/vnd.solent.sdkm+xml',
|
||||
'sdkm' => 'application/vnd.solent.sdkm+xml',
|
||||
'sdp' => 'application/sdp',
|
||||
'sdw' => 'application/vnd.stardivision.writer',
|
||||
'see' => 'application/vnd.seemail',
|
||||
'seed' => 'application/vnd.fdsn.seed',
|
||||
'sema' => 'application/vnd.sema',
|
||||
'semd' => 'application/vnd.semd',
|
||||
'semf' => 'application/vnd.semf',
|
||||
'ser' => 'application/java-serialized-object',
|
||||
'setpay' => 'application/set-payment-initiation',
|
||||
'setreg' => 'application/set-registration-initiation',
|
||||
'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data',
|
||||
'sfs' => 'application/vnd.spotfire.sfs',
|
||||
'sgl' => 'application/vnd.stardivision.writer-global',
|
||||
'sgm' => 'text/sgml',
|
||||
'sgml' => 'text/sgml',
|
||||
'sh' => 'application/x-sh',
|
||||
'shar' => 'application/x-shar',
|
||||
'shf' => 'application/shf+xml',
|
||||
'sig' => 'application/pgp-signature',
|
||||
'silo' => 'model/mesh',
|
||||
'sis' => 'application/vnd.symbian.install',
|
||||
'sisx' => 'application/vnd.symbian.install',
|
||||
'sit' => 'application/x-stuffit',
|
||||
'sitx' => 'application/x-stuffitx',
|
||||
'skd' => 'application/vnd.koan',
|
||||
'skm' => 'application/vnd.koan',
|
||||
'skp' => 'application/vnd.koan',
|
||||
'skt' => 'application/vnd.koan',
|
||||
'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12',
|
||||
'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
|
||||
'slt' => 'application/vnd.epson.salt',
|
||||
'sm' => 'application/vnd.stepmania.stepchart',
|
||||
'smf' => 'application/vnd.stardivision.math',
|
||||
'smi' => 'application/smil+xml',
|
||||
'smil' => 'application/smil+xml',
|
||||
'snd' => 'audio/basic',
|
||||
'snf' => 'application/x-font-snf',
|
||||
'so' => 'application/octet-stream',
|
||||
'spc' => 'application/x-pkcs7-certificates',
|
||||
'spf' => 'application/vnd.yamaha.smaf-phrase',
|
||||
'spl' => 'application/x-futuresplash',
|
||||
'spot' => 'text/vnd.in3d.spot',
|
||||
'spp' => 'application/scvp-vp-response',
|
||||
'spq' => 'application/scvp-vp-request',
|
||||
'spx' => 'audio/ogg',
|
||||
'src' => 'application/x-wais-source',
|
||||
'sru' => 'application/sru+xml',
|
||||
'srx' => 'application/sparql-results+xml',
|
||||
'sse' => 'application/vnd.kodak-descriptor',
|
||||
'ssf' => 'application/vnd.epson.ssf',
|
||||
'ssml' => 'application/ssml+xml',
|
||||
'st' => 'application/vnd.sailingtracker.track',
|
||||
'stc' => 'application/vnd.sun.xml.calc.template',
|
||||
'std' => 'application/vnd.sun.xml.draw.template',
|
||||
'stf' => 'application/vnd.wt.stf',
|
||||
'sti' => 'application/vnd.sun.xml.impress.template',
|
||||
'stk' => 'application/hyperstudio',
|
||||
'stl' => 'application/vnd.ms-pki.stl',
|
||||
'str' => 'application/vnd.pg.format',
|
||||
'stw' => 'application/vnd.sun.xml.writer.template',
|
||||
'sub' => 'image/vnd.dvb.subtitle',
|
||||
'sus' => 'application/vnd.sus-calendar',
|
||||
'susp' => 'application/vnd.sus-calendar',
|
||||
'sv4cpio' => 'application/x-sv4cpio',
|
||||
'sv4crc' => 'application/x-sv4crc',
|
||||
'svc' => 'application/vnd.dvb.service',
|
||||
'svd' => 'application/vnd.svd',
|
||||
'svg' => 'image/svg+xml',
|
||||
'svgz' => 'image/svg+xml',
|
||||
'swa' => 'application/x-director',
|
||||
'swf' => 'application/x-shockwave-flash',
|
||||
'swi' => 'application/vnd.aristanetworks.swi',
|
||||
'sxc' => 'application/vnd.sun.xml.calc',
|
||||
'sxd' => 'application/vnd.sun.xml.draw',
|
||||
'sxg' => 'application/vnd.sun.xml.writer.global',
|
||||
'sxi' => 'application/vnd.sun.xml.impress',
|
||||
'sxm' => 'application/vnd.sun.xml.math',
|
||||
'sxw' => 'application/vnd.sun.xml.writer',
|
||||
't' => 'text/troff',
|
||||
'tao' => 'application/vnd.tao.intent-module-archive',
|
||||
'tar' => 'application/x-tar',
|
||||
'tcap' => 'application/vnd.3gpp2.tcap',
|
||||
'tcl' => 'application/x-tcl',
|
||||
'teacher' => 'application/vnd.smart.teacher',
|
||||
'tei' => 'application/tei+xml',
|
||||
'teicorpus' => 'application/tei+xml',
|
||||
'tex' => 'application/x-tex',
|
||||
'texi' => 'application/x-texinfo',
|
||||
'texinfo' => 'application/x-texinfo',
|
||||
'text' => 'text/plain',
|
||||
'tfi' => 'application/thraud+xml',
|
||||
'tfm' => 'application/x-tex-tfm',
|
||||
'thmx' => 'application/vnd.ms-officetheme',
|
||||
'tif' => 'image/tiff',
|
||||
'tiff' => 'image/tiff',
|
||||
'tmo' => 'application/vnd.tmobile-livetv',
|
||||
'torrent' => 'application/x-bittorrent',
|
||||
'tpl' => 'application/vnd.groove-tool-template',
|
||||
'tpt' => 'application/vnd.trid.tpt',
|
||||
'tr' => 'text/troff',
|
||||
'tra' => 'application/vnd.trueapp',
|
||||
'trm' => 'application/x-msterminal',
|
||||
'tsd' => 'application/timestamped-data',
|
||||
'tsv' => 'text/tab-separated-values',
|
||||
'ttc' => 'application/x-font-ttf',
|
||||
'ttf' => 'application/x-font-ttf',
|
||||
'ttl' => 'text/turtle',
|
||||
'twd' => 'application/vnd.simtech-mindmapper',
|
||||
'twds' => 'application/vnd.simtech-mindmapper',
|
||||
'txd' => 'application/vnd.genomatix.tuxedo',
|
||||
'txf' => 'application/vnd.mobius.txf',
|
||||
'txt' => 'text/plain',
|
||||
'u32' => 'application/x-authorware-bin',
|
||||
'udeb' => 'application/x-debian-package',
|
||||
'ufd' => 'application/vnd.ufdl',
|
||||
'ufdl' => 'application/vnd.ufdl',
|
||||
'umj' => 'application/vnd.umajin',
|
||||
'unityweb' => 'application/vnd.unity',
|
||||
'uoml' => 'application/vnd.uoml+xml',
|
||||
'uri' => 'text/uri-list',
|
||||
'uris' => 'text/uri-list',
|
||||
'urls' => 'text/uri-list',
|
||||
'ustar' => 'application/x-ustar',
|
||||
'utz' => 'application/vnd.uiq.theme',
|
||||
'uu' => 'text/x-uuencode',
|
||||
'uva' => 'audio/vnd.dece.audio',
|
||||
'uvd' => 'application/vnd.dece.data',
|
||||
'uvf' => 'application/vnd.dece.data',
|
||||
'uvg' => 'image/vnd.dece.graphic',
|
||||
'uvh' => 'video/vnd.dece.hd',
|
||||
'uvi' => 'image/vnd.dece.graphic',
|
||||
'uvm' => 'video/vnd.dece.mobile',
|
||||
'uvp' => 'video/vnd.dece.pd',
|
||||
'uvs' => 'video/vnd.dece.sd',
|
||||
'uvt' => 'application/vnd.dece.ttml+xml',
|
||||
'uvu' => 'video/vnd.uvvu.mp4',
|
||||
'uvv' => 'video/vnd.dece.video',
|
||||
'uvva' => 'audio/vnd.dece.audio',
|
||||
'uvvd' => 'application/vnd.dece.data',
|
||||
'uvvf' => 'application/vnd.dece.data',
|
||||
'uvvg' => 'image/vnd.dece.graphic',
|
||||
'uvvh' => 'video/vnd.dece.hd',
|
||||
'uvvi' => 'image/vnd.dece.graphic',
|
||||
'uvvm' => 'video/vnd.dece.mobile',
|
||||
'uvvp' => 'video/vnd.dece.pd',
|
||||
'uvvs' => 'video/vnd.dece.sd',
|
||||
'uvvt' => 'application/vnd.dece.ttml+xml',
|
||||
'uvvu' => 'video/vnd.uvvu.mp4',
|
||||
'uvvv' => 'video/vnd.dece.video',
|
||||
'uvvx' => 'application/vnd.dece.unspecified',
|
||||
'uvx' => 'application/vnd.dece.unspecified',
|
||||
'vcd' => 'application/x-cdlink',
|
||||
'vcf' => 'text/x-vcard',
|
||||
'vcg' => 'application/vnd.groove-vcard',
|
||||
'vcs' => 'text/x-vcalendar',
|
||||
'vcx' => 'application/vnd.vcx',
|
||||
'vis' => 'application/vnd.visionary',
|
||||
'viv' => 'video/vnd.vivo',
|
||||
'vor' => 'application/vnd.stardivision.writer',
|
||||
'vox' => 'application/x-authorware-bin',
|
||||
'vrml' => 'model/vrml',
|
||||
'vsd' => 'application/vnd.visio',
|
||||
'vsf' => 'application/vnd.vsf',
|
||||
'vss' => 'application/vnd.visio',
|
||||
'vst' => 'application/vnd.visio',
|
||||
'vsw' => 'application/vnd.visio',
|
||||
'vtu' => 'model/vnd.vtu',
|
||||
'vxml' => 'application/voicexml+xml',
|
||||
'w3d' => 'application/x-director',
|
||||
'wad' => 'application/x-doom',
|
||||
'wav' => 'audio/x-wav',
|
||||
'wax' => 'audio/x-ms-wax',
|
||||
'wbmp' => 'image/vnd.wap.wbmp',
|
||||
'wbs' => 'application/vnd.criticaltools.wbs+xml',
|
||||
'wbxml' => 'application/vnd.wap.wbxml',
|
||||
'wcm' => 'application/vnd.ms-works',
|
||||
'wdb' => 'application/vnd.ms-works',
|
||||
'weba' => 'audio/webm',
|
||||
'webm' => 'video/webm',
|
||||
'webp' => 'image/webp',
|
||||
'wg' => 'application/vnd.pmi.widget',
|
||||
'wgt' => 'application/widget',
|
||||
'wks' => 'application/vnd.ms-works',
|
||||
'wm' => 'video/x-ms-wm',
|
||||
'wma' => 'audio/x-ms-wma',
|
||||
'wmd' => 'application/x-ms-wmd',
|
||||
'wmf' => 'application/x-msmetafile',
|
||||
'wml' => 'text/vnd.wap.wml',
|
||||
'wmlc' => 'application/vnd.wap.wmlc',
|
||||
'wmls' => 'text/vnd.wap.wmlscript',
|
||||
'wmlsc' => 'application/vnd.wap.wmlscriptc',
|
||||
'wmv' => 'video/x-ms-wmv',
|
||||
'wmx' => 'video/x-ms-wmx',
|
||||
'wmz' => 'application/x-ms-wmz',
|
||||
'woff' => 'application/x-font-woff',
|
||||
'wpd' => 'application/vnd.wordperfect',
|
||||
'wpl' => 'application/vnd.ms-wpl',
|
||||
'wps' => 'application/vnd.ms-works',
|
||||
'wqd' => 'application/vnd.wqd',
|
||||
'wri' => 'application/x-mswrite',
|
||||
'wrl' => 'model/vrml',
|
||||
'wsdl' => 'application/wsdl+xml',
|
||||
'wspolicy' => 'application/wspolicy+xml',
|
||||
'wtb' => 'application/vnd.webturbo',
|
||||
'wvx' => 'video/x-ms-wvx',
|
||||
'x32' => 'application/x-authorware-bin',
|
||||
'x3d' => 'application/vnd.hzn-3d-crossword',
|
||||
'xap' => 'application/x-silverlight-app',
|
||||
'xar' => 'application/vnd.xara',
|
||||
'xbap' => 'application/x-ms-xbap',
|
||||
'xbd' => 'application/vnd.fujixerox.docuworks.binder',
|
||||
'xbm' => 'image/x-xbitmap',
|
||||
'xdf' => 'application/xcap-diff+xml',
|
||||
'xdm' => 'application/vnd.syncml.dm+xml',
|
||||
'xdp' => 'application/vnd.adobe.xdp+xml',
|
||||
'xdssc' => 'application/dssc+xml',
|
||||
'xdw' => 'application/vnd.fujixerox.docuworks',
|
||||
'xenc' => 'application/xenc+xml',
|
||||
'xer' => 'application/patch-ops-error+xml',
|
||||
'xfdf' => 'application/vnd.adobe.xfdf',
|
||||
'xfdl' => 'application/vnd.xfdl',
|
||||
'xht' => 'application/xhtml+xml',
|
||||
'xhtml' => 'application/xhtml+xml',
|
||||
'xhvml' => 'application/xv+xml',
|
||||
'xif' => 'image/vnd.xiff',
|
||||
'xla' => 'application/vnd.ms-excel',
|
||||
'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12',
|
||||
'xlc' => 'application/vnd.ms-excel',
|
||||
'xlm' => 'application/vnd.ms-excel',
|
||||
'xls' => 'application/vnd.ms-excel',
|
||||
'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12',
|
||||
'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12',
|
||||
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'xlt' => 'application/vnd.ms-excel',
|
||||
'xltm' => 'application/vnd.ms-excel.template.macroenabled.12',
|
||||
'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
|
||||
'xlw' => 'application/vnd.ms-excel',
|
||||
'xml' => 'application/xml',
|
||||
'xo' => 'application/vnd.olpc-sugar',
|
||||
'xop' => 'application/xop+xml',
|
||||
'xpi' => 'application/x-xpinstall',
|
||||
'xpm' => 'image/x-xpixmap',
|
||||
'xpr' => 'application/vnd.is-xpr',
|
||||
'xps' => 'application/vnd.ms-xpsdocument',
|
||||
'xpw' => 'application/vnd.intercon.formnet',
|
||||
'xpx' => 'application/vnd.intercon.formnet',
|
||||
'xsl' => 'application/xml',
|
||||
'xslt' => 'application/xslt+xml',
|
||||
'xsm' => 'application/vnd.syncml+xml',
|
||||
'xspf' => 'application/xspf+xml',
|
||||
'xul' => 'application/vnd.mozilla.xul+xml',
|
||||
'xvm' => 'application/xv+xml',
|
||||
'xvml' => 'application/xv+xml',
|
||||
'xwd' => 'image/x-xwindowdump',
|
||||
'xyz' => 'chemical/x-xyz',
|
||||
'yaml' => 'text/yaml',
|
||||
'yang' => 'application/yang',
|
||||
'yin' => 'application/yin+xml',
|
||||
'yml' => 'text/yaml',
|
||||
'zaz' => 'application/vnd.zzazz.deck+xml',
|
||||
'zip' => 'application/zip',
|
||||
'zir' => 'application/vnd.zul',
|
||||
'zirz' => 'application/vnd.zul',
|
||||
'zmm' => 'application/vnd.handheld-entertainment+xml'
|
||||
];
|
||||
|
||||
/**
|
||||
* Get a singleton instance of the class
|
||||
*
|
||||
* @return self
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
if (!self::$instance) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a mimetype value from a file extension
|
||||
*
|
||||
* @param string $extension File extension
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function fromExtension($extension)
|
||||
{
|
||||
$extension = strtolower($extension);
|
||||
|
||||
return isset($this->mimetypes[$extension]) ? $this->mimetypes[$extension] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a mimetype from a filename
|
||||
*
|
||||
* @param string $filename Filename to generate a mimetype from
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function fromFilename($filename)
|
||||
{
|
||||
return $this->fromExtension(pathinfo($filename, PATHINFO_EXTENSION));
|
||||
}
|
||||
}
|
||||
242
website/queries/Facebook/GraphNodes/Collection.php
Normal file
242
website/queries/Facebook/GraphNodes/Collection.php
Normal file
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\GraphNodes;
|
||||
|
||||
/**
|
||||
* Class Collection
|
||||
*
|
||||
* Modified version of Collection in "illuminate/support" by Taylor Otwell
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
|
||||
use ArrayAccess;
|
||||
use ArrayIterator;
|
||||
use Countable;
|
||||
use IteratorAggregate;
|
||||
|
||||
class Collection implements ArrayAccess, Countable, IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* The items contained in the collection.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $items = [];
|
||||
|
||||
/**
|
||||
* Create a new collection.
|
||||
*
|
||||
* @param array $items
|
||||
*/
|
||||
public function __construct(array $items = [])
|
||||
{
|
||||
$this->items = $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of a field from the Graph node.
|
||||
*
|
||||
* @param string $name The field to retrieve.
|
||||
* @param mixed $default The default to return if the field doesn't exist.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getField($name, $default = null)
|
||||
{
|
||||
if (isset($this->items[$name])) {
|
||||
return $this->items[$name];
|
||||
}
|
||||
|
||||
return $default ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the named property for this graph object.
|
||||
*
|
||||
* @param string $name The property to retrieve.
|
||||
* @param mixed $default The default to return if the property doesn't exist.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @deprecated 5.0.0 getProperty() has been renamed to getField()
|
||||
* @todo v6: Remove this method
|
||||
*/
|
||||
public function getProperty($name, $default = null)
|
||||
{
|
||||
return $this->getField($name, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all fields set on the object.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFieldNames()
|
||||
{
|
||||
return array_keys($this->items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all properties set on the object.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @deprecated 5.0.0 getPropertyNames() has been renamed to getFieldNames()
|
||||
* @todo v6: Remove this method
|
||||
*/
|
||||
public function getPropertyNames()
|
||||
{
|
||||
return $this->getFieldNames();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the items in the collection.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the collection of items as a plain array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function asArray()
|
||||
{
|
||||
return array_map(function ($value) {
|
||||
return $value instanceof Collection ? $value->asArray() : $value;
|
||||
}, $this->items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a map over each of the items.
|
||||
*
|
||||
* @param \Closure $callback
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function map(\Closure $callback)
|
||||
{
|
||||
return new static(array_map($callback, $this->items, array_keys($this->items)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the collection of items as JSON.
|
||||
*
|
||||
* @param int $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function asJson($options = 0)
|
||||
{
|
||||
return json_encode($this->asArray(), $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the number of items in the collection.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an iterator for the items.
|
||||
*
|
||||
* @return ArrayIterator
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayIterator($this->items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if an item exists at an offset.
|
||||
*
|
||||
* @param mixed $key
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function offsetExists($key)
|
||||
{
|
||||
return array_key_exists($key, $this->items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an item at a given offset.
|
||||
*
|
||||
* @param mixed $key
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function offsetGet($key)
|
||||
{
|
||||
return $this->items[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the item at a given offset.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($key, $value)
|
||||
{
|
||||
if (is_null($key)) {
|
||||
$this->items[] = $value;
|
||||
} else {
|
||||
$this->items[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset the item at a given offset.
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($key)
|
||||
{
|
||||
unset($this->items[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the collection to its string representation.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->asJson();
|
||||
}
|
||||
}
|
||||
113
website/queries/Facebook/GraphNodes/GraphAchievement.php
Normal file
113
website/queries/Facebook/GraphNodes/GraphAchievement.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\GraphNodes;
|
||||
|
||||
/**
|
||||
* Class GraphAchievement
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
|
||||
class GraphAchievement extends GraphNode
|
||||
{
|
||||
/**
|
||||
* @var array Maps object key names to Graph object types.
|
||||
*/
|
||||
protected static $graphObjectMap = [
|
||||
'from' => '\Facebook\GraphNodes\GraphUser',
|
||||
'application' => '\Facebook\GraphNodes\GraphApplication',
|
||||
];
|
||||
|
||||
/**
|
||||
* Returns the ID for the achievement.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->getField('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user who achieved this.
|
||||
*
|
||||
* @return GraphUser|null
|
||||
*/
|
||||
public function getFrom()
|
||||
{
|
||||
return $this->getField('from');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time at which this was achieved.
|
||||
*
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getPublishTime()
|
||||
{
|
||||
return $this->getField('publish_time');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the app in which the user achieved this.
|
||||
*
|
||||
* @return GraphApplication|null
|
||||
*/
|
||||
public function getApplication()
|
||||
{
|
||||
return $this->getField('application');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about the achievement type this instance is connected with.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->getField('data');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of achievement.
|
||||
*
|
||||
* @see https://developers.facebook.com/docs/graph-api/reference/v2.2/achievement
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return 'game.achievement';
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether gaining the achievement published a feed story for the user.
|
||||
*
|
||||
* @return boolean|null
|
||||
*/
|
||||
public function isNoFeedStory()
|
||||
{
|
||||
return $this->getField('no_feed_story');
|
||||
}
|
||||
}
|
||||
183
website/queries/Facebook/GraphNodes/GraphAlbum.php
Normal file
183
website/queries/Facebook/GraphNodes/GraphAlbum.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\GraphNodes;
|
||||
|
||||
/**
|
||||
* Class GraphAlbum
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
|
||||
class GraphAlbum extends GraphNode
|
||||
{
|
||||
/**
|
||||
* @var array Maps object key names to Graph object types.
|
||||
*/
|
||||
protected static $graphObjectMap = [
|
||||
'from' => '\Facebook\GraphNodes\GraphUser',
|
||||
'place' => '\Facebook\GraphNodes\GraphPage',
|
||||
];
|
||||
|
||||
/**
|
||||
* Returns the ID for the album.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->getField('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the viewer can upload photos to this album.
|
||||
*
|
||||
* @return boolean|null
|
||||
*/
|
||||
public function getCanUpload()
|
||||
{
|
||||
return $this->getField('can_upload');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of photos in this album.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getCount()
|
||||
{
|
||||
return $this->getField('count');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the album's cover photo.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCoverPhoto()
|
||||
{
|
||||
return $this->getField('cover_photo');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time the album was initially created.
|
||||
*
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getCreatedTime()
|
||||
{
|
||||
return $this->getField('created_time');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time the album was updated.
|
||||
*
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getUpdatedTime()
|
||||
{
|
||||
return $this->getField('updated_time');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the album.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->getField('description');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns profile that created the album.
|
||||
*
|
||||
* @return GraphUser|null
|
||||
*/
|
||||
public function getFrom()
|
||||
{
|
||||
return $this->getField('from');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns profile that created the album.
|
||||
*
|
||||
* @return GraphPage|null
|
||||
*/
|
||||
public function getPlace()
|
||||
{
|
||||
return $this->getField('place');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a link to this album on Facebook.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLink()
|
||||
{
|
||||
return $this->getField('link');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the textual location of the album.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLocation()
|
||||
{
|
||||
return $this->getField('location');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the title of the album.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->getField('name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the privacy settings for the album.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPrivacy()
|
||||
{
|
||||
return $this->getField('privacy');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the album.
|
||||
*
|
||||
* enum{ profile, mobile, wall, normal, album }
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->getField('type');
|
||||
}
|
||||
}
|
||||
43
website/queries/Facebook/GraphNodes/GraphApplication.php
Normal file
43
website/queries/Facebook/GraphNodes/GraphApplication.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\GraphNodes;
|
||||
|
||||
/**
|
||||
* Class GraphApplication
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
|
||||
class GraphApplication extends GraphNode
|
||||
{
|
||||
/**
|
||||
* Returns the ID for the application.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->getField('id');
|
||||
}
|
||||
}
|
||||
72
website/queries/Facebook/GraphNodes/GraphCoverPhoto.php
Normal file
72
website/queries/Facebook/GraphNodes/GraphCoverPhoto.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\GraphNodes;
|
||||
|
||||
/**
|
||||
* Class GraphCoverPhoto
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class GraphCoverPhoto extends GraphNode
|
||||
{
|
||||
/**
|
||||
* Returns the id of cover if it exists
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->getField('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the source of cover if it exists
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSource()
|
||||
{
|
||||
return $this->getField('source');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the offset_x of cover if it exists
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getOffsetX()
|
||||
{
|
||||
return $this->getField('offset_x');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the offset_y of cover if it exists
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getOffsetY()
|
||||
{
|
||||
return $this->getField('offset_y');
|
||||
}
|
||||
}
|
||||
260
website/queries/Facebook/GraphNodes/GraphEdge.php
Normal file
260
website/queries/Facebook/GraphNodes/GraphEdge.php
Normal file
@@ -0,0 +1,260 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\GraphNodes;
|
||||
|
||||
use Facebook\FacebookRequest;
|
||||
use Facebook\Url\FacebookUrlManipulator;
|
||||
use Facebook\Exceptions\FacebookSDKException;
|
||||
|
||||
/**
|
||||
* Class GraphEdge
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class GraphEdge extends Collection
|
||||
{
|
||||
/**
|
||||
* @var FacebookRequest The original request that generated this data.
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* @var array An array of Graph meta data like pagination, etc.
|
||||
*/
|
||||
protected $metaData = [];
|
||||
|
||||
/**
|
||||
* @var string|null The parent Graph edge endpoint that generated the list.
|
||||
*/
|
||||
protected $parentEdgeEndpoint;
|
||||
|
||||
/**
|
||||
* @var string|null The subclass of the child GraphNode's.
|
||||
*/
|
||||
protected $subclassName;
|
||||
|
||||
/**
|
||||
* Init this collection of GraphNode's.
|
||||
*
|
||||
* @param FacebookRequest $request The original request that generated this data.
|
||||
* @param array $data An array of GraphNode's.
|
||||
* @param array $metaData An array of Graph meta data like pagination, etc.
|
||||
* @param string|null $parentEdgeEndpoint The parent Graph edge endpoint that generated the list.
|
||||
* @param string|null $subclassName The subclass of the child GraphNode's.
|
||||
*/
|
||||
public function __construct(FacebookRequest $request, array $data = [], array $metaData = [], $parentEdgeEndpoint = null, $subclassName = null)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->metaData = $metaData;
|
||||
$this->parentEdgeEndpoint = $parentEdgeEndpoint;
|
||||
$this->subclassName = $subclassName;
|
||||
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parent Graph edge endpoint that generated the list.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getParentGraphEdge()
|
||||
{
|
||||
return $this->parentEdgeEndpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the subclass name that the child GraphNode's are cast as.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSubClassName()
|
||||
{
|
||||
return $this->subclassName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw meta data associated with this GraphEdge.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMetaData()
|
||||
{
|
||||
return $this->metaData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next cursor if it exists.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getNextCursor()
|
||||
{
|
||||
return $this->getCursor('after');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the previous cursor if it exists.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPreviousCursor()
|
||||
{
|
||||
return $this->getCursor('before');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cursor for a specific direction if it exists.
|
||||
*
|
||||
* @param string $direction The direction of the page: after|before
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCursor($direction)
|
||||
{
|
||||
if (isset($this->metaData['paging']['cursors'][$direction])) {
|
||||
return $this->metaData['paging']['cursors'][$direction];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a pagination URL based on a cursor.
|
||||
*
|
||||
* @param string $direction The direction of the page: next|previous
|
||||
*
|
||||
* @return string|null
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function getPaginationUrl($direction)
|
||||
{
|
||||
$this->validateForPagination();
|
||||
|
||||
// Do we have a paging URL?
|
||||
if (isset($this->metaData['paging'][$direction])) {
|
||||
// Graph returns the full URL with all the original params.
|
||||
// We just want the endpoint though.
|
||||
$pageUrl = $this->metaData['paging'][$direction];
|
||||
|
||||
return FacebookUrlManipulator::baseGraphUrlEndpoint($pageUrl);
|
||||
}
|
||||
|
||||
// Do we have a cursor to work with?
|
||||
$cursorDirection = $direction === 'next' ? 'after' : 'before';
|
||||
$cursor = $this->getCursor($cursorDirection);
|
||||
if (!$cursor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// If we don't know the ID of the parent node, this ain't gonna work.
|
||||
if (!$this->parentEdgeEndpoint) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// We have the parent node ID, paging cursor & original request.
|
||||
// These were the ingredients chosen to create the perfect little URL.
|
||||
$pageUrl = $this->parentEdgeEndpoint . '?' . $cursorDirection . '=' . urlencode($cursor);
|
||||
|
||||
// Pull in the original params
|
||||
$originalUrl = $this->request->getUrl();
|
||||
$pageUrl = FacebookUrlManipulator::mergeUrlParams($originalUrl, $pageUrl);
|
||||
|
||||
return FacebookUrlManipulator::forceSlashPrefix($pageUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates whether or not we can paginate on this request.
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function validateForPagination()
|
||||
{
|
||||
if ($this->request->getMethod() !== 'GET') {
|
||||
throw new FacebookSDKException('You can only paginate on a GET request.', 720);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the request object needed to make a next|previous page request.
|
||||
*
|
||||
* @param string $direction The direction of the page: next|previous
|
||||
*
|
||||
* @return FacebookRequest|null
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function getPaginationRequest($direction)
|
||||
{
|
||||
$pageUrl = $this->getPaginationUrl($direction);
|
||||
if (!$pageUrl) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$newRequest = clone $this->request;
|
||||
$newRequest->setEndpoint($pageUrl);
|
||||
|
||||
return $newRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the request object needed to make a "next" page request.
|
||||
*
|
||||
* @return FacebookRequest|null
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function getNextPageRequest()
|
||||
{
|
||||
return $this->getPaginationRequest('next');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the request object needed to make a "previous" page request.
|
||||
*
|
||||
* @return FacebookRequest|null
|
||||
*
|
||||
* @throws FacebookSDKException
|
||||
*/
|
||||
public function getPreviousPageRequest()
|
||||
{
|
||||
return $this->getPaginationRequest('previous');
|
||||
}
|
||||
|
||||
/**
|
||||
* The total number of results according to Graph if it exists.
|
||||
*
|
||||
* This will be returned if the summary=true modifier is present in the request.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getTotalCount()
|
||||
{
|
||||
if (isset($this->metaData['summary']['total_count'])) {
|
||||
return $this->metaData['summary']['total_count'];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
242
website/queries/Facebook/GraphNodes/GraphEvent.php
Normal file
242
website/queries/Facebook/GraphNodes/GraphEvent.php
Normal file
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\GraphNodes;
|
||||
|
||||
/**
|
||||
* Class GraphEvent
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class GraphEvent extends GraphNode
|
||||
{
|
||||
/**
|
||||
* @var array Maps object key names to GraphNode types.
|
||||
*/
|
||||
protected static $graphObjectMap = [
|
||||
'cover' => '\Facebook\GraphNodes\GraphCoverPhoto',
|
||||
'place' => '\Facebook\GraphNodes\GraphPage',
|
||||
'picture' => '\Facebook\GraphNodes\GraphPicture',
|
||||
'parent_group' => '\Facebook\GraphNodes\GraphGroup',
|
||||
];
|
||||
|
||||
/**
|
||||
* Returns the `id` (The event ID) as string if present.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->getField('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `cover` (Cover picture) as GraphCoverPhoto if present.
|
||||
*
|
||||
* @return GraphCoverPhoto|null
|
||||
*/
|
||||
public function getCover()
|
||||
{
|
||||
return $this->getField('cover');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `description` (Long-form description) as string if present.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->getField('description');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `end_time` (End time, if one has been set) as DateTime if present.
|
||||
*
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getEndTime()
|
||||
{
|
||||
return $this->getField('end_time');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `is_date_only` (Whether the event only has a date specified, but no time) as bool if present.
|
||||
*
|
||||
* @return bool|null
|
||||
*/
|
||||
public function getIsDateOnly()
|
||||
{
|
||||
return $this->getField('is_date_only');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `name` (Event name) as string if present.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->getField('name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `owner` (The profile that created the event) as GraphNode if present.
|
||||
*
|
||||
* @return GraphNode|null
|
||||
*/
|
||||
public function getOwner()
|
||||
{
|
||||
return $this->getField('owner');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `parent_group` (The group the event belongs to) as GraphGroup if present.
|
||||
*
|
||||
* @return GraphGroup|null
|
||||
*/
|
||||
public function getParentGroup()
|
||||
{
|
||||
return $this->getField('parent_group');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `place` (Event Place information) as GraphPage if present.
|
||||
*
|
||||
* @return GraphPage|null
|
||||
*/
|
||||
public function getPlace()
|
||||
{
|
||||
return $this->getField('place');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `privacy` (Who can see the event) as string if present.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPrivacy()
|
||||
{
|
||||
return $this->getField('privacy');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `start_time` (Start time) as DateTime if present.
|
||||
*
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getStartTime()
|
||||
{
|
||||
return $this->getField('start_time');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `ticket_uri` (The link users can visit to buy a ticket to this event) as string if present.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTicketUri()
|
||||
{
|
||||
return $this->getField('ticket_uri');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `timezone` (Timezone) as string if present.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTimezone()
|
||||
{
|
||||
return $this->getField('timezone');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `updated_time` (Last update time) as DateTime if present.
|
||||
*
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getUpdatedTime()
|
||||
{
|
||||
return $this->getField('updated_time');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `picture` (Event picture) as GraphPicture if present.
|
||||
*
|
||||
* @return GraphPicture|null
|
||||
*/
|
||||
public function getPicture()
|
||||
{
|
||||
return $this->getField('picture');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `attending_count` (Number of people attending the event) as int if present.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getAttendingCount()
|
||||
{
|
||||
return $this->getField('attending_count');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `declined_count` (Number of people who declined the event) as int if present.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getDeclinedCount()
|
||||
{
|
||||
return $this->getField('declined_count');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `maybe_count` (Number of people who maybe going to the event) as int if present.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getMaybeCount()
|
||||
{
|
||||
return $this->getField('maybe_count');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `noreply_count` (Number of people who did not reply to the event) as int if present.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getNoreplyCount()
|
||||
{
|
||||
return $this->getField('noreply_count');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `invited_count` (Number of people invited to the event) as int if present.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getInvitedCount()
|
||||
{
|
||||
return $this->getField('invited_count');
|
||||
}
|
||||
}
|
||||
171
website/queries/Facebook/GraphNodes/GraphGroup.php
Normal file
171
website/queries/Facebook/GraphNodes/GraphGroup.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Facebook, Inc.
|
||||
*
|
||||
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
||||
* use, copy, modify, and distribute this software in source code or binary
|
||||
* form for use in connection with the web services and APIs provided by
|
||||
* Facebook.
|
||||
*
|
||||
* As with any software that integrates with the Facebook platform, your use
|
||||
* of this software is subject to the Facebook Developer Principles and
|
||||
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
||||
* shall be included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
namespace Facebook\GraphNodes;
|
||||
|
||||
/**
|
||||
* Class GraphGroup
|
||||
*
|
||||
* @package Facebook
|
||||
*/
|
||||
class GraphGroup extends GraphNode
|
||||
{
|
||||
/**
|
||||
* @var array Maps object key names to GraphNode types.
|
||||
*/
|
||||
protected static $graphObjectMap = [
|
||||
'cover' => '\Facebook\GraphNodes\GraphCoverPhoto',
|
||||
'venue' => '\Facebook\GraphNodes\GraphLocation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Returns the `id` (The Group ID) as string if present.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->getField('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `cover` (The cover photo of the Group) as GraphCoverPhoto if present.
|
||||
*
|
||||
* @return GraphCoverPhoto|null
|
||||
*/
|
||||
public function getCover()
|
||||
{
|
||||
return $this->getField('cover');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `description` (A brief description of the Group) as string if present.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->getField('description');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `email` (The email address to upload content to the Group. Only current members of the Group can use this) as string if present.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->getField('email');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `icon` (The URL for the Group's icon) as string if present.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
return $this->getField('icon');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `link` (The Group's website) as string if present.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLink()
|
||||
{
|
||||
return $this->getField('link');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `name` (The name of the Group) as string if present.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->getField('name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `member_request_count` (Number of people asking to join the group.) as int if present.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getMemberRequestCount()
|
||||
{
|
||||
return $this->getField('member_request_count');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `owner` (The profile that created this Group) as GraphNode if present.
|
||||
*
|
||||
* @return GraphNode|null
|
||||
*/
|
||||
public function getOwner()
|
||||
{
|
||||
return $this->getField('owner');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `parent` (The parent Group of this Group, if it exists) as GraphNode if present.
|
||||
*
|
||||
* @return GraphNode|null
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->getField('parent');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `privacy` (The privacy setting of the Group) as string if present.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPrivacy()
|
||||
{
|
||||
return $this->getField('privacy');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `updated_time` (The last time the Group was updated (this includes changes in the Group's properties and changes in posts and comments if user can see them)) as \DateTime if present.
|
||||
*
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getUpdatedTime()
|
||||
{
|
||||
return $this->getField('updated_time');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `venue` (The location for the Group) as GraphLocation if present.
|
||||
*
|
||||
* @return GraphLocation|null
|
||||
*/
|
||||
public function getVenue()
|
||||
{
|
||||
return $this->getField('venue');
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user