Beispiel #1
0
function search_post_func()
{
    global $context, $smcFunc;
    $post_list = array();
    if (isset($context['get_topics'])) {
        while ($topic = $context['get_topics']()) {
            $topic_info = get_topic_info($topic['board']['id'], $topic['id']);
            $xmlrpc_post = new xmlrpcval(array('forum_id' => new xmlrpcval($topic['board']['id']), 'forum_name' => new xmlrpcval(basic_clean($topic['board']['name']), 'base64'), 'topic_id' => new xmlrpcval($topic['id']), 'topic_title' => new xmlrpcval(basic_clean($topic['first_post']['subject']), 'base64'), 'post_id' => new xmlrpcval($topic['matches'][0]['id'], 'string'), 'post_title' => new xmlrpcval(basic_clean($topic['matches'][0]['subject']), 'base64'), 'post_author_name' => new xmlrpcval(basic_clean($topic['matches'][0]['member']['name']), 'base64'), 'short_content' => new xmlrpcval(basic_clean($topic['matches'][0]['body'], 200, 1), 'base64'), 'icon_url' => new xmlrpcval($topic['matches'][0]['member']['avatar']['href']), 'post_time' => new xmlrpcval($topic['matches'][0]['time'], 'dateTime.iso8601'), 'timestamp' => new xmlrpcval($topic['matches'][0]['timestamp'], 'string'), 'reply_number' => new xmlrpcval($topic_info['num_replies'], 'int'), 'view_number' => new xmlrpcval($topic_info['num_views'], 'int'), 'new_post' => new xmlrpcval($topic_info['new'], 'boolean'), 'can_subscribe' => new xmlrpcval($topic_info['can_mark_notify'], 'boolean'), 'is_subscribed' => new xmlrpcval($topic_info['is_marked_notify'], 'boolean'), 'is_closed' => new xmlrpcval($topic_info['is_locked'], 'boolean'), 'is_sticky' => new xmlrpcval($topic_info['is_sticky'], 'boolean'), 'can_delete' => new xmlrpcval($topic_info['can_remove'], 'boolean'), 'can_close' => new xmlrpcval($topic_info['can_lock'], 'boolean'), 'can_stick' => new xmlrpcval($topic_info['can_sticky'], 'boolean'), 'can_move' => new xmlrpcval($topic_info['can_move'], 'boolean')), 'struct');
            $post_list[] = $xmlrpc_post;
        }
        $result = new xmlrpcval(array('total_post_num' => new xmlrpcval($context['num_results'] == 0 && !empty($post_list) ? count($post_list) : $context['num_results'], 'int'), 'search_id' => new xmlrpcval($context['params'], 'string'), 'posts' => new xmlrpcval($post_list, 'array')), 'struct');
    } elseif (isset($context['exttMbqRecords'])) {
        //search by user
        foreach ($context['exttMbqRecords'] as $topic) {
            $topic_info = get_topic_info($topic['board']['id'], $topic['topic']);
            $mbqResult = $smcFunc['db_query']('', '
                SELECT *
                FROM {db_prefix}messages
                WHERE id_msg = {int:id_msg}', array('id_msg' => $topic['id']));
            $mbqRow = $smcFunc['db_fetch_assoc']($mbqResult);
            require_once ExttMbqBase::$otherParameters['sourcedir'] . '/Subs-Members.php';
            $member = list_getMembers(0, 10, 'member_name', '(mem.id_member = {int:memberId})', array('memberId' => $mbqRow['id_member']));
            $member = $member[0];
            $xmlrpc_post = new xmlrpcval(array('forum_id' => new xmlrpcval($topic['board']['id']), 'forum_name' => new xmlrpcval(basic_clean($topic['board']['name']), 'base64'), 'topic_id' => new xmlrpcval($topic['topic']), 'topic_title' => new xmlrpcval(basic_clean($topic_info['first_subject']), 'base64'), 'post_id' => new xmlrpcval($topic['id'], 'string'), 'post_title' => new xmlrpcval(basic_clean($topic['subject']), 'base64'), 'post_author_name' => new xmlrpcval(basic_clean($member['member_name']), 'base64'), 'short_content' => new xmlrpcval(basic_clean($topic['body'], 200, 1), 'base64'), 'icon_url' => new xmlrpcval($topic['matches'][0]['member']['avatar']['href']), 'post_time' => new xmlrpcval($topic['time'], 'dateTime.iso8601'), 'timestamp' => new xmlrpcval($topic['timestamp'], 'string'), 'reply_number' => new xmlrpcval($topic_info['num_replies'], 'int'), 'view_number' => new xmlrpcval($topic_info['num_views'], 'int'), 'new_post' => new xmlrpcval($topic_info['new'], 'boolean'), 'can_subscribe' => new xmlrpcval($topic_info['can_mark_notify'], 'boolean'), 'is_subscribed' => new xmlrpcval($topic_info['is_marked_notify'], 'boolean'), 'is_closed' => new xmlrpcval($topic_info['is_locked'], 'boolean'), 'is_sticky' => new xmlrpcval($topic_info['is_sticky'], 'boolean'), 'can_delete' => new xmlrpcval($topic_info['can_remove'], 'boolean'), 'can_close' => new xmlrpcval($topic_info['can_lock'], 'boolean'), 'can_stick' => new xmlrpcval($topic_info['can_sticky'], 'boolean'), 'can_move' => new xmlrpcval($topic_info['can_move'], 'boolean')), 'struct');
            $post_list[] = $xmlrpc_post;
        }
        $result = new xmlrpcval(array('total_post_num' => new xmlrpcval($context['exttMbqTotal'] == 0 && !empty($post_list) ? count($post_list) : $context['exttMbqTotal'], 'int'), 'search_id' => new xmlrpcval($context['exttMbqSearchId'], 'string'), 'posts' => new xmlrpcval($post_list, 'array')), 'struct');
    } else {
        $result = new xmlrpcval(array('total_post_num' => new xmlrpcval(0, 'int')), 'struct');
    }
    return new xmlrpcresp($result);
}
Beispiel #2
0
function before_action_update_password()
{
    global $sourcedir, $modSettings, $cur_profile, $user_info, $language;
    if (isset($_POST['old_password'])) {
        $cur_profile['member_name'] = $user_info['username'];
        $cur_profile['real_name'] = $user_info['name'];
        $cur_profile['email_address'] = $user_info['email'];
        $cur_profile['id_member'] = $user_info['id'];
        //action 1: from profile clue.
        // Since the password got modified due to all the $_POST cleaning, lets undo it so we can get the correct password
        $_POST['old_password'] = un_htmlspecialchars($_POST['old_password']);
        // Does the integration want to check passwords?
        $good_password = in_array(true, call_integration_hook('integrate_verify_password', array($cur_profile['member_name'], $_POST['old_password'], false)), true);
        // Bad password!!!
        if (!$good_password && $user_info['passwd'] != sha1(strtolower($cur_profile['member_name']) . $_POST['old_password'])) {
            fatal_lang_error('profile_error_bad_password', false);
        }
    } else {
        //action 2: from email part.
        if (!isset($modSettings['tp_push_key']) || empty($modSettings['tp_push_key'])) {
            get_error('Forum is not configured well, please contact administrator to set up push key for the forum!');
        }
        $email_response = getEmailFromScription($_POST['token'], $_POST['code'], $modSettings['tp_push_key']);
        if (empty($email_response)) {
            get_error('Failed to connect to tapatalk server, please try again later.');
        }
        if (!$email_response['result'] || (!isset($email_response['email']) || empty($email_response['email']))) {
            get_error('You need to input an email or re-login tapatalk id to use default email of tapatalk id.');
        }
        require_once $sourcedir . '/Subs-Members.php';
        $member = list_getMembers(0, 30, 'member_name', '(email_address = {string:email_normal})', array('email_normal' => $email_response['email']));
        if (!isset($member[0]['id_member']) || empty($member[0]['id_member'])) {
            get_error('no email user found.');
        }
        $cur_profile = $member[0];
    }
}