Ignore:
Timestamp:
Nov 14, 2011, 11:17:15 PM (12 years ago)
Author:
dj3c1t
Message:

passage a Fluxbb 1.4.7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/rsr.v5.1.dev/web/punbb/post.php

    r1 r3  
    11<?php
    2 /***********************************************************************
    3 
    4   Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)
    5 
    6   This file is part of PunBB.
    7 
    8   PunBB is free software; you can redistribute it and/or modify it
    9   under the terms of the GNU General Public License as published
    10   by the Free Software Foundation; either version 2 of the License,
    11   or (at your option) any later version.
    12 
    13   PunBB is distributed in the hope that it will be useful, but
    14   WITHOUT ANY WARRANTY; without even the implied warranty of
    15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16   GNU General Public License for more details.
    17 
    18   You should have received a copy of the GNU General Public License
    19   along with this program; if not, write to the Free Software
    20   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
    21   MA  02111-1307  USA
    22 
    23 ************************************************************************/
    24 
    25 
    26 define('PUN_ROOT', './');
     2
     3/**
     4 * Copyright (C) 2008-2011 FluxBB
     5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
     6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
     7 */
     8
     9define('PUN_ROOT', dirname(__FILE__).'/');
    2710require PUN_ROOT.'include/common.php';
    2811
     
    3922// Fetch some info about the topic and/or the forum
    4023if ($tid)
    41         $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('Impossible de retrouver les informations forum', __FILE__, __LINE__, $db->error());
     24        $result = $db->query('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 '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') LEFT JOIN '.$db->prefix.'topic_subscriptions AS s ON (t.id=s.topic_id AND s.user_id='.$pun_user['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());
    4225else
    43         $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('Impossible de retrouver les informations forum', __FILE__, __LINE__, $db->error());
     26        $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());
    4427
    4528if (!$db->num_rows($result))
     
    4730
    4831$cur_posting = $db->fetch_assoc($result);
     32$is_subscribed = $tid && $cur_posting['is_subscribed'];
    4933
    5034// Is someone trying to post into a redirect forum?
     
    5438// Sort out who the moderators are and if we are currently a moderator (or an admin)
    5539$mods_array = ($cur_posting['moderators'] != '') ? unserialize($cur_posting['moderators']) : array();
    56 $is_admmod = ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_id'] == PUN_MOD && array_key_exists($pun_user['username'], $mods_array))) ? true : false;
     40$is_admmod = ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_moderator'] == '1' && array_key_exists($pun_user['username'], $mods_array))) ? true : false;
     41
     42if ($tid && $pun_config['o_censoring'] == '1')
     43        $cur_posting['subject'] = censor_words($cur_posting['subject']);
    5744
    5845// Do we have permission to post?
     
    7360if (isset($_POST['form_sent']))
    7461{
    75         // Make sure form_user is correct
    76         if (($pun_user['is_guest'] && $_POST['form_user'] != 'Invité') || (!$pun_user['is_guest'] && $_POST['form_user'] != $pun_user['username']))
    77                 message($lang_common['Bad request']);
    78 
    7962        // Flood protection
    80         if (!$pun_user['is_guest'] && !isset($_POST['preview']) && $pun_user['last_post'] != '' && (time() - $pun_user['last_post']) < $pun_user['g_post_flood'])
     63        if (!isset($_POST['preview']) && $pun_user['last_post'] != '' && (time() - $pun_user['last_post']) < $pun_user['g_post_flood'])
    8164                $errors[] = $lang_post['Flood start'].' '.$pun_user['g_post_flood'].' '.$lang_post['flood end'];
    8265
     
    8669                $subject = pun_trim($_POST['req_subject']);
    8770
     71                if ($pun_config['o_censoring'] == '1')
     72                        $censored_subject = pun_trim(censor_words($subject));
     73
    8874                if ($subject == '')
    8975                        $errors[] = $lang_post['No subject'];
     76                else if ($pun_config['o_censoring'] == '1' && $censored_subject == '')
     77                        $errors[] = $lang_post['No subject after censoring'];
    9078                else if (pun_strlen($subject) > 70)
    9179                        $errors[] = $lang_post['Too long subject'];
    92                 else if ($pun_config['p_subject_all_caps'] == '0' && strtoupper($subject) == $subject && $pun_user['g_id'] > PUN_MOD)
    93                         $subject = ucwords(strtolower($subject));
    94         }
    95 
    96         // If the user is logged in we get the username and e-mail from $pun_user
     80                else if ($pun_config['p_subject_all_caps'] == '0' && is_all_uppercase($subject) && !$pun_user['is_admmod'])
     81                        $errors[] = $lang_post['All caps subject'];
     82        }
     83
     84        // If the user is logged in we get the username and email from $pun_user
    9785        if (!$pun_user['is_guest'])
    9886        {
     
    10391        else
    10492        {
    105                 $username = trim($_POST['req_username']);
     93                $username = pun_trim($_POST['req_username']);
    10694                $email = strtolower(trim(($pun_config['p_force_guest_email'] == '1') ? $_POST['req_email'] : $_POST['email']));
    107 
    108                 // Load the register.php/profile.php language files
     95                $banned_email = false;
     96
     97                // Load the register.php/prof_reg.php language files
    10998                require PUN_ROOT.'lang/'.$pun_user['language'].'/prof_reg.php';
    11099                require PUN_ROOT.'lang/'.$pun_user['language'].'/register.php';
    111100
    112101                // It's a guest, so we have to validate the username
    113                 if (strlen($username) < 2)
    114                         $errors[] = $lang_prof_reg['Username too short'];
    115                 else if (!strcasecmp($username, 'invité') || !strcasecmp($username, $lang_common['Guest']))
    116                         $errors[] = $lang_prof_reg['Username guest'];
    117                 else if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $username))
    118                         $errors[] = $lang_prof_reg['Username IP'];
    119 
    120                 if ((strpos($username, '[') !== false || strpos($username, ']') !== false) && strpos($username, '\'') !== false && strpos($username, '"') !== false)
    121                         $errors[] = $lang_prof_reg['Username reserved chars'];
    122                 if (preg_match('#\[b\]|\[/b\]|\[u\]|\[/u\]|\[i\]|\[/i\]|\[color|\[/color\]|\[quote\]|\[quote=|\[/quote\]|\[code\]|\[/code\]|\[img\]|\[/img\]|\[url|\[/url\]|\[email|\[/email\]#i', $username))
    123                         $errors[] = $lang_prof_reg['Username BBCode'];
    124 
    125                 // Check username for any censored words
    126                 $temp = censor_words($username);
    127                 if ($temp != $username)
    128                         $errors[] = $lang_register['Username censor'];
    129 
    130                 // Check that the username (or a too similar username) is not already registered
    131                 $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE username=\''.$db->escape($username).'\' OR username=\''.$db->escape(preg_replace('/[^\w]/', '', $username)).'\'') or error('Impossible de retrouver les informations utilisateur', __FILE__, __LINE__, $db->error());
    132                 if ($db->num_rows($result))
    133                 {
    134                         $busy = $db->result($result);
    135                         $errors[] = $lang_register['Username dupe 1'].' '.pun_htmlspecialchars($busy).'. '.$lang_register['Username dupe 2'];
    136                 }
     102                check_username($username);
    137103
    138104                if ($pun_config['p_force_guest_email'] == '1' || $email != '')
     
    140106                        require PUN_ROOT.'include/email.php';
    141107                        if (!is_valid_email($email))
    142                                 $errors[] = $lang_common['Invalid e-mail'];
     108                                $errors[] = $lang_common['Invalid email'];
     109
     110                        // Check if it's a banned email address
     111                        // we should only check guests because members addresses are already verified
     112                        if ($pun_user['is_guest'] && is_banned_email($email))
     113                        {
     114                                if ($pun_config['p_allow_banned_email'] == '0')
     115                                        $errors[] = $lang_prof_reg['Banned email'];
     116
     117                                $banned_email = true; // Used later when we send an alert email
     118                        }
    143119                }
    144120        }
    145121
    146122        // Clean up message from POST
    147         $message = pun_linebreaks(pun_trim($_POST['req_message']));
    148 
    149         if ($message == '')
    150                 $errors[] = $lang_post['No message'];
    151         else if (strlen($message) > 65535)
    152                 $errors[] = $lang_post['Too long message'];
    153         else if ($pun_config['p_message_all_caps'] == '0' && strtoupper($message) == $message && $pun_user['g_id'] > PUN_MOD)
    154                 $message = ucwords(strtolower($message));
     123        $orig_message = $message = pun_linebreaks(pun_trim($_POST['req_message']));
     124
     125        // Here we use strlen() not pun_strlen() as we want to limit the post to PUN_MAX_POSTSIZE bytes, not characters
     126        if (strlen($message) > PUN_MAX_POSTSIZE)
     127                $errors[] = sprintf($lang_post['Too long message'], forum_number_format(PUN_MAX_POSTSIZE));
     128        else if ($pun_config['p_message_all_caps'] == '0' && is_all_uppercase($message) && !$pun_user['is_admmod'])
     129                $errors[] = $lang_post['All caps message'];
    155130
    156131        // Validate BBCode syntax
    157         if ($pun_config['p_message_bbcode'] == '1' && strpos($message, '[') !== false && strpos($message, ']') !== false)
     132        if ($pun_config['p_message_bbcode'] == '1')
    158133        {
    159134                require PUN_ROOT.'include/parser.php';
     
    161136        }
    162137
    163 
    164         require PUN_ROOT.'include/search_idx.php';
    165 
    166         $hide_smilies = isset($_POST['hide_smilies']) ? 1 : 0;
    167         $subscribe = isset($_POST['subscribe']) ? 1 : 0;
     138        if (empty($errors))
     139        {
     140                if ($message == '')
     141                        $errors[] = $lang_post['No message'];
     142                else if ($pun_config['o_censoring'] == '1')
     143                {
     144                        // Censor message to see if that causes problems
     145                        $censored_message = pun_trim(censor_words($message));
     146
     147                        if ($censored_message == '')
     148                                $errors[] = $lang_post['No message after censoring'];
     149                }
     150        }
     151
     152        $hide_smilies = isset($_POST['hide_smilies']) ? '1' : '0';
     153        $subscribe = isset($_POST['subscribe']) ? '1' : '0';
     154        $stick_topic = isset($_POST['stick_topic']) && $is_admmod ? '1' : '0';
    168155
    169156        $now = time();
     
    172159        if (empty($errors) && !isset($_POST['preview']))
    173160        {
     161                require PUN_ROOT.'include/search_idx.php';
     162
    174163                // If it's a reply
    175164                if ($tid)
     
    177166                        if (!$pun_user['is_guest'])
    178167                        {
     168                                $new_tid = $tid;
     169
    179170                                // Insert the new post
    180                                 $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('Impossible de créer le message', __FILE__, __LINE__, $db->error());
     171                                $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());
    181172                                $new_pid = $db->insert_id();
    182173
    183174                                // To subscribe or not to subscribe, that ...
    184                                 if ($pun_config['o_subscriptions'] == '1' && $subscribe)
     175                                if ($pun_config['o_topic_subscriptions'] == '1')
    185176                                {
    186                                         $result = $db->query('SELECT 1 FROM '.$db->prefix.'subscriptions WHERE user_id='.$pun_user['id'].' AND topic_id='.$tid) or error('Impossible de retrouver les informations d\'abonnement', __FILE__, __LINE__, $db->error());
    187                                         if (!$db->num_rows($result))
    188                                                 $db->query('INSERT INTO '.$db->prefix.'subscriptions (user_id, topic_id) VALUES('.$pun_user['id'].' ,'.$tid.')') or error('Impossible d\'ajouter l\'abonnement', __FILE__, __LINE__, $db->error());
     177                                        if ($subscribe && !$is_subscribed)
     178                                                $db->query('INSERT INTO '.$db->prefix.'topic_subscriptions (user_id, topic_id) VALUES('.$pun_user['id'].' ,'.$tid.')') or error('Unable to add subscription', __FILE__, __LINE__, $db->error());
     179                                        else if (!$subscribe && $is_subscribed)
     180                                                $db->query('DELETE FROM '.$db->prefix.'topic_subscriptions WHERE user_id='.$pun_user['id'].' AND topic_id='.$tid) or error('Unable to remove subscription', __FILE__, __LINE__, $db->error());
    189181                                }
    190182                        }
     
    192184                        {
    193185                                // It's a guest. Insert the new post
    194                                 $email_sql = ($pun_config['p_force_guest_email'] == '1' || $email != '') ? '\''.$email.'\'' : 'NULL';
    195                                 $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('Impossible de créer le message', __FILE__, __LINE__, $db->error());
     186                                $email_sql = ($pun_config['p_force_guest_email'] == '1' || $email != '') ? '\''.$db->escape($email).'\'' : 'NULL';
     187                                $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());
    196188                                $new_pid = $db->insert_id();
    197189                        }
    198190
    199191                        // Count number of replies in the topic
    200                         $result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'posts WHERE topic_id='.$tid) or error('Impossible de retrouver le total de messages de la discussion', __FILE__, __LINE__, $db->error());
     192                        $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());
    201193                        $num_replies = $db->result($result, 0) - 1;
    202194
    203195                        // Update topic
    204                         $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('Impossible de modifier la discussion', __FILE__, __LINE__, $db->error());
     196                        $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());
    205197
    206198                        update_search_index('post', $new_pid, $message);
     
    209201
    210202                        // Should we send out notifications?
    211                         if ($pun_config['o_subscriptions'] == '1')
     203                        if ($pun_config['o_topic_subscriptions'] == '1')
    212204                        {
    213205                                // Get the post time for the previous post in this topic
    214                                 $result = $db->query('SELECT posted FROM '.$db->prefix.'posts WHERE topic_id='.$tid.' ORDER BY id DESC LIMIT 1, 1') or error('Impossible de retrouver les information de message', __FILE__, __LINE__, $db->error());
     206                                $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());
    215207                                $previous_post_time = $db->result($result);
    216208
    217209                                // Get any subscribed users that should be notified (banned users are excluded)
    218                                 $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('Impossible de retrouver les informations d\'abonnement', __FILE__, __LINE__, $db->error());
     210                                $result = $db->query('SELECT u.id, u.email, u.notify_with_post, u.language FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'topic_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!='.$pun_user['id']) or error('Unable to fetch subscription info', __FILE__, __LINE__, $db->error());
    219211                                if ($db->num_rows($result))
    220212                                {
     
    223215                                        $notification_emails = array();
    224216
    225                                         // Loop through subscribed users and send e-mails
     217                                        if ($pun_config['o_censoring'] == '1')
     218                                                $cleaned_message = bbcode2email($censored_message, -1);
     219                                        else
     220                                                $cleaned_message = bbcode2email($message, -1);
     221
     222                                        // Loop through subscribed users and send emails
    226223                                        while ($cur_subscriber = $db->fetch_assoc($result))
    227224                                        {
    228                                                 // Is the subscription e-mail for $cur_subscriber['language'] cached or not?
     225                                                // Is the subscription email for $cur_subscriber['language'] cached or not?
    229226                                                if (!isset($notification_emails[$cur_subscriber['language']]))
    230227                                                {
     
    246243                                                                $mail_message_full = trim(substr($mail_tpl_full, $first_crlf));
    247244
    248                                                                 $mail_subject = str_replace('<topic_subject>', '\''.$cur_posting['subject'].'\'', $mail_subject);
    249                                                                 $mail_message = str_replace('<topic_subject>', '\''.$cur_posting['subject'].'\'', $mail_message);
     245                                                                $mail_subject = str_replace('<topic_subject>', $cur_posting['subject'], $mail_subject);
     246                                                                $mail_message = str_replace('<topic_subject>', $cur_posting['subject'], $mail_message);
    250247                                                                $mail_message = str_replace('<replier>', $username, $mail_message);
    251                                                                 $mail_message = str_replace('<post_url>', $pun_config['o_base_url'].'/viewtopic.php?pid='.$new_pid.'#p'.$new_pid, $mail_message);
    252                                                                 $mail_message = str_replace('<unsubscribe_url>', $pun_config['o_base_url'].'/misc.php?unsubscribe='.$tid, $mail_message);
    253                                                                 $mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'].' '.$lang_common['Mailer'], $mail_message);
    254 
    255                                                                 $mail_subject_full = str_replace('<topic_subject>', '\''.$cur_posting['subject'].'\'', $mail_subject_full);
    256                                                                 $mail_message_full = str_replace('<topic_subject>', '\''.$cur_posting['subject'].'\'', $mail_message_full);
     248                                                                $mail_message = str_replace('<post_url>', get_base_url().'/viewtopic.php?pid='.$new_pid.'#p'.$new_pid, $mail_message);
     249                                                                $mail_message = str_replace('<unsubscribe_url>', get_base_url().'/misc.php?action=unsubscribe&tid='.$tid, $mail_message);
     250                                                                $mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'], $mail_message);
     251
     252                                                                $mail_subject_full = str_replace('<topic_subject>', $cur_posting['subject'], $mail_subject_full);
     253                                                                $mail_message_full = str_replace('<topic_subject>', $cur_posting['subject'], $mail_message_full);
    257254                                                                $mail_message_full = str_replace('<replier>', $username, $mail_message_full);
    258                                                                 $mail_message_full = str_replace('<message>', $message, $mail_message_full);
    259                                                                 $mail_message_full = str_replace('<post_url>', $pun_config['o_base_url'].'/viewtopic.php?pid='.$new_pid.'#p'.$new_pid, $mail_message_full);
    260                                                                 $mail_message_full = str_replace('<unsubscribe_url>', $pun_config['o_base_url'].'/misc.php?unsubscribe='.$tid, $mail_message_full);
    261                                                                 $mail_message_full = str_replace('<board_mailer>', $pun_config['o_board_title'].' '.$lang_common['Mailer'], $mail_message_full);
     255                                                                $mail_message_full = str_replace('<message>', $cleaned_message, $mail_message_full);
     256                                                                $mail_message_full = str_replace('<post_url>', get_base_url().'/viewtopic.php?pid='.$new_pid.'#p'.$new_pid, $mail_message_full);
     257                                                                $mail_message_full = str_replace('<unsubscribe_url>', get_base_url().'/misc.php?action=unsubscribe&tid='.$tid, $mail_message_full);
     258                                                                $mail_message_full = str_replace('<board_mailer>', $pun_config['o_board_title'], $mail_message_full);
    262259
    263260                                                                $notification_emails[$cur_subscriber['language']][0] = $mail_subject;
     
    279276                                                }
    280277                                        }
     278
     279                                        unset($cleaned_message);
    281280                                }
    282281                        }
     
    286285                {
    287286                        // Create the topic
    288                         $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('Impossible de créer la discussion', __FILE__, __LINE__, $db->error());
     287                        $db->query('INSERT INTO '.$db->prefix.'topics (poster, subject, posted, last_post, last_poster, sticky, forum_id) VALUES(\''.$db->escape($username).'\', \''.$db->escape($subject).'\', '.$now.', '.$now.', \''.$db->escape($username).'\', '.$stick_topic.', '.$fid.')') or error('Unable to create topic', __FILE__, __LINE__, $db->error());
    289288                        $new_tid = $db->insert_id();
    290289
     
    292291                        {
    293292                                // To subscribe or not to subscribe, that ...
    294                                 if ($pun_config['o_subscriptions'] == '1' && (isset($_POST['subscribe']) && $_POST['subscribe'] == '1'))
    295                                         $db->query('INSERT INTO '.$db->prefix.'subscriptions (user_id, topic_id) VALUES('.$pun_user['id'].' ,'.$new_tid.')') or error('Impossible d\'ajouter l\'abonnement', __FILE__, __LINE__, $db->error());
     293                                if ($pun_config['o_topic_subscriptions'] == '1' && $subscribe)
     294                                        $db->query('INSERT INTO '.$db->prefix.'topic_subscriptions (user_id, topic_id) VALUES('.$pun_user['id'].' ,'.$new_tid.')') or error('Unable to add subscription', __FILE__, __LINE__, $db->error());
    296295
    297296                                // Create the post ("topic post")
    298                                 $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('Impossible de créer le message', __FILE__, __LINE__, $db->error());
     297                                $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());
    299298                        }
    300299                        else
    301300                        {
    302301                                // Create the post ("topic post")
    303                                 $email_sql = ($pun_config['p_force_guest_email'] == '1' || $email != '') ? '\''.$email.'\'' : 'NULL';
    304                                 $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('Impossible de créer le message', __FILE__, __LINE__, $db->error());
     302                                $email_sql = ($pun_config['p_force_guest_email'] == '1' || $email != '') ? '\''.$db->escape($email).'\'' : 'NULL';
     303                                $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());
    305304                        }
    306305                        $new_pid = $db->insert_id();
    307306
    308307                        // Update the topic with last_post_id
    309                         $db->query('UPDATE '.$db->prefix.'topics SET last_post_id='.$new_pid.' WHERE id='.$new_tid) or error('Impossible de modifier la discussion', __FILE__, __LINE__, $db->error());
     308                        $db->query('UPDATE '.$db->prefix.'topics SET last_post_id='.$new_pid.', first_post_id='.$new_pid.' WHERE id='.$new_tid) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
    310309
    311310                        update_search_index('post', $new_pid, $message, $subject);
    312311
    313312                        update_forum($fid);
     313
     314                        // Should we send out notifications?
     315                        if ($pun_config['o_forum_subscriptions'] == '1')
     316                        {
     317                                // Get any subscribed users that should be notified (banned users are excluded)
     318                                $result = $db->query('SELECT u.id, u.email, u.notify_with_post, u.language FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'forum_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.'bans AS b ON u.username=b.username WHERE b.username IS NULL AND (fp.read_forum IS NULL OR fp.read_forum=1) AND s.forum_id='.$cur_posting['id'].' AND u.id!='.$pun_user['id']) or error('Unable to fetch subscription info', __FILE__, __LINE__, $db->error());
     319                                if ($db->num_rows($result))
     320                                {
     321                                        require_once PUN_ROOT.'include/email.php';
     322
     323                                        $notification_emails = array();
     324
     325                                        if ($pun_config['o_censoring'] == '1')
     326                                                $cleaned_message = bbcode2email($censored_message, -1);
     327                                        else
     328                                                $cleaned_message = bbcode2email($message, -1);
     329
     330                                        // Loop through subscribed users and send emails
     331                                        while ($cur_subscriber = $db->fetch_assoc($result))
     332                                        {
     333                                                // Is the subscription email for $cur_subscriber['language'] cached or not?
     334                                                if (!isset($notification_emails[$cur_subscriber['language']]))
     335                                                {
     336                                                        if (file_exists(PUN_ROOT.'lang/'.$cur_subscriber['language'].'/mail_templates/new_topic.tpl'))
     337                                                        {
     338                                                                // Load the "new topic" template
     339                                                                $mail_tpl = trim(file_get_contents(PUN_ROOT.'lang/'.$cur_subscriber['language'].'/mail_templates/new_topic.tpl'));
     340
     341                                                                // Load the "new topic full" template (with post included)
     342                                                                $mail_tpl_full = trim(file_get_contents(PUN_ROOT.'lang/'.$cur_subscriber['language'].'/mail_templates/new_topic_full.tpl'));
     343
     344                                                                // The first row contains the subject (it also starts with "Subject:")
     345                                                                $first_crlf = strpos($mail_tpl, "\n");
     346                                                                $mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8));
     347                                                                $mail_message = trim(substr($mail_tpl, $first_crlf));
     348
     349                                                                $first_crlf = strpos($mail_tpl_full, "\n");
     350                                                                $mail_subject_full = trim(substr($mail_tpl_full, 8, $first_crlf-8));
     351                                                                $mail_message_full = trim(substr($mail_tpl_full, $first_crlf));
     352
     353                                                                $mail_subject = str_replace('<forum_name>', $cur_posting['forum_name'], $mail_subject);
     354                                                                $mail_message = str_replace('<topic_subject>', $pun_config['o_censoring'] == '1' ? $censored_subject : $subject, $mail_message);
     355                                                                $mail_message = str_replace('<forum_name>', $cur_posting['forum_name'], $mail_message);
     356                                                                $mail_message = str_replace('<poster>', $username, $mail_message);
     357                                                                $mail_message = str_replace('<topic_url>', get_base_url().'/viewtopic.php?id='.$new_tid, $mail_message);
     358                                                                $mail_message = str_replace('<unsubscribe_url>', get_base_url().'/misc.php?action=unsubscribe&fid='.$cur_posting['id'], $mail_message);
     359                                                                $mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'], $mail_message);
     360
     361                                                                $mail_subject_full = str_replace('<forum_name>', $cur_posting['forum_name'], $mail_subject_full);
     362                                                                $mail_message_full = str_replace('<topic_subject>', $pun_config['o_censoring'] == '1' ? $censored_subject : $subject, $mail_message_full);
     363                                                                $mail_message_full = str_replace('<forum_name>', $cur_posting['forum_name'], $mail_message_full);
     364                                                                $mail_message_full = str_replace('<poster>', $username, $mail_message_full);
     365                                                                $mail_message_full = str_replace('<message>', $cleaned_message, $mail_message_full);
     366                                                                $mail_message_full = str_replace('<topic_url>', get_base_url().'/viewtopic.php?id='.$new_tid, $mail_message_full);
     367                                                                $mail_message_full = str_replace('<unsubscribe_url>', get_base_url().'/misc.php?action=unsubscribe&fid='.$cur_posting['id'], $mail_message_full);
     368                                                                $mail_message_full = str_replace('<board_mailer>', $pun_config['o_board_title'], $mail_message_full);
     369
     370                                                                $notification_emails[$cur_subscriber['language']][0] = $mail_subject;
     371                                                                $notification_emails[$cur_subscriber['language']][1] = $mail_message;
     372                                                                $notification_emails[$cur_subscriber['language']][2] = $mail_subject_full;
     373                                                                $notification_emails[$cur_subscriber['language']][3] = $mail_message_full;
     374
     375                                                                $mail_subject = $mail_message = $mail_subject_full = $mail_message_full = null;
     376                                                        }
     377                                                }
     378
     379                                                // We have to double check here because the templates could be missing
     380                                                if (isset($notification_emails[$cur_subscriber['language']]))
     381                                                {
     382                                                        if ($cur_subscriber['notify_with_post'] == '0')
     383                                                                pun_mail($cur_subscriber['email'], $notification_emails[$cur_subscriber['language']][0], $notification_emails[$cur_subscriber['language']][1]);
     384                                                        else
     385                                                                pun_mail($cur_subscriber['email'], $notification_emails[$cur_subscriber['language']][2], $notification_emails[$cur_subscriber['language']][3]);
     386                                                }
     387                                        }
     388
     389                                        unset($cleaned_message);
     390                                }
     391                        }
     392                }
     393
     394                // If we previously found out that the email was banned
     395                if ($pun_user['is_guest'] && $banned_email && $pun_config['o_mailing_list'] != '')
     396                {
     397                        // Load the "banned email post" template
     398                        $mail_tpl = trim(file_get_contents(PUN_ROOT.'lang/'.$pun_user['language'].'/mail_templates/banned_email_post.tpl'));
     399
     400                        // The first row contains the subject
     401                        $first_crlf = strpos($mail_tpl, "\n");
     402                        $mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8));
     403                        $mail_message = trim(substr($mail_tpl, $first_crlf));
     404
     405                        $mail_message = str_replace('<username>', $username, $mail_message);
     406                        $mail_message = str_replace('<email>', $email, $mail_message);
     407                        $mail_message = str_replace('<post_url>', get_base_url().'/viewtopic.php?pid='.$new_pid.'#p'.$new_pid, $mail_message);
     408                        $mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'], $mail_message);
     409
     410                        pun_mail($pun_config['o_mailing_list'], $mail_subject, $mail_message);
    314411                }
    315412
     
    317414                if (!$pun_user['is_guest'])
    318415                {
    319                         $low_prio = ($db_type == 'mysql') ? 'LOW_PRIORITY ' : '';
    320                         $db->query('UPDATE '.$low_prio.$db->prefix.'users SET num_posts=num_posts+1, last_post='.$now.' WHERE id='.$pun_user['id']) or error('Impossible de modifier l\'utilisateur', __FILE__, __LINE__, $db->error());
     416                        $db->query('UPDATE '.$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());
     417
     418                        $tracked_topics = get_tracked_topics();
     419                        $tracked_topics['topics'][$new_tid] = time();
     420                        set_tracked_topics($tracked_topics);
     421                }
     422                else
     423                {
     424                        $db->query('UPDATE '.$db->prefix.'online SET last_post='.$now.' WHERE ident=\''.$db->escape(get_remote_address()).'\'' ) or error('Unable to update user', __FILE__, __LINE__, $db->error());
    321425                }
    322426
     
    326430
    327431
    328 // If a topic id was specified in the url (it's a reply).
     432// If a topic ID was specified in the url (it's a reply)
    329433if ($tid)
    330434{
     
    332436        $form = '<form id="post" method="post" action="post.php?action=post&amp;tid='.$tid.'" onsubmit="this.submit.disabled=true;if(process_form(this)){return true;}else{this.submit.disabled=false;return false;}">';
    333437
    334         // If a quote-id was specified in the url.
     438        // If a quote ID was specified in the url
    335439        if (isset($_GET['qid']))
    336440        {
     
    339443                        message($lang_common['Bad request']);
    340444
    341                 $result = $db->query('SELECT poster, message FROM '.$db->prefix.'posts WHERE id='.$qid.' AND topic_id='.$tid) or error('Impossible de retrouver les informations de citation', __FILE__, __LINE__, $db->error());
     445                $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());
    342446                if (!$db->num_rows($result))
    343447                        message($lang_common['Bad request']);
     
    345449                list($q_poster, $q_message) = $db->fetch_row($result);
    346450
    347                 // Mod: Flash MP3 Player (1 nouvelle ligne suit)
    348                 $q_message = preg_replace("/\[mp3 url=([^ ]+)\]/", "[url]$1[/url]", $q_message);
    349 
    350                 $q_message = str_replace('[img]', '[url]', $q_message);
    351                 $q_message = str_replace('[/img]', '[/url]', $q_message);
     451                // If the message contains a code tag we have to split it up (text within [code][/code] shouldn't be touched)
     452                if (strpos($q_message, '[code]') !== false && strpos($q_message, '[/code]') !== false)
     453                {
     454                        $errors = array();
     455                        list($inside, $outside) = split_text($q_message, '[code]', '[/code]', $errors);
     456                        if (!empty($errors)) // Technically this shouldn't happen, since $q_message is an existing post it should only exist if it previously passed validation
     457                                message($errors[0]);
     458
     459                        $q_message = implode("\1", $outside);
     460                }
     461
     462                // Remove [img] tags from quoted message
     463                $q_message = preg_replace('%\[img(?:=(?:[^\[]*?))?\]((ht|f)tps?://)([^\s<"]*?)\[/img\]%U', '\1\3', $q_message);
     464
     465                // If we split up the message before we have to concatenate it together again (code tags)
     466                if (isset($inside))
     467                {
     468                        $outside = explode("\1", $q_message);
     469                        $q_message = '';
     470
     471                        $num_tokens = count($outside);
     472                        for ($i = 0; $i < $num_tokens; ++$i)
     473                        {
     474                                $q_message .= $outside[$i];
     475                                if (isset($inside[$i]))
     476                                        $q_message .= '[code]'.$inside[$i].'[/code]';
     477                        }
     478
     479                        unset($inside);
     480                }
     481
     482                if ($pun_config['o_censoring'] == '1')
     483                        $q_message = censor_words($q_message);
     484
    352485                $q_message = pun_htmlspecialchars($q_message);
    353486
     
    377510                }
    378511                else
    379                         $quote = '> '.$q_poster.' '.$lang_common['wrote'].':'."\n\n".'> '.$q_message."\n";
    380         }
    381 
    382         $forum_name = '<a href="viewforum.php?id='.$cur_posting['id'].'">'.pun_htmlspecialchars($cur_posting['forum_name']).'</a>';
    383 }
    384 // If a forum_id was specified in the url (new topic).
     512                        $quote = '> '.$q_poster.' '.$lang_common['wrote']."\n\n".'> '.$q_message."\n";
     513        }
     514}
     515// If a forum ID was specified in the url (new topic)
    385516else if ($fid)
    386517{
    387518        $action = $lang_post['Post new topic'];
    388519        $form = '<form id="post" method="post" action="post.php?action=post&amp;fid='.$fid.'" onsubmit="return process_form(this)">';
    389 
    390         $forum_name = pun_htmlspecialchars($cur_posting['forum_name']);
    391520}
    392521else
     
    394523
    395524
    396 $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$action;
    397 $required_fields = array('req_email' => $lang_common['E-mail'], 'req_subject' => $lang_common['Subject'], 'req_message' => $lang_common['Message']);
     525$page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $action);
     526$required_fields = array('req_email' => $lang_common['Email'], 'req_subject' => $lang_common['Subject'], 'req_message' => $lang_common['Message']);
    398527$focus_element = array('post');
    399528
     
    406535}
    407536
     537define('PUN_ACTIVE_PAGE', 'index');
    408538require PUN_ROOT.'header.php';
    409539
     
    411541<div class="linkst">
    412542        <div class="inbox">
    413                 <ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li><li>&#160;&raquo;&#160;<?php echo $forum_name ?><?php if (isset($cur_posting['subject'])) echo '</li><li>&#160;&raquo;&#160;'.pun_htmlspecialchars($cur_posting['subject']) ?></li></ul>
     543                <ul class="crumbs">
     544                        <li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li>
     545                        <li><span>»&#160;</span><a href="viewforum.php?id=<?php echo $cur_posting['id'] ?>"><?php echo pun_htmlspecialchars($cur_posting['forum_name']) ?></a></li>
     546<?php if (isset($cur_posting['subject'])): ?>                   <li><span>»&#160;</span><a href="viewtopic.php?id=<?php echo $tid ?>"><?php echo pun_htmlspecialchars($cur_posting['subject']) ?></a></li>
     547<?php endif; ?>                 <li><span>»&#160;</span><strong><?php echo $action ?></strong></li>
     548                </ul>
    414549        </div>
    415550</div>
     
    425560        <h2><span><?php echo $lang_post['Post errors'] ?></span></h2>
    426561        <div class="box">
    427                 <div class="inbox">
     562                <div class="inbox error-info">
    428563                        <p><?php echo $lang_post['Post errors info'] ?></p>
    429                         <ul>
    430 <?php
    431 
    432         while (list(, $cur_error) = each($errors))
     564                        <ul class="error-list">
     565<?php
     566
     567        foreach ($errors as $cur_error)
    433568                echo "\t\t\t\t".'<li><strong>'.$cur_error.'</strong></li>'."\n";
    434569?>
     
    451586        <div class="box">
    452587                <div class="inbox">
    453                         <div class="postright">
    454                                 <div class="postmsg">
    455                                         <?php echo $preview_message."\n" ?>
     588                        <div class="postbody">
     589                                <div class="postright">
     590                                        <div class="postmsg">
     591                                                <?php echo $preview_message."\n" ?>
     592                                        </div>
    456593                                </div>
    457594                        </div>
     
    468605
    469606?>
    470 <div class="blockform">
     607<div id="postform" class="blockform">
    471608        <h2><span><?php echo $action ?></span></h2>
    472609        <div class="box">
     
    477614                                        <div class="infldset txtarea">
    478615                                                <input type="hidden" name="form_sent" value="1" />
    479                                                 <input type="hidden" name="form_user" value="<?php echo (!$pun_user['is_guest']) ? pun_htmlspecialchars($pun_user['username']) : 'Invité'; ?>" />
    480616<?php
    481617
    482618if ($pun_user['is_guest'])
    483619{
    484         $email_label = ($pun_config['p_force_guest_email'] == '1') ? '<strong>'.$lang_common['E-mail'].'</strong>' : $lang_common['E-mail'];
     620        $email_label = ($pun_config['p_force_guest_email'] == '1') ? '<strong>'.$lang_common['Email'].' <span>'.$lang_common['Required'].'</span></strong>' : $lang_common['Email'];
    485621        $email_form_name = ($pun_config['p_force_guest_email'] == '1') ? 'req_email' : 'email';
    486622
    487 ?>                                              <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>
    488                                                 <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>
     623?>
     624                                                <label class="conl required"><strong><?php echo $lang_post['Guest name'] ?> <span><?php echo $lang_common['Required'] ?></span></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>
     625                                                <label class="conl<?php echo ($pun_config['p_force_guest_email'] == '1') ? ' required' : '' ?>"><?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="80" tabindex="<?php echo $cur_index++ ?>" /><br /></label>
    489626                                                <div class="clearer"></div>
    490627<?php
     
    493630
    494631if ($fid): ?>
    495                                                 <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>
    496 <?php endif; require PUN_ROOT.'mod_easy_bbcode.php'; ?>                                         <label><strong><?php echo $lang_common['Message'] ?></strong><br />
    497 
    498                                                 <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>
     632                                                <label class="required"><strong><?php echo $lang_common['Subject'] ?> <span><?php echo $lang_common['Required'] ?></span></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>
     633<?php endif; ?>                                         <label class="required"><strong><?php echo $lang_common['Message'] ?> <span><?php echo $lang_common['Required'] ?></span></strong><br />
     634                                                <textarea name="req_message" rows="20" cols="95" tabindex="<?php echo $cur_index++ ?>"><?php echo isset($_POST['req_message']) ? pun_htmlspecialchars($orig_message) : (isset($quote) ? $quote : ''); ?></textarea><br /></label>
    499635                                                <ul class="bblinks">
    500                                                         <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>
    501                                                         <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>
    502                                                         <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>
     636                                                        <li><span><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']; ?></span></li>
     637                                                        <li><span><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_bbcode'] == '1' && $pun_config['p_message_img_tag'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></span></li>
     638                                                        <li><span><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']; ?></span></li>
    503639                                                </ul>
    504640                                        </div>
     
    507643
    508644$checkboxes = array();
     645if ($is_admmod)
     646        $checkboxes[] = '<label><input type="checkbox" name="stick_topic" value="1" tabindex="'.($cur_index++).'"'.(isset($_POST['stick_topic']) ? ' checked="checked"' : '').' />'.$lang_common['Stick topic'].'<br /></label>';
     647
    509648if (!$pun_user['is_guest'])
    510649{
    511650        if ($pun_config['o_smilies'] == '1')
    512                 $checkboxes[] = '<label><input type="checkbox" name="hide_smilies" value="1" tabindex="'.($cur_index++).'"'.(isset($_POST['hide_smilies']) ? ' checked="checked"' : '').' />'.$lang_post['Hide smilies'];
    513 
    514         if ($pun_config['o_subscriptions'] == '1')
    515                 $checkboxes[] = '<label><input type="checkbox" name="subscribe" value="1" tabindex="'.($cur_index++).'"'.(isset($_POST['subscribe']) ? ' checked="checked"' : '').' />'.$lang_post['Subscribe'];
     651                $checkboxes[] = '<label><input type="checkbox" name="hide_smilies" value="1" tabindex="'.($cur_index++).'"'.(isset($_POST['hide_smilies']) ? ' checked="checked"' : '').' />'.$lang_post['Hide smilies'].'<br /></label>';
     652
     653        if ($pun_config['o_topic_subscriptions'] == '1')
     654        {
     655                $subscr_checked = false;
     656
     657                // If it's a preview
     658                if (isset($_POST['preview']))
     659                        $subscr_checked = isset($_POST['subscribe']) ? true : false;
     660                // If auto subscribed
     661                else if ($pun_user['auto_notify'])
     662                        $subscr_checked = true;
     663                // If already subscribed to the topic
     664                else if ($is_subscribed)
     665                        $subscr_checked = true;
     666
     667                $checkboxes[] = '<label><input type="checkbox" name="subscribe" value="1" tabindex="'.($cur_index++).'"'.($subscr_checked ? ' checked="checked"' : '').' />'.($is_subscribed ? $lang_post['Stay subscribed'] : $lang_post['Subscribe']).'<br /></label>';
     668        }
    516669}
    517670else if ($pun_config['o_smilies'] == '1')
    518         $checkboxes[] = '<label><input type="checkbox" name="hide_smilies" value="1" tabindex="'.($cur_index++).'"'.(isset($_POST['hide_smilies']) ? ' checked="checked"' : '').' />'.$lang_post['Hide smilies'];
     671        $checkboxes[] = '<label><input type="checkbox" name="hide_smilies" value="1" tabindex="'.($cur_index++).'"'.(isset($_POST['hide_smilies']) ? ' checked="checked"' : '').' />'.$lang_post['Hide smilies'].'<br /></label>';
    519672
    520673if (!empty($checkboxes))
     
    528681                                        <div class="infldset">
    529682                                                <div class="rbox">
    530                                                         <?php echo implode('<br /></label>'."\n\t\t\t\t", $checkboxes).'<br /></label>'."\n" ?>
     683                                                        <?php echo implode("\n\t\t\t\t\t\t\t", $checkboxes)."\n" ?>
    531684                                                </div>
    532685                                        </div>
     
    538691?>
    539692                        </div>
    540                         <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>
     693                        <p class="buttons"><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>
    541694                </form>
    542695        </div>
     
    545698<?php
    546699
    547 // Check to see if the topic review is to be displayed.
     700// Check to see if the topic review is to be displayed
    548701if ($tid && $pun_config['o_topic_review'] != '0')
    549702{
    550703        require_once PUN_ROOT.'include/parser.php';
    551704
    552         $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('Impossible de retrouver le résumé de la discussion', __FILE__, __LINE__, $db->error());
    553 
    554 ?>
    555 
    556 <div id="postreview" class="blockpost">
     705        $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());
     706
     707?>
     708
     709<div id="postreview">
    557710        <h2><span><?php echo $lang_post['Topic review'] ?></span></h2>
    558711<?php
    559712
    560         //Set background switching on
    561         $bg_switch = true;
     713        // Set background switching on
    562714        $post_count = 0;
    563715
    564716        while ($cur_post = $db->fetch_assoc($result))
    565717        {
    566                 // Switch the background color for every message.
    567                 $bg_switch = ($bg_switch) ? $bg_switch = false : $bg_switch = true;
    568                 $vtbg = ($bg_switch) ? ' roweven' : ' rowodd';
    569718                $post_count++;
    570719
     
    572721
    573722?>
    574         <div class="box<?php echo $vtbg ?>">
    575                 <div class="inbox">
    576                         <div class="postleft">
    577                                 <dl>
    578                                         <dt><strong><?php echo pun_htmlspecialchars($cur_post['poster']) ?></strong></dt>
    579                                         <dd><?php echo format_time($cur_post['posted']) ?></dd>
    580                                 </dl>
     723        <div class="blockpost">
     724                <div class="box<?php echo ($post_count % 2 == 0) ? ' roweven' : ' rowodd' ?>">
     725                        <div class="inbox">
     726                                <div class="postbody">
     727                                        <div class="postleft">
     728                                                <dl>
     729                                                        <dt><strong><?php echo pun_htmlspecialchars($cur_post['poster']) ?></strong></dt>
     730                                                        <dd><span><?php echo format_time($cur_post['posted']) ?></span></dd>
     731                                                </dl>
     732                                        </div>
     733                                        <div class="postright">
     734                                                <div class="postmsg">
     735                                                        <?php echo $cur_post['message']."\n" ?>
     736                                                </div>
     737                                        </div>
     738                                </div>
     739                                <div class="clearer"></div>
    581740                        </div>
    582                         <div class="postright">
    583                                 <div class="postmsg">
    584                                         <?php echo $cur_post['message'] ?>
    585                                 </div>
    586                         </div>
    587                         <div class="clearer"></div>
    588741                </div>
    589742        </div>
Note: See TracChangeset for help on using the changeset viewer.