26

(14 replies, posted in PunBB 1.2 troubleshooting)

Javascript suprisingly didn't work. hmm

/****************************************************************/
/* 0. HEADER LOGO */
/****************************************************************/

div#brdheader #brdtitle {
    height: 60px; 
    height: 60px; 
    padding: 3px
}

#brdtitle span, #brdtitle p {
    position: absolute;
    display: block;
    overflow: hidden;
    width: 1em;
    left: -999em
 }

#brdtitle {
    width: 800px; 
    height: 60px;
    background: url('/img/Oxygen/logo.png') top left no-repeat;
    }

That's whats in my style_cs.css

27

(14 replies, posted in PunBB 1.2 troubleshooting)

Yep, it results in nothing.

http://reviewstash.com/index.php

I took the code off temporarily, but nothing is made clickable

28

(14 replies, posted in PunBB 1.2 troubleshooting)

open header.php and find <pun_title>

What exactly do you mean why that? I found it, and I tried annexing <a href> onto it, but nothing showed.

29

(14 replies, posted in PunBB 1.2 troubleshooting)

No go, any ideas?

Yeah, and I don't mean about the frontpage, I've already got that, read the OP. I'm trying to get the "subject on forums.php" to work instead of the "date on forums.php" I obviously chose the wrong file, h/o.

http://wiki.punres.org/Last_post's_subject_on_forum_index

Forums.php

<?php
/***********************************************************************

  Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)

  This file is part of PunBB.

  PunBB is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published
  by the Free Software Foundation; either version 2 of the License,
  or (at your option) any later version.

  PunBB is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  MA  02111-1307  USA

************************************************************************/

define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';


if ($pun_user['g_read_board'] == '0')
    message($lang_common['No view']);


// Load the index.php language file
require PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';

$page_title = pun_htmlspecialchars($pun_config['o_board_title']);
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
include PUN_ROOT.'/include/user/newsbox.php';
 include('mod_active_topics.php'); 
$sfcount=0;
$sfdb = array($_parent_id_, $_topics_, $_posts_, $_last_post_id_, $_last_poster_, $_last_post_);
$forums_info = $db->query('SELECT num_topics, num_posts, parent_forum_id, last_post_id, last_poster, last_post, id, forum_name FROM '.$db->prefix.'forums ORDER BY disp_position') or error(implode($db->error(),''),__FILE__,__LINE__,$db->error());
while($current = $db->fetch_assoc($forums_info)) {
 if ($current['parent_forum_id'] != 0)
  {
   $sfdb[$sfcount][0] = $current['parent_forum_id'];
   $sfdb[$sfcount][1] = $current['num_topics'];
   $sfdb[$sfcount][2] = $current['num_posts'];
   $sfdb[$sfcount][3] = $current['last_post_id'];
   $sfdb[$sfcount][4] = $current['last_poster'];
   $sfdb[$sfcount][5] = $current['last_post'];
   $sfdb[$sfcount][6] = $current['id'];
   $sfdb[$sfcount][7] = $current['forum_name'];
   $sfcount++;
  }
}
echo '<script type="text/javascript" src="include/global.js"></script>';
// Print the categories and forums
$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster, f.parent_forum_id FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND (f.parent_forum_id IS NULL OR f.parent_forum_id=0) ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());

$cur_category = 0;
$cat_count = 0;
// stuff for toggling categories
$cat_ids = (isset($_COOKIE['collapseprefs']))? $_COOKIE['collapseprefs'].',': FALSE;
while ($cur_forum = $db->fetch_assoc($result))
{
    $moderators = '';

    if ($cur_forum['cid'] != $cur_category)    // A new category since last iteration?
    {
        if ($cur_category != 0)
            echo "\t\t\t".'</tbody>'."\n\t\t\t".'</table>'."\n\t\t".'</div>'."\n\t".'</div>'."\n".'</div>'."\n\n";

        ++$cat_count;

        // Setting varibles for toggling categories
        $div_box = strstr($cat_ids, $cat_count.',')? ' style="display:none"' : '';
        $exp_img = (is_file('img/'.$pun_user['style'].'/misc/exp_down.png')? 'img/'.$pun_user['style'].'/misc/': 'img/') . (strpos($div_box,'none') ? 'exp_down.png' : 'exp_up.png');
?>
<div id="idx<?php echo $cat_count ?>" class="blocktable">
    <h2>
        <a href="javascript:togglecategory(<?php echo $cat_count?>);"><img align="right" src="<?php echo $exp_img?>" alt="Collapse" id="img_<?php echo $cat_count?>" /></a>
        <span><?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></span>
    </h2>
    <div class="box" id="box_<?php echo $cat_count ?>"<?php echo $div_box?>>
        <div class="inbox">
            <table cellspacing="0">
            <thead>
                <tr>
                    <th class="tcl" scope="col"><?php echo $lang_common['Forum'] ?></th>
                    <th class="tc2" scope="col"><?php echo $lang_index['Topics'] ?></th>
                    <th class="tc3" scope="col"><?php echo $lang_common['Posts'] ?></th>
                    <th class="tcr" scope="col"><?php echo $lang_common['Last post'] ?></th>
                </tr>
            </thead>
            <tbody>
<?php

        $cur_category = $cur_forum['cid'];
    }

    $item_status = '';
    $icon_text = $lang_common['Normal icon'];
    $icon_type = 'icon';

    // Are there new posts?
    if (!$pun_user['is_guest'] && $cur_forum['last_post'] > $pun_user['last_visit'])
    {
        $item_status = 'inew';
        $icon_text = $lang_common['New icon'];
        $icon_type = 'icon inew';
    }

    // Is this a redirect forum?
    if ($cur_forum['redirect_url'] != '')
    {
        $forum_field = '<h3><a href="'.pun_htmlspecialchars($cur_forum['redirect_url']).'" title="'.$lang_index['Link to'].' '.pun_htmlspecialchars($cur_forum['redirect_url']).'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</a></h3>';
        $num_topics = $num_posts = ' ';
        $item_status = 'iredirect';
        $icon_text = $lang_common['Redirect icon'];
        $icon_type = 'icon';
        $l_post = '';
    }
    else
    {
        //$forum_field = '<h3><a href="viewforum.php?id='.$cur_forum['fid'].'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</a></h3>';
        $forum_field = '<h3><a href="extern.php?type=rss&action=active&fid='.$cur_forum['fid'].'"><img src="img/rss.png" border="0" alt="RSS" align="right" /></a><a href="viewforum.php?id='.$cur_forum['fid'].'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</a></h3>';





################################################################################
########################### Sub Forum MOD (start) ##############################
################################################################################
  $n_t = 0;
  $n_p = 0;
  $l_pid = $cur_forum['last_post_id'];
  $l_pr = $cur_forum['last_poster'];
  $l_post = $cur_forum['last_post'];
  for ($i = 0; $i < $sfcount; $i++)
  {
   if ($sfdb[$i][0] == $cur_forum['fid'])
    {
     $n_t = $n_t + $sfdb[$i][1];
     $n_p = $n_p + $sfdb[$i][2];
     if ($l_pid < $sfdb[$i][3])
      {
       $l_pid = $sfdb[$i][3];
       $l_pr = $sfdb[$i][4];
       $l_post = $sfdb[$i][5];
      }
    }
  }
  $num_topics = $n_t + $cur_forum['num_topics'];
  $num_posts = $n_p + $cur_forum['num_posts'];
################################################################################
########################### Sub Forum MOD ( end ) ##############################
################################################################################
    }

    if ($cur_forum['forum_desc'] != '')
        $forum_field .= "\n\t\t\t\t\t\t\t\t".$cur_forum['forum_desc'];


    // If there is a last_post/last_poster.
if ($l_post != '')
            $last_post = '<a href="viewtopic.php?pid='.$l_pid.'#p'.$l_pid.'">'.format_time($l_post).'</a><br /> <span class="byuser">'.$lang_common['by'].' <font style="font-weight: bold;">'.pun_htmlspecialchars($l_pr).'</font></span>';
    else
        $last_post = ' ';

    if ($cur_forum['moderators'] != '')
    {
        $mods_array = unserialize($cur_forum['moderators']);
        $moderators = array();

        while (list($mod_username, $mod_id) = @each($mods_array))
            $moderators[] = '<a href="profile.php?id='.$mod_id.'">'.pun_htmlspecialchars($mod_username).'</a>';

        $moderators = "\t\t\t\t\t\t\t\t".'<p>('.$lang_common['Moderated by'].': <font style="font-weight: bold;">'.implode(', ', $moderators).'</font>)</p>'."\n";
    }
            if (!empty($sfdb))
            {
                foreach ($sfdb as $sub_forums)
                {
                    if ($cur_forum['fid'] == $sub_forums[0] && !$pun_user['is_guest'] && $sub_forums[5] > $pun_user['last_visit'])
                    {
                        $item_status = 'inew';
                        $icon_text = $lang_common['New icon'];
                        $icon_type = 'icon inew';
                    }
                }
            }
?>
                 <tr<?php if ($item_status != '') echo ' class="'.$item_status.'"'; ?>>
                    <td class="tcl">
                        <div class="intd">
                            <div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo $icon_text ?></div></div>
                            <div class="tclcon">
                                <?php echo $forum_field."\n".$moderators ?>
<?php
                        $sub_forums_list = array();
                        if(!empty($sfdb)) {
                           foreach ($sfdb as $sub_forums) {
                                 if($cur_forum['fid'] == $sub_forums[0]) {
                                          $sub_forums_list[] = '<a class="sub_name" href="viewforum.php?id='.$sub_forums[6].'"><span class="sub_name">'.pun_htmlspecialchars($sub_forums[7]).'</span></a>';
                                 }
                             }

                           if(!empty($sub_forums_list)) {
                                 $sub_forums_list = "\t\t\t\t\t\t\t\t".'<span class="sub_title">Sub Forums:</span> '.implode(', ', $sub_forums_list)."\n";
                                             if ($cur_forum['forum_desc'] != NULL) {
                                                echo "<div style='margin-top: 4px;'>";
                                             }
                                 echo "$sub_forums_list</div>";
                           }
                        }
?>
                            </div>
                        </div>
                    </td>
                    <td class="tc2"><?php echo $num_topics ?></td>
                    <td class="tc3"><?php echo $num_posts ?></td>
                    <td class="tcr"><?php echo $last_post ?></td>
                </tr>
<?php

}

// Did we output any categories and forums?
if ($cur_category > 0)
    echo "\t\t\t".'</tbody>'."\n\t\t\t".'</table>'."\n\t\t".'</div>'."\n\t".'</div>'."\n".'</div>'."\n\n";
else
    echo '<div id="idx0" class="block"><div class="box"><div class="inbox"><p>'.$lang_index['Empty board'].'</p></div></div></div>';


// Collect some statistics from the database
$result = $db->query('SELECT COUNT(id)-1 FROM '.$db->prefix.'users') or error('Unable to fetch total user count', __FILE__, __LINE__, $db->error());
$stats['total_users'] = $db->result($result);

$result = $db->query('SELECT id, username FROM '.$db->prefix.'users ORDER BY registered DESC LIMIT 1') or error('Unable to fetch newest registered user', __FILE__, __LINE__, $db->error());
$stats['last_user'] = $db->fetch_assoc($result);

