Changeset 3 for branches/rsr.v5.1.dev/web/punbb/post.php
- Timestamp:
- Nov 14, 2011, 11:17:15 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/rsr.v5.1.dev/web/punbb/post.php
r1 r3 1 1 <?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 9 define('PUN_ROOT', dirname(__FILE__).'/'); 27 10 require PUN_ROOT.'include/common.php'; 28 11 … … 39 22 // Fetch some info about the topic and/or the forum 40 23 if ($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()); 42 25 else 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()); 44 27 45 28 if (!$db->num_rows($result)) … … 47 30 48 31 $cur_posting = $db->fetch_assoc($result); 32 $is_subscribed = $tid && $cur_posting['is_subscribed']; 49 33 50 34 // Is someone trying to post into a redirect forum? … … 54 38 // Sort out who the moderators are and if we are currently a moderator (or an admin) 55 39 $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 42 if ($tid && $pun_config['o_censoring'] == '1') 43 $cur_posting['subject'] = censor_words($cur_posting['subject']); 57 44 58 45 // Do we have permission to post? … … 73 60 if (isset($_POST['form_sent'])) 74 61 { 75 // Make sure form_user is correct76 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 79 62 // 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']) 81 64 $errors[] = $lang_post['Flood start'].' '.$pun_user['g_post_flood'].' '.$lang_post['flood end']; 82 65 … … 86 69 $subject = pun_trim($_POST['req_subject']); 87 70 71 if ($pun_config['o_censoring'] == '1') 72 $censored_subject = pun_trim(censor_words($subject)); 73 88 74 if ($subject == '') 89 75 $errors[] = $lang_post['No subject']; 76 else if ($pun_config['o_censoring'] == '1' && $censored_subject == '') 77 $errors[] = $lang_post['No subject after censoring']; 90 78 else if (pun_strlen($subject) > 70) 91 79 $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_user80 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 97 85 if (!$pun_user['is_guest']) 98 86 { … … 103 91 else 104 92 { 105 $username = trim($_POST['req_username']);93 $username = pun_trim($_POST['req_username']); 106 94 $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 109 98 require PUN_ROOT.'lang/'.$pun_user['language'].'/prof_reg.php'; 110 99 require PUN_ROOT.'lang/'.$pun_user['language'].'/register.php'; 111 100 112 101 // 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); 137 103 138 104 if ($pun_config['p_force_guest_email'] == '1' || $email != '') … … 140 106 require PUN_ROOT.'include/email.php'; 141 107 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 } 143 119 } 144 120 } 145 121 146 122 // 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']; 155 130 156 131 // 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') 158 133 { 159 134 require PUN_ROOT.'include/parser.php'; … … 161 136 } 162 137 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'; 168 155 169 156 $now = time(); … … 172 159 if (empty($errors) && !isset($_POST['preview'])) 173 160 { 161 require PUN_ROOT.'include/search_idx.php'; 162 174 163 // If it's a reply 175 164 if ($tid) … … 177 166 if (!$pun_user['is_guest']) 178 167 { 168 $new_tid = $tid; 169 179 170 // 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()); 181 172 $new_pid = $db->insert_id(); 182 173 183 174 // To subscribe or not to subscribe, that ... 184 if ($pun_config['o_ subscriptions'] == '1' && $subscribe)175 if ($pun_config['o_topic_subscriptions'] == '1') 185 176 { 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()); 189 181 } 190 182 } … … 192 184 { 193 185 // 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()); 196 188 $new_pid = $db->insert_id(); 197 189 } 198 190 199 191 // 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()); 201 193 $num_replies = $db->result($result, 0) - 1; 202 194 203 195 // 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()); 205 197 206 198 update_search_index('post', $new_pid, $message); … … 209 201 210 202 // Should we send out notifications? 211 if ($pun_config['o_ subscriptions'] == '1')203 if ($pun_config['o_topic_subscriptions'] == '1') 212 204 { 213 205 // 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()); 215 207 $previous_post_time = $db->result($result); 216 208 217 209 // 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()); 219 211 if ($db->num_rows($result)) 220 212 { … … 223 215 $notification_emails = array(); 224 216 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 226 223 while ($cur_subscriber = $db->fetch_assoc($result)) 227 224 { 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? 229 226 if (!isset($notification_emails[$cur_subscriber['language']])) 230 227 { … … 246 243 $mail_message_full = trim(substr($mail_tpl_full, $first_crlf)); 247 244 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); 250 247 $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); 257 254 $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); 262 259 263 260 $notification_emails[$cur_subscriber['language']][0] = $mail_subject; … … 279 276 } 280 277 } 278 279 unset($cleaned_message); 281 280 } 282 281 } … … 286 285 { 287 286 // 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()); 289 288 $new_tid = $db->insert_id(); 290 289 … … 292 291 { 293 292 // 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()); 296 295 297 296 // 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()); 299 298 } 300 299 else 301 300 { 302 301 // 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()); 305 304 } 306 305 $new_pid = $db->insert_id(); 307 306 308 307 // 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()); 310 309 311 310 update_search_index('post', $new_pid, $message, $subject); 312 311 313 312 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); 314 411 } 315 412 … … 317 414 if (!$pun_user['is_guest']) 318 415 { 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()); 321 425 } 322 426 … … 326 430 327 431 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) 329 433 if ($tid) 330 434 { … … 332 436 $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;}">'; 333 437 334 // If a quote -id was specified in the url.438 // If a quote ID was specified in the url 335 439 if (isset($_GET['qid'])) 336 440 { … … 339 443 message($lang_common['Bad request']); 340 444 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()); 342 446 if (!$db->num_rows($result)) 343 447 message($lang_common['Bad request']); … … 345 449 list($q_poster, $q_message) = $db->fetch_row($result); 346 450 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 352 485 $q_message = pun_htmlspecialchars($q_message); 353 486 … … 377 510 } 378 511 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) 385 516 else if ($fid) 386 517 { 387 518 $action = $lang_post['Post new topic']; 388 519 $form = '<form id="post" method="post" action="post.php?action=post&fid='.$fid.'" onsubmit="return process_form(this)">'; 389 390 $forum_name = pun_htmlspecialchars($cur_posting['forum_name']);391 520 } 392 521 else … … 394 523 395 524 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']); 398 527 $focus_element = array('post'); 399 528 … … 406 535 } 407 536 537 define('PUN_ACTIVE_PAGE', 'index'); 408 538 require PUN_ROOT.'header.php'; 409 539 … … 411 541 <div class="linkst"> 412 542 <div class="inbox"> 413 <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> 543 <ul class="crumbs"> 544 <li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li> 545 <li><span>» </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>» </span><a href="viewtopic.php?id=<?php echo $tid ?>"><?php echo pun_htmlspecialchars($cur_posting['subject']) ?></a></li> 547 <?php endif; ?> <li><span>» </span><strong><?php echo $action ?></strong></li> 548 </ul> 414 549 </div> 415 550 </div> … … 425 560 <h2><span><?php echo $lang_post['Post errors'] ?></span></h2> 426 561 <div class="box"> 427 <div class="inbox ">562 <div class="inbox error-info"> 428 563 <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) 433 568 echo "\t\t\t\t".'<li><strong>'.$cur_error.'</strong></li>'."\n"; 434 569 ?> … … 451 586 <div class="box"> 452 587 <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> 456 593 </div> 457 594 </div> … … 468 605 469 606 ?> 470 <div class="blockform">607 <div id="postform" class="blockform"> 471 608 <h2><span><?php echo $action ?></span></h2> 472 609 <div class="box"> … … 477 614 <div class="infldset txtarea"> 478 615 <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é'; ?>" />480 616 <?php 481 617 482 618 if ($pun_user['is_guest']) 483 619 { 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']; 485 621 $email_form_name = ($pun_config['p_force_guest_email'] == '1') ? 'req_email' : 'email'; 486 622 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> 489 626 <div class="clearer"></div> 490 627 <?php … … 493 630 494 631 if ($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> 499 635 <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> 503 639 </ul> 504 640 </div> … … 507 643 508 644 $checkboxes = array(); 645 if ($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 509 648 if (!$pun_user['is_guest']) 510 649 { 511 650 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 } 516 669 } 517 670 else 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>'; 519 672 520 673 if (!empty($checkboxes)) … … 528 681 <div class="infldset"> 529 682 <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" ?> 531 684 </div> 532 685 </div> … … 538 691 ?> 539 692 </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> 541 694 </form> 542 695 </div> … … 545 698 <?php 546 699 547 // Check to see if the topic review is to be displayed .700 // Check to see if the topic review is to be displayed 548 701 if ($tid && $pun_config['o_topic_review'] != '0') 549 702 { 550 703 require_once PUN_ROOT.'include/parser.php'; 551 704 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"> 557 710 <h2><span><?php echo $lang_post['Topic review'] ?></span></h2> 558 711 <?php 559 712 560 //Set background switching on 561 $bg_switch = true; 713 // Set background switching on 562 714 $post_count = 0; 563 715 564 716 while ($cur_post = $db->fetch_assoc($result)) 565 717 { 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';569 718 $post_count++; 570 719 … … 572 721 573 722 ?> 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> 581 740 </div> 582 <div class="postright">583 <div class="postmsg">584 <?php echo $cur_post['message'] ?>585 </div>586 </div>587 <div class="clearer"></div>588 741 </div> 589 742 </div>
Note: See TracChangeset
for help on using the changeset viewer.