/**
  * 
  * @return Duoshuo_WordPress
  */
 public static function getInstance()
 {
     if (self::$_instance === null) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Exemple #2
0
 public function dispatch($input)
 {
     if (!isset($input['signature'])) {
         throw new Duoshuo_Exception('Invalid signature.', Duoshuo_Exception::INVALID_SIGNATURE);
     }
     $signature = $input['signature'];
     unset($input['signature']);
     ksort($input);
     $baseString = http_build_query($input, null, '&');
     $expectSignature = base64_encode(Duoshuo_Abstract::hmacsha1($baseString, $this->plugin->getOption('secret')));
     if ($signature !== $expectSignature) {
         throw new Duoshuo_Exception('Invalid signature, expect: ' . $expectSignature . '. (' . $baseString . ')', Duoshuo_Exception::INVALID_SIGNATURE);
     }
     $method = $input['action'];
     if (!method_exists($this, $method)) {
         throw new Duoshuo_Exception('Unknown action.', Duoshuo_Exception::OPERATION_NOT_SUPPORTED);
     }
     $this->response = array();
     $this->{$method}($input);
     $this->sendResponse();
 }
Exemple #3
0
	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);
}
 function __construct()
 {
     $widget_ops = array('classname' => 'ds-widget-recent-visitors', 'description' => '最近访客(由多说提供)');
     parent::__construct('ds-recent-visitors', '最近访客(多说)', $widget_ops);
     $this->alt_option_name = 'duoshuo_widget_recent_visitors';
     if (is_active_widget(false, false, $this->id_base)) {
         add_action('wp_head', array(&$this, 'printScripts'));
     }
     //add_action( 'comment_post', array(&$this, 'flush_widget_cache') );
     //add_action( 'transition_comment_status', array(&$this, 'flush_widget_cache') );
     $this->duoshuoPlugin = Duoshuo_WordPress::getInstance();
 }
Exemple #5
0
 function __construct()
 {
     $widget_ops = array('classname' => 'ds-widget-top-threads', 'description' => '热评文章(由多说提供)');
     parent::__construct('ds-top-threads', '热评文章(多说)', $widget_ops);
     $this->alt_option_name = 'duoshuo_widget_top_threads';
     $this->duoshuoPlugin = Duoshuo_WordPress::getInstance();
 }