Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
[WIDGET] Steam Group Stats Details »»
[WIDGET] Steam Group Stats
Version: 1.00, by Inflikted Inflikted is offline
Developer Last Online: Aug 2012 Show Printable Version Email this Page

Category: vBulletin CMS Widgets - Version: 4.0.3 Rating:
Released: 04-18-2010 Last Update: Never Installs: 36
Re-useable Code Translations  
No support by the author.

For those who have a steam group, you can easily display your steamgroup stats on your frontpage. I included 2 versions a cached version (which I recommend to use but takes a tiny bit more effort to run) and a non-cached version which runs out of the box (might slow down your site a bit more).

Instructions Cached Version:
1.Navigate to AdminCP -> CMS -> Widgets.
2. Create a PHP Type Widget and paste the code from below:

cached version:
PHP Code:
<html>
<style type="text/css">
span.membersInGame {
    font-size: 11px;
    color: #8bc53f;
    font-family:arial, Helvetica, tahoma, sans-serif;
    text-decoration:none;
}
span.membersOnline {
    font-size: 11px;
    color: #62a7e3;
    font-family:arial, Helvetica, tahoma, sans-serif;
    text-decoration:none;
}
</style>
</html>
<?php 
$group 
freefragnet;
$cachefile 'cache/grpcache.html';
$cachetime 60// 5 minutes
if (file_exists($cachefile) && (time() - $cachetime filemtime($cachefile))) {
include(
$cachefile);
echo 
"<!-- Cached ".date('jS F Y H:i'filemtime($cachefile))." -->";

} else {
ob_start();
    
$url file_get_contents('http://steamcommunity.com/groups/'.$group); 
    
ini_set('default_socket_timeout'0); 
    
preg_match('#<h1>(.+)</h1>#sU'$url$aMatches); 
    echo 
"<div class=blockrow>";
    echo 
"<table>";
    echo 
"<a class='clanname' href='http://steamcommunity.com/groups/$group' target='_blank'>$aMatches[1]</a>"
    echo 
"<br>";

    
preg_match('#<div class="groupMemberRow">(.+)</div>#sU'$url$aMatches); 
    
$aMatches str_replace('class="linkStandard"''class="linkStandard" target="_blank"'$aMatches[1]);
    
$pieces explode(" "$aMatches);
$domain strstr($pieces[3], '>');
$strip1 substr($domain1); 
    echo 
"<span class=resultsb>$strip1 Members</span>";
    echo 
"<br>";
$domain1 strstr($pieces[6], '>');
$strip2 substr($domain11);
    echo 
"<span class=membersInGame><font color=#8bc53f>$strip2 In-Game</font></span>"
    echo 
"<br>";
$domain2 strstr($pieces[9], '>');
$strip3 substr($domain21); 
    echo 
"<span class=membersOnline><font color=#62a7e3>$strip3 Online</font></span>";
echo 
"</table>";
echo 
"</div>";
$fp fopen($cachefile'w');
fwrite($fpob_get_contents());
fclose($fp);
ob_end_flush();
ob_end_clean();
}
?>
3. Edit $group = freefragnet; to your group. This is in the url base for your steam group Example: http://steamcommunity.com/groups/freefragnet

4. In your ftp, in the same base folder vbulletin is hosted, create a folder named 'cache' and CHMOD to 777.
5. Your set

Demo: http://www.freefrag.com/

Instructions Non-Cached Version:
1.Navigate to AdminCP -> CMS -> Widgets.
2. Create a PHP Type Widget and paste the code from below:

non-cache
PHP Code:
<html>
<style type="text/css">
span.membersInGame {
    font-size: 11px;
    color: #8bc53f;
    font-family:arial, Helvetica, tahoma, sans-serif;
    text-decoration:none;
}
span.membersOnline {
    font-size: 11px;
    color: #62a7e3;
    font-family:arial, Helvetica, tahoma, sans-serif;
    text-decoration:none;
}
</style>
</html>
<?php 
$group 
freefragnet;
    
$url file_get_contents('http://steamcommunity.com/groups/'.$group); 
    
ini_set('default_socket_timeout'0); 
    
preg_match('#<h1>(.+)</h1>#sU'$url$aMatches); 
    echo 
"<div class=blockrow>";
    echo 
"<table>";
    echo 
"<a class='clanname' href='http://steamcommunity.com/groups/$group' target='_blank'>$aMatches[1]</a>"
    echo 
"<br>";

    
preg_match('#<div class="groupMemberRow">(.+)</div>#sU'$url$aMatches); 
    
$aMatches str_replace('class="linkStandard"''class="linkStandard" target="_blank"'$aMatches[1]);
    
$pieces explode(" "$aMatches);
$domain strstr($pieces[3], '>');
$strip1 substr($domain1); 
    echo 
"<span class=resultsb>$strip1 Members</span>";
    echo 
"<br>";
$domain1 strstr($pieces[6], '>');
$strip2 substr($domain11);
    echo 
"<span class=membersInGame><font color=#8bc53f>$strip2 In-Game</font></span>"
    echo 
"<br>";
$domain2 strstr($pieces[9], '>');
$strip3 substr($domain21); 
    echo 
"<span class=membersOnline><font color=#62a7e3>$strip3 Online</font></span>";
echo 
"</table>";
echo 
"</div>";
?>
3. Edit $group = freefragnet; to your group. This is in the url base for your steam group Example: http://steamcommunity.com/groups/freefragnet
4. Your set

Demo: http://www.freefrag.com/

Screenshots

