php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #630 echo outputs twice.
Submitted: 1998-08-07 11:46 UTC Modified: 1998-08-07 12:10 UTC
From: darrell at clever dot net Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.2a OS: NT 4 Server and FreeBSD 2.2.5
Private report: No CVE-ID: None
 [1998-08-07 11:46 UTC] darrell at clever dot net
The following is the source:

#!/usr/local/bin/php -q

<?
	$fd = fopen("file.txt", "r");
		
	while(!feof($fd)) {
		$line_data = fgets($fd, 100);
		$line = split("\)\" ", $line_data, 2);
		$final = ereg_replace("\r\n", "", $line[1]);
		
		$mypath = "/usr/temp/" . $final;
		
		echo("$mypath");
	}
	
	fclose($fd);
?>

And "file.txt" is just a few lines from an Apache extended log file.

If you run this against file.txt that contains the following line: 

who.is.john.galt.com - - [05/Aug/1998:18:46:42 -0400] "GET / HTTP/1.1" 200 1906 "-" "Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)" cp.clever.net

It will output the following:

/usr/temp/usr/temp/cp.clever.net

I only want it to output:

/usr/temp/cp.clever.net

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-08-07 12:10 UTC] rasmus
No bug - logic problem in script.  Add if(!$line_data) continue;  after the fgets() call.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 15 22:01:32 2024 UTC