<?php
/*
CherryBB Copyright 2006 Liam Dawe
*/
// Check the group
check_group();
// permissions
$permissions = mysql_fetch_array(mysql_query("SELECT `cpost`,`cview` FROM `permissions` WHERE `group` = '" . quote_smart($_SESSION['group']) . "' AND `forum` = '" . quote_smart($_GET['f']) . "'"));
if ($permissions['cpost'] == '0' || $permissions['cview'] == '0')
{
message($lang['title']['no_post'],$lang['text']['no_post']);
}
// checked the topic is not locked
$temp = mysql_query("SELECT `locked` FROM `forum_topics` WHERE `id` = " . quote_smart($_GET['t']) );
print 'First function: ' . mysql_error() . '<br>';
$locked = mysql_fetch_array($temp);
print 'Second function: ' . mysql_error() . '<br>';
$query = "SELECT `locked` FROM `forum_topics` WHERE `id` = " . quote_smart($_GET['t']);
print 'Query is: ' . $query . '<br>';
echo "blah" . $locked['locked'] . "<br />";
print_r ($_GET);
if ($locked['locked'] == '1')
{
message($lang['title']['topic_locked'],$lang['text']['locked']);
}
else if (!isset($_GET['action']))
{
// Get the forum and category name from the url
$forum_name = mysql_fetch_array(mysql_query("SELECT `name`,`category` FROM `forums` WHERE `id` = '" . quote_smart($_GET['f']) . "'")) or die(mysql_error());
$category_name = mysql_fetch_array(mysql_query("SELECT `name` FROM `forums` WHERE `id` = '" . quote_smart($forum_name['category']) . "'"));
display_clickable_smilies_bbcode();
// if is topic
if ($_GET['ist'] == '1')
{
$edit_body = mysql_fetch_array(mysql_query("SELECT `body` FROM `forum_topic_text` WHERE `topic_id` = '" . quote_smart($_GET['t']) . "'"));
}
// if is reply
else if ($_GET['ist'] == '0')
{
$edit_body = mysql_fetch_array(mysql_query("SELECT `body` FROM `forum_reply_text` WHERE `reply_id` = '" . quote_smart($_GET['reply']) . "'"));
}
// make post readable for editing
message($lang['title']['topic_locked'],$lang['text']['locked']);
$edit_body['body'] = edit_post_parser($edit_body['body']);
// get the file to use
get_template('editpost');
}
// Edit Post
else if ($_GET['action'] == 'edit')
{
$locker_exists = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_topics` WHERE `id` = '" . quote_smart($_GET['t']) . "'"));
if ($locker_exists['locked'] == '1')
{
message($lang['title']['topic_locked'],$lang['text']['locked']);
}
else if (!isset($_GET['t']))
{
message($lang['title']['no_topic_id'],$lang['title']['no_topic_id']);
}
else if (empty($locker_exists))
{
message($lang['title']['no_topic_id'],$lang['title']['no_topic_id']);
}
else if (!isset($_POST['body1']))
{
message($lang['title']['no_body'],$lang['text']['no_body']);
}
else
{
if ($_GET['ist'] == '1')
{
// post parsing
main_post_parser();
// Insert the reply body
mysql_query("UPDATE `forum_topic_text` set `body` = '" . quote_smart($_POST['body1']) . "' WHERE `topic_id` = '" . quote_smart($_GET['t']) . "'") or die(mysql_error());
message($lang['title']['post_edited'], $lang['text']['post_edited']);
}
else if ($_GET['ist'] == '0')
{
// post parsing
main_post_parser();
// Insert the reply body
mysql_query("UPDATE `forum_reply_text` set `body` = '" . quote_smart($_POST['body1']) . "' WHERE `reply_id` = '" . quote_smart($_GET['reply']) . "'") or die(mysql_error());
message($lang['title']['post_edited'],$lang['text']['post_edited']);
}
}
}
?>