|
|
 |
THIS DIRECTORY SPONSORED BY

More to come... Please check back soon!
Connect($dsn,'rvcuser','rvcpass');
$url = null;
// echo $COM_CONF['dbhost'] . " " . $COM_CONF['dbuser'] . " " . $COM_CONF['dbpassword'];
// $comments_db_link = mssql_connect($COM_CONF['dbhost'],$COM_CONF['dbuser'],$COM_CONF['dbpassword']);
// mysql_connect($COM_CONF['dbhost'],$COM_CONF['dbuser'],$COM_CONF['dbpassword']);
// mysql_select_db($COM_CONF['dbname'], $comments_db_link);
// mssql_select_db($COM_CONF['dbname'], $comments_db_link);
main();
function main() {
global $url;
if ( isset( $_REQUEST['url'] )) {
$url = $_REQUEST['url'];
// echo $url;
// exit();
}
if ($_REQUEST['action'] == 'add'){
add();
}
elseif ($_REQUEST['action'] == 'unsub'){
unsub();
}
elseif (1) {
view();
}
}
function check_for_errors() {
global $db, $COM_CONF, $COM_LANG;
$ip = mysql_escape_string($_SERVER['REMOTE_ADDR']);
$db->Execute("SELECT ip FROM {$COM_CONF['dbbannedipstable']} WHERE ip='$ip'");
if (mssql_num_rows($result)>0) {
$error_message.=$COM_LANG['not_allowed'] . " ";
}
if ($_REQUEST['disc_name'] == '') {
$error_message.=$_REQUEST['r_disc_name'] . " ";
}
if ($_REQUEST['disc_body'] == '') {
$error_message.=$_REQUEST['r_disc_body'] . " ";
}
return $error_message;
}
function flood_protection($INPUT) {
global $db, $COM_CONF, $COM_LANG;
$db->Execute("select [time] from {$COM_CONF['dbmaintable']} where ip='{$_SERVER['REMOTE_ADDR']}' AND DATEDIFF( s, [time], getdate() ) < {$COM_CONF['anti_flood_pause']}");
if ($db->Affected_Rows()>0) {
$error_message="Flood detected";
return $error_message;
}
$db->Execute("select ID from {$COM_CONF['dbmaintable']} where text='{$INPUT['disc_body']}' AND author='{$INPUT['disc_name']}' AND href='{$INPUT['href']}'");
if ($db->Affected_Rows()>0) {
$error_message="Flood detected";
return $error_message;
}
return "";
}
function add() {
global $db, $url, $COM_CONF, $COM_LANG;
foreach ($_REQUEST as $key => $value) {
$_REQUEST[$key] = str_replace('<', '<', $_REQUEST[$key]);
$_REQUEST[$key] = str_replace('>', '>', $_REQUEST[$key]);
if (get_magic_quotes_gpc()) {
$_REQUEST[$key] = stripslashes($_REQUEST[$key]);
}
$_REQUEST[$key] = mysql_escape_string($_REQUEST[$key]);
}
$error_message = check_for_errors();
$error_message .= flood_protection($_REQUEST);
if ($error_message) {
print "The following errors occured: $error_message";
return 0;
}
if ($_REQUEST['dont_show_email'] != '') { $dont_show="1"; }
else { $dont_show="0"; }
$db->Execute("INSERT INTO {$COM_CONF['dbmaintable']} ( [time], href, text, author, email, dont_show_email, ip ) VALUES (getdate(), '{$url}', '{$_REQUEST['disc_body']}', '{$_REQUEST['disc_name']}', '{$_REQUEST['disc_email']}', '$dont_show', '{$_SERVER['REMOTE_ADDR']}')");
if ($_REQUEST['email_me'] != '' && $_REQUEST['disc_email'] != '') {
$rs = $db->Execute("select COUNT(*) from {$COM_CONF['dbemailstable']} where href='{$url}' AND email='{$_REQUEST['disc_email']}'");
list ($count) = $rs->fields;
if ($count == 0) {
$hash=md5($_REQUEST['disc_email'] . $COM_CONF['copy_random_seed']);
$db->Execute("INSERT INTO {$COM_CONF['dbemailstable']} ( email, href, hash) VALUES ('{$_REQUEST['disc_email']}', '{$url}', '$hash')");
}
}
if ($COM_CONF['email_admin']) {
notify_admin($url, $_REQUEST['disc_name'], $_REQUEST['disc_email'], stripslashes($_REQUEST['disc_body']), "{$_SERVER['REMOTE_ADDR']}, {$_SERVER['HTTP_USER_AGENT']}");
}
notify_users($url, $_REQUEST['disc_name'], $_REQUEST['disc_email']);
header("HTTP/1.1 302");
header("Location: {$_SERVER['HTTP_REFERER']}");
// header("Location: {$COM_CONF['site_url']}{$_REQUEST['href']}");
// print "Click here to get back.";
// echo "Location: {$COM_CONF['site_url']}{$_SERVER['HTTP_REFERER']}";
// exit();
}
function notify_admin($href, $name, $email, $text, $ip) {
global $comments_db_link, $COM_CONF, $COM_LANG;
$headers = "From: {$COM_CONF['email_from']}\r\n";
$text_of_message="
{$COM_LANG['email_new_comment']} $href
{$COM_LANG['email_from']}: $name <$email>
$text
$ip
";
mail($COM_CONF['email_admin'], "{$COM_LANG['email_new_comment']} $href", $text_of_message, $headers);
}
function notify_users($href, $name, $email_from) {
global $db, $COM_CONF, $COM_LANG;
$headers = "From: {$COM_CONF['email_from']}\r\n";
$rs = $db->Execute("select email, hash from {$COM_CONF['dbemailstable']} where href='$href'");
while (list($email, $hash) = $rs->fields) {
if ($email != $email_from) {
$text_of_message="
{$COM_LANG['email_new_comment']} $href
{$COM_LANG['email_from']}: $name
{$COM_LANG['email_to_unsubscribe']}
{$COM_CONF['site_url']}{$COM_CONF['script_url']}?action=unsub&page=$href&id=$hash
";
mail($email, "{$COM_LANG['email_new_comment']} $href",$text_of_message, $headers);
}
// echo $email . " " . $hash . " ";
$rs->MoveNext();
}
// exit();
}
function unsub() {
global $db, $COM_CONF, $COM_LANG;
$id=mysql_escape_string($_REQUEST['id']);
$href=mysql_escape_string($_REQUEST['page']);
$rs = $db->Execute("delete from {$COM_CONF['dbemailstable']} where href='$href' AND hash='$id'");
if ($db->Affected_Rows() > 0) {
print "{$COM_LANG['unsubscribed']}";
}
else {
print "{$COM_LANG['not_unsubscribed']}";
}
}
function view() {
global $db, $url, $COM_CONF, $COM_LANG;
$request_uri = mysql_escape_string( $url ); // mysql_escape_string($_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']);
// print_r ( $_SERVER );
// print_r ( $_REQUEST );
// echo $url;
// exit();
$sql = "select time, text, author, email, dont_show_email from {$COM_CONF['dbmaintable']} where href='$request_uri' order by time {$COM_CONF['sort_order']}";
// $result = mssql_query($sql, $comments_db_link);
$rs = $db->Execute($sql);
$comments_count=0;
$time=$text=$author=$email=$dont_show_email=array();
while (list($time[$comments_count], $text[$comments_count], $author[$comments_count], $email[$comments_count], $dont_show_email[$comments_count])= $rs->fields ) {
$time[$comments_count] = format_date($time[$comments_count]);
$comments_count++;
$rs->MoveNext();
}
require("templates\\{$COM_CONF['template']}.php");
}
function format_date ($date) {
global $COM_LANG;
$year = substr($date, 0, 4);
$month = intval(substr($date, 5, 2)) - 1;
$day = substr($date, 8, 2);
$hour = substr($date, 11, 2);
$min = substr($date, 14, 2);
// return "$day $month $year, $hour:$min";
return "$day {$COM_LANG['months'][$month]} $year, $hour:$min";
}
?>
Top of Page
|
|
 |
|