<?php
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Script: Maian Gallery v2.0
Written by: David Ian Bennett
E-Mail: hide@address.com
Website: http://www.maianscriptworld.co.uk
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
This File: class_comments.inc.php
Description: Comments System Class
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
class galleryComments extends genericOptions {
var $prefix;
// Is e-mail banned?
function isEmailBanned($email)
{
// Get domain for wildcard..
$domain = explode("@",$email);
$query = mysql_query("SELECT * FROM ".$this->prefix."banned
WHERE address = '{$email}'
OR address = '*{$domain[1]}'
LIMIT 1
") or die(mysql_error());
return (mysql_num_rows($query)>0 ? true : false);
}
// Has e-mail been verified?
function isEmailVerified($email)
{
$query = mysql_query("SELECT * FROM ".$this->prefix."allowed_emails
WHERE email = '{$email}'
LIMIT 1
") or die(mysql_error());
return (mysql_num_rows($query)>0 ? true : false);
}
// Add email to accepted addresses..
function addEmailtoDatabase($email)
{
mysql_query("INSERT INTO ".$this->prefix."allowed_emails (
email
) VALUES (
'{$email}'
)") or die(mysql_error());
}
// Add comments to database..
function addCommentsToDatabase($DATA,$approved,$live,$key,$image,$cat)
{
// Use callback function to prepare data for importing..
$DATA = array_map(array($this,'safe_import'),$DATA);
mysql_query("INSERT INTO ".$this->prefix."comments (
name,
email,
ip_address,
addDate,
catID,
imageID,
comments,
is_active,
is_approved,
verification_key
) VALUES (
'{$DATA['name']}',
'{$DATA['email']}',
'".$this->getIP()."',
'".date("Y-m-d")."',
'{$cat}',
'{$image}',
'{$DATA['comments']}',
'{$live}',
'{$approved}',
'{$key}'
)") or die(mysql_error());
}
// Update comments status after e-mail verification..
function updateCommentStatus($id,$approved,$live)
{
mysql_query("UPDATE ".$this->prefix."comments SET
is_active = '{$live}',
is_approved = '{$approved}'
WHERE id = '{$id}'
LIMIT 1
") or die(mysql_error());
}
// Get user ip address..
function getIP()
{
return (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] ?
$_SERVER['HTTP_X_FORWARDED_FOR'] :
$_SERVER['REMOTE_ADDR']
);
}
}