[PHP-DEV] broken script From: Régis SCOTTO (scotto <email protected>)
Date: 05/08/98

Hello,

I'm beginner in Php and a new user of your mailing-list, however i try to read
more and more informations about Php. But i have a little displeasure with
following include-script and i found no solution. The goal of this script is to
extract some data from a Analog generated file (statistic tool) on a same server
in a personnal directory (i know the fsockopen function, but i think it's no
usefull in this case), $FILE_IN exists in specified path, but the problem comes
only on network server from the specified line, showing the rest of script.
However, i use on my local PC PHP under Windows and this problem not exists.

<?

  $FILE_IN = "/stats/analog/index.html";

  $PATH_OLD = "/cgi-image/";
  $PATH_NEW = "/webmaster/stats/";

  if (fileinode($FILE_IN) == -1);
    echo "Incorrect path or filename : $FILE_IN !!!<br>";
    exit;
  endif;

  $array = file($FILE_IN);
  $len = count($array);

    $i = 0;
    $situation = 0;

    while( ($i<$len) && ($situation !=1) );
        $line = $array[$i];
        if ( eregi("<hr>",$line) );
          $situation = 1;
        endif;
        $i++; /* <=============== here, the next part of script is appeared */
    endwhile;

    while( $i<$len );
        $line = $array[$i];

        if ( eregi("This analysis",$line) );
          $i = $array;
        endif;

        if ( eregi("<h2><a NAME=\"Directory\">Directory
Report</a></h2>",$line) );
           while( (!eregi("<h2><a NAME=\"FileType\">File Type
Report</a></h2>",$line)) && ($i < $len));
             $line = $array[$i];
             $i++;
           endwhile;
        endif;

        if ( eregi("<h2><a NAME=\"Request\">Request Report</a></h2>",$line) );
           while( (!eregi("<h2><a NAME=\"FullBrowser\">Browser
Report</a></h2>",$line)) && ($i < $len));
             $line = $array[$i];
             $i++;
           endwhile;
        endif;

        eregi_replace($PATH_OLD,$PATH_NEW,$line);

        if ($i < $len);
          echo $line+"\n";
        endif;

        $i++;

    endwhile;

>

Moreover, i search a solution to replace a whole word or a whole sentence, but i
think the ereg_replace is only usefull on one character :-(

If the answers exist already in mailing-list, to avoid you repeat, please, can
you say
me the references.

Thank for your help.

A bientot

Regis.

---
@ e-mail : scotto <email protected>
WEB page : http://www.bonifacio.com - Corsica - France
---