• 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] Sticky Threads Function

Status
Not open for further replies.

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
######################################
[> Title: Sticky Threads Function
[> Author: Cybermaster
[> Scripted for: Gesior's Simple forum script
[> Coding: PHP+XHTML
[> Revision: 0.1
\________________________________________________/

Well, I think this was missing^_^ AchTung requested it.
Thanks to Absolute Mango for the help :D

Description
This new function allows moderators to stick or unstick threads in Gesior's Simple Forum Script.
Works like OTland's. Stickied threads will appear on top of the section.


Preview
Moderator's Vision
2akfc4g.jpg


Player's Vision

2en2qmg.jpg


Setup
STEP 1 (SQL QUERY)

Execute the next SQL Query, depending of your database class.
MySQL:
Code:
ALTER TABLE `z_forum` ADD `sticky` INT( 11 ) NOT NULL DEFAULT '0' AFTER `id`;
SQlite:
Code:
ALTER TABLE "z_forum" ADD "sticky" INT( 11 ) NOT NULL DEFAULT "0" AFTER `id`;
STEP 2 (SOME PHP CHANGE STUFF)
Search for
PHP:
if($action == 'show_board')
It has this long variable inside
PHP:
$last_threads = $SQL->query("SELECT `players`.`name`, `z_forum`.`post_text`, `z_forum`.`post_topic`, `z_forum`.`id`, `z_forum`.`last_post`, `z_forum`.`replies`, `z_forum`.`views`, `z_forum`.`post_date` FROM `players`, `z_forum` WHERE `players`.`id` = `z_forum`.`author_guid` AND `z_forum`.`section` = ".(int) $section_id." AND `z_forum`.`first_post` = `z_forum`.`id` ORDER BY `z_forum`.`last_post` DESC LIMIT ".$threads_per_page." OFFSET ".($page * $threads_per_page))->fetchAll();
Change it to this one:
PHP:
$last_threads = $SQL->query("SELECT * FROM `players`, `z_forum` WHERE `players`.`id` = `z_forum`.`author_guid` AND `z_forum`.`section` = ".(int) $section_id." AND `z_forum`.`first_post` = `z_forum`.`id` ORDER BY `sticky` DESC, `post_date` DESC LIMIT ".$threads_per_page." OFFSET ".($page * $threads_per_page))->fetchAll();

Some lines below, there is this:
Code:
if($logged  && $group_id_of_acc_logged >= $group_not_blocked)
                $main_content .= '<a href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove thread > '.$thread['post_topic'].' <?\')"><font color="red">[REMOVE]</font></a>  ';
            $main_content .= '<a href="?subtopic=forum&action=show_thread&id='.$thread['id'].'">'.htmlspecialchars($thread['post_topic']).'</a><br /><small>'.htmlspecialchars(substr($thread['post_text'], 0, 50)).'...</small></td><td><a href="?subtopic=characters&name='.urlencode($thread['name']).'">'.$thread['name'].'</a></td><td>'.(int) $thread['replies'].'</td><td>'.(int) $thread['views'].'</td><td>';

You change that to this:
Code:
$stick = ""; $stix = '<span style="color:blue">[STICK]</span>'; if ( $thread['sticky'] == 1 ) { $stick = '<strong>STICKY: </strong>'; $stix = '<span style="color:orange">[UNSTICK]</span>'; }
            if($logged && $group_id_of_acc_logged >= $group_not_blocked)
                $main_content .= '<a href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove thread > '.$thread['post_topic'].' <?\')"><span style="color:red">[REMOVE]</span></a> <a href="?subtopic=forum&action=stick_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want stick or unstick thread > '.$thread['post_topic'].' <?\')">'.$stix.'</a><br/>';
                $main_content .= '<b>'.$stick.'<a STYLE="text-decoration:none" href="?subtopic=forum&action=show_thread&id='.$thread['id'].'">'.htmlspecialchars($thread['post_topic']).'</a></b><br /><small>'.htmlspecialchars(substr($thread['post_text'], 0, 50)).'...</small></td><td><a href="?subtopic=characters&name='.urlencode($thread['name']).'">'.$thread['name'].'</a></td><td>'.(int) $thread['replies'].'</td><td>'.(int) $thread['views'].'</td><td>';



STEP 3 (ADD MY FUNCTION)

Before
PHP:
if($action == 'remove_post')
you add:
PHP:
########################################
//Sticky Threads Function. Scripted by Cybermaster
if($action == 'stick_post')
{
    if($logged && $group_id_of_acc_logged >= $group_not_blocked)
    {
        $id = (int) $_REQUEST['id'];
        $post = $SQL->query("SELECT `id`, `sticky`, `first_post`, `section` FROM `z_forum` WHERE `id` = ".$id." LIMIT 1")->fetch();
        if($post['id'] == $id)
        {
            if($post['id'] == $post['first_post'])
            {
                if($post['sticky'] == 0)
                    {    
                        $SQL->query("UPDATE `z_forum` SET `sticky` = 1 WHERE `id` = ".$post['id']." ");
                        header('Location: ?subtopic=forum&action=show_board&id='.$post['section']);
                    }
                else    
                        $SQL->query("UPDATE `z_forum` SET `sticky` = 0 WHERE `id` = ".$post['id']." ");
                        header('Location: ?subtopic=forum&action=show_board&id='.$post['section']);
            }
        }
        else
            $main_content .= 'Post with ID '.$id.' does not exist.';
    }
    else
        $main_content .= 'You are not logged in or you are not moderator.';
}
########################################

###########################################
Tested with Gesior Account Maker, with TibiaCom Layout. TFS 0.3.6



 
Last edited:
yeah, you must ;p
 
Parse error: syntax error, unexpected ')' in C:\xampp\htdocs\forum.php on line 213

Edit :

PHP:
$stick = ""; $stix = '<span style="color:blue">[Stick]</span>'; if ( $thread['sticky'] == 1 ) { $stick = '<strong>STICKY: </strong>'; $stix = '<span style="color:orange">[UnStick]</span>'; }  
                       if($logged && $group_id_of_acc_logged >= $group_not_blocked)
LINE 213 : $main_content .= '<a STYLE="text-decoration:none" href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove thread > '.$thread['post_topic'].' <?')"><strong><span style="color:red">[Delete]</span></a><a STYLE="text-decoration:none" href="?subtopic=forum&action=stick_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want if stick/unstick thread > '.$thread['post_topic'].' <?\')"> '.$stix.'</span></a></strong>';
                $main_content .= '<br/><b>'.$stick.'<a STYLE="text-decoration:none" href="?subtopic=forum&action=show_thread&id='.$thread['id'].'">'.htmlspecialchars($thread['post_topic']).'</a></b><br /><small>'.htmlspecialchars(substr($thread['post_text'], 0, 50)).'...</small></td><td><a href="?subtopic=characters&name='.urlencode($thread['name']).'">'.$thread['name'].'</a></td><td>'.(int) $thread['replies'].'</td><td>'.(int) $thread['views'].'</td><td>';
 
post that line
 
yeh, ure right, there is something wrong there
try this:
PHP:
if($logged && $group_id_of_acc_logged >= $group_not_blocked)
                $main_content .= '<a STYLE="text-decoration:none" href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove thread > '.$thread['post_topic'].' <?\')"><strong><span style="color:red">[Delete]</span></a><a STYLE="text-decoration:none" href="?subtopic=forum&action=stick_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want to Stick/UnStick > '.$thread['post_topic'].' <?\')"> '.$stix.'</span></a></strong>';
 
wait :D it has a small bug
let me fix it
 
so?
for me is fine
34zbuit.jpg
 
Last edited:
now it works fine
otland's php code tags were deleting something of it, thats why it was bugged
 
As an improvement you might in the function, that it's seperated from the normal posts....like on otland
 
Status
Not open for further replies.
Back
Top