示例#1
0
function mysteam_profile()
{
    global $lang, $memprofile, $templates, $steamname;
    if (!$lang->mysteam) {
        $lang->load('mysteam');
    }
    // Only run if the profile owner has a Steam ID.
    if ($memprofile['steamid']) {
        $steam = mysteam_check_cache();
        // Don't display anything for user if there's no status info stored for the user (may happen if Steam returns a bad response for the user)
        if (isset($steam['users'][$memprofile['uid']]['steamstatus'])) {
            $memprofile = array_merge($memprofile, (array) $steam['users'][$memprofile['uid']]);
            mysteam_status($memprofile);
            eval("\$steamname = \"" . $templates->get("mysteam_contact") . "\";");
        }
    }
}
示例#2
0
function asb_mysteamlist_build_list($settings, $width)
{
    global $mybb, $lang, $templates;
    // Make sure the main plugin's functions are available (may not be if it's disabled).
    if (function_exists(mysteam_check_cache)) {
        // Read the cache, or refresh it if too old.
        $steam = mysteam_check_cache();
    }
    // If no users to display, show error.
    if (!$steam['users']) {
        return false;
    }
    // If set to display multiple columns, reduce each status entry's width accordingly.
    if ((int) $settings['asb_steam_list_cols'] < 2) {
        $entry_width = $width - 5;
    } else {
        $col_number = (int) $settings['asb_steam_list_cols'];
        $entry_width = ($width - (5 + 5 * $col_number)) / $col_number;
    }
    // Sort users who are in-game to top of list.
    foreach ($steam['users'] as $steam_presort) {
        if ($steam_presort['steamgame']) {
            $steam_presort_game[] = $steam_presort;
        } elseif ($steam_presort['steamstatus'] > 0) {
            $steam_presort_online[] = $steam_presort;
        }
    }
    $steam['users'] = array_merge((array) $steam_presort_game, (array) $steam_presort_online);
    $n = 0;
    // Check each user's info and generate status entry.
    foreach ($steam['users'] as $user) {
        // Check display name setting, and set displayed name appropriately.
        if ($mybb->settings['mysteam_displayname'] == 'steam') {
            $displayname = $user['steamname'];
        } elseif ($mybb->settings['mysteam_displayname'] == 'forum') {
            $displayname = $user['username'];
        } else {
            $username_clean = preg_replace("/[^a-zA-Z]+/", "", strtolower($user['username']));
            $steamname_clean = preg_replace("/[^a-zA-Z]+/", "", strtolower($user['steamname']));
            // If names aren't comparable, display both steam name and forum username.
            if (strpos($steamname_clean, $username_clean) === FALSE && strpos($username_clean, $steamname_clean) === FALSE) {
                // If status entry is too narrow, place names on separate lines.
                if ($entry_width < '200') {
                    $displayname = $user['steamname'] . '<br />(' . $user['username'] . ')';
                    $position = 'bottom: 3px;';
                } else {
                    $displayname = $user['steamname'] . ' (' . $user['username'] . ')';
                }
            } else {
                $displayname = $user['steamname'];
            }
        }
        // Generate status text and display style based on current status.
        if (!empty($user['steamgame'])) {
            $steam_state = $user['steamgame'];
            $avatar_class = 'steam_avatar_in-game';
            $color_class = 'steam_in-game';
        } elseif ($user['steamstatus'] == '1') {
            $steam_state = $lang->mysteam_online;
            $avatar_class = 'steam_avatar_online';
            $color_class = 'steam_online';
        } elseif ($user['steamstatus'] == '3') {
            $steam_state = $lang->mysteam_away;
            $avatar_class = 'steam_avatar_online';
            $color_class = 'steam_online';
        } elseif ($user['steamstatus'] == '4') {
            $steam_state = $lang->mysteam_snooze;
            $avatar_class = 'steam_avatar_online';
            $color_class = 'steam_online';
        } elseif ($user['steamstatus'] == '2') {
            $steam_state = $lang->mysteam_busy;
            $avatar_class = 'steam_avatar_online';
            $color_class = 'steam_online';
        } elseif ($user['steamstatus'] == '5') {
            $steam_state = $lang->mysteam_looking_to_trade;
            $avatar_class = 'steam_avatar_online';
            $color_class = 'steam_online';
        } elseif ($user['steamstatus'] == '6') {
            $steam_state = $lang->mysteam_looking_to_play;
            $avatar_class = 'steam_avatar_online';
            $color_class = 'steam_online';
        }
        // Don't generate entries for users in excess of the maximum number setting.
        if ($settings['asb_steam_list_number']) {
            $n++;
            if ($n > (int) $settings['asb_steam_list_number']) {
                break;
            }
        }
        eval("\$asb_list_entries .= \"" . $templates->get("mysteam_list_user") . "\";");
    }
    if ($asb_list_entries) {
        // Set template variable to returned statuses list and return true
        eval("\$asb_mysteamlist = \"" . $templates->get("asb_mysteam") . "\";");
        return $asb_mysteamlist;
    }
    return false;
}
<?php

/* Plugin Name: MySteam Powered
 * License: MIT (http://opensource.org/licenses/MIT)
 * Copyright © 2014 Aryndel Lamb-Marsh (aka Tanweth)
 *
 * STEAM STATUS COMPLETE LIST
 * This page is used by the above plugin to generate a complete list of Steam users' current statuses if there are more users with statuses than allowed on the main list.
 */
$templatelist = 'mysteam_list_user,mysteam_list_complete';
define('IN_MYBB', 1);
require "./global.php";
$lang->load('mysteam');
add_breadcrumb($lang->asb_mysteam_title . ' (' . $lang->mysteam_complete_list . ')', 'steam-status-complete.php');
// Read the cache, or refresh it if too old.
$steam = mysteam_check_cache();
if (!$steam['users']) {
    $list_entries = $lang->mysteam_none_found;
    eval("\$html = \"" . $templates->get("mysteam_list_complete") . "\";");
    output_page($html);
    return;
}
$entry_width = (int) $mybb->settings['mysteam_list_width'];
foreach ($steam['users'] as $steam_presort) {
    if ($steam_presort['steamgame']) {
        $steam_presort_game[] = $steam_presort;
    } elseif ($steam_presort['steamstatus'] > 0) {
        $steam_presort_online[] = $steam_presort;
    } else {
        $steam_presort_offline[] = $steam_presort;
    }