include('config.php');
include('header.php');
//get the comment id
$id = $_GET['id'];
if(isset($id))
{
//MODERATION HANDLING
$remove = $_GET['remove'];
if($remove != '' && $allRights['remove_comments'] & $rights)
{
$remove = mysql_real_escape_string($remove);
$database->query('DELETE FROM comments WHERE id='.$remove);
}
//END OF MODERATION HANDLING
include('ubb.php');
//clean the variabele
$id = mysql_real_escape_string($id);
//fetch the names of the writers
$writers = $database->query('SELECT username FROM writers', 'array');
//fetch the article
$article = $database->query('SELECT * FROM articles WHERE id='.$id, 'array');
//fix up the layout of the message body
$body = $article['text'];
$body = nl2br($body);
$body = parseubb($body);
//build an array with the social networking icons
$socialNetworking = $database->query('SELECT * FROM socialnetworkingicons', 'none');
if($socialNetworking && mysql_num_rows($socialNetworking) > 0)
{
while($icon = mysql_fetch_array($socialNetworking))
{
$snIcons[$icon['name']] = array($icon['imgurl'], $icon['siteurl']);
}
}
//set all the social networking icons for this post
$iconString = '';
$linkcount = 0;
foreach($snIcons AS $name => $url)
{
$siteUrlFixed = str_replace('{url}', urlencode('http://www.digi-online.net/do8/comments.php?id='.$article['id']), $url[1]);
$siteUrlFixed = str_replace('{title}', urlencode($article['title']), $siteUrlFixed);
//new line after this ammount of chars
if($linkcount == 5)
{
$linkcount = 0;
$a = '
';
}
else
{
$a = ' :: ';
$linkcount ++;
}
//create the icon string
$iconString .= ' '.$name.''.$a;
}
//make sure this can't be empty
if($iconString == '') $iconString = " ";
//start a new template engine for this message
$messageTemplate = new templateEngine;
$messageTemplate->setTemplate('templates/'.$currentTemplate.'/messagetemplate.tpl');
$messageTemplate->set('socialnetworking', $iconString);
//fetch the name of the category this article has been posted in
$catName = $database->query('SELECT name FROM categories WHERE id='.$article['cat'], 'result');
//fill in all fields for this template
$messageTemplate->set('title', $article['title']);
$messageTemplate->set('date', $article['date']);
$messageTemplate->set('text', $body);
$messageTemplate->set('cat', ''.$catName.'');
$messageTemplate->set('writer', $writers[$article['writer']-1]);
$messageTemplate->set('commentslink', ' ');
//display it
$content .= $messageTemplate->getLayout();
//from here, comments will follow
$content .= '
';
$content .= '