76

(8 replies, posted in PunBB 1.3 extensions)

Can't wait.

77

(20 replies, posted in PunBB 1.3 extensions)

Version 0.1 is ready for download:

http://fixpc.co.za/download/image_upload.zip

78

(20 replies, posted in PunBB 1.3 extensions)

OK, this is starting to make sense to me, I think.

It seems the basis of the extension system is this manifest.xml file:

<?xml version="1.0" encoding="UTF-8"?>
 
<extension engine="1.0">
  <id>example_extension</id>
  <title>Example Extension</title>
  <version>0.1</version>
  <description>This is a short description of the extension.</description>
  <author>John Doe</author>
  <minversion>1.3 Beta</minversion>
  <maxtestedon>1.3 Beta</maxtestedon>
  <dependencies>
    <dependency>another_extension</dependency>
  </dependencies>
  <note type="install">Add notes before the user installs the extension</note>
 
  <hooks>
    <hook id="vf_start"><![CDATA[
    // Include a file from the extension directory
    require $ext_info['path'].'/foobar.php';
    ]]></hook>
    <hook id="vf_pre_header_load"><![CDATA[
    // Call a function from foobar.php
    foobar_function();
    ]]></hook>
  </hooks>
</extension>

I think I can start working from here but before I do, please let me know if this template will work for PunBB 1.3. If not, what changes should I make?

79

(76 replies, posted in PunBB 1.3 extensions)

Great extension, been using it for a while now with no real problems, just two questions:

  • How do I re-enable showing only guest-readable topics/forums? I get a lot of spamy posts which I move to a folder only visible to admins and now these are getting indexed as well.

  • Google complains that redirected forums are duplicate pages, is there a way to avoid this?

80

(20 replies, posted in PunBB 1.3 extensions)

Thanks KeyDog. I'd really like to turn this into a proper extension, but I will need some help. I can't find any documentation for writing them. All I've figured out so far is that I need to use hooks.

81

(20 replies, posted in PunBB 1.3 extensions)

Slavok wrote:

Maybe you can create an extension which will be based on the code, you have posted above?

I'd like to, but would need a few pointers.

82

(20 replies, posted in PunBB 1.3 extensions)

esupergood wrote:

I think the other image upload is better for my needs.
Simpler integration, more minimal design, doesn't use my hosting or bandwidth.

Cool, never said it wasn't. This is the one I use.

83

(20 replies, posted in PunBB 1.3 extensions)

Version 0.1 is ready for download:

http://fixpc.co.za/download/image_upload.zip

I finally got around to upgrading the very basic, but fairly robust I think, Image Upload I was using on PunBB 1.2

It uses a very basic form:

//Image Upload 
<div>
<form target="_blank" action="upload.php" method="post"
enctype="multipart/form-data">
<input type="file"  name="file" id="file" /></div>
<div><input type="submit" name="submit" value="Upload Image" /></div>
</form>
</div>

Here is upload.php

<?php
$file = $_FILES["file"]["name"];
$filename = date(U).".gif";

if (($_FILES["file"]["type"] == "image/gif")
|| (($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/png")
&& ($_FILES["file"]["size"] < 200)))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    if (file_exists("images/" . $filename))
      {
      echo "<p>The System Is busy, please try again</p>";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "images/" . $filename);
      echo "</p>Success! your image has been uploaded!
             <br>If everything is working correctly you should see your image displayed below:
             <br><br><a href=images/" . $filename . "><img border=0 src=images/" . $filename . "></a></p>";
      }
    }
  }
else
  {
  echo "<p>Sorry, you can only upload <b>.jpg</b>, <b>.gif</b> or <b>.png</b> image files under 200 KB</p>";
  }
?>

You will need to create a directory called images and set the file permissions to 777.

It is set only to allow uploading of .jpg, .gif or .png image files under 200 KB.

The modified post.php (to include the upload form)

<?php
/**
 * Adds a new post to the specified topic or a new topic to the specified forum.
 *
 * @copyright Copyright (C) 2008 PunBB, partially based on code copyright (C) 2008 FluxBB.org
 * @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
 * @package PunBB
 */

define('FORUM_SKIP_CSRF_CONFIRM', 1);

if (!defined('FORUM_ROOT'))
    define('FORUM_ROOT', './');
require FORUM_ROOT.'include/common.php';

($hook = get_hook('po_start')) ? eval($hook) : null;

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

// Load the post.php language file
require FORUM_ROOT.'lang/'.$forum_user['language'].'/post.php';


$tid = isset($_GET['tid']) ? intval($_GET['tid']) : 0;
$fid = isset($_GET['fid']) ? intval($_GET['fid']) : 0;
if ($tid < 1 && $fid < 1 || $tid > 0 && $fid > 0)
    message($lang_common['Bad request']);


// Fetch some info about the topic and/or the forum
if ($tid)
{
    $query = array(
        'SELECT'    => 'f.id, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.subject, t.closed, s.user_id AS is_subscribed',
        'FROM'        => 'topics AS t',
        'JOINS'        => array(
            array(
                'INNER JOIN'    => 'forums AS f',
                'ON'            => 'f.id=t.forum_id'
            ),
            array(
                'LEFT JOIN'        => 'forum_perms AS fp',
                'ON'            => '(fp.forum_id=f.id AND fp.group_id='.$forum_user['g_id'].')'
            ),
            array(
                'LEFT JOIN'        => 'subscriptions AS s',
                'ON'            => '(t.id=s.topic_id AND s.user_id='.$forum_user['id'].')'
            )
        ),
        'WHERE'        => '(fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$tid
    );

    ($hook = get_hook('po_qr_get_topic_forum_info')) ? eval($hook) : null;
}
else
{
    $query = array(
        'SELECT'    => 'f.id, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics',
        'FROM'        => 'forums AS f',
        'JOINS'        => array(
            array(
                'LEFT JOIN'        => 'forum_perms AS fp',
                'ON'            => '(fp.forum_id=f.id AND fp.group_id='.$forum_user['g_id'].')'
            )
        ),
        'WHERE'        => '(fp.read_forum IS NULL OR fp.read_forum=1) AND f.id='.$fid
    );

    ($hook = get_hook('po_qr_get_forum_info')) ? eval($hook) : null;
}

$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);

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

$cur_posting = $forum_db->fetch_assoc($result);
$is_subscribed = $tid && $cur_posting['is_subscribed'];


// Is someone trying to post into a redirect forum?
if ($cur_posting['redirect_url'] != '')
    message($lang_common['Bad request']);

// Sort out who the moderators are and if we are currently a moderator (or an admin)
$mods_array = ($cur_posting['moderators'] != '') ? unserialize($cur_posting['moderators']) : array();
$forum_page['is_admmod'] = ($forum_user['g_id'] == FORUM_ADMIN || ($forum_user['g_moderator'] == '1' && array_key_exists($forum_user['username'], $mods_array))) ? true : false;

