PunBB Resource

Your ultimate PunBB resource!

Keywords:

    (Extended)

You are not logged in.

#26 2007-07-17 16:31:10

doki
Member
Registered: 2007-04-30
Posts: 225

Re: PBB User Blogs 1.2

no errors, but the  edit and delete function is not showing on the bottom of the blog when the moderator is login.

Offline

 

#27 2007-07-17 16:37:50

soonotes
Member
Registered: 2006-09-21
Posts: 112

Re: PBB User Blogs 1.2

So just the mods and the user who wrote the blog don't get the edit or delete but the admin does?  I registered on your site (TinyTim). I'll be out for the day but if you can make me a mod for the blog categories you have I'll check it out later. Nice site by the way.

edited to add: those links are only there in the full blog view so make sure they are checking there. smile

Last edited by soonotes (2007-07-17 16:45:15)

Offline

 

#28 2007-07-17 16:57:40

doki
Member
Registered: 2007-04-30
Posts: 225

Re: PBB User Blogs 1.2

Thanks.

Yes the moderator don't have the edit and delete function. I think the blog creator have the same problem but im not sure. But in admin account, he has the full access to blogs.

edited to add: those links are only there in the full blog view so make sure they are checking there.

Yes, I tried it on the full blog view but still not showing up.

I've found other bug:

When setting the truncate to 800 or more (1000). I having this error message:

Code:

Warning: preg_match() [function.preg-match]: Compilation failed: regular expression too large at offset 48 in /home/xxxx/public_html/include/blog.php on line 145

By the way I just added you to the moderator group and have moderator rights on the blogs (Articles Category).

Last edited by doki (2007-07-17 17:12:39)

Offline

 

#29 2007-07-17 22:25:47

soonotes
Member
Registered: 2006-09-21
Posts: 112

Re: PBB User Blogs 1.2

Did you make any changes to blogs.php? I can edit it if I go directly to http://www.yoursite.com/blogs_edit.php?bid=7 but the links aren't there. Around line 598 in blogs.php do you have

Code:

        if (($cur_blog['poster_id'] == $pun_user['id']) && (!$is_admmod) && (!$pun_user['is_guest']))
                {
                    $post_actions[] = ''.$com_num.'';
                    $post_actions[] = 'Posted by: '.pun_htmlspecialchars($cur_blog['poster']).'';
                    $post_actions[] = ''.format_time($cur_blog['posted']).'';
                    $post_actions[] = '<a href="blogs_delete.php?cid='.$cur_blog['id'].'">Delete</a>';
                    $post_actions[] = '<a href="blogs_edit.php?cid='.$cur_blog['id'].'">Edit</a>';
                }                
                else if ($is_admmod)
                {
                    $post_actions[] = ''.$com_num.'';
                    $post_actions[] = 'Posted by: '.pun_htmlspecialchars($cur_blog['poster']).'';
                    $post_actions[] = ''.format_time($cur_blog['posted']).'';
                    $post_actions[] = '<a href="blogs_delete.php?cid='.$cur_blog['id'].'">Delete</a>';
                    $post_actions[] = '<a href="blogs_edit.php?cid='.$cur_blog['id'].'">Edit</a>';
                    $post_actions[] = 'IP: <a href="moderate.php?get_host='.$cur_blog['poster_ip'].'">'.$cur_blog['poster_ip'].'</a>';
                    if ($cur_blog['poster_id'] == 1)
                    {
                        $post_actions[] = '<a href="mailto:'.$cur_blog['poster_email'].'">'.$cur_blog['poster_email'].'</a>';
                    }                        
                }                    
                else
                {
                    $post_actions[] = ''.$com_num.'';
                    $post_actions[] = 'Posted by: '.pun_htmlspecialchars($cur_blog['poster']).'';
                    $post_actions[] = ''.format_time($cur_blog['posted']).'';
                }

Last edited by soonotes (2007-07-17 22:27:10)

Offline

 

#30 2007-07-18 01:15:39

doki
Member
Registered: 2007-04-30
Posts: 225

Re: PBB User Blogs 1.2

Actually I have two changes on the original files.

blogs.php

1. Add a line on blogs.php to change the template

this would not affect the links stuff

include\blog.php

2. Change the the

Code:

<a href="blog.php?cid='.$id.'&amp;c_id='.$id.'"> to <a href="blogs.php?cid='.$id.'&amp;c_id='.$id.'">

I change this because i don't upload the "upload 1" on the package i only use upload 2

line 132:

//
// Truncate string longer than max length
//

Code:

function truncate($str, $id) {
    global $pun_config;
$len = $pun_config['b_blog_trun_length'];
$splitter = '<!--MORE-->';
$append = '&nbsp;...&nbsp;<span class="barlink"><i><a href="blog.php?cid='.$id.'&amp;c_id='.$id.'">Full&nbsp;Blog';
    if(strlen($str) <= $len){
        return $str;
    }
    if($len > 0 && !strstr($str,$splitter)){
        preg_match('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){'.$len.',}\b#U', $str,$matches);
        $str = $matches[0];
        # remove trailing opener tags and close all other open tags:
        $str = close_tags(preg_replace('#\s*<[^>]+>?\s*$#','',$str).$append);
    } else {
        $arr = explode($splitter,$str,2);
        $str = $arr[0];
    }
    return $str;
}

Last edited by doki (2007-07-18 01:30:09)

Offline

 

#31 2007-07-18 01:24:19

soonotes
Member
Registered: 2006-09-21
Posts: 112

Re: PBB User Blogs 1.2

Can you email your blogs.php to me at tinytim at soonotes dot com or post it on here.

As for the error

Warning: preg_match() [function.preg-match]: Compilation failed: regular expression too large at offset 48 in /home/xxxx/public_html/include/blog.php on line 145

there will be a limit depending on your server configuration. The max for mine is about 650 characters.

Offline

 

#32 2007-07-18 01:26:58

doki
Member
Registered: 2007-04-30
Posts: 225

Re: PBB User Blogs 1.2

here's my blogs.php

Code:

<?php
/***********************************************************************
  Author: tinytim at soonotes dot com
  Date: 2007-04-12
  Description: Modification to let users create blogs within PunBB
************************************************************************

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

  This file is part of PunBB.

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

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

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  MA  02111-1307  USA
************************************************************************/
define('PUN_ROOT', './');
define('PUN_BLOGS_MOD', 1);
require PUN_ROOT.'include/common.php';
if ($pun_user['g_read_board'] == '0')
    message($lang_common['No view']);

$bid = isset($_GET['bid']) ? intval($_GET['bid']) : 0;
$uid = isset($_GET['uid']) ? intval($_GET['uid']) : 0;
$cid = isset($_GET['cid']) ? intval($_GET['cid']) : 0;
$c_id = isset($_GET['c_id']) ? intval($_GET['c_id']) : 0;
$cat_id = isset($_GET['cat_id']) ? intval($_GET['cat_id']) : 0;
$comm = isset($_GET['comm']) ? intval($_GET['comm']) : 0;
$lat = isset($_GET['lat']) ? intval($_GET['lat']) : 0;
$pop = isset($_GET['pop']) ? intval($_GET['pop']) : 0;

//Make sure the user id matches the user and they have permission to post
if ($uid && $uid != $pun_user['id'])
    message($lang_common['No view']);

if ($bid > 0 && ( $uid < 1 && $cid < 1 && $c_id < 1 && $cat_id < 1 && $comm < 1 && $lat < 1 && $pop < 1))
$result = $db->query('SELECT poster FROM '.$db->prefix.'blogs WHERE poster_id='.$bid.'') or error('Unable to fetch blogger name', __FILE__, __LINE__, $db->error());
$title = $db->result($result);

if ($cid > 0 && ( $uid < 1 && $bid < 1 && $cat_id < 1 && $comm < 1 && $lat < 1 && $pop < 1))
$result = $db->query('SELECT heading FROM '.$db->prefix.'blogs WHERE id='.$cid.'') or error('Unable to fetch blog heading', __FILE__, __LINE__, $db->error());
$title = $db->result($result);

if ($cat_id > 0 && ( $uid < 1 && $bid < 1 && $cid < 1 && $c_id < 1 && $comm < 1 && $lat < 1 && $pop < 1))
$result = $db->query('SELECT categories FROM '.$db->prefix.'blog_categories WHERE id='.$cat_id.'') or error('Unable to fetch category info', __FILE__, __LINE__, $db->error());
$title = $db->result($result);

require PUN_ROOT.'lang/'.$pun_user['language'].'/blog.php';    

if ($lat)
$title = $lang_blog['Latest'];

if ($uid)
$title = $lang_blog['Create'];

if ($comm)
$title = $lang_blog['Most commented'];

if ($pop)
$title = $lang_blog['Most viewed'];

if ($cat_id < 1 && $c_id < 1 && $uid < 1 && $bid < 1 && $cid < 1 && $comm < 1 && $lat < 1 && $pop < 1)
$title = $lang_blog['User blogs'];

$page_title = pun_htmlspecialchars($pun_config['o_board_title'].' / UserBlogs / '.$title);
require PUN_ROOT.'header.php';
require PUN_ROOT.'include/blog.php';

//Do we show the blog note and latest blogs or do we jump to the include
if ($bid < 1 && $uid < 1 && $cid < 1 && $cat_id < 1 && $c_id < 1 && $lat < 1 && $pop < 1 && $comm < 1)
{

define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'include/parser.php';

//We only show the blog note if it is not empty and it is set to show
if ($pun_config['b_blog_note'] != '' && $pun_config['b_show_blog_note'] == 1)
{    
?>
<div class="block">
    <div class="box">
    <h2><span><?php echo pun_htmlspecialchars($pun_config['b_blog_note_heading']) ?></span></h2>
        <div class="fakeform">
            <div class="inform">
                <fieldset>
                    <div class="infldset">
                        <div class="postmsg">
<?php
if ($pun_config['b_note_allow_html'] == 0)
{
$cur_blog['hide_smilies'] = 1;
$blog_head = parse_message($pun_config['b_blog_note'], $cur_blog['hide_smilies']);
} else {
$blog_head = $pun_config['b_blog_note'];
}
?>
                            <?php echo $blog_head."\n" ?>
                    </div>
                    </div>
                </fieldset>
            </div>
        </div>
    </div>
</div>

<?php
}

$result = $db->query('SELECT b.* FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE p.read_cat IS NULL OR p.read_cat=1  ORDER BY b.id DESC LIMIT 0 , 5') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());

        if ($db->num_rows($result)) 
        {
            $count = $db->num_rows($result);
            $i = 1;
            
                
if ($pun_config['b_blog_note'] != '' && $pun_config['b_show_blog_note'] == 1)
{    
?>
<div class="block">
    <div class="box">
        <div class="fakeform">
            <div class="block">
                <span class="blogcat"><span style="font-size:1.5em;"><?php echo $lang_blog['Latest'] ?></span></span>
                <div class="clearer"></div>
            </div>
<?php
}
else
{
?>
<div class="block">
    <div class="box">
    <h2><span><?php echo $lang_blog['Latest'] ?></span></h2>
        <div class="fakeform">
<?php
}
?>
            <div class="inform">
                <fieldset>
                    <div class="infldset">
                        <div class="postmsg">
<?php

                while ($cur_blog = $db->fetch_assoc($result))
                {
                $poster_id = '';
                $id = $cur_blog['id'];
                $bid = $cur_blog['poster_id'];
                $posted ='';
                $num_views = '';
                $num_comments = '';
                $poster = '';
                $post_actions = array();
                $post_actions[] = 'Posted by: '.pun_htmlspecialchars($cur_blog['poster']).'';
                $post_actions[] = ''.format_time($cur_blog['posted']).'';
                $post_actions[] = 'Views: '.$cur_blog['num_views'].'';
                $post_actions[] = '<span class="barlink"><a href="blogs.php?cid='.$cur_blog['id'].'">Comments</a>: '.$cur_blog['num_comments'].'</span>';

                //First we parse the message
                $pre = parse_message($cur_blog['blog'], $cur_blog['hide_smilies']);

                // Now we trim it
                $str = truncate ($pre, $id);

?>

                        <div class="postmsg">
                            <p><strong><?php echo pun_htmlspecialchars($cur_blog['heading']) ?></strong></p>
                            <?php echo $str."\n" ?>
                            <br /><?php echo (count($post_actions)) ? ''.implode($lang_blog['Link separator'].'', $post_actions).''."\n" : ''."\n" ?>
                        </div>
                            <?php //Is this the last comment or do we display separator? ?>
                            <?php if ($i < $count) echo '<div class="hr">&nbsp;</div><br />'; ?>
<?php
++$i;
}
?>
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
    </div>
    <div class="clearer"></div>
</div>

<?php
}
unset ($bid);
?>

    
<?php
}
if ($uid || $cid)
{
if ($pun_user['g_read_board'] == '0')
    message($lang_common['No view']);

if (($bid > 0  || $cat_id > 0  || $pop > 0  || $lat > 0  || $comm >0  || $blogrs >0)
|| ($uid > 0 && $cid > 0))
    message($lang_common['Bad request']);

    // Did someone just hit "Submit" or "Preview"?
    if (isset($_POST['form_sent']))
    {
        // Make sure form_user is correct
        if (($pun_user['is_guest'] && $_POST['form_user'] != 'Guest') || (!$pun_user['is_guest'] && $_POST['form_user'] != $pun_user['username']))
            message($lang_common['Bad request']);

        // Flood protection
        if (!$pun_user['is_guest'] && !isset($_POST['preview']) && $pun_user['last_post'] != '' && (time() - $pun_user['last_post']) < $pun_user['g_post_flood'])
            $errors[] = $lang_post['Flood start'].' '.$pun_user['g_post_flood'].' '.$lang_post['flood end'];

        // If it's a new topic
        if ($uid)
        {
            if (isset($_POST['category']))
            {
                $category = pun_trim($_POST['category']);
                $cat_info = explode(",", $category);
                $category = $cat_info[0];
                $cat_id = $cat_info[1];
            }        
            if  ($category == $lang_blog['Choose category'])
                $errors[] = $lang_blog['No category'];

            $subject = pun_trim($_POST['req_subject']);

            if ($subject == '')
                $errors[] = $lang_blog['No subject'];
            else if (pun_strlen($subject) > 70)
                $errors[] = $lang_blog['Too long subject'];
            else if ($pun_config['p_subject_all_caps'] == '0' && strtoupper($subject) == $subject && $pun_user['g_id'] > PUN_MOD)
                $subject = ucwords(strtolower($subject));
        }

        if ($cid) //lets make sure comments are allowed        
        {
            if (!$pun_user['is_guest'])
            $result = $db->query('SELECT b.allow_comments FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.id =('.$cid.') AND (p.reply_cat IS NULL OR p.reply_cat=1) AND b.allow_comments=1 ') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
            else
            $result = $db->query('SELECT b.allow_comments FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.id =('.$cid.') AND p.reply_cat=1 AND b.allow_comments=1 ') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
            if (!$db->num_rows($result))
                $errors[] = $lang_blog['No Comment error'];
        }
        
        // If the user is logged in we get the username and e-mail from $pun_user
        if (!$pun_user['is_guest'])
        {
            $username = $pun_user['username'];
            $email = $pun_user['email'];
        }

        // Otherwise it should be in $_POST
        else
        {
            $username = trim($_POST['req_username']);
            $email = strtolower(trim(($pun_config['p_force_guest_email'] == '1') ? $_POST['req_email'] : $_POST['email']));

            // Load the register.php/profile.php language files
            require PUN_ROOT.'lang/'.$pun_user['language'].'/prof_reg.php';
            require PUN_ROOT.'lang/'.$pun_user['language'].'/register.php';

            // It's a guest, so we have to validate the username
            if (strlen($username) < 2)
                $errors[] = $lang_prof_reg['Username too short'];
            else if (!strcasecmp($username, 'Guest') || !strcasecmp($username, $lang_common['Guest']))
                $errors[] = $lang_prof_reg['Username guest'];
            else if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $username))
                $errors[] = $lang_prof_reg['Username IP'];

            if ((strpos($username, '[') !== false || strpos($username, ']') !== false) && strpos($username, '\'') !== false && strpos($username, '"') !== false)
                $errors[] = $lang_prof_reg['Username reserved chars'];
            if (preg_match('#\[b\]|\[/b\]|\[u\]|\[/u\]|\[i\]|\[/i\]|\[color|\[/color\]|\[quote\]|\[quote=|\[/quote\]|\[code\]|\[/code\]|\[img\]|\[/img\]|\[url|\[/url\]|\[email|\[/email\]#i', $username))
                $errors[] = $lang_prof_reg['Username BBCode'];

            // Check username for any censored words
            $temp = censor_words($username);
            if ($temp != $username)
                $errors[] = $lang_register['Username censor'];

            // Check that the username (or a too similar username) is not already registered
            $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE username=\''.$db->escape($username).'\' OR username=\''.$db->escape(preg_replace('/[^\w]/', '', $username)).'\'') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
            if ($db->num_rows($result))
            {
                $busy = $db->result($result);
                $errors[] = $lang_register['Username dupe 1'].' '.pun_htmlspecialchars($busy).'. '.$lang_register['Username dupe 2'];
            }

            if ($pun_config['p_force_guest_email'] == '1' || $email != '')
            {
                require PUN_ROOT.'include/email.php';
                if (!is_valid_email($email))
                    $errors[] = $lang_common['Invalid e-mail'];
            }
        }

        // Clean up message from POST
        $message = pun_linebreaks(pun_trim($_POST['req_message']));

        if ($message == '')
            $errors[] = $lang_blog['No message'];
        else if (strlen($message) > 65535)
            $errors[] = $lang_blog['Too long message'];
        else if ($pun_config['p_message_all_caps'] == '0' && strtoupper($message) == $message && $pun_user['g_id'] > PUN_MOD)
            $message = ucwords(strtolower($message));

        // Validate BBCode syntax
        if ($pun_config['p_message_bbcode'] == '1' && strpos($message, '[') !== false && strpos($message, ']') !== false)
        {
        require_once PUN_ROOT.'include/parser.php';
            $message = preparse_bbcode($message, $errors);
        }

        $now = time();

        // Did everything go according to plan?
        if (empty($errors) && !isset($_POST['preview']))
        {
            // If it's a comment
            if ($cid)
            {
                if (!$pun_user['is_guest'])
                {
                    // Insert the new post
                    $db->query('INSERT INTO '.$db->prefix.'blog_comments (poster, poster_ip, poster_id, posted, blog, blog_id) VALUES(\''.$db->escape($username).'\', \''.get_remote_address().'\', '.$pun_user['id'].', '.$now.',  \''.$db->escape($message).'\', '.$cid.')') or error('Unable to create comment', __FILE__, __LINE__, $db->error());
                }
                else
                {
                    // It's a guest. Insert the new post
                    $email_sql = ($pun_config['p_force_guest_email'] == '1' || $email != '') ? '\''.$email.'\'' : 'NULL';
                    $db->query('INSERT INTO '.$db->prefix.'blog_comments (poster, poster_ip, poster_email, poster_id, posted, blog, blog_id) VALUES(\''.$db->escape($username).'\', \''.get_remote_address().'\', '.$email_sql.', '.$pun_user['id'].', '.$now.',  \''.$db->escape($message).'\', '.$cid.')') or error('Unable to create comment', __FILE__, __LINE__, $db->error());
                }

                $db->query('UPDATE '.$db->prefix.'blogs SET num_comments=num_comments+1 WHERE id='.$cid) or error('Unable to update count', __FILE__, __LINE__, $db->error());
                $db->query('UPDATE '.$db->prefix.'users SET num_blog_comments=num_blog_comments+1 WHERE id='.$pun_user['id']) or error('Unable to update count', __FILE__, __LINE__, $db->error());
            }

            // If it's a new topic
            else if ($uid)
            {
                if (!$pun_user['is_guest'])
                {
                    $allow_comments = pun_trim($_POST['allow_comments']);    
                    $db->query('INSERT INTO '.$db->prefix.'blogs (poster, poster_ip, poster_id, heading, posted, blog, allow_comments, category, cat_id) VALUES(\''.$db->escape($username).'\', \''.get_remote_address().'\', '.$pun_user['id'].', \''.$db->escape($subject).'\', '.$now.', \''.$db->escape($message).'\', \''.$db->escape($allow_comments).'\', \''.$db->escape($category).'\', \''.$db->escape($cat_id).'\')') or error('Unable to create blog', __FILE__, __LINE__, $db->error());
                    $db->query('UPDATE '.$db->prefix.'users SET num_blogs=num_blogs+1 WHERE id='.$pun_user['id']) or error('Unable to update count', __FILE__, __LINE__, $db->error());
                    $db->query('UPDATE '.$db->prefix.'blog_categories SET num_blogs=num_blogs+1 WHERE id='.$cat_id) or error('Unable to update count', __FILE__, __LINE__, $db->error());
                }
                else
                {
                    // It's a guest. Insert the new post
                    $allow_comments = pun_trim($_POST['allow_comments']);    
                    $email_sql = ($pun_config['p_force_guest_email'] == '1' || $email != '') ? '\''.$email.'\'' : 'NULL';
                    $db->query('INSERT INTO '.$db->prefix.'blogs (poster, poster_ip, poster_email, poster_id, heading, posted, blog, allow_comments, category, cat_id) VALUES(\''.$db->escape($username).'\', \''.get_remote_address().'\', '.$email_sql.', '.$pun_user['id'].', \''.$db->escape($subject).'\', '.$now.', \''.$db->escape($message).'\', \''.$db->escape($allow_comments).'\', \''.$db->escape($category).'\', \''.$db->escape($cat_id).'\')') or error('Unable to create blog', __FILE__, __LINE__, $db->error());
                    $db->query('UPDATE '.$db->prefix.'users SET num_blogs=num_blogs+1 WHERE id='.$pun_user['id']) or error('Unable to update count', __FILE__, __LINE__, $db->error());
                    $db->query('UPDATE '.$db->prefix.'blog_categories SET num_blogs=num_blogs+1 WHERE id='.$cat_id) or error('Unable to update count', __FILE__, __LINE__, $db->error());
                }

            }            
            echo '</div></div>';
            
            if($uid)
                redirect('blogs.php?bid='.$uid.'', $lang_blog['Blog redirect']);
            else
                redirect('blogs.php?cid='.$cid.'&amp;c_id='.$cid.'', $lang_blog['Comment redirect']);
        }
    }


