punbb/delete.php
changeset 2 a8a21e1c7afa
parent 0 f9ffdbd96607
child 5 e3d7322305bf
--- a/punbb/delete.php	Wed Jul 11 21:28:39 2007 -0400
+++ b/punbb/delete.php	Thu Jul 12 01:04:01 2007 -0400
@@ -23,8 +23,11 @@
 ************************************************************************/
 
 
-define('PUN_ROOT', './');
-require PUN_ROOT.'include/common.php';
+//define('PUN_ROOT', './');
+//require PUN_ROOT.'include/common.php';
+
+global $pun_db, $pun_user, $pun_config, $lang_common;
+
 
 
 if ($pun_user['g_read_board'] == '0')
@@ -36,19 +39,19 @@
 	message($lang_common['Bad request']);
 
 // Fetch some info about the post, the topic and the forum
-$result = $db->query('SELECT f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.posted, t.closed, p.poster, p.poster_id, p.message, p.hide_smilies FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id 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 p.id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
-if (!$db->num_rows($result))
+$result = $pun_db->query('SELECT f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.posted, t.closed, p.poster, p.poster_id, p.message, p.hide_smilies FROM '.$pun_db->prefix.'posts AS p INNER JOIN '.$pun_db->prefix.'topics AS t ON t.id=p.topic_id 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 p.id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error());
+if (!$pun_db->num_rows($result))
 	message($lang_common['Bad request']);
 
-$cur_post = $db->fetch_assoc($result);
+$cur_post = $pun_db->fetch_assoc($result);
 
 // Sort out who the moderators are and if we are currently a moderator (or an admin)
 $mods_array = ($cur_post['moderators'] != '') ? unserialize($cur_post['moderators']) : array();
 $is_admmod = ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_id'] == PUN_MOD && array_key_exists($pun_user['username'], $mods_array))) ? true : false;
 
 // Determine whether this post is the "topic post" or not
-$result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$cur_post['tid'].' ORDER BY posted LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
-$topic_post_id = $db->result($result);
+$result = $pun_db->query('SELECT id FROM '.$pun_db->prefix.'posts WHERE topic_id='.$cur_post['tid'].' ORDER BY posted LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error());
+$topic_post_id = $pun_db->result($result);
 
 $is_topic_post = ($id == $topic_post_id) ? true : false;
 
@@ -77,7 +80,7 @@
 		delete_topic($cur_post['tid']);
 		update_forum($cur_post['fid']);
 
-		redirect('viewforum.php?id='.$cur_post['fid'], $lang_delete['Topic del redirect']);
+		pun_redirect('viewforum.php?id='.$cur_post['fid'], $lang_delete['Topic del redirect']);
 	}
 	else
 	{
@@ -85,7 +88,7 @@
 		delete_post($id, $cur_post['tid']);
 		update_forum($cur_post['fid']);
 
-		redirect('viewtopic.php?id='.$cur_post['tid'], $lang_delete['Post del redirect']);
+		pun_redirect('viewtopic.php?id='.$cur_post['tid'], $lang_delete['Post del redirect']);
 	}
 }