($hook = get_hook('po_pre_permission_check')) ? eval($hook) : null;

// Do we have permission to post?
if ((($tid && (($cur_posting['post_replies'] == '' && $forum_user['g_post_replies'] == '0') || $cur_posting['post_replies'] == '0')) ||
    ($fid && (($cur_posting['post_topics'] == '' && $forum_user['g_post_topics'] == '0') || $cur_posting['post_topics'] == '0')) ||
    (isset($cur_posting['closed']) && $cur_posting['closed'] == '1')) &&
    !$forum_page['is_admmod'])
    message($lang_common['No permission']);


($hook = get_hook('po_posting_location_selected')) ? eval($hook) : null;

// Start with a clean slate
$errors = array();

// Did someone just hit "Submit" or "Preview"?
if (isset($_POST['form_sent']))
{
    ($hook = get_hook('po_form_submitted')) ? eval($hook) : null;

    // Make sure form_user is correct
    if (($forum_user['is_guest'] && $_POST['form_user'] != 'Guest') || (!$forum_user['is_guest'] && $_POST['form_user'] != $forum_user['username']))
        message($lang_common['Bad request']);

    // Flood protection
    if (!isset($_POST['preview']) && $forum_user['last_post'] != '' && (time() - $forum_user['last_post']) < $forum_user['g_post_flood'] && (time() - $forum_user['last_post']) >= 0)
        $errors[] = sprintf($lang_post['Flood'], $forum_user['g_post_flood']);

    // If it's a new topic
    if ($fid)
    {
        $subject = forum_trim($_POST['req_subject']);

        if ($subject == '')
            $errors[] = $lang_post['No subject'];
        else if (utf8_strlen($subject) > 70)
            $errors[] = $lang_post['Too long subject'];
        else if ($forum_config['p_subject_all_caps'] == '0' && utf8_strtoupper($subject) == $subject && !$forum_page['is_admmod'])
            $errors[] = $lang_post['All caps subject'];
    }

    // If the user is logged in we get the username and e-mail from $forum_user
    if (!$forum_user['is_guest'])
    {
        $username = $forum_user['username'];
        $email = $forum_user['email'];
    }
    // Otherwise it should be in $_POST
    else
    {
        $username = forum_trim($_POST['req_username']);
        $email = strtolower(forum_trim(($forum_config['p_force_guest_email'] == '1') ? $_POST['req_email'] : $_POST['email']));

        // Load the profile.php language file
        require FORUM_ROOT.'lang/'.$forum_user['language'].'/profile.php';

        // It's a guest, so we have to validate the username
        $errors = array_merge($errors, validate_username($username));

        if ($forum_config['p_force_guest_email'] == '1' || $email != '')
        {
            if (!defined('FORUM_EMAIL_FUNCTIONS_LOADED'))
                require FORUM_ROOT.'include/email.php';

            if (!is_valid_email($email))
                $errors[] = $lang_post['Invalid e-mail'];
        }
    }

    // If we're an administrator or moderator, make sure the CSRF token in $_POST is valid
    if ($forum_user['is_admmod'] && (!isset($_POST['csrf_token']) || $_POST['csrf_token'] !== generate_form_token(get_current_url())))
        $errors[] = $lang_post['CSRF token mismatch'];

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

    if (strlen($message) > FORUM_MAX_POSTSIZE_BYTES)
        $errors[] = sprintf($lang_post['Too long message'], forum_number_format(strlen($message)), forum_number_format(FORUM_MAX_POSTSIZE_BYTES));
    else if ($forum_config['p_message_all_caps'] == '0' && utf8_strtoupper($message) == $message && !$forum_page['is_admmod'])
        $errors[] = $lang_post['All caps message'];

    // Validate BBCode syntax
    if ($forum_config['p_message_bbcode'] == '1' || $forum_config['o_make_links'] == '1')
    {
        if (!defined('FORUM_PARSER_LOADED'))
            require FORUM_ROOT.'include/parser.php';

        $message = preparse_bbcode($message, $errors);
    }

    if ($message == '')
        $errors[] = $lang_post['No message'];

    $hide_smilies = isset($_POST['hide_smilies']) ? 1 : 0;
    $subscribe = isset($_POST['subscribe']) ? 1 : 0;

    $now = time();

    ($hook = get_hook('po_end_validation')) ? eval($hook) : null;

    // Did everything go according to plan?
    if (empty($errors) && !isset($_POST['preview']))
    {
        // If it's a reply
        if ($tid)
        {
            $post_info = array(
                'is_guest'        => $forum_user['is_guest'],
                'poster'        => $username,
                'poster_id'        => $forum_user['id'],    // Always 1 for guest posts
                'poster_email'    => ($forum_user['is_guest'] && $email != '') ? $email : null,    // Always null for non-guest posts
                'subject'        => $cur_posting['subject'],
                'message'        => $message,
                'hide_smilies'    => $hide_smilies,
                'posted'        => $now,
                'subscr_action'    => ($forum_config['o_subscriptions'] == '1' && $subscribe && !$is_subscribed) ? 1 : (($forum_config['o_subscriptions'] == '1' && !$subscribe && $is_subscribed) ? 2 : 0),
                'topic_id'        => $tid,
                'forum_id'        => $cur_posting['id'],
                'update_user'    => true,
                'update_unread'    => true
            );

            ($hook = get_hook('po_pre_add_post')) ? eval($hook) : null;
            add_post($post_info, $new_pid);
        }
        // If it's a new topic
        else if ($fid)
        {
            $post_info = array(
                'is_guest'        => $forum_user['is_guest'],
                'poster'        => $username,
                'poster_id'        => $forum_user['id'],    // Always 1 for guest posts
                'poster_email'    => ($forum_user['is_guest'] && $email != '') ? $email : null,    // Always null for non-guest posts
                'subject'        => $subject,
                'message'        => $message,
                'hide_smilies'    => $hide_smilies,
                'posted'        => $now,
                'subscribe'        => ($forum_config['o_subscriptions'] == '1' && (isset($_POST['subscribe']) && $_POST['subscribe'] == '1')),
                'forum_id'        => $fid,
                'update_user'    => true,
                'update_unread'    => true
            );

            ($hook = get_hook('po_pre_add_topic')) ? eval($hook) : null;
            add_topic($post_info, $new_tid, $new_pid);
        }

        ($hook = get_hook('po_pre_redirect')) ? eval($hook) : null;

        redirect(forum_link($forum_url['post'], $new_pid), $lang_post['Post redirect']);
    }
}


