TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 334
  • Total: 334

[Block] Random User Block - New

Started by JayBachatero, October 22, 2007, 07:11:32 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Zetan

Remove the php tags..

Delete the first and last line of the script:

<?php

and
?>

alving

thanks!  another thing, guys.  what if i want the avatars to be resized to 65px x 65px?  can you please show me what and where to add this?

Zetan

#22
Thats for a different topic, and is a question for SMF..

But, Admin > Forum/Attachments and Avatars > Avatar Settings

is where you can find the options for avatars.


Ignore that.. I just realised you were refering to the avatars for this snippit  :buck2:

IchBin

The avatar for this snippet will use the one from the members context. It will be controlled by SMF's settings for avatars. If you put in the custom avatar you'll need to size that one to your needed settings.

alving

ichbin,

i'm using the dilbermc theme and one thing i noticed was that eventhough i specified 65px by 65 px for avatar size in smf, the theme seems to be resizing it to a smaller version..

IchBin

Then you should probably seek help from the theme author if his theme is doing that.

JayBachatero

Quote from: alving on October 24, 2007, 09:36:58 AM
thanks!  another thing, guys.  what if i want the avatars to be resized to 65px x 65px?  can you please show me what and where to add this?

Code (find) Select

', empty($member['avatar']['image']) ? '<img src="' . $avatarImage . '" />' : $member['avatar']['image'], '<br />


Code (replace) Select

', empty($member['avatar']['image']) ? '<img src="' . $avatarImage . '" />' : str_replace('class="avatar"', 'width="65" height="65" class="avatar"', $member['avatar']['image']), '<br />

wilsy

#27
Hi,

I have this great block but it's also adding the latest two members, so if I limit it to seven, it will display nine (seven random and the two latest members).

I have the tops stats block and the problem is linked to it as when I turn this block off my random members block returns to the correct number.

My top stats block code is below, can anyone help?

global $db_prefix, $memberContext;

$count = 2;
$users = array();

$request = db_query("
SELECT ID_MEMBER FROM {$db_prefix}members WHERE is_activated = 1 ORDER BY ID_MEMBER DESC LIMIT ".$count, __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($request)) {
$users[] = intval($row['ID_MEMBER']);
}

loadMemberData($users);
echo'<table border="1" width="100%" id="table1" cellpadding="2" style="border-collapse: collapse">
<tr><td  bgcolor="#FF9900" width="100"><font color="#FFFFFF" face="Verdana" size="2"><b>Newest Members</b></font></td><td bgcolor="#660066" width="150"><font color="#FFFFFF" face="Verdana" size="2"><b>Top 10 Posters</b></font></td><td  bgcolor="#336699" width="150"><font color="#FFFFFF" face="Verdana" size="2"><b>This Weeks Top Posters</b></font></td><td  bgcolor="#00CC33" width="150"><font color="#FFFFFF" face="Verdana" size="2"><b>This Months Birthdays</b></font></td><td bgcolor="#660066" width="150"><font color="#FFFFFF" face="Verdana" size="2"><b>Top Gamers</b></font></td></tr><tr>
<td>';
$i = 0;
foreach($users as $user_id) {
if ($i > 0) echo '<hr>';
$i++;

loadMemberContext($user_id);

if (!empty($memberContext[$user_id]['avatar']['image']))
echo '<div align="center">'.$memberContext[$user_id]['avatar']['image'].'<BR>'.$memberContext[$user_id]['link'].'</div>';
else
echo '<div align="center"><img src="http://www.rewindlancs.com/forum/images/noava.gif" height=80 widh=80><BR><BR>'.$memberContext[$user_id]['link'].'</div>';
}

$numberofposters = 10; // You can change this to however many you want

require_once "SSI.php";
$top_posters = ssi_topPoster($numberofposters, "return");
echo'</td><td>';
foreach ($top_posters as $poster)
{
  echo $poster['link'] , ' (', $poster['posts'] , ')<br />';
}
echo'</td><td>';

