Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions plugins/steamprofile/class.steamprofile.plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ private function CheckAuthentication($OpenIDRequest) {
*
* @param Gdn_Controller $Sender
*/
public function ProfileController_SteamProfileOpenID_Create(&$Sender) {
public function ProfileController_SteamProfileOpenID_Create($Sender) {
// Grabbing the $_GET array, processed by our framework
$RequestGet = Gdn::Request()->Get();
//die( '<pre>' . print_r($RequestGet, true) . '</pre>' );

// Nabbing the mode of the OpenID request, if any
$OpenIDMode = GetValue('openid_mode', $RequestGet);
Expand Down Expand Up @@ -146,7 +147,8 @@ public function ProfileController_EditMyAccountAfter_Handler($Sender) {

// Assisnging the retrieved data to the form field and loading up the form field view
$Sender->SetData('SteamID64', $SteamID64);
$Sender->Render($this->GetView('steamcommunityid.php'));
//$Sender->Render($this->GetView('steamcommunityid.php'));
include($this->GetView('steamcommunityid.php'));
}

/**
Expand Down
26 changes: 13 additions & 13 deletions plugins/steamprofile/design/style.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
dt.SteamMemberSince { }
dd.SteamMemberSince { }
dt.SteamPlayedGame { text-align: center; }
dd.SteamPlayedGame { }
dt.SteamPlayingTime { }
dd.SteamPlayingTime { }
dt.SteamRating { }
dd.SteamRating { }
dt.SteamUpdated { }
dd.SteamUpdated { }

.SteamAvatar { text-align: center; }
.SteamBasicInfo { }
dt.SteamMemberSince { }
dd.SteamMemberSince { }
dt.SteamPlayedGame { text-align: center; }
dd.SteamPlayedGame { }
dt.SteamPlayingTime { }
dd.SteamPlayingTime { }
dt.SteamRating { }
dd.SteamRating { }
dt.SteamUpdated { }
dd.SteamUpdated { }
.SteamAvatar { text-align: center; }
.SteamBasicInfo { }
.SteamProfile { }
118 changes: 59 additions & 59 deletions plugins/steamprofile/models/class.steamprofilemodel.php
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
<?php if (!defined('APPLICATION')) exit();

class SteamProfileModel extends Gdn_Model {

/**
* Checks the local Steam Profile cache for existing user profile
* information. If found, serve it up. If not found, attempt to fetch
* it from the Steam Community website.
*
* @param string $SteamID A sixty-four bit integer representing the target Steam ID
* @return mixed SimpleXMLElement on success, FALSE on failure
*/
public function GetByID($SteamID) {
// Verify that the ID is only digits and that we have SimpleXML capabilities
if (preg_match('/\d+/', $SteamID) && function_exists('simplexml_load_file')) {
/**
* Check to see if there are any cached profile records matching the ID and are
* more than five minutes old
*/
$CachedProfile = $this->SQL
->Select()
->From('SteamProfileCache')
->Where('SteamID64', $SteamID)
->Where('DateRetrieved >', Gdn_Format::ToDateTime(strtotime('-5 minutes')))
->Get()
->Firstrow();

// Any cached entries?
if ($CachedProfile) {
// ...if so, load up the profile XML into a SimpleXMLElement...
$CommunityProfile = simplexml_load_string($CachedProfile->ProfileXML, 'SimpleXMLElement', LIBXML_NOCDATA);
// set the DateRetrieved of the cached record and go
$CommunityProfile->DateRetrieved = $CachedProfile->DateRetrieved;
return $CommunityProfile;
} else {
// ...if not, attempt to grab the profile's XML
$CommunityProfile = simplexml_load_file('http://steamcommunity.com/profiles/'.$SteamID.'?xml=1', 'SimpleXMLElement', LIBXML_NOCDATA);

// Were we able to successfully fetch the profile?
if ($CommunityProfile && !isset($CommunityProfile->error)) {
// ...if so, insert or update the profile XML into the cache table
$this->SQL->Replace(
'SteamProfileCache',
array('SteamID64' => $SteamID, 'ProfileXML' => $CommunityProfile->asXML(), 'DateRetrieved' => Gdn_Format::ToDateTime()),
array('SteamID64' => $SteamID),
TRUE
);

// Set the DateRetrieved record to now and go
$CommunityProfile->DateRetrieved = Gdn_Format::ToDateTime();
return $CommunityProfile;
}
}
}

// If we hit this point, something bad has happened.
return FALSE;
}
}
<?php if (!defined('APPLICATION')) exit();
class SteamProfileModel extends Gdn_Model {
/**
* Checks the local Steam Profile cache for existing user profile
* information. If found, serve it up. If not found, attempt to fetch
* it from the Steam Community website.
*
* @param string $SteamID A sixty-four bit integer representing the target Steam ID
* @return mixed SimpleXMLElement on success, FALSE on failure
*/
public function GetByID($SteamID) {
// Verify that the ID is only digits and that we have SimpleXML capabilities
if (preg_match('/\d+/', $SteamID) && function_exists('simplexml_load_file')) {
/**
* Check to see if there are any cached profile records matching the ID and are
* more than five minutes old
*/
$CachedProfile = $this->SQL
->Select()
->From('SteamProfileCache')
->Where('SteamID64', $SteamID)
->Where('DateRetrieved >', Gdn_Format::ToDateTime(strtotime('-5 minutes')))
->Get()
->Firstrow();
// Any cached entries?
if ($CachedProfile) {
// ...if so, load up the profile XML into a SimpleXMLElement...
$CommunityProfile = simplexml_load_string($CachedProfile->ProfileXML, 'SimpleXMLElement', LIBXML_NOCDATA);
// set the DateRetrieved of the cached record and go
$CommunityProfile->DateRetrieved = $CachedProfile->DateRetrieved;
return $CommunityProfile;
} else {
// ...if not, attempt to grab the profile's XML
$CommunityProfile = simplexml_load_file('http://steamcommunity.com/profiles/'.$SteamID.'?xml=1', 'SimpleXMLElement', LIBXML_NOCDATA);
// Were we able to successfully fetch the profile?
if ($CommunityProfile && !isset($CommunityProfile->error)) {
// ...if so, insert or update the profile XML into the cache table
$this->SQL->Replace(
'SteamProfileCache',
array('SteamID64' => $SteamID, 'ProfileXML' => $CommunityProfile->asXML(), 'DateRetrieved' => Gdn_Format::ToDateTime()),
array('SteamID64' => $SteamID),
TRUE
);
// Set the DateRetrieved record to now and go
$CommunityProfile->DateRetrieved = Gdn_Format::ToDateTime();
return $CommunityProfile;
}
}
}
// If we hit this point, something bad has happened.
return FALSE;
}
}
66 changes: 33 additions & 33 deletions plugins/steamprofile/views/panel.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
<?php if (!defined('APPLICATION')) exit(); ?>
<div class="Box Steam">
<h4>Steam Profile</h4>
<dl>
<dt class="SteamAvatar"><img alt="Avatar Icon" src="<?php echo $this->Data('SteamProfile')->avatarIcon; ?>" /></dt>
<dd class="SteamCard">
<?php echo Gdn_Theme::Link('http://steamcommunity.com/profiles/'.$this->Data('SteamProfile')->steamID64, $this->Data('SteamProfile')->steamID, '<a href="%url" class="%class" target="_blank" >%text</a>'); ?><br />
<?php echo Gdn_Format::Text($this->Data('SteamProfile')->stateMessage); ?>
</dd>
<?php if ($this->Data('SteamProfile')->privacyState == 'public'): ?>
<dt class="SteamMemberSince">Member Since</dt>
<dd class="SteamMemberSince"><?php echo Gdn_Format::Text($this->Data('SteamProfile')->memberSince); ?></dd>
<dt class="SteamRating">Steam Rating</dt>
<dd class="SteamRating"><?php echo Gdn_Format::Text($this->Data('SteamProfile')->steamRating); ?></dd>
<dt class="SteamPlayingTime">Playing Time</dt>
<dd class="SteamPlayingTime"><?php echo Gdn_Format::Text($this->Data('SteamProfile')->hoursPlayed2Wk.' hrs past 2 weeks'); ?></dd>
<?php if ($this->Data('MostPlayedGame', FALSE)) : ?>
<dt class="SteamPlayedGame"><img alt="<?php echo Gdn_Format::Text($this->Data('MostPlayedGame')->gameName); ?>" src="<?php echo $this->Data('MostPlayedGame')->gameIcon; ?>" /></dt>
<dd class="SteamPlayedGame">
<?php echo Gdn_Format::Text($this->Data('MostPlayedGame')->gameName); ?><br />
<?php echo Gdn_Format::Text($this->Data('MostPlayedGame')->hoursPlayed.' hrs / '.$this->Data('MostPlayedGame')->hoursOnRecord).' hrs'; ?></br>
<?php echo Gdn_Theme::Link('http://steamcommunity.com/profiles/'.$this->Data('SteamProfile')->steamID64.'/stats/'.$this->Data('MostPlayedGame')->statsName, 'View stats', '<a href="%url" class="%class" target="_blank" >%text</a>'); ?>
</dd>
<?php endif; ?>
<dt></dt>
<dd><?php echo Gdn_Theme::Link('http://steamcommunity.com/profiles/'.$this->Data('SteamProfile')->steamID64.'/games?tab=all', 'View All Games', '<a href="%url" class="%class" target="_blank" >%text</a>'); ?></dd>
<dt></dt>
<dd><?php echo Gdn_Theme::Link('http://steamcommunity.com/profiles/'.$this->Data('SteamProfile')->steamID64.'/wishlist', 'View Wishlist', '<a href="%url" class="%class" target="_blank" >%text</a>'); ?></dd>
<?php endif; ?>
<dt class="SteamUpdated">Updated</dt>
<dd class="SteamUpdated"><?php echo Gdn_Format::FuzzyTime($this->Data('SteamProfile')->DateRetrieved, TRUE); ?></dd>
</dl>
</div>
<?php if (!defined('APPLICATION')) exit(); ?>
<div class="Box Steam">
<h4>Steam Profile</h4>
<dl>
<dt class="SteamAvatar"><img alt="Avatar Icon" src="<?php echo $this->Data('SteamProfile')->avatarIcon; ?>" /></dt>
<dd class="SteamCard">
<?php echo Gdn_Theme::Link('http://steamcommunity.com/profiles/'.$this->Data('SteamProfile')->steamID64, $this->Data('SteamProfile')->steamID, '<a href="%url" class="%class" target="_blank" >%text</a>'); ?><br />
<?php echo Gdn_Format::Text($this->Data('SteamProfile')->stateMessage); ?>
</dd>
<?php if ($this->Data('SteamProfile')->privacyState == 'public'): ?>
<dt class="SteamMemberSince">Member Since</dt>
<dd class="SteamMemberSince"><?php echo Gdn_Format::Text($this->Data('SteamProfile')->memberSince); ?></dd>
<dt class="SteamRating">Steam Rating</dt>
<dd class="SteamRating"><?php echo Gdn_Format::Text($this->Data('SteamProfile')->steamRating); ?></dd>
<dt class="SteamPlayingTime">Playing Time</dt>
<dd class="SteamPlayingTime"><?php echo Gdn_Format::Text($this->Data('SteamProfile')->hoursPlayed2Wk.' hrs past 2 weeks'); ?></dd>
<?php if ($this->Data('MostPlayedGame', FALSE)) : ?>
<dt class="SteamPlayedGame"><img alt="<?php echo Gdn_Format::Text($this->Data('MostPlayedGame')->gameName); ?>" src="<?php echo $this->Data('MostPlayedGame')->gameIcon; ?>" /></dt>
<dd class="SteamPlayedGame">
<?php echo Gdn_Format::Text($this->Data('MostPlayedGame')->gameName); ?><br />
<?php echo Gdn_Format::Text($this->Data('MostPlayedGame')->hoursPlayed.' hrs / '.$this->Data('MostPlayedGame')->hoursOnRecord).' hrs'; ?></br>
<?php echo Gdn_Theme::Link('http://steamcommunity.com/profiles/'.$this->Data('SteamProfile')->steamID64.'/stats/'.$this->Data('MostPlayedGame')->statsName, 'View stats', '<a href="%url" class="%class" target="_blank" >%text</a>'); ?>
</dd>
<?php endif; ?>
<dt></dt>
<dd><?php echo Gdn_Theme::Link('http://steamcommunity.com/profiles/'.$this->Data('SteamProfile')->steamID64.'/games?tab=all', 'View All Games', '<a href="%url" class="%class" target="_blank" >%text</a>'); ?></dd>
<dt></dt>
<dd><?php echo Gdn_Theme::Link('http://steamcommunity.com/profiles/'.$this->Data('SteamProfile')->steamID64.'/wishlist', 'View Wishlist', '<a href="%url" class="%class" target="_blank" >%text</a>'); ?></dd>
<?php endif; ?>
<dt class="SteamUpdated">Updated</dt>
<dd class="SteamUpdated"><?php echo Gdn_Format::FuzzyTime($this->Data('SteamProfile')->DateRetrieved, TRUE); ?></dd>
</dl>
</div>
40 changes: 20 additions & 20 deletions plugins/steamprofile/views/steamcommunityid.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?php if (!defined('APPLICATION')) exit(); ?>
<li class="SteamProfile">
<?php
echo $this->Form->Label('Steam Profile');

// Do we happen to already have a Steam ID for our current user?
if ($this->Data('SteamID64')) {
// If so, we just output it. Nothing fancy.
echo '<div>'.T('Steam ID').': '.Gdn_Format::Text($this->Data('SteamID64')).'</div>';
} else {
// If not, we drop in a button and set the stage for OpenID magic.
echo Anchor(
Img('plugins/steamprofile/design/images/sits_small.png', array('alt' => 'Sign in through Steam')),
$this->Data('SteamAuthenticationUrl'),
'',
array('title' => 'Sign in through Steam')
);
}
?>
</li>
<?php if (!defined('APPLICATION')) exit(); ?>
<li class="SteamProfile">
<?php
echo $Sender->Form->Label('Steam Profile');
// Do we happen to already have a Steam ID for our current user?
if ($Sender->Data('SteamID64')) {
// If so, we just output it. Nothing fancy.
echo '<div>'.T('Steam ID').': '.Gdn_Format::Text($Sender->Data('SteamID64')).'</div>';
} else {
// If not, we drop in a button and set the stage for OpenID magic.
echo Anchor(
Img('plugins/steamprofile/design/images/sits_small.png', array('alt' => 'Sign in through Steam')),
$Sender->Data('SteamAuthenticationUrl'),
'',
array('title' => 'Sign in through Steam')
);
}
?>
</li>