2011-12-25 10:07:20 +01:00
|
|
|
<?php # $Id$
|
2011-12-13 12:29:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
if (IN_serendipity !== true) {
|
|
|
|
die ("Don't hack!");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Probe for a language include with constants. Still include defines later on, if some constants were missing
|
|
|
|
$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
|
|
|
|
if (file_exists($probelang)) {
|
|
|
|
include $probelang;
|
|
|
|
}
|
|
|
|
|
|
|
|
include_once dirname(__FILE__) . '/lang_en.inc.php';
|
|
|
|
|
|
|
|
class serendipity_event_xmlrpc extends serendipity_event
|
|
|
|
{
|
|
|
|
var $title = PLUGIN_EVENT_XMLRPC_NAME;
|
|
|
|
|
|
|
|
function introspect(&$propbag)
|
|
|
|
{
|
|
|
|
global $serendipity;
|
|
|
|
|
|
|
|
$propbag->add('name', PLUGIN_EVENT_XMLRPC_NAME);
|
|
|
|
$propbag->add('description', PLUGIN_EVENT_XMLRPC_DESC);
|
|
|
|
$propbag->add('stackable', false);
|
|
|
|
$propbag->add('author', 'Serendipity Team');
|
2012-01-15 21:32:45 +01:00
|
|
|
$propbag->add('version', '1.47');
|
2011-12-13 12:29:05 +01:00
|
|
|
$propbag->add('requirements', array(
|
|
|
|
'serendipity' => '0.8',
|
|
|
|
'smarty' => '2.6.7',
|
|
|
|
'php' => '4.1.0'
|
|
|
|
));
|
|
|
|
$propbag->add('event_hooks', array(
|
|
|
|
'frontend_xmlrpc' => true,
|
|
|
|
'frontend_header' => true
|
|
|
|
));
|
2012-01-05 17:46:26 +01:00
|
|
|
$propbag->add('configuration',
|
2012-01-14 13:50:20 +01:00
|
|
|
array('doc_rpclink','category', 'gmt', 'uploaddir', 'htmlconvert', 'asureauthor', 'wpfakeversion', 'debuglog', 'spamevent_description', 'event_spam', 'event_approved','event_pending')
|
2012-01-05 17:46:26 +01:00
|
|
|
);
|
2011-12-13 12:29:05 +01:00
|
|
|
$propbag->add('groups', array('FRONTEND_FULL_MODS', 'FRONTEND_EXTERNAL_SERVICES'));
|
|
|
|
}
|
|
|
|
|
|
|
|
function generate_content(&$title) {
|
|
|
|
$title = $this->title;
|
|
|
|
}
|
|
|
|
|
|
|
|
function showXSD() {
|
|
|
|
global $serendipity;
|
|
|
|
|
|
|
|
echo '<?xml version="1.0" ?>
|
|
|
|
<rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd" >
|
|
|
|
<service>
|
|
|
|
<engineName>Serendipity (s9y)</engineName>
|
|
|
|
<engineLink>http://www.s9y.org/</engineLink>
|
|
|
|
<homePageLink>' . $serendipity['baseURL'] . '</homePageLink>
|
|
|
|
<apis>
|
2011-12-19 11:46:01 +01:00
|
|
|
<api name="WordPress" preferred="false" apiLink="' . $serendipity['baseURL'] . 'serendipity_xmlrpc.php" blogID="1" />
|
2011-12-13 12:29:05 +01:00
|
|
|
<api name="MovableType" preferred="true" apiLink="' . $serendipity['baseURL'] . 'serendipity_xmlrpc.php" blogID="1" />
|
2011-12-14 03:12:26 +01:00
|
|
|
<api name="MetaWeblog" preferred="false" apiLink="' . $serendipity['baseURL'] . 'serendipity_xmlrpc.php" blogID="1" />
|
2011-12-13 12:29:05 +01:00
|
|
|
<api name="Blogger" preferred="false" apiLink="' . $serendipity['baseURL'] . 'serendipity_xmlrpc.php" blogID="1" />
|
|
|
|
</apis>
|
|
|
|
</service>
|
|
|
|
</rsd>';
|
|
|
|
}
|
2011-12-14 03:28:58 +01:00
|
|
|
// <api name="WordPress" preferred="false" apiLink="' . $serendipity['baseURL'] . 'serendipity_xmlrpc.php" blogID="1" />
|
2011-12-13 12:29:05 +01:00
|
|
|
|
|
|
|
function introspect_config_item($name, &$propbag)
|
|
|
|
{
|
2012-01-04 16:58:49 +01:00
|
|
|
global $serendipity;
|
|
|
|
|
2011-12-13 12:29:05 +01:00
|
|
|
switch($name) {
|
2012-01-04 16:58:49 +01:00
|
|
|
case 'doc_rpclink':
|
|
|
|
$propbag->add('type', 'content');
|
|
|
|
$propbag->add('default', sprintf(PLUGIN_EVENT_XMLRPC_DOC_RPCLINK, $serendipity['baseURL'] . 'serendipity_xmlrpc.php'));
|
|
|
|
break;
|
2012-01-05 17:46:26 +01:00
|
|
|
case 'debuglog':
|
|
|
|
$debuglevels = array(
|
|
|
|
'none' => PLUGIN_EVENT_XMLRPC_DEBUGLOG_NONE,
|
|
|
|
'normal' => PLUGIN_EVENT_XMLRPC_DEBUGLOG_NORMAL,
|
2012-01-10 03:56:02 +01:00
|
|
|
//'verbose' => PLUGIN_EVENT_XMLRPC_DEBUGLOG_VERBOSE
|
2012-01-05 17:46:26 +01:00
|
|
|
);
|
|
|
|
$propbag->add('type', 'select');
|
|
|
|
$propbag->add('select_values', $debuglevels);
|
|
|
|
$propbag->add('name', PLUGIN_EVENT_XMLRPC_DEBUGLOG);
|
|
|
|
$propbag->add('description', PLUGIN_EVENT_XMLRPC_DEBUGLOG_DESC);
|
|
|
|
$propbag->add('default', 'none');
|
|
|
|
break;
|
2011-12-13 12:29:05 +01:00
|
|
|
case 'gmt':
|
|
|
|
$propbag->add('type', 'boolean');
|
|
|
|
$propbag->add('name', PLUGIN_EVENT_XMLRPC_GMT);
|
|
|
|
$propbag->add('description', '');
|
|
|
|
$propbag->add('default', false);
|
|
|
|
break;
|
2012-01-08 04:48:00 +01:00
|
|
|
case 'uploaddir' :
|
|
|
|
$propbag->add('type', 'select');
|
|
|
|
$propbag->add('select_values', $this->scanUploadDir());
|
|
|
|
$propbag->add('name', PLUGIN_EVENT_XMLRPC_UPLOADDIR);
|
|
|
|
$propbag->add('description', PLUGIN_EVENT_XMLRPC_UPLOADDIR_DESC);
|
|
|
|
$propbag->add('default', '');
|
|
|
|
break;
|
2012-01-07 02:59:07 +01:00
|
|
|
case 'htmlconvert':
|
|
|
|
$propbag->add('type', 'boolean');
|
|
|
|
$propbag->add('name', PLUGIN_EVENT_XMLRPC_HTMLCONVERT);
|
|
|
|
$propbag->add('description', PLUGIN_EVENT_XMLRPC_HTMLCONVERT_DESC);
|
|
|
|
$propbag->add('default', true);
|
|
|
|
break;
|
2012-01-14 13:50:20 +01:00
|
|
|
case 'asureauthor':
|
|
|
|
$authoroptions = array(
|
|
|
|
'default' => PLUGIN_EVENT_XMLRPC_ASUREAUTHOR_DEFAULT,
|
|
|
|
'serendipityUser' => PLUGIN_EVENT_XMLRPC_ASUREAUTHOR_LOGIN,
|
|
|
|
'serendipityRealname' => PLUGIN_EVENT_XMLRPC_ASUREAUTHOR_REALNAME,
|
|
|
|
);
|
|
|
|
$propbag->add('type', 'select');
|
|
|
|
$propbag->add('select_values', $authoroptions);
|
|
|
|
$propbag->add('name', PLUGIN_EVENT_XMLRPC_ASUREAUTHOR);
|
|
|
|
$propbag->add('description', PLUGIN_EVENT_XMLRPC_ASUREAUTHOR_DESC);
|
|
|
|
$propbag->add('default', 'default');
|
|
|
|
break;
|
2012-01-05 17:46:26 +01:00
|
|
|
case 'wpfakeversion' :
|
|
|
|
$propbag->add('type', 'string');
|
|
|
|
$propbag->add('name', PLUGIN_EVENT_XMLRPC_WPFAKEVERSION);
|
|
|
|
$propbag->add('description', PLUGIN_EVENT_XMLRPC_WPFAKEVERSION_DESC);
|
|
|
|
$propbag->add('default', '');
|
|
|
|
break;
|
|
|
|
|
2011-12-13 12:29:05 +01:00
|
|
|
case 'category':
|
|
|
|
$cats = serendipity_fetchCategories($serendipity['authorid']);
|
|
|
|
if (!is_array($cats)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$catlist = serendipity_generateCategoryList($cats, array(0), 4);
|
|
|
|
$tmp_select_cats = explode('@@@', $catlist);
|
|
|
|
|
|
|
|
if (!is_array($tmp_select_cats)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$select_cats = array();
|
|
|
|
$select_cats[''] = '';
|
|
|
|
foreach($tmp_select_cats as $cidx => $tmp_select_cat) {
|
|
|
|
$select_cat = explode('|||', $tmp_select_cat);
|
|
|
|
if (!empty($select_cat[0]) && !empty($select_cat[1])) {
|
|
|
|
$select_cats[$select_cat[0]] = $select_cat[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$propbag->add('type', 'select');
|
|
|
|
$propbag->add('select_values', $select_cats);
|
|
|
|
$propbag->add('name', PLUGIN_EVENT_XMLRPC_DEFAULTCAT);
|
|
|
|
$propbag->add('description', PLUGIN_EVENT_XMLRPC_DEFAULTCAT_DESC);
|
|
|
|
$propbag->add('default', '');
|
|
|
|
break;
|
2012-01-10 03:56:02 +01:00
|
|
|
case 'spamevent_description':
|
|
|
|
$propbag->add('type', 'content');
|
|
|
|
$propbag->add('default', PLUGIN_EVENT_XMLRPC_EVENT_SPAM_HEADER);
|
|
|
|
break;
|
|
|
|
case 'event_spam':
|
|
|
|
case 'event_approved':
|
|
|
|
case 'event_pending':
|
|
|
|
$events = array(
|
|
|
|
'none' => PLUGIN_EVENT_XMLRPC_EVENTVALUE_NONE,
|
|
|
|
'spam' => PLUGIN_EVENT_XMLRPC_EVENTVALUE_SPAM,
|
|
|
|
'ham' => PLUGIN_EVENT_XMLRPC_EVENTVALUE_HAM
|
|
|
|
);
|
|
|
|
$propbag->add('type', 'select');
|
|
|
|
$propbag->add('select_values', $events);
|
|
|
|
if ($name=='event_spam') {
|
|
|
|
$propbag->add('name', PLUGIN_EVENT_XMLRPC_EVENT_SPAM);
|
|
|
|
$propbag->add('description', PLUGIN_EVENT_XMLRPC_EVENT_SPAM_DESC);
|
|
|
|
$propbag->add('default', 'spam');
|
|
|
|
}
|
|
|
|
elseif ($name=='event_approved') {
|
|
|
|
$propbag->add('name', PLUGIN_EVENT_XMLRPC_EVENT_APPROVED);
|
|
|
|
$propbag->add('description', PLUGIN_EVENT_XMLRPC_EVENT_APPROVED_DESC);
|
|
|
|
$propbag->add('default', 'ham');
|
|
|
|
}
|
|
|
|
elseif ($name=='event_pending') {
|
|
|
|
$propbag->add('name', PLUGIN_EVENT_XMLRPC_EVENT_PENDING);
|
|
|
|
$propbag->add('description', PLUGIN_EVENT_XMLRPC_EVENT_PENDING_DESC);
|
|
|
|
$propbag->add('default', 'none');
|
|
|
|
}
|
|
|
|
break;
|
2011-12-13 12:29:05 +01:00
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function event_hook($event, &$bag, &$eventData) {
|
|
|
|
global $serendipity, $HTTP_RAW_POST_DATA;
|
|
|
|
|
|
|
|
$hooks = &$bag->get('event_hooks');
|
|
|
|
$links = array();
|
|
|
|
$article_show = false;
|
|
|
|
|
|
|
|
if (isset($hooks[$event])) {
|
|
|
|
switch($event) {
|
|
|
|
case 'frontend_header':
|
2011-12-21 12:45:03 +01:00
|
|
|
echo '<link rel="pingback" href="' . $serendipity['baseURL'] . 'serendipity_xmlrpc.php" />' . "\n";
|
|
|
|
echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . $serendipity['baseURL'] . 'serendipity_xmlrpc.php?xsd=true" />' . "\n";
|
|
|
|
break;
|
2011-12-13 12:29:05 +01:00
|
|
|
|
|
|
|
case 'frontend_xmlrpc':
|
|
|
|
// Those variables should not be set by other plugins!
|
|
|
|
header('Content-Type: text/xml');
|
|
|
|
$eventData = array('XML-RPC' => true);
|
|
|
|
|
|
|
|
if ($_REQUEST['xsd']) {
|
|
|
|
$this->showXSD();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
unset($serendipity['GET']['category']);
|
|
|
|
unset($serendipity['GET']['hide_category']);
|
|
|
|
$serendipity['xmlrpc_default_category'] = $this->get_config('category');
|
2012-01-05 17:46:26 +01:00
|
|
|
$serendipity['xmlrpc_debuglog'] = $this->get_config('debuglog','none');
|
|
|
|
$serendipity['xmlrpc_wpfakeversion'] = $this->get_config('wpfakeversion','');
|
2012-01-07 02:59:07 +01:00
|
|
|
$serendipity['xmlrpc_htmlconvert'] = $this->get_config('htmlconvert',true);
|
2012-01-08 04:48:00 +01:00
|
|
|
$serendipity['xmlrpc_uploadreldir'] = $this->get_config('uploaddir','');
|
2012-01-14 13:50:20 +01:00
|
|
|
$serendipity['xmlrpc_asureauthor'] = $this->get_config('asureauthor','default');
|
2012-01-08 04:48:00 +01:00
|
|
|
|
2012-01-10 03:56:02 +01:00
|
|
|
$serendipity['xmlrpc_event_spam'] = $this->get_config('event_spam','spam');
|
|
|
|
$serendipity['xmlrpc_event_approved'] = $this->get_config('event_approved','ham');
|
|
|
|
$serendipity['xmlrpc_event_pending'] = $this->get_config('event_approved','none');
|
|
|
|
|
2011-12-13 12:29:05 +01:00
|
|
|
@define('SERENDIPITY_IS_XMLRPC', true);
|
|
|
|
$serendipity['XMLRPC_GMT'] = serendipity_db_bool($this->get_config('gmt'));
|
2011-12-21 12:45:03 +01:00
|
|
|
|
|
|
|
$this->setupPearPath();
|
2011-12-13 12:29:05 +01:00
|
|
|
if (!class_exists('XML_RPC_Base')) {
|
2011-12-21 12:45:03 +01:00
|
|
|
require_once PLUGIN_EVENT_XMLRPC_PEAR_PATH . 'XML/RPC.php';
|
2011-12-13 12:29:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!class_exists('XML_RPC_Server')) {
|
2011-12-21 12:45:03 +01:00
|
|
|
require_once PLUGIN_EVENT_XMLRPC_PEAR_PATH . 'XML/RPC/Server.php';
|
2011-12-13 12:29:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
require_once dirname(__FILE__) . '/serendipity_xmlrpc.inc.php';
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2011-12-21 12:45:03 +01:00
|
|
|
|
|
|
|
function setupPearPath() {
|
|
|
|
// use bundled PEAR modules instead of plugins, if found
|
2011-12-21 13:08:28 +01:00
|
|
|
// The s9y bundled lib could be outdated. Upgrading it with the plugin is much more easy.
|
|
|
|
/*
|
2011-12-21 12:45:03 +01:00
|
|
|
@define('S9Y_PEAR_PATH', $serendipity['serendipityPath'] . 'bundled-libs/');
|
|
|
|
if (file_exists(S9Y_PEAR_PATH . 'XML/RPC.php') && file_exists(S9Y_PEAR_PATH . 'XML/RPC/Server.php')) {
|
|
|
|
@define('PLUGIN_EVENT_XMLRPC_PEAR_PATH', S9Y_PEAR_PATH);
|
|
|
|
}
|
2011-12-21 13:08:28 +01:00
|
|
|
else { */
|
2011-12-21 12:45:03 +01:00
|
|
|
@define('PLUGIN_EVENT_XMLRPC_PEAR_PATH',dirname(__FILE__) . '/PEAR/');
|
2011-12-21 13:08:28 +01:00
|
|
|
// }
|
2011-12-21 12:45:03 +01:00
|
|
|
}
|
2012-01-08 04:48:00 +01:00
|
|
|
|
|
|
|
function scanUploadDir(){
|
|
|
|
global $serendipity;
|
|
|
|
|
|
|
|
if (!serendipity_checkPermission('adminImagesDirectories')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$folders = serendipity_traversePath(
|
|
|
|
$serendipity['serendipityPath'] . $serendipity['uploadPath'],
|
|
|
|
'',
|
|
|
|
true,
|
|
|
|
NULL,
|
|
|
|
1,
|
|
|
|
NULL,
|
|
|
|
'write'
|
|
|
|
);
|
|
|
|
usort($folders, 'serendipity_sortPath');
|
|
|
|
$result = array('' => PARENT_DIRECTORY);
|
|
|
|
foreach ($folders as $dirmeta) {
|
|
|
|
$result[$dirmeta['relpath']] = $dirmeta['relpath'];
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
2011-12-13 12:29:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* vim: set sts=4 ts=4 expandtab : */
|