/***********************************************************************
Start some output of stuff
************************************************************************/
        
    if (!empty($errors))
    {
?>
<div id="posterror" class="block">
    <div class="box">
    <h2><span><?php echo $lang_blog['Post errors'] ?></span></h2>
        <div class="inbox">
            <p><?php echo $lang_blog['Post errors info'] ?></p>
            <ul>
<?php
            while (list(, $cur_error) = each($errors))
            echo "\t\t\t\t".'<li><strong>'.$cur_error.'</strong></li>'."\n";
?>
            </ul>
        </div>
    </div>
</div>

<?php

    }
    else if (isset($_POST['preview']))
    {
        require_once PUN_ROOT.'include/parser.php';
        $preview_message = parse_message($message, $hide_smilies);
        $category = pun_trim($_POST['category']);
?>
<div id="postpreview" class="block">
    <h2><span><?php echo $lang_blog['Post preview'] ?></span></h2>
    <div class="box">
        <div class="inbox">
            <div class="postright">
                <div class="postmsg">
                    <?php echo $preview_message."\n" ?>
                </div>
            </div>
        </div>
    </div>
</div>

<?php

    }        
        
    // we show the form above the above the blog if this is a preview of a comment        
    if ((isset($_POST['preview']) || !empty($errors)) && ($cid))        
    {        
        $action = $lang_blog['Post new comment'];
        $form = '<form id="reply" method="post" action="blogs.php?action=post&amp;cid='.$cid.'">';

$cur_index = 1;        
?>
<div class="blockform">
    <div class="box">
        <?php echo $form."\n" ?>
            <div class="inform">
                <fieldset>
                    <legend><?php echo $lang_blog['Write comment legend'] ?></legend>
                    <div class="infldset txtarea">
                        <input type="hidden" name="form_sent" value="1" />
                        <input type="hidden" name="form_user" value="<?php echo (!$pun_user['is_guest']) ? pun_htmlspecialchars($pun_user['username']) : 'Guest'; ?>" />
<?php

        if ($pun_user['is_guest'])
        {
            $email_label = ($pun_config['p_force_guest_email'] == '1') ? '<strong>'.$lang_common['E-mail'].'</strong>' : $lang_common['E-mail'];
            $email_form_name = ($pun_config['p_force_guest_email'] == '1') ? 'req_email' : 'email';
?>
                        <label class="conl"><strong><?php echo $lang_blog['Guest name'] ?></strong><br /><input type="text" name="req_username" value="<?php if (isset($_POST['req_username'])) echo pun_htmlspecialchars($username); ?>" size="25" maxlength="25" tabindex="<?php echo $cur_index++ ?>" /><br /></label>
                        <label class="conl"><?php echo $email_label ?><br /><input type="text" name="<?php echo $email_form_name ?>" value="<?php if (isset($_POST[$email_form_name])) echo pun_htmlspecialchars($email); ?>" size="50" maxlength="50" tabindex="<?php echo $cur_index++ ?>" /><br /></label>
                        <div class="clearer"></div>
<?php
        }
?>
                        <label><strong><?php echo $lang_common['Message'] ?></strong><br />
                        <textarea name="req_message" rows="10" cols="35" tabindex="<?php echo $cur_index++ ?>"><?php echo isset($_POST['req_message']) ? pun_htmlspecialchars($message) : (isset($quote) ? $quote : ''); ?></textarea><br /></label>
                            <ul class="bblinks">
                                <li><a href="help.php#bbcode" onclick="window.open(this.href); return false;"><?php echo $lang_common['BBCode'] ?></a>: <?php echo ($pun_config['p_message_bbcode'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li>
                                <li><a href="help.php#img" onclick="window.open(this.href); return false;"><?php echo $lang_common['img tag'] ?></a>: <?php echo ($pun_config['p_message_img_tag'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li>
                                <li><a href="help.php#smilies" onclick="window.open(this.href); return false;"><?php echo $lang_common['Smilies'] ?></a>: <?php echo ($pun_config['o_smilies'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li>
                            </ul>
                    </div>
                </fieldset>
            </div>
            <p><input type="submit" name="submit" value="<?php echo $lang_common['Submit'] ?>" tabindex="<?php echo $cur_index++ ?>" accesskey="s" /><input type="submit" name="preview" value="<?php echo $lang_blog['Preview'] ?>" tabindex="<?php echo $cur_index++ ?>" accesskey="p" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
        </form>
    </div>
</div>        
        
<?php        
    }        
        
    if ($cid) //it's a comment form, first we retrieve the blog and comments
    {
        
        //retrieve the blog
        require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
        define('PUN_ALLOW_INDEX', 1);
        require_once PUN_ROOT.'include/parser.php';
        $result = $db->query('SELECT b.*, m.moderators FROM '.$db->prefix.'blogs AS b  LEFT JOIN '.$db->prefix.'blog_categories AS m ON m.id=b.cat_id LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.id ='.$cid.' AND (p.read_cat IS NULL OR p.read_cat=1)') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
        if (!$db->num_rows($result))
            message($lang_common['Bad request']);

        $blog = $db->fetch_assoc($result);
        $allow_cmt = $blog['allow_comments'];
        $link1 = $blog['poster_id'];
        $link2 = pun_htmlspecialchars($blog['poster']);
        $link3 = $blog['heading'];

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

        $post_actions = array();

        if (($cur_blog['poster_id'] == $pun_user['id']) && (!$is_admmod) && (!$pun_user['is_guest']))
        {
            $pt_actions[] = '<a href="blogs_delete.php?bid='.$blog['id'].'">'.$lang_topic['Delete'].'</a>';
            $pt_actions[] = '<a href="blogs_edit.php?bid='.$blog['id'].'">'.$lang_topic['Edit'].'</a>';
        }
        if ($is_admmod)
        {
            $pt_actions[] = '<a href="blogs_delete.php?bid='.$blog['id'].'">'.$lang_topic['Delete'].'</a>';
            $pt_actions[] = '<a href="blogs_edit.php?bid='.$blog['id'].'">'.$lang_topic['Edit'].'</a>';
            $pt_actions[] = 'IP: <a href="moderate.php?get_host='.$blog['poster_ip'].'">'.$blog['poster_ip'].'</a>';

            if ($blog['poster_id'] == 1)
            {
                $pt_actions[] = '<a href="mailto:'.$blog['poster_email'].'">'.$blog['poster_email'].'</a>';
            }                        
        }


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

        //update numbeer of views for the current blog
        $db->query('UPDATE '.$db->prefix.'blogs SET num_views=num_views+1 WHERE id='.$cid) or error('Unable to update blog views', __FILE__, __LINE__, $db->error());
        
        $result = $db->query('SELECT id FROM '.$db->prefix.'blog_comments WHERE blog_id='.$c_id.'') or error('Unable to feetch blog info', __FILE__, __LINE__, $db->error());
        $num_comments = $db->num_rows($result);

        // Determine the topic offset (based on $_GET['p'])
        $num_pages = ceil($num_comments / $pun_user['disp_comments']);

        $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
        $start_from = $pun_user['disp_comments'] * ($p - 1);
 
        // Generate paging links
        $paging_links = $lang_common['Pages'].': '.paginate($num_pages, $p, 'blogs.php?cid='.$cid.'&amp;c_id='.$c_id);

?>
<div class="linkst">
    <div class="inbox">
        <p class="pagelink conl"><?php echo $paging_links ?></p>
        <ul><li><a href="blogs.php"><?php echo $lang_blog['Blogs'] ?></a>&nbsp;</li><li>&raquo;&nbsp;<a href="blogs.php?bid=<?php echo $link1 ?>"><?php echo $link2 ?></a>&nbsp;</li><li>&raquo;&nbsp;<?php echo $link3 ?></li></ul>
        <div class="clearer"></div>
    </div>
</div>

<div class="block">
    <div class="box">
        <div class="fakeform">
            <div class="block">
                <span class="blogcat"><span style="font-size:1.5em;"><?php echo $lang_blog['User blogs'] ?></span></span>
                <div class="clearer"></div>
            </div>
            <div class="inform">
                <fieldset>
                    <div class="infldset">
                        <div class="postmsg">
                            <p><?php echo format_time($blog['posted']) ?></p>
                            <p>Posted by <?php echo pun_htmlspecialchars($blog['poster']) ?></p>
                            <p>Category: <?php echo ($blog['category']) ?></p>
                            <p><span style="font-size:2em;"><?php echo pun_htmlspecialchars($blog['heading']) ?></span></p>
                            <?php echo $blog['message']."\n" ?>
                            <?php if ($blog['edited'] != '') echo "\t\t\t\t\t".'<p class="postedit"><em>'.$lang_topic['Last edit'].' '.pun_htmlspecialchars($blog['edited_by']).' ('.format_time($blog['edited']).')</em></p>'."\n"; ?>
                            <br /><?php echo (count($pt_actions)) ? ''.implode($lang_blog['Link separator'].'', $pt_actions).''."\n" : ''."\n" ?>
                        </div>
                    </div>
                </fieldset>
            </div>




<?php
        $result = $db->query('SELECT b.*, c.*, m.moderators FROM '.$db->prefix.'blog_comments AS c INNER JOIN '.$db->prefix.'blogs AS b ON b.id=c.blog_id LEFT JOIN '.$db->prefix.'blog_categories AS m ON m.id=b.cat_id LEFT JOIN '.$db->prefix.'blog_perms AS p ON p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].' WHERE c.blog_id='.$cid.' AND (p.read_cat IS NULL OR p.read_cat=1) ORDER BY c.posted LIMIT '.$start_from.', '.$pun_user['disp_comments']) or error('Unable to fetch comments', __FILE__, __LINE__, $db->error());
        if ($db->num_rows($result)) 
        {
            $count = $db->num_rows($result);
            $i = 1;
?>
            <div class="block">
                <span class="blogcat"><span style="font-size:1.5em;"><?php echo $lang_blog['Comments'] ?></span></span>
                <div class="clearer"></div>
            </div>
            <div class="inform">
                <fieldset>
                    <div class="infldset">
                        <div class="postmsg">


<?php


            while ($cur_blog = $db->fetch_assoc($result))
            {
                // Sort out who the moderators are and if we are currently a moderator (or an admin)
                $mods_array = ($cur_blog['moderators'] != '') ? unserialize($cur_blog['moderators']) : array();
                $is_admmod = ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_id'] == PUN_MOD && array_key_exists($pun_user['username'], $mods_array))) ? true : false;
                $com_num = $start_from + $i;
                $post_actions = array();
        if (($cur_blog['poster_id'] == $pun_user['id']) && (!$is_admmod) && (!$pun_user['is_guest']))
                {
                    $post_actions[] = ''.$com_num.'';
                    $post_actions[] = 'Posted by: '.pun_htmlspecialchars($cur_blog['poster']).'';
                    $post_actions[] = ''.format_time($cur_blog['posted']).'';
                    $post_actions[] = '<a href="blogs_delete.php?cid='.$cur_blog['id'].'">Delete</a>';
                    $post_actions[] = '<a href="blogs_edit.php?cid='.$cur_blog['id'].'">Edit</a>';
                }                
                else if ($is_admmod)
                {
                    $post_actions[] = ''.$com_num.'';
                    $post_actions[] = 'Posted by: '.pun_htmlspecialchars($cur_blog['poster']).'';
                    $post_actions[] = ''.format_time($cur_blog['posted']).'';
                    $post_actions[] = '<a href="blogs_delete.php?cid='.$cur_blog['id'].'">Delete</a>';
                    $post_actions[] = '<a href="blogs_edit.php?cid='.$cur_blog['id'].'">Edit</a>';
                    $post_actions[] = 'IP: <a href="moderate.php?get_host='.$cur_blog['poster_ip'].'">'.$cur_blog['poster_ip'].'</a>';
                    if ($cur_blog['poster_id'] == 1)
                    {
                        $post_actions[] = '<a href="mailto:'.$cur_blog['poster_email'].'">'.$cur_blog['poster_email'].'</a>';
                    }                        
                }                    
                else
                {
                    $post_actions[] = ''.$com_num.'';
                    $post_actions[] = 'Posted by: '.pun_htmlspecialchars($cur_blog['poster']).'';
                    $post_actions[] = ''.format_time($cur_blog['posted']).'';
                }                    
                            
                // Perform the main parsing of the message (BBCode, smilies, censor words etc)
                $cur_blog['message'] = parse_message($cur_blog['blog'], $cur_blog['hide_smilies']);
?>

                            <div class="postmsg">
                                <p>re:<strong><?php echo pun_htmlspecialchars($cur_blog['heading']) ?></strong></p><br />
                                <?php echo $cur_blog['message']."\n" ?>
                                <?php if ($cur_blog['edited'] != '') echo "\t\t\t\t\t".'<p class="postedit"><em>'.$lang_topic['Last edit'].' '.pun_htmlspecialchars($cur_blog['edited_by']).' ('.format_time($cur_blog['edited']).')</em></p>'."\n"; ?>
                                <br /><?php echo (count($post_actions)) ? ''.implode($lang_blog['Link separator'].'', $post_actions).''."\n" : ''."\n" ?>
                            </div>
                            <?php //Is this the last comment or do we display separator? ?>
                            <?php if ($i < $count) echo '<div class="hr">&nbsp;</div><br />'; ?>
<?php
++$i;
            }
?>    
                        </div>            
                        <div class="clearer"></div>
                    </div>
                </fieldset>
            </div>
        </div>
    </div>
</div>    
<?php
        }
        else
        {
?>
        </div>
    </div>
</div>    
<?php
        }
?>
<div class="linksb">
    <div class="inbox">
        <p class="pagelink conl"><?php echo $paging_links ?></p>
        <ul><li><a href="blogs.php"><?php echo $lang_blog['Blogs'] ?></a>&nbsp;</li><li>&raquo;&nbsp;<a href="blogs.php?bid=<?php echo $link1 ?>"><?php echo $link2 ?></a>&nbsp;</li><li>&raquo;&nbsp;<?php echo $link3 ?></li></ul>
        <div class="clearer"></div>
    </div>
</div>
<?php    
        //do we show the post form
        if ($pun_user['is_guest'])
        $result = $db->query('SELECT b.allow_comments FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.id =('.$cid.') AND p.reply_cat=1 AND b.allow_comments=1 ') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());

         else
        $result = $db->query('SELECT b.allow_comments FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.id =('.$cid.') AND (p.reply_cat IS NULL OR p.reply_cat=1) AND b.allow_comments=1 ') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());

        if (!$db->num_rows($result))
        {
            $post = 'no';
        }
    }
    //we show the form here if it is not a preview for a comment
    if (($uid) || (($cid)&& (!$post == no) && (!isset($_POST['preview']) && empty($errors))))
    {
        if ($uid) 
        {
            $action = $lang_blog['Post new blog'];
            $form = '<form id="post" method="post" action="blogs.php?action=post&amp;uid='.$uid.'">';
            $message_legend = $lang_blog['Write blog legend'];
        } 
        else if ($cid) //If a cid was specified it is a new comment
        {
            $action = $lang_blog['Post new comment'];
            $form = '<form id="reply" method="post" action="blogs.php?action=post&amp;cid='.$cid.'">';
            $message_legend = $lang_blog['Write comment legend'];
        }
        $cur_index = 1;
?>
<div class="blockform">
    <div class="box">
<?php
        if ($uid)
        {    
?>    
    <h2><span><?php echo $lang_blog['User blogs'] ?></span></h2>
<?php
        }
?>    
        <?php echo $form."\n" ?>
            <div class="inform">
                <fieldset>
                    <legend><?php echo $message_legend ?></legend>
                    <div class="infldset txtarea">
                        <input type="hidden" name="form_sent" value="1" />
                        <input type="hidden" name="form_user" value="<?php echo (!$pun_user['is_guest']) ? pun_htmlspecialchars($pun_user['username']) : 'Guest'; ?>" />
<?php

        if ($pun_user['is_guest'])
        {
            $email_label = ($pun_config['p_force_guest_email'] == '1') ? '<strong>'.$lang_common['E-mail'].'</strong>' : $lang_common['E-mail'];
            $email_form_name = ($pun_config['p_force_guest_email'] == '1') ? 'req_email' : 'email';
?>
                        <label class="conl"><strong><?php echo $lang_blog['Guest name'] ?></strong><br /><input type="text" name="req_username" value="<?php if (isset($_POST['req_username'])) echo pun_htmlspecialchars($username); ?>" size="25" maxlength="25" tabindex="<?php echo $cur_index++ ?>" /><br /></label>
                        <label class="conl"><?php echo $email_label ?><br /><input type="text" name="<?php echo $email_form_name ?>" value="<?php if (isset($_POST[$email_form_name])) echo pun_htmlspecialchars($email); ?>" size="50" maxlength="50" tabindex="<?php echo $cur_index++ ?>" /><br /></label>
                        <div class="clearer"></div>
<?php
        }
        if ($uid):  // Generate list of categories user is allowed to post in
            if (isset($_POST['category']))
            {
                $cat_info = explode(",", $category);
                $category = $cat_info[0];
                $cat_id = $cat_info[1];
            }
            else
            {
                $category = ($lang_blog['Choose category']);
                $cat_id = '';
            }                
            
?>
                        <label><strong><?php echo $lang_blog['Category'] ?></strong>
                            <br />
                            <select name="category" tabindex="<?php echo $cur_index++ ?>">
                                                                                   
<?php
            echo "\t\t\t\t\t\t\t".'<option value="'.$category.', '.$cat_id.'">'.pun_htmlspecialchars($category).'</option>'."\n";

if ($pun_user['is_guest'])
{
            $result = $db->query('SELECT c.id, c.categories FROM '.$db->prefix.'blog_categories AS c LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=c.id AND p.group_id='.$pun_user['g_id'].') WHERE p.post_cat=1') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
} else {
            $result = $db->query('SELECT c.id, c.categories FROM '.$db->prefix.'blog_categories AS c LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=c.id AND p.group_id='.$pun_user['g_id'].') WHERE p.post_cat IS NULL OR p.post_cat=1') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
}
            $num_cats = $db->num_rows($result);
            for ($i = 0; $i < $num_cats; ++$i)
            $cat_list[] = $db->fetch_row($result);
            while (list(, list($cat_id, $category, ,)) = @each($cat_list))
            echo "\t\t\t\t\t\t\t".'<option value="'.$category.', '.$cat_id.'">'.pun_htmlspecialchars($category).'</option>'."\n";
?>
                            </select><br />
                        </label>
                        <label><strong><?php echo $lang_blog['Heading'] ?></strong><br /><input class="longinput" type="text" name="req_subject" value="<?php if (isset($_POST['req_subject'])) echo pun_htmlspecialchars($subject); ?>" size="80" maxlength="70" tabindex="<?php echo $cur_index++ ?>" /><br /></label>
        <?php endif; ?>
                        <label><strong><?php echo $lang_common['Message'] ?></strong><br />
                        <textarea name="req_message" rows="10" cols="35" tabindex="<?php echo $cur_index++ ?>"><?php echo isset($_POST['req_message']) ? pun_htmlspecialchars($message) : (isset($quote) ? $quote : ''); ?></textarea><br /></label>
                            <ul class="bblinks">
                                <li><a href="help.php#bbcode" onclick="window.open(this.href); return false;"><?php echo $lang_common['BBCode'] ?></a>: <?php echo ($pun_config['p_message_bbcode'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li>
                                <li><a href="help.php#img" onclick="window.open(this.href); return false;"><?php echo $lang_common['img tag'] ?></a>: <?php echo ($pun_config['p_message_img_tag'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li>
                                <li><a href="help.php#smilies" onclick="window.open(this.href); return false;"><?php echo $lang_common['Smilies'] ?></a>: <?php echo ($pun_config['o_smilies'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li>
                            </ul>
        <?php if ($uid): ?>
                        <label><input type="radio" name="allow_comments" value="0" tabindex="<?php echo $cur_index++ ?>" /><?php echo $lang_blog['No Comments'] ?><br /></label>
                        <label><input type="radio" name="allow_comments" value="1" checked="checked" tabindex="<?php echo $cur_index++ ?>" /><?php echo $lang_blog['User Comments'] ?><br /></label>
                        <label><?php echo $lang_blog['Note Comments'] ?><br /></label>
        <?php endif; ?>    
                    </div>
                </fieldset>
            </div>
            <p><input type="submit" name="submit" value="<?php echo $lang_common['Submit'] ?>" tabindex="<?php echo $cur_index++ ?>" accesskey="s" /><input type="submit" name="preview" value="<?php echo $lang_blog['Preview'] ?>" tabindex="<?php echo $cur_index++ ?>" accesskey="p" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
        </form>
    </div>
</div>

<?php        
    }
}

if ($bid)
{

/***********************************************************************
       this output's a preview of all of the selected users blogs
************************************************************************/

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

if ($uid > 0  || $cid > 0  || $cat_id > 0  || $pop > 0  || $lat > 0  || $comm >0  || $blogrs >0)
    message($lang_common['Bad request']);


    require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
    define('PUN_ALLOW_INDEX', 1);
    require_once PUN_ROOT.'include/parser.php';
            require PUN_ROOT.'lang/'.$pun_user['language'].'/profile.php';
    $result = $db->query('SELECT id, username, num_blogs, blog_about, blog_hobbies, blog_other FROM '.$db->prefix.'users WHERE id ='.$bid.'') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
    $bgr = $db->fetch_assoc($result);
    $ac=$bgr['num_blogs'];
    $nm=pun_htmlspecialchars($bgr['username']);
    $blog_about=$bgr['blog_about'];
    $blog_hobbies=$bgr['blog_hobbies'];
    $blog_other=$bgr['blog_other'];
    $prf='<span class="barlink"><a href="profile.php?id='.$bgr['id'].'">View full profile</a></span>';


if ($blog_about != '')
{
    require_once PUN_ROOT.'include/parser.php';
    $parsed_blog_about = parse_signature($blog_about);
}
if ($blog_hobbies != '')
{
    require_once PUN_ROOT.'include/parser.php';
    $parsed_blog_hobbies = parse_signature($blog_hobbies);
}
if ($blog_other != '')
{
    require_once PUN_ROOT.'include/parser.php';
    $parsed_blog_other = parse_signature($blog_other);
}



    $result = $db->query('SELECT COUNT(b.id) FROM '.$db->prefix.'blogs AS b INNER JOIN '.$db->prefix.'users AS u ON b.poster_id=u.id LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.poster_id ='.$bid.' && (p.read_cat IS NULL OR p.read_cat=1)') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
    $num_blogs = $db->result($result);

    // Determine the topic offset (based on $_GET['p'])
    $num_pages = ceil($num_blogs / $pun_user['disp_blogs']);

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

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

    $result = $db->query('SELECT b.*, m.moderators FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_categories AS m ON m.id=b.cat_id LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.poster_id =('.$bid.') && (p.read_cat IS NULL OR p.read_cat=1) ORDER BY b.id DESC LIMIT '.$start_from.', '.$pun_user['disp_blogs'].'') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
    //$result = $db->query('SELECT b.*, u.blog_about, u.blog_hobbies, u.blog_other FROM '.$db->prefix.'blogs AS b INNER JOIN '.db->prefix.'users as u ON u.id=b.poster_id LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.poster_id =('.$bid.') && (p.read_cat IS NULL OR p.read_cat=1)  ORDER BY b.id DESC LIMIT '.$start_from.', '.$pun_user['disp_blogs'].'') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
    if (!$db->num_rows($result))
        message($lang_blog['No Blog']);

    $count = $db->num_rows($result);
    $b_num = 1;
    $i = 1;

    while ($cur_blog = $db->fetch_assoc($result))
    {

        $id = '';
        $num_comments = '';
        $blog_num = $start_from + $i;

        $post_actions = array();
        $post_actions[] = ''.$blog_num.'';
        $post_actions[] = 'Posted : '.format_time($cur_blog['posted']).' in '.pun_htmlspecialchars($cur_blog['category']).'';
        if ($cur_blog['poster_id'] == 1)
            $post_actions[] = 'By: '.pun_htmlspecialchars($cur_blog['poster']).'';
        $post_actions[] = 'Views: '.$cur_blog['num_views'].'';
        $post_actions[] = '<span class="barlink"><a href="blogs.php?cid='.$cur_blog['id'].'&amp;c_id='.$cur_blog['id'].'">Comments</a>:&nbsp;'.$cur_blog['num_comments'].'</span>';

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

        // Trim the blog
        $str = truncate ($pre, $id);

        if ($i == $b_num) //We only show the navigation if it's the first blog
        {



?>
<div class="linkst">
    <div class="inbox">
<?php
        if ($pun_user['id'] == $cur_blog['poster_id'])
        {
        echo '<p class="postlink conr"><a href="blogs.php?uid='.$bid.'">'.$lang_blog['Post new blog'].'</a></p>';
        }
?>
        <p class="pagelink conl"><?php echo $paging_links ?></p>
        <ul><li><a href="blogs.php"><?php echo $lang_blog['Blogs'] ?></a>&nbsp;</li><li>&raquo;&nbsp;<?php echo pun_htmlspecialchars($cur_blog['poster']) ?></li></ul>
        <div class="clearer"></div>
    </div>
</div>
<div class="block">
    <div class="box">
        <div class="fakeform">
            <div class="inform">
                <fieldset>
<?php
if ($blog_num == 1&& $cur_blog['poster_id'] != 1) // We only show the blogger's profile if it is the first page of blogs for the user
{
?>
                    <legend><?php echo $cur_blog['poster'] ?>'s Profile</legend>
                    <div class="infldset">
                        <div class="postmsg">
                            <p>Number of Blogs:&nbsp;<strong><?php echo $ac ?></strong></p>
                            <p><br /><strong><?php echo $lang_profile['Blog about'] ?>:</strong></p>
                            <p><?php echo isset($parsed_blog_about) ? $parsed_blog_about : $lang_profile['Unknown']; ?></p>
                            <p><br /><strong><?php echo $lang_profile['Blog hobbies'] ?>: </strong></p>
                            <p><?php echo isset($parsed_blog_hobbies) ? $parsed_blog_hobbies : $lang_profile['Unknown']; ?></p>
                            <p><br /><strong><?php echo $lang_profile['Blog other'] ?>: </strong></p>
                            <p><?php echo isset($parsed_blog_other) ? $parsed_blog_other : $lang_profile['Unknown']; ?></p>
                            <p><br /><?php echo $prf ?></p>
                        </div>
                    </div>
                </fieldset>
            </div>
            <div class="block">
                <span class="blogcat"><span style="font-size:1.5em;">Blogs for <?php echo pun_htmlspecialchars($cur_blog['poster']) ?>&nbsp;&nbsp;&nbsp;<a href="blogs_rss.php?bid=<?php echo $cur_blog['poster_id'] ?>" ><img src="img/feed.gif" alt="RSS Feed/<?php echo $cur_blog['poster'] ?>" /></a></span></span>
                <div class="clearer"></div>
            </div>
            <div class="inform">
                <fieldset>
                    <div class="infldset">
<?php
} else {
?>
                    <div class="infldset">
<?php        
}        
        }
?>
                        <div class="postmsg">
                            
                            <p><strong><?php echo pun_htmlspecialchars($cur_blog['heading']) ?></strong></p>
                            <?php echo $str."\n" ?>
                            <?php if ($cur_blog['edited'] != '') echo "\t\t\t\t\t".'<p class="postedit"><em>'.$lang_topic['Last edit'].' '.pun_htmlspecialchars($cur_blog['edited_by']).' ('.format_time($cur_blog['edited']).')</em></p>'."\n"; ?>
                            <br /><?php echo (count($post_actions)) ? ''.implode($lang_blog['Link separator'].'', $post_actions).''."\n" : ''."\n" ?>
                        </div>
                            <?php if ($i < $count) echo '<div class="hr">&nbsp;</div><br />'; ?>
<?php
++$i;
    }
            
?>    
                    </div>
                </fieldset>
            </div>
        </div>
    </div>    
</div>
<div class="linkst">
    <div class="inbox">
        <p class="pagelink conl"><?php echo $paging_links ?></p>
        <ul><li><a href="blogs.php"><?php echo $lang_blog['Blogs'] ?></a>&nbsp;</li><li>&raquo;&nbsp;<?php echo $nm ?></li></ul>
        <div class="clearer"></div>
    </div>
</div>

<?php    
}
if ($cat_id)

/***********************************************************************
       this output's a preview of all of the selected category's blogs
************************************************************************/

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

if ($uid > 0  || $cid > 0  || $bid > 0  || $pop > 0  || $lat > 0  || $comm >0)
    message($lang_common['Bad request']);

    require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
    define('PUN_ALLOW_INDEX', 1);
    require_once PUN_ROOT.'include/parser.php';
    
    $result = $db->query('SELECT COUNT(b.id) FROM '.$db->prefix.'blogs AS b INNER JOIN '.$db->prefix.'users AS u ON b.poster_id=u.id LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.cat_id ='.$cat_id.' && (p.read_cat IS NULL OR p.read_cat=1)') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
    $num_blogs = $db->result($result);

    // Determine the topic offset (based on $_GET['p'])
    $num_pages = ceil($num_blogs / $pun_user['disp_blogs']);

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

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

    $result = $db->query('SELECT b.* FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.cat_id =('.$cat_id.') && (p.read_cat IS NULL OR p.read_cat=1)  ORDER BY b.id DESC LIMIT '.$start_from.', '.$pun_user['disp_blogs'].'') or error('Unable to fetch category info', __FILE__, __LINE__, $db->error());
    if (!$db->num_rows($result))
        message($lang_blog['No Blog Cat']);    
    if ($db->num_rows($result)) 
    {
        $count = $db->num_rows($result);
        $i = 1;
        $c_num = 1;            
                
        while ($cur_blog = $db->fetch_assoc($result))
        {
            $post_actions = array();
            $post_actions[] = 'Posted by: '.pun_htmlspecialchars($cur_blog['poster']).'';
            $post_actions[] = ''.format_time($cur_blog['posted']).'';
            $post_actions[] = 'Views: '.$cur_blog['num_views'].'';
            $post_actions[] = '<span class="barlink"><a href="blogs.php?cid='.$cur_blog['id'].'&amp;c_id='.$cur_blog['id'].'">Comments</a>:&nbsp;'.$cur_blog['num_comments'].'</span>';

            $cat_name = pun_htmlspecialchars($cur_blog['category']);
            $bid = $cur_blog['poster_id'];
            $id = $cur_blog['id'];
            $pre = parse_message($cur_blog['blog'], $cur_blog['hide_smilies']);

            // Trim the blog
            $str = truncate ($pre, $id);
            if ($i == $c_num)
            {
?>
<div class="linkst">
    <div class="inbox">
        <p class="pagelink conl"><?php echo $paging_links ?></p>
        <ul><li><a href="blogs.php"><?php echo $lang_blog['Blogs'] ?></a>&nbsp;</li><li>&raquo;&nbsp;<?php echo $cat_name; ?></li></ul>
        <div class="clearer"></div>
    </div>
</div>
<div class="block">
    <div class="box">
        <div class="fakeform">
            <div class="block">
                <span class="blogcat"><span style="font-size:1.5em;"><?php echo pun_htmlspecialchars($cur_blog['category']) ?>&nbsp;&nbsp;&nbsp;<a href="blogs_rss.php?cid=<?php echo $cur_blog['cat_id'] ?>" ><img src="img/feed.gif" alt="RSS Feed/<?php echo $cur_blog['category'] ?>" /></a></span></span>
                <div class="clearer"></div>
            </div>
            <div class="inform">
                <fieldset>
                    <div class="infldset">

<?php        
        
            }
?>
                        <div class="postmsg">

                            <p><strong><?php echo pun_htmlspecialchars($cur_blog['heading']) ?></strong></p>
                            <?php echo $str."\n" ?>
                            <br /><?php echo (count($post_actions)) ? ''.implode($lang_blog['Link separator'].'', $post_actions).''."\n" : ''."\n" ?>
                        </div>
                            <?php //Is this the last comment or do we display separator? ?>
                            <?php if ($i < $count) echo '<div class="hr">&nbsp;</div><br />'; ?>
<?php
++$i;
        }
?>
                    </div>
                </fieldset>
            </div>
        </div>
    </div>
</div>    
<div class="linksb">
    <div class="inbox">
        <p class="pagelink conl"><?php echo $paging_links ?></p>
        <ul><li><a href="blogs.php"><?php echo $lang_blog['Blogs'] ?></a>&nbsp;</li><li>&raquo;&nbsp;<?php echo $cat_name; ?></li></ul>
        <div class="clearer"></div>
    </div>
</div>
    
    
<?php    
    }    
}
if ($pop || $comm || $lat)//we show all blogs ordered by num_views, num_comments, or last posted
{
    if ((($pop) && ($comm >0 || $lat >0))
    || (($comm) && ($pop >0 || $lat >0))
    || (($lat) && ($comm >0 || $pop >0)))
        message($lang_common['Bad request']);    
    
    if ($pop){
        $order = num_views;
        $nav = "blogs.php?pop=";
        $head = ''.$lang_blog['Most viewed'].'';
        $case = ''.$lang_blog['Most viewed'].'';
    }
        
    if ($comm){
        $order = num_comments;
        $nav = "blogs.php?comm=";
        $head = ''.$lang_blog['Most commented'].'';
        $case = ''.$lang_blog['Most commented'].'';
    }
    if ($lat){
        $order = posted;
        $nav = "blogs.php?lat=";
        $case = ''.$lang_blog['Latest'].'';
        $head = ''.$lang_blog['Latest'].'&nbsp;&nbsp;&nbsp;<a href="blogs_rss.php"><img src="img/feed.gif" alt="RSS Feed/Latest Blogs" /></a>';
    }
    
    require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
    define('PUN_ALLOW_INDEX', 1);
    require_once PUN_ROOT.'include/parser.php';
    
    //$result = $db->query('SELECT b.* FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.cat_id =('.$cat_id.') && (p.read_cat IS NULL OR p.read_cat=1)  ORDER BY b.id DESC LIMIT 0 , 10') or error('Unable to fetch category info', __FILE__, __LINE__, $db->error());
    $result = $db->query('SELECT COUNT(b.id) FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE (p.read_cat IS NULL OR p.read_cat=1)') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
    $num_blogs = $db->result($result);

    // Determine the topic offset (based on $_GET['p'])
    $num_pages = ceil($num_blogs / $pun_user['disp_blogs']);

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

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

    $result = $db->query('SELECT b.* FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE (p.read_cat IS NULL OR p.read_cat=1) ORDER BY b.'.$order.' DESC LIMIT '.$start_from.', '.$pun_user['disp_blogs'].'') or error('Unable to fetch category info', __FILE__, __LINE__, $db->error());
    if (!$db->num_rows($result))
        message($lang_blog['No Blog']);    
    if ($db->num_rows($result)) 
    {
        $count = $db->num_rows($result);
        $i = 1;
        //$abc = 1;            
?>
<div class="linkst">
    <div class="inbox">
        <p class="pagelink conl"><?php echo $paging_links ?></p>
        <ul><li><a href="blogs.php"><?php echo $lang_blog['Blogs'] ?></a>&nbsp;</li><li>&raquo;&nbsp;<?php echo $case; ?></li></ul>
        <div class="clearer"></div>
    </div>
</div>
<div class="block">
    <div class="box">
        <div class="fakeform">
            <div class="block">
                <span class="blogcat"><span style="font-size:1.5em;"><?php echo $head; ?></span></span>
                <div class="clearer"></div>
            </div>
            <div class="inform">
                <fieldset>
                    <div class="infldset">

<?php        
                    
        while ($cur_blog = $db->fetch_assoc($result))
        {
            $post_actions = array();
            $post_actions[] = 'Posted by: '.pun_htmlspecialchars($cur_blog['poster']).'';
            $post_actions[] = ''.format_time($cur_blog['posted']).'';
            $post_actions[] = 'Views: '.$cur_blog['num_views'].'';
            $post_actions[] = '<span class="barlink"><a href="blogs.php?cid='.$cur_blog['id'].'&amp;c_id='.$cur_blog['id'].'">Comments</a>:&nbsp;'.$cur_blog['num_comments'].'</span>';

            $bid = $cur_blog['poster_id'];
            $id = $cur_blog['id'];
            $pre = parse_message($cur_blog['blog'], $cur_blog['hide_smilies']);

            // Trim the blog
            $str = truncate ($pre, $id);

?>
                        <div class="postmsg">

                            <p><strong><?php echo pun_htmlspecialchars($cur_blog['heading']) ?></strong></p>
                            <?php echo $str."\n" ?>
                            <br /><?php echo (count($post_actions)) ? ''.implode($lang_blog['Link separator'].'', $post_actions).''."\n" : ''."\n" ?>
                        </div>
                            <?php //Is this the last comment or do we display separator? ?>
                            <?php if ($i < $count) echo '<div class="hr">&nbsp;</div><br />'; ?>
<?php
++$i;
        }

?>
                    </div>
                </fieldset>
            </div>
        </div>
    </div>
</div>    
<div class="linkst">
    <div class="inbox">
        <p class="pagelink conl"><?php echo $paging_links ?></p>
        <ul><li><a href="blogs.php"><?php echo $lang_blog['Blogs'] ?></a>&nbsp;</li><li>&raquo;&nbsp;<?php echo $case ?></li></ul>
        <div class="clearer"></div>
    </div>
</div>
    
    
<?php    
    }    
}

require PUN_ROOT.'footer.php';

Offline

 

#33 2007-07-18 01:33:43

doki
Member
Registered: 2007-04-30
Posts: 225

Re: PBB User Blogs 1.2

soonotes wrote:

Can you email your blogs.php to me at tinytim at soonotes dot com or post it on here.

As for the error

Warning: preg_match() [function.preg-match]: Compilation failed: regular expression too large at offset 48 in /home/xxxx/public_html/include/blog.php on line 145

there will be a limit depending on your server configuration. The max for mine is about 650 characters.

ok. I just change it back to 500... Thanks

Offline

 

#34 2007-07-18 01:51:15

soonotes
Member
Registered: 2006-09-21
Posts: 112

Re: PBB User Blogs 1.2

Try this. I made one small change to blogs.php

edited to remove useless code smile

Last edited by soonotes (2007-07-18 02:08:08)

Offline

 

#35 2007-07-18 01:57:28

doki
Member
Registered: 2007-04-30
Posts: 225

Re: PBB User Blogs 1.2

i just upload the new blogs.php to the server...

Offline

 

#36 2007-07-18 02:06:15

soonotes
Member
Registered: 2006-09-21
Posts: 112

Re: PBB User Blogs 1.2

That didn't make a difference. I see the issue now. Upload this

Code:

<?php
/***********************************************************************
  Author: tinytim at soonotes dot com
  Date: 2007-04-12
  Description: Modification to let users create blogs within PunBB
************************************************************************

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

  This file is part of PunBB.

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

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

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  MA  02111-1307  USA
************************************************************************/
define('PUN_ROOT', './');
define('PUN_BLOGS_MOD', 1);
require PUN_ROOT.'include/common.php';
if ($pun_user['g_read_board'] == '0')
    message($lang_common['No view']);

$bid = isset($_GET['bid']) ? intval($_GET['bid']) : 0;
$uid = isset($_GET['uid']) ? intval($_GET['uid']) : 0;
$cid = isset($_GET['cid']) ? intval($_GET['cid']) : 0;
$c_id = isset($_GET['c_id']) ? intval($_GET['c_id']) : 0;
$cat_id = isset($_GET['cat_id']) ? intval($_GET['cat_id']) : 0;
$comm = isset($_GET['comm']) ? intval($_GET['comm']) : 0;
$lat = isset($_GET['lat']) ? intval($_GET['lat']) : 0;
$pop = isset($_GET['pop']) ? intval($_GET['pop']) : 0;

//Make sure the user id matches the user and they have permission to post
if ($uid && $uid != $pun_user['id'])
    message($lang_common['No view']);

if ($bid > 0 && ( $uid < 1 && $cid < 1 && $c_id < 1 && $cat_id < 1 && $comm < 1 && $lat < 1 && $pop < 1))
$result = $db->query('SELECT poster FROM '.$db->prefix.'blogs WHERE poster_id='.$bid.'') or error('Unable to fetch blogger name', __FILE__, __LINE__, $db->error());
$title = $db->result($result);

if ($cid > 0 && ( $uid < 1 && $bid < 1 && $cat_id < 1 && $comm < 1 && $lat < 1 && $pop < 1))
$result = $db->query('SELECT heading FROM '.$db->prefix.'blogs WHERE id='.$cid.'') or error('Unable to fetch blog heading', __FILE__, __LINE__, $db->error());
$title = $db->result($result);

if ($cat_id > 0 && ( $uid < 1 && $bid < 1 && $cid < 1 && $c_id < 1 && $comm < 1 && $lat < 1 && $pop < 1))
$result = $db->query('SELECT categories FROM '.$db->prefix.'blog_categories WHERE id='.$cat_id.'') or error('Unable to fetch category info', __FILE__, __LINE__, $db->error());
$title = $db->result($result);

require PUN_ROOT.'lang/'.$pun_user['language'].'/blog.php';    

if ($lat)
$title = $lang_blog['Latest'];

if ($uid)
$title = $lang_blog['Create'];

if ($comm)
$title = $lang_blog['Most commented'];

if ($pop)
$title = $lang_blog['Most viewed'];

if ($cat_id < 1 && $c_id < 1 && $uid < 1 && $bid < 1 && $cid < 1 && $comm < 1 && $lat < 1 && $pop < 1)
$title = $lang_blog['User blogs'];

$page_title = pun_htmlspecialchars($pun_config['o_board_title'].' / UserBlogs / '.$title);
require PUN_ROOT.'header.php';
require PUN_ROOT.'include/blog.php';

//Do we show the blog note and latest blogs or do we jump to the include
if ($bid < 1 && $uid < 1 && $cid < 1 && $cat_id < 1 && $c_id < 1 && $lat < 1 && $pop < 1 && $comm < 1)
{

define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'include/parser.php';

//We only show the blog note if it is not empty and it is set to show
if ($pun_config['b_blog_note'] != '' && $pun_config['b_show_blog_note'] == 1)
{    
?>
<div class="block">
    <div class="box">
    <h2><span><?php echo pun_htmlspecialchars($pun_config['b_blog_note_heading']) ?></span></h2>
        <div class="fakeform">
            <div class="inform">
                <fieldset>
                    <div class="infldset">
                        <div class="postmsg">
<?php
if ($pun_config['b_note_allow_html'] == 0)
{
$cur_blog['hide_smilies'] = 1;
$blog_head = parse_message($pun_config['b_blog_note'], $cur_blog['hide_smilies']);
} else {
$blog_head = $pun_config['b_blog_note'];
}
?>
                            <?php echo $blog_head."\n" ?>
                    </div>
                    </div>
                </fieldset>
            </div>
        </div>
    </div>
</div>

<?php
}

$result = $db->query('SELECT b.* FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE p.read_cat IS NULL OR p.read_cat=1  ORDER BY b.id DESC LIMIT 0 , 5') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());

        if ($db->num_rows($result)) 
        {
            $count = $db->num_rows($result);
            $i = 1;
            
                
if ($pun_config['b_blog_note'] != '' && $pun_config['b_show_blog_note'] == 1)
{    
?>
<div class="block">
    <div class="box">
        <div class="fakeform">
            <div class="block">
                <span class="blogcat"><span style="font-size:1.5em;"><?php echo $lang_blog['Latest'] ?></span></span>
                <div class="clearer"></div>
            </div>
<?php
}
else
{
?>
<div class="block">
    <div class="box">
    <h2><span><?php echo $lang_blog['Latest'] ?></span></h2>
        <div class="fakeform">
<?php
}
?>
            <div class="inform">
                <fieldset>
                    <div class="infldset">
                        <div class="postmsg">
<?php

                while ($cur_blog = $db->fetch_assoc($result))
                {
                $poster_id = '';
                $id = $cur_blog['id'];
                $bid = $cur_blog['poster_id'];
                $posted ='';
                $num_views = '';
                $num_comments = '';
                $poster = '';
                $post_actions = array();
                $post_actions[] = 'Posted by: '.pun_htmlspecialchars($cur_blog['poster']).'';
                $post_actions[] = ''.format_time($cur_blog['posted']).'';
                $post_actions[] = 'Views: '.$cur_blog['num_views'].'';
                $post_actions[] = '<span class="barlink"><a href="blogs.php?cid='.$cur_blog['id'].'">Comments</a>: '.$cur_blog['num_comments'].'</span>';

                //First we parse the message
                $pre = parse_message($cur_blog['blog'], $cur_blog['hide_smilies']);

                // Now we trim it
                $str = truncate ($pre, $id);

?>

                        <div class="postmsg">
                            <p><strong><?php echo pun_htmlspecialchars($cur_blog['heading']) ?></strong></p>
                            <?php echo $str."\n" ?>
                            <br /><?php echo (count($post_actions)) ? ''.implode($lang_blog['Link separator'].'', $post_actions).''."\n" : ''."\n" ?>
                        </div>
                            <?php //Is this the last comment or do we display separator? ?>
                            <?php if ($i < $count) echo '<div class="hr">&nbsp;</div><br />'; ?>
<?php
++$i;
}
?>
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
    </div>
    <div class="clearer"></div>
</div>

<?php
}
unset ($bid);
?>

    
<?php
}
if ($uid || $cid)
{
if ($pun_user['g_read_board'] == '0')
    message($lang_common['No view']);

if (($bid > 0  || $cat_id > 0  || $pop > 0  || $lat > 0  || $comm >0  || $blogrs >0)
|| ($uid > 0 && $cid > 0))
    message($lang_common['Bad request']);

    // Did someone just hit "Submit" or "Preview"?
    if (isset($_POST['form_sent']))
    {
        // Make sure form_user is correct
        if (($pun_user['is_guest'] && $_POST['form_user'] != 'Guest') || (!$pun_user['is_guest'] && $_POST['form_user'] != $pun_user['username']))
            message($lang_common['Bad request']);

        // Flood protection
        if (!$pun_user['is_guest'] && !isset($_POST['preview']) && $pun_user['last_post'] != '' && (time() - $pun_user['last_post']) < $pun_user['g_post_flood'])
            $errors[] = $lang_post['Flood start'].' '.$pun_user['g_post_flood'].' '.$lang_post['flood end'];

        // If it's a new topic
        if ($uid)
        {
            if (isset($_POST['category']))
            {
                $category = pun_trim($_POST['category']);
                $cat_info = explode(",", $category);
                $category = $cat_info[0];
                $cat_id = $cat_info[1];
            }        
            if  ($category == $lang_blog['Choose category'])
                $errors[] = $lang_blog['No category'];

            $subject = pun_trim($_POST['req_subject']);

            if ($subject == '')
                $errors[] = $lang_blog['No subject'];
            else if (pun_strlen($subject) > 70)
                $errors[] = $lang_blog['Too long subject'];
            else if ($pun_config['p_subject_all_caps'] == '0' && strtoupper($subject) == $subject && $pun_user['g_id'] > PUN_MOD)
                $subject = ucwords(strtolower($subject));
        }

        if ($cid) //lets make sure comments are allowed        
        {
            if (!$pun_user['is_guest'])
            $result = $db->query('SELECT b.allow_comments FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.id =('.$cid.') AND (p.reply_cat IS NULL OR p.reply_cat=1) AND b.allow_comments=1 ') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
            else
            $result = $db->query('SELECT b.allow_comments FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.id =('.$cid.') AND p.reply_cat=1 AND b.allow_comments=1 ') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
            if (!$db->num_rows($result))
                $errors[] = $lang_blog['No Comment error'];
        }
        
        // If the user is logged in we get the username and e-mail from $pun_user
        if (!$pun_user['is_guest'])
        {
            $username = $pun_user['username'];
            $email = $pun_user['email'];
        }

        // Otherwise it should be in $_POST
        else
        {
            $username = trim($_POST['req_username']);
            $email = strtolower(trim(($pun_config['p_force_guest_email'] == '1') ? $_POST['req_email'] : $_POST['email']));

            // Load the register.php/profile.php language files
            require PUN_ROOT.'lang/'.$pun_user['language'].'/prof_reg.php';
            require PUN_ROOT.'lang/'.$pun_user['language'].'/register.php';

            // It's a guest, so we have to validate the username
            if (strlen($username) < 2)
                $errors[] = $lang_prof_reg['Username too short'];
            else if (!strcasecmp($username, 'Guest') || !strcasecmp($username, $lang_common['Guest']))
                $errors[] = $lang_prof_reg['Username guest'];
            else if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $username))
                $errors[] = $lang_prof_reg['Username IP'];

            if ((strpos($username, '[') !== false || strpos($username, ']') !== false) && strpos($username, '\'') !== false && strpos($username, '"') !== false)
                $errors[] = $lang_prof_reg['Username reserved chars'];
            if (preg_match('#\[b\]|\[/b\]|\[u\]|\[/u\]|\[i\]|\[/i\]|\[color|\[/color\]|\[quote\]|\[quote=|\[/quote\]|\[code\]|\[/code\]|\[img\]|\[/img\]|\[url|\[/url\]|\[email|\[/email\]#i', $username))
                $errors[] = $lang_prof_reg['Username BBCode'];

            // Check username for any censored words
            $temp = censor_words($username);
            if ($temp != $username)
                $errors[] = $lang_register['Username censor'];

            // Check that the username (or a too similar username) is not already registered
            $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE username=\''.$db->escape($username).'\' OR username=\''.$db->escape(preg_replace('/[^\w]/', '', $username)).'\'') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
            if ($db->num_rows($result))
            {
                $busy = $db->result($result);
                $errors[] = $lang_register['Username dupe 1'].' '.pun_htmlspecialchars($busy).'. '.$lang_register['Username dupe 2'];
            }

            if ($pun_config['p_force_guest_email'] == '1' || $email != '')
            {
                require PUN_ROOT.'include/email.php';
                if (!is_valid_email($email))
                    $errors[] = $lang_common['Invalid e-mail'];
            }
        }

        // Clean up message from POST
        $message = pun_linebreaks(pun_trim($_POST['req_message']));

        if ($message == '')
            $errors[] = $lang_blog['No message'];
        else if (strlen($message) > 65535)
            $errors[] = $lang_blog['Too long message'];
        else if ($pun_config['p_message_all_caps'] == '0' && strtoupper($message) == $message && $pun_user['g_id'] > PUN_MOD)
            $message = ucwords(strtolower($message));

        // Validate BBCode syntax
        if ($pun_config['p_message_bbcode'] == '1' && strpos($message, '[') !== false && strpos($message, ']') !== false)
        {
        require_once PUN_ROOT.'include/parser.php';
            $message = preparse_bbcode($message, $errors);
        }

        $now = time();

        // Did everything go according to plan?
        if (empty($errors) && !isset($_POST['preview']))
        {
            // If it's a comment
            if ($cid)
            {
                if (!$pun_user['is_guest'])
                {
                    // Insert the new post
                    $db->query('INSERT INTO '.$db->prefix.'blog_comments (poster, poster_ip, poster_id, posted, blog, blog_id) VALUES(\''.$db->escape($username).'\', \''.get_remote_address().'\', '.$pun_user['id'].', '.$now.',  \''.$db->escape($message).'\', '.$cid.')') or error('Unable to create comment', __FILE__, __LINE__, $db->error());
                }
                else
                {
                    // It's a guest. Insert the new post
                    $email_sql = ($pun_config['p_force_guest_email'] == '1' || $email != '') ? '\''.$email.'\'' : 'NULL';
                    $db->query('INSERT INTO '.$db->prefix.'blog_comments (poster, poster_ip, poster_email, poster_id, posted, blog, blog_id) VALUES(\''.$db->escape($username).'\', \''.get_remote_address().'\', '.$email_sql.', '.$pun_user['id'].', '.$now.',  \''.$db->escape($message).'\', '.$cid.')') or error('Unable to create comment', __FILE__, __LINE__, $db->error());
                }

                $db->query('UPDATE '.$db->prefix.'blogs SET num_comments=num_comments+1 WHERE id='.$cid) or error('Unable to update count', __FILE__, __LINE__, $db->error());
                $db->query('UPDATE '.$db->prefix.'users SET num_blog_comments=num_blog_comments+1 WHERE id='.$pun_user['id']) or error('Unable to update count', __FILE__, __LINE__, $db->error());
            }

            // If it's a new topic
            else if ($uid)
            {
                if (!$pun_user['is_guest'])
                {
                    $allow_comments = pun_trim($_POST['allow_comments']);    
                    $db->query('INSERT INTO '.$db->prefix.'blogs (poster, poster_ip, poster_id, heading, posted, blog, allow_comments, category, cat_id) VALUES(\''.$db->escape($username).'\', \''.get_remote_address().'\', '.$pun_user['id'].', \''.$db->escape($subject).'\', '.$now.', \''.$db->escape($message).'\', \''.$db->escape($allow_comments).'\', \''.$db->escape($category).'\', \''.$db->escape($cat_id).'\')') or error('Unable to create blog', __FILE__, __LINE__, $db->error());
                    $db->query('UPDATE '.$db->prefix.'users SET num_blogs=num_blogs+1 WHERE id='.$pun_user['id']) or error('Unable to update count', __FILE__, __LINE__, $db->error());
                    $db->query('UPDATE '.$db->prefix.'blog_categories SET num_blogs=num_blogs+1 WHERE id='.$cat_id) or error('Unable to update count', __FILE__, __LINE__, $db->error());
                }
                else
                {
                    // It's a guest. Insert the new post
                    $allow_comments = pun_trim($_POST['allow_comments']);    
                    $email_sql = ($pun_config['p_force_guest_email'] == '1' || $email != '') ? '\''.$email.'\'' : 'NULL';
                    $db->query('INSERT INTO '.$db->prefix.'blogs (poster, poster_ip, poster_email, poster_id, heading, posted, blog, allow_comments, category, cat_id) VALUES(\''.$db->escape($username).'\', \''.get_remote_address().'\', '.$email_sql.', '.$pun_user['id'].', \''.$db->escape($subject).'\', '.$now.', \''.$db->escape($message).'\', \''.$db->escape($allow_comments).'\', \''.$db->escape($category).'\', \''.$db->escape($cat_id).'\')') or error('Unable to create blog', __FILE__, __LINE__, $db->error());
                    $db->query('UPDATE '.$db->prefix.'users SET num_blogs=num_blogs+1 WHERE id='.$pun_user['id']) or error('Unable to update count', __FILE__, __LINE__, $db->error());
                    $db->query('UPDATE '.$db->prefix.'blog_categories SET num_blogs=num_blogs+1 WHERE id='.$cat_id) or error('Unable to update count', __FILE__, __LINE__, $db->error());
                }

            }            
            echo '</div></div>';
            
            if($uid)
                redirect('blogs.php?bid='.$uid.'', $lang_blog['Blog redirect']);
            else
                redirect('blogs.php?cid='.$cid.'&amp;c_id='.$cid.'', $lang_blog['Comment redirect']);
        }
    }


/***********************************************************************
Start some output of stuff
************************************************************************/
        
    if (!empty($errors))
    {
?>
<div id="posterror" class="block">
    <div class="box">
    <h2><span><?php echo $lang_blog['Post errors'] ?></span></h2>
        <div class="inbox">
            <p><?php echo $lang_blog['Post errors info'] ?></p>
            <ul>
<?php
            while (list(, $cur_error) = each($errors))
            echo "\t\t\t\t".'<li><strong>'.$cur_error.'</strong></li>'."\n";
?>
            </ul>
        </div>
    </div>
</div>

<?php

    }
    else if (isset($_POST['preview']))
    {
        require_once PUN_ROOT.'include/parser.php';
        $preview_message = parse_message($message, $hide_smilies);
        $category = pun_trim($_POST['category']);
?>
<div id="postpreview" class="block">
    <h2><span><?php echo $lang_blog['Post preview'] ?></span></h2>
    <div class="box">
        <div class="inbox">
            <div class="postright">
                <div class="postmsg">
                    <?php echo $preview_message."\n" ?>
                </div>
            </div>
        </div>
    </div>
</div>

<?php

    }        
        
    // we show the form above the above the blog if this is a preview of a comment        
    if ((isset($_POST['preview']) || !empty($errors)) && ($cid))        
    {        
        $action = $lang_blog['Post new comment'];
        $form = '<form id="reply" method="post" action="blogs.php?action=post&amp;cid='.$cid.'">';

$cur_index = 1;        
?>
<div class="blockform">
    <div class="box">
        <?php echo $form."\n" ?>
            <div class="inform">
                <fieldset>
                    <legend><?php echo $lang_blog['Write comment legend'] ?></legend>
                    <div class="infldset txtarea">
                        <input type="hidden" name="form_sent" value="1" />
                        <input type="hidden" name="form_user" value="<?php echo (!$pun_user['is_guest']) ? pun_htmlspecialchars($pun_user['username']) : 'Guest'; ?>" />
<?php

        if ($pun_user['is_guest'])
        {
            $email_label = ($pun_config['p_force_guest_email'] == '1') ? '<strong>'.$lang_common['E-mail'].'</strong>' : $lang_common['E-mail'];
            $email_form_name = ($pun_config['p_force_guest_email'] == '1') ? 'req_email' : 'email';
?>
                        <label class="conl"><strong><?php echo $lang_blog['Guest name'] ?></strong><br /><input type="text" name="req_username" value="<?php if (isset($_POST['req_username'])) echo pun_htmlspecialchars($username); ?>" size="25" maxlength="25" tabindex="<?php echo $cur_index++ ?>" /><br /></label>
                        <label class="conl"><?php echo $email_label ?><br /><input type="text" name="<?php echo $email_form_name ?>" value="<?php if (isset($_POST[$email_form_name])) echo pun_htmlspecialchars($email); ?>" size="50" maxlength="50" tabindex="<?php echo $cur_index++ ?>" /><br /></label>
                        <div class="clearer"></div>
<?php
        }
?>
                        <label><strong><?php echo $lang_common['Message'] ?></strong><br />
                        <textarea name="req_message" rows="10" cols="35" tabindex="<?php echo $cur_index++ ?>"><?php echo isset($_POST['req_message']) ? pun_htmlspecialchars($message) : (isset($quote) ? $quote : ''); ?></textarea><br /></label>
                            <ul class="bblinks">
                                <li><a href="help.php#bbcode" onclick="window.open(this.href); return false;"><?php echo $lang_common['BBCode'] ?></a>: <?php echo ($pun_config['p_message_bbcode'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li>
                                <li><a href="help.php#img" onclick="window.open(this.href); return false;"><?php echo $lang_common['img tag'] ?></a>: <?php echo ($pun_config['p_message_img_tag'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li>
                                <li><a href="help.php#smilies" onclick="window.open(this.href); return false;"><?php echo $lang_common['Smilies'] ?></a>: <?php echo ($pun_config['o_smilies'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li>
                            </ul>
                    </div>
                </fieldset>
            </div>
            <p><input type="submit" name="submit" value="<?php echo $lang_common['Submit'] ?>" tabindex="<?php echo $cur_index++ ?>" accesskey="s" /><input type="submit" name="preview" value="<?php echo $lang_blog['Preview'] ?>" tabindex="<?php echo $cur_index++ ?>" accesskey="p" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
        </form>
    </div>
</div>        
        
<?php        
    }        
        
    if ($cid) //it's a comment form, first we retrieve the blog and comments
    {
        
        //retrieve the blog
        require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
        define('PUN_ALLOW_INDEX', 1);
        require_once PUN_ROOT.'include/parser.php';
        $result = $db->query('SELECT b.*, m.moderators FROM '.$db->prefix.'blogs AS b  LEFT JOIN '.$db->prefix.'blog_categories AS m ON m.id=b.cat_id LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.id ='.$cid.' AND (p.read_cat IS NULL OR p.read_cat=1)') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
        if (!$db->num_rows($result))
            message($lang_common['Bad request']);

        $blog = $db->fetch_assoc($result);
        $allow_cmt = $blog['allow_comments'];
        $link1 = $blog['poster_id'];
        $link2 = pun_htmlspecialchars($blog['poster']);
        $link3 = $blog['heading'];

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

        $pt_actions = array();

        if (($blog['poster_id'] == $pun_user['id']) && (!$is_admmod) && (!$pun_user['is_guest']))
        {
            $pt_actions[] = '<a href="blogs_delete.php?bid='.$blog['id'].'">'.$lang_topic['Delete'].'</a>';
            $pt_actions[] = '<a href="blogs_edit.php?bid='.$blog['id'].'">'.$lang_topic['Edit'].'</a>';
        }
        if ($is_admmod)
        {
            $pt_actions[] = '<a href="blogs_delete.php?bid='.$blog['id'].'">'.$lang_topic['Delete'].'</a>';
            $pt_actions[] = '<a href="blogs_edit.php?bid='.$blog['id'].'">'.$lang_topic['Edit'].'</a>';
            $pt_actions[] = 'IP: <a href="moderate.php?get_host='.$blog['poster_ip'].'">'.$blog['poster_ip'].'</a>';

            if ($blog['poster_id'] == 1)
            {
                $pt_actions[] = '<a href="mailto:'.$blog['poster_email'].'">'.$blog['poster_email'].'</a>';
            }                        
        }


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

        //update numbeer of views for the current blog
        $db->query('UPDATE '.$db->prefix.'blogs SET num_views=num_views+1 WHERE id='.$cid) or error('Unable to update blog views', __FILE__, __LINE__, $db->error());
        
        $result = $db->query('SELECT id FROM '.$db->prefix.'blog_comments WHERE blog_id='.$c_id.'') or error('Unable to feetch blog info', __FILE__, __LINE__, $db->error());
        $num_comments = $db->num_rows($result);

        // Determine the topic offset (based on $_GET['p'])
        $num_pages = ceil($num_comments / $pun_user['disp_comments']);

        $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
        $start_from = $pun_user['disp_comments'] * ($p - 1);
 
        // Generate paging links
        $paging_links = $lang_common['Pages'].': '.paginate($num_pages, $p, 'blogs.php?cid='.$cid.'&amp;c_id='.$c_id);

?>
<div class="linkst">
    <div class="inbox">
        <p class="pagelink conl"><?php echo $paging_links ?></p>
        <ul><li><a href="blogs.php"><?php echo $lang_blog['Blogs'] ?></a>&nbsp;</li><li>&raquo;&nbsp;<a href="blogs.php?bid=<?php echo $link1 ?>"><?php echo $link2 ?></a>&nbsp;</li><li>&raquo;&nbsp;<?php echo $link3 ?></li></ul>
        <div class="clearer"></div>
    </div>
</div>

<div class="block">
    <div class="box">
        <div class="fakeform">
            <div class="block">
                <span class="blogcat"><span style="font-size:1.5em;"><?php echo $lang_blog['User blogs'] ?></span></span>
                <div class="clearer"></div>
            </div>
            <div class="inform">
                <fieldset>
                    <div class="infldset">
                        <div class="postmsg">
                            <p><?php echo format_time($blog['posted']) ?></p>
                            <p>Posted by <?php echo pun_htmlspecialchars($blog['poster']) ?></p>
                            <p>Category: <?php echo ($blog['category']) ?></p>
                            <p><span style="font-size:2em;"><?php echo pun_htmlspecialchars($blog['heading']) ?></span></p>
                            <?php echo $blog['message']."\n" ?>
                            <?php if ($blog['edited'] != '') echo "\t\t\t\t\t".'<p class="postedit"><em>'.$lang_topic['Last edit'].' '.pun_htmlspecialchars($blog['edited_by']).' ('.format_time($blog['edited']).')</em></p>'."\n"; ?>
                            <br /><?php echo (count($pt_actions)) ? ''.implode($lang_blog['Link separator'].'', $pt_actions).''."\n" : ''."\n" ?>
                        </div>
                    </div>
                </fieldset>
            </div>




<?php
        $result = $db->query('SELECT b.*, c.*, m.moderators FROM '.$db->prefix.'blog_comments AS c INNER JOIN '.$db->prefix.'blogs AS b ON b.id=c.blog_id LEFT JOIN '.$db->prefix.'blog_categories AS m ON m.id=b.cat_id LEFT JOIN '.$db->prefix.'blog_perms AS p ON p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].' WHERE c.blog_id='.$cid.' AND (p.read_cat IS NULL OR p.read_cat=1) ORDER BY c.posted LIMIT '.$start_from.', '.$pun_user['disp_comments']) or error('Unable to fetch comments', __FILE__, __LINE__, $db->error());
        if ($db->num_rows($result)) 
        {
            $count = $db->num_rows($result);
            $i = 1;
?>
            <div class="block">
                <span class="blogcat"><span style="font-size:1.5em;"><?php echo $lang_blog['Comments'] ?></span></span>
                <div class="clearer"></div>
            </div>
            <div class="inform">
                <fieldset>
                    <div class="infldset">
                        <div class="postmsg">


<?php


            while ($cur_blog = $db->fetch_assoc($result))
            {
                // Sort out who the moderators are and if we are currently a moderator (or an admin)
                $mods_array = ($cur_blog['moderators'] != '') ? unserialize($cur_blog['moderators']) : array();
                $is_admmod = ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_id'] == PUN_MOD && array_key_exists($pun_user['username'], $mods_array))) ? true : false;
                $com_num = $start_from + $i;
                $post_actions = array();
        if (($cur_blog['poster_id'] == $pun_user['id']) && (!$is_admmod) && (!$pun_user['is_guest']))
                {
                    $post_actions[] = ''.$com_num.'';
                    $post_actions[] = 'Posted by: '.pun_htmlspecialchars($cur_blog['poster']).'';
                    $post_actions[] = ''.format_time($cur_blog['posted']).'';
                    $post_actions[] = '<a href="blogs_delete.php?cid='.$cur_blog['id'].'">Delete</a>';
                    $post_actions[] = '<a href="blogs_edit.php?cid='.$cur_blog['id'].'">Edit</a>';
                }                
                else if ($is_admmod)
                {
                    $post_actions[] = ''.$com_num.'';
                    $post_actions[] = 'Posted by: '.pun_htmlspecialchars($cur_blog['poster']).'';
                    $post_actions[] = ''.format_time($cur_blog['posted']).'';
                    $post_actions[] = '<a href="blogs_delete.php?cid='.$cur_blog['id'].'">Delete</a>';
                    $post_actions[] = '<a href="blogs_edit.php?cid='.$cur_blog['id'].'">Edit</a>';
                    $post_actions[] = 'IP: <a href="moderate.php?get_host='.$cur_blog['poster_ip'].'">'.$cur_blog['poster_ip'].'</a>';
                    if ($cur_blog['poster_id'] == 1)
                    {
                        $post_actions[] = '<a href="mailto:'.$cur_blog['poster_email'].'">'.$cur_blog['poster_email'].'</a>';
                    }                        
                }                    
                else
                {
                    $post_actions[] = ''.$com_num.'';
                    $post_actions[] = 'Posted by: '.pun_htmlspecialchars($cur_blog['poster']).'';
                    $post_actions[] = ''.format_time($cur_blog['posted']).'';
                }                    
                            
                // Perform the main parsing of the message (BBCode, smilies, censor words etc)
                $cur_blog['message'] = parse_message($cur_blog['blog'], $cur_blog['hide_smilies']);
?>

                            <div class="postmsg">
                                <p>re:<strong><?php echo pun_htmlspecialchars($cur_blog['heading']) ?></strong></p><br />
                                <?php echo $cur_blog['message']."\n" ?>
                                <?php if ($cur_blog['edited'] != '') echo "\t\t\t\t\t".'<p class="postedit"><em>'.$lang_topic['Last edit'].' '.pun_htmlspecialchars($cur_blog['edited_by']).' ('.format_time($cur_blog['edited']).')</em></p>'."\n"; ?>
                                <br /><?php echo (count($post_actions)) ? ''.implode($lang_blog['Link separator'].'', $post_actions).''."\n" : ''."\n" ?>
                            </div>
                            <?php //Is this the last comment or do we display separator? ?>
                            <?php if ($i < $count) echo '<div class="hr">&nbsp;</div><br />'; ?>
<?php
++$i;
            }
?>    
                        </div>            
                        <div class="clearer"></div>
                    </div>
                </fieldset>
            </div>
        </div>
    </div>
</div>    
<?php
        }
        else
        {
?>
        </div>
    </div>
</div>    
<?php
        }
?>
<div class="linksb">
    <div class="inbox">
        <p class="pagelink conl"><?php echo $paging_links ?></p>
        <ul><li><a href="blogs.php"><?php echo $lang_blog['Blogs'] ?></a>&nbsp;</li><li>&raquo;&nbsp;<a href="blogs.php?bid=<?php echo $link1 ?>"><?php echo $link2 ?></a>&nbsp;</li><li>&raquo;&nbsp;<?php echo $link3 ?></li></ul>
        <div class="clearer"></div>
    </div>
</div>
<?php    
        //do we show the post form
        if ($pun_user['is_guest'])
        $result = $db->query('SELECT b.allow_comments FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.id =('.$cid.') AND p.reply_cat=1 AND b.allow_comments=1 ') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());

         else
        $result = $db->query('SELECT b.allow_comments FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.id =('.$cid.') AND (p.reply_cat IS NULL OR p.reply_cat=1) AND b.allow_comments=1 ') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());

        if (!$db->num_rows($result))
        {
            $post = 'no';
        }
    }
    //we show the form here if it is not a preview for a comment
    if (($uid) || (($cid)&& (!$post == no) && (!isset($_POST['preview']) && empty($errors))))
    {
        if ($uid) 
        {
            $action = $lang_blog['Post new blog'];
            $form = '<form id="post" method="post" action="blogs.php?action=post&amp;uid='.$uid.'">';
            $message_legend = $lang_blog['Write blog legend'];
        } 
        else if ($cid) //If a cid was specified it is a new comment
        {
            $action = $lang_blog['Post new comment'];
            $form = '<form id="reply" method="post" action="blogs.php?action=post&amp;cid='.$cid.'">';
            $message_legend = $lang_blog['Write comment legend'];
        }
        $cur_index = 1;
?>
<div class="blockform">
    <div class="box">
<?php
        if ($uid)
        {    
?>    
    <h2><span><?php echo $lang_blog['User blogs'] ?></span></h2>
<?php
        }
?>    
        <?php echo $form."\n" ?>
            <div class="inform">
                <fieldset>
                    <legend><?php echo $message_legend ?></legend>
                    <div class="infldset txtarea">
                        <input type="hidden" name="form_sent" value="1" />
                        <input type="hidden" name="form_user" value="<?php echo (!$pun_user['is_guest']) ? pun_htmlspecialchars($pun_user['username']) : 'Guest'; ?>" />
<?php

        if ($pun_user['is_guest'])
        {
            $email_label = ($pun_config['p_force_guest_email'] == '1') ? '<strong>'.$lang_common['E-mail'].'</strong>' : $lang_common['E-mail'];
            $email_form_name = ($pun_config['p_force_guest_email'] == '1') ? 'req_email' : 'email';
?>
                        <label class="conl"><strong><?php echo $lang_blog['Guest name'] ?></strong><br /><input type="text" name="req_username" value="<?php if (isset($_POST['req_username'])) echo pun_htmlspecialchars($username); ?>" size="25" maxlength="25" tabindex="<?php echo $cur_index++ ?>" /><br /></label>
                        <label class="conl"><?php echo $email_label ?><br /><input type="text" name="<?php echo $email_form_name ?>" value="<?php if (isset($_POST[$email_form_name])) echo pun_htmlspecialchars($email); ?>" size="50" maxlength="50" tabindex="<?php echo $cur_index++ ?>" /><br /></label>
                        <div class="clearer"></div>
<?php
        }
        if ($uid):  // Generate list of categories user is allowed to post in
            if (isset($_POST['category']))
            {
                $cat_info = explode(",", $category);
                $category = $cat_info[0];
                $cat_id = $cat_info[1];
            }
            else
            {
                $category = ($lang_blog['Choose category']);
                $cat_id = '';
            }                
            
?>
                        <label><strong><?php echo $lang_blog['Category'] ?></strong>
                            <br />
                            <select name="category" tabindex="<?php echo $cur_index++ ?>">
                                                                                   
<?php
            echo "\t\t\t\t\t\t\t".'<option value="'.$category.', '.$cat_id.'">'.pun_htmlspecialchars($category).'</option>'."\n";

if ($pun_user['is_guest'])
{
            $result = $db->query('SELECT c.id, c.categories FROM '.$db->prefix.'blog_categories AS c LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=c.id AND p.group_id='.$pun_user['g_id'].') WHERE p.post_cat=1') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
} else {
            $result = $db->query('SELECT c.id, c.categories FROM '.$db->prefix.'blog_categories AS c LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=c.id AND p.group_id='.$pun_user['g_id'].') WHERE p.post_cat IS NULL OR p.post_cat=1') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
}
            $num_cats = $db->num_rows($result);
            for ($i = 0; $i < $num_cats; ++$i)
            $cat_list[] = $db->fetch_row($result);
            while (list(, list($cat_id, $category, ,)) = @each($cat_list))
            echo "\t\t\t\t\t\t\t".'<option value="'.$category.', '.$cat_id.'">'.pun_htmlspecialchars($category).'</option>'."\n";
?>
                            </select><br />
                        </label>
                        <label><strong><?php echo $lang_blog['Heading'] ?></strong><br /><input class="longinput" type="text" name="req_subject" value="<?php if (isset($_POST['req_subject'])) echo pun_htmlspecialchars($subject); ?>" size="80" maxlength="70" tabindex="<?php echo $cur_index++ ?>" /><br /></label>
        <?php endif; ?>
                        <label><strong><?php echo $lang_common['Message'] ?></strong><br />
                        <textarea name="req_message" rows="10" cols="35" tabindex="<?php echo $cur_index++ ?>"><?php echo isset($_POST['req_message']) ? pun_htmlspecialchars($message) : (isset($quote) ? $quote : ''); ?></textarea><br /></label>
                            <ul class="bblinks">
                                <li><a href="help.php#bbcode" onclick="window.open(this.href); return false;"><?php echo $lang_common['BBCode'] ?></a>: <?php echo ($pun_config['p_message_bbcode'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li>
                                <li><a href="help.php#img" onclick="window.open(this.href); return false;"><?php echo $lang_common['img tag'] ?></a>: <?php echo ($pun_config['p_message_img_tag'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li>
                                <li><a href="help.php#smilies" onclick="window.open(this.href); return false;"><?php echo $lang_common['Smilies'] ?></a>: <?php echo ($pun_config['o_smilies'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li>
                            </ul>
        <?php if ($uid): ?>
                        <label><input type="radio" name="allow_comments" value="0" tabindex="<?php echo $cur_index++ ?>" /><?php echo $lang_blog['No Comments'] ?><br /></label>
                        <label><input type="radio" name="allow_comments" value="1" checked="checked" tabindex="<?php echo $cur_index++ ?>" /><?php echo $lang_blog['User Comments'] ?><br /></label>
                        <label><?php echo $lang_blog['Note Comments'] ?><br /></label>
        <?php endif; ?>    
                    </div>
                </fieldset>
            </div>
            <p><input type="submit" name="submit" value="<?php echo $lang_common['Submit'] ?>" tabindex="<?php echo $cur_index++ ?>" accesskey="s" /><input type="submit" name="preview" value="<?php echo $lang_blog['Preview'] ?>" tabindex="<?php echo $cur_index++ ?>" accesskey="p" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
        </form>
    </div>
</div>

<?php        
    }
}

if ($bid)
{

/***********************************************************************
       this output's a preview of all of the selected users blogs
************************************************************************/

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

if ($uid > 0  || $cid > 0  || $cat_id > 0  || $pop > 0  || $lat > 0  || $comm >0  || $blogrs >0)
    message($lang_common['Bad request']);


    require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
    define('PUN_ALLOW_INDEX', 1);
    require_once PUN_ROOT.'include/parser.php';
            require PUN_ROOT.'lang/'.$pun_user['language'].'/profile.php';
    $result = $db->query('SELECT id, username, num_blogs, blog_about, blog_hobbies, blog_other FROM '.$db->prefix.'users WHERE id ='.$bid.'') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
    $bgr = $db->fetch_assoc($result);
    $ac=$bgr['num_blogs'];
    $nm=pun_htmlspecialchars($bgr['username']);
    $blog_about=$bgr['blog_about'];
    $blog_hobbies=$bgr['blog_hobbies'];
    $blog_other=$bgr['blog_other'];
    $prf='<span class="barlink"><a href="profile.php?id='.$bgr['id'].'">View full profile</a></span>';


if ($blog_about != '')
{
    require_once PUN_ROOT.'include/parser.php';
    $parsed_blog_about = parse_signature($blog_about);
}
if ($blog_hobbies != '')
{
    require_once PUN_ROOT.'include/parser.php';
    $parsed_blog_hobbies = parse_signature($blog_hobbies);
}
if ($blog_other != '')
{
    require_once PUN_ROOT.'include/parser.php';
    $parsed_blog_other = parse_signature($blog_other);
}



    $result = $db->query('SELECT COUNT(b.id) FROM '.$db->prefix.'blogs AS b INNER JOIN '.$db->prefix.'users AS u ON b.poster_id=u.id LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.poster_id ='.$bid.' && (p.read_cat IS NULL OR p.read_cat=1)') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
    $num_blogs = $db->result($result);

    // Determine the topic offset (based on $_GET['p'])
    $num_pages = ceil($num_blogs / $pun_user['disp_blogs']);

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

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

    $result = $db->query('SELECT b.*, m.moderators FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_categories AS m ON m.id=b.cat_id LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.poster_id =('.$bid.') && (p.read_cat IS NULL OR p.read_cat=1) ORDER BY b.id DESC LIMIT '.$start_from.', '.$pun_user['disp_blogs'].'') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
    //$result = $db->query('SELECT b.*, u.blog_about, u.blog_hobbies, u.blog_other FROM '.$db->prefix.'blogs AS b INNER JOIN '.db->prefix.'users as u ON u.id=b.poster_id LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.poster_id =('.$bid.') && (p.read_cat IS NULL OR p.read_cat=1)  ORDER BY b.id DESC LIMIT '.$start_from.', '.$pun_user['disp_blogs'].'') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
    if (!$db->num_rows($result))
        message($lang_blog['No Blog']);

    $count = $db->num_rows($result);
    $b_num = 1;
    $i = 1;

    while ($cur_blog = $db->fetch_assoc($result))
    {

        $id = '';
        $num_comments = '';
        $blog_num = $start_from + $i;

        $post_actions = array();
        $post_actions[] = ''.$blog_num.'';
        $post_actions[] = 'Posted : '.format_time($cur_blog['posted']).' in '.pun_htmlspecialchars($cur_blog['category']).'';
        if ($cur_blog['poster_id'] == 1)
            $post_actions[] = 'By: '.pun_htmlspecialchars($cur_blog['poster']).'';
        $post_actions[] = 'Views: '.$cur_blog['num_views'].'';
        $post_actions[] = '<span class="barlink"><a href="blogs.php?cid='.$cur_blog['id'].'&amp;c_id='.$cur_blog['id'].'">Comments</a>:&nbsp;'.$cur_blog['num_comments'].'</span>';

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

        // Trim the blog
        $str = truncate ($pre, $id);

        if ($i == $b_num) //We only show the navigation if it's the first blog
        {



?>
<div class="linkst">
    <div class="inbox">
<?php
        if ($pun_user['id'] == $cur_blog['poster_id'])
        {
        echo '<p class="postlink conr"><a href="blogs.php?uid='.$bid.'">'.$lang_blog['Post new blog'].'</a></p>';
        }
?>
        <p class="pagelink conl"><?php echo $paging_links ?></p>
        <ul><li><a href="blogs.php"><?php echo $lang_blog['Blogs'] ?></a>&nbsp;</li><li>&raquo;&nbsp;<?php echo pun_htmlspecialchars($cur_blog['poster']) ?></li></ul>
        <div class="clearer"></div>
    </div>
</div>
<div class="block">
    <div class="box">
        <div class="fakeform">
            <div class="inform">
                <fieldset>
<?php
if ($blog_num == 1&& $cur_blog['poster_id'] != 1) // We only show the blogger's profile if it is the first page of blogs for the user
{
?>
                    <legend><?php echo $cur_blog['poster'] ?>'s Profile</legend>
                    <div class="infldset">
                        <div class="postmsg">
                            <p>Number of Blogs:&nbsp;<strong><?php echo $ac ?></strong></p>
                            <p><br /><strong><?php echo $lang_profile['Blog about'] ?>:</strong></p>
                            <p><?php echo isset($parsed_blog_about) ? $parsed_blog_about : $lang_profile['Unknown']; ?></p>
                            <p><br /><strong><?php echo $lang_profile['Blog hobbies'] ?>: </strong></p>
                            <p><?php echo isset($parsed_blog_hobbies) ? $parsed_blog_hobbies : $lang_profile['Unknown']; ?></p>
                            <p><br /><strong><?php echo $lang_profile['Blog other'] ?>: </strong></p>
                            <p><?php echo isset($parsed_blog_other) ? $parsed_blog_other : $lang_profile['Unknown']; ?></p>
                            <p><br /><?php echo $prf ?></p>
                        </div>
                    </div>
                </fieldset>
            </div>
            <div class="block">
                <span class="blogcat"><span style="font-size:1.5em;">Blogs for <?php echo pun_htmlspecialchars($cur_blog['poster']) ?>&nbsp;&nbsp;&nbsp;<a href="blogs_rss.php?bid=<?php echo $cur_blog['poster_id'] ?>" ><img src="img/feed.gif" alt="RSS Feed/<?php echo $cur_blog['poster'] ?>" /></a></span></span>
                <div class="clearer"></div>
            </div>
            <div class="inform">
                <fieldset>
                    <div class="infldset">
<?php
} else {
?>
                    <div class="infldset">
<?php        
}        
        }
?>
                        <div class="postmsg">
                            
                            <p><strong><?php echo pun_htmlspecialchars($cur_blog['heading']) ?></strong></p>
                            <?php echo $str."\n" ?>
                            <?php if ($cur_blog['edited'] != '') echo "\t\t\t\t\t".'<p class="postedit"><em>'.$lang_topic['Last edit'].' '.pun_htmlspecialchars($cur_blog['edited_by']).' ('.format_time($cur_blog['edited']).')</em></p>'."\n"; ?>
                            <br /><?php echo (count($post_actions)) ? ''.implode($lang_blog['Link separator'].'', $post_actions).''."\n" : ''."\n" ?>
                        </div>
                            <?php if ($i < $count) echo '<div class="hr">&nbsp;</div><br />'; ?>
<?php
++$i;
    }
            
?>    
                    </div>
                </fieldset>
            </div>
        </div>
    </div>    
</div>
<div class="linkst">
    <div class="inbox">
        <p class="pagelink conl"><?php echo $paging_links ?></p>
        <ul><li><a href="blogs.php"><?php echo $lang_blog['Blogs'] ?></a>&nbsp;</li><li>&raquo;&nbsp;<?php echo $nm ?></li></ul>
        <div class="clearer"></div>
    </div>
</div>

<?php    
}
if ($cat_id)

/***********************************************************************
       this output's a preview of all of the selected category's blogs
************************************************************************/

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

if ($uid > 0  || $cid > 0  || $bid > 0  || $pop > 0  || $lat > 0  || $comm >0)
    message($lang_common['Bad request']);

    require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
    define('PUN_ALLOW_INDEX', 1);
    require_once PUN_ROOT.'include/parser.php';
    
    $result = $db->query('SELECT COUNT(b.id) FROM '.$db->prefix.'blogs AS b INNER JOIN '.$db->prefix.'users AS u ON b.poster_id=u.id LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.cat_id ='.$cat_id.' && (p.read_cat IS NULL OR p.read_cat=1)') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
    $num_blogs = $db->result($result);

    // Determine the topic offset (based on $_GET['p'])
    $num_pages = ceil($num_blogs / $pun_user['disp_blogs']);

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

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

    $result = $db->query('SELECT b.* FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.cat_id =('.$cat_id.') && (p.read_cat IS NULL OR p.read_cat=1)  ORDER BY b.id DESC LIMIT '.$start_from.', '.$pun_user['disp_blogs'].'') or error('Unable to fetch category info', __FILE__, __LINE__, $db->error());
    if (!$db->num_rows($result))
        message($lang_blog['No Blog Cat']);    
    if ($db->num_rows($result)) 
    {
        $count = $db->num_rows($result);
        $i = 1;
        $c_num = 1;            
                
        while ($cur_blog = $db->fetch_assoc($result))
        {
            $post_actions = array();
            $post_actions[] = 'Posted by: '.pun_htmlspecialchars($cur_blog['poster']).'';
            $post_actions[] = ''.format_time($cur_blog['posted']).'';
            $post_actions[] = 'Views: '.$cur_blog['num_views'].'';
            $post_actions[] = '<span class="barlink"><a href="blogs.php?cid='.$cur_blog['id'].'&amp;c_id='.$cur_blog['id'].'">Comments</a>:&nbsp;'.$cur_blog['num_comments'].'</span>';

            $cat_name = pun_htmlspecialchars($cur_blog['category']);
            $bid = $cur_blog['poster_id'];
            $id = $cur_blog['id'];
            $pre = parse_message($cur_blog['blog'], $cur_blog['hide_smilies']);

            // Trim the blog
            $str = truncate ($pre, $id);
            if ($i == $c_num)
            {
?>
<div class="linkst">
    <div class="inbox">
        <p class="pagelink conl"><?php echo $paging_links ?></p>
        <ul><li><a href="blogs.php"><?php echo $lang_blog['Blogs'] ?></a>&nbsp;</li><li>&raquo;&nbsp;<?php echo $cat_name; ?></li></ul>
        <div class="clearer"></div>
    </div>
</div>
<div class="block">
    <div class="box">
        <div class="fakeform">
            <div class="block">
                <span class="blogcat"><span style="font-size:1.5em;"><?php echo pun_htmlspecialchars($cur_blog['category']) ?>&nbsp;&nbsp;&nbsp;<a href="blogs_rss.php?cid=<?php echo $cur_blog['cat_id'] ?>" ><img src="img/feed.gif" alt="RSS Feed/<?php echo $cur_blog['category'] ?>" /></a></span></span>
                <div class="clearer"></div>
            </div>
            <div class="inform">
                <fieldset>
                    <div class="infldset">

<?php        
        
            }
?>
                        <div class="postmsg">

                            <p><strong><?php echo pun_htmlspecialchars($cur_blog['heading']) ?></strong></p>
                            <?php echo $str."\n" ?>
                            <br /><?php echo (count($post_actions)) ? ''.implode($lang_blog['Link separator'].'', $post_actions).''."\n" : ''."\n" ?>
                        </div>
                            <?php //Is this the last comment or do we display separator? ?>
                            <?php if ($i < $count) echo '<div class="hr">&nbsp;</div><br />'; ?>
<?php
++$i;
        }
?>
                    </div>
                </fieldset>
            </div>
        </div>
    </div>
</div>    
<div class="linksb">
    <div class="inbox">
        <p class="pagelink conl"><?php echo $paging_links ?></p>
        <ul><li><a href="blogs.php"><?php echo $lang_blog['Blogs'] ?></a>&nbsp;</li><li>&raquo;&nbsp;<?php echo $cat_name; ?></li></ul>
        <div class="clearer"></div>
    </div>
</div>
    
    
<?php    
    }    
}
if ($pop || $comm || $lat)//we show all blogs ordered by num_views, num_comments, or last posted
{
    if ((($pop) && ($comm >0 || $lat >0))
    || (($comm) && ($pop >0 || $lat >0))
    || (($lat) && ($comm >0 || $pop >0)))
        message($lang_common['Bad request']);    
    
    if ($pop){
        $order = num_views;
        $nav = "blogs.php?pop=";
        $head = ''.$lang_blog['Most viewed'].'';
        $case = ''.$lang_blog['Most viewed'].'';
    }
        
    if ($comm){
        $order = num_comments;
        $nav = "blogs.php?comm=";
        $head = ''.$lang_blog['Most commented'].'';
        $case = ''.$lang_blog['Most commented'].'';
    }
    if ($lat){
        $order = posted;
        $nav = "blogs.php?lat=";
        $case = ''.$lang_blog['Latest'].'';
        $head = ''.$lang_blog['Latest'].'&nbsp;&nbsp;&nbsp;<a href="blogs_rss.php"><img src="img/feed.gif" alt="RSS Feed/Latest Blogs" /></a>';
    }
    
    require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
    define('PUN_ALLOW_INDEX', 1);
    require_once PUN_ROOT.'include/parser.php';
    
    //$result = $db->query('SELECT b.* FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE b.cat_id =('.$cat_id.') && (p.read_cat IS NULL OR p.read_cat=1)  ORDER BY b.id DESC LIMIT 0 , 10') or error('Unable to fetch category info', __FILE__, __LINE__, $db->error());
    $result = $db->query('SELECT COUNT(b.id) FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE (p.read_cat IS NULL OR p.read_cat=1)') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
    $num_blogs = $db->result($result);

    // Determine the topic offset (based on $_GET['p'])
    $num_pages = ceil($num_blogs / $pun_user['disp_blogs']);

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

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

    $result = $db->query('SELECT b.* FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE (p.read_cat IS NULL OR p.read_cat=1) ORDER BY b.'.$order.' DESC LIMIT '.$start_from.', '.$pun_user['disp_blogs'].'') or error('Unable to fetch category info', __FILE__, __LINE__, $db->error());
    if (!$db->num_rows($result))
        message($lang_blog['No Blog']);    
    if ($db->num_rows($result)) 
    {
        $count = $db->num_rows($result);
        $i = 1;
        //$abc = 1;            
?>
<div class="linkst">
    <div class="inbox">
        <p class="pagelink conl"><?php echo $paging_links ?></p>
        <ul><li><a href="blogs.php"><?php echo $lang_blog['Blogs'] ?></a>&nbsp;</li><li>&raquo;&nbsp;<?php echo $case; ?></li></ul>
        <div class="clearer"></div>
    </div>
</div>
<div class="block">
    <div class="box">
        <div class="fakeform">
            <div class="block">
                <span class="blogcat"><span style="font-size:1.5em;"><?php echo $head; ?></span></span>
                <div class="clearer"></div>
            </div>
            <div class="inform">
                <fieldset>
                    <div class="infldset">

<?php        
                    
        while ($cur_blog = $db->fetch_assoc($result))
        {
            $post_actions = array();
            $post_actions[] = 'Posted by: '.pun_htmlspecialchars($cur_blog['poster']).'';
            $post_actions[] = ''.format_time($cur_blog['posted']).'';
            $post_actions[] = 'Views: '.$cur_blog['num_views'].'';
            $post_actions[] = '<span class="barlink"><a href="blogs.php?cid='.$cur_blog['id'].'&amp;c_id='.$cur_blog['id'].'">Comments</a>:&nbsp;'.$cur_blog['num_comments'].'</span>';

            $bid = $cur_blog['poster_id'];
            $id = $cur_blog['id'];
            $pre = parse_message($cur_blog['blog'], $cur_blog['hide_smilies']);

            // Trim the blog
            $str = truncate ($pre, $id);

?>
                        <div class="postmsg">

                            <p><strong><?php echo pun_htmlspecialchars($cur_blog['heading']) ?></strong></p>
                            <?php echo $str."\n" ?>
                            <br /><?php echo (count($post_actions)) ? ''.implode($lang_blog['Link separator'].'', $post_actions).''."\n" : ''."\n" ?>
                        </div>
                            <?php //Is this the last comment or do we display separator? ?>
                            <?php if ($i < $count) echo '<div class="hr">&nbsp;</div><br />'; ?>
<?php
++$i;
        }

?>
                    </div>
                </fieldset>
            </div>
        </div>
    </div>
</div>    
<div class="linkst">
    <div class="inbox">
        <p class="pagelink conl"><?php echo $paging_links ?></p>
        <ul><li><a href="blogs.php"><?php echo $lang_blog['Blogs'] ?></a>&nbsp;</li><li>&raquo;&nbsp;<?php echo $case ?></li></ul>
        <div class="clearer"></div>
    </div>
</div>
    
    
<?php    
    }    
}

require PUN_ROOT.'footer.php';

Offline

 

#37 2007-07-18 02:14:51

doki
Member
Registered: 2007-04-30
Posts: 225

Re: PBB User Blogs 1.2

Just upload it on the server...

Offline

 

#38 2007-07-18 02:19:46

doki
Member
Registered: 2007-04-30
Posts: 225

Re: PBB User Blogs 1.2

Thanks That solves the problem:)

By the way is this normal? the rss link

please check this link:

<removed>

Last edited by doki (2008-05-10 05:39:07)

Offline

 

#39 2007-07-18 02:23:57

soonotes
Member
Registered: 2006-09-21
Posts: 112

Re: PBB User Blogs 1.2

Thanks for bringing this up doki, glad it's working for you now.

The rss looks normal to me. It should display fine in IE7, current versions of Opera and FireFox as well as any rss reader. Does it not display properly for you?


For anyone else who has the issue there is a small change needed to blogs.php or blog_inc.php depending on which set you are using.

In blogs.php lines 494 to 500 and in blog_inc.php lines 319 to 325 find

Code:

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

        $post_actions = array();

        if (($cur_blog['poster_id'] == $pun_user['id']) && (!$is_admmod) && (!$pun_user['is_guest']))

and replace with

Code:

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

        $pt_actions = array();

        if (($blog['poster_id'] == $pun_user['id']) && (!$is_admmod) && (!$pun_user['is_guest']))

Offline

 

#40 2007-07-18 02:30:58

doki
Member
Registered: 2007-04-30
Posts: 225

Re: PBB User Blogs 1.2

Working great on ie7..and Its looks like this on firefox 2.0.0.4 and opera 9.21


Philippines : Blogs : doki
         
Philippines
     
PMAers Guide to Blower Fans in Articles :
INTRODUCTIONrev 1.0c by PMAerBlower Fans (or just plain fans), are part and parcel of our daily computing PC habits. From the near silent HTPCs (Home Theater PCs), to the roaring and raging OverClocker's delights, pushing their PCs to the hardware limits.This is due to the fact that most modern-day PCs need to be actively cooled using air, which is the easiest and most hassle-free way to cool down those components within. Passively-cooled heatsinks don't just cut it anymore. So a cool breeze running through one's case and heatsinks would be the cheapest and most effective way to tame the roaring temps of modern processors and video cards.This brings me to this discussion about blower fans. Their most commong properties, characteristics, proper usage, and tips on buying the right one for you.1. TYPES AND SIZESBlower fans for PC use normally come in a few pre-determined sizes. Since these fans have a square frame, the measurement that comes with each refers to the length of it's side.The metric unit used in this measurement is the millimeter (mm), with 1 inch being roughly equal to 27mm. Sizes then range from:1. 40x40mm - or 1.5 x 1.5 in-> Often seen in chipset heatsinks and in old videocards.2. 60x60mm - or 2 x 2 in-> Often used as exhausts of mATX cases, old ATX mid-towers, and as heatsink fans for Pentium III and old Athlon XP heatsinks.3. 70x70mm - or 2.5 x 2.5 in-> This fan size is what AMD uses as the stock fan for all their Athlon64, Sempron 64 and X2 stock heatsinks.4. 80x80mm - or 3 x 3 in-> This is the typical case fan size. Almost all PC cases nowadays have holes or provisions for at least one or two 80mm fans on them. Some aftermarket heatsinks also sport this fan size.5. 92x92mm - or 3.5 x 3.5 in-> Some high-end cases, noticeably the ones coming from Casetek use this fan size for case cooling. this is also the favorite fan size of high-end aftermarket heatsinks for the past years, only as of late have they been replaced by 120mm-fan heatsinks.6. 120x120mm - or 4 x 4 in-> This is the current best choice for enthusiasts. High-end cases often sport at least one 120mm in them, with the really huge towers accommodating up to 3 or 4. The best aftermarket heatsinks also use this fan size for cooling due to it's extremely large airflow. The Scythe Ninja and Thermaltake big Typhoon are examples of such.2. SPEED, AIRFLOW AND NOISEAs with all things in life, nothing comes free. This is the same with fan technology. The faster a fan spins, the more air it pushes, and consequently, the noisier it will get. That's one thing I have repeated dozens of times when responding to inquiries. Different people have different tolerances for noise, thus, it's important to obtain the fan that suits your noise-levels, while not scrimping on performance.Speed is measured in Rotations Per Minute (RPM). The higher the RPM of a fan, the more air it pushes, which leads me to..Airflow is measured in Cubic feet per Minute (CFM). This literally is a rate of how much cubic feet of air a fan can push while running for one minute. CFM can vary anywhere from 5-15cfm (for 40mm sizes) to as much as 150-200cfm (for those 120mm monsters). As such, the higher the CFM of a fan, the higher its noise level will be.Noise is measured in Decibel Amperes, or Decibels for short (dBA). The most often problem in measuring noise is that some manufacturers grossly "exaggerate" their claims on the noise levels (and sometimes airflow rate) of their fans, especially those catering to the general PC user populace. Industrial fan manufacturers meanwhile, cannot scrimp on this information since mission-critical applications and workplaces depend on these specs of theirs.Thus, the baseline I'll use is that of fans made by Delta Electronics, a well known industrial blower fan manufacturer whose fans often cater to high-end, high-speed PC enthusiasts.3. GENERAL AIRFLOW CATEGORIES5-10cfm- Only applicable to small 40mm fans. Hardly felt at all with larger fan sizes.20-30cfm- The normal range for most generic 80mm fans. Pretty weak, hardly felt on one's hand if exposed directly to the fan's airflow.45-50cfm- Fast 80mm fans are at this speed. Not too noisy, but very good for case cooling.- Medium speed 92mms.- Very slow and silent 120mms. Generic, Quad LED and UV Reactive 120mms are also found here60-75cfm- Ultra-fast 80mm fans, usually for aftermarket heatsinks. The Thermaltake Volcano 12 fan and Smart Case Fan 2 are at this level. Extremely noisy too.- Fast 92mms are found within this airflow rates. These are best used as heatsink fans. Good airflow at a tolerable noise level.- Slow-Medium speed 120mms are found here, as well as the top-end QuadLED and UVRs.75-90cfm- Extremely Fast 92mms.- Medium-speed 120mms. Best for cases or silent aftermarket heatsinks.90-110cfm- Ultra-speed 92mms. Extremely Fast. Extremely Noisy.- Fast 120mms. Medium noise levels. Best for high-performance heatsinks. Could be used as an alternative desk fan too. lol.120-150cfm- Very Fast 120mm fans are the only ones generally found in this bracket, as no readily available 92mm or lower-size fan can push such tremendous amounts of air. High Noise Levels at extremely fast speeds. Recommended only for those serious air-cooling addicts.4. AIR PRESSURE, FAN BLADES AND FAN DEPTHI grouped these three properties together since they're often the factors that affect one another.Air pressure - In layman's terms, air pressure is the measurement of how strong the airflow coming from the fan is, or how strong a fan can suck/push air. High air pressure is important when cooling restrictive environments, such as heatsinks with a lot of fins, or when trying to suck up air through fan filters. Having a higher air pressure will increase a fan's noise level a bit, with the tradeoff of having generally better performance.Fan blades - If you notice, fans often come with a multitude of blades to push air. The number of blades connected to the rotor mechanism ranges from 3 blades up to 9 blades (for standard 80-120mm models), and even up to 20 or more blades (for smaller size models). The number of blades directly affect how much air a fan can push and how much air pressure its airflow exerts. Having a lower number of blades would increase a fan's air pressure, while decreasing the fan's total airflow. While conversely, having more blades would increase a fan's airflow, while decreasing the air pressure it exerts.Fan depth - Fans aren't just stuck with the normal depth (or thickness) of 25mm which is the norm for case fans. The possible values range from 10mm (for those thin 40mm fans) up to 38 or even 76mm (for 120mm high-speed ones). Aside from the convenience of mounting thinner fans, the depth measurement also has a direct effect on the air pressure the fan exerts. The deeper a fan is, the more air pressure it exerts. The trade-off would be a little additional noise, as well as some mounting incompatibilities due to the bigger fan.So the rule of thumb would be, assuming equivalent rpm:A. The more blades a fan has, the less air pressure it exerts, while providing more airflow.B. The deeper a fan is, the more air pressure it exerts, while having a slightly higher noise level.As one could see, there's trend in all these.. with airflow, speed, air pressure and noise all balancing themselves out...

Last edited by doki (2008-08-09 21:36:46)

Offline

 

#41 2007-07-18 02:36:05

doki
Member
Registered: 2007-04-30
Posts: 225

Re: PBB User Blogs 1.2

rss works great also on safari .

Last edited by doki (2007-07-18 02:36:33)

Offline

 

#42 2007-07-18 02:36:23

soonotes
Member
Registered: 2006-09-21
Posts: 112

Re: PBB User Blogs 1.2

Yeah, it formats nicely in IE7 and Opera but not in FireFox. Not sure if it's a firefox issue or if something could be changed to have it display nicely in FF.

I'll have to look into that but if anyone is familiar with it please let us know.

Offline

 

#43 2007-07-18 02:38:30

soonotes
Member
Registered: 2006-09-21
Posts: 112

Re: PBB User Blogs 1.2

Working great on ie7..and Its looks like this on firefox 2.0.0.4 and opera 9.21

For it to display properly in Opera you have to subscribe to the feed.

Offline

 

#44 2007-07-18 02:39:16

doki
Member
Registered: 2007-04-30
Posts: 225

Re: PBB User Blogs 1.2

thanks a lot soonotes... I appreciate your help...

Offline

 

#45 2007-07-18 02:41:04

soonotes
Member
Registered: 2006-09-21
Posts: 112

Re: PBB User Blogs 1.2

It was my mistake. Thanks for pointing it out. smile

Offline

 

#46 2007-07-18 02:46:47

doki
Member
Registered: 2007-04-30
Posts: 225

Re: PBB User Blogs 1.2

By the way if the users will use the upload 2 they need to modify the include/blog.php on line 140

change:

Code:

$append = '&nbsp;...&nbsp;<span class="barlink"><i><a href="blog.php?cid='.$id.'&amp;c_id='.$id.'">Full&nbsp;Blog';

to:

Code:

$append = '&nbsp;...&nbsp;<span class="barlink"><i><a href="blogs.php?cid='.$id.'&amp;c_id='.$id.'">Full&nbsp;Blog';

this will not point the full blog link to blog.php

Last edited by doki (2007-07-18 02:52:29)

Offline

 

#47 2008-02-25 04:36:33

xia0fan
New member
Registered: 2008-02-25
Posts: 1

Re: PBB User Blogs 1.2

Can someone pls send me the affected files
index.php
##                    viewtopic.php
##                    profile.php
##                    userlist.php
##                    include/functions.php
##                    lang/English/profile.php
##                    lang/English/common.php
##                    lang/English/index.php
##                    profile.php
##                    style/imports/base.css
##                    style/*.css

Cos after modifying
the error msg "Unable to fetch information" still appear.
I want to know whr's the wrong part...

Thx

Offline

 

#48 2009-07-04 23:00:29

sspython
New member
Registered: 2009-07-04
Posts: 7

Re: PBB User Blogs 1.2

Bonjour,

J'ai actuellemnt installé Blog 1.2 avec le Upload 1 et il est impossible de pouvoir supprimé ou editer les blogs inscrit.
Pouvez-vous SVP me dire comment faire car c'est urgent.

Merci beaucoup et bonne continuation a tous
A bientot.

Offline

 

#49 2009-07-05 22:59:09

sspython
New member
Registered: 2009-07-04
Posts: 7

Re: PBB User Blogs 1.2

Up Please.

Offline

 

#50 2009-07-07 10:23:22

StevenBullen
Moderator
Registered: 2005-09-13
Posts: 300
Website

Re: PBB User Blogs 1.2

English?


Blog - Follow Me and FluxBB on Twitter

Offline

 

Board footer

Based on PunBB
© Copyright 2002–2005 Rickard Andersson

© Copyright 2004–2006 Kristoffer Jansson

User contributed files are property of their respective owners.