• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Gesior Forum] Latest Posts Function

hodleo

Formerly cbrm -Crypto enthusiast, Retired scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,598
Solutions
3
Reaction score
955
Location
Caribbean Sea
####################################
[> Author: Cybermaster
[> Scripted for: Gesior's Simple forum script
[> Coding: PHP+XHTML+CSS
[> Version: 0.1
\_____________________________________________/

Description
This new function displays the latests posts made in your OT's forum, somewhat like the OTland's New Posts function. It consists of a SQL query that returns the last posts made by users, detailed with date, time, last poster, thread and section. It still doesn't look exactly like OTland's.

Preview
dy17ko.jpg

My Server is in spanish, so that's why you see the language diff.

Setup

STEP 1 (CSS SPAN STYLE)

OPEN "htdocs/forum.php" AND ADD THIS CODE AFTER THE FIRST "<?PHP"

HTML:
$main_content .= '<style type="text/css">
<!-- .Style1 {color: black}
       .Header {color: black;font-size: small}
       .SubHeader {color: white;font-size: x-small}
       .Short {font-size: x-small}
       .Style2 {color: white} -->
</style>';

STEP 2 (ADD THE 'NEW POSTS' LINK)
Search for:
PHP:
if($action == '')
Below it, add in the end of the first line of
PHP:
$main_content .=
This code:
PHP:
<a STYLE="text-decoration: none" href="?subtopic=forum&action=recent_posts">   <b>View Recent Posts</b></a>'

STEP 3 (ADD MY FUNCTION)

Before
PHP:
if($action == 'show_board')
Add:
PHP:
####################################################
//Recent Posts function for Gesior Forum. Scripted by Cybermaster
//Credits to OTland.net for the pictures
if($action == 'recent_posts')
{
	$main_content .= '<span class="Header"><strong><a href="?subtopic=forum">Forum</a> > Recent Posts</span></strong><br/>';
	$main_content .= '<table width="100%" border="0" cellpadding="0" cellspacing="1"><tr bgcolor="'.$config['site']['vdarkborder'].'" align="left"><td><font size="1"><span class="SubHeader"><strong>Thread</strong></td><td align="center"><span class="SubHeader"><strong>Last Post</strong></span></td><td align="center"><span class="SubHeader"><strong>Replies</b></span></td><td align="center"><span class="SubHeader"><strong>Views</strong></span></td><td align="left"><span class="SubHeader"><strong>Forum</strong></span></td></tr>';

$order = 0; 
$posts = $SQL->query('SELECT id,first_post,post_topic,post_date,author_guid,post_text,section FROM z_forum ORDER BY post_date DESC LIMIT 40;');

foreach($posts as $post) { 
$order++; 
if(is_int($order / 2))
            $bgcolor = $config['site']['darkborder'];
        else
            $bgcolor = $config['site']['lightborder'];

$_name = $SQL->query('SELECT `name` FROM `players` WHERE `id` = '.$post['author_guid'].'')->fetch(); 
$_replies = $SQL->query('SELECT `replies` FROM `z_forum` WHERE `first_post` = '.$post['first_post'].'')->fetch(); 
$_views = $SQL->query('SELECT `views` FROM `z_forum` WHERE `first_post` = '.$post['first_post'].'')->fetch(); 
$_text = $post['post_text'];
$_thread = $SQL->query('SELECT `post_topic` FROM `z_forum` WHERE `first_post` = '.$post['first_post'].'')->fetch();
if (strlen($_thread[0]) > 50) //Char Limit Config for the Threads 
	$_thread[0] = substr($_thread[0], 0, strrpos(substr($_thread[0], 0, 50), ' ')) . '...';
if (strlen($_text) > 50) //Char Limit Config for the Posts
	$_text = substr($_text, 0, strrpos(substr($_text, 0, 50), ' ')) . '...';

$main_content .= '<tr bgcolor="'.$bgcolor.'">
<td><img src="http://otland.net/images/galaxy/misc/multipage.gif"> "'.$_text.'"</span><br/><img src="http://otland.net/images/galaxy/buttons/firstnew.gif"><b><a href="?subtopic=forum&action=show_thread&id='.urlencode($post['first_post']).'"><font size="1"><span class="Style1"> '.$_thread[0].'</a></b></span></td>
<td style="text-align: right;"><font size="1"><span class="Style1">'.date("F d (H:m)", $post[post_date]).' <br/>by <strong>'.$_name[0].' </strong></span><a href="?subtopic=forum&action=show_thread&id='.urlencode($post['first_post']).'"><img src="http://otland.net/images/galaxy/buttons/lastpost.gif" style="border: none;"></a></td>
<td><center><span class="Style1">'.$_replies[0].'</center></span></td>
<td><center><span class="Style1">'.$_views[0].'</center></span></td>
<td><span class="Short">'.$sections[$post[section]].'</span></td></tr>';
	}
$main_content .= '</table>';
}
####################################################>

And that's it.:peace:



###########################################
Tested with Gesior Account Maker, with TibiaCom Layout. TFS 0.3.6
 
Last edited:
b ring
u p
m y
p ost
any new comments?
 
^ ^ yay
is there any new function that I can script for that forum?
 
Cant get it working :p
Maybe im a noob but for the screenshots it is looking freaking nice.

Regards,
Wodian
 
Images were hotlinked from Otland's former layout, you'll have to edit them manually
 
Back
Top