tazwok 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 | b982a489e94d |
children | 0df3d667a64e bf7d07bf23ef |
files | tazwok web/download.php web/index.php |
line diff
1.1 --- a/tazwok Sun Feb 13 23:38:35 2011 +0100 1.2 +++ b/tazwok Mon Feb 14 01:59:48 2011 +0100 1.3 @@ -3020,9 +3020,12 @@ 1.4 fi 1.5 mkdir -p $WEBSERVER 1.6 echo "${undigest:-$SLITAZ_VERSION}" >> $WEBSERVER/repositories.list 1.7 - for file in index.php log.php; do 1.8 + for file in index.php log.php download.php; do 1.9 [ -f "$WEBSERVER/$file" ] || ln -s /usr/share/slitaz/web-bb/$file $WEBSERVER 1.10 done 1.11 + for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do 1.12 + ln -s $dir $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/} 1.13 + done 1.14 source $LOCAL_REPOSITORY/tazchroot.conf 1.15 echo "<?php 1.16 1.17 @@ -3058,6 +3061,9 @@ 1.18 sed '/^WEBSERVER/d' -i $LOCAL_REPOSITORY/tazwok.conf 1.19 sed "/^${undigest:-$SLITAZ_VERSION}$/d" -i $WEBSERVER/repositories.list 1.20 rm $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php 1.21 + for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do 1.22 + rm $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/} 1.23 + done 1.24 if ! [ -s "$WEBSERVER/repositories.list" ]; then 1.25 echo "$WEBSERVER/repositories.list is empty; tazwok doesn't remove the server automatically in case you have important stuff in it. If it's not the case, you can remove it using: rm -r $WEBSERVER" 1.26 rm $WEBSERVER/conf.php
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/web/download.php Mon Feb 14 01:59:48 2011 +0100 2.3 @@ -0,0 +1,20 @@ 2.4 +<?php 2.5 +$version=$_GET["version"]; 2.6 +if (file_exists("conf-$version.php")) { 2.7 + include("conf-$version.php"); 2.8 +} 2.9 +else { 2.10 + if (file_exists("conf.php")) { 2.11 + include("conf.php"); 2.12 + } 2.13 +} 2.14 +$package=$_GET["package"]; 2.15 +$filename=preg_replace('/.*\//', '', $package); 2.16 +if (file_exists("$version-$package")) { 2.17 + header("Content-disposition: attachment; filename=$filename"); 2.18 + readfile("$version-$package"); 2.19 +} 2.20 +else { 2.21 + echo "Strange things happens..."; 2.22 +} 2.23 +?> 2.24 \ No newline at end of file
3.1 --- a/web/index.php Sun Feb 13 23:38:35 2011 +0100 3.2 +++ b/web/index.php Mon Feb 14 01:59:48 2011 +0100 3.3 @@ -10,6 +10,29 @@ 3.4 include("conf.php"); 3.5 } 3.6 } 3.7 + 3.8 +function include_and_link($file) 3.9 +{ 3.10 + global $log_dir, $version; 3.11 + if (($fp = fopen($file,"r")) === false) return; 3.12 + while (($pkg = fgets($fp)) !== false) { 3.13 + $pkg = chop($pkg); 3.14 + if (file_exists("$log_dir/$pkg.html")) 3.15 + echo "<a href=\"log.php?version=$version&package=$pkg\">$pkg</a>\n"; 3.16 + else echo "$pkg\n"; 3.17 + } 3.18 + fclose($fp); 3.19 +} 3.20 + 3.21 +function list_last_cooked($dir, $suffix) 3.22 +{ 3.23 + global $version; 3.24 + $path=basename($dir); 3.25 + system("cd $dir && ls -1t *.$suffix | head -20 | \ 3.26 + while read file; do echo -n \$(stat -c '%y' $dir/\$file | \ 3.27 + cut -d. -f1); echo ' <a href=\"download.php?version=$version&package=$path/'\$file'\">'\$file'</a>'; done"); 3.28 +} 3.29 + 3.30 ?> 3.31 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 3.32 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3.33 @@ -148,23 +171,22 @@ 3.34 <h3>Broken</h3> 3.35 <pre class="package"> 3.36 <?php 3.37 -include("$db_dir/broken"); 3.38 +include_and_link("$db_dir/broken"); 3.39 ?> 3.40 </pre> 3.41 3.42 <h3>Blocked</h3> 3.43 <pre class="package"> 3.44 <?php 3.45 -include("$db_dir/blocked"); 3.46 +include_and_link("$db_dir/blocked"); 3.47 ?> 3.48 </pre> 3.49 3.50 <h3>Last cooked packages</h3> 3.51 <pre class="package"> 3.52 <?php 3.53 -system("cd $incoming && ls -1t *.tazpkg | head -20 | \ 3.54 - while read file; do echo -n \$(stat -c '%y' $incoming/\$file | \ 3.55 - cut -d. -f1); echo ' '\$file; done"); ?> 3.56 +list_last_cooked($incoming, "tazpkg"); 3.57 +?> 3.58 </pre> 3.59 3.60 <h3>Last removed packages</h3> 3.61 @@ -177,9 +199,8 @@ 3.62 <h3>Last cooked flavors</h3> 3.63 <pre class="package"> 3.64 <?php 3.65 -system("cd $packages && ls -1t *.flavor | head -20 | \ 3.66 - while read file; do echo -n \$(stat -c '%y' $packages/\$file | \ 3.67 - cut -d. -f1); echo ' '\$file; done"); ?> 3.68 +list_last_cooked($packages, "flavor"); 3.69 +?> 3.70 </pre> 3.71 3.72 <!-- End of content -->