php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18481 Upgrade from 4.0.6 to 4.2.2 Breaks sort() and/or opendir()
Submitted: 2002-07-22 20:58 UTC Modified: 2002-07-22 21:40 UTC
From: van at armor-e dot net Assigned:
Status: Closed Package: Directory function related
PHP Version: 4.2.1 OS: Linux 2.2.20 on Alpha
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
31 + 32 = ?
Subscribe to this entry?

 
 [2002-07-22 20:58 UTC] van at armor-e dot 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-22 21:03 UTC] sniper@php.net
This should be fixed in CVS..please try this snapshot:

http://snaps.php.net/php4-latest.tar.gz
 [2002-07-22 21:38 UTC] van at armor-e dot 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:40 UTC] sniper@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 13:01:28 2024 UTC