-
Notifications
You must be signed in to change notification settings - Fork 9
/
config.php
51 lines (45 loc) · 1.35 KB
/
config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
session_start();
define("FB_ID", "");
define("FB_SECRET", "");
$chatserver = $_SERVER['HTTP_HOST'];
$protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
define("CHAT_MASTER", $protocol."://".$chatserver."/privpub/master");
define("CHAT_CHAT", "http://".$chatserver."/privpub/chat");
define("CHAT_ONLINE", $protocol."://".$chatserver."/pub/online");
function ws_push($room, $data=array()){
return http($room, "POST", json_encode($data));
}
/**
* Make an HTTP request
* Copied from twitteroauth.php
*
* @return API results
*/
function http($url, $method="GET", $postfields = NULL, $agent="animestream/1.1") {
$ci = curl_init();
/* Curl settings */
curl_setopt($ci, CURLOPT_USERAGENT, $agent);
curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ci, CURLOPT_TIMEOUT, 30);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, true);
switch ($method) {
case 'POST':
curl_setopt($ci, CURLOPT_POST, TRUE);
if (!empty($postfields)) {
curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
}
break;
case 'DELETE':
curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
if (!empty($postfields)) {
$url = "{$url}?{$postfields}";
}
}
curl_setopt($ci, CURLOPT_URL, $url);
$response = curl_exec($ci);
curl_close ($ci);
return $response;
}