// Are we quoting someone?
if ($tid && isset($_GET['qid']))
{
    $qid = intval($_GET['qid']);
    if ($qid < 1)
        message($lang_common['Bad request']);

    // Get the quote and quote poster
    $query = array(
        'SELECT'    => 'p.poster, p.message',
        'FROM'        => 'posts AS p',
        'WHERE'        => 'id='.$qid.' AND topic_id='.$tid
    );

    ($hook = get_hook('po_qr_get_quote')) ? eval($hook) : null;
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    if (!$forum_db->num_rows($result))
        message($lang_common['Bad request']);

    list($q_poster, $q_message) = $forum_db->fetch_row($result);

    if ($forum_config['p_message_bbcode'] == '1')
    {
        // If username contains a square bracket, we add "" or '' around it (so we know when it starts and ends)
        if (strpos($q_poster, '[') !== false || strpos($q_poster, ']') !== false)
        {
            if (strpos($q_poster, '\'') !== false)
                $q_poster = '"'.$q_poster.'"';
            else
                $q_poster = '\''.$q_poster.'\'';
        }
        else
        {
            // Get the characters at the start and end of $q_poster
            $ends = utf8_substr($q_poster, 0, 1).utf8_substr($q_poster, -1, 1);

            // Deal with quoting "Username" or 'Username' (becomes '"Username"' or "'Username'")
            if ($ends == '\'\'')
                $q_poster = '"'.$q_poster.'"';
            else if ($ends == '""')
                $q_poster = '\''.$q_poster.'\'';
        }

        $forum_page['quote'] = '[quote='.$q_poster.']'.$q_message.'[/quote]'."\n";
    }
    else
        $forum_page['quote'] = '> '.$q_poster.' '.$lang_common['wrote'].':'."\n\n".'> '.$q_message."\n";
}


// Setup form
$forum_page['group_count'] = $forum_page['item_count'] = $forum_page['fld_count'] = 0;
$forum_page['form_action'] = ($tid ? forum_link($forum_url['new_reply'], $tid) : forum_link($forum_url['new_topic'], $fid));
$forum_page['form_attributes'] = array();

$forum_page['hidden_fields'] = array(
    'form_sent'        => '<input type="hidden" name="form_sent" value="1" />',
    'form_user'        => '<input type="hidden" name="form_user" value="'.((!$forum_user['is_guest']) ? forum_htmlencode($forum_user['username']) : 'Guest').'" />',
    'csrf_token'    => '<input type="hidden" name="csrf_token" value="'.generate_form_token($forum_page['form_action']).'" />'
);

// Setup help
$forum_page['text_options'] = array();
if ($forum_config['p_message_bbcode'] == '1')
    $forum_page['text_options']['bbcode'] = '<span'.(empty($forum_page['text_options']) ? ' class="first-item"' : '').'><a class="exthelp" href="'.forum_link($forum_url['help'], 'bbcode').'" title="'.sprintf($lang_common['Help page'], $lang_common['BBCode']).'">'.$lang_common['BBCode'].'</a></span>';
if ($forum_config['p_message_img_tag'] == '1')
    $forum_page['text_options']['img'] = '<span'.(empty($forum_page['text_options']) ? ' class="first-item"' : '').'><a class="exthelp" href="'.forum_link($forum_url['help'], 'img').'" title="'.sprintf($lang_common['Help page'], $lang_common['Images']).'">'.$lang_common['Images'].'</a></span>';
if ($forum_config['o_smilies'] == '1')
    $forum_page['text_options']['smilies'] = '<span'.(empty($forum_page['text_options']) ? ' class="first-item"' : '').'><a class="exthelp" href="'.forum_link($forum_url['help'], 'smilies').'" title="'.sprintf($lang_common['Help page'], $lang_common['Smilies']).'">'.$lang_common['Smilies'].'</a></span>';

// Setup breadcrumbs
$forum_page['crumbs'][] = array($forum_config['o_board_title'], forum_link($forum_url['index']));
$forum_page['crumbs'][] = array($cur_posting['forum_name'], forum_link($forum_url['forum'], array($cur_posting['id'], sef_friendly($cur_posting['forum_name']))));
if ($tid)
    $forum_page['crumbs'][] = array($cur_posting['subject'], forum_link($forum_url['topic'], array($tid, sef_friendly($cur_posting['subject']))));
$forum_page['crumbs'][] = $tid ? $lang_post['Post reply'] : $lang_post['Post new topic'];

($hook = get_hook('po_pre_header_load')) ? eval($hook) : null;

define('FORUM_PAGE', 'post');
require FORUM_ROOT.'header.php';

// START SUBST - <!-- forum_main -->
ob_start();

($hook = get_hook('po_main_output_start')) ? eval($hook) : null;

?>
    <div class="main-head">
        <h2 class="hn"><span><?php echo $tid ? $lang_post['Post reply'] : $lang_post['Post new topic'] ?></span></h2>
    </div>
<?php

// If preview selected and there are no errors
if (isset($_POST['preview']) && empty($errors))
{
    if (!defined('FORUM_PARSER_LOADED'))
        require FORUM_ROOT.'include/parser.php';

    $forum_page['preview_message'] = parse_message(forum_trim($message), $hide_smilies);

    // Generate the post heading
    $forum_page['post_ident'] = array();
    $forum_page['post_ident']['num'] = '<span class="post-num">#</span>';
    $forum_page['post_ident']['byline'] = '<span class="post-byline">'.sprintf((($tid) ? $lang_post['Reply byline'] : $lang_post['Topic byline']), '<strong>'.forum_htmlencode($forum_user['username']).'</strong>').'</span>';
    $forum_page['post_ident']['link'] = '<span class="post-link">'.format_time(time()).'</span>';

    ($hook = get_hook('po_preview_pre_display')) ? eval($hook) : null;

?>
    <div class="main-subhead">
        <h2 class="hn"><span><?php echo $tid ? $lang_post['Preview reply'] : $lang_post['Preview new topic']; ?></span></h2>
    </div>
    <div id="post-preview" class="main-content main-frm">
        <div class="post singlepost">
            <div class="posthead">
                <h3 class="hn"><?php echo implode(' ', $forum_page['post_ident']) ?></h3>
<?php ($hook = get_hook('po_preview_new_post_head_option')) ? eval($hook) : null; ?>
            </div>
            <div class="postbody">
                <div class="post-entry">
                    <div class="entry-content">
                        <?php echo $forum_page['preview_message']."\n" ?>
                    </div>
<?php ($hook = get_hook('po_preview_new_post_entry_data')) ? eval($hook) : null; ?>
                </div>
            </div>
        </div>
    </div>
<?php

}

?>
    <div class="main-subhead">
        <h2 class="hn"><span><?php echo ($tid) ? $lang_post['Compose your reply'] : $lang_post['Compose your topic'] ?></span></h2>
    </div>
    <div id="post-form" class="main-content main-frm">
<?php

    if (!empty($forum_page['text_options']))
        echo "\t\t".'<p class="ct-options options">'.sprintf($lang_common['You may use'], implode(' ', $forum_page['text_options'])).'</p>'."\n";

    // If there were any errors, show them
    if (!empty($errors))
    {
        $forum_page['errors'] = array();
        foreach ($errors as $cur_error)
            $forum_page['errors'][] = '<li class="warn"><span>'.$cur_error.'</span></li>';

        ($hook = get_hook('po_pre_post_errors')) ? eval($hook) : null;

?>
        <div class="ct-box error-box">
            <h2 class="warn hn"><?php echo $lang_post['Post errors'] ?></h2>
            <ul class="error-list">
                <?php echo implode("\n\t\t\t\t", $forum_page['errors'])."\n" ?>
            </ul>
        </div>
<?php

    }

?>
        <div id="req-msg" class="req-warn ct-box error-box">
            <p><?php printf($lang_common['Required warn'], '<em>'.$lang_common['Required'].'</em>') ?></p>
        </div>
        <form id="afocus" class="frm-form" method="post" accept-charset="utf-8" action="<?php echo $forum_page['form_action'] ?>"<?php if (!empty($forum_page['form_attributes'])) echo ' '.implode(' ', $forum_page['form_attributes']) ?>>
            <div class="hidden">
                <?php echo implode("\n\t\t\t\t", $forum_page['hidden_fields'])."\n" ?>
            </div>
<?php

if ($forum_user['is_guest'])
{
    $forum_page['email_form_name'] = ($forum_config['p_force_guest_email'] == '1') ? 'req_email' : 'email';

    ($hook = get_hook('po_pre_guest_info_fieldset')) ? eval($hook) : null;

?>
            <fieldset class="frm-group group<?php echo ++$forum_page['group_count'] ?>">
                <legend class="group-legend"><strong><?php echo $lang_post['Guest post legend'] ?></strong></legend>
<?php ($hook = get_hook('po_pre_guest_username')) ? eval($hook) : null; ?>
                <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
                    <div class="sf-box text required">
                        <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_post['Guest name'] ?> <em><?php echo $lang_common['Required'] ?></em></span></label><br />
                        <span class="fld-input"><input type="text" id="fld<?php echo $forum_page['fld_count'] ?>" name="req_username" value="<?php if (isset($_POST['req_username'])) echo forum_htmlencode($username); ?>" size="35" maxlength="25" /></span>
                    </div>
                </div>
<?php ($hook = get_hook('po_pre_guest_email')) ? eval($hook) : null; ?>
                <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
                    <div class="sf-box text<?php if ($forum_config['p_force_guest_email'] == '1') echo ' required' ?>">
                        <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_post['Guest e-mail'] ?><?php if ($forum_config['p_force_guest_email'] == '1') echo ' <em>'.$lang_common['Required'].'</em>' ?></span></label><br />
                        <span class="fld-input"><input type="text" id="fld<?php echo $forum_page['fld_count'] ?>" name="<?php echo $forum_page['email_form_name'] ?>" value="<?php if (isset($_POST[$forum_page['email_form_name']])) echo forum_htmlencode($email); ?>" size="35" maxlength="80" /></span>
                    </div>
                </div>
<?php ($hook = get_hook('po_pre_guest_info_fieldset_end')) ? eval($hook) : null; ?>
            </fieldset>
<?php

    ($hook = get_hook('po_guest_info_fieldset_end')) ? eval($hook) : null;

    // Reset counters
    $forum_page['group_count'] = $forum_page['item_count'] = 0;
}

($hook = get_hook('po_pre_req_info_fieldset')) ? eval($hook) : null;

?>
            <fieldset class="frm-group group<?php echo ++$forum_page['group_count'] ?>">
                <legend class="group-legend"><strong><?php echo $lang_common['Required information'] ?></strong></legend>
<?php

if ($fid)
{
    ($hook = get_hook('po_pre_req_subject')) ? eval($hook) : null;

?>
                <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
                    <div class="sf-box text required longtext">
                        <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_post['Topic subject'] ?> <em><?php echo $lang_common['Required'] ?></em></span></label><br />
                        <span class="fld-input"><input id="fld<?php echo $forum_page['fld_count'] ?>" type="text" name="req_subject" value="<?php if (isset($_POST['req_subject'])) echo forum_htmlencode($subject); ?>" size="80" maxlength="70" /></span>
                    </div>
                </div>
<?php

}

($hook = get_hook('po_pre_post_contents')) ? eval($hook) : null;

?>
                <div class="txt-set set<?php echo ++$forum_page['item_count'] ?>">
                    <div class="txt-box textarea required">
                        <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_post['Write message'] ?> <em><?php echo $lang_common['Required'] ?></em></span></label>
                        <div class="txt-input"><span class="fld-input"><textarea id="fld<?php echo $forum_page['fld_count'] ?>" name="req_message" rows="14" cols="95"><?php echo isset($_POST['req_message']) ? forum_htmlencode($message) : (isset($forum_page['quote']) ? forum_htmlencode($forum_page['quote']) : ''); ?></textarea></span></div>
                    </div>
                </div>
<?php

$forum_page['checkboxes'] = array();
if ($forum_config['o_smilies'] == '1')
    $forum_page['checkboxes']['hide_smilies'] = '<div class="mf-item"><span class="fld-input"><input type="checkbox" id="fld'.(++$forum_page['fld_count']).'" name="hide_smilies" value="1"'.(isset($_POST['hide_smilies']) ? ' checked="checked"' : '').' /></span> <label for="fld'.$forum_page['fld_count'].'">'.$lang_post['Hide smilies'].'</label></div>';

// Check/uncheck the checkbox for subscriptions depending on scenario
if (!$forum_user['is_guest'] && $forum_config['o_subscriptions'] == '1')
{
    $subscr_checked = false;

    // If it's a preview
    if (isset($_POST['preview']))
        $subscr_checked = isset($_POST['subscribe']) ? true : false;
    // If auto subscribed
    else if ($forum_user['auto_notify'])
        $subscr_checked = true;
    // If already subscribed to the topic
    else if ($is_subscribed)
        $subscr_checked = true;

    $forum_page['checkboxes']['subscribe'] = '<div class="mf-item"><span class="fld-input"><input type="checkbox" id="fld'.(++$forum_page['fld_count']).'" name="subscribe" value="1"'.($subscr_checked ? ' checked="checked"' : '').' /></span> <label for="fld'.$forum_page['fld_count'].'">'.($is_subscribed ? $lang_post['Stay subscribed'] : $lang_post['Subscribe']).'</label></div>';
}

($hook = get_hook('po_pre_optional_fieldset')) ? eval($hook) : null;

if (!empty($forum_page['checkboxes']))
{

?>
                <fieldset class="mf-set set<?php echo ++$forum_page['item_count'] ?>">
                    <legend><span><?php echo $lang_post['Post settings'] ?></span></legend>
                    <div class="mf-box checkbox">
                        <?php echo implode("\n\t\t\t\t\t", $forum_page['checkboxes'])."\n"; ?>
                    </div>
<?php ($hook = get_hook('po_pre_checkbox_fieldset_end')) ? eval($hook) : null; ?>
                </fieldset>
<?php

}

($hook = get_hook('po_pre_req_info_fieldset_end')) ? eval($hook) : null;

?>
            </fieldset>
<?php

($hook = get_hook('po_req_info_fieldset_end')) ? eval($hook) : null;

?>
            <div class="frm-buttons">
                <span class="submit"><input type="submit" name="submit" value="<?php echo ($tid) ? $lang_post['Submit reply'] : $lang_post['Submit topic'] ?>" /></span>
                <span class="submit"><input type="submit" name="preview" value="<?php echo ($tid) ? $lang_post['Preview reply'] : $lang_post['Preview topic'] ?>" /></span>
            </div>
            </form>
            
    //Image Upload        
            <div class="frm-buttons">
            <div>
            <form target="_blank" action="upload.php" method="post"
            enctype="multipart/form-data">
            <input type="file"  name="file" id="file" /></div>
            <div><input type="submit" name="submit" value="Upload Image" /></div>
            </form>
            </div>
    </div>
<?php


// Check if the topic review is to be displayed
if ($tid && $forum_config['o_topic_review'] != '0')
{
    if (!defined('FORUM_PARSER_LOADED'))
        require FORUM_ROOT.'include/parser.php';

    // Get posts to display in topic review
    $query = array(
        'SELECT'    => 'p.id, p.poster, p.message, p.hide_smilies, p.posted',
        'FROM'        => 'posts AS p',
        'WHERE'        => 'topic_id='.$tid,
        'ORDER BY'    =>    'id DESC',
        'LIMIT'        =>    $forum_config['o_topic_review']
    );

    ($hook = get_hook('po_topic_review_qr_get_topic_review_posts')) ? eval($hook) : null;
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);

?>
    <div class="main-subhead">
        <h2 class="hn"><span><?php echo $lang_post['Topic review'] ?></span></h2>
    </div>
    <div id="topic-review" class="main-content main-frm">
<?php

    $forum_page['item_count'] = 0;
    $forum_page['item_total'] = $forum_db->num_rows($result);
    $forum_page['author_title'] = '';

    while ($cur_post = $forum_db->fetch_assoc($result))
    {
        ++$forum_page['item_count'];

        // Generate the post heading
        $forum_page['post_ident'] = array(
            'num'    => '<span class="post-num">'.forum_number_format($forum_page['item_count']).'</span>',
            'link'    => '<span class="post-link">'.sprintf($lang_post['Post posted'], '<a class="permalink" rel="bookmark" title="'.$lang_post['Permalink post'].'" href="'.forum_link($forum_url['post'], $cur_post['id']).'">'.format_time($cur_post['posted']).'</a>').'</span>'
        );

        ($hook = get_hook('po_topic_review_pre_item_indent_merge')) ? eval($hook) : null;

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

        // Generate the post heading
        $forum_page['post_ident'] = array();
        $forum_page['post_ident']['num'] = '<span class="post-num">'.forum_number_format($forum_page['item_count']).'</span>';
        $forum_page['post_ident']['byline'] = '<span class="post-byline">'.sprintf($lang_post['Post byline'], '<strong>'.forum_htmlencode($cur_post['poster']).'</strong>').'</span>';
        $forum_page['post_ident']['link'] = '<span class="post-link"><a class="permalink" rel="bookmark" title="'.$lang_post['Permalink post'].'" href="'.forum_link($forum_url['post'], $cur_post['id']).'">'.format_time($cur_post['posted']).'</a></span>';

        ($hook = get_hook('po_topic_review_row_pre_display')) ? eval($hook) : null;

?>
        <div class="post<?php echo ($forum_page['item_count'] == 1) ? ' firstpost' : '' ?><?php echo ($forum_page['item_total'] == $forum_page['item_count']) ? ' lastpost' : '' ?>">
            <div class="posthead">
                <h3 class="hn post-ident"><?php echo implode(' ', $forum_page['post_ident']) ?></h3>
<?php ($hook = get_hook('po_topic_review_new_post_head_option')) ? eval($hook) : null; ?>
            </div>
            <div class="postbody">
                <div class="post-entry">
                    <div class="entry-content">
                        <?php echo $forum_page['message']."\n" ?>
<?php ($hook = get_hook('po_topic_review_new_post_entry_data')) ? eval($hook) : null; ?>
                    </div>
                </div>
            </div>
        </div>
<?php

    }

?>
    </div>
<?php

}

$forum_id = $cur_posting['id'];

($hook = get_hook('po_end')) ? eval($hook) : null;

$tpl_temp = forum_trim(ob_get_contents());
$tpl_main = str_replace('<!-- forum_main -->', $tpl_temp, $tpl_main);
ob_end_clean();
// END SUBST - <!-- forum_main -->

require FORUM_ROOT.'footer.php';

Here's a screenshot:

http://adsbb.co.za/free_image_hosting/1236642716.gif
free image hosting

I have updated PunMarks to work with version 1.3

http://adsbb.co.za/viewtopic.php?id=1261

85

(55 replies, posted in Supported extensions)

Just realised, tags applied to topics in forums not visible to guests are still visible to guests. If a guest clicks on the tag the topic is listed, but when the guest clicks on the topic they get:

Bad request. The link you followed is incorrect or outdated.

Is there a way to fix this please?

Also the searches seem to be backwards, oldest topics on top. Is this deliberate?

86

(55 replies, posted in Supported extensions)

Awesome extension! Been looking for something like this for a while now. Thanks so much. big_smile

Any chance of a "See more tags" button?

87

(1 replies, posted in Discussions)

I'd like to start a 1:1 Banner Exchange exclusively for PunBB powered sites.

I recently set up a South African banner exchange program using phpBannerExchange 2.0 here:

http://adsbb.co.za/bannerexchange/

Before I start on this project though, I'd like to gauge the level of interest and find out what size banner would be most appropriate.

Thanks.

88

(0 replies, posted in Feature requests)

The new forum and topic feeds are great! I'd really love it if a search feed was included in the next version. smile

BTW is there any way to clean up the BBCode?

I was thinking, now that the pun_antispam extension is working, it might be useful if it was possible to allow guests to send forum e-mail to registered users. A setting that then allows users to disable this feature would be useful too.

90

(154 replies, posted in Supported extensions)

Is there a way to allow guests to send private messages to registered users without registering themselves and can the pun_antispam captcha be enabled in this case? If this becomes a feature it will be great if the users can disable it too.

http://adsbb.com/free_image_hosting/1201446684.gif
free image hosting

PunMarks was designed for PunBB, but will work on just about any website or Blog:

http://adsbb.com/viewtopic.php?id=381

ViewPage Mod - an easy way to insert HTML into your PunBB forum

Here's an example of how it's used:

http://adsbb.com/viewpage.php?p=pay-per-play.php

You can download this mod here:

http://adsbb.com/viewpage.php

I just modified the parser.php file to include PunBox support:

To display a PunBox in one of your posts:

[punbox=356]

