<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[مەکۆکانی وێبچن - كه‌ زانياری تاكه‌كه‌سی ئه‌كه‌مه‌وه‌ ئه‌مه‌ ديت]]></title>
		<link>https://www.webchin.org/Meko/viewtopic.php?id=27314</link>
		<atom:link href="https://www.webchin.org/Meko/extern.php?action=feed&amp;tid=27314&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[دواترین و نوێترین په‌یامه‌كان له‌ كه‌ زانياری تاكه‌كه‌سی ئه‌كه‌مه‌وه‌ ئه‌مه‌ ديت.]]></description>
		<lastBuildDate>Sat, 26 May 2012 01:37:48 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[وه‌ڵام: كه‌ زانياری تاكه‌كه‌سی ئه‌كه‌مه‌وه‌ ئه‌مه‌ ديت]]></title>
			<link>https://www.webchin.org/Meko/viewtopic.php?pid=219966#p219966</link>
			<description><![CDATA[<p>سەرکەوتووبیت.</p>]]></description>
			<author><![CDATA[null@example.com (ئاسۆ نادری)]]></author>
			<pubDate>Sat, 26 May 2012 01:37:48 +0000</pubDate>
			<guid>https://www.webchin.org/Meko/viewtopic.php?pid=219966#p219966</guid>
		</item>
		<item>
			<title><![CDATA[وه‌ڵام: كه‌ زانياری تاكه‌كه‌سی ئه‌كه‌مه‌وه‌ ئه‌مه‌ ديت]]></title>
			<link>https://www.webchin.org/Meko/viewtopic.php?pid=219965#p219965</link>
			<description><![CDATA[<p>ده‌سته‌كانت خۆش بيت هه‌ربژيت هه‌ر ساغ و سه‌لامه‌ت بيت ئينشالله‌ ته‌مه‌ن دريژ ئه‌بيت كاك ئاسۆ گيان زۆر سوپاس ته‌واو</p>]]></description>
			<author><![CDATA[null@example.com (WlaT_ShaQLaWa)]]></author>
			<pubDate>Sat, 26 May 2012 01:36:32 +0000</pubDate>
			<guid>https://www.webchin.org/Meko/viewtopic.php?pid=219965#p219965</guid>
		</item>
		<item>
			<title><![CDATA[وه‌ڵام: كه‌ زانياری تاكه‌كه‌سی ئه‌كه‌مه‌وه‌ ئه‌مه‌ ديت]]></title>
			<link>https://www.webchin.org/Meko/viewtopic.php?pid=219964#p219964</link>
			<description><![CDATA[<div class="codebox"><pre><code data-language=php>&lt;?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(&#039;PUN_ROOT&#039;, &#039;./&#039;);
require PUN_ROOT.&#039;include/common.php&#039;;


if ($pun_user[&#039;g_read_board&#039;] == &#039;0&#039;)
    message($lang_common[&#039;No view&#039;]);


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

// Load the viewtopic.php language file
require PUN_ROOT.&#039;lang/&#039;.$pun_user[&#039;language&#039;].&#039;/topic.php&#039;;


// 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-&gt;query(&#039;SELECT topic_id FROM &#039;.$db-&gt;prefix.&#039;posts WHERE id=&#039;.$pid) or error(&#039;Unable to fetch post info&#039;, __FILE__, __LINE__, $db-&gt;error());
    if (!$db-&gt;num_rows($result))
        message($lang_common[&#039;Bad request&#039;]);

    $id = $db-&gt;result($result);

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

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

    $_GET[&#039;p&#039;] = ceil($i / $pun_user[&#039;disp_posts&#039;]);
}

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

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

    exit;
}

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

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


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

if (!$db-&gt;num_rows($result))
    message($lang_common[&#039;Bad request&#039;]);

$cur_topic = $db-&gt;fetch_assoc($result);

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

// Can we or can we not post replies?
if ($cur_topic[&#039;closed&#039;] == &#039;0&#039;)
{
    if (($cur_topic[&#039;post_replies&#039;] == &#039;&#039; &amp;&amp; $pun_user[&#039;g_post_replies&#039;] == &#039;1&#039;) || $cur_topic[&#039;post_replies&#039;] == &#039;1&#039; || $is_admmod)
        $post_link = &#039;&lt;a href=&quot;post.php?tid=&#039;.$id.&#039;&quot;&gt;&#039;.$lang_topic[&#039;Post reply&#039;].&#039;&lt;/a&gt;&#039;;
    else
        $post_link = &#039;&amp;nbsp;&#039;;
}
else
{
    $post_link = $lang_topic[&#039;Topic closed&#039;];

    if ($is_admmod)
        $post_link .= &#039; / &lt;a href=&quot;post.php?tid=&#039;.$id.&#039;&quot;&gt;&#039;.$lang_topic[&#039;Post reply&#039;].&#039;&lt;/a&gt;&#039;;
}


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

$p = (!isset($_GET[&#039;p&#039;]) || $_GET[&#039;p&#039;] &lt;= 1 || $_GET[&#039;p&#039;] &gt; $num_pages) ? 1 : $_GET[&#039;p&#039;];
$start_from = $pun_user[&#039;disp_posts&#039;] * ($p - 1);

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


if ($pun_config[&#039;o_censoring&#039;] == &#039;1&#039;)
    $cur_topic[&#039;subject&#039;] = censor_words($cur_topic[&#039;subject&#039;]);


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

if (!$pun_user[&#039;is_guest&#039;] &amp;&amp; $pun_config[&#039;o_subscriptions&#039;] == &#039;1&#039;)
{
    if ($cur_topic[&#039;is_subscribed&#039;])
        // I apologize for the variable naming here. It&#039;s a mix of subscription and action I guess :-)
        $subscraction = &#039;&lt;p class=&quot;subscribelink clearb&quot;&gt;&#039;.$lang_topic[&#039;Is subscribed&#039;].&#039; - &lt;a href=&quot;misc.php?unsubscribe=&#039;.$id.&#039;&quot;&gt;&#039;.$lang_topic[&#039;Unsubscribe&#039;].&#039;&lt;/a&gt;&lt;/p&gt;&#039;.&quot;\n&quot;;
    else
        $subscraction = &#039;&lt;p class=&quot;subscribelink clearb&quot;&gt;&lt;a href=&quot;misc.php?subscribe=&#039;.$id.&#039;&quot;&gt;&#039;.$lang_topic[&#039;Subscribe&#039;].&#039;&lt;/a&gt;&lt;/p&gt;&#039;.&quot;\n&quot;;
}
else
    $subscraction = &#039;&lt;p class=&quot;subscribelink clearb&quot;&gt;&lt;a href=&quot;misc.php?subscribe=&#039;.$id.&#039;&quot;&gt;&#039;.$lang_topic[&#039;Subscribe&#039;].&#039;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;!-- AddThis Button BEGIN --&gt;&lt;div class=&quot;addthis_toolbox addthis_default_style &quot;&gt;&lt;a href=&quot;http://www.addthis.com/bookmark.php?v=250&amp;amp;username=bawar&quot; class=&quot;addthis_button_compact&quot;&gt;Share&lt;/a&gt;&lt;span class=&quot;addthis_separator&quot;&gt;|&lt;/span&gt;&lt;a class=&quot;addthis_button_preferred_1&quot;&gt;&lt;/a&gt;&lt;a class=&quot;addthis_button_preferred_2&quot;&gt;&lt;/a&gt;&lt;a class=&quot;addthis_button_preferred_3&quot;&gt;&lt;/a&gt;&lt;a class=&quot;addthis_button_preferred_4&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;var addthis_config = {&quot;data_track_clickback&quot;:true};&lt;/script&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;http://s7.addthis.com/js/250/addthis_widget.js#username=bawar&quot;&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;&lt;/p&gt;&#039;.&quot;\n&quot;;

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

?&gt;
&lt;div class=&quot;linkst&quot;&gt;
    &lt;div class=&quot;inbox&quot;&gt;
        &lt;p class=&quot;pagelink conl&quot;&gt;&lt;?php echo $paging_links ?&gt;&lt;/p&gt;
        &lt;p class=&quot;postlink conr&quot;&gt;&lt;?php echo $post_link ?&gt;&lt;/p&gt;
        &lt;ul&gt;&lt;li&gt;&lt;a href=&quot;index.php&quot;&gt;&lt;?php echo $lang_common[&#039;Index&#039;] ?&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&amp;nbsp;&amp;raquo;&amp;nbsp;&lt;a href=&quot;viewforum.php?id=&lt;?php echo $cur_topic[&#039;forum_id&#039;] ?&gt;&quot;&gt;&lt;?php echo pun_htmlspecialchars($cur_topic[&#039;forum_name&#039;]) ?&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&amp;nbsp;&amp;raquo;&amp;nbsp;&lt;?php echo pun_htmlspecialchars($cur_topic[&#039;subject&#039;]) ?&gt;&lt;/li&gt;&lt;/ul&gt;
        &lt;div class=&quot;clearer&quot;&gt;&lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;?php


require PUN_ROOT.&#039;include/parser.php&#039;;
require PUN_ROOT.&#039;include/user_agent.php&#039;;

$bg_switch = true;    // Used for switching background color in posts
$post_count = 0;    // Keep track of post numbers

// Retrieve the posts (and their respective poster/online status)
       $result = $db-&gt;query(&#039;SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, 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, o.user_id AS is_online FROM &#039;.$db-&gt;prefix.&#039;posts AS p INNER JOIN &#039;.$db-&gt;prefix.&#039;users AS u ON u.id=p.poster_id INNER JOIN &#039;.$db-&gt;prefix.&#039;groups AS g ON g.g_id=u.group_id LEFT JOIN &#039;.$db-&gt;prefix.&#039;online AS o ON (o.user_id=u.id AND o.user_id!=1 AND o.idle=0) WHERE p.topic_id=&#039;.$id.&#039; ORDER BY p.id LIMIT &#039;.$start_from.&#039;,&#039;.$pun_user[&#039;disp_posts&#039;], true) or error(&#039;Unable to fetch post info&#039;, __FILE__, __LINE__, $db-&gt;error()); 
while ($cur_post = $db-&gt;fetch_assoc($result))
{
    $post_count++;
    $user_avatar = &#039;&lt;img src=&quot;http://webchinupload.com/files/wenay%20asay_1.gif&quot; alt=&quot;avatar&quot; /&gt;&#039;;
    $user_info = array();
    $user_contacts = array();
    $post_actions = array();
    $is_online = &#039;&#039;;
    $signature = &#039;&#039;;
        $rank_pips = &quot;&quot;;


    // If the poster is a registered user.
    if ($cur_post[&#039;poster_id&#039;] &gt; 1)
    {
 if($cur_post[&#039;num_posts&#039;] &gt; 5000) { $num_pips = 10; }
        elseif($cur_post[&#039;num_posts&#039;] &gt; 3000) { $num_pips = 9; }
        elseif($cur_post[&#039;num_posts&#039;] &gt; 2000) { $num_pips = 8; }
        elseif($cur_post[&#039;num_posts&#039;] &gt; 1000) { $num_pips = 7; }
        elseif($cur_post[&#039;num_posts&#039;] &gt; 500) { $num_pips = 6; }
        elseif($cur_post[&#039;num_posts&#039;] &gt; 300) { $num_pips = 5; }
        elseif($cur_post[&#039;num_posts&#039;] &gt; 100) { $num_pips = 4; }
        elseif($cur_post[&#039;num_posts&#039;] &gt; 50) { $num_pips = 3; }
        elseif($cur_post[&#039;num_posts&#039;] &gt; 10) { $num_pips = 2; }
        else { $num_pips = 1; }
 
        for($pip=0; $pip&lt;$num_pips; $pip++) {
            $rank_pips .= &#039;&lt;img src=&quot;img/pip.gif&quot; alt=&quot;&quot; /&gt;&#039;;
        }
        $username = &#039;&lt;a href=&quot;profile.php?id=&#039;.$cur_post[&#039;poster_id&#039;].&#039;&quot;&gt;&#039;.pun_htmlspecialchars($cur_post[&#039;username&#039;]).&#039;&lt;/a&gt;&#039;;
        $user_title = get_title($cur_post);    $user_country = $cur_post[&#039;country&#039;];

        if ($pun_config[&#039;o_censoring&#039;] == &#039;1&#039;)
            $user_title = censor_words($user_title);

        // Format the online indicator
        $is_online = ($cur_post[&#039;is_online&#039;] == $cur_post[&#039;poster_id&#039;]) ? &#039;&lt;strong&gt;&lt;font color=&quot;green&quot;&gt;&#039;.$lang_topic[&#039;Online&#039;].&#039;&lt;/font&gt;&lt;/strong&gt;&#039; : &#039;&lt;font color=&quot;red&quot;&gt;&#039;.$lang_topic[&#039;Offline&#039;].&#039;&lt;/font&gt;&#039;;


        if ($pun_config[&#039;o_avatars&#039;] == &#039;1&#039; &amp;&amp; $cur_post[&#039;use_avatar&#039;] == &#039;1&#039; &amp;&amp; $pun_user[&#039;show_avatars&#039;] != &#039;0&#039;)
        {
            if ($img_size = @getimagesize($pun_config[&#039;o_avatars_dir&#039;].&#039;/&#039;.$cur_post[&#039;poster_id&#039;].&#039;.gif&#039;))
                $user_avatar = &#039;&lt;img src=&quot;&#039;.$pun_config[&#039;o_avatars_dir&#039;].&#039;/&#039;.$cur_post[&#039;poster_id&#039;].&#039;.gif&quot; &#039;.$img_size[3].&#039; alt=&quot;&quot; /&gt;&#039;;
            else if ($img_size = @getimagesize($pun_config[&#039;o_avatars_dir&#039;].&#039;/&#039;.$cur_post[&#039;poster_id&#039;].&#039;.jpg&#039;))
                $user_avatar = &#039;&lt;img src=&quot;&#039;.$pun_config[&#039;o_avatars_dir&#039;].&#039;/&#039;.$cur_post[&#039;poster_id&#039;].&#039;.jpg&quot; &#039;.$img_size[3].&#039; alt=&quot;&quot; /&gt;&#039;;
            else if ($img_size = @getimagesize($pun_config[&#039;o_avatars_dir&#039;].&#039;/&#039;.$cur_post[&#039;poster_id&#039;].&#039;.png&#039;))
                $user_avatar = &#039;&lt;img src=&quot;&#039;.$pun_config[&#039;o_avatars_dir&#039;].&#039;/&#039;.$cur_post[&#039;poster_id&#039;].&#039;.png&quot; &#039;.$img_size[3].&#039; alt=&quot;&quot; /&gt;&#039;;
        }
        else
            $user_avatar = &#039;&#039;;

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

                $user_info[] = &#039;&lt;dd&gt;&#039;.$lang_topic[&#039;From&#039;].&#039;: &#039;.pun_htmlspecialchars($cur_post[&#039;location&#039;]);
            }

            $user_info[] = &#039;&lt;dd&gt;&#039;.$lang_common[&#039;Registered&#039;].&#039;: &#039;.date($pun_config[&#039;o_date_format&#039;], $cur_post[&#039;registered&#039;]);

            if ($pun_config[&#039;o_show_post_count&#039;] == &#039;1&#039; || $pun_user[&#039;g_id&#039;] &lt; PUN_GUEST)
                $user_info[] = &#039;&lt;dd&gt;&#039;.$lang_common[&#039;Posts&#039;].&#039;: &#039;.$cur_post[&#039;num_posts&#039;];

            // Now let&#039;s deal with the contact links (E-mail and URL)
            if (($cur_post[&#039;email_setting&#039;] == &#039;0&#039; &amp;&amp; !$pun_user[&#039;is_guest&#039;]) || $pun_user[&#039;g_id&#039;] &lt; PUN_GUEST)
                $user_contacts[] = &#039;&lt;a href=&quot;mailto:&#039;.$cur_post[&#039;email&#039;].&#039;&quot;&gt;&#039;.$lang_common[&#039;E-mail&#039;].&#039;&lt;/a&gt;&#039;;
            else if ($cur_post[&#039;email_setting&#039;] == &#039;1&#039; &amp;&amp; !$pun_user[&#039;is_guest&#039;])
                $user_contacts[] = &#039;&lt;a href=&quot;misc.php?email=&#039;.$cur_post[&#039;poster_id&#039;].&#039;&quot;&gt;&#039;.$lang_common[&#039;E-mail&#039;].&#039;&lt;/a&gt;&#039;;
            require(PUN_ROOT.&#039;include/pms/viewtopic_PM-link.php&#039;);

            if ($cur_post[&#039;url&#039;] != &#039;&#039;)
                $user_contacts[] = &#039;&lt;a href=&quot;&#039;.pun_htmlspecialchars($cur_post[&#039;url&#039;]).&#039;&quot;&gt;&#039;.$lang_topic[&#039;Website&#039;].&#039;&lt;/a&gt;&#039;;
        }

        if ($pun_user[&#039;g_id&#039;] &lt; PUN_GUEST)
        {
            $user_info[] = &#039;&lt;dd&gt;IP: &lt;a href=&quot;moderate.php?get_host=&#039;.$cur_post[&#039;id&#039;].&#039;&quot;&gt;&#039;.$cur_post[&#039;poster_ip&#039;].&#039;&lt;/a&gt;&#039;;

            if ($cur_post[&#039;admin_note&#039;] != &#039;&#039;)
                $user_info[] = &#039;&lt;dd&gt;&#039;.$lang_topic[&#039;Note&#039;].&#039;: &lt;strong&gt;&#039;.pun_htmlspecialchars($cur_post[&#039;admin_note&#039;]).&#039;&lt;/strong&gt;&#039;;
        }
    }
    // If the poster is a guest (or a user that has been deleted)
    else
    {
        $username = pun_htmlspecialchars($cur_post[&#039;username&#039;]);
        $user_title = get_title($cur_post);

        if ($pun_user[&#039;g_id&#039;] &lt; PUN_GUEST)
            $user_info[] = &#039;&lt;dd&gt;IP: &lt;a href=&quot;moderate.php?get_host=&#039;.$cur_post[&#039;id&#039;].&#039;&quot;&gt;&#039;.$cur_post[&#039;poster_ip&#039;].&#039;&lt;/a&gt;&#039;;

        if ($pun_config[&#039;o_show_user_info&#039;] == &#039;1&#039; &amp;&amp; $cur_post[&#039;poster_email&#039;] != &#039;&#039; &amp;&amp; !$pun_user[&#039;is_guest&#039;])
            $user_contacts[] = &#039;&lt;a href=&quot;mailto:&#039;.$cur_post[&#039;poster_email&#039;].&#039;&quot;&gt;&#039;.$lang_common[&#039;E-mail&#039;].&#039;&lt;/a&gt;&#039;;
    }

    // Generation post action array (quote, edit, delete etc.)
    if (!$is_admmod)
    {
        if (!$pun_user[&#039;is_guest&#039;])
            $post_actions[] = &#039;&lt;li class=&quot;postreport&quot;&gt;&lt;a href=&quot;misc.php?report=&#039;.$cur_post[&#039;id&#039;].&#039;&quot;&gt;&#039;.$lang_topic[&#039;Report&#039;].&#039;&lt;/a&gt;&#039;;

        if ($cur_topic[&#039;closed&#039;] == &#039;0&#039;)
        {
            if ($cur_post[&#039;poster_id&#039;] == $pun_user[&#039;id&#039;])
            {
                if ((($start_from + $post_count) == 1 &amp;&amp; $pun_user[&#039;g_delete_topics&#039;] == &#039;1&#039;) || (($start_from + $post_count) &gt; 1 &amp;&amp; $pun_user[&#039;g_delete_posts&#039;] == &#039;1&#039;))
                    $post_actions[] = &#039;&lt;li class=&quot;postdelete&quot;&gt;&lt;a href=&quot;delete.php?id=&#039;.$cur_post[&#039;id&#039;].&#039;&quot;&gt;&#039;.$lang_topic[&#039;Delete&#039;].&#039;&lt;/a&gt;&#039;;
                if ($pun_user[&#039;g_edit_posts&#039;] == &#039;1&#039;)
                    $post_actions[] = &#039;&lt;li class=&quot;postedit&quot;&gt;&lt;a href=&quot;edit.php?id=&#039;.$cur_post[&#039;id&#039;].&#039;&quot;&gt;&#039;.$lang_topic[&#039;Edit&#039;].&#039;&lt;/a&gt;&#039;;
            }

            if (($cur_topic[&#039;post_replies&#039;] == &#039;&#039; &amp;&amp; $pun_user[&#039;g_post_replies&#039;] == &#039;1&#039;) || $cur_topic[&#039;post_replies&#039;] == &#039;1&#039;)
                $post_actions[] = &#039;&lt;li class=&quot;postquote&quot;&gt;&lt;a href=&quot;post.php?tid=&#039;.$id.&#039;&amp;amp;qid=&#039;.$cur_post[&#039;id&#039;].&#039;&quot;&gt;&#039;.$lang_topic[&#039;Quote&#039;].&#039;&lt;/a&gt;&#039;;
        }
    }
    else
        $post_actions[] = &#039;&lt;li class=&quot;postreport&quot;&gt;&lt;a href=&quot;misc.php?report=&#039;.$cur_post[&#039;id&#039;].&#039;&quot;&gt;&#039;.$lang_topic[&#039;Report&#039;].&#039;&lt;/a&gt;&#039;.$lang_topic[&#039;Link separator&#039;].&#039;&lt;/li&gt;&lt;li class=&quot;postdelete&quot;&gt;&lt;a href=&quot;delete.php?id=&#039;.$cur_post[&#039;id&#039;].&#039;&quot;&gt;&#039;.$lang_topic[&#039;Delete&#039;].&#039;&lt;/a&gt;&#039;.$lang_topic[&#039;Link separator&#039;].&#039;&lt;/li&gt;&lt;li class=&quot;postedit&quot;&gt;&lt;a href=&quot;edit.php?id=&#039;.$cur_post[&#039;id&#039;].&#039;&quot;&gt;&#039;.$lang_topic[&#039;Edit&#039;].&#039;&lt;/a&gt;&#039;.$lang_topic[&#039;Link separator&#039;].&#039;&lt;/li&gt;&lt;li class=&quot;postquote&quot;&gt;&lt;a href=&quot;post.php?tid=&#039;.$id.&#039;&amp;amp;qid=&#039;.$cur_post[&#039;id&#039;].&#039;&quot;&gt;&#039;.$lang_topic[&#039;Quote&#039;].&#039;&lt;/a&gt;&#039;;


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


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

    // Do signature parsing/caching
    if ($cur_post[&#039;signature&#039;] != &#039;&#039; &amp;&amp; $pun_user[&#039;show_sig&#039;] != &#039;0&#039;)
    {
        if (isset($signature_cache[$cur_post[&#039;poster_id&#039;]]))
            $signature = $signature_cache[$cur_post[&#039;poster_id&#039;]];
        else
        {
            $signature = parse_signature($cur_post[&#039;signature&#039;]);
            $signature_cache[$cur_post[&#039;poster_id&#039;]] = $signature;
        }
    }

?&gt;
&lt;div id=&quot;p&lt;?php echo $cur_post[&#039;id&#039;] ?&gt;&quot; class=&quot;blockpost&lt;?php echo $vtbg ?&gt;&lt;?php if (($post_count + $start_from) == 1) echo &#039; firstpost&#039;; ?&gt;&quot;&gt;
    &lt;h2&gt;&lt;span&gt;&lt;span class=&quot;conr&quot;&gt;#&lt;?php echo ($start_from + $post_count) ?&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;viewtopic.php?pid=&lt;?php echo $cur_post[&#039;id&#039;].&#039;#p&#039;.$cur_post[&#039;id&#039;] ?&gt;&quot;&gt;&lt;?php echo format_time($cur_post[&#039;posted&#039;]) ?&gt;&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;
    &lt;div class=&quot;box&quot;&gt;
        &lt;div class=&quot;inbox&quot;&gt;
            &lt;div class=&quot;postleft&quot;&gt;
                &lt;dl&gt;
                    &lt;dt&gt;&lt;strong&gt;&lt;?php echo $username ?&gt;&lt;/strong&gt;&lt;/dt&gt;
                    &lt;dd class=&quot;usertitle&quot;&gt;&lt;strong&gt;&lt;?php echo $user_title ?&gt;&lt;/strong&gt;&lt;/dd&gt;
                                        &lt;dd class=&quot;usertitle&quot;&gt;&lt;?php echo $rank_pips ?&gt;&lt;/dd&gt;
                    &lt;dd class=&quot;postavatar&quot;&gt;&lt;?php echo $user_avatar ?&gt;&lt;/dd&gt; &lt;?php if ( $user_country != &#039;&#039;) {
                echo &#039;&lt;dd class=&quot;postavatar&quot;&gt;&lt;img src=&quot;./img/flags/&#039;.$user_country.&#039;.png&quot; alt=&quot;&#039;.$user_country.&#039;&quot; title=&quot;&#039;.$user_country.&#039;&quot;&gt;&lt;/dd&gt;&#039;; } ?&gt;

&lt;?php if (count($user_info)) echo &quot;\t\t\t\t\t&quot;.implode(&#039;&lt;/dd&gt;&#039;.&quot;\n\t\t\t\t\t&quot;, $user_info).&#039;&lt;/dd&gt;&#039;.&quot;\n&quot;; ?&gt;
&lt;?php if (count($user_contacts)) echo &quot;\t\t\t\t\t&quot;.&#039;&lt;dd class=&quot;usercontacts&quot;&gt;&#039;.implode(&#039;&amp;nbsp;&amp;nbsp;&#039;, $user_contacts).&#039;&lt;/dd&gt;&#039;.&quot;\n&quot;; ?&gt;
&lt;?php if ($cur_post[&#039;user_agent&#039;]) echo &#039;&lt;dd class=&quot;usercontacts&quot;&gt;&#039; . UserAgentIcons($cur_post[&#039;user_agent&#039;]) . &#039;&lt;/dd&gt;&#039;;?&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;bookmark.js&quot;&gt;
&lt;/script&gt;
                &lt;/dl&gt;
            &lt;/div&gt;
            &lt;div class=&quot;postright&quot;&gt;
                &lt;h3&gt;&lt;?php if (($post_count + $start_from) &gt; 1) echo &#039; Re: &#039;; ?&gt;&lt;?php echo pun_htmlspecialchars($cur_topic[&#039;subject&#039;]) ?&gt;&lt;/h3&gt;
                &lt;div class=&quot;postmsg&quot;&gt;
                    &lt;?php echo $cur_post[&#039;message&#039;].&quot;\n&quot; ?&gt;
&lt;?php if ($cur_post[&#039;edited&#039;] != &#039;&#039;) echo &quot;\t\t\t\t\t&quot;.&#039;&lt;p class=&quot;postedit&quot;&gt;&lt;em&gt;&#039;.$lang_topic[&#039;Last edit&#039;].&#039; &#039;.pun_htmlspecialchars($cur_post[&#039;edited_by&#039;]).&#039; (&#039;.format_time($cur_post[&#039;edited&#039;]).&#039;)&lt;/em&gt;&lt;/p&gt;&#039;.&quot;\n&quot;; ?&gt;
                &lt;/div&gt;
&lt;?php if ($signature != &#039;&#039;) echo &quot;\t\t\t\t&quot;.&#039;&lt;div class=&quot;postsignature&quot;&gt;&lt;img src=&quot;http://www.webchinupload.com/files/xoshnaw%20%20SH%20(1)_2.gif&quot; alt=&quot;naw&quot; /&gt;&#039;.$signature.&#039;&lt;/div&gt;&#039;.&quot;\n&quot;; ?&gt;
            &lt;/div&gt;
            &lt;div class=&quot;clearer&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;postfootleft&quot;&gt;&lt;?php if ($cur_post[&#039;poster_id&#039;] &gt; 1) echo &#039;&lt;p&gt;&#039;.$is_online.&#039;&lt;/p&gt;&#039;; ?&gt;&lt;/div&gt;
            &lt;div class=&quot;postfootright&quot;&gt;&lt;?php echo (count($post_actions)) ? &#039;&lt;ul&gt;&#039;.implode($lang_topic[&#039;Link separator&#039;].&#039;&lt;/li&gt;&#039;, $post_actions).&#039;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&#039;.&quot;\n&quot; : &#039;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&#039;.&quot;\n&quot; ?&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;?php

}

?&gt;
&lt;div class=&quot;postlinksb&quot;&gt;
    &lt;div class=&quot;inbox&quot;&gt;
        &lt;p class=&quot;postlink conr&quot;&gt;&lt;?php echo $post_link ?&gt;&lt;/p&gt;
        &lt;p class=&quot;pagelink conl&quot;&gt;&lt;?php echo $paging_links ?&gt;&lt;/p&gt;
        &lt;ul&gt;&lt;li&gt;&lt;a href=&quot;index.php&quot;&gt;&lt;?php echo $lang_common[&#039;Index&#039;] ?&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&amp;nbsp;&amp;raquo;&amp;nbsp;&lt;a href=&quot;viewforum.php?id=&lt;?php echo $cur_topic[&#039;forum_id&#039;] ?&gt;&quot;&gt;&lt;?php echo pun_htmlspecialchars($cur_topic[&#039;forum_name&#039;]) ?&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&amp;nbsp;&amp;raquo;&amp;nbsp;&lt;?php echo pun_htmlspecialchars($cur_topic[&#039;subject&#039;]) ?&gt;&lt;/li&gt;&lt;/ul&gt;
        &lt;?php echo $subscraction ?&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;!-- AddThis Button BEGIN --&gt;
&lt;div class=&quot;addthis_toolbox addthis_default_style addthis_32x32_style&quot;&gt;
&lt;a class=&quot;addthis_button_preferred_1&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;addthis_button_preferred_2&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;addthis_button_preferred_3&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;addthis_button_preferred_4&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;addthis_button_compact&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;addthis_counter addthis_bubble_style&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4de7f5e5136d9f7a&quot;&gt;&lt;/script&gt;
&lt;!-- AddThis Button END --&gt;
&lt;?php

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

?&gt;
&lt;div class=&quot;blockform&quot;&gt;
    &lt;h2&gt;&lt;span&gt;&lt;?php echo $lang_topic[&#039;Quick post&#039;] ?&gt;&lt;/span&gt;&lt;/h2&gt;
    &lt;div class=&quot;box&quot;&gt;
        &lt;form id=&quot;post&quot; method=&quot;post&quot; name=&quot;qpost&quot; action=&quot;post.php?tid=&lt;?php echo $id ?&gt;&quot; onsubmit=&quot;this.submit.disabled=true;if(process_form(this)){return true;}else{this.submit.disabled=false;return false;}&quot;&gt;
            &lt;div class=&quot;inform&quot;&gt;
                &lt;fieldset&gt;
                    &lt;legend&gt;&lt;?php echo $lang_common[&#039;Write message legend&#039;] ?&gt;&lt;/legend&gt;
                    &lt;div class=&quot;infldset txtarea&quot;&gt;
                        &lt;input type=&quot;hidden&quot; name=&quot;form_sent&quot; value=&quot;1&quot; /&gt;
                        &lt;input type=&quot;hidden&quot; name=&quot;form_user&quot; value=&quot;&lt;?php echo (!$pun_user[&#039;is_guest&#039;]) ? pun_htmlspecialchars($pun_user[&#039;username&#039;]) : &#039;Guest&#039;; ?&gt;&quot; /&gt;
                        &lt;?php require PUN_ROOT.&#039;mod_modern_bbcode.php&#039;; ?&gt;
                        &lt;label&gt;&lt;textarea name=&quot;req_message&quot; rows=&quot;7&quot; cols=&quot;75&quot; tabindex=&quot;1&quot;&gt;&lt;/textarea&gt;&lt;/label&gt;
                        &lt;ul class=&quot;bblinks&quot;&gt;
                            &lt;li&gt;&lt;a href=&quot;help.php#bbcode&quot; onclick=&quot;window.open(this.href); return false;&quot;&gt;&lt;?php echo $lang_common[&#039;BBCode&#039;] ?&gt;&lt;/a&gt;: &lt;?php echo ($pun_config[&#039;p_message_bbcode&#039;] == &#039;1&#039;) ? $lang_common[&#039;on&#039;] : $lang_common[&#039;off&#039;]; ?&gt;&lt;/li&gt;
                            &lt;li&gt;&lt;a href=&quot;help.php#img&quot; onclick=&quot;window.open(this.href); return false;&quot;&gt;&lt;?php echo $lang_common[&#039;img tag&#039;] ?&gt;&lt;/a&gt;: &lt;?php echo ($pun_config[&#039;p_message_img_tag&#039;] == &#039;1&#039;) ? $lang_common[&#039;on&#039;] : $lang_common[&#039;off&#039;]; ?&gt;&lt;/li&gt;
                            &lt;li&gt;&lt;a href=&quot;help.php#smilies&quot; onclick=&quot;window.open(this.href); return false;&quot;&gt;&lt;?php echo $lang_common[&#039;Smilies&#039;] ?&gt;&lt;/a&gt;: &lt;?php echo ($pun_config[&#039;o_smilies&#039;] == &#039;1&#039;) ? $lang_common[&#039;on&#039;] : $lang_common[&#039;off&#039;]; ?&gt;&lt;/li&gt;
                        &lt;/ul&gt;
                    &lt;/div&gt;
                &lt;/fieldset&gt;
            &lt;/div&gt;
            &lt;p&gt;&lt;input type=&quot;submit&quot; name=&quot;submit&quot; tabindex=&quot;2&quot; value=&quot;&lt;?php echo $lang_common[&#039;Submit&#039;] ?&gt;&quot; accesskey=&quot;s&quot; /&gt;&lt;/p&gt;
        &lt;/form&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;?php

}

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

$forum_id = $cur_topic[&#039;forum_id&#039;];
$footer_style = &#039;viewtopic&#039;;
require PUN_ROOT.&#039;footer.php&#039;;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (ئاسۆ نادری)]]></author>
			<pubDate>Sat, 26 May 2012 01:33:11 +0000</pubDate>
			<guid>https://www.webchin.org/Meko/viewtopic.php?pid=219964#p219964</guid>
		</item>
		<item>
			<title><![CDATA[وه‌ڵام: كه‌ زانياری تاكه‌كه‌سی ئه‌كه‌مه‌وه‌ ئه‌مه‌ ديت]]></title>
			<link>https://www.webchin.org/Meko/viewtopic.php?pid=219963#p219963</link>
			<description><![CDATA[<p>ببوره‌ له‌ لای من هه‌ر ئه‌مه‌ ئه‌نوسريت&nbsp; هەڵە، بەداخەوە پەڕەی ویستراو نەتوانرا بکرێتەوە</p><p>لەوانەیە کێشەیەکی کاتیی بێت، تکایە پەڕەکە نوێ بکەوە و ئەگەر کێشەکە بەردەوام بوو پاش ١٠ خوولەکی دیکە بگەڕێوە</p><p>ئه‌وه‌ش ئه‌ كۆده‌<br /></p><div class="codebox"><pre><code data-language=php>&lt;?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(&#039;PUN_ROOT&#039;, &#039;./&#039;);
require PUN_ROOT.&#039;include/common.php&#039;;


if ($pun_user[&#039;g_read_board&#039;] == &#039;0&#039;)
    message($lang_common[&#039;No view&#039;]);


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

// Load the viewtopic.php language file
require PUN_ROOT.&#039;lang/&#039;.$pun_user[&#039;language&#039;].&#039;/topic.php&#039;;


// 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-&gt;query(&#039;SELECT topic_id FROM &#039;.$db-&gt;prefix.&#039;posts WHERE id=&#039;.$pid) or error(&#039;Unable to fetch post info&#039;, __FILE__, __LINE__, $db-&gt;error());
    if (!$db-&gt;num_rows($result))
        message($lang_common[&#039;Bad request&#039;]);

    $id = $db-&gt;result($result);

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

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

    $_GET[&#039;p&#039;] = ceil($i / $pun_user[&#039;disp_posts&#039;]);
}

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

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

    exit;
}

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

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


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

if (!$db-&gt;num_rows($result))
    message($lang_common[&#039;Bad request&#039;]);

$cur_topic = $db-&gt;fetch_assoc($result);

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

// Can we or can we not post replies?
if ($cur_topic[&#039;closed&#039;] == &#039;0&#039;)
{
    if (($cur_topic[&#039;post_replies&#039;] == &#039;&#039; &amp;&amp; $pun_user[&#039;g_post_replies&#039;] == &#039;1&#039;) || $cur_topic[&#039;post_replies&#039;] == &#039;1&#039; || $is_admmod)
        $post_link = &#039;&lt;a href=&quot;post.php?tid=&#039;.$id.&#039;&quot;&gt;&#039;.$lang_topic[&#039;Post reply&#039;].&#039;&lt;/a&gt;&#039;;
    else
        $post_link = &#039;&amp;nbsp;&#039;;
}
else
{
    $post_link = $lang_topic[&#039;Topic closed&#039;];

    if ($is_admmod)
        $post_link .= &#039; / &lt;a href=&quot;post.php?tid=&#039;.$id.&#039;&quot;&gt;&#039;.$lang_topic[&#039;Post reply&#039;].&#039;&lt;/a&gt;&#039;;
}


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

$p = (!isset($_GET[&#039;p&#039;]) || $_GET[&#039;p&#039;] &lt;= 1 || $_GET[&#039;p&#039;] &gt; $num_pages) ? 1 : $_GET[&#039;p&#039;];
$start_from = $pun_user[&#039;disp_posts&#039;] * ($p - 1);

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


if ($pun_config[&#039;o_censoring&#039;] == &#039;1&#039;)
    $cur_topic[&#039;subject&#039;] = censor_words($cur_topic[&#039;subject&#039;]);


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

if (!$pun_user[&#039;is_guest&#039;] &amp;&amp; $pun_config[&#039;o_subscriptions&#039;] == &#039;1&#039;)
{
    if ($cur_topic[&#039;is_subscribed&#039;])
        // I apologize for the variable naming here. It&#039;s a mix of subscription and action I guess :-)
        $subscraction = &#039;&lt;p class=&quot;subscribelink clearb&quot;&gt;&#039;.$lang_topic[&#039;Is subscribed&#039;].&#039; - &lt;a href=&quot;misc.php?unsubscribe=&#039;.$id.&#039;&quot;&gt;&#039;.$lang_topic[&#039;Unsubscribe&#039;].&#039;&lt;/a&gt;&lt;/p&gt;&#039;.&quot;\n&quot;;
    else
        $subscraction = &#039;&lt;p class=&quot;subscribelink clearb&quot;&gt;&lt;a href=&quot;misc.php?subscribe=&#039;.$id.&#039;&quot;&gt;&#039;.$lang_topic[&#039;Subscribe&#039;].&#039;&lt;/a&gt;&lt;/p&gt;&#039;.&quot;\n&quot;;
}
else
    $subscraction = &#039;&lt;p class=&quot;subscribelink clearb&quot;&gt;&lt;a href=&quot;misc.php?subscribe=&#039;.$id.&#039;&quot;&gt;&#039;.$lang_topic[&#039;Subscribe&#039;].&#039;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;!-- AddThis Button BEGIN --&gt;&lt;div class=&quot;addthis_toolbox addthis_default_style &quot;&gt;&lt;a href=&quot;http://www.addthis.com/bookmark.php?v=250&amp;amp;username=bawar&quot; class=&quot;addthis_button_compact&quot;&gt;Share&lt;/a&gt;&lt;span class=&quot;addthis_separator&quot;&gt;|&lt;/span&gt;&lt;a class=&quot;addthis_button_preferred_1&quot;&gt;&lt;/a&gt;&lt;a class=&quot;addthis_button_preferred_2&quot;&gt;&lt;/a&gt;&lt;a class=&quot;addthis_button_preferred_3&quot;&gt;&lt;/a&gt;&lt;a class=&quot;addthis_button_preferred_4&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;var addthis_config = {&quot;data_track_clickback&quot;:true};&lt;/script&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;http://s7.addthis.com/js/250/addthis_widget.js#username=bawar&quot;&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;&lt;/p&gt;&#039;.&quot;\n&quot;;

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

?&gt;
&lt;div class=&quot;linkst&quot;&gt;
    &lt;div class=&quot;inbox&quot;&gt;
        &lt;p class=&quot;pagelink conl&quot;&gt;&lt;?php echo $paging_links ?&gt;&lt;/p&gt;
        &lt;p class=&quot;postlink conr&quot;&gt;&lt;?php echo $post_link ?&gt;&lt;/p&gt;
        &lt;ul&gt;&lt;li&gt;&lt;a href=&quot;index.php&quot;&gt;&lt;?php echo $lang_common[&#039;Index&#039;] ?&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&amp;nbsp;&amp;raquo;&amp;nbsp;&lt;a href=&quot;viewforum.php?id=&lt;?php echo $cur_topic[&#039;forum_id&#039;] ?&gt;&quot;&gt;&lt;?php echo pun_htmlspecialchars($cur_topic[&#039;forum_name&#039;]) ?&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&amp;nbsp;&amp;raquo;&amp;nbsp;&lt;?php echo pun_htmlspecialchars($cur_topic[&#039;subject&#039;]) ?&gt;&lt;/li&gt;&lt;/ul&gt;
        &lt;div class=&quot;clearer&quot;&gt;&lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;?php


require PUN_ROOT.&#039;include/parser.php&#039;;
require PUN_ROOT.&#039;include/user_agent.php&#039;;

$bg_switch = true;    // Used for switching background color in posts
$post_count = 0;    // Keep track of post numbers

// Retrieve the posts (and their respective poster/online status)
       $result = $db-&gt;query(&#039;SELECT 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, 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, o.user_id AS is_online FROM &#039;.$db-&gt;prefix.&#039;posts AS p INNER JOIN &#039;.$db-&gt;prefix.&#039;users AS u ON u.id=p.poster_id INNER JOIN &#039;.$db-&gt;prefix.&#039;groups AS g ON g.g_id=u.group_id LEFT JOIN &#039;.$db-&gt;prefix.&#039;online AS o ON (o.user_id=u.id AND o.user_id!=1 AND o.idle=0) WHERE p.topic_id=&#039;.$id.&#039; ORDER BY p.id LIMIT &#039;.$start_from.&#039;,&#039;.$pun_user[&#039;disp_posts&#039;], true) or error(&#039;Unable to fetch post info&#039;, __FILE__, __LINE__, $db-&gt;error()); 
while ($cur_post = $db-&gt;fetch_assoc($result))
{
    $post_count++;
    $user_avatar = &#039;&lt;img src=&quot;http://webchinupload.com/files/wenay%20asay_1.gif&quot; alt=&quot;avatar&quot; /&gt;&#039;;
    $user_info = array();
    $user_contacts = array();
    $post_actions = array();
    $is_online = &#039;&#039;;
    $signature = &#039;&#039;;
        $rank_pips = &quot;&quot;;


    // If the poster is a registered user.
    if ($cur_post[&#039;poster_id&#039;] &gt; 1)
    {
 if($cur_post[&#039;num_posts&#039;] &gt; 5000) { $num_pips = 10; }
        elseif($cur_post[&#039;num_posts&#039;] &gt; 3000) { $num_pips = 9; }
        elseif($cur_post[&#039;num_posts&#039;] &gt; 2000) { $num_pips = 8; }
        elseif($cur_post[&#039;num_posts&#039;] &gt; 1000) { $num_pips = 7; }
        elseif($cur_post[&#039;num_posts&#039;] &gt; 500) { $num_pips = 6; }
        elseif($cur_post[&#039;num_posts&#039;] &gt; 300) { $num_pips = 5; }
        elseif($cur_post[&#039;num_posts&#039;] &gt; 100) { $num_pips = 4; }
        elseif($cur_post[&#039;num_posts&#039;] &gt; 50) { $num_pips = 3; }
        elseif($cur_post[&#039;num_posts&#039;] &gt; 10) { $num_pips = 2; }
        else { $num_pips = 1; }
 
        for($pip=0; $pip&lt;$num_pips; $pip++) {
            $rank_pips .= &#039;&lt;img src=&quot;img/pip.gif&quot; alt=&quot;&quot; /&gt;&#039;;
        }
        $username = &#039;&lt;a href=&quot;profile.php?id=&#039;.$cur_post[&#039;poster_id&#039;].&#039;&quot;&gt;&#039;.pun_htmlspecialchars($cur_post[&#039;username&#039;]).&#039;&lt;/a&gt;&#039;;
        $user_title = get_title($cur_post);    $user_country = $cur_post[&#039;country&#039;];

        if ($pun_config[&#039;o_censoring&#039;] == &#039;1&#039;)
            $user_title = censor_words($user_title);

        // Format the online indicator
        $is_online = ($cur_post[&#039;is_online&#039;] == $cur_post[&#039;poster_id&#039;]) ? &#039;&lt;strong&gt;&lt;font color=&quot;green&quot;&gt;&#039;.$lang_topic[&#039;Online&#039;].&#039;&lt;/font&gt;&lt;/strong&gt;&#039; : &#039;&lt;font color=&quot;red&quot;&gt;&#039;.$lang_topic[&#039;Offline&#039;].&#039;&lt;/font&gt;&#039;;


        if ($pun_config[&#039;o_avatars&#039;] == &#039;1&#039; &amp;&amp; $cur_post[&#039;use_avatar&#039;] == &#039;1&#039; &amp;&amp; $pun_user[&#039;show_avatars&#039;] != &#039;0&#039;)
        {
            if ($img_size = @getimagesize($pun_config[&#039;o_avatars_dir&#039;].&#039;/&#039;.$cur_post[&#039;poster_id&#039;].&#039;.gif&#039;))
                $user_avatar = &#039;&lt;img src=&quot;&#039;.$pun_config[&#039;o_avatars_dir&#039;].&#039;/&#039;.$cur_post[&#039;poster_id&#039;].&#039;.gif&quot; &#039;.$img_size[3].&#039; alt=&quot;&quot; /&gt;&#039;;
            else if ($img_size = @getimagesize($pun_config[&#039;o_avatars_dir&#039;].&#039;/&#039;.$cur_post[&#039;poster_id&#039;].&#039;.jpg&#039;))
                $user_avatar = &#039;&lt;img src=&quot;&#039;.$pun_config[&#039;o_avatars_dir&#039;].&#039;/&#039;.$cur_post[&#039;poster_id&#039;].&#039;.jpg&quot; &#039;.$img_size[3].&#039; alt=&quot;&quot; /&gt;&#039;;
            else if ($img_size = @getimagesize($pun_config[&#039;o_avatars_dir&#039;].&#039;/&#039;.$cur_post[&#039;poster_id&#039;].&#039;.png&#039;))
                $user_avatar = &#039;&lt;img src=&quot;&#039;.$pun_config[&#039;o_avatars_dir&#039;].&#039;/&#039;.$cur_post[&#039;poster_id&#039;].&#039;.png&quot; &#039;.$img_size[3].&#039; alt=&quot;&quot; /&gt;&#039;;
        }
        else
            $user_avatar = &#039;&#039;;

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

                $user_info[] = &#039;&lt;dd&gt;&#039;.$lang_topic[&#039;From&#039;].&#039;: &#039;.pun_htmlspecialchars($cur_post[&#039;location&#039;]);
            }

            $user_info[] = &#039;&lt;dd&gt;&#039;.$lang_common[&#039;Registered&#039;].&#039;: &#039;.date($pun_config[&#039;o_date_format&#039;], $cur_post[&#039;registered&#039;]);

            if ($pun_config[&#039;o_show_post_count&#039;] == &#039;1&#039; || $pun_user[&#039;g_id&#039;] &lt; PUN_GUEST)
                $user_info[] = &#039;&lt;dd&gt;&#039;.$lang_common[&#039;Posts&#039;].&#039;: &#039;.$cur_post[&#039;num_posts&#039;];

            // Now let&#039;s deal with the contact links (E-mail and URL)
            if (($cur_post[&#039;email_setting&#039;] == &#039;0&#039; &amp;&amp; !$pun_user[&#039;is_guest&#039;]) || $pun_user[&#039;g_id&#039;] &lt; PUN_GUEST)
                $user_contacts[] = &#039;&lt;a href=&quot;mailto:&#039;.$cur_post[&#039;email&#039;].&#039;&quot;&gt;&#039;.$lang_common[&#039;E-mail&#039;].&#039;&lt;/a&gt;&#039;;
            else if ($cur_post[&#039;email_setting&#039;] == &#039;1&#039; &amp;&amp; !$pun_user[&#039;is_guest&#039;])
                $user_contacts[] = &#039;&lt;a href=&quot;misc.php?email=&#039;.$cur_post[&#039;poster_id&#039;].&#039;&quot;&gt;&#039;.$lang_common[&#039;E-mail&#039;].&#039;&lt;/a&gt;&#039;;
            require(PUN_ROOT.&#039;include/pms/viewtopic_PM-link.php&#039;);

            if ($cur_post[&#039;url&#039;] != &#039;&#039;)
                $user_contacts[] = &#039;&lt;a href=&quot;&#039;.pun_htmlspecialchars($cur_post[&#039;url&#039;]).&#039;&quot;&gt;&#039;.$lang_topic[&#039;Website&#039;].&#039;&lt;/a&gt;&#039;;
        }

        if ($pun_user[&#039;g_id&#039;] &lt; PUN_GUEST)
        {
            $user_info[] = &#039;&lt;dd&gt;IP: &lt;a href=&quot;moderate.php?get_host=&#039;.$cur_post[&#039;id&#039;].&#039;&quot;&gt;&#039;.$cur_post[&#039;poster_ip&#039;].&#039;&lt;/a&gt;&#039;;

            if ($cur_post[&#039;admin_note&#039;] != &#039;&#039;)
                $user_info[] = &#039;&lt;dd&gt;&#039;.$lang_topic[&#039;Note&#039;].&#039;: &lt;strong&gt;&#039;.pun_htmlspecialchars($cur_post[&#039;admin_note&#039;]).&#039;&lt;/strong&gt;&#039;;
        }
    }
    // If the poster is a guest (or a user that has been deleted)
    else
    {
        $username = pun_htmlspecialchars($cur_post[&#039;username&#039;]);
        $user_title = get_title($cur_post);

        if ($pun_user[&#039;g_id&#039;] &lt; PUN_GUEST)
            $user_info[] = &#039;&lt;dd&gt;IP: &lt;a href=&quot;moderate.php?get_host=&#039;.$cur_post[&#039;id&#039;].&#039;&quot;&gt;&#039;.$cur_post[&#039;poster_ip&#039;].&#039;&lt;/a&gt;&#039;;

        if ($pun_config[&#039;o_show_user_info&#039;] == &#039;1&#039; &amp;&amp; $cur_post[&#039;poster_email&#039;] != &#039;&#039; &amp;&amp; !$pun_user[&#039;is_guest&#039;])
            $user_contacts[] = &#039;&lt;a href=&quot;mailto:&#039;.$cur_post[&#039;poster_email&#039;].&#039;&quot;&gt;&#039;.$lang_common[&#039;E-mail&#039;].&#039;&lt;/a&gt;&#039;;
    }

    // Generation post action array (quote, edit, delete etc.)
    if (!$is_admmod)
    {
        if (!$pun_user[&#039;is_guest&#039;])
            $post_actions[] = &#039;&lt;li class=&quot;postreport&quot;&gt;&lt;a href=&quot;misc.php?report=&#039;.$cur_post[&#039;id&#039;].&#039;&quot;&gt;&#039;.$lang_topic[&#039;Report&#039;].&#039;&lt;/a&gt;&#039;;

        if ($cur_topic[&#039;closed&#039;] == &#039;0&#039;)
        {
            if ($cur_post[&#039;poster_id&#039;] == $pun_user[&#039;id&#039;])
            {
                if ((($start_from + $post_count) == 1 &amp;&amp; $pun_user[&#039;g_delete_topics&#039;] == &#039;1&#039;) || (($start_from + $post_count) &gt; 1 &amp;&amp; $pun_user[&#039;g_delete_posts&#039;] == &#039;1&#039;))
                    $post_actions[] = &#039;&lt;li class=&quot;postdelete&quot;&gt;&lt;a href=&quot;delete.php?id=&#039;.$cur_post[&#039;id&#039;].&#039;&quot;&gt;&#039;.$lang_topic[&#039;Delete&#039;].&#039;&lt;/a&gt;&#039;;
                if ($pun_user[&#039;g_edit_posts&#039;] == &#039;1&#039;)
                    $post_actions[] = &#039;&lt;li class=&quot;postedit&quot;&gt;&lt;a href=&quot;edit.php?id=&#039;.$cur_post[&#039;id&#039;].&#039;&quot;&gt;&#039;.$lang_topic[&#039;Edit&#039;].&#039;&lt;/a&gt;&#039;;
            }

            if (($cur_topic[&#039;post_replies&#039;] == &#039;&#039; &amp;&amp; $pun_user[&#039;g_post_replies&#039;] == &#039;1&#039;) || $cur_topic[&#039;post_replies&#039;] == &#039;1&#039;)
                $post_actions[] = &#039;&lt;li class=&quot;postquote&quot;&gt;&lt;a href=&quot;post.php?tid=&#039;.$id.&#039;&amp;amp;qid=&#039;.$cur_post[&#039;id&#039;].&#039;&quot;&gt;&#039;.$lang_topic[&#039;Quote&#039;].&#039;&lt;/a&gt;&#039;;
        }
    }
    else
        $post_actions[] = &#039;&lt;li class=&quot;postreport&quot;&gt;&lt;a href=&quot;misc.php?report=&#039;.$cur_post[&#039;id&#039;].&#039;&quot;&gt;&#039;.$lang_topic[&#039;Report&#039;].&#039;&lt;/a&gt;&#039;.$lang_topic[&#039;Link separator&#039;].&#039;&lt;/li&gt;&lt;li class=&quot;postdelete&quot;&gt;&lt;a href=&quot;delete.php?id=&#039;.$cur_post[&#039;id&#039;].&#039;&quot;&gt;&#039;.$lang_topic[&#039;Delete&#039;].&#039;&lt;/a&gt;&#039;.$lang_topic[&#039;Link separator&#039;].&#039;&lt;/li&gt;&lt;li class=&quot;postedit&quot;&gt;&lt;a href=&quot;edit.php?id=&#039;.$cur_post[&#039;id&#039;].&#039;&quot;&gt;&#039;.$lang_topic[&#039;Edit&#039;].&#039;&lt;/a&gt;&#039;.$lang_topic[&#039;Link separator&#039;].&#039;&lt;/li&gt;&lt;li class=&quot;postquote&quot;&gt;&lt;a href=&quot;post.php?tid=&#039;.$id.&#039;&amp;amp;qid=&#039;.$cur_post[&#039;id&#039;].&#039;&quot;&gt;&#039;.$lang_topic[&#039;Quote&#039;].&#039;&lt;/a&gt;&#039;;


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


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

    // Do signature parsing/caching
    if ($cur_post[&#039;signature&#039;] != &#039;&#039; &amp;&amp; $pun_user[&#039;show_sig&#039;] != &#039;0&#039;)
    {
        if (isset($signature_cache[$cur_post[&#039;poster_id&#039;]]))
            $signature = $signature_cache[$cur_post[&#039;poster_id&#039;]];
        else
        {
            $signature = parse_signature($cur_post[&#039;signature&#039;]);
            $signature_cache[$cur_post[&#039;poster_id&#039;]] = $signature;
        }
    }

?&gt;
&lt;div id=&quot;p&lt;?php echo $cur_post[&#039;id&#039;] ?&gt;&quot; class=&quot;blockpost&lt;?php echo $vtbg ?&gt;&lt;?php if (($post_count + $start_from) == 1) echo &#039; firstpost&#039;; ?&gt;&quot;&gt;
    &lt;h2&gt;&lt;span&gt;&lt;span class=&quot;conr&quot;&gt;#&lt;?php echo ($start_from + $post_count) ?&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;viewtopic.php?pid=&lt;?php echo $cur_post[&#039;id&#039;].&#039;#p&#039;.$cur_post[&#039;id&#039;] ?&gt;&quot;&gt;&lt;?php echo format_time($cur_post[&#039;posted&#039;]) ?&gt;&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;
    &lt;div class=&quot;box&quot;&gt;
        &lt;div class=&quot;inbox&quot;&gt;
            &lt;div class=&quot;postleft&quot;&gt;
                &lt;dl&gt;
                    &lt;dt&gt;&lt;strong&gt;&lt;?php echo $username ?&gt;&lt;/strong&gt;&lt;/dt&gt;
                    &lt;dd class=&quot;usertitle&quot;&gt;&lt;strong&gt;&lt;?php echo $user_title ?&gt;&lt;/strong&gt;&lt;/dd&gt;
                                        &lt;dd class=&quot;usertitle&quot;&gt;&lt;?php echo $rank_pips ?&gt;&lt;/dd&gt;
                    &lt;dd class=&quot;postavatar&quot;&gt;&lt;?php echo $user_avatar ?&gt;&lt;/dd&gt; &lt;?php if ( $user_country != &#039;&#039;) {
                echo &#039;&lt;dd class=&quot;postavatar&quot;&gt;&lt;img src=&quot;./img/flags/&#039;.$user_country.&#039;.png&quot; alt=&quot;&#039;.$user_country.&#039;&quot; title=&quot;&#039;.$user_country.&#039;&quot;&gt;&lt;/dd&gt;&#039;; } ?&gt;

&lt;?php if (count($user_info)) echo &quot;\t\t\t\t\t&quot;.implode(&#039;&lt;/dd&gt;&#039;.&quot;\n\t\t\t\t\t&quot;, $user_info).&#039;&lt;/dd&gt;&#039;.&quot;\n&quot;; ?&gt;
&lt;?php if (count($user_contacts)) echo &quot;\t\t\t\t\t&quot;.&#039;&lt;dd class=&quot;usercontacts&quot;&gt;&#039;.implode(&#039;&amp;nbsp;&amp;nbsp;&#039;, $user_contacts).&#039;&lt;/dd&gt;&#039;.&quot;\n&quot;; ?&gt;
&lt;?php if ($cur_post[&#039;user_agent&#039;]) echo &#039;&lt;dd class=&quot;usercontacts&quot;&gt;&#039; . UserAgentIcons($cur_post[&#039;user_agent&#039;]) . &#039;&lt;/dd&gt;&#039;;?&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;bookmark.js&quot;&gt;
&lt;/script&gt;
                &lt;/dl&gt;
            &lt;/div&gt;
            &lt;div class=&quot;postright&quot;&gt;
                &lt;h3&gt;&lt;?php if (($post_count + $start_from) &gt; 1) echo &#039; Re: &#039;; ?&gt;&lt;?php echo pun_htmlspecialchars($cur_topic[&#039;subject&#039;]) ?&gt;&lt;/h3&gt;
                &lt;div class=&quot;postmsg&quot;&gt;
                    &lt;?php echo $cur_post[&#039;message&#039;].&quot;\n&quot; ?&gt;
&lt;?php if ($cur_post[&#039;edited&#039;] != &#039;&#039;) echo &quot;\t\t\t\t\t&quot;.&#039;&lt;p class=&quot;postedit&quot;&gt;&lt;em&gt;&#039;.$lang_topic[&#039;Last edit&#039;].&#039; &#039;.pun_htmlspecialchars($cur_post[&#039;edited_by&#039;]).&#039; (&#039;.format_time($cur_post[&#039;edited&#039;]).&#039;)&lt;/em&gt;&lt;/p&gt;&#039;.&quot;\n&quot;; ?&gt;
                &lt;/div&gt;
&lt;?php if ($signature != &#039;&#039;) echo &quot;\t\t\t\t&quot;.&#039;&lt;div class=&quot;postsignature&quot;&gt;&lt;img src=&quot;http://www.webchinupload.com/files/xoshnaw%20%20SH%20(1)_2.gif&quot; alt=&quot;naw&quot; /&gt;&#039;.$signature.&#039;&lt;/div&gt;&#039;.&quot;\n&quot;; ?&gt;
            &lt;/div&gt;
            &lt;div class=&quot;clearer&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;postfootleft&quot;&gt;&lt;?php if ($cur_post[&#039;poster_id&#039;] &gt; 1) echo &#039;&lt;p&gt;&#039;.$is_online.&#039;&lt;/p&gt;&#039;; ?&gt;&lt;/div&gt;
            &lt;div class=&quot;postfootright&quot;&gt;&lt;?php echo (count($post_actions)) ? &#039;&lt;ul&gt;&#039;.implode($lang_topic[&#039;Link separator&#039;].&#039;&lt;/li&gt;&#039;, $post_actions).&#039;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&#039;.&quot;\n&quot; : &#039;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&#039;.&quot;\n&quot; ?&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;?php

}

?&gt;
&lt;div class=&quot;postlinksb&quot;&gt;
    &lt;div class=&quot;inbox&quot;&gt;
        &lt;p class=&quot;postlink conr&quot;&gt;&lt;?php echo $post_link ?&gt;&lt;/p&gt;
        &lt;p class=&quot;pagelink conl&quot;&gt;&lt;?php echo $paging_links ?&gt;&lt;/p&gt;
        &lt;ul&gt;&lt;li&gt;&lt;a href=&quot;index.php&quot;&gt;&lt;?php echo $lang_common[&#039;Index&#039;] ?&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&amp;nbsp;&amp;raquo;&amp;nbsp;&lt;a href=&quot;viewforum.php?id=&lt;?php echo $cur_topic[&#039;forum_id&#039;] ?&gt;&quot;&gt;&lt;?php echo pun_htmlspecialchars($cur_topic[&#039;forum_name&#039;]) ?&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&amp;nbsp;&amp;raquo;&amp;nbsp;&lt;?php echo pun_htmlspecialchars($cur_topic[&#039;subject&#039;]) ?&gt;&lt;/li&gt;&lt;/ul&gt;
        &lt;?php echo $subscraction ?&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;!-- AddThis Button BEGIN --&gt;
&lt;div class=&quot;addthis_toolbox addthis_default_style addthis_32x32_style&quot;&gt;
&lt;a class=&quot;addthis_button_preferred_1&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;addthis_button_preferred_2&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;addthis_button_preferred_3&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;addthis_button_preferred_4&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;addthis_button_compact&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;addthis_counter addthis_bubble_style&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4de7f5e5136d9f7a&quot;&gt;&lt;/script&gt;
&lt;!-- AddThis Button END --&gt;
&lt;?php

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

?&gt;
&lt;div class=&quot;blockform&quot;&gt;
    &lt;h2&gt;&lt;span&gt;&lt;?php echo $lang_topic[&#039;Quick post&#039;] ?&gt;&lt;/span&gt;&lt;/h2&gt;
    &lt;div class=&quot;box&quot;&gt;
        &lt;form id=&quot;post&quot; method=&quot;post&quot; name=&quot;qpost&quot; action=&quot;post.php?tid=&lt;?php echo $id ?&gt;&quot; onsubmit=&quot;this.submit.disabled=true;if(process_form(this)){return true;}else{this.submit.disabled=false;return false;}&quot;&gt;
            &lt;div class=&quot;inform&quot;&gt;
                &lt;fieldset&gt;
                    &lt;legend&gt;&lt;?php echo $lang_common[&#039;Write message legend&#039;] ?&gt;&lt;/legend&gt;
                    &lt;div class=&quot;infldset txtarea&quot;&gt;
                        &lt;input type=&quot;hidden&quot; name=&quot;form_sent&quot; value=&quot;1&quot; /&gt;
                        &lt;input type=&quot;hidden&quot; name=&quot;form_user&quot; value=&quot;&lt;?php echo (!$pun_user[&#039;is_guest&#039;]) ? pun_htmlspecialchars($pun_user[&#039;username&#039;]) : &#039;Guest&#039;; ?&gt;&quot; /&gt;
                        &lt;?php require PUN_ROOT.&#039;mod_modern_bbcode.php&#039;; ?&gt;
                        &lt;label&gt;&lt;textarea name=&quot;req_message&quot; rows=&quot;7&quot; cols=&quot;75&quot; tabindex=&quot;1&quot;&gt;&lt;/textarea&gt;&lt;/label&gt;
                        &lt;ul class=&quot;bblinks&quot;&gt;
                            &lt;li&gt;&lt;a href=&quot;help.php#bbcode&quot; onclick=&quot;window.open(this.href); return false;&quot;&gt;&lt;?php echo $lang_common[&#039;BBCode&#039;] ?&gt;&lt;/a&gt;: &lt;?php echo ($pun_config[&#039;p_message_bbcode&#039;] == &#039;1&#039;) ? $lang_common[&#039;on&#039;] : $lang_common[&#039;off&#039;]; ?&gt;&lt;/li&gt;
                            &lt;li&gt;&lt;a href=&quot;help.php#img&quot; onclick=&quot;window.open(this.href); return false;&quot;&gt;&lt;?php echo $lang_common[&#039;img tag&#039;] ?&gt;&lt;/a&gt;: &lt;?php echo ($pun_config[&#039;p_message_img_tag&#039;] == &#039;1&#039;) ? $lang_common[&#039;on&#039;] : $lang_common[&#039;off&#039;]; ?&gt;&lt;/li&gt;
                            &lt;li&gt;&lt;a href=&quot;help.php#smilies&quot; onclick=&quot;window.open(this.href); return false;&quot;&gt;&lt;?php echo $lang_common[&#039;Smilies&#039;] ?&gt;&lt;/a&gt;: &lt;?php echo ($pun_config[&#039;o_smilies&#039;] == &#039;1&#039;) ? $lang_common[&#039;on&#039;] : $lang_common[&#039;off&#039;]; ?&gt;&lt;/li&gt;
                        &lt;/ul&gt;
                    &lt;/div&gt;
                &lt;/fieldset&gt;
            &lt;/div&gt;
            &lt;p&gt;&lt;input type=&quot;submit&quot; name=&quot;submit&quot; tabindex=&quot;2&quot; value=&quot;&lt;?php echo $lang_common[&#039;Submit&#039;] ?&gt;&quot; accesskey=&quot;s&quot; /&gt;&lt;/p&gt;
        &lt;/form&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;?php

}

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

$forum_id = $cur_topic[&#039;forum_id&#039;];
$footer_style = &#039;viewtopic&#039;;
require PUN_ROOT.&#039;footer.php&#039;;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (WlaT_ShaQLaWa)]]></author>
			<pubDate>Sat, 26 May 2012 01:31:43 +0000</pubDate>
			<guid>https://www.webchin.org/Meko/viewtopic.php?pid=219963#p219963</guid>
		</item>
		<item>
			<title><![CDATA[وه‌ڵام: كه‌ زانياری تاكه‌كه‌سی ئه‌كه‌مه‌وه‌ ئه‌مه‌ ديت]]></title>
			<link>https://www.webchin.org/Meko/viewtopic.php?pid=219960#p219960</link>
			<description><![CDATA[<p>کەواتە کۆدەکانی viewtopic.php ـیش لێرە دابنێ.</p><p>هەروەها تەنیا یەکجار کرتە لە دووگمەی ناردن بکە بۆ ئەوەی پەیامەکانت دووبارە نەبنەوە.</p>]]></description>
			<author><![CDATA[null@example.com (ئاسۆ نادری)]]></author>
			<pubDate>Sat, 26 May 2012 01:29:00 +0000</pubDate>
			<guid>https://www.webchin.org/Meko/viewtopic.php?pid=219960#p219960</guid>
		</item>
		<item>
			<title><![CDATA[وه‌ڵام: كه‌ زانياری تاكه‌كه‌سی ئه‌كه‌مه‌وه‌ ئه‌مه‌ ديت]]></title>
			<link>https://www.webchin.org/Meko/viewtopic.php?pid=219959#p219959</link>
			<description><![CDATA[<p>كاك ئاسۆ ز تاكه‌كه‌سی چاك بوو به‌لام كه‌ بابه‌ت ده‌كه‌مه‌وه‌ ئه‌مه‌ پێشان ده‌دات <br /><a href="http://www.gulfup.com/show/Xmlgafe13u4gwk"><span class="postimg"><img src="http://im25.gulfup.com/2012-05-26/1337995575381.jpg" alt="http://im25.gulfup.com/2012-05-26/1337995575381.jpg" /></span></a></p>]]></description>
			<author><![CDATA[null@example.com (WlaT_ShaQLaWa)]]></author>
			<pubDate>Sat, 26 May 2012 01:28:48 +0000</pubDate>
			<guid>https://www.webchin.org/Meko/viewtopic.php?pid=219959#p219959</guid>
		</item>
		<item>
			<title><![CDATA[وه‌ڵام: كه‌ زانياری تاكه‌كه‌سی ئه‌كه‌مه‌وه‌ ئه‌مه‌ ديت]]></title>
			<link>https://www.webchin.org/Meko/viewtopic.php?pid=219956#p219956</link>
			<description><![CDATA[<p>كاك ئاسۆ ز تاكه‌كه‌سی چاك بوو به‌لام كه‌ بابه‌ت ده‌كه‌مه‌وه‌ ئه‌مه‌ پێشان ده‌دات <br /><a href="http://www.gulfup.com/show/Xmlgafe13u4gwk"><span class="postimg"><img src="http://im25.gulfup.com/2012-05-26/1337995575381.jpg" alt="http://im25.gulfup.com/2012-05-26/1337995575381.jpg" /></span></a></p>]]></description>
			<author><![CDATA[null@example.com (WlaT_ShaQLaWa)]]></author>
			<pubDate>Sat, 26 May 2012 01:28:04 +0000</pubDate>
			<guid>https://www.webchin.org/Meko/viewtopic.php?pid=219956#p219956</guid>
		</item>
		<item>
			<title><![CDATA[وه‌ڵام: كه‌ زانياری تاكه‌كه‌سی ئه‌كه‌مه‌وه‌ ئه‌مه‌ ديت]]></title>
			<link>https://www.webchin.org/Meko/viewtopic.php?pid=219955#p219955</link>
			<description><![CDATA[<p>كاك ئاسۆ ز تاكه‌كه‌سی چاك بوو به‌لام كه‌ بابه‌ت ده‌كه‌مه‌وه‌ ئه‌مه‌ پێشان ده‌دات <br /><a href="http://www.gulfup.com/show/Xmlgafe13u4gwk"><span class="postimg"><img src="http://im25.gulfup.com/2012-05-26/1337995575381.jpg" alt="http://im25.gulfup.com/2012-05-26/1337995575381.jpg" /></span></a></p>]]></description>
			<author><![CDATA[null@example.com (WlaT_ShaQLaWa)]]></author>
			<pubDate>Sat, 26 May 2012 01:27:57 +0000</pubDate>
			<guid>https://www.webchin.org/Meko/viewtopic.php?pid=219955#p219955</guid>
		</item>
		<item>
			<title><![CDATA[وه‌ڵام: كه‌ زانياری تاكه‌كه‌سی ئه‌كه‌مه‌وه‌ ئه‌مه‌ ديت]]></title>
			<link>https://www.webchin.org/Meko/viewtopic.php?pid=219951#p219951</link>
			<description><![CDATA[<p>هەر هەمان وێنەی سەرەوەیە کە داتناوەتەوە.</p>]]></description>
			<author><![CDATA[null@example.com (ئاسۆ نادری)]]></author>
			<pubDate>Sat, 26 May 2012 01:25:39 +0000</pubDate>
			<guid>https://www.webchin.org/Meko/viewtopic.php?pid=219951#p219951</guid>
		</item>
		<item>
			<title><![CDATA[وه‌ڵام: كه‌ زانياری تاكه‌كه‌سی ئه‌كه‌مه‌وه‌ ئه‌مه‌ ديت]]></title>
			<link>https://www.webchin.org/Meko/viewtopic.php?pid=219950#p219950</link>
			<description><![CDATA[<p>كاك ئاسۆ ز تاكه‌كه‌سی چاك بوو به‌لام كه‌ بابه‌ت ده‌كه‌مه‌وه‌ ئه‌مه‌ پێشان ده‌دات <br /><a href="http://www.gulfup.com/show/X5n1qy47ibwxx"><span class="postimg"><img src="http://im13.gulfup.com/2012-05-26/1337994534391.jpg" alt="http://im13.gulfup.com/2012-05-26/1337994534391.jpg" /></span></a></p>]]></description>
			<author><![CDATA[null@example.com (WlaT_ShaQLaWa)]]></author>
			<pubDate>Sat, 26 May 2012 01:25:22 +0000</pubDate>
			<guid>https://www.webchin.org/Meko/viewtopic.php?pid=219950#p219950</guid>
		</item>
		<item>
			<title><![CDATA[وه‌ڵام: كه‌ زانياری تاكه‌كه‌سی ئه‌كه‌مه‌وه‌ ئه‌مه‌ ديت]]></title>
			<link>https://www.webchin.org/Meko/viewtopic.php?pid=219946#p219946</link>
			<description><![CDATA[<p>کۆدەکان لێرە وەرگرە و دووبارە لە نێو profile.php دایانبنێ،<br /><a href="http://pastebin.com/raw.php?i=M8ExRFhC">http://pastebin.com/raw.php?i=M8ExRFhC</a></p>]]></description>
			<author><![CDATA[null@example.com (ئاسۆ نادری)]]></author>
			<pubDate>Sat, 26 May 2012 01:20:34 +0000</pubDate>
			<guid>https://www.webchin.org/Meko/viewtopic.php?pid=219946#p219946</guid>
		</item>
		<item>
			<title><![CDATA[وه‌ڵام: كه‌ زانياری تاكه‌كه‌سی ئه‌كه‌مه‌وه‌ ئه‌مه‌ ديت]]></title>
			<link>https://www.webchin.org/Meko/viewtopic.php?pid=219945#p219945</link>
			<description><![CDATA[<p><a href="http://www.gulfup.com/X5mzlovnuwr6o">http://www.gulfup.com/X5mzlovnuwr6o</a></p><p>فه‌رموو</p>]]></description>
			<author><![CDATA[null@example.com (WlaT_ShaQLaWa)]]></author>
			<pubDate>Sat, 26 May 2012 01:16:22 +0000</pubDate>
			<guid>https://www.webchin.org/Meko/viewtopic.php?pid=219945#p219945</guid>
		</item>
		<item>
			<title><![CDATA[وه‌ڵام: كه‌ زانياری تاكه‌كه‌سی ئه‌كه‌مه‌وه‌ ئه‌مه‌ ديت]]></title>
			<link>https://www.webchin.org/Meko/viewtopic.php?pid=219944#p219944</link>
			<description><![CDATA[<p>کۆدەکانی نێو profile.php لێرە دابنێ.</p>]]></description>
			<author><![CDATA[null@example.com (ئاسۆ نادری)]]></author>
			<pubDate>Sat, 26 May 2012 01:11:44 +0000</pubDate>
			<guid>https://www.webchin.org/Meko/viewtopic.php?pid=219944#p219944</guid>
		</item>
		<item>
			<title><![CDATA[وه‌ڵام: كه‌ زانياری تاكه‌كه‌سی ئه‌كه‌مه‌وه‌ ئه‌مه‌ ديت]]></title>
			<link>https://www.webchin.org/Meko/viewtopic.php?pid=219943#p219943</link>
			<description><![CDATA[<p>ئه‌وه‌ش كۆدی functions.php<br /></p><div class="quotebox"><blockquote><div class="codebox"><pre><code data-language=php>&lt;?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

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

//
// Cookie stuff!
//
function check_cookie(&amp;$pun_user)
{
    global $db, $db_type, $pun_config, $cookie_name, $cookie_seed;

    $now = time();
    $expire = $now + 31536000;    // The cookie expires after a year

    // We assume it&#039;s a guest
    $cookie = array(&#039;user_id&#039; =&gt; 1, &#039;password_hash&#039; =&gt; &#039;Guest&#039;);

    // If a cookie is set, we get the user_id and password hash from it
    if (isset($_COOKIE[$cookie_name]))
        list($cookie[&#039;user_id&#039;], $cookie[&#039;password_hash&#039;]) = @unserialize($_COOKIE[$cookie_name]);

    if ($cookie[&#039;user_id&#039;] &gt; 1)
    {
        // Check if there&#039;s a user with the user ID and password hash from the cookie
        $result = $db-&gt;query(&#039;SELECT u.*, g.*, o.logged, o.idle FROM &#039;.$db-&gt;prefix.&#039;users AS u INNER JOIN &#039;.$db-&gt;prefix.&#039;groups AS g ON u.group_id=g.g_id LEFT JOIN &#039;.$db-&gt;prefix.&#039;online AS o ON o.user_id=u.id WHERE u.id=&#039;.intval($cookie[&#039;user_id&#039;])) or error(&#039;Unable to fetch user information&#039;, __FILE__, __LINE__, $db-&gt;error());
        $pun_user = $db-&gt;fetch_assoc($result);

        // If user authorisation failed
        if (!isset($pun_user[&#039;id&#039;]) || md5($cookie_seed.$pun_user[&#039;password&#039;]) !== $cookie[&#039;password_hash&#039;])
        {
            pun_setcookie(0, random_pass(8), $expire);
            set_default_user();

            return;
        }

        // Set a default language if the user selected language no longer exists
        if (!@file_exists(PUN_ROOT.&#039;lang/&#039;.$pun_user[&#039;language&#039;]))
            $pun_user[&#039;language&#039;] = $pun_config[&#039;o_default_lang&#039;];

        // Set a default style if the user selected style no longer exists
        if (!@file_exists(PUN_ROOT.&#039;style/&#039;.$pun_user[&#039;style&#039;].&#039;.css&#039;))
            $pun_user[&#039;style&#039;] = $pun_config[&#039;o_default_style&#039;];

        if (!$pun_user[&#039;disp_topics&#039;])
            $pun_user[&#039;disp_topics&#039;] = $pun_config[&#039;o_disp_topics_default&#039;];
        if (!$pun_user[&#039;disp_posts&#039;])
            $pun_user[&#039;disp_posts&#039;] = $pun_config[&#039;o_disp_posts_default&#039;];

        if ($pun_user[&#039;save_pass&#039;] == &#039;0&#039;)
            $expire = 0;

        // Define this if you want this visit to affect the online list and the users last visit data
        if (!defined(&#039;PUN_QUIET_VISIT&#039;))
        {
            // Update the online list
            if (!$pun_user[&#039;logged&#039;])
            {
                $pun_user[&#039;logged&#039;] = $now;

                // With MySQL/MySQLi, REPLACE INTO avoids a user having two rows in the online table
                switch ($db_type)
                {
                    case &#039;mysql&#039;:
                    case &#039;mysqli&#039;:
                        $db-&gt;query(&#039;REPLACE INTO &#039;.$db-&gt;prefix.&#039;online (user_id, ident, logged) VALUES(&#039;.$pun_user[&#039;id&#039;].&#039;, \&#039;&#039;.$db-&gt;escape($pun_user[&#039;username&#039;]).&#039;\&#039;, &#039;.$pun_user[&#039;logged&#039;].&#039;)&#039;) or error(&#039;Unable to insert into online list&#039;, __FILE__, __LINE__, $db-&gt;error());
                        break;

                    default:
                        $db-&gt;query(&#039;INSERT INTO &#039;.$db-&gt;prefix.&#039;online (user_id, ident, logged) VALUES(&#039;.$pun_user[&#039;id&#039;].&#039;, \&#039;&#039;.$db-&gt;escape($pun_user[&#039;username&#039;]).&#039;\&#039;, &#039;.$pun_user[&#039;logged&#039;].&#039;)&#039;) or error(&#039;Unable to insert into online list&#039;, __FILE__, __LINE__, $db-&gt;error());
                        break;
                }
            }
            else
            {
                // Special case: We&#039;ve timed out, but no other user has browsed the forums since we timed out
                if ($pun_user[&#039;logged&#039;] &lt; ($now-$pun_config[&#039;o_timeout_visit&#039;]))
                {
                    $db-&gt;query(&#039;UPDATE &#039;.$db-&gt;prefix.&#039;users SET last_visit=&#039;.$pun_user[&#039;logged&#039;].&#039; WHERE id=&#039;.$pun_user[&#039;id&#039;]) or error(&#039;Unable to update user visit data&#039;, __FILE__, __LINE__, $db-&gt;error());
                    $pun_user[&#039;last_visit&#039;] = $pun_user[&#039;logged&#039;];
                }

                $idle_sql = ($pun_user[&#039;idle&#039;] == &#039;1&#039;) ? &#039;, idle=0&#039; : &#039;&#039;;
                $db-&gt;query(&#039;UPDATE &#039;.$db-&gt;prefix.&#039;online SET logged=&#039;.$now.$idle_sql.&#039; WHERE user_id=&#039;.$pun_user[&#039;id&#039;]) or error(&#039;Unable to update online list&#039;, __FILE__, __LINE__, $db-&gt;error());
            }
        }

        $pun_user[&#039;is_guest&#039;] = false;
    }
    else
        set_default_user();
}


//
// Fill $pun_user with default values (for guests)
//
function set_default_user()
{
    global $db, $db_type, $pun_user, $pun_config;

    $remote_addr = get_remote_address();

    // Fetch guest user
    $result = $db-&gt;query(&#039;SELECT u.*, g.*, o.logged FROM &#039;.$db-&gt;prefix.&#039;users AS u INNER JOIN &#039;.$db-&gt;prefix.&#039;groups AS g ON u.group_id=g.g_id LEFT JOIN &#039;.$db-&gt;prefix.&#039;online AS o ON o.ident=\&#039;&#039;.$remote_addr.&#039;\&#039; WHERE u.id=1&#039;) or error(&#039;Unable to fetch guest information&#039;, __FILE__, __LINE__, $db-&gt;error());
    if (!$db-&gt;num_rows($result))
        exit(&#039;Unable to fetch guest information. The table \&#039;&#039;.$db-&gt;prefix.&#039;users\&#039; must contain an entry with id = 1 that represents anonymous users.&#039;);

    $pun_user = $db-&gt;fetch_assoc($result);

    // Update online list
    if (!$pun_user[&#039;logged&#039;])
    {
        $pun_user[&#039;logged&#039;] = time();

        // With MySQL/MySQLi, REPLACE INTO avoids a user having two rows in the online table
        switch ($db_type)
        {
            case &#039;mysql&#039;:
            case &#039;mysqli&#039;:
                $db-&gt;query(&#039;REPLACE INTO &#039;.$db-&gt;prefix.&#039;online (user_id, ident, logged) VALUES(1, \&#039;&#039;.$db-&gt;escape($remote_addr).&#039;\&#039;, &#039;.$pun_user[&#039;logged&#039;].&#039;)&#039;) or error(&#039;Unable to insert into online list&#039;, __FILE__, __LINE__, $db-&gt;error());
                break;

            default:
                $db-&gt;query(&#039;INSERT INTO &#039;.$db-&gt;prefix.&#039;online (user_id, ident, logged) VALUES(1, \&#039;&#039;.$db-&gt;escape($remote_addr).&#039;\&#039;, &#039;.$pun_user[&#039;logged&#039;].&#039;)&#039;) or error(&#039;Unable to insert into online list&#039;, __FILE__, __LINE__, $db-&gt;error());
                break;
        }
    }
    else
        $db-&gt;query(&#039;UPDATE &#039;.$db-&gt;prefix.&#039;online SET logged=&#039;.time().&#039; WHERE ident=\&#039;&#039;.$db-&gt;escape($remote_addr).&#039;\&#039;&#039;) or error(&#039;Unable to update online list&#039;, __FILE__, __LINE__, $db-&gt;error());

    $pun_user[&#039;disp_topics&#039;] = $pun_config[&#039;o_disp_topics_default&#039;];
    $pun_user[&#039;disp_posts&#039;] = $pun_config[&#039;o_disp_posts_default&#039;];
    $pun_user[&#039;timezone&#039;] = $pun_config[&#039;o_server_timezone&#039;];
    $pun_user[&#039;language&#039;] = $pun_config[&#039;o_default_lang&#039;];
    $pun_user[&#039;style&#039;] = $pun_config[&#039;o_default_style&#039;];
    $pun_user[&#039;is_guest&#039;] = true;
}


//
// Set a cookie, PunBB style!
//
function pun_setcookie($user_id, $password_hash, $expire)
{
    global $cookie_name, $cookie_path, $cookie_domain, $cookie_secure, $cookie_seed;

    // Enable sending of a P3P header by removing // from the following line (try this if login is failing in IE6)
//    @header(&#039;P3P: CP=&quot;CUR ADM&quot;&#039;);

    if (version_compare(PHP_VERSION, &#039;5.2.0&#039;, &#039;&gt;=&#039;))
        setcookie($cookie_name, serialize(array($user_id, md5($cookie_seed.$password_hash))), $expire, $cookie_path, $cookie_domain, $cookie_secure, true);
    else
        setcookie($cookie_name, serialize(array($user_id, md5($cookie_seed.$password_hash))), $expire, $cookie_path.&#039;; HttpOnly&#039;, $cookie_domain, $cookie_secure);
}


//
// Check whether the connecting user is banned (and delete any expired bans while we&#039;re at it)
//
function check_bans()
{
    global $db, $pun_config, $lang_common, $pun_user, $pun_bans;

    // Admins aren&#039;t affected
    if ($pun_user[&#039;g_id&#039;] == PUN_ADMIN || !$pun_bans)
        return;

    // Add a dot at the end of the IP address to prevent banned address 192.168.0.5 from matching e.g. 192.168.0.50
    $user_ip = get_remote_address().&#039;.&#039;;
    $bans_altered = false;

    foreach ($pun_bans as $cur_ban)
    {
        // Has this ban expired?
        if ($cur_ban[&#039;expire&#039;] != &#039;&#039; &amp;&amp; $cur_ban[&#039;expire&#039;] &lt;= time())
        {
            $db-&gt;query(&#039;DELETE FROM &#039;.$db-&gt;prefix.&#039;bans WHERE id=&#039;.$cur_ban[&#039;id&#039;]) or error(&#039;Unable to delete expired ban&#039;, __FILE__, __LINE__, $db-&gt;error());
            $bans_altered = true;
            continue;
        }

        if ($cur_ban[&#039;username&#039;] != &#039;&#039; &amp;&amp; !strcasecmp($pun_user[&#039;username&#039;], $cur_ban[&#039;username&#039;]))
        {
            $db-&gt;query(&#039;DELETE FROM &#039;.$db-&gt;prefix.&#039;online WHERE ident=\&#039;&#039;.$db-&gt;escape($pun_user[&#039;username&#039;]).&#039;\&#039;&#039;) or error(&#039;Unable to delete from online list&#039;, __FILE__, __LINE__, $db-&gt;error());
            message($lang_common[&#039;Ban message&#039;].&#039; &#039;.(($cur_ban[&#039;expire&#039;] != &#039;&#039;) ? $lang_common[&#039;Ban message 2&#039;].&#039; &#039;.strtolower(format_time($cur_ban[&#039;expire&#039;], true)).&#039;. &#039; : &#039;&#039;).(($cur_ban[&#039;message&#039;] != &#039;&#039;) ? $lang_common[&#039;Ban message 3&#039;].&#039;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&#039;.pun_htmlspecialchars($cur_ban[&#039;message&#039;]).&#039;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&#039; : &#039;&lt;br /&gt;&lt;br /&gt;&#039;).$lang_common[&#039;Ban message 4&#039;].&#039; &lt;a href=&quot;mailto:&#039;.$pun_config[&#039;o_admin_email&#039;].&#039;&quot;&gt;&#039;.$pun_config[&#039;o_admin_email&#039;].&#039;&lt;/a&gt;.&#039;, true);
        }

        if ($cur_ban[&#039;ip&#039;] != &#039;&#039;)
        {
            $cur_ban_ips = explode(&#039; &#039;, $cur_ban[&#039;ip&#039;]);

            for ($i = 0; $i &lt; count($cur_ban_ips); ++$i)
            {
                $cur_ban_ips[$i] = $cur_ban_ips[$i].&#039;.&#039;;

                if (substr($user_ip, 0, strlen($cur_ban_ips[$i])) == $cur_ban_ips[$i])
                {
                    $db-&gt;query(&#039;DELETE FROM &#039;.$db-&gt;prefix.&#039;online WHERE ident=\&#039;&#039;.$db-&gt;escape($pun_user[&#039;username&#039;]).&#039;\&#039;&#039;) or error(&#039;Unable to delete from online list&#039;, __FILE__, __LINE__, $db-&gt;error());
                    message($lang_common[&#039;Ban message&#039;].&#039; &#039;.(($cur_ban[&#039;expire&#039;] != &#039;&#039;) ? $lang_common[&#039;Ban message 2&#039;].&#039; &#039;.strtolower(format_time($cur_ban[&#039;expire&#039;], true)).&#039;. &#039; : &#039;&#039;).(($cur_ban[&#039;message&#039;] != &#039;&#039;) ? $lang_common[&#039;Ban message 3&#039;].&#039;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&#039;.pun_htmlspecialchars($cur_ban[&#039;message&#039;]).&#039;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&#039; : &#039;&lt;br /&gt;&lt;br /&gt;&#039;).$lang_common[&#039;Ban message 4&#039;].&#039; &lt;a href=&quot;mailto:&#039;.$pun_config[&#039;o_admin_email&#039;].&#039;&quot;&gt;&#039;.$pun_config[&#039;o_admin_email&#039;].&#039;&lt;/a&gt;.&#039;, true);
                }
            }
        }
    }

    // If we removed any expired bans during our run-through, we need to regenerate the bans cache
    if ($bans_altered)
    {
        require_once PUN_ROOT.&#039;include/cache.php&#039;;
        generate_bans_cache();
    }
}


//
// Update &quot;Users online&quot;
//
function update_users_online()
{
    global $db, $pun_config, $pun_user;

    $now = time();

    // Fetch all online list entries that are older than &quot;o_timeout_online&quot;
    $result = $db-&gt;query(&#039;SELECT * FROM &#039;.$db-&gt;prefix.&#039;online WHERE logged&lt;&#039;.($now-$pun_config[&#039;o_timeout_online&#039;])) or error(&#039;Unable to fetch old entries from online list&#039;, __FILE__, __LINE__, $db-&gt;error());
    while ($cur_user = $db-&gt;fetch_assoc($result))
    {
        // If the entry is a guest, delete it
        if ($cur_user[&#039;user_id&#039;] == &#039;1&#039;)
            $db-&gt;query(&#039;DELETE FROM &#039;.$db-&gt;prefix.&#039;online WHERE ident=\&#039;&#039;.$db-&gt;escape($cur_user[&#039;ident&#039;]).&#039;\&#039;&#039;) or error(&#039;Unable to delete from online list&#039;, __FILE__, __LINE__, $db-&gt;error());
        else
        {
            // If the entry is older than &quot;o_timeout_visit&quot;, update last_visit for the user in question, then delete him/her from the online list
            if ($cur_user[&#039;logged&#039;] &lt; ($now-$pun_config[&#039;o_timeout_visit&#039;]))
            {
                $db-&gt;query(&#039;UPDATE &#039;.$db-&gt;prefix.&#039;users SET last_visit=&#039;.$cur_user[&#039;logged&#039;].&#039; WHERE id=&#039;.$cur_user[&#039;user_id&#039;]) or error(&#039;Unable to update user visit data&#039;, __FILE__, __LINE__, $db-&gt;error());
                $db-&gt;query(&#039;DELETE FROM &#039;.$db-&gt;prefix.&#039;online WHERE user_id=&#039;.$cur_user[&#039;user_id&#039;]) or error(&#039;Unable to delete from online list&#039;, __FILE__, __LINE__, $db-&gt;error());
            }
            else if ($cur_user[&#039;idle&#039;] == &#039;0&#039;)
                $db-&gt;query(&#039;UPDATE &#039;.$db-&gt;prefix.&#039;online SET idle=1 WHERE user_id=&#039;.$cur_user[&#039;user_id&#039;]) or error(&#039;Unable to insert into online list&#039;, __FILE__, __LINE__, $db-&gt;error());
        }
    }
}


//
// Generate the &quot;navigator&quot; that appears at the top of every page
//
function generate_navlinks()
{
    global $pun_config, $lang_common, $pun_user;

    // Index and Userlist should always be displayed
    $links[] = &#039;&lt;li id=&quot;navindex&quot;&gt;&lt;a href=&quot;index.php&quot;&gt;&#039;.$lang_common[&#039;Index&#039;].&#039;&lt;/a&gt;&#039;;
    $links[] = &#039;&lt;li id=&quot;navuserlist&quot;&gt;&lt;a href=&quot;userlist.php&quot;&gt;&#039;.$lang_common[&#039;User list&#039;].&#039;&lt;/a&gt;&#039;;

    if ($pun_config[&#039;o_rules&#039;] == &#039;1&#039;)
        $links[] = &#039;&lt;li id=&quot;navrules&quot;&gt;&lt;a href=&quot;misc.php?action=rules&quot;&gt;&#039;.$lang_common[&#039;Rules&#039;].&#039;&lt;/a&gt;&#039;;

    if ($pun_user[&#039;is_guest&#039;])
    {
        if ($pun_user[&#039;g_search&#039;] == &#039;1&#039;)
            $links[] = &#039;&lt;li id=&quot;navsearch&quot;&gt;&lt;a href=&quot;search.php&quot;&gt;&#039;.$lang_common[&#039;Search&#039;].&#039;&lt;/a&gt;&#039;;

        $links[] = &#039;&lt;li id=&quot;navregister&quot;&gt;&lt;a href=&quot;register.php&quot;&gt;&#039;.$lang_common[&#039;Register&#039;].&#039;&lt;/a&gt;&#039;;
        $links[] = &#039;&lt;li id=&quot;navlogin&quot;&gt;&lt;a href=&quot;login.php&quot;&gt;&#039;.$lang_common[&#039;Login&#039;].&#039;&lt;/a&gt;&#039;;

        $info = $lang_common[&#039;Not logged in&#039;];
    }
    else
    {
        if ($pun_user[&#039;g_id&#039;] &gt; PUN_MOD)
        {
            if ($pun_user[&#039;g_search&#039;] == &#039;1&#039;)
                $links[] = &#039;&lt;li id=&quot;navsearch&quot;&gt;&lt;a href=&quot;search.php&quot;&gt;&#039;.$lang_common[&#039;Search&#039;].&#039;&lt;/a&gt;&#039;;

            $links[] = &#039;&lt;li id=&quot;navprofile&quot;&gt;&lt;a href=&quot;profile.php?id=&#039;.$pun_user[&#039;id&#039;].&#039;&quot;&gt;&#039;.$lang_common[&#039;Profile&#039;].&#039;&lt;/a&gt;&#039;;
            require(PUN_ROOT.&#039;include/pms/functions_navlinks.php&#039;);
            $links[] = &#039;&lt;li id=&quot;navlogout&quot;&gt;&lt;a href=&quot;login.php?action=out&amp;amp;id=&#039;.$pun_user[&#039;id&#039;].&#039;&quot;&gt;&#039;.$lang_common[&#039;Logout&#039;].&#039;&lt;/a&gt;&#039;;
        }
        else
        {
            $links[] = &#039;&lt;li id=&quot;navsearch&quot;&gt;&lt;a href=&quot;search.php&quot;&gt;&#039;.$lang_common[&#039;Search&#039;].&#039;&lt;/a&gt;&#039;;
            $links[] = &#039;&lt;li id=&quot;navprofile&quot;&gt;&lt;a href=&quot;profile.php?id=&#039;.$pun_user[&#039;id&#039;].&#039;&quot;&gt;&#039;.$lang_common[&#039;Profile&#039;].&#039;&lt;/a&gt;&#039;;
            $links[] = &#039;&lt;li id=&quot;navadmin&quot;&gt;&lt;a href=&quot;admin_index.php&quot;&gt;&#039;.$lang_common[&#039;Admin&#039;].&#039;&lt;/a&gt;&#039;;
            require(PUN_ROOT.&#039;include/pms/functions_navlinks.php&#039;);
            $links[] = &#039;&lt;li id=&quot;navlogout&quot;&gt;&lt;a href=&quot;login.php?action=out&amp;amp;id=&#039;.$pun_user[&#039;id&#039;].&#039;&quot;&gt;&#039;.$lang_common[&#039;Logout&#039;].&#039;&lt;/a&gt;&#039;;
        }
    }

    // Are there any additional navlinks we should insert into the array before imploding it?
    if ($pun_config[&#039;o_additional_navlinks&#039;] != &#039;&#039;)
    {
        if (preg_match_all(&#039;#([0-9]+)\s*=\s*(.*?)\n#s&#039;, $pun_config[&#039;o_additional_navlinks&#039;].&quot;\n&quot;, $extra_links))
        {
            // Insert any additional links into the $links array (at the correct index)
            for ($i = 0; $i &lt; count($extra_links[1]); ++$i)
                array_splice($links, $extra_links[1][$i], 0, array(&#039;&lt;li id=&quot;navextra&#039;.($i + 1).&#039;&quot;&gt;&#039;.$extra_links[2][$i]));
        }
    }

    return &#039;&lt;ul&gt;&#039;.&quot;\n\t\t\t\t&quot;.implode($lang_common[&#039;Link separator&#039;].&#039;&lt;/li&gt;&#039;.&quot;\n\t\t\t\t&quot;, $links).&#039;&lt;/li&gt;&#039;.&quot;\n\t\t\t&quot;.&#039;&lt;/ul&gt;&#039;;
}


//
// Display the profile navigation menu
//
function generate_profile_menu($page = &#039;&#039;)
{
    global $lang_profile, $pun_config, $pun_user, $id;

?&gt;
&lt;div id=&quot;profile&quot; class=&quot;block2col&quot;&gt;
    &lt;div class=&quot;blockmenu&quot;&gt;
        &lt;h2&gt;&lt;span&gt;&lt;?php echo $lang_profile[&#039;Profile menu&#039;] ?&gt;&lt;/span&gt;&lt;/h2&gt;
        &lt;div class=&quot;box&quot;&gt;
            &lt;div class=&quot;inbox&quot;&gt;
                &lt;ul&gt;
                    &lt;li&lt;?php if ($page == &#039;essentials&#039;) echo &#039; class=&quot;isactive&quot;&#039;; ?&gt;&gt;&lt;a href=&quot;profile.php?section=essentials&amp;amp;id=&lt;?php echo $id ?&gt;&quot;&gt;&lt;?php echo $lang_profile[&#039;Section essentials&#039;] ?&gt;&lt;/a&gt;&lt;/li&gt;
                    &lt;li&lt;?php if ($page == &#039;personal&#039;) echo &#039; class=&quot;isactive&quot;&#039;; ?&gt;&gt;&lt;a href=&quot;profile.php?section=personal&amp;amp;id=&lt;?php echo $id ?&gt;&quot;&gt;&lt;?php echo $lang_profile[&#039;Section personal&#039;] ?&gt;&lt;/a&gt;&lt;/li&gt;
                    &lt;li&lt;?php if ($page == &#039;messaging&#039;) echo &#039; class=&quot;isactive&quot;&#039;; ?&gt;&gt;&lt;a href=&quot;profile.php?section=messaging&amp;amp;id=&lt;?php echo $id ?&gt;&quot;&gt;&lt;?php echo $lang_profile[&#039;Section messaging&#039;] ?&gt;&lt;/a&gt;&lt;/li&gt;
                    &lt;li&lt;?php if ($page == &#039;personality&#039;) echo &#039; class=&quot;isactive&quot;&#039;; ?&gt;&gt;&lt;a href=&quot;profile.php?section=personality&amp;amp;id=&lt;?php echo $id ?&gt;&quot;&gt;&lt;?php echo $lang_profile[&#039;Section personality&#039;] ?&gt;&lt;/a&gt;&lt;/li&gt;
                    &lt;li&lt;?php if ($page == &#039;display&#039;) echo &#039; class=&quot;isactive&quot;&#039;; ?&gt;&gt;&lt;a href=&quot;profile.php?section=display&amp;amp;id=&lt;?php echo $id ?&gt;&quot;&gt;&lt;?php echo $lang_profile[&#039;Section display&#039;] ?&gt;&lt;/a&gt;&lt;/li&gt;
                    &lt;li&lt;?php if ($page == &#039;privacy&#039;) echo &#039; class=&quot;isactive&quot;&#039;; ?&gt;&gt;&lt;a href=&quot;profile.php?section=privacy&amp;amp;id=&lt;?php echo $id ?&gt;&quot;&gt;&lt;?php echo $lang_profile[&#039;Section privacy&#039;] ?&gt;&lt;/a&gt;&lt;/li&gt;
&lt;?php if ($pun_user[&#039;g_id&#039;] == PUN_ADMIN || ($pun_user[&#039;g_id&#039;] == PUN_MOD &amp;&amp; $pun_config[&#039;p_mod_ban_users&#039;] == &#039;1&#039;)): ?&gt;                    &lt;li&lt;?php if ($page == &#039;admin&#039;) echo &#039; class=&quot;isactive&quot;&#039;; ?&gt;&gt;&lt;a href=&quot;profile.php?section=admin&amp;amp;id=&lt;?php echo $id ?&gt;&quot;&gt;&lt;?php echo $lang_profile[&#039;Section admin&#039;] ?&gt;&lt;/a&gt;&lt;/li&gt;
&lt;?php endif; ?&gt;                &lt;/ul&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;?php

}


//
// Update posts, topics, last_post, last_post_id and last_poster for a forum (redirect topics are not included)
//
function update_forum($forum_id)
{
    global $db;

    $result = $db-&gt;query(&#039;SELECT COUNT(id), SUM(num_replies) FROM &#039;.$db-&gt;prefix.&#039;topics WHERE moved_to IS NULL AND forum_id=&#039;.$forum_id) or error(&#039;Unable to fetch forum topic count&#039;, __FILE__, __LINE__, $db-&gt;error());
    list($num_topics, $num_posts) = $db-&gt;fetch_row($result);

    $num_posts = $num_posts + $num_topics;        // $num_posts is only the sum of all replies (we have to add the topic posts)

    $result = $db-&gt;query(&#039;SELECT last_post, last_post_id, last_poster FROM &#039;.$db-&gt;prefix.&#039;topics WHERE forum_id=&#039;.$forum_id.&#039; AND moved_to IS NULL ORDER BY last_post DESC LIMIT 1&#039;) or error(&#039;Unable to fetch last_post/last_post_id/last_poster&#039;, __FILE__, __LINE__, $db-&gt;error());
    if ($db-&gt;num_rows($result))        // There are topics in the forum
    {
        list($last_post, $last_post_id, $last_poster) = $db-&gt;fetch_row($result);

        $db-&gt;query(&#039;UPDATE &#039;.$db-&gt;prefix.&#039;forums SET num_topics=&#039;.$num_topics.&#039;, num_posts=&#039;.$num_posts.&#039;, last_post=&#039;.$last_post.&#039;, last_post_id=&#039;.$last_post_id.&#039;, last_poster=\&#039;&#039;.$db-&gt;escape($last_poster).&#039;\&#039; WHERE id=&#039;.$forum_id) or error(&#039;Unable to update last_post/last_post_id/last_poster&#039;, __FILE__, __LINE__, $db-&gt;error());
    }
    else    // There are no topics
        $db-&gt;query(&#039;UPDATE &#039;.$db-&gt;prefix.&#039;forums SET num_topics=0, num_posts=0, last_post=NULL, last_post_id=NULL, last_poster=NULL WHERE id=&#039;.$forum_id) or error(&#039;Unable to update last_post/last_post_id/last_poster&#039;, __FILE__, __LINE__, $db-&gt;error());
}


//
// Delete a topic and all of it&#039;s posts
//
function delete_topic($topic_id)
{
    global $db;

    // Delete the topic and any redirect topics
    $db-&gt;query(&#039;DELETE FROM &#039;.$db-&gt;prefix.&#039;topics WHERE id=&#039;.$topic_id.&#039; OR moved_to=&#039;.$topic_id) or error(&#039;Unable to delete topic&#039;, __FILE__, __LINE__, $db-&gt;error());

    // Create a list of the post ID&#039;s in this topic
    $post_ids = &#039;&#039;;
    $result = $db-&gt;query(&#039;SELECT id FROM &#039;.$db-&gt;prefix.&#039;posts WHERE topic_id=&#039;.$topic_id) or error(&#039;Unable to fetch posts&#039;, __FILE__, __LINE__, $db-&gt;error());
    while ($row = $db-&gt;fetch_row($result))
        $post_ids .= ($post_ids != &#039;&#039;) ? &#039;,&#039;.$row[0] : $row[0];

    // Make sure we have a list of post ID&#039;s
    if ($post_ids != &#039;&#039;)
    {
        strip_search_index($post_ids);

        // Delete posts in topic
        $db-&gt;query(&#039;DELETE FROM &#039;.$db-&gt;prefix.&#039;posts WHERE topic_id=&#039;.$topic_id) or error(&#039;Unable to delete posts&#039;, __FILE__, __LINE__, $db-&gt;error());
    }

    // Delete any subscriptions for this topic
    $db-&gt;query(&#039;DELETE FROM &#039;.$db-&gt;prefix.&#039;subscriptions WHERE topic_id=&#039;.$topic_id) or error(&#039;Unable to delete subscriptions&#039;, __FILE__, __LINE__, $db-&gt;error());
}


//
// Delete a single post
//
function delete_post($post_id, $topic_id)
{
    global $db;

    $result = $db-&gt;query(&#039;SELECT id, poster, posted FROM &#039;.$db-&gt;prefix.&#039;posts WHERE topic_id=&#039;.$topic_id.&#039; ORDER BY id DESC LIMIT 2&#039;) or error(&#039;Unable to fetch post info&#039;, __FILE__, __LINE__, $db-&gt;error());
    list($last_id, ,) = $db-&gt;fetch_row($result);
    list($second_last_id, $second_poster, $second_posted) = $db-&gt;fetch_row($result);

    // Delete the post
    $db-&gt;query(&#039;DELETE FROM &#039;.$db-&gt;prefix.&#039;posts WHERE id=&#039;.$post_id) or error(&#039;Unable to delete post&#039;, __FILE__, __LINE__, $db-&gt;error());

    strip_search_index($post_id);

    // Count number of replies in the topic
    $result = $db-&gt;query(&#039;SELECT COUNT(id) FROM &#039;.$db-&gt;prefix.&#039;posts WHERE topic_id=&#039;.$topic_id) or error(&#039;Unable to fetch post count for topic&#039;, __FILE__, __LINE__, $db-&gt;error());
    $num_replies = $db-&gt;result($result, 0) - 1;

    // If the message we deleted is the most recent in the topic (at the end of the topic)
    if ($last_id == $post_id)
    {
        // If there is a $second_last_id there is more than 1 reply to the topic
        if (!empty($second_last_id))
            $db-&gt;query(&#039;UPDATE &#039;.$db-&gt;prefix.&#039;topics SET last_post=&#039;.$second_posted.&#039;, last_post_id=&#039;.$second_last_id.&#039;, last_poster=\&#039;&#039;.$db-&gt;escape($second_poster).&#039;\&#039;, num_replies=&#039;.$num_replies.&#039; WHERE id=&#039;.$topic_id) or error(&#039;Unable to update topic&#039;, __FILE__, __LINE__, $db-&gt;error());
        else
            // We deleted the only reply, so now last_post/last_post_id/last_poster is posted/id/poster from the topic itself
            $db-&gt;query(&#039;UPDATE &#039;.$db-&gt;prefix.&#039;topics SET last_post=posted, last_post_id=id, last_poster=poster, num_replies=&#039;.$num_replies.&#039; WHERE id=&#039;.$topic_id) or error(&#039;Unable to update topic&#039;, __FILE__, __LINE__, $db-&gt;error());
    }
    else
        // Otherwise we just decrement the reply counter
        $db-&gt;query(&#039;UPDATE &#039;.$db-&gt;prefix.&#039;topics SET num_replies=&#039;.$num_replies.&#039; WHERE id=&#039;.$topic_id) or error(&#039;Unable to update topic&#039;, __FILE__, __LINE__, $db-&gt;error());
}


//
// Replace censored words in $text
//
function censor_words($text)
{
    global $db;
    static $search_for, $replace_with;

    // If not already built in a previous call, build an array of censor words and their replacement text
    if (!isset($search_for))
    {
        $result = $db-&gt;query(&#039;SELECT search_for, replace_with FROM &#039;.$db-&gt;prefix.&#039;censoring&#039;) or error(&#039;Unable to fetch censor word list&#039;, __FILE__, __LINE__, $db-&gt;error());
        $num_words = $db-&gt;num_rows($result);

        $search_for = array();
        for ($i = 0; $i &lt; $num_words; ++$i)
        {
            list($search_for[$i], $replace_with[$i]) = $db-&gt;fetch_row($result);
            $search_for[$i] = &#039;/\b(&#039;.str_replace(&#039;\*&#039;, &#039;\w*?&#039;, preg_quote($search_for[$i], &#039;/&#039;)).&#039;)\b/i&#039;;
        }
    }

    if (!empty($search_for))
        $text = substr(preg_replace($search_for, $replace_with, &#039; &#039;.$text.&#039; &#039;), 1, -1);

    return $text;
}


//
// Determines the correct title for $user
// $user must contain the elements &#039;username&#039;, &#039;title&#039;, &#039;posts&#039;, &#039;g_id&#039; and &#039;g_user_title&#039;
//
function get_title($user)
{
    global $db, $pun_config, $pun_bans, $lang_common;
    static $ban_list, $pun_ranks;

    // If not already built in a previous call, build an array of lowercase banned usernames
    if (empty($ban_list))
    {
        $ban_list = array();

        foreach ($pun_bans as $cur_ban)
            $ban_list[] = strtolower($cur_ban[&#039;username&#039;]);
    }

    // If not already loaded in a previous call, load the cached ranks
    if ($pun_config[&#039;o_ranks&#039;] == &#039;1&#039; &amp;&amp; empty($pun_ranks))
    {
        @include PUN_ROOT.&#039;cache/cache_ranks.php&#039;;
        if (!defined(&#039;PUN_RANKS_LOADED&#039;))
        {
            require_once PUN_ROOT.&#039;include/cache.php&#039;;
            generate_ranks_cache();
            require PUN_ROOT.&#039;cache/cache_ranks.php&#039;;
        }
    }

    // If the user has a custom title
    if ($user[&#039;title&#039;] != &#039;&#039;)
        $user_title = pun_htmlspecialchars($user[&#039;title&#039;]);
    // If the user is banned
    else if (in_array(strtolower($user[&#039;username&#039;]), $ban_list))
        $user_title = $lang_common[&#039;Banned&#039;];
    // If the user group has a default user title
    else if ($user[&#039;g_user_title&#039;] != &#039;&#039;)
        $user_title = pun_htmlspecialchars($user[&#039;g_user_title&#039;]);
    // If the user is a guest
    else if ($user[&#039;g_id&#039;] == PUN_GUEST)
        $user_title = $lang_common[&#039;Guest&#039;];
    else
    {
        // Are there any ranks?
        if ($pun_config[&#039;o_ranks&#039;] == &#039;1&#039; &amp;&amp; !empty($pun_ranks))
        {
            @reset($pun_ranks);
            while (list(, $cur_rank) = @each($pun_ranks))
            {
                if (intval($user[&#039;num_posts&#039;]) &gt;= $cur_rank[&#039;min_posts&#039;])
                    $user_title = pun_htmlspecialchars($cur_rank[&#039;rank&#039;]);
            }
        }

        // If the user didn&#039;t &quot;reach&quot; any rank (or if ranks are disabled), we assign the default
        if (!isset($user_title))
            $user_title = $lang_common[&#039;Member&#039;];
    }

    return $user_title;
}


//
// Generate a string with numbered links (for multipage scripts)
//
function paginate($num_pages, $cur_page, $link_to)
{
    $pages = array();
    $link_to_all = false;

    // If $cur_page == -1, we link to all pages (used in viewforum.php)
    if ($cur_page == -1)
    {
        $cur_page = 1;
        $link_to_all = true;
    }

    if ($num_pages &lt;= 1)
        $pages = array(&#039;&lt;strong&gt;1&lt;/strong&gt;&#039;);
    else
    {
        if ($cur_page &gt; 3)
        {
            $pages[] = &#039;&lt;a href=&quot;&#039;.$link_to.&#039;&amp;amp;p=1&quot;&gt;1&lt;/a&gt;&#039;;

            if ($cur_page != 4)
                $pages[] = &#039;&amp;hellip;&#039;;
        }

        // Don&#039;t ask me how the following works. It just does, OK? :-)
        for ($current = $cur_page - 2, $stop = $cur_page + 3; $current &lt; $stop; ++$current)
        {
            if ($current &lt; 1 || $current &gt; $num_pages)
                continue;
            else if ($current != $cur_page || $link_to_all)
                $pages[] = &#039;&lt;a href=&quot;&#039;.$link_to.&#039;&amp;amp;p=&#039;.$current.&#039;&quot;&gt;&#039;.$current.&#039;&lt;/a&gt;&#039;;
            else
                $pages[] = &#039;&lt;strong&gt;&#039;.$current.&#039;&lt;/strong&gt;&#039;;
        }

        if ($cur_page &lt;= ($num_pages-3))
        {
            if ($cur_page != ($num_pages-3))
                $pages[] = &#039;&amp;hellip;&#039;;

            $pages[] = &#039;&lt;a href=&quot;&#039;.$link_to.&#039;&amp;amp;p=&#039;.$num_pages.&#039;&quot;&gt;&#039;.$num_pages.&#039;&lt;/a&gt;&#039;;
        }
    }

    return implode(&#039;&amp;nbsp;&#039;, $pages);
}


//
// Display a message
//
function message($message, $no_back_link = false)
{
    global $db, $lang_common, $pun_config, $pun_start, $tpl_main;

    if (!defined(&#039;PUN_HEADER&#039;))
    {
        global $pun_user;

        $page_title = pun_htmlspecialchars($pun_config[&#039;o_board_title&#039;]).&#039; / &#039;.$lang_common[&#039;Info&#039;];
        require PUN_ROOT.&#039;header.php&#039;;
    }

?&gt;

&lt;div id=&quot;msg&quot; class=&quot;block&quot;&gt;
    &lt;h2&gt;&lt;span&gt;&lt;?php echo $lang_common[&#039;Info&#039;] ?&gt;&lt;/span&gt;&lt;/h2&gt;
    &lt;div class=&quot;box&quot;&gt;
        &lt;div class=&quot;inbox&quot;&gt;
        &lt;p&gt;&lt;?php echo $message ?&gt;&lt;/p&gt;
&lt;?php if (!$no_back_link): ?&gt;        &lt;p&gt;&lt;a href=&quot;javascript: history.go(-1)&quot;&gt;&lt;?php echo $lang_common[&#039;Go back&#039;] ?&gt;&lt;/a&gt;&lt;/p&gt;
&lt;?php endif; ?&gt;        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;?php

    require PUN_ROOT.&#039;footer.php&#039;;
}


//
// Format a time string according to $time_format and timezones
//
function format_time($timestamp, $date_only = false)
{
    global $pun_config, $lang_common, $pun_user;

    if ($timestamp == &#039;&#039;)
        return $lang_common[&#039;Never&#039;];

    $diff = ($pun_user[&#039;timezone&#039;] - $pun_config[&#039;o_server_timezone&#039;]) * 3600;
    $timestamp += $diff;
    $now = time();

    $date = date($pun_config[&#039;o_date_format&#039;], $timestamp);
    $today = date($pun_config[&#039;o_date_format&#039;], $now+$diff);
    $yesterday = date($pun_config[&#039;o_date_format&#039;], $now+$diff-86400);

    if ($date == $today)
        $date = $lang_common[&#039;Today&#039;];
    else if ($date == $yesterday)
        $date = $lang_common[&#039;Yesterday&#039;];

    if (!$date_only)
        return $date.&#039; &#039;.date($pun_config[&#039;o_time_format&#039;], $timestamp);
    else
        return $date;
}


//
// If we are running pre PHP 4.3.0, we add our own implementation of file_get_contents
//
if (!function_exists(&#039;file_get_contents&#039;))
{
    function file_get_contents($filename, $use_include_path = 0)
    {
        $data = &#039;&#039;;

        if ($fh = fopen($filename, &#039;rb&#039;, $use_include_path))
        {
            $data = fread($fh, filesize($filename));
            fclose($fh);
        }

        return $data;
    }
}


//
// Make sure that HTTP_REFERER matches $pun_config[&#039;o_base_url&#039;]/$script
//
function confirm_referrer($script)
{
    global $pun_config, $lang_common;

    if (!preg_match(&#039;#^&#039;.preg_quote(str_replace(&#039;www.&#039;, &#039;&#039;, $pun_config[&#039;o_base_url&#039;]).&#039;/&#039;.$script, &#039;#&#039;).&#039;#i&#039;, str_replace(&#039;www.&#039;, &#039;&#039;, (isset($_SERVER[&#039;HTTP_REFERER&#039;]) ? $_SERVER[&#039;HTTP_REFERER&#039;] : &#039;&#039;))))
        message($lang_common[&#039;Bad referrer&#039;]);
}


//
// Generate a random password of length $len
//
function random_pass($len)
{
    $chars = &#039;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789&#039;;

    $password = &#039;&#039;;
    for ($i = 0; $i &lt; $len; ++$i)
        $password .= substr($chars, (mt_rand() % strlen($chars)), 1);

    return $password;
}


//
// Compute a hash of $str
// Uses sha1() if available. If not, SHA1 through mhash() if available. If not, fall back on md5().
//
function pun_hash($str)
{
    if (function_exists(&#039;sha1&#039;))    // Only in PHP 4.3.0+
        return sha1($str);
    else if (function_exists(&#039;mhash&#039;))    // Only if Mhash library is loaded
        return bin2hex(mhash(MHASH_SHA1, $str));
    else
        return md5($str);
}


//
// Try to determine the correct remote IP-address
//
function get_remote_address()
{
    return $_SERVER[&#039;REMOTE_ADDR&#039;];
}


//
// Equivalent to htmlspecialchars(), but allows &amp;#[0-9]+ (for unicode)
//
function pun_htmlspecialchars($str)
{
    $str = preg_replace(&#039;/&amp;(?!#[0-9]+;)/s&#039;, &#039;&amp;amp;&#039;, $str);
    $str = str_replace(array(&#039;&lt;&#039;, &#039;&gt;&#039;, &#039;&quot;&#039;), array(&#039;&amp;lt;&#039;, &#039;&amp;gt;&#039;, &#039;&amp;quot;&#039;), $str);

    return $str;
}


//
// Equivalent to strlen(), but counts &amp;#[0-9]+ as one character (for unicode)
//
function pun_strlen($str)
{
    return strlen(preg_replace(&#039;/&amp;#([0-9]+);/&#039;, &#039;!&#039;, $str));
}


//
// Convert \r\n and \r to \n
//
function pun_linebreaks($str)
{
    return str_replace(&quot;\r&quot;, &quot;\n&quot;, str_replace(&quot;\r\n&quot;, &quot;\n&quot;, $str));
}


//
// A more aggressive version of trim()
//
function pun_trim($str)
{
    global $lang_common;

    if (strpos($lang_common[&#039;lang_encoding&#039;], &#039;8859&#039;) !== false)
    {
        $fishy_chars = array(chr(0x81), chr(0x8D), chr(0x8F), chr(0x90), chr(0x9D), chr(0xA0));
        return trim(str_replace($fishy_chars, &#039; &#039;, $str));
    }
    else
        return trim($str);
}


//
// Display a message when board is in maintenance mode
//
function maintenance_message()
{
    global $db, $pun_config, $lang_common, $pun_user;

    // Deal with newlines, tabs and multiple spaces
    $pattern = array(&quot;\t&quot;, &#039;  &#039;, &#039;  &#039;);
    $replace = array(&#039;&amp;nbsp; &amp;nbsp; &#039;, &#039;&amp;nbsp; &#039;, &#039; &amp;nbsp;&#039;);
    $message = str_replace($pattern, $replace, $pun_config[&#039;o_maintenance_message&#039;]);


    // Load the maintenance template
    $tpl_maint = trim(file_get_contents(PUN_ROOT.&#039;include/template/maintenance.tpl&#039;));


    // START SUBST - &lt;pun_include &quot;*&quot;&gt;
    while (preg_match(&#039;#&lt;pun_include &quot;([^/\\\\]*?)\.(php[45]?|inc|html?|txt)&quot;&gt;#&#039;, $tpl_maint, $cur_include))
    {
        if (!file_exists(PUN_ROOT.&#039;include/user/&#039;.$cur_include[1].&#039;.&#039;.$cur_include[2]))
            error(&#039;Unable to process user include &#039;.htmlspecialchars($cur_include[0]).&#039; from template maintenance.tpl. There is no such file in folder /include/user/&#039;);

        ob_start();
        include PUN_ROOT.&#039;include/user/&#039;.$cur_include[1].&#039;.&#039;.$cur_include[2];
        $tpl_temp = ob_get_contents();
        $tpl_maint = str_replace($cur_include[0], $tpl_temp, $tpl_maint);
        ob_end_clean();
    }
    // END SUBST - &lt;pun_include &quot;*&quot;&gt;


    // START SUBST - &lt;pun_content_direction&gt;
    $tpl_maint = str_replace(&#039;&lt;pun_content_direction&gt;&#039;, $lang_common[&#039;lang_direction&#039;], $tpl_maint);
    // END SUBST - &lt;pun_content_direction&gt;


    // START SUBST - &lt;pun_char_encoding&gt;
    $tpl_maint = str_replace(&#039;&lt;pun_char_encoding&gt;&#039;, $lang_common[&#039;lang_encoding&#039;], $tpl_maint);
    // END SUBST - &lt;pun_char_encoding&gt;


    // START SUBST - &lt;pun_head&gt;
    ob_start();

?&gt;
&lt;title&gt;&lt;?php echo pun_htmlspecialchars($pun_config[&#039;o_board_title&#039;]).&#039; / &#039;.$lang_common[&#039;Maintenance&#039;] ?&gt;&lt;/title&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;style/&lt;?php echo $pun_user[&#039;style&#039;].&#039;.css&#039; ?&gt;&quot; /&gt;
&lt;?php

    $tpl_temp = trim(ob_get_contents());
    $tpl_maint = str_replace(&#039;&lt;pun_head&gt;&#039;, $tpl_temp, $tpl_maint);
    ob_end_clean();
    // END SUBST - &lt;pun_head&gt;


    // START SUBST - &lt;pun_maint_heading&gt;
    $tpl_maint = str_replace(&#039;&lt;pun_maint_heading&gt;&#039;, $lang_common[&#039;Maintenance&#039;], $tpl_maint);
    // END SUBST - &lt;pun_maint_heading&gt;


    // START SUBST - &lt;pun_maint_message&gt;
    $tpl_maint = str_replace(&#039;&lt;pun_maint_message&gt;&#039;, $message, $tpl_maint);
    // END SUBST - &lt;pun_maint_message&gt;


    // End the transaction
    $db-&gt;end_transaction();


    // Close the db connection (and free up any result data)
    $db-&gt;close();

    exit($tpl_maint);
}


//
// Display $message and redirect user to $destination_url
//
function redirect($destination_url, $message)
{
    global $db, $pun_config, $lang_common, $pun_user;

    if ($destination_url == &#039;&#039;)
        $destination_url = &#039;index.php&#039;;

    // If the delay is 0 seconds, we might as well skip the redirect all together
    if ($pun_config[&#039;o_redirect_delay&#039;] == &#039;0&#039;)
        header(&#039;Location: &#039;.str_replace(&#039;&amp;amp;&#039;, &#039;&amp;&#039;, $destination_url));


    // Load the redirect template
    $tpl_redir = trim(file_get_contents(PUN_ROOT.&#039;include/template/redirect.tpl&#039;));


    // START SUBST - &lt;pun_include &quot;*&quot;&gt;
    while (preg_match(&#039;#&lt;pun_include &quot;([^/\\\\]*?)\.(php[45]?|inc|html?|txt)&quot;&gt;#&#039;, $tpl_redir, $cur_include))
    {
        if (!file_exists(PUN_ROOT.&#039;include/user/&#039;.$cur_include[1].&#039;.&#039;.$cur_include[2]))
            error(&#039;Unable to process user include &#039;.htmlspecialchars($cur_include[0]).&#039; from template redirect.tpl. There is no such file in folder /include/user/&#039;);

        ob_start();
        include PUN_ROOT.&#039;include/user/&#039;.$cur_include[1].&#039;.&#039;.$cur_include[2];
        $tpl_temp = ob_get_contents();
        $tpl_redir = str_replace($cur_include[0], $tpl_temp, $tpl_redir);
        ob_end_clean();
    }
    // END SUBST - &lt;pun_include &quot;*&quot;&gt;


    // START SUBST - &lt;pun_content_direction&gt;
    $tpl_redir = str_replace(&#039;&lt;pun_content_direction&gt;&#039;, $lang_common[&#039;lang_direction&#039;], $tpl_redir);
    // END SUBST - &lt;pun_content_direction&gt;


    // START SUBST - &lt;pun_char_encoding&gt;
    $tpl_redir = str_replace(&#039;&lt;pun_char_encoding&gt;&#039;, $lang_common[&#039;lang_encoding&#039;], $tpl_redir);
    // END SUBST - &lt;pun_char_encoding&gt;


    // START SUBST - &lt;pun_head&gt;
    ob_start();

?&gt;
&lt;meta http-equiv=&quot;refresh&quot; content=&quot;&lt;?php echo $pun_config[&#039;o_redirect_delay&#039;] ?&gt;;URL=&lt;?php echo str_replace(array(&#039;&lt;&#039;, &#039;&gt;&#039;, &#039;&quot;&#039;), array(&#039;&amp;lt;&#039;, &#039;&amp;gt;&#039;, &#039;&amp;quot;&#039;), $destination_url) ?&gt;&quot; /&gt;
&lt;title&gt;&lt;?php echo pun_htmlspecialchars($pun_config[&#039;o_board_title&#039;]).&#039; / &#039;.$lang_common[&#039;Redirecting&#039;] ?&gt;&lt;/title&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;style/&lt;?php echo $pun_user[&#039;style&#039;].&#039;.css&#039; ?&gt;&quot; /&gt;
&lt;?php

    $tpl_temp = trim(ob_get_contents());
    $tpl_redir = str_replace(&#039;&lt;pun_head&gt;&#039;, $tpl_temp, $tpl_redir);
    ob_end_clean();
    // END SUBST - &lt;pun_head&gt;


    // START SUBST - &lt;pun_redir_heading&gt;
    $tpl_redir = str_replace(&#039;&lt;pun_redir_heading&gt;&#039;, $lang_common[&#039;Redirecting&#039;], $tpl_redir);
    // END SUBST - &lt;pun_redir_heading&gt;


    // START SUBST - &lt;pun_redir_text&gt;
    $tpl_temp = $message.&#039;&lt;br /&gt;&lt;br /&gt;&#039;.&#039;&lt;a href=&quot;&#039;.$destination_url.&#039;&quot;&gt;&#039;.$lang_common[&#039;Click redirect&#039;].&#039;&lt;/a&gt;&#039;;
    $tpl_redir = str_replace(&#039;&lt;pun_redir_text&gt;&#039;, $tpl_temp, $tpl_redir);
    // END SUBST - &lt;pun_redir_text&gt;


    // START SUBST - &lt;pun_footer&gt;
    ob_start();

    // End the transaction
    $db-&gt;end_transaction();

    // Display executed queries (if enabled)
    if (defined(&#039;PUN_SHOW_QUERIES&#039;))
        display_saved_queries();

    $tpl_temp = trim(ob_get_contents());
    $tpl_redir = str_replace(&#039;&lt;pun_footer&gt;&#039;, $tpl_temp, $tpl_redir);
    ob_end_clean();
    // END SUBST - &lt;pun_footer&gt;


    // Close the db connection (and free up any result data)
    $db-&gt;close();

    exit($tpl_redir);
}


//
// Display a simple error message
//
function error($message, $file, $line, $db_error = false)
{
    global $pun_config;

    // Set a default title if the script failed before $pun_config could be populated
    if (empty($pun_config))
        $pun_config[&#039;o_board_title&#039;] = &#039;PunBB&#039;;

    // Empty output buffer and stop buffering
    @ob_end_clean();

    // &quot;Restart&quot; output buffering if we are using ob_gzhandler (since the gzip header is already sent)
    if (!empty($pun_config[&#039;o_gzip&#039;]) &amp;&amp; extension_loaded(&#039;zlib&#039;) &amp;&amp; (strpos($_SERVER[&#039;HTTP_ACCEPT_ENCODING&#039;], &#039;gzip&#039;) !== false || strpos($_SERVER[&#039;HTTP_ACCEPT_ENCODING&#039;], &#039;deflate&#039;) !== false))
        ob_start(&#039;ob_gzhandler&#039;);

?&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;[url]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd[/url]&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; dir=&quot;ltr&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; /&gt;
&lt;title&gt;&lt;?php echo pun_htmlspecialchars($pun_config[&#039;o_board_title&#039;]) ?&gt; / Error&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
&lt;!--
BODY {MARGIN: 10% 20% auto 20%; font: 10px Verdana, Arial, Helvetica, sans-serif}
#errorbox {BORDER: 1px solid #B84623}
H2 {MARGIN: 0; COLOR: #FFFFFF; BACKGROUND-COLOR: #B84623; FONT-SIZE: 1.1em; PADDING: 5px 4px}
#errorbox DIV {PADDING: 6px 5px; BACKGROUND-COLOR: #F1F1F1}
--&gt;
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;div id=&quot;errorbox&quot;&gt;
    &lt;h2&gt;An error was encountered&lt;/h2&gt;
    &lt;div&gt;
&lt;?php

    if (defined(&#039;PUN_DEBUG&#039;))
    {
        echo &quot;\t\t&quot;.&#039;&lt;strong&gt;File:&lt;/strong&gt; &#039;.$file.&#039;&lt;br /&gt;&#039;.&quot;\n\t\t&quot;.&#039;&lt;strong&gt;Line:&lt;/strong&gt; &#039;.$line.&#039;&lt;br /&gt;&lt;br /&gt;&#039;.&quot;\n\t\t&quot;.&#039;&lt;strong&gt;PunBB reported&lt;/strong&gt;: &#039;.$message.&quot;\n&quot;;

        if ($db_error)
        {
            echo &quot;\t\t&quot;.&#039;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Database reported:&lt;/strong&gt; &#039;.pun_htmlspecialchars($db_error[&#039;error_msg&#039;]).(($db_error[&#039;error_no&#039;]) ? &#039; (Errno: &#039;.$db_error[&#039;error_no&#039;].&#039;)&#039; : &#039;&#039;).&quot;\n&quot;;

            if ($db_error[&#039;error_sql&#039;] != &#039;&#039;)
                echo &quot;\t\t&quot;.&#039;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Failed query:&lt;/strong&gt; &#039;.pun_htmlspecialchars($db_error[&#039;error_sql&#039;]).&quot;\n&quot;;
        }
    }
    else
        echo &quot;\t\t&quot;.&#039;Error: &lt;strong&gt;&#039;.$message.&#039;.&lt;/strong&gt;&#039;.&quot;\n&quot;;

?&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;
&lt;?php

    // If a database connection was established (before this error) we close it
    if ($db_error)
        $GLOBALS[&#039;db&#039;]-&gt;close();

    exit;
}

// DEBUG FUNCTIONS BELOW

//
// Display executed queries (if enabled)
//
function display_saved_queries()
{
    global $db, $lang_common;

    // Get the queries so that we can print them out
    $saved_queries = $db-&gt;get_saved_queries();

?&gt;

&lt;div id=&quot;debug&quot; class=&quot;blocktable&quot;&gt;
    &lt;h2&gt;&lt;span&gt;&lt;?php echo $lang_common[&#039;Debug table&#039;] ?&gt;&lt;/span&gt;&lt;/h2&gt;
    &lt;div class=&quot;box&quot;&gt;
        &lt;div class=&quot;inbox&quot;&gt;
            &lt;table cellspacing=&quot;0&quot;&gt;
            &lt;thead&gt;
                &lt;tr&gt;
                    &lt;th class=&quot;tcl&quot; scope=&quot;col&quot;&gt;Time (s)&lt;/th&gt;
                    &lt;th class=&quot;tcr&quot; scope=&quot;col&quot;&gt;Query&lt;/th&gt;
                &lt;/tr&gt;
            &lt;/thead&gt;
            &lt;tbody&gt;
&lt;?php

    $query_time_total = 0.0;
    while (list(, $cur_query) = @each($saved_queries))
    {
        $query_time_total += $cur_query[1];

?&gt;
                &lt;tr&gt;
                    &lt;td class=&quot;tcl&quot;&gt;&lt;?php echo ($cur_query[1] != 0) ? $cur_query[1] : &#039;&amp;nbsp;&#039; ?&gt;&lt;/td&gt;
                    &lt;td class=&quot;tcr&quot;&gt;&lt;?php echo pun_htmlspecialchars($cur_query[0]) ?&gt;&lt;/td&gt;
                &lt;/tr&gt;
&lt;?php

    }

?&gt;
                &lt;tr&gt;
                    &lt;td class=&quot;tcl&quot; colspan=&quot;2&quot;&gt;Total query time: &lt;?php echo $query_time_total ?&gt; s&lt;/td&gt;
                &lt;/tr&gt;
            &lt;/tbody&gt;
            &lt;/table&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;?php

}


//
// Unset any variables instantiated as a result of register_globals being enabled
//
function unregister_globals()
{
    $register_globals = @ini_get(&#039;register_globals&#039;);
    if ($register_globals === &quot;&quot; || $register_globals === &quot;0&quot; || strtolower($register_globals === &quot;off&quot;))
        return;

    // Prevent script.php?GLOBALS[foo]=bar
    if (isset($_REQUEST[&#039;GLOBALS&#039;]) || isset($_FILES[&#039;GLOBALS&#039;]))
        exit(&#039;I\&#039;ll have a steak sandwich and... a steak sandwich.&#039;);
    
    // Variables that shouldn&#039;t be unset
    $no_unset = array(&#039;GLOBALS&#039;, &#039;_GET&#039;, &#039;_POST&#039;, &#039;_COOKIE&#039;, &#039;_REQUEST&#039;, &#039;_SERVER&#039;, &#039;_ENV&#039;, &#039;_FILES&#039;);

    // Remove elements in $GLOBALS that are present in any of the superglobals
    $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) &amp;&amp; is_array($_SESSION) ? $_SESSION : array());
    foreach ($input as $k =&gt; $v)
    {
        if (!in_array($k, $no_unset) &amp;&amp; isset($GLOBALS[$k]))
        {
            unset($GLOBALS[$k]);
            unset($GLOBALS[$k]);    // Double unset to circumvent the zend_hash_del_key_or_index hole in PHP &lt;4.4.3 and &lt;5.1.4
        }
    }
}


//
// Dump contents of variable(s)
//
function dump()
{
    echo &#039;&lt;pre&gt;&#039;;

    $num_args = func_num_args();

    for ($i = 0; $i &lt; $num_args; ++$i)
    {
        print_r(func_get_arg($i));
        echo &quot;\n\n&quot;;
    }

    echo &#039;&lt;/pre&gt;&#039;;
    exit;
}</code></pre></div></blockquote></div>]]></description>
			<author><![CDATA[null@example.com (WlaT_ShaQLaWa)]]></author>
			<pubDate>Sat, 26 May 2012 01:11:03 +0000</pubDate>
			<guid>https://www.webchin.org/Meko/viewtopic.php?pid=219943#p219943</guid>
		</item>
		<item>
			<title><![CDATA[وه‌ڵام: كه‌ زانياری تاكه‌كه‌سی ئه‌كه‌مه‌وه‌ ئه‌مه‌ ديت]]></title>
			<link>https://www.webchin.org/Meko/viewtopic.php?pid=219942#p219942</link>
			<description><![CDATA[<p>فه‌رموو كاك ئاسۆ سوپاس بۆ وه‌لامه‌كه‌ت <br /><a href="http://www.gulfup.com/show/X5n1qy47ibwxx"><span class="postimg"><img src="http://im13.gulfup.com/2012-05-26/1337994534391.jpg" alt="http://im13.gulfup.com/2012-05-26/1337994534391.jpg" /></span></a></p>]]></description>
			<author><![CDATA[null@example.com (WlaT_ShaQLaWa)]]></author>
			<pubDate>Sat, 26 May 2012 01:09:39 +0000</pubDate>
			<guid>https://www.webchin.org/Meko/viewtopic.php?pid=219942#p219942</guid>
		</item>
	</channel>
</rss>
