Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: smirre - tammikuu 11, 2014, 02:02:14 AP

Otsikko: Steam Ingame/Online/Offline Status
Kirjoitti: smirre - tammikuu 11, 2014, 02:02:14 AP
Hello again!

I would want a modification made for Steamusers on my website. I have an older version of
php-fusion addon that let me have this status on my old website, and its great to have.

Here you have the code from my old "viewthread" in php-fusion.


   $result = dbquery(
      "SELECT p.forum_id, p.thread_id, p.post_id, p.post_message, p.post_showsig, p.post_smileys, p.post_author,
      p.post_datestamp, p.post_ip, p.post_ip_type, p.post_edituser, p.post_edittime, p.post_editreason,
      u.user_id, u.user_name, u.user_status, u.user_avatar, u.user_level, u.user_posts, u.user_groups, u.user_joined, u.user_steam,
      ".($user_field['user_sig'] ? " u.user_sig," : "").($user_field['user_web'] ? " u.user_web," : "")."
      u2.user_name AS edit_name, u2.user_status AS edit_status
      FROM ".DB_POSTS." p
      LEFT JOIN ".DB_USERS." u ON p.post_author = u.user_id
      LEFT JOIN ".DB_USERS." u2 ON p.post_edituser = u2.user_id AND post_edituser > '0'
      WHERE p.thread_id='".$_GET['thread_id']."' AND post_hidden='0'
      ORDER BY post_datestamp LIMIT ".$_GET['rowstart'].",$posts_per_page"
   );
   if (iMOD) { echo "<form name='mod_form' method='post' action='".FUSION_SELF."?thread_id=".$_GET['thread_id']."&amp;rowstart=".$_GET['rowstart']."'>\n"; }
   echo "<table cellpadding='0' cellspacing='1' width='100%' class='tbl-border forum_thread_table'>\n";
   $numrows = dbrows($result); $current_row = 1; $colorbox_rel = array(); $edit_reason = false;
   while ($data = dbarray($result)) {
      $message = $data['post_message'];
      if ($data['post_smileys']) { $message = parsesmileys($message); }
      if ($current_row == 1) {
         echo "<tr>\n<td colspan='2' class='tbl2 forum-caption'>\n<div style='float:right' class='small'>";
         if (iMEMBER && $settings['thread_notify']) {
            if (dbcount("(thread_id)", DB_THREAD_NOTIFY, "thread_id='".$_GET['thread_id']."' AND notify_user='".$userdata['user_id']."'")) {
               $result2 = dbquery("UPDATE ".DB_THREAD_NOTIFY." SET notify_datestamp='".time()."', notify_status='1' WHERE thread_id='".$_GET['thread_id']."' AND notify_user='".$userdata['user_id']."'");
               echo "<a href='postify.php?post=off&amp;forum_id=".$fdata['forum_id']."&amp;thread_id=".$_GET['thread_id']."'>".$locale['515']."</a>";
            } else {
               echo "<a href='postify.php?post=on&amp;forum_id=".$fdata['forum_id']."&amp;thread_id=".$_GET['thread_id']."'>".$locale['516']."</a>";
            }
         }
         echo "&nbsp;<a href='".BASEDIR."print.php?type=F&amp;thread=".$_GET['thread_id']."&amp;rowstart=".$_GET['rowstart']."'><img src='".get_image("printer")."' alt='".$locale['519']."' title='".$locale['519']."' style='border:0;vertical-align:middle' /></a></div>\n";
         add_to_title($locale['global_201'].$fdata['thread_subject']);
         echo "<div style='position:absolute' class='forum_thread_title'><!--forum_thread_title--><strong>".$fdata['thread_subject']."</strong></div>\n</td>\n</tr>\n";
      }
      echo "<!--forum_thread_prepost_".$current_row."-->\n";
      if ($current_row > 1) { echo "<tr>\n<td colspan='2' class='tbl1 forum_thread_post_space' style='height:10px'></td>\n</tr>\n"; }
      echo "<tr>\n<td class='tbl2 forum_thread_user_name' style='width:140px'><!--forum_thread_user_name-->".profile_link($data['user_id'], $data['user_name'], $data['user_status'])."</td>\n";
      echo "<td class='tbl2 forum_thread_post_date'>\n";
      echo "<div style='float:right' class='small'>";
      echo "<a href='#top'><img src='".get_image("up")."' alt='".$locale['541']."' title='".$locale['542']."' style='border:0;vertical-align:middle' /></a>\n";
      echo "&nbsp;<a href='#post_".$data['post_id']."' name='post_".$data['post_id']."' id='post_".$data['post_id']."'>#".($current_row+$_GET['rowstart'])."</a>";
      echo "&nbsp;<a href='".BASEDIR."print.php?type=F&amp;thread=".$_GET['thread_id']."&amp;post=".$data['post_id']."&amp;nr=".($current_row+$_GET['rowstart'])."'><img src='".get_image("printer")."' alt='".$locale['519a']."' title='".$locale['519a']."' style='border:0;vertical-align:middle' /></a></div>\n";
      echo "<div class='small'>".$locale['505'].showdate("forumdate", $data['post_datestamp'])."</div>\n";
      echo "</td>\n";
      echo "</tr>\n<tr>\n<td valign='top' class='tbl2 forum_thread_user_info' style='width:140px'>\n";
      if ($data['user_avatar'] && file_exists(IMAGES."avatars/".$data['user_avatar']) && $data['user_status']!=6 && $data['user_status']!=5) {
         echo "<img src='".IMAGES."avatars/".$data['user_avatar']."' alt='".$locale['567']."' /><br /><br />\n";
      } else {
         echo "<img src='".IMAGES."avatars/noavatar100.png' alt='".$locale['567']."' /><br /><br />\n";
      }
      echo "<span class='small'>";
      if ($data['user_level'] >= 102) {
         echo $settings['forum_ranks'] ? show_forum_rank($data['user_posts'], $data['user_level'], $data['user_groups']) : getuserlevel($data['user_level']);
      } else {
         $is_mod = false;
         foreach ($mod_groups as $mod_group) {
            if (!$is_mod && preg_match("(^\.{$mod_group}$|\.{$mod_group}\.|\.{$mod_group}$)", $data['user_groups'])) {
               $is_mod = true;
            }
         }
         if ($settings['forum_ranks']) {
            echo $is_mod ? show_forum_rank($data['user_posts'], 104, $data['user_groups']) : show_forum_rank($data['user_posts'], $data['user_level'], $data['user_groups']);
         } else {
            echo $is_mod ? $locale['userf1'] : getuserlevel($data['user_level']);
         }
      }
      echo "</span><br /><br />\n";
      echo "<!--forum_thread_user_info--><span class='small'><strong>".$locale['502']."</strong> ".$data['user_posts']."</span><br />\n";
      echo "<span class='small'><strong>".$locale['504']."</strong> ".showdate("shortdate", $data['user_joined'])."</span><br />\n";     
      //User Steam Community status start
      if ($data['user_steam']) {
         $id = "".$data['user_steam'].""; // Kollar upp STEAM ID som anv?ndaren fyllt i sin profil
         $xml = @simplexml_load_file("http://steamcommunity.com/profiles/".$id."/?xml=1");
      switch($xml->onlineState){
      case "online":
         echo "<strong>Steam:</strong> <span class=\"steam_on\"><a href='http://steamcommunity.com/profiles/".$data['user_steam']."/' target='_blank'><strong>Online</strong></a></span>";
      break;
     case "in-game":
         echo "<strong>Steam:</strong> <span class=\"steam_ing\"><a href='http://steamcommunity.com/profiles/".$data['user_steam']."/' target='_blank'><span style='color:#8bc53f;'><strong>".$xml->stateMessage."</strong></span></a></span>";
      break;
      default:
         echo "<strong>Steam:</strong> <span class=\"steam_off\"><a href='http://steamcommunity.com/profiles/".$data['user_steam']."/' target='_blank'><span style='color:#6f9fc8'><strong>Offline</strong></span></a></span>";
      break;
   }   
   
      echo "";
}
      else {
      echo "<strong>Steam:</strong> N/A";
}
      //User Steam Community status end




Code above generates the text in theese pictures, in the forum.
So, is it possible to make this directly in SMF too or can it be made as an addon instaed?
The last one should be easier for the most ppl I think?! I use vers. 2.0.6. :)

