Jump to content


Welcome block for v2.2.0


  • You cannot reply to this topic
25 replies to this topic

#1 misterc

    Member

  • Members
  • PipPip
  • 24 posts

Posted 10 January 2007 - 06:34 AM

I had some spare time last night (couldn't sleep) and got to work on getting a working Welcome block for Unreal Portal v2.2.0. There are some differences to the original such as the title doesnt say 'Welcome JoeBloggs', just 'Welcome' and the current time/date isn't working as it was giving me errors, it was 2am in the morning when I wrote the code so patience was a bit short :) You do have the added extra of having avatars in the welcome block which was not in the original code, you had to modify some code to do this. I will try and get the missing bits added soon.

This is how my block looks on my local test forum, ignore the 0 posts and 0 topics, its where I haven't posted anything new on the forum since the last visit :)

Posted Image

I wrote this in mind with it being on top of the middle column but the code is fairly easy to change if you want different formatting for other locations. From the Admin page, goto Portal -> Add Custom Blocks. Then fill out the first two details and copy and paste the below code into the third field.

<?php

if ($this->ipsclass->member['id'])
{
// for members
$welcometext ="<table cellpadding='0' cellspacing='0' border='0' width='100%' align='center'><tr><td align='left'>";

// avatar (1st column)
$welcomequery1 = $this->ipsclass->DB->query("SELECT * FROM ibf_member_extra WHERE id = " . $this->ipsclass->member['id']);
$avatar = $this->ipsclass->DB->fetch_row($welcomequery1);
$data['avatar'] = $this->ipsclass->get_avatar($avatar['avatar_location'], 1,$avatar['avatar_size'], $avatar['avatar_type']);
$welcometext .= $data['avatar'];
$welcometext .="</td>";

// Member text (2nd column)
$welcometext .="<td align='left'>";
$welcometext .= "Welcome back {$this->ipsclass->member['members_display_name']}<br>";

$welcomedate= $this->ipsclass->get_date($this->ipsclass->member['last_visit'], LONG);
$welcometext .= "You last visited {$welcomedate}<br>";

$welcomequery2 = $this->ipsclass->DB->query("SELECT COUNT(DISTINCT(t.tid)) as tcnt, COUNT(DISTINCT(p.pid)) as pcnt FROM ibf_posts p, ibf_topics t WHERE p.post_date < ".time()." AND p.post_date > ".$this->ipsclass->member['last_visit']." AND p.topic_id=t.tid");
$row = $this->ipsclass->DB->fetch_row($welcomequery2);
$data['topics_since']	= $row[tcnt];
$data['posts_since']	= $row[pcnt];

$welcometext .= "There has been {$data['topics_since']} posts in {$data['posts_since']} topics since your last visit!<br>";
$welcometext .= "<a href=\"{$this->ipsclass->base_url}act=Search&CODE=getnew\">{$this->ipsclass->lang['view_new_posts']}</a><br>";
$welcometext .="</td>";

// forum stats (3rd column)
$welcometext .="<td align='left'>";
$welcometext .="Forum stats:<br>";

if ( ! is_array( $this->ipsclass->cache['stats'] ) )
{
$this->ipsclass->cache['stats'] = array();
$this->ipsclass->DB->simple_exec_query( array( 'delete' => 'cache_store', 'where' => "cs_key='stats'" ) );
$this->ipsclass->DB->do_insert( 'cache_store', array( 'cs_array' => 1, 'cs_key' => 'stats', 'cs_value' =>addslashes(serialize($this->ipsclass->cache['stats'])) ) );
}
$stats = $this->ipsclass->cache['stats'];
if ($this->users_online > $stats['most_count'])
{
$stats['most_count']	= $this->users_online;
$stats['most_date']	= time();
$this->ipsclass->DB->do_update( 'cache_store',array( 'cs_array' => 1, 'cs_value' => addslashes(serialize($stats)) ),"cs_key='stats'");
}
$total_posts = $stats['total_replies'] + $stats['total_topics'];
$total_posts= $this->ipsclass->do_number_format($total_posts);

$welcometext .= "Members: {$stats['mem_count']}, Topics {$stats['total_topics']}<br>";
$welcometext .= "Replies: {$stats['total_replies']}, Total Posts: {$total_posts}<br>";
$welcometext .= "Our newest member: <a href=\"{$this->ipsclass->base_url}showuser={$stats['last_mem_id']}\">{$stats['last_mem_name']}</a><br>";

$welcomequery3 = $this->ipsclass->DB->query("SELECT `id`,`name`,`posts` FROM ibf_members WHERE 1 ORDER BY `posts` DESC LIMIT 1");
$row = $this->ipsclass->DB->fetch_row($welcomequery3);

$welcometext .= "Top poster: <a href=\"{$this->ipsclass->base_url}showuser={$row[id]}\">{$row[name]}</a> ({$row[posts]} posts)<br>";
$welcometext .="</td></tr></table>";
}
// for guests
else
{
// first column
$welcometext ="<table cellpadding='0' cellspacing='0' border='0' width='100%' align='center'><tr><td align='left'>";
$welcometext .="Welcome Guest!<br>";
$welcometext .= "<a href=\"{$this->ipsclass->base_url}act=Search&CODE=getactive\">View all of todays active posts.</a><br>";
$welcometext .="</td>";
// second column
$welcometext .="<td align='left'>";
$welcometext .="<form action=\"{$this->ipsclass->base_url}act=Login&CODE=01\" method=\"post\" name=\"LOGIN\" onsubmit=\"return ValidateForm()\">
<input type=\"hidden\" name=\"CookieDate\" value=\"1\" checked=\"checked\" />
<table width=\"50%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td>Username:</td>
<td><input type=\"text\" size=\"15\" maxlength='150' value=\"\" name=\"UserName\" class=\"forminput\" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type=\"password\" size=\"15\" name=\"PassWord\" class=\"forminput\" /></td>
</tr>
<tr>
<td><input class=\"button\" type=\"submit\" name=\"submit\" value=\"Login\" /></td>
</tr>
</table>
</form>";
$welcometext .="<a href=\"{$this->ipsclass->base_url}act=Reg&CODE=00\">Register</a>";
$welcometext .="</td></tr></table>";
}

