Ejemplo n.º 1
0
function login_func($xmlrpc_params)
{
    global $auth, $user, $config, $db, $phpbb_root_path, $phpEx;
    $params = php_xmlrpc_decode($xmlrpc_params);
    $user->setup('ucp');
    $username = $params[0];
    $password = $params[1];
    $viewonline = isset($params[2]) ? !$params[2] : 1;
    set_var($username, $username, 'string', true);
    set_var($password, $password, 'string', true);
    header('Set-Cookie: mobiquo_a=0');
    header('Set-Cookie: mobiquo_b=0');
    header('Set-Cookie: mobiquo_c=0');
    $login_result = $auth->login($username, $password, true, $viewonline);
    $usergroup_id = array();
    if ($login_result['status'] == LOGIN_SUCCESS) {
        $auth->acl($user->data);
        //add tapatalk_users here,for push service
        if ($params[3] == '1' && push_table_exists()) {
            global $table_prefix;
            $sql = "SELECT * FROM " . $table_prefix . "tapatalk_users where userid = '" . $user->data['user_id'] . "'";
            $result = $db->sql_query($sql);
            $userInfo = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            $time = time();
            if (empty($userInfo)) {
                $sql_data[$table_prefix . "tapatalk_users"]['sql'] = array('userid' => $user->data['user_id'], 'announcement' => 1, 'pm' => 1, 'subscribe' => 1, 'quote' => 1, 'tag' => 1, 'newtopic' => 1, 'updated' => time());
                $sql = 'INSERT INTO ' . $table_prefix . "tapatalk_users" . ' ' . $db->sql_build_array('INSERT', $sql_data[$table_prefix . "tapatalk_users"]['sql']);
                $db->sql_query($sql);
            } else {
                $sql = "UPDATE " . $table_prefix . "tapatalk_users \n\t        \tSET updated= '" . time() . "' WHERE userid='" . $user->data['user_id'] . "'";
                $db->sql_query($sql);
            }
        }
        // Compatibility with mod NV who was here
        if (file_exists($phpbb_root_path . 'includes/mods/who_was_here.' . $phpEx)) {
            include_once $phpbb_root_path . 'includes/mods/who_was_here.' . $phpEx;
            if (class_exists('phpbb_mods_who_was_here') && method_exists('phpbb_mods_who_was_here', 'update_session')) {
                @phpbb_mods_who_was_here::update_session();
            }
        }
    } else {
        $error_msg = str_replace('%s', '', strip_tags($user->lang[$login_result['error_msg']]));
        return new xmlrpcresp(new xmlrpcval(array('result' => new xmlrpcval(false, 'boolean'), 'result_text' => new xmlrpcval($error_msg, 'base64')), 'struct'));
    }
    if ($config['max_attachments'] == 0) {
        $config['max_attachments'] = 100;
    }
    $usergroup_id[] = new xmlrpcval($user->data['group_id']);
    $can_readpm = $config['allow_privmsg'] && $auth->acl_get('u_readpm') && ($user->data['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'));
    $can_sendpm = $config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user->data['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'));
    $can_upload = $config['allow_avatar_upload'] && file_exists($phpbb_root_path . $config['avatar_path']) && (function_exists('phpbb_is_writable') ? phpbb_is_writable($phpbb_root_path . $config['avatar_path']) : 1) && $auth->acl_get('u_chgavatar') && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on') ? true : false;
    $can_search = $auth->acl_get('u_search') && $auth->acl_getf_global('f_search') && $config['load_search'];
    $can_whosonline = $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel');
    $max_filesize = $config['max_filesize'] === '0' || $config['max_filesize'] > 10485760 ? 10485760 : $config['max_filesize'];
    $response = new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean'), 'user_id' => new xmlrpcval($user->data['user_id'], 'string'), 'username' => new xmlrpcval($user->data['username'], 'base64'), 'usergroup_id' => new xmlrpcval($usergroup_id, 'array'), 'icon_url' => new xmlrpcval(get_user_avatar_url($user->data['user_avatar'], $user->data['user_avatar_type']), 'string'), 'post_count' => new xmlrpcval($user->data['user_posts'], 'int'), 'can_pm' => new xmlrpcval($can_readpm, 'boolean'), 'can_send_pm' => new xmlrpcval($can_sendpm, 'boolean'), 'can_moderate' => new xmlrpcval($auth->acl_get('m_') || $auth->acl_getf_global('m_'), 'boolean'), 'max_attachment' => new xmlrpcval($config['max_attachments'], 'int'), 'max_png_size' => new xmlrpcval($max_filesize, 'int'), 'max_jpg_size' => new xmlrpcval($max_filesize, 'int'), 'can_search' => new xmlrpcval($can_search, 'boolean'), 'can_whosonline' => new xmlrpcval($can_whosonline, 'boolean'), 'can_upload_avatar' => new xmlrpcval($can_upload, 'boolean')), 'struct');
    return new xmlrpcresp($response);
}
Ejemplo n.º 2
0
function get_user_info_func($xmlrpc_params)
{
    global $db, $user, $auth, $template, $config, $phpbb_root_path, $phpEx, $table_prefix;
    $user->setup(array('memberlist', 'groups'));
    if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) {
        if ($user->data['user_id'] != ANONYMOUS) {
            trigger_error('NO_VIEW_USERS');
        }
        trigger_error('LOGIN_EXPLAIN_VIEWPROFILE');
    }
    $params = php_xmlrpc_decode($xmlrpc_params);
    $username = $params[0];
    if (isset($params[1]) && !empty($params[1])) {
        $user_id = $params[1];
    } elseif (isset($params[0]) && !empty($params[0])) {
        $username = $params[0];
        $user_id = get_user_id_by_name($username);
    } else {
        $user_id = $user->data['user_id'];
    }
    $user_id = intval($user_id);
    // Display a profile
    if (!$user_id) {
        trigger_error('NO_USER');
    }
    // Get user...
    $sql = 'SELECT *
        FROM ' . USERS_TABLE . "\r\r\n        WHERE user_id = '{$user_id}'";
    $result = $db->sql_query($sql);
    $member = $db->sql_fetchrow($result);
    $db->sql_freeresult($result);
    if (!$member) {
        trigger_error('NO_USER');
    }
    // a_user admins and founder are able to view inactive users and bots to be able to manage them more easily
    // Normal users are able to see at least users having only changed their profile settings but not yet reactivated.
    if (!$auth->acl_get('a_user') && $user->data['user_type'] != USER_FOUNDER) {
        if ($member['user_type'] == USER_IGNORE) {
            trigger_error('NO_USER');
        } else {
            if ($member['user_type'] == USER_INACTIVE && $member['user_inactive_reason'] != INACTIVE_PROFILE) {
                trigger_error('NO_USER');
            }
        }
    }
    $user_id = (int) $member['user_id'];
    // Do the SQL thang
    $sql = 'SELECT g.group_id, g.group_name, g.group_type
        FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug\r\r\n        WHERE ug.user_id = {$user_id}\r\r\n            AND g.group_id = ug.group_id" . (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') ? ' AND g.group_type <> ' . GROUP_HIDDEN : '') . '
            AND ug.user_pending = 0
        ORDER BY g.group_type, g.group_name';
    $result = $db->sql_query($sql);
    $group_options = '';
    while ($row = $db->sql_fetchrow($result)) {
        if ($row['group_type'] == GROUP_SPECIAL) {
            // Lookup group name in language dictionary
            if (isset($user->lang['G_' . $row['group_name']])) {
                $row['group_name'] = $user->lang['G_' . $row['group_name']];
            }
        } else {
            if (!$auth_hidden_groups && $row['group_type'] == GROUP_HIDDEN && !isset($user_groups[$row['group_id']])) {
                // Skip over hidden groups the user cannot see
                continue;
            }
        }
        $group_options .= $row['group_id'] == $member['group_id'] ? $row['group_name'] . " *\n" : $row['group_name'] . "\n";
    }
    $group_options = trim($group_options);
    $db->sql_freeresult($result);
    // What colour is the zebra
    $sql = 'SELECT friend, foe
        FROM ' . ZEBRA_TABLE . "\r\r\n        WHERE zebra_id = {$user_id}\r\r\n            AND user_id = {$user->data['user_id']}";
    $result = $db->sql_query($sql);
    $row = $db->sql_fetchrow($result);
    $foe = $row['foe'] ? true : false;
    $friend = $row['friend'] ? true : false;
    $db->sql_freeresult($result);
    if ($config['load_onlinetrack']) {
        if ($config['version'] < '3.0.3') {
            $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline, session_page
            FROM ' . SESSIONS_TABLE . "\r\r\n            WHERE session_user_id = {$user_id}\r\r\n            GROUP BY session_page\r\r\n            ORDER BY session_time DESC";
        } else {
            $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline, session_page, session_forum_id
            FROM ' . SESSIONS_TABLE . "\r\r\n            WHERE session_user_id = {$user_id}\r\r\n            GROUP BY session_page, session_forum_id\r\r\n            ORDER BY session_time DESC";
        }
        $result = $db->sql_query_limit($sql, 1);
        $row = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        $member['session_time'] = isset($row['session_time']) ? $row['session_time'] : 0;
        $member['session_viewonline'] = isset($row['session_viewonline']) ? $row['session_viewonline'] : 0;
        $member['session_page'] = isset($row['session_page']) ? $row['session_page'] : 0;
        $member['session_forum_id'] = isset($row['session_forum_id']) ? $row['session_forum_id'] : 0;
        unset($row);
    }
    if ($config['load_user_activity']) {
        display_user_activity($member);
    }
    // Do the relevant calculations
    $memberdays = max(1, round((time() - $member['user_regdate']) / 86400));
    $posts_per_day = $member['user_posts'] / $memberdays;
    $percentage = $config['num_posts'] ? min(100, $member['user_posts'] / $config['num_posts'] * 100) : 0;
    if ($member['user_sig']) {
        $member['user_sig'] = censor_text($member['user_sig']);
        if ($member['user_sig_bbcode_bitfield']) {
            include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx;
            $bbcode = new bbcode();
            $bbcode->bbcode_second_pass($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield']);
        }
        $member['user_sig'] = bbcode_nl2br($member['user_sig']);
        $member['user_sig'] = smiley_text($member['user_sig']);
    }
    $poster_avatar = get_user_avatar($member['user_avatar'], $member['user_avatar_type'], $member['user_avatar_width'], $member['user_avatar_height']);
    // We need to check if the modules 'zebra' ('friends' & 'foes' mode),  'notes' ('user_notes' mode) and  'warn' ('warn_user' mode) are accessible to decide if we can display appropriate links
    $zebra_enabled = $friends_enabled = $foes_enabled = $user_notes_enabled = $warn_user_enabled = false;
    // Only check if the user is logged in
    if ($user->data['is_registered']) {
        if (!class_exists('p_master')) {
            include $phpbb_root_path . 'includes/functions_module.' . $phpEx;
        }
        $module = new p_master();
        $module->list_modules('ucp');
        $module->list_modules('mcp');
        $user_notes_enabled = $module->loaded('notes', 'user_notes') ? true : false;
        $warn_user_enabled = $module->loaded('warn', 'warn_user') ? true : false;
        $zebra_enabled = $module->loaded('zebra') ? true : false;
        $friends_enabled = $module->loaded('zebra', 'friends') ? true : false;
        $foes_enabled = $module->loaded('zebra', 'foes') ? true : false;
        unset($module);
    }
    $template->assign_vars(show_profile($member, $user_notes_enabled, $warn_user_enabled));
    // Custom Profile Fields
    $profile_fields = array();
    if ($config['load_cpf_viewprofile']) {
        include_once $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx;
        $cp = new custom_profile();
        $profile_fields = $cp->generate_profile_fields_template('grab', $user_id);
        $profile_fields = isset($profile_fields[$user_id]) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user_id]) : array();
    }
    // If the user has m_approve permission or a_user permission, then list then display unapproved posts
    if ($auth->acl_getf_global('m_approve') || $auth->acl_get('a_user')) {
        $sql = 'SELECT COUNT(post_id) as posts_in_queue
            FROM ' . POSTS_TABLE . '
            WHERE poster_id = ' . $user_id . '
                AND post_approved = 0';
        $result = $db->sql_query($sql);
        $member['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue');
        $db->sql_freeresult($result);
    } else {
        $member['posts_in_queue'] = 0;
    }
    $template->assign_vars(array('OCCUPATION' => !empty($member['user_occ']) ? censor_text($member['user_occ']) : '', 'INTERESTS' => !empty($member['user_interests']) ? censor_text($member['user_interests']) : '', 'SIGNATURE' => $member['user_sig'], 'POSTS_IN_QUEUE' => $member['posts_in_queue'], 'AVATAR_IMG' => $poster_avatar, 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']), 'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']), 'WWW_IMG' => $user->img('icon_contact_www', $user->lang['WWW']), 'ICQ_IMG' => $user->img('icon_contact_icq', $user->lang['ICQ']), 'AIM_IMG' => $user->img('icon_contact_aim', $user->lang['AIM']), 'MSN_IMG' => $user->img('icon_contact_msnm', $user->lang['MSNM']), 'YIM_IMG' => $user->img('icon_contact_yahoo', $user->lang['YIM']), 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), 'S_PROFILE_ACTION' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=group'), 'S_GROUP_OPTIONS' => $group_options, 'S_CUSTOM_FIELDS' => isset($profile_fields['row']) && sizeof($profile_fields['row']) ? true : false, 'U_USER_ADMIN' => $auth->acl_get('a_user') ? append_sid("{$phpbb_root_path}adm/index.{$phpEx}", 'i=users&amp;mode=overview&amp;u=' . $user_id, true, $user->session_id) : '', 'U_USER_BAN' => $auth->acl_get('m_ban') && $user_id != $user->data['user_id'] ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=ban&amp;mode=user&amp;u=' . $user_id, true, $user->session_id) : '', 'U_MCP_QUEUE' => $auth->acl_getf_global('m_approve') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue', true, $user->session_id) : '', 'S_USER_NOTES' => $user_notes_enabled ? true : false, 'S_WARN_USER' => $warn_user_enabled ? true : false, 'S_ZEBRA' => $user->data['user_id'] != $user_id && $user->data['is_registered'] && $zebra_enabled ? true : false, 'U_ADD_FRIEND' => !$friend && !$foe && $friends_enabled ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=zebra&amp;add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', 'U_ADD_FOE' => !$friend && !$foe && $foes_enabled ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=zebra&amp;mode=foes&amp;add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', 'U_REMOVE_FRIEND' => $friend && $friends_enabled ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=zebra&amp;remove=1&amp;usernames[]=' . $user_id) : '', 'U_REMOVE_FOE' => $foe && $foes_enabled ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=zebra&amp;remove=1&amp;mode=foes&amp;usernames[]=' . $user_id) : ''));
    if (!empty($profile_fields['row'])) {
        $template->assign_vars($profile_fields['row']);
    }
    if (!empty($profile_fields['blockrow'])) {
        foreach ($profile_fields['blockrow'] as $field_data) {
            $template->assign_block_vars('custom_fields', $field_data);
        }
    }
    // Inactive reason/account?
    if ($member['user_type'] == USER_INACTIVE) {
        $user->add_lang('acp/common');
        $inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN'];
        switch ($member['user_inactive_reason']) {
            case INACTIVE_REGISTER:
                $inactive_reason = $user->lang['INACTIVE_REASON_REGISTER'];
                break;
            case INACTIVE_PROFILE:
                $inactive_reason = $user->lang['INACTIVE_REASON_PROFILE'];
                break;
            case INACTIVE_MANUAL:
                $inactive_reason = $user->lang['INACTIVE_REASON_MANUAL'];
                break;
            case INACTIVE_REMIND:
                $inactive_reason = $user->lang['INACTIVE_REASON_REMIND'];
                break;
        }
        $template->assign_vars(array('S_USER_INACTIVE' => true, 'USER_INACTIVE_REASON' => $inactive_reason));
    }
    $custom_fields_list = get_custom_fields();
    if (!empty($member['user_sig'])) {
        $custom_fields_list[] = new xmlrpcval(array('name' => new xmlrpcval($user->lang['SIGNATURE'], 'base64'), 'value' => new xmlrpcval(basic_clean($member['user_sig']), 'base64')), 'struct');
    }
    if ($member['user_id'] == $user->data['user_id'] && push_table_exists()) {
        $sql = "SELECT * FROM " . $table_prefix . "tapatalk_users WHERE userid = '" . $member['user_id'] . "'";
        $result = $db->sql_query($sql);
        $row = $db->sql_fetchrow($result);
        if (!empty($row)) {
            array_push($custom_fields_list, new xmlrpcval(array('name' => new xmlrpcval('Notification - Message', 'base64'), 'value' => new xmlrpcval($row['pm'] ? 'On' : 'Off', 'base64')), 'struct'));
            array_push($custom_fields_list, new xmlrpcval(array('name' => new xmlrpcval('Notification - Quoted', 'base64'), 'value' => new xmlrpcval($row['quote'] ? 'On' : 'Off', 'base64')), 'struct'));
            array_push($custom_fields_list, new xmlrpcval(array('name' => new xmlrpcval('Notification - Mentioned', 'base64'), 'value' => new xmlrpcval($row['tag'] ? 'On' : 'Off', 'base64')), 'struct'));
            array_push($custom_fields_list, new xmlrpcval(array('name' => new xmlrpcval('Notification - New Topic', 'base64'), 'value' => new xmlrpcval($row['newtopic'] ? 'On' : 'Off', 'base64')), 'struct'));
            array_push($custom_fields_list, new xmlrpcval(array('name' => new xmlrpcval('Notification - Replies', 'base64'), 'value' => new xmlrpcval($row['subscribe'] ? 'On' : 'Off', 'base64')), 'struct'));
        }
    }
    $user_avatar_url = get_user_avatar_url($member['user_avatar'], $member['user_avatar_type']);
    // Forum info
    $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id
        FROM ' . FORUMS_TABLE . '
        ORDER BY left_id ASC';
    $result = $db->sql_query($sql, 600);
    $forum_data = array();
    while ($row = $db->sql_fetchrow($result)) {
        $forum_data[$row['forum_id']] = $row;
    }
    $db->sql_freeresult($result);
    // get user current activity
    preg_match('#^([a-z0-9/_-]+)#i', $member['session_page'], $on_page);
    if (!sizeof($on_page)) {
        $on_page[1] = '';
    }
    switch ($on_page[1]) {
        case 'index':
            $location = $user->lang['INDEX'];
            break;
        case 'adm/index':
            $location = $user->lang['ACP'];
            break;
        case 'posting':
        case 'viewforum':
        case 'viewtopic':
            $forum_id = $member['session_forum_id'];
            if ($forum_id && $auth->acl_get('f_list', $forum_id)) {
                $location = '';
                if ($forum_data[$forum_id]['forum_type'] == FORUM_LINK) {
                    $location = sprintf($user->lang['READING_LINK'], $forum_data[$forum_id]['forum_name']);
                    break;
                }
                switch ($on_page[1]) {
                    case 'posting':
                        preg_match('#mode=([a-z]+)#', $member['session_page'], $on_page);
                        $posting_mode = !empty($on_page[1]) ? $on_page[1] : '';
                        switch ($posting_mode) {
                            case 'reply':
                            case 'quote':
                                $location = sprintf($user->lang['REPLYING_MESSAGE'], $forum_data[$forum_id]['forum_name']);
                                break;
                            default:
                                $location = sprintf($user->lang['POSTING_MESSAGE'], $forum_data[$forum_id]['forum_name']);
                                break;
                        }
                        break;
                    case 'viewtopic':
                        $location = sprintf($user->lang['READING_TOPIC'], $forum_data[$forum_id]['forum_name']);
                        break;
                    case 'viewforum':
                        $location = sprintf($user->lang['READING_FORUM'], $forum_data[$forum_id]['forum_name']);
                        break;
                }
            } else {
                $location = $user->lang['INDEX'];
            }
            break;
        case 'search':
            $location = $user->lang['SEARCHING_FORUMS'];
            break;
        case 'faq':
            $location = $user->lang['VIEWING_FAQ'];
            break;
        case 'viewonline':
            $location = $user->lang['VIEWING_ONLINE'];
            break;
        case 'memberlist':
            $location = strpos($member['session_page'], 'mode=viewprofile') !== false ? $user->lang['VIEWING_MEMBER_PROFILE'] : $user->lang['VIEWING_MEMBERS'];
            break;
        case 'mcp':
            $location = $user->lang['VIEWING_MCP'];
            break;
        case 'ucp':
            $location = $user->lang['VIEWING_UCP'];
            // Grab some common modules
            $url_params = array('mode=register' => 'VIEWING_REGISTER', 'i=pm&mode=compose' => 'POSTING_PRIVATE_MESSAGE', 'i=pm&' => 'VIEWING_PRIVATE_MESSAGES', 'i=profile&' => 'CHANGING_PROFILE', 'i=prefs&' => 'CHANGING_PREFERENCES');
            foreach ($url_params as $param => $lang) {
                if (strpos($member['session_page'], $param) !== false) {
                    $location = $user->lang[$lang];
                    break;
                }
            }
            break;
        case 'download/file':
            $location = $user->lang['DOWNLOADING_FILE'];
            break;
        case 'report':
            $location = $user->lang['REPORTING_POST'];
            break;
        case 'mobiquo/mobiquo':
            $location = 'On Tapatalk';
            break;
        default:
            $location = $user->lang['INDEX'];
            break;
    }
    $user_info = array('user_id' => new xmlrpcval($member['user_id']), 'username' => new xmlrpcval(basic_clean($member['username']), 'base64'), 'user_type' => check_return_user_type($member['username']), 'post_count' => new xmlrpcval($member['user_posts'], 'int'), 'reg_time' => new xmlrpcval(mobiquo_iso8601_encode($member['user_regdate']), 'dateTime.iso8601'), 'timestamp_reg' => new xmlrpcval($member['user_regdate'], 'string'), 'last_activity_time' => new xmlrpcval(mobiquo_iso8601_encode($template->_rootref['VISITED']), 'dateTime.iso8601'), 'timestamp' => new xmlrpcval($template->_rootref['VISITED'], 'string'), 'is_online' => new xmlrpcval($template->_rootref['S_ONLINE'], 'boolean'), 'accept_pm' => new xmlrpcval($template->_rootref['U_PM'] ? true : false, 'boolean'), 'display_text' => new xmlrpcval('', 'base64'), 'icon_url' => new xmlrpcval($user_avatar_url), 'current_activity' => new xmlrpcval($location, 'base64'), 'custom_fields_list' => new xmlrpcval($custom_fields_list, 'array'));
    $xmlrpc_user_info = new xmlrpcval($user_info, 'struct');
    return new xmlrpcresp($xmlrpc_user_info);
}
Ejemplo n.º 3
0
function tt_get_user_push_type($userid)
{
    global $table_prefix, $db, $phpbb_root_path, $config, $phpEx;
    if (!function_exists('push_table_exists')) {
        define('IN_MOBIQUO', 1);
        require_once $phpbb_root_path . $config['tapatalkdir'] . '/xmlrpcresp.' . $phpEx;
    }
    if (!push_table_exists()) {
        return array();
    }
    $sql = "SELECT pm,subscribe as sub,quote,newtopic,tag FROM " . $table_prefix . "tapatalk_users WHERE userid = '" . $userid . "'";
    $result = $db->sql_query($sql);
    $row = $db->sql_fetchrow($result);
    return $row;
}
Ejemplo n.º 4
0
function check_push()
{
    global $db, $config, $phpbb_root_path, $phpEx;
    if (!function_exists('push_table_exists')) {
        define('IN_MOBIQUO', 1);
        require_once $phpbb_root_path . $config['tapatalkdir'] . '/xmlrpcresp.' . $phpEx;
    }
    if (!push_table_exists()) {
        return false;
    }
    if (!$config['mobiquo_push']) {
        return false;
    }
    return true;
}
Ejemplo n.º 5
0
function get_config_func()
{
    global $mobiquo_config, $config, $auth;
    $config_list = array('sys_version' => new xmlrpcval($config['version'], 'string'), 'is_open' => new xmlrpcval($mobiquo_config['is_open'] ? true : false, 'boolean'), 'guest_okay' => new xmlrpcval(true, 'boolean'));
    if ($config['require_activation'] == USER_ACTIVATION_ADMIN) {
        $mobiquo_config['sso_signin'] = 0;
        $mobiquo_config['sso_register'] = 0;
    }
    if ($config['require_activation'] == USER_ACTIVATION_DISABLE) {
        $mobiquo_config['sign_in'] = 0;
        $mobiquo_config['inappreg'] = 0;
        $mobiquo_config['sso_signin'] = 0;
        $mobiquo_config['sso_register'] = 0;
        $mobiquo_config['native_register'] = 0;
    }
    if (!function_exists('curl_init') && !@ini_get('allow_url_fopen')) {
        $mobiquo_config['sign_in'] = 0;
        $mobiquo_config['inappreg'] = 0;
        $mobiquo_config['sso_login'] = 0;
        $mobiquo_config['sso_signin'] = 0;
        $mobiquo_config['sso_register'] = 0;
    }
    if (isset($config['tapatalk_register_status'])) {
        if ($config['tapatalk_register_status'] == 0) {
            $mobiquo_config['sign_in'] = 0;
            $mobiquo_config['inappreg'] = 0;
            $mobiquo_config['sso_signin'] = 0;
            $mobiquo_config['sso_register'] = 0;
            $mobiquo_config['native_register'] = 0;
        } elseif ($config['tapatalk_register_status'] == 1) {
            $mobiquo_config['inappreg'] = 0;
            $mobiquo_config['sign_in'] = 0;
            $mobiquo_config['sso_signin'] = 0;
            $mobiquo_config['sso_register'] = 0;
        }
    }
    foreach ($mobiquo_config as $key => $value) {
        if (!in_array($key, array('is_open', 'guest_okay', 'php_extension', 'shorten_quote', 'hide_forum_id', 'check_dnsbl'))) {
            $config_list[$key] = new xmlrpcval($value, 'string');
        }
    }
    if (!$mobiquo_config['is_open']) {
        $config_list['is_open'] = new xmlrpcval(0, 'string');
        $config_list['result_text'] = new xmlrpcval('Tapatalk pulgin is disabled', 'base64');
    }
    if ($config['board_disable']) {
        $config_list['is_open'] = new xmlrpcval(0, 'string');
        $config_list['result_text'] = new xmlrpcval($config['board_disable_msg'], 'base64');
    }
    if (push_table_exists()) {
        $config_list['alert'] = new xmlrpcval(1, 'string');
    }
    if ($auth->acl_get('u_search') && $auth->acl_getf_global('f_search') && $config['load_search']) {
        $config_list['guest_search'] = new xmlrpcval('1', 'string');
    }
    if ($auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) {
        $config_list['guest_whosonline'] = new xmlrpcval('1', 'string');
    }
    if ($config['require_activation'] == USER_ACTIVATION_DISABLE) {
        $config_list['inappreg'] = new xmlrpcval(0, 'string');
        $config_list['inappsignin'] = new xmlrpcval(0, 'string');
    }
    if ($config['search_type'] == 'fulltext_native') {
        $config_list['min_search_length'] = new xmlrpcval($config['fulltext_native_min_chars'], 'int');
    } else {
        if ($config['search_type'] == 'fulltext_mysql') {
            $config_list['min_search_length'] = new xmlrpcval($config['fulltext_mysql_min_word_len'], 'int');
        }
    }
    if (isset($config['tapatalk_push_key'])) {
        $config_list['automod'] = new xmlrpcval(1, 'string');
    } else {
        $config_list['automod'] = new xmlrpcval(0, 'string');
    }
    if (!empty($config['tapatalk_push_key'])) {
        $config_list['api_key'] = new xmlrpcval(md5($config['tapatalk_push_key']), 'string');
    }
    $config_list['stats'] = new xmlrpcval(array('topic' => new xmlrpcval($config['num_topics'], 'int'), 'user' => new xmlrpcval($config['num_users'], 'int'), 'post' => new xmlrpcval($config['num_posts'], 'int'), 'active' => new xmlrpcval($config['record_online_users'], 'int')), 'struct');
    $response = new xmlrpcval($config_list, 'struct');
    return new xmlrpcresp($response);
}
Ejemplo n.º 6
0
<?php

