Bug #18481 Updated: Upgrade from 4.0.6 to 4.2.2 Breaks sort() and/or opendir()

From: Date: Tue, 23 Jul 2002 01:40:44 +0000
Subject: Bug #18481 Updated: Upgrade from 4.0.6 to 4.2.2 Breaks sort() and/or opendir()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-14840@lists.php.net to get a copy of this message
ID: 18481 Updated by: sniper@php.net Reported By: van@armor-e.net -Status: Feedback +Status: Closed Bug Type: Directory function related Operating System: Linux 2.2.20 on Alpha PHP Version: 4.2.1 New Comment: Thanks for verifying it. Could you also try this snapshot: http://snaps.php.net/php4-STABLE-latest.tar.gz It's from the 4.2.x branch..we're gonna release 4.2.3 soon, and it would be nice to have the fix merged there too, if it's not yet done. Previous Comments: ------------------------------------------------------------------------ [2002-07-22 21:38:31] van@armor-e.net Thanks. That fixed it. Feel free to close this out: Server Version: Apache/1.3.26 (Unix) PHP/4.3.0-dev Server Built: Jul 22 2002 18:38:31 ------------------------------------------------------------------------ [2002-07-22 21:03:14] sniper@php.net This should be fixed in CVS..please try this snapshot: http://snaps.php.net/php4-latest.tar.gz ------------------------------------------------------------------------ [2002-07-22 20:58:36] van@armor-e.net The script below lists files in the current directory, which are mrtg html and image output files. The directory listing is parsed for the host name and a row for each host is rendered with traffic, cpu, and uptime html and image files on the corresponding row. Prior to upgrading from 4.0.6 to 4.2.2 the following script produced correct output. After upgrading, multiple rows for each host are output in no specific order. Here's the broken application: http://tempe.dedserius.com/mrtg/ I took the application to an i386 server configured identically and tested it and it worked fine: http://winslow.dedserius.com/mrtg/ ================================================================================ <table align="center" border=0 width="80%"> <% $handle=opendir('.'); $colcount=0; %> <tr bgcolor="#cccccc"> <td align=center><!--mstheme--><font face="Century Gothic, Arial, Helvetica"><STRONG>Host</STRONG><!--mstheme--></font></td> <td align=center><!--mstheme--><font face="Century Gothic, Arial, Helvetica"><STRONG>Traffic</STRONG><!--mstheme--></font></td> <td align=center><!--mstheme--><font face="Century Gothic, Arial, Helvetica"><STRONG>CPU</STRONG><!--mstheme--></font></td> <td align=center><!--mstheme--><font face="Century Gothic, Arial, Helvetica"><STRONG>Uptime</STRONG><!--mstheme--></font></td> </tr> <% while ($file = readdir($handle)) { // Get the host name $host = substr($file,0,strpos($file,".")); if ( $host == "why" || $host == "cisco" || $host == "winslow" || $host == "yuma" || $host == "sedona" || $host == "tempe" || $host == "scottsdale" || $host == "vanboers" || $host == "sedonant" ) { if ($host != $tmphost ) { $i++; $fArray[$i] = array( "host"=>"$host"); } $tmphost = $host; } } sort($fArray); closedir($handle); $cnt=0; for ($j=0; $j < count($fArray); $j++) { if ($fArray[$j][host] != $fArray[$j-1][host]) { if ( ($cnt/2) == round($cnt/2)) { $bgcolor="#ccccff"; } else { $bgcolor="#ccddff"; } echo "<tr bgcolor=\"$bgcolor\">\n"; echo "<td><b>".$j." | ".ucfirst($fArray[$j][host])."</b></td>\n"; switch ($fArray[$j][host]) { case "why"; echo "<td align=\"center\"><a href=\"http://".$HTTP_HOST."/mrtg/".$fArray[$j][host].".eth0.pub.html\">"; echo "<img src=\"http://".$HTTP_HOST."/mrtg/".$fArray[$j][host].".eth0.pub-day.png\" border=0 alt=\"".$fArray[$j][host]." Daily Public Traffic\" width=\"100\" height=\"50\"></a>&nbsp;"; echo "<a href=\"http://".$HTTP_HOST."/mrtg/".$fArray[$j][host].".eth1.priv.html\">"; echo "<img src=\"http://".$HTTP_HOST."/mrtg/".$fArray[$j][host].".eth1.priv-day.png\" border=0 alt=\"".$fArray[$j][host]." Daily Private Traffic\" width=\"100\" height=\"50\"></a>"; echo "</td>"; break; case "cisco"; echo "<td align=\"center\"><a href=\"http://".$HTTP_HOST."/mrtg/".$fArray[$j][host].".eth0.html\">"; echo "<img src=\"http://".$HTTP_HOST."/mrtg/".$fArray[$j][host].".eth0-day.png\" border=0 alt=\"".$fArray[$j][host]." Daily Private Traffic\" width=\"100\" height=\"50\"></a>&nbsp;"; echo "<a href=\"http://".$HTTP_HOST."/mrtg/".$fArray[$j][host].".ppp0.html\">"; echo "<img src=\"http://".$HTTP_HOST."/mrtg/".$fArray[$j][host].".ppp0-day.png\" border=0 alt=\"".$fArray[$j][host]." Daily Public Traffic\" width=\"100\" height=\"50\"></a>"; echo "</td>"; break; default; echo "<td align=\"center\"><a href=\"http://".$HTTP_HOST."/mrtg/".$fArray[$j][host].".eth0.html\">"; echo "<img src=\"http://".$HTTP_HOST."/mrtg/".$fArray[$j][host].".eth0-day.png\" border=0 alt=\"".$fArray[$j][host]." Daily Traffic\" width=\"200\" height=\"50\"></a></td>"; break; } echo "<td align=\"center\"><a href=\"http://".$HTTP_HOST."/mrtg/".$fArray[$j][host].".cpu.html\">"; echo "<img src=\"http://".$HTTP_HOST."/mrtg/".$fArray[$j][host].".cpu-day.png\" border=0 alt=\"".$fArray[$j][host]." Daily CPU\" width=\"200\" height=\"50\"></a></td>"; echo "<td align=\"center\"><a href=\"http://".$HTTP_HOST."/mrtg/".$fArray[$j][host].".uptime.html\">"; echo "<img src=\"http://".$HTTP_HOST."/mrtg/".$fArray[$j][host].".uptime-month.png\" border=0 alt=\"".$fArray[$j][host]." Daily Uptime\" width=\"200\" height=\"50\"></a></td>"; echo "</tr>\n"; $cnt++; } } %> <tr bgcolor="#cccccc"> <td align=center><!--mstheme--><font face="Century Gothic, Arial, Helvetica"> <STRONG>All</STRONG><!--mstheme--></font></td> <td align=center><!--mstheme--><font face="Century Gothic, Arial, Helvetica"> <STRONG><a href="http://<% echo $HTTP_HOST."/mrtg/"%>all.traffic.html">Traffic</a></STRONG><!--mstheme--></font></td> <td align=center><!--mstheme--><font face="Century Gothic, Arial, Helvetica"> <STRONG><a href="http://<% echo $HTTP_HOST."/mrtg/"%>all.cpu.html">CPU</a></STRONG><!--mstheme--></font></td> <td align=center><!--mstheme--><font face="Century Gothic, Arial, Helvetica"> <STRONG><a href="http://<% echo $HTTP_HOST."/mrtg/"%>all.uptime.html">Uptime</a></STRONG><!--mstheme--></font></td> </tr> <% echo "</table>"; ================================================================================ ./configure --with-apache=/usr/src/apache_1.3.26 --with-mysql=/usr/local --with-gd=/usr/gd1.3 --with-snmp --enable-ucd-snmp-hack ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18481&edit=1

« previous php.bugs (#14840) next »