echo "$welcometext";
?>


While everything should work fine, I should point out I am not an expert coder so there are likely better ways of writing the code, feel free to post any changes here and I will add them to this post. If you have any problems or questions feel free to ask and I will try and answer them.
misterc - aka Guyfawkes :)
Posted Image
Emuholic - News for Wiz, Pandora, Wii, GP2X, GP32, GBA, PSP, DS and more
My Twitter

#2 redalert19882000

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts

Posted 10 January 2007 - 08:39 AM

ok you have beat me :)

But:

Parse error: parse error, unexpected '(', expecting '}' in /home/httpd/vhosts/*****/httpdocs/sources/action_public/uportal.php(846) : eval()'d code on line 18

#3 misterc

    Member

  • Members
  • PipPip
  • 24 posts

Posted 10 January 2007 - 05:08 PM

strange, it works fine on my local test server but gives the same error you got on my proper site. ill look into it and update soon.

update - seems it was being fussy with the code so i put the date in its own variable and it works fine on both servers now. I have updated the above code with the fix.
misterc - aka Guyfawkes :)
Posted Image
Emuholic - News for Wiz, Pandora, Wii, GP2X, GP32, GBA, PSP, DS and more
My Twitter

#4 Gerry

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts
  • Gender:Male
  • Location:St Helens - UK -

Posted 15 January 2007 - 08:42 AM

