有什么办法可以丢弃Oracle数据库中的图像文件?

时间:2018-08-06 10:22:35

标签: oracle

<?php
$conn = oci_connect('ABCC', 'abcAA', 'orrfgfd2/UID1');
if (!$conn) {
   $m = oci_error();
   echo $m['message'], "\n";
   exit;
}
else {
   
	$d = new DateTime();
	$yesterday = $d->sub(new DateInterval('P1D'))->format('Y.m.d');
	$filename = "access.$yesterday.txt";

	if(file_exists($filename)){
		$myfile = fopen($filename, "r");
		while(!feof($myfile)) {
			$content= fgets($myfile);
				
			$carray=explode(',',$content);
			list($IP_ADDRESS, $USER_IDENTIFIER, $USERID , $REQUEST_TIME , $CLIENT_REQUEST ,$RESPONSE_CODE ,$SIZEOFOBJECT, $COOKIES)=$carray;
				
			$stdii = 'INSERT INTO LOGS(IP_ADDRESS, USER_IDENTIFIER, USERID , REQUEST_TIME , CLIENT_REQUEST ,RESPONSE_CODE ,SIZEOFOBJECT, COOKIES)'.
			'values(:IP_ADDRESS, :USER_IDENTIFIER, :USERID , :REQUEST_TIME , :CLIENT_REQUEST ,:RESPONSE_CODE ,:SIZEOFOBJECT, :COOKIES)';
			$compiled1 = oci_parse($conn, $stdii);
			oci_bind_by_name($compiled1, ':IP_ADDRESS', $IP_ADDRESS);
			oci_bind_by_name($compiled1, ':USER_IDENTIFIER', $USER_IDENTIFIER);
			oci_bind_by_name($compiled1,':USERID', $USERID);
			oci_bind_by_name($compiled1, ':REQUEST_TIME', $REQUEST_TIME);
			oci_bind_by_name($compiled1, ':CLIENT_REQUEST', $CLIENT_REQUEST);
			oci_bind_by_name($compiled1, ':RESPONSE_CODE', $RESPONSE_CODE);
			oci_bind_by_name($compiled1, ':SIZEOFOBJECT', $SIZEOFOBJECT);
			oci_bind_by_name($compiled1, ':COOKIES', $COOKIES);
			oci_execute($compiled1, OCI_COMMIT_ON_SUCCESS);
			
			
			
			}
			$message="File Uploaded";
			echo "<script type='text/javascript'>alert(\"$message\");</script>";
		
			fclose($myfile);
	}
	
	else{
		$message2="File Doesn't exists";
		echo "<script type='text/javascript'>alert(\"$message2\");</script>";
		
	}

}
oci_close($conn);

?>

我设计了一个脚本,该脚本会将日志文件数据上传到oracle数据库。但是我想在数据上传中过滤图像。在这种情况下,我不希望我的代码上传请求中具有.gif扩展名的CLIENT_REQUEST(“ GET /icons/back.gif HTTP / 1.1”)。有人可以帮助我进行查询。

我的日志文件

127.0.0.1,-,-,[06/Aug/2018:09:22:02 +0200],"GET /icons/back.gif HTTP/1.1",304,-,"-"
127.0.0.1,-,-,[06/Aug/2018:09:22:02 +0200],"GET /icons/blank.gif HTTP/1.1",304,-,"-"
127.0.0.1,-,-,[06/Aug/2018:09:22:02 +0200],"GET /icons/unknown.gif HTTP/1.1",304,-,"-"
127.0.0.1,-,-,[06/Aug/2018:09:22:02 +0200],"GET /icons/image2.gif HTTP/1.1",304,-,"-"
127.0.0.1,-,-,[06/Aug/2018:09:22:02 +0200],"GET /icons/text.gif HTTP/1.1",304,-,"-"

1 个答案:

答案 0 :(得分:1)

如果将日志文件用作外部表,则可以通过(PL /)SQL load 加载它,并实际编写一个http.createServer(function(request, response) { try{ response.writeContinue(undefinedVariable); }catch (error) { response.status(400).end(error.message); } }).listen(port); 子句来拒绝此类行。例如:

WHERE