File Type: jpg steamstats.jpg (12.9 KB, 0 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #42  
Old 09-08-2012, 11:40 PM
MadMakz MadMakz is offline
 
Join Date: Apr 2011
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've updated my custom-code and simplyfied it. Working with 2012/Greenlight update.
https://tracker.madmakz.com/redmine/...Status/sgs.php

to have it working on vBulletin sidebar, change
PHP Code:
echo stgrp_status($gruppe); 
to
PHP Code:
return stgrp_status($gruppe); 
Reply With Quote
Благодарность от:
fookaa
  #43  
Old 09-23-2012, 02:40 PM
fookaa fookaa is offline
 
Join Date: Dec 2009
Posts: 85
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks
Reply With Quote
  #44  
Old 09-25-2012, 10:04 AM
CoZmicShReddeR's Avatar
CoZmicShReddeR CoZmicShReddeR is offline
 
Join Date: Sep 2006
Location: MI, USA
Posts: 338
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MadMakz View Post
I've updated my custom-code and simplyfied it. Working with 2012/Greenlight update.
http://rcs.madmakz.com/misc-tools/sr...Status/sgs.php

to have it working on vBulletin sidebar, change
PHP Code:
echo stgrp_status($gruppe); 
to
PHP Code:
return stgrp_status($gruppe); 
I am trying to use your code as a widget on front page and all I keep getting is
"Steamcommunity appears to be down."

Any ideas?
Reply With Quote
  #45  
Old 09-26-2012, 09:47 AM
MadMakz MadMakz is offline
 
Join Date: Apr 2011
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Either you've tested when steam had its massive maintenaince downtime yesterday or file_get_contents() might not be allowed on your server (allow_fopen_url must be enabled).

if you have php-curl installed you could workaround this by adding the following function
PHP Code:
function file_get_contents_curl($url$agent "My Agent"){
    
$ch curl_init();
    
    
curl_setopt($chCURLOPT_HEADER0);
    
curl_setopt($chCURLOPT_RETURNTRANSFER1); //Set curl to return the data instead of printing it to the browser.
    
curl_setopt($chCURLOPT_USERAGENT$agent);
    
curl_setopt($chCURLOPT_URL$url);
     
    
$data curl_exec($ch);
    
curl_close($ch);
     
    return 
$data;

and replace
PHP Code:
file_get_contents('http://steamcommunity.com/groups/'.$group
with
PHP Code:
file_get_contents_curl('http://steamcommunity.com/groups/'.$group
.
i have not tested this but it should work.

other problem could be that your host can't resolve the steamcommunity domain properly.
Reply With Quote
  #46  
Old 09-26-2012, 12:33 PM
MadMakz MadMakz is offline
 
Join Date: Apr 2011
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

addition: simply changeing file_get_contents won't do it so here's a cURL version of the whole script:
https://tracker.madmakz.com/redmine/...s/sgs_curl.php
Reply With Quote
  #47  
Old 09-26-2012, 02:05 PM
fookaa fookaa is offline
 
Join Date: Dec 2009
Posts: 85
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I never did the edit you said "echo to return" and mine works

Did you enter your steam group name in the file ?
Reply With Quote
  #48  
Old 09-26-2012, 02:33 PM
Crotan's Avatar
Crotan Crotan is offline
 
Join Date: Feb 2010
Posts: 249
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MadMakz View Post
addition: simply changeing file_get_contents won't do it so here's a cURL version of the whole script:
http://rcs.madmakz.com/misc-tools/sr...s/sgs_curl.php
Since this is reusable code, might you want to make a separate mod for tracking and discussion purposes?

Maybe [WIDGET] Steam Group Stats cURL

Also is this what you use on your site?
Reply With Quote
  #49  
Old 09-26-2012, 06:51 PM
CoZmicShReddeR's Avatar
CoZmicShReddeR CoZmicShReddeR is offline
 
Join Date: Sep 2006
Location: MI, USA
Posts: 338
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MadMakz View Post
addition: simply changeing file_get_contents won't do it so here's a cURL version of the whole script:
http://rcs.madmakz.com/misc-tools/sr...s/sgs_curl.php

Ok new code works now!

Now I was wondering how can we dress this up a little bit like with a banner above the out put and maybe some RSS info below like some of the latest Announcements?

I just need an example of the image code because every time I try to add something it is at the top of the page...

Thanks!
Reply With Quote
  #50  
Old 09-29-2012, 12:21 AM
Crotan's Avatar
Crotan Crotan is offline
 
Join Date: Feb 2010
Posts: 249
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by CoZmicShReddeR View Post
Ok new code works now!

Now I was wondering how can we dress this up a little bit like with a banner above the out put and maybe some RSS info below like some of the latest Announcements?

I just need an example of the image code because every time I try to add something it is at the top of the page...

Thanks!
What would be awesome to see, or atleast what i see in my dreams is if someone could create a widget that displays the usernames of a specified steam group that are In-Game, and then of those players what game they are in.

Some php coders that want to be loved forever should check out github and the new steam web api.

https://github.com/koraktor/steam-co...mGroupTest.php
Reply With Quote
  #51  
Old 10-05-2012, 06:02 AM
Crotan's Avatar
Crotan Crotan is offline
 
Join Date: Feb 2010
Posts: 249
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MadMakz View Post
btw: it might be good idea to redo the whole mod using steamcommunities webapi. it's way more lightweight an easier to handle.
I actually just did this using the steam webapi, group information doesn't need an API key and is all xml based. I'm just not sure how to put it into a vBulletin php widget. Doing it in a html iframe calling the php works, but not really the route that I would think is best.

I'm sure using the xml page is faster than loading the real page like all these previous ones are.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:53 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05483 seconds
  • Memory Usage 2,396KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (9)bbcode_php
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (1)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete