<?PHP
ob_start();
session_start();
include("includes/globals.php.inc");
include("includes/functions.php");
include("lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("lang/".$sxSetup['Language'].".php");
include("themes/$THEME_FOLDER/config.php.inc");
protectComponentPage(1);
if($StartSearch)
{
header("Location: search.php?type=journal&search=$search");
die();
}
$query = "SELECT id FROM $DB_Journal";
$result = mysql_query($query, $Link) or queryError("7", mysql_error());
$totalJournals = mysql_num_rows($result);
if(!$page)
$page = 1;
$start = ($page - 1)*$sxSetup['JournalsPerPage'];
$sxTitleAddendum = getComponentName("1");
include("themes/$THEME_FOLDER/header.php");
?>
<div class="bodyWrapper">
<h1><?PHP echo getComponentName("1"); ?></h1>
<?PHP echoMessage($message); ?>
<?PHP
if((userAdmin()) OR ((userEditor()) AND ($sxSetup['EditorRightsJournalAdd'])))
echo '<div class="journalAdd"><a href="admin/journal_add.php">' .$sxLang['JournalButtonAddNew'] . '</a></div>';
if(!$sxEntryID)
{
if($totalJournals > $sxSetup['JournalsPerPage'])
echo '<div style="padding-top:8px;padding-bottom:8px;font-size:10px;">';
pageTurns($PHP_SELF.'?', $totalJournals, $page, $sxSetup['JournalsPerPage']);
if($totalJournals > $sxSetup['JournalsPerPage'])
echo '</div>';
$sxQueryTail = " ORDER BY timestamp DESC LIMIT $start, ".$sxSetup['JournalsPerPage'];
}
else
{
$sxEntryID = intval($sxEntryID);
$sxQueryTail = " WHERE id='$sxEntryID'";
}
$query = "SELECT * FROM $DB_Journal".$sxQueryTail;
$result = mysql_query($query, $Link) or queryError("8", mysql_error());
while($ROW = mysql_fetch_object($result))
{
$query2 = "SELECT * FROM $DB_Users WHERE id='$ROW->userid'";
$result2 = mysql_query($query2, $Link) or queryError("190", mysql_error());
$ROW2 = mysql_fetch_object($result2);
echo '<div class="journalHead"><div class="journalTitle"><a name="' . $ROW->id . '" href="' . $_SERVER['PHP_SELF'] . '?sxEntryID=' . $ROW->id . '">' . $ROW->title . '</a></div><div class="journalBy">' . $sxLang['PostedBy'] . ': <a href="admin/profile_view.php?user=' . $ROW2->username . '">' . getUserFullName($ROW->userid) . '</a> - <span class="journalDate">' . fetchDate($ROW->timestamp, 1, 1) . '</span></div></div>'."\n";
if(userAdmin())
echo '<div class="journalControls"><a href="admin/journal_edit.php?entryid=' . $ROW->id . '">' . $sxLang['JournalButtonEditPost'] . '</a></div>'."\n";
echo '<div class="journalEntry">'.parseSpecial($ROW->entry).'</div>'."\n";
if($sxSetup['CommentsEnabled'])
{
echo '<div class="journalComments">'."\n";
echo '<a href="comments.php?previousPage=' . urlencode("http://{$HTTP_HOST}{$REQUEST_URI}") . '§ionid=1&rowid=' . $ROW->id . '">' . $sxLang['CommentsHeadingAdd'] . '</a>'."\n";
if($comments == $ROW->id)
{
echo ' <a href="' . $PHP_SELF . '?page=' . $page . '#' . $ROW->id . '">' . $sxLang['CommentsButtonHide'] . '</a>'."\n";
}
else
{
if(objectNumComments($ROW->id, 1))
{
echo ' <a href="' . $PHP_SELF . '?page=' . $page . '&comments=' . $ROW->id . '#' . $ROW->id . '">' . $sxLang['CommentsButtonView'] . ' (' . objectNumComments($ROW->id, 1) . ')</a>'."\n";
}
}
echo '</div>'."\n";
// View comments
if($comments == $ROW->id)
{
echo '<div class="sxCommentsTable">'."\n";
echo '<div class="sxCommentsTableHeader"><strong>' . $sxLang['CommentsItemComments'] . '</strong></div><div class="commentBy" style="">'."\n";
if($sxSetup['CommentsApproval'] == 1)
$appr = " AND approved='1' ";
$query2 = "SELECT * FROM $DB_Comments WHERE sectionid='1' AND rowid='$ROW->id' $appr ORDER BY timestamp DESC";
$result2 = mysql_query($query2, $Link) or queryError("11", mysql_error());
while($ROW2 = mysql_fetch_object($result2))
{
if($ROW2->email)
echo '<a href="mailto:' . $ROW2->email . '" rel="nofollow">';
if(($ROW2->name == '')AND($ROW2->email != ''))
echo '<strong>' . $ROW2->email . '</strong>';
else
echo '<strong>' . $ROW2->name . '</strong>';
if($ROW2->email)
echo '</a>';
echo ' - <span class="journalDate">';
echo fetchDate($ROW2->timestamp, 1, 1);
echo '</span><br />';
echo nl2br($ROW2->comments);
echo '<br /><br />';
}
if(userAdmin())
echo '<p align="right"><a href="admin/comments_manager.php">' . $sxLang['CommentsManageHeading'] . '</a></p>'."\n";
echo '</div></div>'."\n";
}
} // End if comments enabled
}
if(mysql_num_rows($result) == 0)
echo '<em>' . $sxLang['NoEntries'] . '</em>';
?>
<?PHP
if(!$sxEntryID)
{
if($totalJournals > $sxSetup['JournalsPerPage']) echo '<div style="padding-top:18px;padding-bottom:8px;font-size:10px;">';
pageTurns($PHP_SELF.'?', $totalJournals, $page, $sxSetup['JournalsPerPage']);
if($totalJournals > $sxSetup['JournalsPerPage']) echo '</div>';
}
?>
<span style="text-align:left;"><br /><form action="<?PHP echo $PHP_SELF; ?>" name="sxFormSearchJournal" method="post">
<input type="text" name="search" style="width:150px;" />
<input type="submit" name="StartSearch" value="<?PHP echo $sxLang['ButtonFind']; ?>" style="width:50px;" class="sxButton" />
</form>
</span>
<div style="text-align:right"><a href="content/rss.xml"><img src="images/rss20.gif" style="border: 0;" alt="RSS 2.0" /></a></div>
</div>
<?PHP
include("themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>