<?
/*
Author		: Cyrus_X
Date		: 19th July 2001
Revision	: 1.01
Function	: Local function for transmarco Module
*/

function logtransaction($string) {
	GLOBAL $Transmarco;
	if ($string!="") {
		$todaydate = date("Y-m-d H:i:s");
		$uid = getuid($Transmarco["SessID"]);
		$newid = find_new_id("id","logs");
		$string = magiccode($string);
		$sql = "insert into logs values ('$newid','$uid','$todaydate','$string')";
		db_query($sql);
	}
}

function find_new_id($idname,$tablename) {
	GLOBAL $Transmarco;
	$sql = "select * from $tablename order by $idname";
	$result = db_query($sql);
	for($x=0;$x<db_numrows($result);$x++) {
		$row = db_fetch_array($result,$x);
		if ($x != ($row["$idname"] + 0)) return($x);
	}
	return($x);
}

function magiccode($inputvalue){
	if (get_magic_quotes_gpc()==0){
		return (Addslashes($inputvalue));
	} else {
		return ($inputvalue);
	}
}
function HasIllegalChars($string){
	if(eregi("[^a-zA-Z0-9_\.\-]",$string)){
	    return true;
    }else{
        return false;
	}
}

function HasIllegalChars2($string){
	if(eregi("[^a-zA-Z]",$string)){
	    return true;
    }else{
        return false;
	}
}

function isValidEmail($email){
	if (eregi( "^" . "[a-z0-9]+([_\\.-][a-z0-9]+)*" . "@" . "([a-z0-9]+([\.-][a-z0-9]+)*)+" . "\\.[a-z]{2,}", $email)) {
		return true;
	}else{
		return false;
	}
}
?>