<?
    
require_once('include/functions/table_exists.php');

    
$_back = isset($_GET['b']) ? str_replace('@''&'trim(strval($_GET['b']))) : 's=home';
    
$_link = isset($_POST['link']) ? intval($_POST['link']) : 0;
    
$_table = isset($_POST['table']) ? trim(strval($_POST['table'])) : '';
    
$_comment = isset($_POST['comment']) ? trim(strval($_POST['comment'])) : '';
    
    if (
$GLOBALS['auth']['id'])
    {
        if (
table_exists($_table))
        {
            if (
$_comment == '')
            {
                
make_cookie('notice''You cannot post a blank message.');
            }                
            if (!
mysql_num_rows(mysql_query("SELECT * FROM " $_table " WHERE id = " sq($_link))))
            {
                
make_cookie('notice''Sorry, but you can\'t comment on something that doesn\'t exist.');
            }
            
mysql_query("INSERT INTO " $_table "_comments SET link_id = " sq($_link) . ", user_id = '" $GLOBALS['auth']['id'] . "', comment = " sq(substr($_comment01024)));
        }
    }

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