This does not work for me either Im afraid. :(

#5 RisingPhoenix

    Advanced Member

  • Administrators[Admin]
  • PipPipPip
  • 249 posts
  • Gender:Male
  • Location:Fort Benning, GA
  • Interests:I am currently in the US Army. I am not a coder. I am really familiar with Unreal Portal and IPB. So if it isn't in reference to something I have on my site ba4life.com then there isn't much I can do to help you.<br /><br />I am a normal user like most of you. Please don't invade my personal life by asking me questions that can already be found on this website.

Posted 27 January 2007 - 01:23 PM

It works on my board thanks. What version of PHP are you all running maybe that is what caused it not to work.

IPB Version v2.2.1 (ID: 22010)
SQL Version MYSQL (4.0.27-max-log)
PHP Version 4.3.11 (cgi-fcgi)
Posted Image
MultiGaming Clan Playing Games since 1997

#6 moto823

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 28 January 2007 - 07:27 AM

Works great on my forums. However, i did find one issue...
I got the error: Parse error: syntax error, unexpected T_STRING in /home/*****/public_html/*****/*****/sources/action_public/uportal.php(846) : eval()'d code on line 66 when i tried to put a mailto html tag in the "for guests" section. So, when a guest came on, in the welcome box it would say "welcome to bla bla bla. ect ect if you have any question email blabla at lol@lol.com(using the html <a href=mailto:> tag)
Once i took that mailto tag out, it worked again. Weird eh?



Now, as for edits i found other people can do: (Im working with coding them a bit myself, i will be sure to post anything i find.)

Anybody running a different mysql table prefix needs to edit this code. Although, strangely enough, it seemed to work fine without the edits.
However, just to be safe, if you are running a different table prefix then ibf_ then go through and change anything saying ibf_ to your table prefix.


I also found this...

The "Top Poster" shows usernames instead of display names. To make it show display names...

Find - Right above "//For Guests"
$welcometext .= "Top poster: <a href=\"{$this->ipsclass->base_url}showuser={$row[id]}\">{$row[name]}</a> ({$row[posts]} posts)<br>";
$welcometext .="</td></tr></table>";


Replace With:
$welcometext .= "Top poster: <a href=\"{$this->ipsclass->base_url}showuser={$row[id]}\">{$this->ipsclass->member['members_display_name']}</a> ({$row[posts]} posts)<br>";
$welcometext .="</td></tr></table>";


Tested and working(by me :) )


Thanks.

#7 moto823

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 28 January 2007 - 08:33 AM

Got another one. This is just a link to their user control panel in the box.

Find in //member text:
$welcometext .= "There has been {$data['topics_since']} posts in {$data['posts_since']} topics since your last visit!<br>";
$welcometext .= "<a href=\"{$this->ipsclass->base_url}act=Search&CODE=getnew\">{$this->ipsclass->lang['view_new_posts']}</a><br>";



Add below:
$welcometext .= "<a href=\"{$this->ipsclass->base_url}act=UserCP&CODE=00\">Click Here to go to your User Control Panel</a><br>";


#8 RisingPhoenix

    Advanced Member

  • Administrators[Admin]
  • PipPipPip
  • 249 posts
  • Gender:Male
  • Location:Fort Benning, GA
  • Interests:I am currently in the US Army. I am not a coder. I am really familiar with Unreal Portal and IPB. So if it isn't in reference to something I have on my site ba4life.com then there isn't much I can do to help you.<br /><br />I am a normal user like most of you. Please don't invade my personal life by asking me questions that can already be found on this website.

Posted 29 January 2007 - 07:46 PM

Awesome Work
Posted Image
MultiGaming Clan Playing Games since 1997

#9 misterc

    Member

  • Members
  • PipPip
  • 24 posts

Posted 06 February 2007 - 10:36 AM

