]> git.pld-linux.org Git - projects/buildlogs.git/commitdiff
Use the same filters in both cases. Use fpassthru instead of manual reading && echoing.
authorArkadiusz Miśkiewicz <arekm@maven.pl>
Thu, 17 May 2018 08:36:00 +0000 (10:36 +0200)
committerArkadiusz Miśkiewicz <arekm@maven.pl>
Thu, 17 May 2018 08:36:00 +0000 (10:36 +0200)
index.php

index 38ffa83ff93c93fd5575a4280910303f16e05635..35cbe0dd36cf1aee2ceca889f8e33b674e0f1478 100644 (file)
--- a/index.php
+++ b/index.php
@@ -284,6 +284,21 @@ function file_name()
        }
 }
 
+function get_filter($f)
+{
+       if (preg_match("/\.bz2$/", $f)) {
+               if (is_executable("/usr/bin/lbzcat"))
+                       $filter = "lbzcat";
+               else
+                       $filter = "bzcat";
+       } elseif (preg_match("/\.gz$/", $f)) {
+               $filter = "zcat";
+       } else {
+               $filter = "cat";
+       }
+       return $filter;
+}
+
 function dump_log($tail)
 {
        global $ok, $url, $dist, $arch, $name, $name_url;
@@ -353,13 +368,7 @@ function dump_log($tail)
        # what can I say beside PHP suxx? how the fuck should I create
        # bidirectional pipe? gotta use wget
 
-       if (preg_match("/\.bz2$/", $f)) {
-               $filter = "bzcat";
-       } elseif (preg_match("/\.gz$/", $f)) {
-               $filter = "zcat";
-       } else {
-               $filter = "cat";
-       }
+       $filter = get_filter($f);
 
        $cmd = "$filter '$root_directory/$f'";
        $fd = popen($cmd, "r");
@@ -504,22 +513,11 @@ function dump_text()
        echo "# date   : " .
                        date("Y/m/d H:i:s", filemtime("$root_directory/$f")) . "\n";
 
-       if (preg_match("/\.bz2$/", $f)) {
-               if (is_executable("/usr/bin/lbzcat"))
-                       $filter = "lbzcat";
-               else
-                       $filter = "bzcat";
-       } elseif (preg_match("/\.gz$/", $f)) {
-               $filter = "zcat";
-       } else {
-               $filter = "cat";
-       }
+       $filter = get_filter($f);
 
-  $cmd = "$filter '$root_directory/$f'";
+       $cmd = "$filter '$root_directory/$f'";
        $fd = popen($cmd, "r");
-       while (($s = fgets($fd, 1000)) != false) {
-               echo $s;
-       }
+       fpassthru($fd);
        pclose($fd);
 }
 
This page took 0.166314 seconds and 4 git commands to generate.