tazwok diff web/index.php @ rev 267

Improve webserver interface (thanks Bellard)
author Antoine Bodin <gokhlayeh@slitaz.org>
date Mon Feb 14 01:59:48 2011 +0100 (2011-02-14)
parents 093de6dde7f8
children 3271becd1c47
line diff
     1.1 --- a/web/index.php	Sun Feb 13 23:10:02 2011 +0100
     1.2 +++ b/web/index.php	Mon Feb 14 01:59:48 2011 +0100
     1.3 @@ -10,6 +10,29 @@
     1.4  		include("conf.php");
     1.5  	}
     1.6  }
     1.7 +
     1.8 +function include_and_link($file)
     1.9 +{
    1.10 +	global $log_dir, $version;
    1.11 +	if (($fp = fopen($file,"r")) === false) return;
    1.12 +	while (($pkg = fgets($fp)) !== false) {
    1.13 +		$pkg = chop($pkg);
    1.14 +		if (file_exists("$log_dir/$pkg.html"))
    1.15 +			echo "<a href=\"log.php?version=$version&package=$pkg\">$pkg</a>\n";
    1.16 +		else	echo "$pkg\n";
    1.17 +	}
    1.18 +	fclose($fp);
    1.19 +}
    1.20 +
    1.21 +function list_last_cooked($dir, $suffix)
    1.22 +{
    1.23 +	global $version;
    1.24 +	$path=basename($dir);
    1.25 +	system("cd $dir && ls -1t *.$suffix | head -20 | \
    1.26 +		while read file; do echo -n \$(stat -c '%y' $dir/\$file | \
    1.27 +		cut -d. -f1); echo '   <a href=\"download.php?version=$version&package=$path/'\$file'\">'\$file'</a>'; done");
    1.28 +}
    1.29 +
    1.30  ?>
    1.31  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    1.32      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    1.33 @@ -148,23 +171,22 @@
    1.34  <h3>Broken</h3>
    1.35  <pre class="package">
    1.36  <?php
    1.37 -include("$db_dir/broken");
    1.38 +include_and_link("$db_dir/broken");
    1.39  ?>
    1.40  </pre>
    1.41  
    1.42  <h3>Blocked</h3>
    1.43  <pre class="package">
    1.44  <?php
    1.45 -include("$db_dir/blocked");
    1.46 +include_and_link("$db_dir/blocked");
    1.47  ?>
    1.48  </pre>
    1.49  
    1.50  <h3>Last cooked packages</h3>
    1.51  <pre class="package">
    1.52  <?php
    1.53 -system("cd $incoming && ls -1t *.tazpkg | head -20 | \
    1.54 -	while read file; do echo -n \$(stat -c '%y' $incoming/\$file | \
    1.55 -	cut -d. -f1); echo '   '\$file; done"); ?>
    1.56 +list_last_cooked($incoming, "tazpkg");
    1.57 +?>
    1.58  </pre>
    1.59  
    1.60  <h3>Last removed packages</h3>
    1.61 @@ -177,9 +199,8 @@
    1.62  <h3>Last cooked flavors</h3>
    1.63  <pre class="package">
    1.64  <?php
    1.65 -system("cd $packages && ls -1t *.flavor | head -20 | \
    1.66 -	while read file; do echo -n \$(stat -c '%y' $packages/\$file | \
    1.67 -	cut -d. -f1); echo '   '\$file; done"); ?>
    1.68 +list_last_cooked($packages, "flavor");
    1.69 +?>
    1.70  </pre>
    1.71  
    1.72  <!-- End of content -->