Ejemplo n.º 1
0
     if ($memprofile['lastactive']) {
         $memlastvisitsep = $lang->comma;
         $memlastvisitdate = my_date('relative', $memprofile['lastactive']);
     }
     // Time Online
     $timeonline = $lang->none_registered;
     if ($memprofile['timeonline'] > 0) {
         $timeonline = nice_time($memprofile['timeonline']);
     }
     // Online?
     if (!empty($session)) {
         // Fetch their current location
         $lang->load("online");
         require_once MYBB_ROOT . "inc/functions_online.php";
         $activity = fetch_wol_activity($session['location'], $session['nopermission']);
         $location = build_friendly_wol_location($activity);
         $location_time = my_date($mybb->settings['timeformat'], $memprofile['lastactive']);
         eval("\$online_status = \"" . $templates->get("member_profile_online") . "\";");
     } else {
         eval("\$online_status = \"" . $templates->get("member_profile_offline") . "\";");
     }
 }
 if ($memprofile['invisible'] == 1 && $mybb->usergroup['canviewwolinvis'] != 1 && $memprofile['uid'] != $mybb->user['uid']) {
     $memlastvisitsep = '';
     $memlastvisittime = '';
     $memlastvisitdate = $lang->lastvisit_never;
     if ($memprofile['lastactive']) {
         // We have had at least some active time, hide it instead
         $memlastvisitdate = $lang->lastvisit_hidden;
     }
     $timeonline = $lang->timeonline_hidden;
Ejemplo n.º 2
0
function get_user_info_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups, $parser, $displaygroupfields;
    $lang->load("member");
    $input = Tapatalk_Input::filterXmlInput(array('user_name' => Tapatalk_Input::STRING, 'user_id' => Tapatalk_Input::INT), $xmlrpc_params);
    if ($mybb->usergroup['canviewprofiles'] == 0) {
        error_no_permission();
    }
    if (isset($input['user_id']) && !empty($input['user_id'])) {
        $uid = $input['user_id'];
    } elseif (!empty($input['user_name'])) {
        $query = $db->simple_select("users", "uid", "username='******'user_name_esc']}'");
        $uid = $db->fetch_field($query, "uid");
    } else {
        $uid = $mybb->user['uid'];
    }
    if ($mybb->user['uid'] != $uid) {
        $memprofile = get_user($uid);
    } else {
        $memprofile = $mybb->user;
    }
    if (!$memprofile['uid']) {
        error($lang->error_nomember);
    }
    // Get member's permissions
    $memperms = user_permissions($memprofile['uid']);
    if (!$memprofile['displaygroup']) {
        $memprofile['displaygroup'] = $memprofile['usergroup'];
    }
    // Grab the following fields from the user's displaygroup
    $displaygroupfields = array("title", "usertitle", "stars", "starimage", "image", "usereputationsystem");
    $displaygroup = usergroup_displaygroup($memprofile['displaygroup']);
    // Get the user title for this user
    unset($usertitle);
    unset($stars);
    if (trim($memprofile['usertitle']) != '') {
        // User has custom user title
        $usertitle = $memprofile['usertitle'];
    } elseif (trim($displaygroup['usertitle']) != '') {
        // User has group title
        $usertitle = $displaygroup['usertitle'];
    } else {
        // No usergroup title so get a default one
        $query = $db->simple_select("usertitles", "*", "", array('order_by' => 'posts', 'order_dir' => 'DESC'));
        while ($title = $db->fetch_array($query)) {
            if ($memprofile['postnum'] >= $title['posts']) {
                $usertitle = $title['title'];
                $stars = $title['stars'];
                $starimage = $title['starimage'];
                break;
            }
        }
    }
    // User is currently online and this user has permissions to view the user on the WOL
    $timesearch = TIME_NOW - $mybb->settings['wolcutoffmins'] * 60;
    $query = $db->simple_select("sessions", "location,nopermission", "uid='{$uid}' AND time>'{$timesearch}'", array('order_by' => 'time', 'order_dir' => 'DESC', 'limit' => 1));
    $session = $db->fetch_array($query);
    if (($memprofile['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $memprofile['uid'] == $mybb->user['uid']) && !empty($session)) {
        // Fetch their current location
        $lang->load("online");
        require_once MYBB_ROOT . "inc/functions_online.php";
        $activity = fetch_wol_activity($session['location'], $session['nopermission']);
        /*unset($activity['tid']);
          unset($activity['fid']);
          unset($activity['pid']);
          unset($activity['eid']);
          unset($activity['aid']);*/
        $location = strip_tags(build_friendly_wol_location($activity));
        $location_time = my_date($mybb->settings['timeformat'], $memprofile['lastactive']);
        $online = true;
    } else {
        $online = false;
    }
    // Get custom fields start
    $custom_fields_list = array();
    if ($memprofile['birthday']) {
        $membday = explode("-", $memprofile['birthday']);
        if ($memprofile['birthdayprivacy'] != 'none') {
            if ($membday[0] && $membday[1] && $membday[2]) {
                $lang->membdayage = $lang->sprintf($lang->membdayage, get_age($memprofile['birthday']));
                if ($membday[2] >= 1970) {
                    $w_day = date("l", mktime(0, 0, 0, $membday[1], $membday[0], $membday[2]));
                    $membday = format_bdays($mybb->settings['dateformat'], $membday[1], $membday[0], $membday[2], $w_day);
                } else {
                    $bdayformat = fix_mktime($mybb->settings['dateformat'], $membday[2]);
                    $membday = mktime(0, 0, 0, $membday[1], $membday[0], $membday[2]);
                    $membday = date($bdayformat, $membday);
                }
                $membdayage = $lang->membdayage;
            } elseif ($membday[2]) {
                $membday = mktime(0, 0, 0, 1, 1, $membday[2]);
                $membday = date("Y", $membday);
                $membdayage = '';
            } else {
                $membday = mktime(0, 0, 0, $membday[1], $membday[0], 0);
                $membday = date("F j", $membday);
                $membdayage = '';
            }
        }
        if ($memprofile['birthdayprivacy'] == 'age') {
            $membday = $lang->birthdayhidden;
        } else {
            if ($memprofile['birthdayprivacy'] == 'none') {
                $membday = $lang->birthdayhidden;
                $membdayage = '';
            }
        }
        $custom_fields_list[] = new xmlrpcval(array('name' => new xmlrpcval(basic_clean($lang->date_of_birth), 'base64'), 'value' => new xmlrpcval(basic_clean("{$membday} {$membdayage}"), 'base64')), 'struct');
    }
    // thank you/like field
    global $mobiquo_config;
    $prefix = $mobiquo_config['thlprefix'];
    if ($mybb->settings[$prefix . 'enabled'] == "1") {
        $lang->load("thankyoulike");
        if ($mybb->settings[$prefix . 'thankslike'] == "like") {
            $lang->tyl_total_tyls_given = $lang->tyl_total_likes_given;
            $lang->tyl_total_tyls_rcvd = $lang->tyl_total_likes_rcvd;
        } else {
            if ($mybb->settings[$prefix . 'thankslike'] == "thanks") {
                $lang->tyl_total_tyls_given = $lang->tyl_total_thanks_given;
                $lang->tyl_total_tyls_rcvd = $lang->tyl_total_thanks_rcvd;
            }
        }
        $daysreg = (TIME_NOW - $memprofile['regdate']) / (24 * 3600);
        $tylpd = $memprofile['tyl_unumtyls'] / $daysreg;
        $tylpd = round($tylpd, 2);
        if ($tylpd > $memprofile['tyl_unumtyls']) {
            $tylpd = $memprofile['tyl_unumtyls'];
        }
        $tylrcvpd = $memprofile['tyl_unumrcvtyls'] / $daysreg;
        $tylrcvpd = round($tylrcvpd, 2);
        if ($tylrcvpd > $memprofile['tyl_unumrcvtyls']) {
            $tylrcvpd = $memprofile['tyl_unumrcvtyls'];
        }
        // Get total tyl and percentage
        $options = array("limit" => 1);
        $query = $db->simple_select($prefix . "stats", "*", "title='total'", $options);
        $total = $db->fetch_array($query);
        if ($total['value'] == 0) {
            $percent = "0";
            $percent_rcv = "0";
        } else {
            $percent = $memprofile['tyl_unumtyls'] * 100 / $total['value'];
            $percent = round($percent, 2);
            $percent_rcv = $memprofile['tyl_unumrcvtyls'] * 100 / $total['value'];
            $percent_rcv = round($percent_rcv, 2);
        }
        if ($percent > 100) {
            $percent = 100;
        }
        if ($percent_rcv > 100) {
            $percent_rcv = 100;
        }
        $memprofile['tyl_unumtyls'] = my_number_format($memprofile['tyl_unumtyls']);
        $memprofile['tyl_unumrcvtyls'] = my_number_format($memprofile['tyl_unumrcvtyls']);
        $tylpd_percent_total = $lang->sprintf($lang->tyl_tylpd_percent_total, my_number_format($tylpd), $tyl_thankslikes_given, $percent);
        $tylrcvpd_percent_total = $lang->sprintf($lang->tyl_tylpd_percent_total, my_number_format($tylrcvpd), $tyl_thankslikes_rcvd, $percent_rcv);
        addCustomField($lang->tyl_total_tyls_given, "{$memprofile['tyl_unumtyls']} ({$tylpd_percent_total})", $custom_fields_list);
        addCustomField($lang->tyl_total_tyls_rcvd, "{$memprofile['tyl_unumrcvtyls']} ({$tylrcvpd_percent_total})", $custom_fields_list);
    }
    if ($memprofile['timeonline'] > 0) {
        $timeonline = nice_time($memprofile['timeonline']);
        addCustomField($lang->timeonline, $timeonline, $custom_fields_list);
    }
    if ($mybb->settings['usereferrals'] == 1 && $memprofile['referrals'] > 0) {
        addCustomField($lang->members_referred, $memprofile['referrals'], $custom_fields_list);
    }
    if ($memperms['usereputationsystem'] == 1 && $displaygroup['usereputationsystem'] == 1 && $mybb->settings['enablereputation'] == 1 && ($mybb->settings['posrep'] || $mybb->settings['neurep'] || $mybb->settings['negrep'])) {
        addCustomField($lang->reputation, $memprofile['reputation'], $custom_fields_list);
    }
    if ($mybb->settings['enablewarningsystem'] != 0 && $memperms['canreceivewarnings'] != 0 && ($mybb->usergroup['canwarnusers'] != 0 || $mybb->user['uid'] == $memprofile['uid'] && $mybb->settings['canviewownwarning'] != 0)) {
        $warning_level = round($memprofile['warningpoints'] / $mybb->settings['maxwarningpoints'] * 100);
        if ($warning_level > 100) {
            $warning_level = 100;
        }
        addCustomField($lang->warning_level, $warning_level . '%', $custom_fields_list);
    }
    if ($memprofile['website']) {
        $memprofile['website'] = htmlspecialchars_uni($memprofile['website']);
        addCustomField($lang->homepage, $memprofile['website'], $custom_fields_list);
    }
    if ($memprofile['icq']) {
        addCustomField($lang->icq_number, $memprofile['icq'], $custom_fields_list);
    }
    if ($memprofile['aim']) {
        addCustomField($lang->aim_screenname, $memprofile['aim'], $custom_fields_list);
    }
    if ($memprofile['yahoo']) {
        addCustomField($lang->yahoo_id, $memprofile['yahoo'], $custom_fields_list);
    }
    if ($memprofile['msn']) {
        addCustomField($lang->msn, $memprofile['msn'], $custom_fields_list);
    }
    $query = $db->simple_select("userfields", "*", "ufid='{$uid}'");
    $userfields = $db->fetch_array($query);
    if ($mybb->usergroup['cancp'] == 1 || $mybb->usergroup['issupermod'] == 1 || $mybb->usergroup['canmodcp'] == 1) {
        $field_hidden = '1=1';
    } else {
        $field_hidden = "hidden=0";
    }
    $query = $db->simple_select("profilefields", "*", "{$field_hidden}", array('order_by' => 'disporder'));
    while ($customfield = $db->fetch_array($query)) {
        $thing = explode("\n", $customfield['type'], "2");
        $type = trim($thing[0]);
        $field = "fid{$customfield['fid']}";
        $useropts = explode("\n", $userfields[$field]);
        $customfieldval = $comma = '';
        if (is_array($useropts) && ($type == "multiselect" || $type == "checkbox")) {
            $customfieldval = $userfields[$field];
        } else {
            $customfieldval = $parser->parse_badwords($userfields[$field]);
        }
        $customfield['name'] = htmlspecialchars_uni($customfield['name']);
        if ($customfieldval) {
            addCustomField($customfield['name'], $customfieldval, $custom_fields_list);
        }
    }
    if ($memprofile['signature'] && ($memprofile['suspendsignature'] == 0 || $memprofile['suspendsigtime'] < TIME_NOW)) {
        $sig_parser = array("allow_html" => $mybb->settings['sightml'], "allow_mycode" => $mybb->settings['sigmycode'], "allow_smilies" => $mybb->settings['sigsmilies'], "allow_imgcode" => $mybb->settings['sigimgcode'], "me_username" => $memprofile['username'], "filter_badwords" => 1);
        $memprofile['signature'] = $parser->parse_message($memprofile['signature'], $sig_parser);
        $lang->users_signature = $lang->sprintf($lang->users_signature, $memprofile['username']);
        addCustomField($lang->users_signature, $memprofile['signature'], $custom_fields_list);
    }
    // Get custom fields end
    $query = $db->simple_select("banned", "uid", "uid='{$uid}'");
    $isbanned = !!$db->fetch_field($query, "uid");
    $xmlrpc_user_info = array('user_id' => new xmlrpcval($memprofile['uid'], 'string'), 'username' => new xmlrpcval(basic_clean($memprofile['username']), 'base64'), 'user_name' => new xmlrpcval(basic_clean($memprofile['username']), 'base64'), 'user_type' => check_return_user_type($memprofile['username']), 'post_count' => new xmlrpcval($memprofile['postnum'], 'int'), 'reg_time' => new xmlrpcval(mobiquo_iso8601_encode($memprofile['regdate']), 'dateTime.iso8601'), 'timestamp_reg' => new xmlrpcval($memprofile['regdate'], 'string'), 'last_activity_time' => new xmlrpcval(mobiquo_iso8601_encode($memprofile['lastactive']), 'dateTime.iso8601'), 'timestamp' => new xmlrpcval($memprofile['lastactive'], 'string'), 'is_online' => new xmlrpcval($online, 'boolean'), 'accept_pm' => new xmlrpcval($memprofile['receivepms'], 'boolean'), 'display_text' => new xmlrpcval($usertitle, 'base64'), 'icon_url' => new xmlrpcval(absolute_url($memprofile['avatar']), 'string'), 'current_activity' => new xmlrpcval($location, 'base64'));
    if ($mybb->usergroup['canmodcp'] == 1 && $uid != $mybb->user['uid']) {
        $xmlrpc_user_info['can_ban'] = new xmlrpcval(ture, 'boolean');
    }
    if ($isbanned) {
        $xmlrpc_user_info['is_ban'] = new xmlrpcval(ture, 'boolean');
    }
    $xmlrpc_user_info['custom_fields_list'] = new xmlrpcval($custom_fields_list, 'array');
    return new xmlrpcresp(new xmlrpcval($xmlrpc_user_info, 'struct'));
}
Ejemplo n.º 3
0
/**
 * Build a Who's Online row for a specific user
 *
 * @param array Array of user information including activity information
 * @return string Formatted online row
 */
function build_wol_row($user)
{
    global $mybb, $lang, $templates, $theme, $session, $db;
    // We have a registered user
    if ($user['uid'] > 0) {
        // Only those with "canviewwolinvis" permissions can view invisible users
        if ($user['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $user['uid'] == $mybb->user['uid']) {
            // Append an invisible mark if the user is invisible
            if ($user['invisible'] == 1) {
                $invisible_mark = "*";
            } else {
                $invisible_mark = '';
            }
            $user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
            $online_name = build_profile_link($user['username'], $user['uid']) . $invisible_mark;
        }
    } elseif (!empty($user['bot'])) {
        $online_name = format_name($user['bot'], $user['usergroup']);
    } else {
        $online_name = format_name($lang->guest, 1);
    }
    $online_time = my_date($mybb->settings['timeformat'], $user['time']);
    // Fetch the location name for this users activity
    $location = build_friendly_wol_location($user['activity']);
    // Can view IPs, then fetch the IP template
    if ($mybb->usergroup['canviewonlineips'] == 1) {
        $user['ip'] = my_inet_ntop($db->unescape_binary($user['ip']));
        if ($mybb->usergroup['canmodcp'] == 1 && $mybb->usergroup['canuseipsearch'] == 1) {
            eval("\$lookup = \"" . $templates->get("online_row_ip_lookup") . "\";");
        }
        eval("\$user_ip = \"" . $templates->get("online_row_ip") . "\";");
    } else {
        $user_ip = $lookup = $user['ip'] = '';
    }
    // And finally if we have permission to view this user, return the completed online row
    if ($user['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $user['uid'] == $mybb->user['uid']) {
        eval("\$online_row = \"" . $templates->get("online_row") . "\";");
    }
    return $online_row;
}
Ejemplo n.º 4
0
function get_online_users_func()
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    $lang->load("online");
    $user_lists = array();
    if ($mybb->usergroup['canviewonline'] == 0) {
        return tt_no_permission();
    }
    switch ($db->type) {
        case "sqlite":
        case "pgsql":
            $sql = "s.time DESC";
            break;
        default:
            $sql = "IF( s.uid >0, 1, 0 ) DESC, s.time DESC";
            break;
    }
    $refresh_string = '';
    $timesearch = TIME_NOW - $mybb->settings['wolcutoffmins'] * 60;
    // Query for active sessions
    $query = $db->query("\n\t\tSELECT DISTINCT s.sid, s.ip, s.uid, s.time, s.location, u.username, s.nopermission,s.useragent,u.invisible, u.usergroup, u.displaygroup, u.avatar\n\t\tFROM " . TABLE_PREFIX . "sessions s\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (s.uid=u.uid)\n\t\tWHERE s.time>'{$timesearch}'\n\t\tORDER BY {$sql}\n\t");
    // Fetch spiders
    $spiders = $cache->read("spiders");
    while ($user = $db->fetch_array($query)) {
        // Fetch the WOL activity
        $user['activity'] = fetch_wol_activity($user['location'], $user['nopermission']);
        $user['from'] = 'broswer';
        if (strpos($user['useragent'], 'Android') !== false || strpos($user['useragent'], 'iPhone') !== false || strpos($user['useragent'], 'BlackBerry') !== false) {
            $user['from'] = 'mobile';
        }
        if (strpos($user['location'], 'mobiquo') !== false) {
            $user['from'] = 'tapatalk';
        }
        if (strpos($user['useragent'], 'BYO') !== false) {
            $user['from'] = 'byo';
        }
        // Stop links etc.
        /*unset($user['activity']['tid']);
        		unset($user['activity']['fid']);
        		unset($user['activity']['pid']);
        		unset($user['activity']['eid']);
        		unset($user['activity']['aid']);*/
        $botkey = my_strtolower(str_replace("bot=", '', $user['sid']));
        // Have a registered user
        if ($user['uid'] > 0) {
            if ($users[$user['uid']]['time'] < $user['time'] || !$users[$user['uid']]) {
                $users[$user['uid']] = $user;
            }
        } else {
            if (my_strpos($user['sid'], "bot=") !== false && $spiders[$botkey]) {
                $user['bot'] = $spiders[$botkey]['name'];
                $user['usergroup'] = $spiders[$botkey]['usergroup'];
                $guests[] = $user;
            } else {
                $guests[] = $user;
            }
        }
    }
    // Now we build the actual online rows - we do this separately because we need to query all of the specific activity and location information
    $online_rows = '';
    if (is_array($users)) {
        reset($users);
        foreach ($users as $user) {
            // We have a registered user
            if ($user['uid'] > 0) {
                // Only those with "canviewwolinvis" permissions can view invisible users
                if ($user['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $user['uid'] == $mybb->user['uid']) {
                    // Append an invisible mark if the user is invisible
                    if ($user['invisible'] == 1) {
                        $invisible_mark = "(*)";
                    } else {
                        $invisible_mark = '';
                    }
                    //$user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
                    //$online_name = build_profile_link($user['username'], $user['uid']).$invisible_mark;
                    $online_name = $user['username'];
                }
            } elseif ($user['bot']) {
                //$online_name = format_name($user['bot'], $user['usergroup']);
                continue;
            } else {
                //$online_name = format_name($lang->guest, 1);
                continue;
            }
            // Fetch the location name for this users activity
            $location = $invisible_mark . strip_tags(build_friendly_wol_location($user['activity']));
            $user_lists[] = new xmlrpcval(array('user_name' => new xmlrpcval($online_name, 'base64'), 'user_type' => check_return_user_type($online_name), 'user_id' => new xmlrpcval($user['uid'], 'string'), 'display_text' => new xmlrpcval($location, 'base64'), 'icon_url' => new xmlrpcval(absolute_url($user['avatar']), 'string'), 'from' => new xmlrpcval($user['from'], 'string')), 'struct');
        }
    }
    $online_users = new xmlrpcval(array('member_count' => new xmlrpcval(count($user_lists), 'int'), 'guest_count' => new xmlrpcval(count($guests), 'int'), 'list' => new xmlrpcval($user_lists, 'array')), 'struct');
    return new xmlrpcresp($online_users);
}