Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Author: itsmeJAY
- Year: 2019
- Version tested: 1.8.21
- Contact and support exclusively in the MyBB.de Forum (German Community - https://www.mybb.de/).
- */
- if (!defined("IN_MYBB")) {
- die("Direct initialization of this file is not allowed.");
- }
- // Hooks and Functions
- $plugins->add_hook("member_profile_end", "steamprofile_curl");
- $plugins->add_hook("postbit", "steamprofile_showthread");
- function steamprofile_info()
- {
- global $db, $lang;
- // Sprachdatei laden
- $lang->load("steamprofile");
- return array(
- "name" => $db->escape_string($lang->sp_steamprofile_name),
- "description" => $db->escape_string($lang->sp_steamprofile_desc),
- "website" => "https://www.mybb.de/forum/user-10220.html",
- "author" => "itsmeJAY",
- "authorsite" => "https://www.mybb.de/forum/user-10220.html",
- "version" => "1.1.0",
- "guid" => "",
- "codename" => "steamprofile",
- "compatibility" => "18*"
- );
- }
- function steamprofile_install()
- {
- global $db, $mybb, $lang, $cache;
- // Sprachdatei laden
- $lang->load("steamprofile");
- $setting_group = array(
- 'name' => 'steamprofile',
- 'title' => $db->escape_string($lang->sp_steamprofile_name),
- 'description' => $db->escape_string($lang->sp_steamprofile_name_setting_desc),
- 'disporder' => 5,
- 'isdefault' => 0
- );
- $gid = $db->insert_query("settinggroups", $setting_group);
- // Einstellungen
- $setting_array = array(
- 'steamprofile_api_key' => array(
- 'title' => $db->escape_string($lang->sp_steamapi_key),
- 'description' => $db->escape_string($lang->sp_steamapi_key_desc),
- 'optionscode' => 'text',
- 'value' => '0', // Default
- 'disporder' => 1
- ),
- 'steamprofile_show_last_game' => array(
- 'title' => $db->escape_string($lang->sp_lastgame),
- 'description' => $db->escape_string($lang->sp_lastgame_desc),
- 'optionscode' => 'yesno',
- 'value' => 1, // Default
- 'disporder' => 2
- ),
- 'steamprofile_show_steamname' => array(
- 'title' => $db->escape_string($lang->sp_steamname),
- 'description' => $db->escape_string($lang->sp_steamname_desc),
- 'optionscode' => 'yesno',
- 'value' => 1, // Default
- 'disporder' => 3
- ),
- 'steamprofile_show_lastlogoff' => array(
- 'title' => $db->escape_string($lang->sp_lastlogoff),
- 'description' => $db->escape_string($lang->sp_lastlogoff_desc),
- 'optionscode' => 'yesno',
- 'value' => 1, // Default
- 'disporder' => 4
- ),
- 'steamprofile_show_onlinestatus' => array(
- 'title' => $db->escape_string($lang->sp_showonline),
- 'description' => $db->escape_string($lang->sp_showonline_desc),
- 'optionscode' => 'yesno',
- 'value' => 1, // Default
- 'disporder' => 5
- ),
- 'steamprofile_show_bitsteamid' => array(
- 'title' => $db->escape_string($lang->sp_steamid),
- 'description' => $db->escape_string($lang->sp_steamid),
- 'optionscode' => 'yesno',
- 'value' => 1, // Default
- 'disporder' => 6
- ),
- 'steamprofile_show_accountcreated' => array(
- 'title' => $db->escape_string($lang->sp_accountcreated),
- 'description' => $db->escape_string($lang->sp_accountcreated_desc),
- 'optionscode' => 'yesno',
- 'value' => 1, // Default
- 'disporder' => 7
- ),
- 'steamprofile_show_avatar' => array(
- 'title' => $db->escape_string($lang->sp_avatar),
- 'description' => $db->escape_string($lang->sp_avatar_desc),
- 'optionscode' => 'yesno',
- 'value' => 1, // Default
- 'disporder' => 8
- ),
- 'steamprofile_show_ingame' => array(
- 'title' => $db->escape_string($lang->sp_ingame),
- 'description' => $db->escape_string($lang->sp_ingame_desc),
- 'optionscode' => 'yesno',
- 'value' => 1, // Default
- 'disporder' => 9
- ),
- 'steamprofile_show_gamecount' => array(
- 'title' => $db->escape_string($lang->sp_gamecount),
- 'description' => $db->escape_string($lang->sp_gamecount_desc),
- 'optionscode' => 'yesno',
- 'value' => 1, // Default
- 'disporder' => 10
- ),
- 'steamprofile_show_postbit' => array(
- 'title' => $db->escape_string($lang->sp_postbit),
- 'description' => $db->escape_string($lang->sp_postbit_desc),
- 'optionscode' => 'yesno',
- 'value' => 1, // Default
- 'disporder' => 11
- ),
- );
- // Einstellungen in Datenbank speichern
- foreach ($setting_array as $name => $setting) {
- $setting['name'] = $name;
- $setting['gid'] = $gid;
- $db->insert_query('settings', $setting);
- }
- //Erstelle neues Profilfeld
- $new_profile_field = array(
- "name" => $db->escape_string($lang->sp_steamid_enter),
- "description" => $db->escape_string($lang->sp_steamid_enter_desc),
- "disporder" => 6,
- "maxlength" => intval('60'),
- "type" => 'text',
- "required" => intval('0'),
- "viewableby" => '-1',
- "editableby" => '-1',
- "regex" => ''
- );
- $fid = $db->insert_query("profilefields", $new_profile_field);
- $db->write_query("ALTER TABLE " . TABLE_PREFIX . "userfields ADD fid{$fid} TEXT");
- // Rebuild Settings! :-)
- rebuild_settings();
- //Cache Update
- $cache->update_profilefields();
- }
- function steamprofile_is_installed()
- {
- global $db;
- // Hole FID des Profilfeldes aus der Datenbank
- $query = $db->simple_select("profilefields", "*", "name='SteamID'");
- $profile_field = $db->fetch_array($query);
- if (!empty($profile_field)) {
- return true;
- } else {
- return false;
- }
- }
- function steamprofile_activate()
- {
- //Template ergänzen
- require MYBB_ROOT . "/inc/adminfunctions_templates.php";
- find_replace_templatesets("member_profile", "#" . preg_quote('{$contact_details}') . "#i", '{$contact_details}<br/>{$steamprofile}');
- find_replace_templatesets("postbit", "#" . preg_quote('{$post[\'userstars\']}') . "#i", '{$post[\'userstars\']}<br/>{$post[\'steamprofile\']}');
- }
- function steamprofile_deactivate()
- {
- //Template ergänzen
- require MYBB_ROOT . "/inc/adminfunctions_templates.php";
- find_replace_templatesets("member_profile", "#" . preg_quote('<br/>{$steamprofile}') . "#i", '');
- find_replace_templatesets("postbit", "#" . preg_quote('<br/>{$post[\'steamprofile\']}') . "#i", '');
- }
- function steamprofile_uninstall()
- {
- global $db;
- $db->delete_query('settings', "name IN ('steamprofile_api_key','steamprofile_show_last_game', 'steamprofile_show_steamname', 'steamprofile_show_lastlogoff', 'steamprofile_show_onlinestatus', 'steamprofile_show_bitsteamid', 'steamprofile_show_ingame', 'steamprofile_show_gamecount', 'steamprofile_show_postbit')");
- $db->delete_query('settinggroups', "name = 'steamprofile'");
- // Hole FID des Profilfeldes aus der Datenbank
- $query = $db->simple_select("profilefields", "*", "name='SteamID'");
- $profile_field = $db->fetch_array($query);
- // Lösche das Profilfeld
- if ($profile_field['fid']) {
- $db->delete_query("profilefields", "fid='{$profile_field['fid']}'");
- $db->write_query("ALTER TABLE " . TABLE_PREFIX . "userfields DROP fid{$profile_field['fid']}");
- }
- // Rebuild Settings! :-)
- rebuild_settings();
- }
- function steamprofile_curl()
- {
- global $mybb, $steamprofile, $db, $lang, $userfields;
- // Sprachdatei laden
- $lang->load("steamprofile");
- function request($url, $int, $api)
- {
- if ($int == 1) {
- $curl = curl_init();
- curl_setopt_array($curl, [
- CURLOPT_RETURNTRANSFER => 1,
- CURLOPT_URL => 'http://api.steampowered.com/IPlayerService/GetRecentlyPlayedGames/v0001/?key=' . $api . '&steamid=' . $url . '&format=json&count=1'
- ]);
- $result = curl_exec($curl);
- curl_close($curl);
- }
- if ($int == 2) {
- $curl = curl_init();
- curl_setopt_array($curl, [
- CURLOPT_RETURNTRANSFER => 1,
- CURLOPT_URL => 'http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' . $api . '&steamids=' . $url . '&format=json'
- ]);
- $result = curl_exec($curl);
- curl_close($curl);
- }
- if ($int == 3) {
- $curl = curl_init();
- curl_setopt_array($curl, [
- CURLOPT_RETURNTRANSFER => 1,
- CURLOPT_URL => 'http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key=' . $api . '&steamid=' . $url . '&format=json'
- ]);
- $result = curl_exec($curl);
- curl_close($curl);
- }
- $result = json_decode($result, true);
- return $result;
- }
- // Hole FID des Profilfeldes aus der Datenbank
- $query = $db->simple_select("profilefields", "*", "name='SteamID'");
- $profile_field = $db->fetch_array($query);
- $fid = $profile_field['fid'];
- // Fülle Variable mit Tabelle
- $steamprofile = '<br/><table border="0" cellspacing="0" cellpadding="5" class="tborder tfixed">
- <colgroup>
- <col style="width: 30%;">
- </colgroup>
- <tbody><tr>
- <td colspan="3" class="thead"><strong>' . $lang->sp_f_steamdetails . '</strong></td>
- </tr>';
- // Zeige den Steamnamen an
- if ($mybb->settings['steamprofile_show_steamname'] == 1 || $mybb->settings['steamprofile_show_lastlogoff'] == 1 || $mybb->settings['steamprofile_show_avatar'] == 1 || $mybb->settings['steamprofile_show_onlinestatus'] == 1 || $mybb->settings['steamprofile_show_bitsteamid'] == 1 || $mybb->settings['steamprofile_show_accountcreated'] || $mybb->settings['steamprofile_show_ingame'] == 1) {
- $result = request($userfields['fid' . $fid], 2, $mybb->settings['steamprofile_api_key']);
- // Zeige Steam-Namen
- if (!empty($result['response']['players']['0']['personaname']) && $mybb->settings['steamprofile_show_steamname'] == 1) {
- $steamprofile .= '<tr>
- <td class="trow1"><strong>' . $lang->sp_f_steamname . '</strong></td>
- <td class="trow1">' . $result['response']['players']['0']['personaname'] . '</td>';
- // Zeige Profilbild an, sofern gewünscht.
- if (!empty($result['response']['players']['0']['avatarfull']) && $mybb->settings['steamprofile_show_avatar'] == 1) {
- $steamprofile .= '<td rowspan="8" style="padding: 0; margin: 0; float: none; text-align: center;"><img align="right" alt="' . $lang->sp_f_avatar . '" height="184" width="184" style="border-radius: 50%; float: none; text-align: center;" src="' . $result['response']['players']['0']['avatarfull'] . '"></td>';
- }
- $steamprofile .= "</tr>";
- }
- // Zeige letzten Login
- if (!empty($result['response']['players']['0']['lastlogoff']) && $mybb->settings['steamprofile_show_lastlogoff'] == 1) {
- $steamprofile .= '<tr>
- <td class="trow1"><strong>' . $lang->sp_f_lastlogin . '</strong></td>
- <td class="trow1">' . date("d.m.Y - H:i", $result['response']['players']['0']['lastlogoff']) . '</td>
- </tr>';
- }
- // Zeige Status
- if ($mybb->settings['steamprofile_show_onlinestatus'] == 1) {
- $status = "";
- switch ($result['response']['players']['0']['personastate']) {
- case 0:
- $status = '<span style="color: #ff0000;"><strong>Offline</strong></span>';
- break;
- case 1:
- $status = '<span style="color: #008000;"><strong>Online</strong></span>';
- break;
- case 2:
- $status = $lang->sp_f_busy;
- break;
- case 3:
- $status = $lang->sp_f_away;
- break;
- case 4:
- $status = $lang->sp_f_snooze;
- break;
- case 5:
- $status = $lang->sp_f_trade;
- break;
- case 6:
- $status = $lang->sp_f_play;
- break;
- default:
- $status = '<span style="color: #ff0000;"><strong>Offline</strong></span>';
- }
- $steamprofile .= '<tr>
- <td class="trow1"><strong>' . $lang->sp_f_currentstatus . '</strong></td>
- <td class="trow1">' . $status . '</td>
- </tr>';
- }
- // Zeige 64bit SteamID
- if (!empty($result['response']['players']['0']['steamid']) && $mybb->settings['steamprofile_show_bitsteamid'] == 1) {
- $steamprofile .= '<tr>
- <td class="trow1"><strong>' . $lang->sp_f_steamid . '</strong></td>
- <td class="trow1"><a href="' . $result['response']['players'][0]['profileurl'] . '">' . $result['response']['players']['0']['steamid'] . '</a></td>
- </tr>';
- }
- // Zeige an, wann der Steam Account erstellt wurde
- if (!empty($result['response']['players']['0']['timecreated']) && $mybb->settings['steamprofile_show_accountcreated'] == 1) {
- $steamprofile .= '<tr>
- <td class="trow1"><strong>' . $lang->sp_f_acccreated . '</strong></td>
- <td class="trow1">' . date("d.m.Y - H:i:s", $result['response']['players']['0']['timecreated']) . '</td>
- </tr>';
- }
- }
- // Zeige das letzte gespielte Spiel inklusive 16x16 Icon an!
- if ($mybb->settings['steamprofile_show_last_game'] == 1) {
- $result = request($userfields['fid' . $fid], 1, $mybb->settings['steamprofile_api_key']);
- if (!empty($result['response']['games']['0']['name'])) {
- $steamprofile .= '<tr>
- <td class="trow1"><strong>' . $lang->sp_f_lastplayed . '</strong></td>
- <td class="trow1"><img alt="Icon" height="16px" width="16px" src="http://media.steampowered.com/steamcommunity/public/images/apps/' . $result['response']['games'][0]['appid'] . '/' . $result['response']['games'][0]['img_icon_url'] . '.jpg" > ' . $result['response']['games']['0']['name'] . '<br/>
- (<em>' . $lang->sp_f_l2w . '</em> ' . number_format(round($result['response']['games'][0]['playtime_2weeks'] / 60, 2), '2', '.', ',') . ' ' . $lang->sp_f_hours . ')<br>
- (<em>' . $lang->sp_f_total . '</em> ' . number_format(round($result['response']['games'][0]['playtime_forever'] / 60, 2), 0, ".", ',') . ' ' . $lang->sp_f_hours . ')<br>
- </td>
- </tr>';
- }
- }
- // Zeige an, wie viele Spiele der Spieler hat
- if ($mybb->settings['steamprofile_show_gamecount'] == 1) {
- $result = request($userfields['fid' . $fid], 3, $mybb->settings['steamprofile_api_key']);
- if (!empty($result['response']['game_count'])) {
- $steamprofile .= '<tr>
- <td class="trow1"><strong>' . $lang->sp_f_gamescounted . '</strong></td>
- <td class="trow1">' . $result['response']['game_count'] . '</td>
- </tr>';
- }
- }
- // Zeige an, ob Spieler In-Game ist!
- if ($mybb->settings['steamprofile_show_ingame'] == 1) {
- $result = request($userfields['fid' . $fid], 2, $mybb->settings['steamprofile_api_key']);
- if (!empty($result['response']['players']['0']['gameextrainfo'])) {
- $steamprofile .= '<tr>
- <td class="trow1" colspan="3" style="text-align: center; background-color: #0066a2; color: #fff;"><strong>' . $lang->sp_f_currentlyplaying . ' ' . $result['response']['players']['0']['gameextrainfo'] . '</strong></td></td>
- </tr>';
- }
- }
- $steamprofile .= '</tbody></table>';
- if (empty($userfields['fid' . $fid]) || $userfields['fid' . $fid] == 0) {
- $steamprofile = "";
- }
- }
- function steamprofile_showthread(&$post)
- {
- global $mybb, $db, $lang;
- if ($mybb->settings['steamprofile_show_postbit'] == 1 && $mybb->settings['steamprofile_api_key'] != 0 && !empty($mybb->settings['steamprofile_api_key'])) {
- $lang->load("steamprofile");
- // Hole FID des Profilfeldes aus der Datenbank
- $query = $db->simple_select("profilefields", "*", "name='SteamID'");
- $profile_field = $db->fetch_array($query);
- $fid = $profile_field['fid'];
- $user = get_user($post['uid']);
- // Sende Request
- if (!empty($user['fid' . $fid]) && $user['fid' . $fid] != 0) {
- $curl = curl_init();
- curl_setopt_array($curl, [
- CURLOPT_RETURNTRANSFER => 1,
- CURLOPT_URL => 'http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' . $mybb->settings['steamprofile_api_key'] . '&steamids=' . $user['fid' . $fid] . '&format=json'
- ]);
- $result = curl_exec($curl);
- curl_close($curl);
- $result = json_decode($result, true);
- }
- if (isset($result['response']['players']['0']['gameextrainfo']) && !empty($result['response']['players']['0']['gameextrainfo'])) {
- $post['steamprofile'] = '<div class="mysteam_list_wrapper" style="width: 200px;" >
- <div class="steam_avatar_in-game steam_avatar mysteam_list_avatar" >
- <div >
- <a href="' . $result['response']['players']['0']['profileurl'] . '" target="_blank" ><img src="' . $result['response']['players']['0']['avatar'] . '" ></a>
- </div>
- </div>
- <span class="steam_in-game smalltext" >
- <div class="mysteam_list_status">
- <div class="mysteam_status_wrapper" >
- <a href="' . $result['response']['players']['0']['profileurl'] . '" target="_blank" >' . $result['response']['players']['0']['personaname'] . '</a><br>
- ' . $lang->sp_f_ingame_pb . '<br>
- ' . $result['response']['players']['0']['gameextrainfo'] . '<br>
- </div>
- </div>
- </span>
- </div>';
- } else if ($result['response']['players']['0']['personastate'] == 1 && !isset($result['response']['players']['0']['gameextrainfo'])) {
- $post['steamprofile'] = '<div class="mysteam_list_wrapper" style="width: 200px" >
- <div class="steam_avatar_online steam_avatar mysteam_list_avatar" >
- <div >
- <a href="' . $result['response']['players']['0']['profileurl'] . '" target="_blank" ><img src="' . $result['response']['players']['0']['avatar'] . '" ></a>
- </div>
- </div>
- <span class="steam_online smalltext" >
- <div class="mysteam_list_status">
- <div class="mysteam_status_wrapper" >
- <a href="' . $result['response']['players']['0']['profileurl'] . '" target="_blank" >' . $result['response']['players']['0']['personaname'] . '</a><br>
- Online<br>
- </div>
- </div>
- </span>
- </div>';
- } else {
- $post['steamprofile'] = '<div class="mysteam_list_wrapper" style="width: 200px" >
- <div class="steam_avatar_offline steam_avatar mysteam_list_avatar" >
- <div >
- <a href="' . $result['response']['players']['0']['profileurl'] . '" target="_blank" ><img src="' . $result['response']['players']['0']['avatar'] . '" ></a>
- </div>
- </div>
- <span class="steam_offline smalltext" >
- <div class="mysteam_list_status">
- <div class="mysteam_status_wrapper" >
- <a href="' . $result['response']['players']['0']['profileurl'] . '" target="_blank" >' . $result['response']['players']['0']['personaname'] . '</a><br>
- Offline<br>
- </div>
- </div>
- </span>
- </div>';
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement