<?php

/*
   +----------------------------------------------------------------------+
   | Logging Class                                                        |
   | Author: Adam Goldberg                                                |
   +----------------------------------------------------------------------+
   | Copyright (c) 2008-2009 Adam J Goldberg                              |
   | This file is part of Lifebox.                                        |
   |                                                                      |
   | Lifebox is free software: you can redistribute it and/or modify      |
   | it under the terms of the GNU General Public License as published by |
   | the Free Software Foundation, either version 3 of the License, or    |
   | (at your option) any later version.                                  |
   |                                                                      |
   | Lifebox is distributed in the hope that it will be useful,           |
   | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
   | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        |
   | GNU General Public License for more details.                         |
   |                                                                      |
   | You should have received a copy of the GNU General Public License    |
   | along with Lifebox.  If not, see <http://www.gnu.org/licenses/>.     |
   +----------------------------------------------------------------------+
   | Index of Photos							  |
   +----------------------------------------------------------------------+
	function Log($type) {
	function addEvent($item,$old,$new) {
   +----------------------------------------------------------------------+
*/


class Log {

	var $type;

	/*****************************************************************
	 * Constructor
         *****************************************************************/
	function Log($type) {

		$this->type = $type;

	}

	/*****************************************************************
	 * Add Event
         *****************************************************************/
	function addEvent($item,$old,$new) {
	global $CONFIG;
	global $db;
	global $_USER;

		$timestamp = time();

		$query = "INSERT INTO ".$CONFIG['tbl_changelog']."
                          (item,member_id,ip,host,first,last,email,
                           timestamp_created,old,new,type)
                          VALUES ('".$item."',
                                  '".$_USER['id']."',
				  '".$_SERVER['REMOTE_ADDR']."',
                                  '".gethostbyaddr($_SERVER['REMOTE_ADDR'])."',
                                  '".$_USER['first']."',
                                  '".$_USER['last']."',
                                  '".$_USER['email']."',
                                  '".$timestamp."',
                                  '".$old."',
                                  '".$new."',
                                  '".$this->type."')";
                $result = $db->Execute($query);
		
		if ($result) {
			return true;
		} else {
			return false;
		}
	}

}
