コード例 #1
0
ファイル: xmlrpcresp.php プロジェクト: keweiliu6/test-smf2
function get_alert_func()
{
    global $user_info, $smcFunc, $user_profile, $scripturl, $modSettings, $settings;
    $alert_format = array('sub' => '%s replied to "%s"', 'like' => '%s liked your post in thread "%s"', 'thank' => '%s thanked your post in thread "%s"', 'quote' => '%s quoted your post in thread "%s"', 'tag' => '%s mentioned you in thread "%s"', 'newtopic' => '%s started a new thread "%s"', 'pm' => '%s sent you a message "%s"', 'ann' => '%sNew Announcement "%s"');
    $start = ($_POST['page'] - 1) * $_POST['perpage'];
    $current_userid = $user_info['id'];
    if ($current_userid == 0) {
        return new xmlrpcresp(new xmlrpcval(array('result' => new xmlrpcval(false, 'boolean'), 'result_text' => new xmlrpcval("You should loggin to do that!", 'base64'))));
    }
    $alerts = array();
    $request = $smcFunc['db_query']('', '
        SELECT * FROM {db_prefix}tapatalk_push
        WHERE userid = {int:current_userid} ORDER BY dateline DESC LIMIT {int:start}, {int:perpage}', array('current_userid' => $current_userid, 'start' => $start, 'perpage' => $_POST['perpage']));
    while ($result = $smcFunc['db_fetch_assoc']($request)) {
        if (!isset($alert_format[$result['type']])) {
            continue;
        }
        $message = sprintf($alert_format[$result['type']], $result['author'], mobiquo_encode($result['title']));
        $userids = loadMemberData($result['author'], true);
        $userid = is_array($userids) ? $userids[0] : $userids;
        $profile = $user_profile[$userid];
        if (!empty($settings['show_user_images']) && empty($profile['options']['show_no_avatars'])) {
            $avatar = $profile['avatar'] == '' ? $profile['id_attach'] > 0 ? empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename'] : '' : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']);
        }
        $alert = array('user_id' => new xmlrpcval($userid, 'string'), 'username' => new xmlrpcval($result['author'], 'base64'), 'icon_url' => new xmlrpcval($avatar, 'string'), 'message' => new xmlrpcval($message, 'base64'), 'timestamp' => new xmlrpcval($result['dateline'], 'string'), 'content_type' => new xmlrpcval($result['type'], 'string'), 'content_id' => new xmlrpcval($result['type'] == 'pm' ? $result['id'] : $result['subid'], 'string'));
        if ($result['type'] == 'sub' || $result['type'] == 'like' || $result['type'] == 'thank' || $result['type'] == 'quote' || $result['type'] == 'tag' || $result['type'] == 'newtopic') {
            $alert['topic_id'] = new xmlrpcval($result['id'], 'string');
        }
        $alerts[] = new xmlrpcval($alert, 'struct');
    }
    $total_num = count($alerts);
    $return_data = array('total' => new xmlrpcval($total_num, 'int'), 'items' => new xmlrpcval($alerts, 'array'));
    return new xmlrpcresp(new xmlrpcval($return_data, 'struct'));
}
コード例 #2
0
function outputRPCLogin($result = false, $result_text = '')
{
    global $user_info, $register;
    $can_moderate = (allowedTo('make_sticky') || allowedTo('remove_any') || allowedTo('lock_any')) && $_SERVER['HTTP_MOBIQUO_ID'] == 4;
    $pm_read = allowedTo('pm_read');
    $pm_send = allowedTo('pm_send');
    $can_whosonline = allowedTo('who_view');
    $can_search = allowedTo('search_posts');
    $response = '
<params>
<param>
<value>
<struct>
<member>
<name>result</name>
<value><boolean>' . ($result ? '1' : '0') . '</boolean></value>
</member>
<member>
<name>result_text</name>
<value><base64>' . base64_encode($result_text) . '</base64></value>
</member>' . ($register ? '
<member>
<name>register</name>
<value><boolean>1</boolean></value>
</member>' : '') . '
<member>
<name>user_id</name>
<value><string>' . $user_info['ID_MEMBER'] . '</string></value>
</member>
<member>
<name>username</name>
<value><base64>' . base64_encode(mobiquo_encode($user_info['realName'])) . '</base64></value>
</member>
<member>
<name>login_name</name>
<value><base64>' . base64_encode(mobiquo_encode($user_info['memberName'])) . '</base64></value>
</member>
<member>
<name>email</name>
<value><base64>' . base64_encode(mobiquo_encode($user_info['emailAddress'])) . '</base64></value>
</member>
<member>
<name>post_count</name>
<value><int>' . intval($user_info['posts']) . '</int></value>
</member>
<member>
<name>icon_url</name>
<value><string>' . get_avatar($user_info) . '</string></value>
</member>' . ($can_moderate ? '
<member>
<name>can_moderate</name>
<value><boolean>1</boolean></value>
</member>' : '') . '
<member>
<name>can_pm</name>
<value><boolean>' . ($pm_read ? '1' : '0') . '</boolean></value>
</member>
<member>
<name>can_send_pm</name>
<value><boolean>' . ($pm_send ? '1' : '0') . '</boolean></value>
</member>
<member>
<name>can_whosonline</name>
<value><boolean>' . ($can_whosonline ? '1' : '0') . '</boolean></value>
</member>
<member>
<name>can_search</name>
<value><boolean>' . ($can_search ? '1' : '0') . '</boolean></value>
</member>
<member>
<name>usergroup_id</name>
<value>
<array>
<data>';
    foreach ($user_info['groups'] as $group_id) {
        $response .= '
<value><string>' . intval($group_id) . '</string></value>';
    }
    $response .= '
</data>
</array>
</value>
</member>
</struct>
</value>
</param>
</params>';
    outputRPCResponse($response);
}
コード例 #3
0
function action_m_rename_topic()
{
    global $smcFunc, $context, $user_info, $topic, $modSettings, $txt;
    if (empty($topic)) {
        fatal_lang_error('no_access', false);
    }
    $_POST['custom_subject'] = mobiquo_encode($_POST['custom_subject']);
    $request = $smcFunc['db_query']('', '
        SELECT id_member_started, id_first_msg, approved
        FROM {db_prefix}topics
        WHERE id_topic = {int:current_topic}
        LIMIT 1', array('current_topic' => $topic));
    list($id_member_started, $id_first_msg, $context['is_approved']) = $smcFunc['db_fetch_row']($request);
    $smcFunc['db_free_result']($request);
    // Can they see it?
    if (!$context['is_approved']) {
        isAllowedTo('approve_posts');
    }
    // Can they move topics on this board?
    if (!allowedTo('move_any')) {
        if ($id_member_started == $user_info['id']) {
            isAllowedTo('move_own');
            $boards = array_merge(boardsAllowedTo('move_own'), boardsAllowedTo('move_any'));
        } else {
            isAllowedTo('move_any');
        }
    } else {
        $boards = boardsAllowedTo('move_any');
    }
    // If this topic isn't approved don't let them move it if they can't approve it!
    if ($modSettings['postmod_active'] && !$context['is_approved'] && !allowedTo('approve_posts')) {
        // Only allow them to move it to other boards they can't approve it in.
        $can_approve = boardsAllowedTo('approve_posts');
        $boards = array_intersect($boards, $can_approve);
    }
    checkSession();
    if (isset($_POST['custom_subject']) && $_POST['custom_subject'] != '') {
        $_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => ''));
        // Keep checking the length.
        if ($smcFunc['strlen']($_POST['custom_subject']) > 100) {
            $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100);
        }
        // If it's still valid move onwards and upwards.
        if ($_POST['custom_subject'] != '') {
            if (isset($_POST['enforce_subject'])) {
                // Get a response prefix, but in the forum's default language.
                if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) {
                    if ($language === $user_info['language']) {
                        $context['response_prefix'] = $txt['response_prefix'];
                    } else {
                        loadLanguage('index', $language, false);
                        $context['response_prefix'] = $txt['response_prefix'];
                        loadLanguage('index');
                    }
                    cache_put_data('response_prefix', $context['response_prefix'], 600);
                }
                $smcFunc['db_query']('', '
                    UPDATE {db_prefix}messages
                    SET subject = {string:subject}
                    WHERE id_topic = {int:current_topic}', array('current_topic' => $topic, 'subject' => $context['response_prefix'] . $_POST['custom_subject']));
            }
            $smcFunc['db_query']('', '
                UPDATE {db_prefix}messages
                SET subject = {string:custom_subject}
                WHERE id_msg = {int:id_first_msg}', array('id_first_msg' => $id_first_msg, 'custom_subject' => $_POST['custom_subject']));
            // Fix the subject cache.
            updateStats('subject', $topic, $_POST['custom_subject']);
            return;
        }
    }
    get_error($txt['error_no_subject']);
}
コード例 #4
0
ファイル: Subs-Mobiquo.php プロジェクト: keweiliu6/test_smf1
function mobi_unescape_html($str)
{
    $str = strip_tags($str);
    $str = mobiquo_encode($str);
    return $str;
}
コード例 #5
0
/**
 * send email
 *
 * @return  Boolean
 */
