function mob_get_user_topic($rpcmsg) { global $mobdb, $context, $scripturl, $modSettings, $sourcedir; require_once $sourcedir . '/Subs-Auth.php'; // Get the user $username = $rpcmsg->getScalarValParam(0); $id_user = $rpcmsg->getParam(1) ? $rpcmsg->getScalarValParam(1) : null; // If we have an user ID, use it otherwise search for the user if (!is_null($id_user)) { $request = $mobdb->query(' SELECT ID_MEMBER FROM {db_prefix}members WHERE ID_MEMBER = {int:member}', array('member' => $id_user)); if ($mobdb->num_rows($request) == 0) { $id_user = null; } else { list($id_user) = $mobdb->fetch_row($request); } $mobdb->free_result($request); } // Otherwise search from the DB, if (is_null($id_user)) { $username = utf8ToAscii($username); $members = findMembers($username); if (empty($members)) { mob_error('user not found'); } $member_ids = array_keys($members); $id_user = $members[$member_ids[0]]['id']; } // Return the topics by this user return new xmlrpcresp(new xmlrpcval(get_topics('t.ID_MEMBER_STARTED = {int:member}', array('member' => $id_user), 0, 50, true), 'array')); }
function mob_get_subscribed_topic($rpcmsg) { global $mobdb, $context, $scripturl, $settings; // Start and end...The usual business $start = $rpcmsg->getParam(0) ? $rpcmsg->getScalarValParam(0) : 0; $end = $rpcmsg->getParam(1) ? $rpcmsg->getScalarValParam(1) : 9; list($start, $limit) = process_page($start, $end); // Get the subscribed topic ID's $topics = get_subscribed_tids(); $count = count($topics); $topics = !empty($topics) ? get_topics('t.ID_TOPIC IN ({array_int:topics})', array('topics' => $topics), $start, $limit, false) : array(); // Return the topics return new xmlrpcresp(new xmlrpcval(array('total_topic_num' => new xmlrpcval($count, 'int'), 'topics' => new xmlrpcval($topics, 'array')), 'struct')); }
protected function topics() { global $db; $params = array(); if ($this->method == "GET") { if (sizeof($this->args) == 0) { return get_topics($db, $params); } else { return "This returns all topics, therefore no parameters are taken!"; } } else { return "This only accepts GET requests!"; } }
<?php echo '<li><strong>相关操作:</strong></li>'; echo '<li><a href="resource_editor.php?db_name=' . $db_name . '&id=' . $file_id . '"><span class="glyphicon glyphicon-edit"></span> 编辑文献元数据</a></li>'; if ($row['file'] != '') { $file_name = iconv('utf-8', 'gb2312', $row['file']); if (is_file(GW_UPLOADPATH . $db_name . '/' . $file_name)) { echo '<li><a class="btn btn-link " href="' . GW_UPLOADPATH . $db_name . '/' . $row['file'] . '"><span class="glyphicon glyphicon-cloud-download"></span> 下载原文</a></li>'; } else { echo '<li class="disabled"><a><span class="glyphicon glyphicon-cloud-download"></span>下载原文</a>'; } } else { echo '<li class="disabled"><a><span class="glyphicon glyphicon-cloud-download"></span>下载原文</a>'; } echo '<hr>'; echo '<li><strong>相关主题:</strong></li> '; foreach (get_topics($row['subject']) as $topic) { if ($topic != '') { echo '<li><a href="#">' . $topic . '</a></li>'; } } echo '<hr>'; echo '<li><strong>录入时间: </strong></li>'; echo '<li>' . $row['create_time'] . '</li>'; ?> </ul> </div>
delete_programming_language($pl_id, Flight::request()); }); Flight::route('GET /programming_languages/@pl_id', function ($pl_id) { incl('get_programming_language'); get_programming_language($pl_id, Flight::request()); }); Flight::route('/programming_languages/@pl_id', function ($pl_id) { method_not_allowed(); }); Flight::route('POST /topics', function () { incl('create_topic'); create_topic(Flight::request()); }); Flight::route('GET /topics', function () { incl('get_topics'); get_topics(Flight::request()); }); Flight::route('/topics', function () { method_not_allowed(); }); Flight::route('GET /topics/@topic_id', function ($topic_id) { incl('get_topic'); get_topic($topic_id, Flight::request()); }); Flight::route('DELETE /topics/@topic_id', function ($topic_id) { incl('delete_topic'); delete_topic($topic_id, Flight::request()); }); Flight::route('/topic/@topic_id', function ($topic_id) { method_not_allowed(); });
function mob_get_participated_topic($rpcmsg) { global $mobdb, $scripturl, $user_info, $settings, $modSettings, $sourcedir; require_once $sourcedir . '/Subs-Auth.php'; // Load the parameters, username must always be there $username = $rpcmsg->getScalarValParam(0); $start = $rpcmsg->getParam(1) ? $rpcmsg->getScalarValParam(1) : 0; $end = $rpcmsg->getParam(2) ? $rpcmsg->getScalarValParam(2) : $start + 9; $id_user = $rpcmsg->getParam(3) ? (int) $rpcmsg->getScalarValParam(3) : null; $count = $end - $start + 1; // If we have an user ID, use it otherwise search for the user if (!is_null($id_user)) { $request = $mobdb->query(' SELECT ID_MEMBER FROM {db_prefix}members WHERE ID_MEMBER = {int:member}', array('member' => $id_user)); if ($mobdb->num_rows($request) == 0) { $id_user = null; } else { list($id_user) = $mobdb->fetch_row($request); } $mobdb->free_result($request); } // Otherwise search from the DB, if (is_null($id_user)) { $username = utf8ToAscii($username); $members = findMembers($username); if (empty($members)) { mob_error('user not found'); } $member_ids = array_keys($members); $id_user = $members[$member_ids[0]]['id']; } // Get the topic's count $request = $mobdb->query(' SELECT COUNT(*) FROM {db_prefix}messages AS m INNER JOIN {db_prefix}topics AS t ON (m.ID_TOPIC = t.ID_TOPIC) WHERE m.ID_MEMBER = {int:member} GROUP BY m.ID_TOPIC', array('member' => $id_user)); list($topic_count) = $mobdb->fetch_row($request); $mobdb->free_result($request); // Get the topics themselves $request = $mobdb->query(' SELECT t.ID_TOPIC AS 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 = m.ID_BOARD) INNER JOIN {db_prefix}messages AS lm ON (t.ID_LAST_MSG = lm.ID_MSG) WHERE m.ID_MEMBER = {int:member} AND {query_see_board} GROUP BY m.ID_TOPIC ORDER BY lm.posterTime DESC LIMIT {int:start}, {int:limit}', array('member' => $id_user, 'start' => $start, 'limit' => $count)); $topics = array(); while ($row = $mobdb->fetch_assoc($request)) { $topics[] = $row['id_topic']; } $mobdb->free_result($request); // Return the topics return new xmlrpcresp(new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean'), 'total_topic_num' => new xmlrpcval($topic_count, 'int'), 'topics' => new xmlrpcval(!empty($topics) ? get_topics('t.ID_TOPIC IN ({array_int:topics})', array('topics' => $topics), $start, $count, false) : array(), 'array')), 'struct')); }