function createErrorResponse($code, $append = '', $type = 'mobiquo') { global $context, $scripturl, $mobsettings; // Error not found? if (empty($mobsettings[$type . '_error'][$code])) { return createErrorResponse('server_error', '', 'xmlrpc'); } $faultString = $mobsettings[$type . '_error'][$code] . $append; // Get the faultCode... if (is_int($code) || is_numeric($code)) { $faultCode = $code; } else { $i = 0; foreach ($mobsettings[$type . '_error'] as $key => $val) { $i++; if ($key == $code) { $faultCode = $i; } } } // Now that we have figurred it out, output the XML outputRPCResponse(' <params> <param> <value><struct> <member><name>result</name> <value><boolean>0</boolean></value> </member> <member><name>result_text</name> <value><base64>' . base64_encode($faultString) . '</base64></value> </member> </struct></value> </param> </params>'); }
require_once './api/post.php'; require_once './api/moderation.php'; header('Mobiquo_is_login: '******'is_guest'] ? 'false' : 'true')); header('Content-type: text/xml'); $rpcServer = new xmlrpc_server($methods, false); $rpcServer->setDebug(1); $rpcServer->compress_response = true; $rpcServer->response_charset_encoding = 'UTF-8'; $pass = $rpcServer->service(); if ($pass !== false) { exit; } // Load settings and the database loadMobiquoSettings(); // Parse the request parseMobRequest(); // Are we closed? if (!empty($context['in_maintenance']) && !$user_info['is_admin'] && !in_array($context['mob_request']['method'], array('get_config', 'login'))) { createErrorResponse(5, ' due to maintenance'); } // Invalid method? if (!function_exists('method_' . $context['mob_request']['method'])) { createErrorResponse('unknown_method', ' : ' . $context['mob_request']['method'], 'xmlrpc'); } if (isset($mobiquo_config['hide_forum_id']) && count($mobiquo_config['hide_forum_id']) && !$user_info['is_admin']) { $user_info['query_see_board'] .= ' AND b.ID_BOARD NOT IN (' . implode(',', $mobiquo_config['hide_forum_id']) . ') '; } @ob_end_clean(); // Allright, method passed...call it call_user_func('method_' . $context['mob_request']['method']); exit;
function method_get_participated_topic() { global $context, $mobdb, $mobsettings, $modSettings, $user_info, $sourcedir; // Guest? if ($user_info['is_guest']) { createErrorResponse(21); } // Get the username $username = base64_decode($context['mob_request']['params'][0][0]); if (empty($username)) { createErrorResponse(8); } require_once $sourcedir . '/Subs-Auth.php'; ######## Added by Sean############## $username = htmltrim__recursive($username); $username = stripslashes__recursive($username); $username = htmlspecialchars__recursive($username); $username = addslashes__recursive($username); ################################################################## // Does this user exist? $members = findMembers($username); if (empty($members)) { createErrorResponse(8); } $id_member = array_keys($members); $member = $members[$id_member[0]]; if (empty($member)) { createErrorResponse(8); } // Do we have start num defined? if (isset($context['mob_request']['params'][1])) { $start_num = (int) $context['mob_request']['params'][1][0]; } // Do we have last number defined? if (isset($context['mob_request']['params'][2])) { $last_num = (int) $context['mob_request']['params'][2][0]; } // Perform some start/last num checks if (isset($start_num) && isset($last_num)) { if ($start_num > $last_num) { createErrorResponse(3); } elseif ($last_num - $start_num > 50) { $last_num = $start_num + 50; } } // Default number of topics per page $topics_per_page = 20; // Generate the limit clause $limit = ''; if (!isset($start_num) && !isset($last_num)) { $start_num = 0; $limit = $topics_per_page; } elseif (isset($start_num) && !isset($last_num)) { $limit = $topics_per_page; } elseif (isset($start_num) && isset($last_num)) { $limit = $last_num - $start_num + 1; } elseif (empty($start_num) && empty($last_num)) { $start_num = 0; $limit = $topics_per_page; } // Get the count $mobdb->query(' SELECT t.ID_TOPIC FROM {db_prefix}messages AS m INNER JOIN {db_prefix}topics AS t ON (m.ID_TOPIC = t.ID_TOPIC) INNER JOIN {db_prefix}boards AS b ON (b.ID_BOARD = t.ID_BOARD) WHERE {query_see_board} AND m.ID_MEMBER = {int:member} GROUP BY t.ID_TOPIC ORDER BY t.ID_TOPIC DESC', array('member' => $id_member[0])); $tids = array(); while ($row = $mobdb->fetch_assoc()) { $tids[] = $row['ID_TOPIC']; } $mobdb->free_result(); $count = count($tids); if ($limit + $start_num > $count) { $limit = $count - $start_num; } $tids = array_slice($tids, $start_num, $limit); $topics = array(); if (count($tids)) { // Grab the topics $mobdb->query(' SELECT t.ID_TOPIC AS id_topic, t.isSticky AS is_sticky, t.locked, fm.subject AS topic_title, t.numViews AS views, t.numReplies AS replies, IFNULL(mem.ID_MEMBER, 0) AS id_member, mem.realName, mem.memberName, mem.avatar, IFNULL(a.ID_ATTACH, 0) AS id_attach, a.filename, a.attachmentType AS attachment_type, IFNULL(lm.posterTime, fm.posterTime) AS last_message_time, ' . ($user_info['is_guest'] ? '0' : 'ln.ID_TOPIC AS is_notify, IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1') . ' AS new_from, IFNULL(lm.body, fm.body) AS body, lm.ID_MSG_MODIFIED AS id_msg_modified, b.name AS board_name, b.ID_BOARD AS id_board FROM {db_prefix}messages AS m INNER JOIN {db_prefix}topics AS t ON (m.ID_TOPIC = t.ID_TOPIC) INNER JOIN {db_prefix}messages AS fm ON (t.ID_FIRST_MSG = fm.ID_MSG) INNER JOIN {db_prefix}boards AS b ON (b.ID_BOARD = t.ID_BOARD) LEFT JOIN {db_prefix}messages AS lm ON (t.ID_LAST_MSG = lm.ID_MSG) LEFT JOIN {db_prefix}members AS mem ON (lm.ID_MEMBER = mem.ID_MEMBER)' . ($user_info['is_guest'] ? '' : ' LEFT JOIN {db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = {int:current_member}) LEFT JOIN {db_prefix}log_notify AS ln ON ((ln.ID_TOPIC = t.ID_TOPIC OR ln.ID_BOARD = t.ID_BOARD) AND ln.ID_MEMBER = {int:current_member}) LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = {int:current_member})') . ' LEFT JOIN {db_prefix}attachments AS a ON (a.ID_MEMBER = mem.ID_MEMBER) WHERE {query_see_board} AND m.ID_MEMBER = {int:member} AND t.ID_TOPIC IN ({array_int:topic_ids}) ORDER BY lm.posterTime DESC', array('current_member' => $user_info['id'], 'member' => $id_member[0], 'topic_ids' => $tids)); while ($row = $mobdb->fetch_assoc()) { // Add stuff to the array $topics[$row['id_topic']] = array('id' => $row['id_topic'], 'title' => processSubject($row['topic_title']), 'short_msg' => processShortContent($row['body']), 'replies' => $row['replies'], 'views' => $row['views'], 'poster' => array('id' => $row['id_member'], 'username' => $row['memberName'], 'post_name' => $row['realName'], 'avatar' => get_avatar($row)), 'is_new' => $user_info['is_guest'] ? 0 : $row['new_from'] <= $row['id_msg_modified'], 'board' => $row['id_board'], 'board_name' => $row['board_name'], 'post_time' => mobiquo_time($row['last_message_time']), 'is_marked_notify' => !empty($row['is_notify']), 'is_locked' => !empty($row['locked'])); } $mobdb->free_result(); } // LAME! outputRPCSubscribedTopics($topics, $count); }