/[svn.andrew.net.au]/changelogs.debian.net/changelog.php
ViewVC logotype

Annotation of /changelogs.debian.net/changelog.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 17 - (hide annotations)
Wed May 16 06:44:39 2007 UTC (17 years, 4 months ago) by apollock
File size: 4559 byte(s)
Add anchors for each package version

1 apollock 4 <?php
2    
3     $SOURCES="/srv/andrew.net.au/changelogs/Sources";
4     $URL_STUB="http://packages.debian.org/changelogs/";
5     $HTTP_CODES="/srv/andrew.net.au/changelogs/http_codes.ini";
6    
7     header("Pragma: no-cache");
8     header("Content-Type: text/html; charset=utf-8");
9     list(, $package) = explode("/", $HTTP_SERVER_VARS["REQUEST_URI"]);
10     $handle = popen("grep-dctrl -sDirectory -sVersion -P $package -X -n $SOURCES", 'r');
11    
12     $directory = chop(fgets($handle, 1024));
13     $version = chop(fgets($handle, 1024));
14    
15     pclose($handle);
16    
17     $version = ereg_replace("^[[:digit:]]+\:", "", $version);
18    
19     if (!strlen($directory) || !strlen($version)) {
20     header("HTTP/1.1 404 Not Found"); ?>
21     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
22     "http://www.w3.org/TR/html4/loose.dtd">
23     <HTML>
24     <HEAD>
25     <TITLE>Debian source package changelog viewer</TITLE>
26     </HEAD>
27     <LINK rel="stylesheet" type="text/css" href="default.css">
28     <BODY>
29     <H1>Debian source package changelog viewer</H1>
30     <H2>Error: No such package</H2>
31     The package name you provided, <B><?php echo $package ?></B>, does not seem to exist in the Sources file (for main).
32     <HR>
33     <DIV class="footer">changelogs.debian.net <a href="http://www.debian.org/"><img alt="Powered by Debian" height="30" width="88" src="logos/button-k1.png"></a> Made by Andrew Pollock</DIV>
34     </BODY>
35     </HTML>
36    
37     <?php } else {
38     $URL = $URL_STUB . $directory . "/" .$package . "_" . $version . "/changelog";
39    
40     $ch = curl_init($URL);
41     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
42     curl_setopt($ch, CURLOPT_REFERER, "http://changelogs.debian.net/");
43     curl_setopt($ch, CURLOPT_USERAGENT, "changelogs.debian.net");
44     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
45    
46     $result = curl_exec($ch);
47     if (curl_errno($ch) == 0 && curl_getinfo($ch, CURLINFO_HTTP_CODE) == "200") {
48     if (ereg("text/html", $_SERVER["HTTP_ACCEPT"])) {
49    
50     # Delouse
51     $result = htmlentities($result, ENT_COMPAT);
52    
53     # Turn URLs into hyperlinks
54     $result = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\">\\0</a>", $result);
55    
56     # Turn bug IDs into BTS hyperlinks
57     $result = ereg_replace("#([[:digit:]]{1,6})", "#<a href=\"http://bugs.debian.org/\\1\" class=\"bts\" title=\"View bug #\\1 in the BTS\">\\1</a>", $result);
58    
59     foreach (explode("\n", $result) as $line) {
60 apollock 17 if (ereg("\((.*)\) (unstable|stable|testing|experimental); urgency=", $line, $matches)) {
61     $line = "<a name=\"" . $matches[1] . "\"><span class=\"header\">" . $line . "</span></a>";
62 apollock 4 }
63     if (ereg("^ --",$line)) {
64     $line = ereg_replace("-- (.*) &lt;(.*)&gt;", "-- \\1 &lt;<a href=\"http://qa.debian.org/developer.php?login=\\2\" class=\"ddpo\" title=\"View the Debian Developer Package Overview for \\1\">\\2</a>&gt;", $line);
65     $line = "<span class=\"footer\">" . $line . "</span>";
66     }
67     $fixed_result .= $line . "\n";
68     }
69     ?>
70     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
71     "http://www.w3.org/TR/html4/loose.dtd">
72     <HTML>
73     <HEAD>
74     <META http-equiv="Content-Type" content="text/html; charset=utf-8">
75     <META name="generator" content="changelogs.debian.net">
76     <LINK rel="stylesheet" href="default.css" type="text/css">
77     <LINK rel="made" href="mailto:apollock@debian.org" TITLE="changelogs.debian.net feedback">
78     <LINK rel="icon" href="/favicon.ico">
79     <LINK rel="shortcut icon" href="/favicon.ico">
80     <TITLE>Changelog for <?php echo $package?></TITLE>
81     </HEAD>
82     <BODY>
83     <PRE>
84     <?php echo $fixed_result ?>
85     </PRE>
86     <HR>
87     <DIV class="footer">changelogs.debian.net <a href="http://www.debian.org/"><img alt="Powered by Debian" height="30" width="88" src="logos/button-k1.png"></a> Made by Andrew Pollock</DIV>
88     </BODY>
89     <?php } else {
90     Header("Content-Type: text/plain");
91     echo $result;
92     }
93     } else {
94     $http_code = parse_ini_file($HTTP_CODES);
95     header("HTTP/1.1 503 $http_code[500]"); ?>
96     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
97     "http://www.w3.org/TR/html4/loose.dtd">
98     <HTML>
99     <HEAD>
100     <TITLE>Debian source package changelog viewer</TITLE>
101     <LINK rel="stylesheet" type="text/css" href="default.css">
102     </HEAD>
103     <BODY>
104     <H1>Debian source package changelog viewer</H1>
105     <H2>Error: <?php echo (curl_errno($ch) != 0) ? (curl_error($ch)) : (curl_getinfo($ch, CURLINFO_HTTP_CODE) . " " . $http_code[curl_getinfo($ch, CURLINFO_HTTP_CODE)]) ?></H2>
106     There was an error retrieving <a href="<?php echo $URL ?>"><?php echo $URL ?></a>
107     <HR>
108     <DIV class="footer">changelogs.debian.net <a href="http://www.debian.org/"><img alt="Powered by Debian" height="30" width="88" src="logos/button-k1.png"></a> Made by Andrew Pollock</DIV>
109     </BODY>
110     </HTML><?php
111     }
112     curl_close($ch);
113    
114     } ?>

  ViewVC Help
Powered by ViewVC 1.1.22