global $db_prefix, $scripturl;
$count= array();
$poster_number = array();
$query = db_query(
    "SELECT realName, {$db_prefix}messages.ID_MEMBER, ID_GROUP
     FROM {$db_prefix}members
     JOIN {$db_prefix}messages
     ON {$db_prefix}members.ID_MEMBER = {$db_prefix}messages.ID_MEMBER
     
     ORDER BY posterTime DESC
     LIMIT 100", __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($query))
{
  if (!isset($count[$row['realName']]))
    $count[$row['realName']] = 0;
  ++$count[$row['realName']];
    $poster_number[$row['realName']] = $row['ID_MEMBER'];
}

$random = array_rand($count, count($count));
echo '<div style="text-align: center">';
foreach ($random as $value)
{
  $fsize = $count[$value] + 7;
  if ($fsize > 13)
    $fsize = 13;
  elseif ($fsize < 7)
    $fsize = 7;
    $name = str_replace(" ",'·',$value);
  echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $poster_number[$value] . '">
          <span style="font-size:' . $fsize . 'pt;">' . $name . '</span></a> ';
}

echo '</div></td><td>';
global $db_prefix, $scripturl;

echo '
  <div style="padding: 4px; font-weight: bold;">';
// echo $title;
echo '
  </div>
  <div class="windowbg" style="padding: 4px; ">';
      $month = date('m');
      $month_number = '-' . $month . '-';
      $query = db_query(
    "SELECT ID_MEMBER, memberName, birthdate
     FROM {$db_prefix}members
     WHERE birthdate LIKE '%$month_number%'
     AND birthdate NOT LIKE '0001-01-01'
     ORDER BY memberName", __FILE__, __LINE__);
  if(db_affected_rows() != 0)
  {
    $birthdays = array();
    $member = array();
    while ($row = mysql_fetch_assoc($query))
    {
       $day = substr($row['birthdate'],8,2);
       $birthdays[$row['memberName']] =  $day;
       $member[$row['memberName']] = $row['ID_MEMBER'];
    }
    asort($birthdays);
    foreach ($birthdays as $key => $value)
    {
      echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $member[$key] . '">' . $key . '</a> (' . $value . '.' . $month . ')<br />';
   }
}
else
  echo 'No birthdays this month';

echo'</td><td>';

//-------START-------------
/*
|----------------------------------
SMF ARCADE SCROLLING CHAMPS BLOCK for SMFARCADE V2
by Eric Lawson
|----------------------------------
Made for TinyPortal and SMF forum

*/
//Upload a pic called arcade_block.gif (you can use you own gif - just name it arcade_block.gif)
//to your Themes/<themename>/images/ folder

// -- SETUP EDITS ---

$no = 10; //number of top players to show

// --LANGUAGE EDITS --
$txtplay = "The Top Players"; // change "The Top Players" to your language
$txtwin = "Number Of Wins :";// change "Number Of Wins :" to your language
$txtlate = "Latest High Score by ";// change "Latest High Score set by" to your language
$txtwit = "with ";// change "with" to your language
$txton = "on ";// change "on" to your language

global $scripturl,$sourcedir,$boardurl,$db_prefix,$modSettings;
require_once($sourcedir.'/ArcadeStats.php');

//Get newest champ or die
$sql = "SELECT game.ID_GAME, game.gameName, game.thumbnail, game.gameDirectory,
        IFNULL(mem.ID_MEMBER, 0) AS ID_MEMBER, IFNULL(mem.realName,'') AS realName, score.score
        FROM {$db_prefix}arcade_scores AS score
        LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = score.ID_MEMBER)
        JOIN {$db_prefix}arcade_games AS game ON (game.ID_GAME = score.ID_GAME)
        ORDER BY `championFrom` DESC
        LIMIT 0,1";
if(!($result = db_query($sql,__FILE__,__LINE__)))
{
die("Could not get the newest champ");
}
$row = mysql_fetch_assoc($result);
mysql_free_result($result);

if(isset($row['gameDirectory']))
{
$row['gameDirectory']=$row['gameDirectory']."/";
}

//newest champ details
$playerid = $row['ID_MEMBER'];
$player = $row['realName'];
$game_id = $row['ID_GAME'];
$game_name = $row['gameName'];
$score = $row['score'];
$game_pic = $modSettings['gamesUrl'].$row['gameDirectory'].$row['thumbnail'];

$bp=ArcadeStats_BestPlayers($no);

$score_poss=0; //players position

echo '
<script type="text/javascript">';

/***********************************************
* Cross browser Marquee II- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
//Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
//Specify marquee scroll speed (larger is faster 1-10)
//Pause marquee onMousever (0=no. 1=yes)?
echo '
var delayb4scrollx=2000
var marqueespeedx=1
var pauseitx=1';

////NO NEED TO EDIT BELOW THIS LINE////////////
echo '
var copyspeedx=marqueespeedx
var pausespeedx=(pauseitx==0)? copyspeedx: 0
var actualheightx=\'\'';
echo '
function scrollmarqueex(){
if (parseInt(cross_marqueex.style.top)>(actualheightx*(-1)+8))
cross_marqueex.style.top=parseInt(cross_marqueex.style.top)-copyspeedx+"px"
else
cross_marqueex.style.top=parseInt(marqueeheightx)+8+"px"
}

function initializemarqueex(){
cross_marqueex=document.getElementById("vmarqueex")
cross_marqueex.style.top=0
marqueeheightx=document.getElementById("marqueecontainerx").offsetHeight
actualheightx=cross_marqueex.offsetHeight
if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){
cross_marqueex.style.height=marqueeheightx+"px"
cross_marqueex.style.overflow="scroll"
return
}
setTimeout(\'lefttime=setInterval("scrollmarqueex()",30)\', delayb4scrollx)
}

if (window.addEventListener)
window.addEventListener("load", initializemarqueex, false)
else if (window.attachEvent)
window.attachEvent("onload", initializemarqueex)
else if (document.getElementById)
window.onload=initializemarqueex

</script>';

echo '<table width="100%">
<tr>
<td align="center">

</td>
</tr>
</table>
<div id="marqueecontainerx" style="position: relative; width: 95%; height:200px; overflow: hidden; border: 0px; padding: 2px; padding-left: 4px;" onmouseover="copyspeedx=pausespeedx" onmouseout="copyspeedx=marqueespeedx">
<div id="vmarqueex" style="position: absolute; width: 98%;">
<div align="center">
<a href="',$scripturl,'?action=arcade;sa=play;game=',$game_id,'"><img src="',$game_pic,'" border="0" alt="',$game_name,'" width="60" height="60"/></a>
<br />',$txtlate,'<br />
<a href="',$scripturl,'?action=profile;u=',$playerid,'">',$player,'</a>
<br/>',$txtwit,' ',$score,' ',$txton,'<br />',$game_name,'
<br />------------------<br />',$txtplay,'<br /><br />';
foreach ($bp as $out)
{
$score_poss++;
echo '',$score_poss,' - ',$out['link'],'<br />',$txtwin,' ',$out['champions'],'
     <br /><br />';
};
echo '</div>
</div>
</div>';

//---------END--------------

echo'</td></tr>
</table>';


and my random members code is: -

global $db_prefix, $memberContext;

// How many members we want?
$members_limit = 7;
// Just special groups get to be part of the block.
// To select Admins and moderators would be like $groups = array(1, 2);
$groups = array();
// Avatar images.
$avatarImage = 'http://rewindlancs.com/forum/images/noava.gif';

$group_clause = empty($groups) ? '1' : 'ID_GROUP IN(' . implode(',', $groups) . ')';

// Lets get the ID's of the members we want.
$request = db_query("
SELECT ID_MEMBER
FROM {$db_prefix}members
WHERE $group_clause
ORDER BY RAND()
LIMIT $members_limit", __FILE__, __LINE__);
$members = array();
while ($row = mysql_fetch_assoc($request))
$members[] = $row['ID_MEMBER'];
mysql_free_result($request);

// Load the data for these members.
loadMemberData($members);

// Now get the context.
foreach ($members as $member)
loadMemberContext($member);

echo '
<table ALIGN="center">
<tr>';
foreach ($memberContext as $member)
{
echo '
<td><center>
', empty($member['avatar']['image']) ? '<img src="' . $avatarImage . '" />' : str_replace('class="avatar"', 'width="65" height="65" class="avatar"', $member['avatar']['image']), '<br />
', $member['link'], '
</center></td>';
}
echo '
</tr>
</table>';


Regards,

Wilsy.

Ianedres

Shared variables between the two scripts? Second script inherits the value left behind by the first?

JPDeni

It's the fact that the $memberContext variable is global in both blocks, without being cleared. You could try adding


$memberContext = array();


at the end of your first block, after everything is printed out.

This website is proudly hosted on Crocweb Cloud Website Hosting.