<?
    
require_once('include/functions/table_exists.php');
        
    
$_back = isset($_GET['b']) ? str_replace('@''&'trim(strval($_GET['b']))) : 's=home';
    
$_id = isset($_GET['i']) ? intval($_GET['i']) : 0;
    
$_link = (isset($_GET['link'])) ? intval($_GET['link']) : 0;
    
$_table = (isset($_GET['table'])) ? trim($_GET['table']) : '';
    
    if (
$GLOBALS['auth']['id'])
    {
        if (
table_exists($_table))
        {
            if (
mysql_num_rows(mysql_query("SELECT id FROM " $_table " WHERE id = " sq($_link))))
            {
                if (
$GLOBALS['auth']['root'])
                {
                    
mysql_query("DELETE FROM " $_table "_comments WHERE id = " sq($_id) . " AND link_id = " sq($_link));
                }
                else
                {
                    
mysql_query("DELETE FROM " $_table "_comments WHERE id = " sq($_id) . " AND link_id = " sq($_link) . " AND user_id = '" $GLOBALS['auth']['id'] . "'");
                }
            }
            else
            {
                
make_cookie('notice''Sorry, but you can\'t delete a comment that doesn\'t exist.');
            }
        }
    }

    
header('Location: ./?' $_back);
    die;
?>