本文整理汇总了PHP中get_thread函数的典型用法代码示例。如果您正苦于以下问题:PHP get_thread函数的具体用法?PHP get_thread怎么用?PHP get_thread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_thread函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_thread_by_unread_func
function get_thread_by_unread_func($xmlrpc_params)
{
global $db, $mybb;
$input = Tapatalk_Input::filterXmlInput(array('topic_id' => Tapatalk_Input::STRING, 'posts_per_request' => 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);
}
$thread = get_thread($input['topic_id']);
if (!empty($thread['closed'])) {
$moved = explode("|", $thread['closed']);
if ($moved[0] == "moved") {
$thread = get_thread($moved[1]);
}
}
if (is_moderator($thread['fid'])) {
$visible = "AND (p.visible='0' OR p.visible='1')";
} else {
$visible = "AND p.visible='1'";
}
$cutoff = 0;
if ($mybb->settings['threadreadcut'] > 0) {
$cutoff = TIME_NOW - $mybb->settings['threadreadcut'] * 60 * 60 * 24;
}
$query = $db->query("select min(p.pid) as pid from " . TABLE_PREFIX . "posts p\n LEFT JOIN " . TABLE_PREFIX . "threadsread tr on p.tid = tr.tid and tr.uid = '{$mybb->user['uid']}'\n where p.tid='{$thread['tid']}' and p.uid != '{$mybb->user['uid']}' and (p.dateline > tr.dateline or tr.dateline is null) and p.dateline > {$cutoff} {$visible}\n ");
$pid = $db->fetch_field($query, 'pid');
if (!$pid) {
$query = $db->query("select p.pid from " . TABLE_PREFIX . "posts p\n where p.tid='{$thread['tid']}' {$visible}\n order by p.dateline desc\n limit 1");
$pid = $db->fetch_field($query, 'pid');
}
return get_thread_by_post_func(new xmlrpcval(array(new xmlrpcval($pid, "string"), new xmlrpcval($input['posts_per_request'], 'int'), new xmlrpcval(!!$input['return_html'], 'boolean')), 'array'));
}
示例2: rebuild_thread_counters
/**
* Completely rebuild the counters for a particular thread (useful if they become out of sync)
*
* @param int The thread ID
* @param array Optional thread array so we don't have to query it
*/
function rebuild_thread_counters($tid)
{
global $db;
if (!$thread['tid']) {
$thread = get_thread($tid);
}
$query = $db->simple_select("posts", "COUNT(*) AS replies", "tid='{$tid}' AND pid!='{$thread['firstpost']}' AND visible='1'");
$count['replies'] = $db->fetch_field($query, "replies");
if ($count['replies'] < 0) {
$count['replies'] = 0;
}
// Unapproved posts
$query = $db->simple_select("posts", "COUNT(pid) AS totunposts", "tid='{$tid}' AND pid != '{$thread['firstpost']}' AND visible='0'");
$count['unapprovedposts'] = $db->fetch_field($query, "totunposts");
if (!$count['unapprovedposts']) {
$count['unapprovedposts'] = 0;
}
// Attachment count
$query = $db->query("\n\t\t\tSELECT COUNT(aid) AS attachment_count\n\t\t\tFROM " . TABLE_PREFIX . "attachments a\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "posts p ON (a.pid=p.pid)\n\t\t\tWHERE p.tid='{$tid}'\n\t");
$count['attachmentcount'] = $db->fetch_field($query, "attachment_count");
if (!$count['attachmentcount']) {
$count['attachmentcount'] = 0;
}
update_thread_counters($tid, $count);
}
示例3: remove_attachment_func
function remove_attachment_func($xmlrpc_params)
{
global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
chdir("../");
$lang->load("member");
$parser = new postParser();
$input = Tapatalk_Input::filterXmlInput(array('attachment_id' => Tapatalk_Input::INT, 'forum_id' => Tapatalk_Input::INT, 'group_id' => Tapatalk_Input::STRING, 'post_id' => Tapatalk_Input::INT), $xmlrpc_params);
$fid = $input['forum_id'];
$forum = get_forum($fid);
if (!$forum) {
return xmlrespfalse($lang->error_invalidforum);
}
$forumpermissions = forum_permissions($fid);
if ($forum['open'] == 0 || $forum['type'] != "f") {
return xmlrespfalse($lang->error_closedinvalidforum);
}
if ($mybb->user['uid'] < 1 || $forumpermissions['canview'] == 0 || $forumpermissions['canpostthreads'] == 0 || $mybb->user['suspendposting'] == 1) {
return tt_no_permission();
}
tt_check_forum_password($forum['fid']);
$posthash = $input['group_id'];
$mybb->input['posthash'] = $posthash;
// If we're removing an attachment that belongs to an existing post, some security checks...
$query = $db->simple_select("attachments", "pid", "aid='{$input['attachment_id']}'");
$attachment = $db->fetch_array($query);
$pid = $attachment['pid'];
if ($pid > 0) {
if ($pid != $input['post_id']) {
return xmlrespfalse("The attachment you are trying to remove does not belong to this post");
}
$query = $db->simple_select("posts", "*", "pid='{$pid}'");
$post = $db->fetch_array($query);
if (!$post['pid']) {
return xmlrespfalse($lang->error_invalidpost);
}
// Get thread info
$tid = $post['tid'];
$thread = get_thread($tid);
if (!$thread['tid']) {
return xmlrespfalse($lang->error_invalidthread);
}
if (!is_moderator($fid, "caneditposts")) {
if ($thread['closed'] == 1) {
return xmlrespfalse($lang->redirect_threadclosed);
}
if ($forumpermissions['caneditposts'] == 0) {
return tt_no_permission();
}
if ($mybb->user['uid'] != $post['uid']) {
return tt_no_permission();
}
}
} else {
$pid = 0;
}
require_once MYBB_ROOT . "inc/functions_upload.php";
remove_attachment($pid, $mybb->input['posthash'], $input['attachment_id']);
return xmlresptrue();
}
示例4: unsubscribe_topic_func
function unsubscribe_topic_func($xmlrpc_params)
{
global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
$lang->load("usercp");
$input = Tapatalk_Input::filterXmlInput(array('topic_id' => Tapatalk_Input::INT), $xmlrpc_params);
$thread = get_thread($input['topic_id']);
if (!$thread['tid']) {
return xmlrespfalse($lang->error_invalidthread);
}
remove_subscribed_thread($thread['tid']);
return xmlresptrue();
}
示例5: subscribe_topic_func
function subscribe_topic_func($xmlrpc_params)
{
global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
$lang->load("usercp");
$input = Tapatalk_Input::filterXmlInput(array('topic_id' => Tapatalk_Input::INT), $xmlrpc_params);
$thread = get_thread($input['topic_id']);
if (!$thread['tid']) {
return xmlrespfalse($lang->error_invalidthread);
}
$forumpermissions = forum_permissions($thread['fid']);
if ($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0) {
return tt_no_permission();
}
add_subscribed_thread($thread['tid'], 0);
return xmlresptrue();
}
示例6: rebuild_thread_counters
/**
* Completely rebuild the counters for a particular thread (useful if they become out of sync)
*
* @param int The thread ID
*/
function rebuild_thread_counters($tid)
{
global $db;
$thread = get_thread($tid);
$count = array();
$query = $db->simple_select("posts", "COUNT(pid) AS replies", "tid='{$tid}' AND pid!='{$thread['firstpost']}' AND visible='1'");
$count['replies'] = $db->fetch_field($query, "replies");
// Unapproved posts
$query = $db->simple_select("posts", "COUNT(pid) AS unapprovedposts", "tid='{$tid}' AND pid != '{$thread['firstpost']}' AND visible='0'");
$count['unapprovedposts'] = $db->fetch_field($query, "unapprovedposts");
// Soft deleted posts
$query = $db->simple_select("posts", "COUNT(pid) AS deletedposts", "tid='{$tid}' AND pid != '{$thread['firstpost']}' AND visible='-1'");
$count['deletedposts'] = $db->fetch_field($query, "deletedposts");
// Attachment count
$query = $db->query("\n\t\t\tSELECT COUNT(aid) AS attachment_count\n\t\t\tFROM " . TABLE_PREFIX . "attachments a\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "posts p ON (a.pid=p.pid)\n\t\t\tWHERE p.tid='{$tid}' AND a.visible=1\n\t");
$count['attachmentcount'] = $db->fetch_field($query, "attachment_count");
update_thread_counters($tid, $count);
update_thread_data($tid);
}
示例7: reportthread_dopost
function reportthread_dopost()
{
require_once MYBB_ROOT . "inc/datahandlers/post.php";
global $db, $mybb;
if (intval($mybb->settings['rtt_enabled']) == 1 || preg_replace("/[^a-z]/i", "", $mybb->settings['rtt_enabled']) == "yes") {
if ($mybb->input['type'] == 'post') {
$title = "Reported Post By ";
$post = get_post($mybb->input['pid']);
$thread = get_thread($post['tid']);
$forum = get_forum($thread['fid']);
$tlink = get_thread_link($thread['tid']);
$flink = get_forum_link($thread['fid']);
$reason = $mybb->input['reason'];
if ($reason === 'other') {
$reason = $mybb->input['comment'];
}
$post_data = $mybb->user['username'] . " has reported a post.\r\n\r\nOriginal Thread: [url=" . $mybb->settings['bburl'] . "/{$tlink}]" . $thread['subject'] . "[/url]\r\nForum: [url=" . $mybb->settings['bburl'] . "/{$flink}]" . $forum['name'] . "[/url]\r\n\r\nReason Given:\r\n[quote=\"" . $mybb->user['username'] . "\" dateline=\"" . time() . "\"]" . $reason . "[/quote]\r\n\r\nPost Content:\r\n[quote=\"" . $post['username'] . "\" pid=\"" . $post['pid'] . "\" dateline=\"" . $post['dateline'] . "\"]" . $post['message'] . "[/quote]";
} else {
if ($mybb->input['type'] == 'reputation') {
$title = "Reported Reputation By ";
$rep = get_reputation_point($mybb->input['pid']);
$giver = get_user($rep['adduid']);
$reason = $mybb->input['reason'];
if ($reason === 'other') {
$reason = $mybb->input['comment'];
}
$post_data = $mybb->user['username'] . " has reported a reputation point.\r\n\r\nReason Given:\r\n[quote=\"" . $mybb->user['username'] . "\" dateline=\"" . time() . "\"]" . $reason . "[/quote]\r\n\r\nReputation comment:\r\n[quote=\"" . $giver['username'] . "\" dateline=\"" . $rep['dateline'] . "\"]" . $rep['comments'] . "[/quote]";
}
}
$new_thread = array("fid" => $mybb->settings['rtt_fid'], "prefix" => 0, "subject" => $title . $mybb->user['username'], "icon" => 0, "uid" => $mybb->user['uid'], "username" => $mybb->user['username'], "message" => $post_data, "ipaddress" => get_ip(), "posthash" => md5($mybb->user['uid'] . random_str()));
$posthandler = new PostDataHandler("insert");
$posthandler->action = "thread";
$posthandler->set_data($new_thread);
if ($posthandler->validate_thread()) {
$thread_info = $posthandler->insert_thread();
}
}
}
示例8: elseif
} elseif ($mybb->get_input('action') == "removesubscription") {
if ($mybb->get_input('type') == "forum") {
$forum = get_forum($mybb->get_input('fid', MyBB::INPUT_INT));
if (!$forum) {
error($lang->error_invalidforum);
}
$plugins->run_hooks("usercp2_removesubscription_forum");
remove_subscribed_forum($forum['fid']);
if ($server_http_referer) {
$url = $server_http_referer;
} else {
$url = "usercp.php?action=forumsubscriptions";
}
redirect($url, $lang->redirect_forumsubscriptionremoved);
} else {
$thread = get_thread($mybb->get_input('tid', MyBB::INPUT_INT));
if (!$thread) {
error($lang->error_invalidthread);
}
// Is the currently logged in user a moderator of this forum?
if (is_moderator($thread['fid'])) {
$ismod = true;
} else {
$ismod = false;
}
// Make sure we are looking at a real thread here.
if ($thread['visible'] != 1 && $ismod == false || $thread['visible'] > 1 && $ismod == true) {
error($lang->error_invalidthread);
}
$plugins->run_hooks("usercp2_removesubscription_thread");
remove_subscribed_thread($thread['tid']);
示例9: bb_getPosts
/**
* Returns details of the posts in a given topic
*
* @since 1.0
* @return array|object The posts when successfully executed or an IXR_Error object on failure
* @param array $args Arguments passed by the XML-RPC call
* @param string $args[0] The username for authentication
* @param string $args[1] The password for authentication
* @param integer|string $args[2] The topic id or slug
* @param integer $args[3] The number of posts to return (optional)
* @param integer $args[4] The number of the page to return (optional)
*
* XML-RPC request to get all posts in the topic with id number 53
* <methodCall>
* <methodName>bb.getPosts</methodName>
* <params>
* <param><value><string>joeblow</string></value></param>
* <param><value><string>123password</string></value></param>
* <param><value><int>53</int></value></param>
* </params>
* </methodCall>
*
* XML-RPC request to get the latest 5 posts in the topic with id number 341
* <methodCall>
* <methodName>bb.getPosts</methodName>
* <params>
* <param><value><string>joeblow</string></value></param>
* <param><value><string>123password</string></value></param>
* <param><value><int>341</int></value></param>
* <param><value><int>5</int></value></param>
* </params>
* </methodCall>
*
* XML-RPC request to get posts 11 to 20 in the topic with slug "long-topic"
* <methodCall>
* <methodName>bb.getPosts</methodName>
* <params>
* <param><value><string>joeblow</string></value></param>
* <param><value><string>123password</string></value></param>
* <param><value><string>long-topic</string></value></param>
* <param><value><int>10</int></value></param>
* <param><value><int>2</int></value></param>
* </params>
* </methodCall>
*/
function bb_getPosts($args)
{
do_action('bb_xmlrpc_call', 'bb.getPosts');
// Escape args
$this->escape($args);
// Get the login credentials
$username = $args[0];
$password = (string) $args[1];
// Check the user is valid
if ($this->auth_readonly) {
$user = $this->authenticate($username, $password);
}
do_action('bb_xmlrpc_call_authenticated', 'bb.getPosts');
// If an error was raised by authentication or by an action then return it
if ($this->error) {
return $this->error;
}
// Can be numeric id or slug
$topic_id = isset($args[2]) ? $args[2] : false;
// Check for bad data
if (!$topic_id || !is_string($topic_id) && !is_integer($topic_id)) {
$this->error = new IXR_Error(400, __('The topic id is invalid.'));
return $this->error;
}
// Check the requested topic exists
if (!($topic = get_topic($topic_id))) {
$this->error = new IXR_Error(400, __('No topic found.'));
return $this->error;
}
// The topic id may have been a slug, so make sure it's an integer here
$topic_id = (int) $topic->topic_id;
// Setup an array to store arguments to pass to get_thread() function
$get_thread_args = array();
// Can only be an integer
if (isset($args[3]) && ($per_page = (int) $args[3])) {
$get_thread_args['per_page'] = $per_page;
}
// Can only be an integer
if (isset($args[4]) && ($page = (int) $args[4])) {
$get_thread_args['page'] = $page;
}
// Get the posts
if (!($posts = get_thread($topic_id, $get_thread_args))) {
$this->error = new IXR_Error(500, __('No posts found.'));
return $this->error;
}
// Only include "safe" data in the array
$_posts = array();
foreach ($posts as $post) {
$_posts[] = $this->prepare_post($post);
}
do_action('bb_xmlrpc_call_return', 'bb.getPosts');
// Return the posts
return $_posts;
}
示例10: ougc_showinportal_myalerts_output
function ougc_showinportal_myalerts_output(&$args)
{
global $mybb;
if ($args['alert_type'] != 'ougc_showinportal' || !$mybb->user['myalerts_settings']['ougc_showinportal']) {
return;
}
global $showinportal, $lang;
$showinportal->lang_load();
$lang_var = 'ougc_showinportal_myalerts_showinportal';
if (!$args['content'][0]) {
$lang_var = 'ougc_showinportal_myalerts_unshowinportal';
}
$thread = get_thread($args['tid']);
if (!$thread) {
return;
}
$args['threadLink'] = $mybb->settings['bburl'] . '/' . get_thread_link($thread['tid']);
$args['message'] = $lang->sprintf($lang->{$lang_var}, $args['user'], $args['threadLink'], htmlspecialchars_uni($thread['subject']), $args['dateline']);
$args['rowType'] = 'showinportal';
}
示例11: get_thread
function get_thread($topic_id, $page = 1, $reverse = 0)
{
bb_log_deprecated('class::function', __CLASS__ . '::' . __FUNCTION__, 'get_thread');
return get_thread($topic_id, $page, $reverse);
}
示例12: get_thread_func
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
//.........这里部分代码省略.........
示例13: get_special_locations
/**
* Find out the special locations.
*
* @return array Special locations array.
*/
function get_special_locations()
{
global $mybb;
$array = array('1' => '', '2' => '');
if (preg_match("#forumdisplay.php#", $_SERVER['PHP_SELF']) && $mybb->get_input('fid', MyBB::INPUT_INT) > 0) {
$array[1] = $mybb->get_input('fid', MyBB::INPUT_INT);
$array[2] = '';
} elseif (preg_match("#showthread.php#", $_SERVER['PHP_SELF'])) {
global $db;
if ($mybb->get_input('tid', MyBB::INPUT_INT) > 0) {
$array[2] = $mybb->get_input('tid', MyBB::INPUT_INT);
} elseif (isset($mybb->input['pid']) && !empty($mybb->input['pid'])) {
$options = array("limit" => 1);
$query = $db->simple_select("posts", "tid", "pid=" . $mybb->get_input('pid', MyBB::INPUT_INT), $options);
$post = $db->fetch_array($query);
$array[2] = $post['tid'];
}
$thread = get_thread($array[2]);
$array[1] = $thread['fid'];
}
return $array;
}
示例14: get_thread_post_ids
function get_thread_post_ids($topic_id)
{
$return = array('post' => array(), 'poster' => array());
foreach (get_thread($topic_id, array('per_page' => -1)) as $post) {
$return['post'][] = $post->post_id;
$return['poster'][] = $post->poster_id;
}
return $return;
}
示例15: get_thread
<?php
// Update the tags for a thread
include 'init.php';
$thread_id = (int) $_POST['thread_id'];
$thread = get_thread($thread_id);
if (!$thread) {
die('Thread not found.');
}
$tags = $_POST['tags'];
update_tags($thread_id, $tags);
header('Location: thread.php?updated=tags&t=' . $thread_id);