/** * XML-RPC Query * * This method sends calls stack to XML-RPC system.multicall method. * See {@link xmlrpcServer::multiCall()} for details and links about it. * * @return array */ function query() { # Prepare multicall, then call the parent::query() method return parent::query('system.multicall', $this->calls); }
/** Sends a ping to given <var>$url</var>. @param url <b>string</b> URL to ping @param post_id <b>integer</b> Post ID @param post_title <b>string</b> Post title @param post_excerpt <b>string</b> Post excerpt @param post_url <b>string</b> Post URL */ public function ping($url, $post_id, $post_title, $post_excerpt, $post_url) { if ($this->core->blog === null) { return false; } $post_id = (int) $post_id; # Check for previously done trackback $strReq = 'SELECT post_id, ping_url FROM ' . $this->table . ' ' . 'WHERE post_id = ' . $post_id . ' ' . "AND ping_url = '" . $this->con->escape($url) . "' "; $rs = $this->con->select($strReq); if (!$rs->isEmpty()) { throw new Exception(sprintf(__('%s has still been pinged'), $url)); } $ping_parts = explode('|', $url); # Let's walk by the trackback way if (count($ping_parts) < 2) { $data = array('title' => $post_title, 'excerpt' => $post_excerpt, 'url' => $post_url, 'blog_name' => trim(html::escapeHTML(html::clean($this->core->blog->name)))); # Ping try { $http = self::initHttp($url, $path); $http->post($path, $data, 'UTF-8'); $res = $http->getContent(); } catch (Exception $e) { throw new Exception(__('Unable to ping URL')); } $pattern = '|<response>.*<error>(.*)</error>(.*)' . '(<message>(.*)</message>(.*))?' . '</response>|msU'; if (!preg_match($pattern, $res, $match)) { throw new Exception(sprintf(__('%s is not a ping URL'), $url)); } $ping_error = trim($match[1]); $ping_msg = !empty($match[4]) ? $match[4] : ''; } else { try { $xmlrpc = new xmlrpcClient($ping_parts[0]); $res = $xmlrpc->query('pingback.ping', $post_url, $ping_parts[1]); $ping_error = '0'; } catch (xmlrpcException $e) { $ping_error = $e->getCode(); $ping_msg = $e->getMessage(); } catch (Exception $e) { throw new Exception(__('Unable to ping URL')); } } if ($ping_error != '0') { throw new Exception(sprintf(__('%s, ping error:'), $url) . ' ' . $ping_msg); } else { # Notify ping result in database $cur = $this->con->openCursor($this->table); $cur->post_id = $post_id; $cur->ping_url = $url; $cur->ping_dt = date('Y-m-d H:i:s'); $cur->insert(); } }