<?php

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

  Script: Maian Events v2.0
  Written by: David Ian Bennett
  E-Mail: support@maianscriptworld.co.uk
  Website: http://www.maianscriptworld.co.uk

  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  
  This File: class_comments.inc.php
  Description: Comments System Class
  New in v2.0

  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

class eventComments extends genericOptions {

var $prefix;

// Add comments to database..
function addCommentsToDatabase($DATA,$event,$approve)
{
  // 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,
               addDate,
               eventid,
               comments,
               is_active,
               is_approved
               ) VALUES (
               '{$DATA['name']}',
               '{$DATA['email']}',
               '".$this->getIP()."',
               '".date("Y-m-d")."',
               '{$event}',
               '{$DATA['comments']}',
               '".($approve ? '0' : '1')."',
               '".($approve ? '1' : '0')."'
               )") 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']
          );
}

}