Here's an example:

http://adsbb.com/viewtopic.php?id=357

Thanks for the interest smile
At what point are you getting stuck?

I've only added:

<?php 
// Loads Image Upload - free image hosting by AdsBB
include("http://adsbb.com/free_image_hosting/index.html");
 ?>

Here is my post.php:

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

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

  This file is part of PunBB.

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

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

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

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


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


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


$tid = isset($_GET['tid']) ? intval($_GET['tid']) : 0;
$fid = isset($_GET['fid']) ? intval($_GET['fid']) : 0;
if ($tid < 1 && $fid < 1 || $tid > 0 && $fid > 0)
    message($lang_common['Bad request']);

// Fetch some info about the topic and/or the forum
if ($tid)
    $result = $db->query('SELECT f.id, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.subject, t.closed FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$tid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
else
    $result = $db->query('SELECT f.id, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics FROM '.$db->prefix.'forums AS f LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.id='.$fid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());

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

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

// Is someone trying to post into a redirect forum?
if ($cur_posting['redirect_url'] != '')
    message($lang_common['Bad request']);

// Sort out who the moderators are and if we are currently a moderator (or an admin)
$mods_array = ($cur_posting['moderators'] != '') ? unserialize($cur_posting['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;

// Do we have permission to post?
if ((($tid && (($cur_posting['post_replies'] == '' && $pun_user['g_post_replies'] == '0') || $cur_posting['post_replies'] == '0')) ||
    ($fid && (($cur_posting['post_topics'] == '' && $pun_user['g_post_topics'] == '0') || $cur_posting['post_topics'] == '0')) ||
    (isset($cur_posting['closed']) && $cur_posting['closed'] == '1')) &&
    !$is_admmod)
    message($lang_common['No permission']);

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

// Start with a clean slate
$errors = array();


// 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 ($fid)
    {
        $subject = pun_trim($_POST['req_subject']);

        if ($subject == '')
            $errors[] = $lang_post['No subject'];
        else if (pun_strlen($subject) > 70)
            $errors[] = $lang_post['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 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_post['No message'];
    else if (strlen($message) > 65535)
        $errors[] = $lang_post['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 PUN_ROOT.'include/parser.php';
        $message = preparse_bbcode($message, $errors);
    }


    require PUN_ROOT.'include/search_idx.php';

    $hide_smilies = isset($_POST['hide_smilies']) ? 1 : 0;
    $subscribe = isset($_POST['subscribe']) ? 1 : 0;

    $now = time();

    // Did everything go according to plan?
    if (empty($errors) && !isset($_POST['preview']))
    {
        // If it's a reply
        if ($tid)
        {
            if (!$pun_user['is_guest'])
            {
                // Insert the new post
                $db->query('INSERT INTO '.$db->prefix.'posts (poster, poster_id, poster_ip, message, hide_smilies, posted, topic_id) VALUES(\''.$db->escape($username).'\', '.$pun_user['id'].', \''.get_remote_address().'\', \''.$db->escape($message).'\', \''.$hide_smilies.'\', '.$now.', '.$tid.')') or error('Unable to create post', __FILE__, __LINE__, $db->error());
                $new_pid = $db->insert_id();

                // To subscribe or not to subscribe, that ...
                if ($pun_config['o_subscriptions'] == '1' && $subscribe)
                {
                    $result = $db->query('SELECT 1 FROM '.$db->prefix.'subscriptions WHERE user_id='.$pun_user['id'].' AND topic_id='.$tid) or error('Unable to fetch subscription info', __FILE__, __LINE__, $db->error());
                    if (!$db->num_rows($result))
                        $db->query('INSERT INTO '.$db->prefix.'subscriptions (user_id, topic_id) VALUES('.$pun_user['id'].' ,'.$tid.')') or error('Unable to add subscription', __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.'posts (poster, poster_ip, poster_email, message, hide_smilies, posted, topic_id) VALUES(\''.$db->escape($username).'\', \''.get_remote_address().'\', '.$email_sql.', \''.$db->escape($message).'\', \''.$hide_smilies.'\', '.$now.', '.$tid.')') or error('Unable to create post', __FILE__, __LINE__, $db->error());
                $new_pid = $db->insert_id();
            }

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

            // Update topic
            $db->query('UPDATE '.$db->prefix.'topics SET num_replies='.$num_replies.', last_post='.$now.', last_post_id='.$new_pid.', last_poster=\''.$db->escape($username).'\' WHERE id='.$tid) or error('Unable to update topic', __FILE__, __LINE__, $db->error());

            update_search_index('post', $new_pid, $message);

            update_forum($cur_posting['id']);

            // Should we send out notifications?
            if ($pun_config['o_subscriptions'] == '1')
            {
                // Get the post time for the previous post in this topic
                $result = $db->query('SELECT posted FROM '.$db->prefix.'posts WHERE topic_id='.$tid.' ORDER BY id DESC LIMIT 1, 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
                $previous_post_time = $db->result($result);

                // Get any subscribed users that should be notified (banned users are excluded)
                $result = $db->query('SELECT u.id, u.email, u.notify_with_post, u.language FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'subscriptions AS s ON u.id=s.user_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id='.$cur_posting['id'].' AND fp.group_id=u.group_id) LEFT JOIN '.$db->prefix.'online AS o ON u.id=o.user_id LEFT JOIN '.$db->prefix.'bans AS b ON u.username=b.username WHERE b.username IS NULL AND COALESCE(o.logged, u.last_visit)>'.$previous_post_time.' AND (fp.read_forum IS NULL OR fp.read_forum=1) AND s.topic_id='.$tid.' AND u.id!='.intval($pun_user['id'])) or error('Unable to fetch subscription info', __FILE__, __LINE__, $db->error());
                if ($db->num_rows($result))
                {
                    require_once PUN_ROOT.'include/email.php';

                    $notification_emails = array();

                    // Loop through subscribed users and send e-mails
                    while ($cur_subscriber = $db->fetch_assoc($result))
                    {
                        // Is the subscription e-mail for $cur_subscriber['language'] cached or not?
                        if (!isset($notification_emails[$cur_subscriber['language']]))
                        {
                            if (file_exists(PUN_ROOT.'lang/'.$cur_subscriber['language'].'/mail_templates/new_reply.tpl'))
                            {
                                // Load the "new reply" template
                                $mail_tpl = trim(file_get_contents(PUN_ROOT.'lang/'.$cur_subscriber['language'].'/mail_templates/new_reply.tpl'));

                                // Load the "new reply full" template (with post included)
                                $mail_tpl_full = trim(file_get_contents(PUN_ROOT.'lang/'.$cur_subscriber['language'].'/mail_templates/new_reply_full.tpl'));

                                // The first row contains the subject (it also starts with "Subject:")
                                $first_crlf = strpos($mail_tpl, "\n");
                                $mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8));
                                $mail_message = trim(substr($mail_tpl, $first_crlf));

                                $first_crlf = strpos($mail_tpl_full, "\n");
                                $mail_subject_full = trim(substr($mail_tpl_full, 8, $first_crlf-8));
                                $mail_message_full = trim(substr($mail_tpl_full, $first_crlf));

                                $mail_subject = str_replace('<topic_subject>', '\''.$cur_posting['subject'].'\'', $mail_subject);
                                $mail_message = str_replace('<topic_subject>', '\''.$cur_posting['subject'].'\'', $mail_message);
                                $mail_message = str_replace('<replier>', $username, $mail_message);
                                $mail_message = str_replace('<post_url>', $pun_config['o_base_url'].'/viewtopic.php?pid='.$new_pid.'#p'.$new_pid, $mail_message);
                                $mail_message = str_replace('<unsubscribe_url>', $pun_config['o_base_url'].'/misc.php?unsubscribe='.$tid, $mail_message);
                                $mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'].' '.$lang_common['Mailer'], $mail_message);

                                $mail_subject_full = str_replace('<topic_subject>', '\''.$cur_posting['subject'].'\'', $mail_subject_full);
                                $mail_message_full = str_replace('<topic_subject>', '\''.$cur_posting['subject'].'\'', $mail_message_full);
                                $mail_message_full = str_replace('<replier>', $username, $mail_message_full);
                                $mail_message_full = str_replace('<message>', $message, $mail_message_full);
                                $mail_message_full = str_replace('<post_url>', $pun_config['o_base_url'].'/viewtopic.php?pid='.$new_pid.'#p'.$new_pid, $mail_message_full);
                                $mail_message_full = str_replace('<unsubscribe_url>', $pun_config['o_base_url'].'/misc.php?unsubscribe='.$tid, $mail_message_full);
                                $mail_message_full = str_replace('<board_mailer>', $pun_config['o_board_title'].' '.$lang_common['Mailer'], $mail_message_full);

                                $notification_emails[$cur_subscriber['language']][0] = $mail_subject;
                                $notification_emails[$cur_subscriber['language']][1] = $mail_message;
                                $notification_emails[$cur_subscriber['language']][2] = $mail_subject_full;
                                $notification_emails[$cur_subscriber['language']][3] = $mail_message_full;

                                $mail_subject = $mail_message = $mail_subject_full = $mail_message_full = null;
                            }
                        }

                        // We have to double check here because the templates could be missing
                        if (isset($notification_emails[$cur_subscriber['language']]))
                        {
                            if ($cur_subscriber['notify_with_post'] == '0')
                                pun_mail($cur_subscriber['email'], $notification_emails[$cur_subscriber['language']][0], $notification_emails[$cur_subscriber['language']][1]);
                            else
                                pun_mail($cur_subscriber['email'], $notification_emails[$cur_subscriber['language']][2], $notification_emails[$cur_subscriber['language']][3]);
                        }
                    }
                }
            }
        }
        // If it's a new topic
        else if ($fid)
        {
            // Create the topic
            $db->query('INSERT INTO '.$db->prefix.'topics (poster, subject, posted, last_post, last_poster, forum_id) VALUES(\''.$db->escape($username).'\', \''.$db->escape($subject).'\', '.$now.', '.$now.', \''.$db->escape($username).'\', '.$fid.')') or error('Unable to create topic', __FILE__, __LINE__, $db->error());
            $new_tid = $db->insert_id();

            if (!$pun_user['is_guest'])
            {
                // To subscribe or not to subscribe, that ...
                if ($pun_config['o_subscriptions'] == '1' && (isset($_POST['subscribe']) && $_POST['subscribe'] == '1'))
                    $db->query('INSERT INTO '.$db->prefix.'subscriptions (user_id, topic_id) VALUES('.$pun_user['id'].' ,'.$new_tid.')') or error('Unable to add subscription', __FILE__, __LINE__, $db->error());

                // Create the post ("topic post")
                $db->query('INSERT INTO '.$db->prefix.'posts (poster, poster_id, poster_ip, message, hide_smilies, posted, topic_id) VALUES(\''.$db->escape($username).'\', '.$pun_user['id'].', \''.get_remote_address().'\', \''.$db->escape($message).'\', \''.$hide_smilies.'\', '.$now.', '.$new_tid.')') or error('Unable to create post', __FILE__, __LINE__, $db->error());
            }
            else
            {
                // Create the post ("topic post")
                $email_sql = ($pun_config['p_force_guest_email'] == '1' || $email != '') ? '\''.$email.'\'' : 'NULL';
                $db->query('INSERT INTO '.$db->prefix.'posts (poster, poster_ip, poster_email, message, hide_smilies, posted, topic_id) VALUES(\''.$db->escape($username).'\', \''.get_remote_address().'\', '.$email_sql.', \''.$db->escape($message).'\', \''.$hide_smilies.'\', '.$now.', '.$new_tid.')') or error('Unable to create post', __FILE__, __LINE__, $db->error());
            }
            $new_pid = $db->insert_id();

            // Update the topic with last_post_id
            $db->query('UPDATE '.$db->prefix.'topics SET last_post_id='.$new_pid.' WHERE id='.$new_tid) or error('Unable to update topic', __FILE__, __LINE__, $db->error());

            update_search_index('post', $new_pid, $message, $subject);

            update_forum($fid);
        }

        // If the posting user is logged in, increment his/her post count
        if (!$pun_user['is_guest'])
        {
            $low_prio = ($db_type == 'mysql') ? 'LOW_PRIORITY ' : '';
            $db->query('UPDATE '.$low_prio.$db->prefix.'users SET num_posts=num_posts+1, last_post='.$now.' WHERE id='.$pun_user['id']) or error('Unable to update user', __FILE__, __LINE__, $db->error());
        }

        redirect('viewtopic.php?pid='.$new_pid.'#p'.$new_pid, $lang_post['Post redirect']);
    }
}


// If a topic id was specified in the url (it's a reply).
if ($tid)
{
    $action = $lang_post['Post a reply'];
    $form = '<form id="post" method="post" action="post.php?action=post&tid='.$tid.'" onsubmit="this.submit.disabled=true;if(process_form(this)){return true;}else{this.submit.disabled=false;return false;}">';

    // If a quote-id was specified in the url.
    if (isset($_GET['qid']))
    {
        $qid = intval($_GET['qid']);
        if ($qid < 1)
            message($lang_common['Bad request']);

        $result = $db->query('SELECT poster, message FROM '.$db->prefix.'posts WHERE id='.$qid.' AND topic_id='.$tid) or error('Unable to fetch quote info', __FILE__, __LINE__, $db->error());
        if (!$db->num_rows($result))
            message($lang_common['Bad request']);

        list($q_poster, $q_message) = $db->fetch_row($result);

        $q_message = str_replace('[img]', '[url]', $q_message);
        $q_message = str_replace('[/img]', '[/url]', $q_message);
        $q_message = pun_htmlspecialchars($q_message);

        if ($pun_config['p_message_bbcode'] == '1')
        {
            // If username contains a square bracket, we add "" or '' around it (so we know when it starts and ends)
            if (strpos($q_poster, '[') !== false || strpos($q_poster, ']') !== false)
            {
                if (strpos($q_poster, '\'') !== false)
                    $q_poster = '"'.$q_poster.'"';
                else
                    $q_poster = '\''.$q_poster.'\'';
            }
            else
            {
                // Get the characters at the start and end of $q_poster
                $ends = substr($q_poster, 0, 1).substr($q_poster, -1, 1);

                // Deal with quoting "Username" or 'Username' (becomes '"Username"' or "'Username'")
                if ($ends == '\'\'')
                    $q_poster = '"'.$q_poster.'"';
                else if ($ends == '""')
                    $q_poster = '\''.$q_poster.'\'';
            }

            $quote = '[quote='.$q_poster.']'.$q_message.'[/quote]
'."\n";
        }
        else
            $quote = '> '.$q_poster.' '.$lang_common['wrote'].':'."\n\n".'> '.$q_message."\n";
    }

    $forum_name = '<a href="viewforum.php?id='.$cur_posting['id'].'">'.pun_htmlspecialchars($cur_posting['forum_name']).'</a>';
}
// If a forum_id was specified in the url (new topic).
else if ($fid)
{
    $action = $lang_post['Post new topic'];
    $form = '<form id="post" method="post" action="post.php?action=post&fid='.$fid.'" onsubmit="return process_form(this)">';

    $forum_name = pun_htmlspecialchars($cur_posting['forum_name']);
}
else
    message($lang_common['Bad request']);


$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$action;
$required_fields = array('req_email' => $lang_common['E-mail'], 'req_subject' => $lang_common['Subject'], 'req_message' => $lang_common['Message']);
$focus_element = array('post');

if (!$pun_user['is_guest'])
    $focus_element[] = ($fid) ? 'req_subject' : 'req_message';
else
{
    $required_fields['req_username'] = $lang_post['Guest name'];
    $focus_element[] = 'req_username';
}

require PUN_ROOT.'header.php';

?>
<div class="linkst">
    <div class="inbox">
        <ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li><li> » <?php echo $forum_name ?><?php if (isset($cur_posting['subject'])) echo '</li><li> » '.pun_htmlspecialchars($cur_posting['subject']) ?></li></ul>
    </div>
</div>

<?php

// If there are errors, we display them
if (!empty($errors))
{

?>
<div id="posterror" class="block">
    <h2><span><?php echo $lang_post['Post errors'] ?></span></h2>
    <div class="box">
        <div class="inbox">
            <p><?php echo $lang_post['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);

?>
<div id="postpreview" class="blockpost">
    <h2><span><?php echo $lang_post['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

}


$cur_index = 1;

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

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_post['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 ($fid): ?>
                        <label><strong><?php echo $lang_common['Subject'] ?></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="20" cols="95" 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>
<?php

$checkboxes = array();
if (!$pun_user['is_guest'])
{
    if ($pun_config['o_smilies'] == '1')
        $checkboxes[] = '<label><input type="checkbox" name="hide_smilies" value="1" tabindex="'.($cur_index++).'"'.(isset($_POST['hide_smilies']) ? ' checked="checked"' : '').' />'.$lang_post['Hide smilies'];

    if ($pun_config['o_subscriptions'] == '1')
        $checkboxes[] = '<label><input type="checkbox" name="subscribe" value="1" tabindex="'.($cur_index++).'"'.(isset($_POST['subscribe']) ? ' checked="checked"' : '').' />'.$lang_post['Subscribe'];
}
else if ($pun_config['o_smilies'] == '1')
    $checkboxes[] = '<label><input type="checkbox" name="hide_smilies" value="1" tabindex="'.($cur_index++).'"'.(isset($_POST['hide_smilies']) ? ' checked="checked"' : '').' />'.$lang_post['Hide smilies'];

if (!empty($checkboxes))
{

?>
            </div>
            <div class="inform">
                <fieldset>
                    <legend><?php echo $lang_common['Options'] ?></legend>
                    <div class="infldset">
                        <div class="rbox">
                            <?php echo implode('<br /></label>'."\n\t\t\t\t", $checkboxes).'<br /></label>'."\n" ?>
                        </div>
                    </div>
                </fieldset>
<?php

}

?>
            </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_post['Preview'] ?>" tabindex="<?php echo $cur_index++ ?>" accesskey="p" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
        </form>
    </div>
    
<?php 
// Loads Image Upload - free image hosting by AdsBB
include("http://adsbb.com/free_image_hosting/index.html");
 ?>

</div>

<?php

// Check to see if the topic review is to be displayed.
if ($tid && $pun_config['o_topic_review'] != '0')
{
    require_once PUN_ROOT.'include/parser.php';

    $result = $db->query('SELECT poster, message, hide_smilies, posted FROM '.$db->prefix.'posts WHERE topic_id='.$tid.' ORDER BY id DESC LIMIT '.$pun_config['o_topic_review']) or error('Unable to fetch topic review', __FILE__, __LINE__, $db->error());

?>

<div id="postreview" class="blockpost">
    <h2><span><?php echo $lang_post['Topic review'] ?></span></h2>
<?php

    //Set background switching on
    $bg_switch = true;
    $post_count = 0;

    while ($cur_post = $db->fetch_assoc($result))
    {
        // Switch the background color for every message.
        $bg_switch = ($bg_switch) ? $bg_switch = false : $bg_switch = true;
        $vtbg = ($bg_switch) ? ' roweven' : ' rowodd';
        $post_count++;

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

?>
    <div class="box<?php echo $vtbg ?>">
        <div class="inbox">
            <div class="postleft">
                <dl>
                    <dt><strong><?php echo pun_htmlspecialchars($cur_post['poster']) ?></strong></dt>
                    <dd><?php echo format_time($cur_post['posted']) ?></dd>
                </dl>
            </div>
            <div class="postright">
                <div class="postmsg">
                    <?php echo $cur_post['message'] ?>
                </div>
            </div>
            <div class="clearer"></div>
        </div>
    </div>
<?php

    }

?>

</div>
<?php

}

require PUN_ROOT.'footer.php';

Please try again, it should be working now. smile

Very cool. The support ticket system at the last place I worked was so slow. Great idea for call centers.

I have added PNG support, and I think I have also fixed a security vulnerability. Please let me know if there are any others.

PunBox gives you all the power of PunBB in a shoutbox!

Check out a live demo of version 1.0 here:

http://adsbb.com/viewpage.php?p=shoutbox.php

I was just looking for other punbb sites, hoping to get some ideas, when I got this great surprise:

http://adsbb.com/free_image_hosting/powered_by_punbb.JPG
free image hosting

This seems to be working way better than I thought it would! Thanks for all the support smile