error_reporting(E_ALL & ~E_NOTICE);
$phpbb_root_path = dirname(dirname(__FILE__)) . '/';
define('IN_PHPBB', 1);
$phpEx = 'php';
define('IN_MOBIQUO', 1);
require_once 'xmlrpcresp.' . $phpEx;
include $phpbb_root_path . 'common.php';
include 'push_hook.php';
$return_status = tt_do_post_request(array('test' => 1, 'key' => $config['tapatalk_push_key']), true);
if (empty($config['tapatalk_push_key'])) {
    $return_status = 'Please set Tapatalk API Key at forum option/setting';
}
$server_ip = tt_do_post_request(array('ip' => 1), true);
$board_url = generate_board_url();
$table_exist = push_table_exists();
if (isset($_GET['checkcode'])) {
    $string = file_get_contents($phpbb_root_path . 'includes/functions_posting.php');
    echo 'push code have been added in phpbb : ' . (strstr($string, 'tapatalk_push_reply($data);') ? 'yes' : 'no') . '<br/>';
    exit;
}
echo '<b>Tapatalk Push Notification Status Monitor</b><br/>';
echo '<br/>Push notification test: ' . ($return_status === '1' ? '<b>Success</b>' : 'Failed(' . $return_status . ')');
echo '<br/>Current server IP: ' . $server_ip;
echo '<br/>Current forum url: ' . $board_url;
echo '<br/>Tapatalk user table existence: ' . ($table_exist ? 'Yes' : 'No');
echo '<br/><br/><a href="http://tapatalk.com/api/api.php" target="_blank">Tapatalk API for Universal Forum Access</a> | <a href="http://tapatalk.com/mobile.php" target="_blank">Tapatalk Mobile Applications</a><br>
    For more details, please visit <a href="http://tapatalk.com" target="_blank">http://tapatalk.com</a>';
