die('-1');*/ if (!extension_loaded('json')) { include dirname(__FILE__) . '/compat-json.php'; } require '../../../wp-load.php'; require '../../../wp-admin/includes/admin.php'; do_action('admin_init'); if (!headers_sent()) { nocache_headers(); header('Content-Type: text/javascript; charset=utf-8'); } if (!class_exists('Duoshuo_WordPress', false)) { $response = array('code' => 30, 'errorMessage' => 'Duoshuo plugin hasn\'t been activated.'); echo json_encode($response); exit; } require DUOSHUO_PLUGIN_PATH . '/LocalServer.php'; $plugin = Duoshuo_WordPress::getInstance(); try { if ($_SERVER['REQUEST_METHOD'] == 'POST') { $input = $_POST; if (isset($input['spam_confirmed'])) { //D-Z Theme 会给POST设置这个参数 unset($input['spam_confirmed']); } $server = new Duoshuo_LocalServer($plugin); $server->dispatch($input); } } catch (Exception $e) { $plugin->sendException($e); }
public function api() { $this->fileload(); if (!headers_sent()) { $this->nocache_headers(); //max age TODO: header('Content-Type: text/javascript; charset=utf8'); } if (!class_exists('Duoshuo_Typecho')) { $response = array('code' => 30, 'errorMessage' => 'duoshuo plugin hasn\'t been activated.'); echo json_encode($response); exit; } $plugin = Duoshuo_Typecho::getInstance(); try { if ($plugin->getPlugOption('sync_to_local') !== NULL) { if ($plugin->getPlugOption('sync_to_local') == 0) { $response = array('code' => 31, 'errorMessage' => 'duoshuo plugin hasn\'t been closed'); echo json_encode($response); exit; } } 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; } }