php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11429 PHP 4.0.5 fails on simple while loop.
Submitted: 2001-06-12 06:42 UTC Modified: 2001-06-12 12:44 UTC
From: Dylan_G at bigfoot dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.0.5 OS: Slackware Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: Dylan_G at bigfoot dot com
New email:
PHP Version: OS:

 

 [2001-06-12 06:42 UTC] Dylan_G at bigfoot dot com
Given this script:
-=-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>FTP server info</title>
<meta HTTP-EQUIV="REFRESH" CONTENT="60">
</head>
<body bgcolor="#FFFFFF">
<h1>Transfers in progress:</h1>
<table border="1" align="center" width="100%">
<?
$i = 0;
$anon = 0;
$idleanon = 0;
$maxconn = "5";
$types['RETR'] = "downloading";
$types['STOR'] = "uploading";
$inputfile = "/tmp/ftpinfo.txt";
$fp = fopen($inputfile,"r");
fgets($fp, 4096);
while($i < 25)
{
	$line = fgets($fp, 4096);	
	if(strstr($line, "Service class"))
		continue; /* Skip the lead in line */

	$bits = explode(" ", $line);
	if(substr($bits[12], 0, 9) == "anonymous" || substr($bits[7],
0, 9) == "anonymous")
	{
		if($bits[1] == '-')
		{
			echo "\t<tr>";
			echo "<td>$bits[11]</td><td> " . $types[$bits[13]] . " " .
chop($bits[14]) . "</td>";
			$percent_done = substr($bits[7], 1, strlen($bits[7]) - 3);
			/* Algorithm: speed colour is a factor of 10/3 */
			/* Note: since I can't get speed, I just use percent done */
			switch($percent_done)
			{
				case ($percent_done > 66):
					echo "<td bgcolor=\"#FF0000\">";
					break;

				case ($percent_done > 33):
					echo "<td bgcolor=\"#FFFF00\">";
					break;

				default:
					echo "<td bgcolor=\"#00FF00\">"; 
					break;
			}
			/* Leet progress meter. */
			print("[");
			$the_temp = 0;
			while($the_temp < 5)
			{
				if(($the_temp * 20) < $percent_done)
				{
					print("*");
				}
				else
				{
					print("\.");
				}
				$the_temp++;
			}
			print("]");

			echo " (" . $percent_done . "% done)</td>";
			echo "</tr>\n";
			$anon++;
		}
		else
			$idleanon++;
	}
	$line = fgets($fp, 4096);
	$line = fgets($fp, 4096);
	$i++;
}

echo "\t</table>\n";
if($idleanon)
	echo "\t<p>$idleanon user(s) are connected but idle</p>\n";
echo "\t<p>" . ($anon + $idleanon) . " of $maxconn users
connected</p>";
fclose($fp);

?>
<p><small>This page will autorefresh every minute.</small></p>
</body>
</html>
-=-
I get:
-=-
dylang@shadowgate:~$ lynx http://thock.com/ftpstats.php

Looking up thock.com
Making HTTP connection to thock.com
Sending HTTP request.
HTTP request sent; waiting for response.
Alert!: Unexpected network read error; connection aborted.
Can't Access `http://thock.com/ftpstats.php'
Alert!: Unable to access document.

lynx: Can't access startfile 
-=-

Not cool!

Commenting out
while($the_temp < 5)
{
...
}

makes it work, but there is no logical reason why it should
fail.

The file it is parsing is the output of ftpwho -v from ProFTPD.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-12 12:44 UTC] sniper@php.net
Please submit a new bug report with shortest possible
example that can be used to reproduce this.
The one here is way too long.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 00:01:29 2025 UTC