$result = $db->query('SELECT SUM(num_topics), SUM(num_posts) FROM '.$db->prefix.'forums') or error('Unable to fetch topic/post count', __FILE__, __LINE__, $db->error());
list($stats['total_topics'], $stats['total_posts']) = $db->fetch_row($result);
$result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'polls') or error('Impossible de reFIND le nombre total de sondage', __FILE__, __LINE__, $db->error());
$stats['total_polls'] = $db->result($result);

?>
<div class="block">
                        <h2><span><?php echo $lang_index['Board info'] ?></span></h2>
    <div class="box">
        <div id="brdstats" class="inbox">
            <dl class="conr">
                <dt><strong><?php echo $lang_index['Board stats'] ?></strong></dt>
                <dd><?php echo $lang_index['No of users'].': <strong>'. $stats['total_users'] ?></strong></dd>
                <dd><?php echo $lang_index['No of topics'].': <strong>'.$stats['total_topics'] ?></strong></dd>
                <dd><?php echo $lang_index['No of polls'].': <strong>'.$stats['total_polls'] ?></strong></dd>
                <dd><?php echo $lang_index['No of posts'].': <strong>'.$stats['total_posts'] ?></strong></dd>
            </dl>
            <dl class="con1">
                <dt><strong><?php echo $lang_index['User info'] ?></strong></dt>
                <dd><?php echo $lang_index['Newest user'] ?>: <a href="profile.php?id=<?php echo $stats['last_user']['id'] ?>"><?php echo pun_htmlspecialchars($stats['last_user']['username']) ?></a></dd>
<?php