Cool, good to see its working for some people at least. I haven't really had the time to look into it (working on a new site atm) but it could be a PHP version problem as someone mentioned. Also good to see people adding to the code, the guest version of the block looked very bare, I couldn't think of anything to put in it :)
misterc - aka Guyfawkes :)
Posted Image
Emuholic - News for Wiz, Pandora, Wii, GP2X, GP32, GBA, PSP, DS and more
My Twitter

#10 il saggio

    Advanced Member

  • Members
  • PipPipPip
  • 39 posts

Posted 12 December 2007 - 08:06 AM

It works well with ipb 2.3
But if you want to get the information on-line, rather than on 3 columns?

#11 il saggio

    Advanced Member

  • Members
  • PipPipPip
  • 39 posts

Posted 12 December 2007 - 02:39 PM

i have used this
<?php

if ($this->ipsclass->member['id'])
{
// for members
$welcometext ="<table cellpadding='0' cellspacing='0' border='0' width='100%' align='center'><tr><td align='center'>";

// avatar (1st row)
$welcomequery1 = $this->ipsclass->DB->query("SELECT * FROM ibf_member_extra WHERE id = " . $this->ipsclass->member['id']);
$avatar = $this->ipsclass->DB->fetch_row($welcomequery1);
$data['avatar'] = $this->ipsclass->get_avatar($avatar['avatar_location'], 1,$avatar['avatar_size'], $avatar['avatar_type']);
$welcometext .= $data['avatar'];
$welcometext .="</td></tr>";
$welcometext .="<tr>";
// Member text (2nd row)
$welcometext .="<td align='left'>";
$welcometext .= "Bentornato <font color=#FF3333><strong>{$this->ipsclass->member['members_display_name']}</strong></font><br>";

$welcomedate= $this->ipsclass->get_date($this->ipsclass->member['last_visit'], LONG);
$welcometext .= "Sei stato qui {$welcomedate}<br>";

$welcomequery2 = $this->ipsclass->DB->query("SELECT COUNT(DISTINCT(t.tid)) as tcnt, COUNT(DISTINCT(p.pid)) as pcnt FROM ibf_posts p, ibf_topics t WHERE p.post_date < ".time()." AND p.post_date > ".$this->ipsclass->member['last_visit']." AND p.topic_id=t.tid");
$row = $this->ipsclass->DB->fetch_row($welcomequery2);
$data['topics_since']	= $row[tcnt];
$data['posts_since']	= $row[pcnt];

$welcometext .= "Ci sono {$data['topics_since']} risposte in {$data['posts_since']} topic dalla tua ultima visita!<br>";
$welcometext .= "<a href=\"{$this->ipsclass->base_url}act=Search&CODE=getnew\">{$this->ipsclass->lang['view_new_posts']}</a><br>";

$welcometext .="</td></tr></table>";
}
// for guests
else
{
// first row
$welcometext ="<table cellpadding='0' cellspacing='0' border='0' width='100%' align='center'><tr><td align='center'>";


$welcometext .="</td></tr>";
// second row
$welcometext .="<tr><td>";
$welcometext .="Benvenuto visitatore!<br>";
$welcometext .= "<a href=\"{$this->ipsclass->base_url}act=Search&CODE=getactive\">Vedi i post di oggi.</a><br>";
$welcometext .="</td>";
// third row
$welcometext .="<tr>";
$welcometext .="<td align='left'>";
$welcometext .="<form action=\"{$this->ipsclass->base_url}act=Login&CODE=01\" method=\"post\" name=\"LOGIN\" onsubmit=\"return ValidateForm()\">
<input type=\"hidden\" name=\"CookieDate\" value=\"1\" checked=\"checked\" />
<table width=\"30%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td>Username:</td>
<td><input type=\"text\" size=\"15\" maxlength='100' value=\"\" name=\"UserName\" class=\"forminput\" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type=\"password\" size=\"15\" name=\"PassWord\" class=\"forminput\" /></td>
</tr>
<tr>
<td><input class=\"button\" type=\"submit\" name=\"submit\" value=\"Login\" /></td>
</tr>
</table>
</form>";
$welcometext .="</td></tr></tr></table>";
}

