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')); }
function get_box_func($xmlrpc_params) { global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups; $input = Tapatalk_Input::filterXmlInput(array('box_id' => Tapatalk_Input::INT, 'start_num' => Tapatalk_Input::INT, 'last_num' => Tapatalk_Input::INT), $xmlrpc_params); list($start, $limit) = process_page($input['start_num'], $input['last_num']); $lang->load("private"); $parser = new postParser(); if ($mybb->settings['enablepms'] == 0) { return xmlrespfalse($lang->pms_disabled); } if ($mybb->user['uid'] == '/' || $mybb->user['uid'] == 0 || $mybb->usergroup['canusepms'] == 0) { return tt_no_permission(); } if (!$mybb->user['pmfolders']) { $mybb->user['pmfolders'] = "1**\$%%\$2**\$%%\$3**\$%%\$4**"; $sql_array = array("pmfolders" => $mybb->user['pmfolders']); $db->update_query("users", $sql_array, "uid = " . $mybb->user['uid']); } $rand = my_rand(0, 9); if ($rand == 5) { update_pm_count(); } $foldernames = array(); $foldersexploded = explode("\$%%\$", $mybb->user['pmfolders']); foreach ($foldersexploded as $key => $folders) { $folderinfo = explode("**", $folders, 2); $folderinfo[1] = get_pm_folder_name($folderinfo[0], $folderinfo[1]); $foldernames[$folderinfo[0]] = $folderinfo[1]; } if (!$input['box_id'] || !array_key_exists($input['box_id'], $foldernames)) { $input['box_id'] = 1; } $folder = $input['box_id']; $foldername = $foldernames[$folder]; $lang->pms_in_folder = $lang->sprintf($lang->pms_in_folder, $foldername); if ($folder == 2 || $folder == 3) { $sender = $lang->sentto; } else { $sender = $lang->sender; } // Do Multi Pages $query = $db->simple_select("privatemessages", "COUNT(*) AS total", "uid='" . $mybb->user['uid'] . "' AND folder='{$folder}'"); $count_total = $db->fetch_field($query, 'total'); $query = $db->simple_select("privatemessages", "COUNT(*) AS unread", "uid='" . $mybb->user['uid'] . "' AND folder='{$folder}' AND readtime = 0"); $count_unread = $db->fetch_field($query, 'unread'); // Get all recipients into an array $cached_users = $get_users = array(); $users_query = $db->simple_select("privatemessages", "recipients", "folder='{$folder}' AND uid='{$mybb->user['uid']}'", array('limit_start' => $start, 'limit' => $limit, 'order_by' => 'dateline', 'order_dir' => 'DESC')); while ($row = $db->fetch_array($users_query)) { $recipients = unserialize($row['recipients']); if (is_array($recipients['to']) && count($recipients['to'])) { $get_users = array_merge($get_users, $recipients['to']); } if (is_array($recipients['bcc']) && count($recipients['bcc'])) { $get_users = array_merge($get_users, $recipients['bcc']); } } $get_users = implode(',', array_unique($get_users)); // Grab info if ($get_users) { $users_query = $db->simple_select("users", "uid, username, usergroup, displaygroup", "uid IN ({$get_users})"); while ($user = $db->fetch_array($users_query)) { $cached_users[$user['uid']] = $user; } } $user_online = $folder == 1 ? ', fu.lastactive, fu.invisible, fu.lastvisit ' : ', tu.lastactive, tu.invisible, tu.lastvisit '; $query = $db->query("\n\t\tSELECT pm.*, fu.username AS fromusername, tu.username as tousername, fu.avatar as favatar, tu.avatar as tavatar {$user_online}\n\t\tFROM " . TABLE_PREFIX . "privatemessages pm\n\t\tLEFT JOIN " . TABLE_PREFIX . "users fu ON (fu.uid=pm.fromid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "users tu ON (tu.uid=pm.toid)\n\t\tWHERE pm.folder='{$folder}' AND pm.uid='" . $mybb->user['uid'] . "'\n\t\tORDER BY pm.dateline DESC\n\t\tLIMIT {$start}, {$limit}\n\t"); $message_list = array(); if ($db->num_rows($query) > 0) { while ($message = $db->fetch_array($query)) { $status = 1; if ($message['status'] == 0) { $msgalt = $lang->new_pm; } elseif ($message['status'] == 1) { $msgalt = $lang->old_pm; $status = 2; } elseif ($message['status'] == 3) { $msgalt = $lang->reply_pm; $status = 3; } elseif ($message['status'] == 4) { $msgalt = $lang->fwd_pm; $status = 4; } $msg_from = null; $msg_to = array(); $avatar = ""; $outboxdisplayuserid = 0; // Sent Items or Drafts Folder Check $recipients = unserialize($message['recipients']); if (count($recipients['to']) > 1 || count($recipients['to']) == 1 && count($recipients['bcc']) > 0) { foreach ($recipients['to'] as $uid) { $profilelink = get_profile_link($uid); $user = $cached_users[$uid]; if (!empty($user['username'])) { $msg_to[] = new xmlrpcval(array("username" => new xmlrpcval($user['username'], "base64"), "user_id" => new xmlrpcval($uid, "string"), "user_type" => check_return_user_type($user['username'])), "struct"); } if (($folder == 2 or $folder == 3) && !$outboxdisplayuserid) { $outboxdisplayuserid = $uid; } } /*if(is_array($recipients['bcc']) && count($recipients['bcc'])) { foreach($recipients['bcc'] as $uid) { $profilelink = get_profile_link($uid); $user = $cached_users[$uid]; $msg_to[]=new xmlrpcval($user['username'], "base64"); } }*/ } else { if ($message['toid']) { $tofromusername = $message['tousername']; $tofromuid = $message['toid']; if (!empty($tofromusername)) { $msg_to[] = new xmlrpcval(array("username" => new xmlrpcval($tofromusername, "base64"), "user_id" => new xmlrpcval($message['toid'], "string"), "user_type" => check_return_user_type($tofromusername)), "struct"); } } } $avatar = $message['tavatar']; if ($folder != 2 && $folder != 3) { $tofromusername = $message['fromusername']; $tofromuid = $message['fromid']; if ($tofromuid == 0) { $tofromusername = $lang->mybb_engine; } if (!$tofromusername) { $tofromuid = 0; $tofromusername = $lang->na; } $msg_from = $tofromusername; $avatar = $message['favatar']; } else { if ($outboxdisplayuserid) { $outboxdisplayuser = get_user($outboxdisplayuserid); $avatar = $outboxdisplayuser['avatar']; } } if (!trim($message['subject'])) { $message['subject'] = $lang->pm_no_subject; } $is_online = false; $timecut = TIME_NOW - $mybb->settings['wolcutoff']; if ($message['lastactive'] > $timecut && ($message['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1) && $message['lastvisit'] != $message['lastactive']) { $is_online = true; } $new_message = array('msg_id' => new xmlrpcval($message['pmid'], 'string'), 'msg_state' => new xmlrpcval($status, 'int'), 'sent_date' => new xmlrpcval(mobiquo_iso8601_encode($message['dateline']), 'dateTime.iso8601'), 'msg_to' => new xmlrpcval($msg_to, 'array'), 'icon_url' => new xmlrpcval(absolute_url($avatar), 'string'), 'msg_subject' => new xmlrpcval($message['subject'], 'base64'), 'short_content' => new xmlrpcval(process_short_content($message['message'], $parser), 'base64'), 'is_online' => new xmlrpcval($is_online, 'boolean')); if ($msg_from !== null) { $new_message['msg_from'] = new xmlrpcval($msg_from, 'base64'); } $message_list[] = new xmlrpcval($new_message, "struct"); } } $result = new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean'), 'result_text' => new xmlrpcval('', 'base64'), 'total_message_count' => new xmlrpcval($count_total, 'int'), 'total_unread_count' => new xmlrpcval($count_unread, 'int'), 'list' => new xmlrpcval($message_list, 'array')), 'struct'); return new xmlrpcresp($result); }
case 'get_user_reply_post': $function_file_name = 'search'; $include_topic_num = false; $_GET['page'] = 1; $_GET['perpage'] = 20; $_GET['action'] = 'finduser'; if (isset($request_params[1]) && intval($request_params[1])) { $_GET['uid'] = intval($request_params[1]); } else { $_GET['username'] = $request_params[0]; } break; case 'get_subscribed_topic': $function_file_name = 'search'; $include_topic_num = true; list($start, $limit, $page) = process_page($request_params[0], $request_params[1]); $_GET['page'] = $page; $_GET['perpage'] = $limit; $_GET['action'] = 'getsubs'; break; case 'like_post': case 'thank_post': $function_file_name = 'thankyoulike'; $_GET['pid'] = $request_params[0]; $_GET['action'] = 'add'; break; case 'unlike_post': case 'remove_thank_post': $function_file_name = 'thankyoulike'; $_GET['pid'] = $request_params[0]; $_GET['action'] = 'del';
print_r($postvars) . "\n"; $cookie = $m[1]; print "cookie" . $cookie . "\n"; $applications = process_page($html); //print_r($applications); foreach ($applications as $key => $value) { scraperwiki::save_sqlite(array('appref', 'url'), $value); } unset($applications); if (stristr($html, "Currently viewing page")) { # There's >1 pages of results # I'm sorry. I'm so sorry. $hackysplice = explode("Currently viewing page", $html); $hackysplice2 = explode("</font>", $hackysplice[1]); $hackysplice3 = explode(" of ", $hackysplice2[0]); $numpages = intval($hackysplice3[1]); unset($html); while ($thispage < $numpages) { $postvars["page_num"] = $thispage; print $thispage . " of " . $numpages . "\n"; $postvars["Op"] = 1; $html = scraperpost("http://planning.corkcity.ie/InternetEnquiry/frmSelCritSearch.asp?page_num=" . $thispage . "&Op=1", NULL, $cookie); $applications = process_page($html); foreach ($applications as $key => $value) { scraperwiki::save_sqlite(array('appref', 'url'), $value); } $thispage += 1; unset($applications); unset($html); } }
//search for the entity on wikipedia $page = get_wiki_title($query); $title = $page; if (!$page) { echo "Can not find sufficient information on wikipedia"; exit(1); } $page = str_replace(" ", "_", $page); $page = "http://en.wikipedia.org/wiki/" . $page; //$page="http://en.wikipedia.org/wiki/Mahatma_Gandhi"; /*$sentence="next sale is scheduled for oct 14, 2014"; $i=20; process_sentence($sentence,$i); exit();*/ $content = file_get_contents($page); process_page($content); //printf("max_rules=%d\n",MAX_RULES); //Now process the rule_hits array foreach ($rule_hits as $sentence_hits) { $event = array(); foreach ($sentence_hits as $hit) { //print_r($hit); $event['sid'] = $hit['sid']; if (isset($hit['day'])) { $event['day'] = $hit['day']; } if (isset($hit['month'])) { $event['month'] = $hit['month']; } if (isset($hit['year'])) { $event['year'] = $hit['year'];
function get_thread_func($xmlrpc_params) { global $db, $lang, $mybb, $position, $plugins, $pids; global $pforumcache, $currentitem, $forum_cache, $navbits, $base_url, $archiveurl; $input = Tapatalk_Input::filterXmlInput(array('topic_id' => Tapatalk_Input::STRING, 'start_num' => Tapatalk_Input::INT, 'last_num' => Tapatalk_Input::INT, 'return_html' => Tapatalk_Input::INT), $xmlrpc_params); if (preg_match('/^ann_/', $input['topic_id'])) { $_GET["aid"] = intval(str_replace('ann_', '', $input['topic_id'])); return get_announcement_func($xmlrpc_params); } $lang->load("showthread"); global $parser; $parser = new Tapatalk_Parser(); // Get the thread details from the database. $thread = get_thread($input['topic_id']); if (!empty($thread['closed'])) { $moved = explode("|", $thread['closed']); if ($moved[0] == "moved") { $thread = get_thread($moved[1]); } } // Get thread prefix if there is one. $thread['threadprefix'] = ''; $thread['displayprefix'] = ''; if ($thread['prefix'] != 0) { $threadprefix = build_prefixes($thread['prefix']); if ($threadprefix['prefix']) { $thread['threadprefix'] = $threadprefix['prefix'] . ' '; $thread['displayprefix'] = $threadprefix['displaystyle'] . ' '; } } $thread['subject'] = $parser->parse_badwords($thread['subject']); $tid = $thread['tid']; $fid = $thread['fid']; if (!$thread['username']) { $thread['username'] = $lang->guest; } $visibleonly = "AND visible='1'"; // Is the currently logged in user a moderator of this forum? if (is_moderator($fid)) { $visibleonly = " AND (visible='1' OR visible='0')"; $ismod = true; } else { $ismod = false; } $forumpermissions = forum_permissions($thread['fid']); // Does the user have permission to view this thread? if ($forumpermissions['canview'] != 1 || $forumpermissions['canviewthreads'] != 1) { error_no_permission(); } if ($forumpermissions['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid']) { error_no_permission(); } // Make sure we are looking at a real thread here. if (!$thread['tid'] || $thread['visible'] == 0 && $ismod == false || $thread['visible'] > 1 && $ismod == true) { return xmlrespfalse($lang->error_invalidthread); } // Does the thread belong to a valid forum? $forum = get_forum($fid); if (!$forum || $forum['type'] != "f") { return xmlrespfalse($lang->error_invalidforum); } tt_check_forum_password($forum['fid']); if ($thread['firstpost'] == 0) { update_first_post($tid); } // Mark this thread as read mark_thread_read($tid, $fid); // Increment the thread view. if ($mybb->settings['delayedthreadviews'] == 1) { $db->shutdown_query("INSERT INTO " . TABLE_PREFIX . "threadviews (tid) VALUES('{$tid}')"); } else { $db->shutdown_query("UPDATE " . TABLE_PREFIX . "threads SET views=views+1 WHERE tid='{$tid}'"); } ++$thread['views']; // Work out if we are showing unapproved posts as well (if the user is a moderator etc.) if ($ismod) { $visible = "AND (p.visible='0' OR p.visible='1')"; } else { $visible = "AND p.visible='1'"; } // Fetch the ignore list for the current user if they have one $ignored_users = array(); if ($mybb->user['uid'] > 0 && $mybb->user['ignorelist'] != "") { $ignore_list = explode(',', $mybb->user['ignorelist']); foreach ($ignore_list as $uid) { $ignored_users[$uid] = 1; } } list($start, $limit) = process_page($input['start_num'], $input['last_num']); // Recount replies if user is a moderator to take into account unapproved posts. if ($ismod) { $query = $db->simple_select("posts p", "COUNT(*) AS replies", "p.tid='{$tid}' {$visible}"); $thread['replies'] = $db->fetch_field($query, 'replies') - 1; } $postcount = intval($thread['replies']) + 1; $pids = ""; $comma = ''; $query = $db->simple_select("posts p", "p.pid", "p.tid='{$tid}' {$visible}", array('order_by' => 'p.dateline', 'limit_start' => $start, 'limit' => $limit)); while ($getid = $db->fetch_array($query)) { // Set the ID of the first post on page to $pid if it doesn't hold any value // to allow this value to be used for Thread Mode/Linear Mode links // and ensure the user lands on the correct page after changing view mode if (!$pid) { $pid = $getid['pid']; } // Gather a comma separated list of post IDs $pids .= "{$comma}'{$getid['pid']}'"; $comma = ","; } if ($pids) { $pids = "pid IN({$pids})"; global $attachcache; $attachcache = array(); if ($thread['attachmentcount'] > 0) { // Now lets fetch all of the attachments for these posts. $query = $db->simple_select("attachments", "*", $pids); while ($attachment = $db->fetch_array($query)) { $attachcache[$attachment['pid']][$attachment['aid']] = $attachment; } } } else { // If there are no pid's the thread is probably awaiting approval. return xmlrespfalse($lang->error_invalidthread); } $post_list = array(); // Get the actual posts from the database here. $posts = ''; $query = $db->query("\n SELECT u.*, u.username AS userusername, p.*, f.*, eu.username AS editusername, IF(b.lifted > UNIX_TIMESTAMP() OR b.lifted = 0, 1, 0) as isbanned\n FROM " . TABLE_PREFIX . "posts p\n LEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=p.uid)\n LEFT JOIN " . TABLE_PREFIX . "userfields f ON (f.ufid=u.uid)\n LEFT JOIN " . TABLE_PREFIX . "users eu ON (eu.uid=p.edituid)\n LEFT JOIN " . TABLE_PREFIX . "banned b ON (b.uid = p.uid)\n WHERE {$pids}\n ORDER BY p.dateline\n "); //can_rename topic $can_rename = (is_moderator($fid, "caneditposts") || $forumpermissions['caneditposts'] == 1 && $mybb->user['uid'] == $thread['uid']) && $mybb->user['uid'] != 0; while ($post = $db->fetch_array($query)) { if ($thread['firstpost'] == $post['pid'] && $thread['visible'] == 0) { $post['visible'] = 0; } //$posts .= build_postbit($post); $parser_options = array(); $parser_options['allow_html'] = false; $parser_options['allow_mycode'] = true; $parser_options['allow_smilies'] = false; $parser_options['allow_imgcode'] = true; $parser_options['allow_videocode'] = true; $parser_options['nl2br'] = (bool) $input['return_html']; $parser_options['filter_badwords'] = 1; if (!$post['username']) { $post['username'] = $lang->guest; } if ($post['userusername']) { $parser_options['me_username'] = $post['userusername']; } else { $parser_options['me_username'] = $post['username']; } $post['subject'] = $parser->parse_badwords($post['subject']); $post['author'] = $post['uid']; if ($post['userusername']) { // This post was made by a registered user $post['username'] = $post['userusername']; } // Eidt Option $can_edit = (is_moderator($fid, "caneditposts") || $forumpermissions['caneditposts'] == 1 && $mybb->user['uid'] == $post['uid']) && $mybb->user['uid'] != 0; // Quick Delete Option $can_delete = 0; if ($mybb->user['uid'] == $post['uid']) { if ($forumpermissions['candeletethreads'] == 1 && $postcounter == 1) { $can_delete = 1; } else { if ($forumpermissions['candeleteposts'] == 1 && $postcounter != 1) { $can_delete = 1; } } } $can_delete = (is_moderator($fid, "candeleteposts") || $can_delete == 1) && $mybb->user['uid'] != 0; // User Online status $is_online = false; $timecut = TIME_NOW - $mybb->settings['wolcutoff']; if ($post['lastactive'] > $timecut && ($post['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1) && $post['lastvisit'] != $post['lastactive']) { $is_online = true; } $post['message'] = post_bbcode_clean($post['message']); $plugins->remove_hook('parse_message', 'mybbirckeditor_parser'); // Post content and attachments $post['message'] = $parser->parse_message($post['message'], $parser_options); $attachment_list = process_post_attachments($post['pid'], $post); // add for thank/like support $post = $plugins->run_hooks("postbit", $post); if (is_array($ignored_users) && $post['uid'] != 0 && $ignored_users[$post['uid']] == 1) { $show_spoiler = "[spoiler]" . $post['message'] . "[/spoiler]"; $post['message'] = $lang->sprintf($lang->postbit_currently_ignoring_user, $post['username']) . $show_spoiler; } $post_xmlrpc = array('post_id' => new xmlrpcval($post['pid'], 'string'), 'post_title' => new xmlrpcval(basic_clean($post['subject']), 'base64'), 'post_content' => new xmlrpcval(process_post($post['message'], $input['return_html']), 'base64'), 'post_author_id' => new xmlrpcval($post['uid'], 'string'), 'post_author_name' => new xmlrpcval(basic_clean($post['username']), 'base64'), 'icon_url' => new xmlrpcval(absolute_url($post['avatar']), 'string'), 'post_time' => new xmlrpcval(mobiquo_iso8601_encode($post['dateline']), 'dateTime.iso8601'), 'timestamp' => new xmlrpcval($post['dateline'], 'string'), 'attachments' => new xmlrpcval($attachment_list, 'array')); if (!$post['visible']) { $post_xmlrpc['is_approved'] = new xmlrpcval(false, 'boolean'); } // default as true if ($post['smilieoff']) { $post_xmlrpc['allow_smilies'] = new xmlrpcval(false, 'boolean'); } // default as true if ($post['isbanned']) { $post_xmlrpc['is_ban'] = new xmlrpcval(true, 'boolean'); } if ($is_online) { $post_xmlrpc['is_online'] = new xmlrpcval(true, 'boolean'); } if ($can_edit) { $post_xmlrpc['can_edit'] = new xmlrpcval(true, 'boolean'); } if ($can_delete) { $post_xmlrpc['can_delete'] = new xmlrpcval(true, 'boolean'); } if (is_moderator($fid, 'canmanagethreads')) { $post_xmlrpc['can_approve'] = new xmlrpcval(true, 'boolean'); } if (is_moderator($fid, 'canmanagethreads')) { $post_xmlrpc['can_move'] = new xmlrpcval(true, 'boolean'); } if ($mybb->usergroup['canmodcp'] == 1) { $post_xmlrpc['can_ban'] = new xmlrpcval(true, 'boolean'); } if ($post['edituid']) { //add edit info $edit_info = array('editor_id' => new xmlrpcval($post['edituid'], 'string'), 'editor_name' => new xmlrpcval($post['editusername'], 'base64'), 'edit_time' => new xmlrpcval($post['edittime'], 'string')); if (!empty($post['editreason'])) { $edit_info['edit_reason'] = new xmlrpcval($post['editreason'], 'base64'); } $post_xmlrpc = array_merge($post_xmlrpc, $edit_info); } // add for thank/like support if (isset($post['button_tyl']) && $mybb->user['uid']) { global $mobiquo_config, $g33k_pcache; $thlprefix = $mobiquo_config['thlprefix']; $tyled = false; $tyl_list = array(); if ($mybb->settings[$thlprefix . 'enabled'] == "1") { if ($post['thankyoulike'] && isset($g33k_pcache[$post['pid']])) { foreach ($g33k_pcache[$post['pid']] as $tyl) { if ($tyl['uid'] == $mybb->user['uid']) { $tyled = true; } $tyl_list[] = new xmlrpcval(array('userid' => new xmlrpcval($tyl['uid'], 'string'), 'username' => new xmlrpcval(basic_clean($tyl['username']), 'base64')), 'struct'); } } if ($mybb->settings[$thlprefix . 'thankslike'] == "like") { if ($post['button_tyl']) { $post_xmlrpc['can_like'] = new xmlrpcval(true, 'boolean'); } if ($tyled) { $post_xmlrpc['is_liked'] = new xmlrpcval(true, 'boolean'); } if ($tyl_list) { $post_xmlrpc['likes_info'] = new xmlrpcval($tyl_list, 'array'); } } else { if ($mybb->settings[$thlprefix . 'thankslike'] == "thanks") { if ($post['button_tyl']) { $post_xmlrpc['can_thank'] = new xmlrpcval(true, 'boolean'); } if ($mybb->settings[$thlprefix . 'removing'] == 1) { $post_xmlrpc['can_remove_thank'] = new xmlrpcval(true, 'boolean'); } if ($tyled) { $post_xmlrpc['is_thanked'] = new xmlrpcval(true, 'boolean'); } if ($tyl_list) { $post_xmlrpc['thanks_info'] = new xmlrpcval($tyl_list, 'array'); } } } } } $post_list[] = new xmlrpcval($post_xmlrpc, 'struct'); } $query = $db->simple_select("threadsubscriptions", "tid", "tid='" . intval($tid) . "' AND uid='" . intval($mybb->user['uid']) . "'", array('limit' => 1)); $subscribed = (bool) $db->fetch_field($query, 'tid'); $query = $db->simple_select("banned", "uid", "uid='{$thread['uid']}'"); $isbanned = !!$db->fetch_field($query, "uid"); $can_reply = $forumpermissions['canpostreplys'] != 0 && $mybb->user['suspendposting'] != 1 && ($thread['closed'] != 1 || is_moderator($fid)) && $forum['open'] != 0; build_tt_breadcrumb($fid); $navgation_arr = $navbits; if (is_array($navgation_arr) && count($navgation_arr) > 1) { unset($navgation_arr[0]); foreach ($navgation_arr as $navigation) { $forum_id = $navigation['fid']; $sub_only = false; if ($navigation['type'] != 'f') { $sub_only = true; } $breadcrumb[] = new xmlrpcval(array('forum_id' => new xmlrpcval($forum_id, 'string'), 'forum_name' => new xmlrpcval($navigation['name'], 'base64'), 'sub_only' => new xmlrpcval($sub_only, 'boolean')), 'struct'); } } $is_poll = !empty($thread['poll']) ? true : false; $result = array('total_post_num' => new xmlrpcval($postcount, 'int'), 'forum_id' => new xmlrpcval($thread['fid'], 'string'), 'forum_name' => new xmlrpcval(basic_clean($forum['name']), 'base64'), 'topic_id' => new xmlrpcval($thread['tid'], 'string'), 'topic_title' => new xmlrpcval(basic_clean($thread['subject']), 'base64'), 'can_upload' => new xmlrpcval($forumpermissions['canpostattachments'] != 0, 'boolean'), 'can_report' => new xmlrpcval(true, 'boolean'), 'can_reply' => new xmlrpcval($can_reply, 'boolean'), 'is_poll' => new xmlrpcval($is_poll, 'boolean'), 'view_number' => new xmlrpcval(intval($thread['views']), 'int')); if ($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0) { $new_topic['can_subscribe'] = new xmlrpcval(false, 'boolean'); } else { $new_topic['can_subscribe'] = new xmlrpcval(true, 'boolean'); } if ($thread['prefix']) { $result['prefix'] = new xmlrpcval(basic_clean($thread['displayprefix']), 'base64'); } if (!$thread['visible']) { $result['is_approved'] = new xmlrpcval(false, 'boolean'); } // default as true if ($thread['closed']) { $result['is_closed'] = new xmlrpcval(true, 'boolean'); } if ($thread['sticky']) { $result['is_sticky'] = new xmlrpcval(true, 'boolean'); } if ($subscribed) { $result['is_subscribed'] = new xmlrpcval(true, 'boolean'); } else { $result['is_subscribed'] = new xmlrpcval(false, 'boolean'); } if ($isbanned) { $result['is_ban'] = new xmlrpcval(true, 'boolean'); } if ($position) { $result['position'] = new xmlrpcval(intval($position), 'int'); } if (is_moderator($fid, "canopenclosethreads")) { $result['can_close'] = new xmlrpcval(true, 'boolean'); } if (is_moderator($fid, "candeleteposts")) { $result['can_delete'] = new xmlrpcval(true, 'boolean'); } if (is_moderator($fid, "canmanagethreads")) { $result['can_stick'] = new xmlrpcval(true, 'boolean'); } if (is_moderator($fid, "canmanagethreads")) { $result['can_move'] = new xmlrpcval(true, 'boolean'); $result['can_merge'] = new xmlrpcval(true, 'boolean'); $result['can_merge_post'] = new xmlrpcval(true, 'boolean'); } if (is_moderator($fid, "canopenclosethreads")) { $result['can_approve'] = new xmlrpcval(true, 'boolean'); } if ($can_rename) { $result['can_rename'] = new xmlrpcval(true, 'boolean'); } if ($mybb->usergroup['canmodcp'] == 1) { $result['can_ban'] = new xmlrpcval(true, 'boolean'); } if (!empty($breadcrumb)) { $result['breadcrumb'] = new xmlrpcval($breadcrumb, 'array'); } $result['posts'] = new xmlrpcval($post_list, 'array'); return new xmlrpcresp(new xmlrpcval($result, 'struct')); }
} } $news = new ElggObject(); $news->subtype = "news"; $news->title = $page->title; $news->description = $page->description; $news->tags = $page->tags; $news->owner_guid = $page->owner_guid; $news->container_guid = $container_guid; $news->access_id = get_default_access(); $news->save(); $news->time_created = $page->time_created; $news->time_updated = $page->time_updated; $news->save(); } $bookmarks = new ElggBatch('elgg_get_entities_from_metadata', array('type' => 'object', 'subtype' => 'bookmarks', 'metadata_name_value_pairs' => array(array('name' => 'tags', 'value' => 'redactie')), 'limit' => false)); foreach ($bookmarks as $bookmark) { preg_match("/(?:.*)\\/pages\\/view\\/([0-9]*)\\/(?:.*)/", $bookmark->address, $address); if (count($address) === 0) { continue; } $page = get_entity($address[1]); if ($page) { process_page($page); } } $pages = new ElggBatch('elgg_get_entities_from_metadata', array('type' => 'object', 'subtype' => 'page_top', 'metadata_name_value_pairs' => array(array('name' => 'tags', 'value' => 'juris')), 'limit' => false)); foreach ($pages as $page) { process_page($page); } elgg_set_ignore_access($ia);
function m_get_moderate_post_func($xmlrpc_params) { global $input, $post, $thread, $forum, $pid, $tid, $fid, $modlogdata, $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups, $moderation, $parser; $input = Tapatalk_Input::filterXmlInput(array('start_num' => Tapatalk_Input::INT, 'last_num' => Tapatalk_Input::INT), $xmlrpc_params); mod_setup(); list($start, $limit) = process_page($input['start_num'], $input['last_num']); // Load global language phrases $lang->load("modcp"); if ($mybb->user['uid'] == 0 || $mybb->usergroup['canmodcp'] != 1) { return tt_no_permission(); } $errors = ''; // SQL for fetching items only related to forums this user moderates $moderated_forums = array(); if ($mybb->usergroup['issupermod'] != 1) { $query = $db->simple_select("moderators", "*", "id='{$mybb->user['uid']}' AND isgroup = '0'"); while ($forum = $db->fetch_array($query)) { $flist .= ",'{$forum['fid']}'"; $children = get_child_list($forum['fid']); if (!empty($children)) { $flist .= ",'" . implode("','", $children) . "'"; } $moderated_forums[] = $forum['fid']; } if ($flist) { $tflist = " AND t.fid IN (0{$flist})"; $flist = " AND fid IN (0{$flist})"; } } else { $flist = $tflist = ''; } $forum_cache = $cache->read("forums"); $query = $db->query("\n SELECT COUNT(pid) AS unapprovedposts\n FROM " . TABLE_PREFIX . "posts p\n LEFT JOIN " . TABLE_PREFIX . "threads t ON (t.tid=p.tid)\n WHERE p.visible='0' {$tflist} AND t.firstpost != p.pid\n "); $unapproved_posts = $db->fetch_field($query, "unapprovedposts"); $query = $db->query("\n SELECT p.pid, p.subject, p.message, t.subject AS threadsubject, t.tid, u.username, p.uid, t.fid, p.dateline, u.avatar, t.views, t.replies, IF(b.lifted > UNIX_TIMESTAMP() OR b.lifted = 0, 1, 0) as isbanned\n FROM " . TABLE_PREFIX . "posts p\n LEFT JOIN " . TABLE_PREFIX . "threads t ON (t.tid=p.tid)\n LEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=p.uid)\n LEFT JOIN " . TABLE_PREFIX . "banned b ON (b.uid = p.uid)\n left join " . TABLE_PREFIX . "forums f on f.fid = t.fid\n WHERE p.visible='0' {$tflist} AND t.firstpost != p.pid\n ORDER BY p.dateline DESC\n LIMIT {$start}, {$limit}\n "); $forumcache = $cache->read("forums"); $post_list = array(); while ($post = $db->fetch_array($query)) { $post['threadsubject'] = $parser->parse_badwords($post['threadsubject']); $forumpermissions = forum_permissions($post['fid']); $can_delete = 0; if ($mybb->user['uid'] == $post['uid']) { if ($forumpermissions['candeletethreads'] == 1 && $post['replies'] == 0) { $can_delete = 1; } else { if ($forumpermissions['candeleteposts'] == 1 && $post['replies'] > 0) { $can_delete = 1; } } } $can_delete = (is_moderator($post['fid'], "candeleteposts") || $can_delete == 1) && $mybb->user['uid'] != 0; $post_list[] = new xmlrpcval(array('forum_id' => new xmlrpcval($post['fid'], 'string'), 'forum_name' => new xmlrpcval(basic_clean($forumcache[$post['fid']]['name']), 'base64'), 'topic_id' => new xmlrpcval($post['tid'], 'string'), 'topic_title' => new xmlrpcval($post['threadsubject'], 'base64'), 'post_id' => new xmlrpcval($post['pid'], 'string'), 'post_title' => new xmlrpcval($post['subject'], 'base64'), 'post_author_name' => new xmlrpcval($post['username'], 'base64'), 'icon_url' => new xmlrpcval(absolute_url($post['avatar']), 'string'), 'post_time' => new xmlrpcval(mobiquo_iso8601_encode($post['dateline']), 'dateTime.iso8601'), 'short_content' => new xmlrpcval(process_short_content($post['message'], $parser), 'base64'), 'reply_number' => new xmlrpcval($post['replies'], 'int'), 'view_number' => new xmlrpcval($post['views'], 'int'), 'can_delete' => new xmlrpcval($can_delete, 'boolean'), 'can_approve' => new xmlrpcval(is_moderator($post['fid'], "canmanagethreads"), 'boolean'), 'can_move' => new xmlrpcval(is_moderator($post['fid'], "canmovetononmodforum"), 'boolean'), 'can_ban' => new xmlrpcval($mybb->usergroup['canmodcp'] == 1, 'boolean'), 'is_ban' => new xmlrpcval($post['isbanned'], 'boolean'), 'is_approved' => new xmlrpcval(false, 'boolean'), 'is_deleted' => new xmlrpcval(false, 'boolean')), "struct"); } $result = new xmlrpcval(array('total_post_num' => new xmlrpcval($unapproved_posts, 'int'), 'posts' => new xmlrpcval($post_list, 'array')), 'struct'); return new xmlrpcresp($result); }
function get_topic_func($xmlrpc_params) { global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $time, $mybbgroups; $lang->load("member"); $parser = new postParser(); $input = Tapatalk_Input::filterXmlInput(array('forum_id' => Tapatalk_Input::INT, 'start_num' => Tapatalk_Input::INT, 'last_num' => Tapatalk_Input::INT, 'mode' => Tapatalk_Input::STRING), $xmlrpc_params); $lang->load("forumdisplay"); $fid = $input['forum_id']; $foruminfo = get_forum($fid); if (!$foruminfo) { return xmlrespfalse($lang->error_invalidforum); } list($start, $limit) = process_page($input['start_num'], $input['last_num']); $forumpermissions = forum_permissions(); $fpermissions = $forumpermissions[$fid]; if ($fpermissions['canview'] != 1) { return tt_no_permission(); } switch ($input['mode']) { case 'TOP': $stickyonly = " AND sticky=1 "; $tstickyonly = " AND t.sticky=1 "; break; case 'ANN': return get_announcement_list($foruminfo, $fid); break; default: $stickyonly = " AND sticky=0 "; $tstickyonly = " AND t.sticky=0 "; break; } if ($mybb->user['uid'] == 0) { // Build a forum cache. $query = $db->query("\n SELECT *\n FROM " . TABLE_PREFIX . "forums\n WHERE active != 0\n ORDER BY pid, disporder\n "); $forumsread = unserialize($mybb->cookies['mybb']['forumread']); if (!is_array($forumsread)) { $forumsread = array(); } } else { // Build a forum cache. $query = $db->query("\n SELECT f.*, fr.dateline AS lastread\n FROM " . TABLE_PREFIX . "forums f\n LEFT JOIN " . TABLE_PREFIX . "forumsread fr ON (fr.fid=f.fid AND fr.uid='{$mybb->user['uid']}')\n WHERE f.active != 0\n ORDER BY pid, disporder\n "); } while ($forum = $db->fetch_array($query)) { if ($mybb->user['uid'] == 0) { if ($forumsread[$forum['fid']]) { $forum['lastread'] = $forumsread[$forum['fid']]; } } $fcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum; } tt_check_forum_password($foruminfo['fid']); if ($foruminfo['linkto']) { return xmlrespfalse('This forum is a link'); } $visibleonly = "AND visible='1'"; $tvisibleonly = "AND t.visible='1'"; // Check if the active user is a moderator and get the inline moderation tools. if (is_moderator($fid)) { $ismod = true; $inlinecount = "0"; $inlinecookie = "inlinemod_forum" . $fid; $visibleonly = " AND (visible='1' OR visible='0')"; $tvisibleonly = " AND (t.visible='1' OR t.visible='0')"; } else { $inlinemod = ''; $ismod = false; } if (is_moderator($fid, "caneditposts") || $fpermissions['caneditposts'] == 1) { $can_edit_titles = 1; } else { $can_edit_titles = 0; } $t = "t."; $sortby = "lastpost"; $sortfield = "lastpost"; $sortordernow = "desc"; $threadcount = 0; $useronly = $tuseronly = ""; if ($fpermissions['canonlyviewownthreads'] == 1) { $useronly = "AND uid={$mybb->user['uid']}"; $tuseronly = "AND t.uid={$mybb->user['uid']}"; } if ($fpermissions['canviewthreads'] != 0) { // How many posts are there? if ($datecut > 0 || $fpermissions['canonlyviewownthreads'] == 1) { $query = $db->simple_select("threads", "COUNT(tid) AS threads", "fid = '{$fid}' {$useronly} {$visibleonly} {$stickyonly}"); $threadcount = $db->fetch_field($query, "threads"); } else { $query = $db->simple_select("threads", "COUNT(tid) AS threads", "fid = '{$fid}' {$useronly} {$visibleonly} {$stickyonly}", array('limit' => 1)); $threadcount = $db->fetch_field($query, "threads"); } } // count unread stickies $query = $db->query("\n select COUNT(t.tid) AS threads\n from " . TABLE_PREFIX . "threads t\n left join " . TABLE_PREFIX . "threadsread tr on t.tid = tr.tid and tr.uid = '{$mybb->user['uid']}'\n where t.fid = '{$fid}' {$tuseronly} {$tvisibleonly} and t.sticky=1 and (tr.dateline < t.lastpost or tr.dateline is null)\n "); $unreadStickyCount = $db->fetch_field($query, "threads"); if ($fpermissions['canviewthreads'] != 0) { // Start Getting Threads $query = $db->query("\n SELECT t.*, {$ratingadd}{$select_rating_user}t.username AS threadusername, u.username, u.avatar, s.sid as subscribed, po.message, IF(b.lifted > UNIX_TIMESTAMP() OR b.lifted = 0, 1, 0) as isbanned\n FROM " . TABLE_PREFIX . "threads t\n LEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid = t.uid){$select_voting}\n LEFT JOIN " . TABLE_PREFIX . "banned b ON (b.uid = t.uid) \n LEFT JOIN " . TABLE_PREFIX . "threadsubscriptions s ON (s.tid = t.tid) AND (s.uid = '{$mybb->user['uid']}')\n LEFT JOIN " . TABLE_PREFIX . "posts po ON (po.pid = t.firstpost)\n WHERE t.fid='{$fid}' {$tuseronly} {$tvisibleonly} {$tstickyonly}\n GROUP BY t.tid\n ORDER BY t.sticky DESC, {$t}{$sortfield} {$sortordernow} {$sortfield2}\n LIMIT {$start}, {$limit}\n "); while ($thread = $db->fetch_array($query)) { $threadcache[$thread['tid']] = $thread; // If this is a moved thread - set the tid for participation marking and thread read marking to that of the moved thread if (substr($thread['closed'], 0, 5) == "moved") { $tid = substr($thread['closed'], 6); if (!$tids[$tid]) { $moved_threads[$tid] = $thread['tid']; $tids[$thread['tid']] = $tid; } } else { $tids[$thread['tid']] = $thread['tid']; if ($moved_threads[$tid]) { unset($moved_threads[$tid]); } } } } else { $threadcache = $tids = null; } if ($tids) { $tids = implode(",", $tids); } if ($mybb->settings['dotfolders'] != 0 && $mybb->user['uid'] && $threadcache) { $query = $db->simple_select("posts", "tid,uid", "uid='{$mybb->user['uid']}' AND tid IN ({$tids})"); while ($post = $db->fetch_array($query)) { if ($moved_threads[$post['tid']]) { $post['tid'] = $moved_threads[$post['tid']]; } if ($threadcache[$post['tid']]) { $threadcache[$post['tid']]['doticon'] = 1; } } } if ($mybb->user['uid'] && $mybb->settings['threadreadcut'] > 0 && $threadcache) { $query = $db->simple_select("threadsread", "*", "uid='{$mybb->user['uid']}' AND tid IN ({$tids})"); while ($readthread = $db->fetch_array($query)) { if ($moved_threads[$readthread['tid']]) { $readthread['tid'] = $moved_threads[$readthread['tid']]; } if ($threadcache[$readthread['tid']]) { $threadcache[$readthread['tid']]['lastread'] = $readthread['dateline']; } } } if ($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid']) { $query = $db->simple_select("forumsread", "dateline", "fid='{$fid}' AND uid='{$mybb->user['uid']}'"); $forum_read = $db->fetch_field($query, "dateline"); $read_cutoff = TIME_NOW - $mybb->settings['threadreadcut'] * 60 * 60 * 24; if ($forum_read == 0 || $forum_read < $read_cutoff) { $forum_read = $read_cutoff; } } else { $forum_read = my_get_array_cookie("forumread", $fid); } $threads = ''; $load_inline_edit_js = 0; $topic_list = array(); if (is_array($threadcache)) { reset($threadcache); foreach ($threadcache as $thread) { $unreadpost = false; $moved = explode("|", $thread['closed']); $thread['author'] = $thread['uid']; if (!$thread['username']) { $thread['username'] = $thread['threadusername']; $thread['profilelink'] = $thread['threadusername']; } else { $thread['profilelink'] = build_profile_link($thread['username'], $thread['uid']); } // If this thread has a prefix, insert a space between prefix and subject if ($thread['prefix'] != 0) { $threadprefix = build_prefixes($thread['prefix']); $thread['displayprefix'] = $threadprefix['displaystyle']; } $thread['subject'] = $parser->parse_badwords($thread['subject']); $prefix = ''; if ($thread['poll']) { $prefix = $lang->poll_prefix; } $thread['posts'] = $thread['replies'] + 1; if ($moved[0] == "moved") { $prefix = $lang->moved_prefix; $thread['replies'] = "-"; $thread['views'] = "-"; } $gotounread = ''; $isnew = 0; $donenew = 0; if ($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'] && $thread['lastpost'] > $forum_read) { if ($thread['lastread']) { $last_read = $thread['lastread']; } else { $last_read = $read_cutoff; } } else { $last_read = my_get_array_cookie("threadread", $thread['tid']); } if ($forum_read > $last_read) { $last_read = $forum_read; } if ($thread['lastpost'] > $last_read && $moved[0] != "moved") { $folder .= "new"; $folder_label .= $lang->icon_new; $new_class = "subject_new"; $unreadpost = true; } else { $folder_label .= $lang->icon_no_new; $new_class = "subject_old"; } if (!empty($thread['closed'])) { $moved = explode("|", $thread['closed']); if ($moved[0] == "moved") { $thread['subject'] = $lang->moved_prefix . ' ' . $thread['subject']; } } $new_topic = array('forum_id' => new xmlrpcval($thread['fid'], 'string'), 'topic_id' => new xmlrpcval($thread['tid'], 'string'), 'topic_title' => new xmlrpcval(basic_clean($thread['subject']), 'base64'), 'prefix' => new xmlrpcval(basic_clean($thread['displayprefix']), 'base64'), 'topic_author_id' => new xmlrpcval($thread['uid'], 'string'), 'topic_author_name' => new xmlrpcval(basic_clean($thread['username']), 'base64'), 'icon_url' => new xmlrpcval(absolute_url($thread['avatar']), 'string'), 'last_reply_time' => new xmlrpcval(mobiquo_iso8601_encode($thread['lastpost']), 'dateTime.iso8601'), 'timestamp' => new xmlrpcval($thread['lastpost'], 'string'), 'short_content' => new xmlrpcval(process_short_content($thread['message'], $parser), 'base64'), 'reply_number' => new xmlrpcval(intval($thread['replies']), 'int'), 'view_number' => new xmlrpcval(intval($thread['views']), 'int'), 'is_approved' => new xmlrpcval($thread['visible'], 'boolean'), 'is_moved' => new xmlrpcval(isset($moved[0]) && $moved[0] == "moved" ? true : false, 'boolean'), 'real_topic_id' => new xmlrpcval(isset($moved[1]) ? $moved[1] : $thread['tid'])); $forumpermissions = forum_permissions($thread['fid']); if ($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0) { $new_topic['can_subscribe'] = new xmlrpcval(false, 'boolean'); } else { $new_topic['can_subscribe'] = new xmlrpcval(true, 'boolean'); } //can_rename topic $can_rename = (is_moderator($fid, "caneditposts") || $forumpermissions['caneditposts'] == 1 && $mybb->user['uid'] == $thread['uid']) && $mybb->user['uid'] != 0; if ($unreadpost) { $new_topic['new_post'] = new xmlrpcval(true, 'boolean'); } if ($thread['sticky']) { $new_topic['is_sticky'] = new xmlrpcval(true, 'boolean'); } if (!empty($thread['subscribed'])) { $new_topic['is_subscribed'] = new xmlrpcval(true, 'boolean'); } else { $new_topic['is_subscribed'] = new xmlrpcval(false, 'boolean'); } if ($thread['closed']) { $new_topic['is_closed'] = new xmlrpcval(true, 'boolean'); } if ($thread['isbanned']) { $new_topic['is_ban'] = new xmlrpcval(true, 'boolean'); } if ($mybb->usergroup['canmodcp'] == 1) { $new_topic['can_ban'] = new xmlrpcval(true, 'boolean'); } if (is_moderator($fid, "canmanagethreads")) { $new_topic['can_move'] = new xmlrpcval(true, 'boolean'); $new_topic['can_merge'] = new xmlrpcval(true, 'boolean'); $new_topic['can_merge_post'] = new xmlrpcval(true, 'boolean'); } if (is_moderator($fid, "canopenclosethreads")) { $new_topic['can_close'] = new xmlrpcval(true, 'boolean'); } if (is_moderator($fid, "candeleteposts")) { $new_topic['can_delete'] = new xmlrpcval(true, 'boolean'); } if (is_moderator($fid, "canmanagethreads")) { $new_topic['can_stick'] = new xmlrpcval(true, 'boolean'); } if (is_moderator($fid, "canopenclosethreads")) { $new_topic['can_approve'] = new xmlrpcval(true, 'boolean'); } if ($can_rename) { $new_topic['can_rename'] = new xmlrpcval(true, 'boolean'); } $topic_list[] = new xmlrpcval($new_topic, 'struct'); } $customthreadtools = ''; } // If there are no unread threads in this forum and no unread child forums - mark it as read require_once MYBB_ROOT . "inc/functions_indicators.php"; if (fetch_unread_count($fid) == 0 && $unread_forums == 0) { mark_forum_read($fid); } $prefix_list = array(); // Does this user have additional groups? if ($mybb->user['additionalgroups']) { $exp = explode(",", $mybb->user['additionalgroups']); // Because we like apostrophes... $imps = array(); foreach ($exp as $group) { $imps[] = "'{$group}'"; } $additional_groups = implode(",", $imps); $extra_sql = "groups IN ({$additional_groups}) OR "; } else { $extra_sql = ''; } if ($mybb->version_code >= 1600 && $mybb->user['uid']) { $prefixes = get_prefix_list($fid); foreach ($prefixes as $prefix) { $prefix_list[] = new xmlrpcval(array('prefix_id' => new xmlrpcval($prefix['pid'], "string"), 'prefix_display_name' => new xmlrpcval(basic_clean($prefix['prefix']), "base64")), "struct"); } } $read_only_forums = explode(",", $settings['tapatalk_forum_read_only']); $can_post = true; if (empty($read_only_forums) || !is_array($read_only_forums)) { $read_only_forums = array(); } if (!($foruminfo['type'] == "f" && $foruminfo['open'] != 0 && $mybb->user['uid'] > 0 && $mybb->usergroup['canpostthreads']) || in_array($fid, $read_only_forums)) { $can_post = false; } $result = array('total_topic_num' => new xmlrpcval($threadcount, 'int'), 'forum_id' => new xmlrpcval($fid, 'string'), 'forum_name' => new xmlrpcval(basic_clean($foruminfo['name']), 'base64'), 'can_post' => new xmlrpcval($can_post, 'boolean'), 'prefixes' => new xmlrpcval($prefix_list, 'array'), 'can_upload' => new xmlrpcval($fpermissions['canpostattachments'], 'boolean')); if ($unreadStickyCount) { $result['unread_sticky_count'] = new xmlrpcval($unreadStickyCount, 'int'); } if ($mybb->user['uid']) { $query = $db->simple_select("forumsubscriptions", "fid", "fid='" . $fid . "' AND uid='{$mybb->user['uid']}'", array('limit' => 1)); if ($db->fetch_field($query, 'fid')) { $result['is_subscribed'] = new xmlrpcval(true, 'boolean'); } } $result['topics'] = new xmlrpcval($topic_list, 'array'); return new xmlrpcresp(new xmlrpcval($result, 'struct')); }
case 'm_get_moderate_post': if ($params_num == 2) { process_page($request_params[0], $request_params[1]); } elseif ($params_num == 3) { process_page($request_params[1], $request_params[2]); } else { $start = 0; $limit = 50; } $config['topics_per_page'] = $limit; $_GET['start'] = $start; $_GET['i'] = 'queue'; $_GET['mode'] = 'unapproved_posts'; break; case 'm_get_report_post': process_page($request_params[0], $request_params[1]); $config['topics_per_page'] = $limit; $_GET['start'] = $start; $_GET['i'] = 'reports'; $_GET['mode'] = 'reports'; break; case 'register': $_POST['creation_time'] = time(); $_POST['username'] = $request_params[0]; $_POST['new_password'] = $request_params[1]; $_POST['password_confirm'] = $request_params[1]; $_POST['email'] = $request_params[2]; if (count($request_params) == 5) { $_POST['tt_token'] = $request_params[3]; $_POST['tt_code'] = $request_params[4]; }
function get_subscribed_topic_func($xmlrpc_params) { global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups; $lang->load("usercp"); $parser = new postParser(); $input = Tapatalk_Input::filterXmlInput(array('start_num' => Tapatalk_Input::INT, 'last_num' => Tapatalk_Input::INT), $xmlrpc_params); if ($mybb->user['uid'] == 0 || $mybb->usergroup['canusercp'] == 0) { return tt_no_permission(); } $query = $db->simple_select("forumpermissions", "*", "gid='" . $db->escape_string($mybb->user['usergroup']) . "'"); while ($permissions = $db->fetch_array($query)) { $permissioncache[$permissions['gid']][$permissions['fid']] = $permissions; } while ($forum = $db->fetch_array($query)) { if ($mybb->user['uid'] == 0) { if ($forumsread[$forum['fid']]) { $forum['lastread'] = $forumsread[$forum['fid']]; } } $readforums[$forum['fid']] = $forum['lastread']; } require_once MYBB_ROOT . "inc/functions_forumlist.php"; $fpermissions = forum_permissions(); list($start, $limit) = process_page($input['start_num'], $input['last_num']); // Thread visiblity $visible = "AND t.visible != 0"; if (is_moderator() == true) { $visible = ''; } // Do Multi Pages $query = $db->query("\n\t\tSELECT COUNT(ts.tid) as threads\n\t\tFROM " . TABLE_PREFIX . "threadsubscriptions ts\n\t\tLEFT JOIN " . TABLE_PREFIX . "threads t ON (t.tid = ts.tid)\n\t\tWHERE ts.uid = '" . $mybb->user['uid'] . "' {$visible}\n\t"); $threadcount = $db->fetch_field($query, "threads"); // Fetch subscriptions $query = $db->query("\n\t\tSELECT s.*, t.*, t.username AS threadusername, u.username, u.username, u.avatar, if({$mybb->user['uid']} > 0 and s.uid = {$mybb->user['uid']}, 1, 0) as subscribed, po.message, f.name as forumname, IF(b.lifted > UNIX_TIMESTAMP() OR b.lifted = 0, 1, 0) as isbanned\n\t\tFROM " . TABLE_PREFIX . "threadsubscriptions s\n\t\tLEFT JOIN " . TABLE_PREFIX . "threads t ON (s.tid=t.tid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid = t.uid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "banned b ON (b.uid = t.uid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "posts po ON (po.pid = t.firstpost)\n\t\tleft join " . TABLE_PREFIX . "forums f on f.fid = t.fid\n\t\tWHERE s.uid='" . $mybb->user['uid'] . "' {$visible}\n\t\tORDER BY t.lastpost DESC\n\t\tLIMIT {$start}, {$limit}\n\t"); while ($subscription = $db->fetch_array($query)) { $forumpermissions = $fpermissions[$subscription['fid']]; if ($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0) { // Hmm, you don't have permission to view this thread - unsubscribe! $del_subscriptions[] = $subscription['tid']; } else { if ($subscription['tid']) { $subscriptions[$subscription['tid']] = $subscription; } } } if (is_array($del_subscriptions)) { $tids = implode(',', $del_subscriptions); if ($tids) { $db->delete_query("threadsubscriptions", "tid IN ({$tids}) AND uid='{$mybb->user['uid']}'"); } } $topic_list = array(); if (is_array($subscriptions)) { $tids = implode(",", array_keys($subscriptions)); // Build a forum cache. $query = $db->query("\n\t\t\tSELECT f.fid, fr.dateline AS lastread\n\t\t\tFROM " . TABLE_PREFIX . "forums f\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "forumsread fr ON (fr.fid=f.fid AND fr.uid='{$mybb->user['uid']}')\n\t\t\tWHERE f.active != 0\n\t\t\tORDER BY pid, disporder\n\t\t"); while ($forum = $db->fetch_array($query)) { if ($mybb->user['uid'] == 0) { if ($forumsread[$forum['fid']]) { $forum['lastread'] = $forumsread[$forum['fid']]; } } $readforums[$forum['fid']] = $forum['lastread']; } // Read threads if ($mybb->settings['threadreadcut'] > 0) { $query = $db->simple_select("threadsread", "*", "uid='{$mybb->user['uid']}' AND tid IN ({$tids})"); while ($readthread = $db->fetch_array($query)) { $subscriptions[$readthread['tid']]['lastread'] = $readthread['dateline']; } } // Now we can build our subscription list foreach ($subscriptions as $thread) { $bgcolor = alt_trow(); $folder = ''; $prefix = ''; // If this thread has a prefix, insert a space between prefix and subject if ($thread['prefix'] != 0) { $thread['threadprefix'] .= ' '; } // Sanitize $thread['subject'] = $parser->parse_badwords($thread['subject']); $gotounread = ''; $isnew = 0; $donenew = 0; $lastread = 0; $unreadpost = 0; if ($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid']) { $forum_read = $readforums[$thread['fid']]; $read_cutoff = TIME_NOW - $mybb->settings['threadreadcut'] * 60 * 60 * 24; if ($forum_read == 0 || $forum_read < $read_cutoff) { $forum_read = $read_cutoff; } } else { $forum_read = $forumsread[$thread['fid']]; } if ($mybb->settings['threadreadcut'] > 0 && $thread['lastpost'] > $forum_read) { $cutoff = TIME_NOW - $mybb->settings['threadreadcut'] * 60 * 60 * 24; } if ($thread['lastpost'] > $cutoff) { if ($thread['lastpost'] > $cutoff) { if ($thread['lastread']) { $lastread = $thread['lastread']; } else { $lastread = 1; } } } if (!$lastread) { $readcookie = $threadread = my_get_array_cookie("threadread", $thread['tid']); if ($readcookie > $forum_read) { $lastread = $readcookie; } else { $lastread = $forum_read; } } if ($thread['lastpost'] > $lastread && $lastread) { $unreadpost = 1; } $topic_list[] = new xmlrpcval(array('forum_id' => new xmlrpcval($thread['fid'], 'string'), 'forum_name' => new xmlrpcval(basic_clean($thread['forumname']), 'base64'), 'topic_id' => new xmlrpcval($thread['tid'], 'string'), 'topic_title' => new xmlrpcval($thread['subject'], 'base64'), 'topic_author_id' => new xmlrpcval($thread['uid'], 'string'), 'post_author_name' => new xmlrpcval($thread['username'], 'base64'), 'can_subscribe' => new xmlrpcval(true, 'boolean'), 'is_subscribed' => new xmlrpcval((bool) $thread['subscribed'], 'boolean'), 'is_closed' => new xmlrpcval((bool) $thread['closed'], 'boolean'), 'short_content' => new xmlrpcval(process_short_content($thread['message'], $parser), 'base64'), 'icon_url' => new xmlrpcval(absolute_url($thread['avatar']), 'string'), 'post_time' => new xmlrpcval(mobiquo_iso8601_encode($thread['lastpost']), 'dateTime.iso8601'), 'reply_number' => new xmlrpcval($thread['replies'], 'int'), 'view_number' => new xmlrpcval($thread['views'], 'int'), 'new_post' => new xmlrpcval($unreadpost, 'boolean'), 'can_delete' => new xmlrpcval(is_moderator($thread['fid'], "candeleteposts"), 'boolean'), 'can_close' => new xmlrpcval(is_moderator($thread['fid'], "canopenclosethreads"), 'boolean'), 'can_approve' => new xmlrpcval(is_moderator($thread['fid'], "canopenclosethreads"), 'boolean'), 'can_stick' => new xmlrpcval(is_moderator($thread['fid'], "canmanagethreads"), 'boolean'), 'can_merge' => new xmlrpcval(is_moderator($thread['fid'], "canmanagethreads"), 'boolean'), 'can_merge_post' => new xmlrpcval(is_moderator($thread['fid'], "canmanagethreads"), 'boolean'), 'can_move' => new xmlrpcval(is_moderator($thread['fid'], "canmovetononmodforum"), 'boolean'), 'can_ban' => new xmlrpcval($mybb->usergroup['canmodcp'] == 1, 'boolean'), 'can_rename' => new xmlrpcval(false, 'boolean'), 'is_ban' => new xmlrpcval($thread['isbanned'], 'boolean'), 'is_sticky' => new xmlrpcval($thread['sticky'], 'boolean'), 'is_approved' => new xmlrpcval(!!$thread['visible'], 'boolean'), 'is_deleted' => new xmlrpcval(false, 'boolean')), 'struct'); } } $result = new xmlrpcval(array('total_topic_num' => new xmlrpcval($threadcount, 'int'), 'topics' => new xmlrpcval($topic_list, 'array')), 'struct'); return new xmlrpcresp($result); }
function get_box_func($xmlrpc_params) { global $db, $auth, $user, $cache, $config, $phpbb_home, $phpbb_root_path, $phpEx; $params = php_xmlrpc_decode($xmlrpc_params); $user->setup('ucp'); if (!$user->data['is_registered']) { trigger_error('LOGIN_EXPLAIN_UCP'); } if (!$config['allow_privmsg']) { trigger_error('Module not accessible'); } if (!isset($params[0])) { trigger_error('UNKNOWN_FOLDER'); } // get folder id from parameters $folder_id = intval($params[0]); if (PRIVMSGS_INBOX !== $folder_id) { $folder_id = PRIVMSGS_SENTBOX; } list($start, $limit, $page) = process_page($params[1], $params[2]); // Grab icons //$icons = $cache->obtain_icons(); $user_id = $user->data['user_id']; include_once $phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx; $folder = get_folder($user_id, $folder_id); include $phpbb_root_path . 'includes/ucp/ucp_pm_viewfolder.' . $phpEx; $folder_info = get_pm_from($folder_id, $folder, $user_id); $address_list = array(); // Build Recipient List if in outbox/sentbox - max two additional queries if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) { $recipient_list = $address = array(); foreach ($folder_info['rowset'] as $message_id => $row) { $address[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address'])); $_save = array('u', 'g'); foreach ($_save as $save) { if (isset($address[$message_id][$save]) && sizeof($address[$message_id][$save])) { foreach (array_keys($address[$message_id][$save]) as $ug_id) { $recipient_list[$save][$ug_id] = array('name' => $user->lang['NA'], 'colour' => ''); } } } } $_types = array('u', 'g'); foreach ($_types as $ug_type) { if (!empty($recipient_list[$ug_type])) { if ($ug_type == 'u') { $sql = 'SELECT user_id as id, username as name, user_colour as colour FROM ' . USERS_TABLE . ' WHERE '; } else { $sql = 'SELECT group_id as id, group_name as name, group_colour as colour, group_type FROM ' . GROUPS_TABLE . ' WHERE '; } $sql .= $db->sql_in_set($ug_type == 'u' ? 'user_id' : 'group_id', array_map('intval', array_keys($recipient_list[$ug_type]))); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if ($ug_type == 'g') { $row['name'] = $row['group_type'] == GROUP_SPECIAL ? $user->lang['G_' . $row['name']] : $row['name']; } $recipient_list[$ug_type][$row['id']] = array('id' => $row['id'], 'name' => $row['name'], 'colour' => $row['colour']); } $db->sql_freeresult($result); } } foreach ($address as $message_id => $adr_ary) { foreach ($adr_ary as $type => $id_ary) { foreach ($id_ary as $ug_id => $_id) { $address_list[$message_id][] = $recipient_list[$type][$ug_id]; } } } unset($recipient_list, $address); } // get unread count in inbox only if (PRIVMSGS_INBOX === $folder_id) { $sql = 'SELECT COUNT(msg_id) as num_messages FROM ' . PRIVMSGS_TO_TABLE . ' WHERE pm_unread = 1 AND folder_id = ' . PRIVMSGS_INBOX . ' AND user_id = ' . $user->data['user_id']; $result = $db->sql_query($sql); $unread_num = (int) $db->sql_fetchfield('num_messages'); $db->sql_freeresult($result); } else { $unread_num = 0; } $sql = 'SELECT COUNT(msg_id) as num_messages FROM ' . PRIVMSGS_TO_TABLE . ' WHERE folder_id = ' . $folder_id . ' AND user_id = ' . $user->data['user_id']; $result = $db->sql_query($sql); $total_num = (int) $db->sql_fetchfield('num_messages'); $db->sql_freeresult($result); $sql = 'SELECT t.*, p.*, u.username, u.user_avatar, u.user_avatar_type, u.user_id FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . " u\r\r\n WHERE t.user_id = {$user_id}\r\r\n AND p.author_id = u.user_id\r\r\n AND t.folder_id = {$folder_id}\r\r\n AND t.msg_id = p.msg_id\r\r\n ORDER BY p.message_time DESC"; $result = $db->sql_query_limit($sql, $limit, $start); $total_message_count = $total_unread_count = 0; $online_cache = array(); while ($row = $db->sql_fetchrow($result)) { $msg_state = 2; // message read if ($row['pm_unread']) { $msg_state = 1; } else { if ($row['pm_replied']) { $msg_state = 3; } else { if ($row['pm_forwarded']) { $msg_state = 4; } } } if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) { $msg_to_list = $address_list[$row['msg_id']]; } else { $msg_to_list = array(array('id' => $user->data['user_id'], 'name' => $user->data['username'])); } $msg_to = array(); foreach ($msg_to_list as $address) { $msg_to[] = new xmlrpcval(array('user_id' => new xmlrpcval($address['id'], 'string'), 'username' => new xmlrpcval(basic_clean($address['name']), 'base64'), 'user_type' => check_return_user_type($address['name'])), 'struct'); } $sent_date = mobiquo_iso8601_encode($row['message_time']); //$icon_url = (!empty($icons[$row['icon_id']])) ? $phpbb_home . $config['icons_path'] . '/' . $icons[$row['icon_id']]['img'] : ''; $icon_url = $user->optionget('viewavatars') ? get_user_avatar_url($row['user_avatar'], $row['user_avatar_type']) : ''; $msg_subject = html_entity_decode(strip_tags(censor_text($row['message_subject']))); $short_content = censor_text($row['message_text']); $short_content = preg_replace('/\\[url.*?\\].*?\\[\\/url.*?\\]/', '[url]', $short_content); $short_content = preg_replace('/\\[img.*?\\].*?\\[\\/img.*?\\]/', '[img]', $short_content); $short_content = preg_replace('/[\\n\\r\\t]+/', ' ', $short_content); strip_bbcode($short_content); $short_content = html_entity_decode($short_content); $short_content = substr($short_content, 0, 200); if ($config['load_onlinetrack'] && !isset($online_cache[$row['user_id']])) { $sql = 'SELECT session_user_id, MAX(session_time) as online_time, MIN(session_viewonline) AS viewonline FROM ' . SESSIONS_TABLE . ' WHERE session_user_id=' . $row['user_id'] . ' GROUP BY session_user_id'; $online_result = $db->sql_query($sql); $online_info = $db->sql_fetchrow($online_result); $db->sql_freeresult($online_result); $update_time = $config['load_online_time'] * 60; $online_cache[$row['user_id']] = time() - $update_time < $online_info['online_time'] && ($online_info['viewonline'] || $auth->acl_get('u_viewonline')) ? true : false; } $is_online = isset($online_cache[$row['user_id']]) ? $online_cache[$row['user_id']] : false; $pm_list[] = new xmlrpcval(array('msg_id' => new xmlrpcval($row['msg_id']), 'msg_state' => new xmlrpcval($msg_state, 'int'), 'sent_date' => new xmlrpcval($sent_date, 'dateTime.iso8601'), 'timestamp' => new xmlrpcval($row['message_time'], 'string'), 'msg_from' => new xmlrpcval(basic_clean($row['username']), 'base64'), 'msg_from_id' => new xmlrpcval($row['user_id']), 'icon_url' => new xmlrpcval($icon_url), 'msg_to' => new xmlrpcval($msg_to, 'array'), 'msg_subject' => new xmlrpcval($msg_subject, 'base64'), 'short_content' => new xmlrpcval($short_content, 'base64'), 'is_online' => new xmlrpcval($is_online, 'boolean')), 'struct'); } $db->sql_freeresult($result); $result = new xmlrpcval(array('total_message_count' => new xmlrpcval($total_num, 'int'), 'total_unread_count' => new xmlrpcval($unread_num, 'int'), 'list' => new xmlrpcval($pm_list, 'array')), 'struct'); return new xmlrpcresp($result); }
function get_topic_func($xmlrpc_params) { global $db, $auth, $user, $config; $user->setup('viewforum'); $params = php_xmlrpc_decode($xmlrpc_params); list($start, $limit) = process_page($params[1], $params[2]); // get forum id from parameters $forum_id = intval($params[0]); if (!$forum_id) { trigger_error('NO_FORUM'); } // check if need sticky/announce topic only $topic_type = ''; if (isset($params[3])) { // check if need sticky topic only if ($params[3] == 'TOP') { $topic_type = POST_STICKY; $start = 0; $limit = 20; } else { if ($params[3] == 'ANN') { $topic_type = POST_ANNOUNCE . ', ' . POST_GLOBAL; $start = 0; $limit = 20; } } } // $default_sort_days = (!empty($user->data['user_topic_show_days'])) ? $user->data['user_topic_show_days'] : 0; // $default_sort_key = (!empty($user->data['user_topic_sortby_type'])) ? $user->data['user_topic_sortby_type'] : 't'; // $default_sort_dir = (!empty($user->data['user_topic_sortby_dir'])) ? $user->data['user_topic_sortby_dir'] : 'd'; // // $sort_days = request_var('st', $default_sort_days); // default to get all topic // $sort_key = request_var('sk', $default_sort_key); // default sort by last post time // $sort_dir = request_var('sd', $default_sort_dir); // default sort as DESC $sort_days = 0; $sort_key = 't'; $sort_dir = 'd'; //------- Grab appropriate forum data -------- $sql = "SELECT f.* FROM " . FORUMS_TABLE . " f WHERE f.forum_id = {$forum_id}"; $result = $db->sql_query($sql); $forum_data = $db->sql_fetchrow($result); $db->sql_freeresult($result); // Forum does not exist if (!$forum_data) { trigger_error('NO_FORUM'); } // Can not get topics from link forum if ($forum_data['forum_type'] == FORUM_LINK) { trigger_error('NO_FORUM'); } // Permissions check if (!$auth->acl_gets('f_list', 'f_read', $forum_id) || $forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link'] && !$auth->acl_get('f_read', $forum_id)) { if ($user->data['user_id'] != ANONYMOUS) { trigger_error('SORRY_AUTH_READ'); } trigger_error('LOGIN_VIEWFORUM'); } // Forum is passworded if ($forum_data['forum_password'] && !check_forum_password($forum_id)) { trigger_error('LOGIN_FORUM'); } if (!$auth->acl_get('f_read', $forum_id)) { trigger_error('NO_READ_ACCESS'); } // Topic ordering options $sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'r' => 't.topic_replies', 's' => 't.topic_title', 'v' => 't.topic_views'); // Limit topics to certain time frame, obtain correct topic count // global announcements must not be counted, normal announcements have to // be counted, as forum_topics(_real) includes them $sql_approved = $auth->acl_get('m_approve', $forum_id) ? '' : ' AND t.topic_approved = 1 '; // Get all shadow topics in this forum $sql = 'SELECT t.topic_moved_id, t.topic_id FROM ' . TOPICS_TABLE . ' t WHERE t.forum_id = ' . $forum_id . ' AND t.topic_type IN (' . POST_NORMAL . ', ' . POST_STICKY . ', ' . POST_ANNOUNCE . ', ' . POST_GLOBAL . ') AND t.topic_status = ' . ITEM_MOVED . ' ' . $sql_approved; $result = $db->sql_query($sql); $shadow_topic_list = array(); while ($row = $db->sql_fetchrow($result)) { $shadow_topic_list[$row['topic_moved_id']] = $row['topic_id']; } $db->sql_freeresult($result); // Pick out those shadow topics that the user has no permission to access if (!empty($shadow_topic_list)) { $sql = 'SELECT t.topic_id, t.forum_id FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('t.topic_id', array_keys($shadow_topic_list)); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if ($auth->acl_get('f_read', $row['forum_id'])) { unset($shadow_topic_list[$row['topic_id']]); } } $db->sql_freeresult($result); } // Grab all topic data $topic_list = array(); $sql_limit = $limit; // num of topics needs to be return, default is 20, at most 50 $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC'); $sql_shadow_out = empty($shadow_topic_list) ? '' : 'AND ' . $db->sql_in_set('t.topic_moved_id', $shadow_topic_list, true); // If the user is trying to reach late pages, start searching from the end $store_reverse = false; $unread_sticky_num = $unread_announce_count = 0; //get subscribe users $user_watch_row = array(); $sql = 'SELECT * FROM ' . TOPICS_WATCH_TABLE . ' WHERE user_id = ' . $user->data['user_id']; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $user_watch_row[$row['topic_id']] = $row['notify_status']; } $db->sql_freeresult($result); if (!empty($topic_type)) { $sql = 'SELECT t.*, u.user_avatar, u.user_avatar_type,bm.topic_id as bookmarked FROM ' . TOPICS_TABLE . ' t LEFT JOIN ' . USERS_TABLE . ' u ON (t.topic_poster = u.user_id) LEFT JOIN ' . BOOKMARKS_TABLE . ' bm ON (bm.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = bm.topic_id) WHERE t.forum_id IN (' . $forum_id . ', 0) AND t.topic_type IN (' . $topic_type . ') ' . $sql_shadow_out . ' ' . $sql_approved . ' ORDER BY ' . $sql_sort_order; $result = $db->sql_query_limit($sql, $sql_limit, $start); } else { if ($user->data['user_id'] != ANONYMOUS) { // get total number of unread sticky topics number $sql = 'SELECT t.topic_id, t.topic_last_post_time FROM ' . TOPICS_TABLE . ' t WHERE t.forum_id = ' . $forum_id . ' AND t.topic_type = ' . POST_STICKY . ' ' . $sql_shadow_out . ' ' . $sql_approved; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (empty($forum_id) || empty($row['topic_id'])) { continue; } $topic_tracking = get_complete_topic_tracking($forum_id, $row['topic_id']); if (isset($topic_tracking[$row['topic_id']]) && $topic_tracking[$row['topic_id']] < $row['topic_last_post_time']) { $unread_sticky_num++; } } $db->sql_freeresult($result); // get total number of unread announce topics number $sql = 'SELECT t.topic_id, t.topic_last_post_time FROM ' . TOPICS_TABLE . ' t WHERE t.forum_id IN (' . $forum_id . ', 0) AND t.topic_type IN (' . POST_ANNOUNCE . ', ' . POST_GLOBAL . ') ' . $sql_shadow_out . ' ' . $sql_approved; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (empty($forum_id) || empty($row['topic_id'])) { continue; } $topic_tracking = get_complete_topic_tracking($forum_id, $row['topic_id']); if (isset($topic_tracking[$row['topic_id']]) && $topic_tracking[$row['topic_id']] < $row['topic_last_post_time']) { $unread_announce_count++; } } $db->sql_freeresult($result); } // get total number of normal topics $sql = 'SELECT count(t.topic_id) AS num_topics FROM ' . TOPICS_TABLE . ' t WHERE t.forum_id = ' . $forum_id . ' AND t.topic_type = ' . POST_NORMAL . ' ' . $sql_shadow_out . ' ' . $sql_approved; $result = $db->sql_query($sql); $topics_count = (int) $db->sql_fetchfield('num_topics'); $db->sql_freeresult($result); if ($start > $topics_count / 2) { $store_reverse = true; if ($start + $sql_limit > $topics_count) { $sql_limit = min($sql_limit, max(1, $topics_count - $start)); } // Select the sort order $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'ASC' : 'DESC'); $start = max(0, $topics_count - $sql_limit - $start); } $sql = 'SELECT t.*, u.user_avatar, u.user_avatar_type,bm.topic_id as bookmarked FROM ' . TOPICS_TABLE . ' t LEFT JOIN ' . USERS_TABLE . ' u ON (t.topic_poster = u.user_id) LEFT JOIN ' . BOOKMARKS_TABLE . ' bm ON (bm.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = bm.topic_id) WHERE t.forum_id = ' . $forum_id . ' AND t.topic_type = ' . POST_NORMAL . ' ' . $sql_shadow_out . ' ' . $sql_approved . ' ORDER BY ' . $sql_sort_order; $result = $db->sql_query_limit($sql, $sql_limit, $start); } $tids = array(); $rowset = array(); while ($row = $db->sql_fetchrow($result)) { $rowset[] = $row; $tids[] = $row['topic_moved_id'] ? $row['topic_moved_id'] : $row['topic_id']; } $db->sql_freeresult($result); // get participated users of each topic // get_participated_user_avatars($tids); // global $topic_users, $user_avatar; $topic_list = array(); foreach ($rowset as $row) { $replies = $auth->acl_get('m_approve', $forum_id) ? $row['topic_replies_real'] : $row['topic_replies']; $short_content = get_short_content($row['topic_first_post_id']); $user_avatar_url = get_user_avatar_url($row['user_avatar'], $row['user_avatar_type']); $new_post = false; if ($user->data['user_id'] != ANONYMOUS) { if (empty($forum_id) || empty($row['topic_id'])) { continue; } $topic_tracking = get_complete_topic_tracking($forum_id, $row['topic_id']); $new_post = $topic_tracking[$row['topic_id']] < $row['topic_last_post_time'] ? true : false; } $allow_change_type = $auth->acl_get('m_', $forum_id) || $user->data['is_registered'] && $user->data['user_id'] == $row['topic_poster'] ? true : false; $topic_id = $row['topic_moved_id'] ? $row['topic_moved_id'] : $row['topic_id']; // $icon_urls = array(); // foreach($topic_users[$topic_id] as $posterid){ // $icon_urls[] = new xmlrpcval($user_avatar[$posterid], 'string'); // } $can_rename = $user->data['is_registered'] && ($auth->acl_get('m_edit', $forum_id) || $user->data['user_id'] == $row['topic_poster'] && $auth->acl_get('f_edit', $forum_id) && ($row['topic_time'] > time() - $config['edit_time'] * 60 || !$config['edit_time'])); $xmlrpc_topic = new xmlrpcval(array('forum_id' => new xmlrpcval($forum_id), 'topic_id' => new xmlrpcval($row['topic_moved_id'] ? $row['topic_moved_id'] : $row['topic_id']), 'topic_title' => new xmlrpcval(html_entity_decode(strip_tags(censor_text($row['topic_title'])), ENT_QUOTES, 'UTF-8'), 'base64'), 'topic_author_id' => new xmlrpcval($row['topic_first_post_id'], 'string'), 'topic_author_name' => new xmlrpcval(html_entity_decode($row['topic_first_poster_name']), 'base64'), 'last_reply_time' => new xmlrpcval(mobiquo_iso8601_encode($row['topic_last_post_time']), 'dateTime.iso8601'), 'timestamp' => new xmlrpcval($row['topic_last_post_time'], 'string'), 'reply_number' => new xmlrpcval($replies, 'int'), 'view_number' => new xmlrpcval($row['topic_views'], 'int'), 'short_content' => new xmlrpcval($short_content, 'base64'), 'new_post' => new xmlrpcval($new_post, 'boolean'), 'icon_url' => new xmlrpcval($user_avatar_url), 'attachment' => new xmlrpcval($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment'] ? 1 : 0, 'string'), 'can_delete' => new xmlrpcval($auth->acl_get('m_delete', $forum_id), 'boolean'), 'can_move' => new xmlrpcval($auth->acl_get('m_move', $forum_id), 'boolean'), 'can_subscribe' => new xmlrpcval(($config['email_enable'] || $config['jab_enable']) && $config['allow_topic_notify'] && $user->data['is_registered'], 'boolean'), 'is_subscribed' => new xmlrpcval(isset($user_watch_row[$topic_id]) ? true : false, 'boolean'), 'can_close' => new xmlrpcval($auth->acl_get('m_lock', $forum_id) || $auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $row['topic_poster'], 'boolean'), 'is_closed' => new xmlrpcval($row['topic_status'] == ITEM_LOCKED, 'boolean'), 'can_stick' => new xmlrpcval($allow_change_type && $auth->acl_get('f_sticky', $forum_id), 'boolean'), 'is_sticky' => new xmlrpcval($row['topic_type'] == POST_STICKY, 'boolean'), 'can_approve' => new xmlrpcval($auth->acl_get('m_approve', $forum_id) && !$row['topic_approved'], 'boolean'), 'is_approved' => new xmlrpcval($row['topic_approved'] ? true : false, 'boolean'), 'can_rename' => new xmlrpcval($can_rename, 'boolean')), 'struct'); $topic_list[] = $xmlrpc_topic; unset($xmlrpc_topic); } if ($store_reverse) { $topic_list = array_reverse($topic_list); } if (!empty($topic_type)) { $topic_num = count($topic_list); } else { $topic_num = $topics_count; } $allowed = $config['max_attachments'] && $auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && $config['allow_attachments'] && @ini_get('file_uploads') != '0' && strtolower(@ini_get('file_uploads')) != 'off'; $max_attachment = $auth->acl_get('a_') || $auth->acl_get('m_', $forum_id) ? 99 : ($allowed ? $config['max_attachments'] : 0); $max_png_size = $auth->acl_get('a_') || $auth->acl_get('m_', $forum_id) ? 10485760 : ($allowed ? $config['max_filesize'] === '0' ? 10485760 : $config['max_filesize'] : 0); $max_jpg_size = $auth->acl_get('a_') || $auth->acl_get('m_', $forum_id) ? 10485760 : ($allowed ? $config['max_filesize'] === '0' ? 10485760 : $config['max_filesize'] : 0); $read_only_forums = explode(",", $config['tapatalk_forum_read_only']); $can_post = true; if (empty($read_only_forums) || !is_array($read_only_forums)) { $read_only_forums = array(); } if (!$auth->acl_get('f_post', $forum_id) || in_array($forum_id, $read_only_forums)) { $can_post = false; } $response = new xmlrpcval(array('total_topic_num' => new xmlrpcval($topic_num, 'int'), 'unread_sticky_count' => new xmlrpcval($unread_sticky_num, 'int'), 'unread_announce_count' => new xmlrpcval($unread_announce_count, 'int'), 'forum_id' => new xmlrpcval($forum_id, 'string'), 'forum_name' => new xmlrpcval(html_entity_decode($forum_data['forum_name']), 'base64'), 'can_post' => new xmlrpcval($can_post, 'boolean'), 'can_upload' => new xmlrpcval($allowed, 'boolean'), 'max_attachment' => new xmlrpcval($max_attachment, 'int'), 'max_png_size' => new xmlrpcval($max_png_size, 'int'), 'max_jpg_size' => new xmlrpcval($max_jpg_size, 'int'), 'topics' => new xmlrpcval($topic_list, 'array')), 'struct'); return new xmlrpcresp($response); }
function method_get_unread_topic() { global $forum_root, $context, $modSettings; include_once $forum_root . '/Sources/Recent.php'; // Star/end if (isset($context['mob_request']['params'][0])) { $start_num = (int) $context['mob_request']['params'][0][0]; } if (isset($context['mob_request']['params'][1])) { $last_num = (int) $context['mob_request']['params'][1][0]; } list($_REQUEST['start'], $modSettings['defaultMaxTopics']) = process_page($start_num, $last_num); $_REQUEST['action'] = 'unread'; UnreadTopics(); $stids = get_subscribed_tids(); $uids = array(); if (!empty($context['topics'])) { foreach ($context['topics'] as $tid => $topic) { $context['topics'][$tid]['is_marked_notify'] = in_array($tid, $stids); $uids[] = $topic['last_post']['member']['id']; } } if (!empty($uids)) { $avatars = get_avatar_by_ids($uids); foreach ($context['topics'] as $tid => $topic) { $context['topics'][$tid]['last_post']['member']['avatar'] = $avatars[$topic['last_post']['member']['id']]; } } outputRPCSubscribedTopics($context['topics'], $context['num_topics']); }
public function process() { global $config; // check if there is data to be processed and figure out what page to display if (empty($_POST)) { // in case of empty post just refresh the previous page if (isset($_COOKIE['page'])) { $this->page = filter_var($_COOKIE['page'], FILTER_SANITIZE_STRING); } } else { // check if there is a page defined if (isset($_POST['page'])) { $this->page = filter_var($_POST['page'], FILTER_SANITIZE_STRING); // check if there is a action defined if (isset($_POST['action'])) { $this->action = filter_var($_POST['action'], FILTER_SANITIZE_STRING); } // get all variables from the post foreach ($_POST as $key => $value) { $this->var[$key] = filter_var($value, FILTER_SANITIZE_STRING); } } else { // in case no page is defined we need to show a error $this->err->add($this->txt->tr('txt_no_page')); $this->page = 'error'; return; } } // process language change $language = 'en'; if (isset($this->var['language']) && $this->action == 'change_language') { $language = $this->var['language']; setcookie('language', $language); $this->reload(); } else { if (isset($_COOKIE['language'])) { $language = filter_var($_COOKIE['language'], FILTER_SANITIZE_STRING); } } $this->txt->set_language($language); // check authentication if (!isset($_SESSION['user_id'])) { $this->page = 'login'; $this->status = $this->txt->tr('txt_version') . ' ' . $this->version; } else { if ($this->page == 'login') { $this->page = 'info'; } else { if ($this->page == 'logout') { session_unset(); session_destroy(); $this->reload(); } } $this->status = $this->txt->tr('txt_login_as') . ' ' . User::list_by_id($_SESSION['user_id'])->get_email(); } // process navigation if ($this->action == 'change_page') { setcookie('page', $this->page); $this->reload(); } // distribute based on required page include $this->page . '.php'; process_page($this, $this->action, $this->var); }