<?php
if(isset($s)){
include('search.php');
}
elseif(isset($p)){
if(!is_numeric($p)){
echo '<div id="error_page">'.hava_options('error_page').'</div>';
}
else{
// view single post ---------------------------
$postCat = hava_single_post($p, 'cat');
?>
<div class="article">
<h2><span><?php echo hava_single_post($p, 'title'); ?></span> </h2>
<p class="post-data"><span class="date"><?php echo hava_single_post($p, 'date'); ?></span> | Posted by <a href="#"><?php echo hava_single_post($p, 'author'); ?></a> | Filed under <a href="#"><?php echo $postCat; ?></a></p>
<p><?php echo hava_single_post($p, 'text'); ?></p>
</div>
<?php
include('comments.php');
}
}
else{
// view all posts or only post in a category -----------------
if(!isset($limit)) $limit=0; // SET to 0 to begin limiting posts (empty variable will view all posts) --------------------
if(isset($cat)){
$postResults = hava_posts($cat, $limit);
foreach($postResults as $row){
$postDate = hava_date($row['date']);
$postText = strip_tags($row['text'], '<p><br>'); // remove html tags, leave only <p> and <br>
?>
<div class="article">
<h2><span><?php echo $row['title']; ?></span> </h2>
<div class="clr"></div>
<p class="post-data"><a href="<?php echo $row['id']; ?>" class="com">Comments (<?=hava_num_comments($row['id']); ?>)</a> <span class="date"><?php echo $postDate; ?></span> | Posted by <a href="#"><?php echo $row['author']; ?></a> | Filed under <a href="#"><?php echo $row['cat']; ?></a></p>
<p><?php echo substr($postText, 0, 400); ?> </p>
<p class="spec"><a href="?p=<?php echo $row['id']; ?>" class="rm">Read more</a></p>
</div>
<?php
}
}
?>
<div class="article">
<div id="nav"><?php if(isset($cat)) echo hava_nav($cat, $limit); ?></div>
</div>
<?php
}
?>
</div>
<?php include('sidebar.php'); ?>