<?php

function LoginHistory($SUCSESS = false,$USER_ID = false,$LOGIN = false,$PROFILE=false)
{
    global $_SYSTEM;
    //,$IP = $_SERVER['REMOTE_ADDR'],$REQUEST_METHOD = $_SERVER['REQUEST_METHOD'],$HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'],$QUERY_STRING = $_SERVER['QUERY_STRING'],$LDATA = date("Y-m-d H:i:s")
    $sql = "INSERT INTO LOGIN_HISTORY (IP,REQUEST_METHOD,HTTP_USER_AGENT,QUERY_STRING,SUCSESS,USER_ID,LOGIN,PROFILE,LDATA) values ('".$_SERVER['REMOTE_ADDR']."','".$_SERVER['REQUEST_METHOD']."','".$_SERVER['HTTP_USER_AGENT']."','".$_SERVER['QUERY_STRING']."',".(($SUCSESS<>'')?"'".$SUCSESS."'":'NULL').",".(($USER_ID<>'')?"'".$USER_ID."'":'NULL').",".(($LOGIN<>'')?"'".str_replace("'","",$LOGIN)."'":'NULL').",".(($PROFILE<>'')?"'".$PROFILE."'":"'N/A'").",'".date("Y-m-d H:i:s")."');";
    db_execute($sql);
}

function GenerateRandString()
{
	$j=0;
	for($i=97;$i<>122;$i++){
		$mas[$j] = chr($i);
		$j++;
	}
	$rand_keys = array_rand ($mas, count($mas));
	$str = "";
        $count = rand(4,6);
	for($i=0;$i<>$count;$i++)
	{
		if($i%2 == 0)
			$str.=$mas[$rand_keys[rand(1,count($rand_keys))]];
		else
			$str.=rand(0,9);
	}
	return $str;
}

?>