echo "$welcometext";
?>

in italian :)

But to show default avatar for guest?

#12 crok

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 10 March 2008 - 12:21 PM

when i try add this block get error :
Forbidden
You don't have permission to access /admin/index.php on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


--------------------------------------------------------------------------------

Apache Server at Port 80

please help...

#13 highlander

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts

Posted 13 May 2008 - 08:45 PM

None of these blocks display ANYTHING on my site... i have 2.3.5 and on 2.3.0 it works fine...

#14 highlander

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts

Posted 15 May 2008 - 05:28 PM

pretty please

#15 eyepuppy

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 17 May 2008 - 12:47 PM

Ok, I had to modify the code for the block to work in IPB version 2.3.5, Portal version 2.2.3. See if this works highlander.

<?php

if ($this->ipsclass->member['id'])
{
// for members
echo "<table cellpadding='0' cellspacing='0' border='0' width='100%' align='center'><tr><td align='left'>";

// avatar (1st column)
$welcomequery1 = $this->ipsclass->DB->query("SELECT * FROM ibf_member_extra WHERE id = " . $this->ipsclass->member['id']);
$avatar = $this->ipsclass->DB->fetch_row($welcomequery1);
$data['avatar'] = $this->ipsclass->get_avatar($avatar['avatar_location'], 1,$avatar['avatar_size'], $avatar['avatar_type']);
echo $data['avatar'];
echo "</td>";

// Member text (2nd column)
echo "<td align='left'>";
echo "Welcome back {$this->ipsclass->member['members_display_name']}<br>";

$welcomedate= $this->ipsclass->get_date($this->ipsclass->member['last_visit'], LONG);
echo "You last visited {$welcomedate}<br>";

$welcomequery2 = $this->ipsclass->DB->query("SELECT COUNT(DISTINCT(t.tid)) as tcnt, COUNT(DISTINCT(p.pid)) as pcnt FROM ibf_posts p, ibf_topics t WHERE p.post_date < ".time()." AND p.post_date > ".$this->ipsclass->member['last_visit']." AND p.topic_id=t.tid");
$row = $this->ipsclass->DB->fetch_row($welcomequery2);
$data['topics_since']	= $row[tcnt];
$data['posts_since']	= $row[pcnt];

echo "There has been {$data['topics_since']} posts in {$data['posts_since']} topics since your last visit!<br>";
echo "<a href='{$this->ipsclass->base_url}act=Search&CODE=getnew'>{$this->ipsclass->lang['view_new_posts']}</a><br>";
echo "</td>";

// forum stats (3rd column)
echo "<td align='left'>";
echo "Forum stats:<br>";

if ( ! is_array( $this->ipsclass->cache['stats'] ) )
{
$this->ipsclass->cache['stats'] = array();
$this->ipsclass->DB->simple_exec_query( array( 'delete' => 'cache_store', 'where' => "cs_key='stats'" ) );
$this->ipsclass->DB->do_insert( 'cache_store', array( 'cs_array' => 1, 'cs_key' => 'stats', 'cs_value' =>addslashes(serialize($this->ipsclass->cache['stats'])) ) );
}
$stats = $this->ipsclass->cache['stats'];
if ($this->users_online > $stats['most_count'])
{
$stats['most_count']	= $this->users_online;
$stats['most_date']	= time();
$this->ipsclass->DB->do_update( 'cache_store',array( 'cs_array' => 1, 'cs_value' => addslashes(serialize($stats)) ),"cs_key='stats'");
}
$total_posts = $stats['total_replies'] + $stats['total_topics'];
$total_posts= $this->ipsclass->do_number_format($total_posts);

echo "Members: {$stats['mem_count']}, Topics {$stats['total_topics']}<br>";
echo "Replies: {$stats['total_replies']}, Total Posts: {$total_posts}<br>";
echo "Our newest member: <a href='{$this->ipsclass->base_url}showuser={$stats['last_mem_id']}'>{$stats['last_mem_name']}</a><br>";

$welcomequery3 = $this->ipsclass->DB->query("SELECT `id`,`name`,`posts` FROM ibf_members WHERE 1 ORDER BY `posts` DESC LIMIT 1");
$row = $this->ipsclass->DB->fetch_row($welcomequery3);

echo "Top poster: <a href='{$this->ipsclass->base_url}showuser={$row[id]}'>{$row[name]}</a> ({$row[posts]} posts)<br>";
echo"</td></tr></table>";
}
// for guests

