punbb/post.php
author Dan
Thu, 12 Jul 2007 01:04:01 -0400
changeset 2 a8a21e1c7afa
parent 0 f9ffdbd96607
permissions -rw-r--r--
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     1
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     2
/***********************************************************************
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     3
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     4
  Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     5
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     6
  This file is part of PunBB.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     7
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     8
  PunBB is free software; you can redistribute it and/or modify it
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     9
  under the terms of the GNU General Public License as published
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    10
  by the Free Software Foundation; either version 2 of the License,
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    11
  or (at your option) any later version.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    12
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    13
  PunBB is distributed in the hope that it will be useful, but
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    14
  WITHOUT ANY WARRANTY; without even the implied warranty of
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    15
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    16
  GNU General Public License for more details.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    17
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    18
  You should have received a copy of the GNU General Public License
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    19
  along with this program; if not, write to the Free Software
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    20
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    21
  MA  02111-1307  USA
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    22
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    23
************************************************************************/
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    24
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    25
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    26
//define('PUN_ROOT', './');
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    27
//require PUN_ROOT.'include/common.php';
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    28
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    29
global $pun_db, $pun_user, $pun_config, $lang_common;
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    30
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    31
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    32
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    33
if ($pun_user['g_read_board'] == '0')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    34
	message($lang_common['No view']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    35
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    36
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    37
$tid = isset($_GET['tid']) ? intval($_GET['tid']) : 0;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    38
$fid = isset($_GET['fid']) ? intval($_GET['fid']) : 0;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    39
if ($tid < 1 && $fid < 1 || $tid > 0 && $fid > 0)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    40
	message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    41
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    42
// Fetch some info about the topic and/or the forum
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    43
if ($tid)
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    44
	$result = $pun_db->query('SELECT f.id, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.subject, t.closed FROM '.$pun_db->prefix.'topics AS t INNER JOIN '.$pun_db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$pun_db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$tid) or error('Unable to fetch forum info', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    45
else
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    46
	$result = $pun_db->query('SELECT f.id, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics FROM '.$pun_db->prefix.'forums AS f LEFT JOIN '.$pun_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__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    47
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    48
if (!$pun_db->num_rows($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    49
	message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    50
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    51
$cur_posting = $pun_db->fetch_assoc($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    52
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    53
// Is someone trying to post into a redirect forum?
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    54
if ($cur_posting['redirect_url'] != '')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    55
	message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    56
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    57
// Sort out who the moderators are and if we are currently a moderator (or an admin)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    58
$mods_array = ($cur_posting['moderators'] != '') ? unserialize($cur_posting['moderators']) : array();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    59
$is_admmod = ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_id'] == PUN_MOD && array_key_exists($pun_user['username'], $mods_array))) ? true : false;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    60
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    61
// Do we have permission to post?
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    62
if ((($tid && (($cur_posting['post_replies'] == '' && $pun_user['g_post_replies'] == '0') || $cur_posting['post_replies'] == '0')) ||
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    63
	($fid && (($cur_posting['post_topics'] == '' && $pun_user['g_post_topics'] == '0') || $cur_posting['post_topics'] == '0')) ||
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    64
	(isset($cur_posting['closed']) && $cur_posting['closed'] == '1')) &&
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    65
	!$is_admmod)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    66
	message($lang_common['No permission']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    67
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    68
// Load the post.php language file
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    69
require PUN_ROOT.'lang/'.$pun_user['language'].'/post.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    70
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    71
// Start with a clean slate
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    72
$errors = array();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    73
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    74
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    75
// Did someone just hit "Submit" or "Preview"?
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    76
if (isset($_POST['form_sent']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    77
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    78
	// Make sure form_user is correct
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    79
	if (($pun_user['is_guest'] && $_POST['form_user'] != 'Guest') || (!$pun_user['is_guest'] && $_POST['form_user'] != $pun_user['username']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    80
		message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    81
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    82
	// Flood protection
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    83
	if (!$pun_user['is_guest'] && !isset($_POST['preview']) && $pun_user['last_post'] != '' && (time() - $pun_user['last_post']) < $pun_user['g_post_flood'])
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    84
		$errors[] = $lang_post['Flood start'].' '.$pun_user['g_post_flood'].' '.$lang_post['flood end'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    85
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    86
	// If it's a new topic
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    87
	if ($fid)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    88
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    89
		$subject = pun_trim($_POST['req_subject']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    90
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    91
		if ($subject == '')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    92
			$errors[] = $lang_post['No subject'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    93
		else if (pun_strlen($subject) > 70)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    94
			$errors[] = $lang_post['Too long subject'];
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    95
		else if ($pun_config['p_subject_all_caps'] == '0' && strtoupper($subject) == $subject && $pun_user['g_id'] < PUN_MOD)
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    96
			$subject = ucwords(strtolower($subject));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    97
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    98
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    99
	// If the user is logged in we get the username and e-mail from $pun_user
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   100
	if (!$pun_user['is_guest'])
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   101
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   102
		$username = $pun_user['username'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   103
		$email = $pun_user['email'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   104
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   105
	// Otherwise it should be in $_POST
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   106
	else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   107
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   108
		$username = trim($_POST['req_username']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   109
		$email = strtolower(trim(($pun_config['p_force_guest_email'] == '1') ? $_POST['req_email'] : $_POST['email']));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   110
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   111
		// Load the register.php/profile.php language files
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   112
		require PUN_ROOT.'lang/'.$pun_user['language'].'/prof_reg.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   113
		require PUN_ROOT.'lang/'.$pun_user['language'].'/register.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   114
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   115
		// It's a guest, so we have to validate the username
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   116
		if (strlen($username) < 2)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   117
			$errors[] = $lang_prof_reg['Username too short'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   118
		else if (!strcasecmp($username, 'Guest') || !strcasecmp($username, $lang_common['Guest']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   119
			$errors[] = $lang_prof_reg['Username guest'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   120
		else if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $username))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   121
			$errors[] = $lang_prof_reg['Username IP'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   122
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   123
		if ((strpos($username, '[') !== false || strpos($username, ']') !== false) && strpos($username, '\'') !== false && strpos($username, '"') !== false)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   124
			$errors[] = $lang_prof_reg['Username reserved chars'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   125
		if (preg_match('#\[b\]|\[/b\]|\[u\]|\[/u\]|\[i\]|\[/i\]|\[color|\[/color\]|\[quote\]|\[quote=|\[/quote\]|\[code\]|\[/code\]|\[img\]|\[/img\]|\[url|\[/url\]|\[email|\[/email\]#i', $username))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   126
			$errors[] = $lang_prof_reg['Username BBCode'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   127
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   128
		// Check username for any censored words
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   129
		$temp = censor_words($username);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   130
		if ($temp != $username)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   131
			$errors[] = $lang_register['Username censor'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   132
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   133
		// Check that the username (or a too similar username) is not already registered
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   134
		$result = $pun_db->query('SELECT username FROM '.$pun_db->prefix.'users WHERE (username=\''.$pun_db->escape($username).'\' OR username=\''.$pun_db->escape(preg_replace('/[^\w]/', '', $username)).'\') AND id>1') or error('Unable to fetch user info', __FILE__, __LINE__, $pun_db->error());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   135
		if ($pun_db->num_rows($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   136
		{
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   137
			$busy = $pun_db->result($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   138
			$errors[] = $lang_register['Username dupe 1'].' '.pun_htmlspecialchars($busy).'. '.$lang_register['Username dupe 2'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   139
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   140
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   141
		if ($pun_config['p_force_guest_email'] == '1' || $email != '')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   142
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   143
			require PUN_ROOT.'include/email.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   144
			if (!is_valid_email($email))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   145
				$errors[] = $lang_common['Invalid e-mail'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   146
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   147
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   148
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   149
	// Clean up message from POST
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   150
	$message = pun_linebreaks(pun_trim($_POST['req_message']));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   151
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   152
	if ($message == '')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   153
		$errors[] = $lang_post['No message'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   154
	else if (strlen($message) > 65535)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   155
		$errors[] = $lang_post['Too long message'];
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   156
	else if ($pun_config['p_message_all_caps'] == '0' && strtoupper($message) == $message && $pun_user['g_id'] < PUN_MOD)
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   157
		$message = ucwords(strtolower($message));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   158
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   159
	// Validate BBCode syntax
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   160
	if ($pun_config['p_message_bbcode'] == '1' && strpos($message, '[') !== false && strpos($message, ']') !== false)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   161
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   162
		require PUN_ROOT.'include/parser.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   163
		$message = preparse_bbcode($message, $errors);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   164
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   165
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   166
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   167
	require PUN_ROOT.'include/search_idx.php';
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   168
  global $db, $session, $paths, $template, $plugins; // Common objects
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   169
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   170
	$hide_smilies = isset($_POST['hide_smilies']) ? 1 : 0;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   171
	$subscribe = isset($_POST['subscribe']) ? 1 : 0;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   172
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   173
	$now = time();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   174
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   175
	// Did everything go according to plan?
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   176
	if (empty($errors) && !isset($_POST['preview']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   177
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   178
		// If it's a reply
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   179
		if ($tid)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   180
		{
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   181
			if ($session->user_logged_in)
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   182
			{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   183
				// Insert the new post
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   184
				$pun_db->query('INSERT INTO '.$pun_db->prefix.'posts (poster, poster_id, poster_ip, message, hide_smilies, posted, topic_id) VALUES(\''.$pun_db->escape($username).'\', '.$pun_user['id'].', \''.get_remote_address().'\', \''.$pun_db->escape($message).'\', \''.$hide_smilies.'\', '.$now.', '.$tid.')') or error('Unable to create post', __FILE__, __LINE__, $pun_db->error());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   185
				$new_pid = $pun_db->insert_id();
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   186
      
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   187
				// To subscribe or not to subscribe, that ...
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   188
				if ($pun_config['o_subscriptions'] == '1' && $subscribe)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   189
				{
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   190
					$result = $pun_db->query('SELECT 1 FROM '.$pun_db->prefix.'subscriptions WHERE user_id='.$pun_user['id'].' AND topic_id='.$tid) or error('Unable to fetch subscription info', __FILE__, __LINE__, $pun_db->error());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   191
					if (!$pun_db->num_rows($result))
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   192
						$pun_db->query('INSERT INTO '.$pun_db->prefix.'subscriptions (user_id, topic_id) VALUES('.$pun_user['id'].' ,'.$tid.')') or error('Unable to add subscription', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   193
				}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   194
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   195
			else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   196
			{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   197
				// It's a guest. Insert the new post
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   198
				$email_sql = ($pun_config['p_force_guest_email'] == '1' || $email != '') ? '\''.$email.'\'' : 'NULL';
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   199
				$pun_db->query('INSERT INTO '.$pun_db->prefix.'posts (poster, poster_ip, poster_email, message, hide_smilies, posted, topic_id) VALUES(\''.$pun_db->escape($username).'\', \''.get_remote_address().'\', '.$email_sql.', \''.$pun_db->escape($message).'\', \''.$hide_smilies.'\', '.$now.', '.$tid.')') or error('Unable to create post', __FILE__, __LINE__, $pun_db->error());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   200
				$new_pid = $pun_db->insert_id();
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   201
			}
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   202
      
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   203
			// Count number of replies in the topic
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   204
			$result = $pun_db->query('SELECT COUNT(id) FROM '.$pun_db->prefix.'posts WHERE topic_id='.$tid) or error('Unable to fetch post count for topic', __FILE__, __LINE__, $pun_db->error());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   205
			$num_replies = $pun_db->result($result, 0) - 1;
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   206
      
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   207
			// Update topic
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   208
			$pun_db->query('UPDATE '.$pun_db->prefix.'topics SET num_replies='.$num_replies.', last_post='.$now.', last_post_id='.$new_pid.', last_poster=\''.$pun_db->escape($username).'\' WHERE id='.$tid) or error('Unable to update topic', __FILE__, __LINE__, $pun_db->error());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   209
      
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   210
			update_search_index('post', $new_pid, $message);
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   211
      
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   212
			update_forum($cur_posting['id']);
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   213
      
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   214
			// Should we send out notifications?
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   215
			if ($pun_config['o_subscriptions'] == '1')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   216
			{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   217
				// Get the post time for the previous post in this topic
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   218
				$result = $pun_db->query('SELECT posted FROM '.$pun_db->prefix.'posts WHERE topic_id='.$tid.' ORDER BY id DESC LIMIT 1, 1') or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   219
				$previous_post_time = $pun_db->result($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   220
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   221
				// Get any subscribed users that should be notified (banned users are NOT excluded in Enano)
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   222
				$result = $pun_db->query('SELECT u.id, eu.email, u.notify_with_post, u.language FROM '.$pun_db->prefix.'users AS u LEFT JOIN '.table_prefix.'users AS eu ON eu.user_id=u.id INNER JOIN '.$pun_db->prefix.'subscriptions AS s ON u.id=s.user_id LEFT JOIN '.$pun_db->prefix.'forum_perms AS fp ON (fp.forum_id='.$cur_posting['id'].' AND fp.group_id=u.group_id) LEFT JOIN '.$pun_db->prefix.'online AS o ON u.id=o.user_id WHERE COALESCE(o.logged, u.last_visit)>'.$previous_post_time.' AND (fp.read_forum IS NULL OR fp.read_forum=1) AND s.topic_id='.$tid.' AND u.id!='.intval($pun_user['id'])) or error('Unable to fetch subscription info', __FILE__, __LINE__, $pun_db->error());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   223
				if ($pun_db->num_rows($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   224
				{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   225
					require_once PUN_ROOT.'include/email.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   226
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   227
					$notification_emails = array();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   228
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   229
					// Loop through subscribed users and send e-mails
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   230
					while ($cur_subscriber = $pun_db->fetch_assoc($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   231
					{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   232
						// Is the subscription e-mail for $cur_subscriber['language'] cached or not?
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   233
						if (!isset($notification_emails[$cur_subscriber['language']]))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   234
						{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   235
							if (file_exists(PUN_ROOT.'lang/'.$cur_subscriber['language'].'/mail_templates/new_reply.tpl'))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   236
							{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   237
								// Load the "new reply" template
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   238
								$mail_tpl = trim(file_get_contents(PUN_ROOT.'lang/'.$cur_subscriber['language'].'/mail_templates/new_reply.tpl'));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   239
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   240
								// Load the "new reply full" template (with post included)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   241
								$mail_tpl_full = trim(file_get_contents(PUN_ROOT.'lang/'.$cur_subscriber['language'].'/mail_templates/new_reply_full.tpl'));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   242
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   243
								// The first row contains the subject (it also starts with "Subject:")
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   244
								$first_crlf = strpos($mail_tpl, "\n");
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   245
								$mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   246
								$mail_message = trim(substr($mail_tpl, $first_crlf));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   247
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   248
								$first_crlf = strpos($mail_tpl_full, "\n");
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   249
								$mail_subject_full = trim(substr($mail_tpl_full, 8, $first_crlf-8));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   250
								$mail_message_full = trim(substr($mail_tpl_full, $first_crlf));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   251
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   252
								$mail_subject = str_replace('<topic_subject>', '\''.$cur_posting['subject'].'\'', $mail_subject);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   253
								$mail_message = str_replace('<topic_subject>', '\''.$cur_posting['subject'].'\'', $mail_message);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   254
								$mail_message = str_replace('<replier>', $username, $mail_message);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   255
								$mail_message = str_replace('<post_url>', $pun_config['o_base_url'].'/viewtopic.php?pid='.$new_pid.'#p'.$new_pid, $mail_message);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   256
								$mail_message = str_replace('<unsubscribe_url>', $pun_config['o_base_url'].'/misc.php?unsubscribe='.$tid, $mail_message);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   257
								$mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'].' '.$lang_common['Mailer'], $mail_message);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   258
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   259
								$mail_subject_full = str_replace('<topic_subject>', '\''.$cur_posting['subject'].'\'', $mail_subject_full);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   260
								$mail_message_full = str_replace('<topic_subject>', '\''.$cur_posting['subject'].'\'', $mail_message_full);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   261
								$mail_message_full = str_replace('<replier>', $username, $mail_message_full);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   262
								$mail_message_full = str_replace('<message>', $message, $mail_message_full);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   263
								$mail_message_full = str_replace('<post_url>', $pun_config['o_base_url'].'/viewtopic.php?pid='.$new_pid.'#p'.$new_pid, $mail_message_full);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   264
								$mail_message_full = str_replace('<unsubscribe_url>', $pun_config['o_base_url'].'/misc.php?unsubscribe='.$tid, $mail_message_full);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   265
								$mail_message_full = str_replace('<board_mailer>', $pun_config['o_board_title'].' '.$lang_common['Mailer'], $mail_message_full);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   266
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   267
								$notification_emails[$cur_subscriber['language']][0] = $mail_subject;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   268
								$notification_emails[$cur_subscriber['language']][1] = $mail_message;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   269
								$notification_emails[$cur_subscriber['language']][2] = $mail_subject_full;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   270
								$notification_emails[$cur_subscriber['language']][3] = $mail_message_full;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   271
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   272
								$mail_subject = $mail_message = $mail_subject_full = $mail_message_full = null;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   273
							}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   274
						}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   275
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   276
						// We have to double check here because the templates could be missing
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   277
						if (isset($notification_emails[$cur_subscriber['language']]))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   278
						{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   279
							if ($cur_subscriber['notify_with_post'] == '0')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   280
								pun_mail($cur_subscriber['email'], $notification_emails[$cur_subscriber['language']][0], $notification_emails[$cur_subscriber['language']][1]);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   281
							else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   282
								pun_mail($cur_subscriber['email'], $notification_emails[$cur_subscriber['language']][2], $notification_emails[$cur_subscriber['language']][3]);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   283
						}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   284
					}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   285
				}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   286
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   287
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   288
		// If it's a new topic
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   289
		else if ($fid)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   290
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   291
			// Create the topic
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   292
			$pun_db->query('INSERT INTO '.$pun_db->prefix.'topics (poster, subject, posted, last_post, last_poster, forum_id) VALUES(\''.$pun_db->escape($username).'\', \''.$pun_db->escape($subject).'\', '.$now.', '.$now.', \''.$pun_db->escape($username).'\', '.$fid.')') or error('Unable to create topic', __FILE__, __LINE__, $pun_db->error());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   293
			$new_tid = $pun_db->insert_id();
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   294
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   295
			if (!$pun_user['is_guest'])
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   296
			{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   297
				// To subscribe or not to subscribe, that ...
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   298
				if ($pun_config['o_subscriptions'] == '1' && (isset($_POST['subscribe']) && $_POST['subscribe'] == '1'))
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   299
					$pun_db->query('INSERT INTO '.$pun_db->prefix.'subscriptions (user_id, topic_id) VALUES('.$pun_user['id'].' ,'.$new_tid.')') or error('Unable to add subscription', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   300
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   301
				// Create the post ("topic post")
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   302
				$pun_db->query('INSERT INTO '.$pun_db->prefix.'posts (poster, poster_id, poster_ip, message, hide_smilies, posted, topic_id) VALUES(\''.$pun_db->escape($username).'\', '.$pun_user['id'].', \''.get_remote_address().'\', \''.$pun_db->escape($message).'\', \''.$hide_smilies.'\', '.$now.', '.$new_tid.')') or error('Unable to create post', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   303
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   304
			else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   305
			{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   306
				// Create the post ("topic post")
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   307
				$email_sql = ($pun_config['p_force_guest_email'] == '1' || $email != '') ? '\''.$email.'\'' : 'NULL';
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   308
				$pun_db->query('INSERT INTO '.$pun_db->prefix.'posts (poster, poster_ip, poster_email, message, hide_smilies, posted, topic_id) VALUES(\''.$pun_db->escape($username).'\', \''.get_remote_address().'\', '.$email_sql.', \''.$pun_db->escape($message).'\', \''.$hide_smilies.'\', '.$now.', '.$new_tid.')') or error('Unable to create post', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   309
			}
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   310
			$new_pid = $pun_db->insert_id();
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   311
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   312
			// Update the topic with last_post_id
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   313
			$pun_db->query('UPDATE '.$pun_db->prefix.'topics SET last_post_id='.$new_pid.' WHERE id='.$new_tid) or error('Unable to update topic', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   314
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   315
			update_search_index('post', $new_pid, $message, $subject);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   316
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   317
			update_forum($fid);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   318
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   319
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   320
		// If the posting user is logged in, increment his/her post count
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   321
		if (!$pun_user['is_guest'])
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   322
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   323
			$low_prio = ($db_type == 'mysql') ? 'LOW_PRIORITY ' : '';
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   324
			$pun_db->query('UPDATE '.$low_prio.$pun_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__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   325
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   326
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   327
		pun_redirect('viewtopic.php?pid='.$new_pid.'#p'.$new_pid, $lang_post['Post redirect']);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   328
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   329
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   330
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   331
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   332
// If a topic id was specified in the url (it's a reply).
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   333
if ($tid)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   334
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   335
	$action = $lang_post['Post a reply'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   336
	$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;}">';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   337
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   338
	// If a quote-id was specified in the url.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   339
	if (isset($_GET['qid']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   340
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   341
		$qid = intval($_GET['qid']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   342
		if ($qid < 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   343
			message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   344
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   345
		$result = $pun_db->query('SELECT poster, message FROM '.$pun_db->prefix.'posts WHERE id='.$qid.' AND topic_id='.$tid) or error('Unable to fetch quote info', __FILE__, __LINE__, $pun_db->error());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   346
		if (!$pun_db->num_rows($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   347
			message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   348
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   349
		list($q_poster, $q_message) = $pun_db->fetch_row($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   350
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   351
		$q_message = str_replace('[img]', '[url]', $q_message);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   352
		$q_message = str_replace('[/img]', '[/url]', $q_message);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   353
		$q_message = pun_htmlspecialchars($q_message);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   354
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   355
		if ($pun_config['p_message_bbcode'] == '1')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   356
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   357
			// If username contains a square bracket, we add "" or '' around it (so we know when it starts and ends)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   358
			if (strpos($q_poster, '[') !== false || strpos($q_poster, ']') !== false)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   359
			{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   360
				if (strpos($q_poster, '\'') !== false)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   361
					$q_poster = '"'.$q_poster.'"';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   362
				else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   363
					$q_poster = '\''.$q_poster.'\'';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   364
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   365
			else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   366
			{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   367
				// Get the characters at the start and end of $q_poster
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   368
				$ends = substr($q_poster, 0, 1).substr($q_poster, -1, 1);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   369
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   370
				// Deal with quoting "Username" or 'Username' (becomes '"Username"' or "'Username'")
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   371
				if ($ends == '\'\'')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   372
					$q_poster = '"'.$q_poster.'"';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   373
				else if ($ends == '""')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   374
					$q_poster = '\''.$q_poster.'\'';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   375
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   376
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   377
			$quote = '[quote='.$q_poster.']'.$q_message.'[/quote]'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   378
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   379
		else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   380
			$quote = '> '.$q_poster.' '.$lang_common['wrote'].':'."\n\n".'> '.$q_message."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   381
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   382
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   383
	$forum_name = '<a href="viewforum.php?id='.$cur_posting['id'].'">'.pun_htmlspecialchars($cur_posting['forum_name']).'</a>';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   384
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   385
// If a forum_id was specified in the url (new topic).
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   386
else if ($fid)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   387
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   388
	$action = $lang_post['Post new topic'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   389
	$form = '<form id="post" method="post" action="post.php?action=post&amp;fid='.$fid.'" onsubmit="return process_form(this)">';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   390
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   391
	$forum_name = pun_htmlspecialchars($cur_posting['forum_name']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   392
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   393
else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   394
	message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   395
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   396
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   397
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$action;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   398
$required_fields = array('req_email' => $lang_common['E-mail'], 'req_subject' => $lang_common['Subject'], 'req_message' => $lang_common['Message']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   399
$focus_element = array('post');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   400
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   401
if (!$pun_user['is_guest'])
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   402
	$focus_element[] = ($fid) ? 'req_subject' : 'req_message';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   403
else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   404
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   405
	$required_fields['req_username'] = $lang_post['Guest name'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   406
	$focus_element[] = 'req_username';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   407
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   408
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   409
require PUN_ROOT.'header.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   410
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   411
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   412
<div class="linkst">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   413
	<div class="inbox">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   414
		<ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li><li>&nbsp;&raquo;&nbsp;<?php echo $forum_name ?><?php if (isset($cur_posting['subject'])) echo '</li><li>&nbsp;&raquo;&nbsp;'.pun_htmlspecialchars($cur_posting['subject']) ?></li></ul>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   415
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   416
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   417
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   418
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   419
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   420
// If there are errors, we display them
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   421
if (!empty($errors))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   422
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   423
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   424
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   425
<div id="posterror" class="block">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   426
	<h2><span><?php echo $lang_post['Post errors'] ?></span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   427
	<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   428
		<div class="inbox">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   429
			<p><?php echo $lang_post['Post errors info'] ?></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   430
			<ul>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   431
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   432
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   433
	while (list(, $cur_error) = each($errors))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   434
		echo "\t\t\t\t".'<li><strong>'.$cur_error.'</strong></li>'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   435
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   436
			</ul>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   437
		</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   438
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   439
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   440
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   441
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   442
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   443
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   444
else if (isset($_POST['preview']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   445
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   446
	require_once PUN_ROOT.'include/parser.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   447
	$preview_message = parse_message($message, $hide_smilies);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   448
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   449
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   450
<div id="postpreview" class="blockpost">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   451
	<h2><span><?php echo $lang_post['Post preview'] ?></span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   452
	<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   453
		<div class="inbox">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   454
			<div class="postright">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   455
				<div class="postmsg">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   456
					<?php echo $preview_message."\n" ?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   457
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   458
			</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   459
		</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   460
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   461
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   462
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   463
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   464
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   465
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   466
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   467
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   468
$cur_index = 1;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   469
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   470
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   471
<div class="blockform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   472
	<h2><span><?php echo $action ?></span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   473
	<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   474
		<?php echo $form."\n" ?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   475
			<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   476
				<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   477
					<legend><?php echo $lang_common['Write message legend'] ?></legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   478
					<div class="infldset txtarea">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   479
						<input type="hidden" name="form_sent" value="1" />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   480
						<input type="hidden" name="form_user" value="<?php echo (!$pun_user['is_guest']) ? pun_htmlspecialchars($pun_user['username']) : 'Guest'; ?>" />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   481
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   482
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   483
if ($pun_user['is_guest'])
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   484
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   485
	$email_label = ($pun_config['p_force_guest_email'] == '1') ? '<strong>'.$lang_common['E-mail'].'</strong>' : $lang_common['E-mail'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   486
	$email_form_name = ($pun_config['p_force_guest_email'] == '1') ? 'req_email' : 'email';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   487
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   488
?>						<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>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   489
						<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>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   490
						<div class="clearer"></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   491
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   492
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   493
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   494
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   495
if ($fid): ?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   496
						<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>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   497
<?php endif; ?>						<label><strong><?php echo $lang_common['Message'] ?></strong><br />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   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>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   499
						<ul class="bblinks">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   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>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   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>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   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>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   503
						</ul>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   504
					</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   505
				</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   506
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   507
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   508
$checkboxes = array();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   509
if (!$pun_user['is_guest'])
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   510
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   511
	if ($pun_config['o_smilies'] == '1')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   512
		$checkboxes[] = '<label><input type="checkbox" name="hide_smilies" value="1" tabindex="'.($cur_index++).'"'.(isset($_POST['hide_smilies']) ? ' checked="checked"' : '').' />'.$lang_post['Hide smilies'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   513
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   514
	if ($pun_config['o_subscriptions'] == '1')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   515
		$checkboxes[] = '<label><input type="checkbox" name="subscribe" value="1" tabindex="'.($cur_index++).'"'.(isset($_POST['subscribe']) ? ' checked="checked"' : '').' />'.$lang_post['Subscribe'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   516
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   517
else if ($pun_config['o_smilies'] == '1')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   518
	$checkboxes[] = '<label><input type="checkbox" name="hide_smilies" value="1" tabindex="'.($cur_index++).'"'.(isset($_POST['hide_smilies']) ? ' checked="checked"' : '').' />'.$lang_post['Hide smilies'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   519
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   520
if (!empty($checkboxes))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   521
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   522
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   523
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   524
			</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   525
			<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   526
				<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   527
					<legend><?php echo $lang_common['Options'] ?></legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   528
					<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   529
						<div class="rbox">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   530
							<?php echo implode('<br /></label>'."\n\t\t\t\t", $checkboxes).'<br /></label>'."\n" ?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   531
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   532
					</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   533
				</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   534
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   535
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   536
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   537
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   538
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   539
			</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   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>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   541
		</form>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   542
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   543
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   544
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   545
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   546
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   547
// Check to see if the topic review is to be displayed.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   548
if ($tid && $pun_config['o_topic_review'] != '0')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   549
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   550
	require_once PUN_ROOT.'include/parser.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   551
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   552
	$result = $pun_db->query('SELECT poster, message, hide_smilies, posted FROM '.$pun_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__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   553
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   554
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   555
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   556
<div id="postreview" class="blockpost">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   557
	<h2><span><?php echo $lang_post['Topic review'] ?></span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   558
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   559
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   560
	//Set background switching on
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   561
	$bg_switch = true;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   562
	$post_count = 0;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   563
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   564
	while ($cur_post = $pun_db->fetch_assoc($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   565
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   566
		// Switch the background color for every message.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   567
		$bg_switch = ($bg_switch) ? $bg_switch = false : $bg_switch = true;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   568
		$vtbg = ($bg_switch) ? ' roweven' : ' rowodd';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   569
		$post_count++;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   570
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   571
		$cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   572
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   573
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   574
	<div class="box<?php echo $vtbg ?>">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   575
		<div class="inbox">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   576
			<div class="postleft">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   577
				<dl>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   578
					<dt><strong><?php echo pun_htmlspecialchars($cur_post['poster']) ?></strong></dt>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   579
					<dd><?php echo format_time($cur_post['posted']) ?></dd>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   580
				</dl>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   581
			</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   582
			<div class="postright">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   583
				<div class="postmsg">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   584
					<?php echo $cur_post['message'] ?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   585
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   586
			</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   587
			<div class="clearer"></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   588
		</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   589
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   590
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   591
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   592
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   593
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   594
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   595
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   596
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   597
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   598
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   599
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   600
require PUN_ROOT.'footer.php';