-
Notifications
You must be signed in to change notification settings - Fork 14
/
api.php
57 lines (49 loc) · 1.17 KB
/
api.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
52
53
54
55
56
<?php
/**
* 多说插件 api处理
*
* @version $Id: api.php 0 10:17 2013-4-11
* @author xiaowu
* @copyright Copyright (c) 2012 - , Duoshuo, Inc.
* @link http://dev.duoshuo.com
*/
if (!extension_loaded('json'))
include_once 'compat_json.php';
function nocache_headers(){
header("Pragma:no-cache\r\n");
header("Cache-Control:no-cache\r\n");
header("Expires:0\r\n");
}
if (!headers_sent()) {
nocache_headers();//max age TODO:
header('Content-Type: text/javascript; charset=gb2312');
}
require_once 'Client.php';
require_once 'Abstract.php';
require_once 'SDK.php';
require_once 'LocalServer.php';
require_once 'Exception.php';
if (!class_exists('Duoshuo_SDK')){
$response = array(
'code' => 30,
'errorMessage' => 'Duoshuo plugin hasn\'t been activated.'
);
echo json_encode($response);
exit;
}
$plugin = Duoshuo_SDK::getInstance();
try{
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$server = new Duoshuo_LocalServer($plugin);
$input = $_POST;
if (get_magic_quotes_gpc()){
foreach($input as $key => $value)
$input[$key] = stripslashes($value);
}
$server->dispatch($input);
}
}
catch (Exception $e){
Duoshuo_LocalServer::sendException($e);
exit;
}