function FAS_Call($type, $name, $title, $url, $content) { $context = Model_Context::getInstance(); $pool = DBModel::getInstance(); $blogstr = $context->getProperty('uri.host') . $context->getProperty('uri.blog'); $DDosTimeWindowSize = 300; $rpc = new XMLRPC(); $rpc->url = 'http://antispam.textcube.org/RPC/'; if ($rpc->call('checkSpam', $blogstr, $type, $name, $title, $url, $content, $_SERVER['REMOTE_ADDR']) == false) { // call fail // Do Local spam check with "Thief-cat algorithm" $count = 0; if ($type == 2) { $storage = "RemoteResponses"; $pool->reset($storage); $pool->setQualifier("url", "eq", $url, true); $pool->setQualifier("isfiltered", ">", 0); if ($cnt = $pool->getCount("id")) { $count += $cnt; } } else { // Comment Case $storage = "Comments"; $pool->reset($storage); $pool->setQualifier("comment", "eq", ${$content}, true); $pool->setQualifier("name", "eq", $name, true); $pool->setQualifier("homepage", "eq", $url, true); $pool->setQualifier("isfiltered", ">", 0); if ($cnt = $pool->getCount("id")) { $count += $cnt; } } // Check IP $pool->reset($storage); $pool->setQualifier("ip", "eq", $_SERVER['REMOTE_ADDR'], true); $pool->setQualifier("written", ">", Timestamp::getUNIXtime() - $DDosTimeWindowSize); if ($cnt = $pool->getCount("id")) { $count += $cnt; } if ($count >= 10) { return false; } return true; } if (!is_null($rpc->fault)) { // FAS has some problem return true; } if ($rpc->result['result'] == true) { return false; // it's spam } return true; }
function EAS_Call($type, $name, $title, $url, $content) { global $hostURL, $blogURL, $database; $blogstr = $hostURL . $blogURL; $rpc = new XMLRPC(); $rpc->url = 'http://antispam.eolin.com/RPC/index.php'; if ($rpc->call('checkSpam', $blogstr, $type, $name, $title, $url, $content, $_SERVER['REMOTE_ADDR']) == false) { // call fail // Do Local spam check with "Thief-cat algorithm" $count = 0; $tableName = $database['prefix'] . 'RemoteResponses'; if ($type == 2) { $sql = 'SELECT COUNT(id) as cc FROM ' . $database['prefix'] . 'RemoteResponses WHERE'; $sql .= ' url = \'' . POD::escapeString($url) . '\''; $sql .= ' AND isfiltered > 0'; if ($row = POD::queryRow($sql)) { $count += @$row[0]; } } else { // Comment Case $tableName = $database['prefix'] . 'Comments'; $sql = 'SELECT COUNT(id) as cc FROM ' . $database['prefix'] . 'Comments WHERE'; $sql .= ' comment = \'' . POD::escapeString($content) . '\''; $sql .= ' AND homepage = \'' . POD::escapeString($url) . '\''; $sql .= ' AND name = \'' . POD::escapeString($name) . '\''; $sql .= ' AND isfiltered > 0'; if ($row = POD::queryRow($sql)) { $count += @$row[0]; } } // Check IP $sql = 'SELECT COUNT(id) as cc FROM ' . $tableName . ' WHERE'; $sql .= ' ip = \'' . POD::escapeString($_SERVER['REMOTE_ADDR']) . '\''; $sql .= ' AND isfiltered > 0'; if ($row = POD::queryRow($sql)) { $count += @$row[0]; } if ($count >= 10) { return false; } return true; } if (!is_null($rpc->fault)) { // EAS has some problem return true; } if ($rpc->result['result'] == true) { return false; // it's spam } return true; }
/** * @brief Syndicating routine. * @see Tag, User, DBModel, Model_Context */ function SyndicateToEolin($entryId, $entry, $mode) { $context = Model_Context::getInstance(); $blogid = $context->getProperty('blog.id'); $rpc = new XMLRPC(); $rpc->url = 'http://ping.eolin.com/'; $summary = array('blogURL' => $context->getProperty('uri.default'), 'syncURL' => $context->getProperty('uri.default') . "/plugin/abstractToEolin?entryId={$entryId}"); if ($mode == 'create') { $summary['blogTitle'] = $context->getProperty('blog.title'); $summary['language'] = $context->getProperty('blog.language'); $summary['permalink'] = $context->getProperty('uri.default') . "/" . ($context->getProperty('blog.useSloganOnPost') ? "entry/{$entry['slogan']}" : $entry['id']); $summary['title'] = Utils_Unicode::lessenAsByte($entry['title'], 255); $summary['content'] = Utils_Unicode::lessenAsByte(stripHTML(getEntryContentView($blogid, $entry['id'], $entry['content'], $entry['contentformatter'])), 1023, ''); $summary['author'] = User::authorName($entry['userid'], $entryId); $summary['tags'] = Tag::getTagsWithEntryId($blogid, $entry); $summary['location'] = $entry['location']; $summary['written'] = Timestamp::getRFC1123($entry['published']); } return $rpc->call("sync.{$mode}", $summary); }
function api_BlogAPI() { global $blogApiFunctions; if (!array_key_exists('HTTP_RAW_POST_DATA', $GLOBALS)) { XMLRPC::sendFault(1, 'Invalid Method Call'); exit; } $xml = $GLOBALS['HTTP_RAW_POST_DATA']; $blogApiFunctions = array("blogger.getUsersBlogs", "blogger.newPost", "blogger.editPost", "blogger.getTemplate", "blogger.getRecentPosts", "blogger.deletePost", "blogger.getPost", "metaWeblog.newPost", "metaWeblog.getPost", "metaWeblog.getCategories", "metaWeblog.getRecentPosts", "metaWeblog.editPost", "metaWeblog.newMediaObject", "mt.getPostCategories", "mt.setPostCategories", "mt.getCategoryList", "mt.supportedMethods", "mt.publishPost", "mt.getRecentPostTitles"); $xmlrpc = new XMLRPC(); foreach ($blogApiFunctions as $func) { $callback = str_replace(".", "_", $func); $xmlrpc->registerMethod($func, $callback); } $otherMethods = fireEvent('RegisterRpcMethod', array()); foreach ($otherMethods as $func => $callback) { $xmlrpc->registerMethod($func, $callback); } $xmlrpc->receive($xml); }
function _encodeValue($value) { echo '<value>'; if (is_a($value, 'XMLCustomType')) { echo "<{$value->name}>"; echo $value->value; echo "</{$value->name}>"; } else if (is_int($value)) { echo '<i4>'; echo $value; echo '</i4>'; } else if (is_double($value)) { echo '<double>'; echo $value; echo '</double>'; } else if (is_bool($value)) { echo '<boolean>'; echo ($value ? '1' : '0'); echo '</boolean>'; } else if (is_array($value)) { for ($i = 0; $i < count($value); $i++) { if (!isset($value[$i])) break; } if ($i < count($value)) { echo '<struct>'; foreach ($value as $name => $data) { echo '<member><name>'; echo $name; echo '</name>'; $this->_encodeValue($data); echo '</member>'; } echo '</struct>'; } else { echo '<array><data>'; for ($i = 0; $i < count($value); $i++) $this->_encodeValue($value[$i]); echo '</data></array>'; } } else if ((strlen($value) == 17) && ($value{8} == 'T') && ($value{11} == ':') && ($value{14} == ':')) { echo '<dateTime.iso8601>'; echo $value; echo '</dateTime.iso8601>'; } else { echo '<string>'; if ($this->useOldXmlRPC == true) { echo XMLRPC::encodingStringEx($value); } else { echo htmlspecialchars($value); } echo '</string>'; } echo '</value>'; }
function sendTrackbackPing($entryId, $permalink, $url, $site, $title) { $rpc = new XMLRPC(); $rpc->url = TEXTCUBE_SYNC_URL; $summary = array('permalink' => $permalink, 'url' => $url, 'blogName' => $site, 'title' => $title); $rpc->async = true; $rpc->call('sync.trackback', $summary); }
function syndicateEntry($id, $mode) { $context = Model_Context::getInstance(); $pool = DBModel::getInstance(); $pool->reset('XMLRPCPingSettings'); $pool->setQualifier('blogid', 'equals', $context->getProperty('blog.id')); $sites = $pool->getAll('url,pingtype'); $entry = getEntry($context->getProperty('blog.id'), $id); if (is_null($entry)) { return false; } if (!empty($sites)) { foreach ($sites as $site) { $rpc = new XMLRPC(); $rpc->url = $site['url']; $result[$site['url']] = $rpc->call($context->getProperty('blog.title'), $context->getProperty('uri.default')); } } if ($mode == 'create') { fireEvent('CreatePostSyndicate', $id, $entry); } else { if ($mode == 'modify') { fireEvent('ModifyPostSyndicate', $id, $entry); } else { if ($mode == 'delete') { fireEvent('DeletePostSyndicate', $id, $entry); } } } return true; }
function sendCommentPing($entryId, $permalink, $name, $homepage) { return true; global $database, $blog; $blogid = getBlogId(); if ($slogan = POD::queryCell("SELECT slogan\n\t\tFROM {$database['prefix']}Entries\n\t\tWHERE blogid = {$blogid}\n\t\t\tAND id = {$entryId}\n\t\t\tAND draft = 0\n\t\t\tAND visibility = 3 \n\t\t\tAND acceptcomment = 1")) { $rpc = new XMLRPC(); $rpc->url = TEXTCUBE_SYNC_URL; $summary = array('permalink' => $permalink, 'name' => $name, 'homepage' => $homepage); $rpc->async = true; $rpc->call('sync.comment', $summary); } }
function call($url = "", $function = "", $arguments = array()) { $arguments = XMLRPC::array_encode($arguments); $myResult = XMLRPC::call_raw($url, $function, $arguments); if (!$myResult) { $result = "XMLRPC::Error ErrNo: " . $myClient->errno . " ErrStr: " . $myClient->errstr; } else { if ($myResult->faultCode()) { $result = "XMLRPC::ResultError Code: " . $myResult->faultCode() . " Reason: " . $myResult->faultString(); } else { // We have a valid response $result = array(XML_RPC_Decode($myResult->Value())); } } return $result; }