pkgbrowse/html/pkg/pkg.php

651 lines
18 KiB
PHP
Raw Permalink Normal View History

2008-09-04 18:33:49 +02:00
<?
// $RCSfile: pkg.php,v $
// $Revision: 1.1 $
// $Name: $
// $Date: 2008/09/04 16:36:18 $
// $Author: agibert $
/*
* PkgBrowse - Packaging Project Browser
* Copyright (C) 2008 Arnaud G. Gibert
* mailto:arnaud@rx3.net
* http://www.rx3.org/dvp/dvpbrowse
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$time_start = microtime_float();
include "/var/httpd/www.rx3.org/html/pkg/pkg_config.inc";
$pkg_myname="Pkg_Browse";
$pkg_tag_tab=explode( " ", "$Name: $");
$pkg_tag_tab=explode( "-", $pkg_tag_tab[1]);
$pkg_myver=strtr( "$pkg_tag_tab[1]-$pkg_tag_tab[2]", "_", ".");
/*--------------------------------------------------------------------------------------------------------------------*/
/* */
/*--------------------------------------------------------------------------------------------------------------------*/
function pkg_get_section( $pkg_id_lookup)
{
global $pkg_tab;
foreach( $pkg_tab as $section_id => $value)
{
$pkg=$pkg_tab[$section_id]["pkg"];
foreach( $pkg as $pkg_id => $value)
{
if( $pkg_id == $pkg_id_lookup)
{
return $section_id;
}
}
}
return "";
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* */
/*--------------------------------------------------------------------------------------------------------------------*/
function pkg_get_name( $pkg_id_lookup)
{
global $pkg_tab;
foreach( $pkg_tab as $section_id => $value)
{
$pkg=$pkg_tab[$section_id]["pkg"];
foreach( $pkg as $pkg_id => $value)
{
if( $pkg_id == $pkg_id_lookup)
{
return $pkg[$pkg_id]["name"];
}
}
}
return "";
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* */
/*--------------------------------------------------------------------------------------------------------------------*/
function pkg_curverrel_get( $id)
{
$cmd="ls -rt download/$id/*/$id*.src.rpm | sed -e 's/^download.$id.//' -e 's/.src.rpm$//'";
$curverrel=exec($cmd);
$tab=explode( "/", $curverrel);
$curver=$tab[0];
$tab=explode( "-$curver-", $curverrel);
$currel=$tab[1];
return( array( $curver, $currel));
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* */
/*--------------------------------------------------------------------------------------------------------------------*/
function pkg_list_get( $id, $curver, $currel)
{
$cmd="ls download/$id/$curver/$id-*$curver-$currel* | sort | sed -e 's/^download.$id.$curver.//'";
exec($cmd, $list);
return( $list);
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* */
/*--------------------------------------------------------------------------------------------------------------------*/
function pkg_tag_get( $pkg_id, $pkg_curver, $pkg_currel, $pkg_name, $pkg_qt)
{
if( $pkg_name == "")
{
$pkg_name="$pkg_id-$pkg_curver-$pkg_currel.src.rpm";
}
$cmd="rpm -qp --qf \"$pkg_qt\" download/$pkg_id/$pkg_curver/$pkg_name | sed -e 's/</\&lt;/g' -e's/>/\&gt;/g'";
exec( $cmd, $reply_tab);
return $reply_tab;
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* */
/*--------------------------------------------------------------------------------------------------------------------*/
function pkg_tab_dump( $tab, $start)
{
for( $i = $start; $i < count($tab); $i++)
{
echo "$tab[$i]\n";
}
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* */
/*--------------------------------------------------------------------------------------------------------------------*/
function pkg_main_header( $name)
{
$page_name="$name";
$page_title="$page_name !";
global $pkg_tab;
global $pkg_header;
global $pkg_keywords;
$keywords="$pkg_keywords";
foreach( $pkg_tab as $section_id => $value)
{
foreach( $pkg_tab[$section_id]["pkg"] as $pkg_id => $value)
{
$keywords="$keywords,$pkg_id";
}
}
include "$pkg_header";
echo " <META NAME=\"keywords\" CONTENT=\"$keywords\">
<TITLE>$page_name</TITLE>
</HEAD>
<BODY>
<H1>$page_title</H1>
<H5><A HREF=\"..\">Rx3.Org Main Page</A></H5>
<HR>
";
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* */
/*--------------------------------------------------------------------------------------------------------------------*/
function pkg_main_body( $pkg_tab)
{
global $pkg_download_http_url;
global $pkg_download_ftp_url;
global $pkg_notes;
echo " <P>
<BR>
<BR>
</P>
";
foreach( $pkg_tab as $section_id => $value)
{
$section_name=$pkg_tab[$section_id]["name"];
$pkg=$pkg_tab[$section_id]["pkg"];
echo " <H3>$section_name</H3>
<UL>
";
foreach( $pkg as $pkg_id => $value)
{
$pkg_name=$pkg[$pkg_id]["name"];
// $pkg_summary=$pkg[$pkg_id]["summary"];
$pkg_listbrk=$pkg[$pkg_id]["listbrk"];
$pkg_curverrel=pkg_curverrel_get( $pkg_id);
$pkg_curver=$pkg_curverrel[0];
$pkg_currel=$pkg_curverrel[1];
$summary = pkg_tag_get( $pkg_id, $pkg_curver, $pkg_currel, "", "%{SUMMARY}");
$pkg_summary = $summary[0];
if( $pkg_listbrk == "yes")
{
$pkg_cl="chap1";
}
else
{
$pkg_cl="chap2";
}
echo " <LI CLASS=\"$pkg_cl\"><A HREF=\"?pkg=$pkg_id\">$pkg_name</A>: $pkg_summary</LI>
";
}
echo " </UL>
<P>
<BR>
<BR>
</P>
";
}
echo "
<P>
<BR>
<BR>
$pkg_notes
<BR>
<BR>
</P>
<HR>
<H5>";
echo "<A HREF=\"$pkg_download_http_url\">Rx3 Free Software Packaging HTTP download page</A>&nbsp;&nbsp;&nbsp;";
echo "<A HREF=\"$pkg_download_ftp_url\">Rx3 Free Software Packaging FTP download page</A>&nbsp;&nbsp;&nbsp;</H5>
";
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* */
/*--------------------------------------------------------------------------------------------------------------------*/
function pkg_main_page()
{
global $pkg_tab;
pkg_main_header( "Rx3 Free Software Packaging Main Page");
pkg_main_body( $pkg_tab);
pkg_footer();
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* */
/*--------------------------------------------------------------------------------------------------------------------*/
function pkg_header( $id, $name, $summary, $curver, $currel)
{
$page_name="Rx3 $name Home Page";
$page_title="$page_name !";
global $pkg_url;
global $pkg_header;
global $pkg_keywords;
$keywords="$pkg_keywords,$id";
include "$pkg_header";
echo " <META NAME=\"keywords\" CONTENT=\"$keywords\">
<TITLE>$page_name</TITLE>
</HEAD>
<BODY>
<H1>$page_title</H1>
<H4>$summary</H4>
<H4>$curver-$currel</H4>
<H5><A HREF=\"..\">Rx3.Org Main Page</A>&nbsp;&nbsp;/&nbsp;&nbsp;<A HREF=\"$pkg_url\">Rx3 Free Software Packaging Main Page</A></H5>
<HR>
";
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* */
/*--------------------------------------------------------------------------------------------------------------------*/
function pkg_body( $id, $name, $curver, $currel)
{
global $pkg_download_http_url;
global $pkg_download_ftp_url;
$description = pkg_tag_get( $id, $curver, $currel, "", "%{DESCRIPTION}");
$change_log = pkg_tag_get( $id, $curver, $currel, "", "%{CHANGELOGTIME:date} %{CHANGELOGNAME}\n%{CHANGELOGTEXT}");
echo " <P>
<BR>
<BR>
</P>
<PRE>
";
pkg_tab_dump( $description, 0);
echo " </PRE>
<P>
<BR>
<BR>
</P>
";
echo " <P>
<BR>
</P>
<HR>
<H5>Last Release Notes:</H5>
";
echo " <PRE>
";
pkg_tab_dump( $change_log, 0);
echo " </PRE>
";
$pkg_list = pkg_list_get( $id, $curver, $currel);
if( $pkg_list != "")
{
echo" <HR>
<H5>Sub-Package List:</H5><P>";
for( $i = 0; $i < count($pkg_list); $i++)
{
echo "&nbsp;&nbsp;&nbsp;$pkg_list[$i]";
}
echo "</P>
";
}
echo" <HR>
<H5>";
echo "<A HREF=\"?pkg=$id&amp;cl=yes\">$name changelog page</A>&nbsp;&nbsp;&nbsp;";
echo "<A HREF=\"?pkg=$id&amp;fl=yes\">$name file list page</A>&nbsp;&nbsp;&nbsp;";
echo "<A HREF=\"$pkg_download_http_url/$id\">$name HTTP download page</A>&nbsp;&nbsp;&nbsp;";
echo "<A HREF=\"$pkg_download_ftp_url/$id\">$name FTP download page</A>&nbsp;&nbsp;&nbsp;";
echo "</H5>";
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* */
/*--------------------------------------------------------------------------------------------------------------------*/
function pkg_footer()
{
global $pkg_myname;
global $pkg_myver;
global $pkg_footer;
global $time_start;
include "$pkg_footer";
$time_stop = microtime_float();
$time_elaps = intval( ( $time_stop - $time_start) * 1000) / 1000;
echo " </P>
";
echo " <H6>Page generated in $time_elaps seconds by $pkg_myname V $pkg_myver</H6>";
echo" </BODY>
</HTML>
";
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* */
/*--------------------------------------------------------------------------------------------------------------------*/
function pkg_page( $pkg_id, $pkg_name, $pkg_curver, $pkg_currel)
{
$summary = pkg_tag_get( $pkg_id, $pkg_curver, $pkg_currel, "", "%{SUMMARY}");
$pkg_summary = $summary[0];
pkg_header( $pkg_id, $pkg_name, $pkg_summary, $pkg_curver, $pkg_currel);
pkg_body( $pkg_id, $pkg_name, $pkg_curver, $pkg_currel);
pkg_footer();
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* */
/*--------------------------------------------------------------------------------------------------------------------*/
function pkg_cl_header( $id, $name, $curver, $currel)
{
$page_name="Rx3 $name ChangeLog Page";
$page_title="$page_name";
global $pkg_url;
global $pkg_header;
global $pkg_keywords;
$keywords="$pkg_keywords,$id, rx3 $id changelog";
include "$pkg_header";
echo " <META NAME=\"keywords\" CONTENT=\"$keywords\">
<TITLE>$page_name</TITLE>
</HEAD>
<BODY>
<H1>$page_title</H1>
<H4>$curver-$currel</H4>
<H5><A HREF=\"..\">Rx3.Org Main Page</A>&nbsp;&nbsp;/&nbsp;&nbsp;<A HREF=\"$pkg_url\">Rx3 Free Software Packaging Main Page</A>&nbsp;&nbsp;/&nbsp;&nbsp;<A HREF=\"$pkg_url?pkg=$id\">Rx3 $name Home Page</A></H5>
<HR>
";
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* */
/*--------------------------------------------------------------------------------------------------------------------*/
function pkg_cl_body( $id, $curver, $currel)
{
echo " <PRE>
";
$changelog_tab = pkg_tag_get( $id, $curver, $currel, "", "[\n%{CHANGELOGTIME:date} %{CHANGELOGNAME}\n%{CHANGELOGTEXT}\n]");
pkg_tab_dump( $changelog_tab, 0);
echo " </PRE>
";
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* */
/*--------------------------------------------------------------------------------------------------------------------*/
function pkg_cl_page( $pkg_id, $pkg_name, $pkg_curver, $pkg_currel)
{
pkg_cl_header( $pkg_id, $pkg_name, $pkg_curver, $pkg_currel);
pkg_cl_body( $pkg_id, $pkg_curver, $pkg_currel);
pkg_footer();
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* */
/*--------------------------------------------------------------------------------------------------------------------*/
function pkg_fl_header( $id, $name, $curver, $currel)
{
$page_name="Rx3 $name File List Page";
$page_title="$page_name";
global $pkg_url;
global $pkg_header;
global $pkg_keywords;
$keywords="$pkg_keywords,$id, rx3 $id file list";
include "$pkg_header";
echo " <META NAME=\"keywords\" CONTENT=\"$keywords\">
<TITLE>$page_name</TITLE>
</HEAD>
<BODY>
<H1>$page_title</H1>
<H4>$curver-$currel</H4>
<H5><A HREF=\"..\">Rx3.Org Main Page</A>&nbsp;&nbsp;/&nbsp;&nbsp;<A HREF=\"$pkg_url\">Rx3 Free Software Packaging Main Page</A>&nbsp;&nbsp;/&nbsp;&nbsp;<A HREF=\"$pkg_url?pkg=$id\">$name Home Page</A></H5>
<HR>
";
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* */
/*--------------------------------------------------------------------------------------------------------------------*/
function pkg_fl_body( $id, $curver, $currel)
{
$pkg_list = pkg_list_get( $id, $curver, $currel);
if( $pkg_list != "")
{
for( $i = 0; $i < count($pkg_list); $i++)
{
echo" <H5>Sub-Package $pkg_list[$i]:</H5>
<PRE>";
$filelist_tab = pkg_tag_get( $id, $curver, $currel, $pkg_list[$i], "[%{FILENAMES}\n]");
pkg_tab_dump( $filelist_tab, 0);
echo " </PRE>
";
if( $i < count($pkg_list) - 1)
{
echo" <HR>
";
}
}
}
else
{
echo " <PRE>
";
$filelist_tab = pkg_tag_get( $id, $curver, $currel, "", "[%{FILENAMES}\n]");
pkg_tab_dump( $filelist_tab, 0);
echo " </PRE>
";
}
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* */
/*--------------------------------------------------------------------------------------------------------------------*/
function pkg_fl_page( $pkg_id, $pkg_name, $pkg_curver, $pkg_currel)
{
pkg_fl_header( $pkg_id, $pkg_name, $pkg_curver, $pkg_currel);
pkg_fl_body( $pkg_id, $pkg_curver, $pkg_currel);
pkg_footer();
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* */
/*--------------------------------------------------------------------------------------------------------------------*/
if( $_GET["pkg"] == "")
{
pkg_main_page( $pkg_tab);
}
else
{
$pkg_id=$_GET["pkg"];
$section_id=pkg_get_section( $pkg_id);
$pkg_name=$pkg_tab[$section_id]["pkg"][$pkg_id]["name"];
$pkg_curverrel=pkg_curverrel_get( $pkg_id);
$pkg_curver=$pkg_curverrel[0];
$pkg_currel=$pkg_curverrel[1];
if( $_GET["cl"] == "yes")
{
pkg_cl_page( $pkg_id, $pkg_name, $pkg_curver, $pkg_currel);
}
else
{
if( $_GET["fl"] == "yes")
{
pkg_fl_page( $pkg_id, $pkg_name, $pkg_curver, $pkg_currel);
}
else
{
pkg_page( $pkg_id, $pkg_name, $pkg_curver, $pkg_currel);
}
}
}
?>