<?php
// ----------------------------------------------------------------------
// Copyright (C) 2007 by GREGORY LE BRAS
// ----------------------------------------------------------------------
// LICENSE
//
// This file is part of ODCNMS - Open DataCenter Network Management System
//
// ODCNMS 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 2 of the License, or
// (at your option) any later version.
//
// Foobar 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 Foobar; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// ----------------------------------------------------------------------
// Original Author of file: GREGORY LE BRAS - http://www.odcnms.org/
// ----------------------------------------------------------------------
// User Log Function
function user_log ($username,$name_table_users,$name_table_users_log,$action,$what,$description,$mysql_hostname,$mysql_username,$mysql_password,$mysql_database)
{
$db_connect=mysql_connect($mysql_hostname,$mysql_username,$mysql_password);
mysql_select_db($mysql_database,$db_connect);
$username=trim(htmlentities($username));
$action=trim(htmlentities($action));
$description=trim(htmlentities($description));
$currentdate = date('Y-m-d');
$currenttime = date("H:i:s");
$request=mysql_query("SELECT id FROM $name_table_users WHERE username=\"$username\"") or die ("ERROR!");
while($tmp_request=mysql_fetch_array($request))
{
$query=mysql_query("INSERT INTO $name_table_users_log VALUES ('',\"$tmp_request[id]\",\"$currentdate\",\"$currenttime\",\"$action\",\"$what\",\"$description\")") or die ("ERROR!");
if(!$query)
{
echo "ERROR!";
}
else
{
$_SESSION['user_log'] = "ok";
}
}
}
?>