if ($pun_config['o_users_online'] == '1')
{
    // Fetch users online info and generate strings for output
    $num_guests = 0;
    $users = array();
    $result = $db->query('SELECT user_id, ident, color FROM '.$db->prefix.'online WHERE idle=0 ORDER BY ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $db->error());

    while ($pun_user_online = $db->fetch_assoc($result))
    {
        if ($pun_user_online['user_id'] > 1)
            $users[] = "\n\t\t\t\t".'<dd><a href="profile.php?id='.$pun_user_online['user_id'].'"><span style="color: '.$pun_user_online['color'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</span></a>';
        else
            ++$num_guests;
    }

    $num_users = count($users);
    echo "\t\t\t\t".'<dd>'. $lang_index['Users online'].': <strong>'.$num_users.'</strong></dd>'."\n\t\t\t\t".'<dd>'.$lang_index['Guests online'].': <strong>'.$num_guests.'</strong></dd>'."\n\t\t\t".'</dl>'."\n";


    include('botdetect.php');
    $botStatus = isBotOnline();

    if ($num_users > 0 || $botStatus != '') {
       echo "\t\t\t".'<dl id="onlinelist" class= "clearb">'."\n\t\t\t\t".'<dt><strong>'.$lang_index['Online'].': </strong></dt>'."\t\t\t\t".implode(',</dd> ', $users);
    if($botStatus != '' & $num_users == 0)
        echo substr($botStatus, 1);
    else
        echo $botStatus;    

    echo '</dd>'."\n\t\t\t".'</dl>'."\n";
    }
        echo "\t\t\t".'<div class="clearer"></div>'."\n";

}
else
    echo "\t\t".'</dl>'."\n\t\t\t".'<div class="clearer"></div>'."\n";


?>
        </div>
    </div><div id="announce" class="block">
    <div id="stats1"><span>Top 15 most active users</span></div>
    <div class="box">
        <div class="inbox">
            <div>
<?php
 
$result = $db->query('SELECT id, username, num_posts FROM '.$db->prefix.'users ORDER BY num_posts DESC, username LIMIT 15') or error('Unable to fetch user data', __FILE__, __LINE__, $db->error());
while ($data = $db->fetch_assoc($result))
{
    if ($data['id'] != 1)
    {
        echo "\t\t\t\t\t\t".'<a href="profile.php?id='.$data['id'].'">'.pun_htmlspecialchars($data['username']).'</a> ('.$data['num_posts'].') '."\n";
    }
}
 
?>
        </div>
    </div>
</div>
<?php
?>

                        <div id="most_users_online" class="block">
    <div id="stats3"><span><?php echo $lang_index['most_users_online'] ?></span></div>
    <div class="box">
        <div style="padding-top: 4px;" align="center" class="inbox">


<?php


    if($num_users > $pun_config['o_max_users_online'])
    {
        $db->query("UPDATE ".$db->prefix."config SET conf_value = '".$num_users."' WHERE conf_name = 'o_max_users_online'");
        echo $lang_index['Max users online'].": <strong>".$num_users."</strong>\n";
        unlink(PUN_ROOT.'cache/cache_config.php');
    }
    else
        echo $lang_index['Max users online'].": [<strong>".$pun_config['o_max_users_online']."</strong>]\n";
    
    /* To disable guest counting, remove the last 2 characters of this line
    if($num_guests > $pun_config['o_max_guests_online'])
    {
        $db->query("UPDATE ".$db->prefix."config SET conf_value = '".$num_users."' WHERE conf_name = 'o_max_guests_online'");
        echo "<br />".$lang_index['Max guests online'].": <strong>".$num_guests."</strong>\n";
        unlink(PUN_ROOT.'cache/cache_config.php');
    }
    else
        echo $lang_index['Max guests online'].": <strong>".$pun_config['o_max_guests_online']."</strong>\n";
    // */


?>
</div></div>

<div id="legend" class="block">
    <div id="stats2"><span><?php echo $lang_index['board_legend'] ?></span></div>
        <div class="box">
            <div style="padding-top: 10px;" align="center" class="inbox">

                                <img style="vertical-align: middle;" src="img/<?php echo $pun_user['style'] ?>/new.png" alt="New posts" />  <small><?php echo $lang_index['New posts']; ?></small>   
                                <img style="vertical-align: middle;" src="img/<?php echo $pun_user['style'] ?>/normal.png" alt="No new posts" /><small>  <?php echo $lang_index['No new posts']; ?></small>   
                                <img style="vertical-align: middle;" src="img/<?php echo $pun_user['style'] ?>/sticky.png" alt="Sticky thread" /><small>  <?php echo $lang_index['Sticky thread']; ?></small>   
                                <img style="vertical-align: middle;" src="img/<?php echo $pun_user['style'] ?>/closed.png" alt="Closed thread" /><small>  <?php echo $lang_index['Closed thread']; ?></small>   
                                <img style="vertical-align: middle;" src="img/<?php echo $pun_user['style'] ?>/moved.png" alt="Moved thread" /><small>  <?php echo $lang_index['Moved thread']; ?></small><br /><br />
</div></div>
</div></div>
</div></div>

<?php

$footer_style = 'index';
require PUN_ROOT.'footer.php';
?>

Thanks, that did the trick. Now I just have to figure out how to get the subject on the index. hmm

Hmm, didn't seem to work, I added this

#navregister {FONT-WEIGHT: bold}

To the end of my oxygen.css file, and no go

Ah, sweet, thanks.

http://jedi.net.ru/ <--- Example

How do I make all my links change color, instead of underline? And, how do I make my "register" link a different color / bold?

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

Also, how do I get "http://wiki.punres.org/Last_post's_subject_on_forum_index" to work on my website? For some reason when I try to manually add in the change, it won't work and will just show a blank default subject.

Here's my index.php for reference.

<?php
 
define('PUN_ROOT', './');
require_once PUN_ROOT.'include/common.php';
 
//Set the page title here
$page_title = pun_htmlspecialchars('reviewstash / by the stash, for the stash');

define('PUN_ALLOW_INDEX', 1);
require_once PUN_ROOT.'header.php';
require_once PUN_ROOT.'include/parser.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/login.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php';

//----------------------------------------------------------------------//

//These are the forums from which the news is retrieved - You may add more forums in the array. Make sure to seperate them with a (,)
$forumids = array(8,6,7);

//How many items on a page \\ Created by Utchin
$perpage= 10;

//This is the overall limit for how many news items will be displayed
$master_limit = '10';

//This is the amount of characters above which truncation will occur
$trunc_chars = '1000';

//----------------------------------------------------------------------//

if ($pun_config['o_index_message_show'] == 1)
{
?>
    <div class="block">
        <h2><span><?php echo pun_htmlspecialchars($pun_config['o_index_message_head']) ?></span></h2>
        <div class="box">
            <div class="inbox">
            <?php echo $pun_config['o_index_message'] ?>
            </div>
        </div>
    </div>
<?php
}
?>
<?php
//----------------------------------------------------------------------//

function close_tags($string)
{
    if (preg_match_all ('/<([a-z]+)[ >]/', $string, $start_tags))
    {
        $start_tags = $start_tags[1];

        if (preg_match_all ('/<\/([a-z]+)>/', $string, $end_tags))
        {
            $complete_tags = array();
            $end_tags = $end_tags[1];

            foreach ($start_tags as $key => $val)
            {
                $posb = array_search ($val, $end_tags);
                if (is_integer ($posb))
                {
                    unset ($end_tags[$posb]);
                }
                else
                {
                    $complete_tags[] = $val;
                }
            }
        }
        else
        {
            $complete_tags = $start_tags;
        }

        $complete_tags = array_reverse ($complete_tags);
        for ($i = 0; $i < count ($complete_tags); $i++)
        {
            $string .= '</' . $complete_tags[$i] . '>';
        }
    }

        // Removes irrelevant tags
    $xhtml_tags = array ('</img>', '</hr>', '</br>');
    $string = str_replace ($xhtml_tags, '', $string);
    return $string;
}

//----------------------------------------------------------------------//

function truncate($string)
{
global $pun_config;
$trunc_chars = '350';
$length = $trunc_chars;
$append = '...';

    if (strlen ($string) <= $length)
    {
        return $string;
    }
    else if ($length > 0)
    {
        preg_match ('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){'.$length.',}\b#U', $string, $matches);
        $string = $matches[0];
        $string = close_tags (preg_replace ('#\s*<[^>]+>?\s*$#', '', $string).$append);
        return $string;
    }
}


// Fetch user count
$result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'topics WHERE forum_id IN ('.implode(',', $forumids).') ') or error('Unable to fetch user list count', __FILE__, __LINE__, $db->error());
$num_users = $db->result($result);
// Determine the user offset (based on $_GET['p'])
$num_pages = ceil($num_users / $perpage);

$p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
$start_from = $perpage * ($p - 1);

// Generate paging links
$paging_links = $lang_common['Pages'].': '.paginate($num_pages, $p, 'index.php?'.strtoupper($sort_dir));

$result = $db->query('SELECT t.id, t.subject, t.num_replies, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.forum_id, u.use_avatar, u.num_posts, u.registered, u.title, p.id AS pid, p.poster, p.poster_id, p.message, p.hide_smilies, p.posted, g.g_title, f.forum_name FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'posts AS p ON p.topic_id=t.id AND p.posted=t.posted INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id WHERE t.forum_id IN ('.implode(',', $forumids).') AND t.moved_to IS NULL AND f.redirect_url IS NULL ORDER BY t.posted DESC LIMIT '.$start_from.', '.$perpage) or error('Unable to fetch announcements', __FILE__, __LINE__, $db->error());

if ($db->num_rows($result))
{
    while($cur_post = $db->fetch_assoc($result))
    {
        echo '<div class="block">';
        if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0')
        {
            if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif'))
            {
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
            }
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg'))
            {
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
            }
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png'))
            {
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
            }
        }
        else
        {
            $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="img/noimage.gif" alt=""/></a>';
        }

      $news_message = parse_message($cur_post['message'], $cur_post['hide_smilies']);

        if (pun_strlen($news_message) > $trunc_chars)
        {
            $news_message = truncate($news_message);
            $read_more = ' | <a href="viewtopic.php?id='.$cur_post['id'].'">Read More</a> | ';
        }
        else
        {
            $read_more = ' | ';
        }

        if ($cur_post['num_replies'] != '0')
        {
            $replies = ' <a href="viewtopic.php?id='.$cur_post['id'].'#p'.$cur_post['last_post_id'].'">Replies</a>: '.$cur_post['num_replies'].' ';
        }
        else
        {
            $replies = ' Replies: '.$cur_post['num_replies'].' ';
        }

echo "\t\t\t\t\t\t\t".'<h2><strong><a href="forum.php">Forum</a> » <a href="viewforum.php?id='.$cur_post['forum_id'].'">'.pun_htmlspecialchars($cur_post['forum_name']).'</a>'.'</strong></h2>'."\n";
?>
    <div class="box">
        <div class="inbox">
<ul><li>
<table width="100%" border="0">
    <tr>
        <td style="border: 0px; padding: 0px 10px 7px 7px;"><a class="news_subject" href="viewtopic.php?id=<?php echo $cur_post['id']; ?>"><?php echo $cur_post['subject']; ?></a></td>
    </tr>
</table> 
<table width="100%" border="0">
    <tr>
        <td style="text-align: left; border: 0px; padding-top: 0px;" valign="top"><?php echo $news_message."\n" ?></td>
    </tr>
</table>

    <div style="padding-bottom: 20px;" class="news_footer"><div style="padding: 5px 5px 0px 5px;">

<?php

                if ($cur_post['poster_id'] == $pun_user['id'] || $pun_user['g_id'] < PUN_GUEST){
                echo "\t\t\t\t\t\t\t".'<span class="user" style="float:left">Posted: '.format_time($cur_post['posted']).' by:<span class="user'.(isset($cur_post['g_title']) ? ' '.strtolower(str_replace(' ', '', $cur_post['g_title'])) : '').'"> <a class="poster" href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['poster']).'</a>'.$read_more.'Views: '.$cur_post['num_views'].' |'.$replies.'</span></span>'."\n\n\n\n";
                echo "\t\t\t\t\t\t\t".'<a href="viewtopic.php?id='.$cur_post['id'].'">'.pun_htmlspecialchars($lang_portal['Visit_Topic']).'</a>'.'<span style="white-space: nowrap; float:right">'.'<a href="misc.php?report='.$cur_post['pid'].'">'.$lang_topic['Report'].'</a>'.' | <a href="delete.php?id='.$cur_post['pid'].'">'.$lang_topic['Delete'].'</a> | <a href="edit.php?id='.$cur_post['pid'].'">'.$lang_topic['Edit'].'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'">'.'Reply'.'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'&qid='.$cur_post['pid'].'">'.$lang_topic['Quote'].'</a>'.'</span></div></div>'."\n\n\n\n";
            }else{
                echo "\t\t\t\t\t\t\t".'<span class="user" style="float:left">Posted: '.format_time($cur_post['posted']).' by:<span class="user'.(isset($cur_post['g_title']) ? ' '.strtolower(str_replace(' ', '', $cur_post['g_title'])) : '').'"> <a class="poster" href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['poster']).'</a>'.$read_more.'Views: '.$cur_post['num_views'].' |'.$replies.'</span></span></div></div>'."\n";
}
?>   
</li></ul>
        </div>
    </div>
</div>
<?php
    }
}

?>

<div class="linkst">
    <div class="inbox">
        <p class="pagelink"><?php echo $paging_links ?></p>
    </div>
</div>

<?php

require PUN_ROOT.'footer.php';

?>

Thanks

Heh, I'm trying to make it automatically click open in the code.

How would I put that into the bbcode?

Is there anyway to do this without litebox, or any of those ridiculous JS / Flash scripts? I'm just looking for a way for "resized / compressed" images to be clickable and shown in fullsize in a new window.

For some reason they're not showing on my copy.

http://reviewstash.com/viewtopic.php?id=230 <---Example

How would I go about removed the left user info box from just the first post in a specific forum? Sounds bizzare, but if anyone has any ideas let me know.

40

(18 replies, posted in PunBB 1.2 troubleshooting)

Doesn't seem worth it. Thanks for the help.

41

(18 replies, posted in PunBB 1.2 troubleshooting)

That did the trick, thanks. One last thing, how would I go about removing the footer from the index only, yet still keep everything formated correctly? When I remove the "require: footer.php" I get an improperly formated page. Thanks.

42

(18 replies, posted in PunBB 1.2 troubleshooting)

There doesn't seem to be any actual place within the file that allows the page links to show DIRECTLY at the bottom, only within each box, and at the top.

43

(18 replies, posted in PunBB 1.2 troubleshooting)

Also, how would you place the "pages: 1,2,3" at the bottom of the index page?
Thanks

44

(18 replies, posted in PunBB 1.2 troubleshooting)

So close. Now, how do you have multiple forumids?

$forumids = array(1);
doing
$forumids = array(1,2,3);
results in an error

45

(18 replies, posted in PunBB 1.2 troubleshooting)

Thanks

46

(18 replies, posted in PunBB 1.2 troubleshooting)

Any progress? I can let you guys into my FTP if you need it.

47

(18 replies, posted in PunBB 1.2 troubleshooting)

No go, thanks though

I am looking for someone who is interested in adding pagination to the bottom of punportal pages (see: http://reviewstash.com) at the bottom of punportal's index to see previous postings.

// Generate paging links
$paging_links = $lang_common['Pages'].': '.paginate($num_pages, $p, 'userlist.php?username='.urlencode($username).'&show_group='.$show_group.'&sort_by='.$sort_by.'&sort_dir='.strtoupper($sort_dir));


?>
<div class="linkst">
    <div class="inbox">
        <p class="pagelink"><?php echo $paging_links ?></p>
    </div>
</div>

That's what I got out of the userlist file, however I have no idea where to go from here, so here's my index file.

<?php
 
define('PUN_ROOT', './');
require_once PUN_ROOT.'include/common.php';
 
//Set the page title here
$page_title = pun_htmlspecialchars('reviewstash / by the stash, for the stash');

define('PUN_ALLOW_INDEX', 1);
require_once PUN_ROOT.'header.php';
require_once PUN_ROOT.'include/parser.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/login.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php';

//----------------------------------------------------------------------//

//These are the forums from which the news is retrieved - You may add more forums in the array. Make sure to seperate them with a (,)
$forumids = array(8,6,7);

//This is the overall limit for how many news items will be displayed
$master_limit = '10';

//This is the amount of characters above which truncation will occur
$trunc_chars = '1000';

//----------------------------------------------------------------------//

if ($pun_config['o_index_message_show'] == 1)
{
?>
    <div class="block">
        <h2><span><?php echo pun_htmlspecialchars($pun_config['o_index_message_head']) ?></span></h2>
        <div class="box">
            <div class="inbox">
            <?php echo $pun_config['o_index_message'] ?>
            </div>
        </div>
    </div>
<?php
}
?>
<?php
//----------------------------------------------------------------------//

function close_tags($string)
{
    if (preg_match_all ('/<([a-z]+)[ >]/', $string, $start_tags))
    {
        $start_tags = $start_tags[1];

        if (preg_match_all ('/<\/([a-z]+)>/', $string, $end_tags))
        {
            $complete_tags = array();
            $end_tags = $end_tags[1];

            foreach ($start_tags as $key => $val)
            {
                $posb = array_search ($val, $end_tags);
                if (is_integer ($posb))
                {
                    unset ($end_tags[$posb]);
                }
                else
                {
                    $complete_tags[] = $val;
                }
            }
        }
        else
        {
            $complete_tags = $start_tags;
        }

        $complete_tags = array_reverse ($complete_tags);
        for ($i = 0; $i < count ($complete_tags); $i++)
        {
            $string .= '</' . $complete_tags[$i] . '>';
        }
    }

        // Removes irrelevant tags
    $xhtml_tags = array ('</img>', '</hr>', '</br>');
    $string = str_replace ($xhtml_tags, '', $string);
    return $string;
}

//----------------------------------------------------------------------//

function truncate($string)
{
global $pun_config;
$trunc_chars = '350';
$length = $trunc_chars;
$append = '...';

    if (strlen ($string) <= $length)
    {
        return $string;
    }
    else if ($length > 0)
    {
        preg_match ('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){'.$length.',}\b#U', $string, $matches);
        $string = $matches[0];
        $string = close_tags (preg_replace ('#\s*<[^>]+>?\s*$#', '', $string).$append);
        return $string;
    }
}

$result = $db->query('SELECT t.id, t.subject, t.num_replies, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.forum_id, u.use_avatar, u.num_posts, u.registered, u.title, p.id AS pid, p.poster, p.poster_id, p.message, p.hide_smilies, p.posted, g.g_title, f.forum_name FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'posts AS p ON p.topic_id=t.id AND p.posted=t.posted INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id WHERE t.forum_id IN ('.implode(',', $forumids).') AND t.moved_to IS NULL AND f.redirect_url IS NULL ORDER BY t.posted DESC LIMIT '.$master_limit) or error('Unable to fetch announcements', __FILE__, __LINE__, $db->error());

if ($db->num_rows($result))
{
    while($cur_post = $db->fetch_assoc($result))
    {
        echo '<div class="block">';
        if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0')
        {
            if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif'))
            {
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
            }
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg'))
            {
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
            }
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png'))
            {
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
            }
        }
        else
        {
            $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="img/noimage.gif" alt=""/></a>';
        }

      $news_message = parse_message($cur_post['message'], $cur_post['hide_smilies']);

        if (pun_strlen($news_message) > $trunc_chars)
        {
            $news_message = truncate($news_message);
            $read_more = ' | <a href="viewtopic.php?id='.$cur_post['id'].'">Read More</a> | ';
        }
        else
        {
            $read_more = ' | ';
        }

        if ($cur_post['num_replies'] != '0')
        {
            $replies = ' <a href="viewtopic.php?id='.$cur_post['id'].'#p'.$cur_post['last_post_id'].'">Replies</a>: '.$cur_post['num_replies'].' ';
        }
        else
        {
            $replies = ' Replies: '.$cur_post['num_replies'].' ';
        }

echo "\t\t\t\t\t\t\t".'<h2><strong><a href="forum.php">Forum</a> » <a href="viewforum.php?id='.$cur_post['forum_id'].'">'.pun_htmlspecialchars($cur_post['forum_name']).'</a>'.'</strong></h2>'."\n";
?>
    <div class="box">
        <div class="inbox">
<ul><li>
<table width="100%" border="0">
    <tr>
        <td style="border: 0px; padding: 0px 10px 7px 7px;"><a class="news_subject" href="viewtopic.php?id=<?php echo $cur_post['id']; ?>"><?php echo $cur_post['subject']; ?></a></td>
    </tr>
</table> 
<table width="100%" border="0">
    <tr>
        <td style="text-align: left; border: 0px; padding-top: 0px;" valign="top"><?php echo $news_message."\n" ?></td>
    </tr>
</table>

    <div style="padding-bottom: 20px;" class="news_footer"><div style="padding: 5px 5px 0px 5px;">

<?php

                if ($cur_post['poster_id'] == $pun_user['id'] || $pun_user['g_id'] < PUN_GUEST){
                echo "\t\t\t\t\t\t\t".'<span class="user" style="float:left">Posted: '.format_time($cur_post['posted']).' by:<span class="user'.(isset($cur_post['g_title']) ? ' '.strtolower(str_replace(' ', '', $cur_post['g_title'])) : '').'"> <a class="poster" href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['poster']).'</a>'.$read_more.'Views: '.$cur_post['num_views'].' |'.$replies.'</span></span>'."\n\n\n\n";
                echo "\t\t\t\t\t\t\t".'<a href="viewtopic.php?id='.$cur_post['id'].'">'.pun_htmlspecialchars($lang_portal['Visit_Topic']).'</a>'.'<span style="white-space: nowrap; float:right">'.'<a href="misc.php?report='.$cur_post['pid'].'">'.$lang_topic['Report'].'</a>'.' | <a href="delete.php?id='.$cur_post['pid'].'">'.$lang_topic['Delete'].'</a> | <a href="edit.php?id='.$cur_post['pid'].'">'.$lang_topic['Edit'].'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'">'.'Reply'.'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'&qid='.$cur_post['pid'].'">'.$lang_topic['Quote'].'</a>'.'</span></div></div>'."\n\n\n\n";
            }else{
                echo "\t\t\t\t\t\t\t".'<span class="user" style="float:left">Posted: '.format_time($cur_post['posted']).' by:<span class="user'.(isset($cur_post['g_title']) ? ' '.strtolower(str_replace(' ', '', $cur_post['g_title'])) : '').'"> <a class="poster" href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['poster']).'</a>'.$read_more.'Views: '.$cur_post['num_views'].' |'.$replies.'</span></span></div></div>'."\n";
}
?>   
</li></ul>
        </div>
    </div>
</div>
<?php
    }
}

require PUN_ROOT.'footer.php';

?>

49

(7 replies, posted in PunBB 1.2 troubleshooting)

It doesn't work.

50

(7 replies, posted in PunBB 1.2 troubleshooting)

<?php
/***********************************************************************

  Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)

  This file is part of PunBB.

  PunBB is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published
  by the Free Software Foundation; either version 2 of the License,
  or (at your option) any later version.

  PunBB is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  MA  02111-1307  USA

************************************************************************/

define('PUN_ALT3',1);
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
require PUN_ROOT.'include/image_upload/image_upload.php';

if ($pun_user['g_read_board'] == '0')
    message($lang_common['No view']);


$action = isset($_GET['action']) ? $_GET['action'] : null;
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$pid = isset($_GET['pid']) ? intval($_GET['pid']) : 0;
if ($id < 1 && $pid < 1)
    message($lang_common['Bad request']);

// Load the viewtopic.php language file
require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/reputation.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/topic_rating.php';

// If a post ID is specified we determine topic ID and page number so we can redirect to the correct message
if ($pid)
{
    $result = $db->query('SELECT topic_id FROM '.$db->prefix.'posts WHERE id='.$pid) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
    if (!$db->num_rows($result))
        message($lang_common['Bad request']);

    $id = $db->result($result);

    // Determine on what page the post is located (depending on $pun_user['disp_posts'])
    $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$id.' ORDER BY posted'.($pun_user['reverse_posts']? ' DESC':'')) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
    $num_posts = $db->num_rows($result);

    for ($i = 0; $i < $num_posts; ++$i)
    {
        $cur_id = $db->result($result, $i);
        if ($cur_id == $pid)
            break;
    }
    ++$i;    // we started at 0

    $_GET['p'] = ceil($i / $pun_user['disp_posts']);
}

// If action=new, we redirect to the first new post (if any)
else if ($action == 'new' && !$pun_user['is_guest'])
{
    $result = $db->query('SELECT MIN(id) FROM '.$db->prefix.'posts WHERE topic_id='.$id.' AND posted>'.$pun_user['last_visit']) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
    $first_new_post_id = $db->result($result);

    if ($first_new_post_id)
        header('Location: viewtopic.php?pid='.$first_new_post_id.'#p'.$first_new_post_id);
    else    // If there is no new post, we go to the last post
        header('Location: viewtopic.php?id='.$id.'&action=last');

    exit;
}

// If action=last, we redirect to the last post
else if ($action == 'last')
{
    $result = $db->query('SELECT MAX(id) FROM '.$db->prefix.'posts WHERE topic_id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
    $last_post_id = $db->result($result);

    if ($last_post_id)
    {
        header('Location: viewtopic.php?pid='.$last_post_id.'#p'.$last_post_id);
        exit;
    }
}

    // Increase rating of the topic
    else if ($action == 'incr_rating')
    {
        if(($pun_user['last_rating'] > time() - $pun_config['o_rating_timeout']) || $pun_user['is_guest'])
            message(str_replace('%d', $pun_config['o_rating_timeout'], $lang_topic_rating['Unallowed rate']));
        
        $db->query("UPDATE ".$db->prefix."topics SET rating = rating + 1 WHERE id=".$id) or error('Unable to update thread rating', __FILE__, __LINE__, $db->error());
        $db->query("UPDATE ".$db->prefix."users SET last_rating = ".time()." WHERE id=".$pun_user['id']) or error('Unable to update user timeout', __FILE__, __LINE__, $db->error());
        
        redirect(PUN_ROOT.'viewtopic.php?id='.$id, $lang_topic_rating['Topic rating increased']);
    }
    // Decrease rating of the topic
    else if ($action == 'decr_rating')
    {
        if(($pun_user['last_rating'] > time() - $pun_config['o_rating_timeout']) || $pun_user['is_guest'])
            message(str_replace('%d', $pun_config['o_rating_timeout'], $lang_topic_rating['Unallowed rate']));
        
        $db->query("UPDATE ".$db->prefix."topics SET rating = rating - 1 WHERE id=".$id) or error('Unable to update thread rating', __FILE__, __LINE__, $db->error());
        $db->query("UPDATE ".$db->prefix."users SET last_rating = ".time()." WHERE id=".$pun_user['id']) or error('Unable to update user timeout', __FILE__, __LINE__, $db->error());
        
        redirect(PUN_ROOT.'viewtopic.php?id='.$id, $lang_topic_rating['Topic rating decreased']);
    }

// Fetch some info about the topic
if (!$pun_user['is_guest'])
    $result = $db->query('SELECT pf.forum_name AS parent_forum, f.parent_forum_id, t.subject, t.closed, t.num_replies, t.sticky, t.rating, f.id, t.question, t.yes, t.no, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, s.user_id AS is_subscribed FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'subscriptions AS s ON (t.id=s.topic_id AND s.user_id='.$pun_user['id'].') LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') LEFT JOIN '.$db->prefix.'forums AS pf ON f.parent_forum_id=pf.id WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
else
    $result = $db->query('SELECT pf.forum_name AS parent_forum, f.parent_forum_id, t.subject, t.closed, t.num_replies, t.sticky, t.rating, t.labels, f.id, t.question, t.yes, t.no, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, 0 FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') LEFT JOIN '.$db->prefix.'forums AS pf ON f.parent_forum_id=pf.id WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());

if (!$db->num_rows($result))
    message($lang_common['Bad request']);

$cur_topic = $db->fetch_assoc($result);

// Sort out who the moderators are and if we are currently a moderator (or an admin)
$mods_array = ($cur_topic['moderators'] != '') ? unserialize($cur_topic['moderators']) : array();
$is_admmod = ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_id'] == PUN_MOD && array_key_exists($pun_user['username'], $mods_array))) ? true : false;

// Can we or can we not post replies?
if ($cur_topic['closed'] == '0')
{

    if (($cur_topic['post_replies'] == '' && $pun_user['g_post_replies'] == '1') || $cur_topic['post_replies'] == '1' || $is_admmod) $post_link = '<a href="javascript:void(0)" onClick="document.getElementById(\'show_quick\').style.display = \'none\' ? \'block\' : \'none\'; insert_text(\'\',\'\');" rel="nofollow"><img src="img/'.$pun_user['style'].'/buttons/btn_quick.png" ="'.$lang_topic['Quick reply'].'" alt="'.$lang_topic['Quick reply'].'" /></a> <a href="post.php?tid='.$id.'" rel="nofollow" title="'.$lang_topic['Post reply'].'"><img src="img/'.$pun_user['style'].'/buttons/new_reply.png" alt="'.$lang_topic['Post reply'].'" /></a>';
    else $post_link = '<a href="login.php" title="'.$lang_topic['Post reply'].'"><img src="img/'.$pun_user['style'].'/buttons/new_reply.png" alt="'.$lang_topic['Post reply'].'" /></a>'; 
}




else
{

    $post_link = '<img src="img/'.$pun_user['style'].'/buttons/topic_closed.png" alt="'.$lang_topic['Topic closed'].'" />';
    if ($is_admmod) 
    $post_link .= ' <a href="post.php?tid='.$id.'" title="'.$lang_topic['Post reply'].'"><img src="img/'.$pun_user['style'].'/buttons/new_reply.png" alt="'.$lang_topic['Post reply'].'" /></a>';
}


// Determine the post offset (based on $_GET['p'])
$num_pages = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']);

$p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
$start_from = $pun_user['disp_posts'] * ($p - 1);

// Generate paging links
$paging_links = $lang_common['Pages'].': '.paginate($num_pages, $p, 'viewtopic.php?id='.$id);


if ($pun_config['o_censoring'] == '1')
    $cur_topic['subject'] = censor_words($cur_topic['subject']);


$quickpost = false;
if ($pun_config['o_quickpost'] == '1' &&
    !$pun_user['is_guest'] &&
    ($cur_topic['post_replies'] == '1' || ($cur_topic['post_replies'] == '' && $pun_user['g_post_replies'] == '1')) &&
    ($cur_topic['closed'] == '0' || $is_admmod))
{
    $required_fields = array('req_message' => $lang_common['Message']);
    $quickpost = true;
}

if (!$pun_user['is_guest'] && $pun_config['o_subscriptions'] == '1')
{
    if ($cur_topic['is_subscribed'])
        // I apologize for the variable naming here. It's a mix of subscription and action I guess :-)
        $subscraction = '<p class="subscribelink clearb"><img src="img/'.$pun_user['style'].'/misc/icon_arrow.gif" alt="·" title="·" /> '.$lang_topic['Is subscribed'].' - <a href="misc.php?unsubscribe='.$id.'">'.$lang_topic['Unsubscribe'].'</a> <br /><img src="img/'.$pun_user['style'].'/misc/icon_arrow.gif" alt="·" title="·" /> <a href="viewprintable.php?id='.$id.'">'.$lang_common['Print version'].'</a><br /></a></p>'."\n";
    else
        $subscraction = '<p class="subscribelink clearb"><img src="img/'.$pun_user['style'].'/misc/icon_arrow.gif" alt="·" title="·" /> <a href="misc.php?subscribe='.$id.'">'.$lang_topic['Subscribe'].'</a> <br /><img src="img/'.$pun_user['style'].'/misc/icon_arrow.gif" alt="·" title="·" /> <a href="viewprintable.php?id='.$id.'">'.$lang_common['Print version'].'</a><br /><img src="img/'.$pun_user['style'].'/misc/icon_arrow.gif" alt="·" title="·" /> <a href="/forum.php">Forum Home</a><br /></a></p>'."\n";
}
else
    $subscraction = '<div class="clearer"></div>'."\n";

if ($cur_topic['question'])
    $cur_topic_question = $cur_topic['question'].' - ';
else
    $cur_topic_question = '';

$page_title = pun_htmlspecialchars($pun_config['o_board_title'].' / '.$cur_topic_question . $cur_topic['subject']);
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';

?>
<div class="linkst">
    <div class="inbox">
        <p class="pagelink conl"><?php echo $paging_links ?></p>
        <p class="postlink conr"><?php echo $post_link ?></p>
<?php

if($cur_topic['parent_forum'])
    echo "\t\t".'<ul><li><a href="index.php">'.$lang_common['Index'].'</a> </li><li>» <a href="viewforum.php?id='.$cur_topic['parent_forum_id'].'">'.pun_htmlspecialchars($cur_topic['parent_forum']).'</a> </li><li>» <a href="viewforum.php?id='.$cur_topic['forum_id'].'">'.pun_htmlspecialchars($cur_topic['forum_name']).'</a> </li><li>» '.pun_htmlspecialchars($cur_topic['subject']).'</li></ul>';
else
    echo "\t\t".'<ul><li><a href="index.php">'.$lang_common['Index'].'</a></li><li> » <a href="viewforum.php?id='.$cur_topic['forum_id'].'">'.pun_htmlspecialchars($cur_topic['forum_name']).'</a></li><li> » '.pun_htmlspecialchars($cur_topic['subject']).'</li></ul>';

?>
    <?php
    // This was added for topic rating
    if(!$pun_user['is_guest'])
        echo '<span>'.$lang_topic_rating['Topic rating'].' <a href="'.PUN_ROOT.'viewtopic.php?action=incr_rating&id='.$id.'" title="Increase thread rating"><img src="'.PUN_ROOT.'img/rate_topic/warn_add.gif" alt="+" /></a> <strong>'.intval($cur_topic['rating']).'</strong> <a href="'.PUN_ROOT.'viewtopic.php?action=decr_rating&id='.$id.'" title="Decrease thread rating"><img src="'.PUN_ROOT.'img/rate_topic/warn_minus.gif" alt="-" /></a></span>'."\n";
    else
        echo '<span>'.$lang_topic_rating['Topic rating'].' <strong>'.intval($cur_topic['rating']).'</strong></span>'."\n";
    // End topic rating subsection
    ?>
        <div class="clearer"></div>
    </div>
</div>

<?php


require PUN_ROOT.'include/parser.php';

$bg_switch = true;    // Used for switching background color in posts
$post_count = 0;    // Keep track of post numbers
// Mod poll begin
if ($cur_topic['question'])
{
    require PUN_ROOT . 'lang/' . $pun_user['language'] . '/polls.php'; 
    // get the poll data
    $result = $db->query('SELECT ptype,options,voters,votes FROM ' . $db->prefix . 'polls WHERE pollid=' . $id . '') or error('Unable to fetch poll info', __FILE__, __LINE__, $db->error());

    if (!$db->num_rows($result))
        message($lang_common['Bad request']);

    $cur_poll = $db->fetch_assoc($result);

    $options = unserialize($cur_poll['options']);
    if (!empty($cur_poll['voters']))
        $voters = unserialize($cur_poll['voters']);
    else
        $voters = array();

    $ptype = $cur_poll['ptype']; 
    // yay memory!
    // $cur_poll = null;
    $firstcheck = false;
    ?>
<div class="blockform">
    <h2><span><?php echo $lang_polls['Poll'] ?></span></h2>
    <div class="box">
        <?php
    if ((!$pun_user['is_guest']) && (!in_array($pun_user['id'], $voters)) && ($cur_topic['closed'] == '0') && (($cur_topic['post_replies'] == '1' || ($cur_topic['post_replies'] == '' && $pun_user['g_post_replies'] == '1')) || $is_admmod)) 
    {
        $showsubmit = true;
        ?>
        <form id="post2" method="post" action="vote.php">
            <div class="inform">
                <div class="rbox">
                <fieldset>
                    <legend><?php echo pun_htmlspecialchars($cur_topic['question']) ?></legend>
                    <div class="infldset txtarea">
                        <input type="hidden" name="poll_id" value="<?php echo $id; ?>" />
                        <input type="hidden" name="form_sent" value="1" />
                        <input type="hidden" name="form_user" value="<?php echo (!$pun_user['is_guest']) ? pun_htmlspecialchars($pun_user['username']) : 'Guest'; ?>" />
    
                        <?php
                        if ($ptype == 1) 
                        {
                            while (list($key, $value) = each($options)) 
                            {
                            ?>
                                <label><input name="vote" <?php if (!$firstcheck) { echo 'checked="checked"'; $firstcheck = true; }; ?> type="radio" value="<?php echo $key ?>" /> <span><?php echo pun_htmlspecialchars($value); ?></span></label>
                            <?php
                            } 
                        } 
                        elseif ($ptype == 2) 
                        {
                            while (list($key, $value) = each($options)) 
                            {         
                            ?>
                                <label><input name="options[<?php echo $key ?>]" type="checkbox" value="1" /> <span><?php echo pun_htmlspecialchars($value); ?></span></label>
                            <?php
                            } 
                        } 
                        elseif ($ptype == 3) 
                        {
                            
                            while (list($key, $value) = each($options)) 
                            {
                                echo pun_htmlspecialchars($value); ?>
                                <label><input class="button"name="options[<?php echo $key ?>]" checked="checked" type="radio" value="yes" /> <?php echo $cur_topic['yes']; ?></label>
                                <label><input name="options[<?php echo $key ?>]" type="radio" value="no" /> <?php echo $cur_topic['no']; ?></label>
                                <br />
                            <?php
                            } 
                        } 
                        else
                        {
                            message($lang_common['Bad request']);
                        }
            ?></div></fieldset><?php
    } 
    else 
    {
        $showsubmit = false;
        ?>
        <div class="inform">
        <div class="rbox">
            
            <p class="poll_info"><strong><?php echo pun_htmlspecialchars($cur_topic['question']) ?></strong></p>            
            <?php
            if (!empty($cur_poll['votes']))
                    $votes = unserialize($cur_poll['votes']);
            else
                  $votes = array();
        
            if ($ptype == 1 || $ptype == 2) 
            {
                $total = 0;
                $percent = 0;
                $percent_int = 0;
                while (list($key, $val) = each($options)) 
                {
                    if (isset($votes[$key]))
                        $total += $votes[$key];
                }
                reset($options);
            }
            
              while (list($key, $value) = each($options)) {    

                if ($ptype == 1 || $ptype == 2)
                { 
                    if (isset($votes[$key]))
                    {
                        $percent =  $votes[$key] * 100 / $total;
                        $percent_int = floor($percent);
                    }
                    ?>
                        <div class="poll_question"><?php echo pun_htmlspecialchars($value); ?></div>
                        <div class="poll_result">
                            <img src="img/transparent.gif" class="poll_bar" style="width:<?php if (isset($votes[$key])) echo $percent_int/2; else echo '0'; ?>%;" alt="" />
                            <span><?php if (isset($votes[$key])) echo $percent_int . '% - ' . $votes[$key]; else echo '0% - 0'; ?></span>
                        </div>
                <?php
                }
                else if ($ptype == 3) 
                { 
                    $total = 0;
                    $yes_percent = 0;
                    $no_percent = 0;
                    $vote_yes = 0;
                    $vote_no = 0;
                    if (isset($votes[$key]['yes']))
                    {
                        $vote_yes = $votes[$key]['yes'];
                    }

                    if (isset($votes[$key]['no'])) {
                        $vote_no += $votes[$key]['no'];
                    }

                    $total = $vote_yes + $vote_no;
                    if (isset($votes[$key]))
                    {
                        $yes_percent =   floor($vote_yes * 100 / $total);
                        $no_percent = floor($vote_no * 100 / $total);
                    }
                    ?>
                        <div class="poll_question"><?php echo pun_htmlspecialchars($value); ?></div>
                        
                        <div class="poll_result_yesno">
                            <strong><?php echo $cur_topic['yes']; ?></strong>
                                <img src="img/transparent.gif" class="poll_bar" style="width:<?php if (isset($votes[$key]['yes'])) { echo $yes_percent/2; } else { echo '0';  } ?>%;" alt="" />
                                <span><?php if (isset($votes[$key]['yes'])) { echo $yes_percent . "% - " . $votes[$key]['yes']; } else { echo "0% - " . 0; } ?></span>
                        </div>
                        <div class="poll_result_yesno">                        
                            <strong><?php echo $cur_topic['no']; ?></strong>
                                <img src="img/transparent.gif" class="poll_bar" style="width:<?php if (isset($votes[$key]['no'])) { echo $no_percent/2; } else { echo '0';  } ?>%;" alt="" />
                                <span><?php if (isset($votes[$key]['no'])) { echo $no_percent . "% - " . $votes[$key]['no']; } else { echo "0% - " . 0; } ?></span>
                        </div>
                    <?php 
                }
                else
                message($lang_common['Bad request']);
            }     
            ?>
                <p class="poll_info">Total : <?php echo $total; ?></p>
            <?php
        } 
        ?>
            </div>
                
            </div>

            <?php if ($showsubmit == true) 
            { 
                echo '<p><input class="button" type="submit" name="submit" tabindex="2" value="' . $lang_common['Submit'] . '" accesskey="s" /> <input class="button" type="submit" name="null" tabindex="2" value="' . $lang_polls['Null vote']. '" accesskey="n" /></p>
                </form>';
            } 
            ?>
    </div>
</div>
<?php
}
// Mod poll end
// Retrieve the posts (and their respective poster/online status) 
$result = $db->query("SELECT COUNT(*) FROM ".$db->prefix."posts WHERE topic_id=".$id) or error('Unable to count posts in thread', __FILE__, __LINE__, $db->error());
$num_posts = $db->result($result);
$result = $db->query('SELECT u.karma, u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, u.country, SUM(r.rep_plus) AS count_rep_plus, SUM(r.rep_minus) AS count_rep_minus, u.reputation_enable, u.sex, u.imgaward, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, g.g_color, o.user_id AS is_online FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id LEFT JOIN '.$db->prefix.'online AS o ON (o.user_id=u.id AND o.user_id!=1 AND o.idle=0) LEFT JOIN '.$db->prefix.'reputation as r ON (r.user_id=u.id) WHERE p.topic_id='.$id.' GROUP BY p.id ORDER BY p.id '.($pun_user['reverse_posts']? 'DESC ' : '').'LIMIT '.$start_from.','.$pun_user['disp_posts'], true) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

while ($cur_post = $db->fetch_assoc($result))
{
    $post_count++;
    $user_avatar = '';
    $user_info = array();
    $user_contacts = array();
    $post_actions = array();
    $is_online = '';
    $signature = '';
    $user_image_award = '';
    $rank_icons = "";
    // If the poster is a registered user.
    if ($cur_post['poster_id'] > 1)
    {
        // Image Award Mod Block Start
        if(strlen($cur_post['imgaward']) > 0){    // if we have something there, figure out what to output...
            //figure out the size of the award (Name of award should be in teh form:  Test_Award_100x20.png ... where png is format, 100x20 is dimensions and Test_Award is name of award (seen in admin interface)
            $awardmod_filename=$cur_post['imgaward'];
            $awardmod_temp=substr($awardmod_filename,strrpos($awardmod_filename,'_')+1); //we still have the file extentsion
            $awardmod_temp=substr($awardmod_temp,0,strpos($awardmod_temp,'.'));
            $awardmod_dimensions = explode('x',$awardmod_temp);    // there ... now the array will hold 100 and 20 in [0] and [1] respecively ... :)
            $awardmod_name=str_replace('_',' ',substr($awardmod_filename,0,strrpos($awardmod_filename,'_')));
            if($pun_config['o_avatars'] == '1' && $pun_user['show_avatars'] != '0')
                $user_image_award = "\t\t\t\t\t".'<dd><img src="img/awards/'.$awardmod_filename.'" width="'.$awardmod_dimensions[0].'" height="'.$awardmod_dimensions[1].'" alt="Award: '.$awardmod_name.'" /></dd>';
            else
                $user_image_award = "\t\t\t\t\t".'<dd>Award: "'.$awardmod_name.'"</dd>';
        }
        // Image Award Mod Block End


            if($cur_post['num_posts'] > 5000) { $num_ranks = 10; }
            elseif($cur_post['num_posts'] > 3000 && $cur_post['num_posts'] < 5000) { $num_ranks = 9; }
            elseif($cur_post['num_posts'] > 2000 && $cur_post['num_posts'] < 3000) { $num_ranks = 8; }
            elseif($cur_post['num_posts'] > 1000 && $cur_post['num_posts'] < 2000) { $num_ranks = 7; }
            elseif($cur_post['num_posts'] > 500 && $cur_post['num_posts'] < 1000) { $num_ranks = 6; }
            elseif($cur_post['num_posts'] > 300 && $cur_post['num_posts'] < 500) { $num_ranks = 5; }
            elseif($cur_post['num_posts'] > 100 && $cur_post['num_posts'] < 300) { $num_ranks = 4; }
            elseif($cur_post['num_posts'] > 50 && $cur_post['num_posts'] < 100) { $num_ranks = 3; }
            elseif($cur_post['num_posts'] > 30 && $cur_post['num_posts'] < 50) { $num_ranks = 2; }
            elseif($cur_post['num_posts'] > 10 && $cur_post['num_posts'] < 50) { $num_ranks = 1; }
            else { $num_ranks = 0; }
            /*if ($cur_post['g_id'] == 1) 
            $rank_icons = '<img style="border:0;" src="img/'.$pun_user['style'].'/ranks/rank_1.png" title="'.$lang_common['Administrator'].'" alt="'.$lang_common['Administrator'].'" />';
            else if ($cur_post['g_id'] == 2) 
            $rank_icons  = '<img style="border:0;" src="img/'.$pun_user['style'].'/ranks/rank_2.png" title="'.$lang_common['Moderator'].'" alt="'.$lang_common['Moderator'].'" />';
            else if ($img_size = @getimagesize(FORUM_ROOT.'/img/'.$pun_user['style'].'/ranks/rank_'.$cur_post['g_id'].'.png')) 
            $rank_icons  = '<img style="border:0;" src="img/'.$pun_user['style'].'/ranks/rank_'.$cur_post['g_id'].'.png" alt="" />';
            else $rank_icons = '<img style="border:0;" src="img/'.$pun_user['style'].'/ranks/stars_'.$num_ranks.'.png" title="'.$lang_common['Ranks'].'" alt="'.$lang_common['Ranks'].'" />'; */


        $username = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><span style="color:'.$cur_post['g_color'].'">' . pun_htmlspecialchars($cur_post['username']) . '</span></a>';
        $user_title = get_title($cur_post);
        $user_country = $cur_post['country'];
        if ($pun_config['o_censoring'] == '1')
            $user_title = censor_words($user_title);

        // Format the online indicator
        $is_online = ($cur_post['is_online'] == $cur_post['poster_id']) ? '<strong>'.$lang_topic[''].'</strong>' : $lang_topic[''];

        if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0')
        {
            if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif'))
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif" '.$img_size[3].' title="'.$cur_post['username'].'\'s Avatar" alt="'.$cur_post['username'].'\'s Avatar" /></a>';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg'))
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg" '.$img_size[3].' title="'.$cur_post['username'].'\'s Avatar" alt="'.$cur_post['username'].'\'s Avatar" /></a>';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png'))
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png" '.$img_size[3].' title="'.$cur_post['username'].'\'s Avatar" alt="'.$cur_post['username'].'\'s Avatar" /></a>';
        }
        else
            $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img alt="" src="img/noimage.gif" /></a>';

        if ($cur_post['sex'] != '') 
        {
            if ($cur_post['sex'] == 'male') $user_info[] = '<dd class="info">'.Gender.': <img style="border:0;" src="img/'.$pun_user['style'].'/misc/male.png" title="'.$cur_post['sex'].'" alt="'.$cur_post['sex'].'" />';
        else $user_info[] = '<dd class="info">'.Gender.': <img style="border:0;" src="img/'.$pun_user['style'].'/misc/female.png" title="'.$cur_post['sex'].'" alt="'.$cur_post['sex'].'" />';
            }

        // We only show location, register date, post count and the contact links if "Show user info" is enabled
        if ($pun_config['o_show_user_info'] == '1')
        {
            if ($cur_post['location'] != '')
            {
                if ($pun_config['o_censoring'] == '1')
                    $cur_post['location'] = censor_words($cur_post['location']);

                $user_info[] = '<dd>'.$lang_topic['From'].': '.pun_htmlspecialchars($cur_post['location']);
            }

            $user_info[] = '<dd>'.$lang_common['Registered'].': '.date($pun_config['o_date_format'], $cur_post['registered']);

            if ($pun_config['o_show_post_count'] == '1' || $pun_user['g_id'] < PUN_GUEST)
                $user_info[] = '<dd>'.$lang_common['Posts'].': '.$cur_post['num_posts'];
            $user_info[] = '<dd>'.'Karma'.': '.$cur_post['karma'];
            // Now let's deal with the contact links (E-mail and URL)


            if ($pun_user['g_id'] < PUN_GUEST)  
                $user_contacts[] = '<a href="moderate.php?get_host='.$cur_post['id'].'" title="'.$cur_post['poster_ip'].'"><img src="img/'.$pun_user['style'].'/buttons/btn_icon_ip.png" alt="'.$cur_post['poster_ip'].'" /></a>';


            if (($cur_post['email_setting'] == '0' && !$pun_user['is_guest']) || $pun_user['g_id'] < PUN_GUEST)
                $user_contacts[] = '<a href="mailto:'.$cur_post['email'].'"><img src="img/'.$pun_user['style'].'/buttons/btn_icon_email.png" title="'.$lang_common['E-mail'].'" alt="'.$lang_common['E-mail'].'" /></a>';
            else if ($cur_post['email_setting'] == '1' && !$pun_user['is_guest'])
                $user_contacts[] = '<a href="misc.php?email='.$cur_post['poster_id'].'"><img src="img/'.$pun_user['style'].'/buttons/btn_icon_email.png" title="'.$lang_common['E-mail'].'" alt="'.$lang_common['E-mail'].'" /></a>';


            if($pun_config['o_pms_enabled'] && !$pun_user['is_guest'] && $pun_user['g_pm'] == 1)
            {
                $pid = isset($cur_post['poster_id']) ? $cur_post['poster_id'] : $cur_post['id'];
                $user_contacts[] = '<a href="message_send.php?id='.$pid.'&tid='.$id.'" title="'.$lang_pms['Quick message'].'"><img src="img/'.$pun_user['style'].'/buttons/btn_icon_pm.png" alt="'.$lang_pms['Quick message'].'" /></a>';
            }

            //require(PUN_ROOT.' include/pms/viewtopic_PM-link.php');
            if ($cur_post['url'] != '')
                $user_contacts[] = '<a onclick="window.open(this.href); return false;" href="'.pun_htmlspecialchars($cur_post['url']).'" title="'.$lang_topic['Website'].'"><img src="img/'.$pun_user['style'].'/buttons/btn_icon_www.png" alt="'.$lang_topic['Website'].'" /></a>';
        }

}

            if ($cur_post['admin_note'] != '')
                $user_info[] = '<dd>'.$lang_topic['Note'].': <strong>'.pun_htmlspecialchars($cur_post['admin_note']).'</strong>';

    


    if ($cur_post['poster_id'] > 1&&!$pun_user['is_guest'])    
        $post_actions[] = '<li class="postedit"><br /><a href="karma.php?post='.$cur_post['id'].'&vote=1"><img src="img/'.$pun_user['style'].'/buttons/btn_praise.png" title="'.$lang_topic['Praise User'].'" alt="'.$lang_topic['Praise User'].'" /></a> <a href="karma.php?post='.$cur_post['id'].'&vote=0"><img src="img/'.$pun_user['style'].'/buttons/btn_smite.png" title="'.$lang_topic['Smite User'].'" alt="'.$lang_topic['Smite User'].'" /></a>';

    // Generation post action array (quote, edit, delete etc.)
    if (!$is_admmod)
    {
        if (!$pun_user['is_guest'])
            $post_actions[] = '<li class=""><a href="forward.php?forward='.$pun_user['id'].'&pid='.$cur_post['id'].'"><img src="img/'.$pun_user['style'].'/buttons/btn_forward.png" title="'.$lang_topic['Forward'].'" alt="'.$lang_topic['Forward'].'" /></a></li> <li class="post"><a href="javascript:scrollTo(0,0);"><img src="img/'.$pun_user['style'].'/buttons/btn_icon_top.png" title="'.$lang_topic['Top'].'" alt="'.$lang_topic['Top'].'" /></a></li> <li class="postreport"><a href="misc.php?report='.$cur_post['id'].'" title="'.$lang_topic['Report'].'"><img src="img/'.$pun_user['style'].'/buttons/btn_icon_report.png" alt="'.$lang_topic['Report'].'" /></a>';

        if ($cur_topic['closed'] == '0')
        {
            if ($cur_post['poster_id'] == $pun_user['id'])
            {
                if ((($start_from + $post_count) == 1 && $pun_user['g_delete_topics'] == '1') || (($start_from + $post_count) > 1 && $pun_user['g_delete_posts'] == '1'))
                    $post_actions[] = '<li class="postdelete"><a href="delete.php?id='.$cur_post['id'].'" title="'.$lang_topic['Delete'].'"><img src="img/'.$pun_user['style'].'/buttons/btn_delete.png" alt="'.$lang_topic['Delete'].'" /></a>';
                if ($pun_user['g_edit_posts'] == '1')
                    $post_actions[] = '<li class="postedit"><a href="edit.php?id='.$cur_post['id'].'" title="'.$lang_topic['Edit'].'"><img src="img/'.$pun_user['style'].'/buttons/btn_edit.png" alt="'.$lang_topic['Edit'].'" /></a>';
            }

            if (($cur_topic['post_replies'] == '' && $pun_user['g_post_replies'] == '1') || $cur_topic['post_replies'] == '1')
                $post_actions[] = '<li class="postquote"><a href="post.php?tid='.$id.'&qid='.$cur_post['id'].'" title="'.$lang_topic['Quote'].'"><img src="img/'.$pun_user['style'].'/buttons/btn_quote.png" alt="'.$lang_topic['Quote'].'" /></a><a href="javascript:void(0)" onClick="document.getElementById(\'show_quick\').style.display = \'none\' ? \'block\' : \'none\'; insert_text(\'[quote='.pun_htmlspecialchars($cur_post['username']).']'.$db->escape(pun_htmlspecialchars($cur_post['message'])).'[/quote]
\n\n\',\'\');" rel="nofollow" title="'.$lang_topic['Multi quote'].'"><img src="img/'.$pun_user['style'].'/buttons/btn_quote_m.png" alt="'.$lang_topic['Multi quote'].'" /></a>';
        }
    }
    else
        $post_actions[] = '<li class=""><a href="forward.php?forward='.$pun_user['id'].'&pid='.$cur_post['id'].'"><img src="img/'.$pun_user['style'].'/buttons/btn_forward.png" title="'.$lang_topic['Forward'].'" alt="'.$lang_topic['Forward'].'" /></a></li> <li class="post"><a href="javascript:scrollTo(0,0);"><img src="img/'.$pun_user['style'].'/buttons/btn_icon_top.png" title="'.$lang_topic['Top'].'" alt="'.$lang_topic['Top'].'" /></a></li> <li class="postreport"><a href="misc.php?report='.$cur_post['id'].'" title="'.$lang_topic['Report'].'"><img src="img/'.$pun_user['style'].'/buttons/btn_icon_report.png" alt="'.$lang_topic['Report'].'" /></a></li> <li class="postdelete"><a href="delete.php?id='.$cur_post['id'].'" title="'.$lang_topic['Delete'].'"><img src="img/'.$pun_user['style'].'/buttons/btn_delete.png" alt="'.$lang_topic['Delete'].'" /></a></li> <li class="postedit"><a href="edit.php?id='.$cur_post['id'].'" title="'.$lang_topic['Edit'].'"><img src="img/'.$pun_user['style'].'/buttons/btn_edit.png" alt="'.$lang_topic['Edit'].'" /></a></li> <li class="postquote"><a href="post.php?tid='.$id.'&qid='.$cur_post['id'].'" title="'.$lang_topic['Quote'].'"><img src="img/'.$pun_user['style'].'/buttons/btn_quote.png" alt="'.$lang_topic['Quote'].'" /></a><a href="javascript:void(0)" onClick="document.getElementById(\'show_quick\').style.display = \'none\' ? \'block\' : \'none\'; insert_text(\'[quote='.pun_htmlspecialchars($cur_post['username']).']'.$db->escape(pun_htmlspecialchars($cur_post['message'])).'[/quote]
\n\n\',\'\');" rel="nofollow" title="'.$lang_topic['Multi quote'].'"><img src="img/'.$pun_user['style'].'/buttons/btn_quote_m.png" alt="'.$lang_topic['Multi quote'].'" /></a>';


    // Switch the background color for every message.
    $bg_switch = ($bg_switch) ? $bg_switch = false : $bg_switch = true;
    $vtbg = ($bg_switch) ? ' roweven' : ' rowodd';


    // Perform the main parsing of the message (BBCode, smilies, censor words etc)
    $cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);

    // Do signature parsing/caching
    if ($cur_post['signature'] != '' && $pun_user['show_sig'] != '0')
    {
        if (isset($signature_cache[$cur_post['poster_id']]))
            $signature = $signature_cache[$cur_post['poster_id']];
        else
        {
            $signature = parse_signature($cur_post['signature']);
            $signature_cache[$cur_post['poster_id']] = $signature;
        }
    }
    if (($start_from + $post_count) == 1)
        $labels = (!empty($pun_config['o_topic_labels']))? $cur_topic['labels']: '';
    else
        $labels = '';
?>
<div id="p<?php echo $cur_post['id'] ?>" class="blockpost<?php echo $vtbg ?><?php if (($post_count + $start_from) == 1) echo ' firstpost'; ?>">
    <h2><span><span class="conr">#<?php echo $pun_user['reverse_posts']? ($num_posts+1-($start_from + $post_count)):($start_from + $post_count) ?> </span><a href="viewtopic.php?pid=<?php echo $cur_post['id'].'#p'.$cur_post['id'] ?>"><?php echo format_time($cur_post['posted']) ?></a></span></h2>
    <div class="box">
        <div class="inbox">
            <div class="postleft">
                <dl>
                    <dt><strong><?php echo $username ?></strong></dt>
                    <dd class="usertitle"><strong><?php echo $user_title ?></strong></dd>
                    <dd class="usertitle"><?php echo $rank_icons ?></dd>
                    <?php if ($user_avatar != '') echo "\t\t\t\t\t".'<dd class="postavatar">'.$user_avatar.'</dd>'."\n" ?>
 <?php if (trim($user_country) != '') {
                echo '<dd class="postavatar"><img src="./img/flags/'.$user_country.'.png" alt="'.$user_country.'" title="'.$user_country.'"></dd>'; } ?>
                    <?php if (strlen($user_image_award)>0) echo $user_image_award;  ## Image Award Mod ?>
<?php if (count($user_info)) echo "\t\t\t\t\t".implode('</dd>'."\n\t\t\t\t\t", $user_info).'</dd>'."\n"; ?>
<?php require(PUN_ROOT.'include/reputation/rep_viewtopic.php'); ?>
<?php if (count($user_contacts)) echo "\t\t\t\t\t".'<dd class="usercontacts">'.implode('  ', $user_contacts).'</dd>'."\n"; ?>
                </dl>
            </div>
            <div class="postright">
                <h3><?php if (($post_count + $start_from) > 1) echo ' Re: '; ?><?php echo pun_htmlspecialchars($cur_topic['subject']) ?></h3>
                <div class="postmsg">
                    <?php if (!empty($labels)) echo '<div class="topiclabels">' . $lang_common['Labels'] . ': ['. show_labels($labels) . ']</div>'; ?>
                    <?php echo $cur_post['message']."\n" ?>
                    <?php show_post_images($cur_post['id']) ?>
<?php if ($cur_post['edited'] != '') echo "\t\t\t\t\t".'<p class="postedit"><em>'.$lang_topic['Last edit'].' '.pun_htmlspecialchars($cur_post['edited_by']).' ('.format_time($cur_post['edited']).')</em></p>'."\n"; ?>
                </div>
<?php if ($signature != '') echo "\t\t\t\t".'<div class="postsignature"><hr />'.$signature.'</div>'."\n"; ?>
            </div>
            <div class="clearer"></div>
            <div class="postfootleft"><?php if ($cur_post['poster_id'] > 1) echo '<br /><p>'.$is_online.'</p>'; ?></div>
            <div class="postfootright"><div style="float:left;"><img src="/img/10x10-digg-thumb.png" width="10" height="10" alt="Digg!" /> <a href="http://digg.com/submit?phase=2&url=<?php echo $pun_config['o_base_url'] ?>/viewtopic.php?pid=<?php echo $cur_post['id'].'#p'.$cur_post['id'] ?>&title=<?php echo pun_htmlspecialchars($cur_topic['subject']) ?>">Digg It</a></div><?php echo (count($post_actions)) ? '<ul>'.implode('</li> ', $post_actions).'</li></ul></div>'."\n" : ' <div> </div> </div>'."\n" ?>
            
        </div>
    </div>
</div>

<?php
    if ($post_count == '1' && $adsense_config['google_adsense_enabled'] == '1' && strpos($adsense_config['google_exclude_forums'], ','.$cur_topic['forum_id'].',') === FALSE && strpos($adsense_config['google_exclude_groups'], ','.$pun_user['g_id'].',') === FALSE)
    {
?>
<div class="blockpost<?php echo $vtbg ?>">
    <h2><span><?php echo format_time($cur_post['posted']) ?></span></h2>
    <div class="box">
        <div class="inbox">
            <div class="postleft">
                <dl>
                    <dt><strong><?php echo $adsense_config['google_bot_name'] ?></strong></dt>
                    <dd class="usertitle"><?php echo $adsense_config['google_bot_tag'] ?></dd>
                </dl>
            </div>
            <div class="postright">
                <div class="postmsg">
                    <?php echo "<br /><div style=\"TEXT-ALIGN: center\">
    <script type=\"text/javascript\">
    <!--
        google_ad_client = \"".$adsense_config['google_ad_client']."\";
        google_ad_width = ".$adsense_config['google_ad_width'].";
        google_ad_height = ".$adsense_config['google_ad_height'].";
        google_ad_format = \"".$adsense_config['google_ad_format']."\";
        google_ad_channel = \"".$adsense_config['google_ad_channel']."\";
        google_ad_type = \"".$adsense_config['google_ad_type']."\";
        google_color_border = \"".$adsense_config['google_color_border']."\";
        google_color_bg = \"".$adsense_config['google_color_bg']."\";
        google_color_link = \"".$adsense_config['google_color_link']."\";
        google_color_url = \"".$adsense_config['google_color_url']."\";
        google_color_text = \"".$adsense_config['google_color_text']."\";
        google_alternate_color = \"".$adsense_config['google_alternate_color']."\";
    //-->
    </script>
    <script type=\"text/javascript\" src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\"></script>
</div><br />\n" ?>
                </div>
            </div>
            <div class="clearer"></div>
        </div>
    </div>
</div>
<?php
    }
}

?>
<div class="postlinksb">
    <div class="inbox">
        <p class="postlink conr"><?php echo $post_link ?></p>
        <p class="pagelink conl"><?php echo $paging_links ?></p>
<?php

if($cur_topic['parent_forum'])
    echo "\t\t".'<ul><li><a href="index.php">'.$lang_common['Index'].'</a> </li><li>» <a href="viewforum.php?id='.$cur_topic['parent_forum_id'].'">'.pun_htmlspecialchars($cur_topic['parent_forum']).'</a> </li><li>» <a href="viewforum.php?id='.$cur_topic['forum_id'].'">'.pun_htmlspecialchars($cur_topic['forum_name']).'</a> </li><li>» '.pun_htmlspecialchars($cur_topic['subject']).'</li></ul>';
else
    echo "\t\t".'<ul><li><a href="index.php">'.$lang_common['Index'].'</a></li><li> » <a href="viewforum.php?id='.$cur_topic['forum_id'].'">'.pun_htmlspecialchars($cur_topic['forum_name']).'</a></li><li> » '.pun_htmlspecialchars($cur_topic['subject']).'</li></ul>';

?>
        <?php echo $subscraction ?>
    </div>
</div>

<?php

// Display quick post if enabled
if ($quickpost)
{

?>
<div id="show_quick" style="display: none; padding-top: 6px">
<div class="blockform">
    <h2><span><?php echo $lang_topic['Quick post'] ?></span></h2>
    <div class="box">
    <form name="post" method="post" action="post.php?tid=<?php echo $id ?>" onsubmit="this.submit.disabled=true;if(process_form(this)){return true;}else{this.submit.disabled=false;return false;}">
            <div class="inform">
                <fieldset>
                    <legend><?php echo $lang_common['Write message legend'] ?></legend>
                    <div class="infldset txtarea">
                        <input type="hidden" name="form_sent" value="1" />
                        <input type="hidden" name="form_user" value="<?php echo (!$pun_user['is_guest']) ? pun_htmlspecialchars($pun_user['username']) : 'Guest'; ?>" />
                        <?php require PUN_ROOT.'multi_quote.php'; ?>
                        <label><textarea name="req_message" class="textbox" id="req_message" rows="7" cols="75" tabindex="1"></textarea></label>
<?php /* punToolBar */
if (file_exists(PUN_ROOT.'cache/cache_puntoolbar_quickreply.php')) {
    include PUN_ROOT.'cache/cache_puntoolbar_quickreply.php';
} else {
    require_once PUN_ROOT.'include/cache_puntoolbar.php';
    generate_ptb_cache('quickreply');
    require PUN_ROOT.'cache/cache_puntoolbar_quickreply.php';
}
?>
                        <ul class="bblinks">
                            <li><a href="help.php#bbcode" onclick="window.open(this.href); return false;"><?php echo $lang_common['BBCode'] ?></a>: <?php echo ($pun_config['p_message_bbcode'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li>
                            <li><a href="help.php#img" onclick="window.open(this.href); return false;"><?php echo $lang_common['img tag'] ?></a>: <?php echo ($pun_config['p_message_img_tag'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li>
                            <li><a href="help.php#smilies" onclick="window.open(this.href); return false;"><?php echo $lang_common['Smilies'] ?></a>: <?php echo ($pun_config['o_smilies'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li>
                        </ul>
                    </div>
                </fieldset>
            </div>
 
            <p><input class="button" type="submit" name="submit" tabindex="2" value="<?php echo $lang_common['Submit'] ?>" accesskey="s" /><input class="button" type="submit" name="preview" value="Preview" tabindex="2" accesskey="p" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
        </form>
    </div>
</div></div>
<?php

}

// Increment "num_views" for topic
$low_prio = ($db_type == 'mysql') ? 'LOW_PRIORITY ' : '';
$db->query('UPDATE '.$low_prio.$db->prefix.'topics SET num_views=num_views+1 WHERE id='.$id) or error('Unable to update topic', __FILE__, __LINE__, $db->error());

$forum_id = $cur_topic['forum_id'];
$footer_style = 'viewtopic';
require PUN_ROOT.'footer.php';
<?php
/***********************************************************************

  Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)

  This file is part of PunBB.

  PunBB is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published
  by the Free Software Foundation; either version 2 of the License,
  or (at your option) any later version.

  PunBB is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  MA  02111-1307  USA

************************************************************************/
define('PUN_ALT4',1);
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';


if ($pun_user['g_read_board'] == '0')
    message($lang_common['No view']);


// Load the userlist.php language file
require PUN_ROOT.'lang/'.$pun_user['language'].'/userlist.php';

// Load the search.php language file
require PUN_ROOT.'lang/'.$pun_user['language'].'/search.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/profile.php';

// Determine if we are allowed to view post counts
$show_post_count = ($pun_config['o_show_post_count'] == '1' || $pun_user['g_id'] < PUN_GUEST) ? true : false;

$username = (isset($_GET['username']) && $pun_user['g_search_users'] == '1') ? pun_trim($_GET['username']) : '';
$show_group = (!isset($_GET['show_group']) || intval($_GET['show_group']) < -1 && intval($_GET['show_group']) > 2) ? -1 : intval($_GET['show_group']);
$sort_by = (!isset($_GET['sort_by']) || $_GET['sort_by'] != 'username' && $_GET['sort_by'] != 'registered' && ($_GET['sort_by'] != 'num_posts' || !$show_post_count)) ? 'username' : $_GET['sort_by'];
$sort_dir = (!isset($_GET['sort_dir']) || $_GET['sort_dir'] != 'ASC' && $_GET['sort_dir'] != 'DESC') ? 'ASC' : strtoupper($_GET['sort_dir']);


$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['User list'];
if ($pun_user['g_search_users'] == '1')
    $focus_element = array('userlist', 'username');

define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';

?>
<div class="blockform">
    <h2><span><?php echo $lang_search['User search'] ?></span></h2>
    <div class="box">
    <form id="userlist" method="get" action="userlist.php">
        <div class="inform">
            <fieldset>
                <legend><?php echo $lang_ul['User find legend'] ?></legend>
                <div class="infldset">
<?php if ($pun_user['g_search_users'] == '1'): ?>                    <label class="conl"><?php echo $lang_common['Username'] ?><br /><input class="textbox" type="text" name="username" value="<?php echo pun_htmlspecialchars($username) ?>" size="25" maxlength="25" /><br /></label>
<?php endif; ?>                    <label class="conl"><?php echo $lang_ul['User group']."\n" ?>
                    <br /><select class="textbox" name="show_group">
                        <option value="-1"<?php if ($show_group == -1) echo ' selected="selected"' ?>><?php echo $lang_ul['All users'] ?></option>
<?php

$result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id!='.PUN_GUEST.' ORDER BY g_id') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());

while ($cur_group = $db->fetch_assoc($result))
{
    if ($cur_group['g_id'] == $show_group)
        echo "\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
    else
        echo "\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
}

?>
                    </select>
                    <br /></label>
                    <label class="conl"><?php echo $lang_search['Sort by']."\n" ?>
                    <br /><select class="textbox" name="sort_by">
                        <option value="username"<?php if ($sort_by == 'username') echo ' selected="selected"' ?>><?php echo $lang_common['Username'] ?></option>
                        <option value="registered"<?php if ($sort_by == 'registered') echo ' selected="selected"' ?>><?php echo $lang_common['Registered'] ?></option>
<?php if ($show_post_count): ?>                        <option value="num_posts"<?php if ($sort_by == 'num_posts') echo ' selected="selected"' ?>><?php echo $lang_ul['No of posts'] ?></option>
<?php endif; ?>                    </select>
                    <br /></label>
                    <label class="conl"><?php echo $lang_search['Sort order']."\n" ?>
                    <br /><select class="textbox" name="sort_dir">
                        <option value="ASC"<?php if ($sort_dir == 'ASC') echo ' selected="selected"' ?>><?php echo $lang_search['Ascending'] ?></option>
                        <option value="DESC"<?php if ($sort_dir == 'DESC') echo ' selected="selected"' ?>><?php echo $lang_search['Descending'] ?></option>
                    </select>
                    <br /></label>
                    <p class="clearb"><?php echo $lang_ul['User search info'] ?></p>
                </div>
            </fieldset>
        </div>
        <p><input class="button" type="submit" name="search" value="<?php echo $lang_common['Submit'] ?>" accesskey="s" /></p>
    </form>
    </div>
</div>
<?php


// Create any SQL for the WHERE clause
$where_sql = array();
$like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE';

if ($pun_user['g_search_users'] == '1' && $username != '')
    $where_sql[] = 'u.username '.$like_command.' \''.$db->escape(str_replace('*', '%', $username)).'\'';
if ($show_group > -1)
    $where_sql[] = 'u.group_id='.$show_group;

// Fetch user count
$result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'users AS u WHERE u.id>1'.(!empty($where_sql) ? ' AND '.implode(' AND ', $where_sql) : '')) or error('Unable to fetch user list count', __FILE__, __LINE__, $db->error());
$num_users = $db->result($result);


// Determine the user offset (based on $_GET['p'])
$num_pages = ceil($num_users / 50);

$p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
$start_from = 50 * ($p - 1);

// Generate paging links
$paging_links = $lang_common['Pages'].': '.paginate($num_pages, $p, 'userlist.php?username='.urlencode($username).'&show_group='.$show_group.'&sort_by='.$sort_by.'&sort_dir='.strtoupper($sort_dir));


?>
<div class="linkst">
    <div class="inbox">
        <p class="pagelink"><?php echo $paging_links ?></p>
    </div>
</div>

<div id="users1" class="blocktable">
    <h2><span><?php echo $lang_common['User list'] ?></span></h2>
    <div class="box">
        <div class="inbox">
        <table cellspacing="0">
        <thead>
            <tr>
                <th class="tcl" scope="col"><?php echo $lang_common['Username'] ?></th>
                <th class="tc2" scope="col"><?php echo 'Group Title'; ?></th>
            <th class="tc4" scope="col">Avatar</th>
            <th class="tc3" scope="col">Karma</th>
<?php if ($show_post_count): ?>                <th class="tc3" scope="col"><?php echo $lang_common['Posts'] ?></th>                                    
<?php endif; ?>                <th class="tcr" scope="col"><?php echo $lang_common['Registered'] ?></th>
                     <th class="tcr" scope="col"><?php echo $lang_profile['Country'] ?></th>
            </tr>
        </thead>
        <tbody>
<?php

// Grab the users
$result = $db->query('SELECT u.karma, u.id, u.username, u.title, u.num_posts, u.registered, u.use_avatar, u.country, g.g_id, g.g_user_title, g.g_color FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1'.(!empty($where_sql) ? ' AND '.implode(' AND ', $where_sql) : '').' ORDER BY '.$sort_by.' '.$sort_dir.' LIMIT '.$start_from.', 50') or error('Unable to fetch user list', __FILE__, __LINE__, $db->error());

if ($db->num_rows($result))
{
    while ($user_data = $db->fetch_assoc($result))
    {
        $user_group = $user_data['g_user_title'];
        $user_title_field = get_title($user_data);
        $user_country = $user_data['country'];
        $user_avatar = '';
        
 
        if ($pun_config['o_avatars'] == '1' && $user_data['use_avatar'] == '1' && $pun_user['show_avatars'] != '0')
        {
            if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$user_data['id'].'.gif'))
                $user_avatar = '<a href="profile.php?id=' . $user_data['id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$user_data['id'].'.gif" '.$img_size[3].' title="'.$user_data['username'].'\'s Avatar" alt="'.$user_data['username'].'\'s Avatar" /></a>';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$user_data['id'].'.jpg'))
                $user_avatar = '<a href="profile.php?id=' . $user_data['id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$user_data['id'].'.jpg" '.$img_size[3].' title="'.$user_data['username'].'\'s Avatar" alt="'.$user_data['username'].'\'s Avatar" /></a>';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$user_data['id'].'.png'))
                $user_avatar = '<a href="profile.php?id=' . $user_data['id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$user_data['id'].'.png" '.$img_size[3].' title="'.$user_data['username'].'\'s Avatar" alt="'.$user_data['username'].'\'s Avatar" /></a>';
        }
        else
            $user_avatar = '<a href="profile.php?id=' . $user_data['id'] . '"><img alt="" src="img/noimage.gif" /></a>';

?>
                <tr>
                    <td class="tcl"><?php echo '<a href="profile.php?id='.$user_data['id'].'"><span style="color:'.$user_data['g_color'].'">'.pun_htmlspecialchars($user_data['username']).'</span></a>' ?><br /><?php echo $user_title_field ?></td>
        <td class="tc2"><?php echo $user_group ?></td>
        <td class="tc4"><?php echo $user_avatar ?></td>
        <td class="tc3"><?php echo $user_data['karma'] ?></td>
<?php if ($show_post_count): ?>
        <td class="tc3"><?php echo $user_data['num_posts'] ?></td>
<?php endif; ?>
        <td class="tcr"><?php echo format_time($user_data['registered'], true) ?></td>
        <td class="tcr">
<?php if ( $user_country != '' ) {
echo '<img src="./img/flags/'.$user_country.'.png" alt="'.$user_country.'" title="'.$user_country.'" />'; 
}else {
echo '<img src="/img/flags/no_flag.png" alt="no flag selected" title="no flag selected" />';
} 
 ?>
        </td>



<?php if ($show_post_count): ?></td>
<?php endif; ?>
            </tr>
<?php

    }
}
else
    echo "\t\t\t".'<tr>'."\n\t\t\t\t\t".'<td class="tcl" colspan="'.(($show_post_count) ? 4 : 3).'">'.$lang_search['No hits'].'</td></tr>'."\n";

?>
            </tbody>
            </table>
        </div>
    </div>
</div>

<div class="linksb">
    <div class="inbox">
        <p class="pagelink"><?php echo $paging_links ?></p>
    </div>
</div>
<?php

require PUN_ROOT.'footer.php';