else
{
// first column
echo "<table cellpadding='0' cellspacing='0' border='0' width='100%' align='center'><tr><td align='left'>";
echo "Welcome Guest!<br>";
echo "<a href='{$this->ipsclass->base_url}act=Search&CODE=getactive'>View all of todays active posts.</a><br>";
echo "</td>";
// second column
echo "<td align='left'>";
echo "<form action='{$this->ipsclass->base_url}act=Login&CODE=01' method='post' name='LOGIN' onsubmit='return ValidateForm()'>
<input type='hidden' name='CookieDate' value='1' checked='checked' />
<table width='50%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td>Username:</td>
<td><input type='text' size='15' maxlength='150' value='' name='UserName' class='forminput' /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' size='15' name='PassWord' class='forminput' /></td>
</tr>
<tr>
<td><input class='button' type='submit' name='submit' value='Login' /></td>
</tr>
</table>
</form>";
echo "<a href='{$this->ipsclass->base_url}act=Reg&CODE=00'>Register</a>";
echo "</td></tr></table>";
}
?>


#16 highlander

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts

Posted 17 May 2008 - 02:09 PM

SIMPLY AWESOME thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

#17 Hobbes

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 02 June 2008 - 11:05 AM

Thxs for great block and also update !

#18 marto_182

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 17 June 2008 - 09:06 PM

THANK YOU VERY MUCH !!! works fine for me on ipb 2.3 ;)

*EDIT: the top poster appears as the name of the logged in member, not the real top poster's name.. does someone know how to fix this??

thanks in advance!

...EDIT 2: WOW

i don't know much about php coding, but somehow figured out how to fix what i just said. :D :D

Find:
$welcomequery3 = $this->ipsclass->DB->query("SELECT `id`,`name`,`posts` FROM ibf_members WHERE 1 ORDER BY `posts` DESC LIMIT 1");

Replace with:
$welcomequery3 = $this->ipsclass->DB->query("SELECT `id`,`name`,`posts`,`members_display_name` FROM ibf_members WHERE 1 ORDER BY `posts` DESC LIMIT 1");



Find:
$welcometext .= "Top poster: <a href=\"{$this->ipsclass->base_url}showuser={$row[id]}\">{$this->ipsclass->member['members_display_name']}</a> ({$row[posts]} posts)<br>";

Replace with:
$welcometext .= "Top poster: <a href=\"{$this->ipsclass->base_url}showuser={$row[id]}\">{$row['members_display_name']}</a> ({$row[posts]} posts)<br>";


before this the top poster's name shown, was the logged in member display name (in my case I was the top poster, but then I logged in with another username and noticed that the top poster's name had changed to my just logged in member)

let me know if this works fine for you, or if there's something wrong in the coding.
as I said, i know almost nothing about php coding, so it's possible there's some mistake..

hope this helps someone! :)

#19 jdoc1984

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 23 October 2008 - 10:00 AM

If i only want to show the part with....

Welcome back, last visit And avatar....

WHAT to do then... I ONLY want it to be left colum, not the BIG top one there

#20 Kojek

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 14 January 2009 - 10:33 AM

how do i integrate it with member group colour? so that user have colour on their username/display name based on group color?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users