Many regards

Smirre
Otsikko: Re: Steam Ingame/Online/Offline Status
Kirjoitti: Illori - tammikuu 11, 2014, 06:47:01 AP
since the files you have attached do not have a defined license you are not allowed to attach them here, or distribute them in anyway. they have been removed from your post.
Otsikko: Re: Steam Ingame/Online/Offline Status
Kirjoitti: smirre - tammikuu 11, 2014, 12:06:09 IP
Ok, sry about that. Never crossed my mind. But if we jump to the other part instaed.
Can it be done for 2.0.6, since I cannot install the earlier versions even if I change my
version to an emulated version? I have another addon that is emulated before this
one, and therefor it says I cannot & exits the installation.

Regards

Smirre
Otsikko: Re: Steam Ingame/Online/Offline Status
Kirjoitti: smirre - tammikuu 12, 2014, 09:55:06 AP
Added some pictures in my first post, so it´s easier for you to picture how
I want it to be presented. If someone can modify the code to work under
SMF 2.0.6, I would be so happy! :D

//Smirre
Otsikko: Re: Steam Ingame/Online/Offline Status
Kirjoitti: smirre - tammikuu 16, 2014, 12:07:05 IP
almost 500 viewers and only 1 replay against the attachment..Gives me the chill.
Guess this CMS wasn´t worth my time.

Have a good one, tjaoo!