function exttmbq_sendmail($email, $subject, $body)
{
    global $modSettings, $webmaster_email;
    if (substr(phpversion(), 0, 1) < 5) {
        $subject = mobiquo_encode($subject, 'to_local');
        $body = mobiquo_encode($body, 'to_local');
        return sendmail($email, $subject, $body);
    } else {
        if ($modSettings['mail_type'] == 1) {
            $mail = new PHPMailer();
            $mail->CharSet = 'utf-8';
            $mail->IsSMTP();
            $mail->Host = $modSettings['smtp_host'];
            $mail->Port = $modSettings['smtp_port'];
            $mail->From = $webmaster_email;
            $mail->FromName = "";
            $mail->SMTPAuth = true;
            $mail->Username = $modSettings['smtp_username'];
            $mail->Password = base64_decode($modSettings['smtp_password']);
            $mail->IsHTML(true);
            $mail->WordWrap = 50;
            $mail->Subject = $subject;
            $mail->AltBody = $body;
            $mail->Body = str_replace("\r", "", $mail->AltBody);
            $mail->Body = str_replace("\n", "<br />", $mail->Body);
            //$mail->MsgHTML($body);
            $mail->AddAddress($email);
            if (!$mail->Send()) {
                return false;
            } else {
                return true;
            }
        } else {
            $subject = mobiquo_encode($subject, 'to_local');
            $body = mobiquo_encode($body, 'to_local');
            return sendmail($email, $subject, $body);
        }
    }
}