<?php

/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2005 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* Based on Atomic Journal                                              */
/* Copyright (c) by Trevor Scott                                        */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
defined('MAXIMUS') or Header("Location: ../../index.php");

$module_name = "Journal";
get_lang($module_name);

$pagetitle = "- "._USERJOURNAL."";
incoh();
include_once("modules/$module_name/functions.php");

cookiedecode($user);
$username = $cookie[1];

startjournal($sitename,$user);

#####################################################
# Check to see if the current username matches the  #
# the name of the author recorded in the database.  #
# If not - inform them that there is a problem and  #
# to check their current username.		    #
#####################################################

$jid = $db->XMFnum($jid);
$sql = "SELECT * FROM `".$prefix."_journal` WHERE `jid` = '$jid'";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
	$owner = stripslashes($row['aid']);
	if ($owner != $username):
	max_openTable();
	echo "<div align=center>"._YOUWRONG."</div>";
	Max_CloseTable();
	br('1');
	journalfoot();
	die();
	endif;
	$sql = "DELETE FROM `".$prefix."_journal` WHERE `jid` = '$jid'";
	$db->sql_query($sql);
	$sql = "DELETE FROM `".$prefix."_journal_comments` WHERE `rid` = '$jid'";
	$db->sql_query($sql);
	br('1');
	max_openTable();
	echo "<div align=\"center\">"._ENTRYREMOVED."";
	br('2');
	echo "<a href=\"modules.php?name=$module_name&file=edit\">"._RETURNJOURNAL."</a></div>";
	Max_CloseTable();
}

journalfoot();