示例#1
0
function mark_pm_unread_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    $input = Tapatalk_Input::filterXmlInput(array('message_id' => Tapatalk_Input::INT), $xmlrpc_params);
    $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];
    }
    $sql_array = array("status" => 0, "readtime" => 0);
    $db->update_query("privatemessages", $sql_array, "pmid='{$input['message_id']}' AND uid='" . $mybb->user['uid'] . "'");
    update_pm_count();
    return xmlresptrue();
}
function mark_pm_unread_func($xmlrpc_params)
{
    global $db, $auth, $user, $config;
    $params = php_xmlrpc_decode($xmlrpc_params);
    $msg_id = intval($params[0]);
    $user->setup('ucp');
    $message_row = array();
    // Get Message user want to see
    $sql = 'SELECT t.*, p.*, u.*
            FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u
            WHERE t.user_id = ' . $user->data['user_id'] . "\r\r\n            AND p.author_id = u.user_id\r\r\n            AND t.msg_id = p.msg_id\r\r\n            AND p.msg_id = {$msg_id}";
    $result = $db->sql_query($sql);
    $message_row = $db->sql_fetchrow($result);
    $db->sql_freeresult($result);
    $folder_id = $message_row['folder_id'];
    $user_id = $user->data['user_id'];
    if (!$message_row) {
        trigger_error('NO_MESSAGE');
    }
    $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . "\r\r\n\t\tSET pm_unread = 1\r\r\n\t\tWHERE msg_id = {$msg_id}\r\r\n\t\t\tAND user_id = {$user_id}\r\r\n\t\t\tAND folder_id = {$folder_id}";
    $db->sql_query($sql);
    $sql = 'UPDATE ' . USERS_TABLE . "\r\r\n\t\tSET user_unread_privmsg = user_unread_privmsg + 1\r\r\n\t\tWHERE user_id = {$user_id}";
    $db->sql_query($sql);
    if ($user->data['user_id'] == $user_id) {
        $user->data['user_unread_privmsg']++;
        // Try to cope with previous wrong conversions...
        if ($user->data['user_unread_privmsg'] < 0) {
            $sql = 'UPDATE ' . USERS_TABLE . "\r\r\n\t\t\t\tSET user_unread_privmsg = 0\r\r\n\t\t\t\tWHERE user_id = {$user_id}";
            $db->sql_query($sql);
            $user->data['user_unread_privmsg'] = 0;
        }
    }
    return xmlresptrue();
}
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
0
function login_forum_func($xmlrpc_params)
{
    global $lang;
    $lang->load("forumdisplay");
    $input = Tapatalk_Input::filterXmlInput(array('forum_id' => Tapatalk_Input::INT, 'password' => Tapatalk_Input::STRING), $xmlrpc_params);
    tt_check_forum_password($input['forum_id'], 0, $input['password']);
    return xmlresptrue();
}
function unsubscribe_forum_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    $lang->load("usercp");
    $input = Tapatalk_Input::filterXmlInput(array('forum_id' => Tapatalk_Input::INT), $xmlrpc_params);
    $forum = get_forum($input['forum_id']);
    if (!$forum['fid']) {
        return xmlrespfalse($lang->error_invalidforum);
    }
    remove_subscribed_forum($forum['fid']);
    return xmlresptrue();
}
示例#6
0
function logout_user_func()
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups, $forum_cache;
    if (!$mybb->user['uid']) {
        return xmlrespfalse('Already logged out');
    }
    my_unsetcookie("mybbuser");
    my_unsetcookie("sid");
    if ($mybb->user['uid']) {
        $time = TIME_NOW;
        $lastvisit = array("lastactive" => $time - 900, "lastvisit" => $time);
        $db->update_query("users", $lastvisit, "uid='" . $mybb->user['uid'] . "'");
        $db->delete_query("sessions", "sid='" . $session->sid . "'");
    }
    return xmlresptrue();
}
示例#7
0
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();
}
function mark_all_as_read_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups, $forum_cache;
    $input = Tapatalk_Input::filterXmlInput(array('forum_id' => Tapatalk_Input::INT), $xmlrpc_params);
    if (!empty($input['forum_id'])) {
        $validforum = get_forum($input['forum_id']);
        if (!$validforum) {
            return xmlrespfalse('Invalid forum');
        }
        require_once MYBB_ROOT . "/inc/functions_indicators.php";
        mark_forum_read($input['forum_id']);
    } else {
        require_once MYBB_ROOT . "/inc/functions_indicators.php";
        mark_all_forums_read();
    }
    return xmlresptrue();
}
示例#9
0
function upload_avatar_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    //chdir("../");
    $input = Tapatalk_Input::filterXmlInput(array('content' => Tapatalk_Input::STRING), $xmlrpc_params);
    if ($mybb->usergroup['canuploadavatars'] == 0) {
        error_no_permission();
    }
    $avatar = upload_avatar($_FILES['upload']);
    if ($avatar['error']) {
        return xmlrespfalse($avatar['error']);
    } else {
        if ($avatar['width'] > 0 && $avatar['height'] > 0) {
            $avatar_dimensions = $avatar['width'] . "|" . $avatar['height'];
        }
        $updated_avatar = array("avatar" => $avatar['avatar'] . '?dateline=' . TIME_NOW, "avatardimensions" => $avatar_dimensions, "avatartype" => "upload");
        $db->update_query("users", $updated_avatar, "uid='" . $mybb->user['uid'] . "'");
    }
    return xmlresptrue();
}
示例#10
0
function create_message_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups, $pminfo, $pm;
    $input = Tapatalk_Input::filterXmlInput(array('user_name' => Tapatalk_Input::RAW, 'subject' => Tapatalk_Input::STRING, 'text_body' => Tapatalk_Input::STRING, 'action' => Tapatalk_Input::INT, 'pm_id' => Tapatalk_Input::INT), $xmlrpc_params);
    $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();
    }
    if ($mybb->usergroup['cansendpms'] == 0) {
        return tt_no_permission();
    }
    $pmhandler = new PMDataHandler();
    $pm = array("subject" => $input['subject'], "message" => $input['text_body'], "icon" => 0, "fromid" => $mybb->user['uid'], "do" => $input['action'] == 1 ? 'reply' : 'forward', "pmid" => $input['pm_id']);
    $pm['to'] = array_map("trim", $input['user_name']);
    $pm['options'] = array("signature" => 0, "disablesmilies" => 0, "savecopy" => 1, "readreceipt" => 0);
    $pmhandler->set_data($pm);
    if (!$pmhandler->validate_pm()) {
        $pm_errors = $pmhandler->get_friendly_errors();
        return xmlrespfalse(implode(" :: ", $pm_errors));
    } else {
        $pminfo = $pmhandler->insert_pm();
        $plugins->run_hooks("private_do_send_end");
    }
    return xmlresptrue();
}
示例#11
0
function delete_message_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    $input = Tapatalk_Input::filterXmlInput(array('message_id' => Tapatalk_Input::INT, 'box_id' => Tapatalk_Input::INT), $xmlrpc_params);
    $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];
    }
    $query = $db->simple_select("privatemessages", "*", "pmid='{$input['message_id']}' AND uid='" . $mybb->user['uid'] . "' AND folder='4'", array('order_by' => 'pmid'));
    if ($db->num_rows($query) == 1) {
        $db->delete_query("privatemessages", "pmid='{$input['message_id']}'");
    } else {
        $sql_array = array("folder" => 4, "deletetime" => TIME_NOW);
        $db->update_query("privatemessages", $sql_array, "pmid='{$input['message_id']}' AND uid='" . $mybb->user['uid'] . "'");
    }
    update_pm_count();
    return xmlresptrue();
}
示例#12
0
function ignore_user_func()
{
    return xmlresptrue();
}
示例#13
0
function report_post_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    $input = Tapatalk_Input::filterXmlInput(array('post_id' => Tapatalk_Input::INT, 'reason' => Tapatalk_Input::STRING), $xmlrpc_params);
    $lang->load("report");
    if ($mybb->usergroup['canview'] == 0 || !$mybb->user['uid']) {
        return tt_no_permission();
    }
    $post = get_post($input['post_id']);
    if (!$post['pid']) {
        return xmlrespfalse($lang->error_invalidpost);
    }
    $forum = get_forum($post['fid']);
    if (!$forum) {
        $error = $lang->error_invalidforum;
        eval("\$report_error = \"" . $templates->get("report_error") . "\";");
        output_page($report_error);
        exit;
    }
    tt_check_forum_password($forum['parentlist']);
    $thread = get_thread($post['tid']);
    if (version_compare($mybb->version, '1.8.0', '<')) {
        if ($mybb->settings['reportmethod'] == "email" || $mybb->settings['reportmethod'] == "pms") {
            $query = $db->query("\n\t\t\t\tSELECT DISTINCT u.username, u.email, u.receivepms, u.uid\n\t\t\t\tFROM " . TABLE_PREFIX . "moderators m\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=m.id)\n\t\t\t\tWHERE m.fid IN (" . $forum['parentlist'] . ") AND m.isgroup = '0'\n\t\t\t");
            $nummods = $db->num_rows($query);
            if (!$nummods) {
                unset($query);
                switch ($db->type) {
                    case "pgsql":
                    case "sqlite":
                        $query = $db->query("\n\t\t\t\t\t\t\tSELECT u.username, u.email, u.receivepms, u.uid\n\t\t\t\t\t\t\tFROM " . TABLE_PREFIX . "users u\n\t\t\t\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "usergroups g ON (((','|| u.additionalgroups|| ',' LIKE '%,'|| g.gid|| ',%') OR u.usergroup = g.gid))\n\t\t\t\t\t\t\tWHERE (g.cancp=1 OR g.issupermod=1)\n\t\t\t\t\t\t");
                        break;
                    default:
                        $query = $db->query("\n\t\t\t\t\t\t\tSELECT u.username, u.email, u.receivepms, u.uid\n\t\t\t\t\t\t\tFROM " . TABLE_PREFIX . "users u\n\t\t\t\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "usergroups g ON (((CONCAT(',', u.additionalgroups, ',') LIKE CONCAT('%,', g.gid, ',%')) OR u.usergroup = g.gid))\n\t\t\t\t\t\t\tWHERE (g.cancp=1 OR g.issupermod=1)\n\t\t\t\t\t\t");
                }
            }
            while ($mod = $db->fetch_array($query)) {
                $emailsubject = $lang->sprintf($lang->emailsubject_reportpost, $mybb->settings['bbname']);
                $emailmessage = $lang->sprintf($lang->email_reportpost, $mybb->user['username'], $mybb->settings['bbname'], $post['subject'], $mybb->settings['bburl'], str_replace('&amp;', '&', get_post_link($post['pid'], $thread['tid']) . "#pid" . $post['pid']), $thread['subject'], $input['reason']);
                if ($mybb->settings['reportmethod'] == "pms" && $mod['receivepms'] != 0 && $mybb->settings['enablepms'] != 0) {
                    $pm_recipients[] = $mod['uid'];
                } else {
                    my_mail($mod['email'], $emailsubject, $emailmessage);
                }
            }
            if (count($pm_recipients) > 0) {
                $emailsubject = $lang->sprintf($lang->emailsubject_reportpost, $mybb->settings['bbname']);
                $emailmessage = $lang->sprintf($lang->email_reportpost, $mybb->user['username'], $mybb->settings['bbname'], $post['subject'], $mybb->settings['bburl'], str_replace('&amp;', '&', get_post_link($post['pid'], $thread['tid']) . "#pid" . $post['pid']), $thread['subject'], $input['reason']);
                require_once MYBB_ROOT . "inc/datahandlers/pm.php";
                $pmhandler = new PMDataHandler();
                $pm = array("subject" => $emailsubject, "message" => $emailmessage, "icon" => 0, "fromid" => $mybb->user['uid'], "toid" => $pm_recipients);
                $pmhandler->admin_override = true;
                $pmhandler->set_data($pm);
                // Now let the pm handler do all the hard work.
                if (!$pmhandler->validate_pm()) {
                    // Force it to valid to just get it out of here
                    $pmhandler->is_validated = true;
                    $pmhandler->errors = array();
                }
                $pminfo = $pmhandler->insert_pm();
            }
        } else {
            $reportedpost = array("pid" => $input['post_id'], "tid" => $thread['tid'], "fid" => $thread['fid'], "uid" => $mybb->user['uid'], "dateline" => TIME_NOW, "reportstatus" => 0, "reason" => $db->escape_string(htmlspecialchars_uni($input['reason'])));
            $db->insert_query("reportedposts", $reportedpost);
            $cache->update_reportedposts();
        }
    } else {
        require_once MYBB_ROOT . 'inc/functions_modcp.php';
        $plugins->run_hooks("report_do_report_start");
        $id = $post['pid'];
        $id2 = $post['tid'];
        $id3 = $forum['fid'];
        $report_type = 'post';
        $report_type_db = "(type = 'post' OR type = '')";
        if (!empty($report_type_db)) {
            $query = $db->simple_select("reportedcontent", "*", "reportstatus != '1' AND id = '{$id}' AND {$report_type_db}");
            if ($db->num_rows($query)) {
                // Existing report
                $report = $db->fetch_array($query);
                $report['reporters'] = my_unserialize($report['reporters']);
                if ($mybb->user['uid'] == $report['uid'] || is_array($report['reporters']) && in_array($mybb->user['uid'], $report['reporters'])) {
                    $error = $lang->success_report_voted;
                }
            }
        }
        // Is this an existing report or a new offender?
        if (!empty($report)) {
            // Existing report, add vote
            $report['reporters'][] = $mybb->user['uid'];
            update_report($report);
            //$plugins->run_hooks("report_do_report_end");
        } else {
            // Bad user!
            $new_report = array('id' => $id, 'id2' => $id2, 'id3' => $id3, 'uid' => $mybb->user['uid']);
            // Figure out the reason
            $reason = trim($input['reason']);
            if ($reason == 'other') {
                // Replace the reason with the user comment
                $reason = trim($mybb->get_input('comment'));
            } else {
                $report_reason_string = "report_reason_{$reason}";
                //$reason = "\n".$lang->$report_reason_string;
            }
            if (my_strlen($reason) < 3) {
                $error = $lang->error_report_length;
            }
            if (empty($error)) {
                $new_report['reason'] = $reason;
                add_report($new_report, $report_type);
            } else {
                error($error);
            }
        }
    }
    return xmlresptrue();
}
function update_push_status_func($xmlrpc_params)
{
    return xmlresptrue();
}