summaryrefslogtreecommitdiffstats
path: root/all.php
blob: 2dfe2f402922d3ed89e0fdc4cde1f7f71ebe36f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<title>Packages in Fedora</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<link rel="stylesheet" type="text/css" media="print" href="http://docs.fedoraproject.org/css/print.css">
		<style type="text/css" media="screen">
			@import url("http://docs.fedoraproject.org/css/layout.css");
			@import url("http://docs.fedoraproject.org/css/content.css");
			@import url("http://docs.fedoraproject.org/css/docbook.css");
            
body {
    background-image:none; 
}
.error {
    background:url(http://fedoraproject.org/wikidata/kindofblue/img/icon-error.png) no-repeat left;
    padding-left: 21px;
}

.info {
    background:url(http://fedoraproject.org/wikidata/kindofblue/img/icon-info.png) no-repeat left;
    padding-left: 21px;
}

.attn {
    background:url(http://fedoraproject.org/wikidata/kindofblue/img/attention.png) no-repeat left;
    padding-left: 21px;
}

.check {
    background:url(http://fedoraproject.org/wikidata/kindofblue/img/checkmark.png) no-repeat left;
    padding-left: 21px;
}

.cpan {
    background:url(http://www.perl.com/favicon.ico) no-repeat left;
    padding-left: 18px;
}

.rt {
    background:url(/img/rt.png) no-repeat left;
    padding-left: 18px;
}

.bz {
    background:url(/img/bz.png) no-repeat left;
    padding-left: 18px;
}

<?php
$what=(isset($_GET["what"]) ? $_GET["what"] : false);

require "config.inc.php";

function Report ($db) {
	global $what;

	echo "<h1>Packages in Fedora</h1>\n";


	$repos=array();
	$res=$db->query("SELECT * FROM repo WHERE active=1 ORDER BY ID");
	if ($res) while ($repo = $res->fetchObject()) {
		$repos[$repo->main][$repo->sub]=$repo;
	}

	if (substr($what,0,1)=='%') {
		$sql=sprintf("SELECT DISTINCT name FROM rpm WHERE SUBSTRING(name,1,1)='%s' ORDER BY name", substr($what,1,1));
	} else {
		$sql=sprintf("SELECT DISTINCT name FROM acls WHERE owner='%s' ORDER BY name", $what);
	}
	//echo "<p>SQL=$sql</p>";

	echo "<table id='fedora-list-packages'>\n";
	echo "<tr class='odd'><th>Package</th><th>Owner(s)</th>";

	foreach($repos as $repomain) {
		foreach ($repomain as $repo) {
			printf ("<th align='left'>%s</th>", $repo->main);
			break;
		}
	}
	echo "</tr>\n";

	$i=0;
	$res=$db->query($sql);
	if ($res) while ($desc = $res->fetchObject()) {
		$rpmname = $desc->name;

		$sql2="SELECT DISTINCT owner FROM acls WHERE name LIKE '$rpmname'";
	 	$res2=$db->query($sql2);
		$dispowner="";
		if ($res2) while ($owner= $res2->fetchObject()) {
			if ($dispowner) $dispowner .= "<br>";
			$dispowner .= sprintf ("<a href='%s?what=%s'>%s</a>", $_SERVER["PHP_SELF"], $owner->owner, $owner->owner);
		}

		$sql3 = "SELECT * FROM rpm WHERE name LIKE '$rpmname'";
	 	$res3=$db->query($sql3);
		$rpm = ($res3 ? $res3->fetchObject() : false);

		if ($rpm) {
			$url = $rpm->url;
			$des = $rpm->summary;

			$rpms=array();
			do {
				$rpms[$rpm->repo_main."-".$rpm->repo_sub]=$rpm;
			} while ($rpm = $res3->fetchObject());

			printf ("<tr class='%s'><td><a href='zoom.php?rpm=%s' title='%s'>%s</a></td><td>%s</td>",
				($i%2 ? "odd" : "even"), $rpmname, $des, $rpmname, $dispowner);


			foreach($repos as $repomain) {
				$display="";
				$class="";
				foreach ($repomain as $repo) {
					if (isset($rpms[$repo->main."-".$repo->sub])) {			
						$rpm=$rpms[$repo->main."-".$repo->sub];
	
						$maxver = (isset($rpms["rawhide-"]) ? $rpms["rawhide-"]->ver : "");

						switch ($repo->sub) {
							case "base":
								if (isset($rpms[$repo->main."-updates"])) {
									$display .= sprintf("%s-%s<br>", $rpm->ver, $rpm->rel);
								} else {
									$display .= sprintf("<b>%s</b>-%s<br>", $rpm->ver, $rpm->rel);
									$class = ($rpm->ver == $maxver ? "check" : "attn");
								}
								break;
							case "":
								$display .= sprintf("<b>%s</b>-%s<br>", $rpm->ver, $rpm->rel);
								break;
							case "updates":
								$display .= sprintf("<b>%s</b>-%s <small>(updates)</small><br>", $rpm->ver, $rpm->rel);
								$class = ($rpm->ver == $maxver ? "check" : "attn");
								break;
							case "testing":
								$display .= sprintf("%s-%s <small>(testing)</small><br>", $rpm->ver, $rpm->rel);
								$class = ($rpm->ver == $maxver ? "info" : "attn");
								break;								
						}
					} // RPM exists
				} // sub repo

				if ($class && $maxver) {
					printf("<td><div class='%s'>%s</div></td>", $class, $display);
				} else if ($display) {
					printf("<td>%s</td>", $display);
				} else {
					echo "<td>&nbsp;</td>";
				}
			} // mainrepo

			echo "</tr>\n";
			$i++;	
		}
	} // each Line
	echo "</table>\n";
}

try {
	$db = new PDO ("mysql:dbname=" . MYBASE . ";host=" . MYHOST, MYUSER, MYPASS);
?>
		</style>

		<meta name="MSSmartTagsPreventParsing" content="TRUE">
		<link rel="shortcut icon" href="http://docs.fedoraproject.org/images/favicon.ico">
		<link rel="icon" href="http://docs.fedoraproject.org/images/favicon.ico">
	</head>

	<body>
		<!-- header BEGIN -->
		<div id="fedora-header">
			<div id="fedora-header-logo">

			<a href="http://fedoraproject.org"><img src="http://docs.fedoraproject.org/images/header-fedora_logo01.png" alt="Fedora Project"></a>
			</div>

			<div id="fedora-header-items">
				<span class="fedora-header-search">
					<form action='<?php echo $_SERVER["PHP_SELF"]; ?>' method='get'>
					<select name='what' size='1'>
					<optgroup label='Pakages'>
<?php
	$sql="SELECT DISTINCT CONCAT('%',SUBSTRING(name,1,1)) as init FROM rpm ORDER BY init";
	$res=$db->query($sql);
	if ($res)while ($start = $res->fetchObject()) {
		printf("<option value='%s' %s>Start with %s</option>", $start->init, ($what==$start->init ? "selected='1'" : ""), substr($start->init,1));
	} else {
		echo "<option value='remi'>remi</option>";
	}
?>
					</optgroup>
					<optgroup label='Owner'>
<?php
	$sql="SELECT DISTINCT owner FROM acls ORDER BY owner";
	$res=$db->query($sql);
	if ($res)while ($owner = $res->fetchObject()) {
		printf("<option value='%s' %s>%s</option>", $owner->owner, ($what==$owner->owner ? "selected='1'" : ""), $owner->owner);
	} else {
		echo "<option value='remi'>remi</option>";
	}
?>
					</optgroup>
					</select>
					<input type="image" src='http://docs.fedoraproject.org/images/header-search.png' alt="Search" />
				</form></span>

			</div>

		</div>

		<div id="fedora-nav"></div>
			&nbsp;<img src='http://docs.fedoraproject.org/images/link-offsite-side.png' />
			<a href="./">Reports home</a>
			&nbsp;<img src='http://docs.fedoraproject.org/images/link-offsite-side.png' />
			All packages	
		<!-- header END -->
		
		<!-- leftside BEGIN -->
		<div id="fedora-side-left">
                </div>

		<!-- leftside END -->

		<!-- content BEGIN -->
        <div id="fedora-middle-one">
            <div class="fedora-corner-tr">&nbsp;</div>
            <div class="fedora-corner-tl">&nbsp;</div>
            <div id="fedora-content">

        <!-- document BEGIN -->

        
     
<?php

	$sql='SELECT MAX(stamp) AS stamp FROM repo';
	$res=$db->query($sql);
	if ($res && $row=$res->fetchObject()) {
		printf("<p>Repositories last updated %s.</p>", date("r", $row->stamp));
	}

	if ($what) Report($db);
	else echo "<h2>Choose a criteria from the search menu</h2>";

	//echo "<pre>"; print_r($rpms); echo "</pre>";

}
catch(PDOException $e) {
	printf("%s ERREUR : %s\n", date("r"),  $e->getMessage());
}

?>
<p>&nbsp;</p>

<table id='fedora-list-packages'><tr><th>Legend:&nbsp;</th>
<td><b>Repo</b>: bold for latest release.</td>
<td><div class='check'>Lastest released (as in rawhide)</div></td>
<td><div class='info'>Lastest in testing</div></td>
<td><div class='attn'>Lastest not available</div></td>
</tr></table>

        <!-- document END -->
        </div>
            <div class="fedora-corner-br">&nbsp;</div>
            <div class="fedora-corner-bl">&nbsp;</div>
        </div>

		<!-- content END -->
		
		<!-- footer BEGIN -->

		<div id="fedora-footer">
			<br/>The Fedora Project is maintained and driven by the community and sponsored by Red Hat. 
			<br/><a href="http://fedoraproject.org/wiki/Legal">Legal</a> | <a href="http://fedoraproject.org/wiki/Legal/TrademarkGuidelines">Trademark Guidelines</a>
			<br>		
		</div>

		<!-- footer END -->
	</body>
</html>