Ejemplo n.º 7
0
function tt_login_success()
{
    global $config, $db, $user, $phpbb_root_path, $phpEx, $user_info, $auth, $register;
    header('Set-Cookie: mobiquo_a=0');
    header('Set-Cookie: mobiquo_b=0');
    header('Set-Cookie: mobiquo_c=0');
    $result = $user->session_create($user_info['user_id'], 0, true, 1);
    if ($result) {
        $usergroup_id = array();
        $auth->acl($user->data);
        //add tapatalk_users here,for push service
        if (push_table_exists()) {
            global $table_prefix;
            $sql = "SELECT * FROM " . $table_prefix . "tapatalk_users where userid = '" . $user->data['user_id'] . "'";
            $result = $db->sql_query($sql);
            $userInfo = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            $time = time();
            if (empty($userInfo)) {
                $sql_data[$table_prefix . "tapatalk_users"]['sql'] = array('userid' => $user->data['user_id'], 'announcement' => 1, 'pm' => 1, 'subscribe' => 1, 'quote' => 1, 'tag' => 1, 'newtopic' => 1, 'updated' => time());
                $sql = 'INSERT INTO ' . $table_prefix . "tapatalk_users" . ' ' . $db->sql_build_array('INSERT', $sql_data[$table_prefix . "tapatalk_users"]['sql']);
                $db->sql_query($sql);
            }
        }
        // Compatibility with mod NV who was here
        if (file_exists($phpbb_root_path . 'includes/mods/who_was_here.' . $phpEx)) {
            include_once $phpbb_root_path . 'includes/mods/who_was_here.' . $phpEx;
            if (class_exists('phpbb_mods_who_was_here') && method_exists('phpbb_mods_who_was_here', 'update_session')) {
                @phpbb_mods_who_was_here::update_session();
            }
        }
        if ($config['max_attachments'] == 0) {
            $config['max_attachments'] = 100;
        }
        $usergroup_id[] = new xmlrpcval($user->data['group_id']);
        $can_readpm = $config['allow_privmsg'] && $auth->acl_get('u_readpm') && ($user->data['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'));
        $can_sendpm = $config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user->data['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'));
        $can_upload = $config['allow_avatar_upload'] && file_exists($phpbb_root_path . $config['avatar_path']) && (function_exists('phpbb_is_writable') ? phpbb_is_writable($phpbb_root_path . $config['avatar_path']) : 1) && $auth->acl_get('u_chgavatar') && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on') ? true : false;
        $can_search = $auth->acl_get('u_search') && $auth->acl_getf_global('f_search') && $config['load_search'];
        $can_whosonline = $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel');
        $max_filesize = $config['max_filesize'] === '0' || $config['max_filesize'] > 10485760 ? 10485760 : $config['max_filesize'];
        $userPushType = array('pm' => 1, 'newtopic' => 1, 'sub' => 1, 'tag' => 1, 'quote' => 1);
        $push_type = array();
        foreach ($userPushType as $name => $value) {
            $push_type[] = new xmlrpcval(array('name' => new xmlrpcval($name, 'string'), 'value' => new xmlrpcval($value, 'boolean')), 'struct');
        }
        $response = new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean'), 'user_id' => new xmlrpcval($user->data['user_id'], 'string'), 'username' => new xmlrpcval(basic_clean($user->data['username']), 'base64'), 'email' => new xmlrpcval($user->data['user_email'], 'base64'), 'user_type' => check_return_user_type($user->data['username']), 'usergroup_id' => new xmlrpcval($usergroup_id, 'array'), 'ignored_uids' => new xmlrpcval(implode(',', tt_get_ignore_users($user->data['user_id'])), 'string'), 'icon_url' => new xmlrpcval(get_user_avatar_url($user->data['user_avatar'], $user->data['user_avatar_type']), 'string'), 'post_count' => new xmlrpcval($user->data['user_posts'], 'int'), 'can_pm' => new xmlrpcval($can_readpm, 'boolean'), 'can_send_pm' => new xmlrpcval($can_sendpm, 'boolean'), 'can_moderate' => new xmlrpcval($auth->acl_get('m_') || $auth->acl_getf_global('m_'), 'boolean'), 'max_attachment' => new xmlrpcval($config['max_attachments'], 'int'), 'max_png_size' => new xmlrpcval($max_filesize, 'int'), 'max_jpg_size' => new xmlrpcval($max_filesize, 'int'), 'can_search' => new xmlrpcval($can_search, 'boolean'), 'can_whosonline' => new xmlrpcval($can_whosonline, 'boolean'), 'can_upload_avatar' => new xmlrpcval($can_upload, 'boolean'), 'register' => new xmlrpcval($register, "boolean"), 'push_type' => new xmlrpcval($push_type, 'array')), 'struct');
        return new xmlrpcresp($response);
    }
}
Ejemplo n.º 8
0
if (isset($_GET['checkip'])) {
    print do_post_request(array('ip' => 1));
} else {
    if (isset($_GET['checkurl'])) {
        $url = generate_board_url();
        echo $url;
    } else {
        if (isset($_GET['checkpush'])) {
            $return_status = do_post_request(array('test' => 1));
            $return_ip = do_post_request(array('ip' => 1));
            $string = file_get_contents($phpbb_root_path . 'includes/functions_posting.php');
            $url = generate_board_url();
            echo 'push enabled :' . (!empty($config['mobiquo_push']) ? ' on' : ' off') . '<br/>';
            echo 'test push data be send :' . ($return_status == 1 ? ' sucess' : ' failed ' . $return_status) . '<br/>';
            echo 'your server ip is : ' . $return_ip . '<br/>';
            echo 'push table is exist :' . (push_table_exists() ? ' yes' : ' no') . '<br/>';
            echo 'push code have been added in phpbb : ' . (strstr($string, 'tapatalk_push_reply($data);') ? 'yes' : 'no') . '<br/>';
            echo 'your forum url is : ' . $url . '<br/>';
        } else {
            echo 'Tapatalk push notification test: <b>';
            $return_status = do_post_request(array('test' => 1));
            if ($return_status === '1') {
                echo 'Success</b>';
            } else {
                echo 'Failed</b><br />' . $return_status;
            }
        }
    }
}
function do_post_request($data)
{