function formatcomments($str,$row){
global $timezone, $newsusers, $newsfilter, $newssmilies, $newstemplates, $commentstimeformat, $commentslength;
....
if($_POST['ajax'] == true){
$pid = $_POST['id'];
}else{
$pid = $_GET['id'];
}
$str = str_replace("{pid}", $pid, $str);
// Only show the delete link if the author if $_SESSION['name'] is the same as the author of the comment
if($_SESSION['name'] == $row['user']){
$str = preg_replace('#\[delete-link\](.*?)\[\/delete-link\]#si', '<a href="?id=' . $pid . '&delete=' . $row['id'] . '">$1</a>' . $ddlink, $str);
}else{
$str = preg_replace('#\[delete-link\](.*?)\[\/delete-link\]#se', '', $str);
}
$delimiter = '<!-- ####@@@**split**@@@### -->';
require_once 'db.php';
require_once 'config.php';
require_once 'language/' . $default_index_language;
$_SESSION['language'] = str_replace(".php", "", $default_index_language);
if($_GET['delete']){
// Check the comment the user wants to delete belongs to them
// $_SESSION['name'] is where the username is stored when the user is logged in
if(count(DataAccess::fetch("SELECT id FROM $newscomments WHERE user = ? AND id = ?", $_SESSION['name'], $_GET['delete'])) > 0){
// the comment belongs to them so we can delete it
DataAccess::put("DELETE FROM $newscomments WHERE user = ? AND id = ?", $_SESSION['name'], $_GET['delete']);
}else{
// doesn't belong to them do something here
}
}
[delete-link]Delete[/delete-link]
session_name('n13news');