SVN: security: generate.php index.php

vip vip at pld-linux.org
Fri Nov 2 17:45:28 CET 2007


Author: vip
Date: Fri Nov  2 17:45:27 2007
New Revision: 8967

Added:
   security/generate.php
Modified:
   security/index.php
Log:
- simple cache mechanism (cache/ dir should be http writable)


Added: security/generate.php
==============================================================================
--- (empty file)
+++ security/generate.php	Fri Nov  2 17:45:27 2007
@@ -0,0 +1,159 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl">
+<head>
+<title>PLD Security Logs</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+<style type="text/css">
+#h2 { text-align: center; }
+body, td { font-family: Verdana; font-size: 9pt; }
+table { border-collapse: collapse; width: 100%; }
+td { padding: 6px 15px; }
+tr.entry { padding: 6px 15px; border-top: 3px solid #ebebe4; border-bottom: 1px solid #ebebe4 }
+tr.branch { padding: 6px 15px; width: 150px; color: red; }
+.thead td, thead td, tfoot td { background-color: #ebebe4 }
+.thead td, thead td { border-bottom: 1px solid #c0c0c0; border-top: 1px solid #c0c0c0; padding: 5px 15px }
+.thead td a, thead td a { color: #000000 }
+tfoot td { border-top: 2px solid #c0c0c0; border-bottom: 1px solid #c0c0c0 }
+tfoot td a { display: block; padding: 2px 5px; border: 1px outset; float: left; border: 1px solid #c0c0c0; background-color: #ffffff; color: #000000; text-decoration: none; margin-left: 5px }
+#phonebookTable thead tr td div {
+	text-align: center;
+	font-weight: bold;
+}
+.status {
+	width: 200px;
+}
+.builder, .spec, .status {
+	width: 100px;
+}
+.recip {
+	width: 80px;
+}
+
+.date {
+	width: 80px;
+	text-align: center;
+}
+.sender {
+	width: 80px;
+}
+.appInfoHead td {
+	text-decoration: underline;
+}
+tr.application:hover td {
+	background: #f2f2f2;
+}
+div#logoPLD {
+	text-align: right;
+}
+
+a, a:visited {
+	color: blue;
+}
+a:hover, a:visited:hover {
+	color: red;
+}
+
+a.mailto, a.mailto:visited {
+	background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAANBAMAAABSlfMXAAAAElBMVEUAAADAwMDIyMjU1NTh4eHq6urvtBmjAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfXBRIQIwkqTPrmAAAANElEQVQI12NgIAIIQgGDsEooEDgZMog6AVlOKoEMoqFOpsEqoSBGqKFwKIQBAtgYihBjhABusBAkFbJeowAAAABJRU5ErkJggg==) right center no-repeat;
+	padding-right: 18px;
+}
+a.mailto:hover, a.mailto:visited:hover {
+	background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAANBAMAAABSlfMXAAAAGFBMVEUAAADAwMDMzMzf39/q6ury8vL5+fn///9jzSKfAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfXBRIQKiMgNYh5AAAAPklEQVQI12NgYGAwFGYAgyDzYlUwrVpeHgRkMQNpIMuAQbgcDAwZRNJBdJkjg4gbiJECZLiAAXEMRUEwEAIApjwY+YHESpgAAAAASUVORK5CYII=);
+}
+#Popup {
+	display: none;
+	position: absolute;
+	padding: 2px;
+	border: 2px solid #c0c0c0;
+	background-color: #ebebe4;
+	color: #000;
+	z-index: 1000;
+	right: auto;
+	bottom: auto;
+	width: auto;
+	max-width: 490px;
+	height: auto;
+	left: 10px;
+	top: 10px;
+}
+.ok { color: green; }
+.fail { color: red; }
+#bottomlink {
+	padding: 15px 15px 15px 15px;
+	text-align: right;
+}
+
+table.sortable thead {
+    background-color:#eee;
+    color:#666666;
+    font-weight: bold;
+    cursor: default;
+}
+</style>
+<script src="sorttable.js"></script>
+</head>
+<body>
+<div id="h2">
+<h2>PLD Security Logs</h2>
+<small>cached; generated <?=date('Y-m-d H:i:s')?></small><br/>
+<a href="rss.xml">Get the RSS feed!</a>
+</div>
+<?php
+
+$header = array('Date', 'Spec','CVE Entry','Revision','Resolved with');
+
+$xml = simplexml_load_file("security.xml");
+
+echo "<table border=0 class='sortable'><tr>";
+
+foreach($header as $i)
+{
+	echo "<td>$i</td>";
+}
+
+echo "</tr>";
+
+foreach($xml->package as $package)
+{
+	echo "<tr><td>"
+		. $package->date . "</td><td>"
+		. $package->spec . "</td><td>";
+
+	foreach($package->cves->entry as $c)
+	{
+		echo "<a href='http://cve.mitre.org/cgi-bin/cvename.cgi?name=" . $c . "'>" . $c . "</a> ";
+	}
+
+	echo "</td><td>";
+	echo '<a href="http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SPECS/'
+		. $package->spec
+		.'?rev='
+		. urlencode($package->revision)
+		. '">'
+		. $package->revision
+		. "</a>";
+	echo "</td><td>";
+
+	foreach($package->resolved->entry as $r)
+	{
+		if(!empty($r->autotag))
+		{
+			echo '<a href="http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SPECS/'
+				. $package->spec
+				.'?logsort=rev;only_with_tag='
+				. urlencode($r->autotag)
+				. '">';
+			echo $r->autotag . "</a>: ";
+		}
+		echo  $r->revision . "<br/>";
+	}
+	echo "</td></tr>";
+}
+echo "</table>";
+?>
+<p align="right">
+<img src="http://pl.docs.pld-linux.org/zrzuty_ekr/logo_03.png" alt="PLD" />
+</p>
+</body>
+</html>

Modified: security/index.php
==============================================================================
--- security/index.php	(original)
+++ security/index.php	Fri Nov  2 17:45:27 2007
@@ -1,160 +1,26 @@
 <?
-ob_start("ob_gzhandler");
-?>
-<!-- http://www.ajaximpact.com/ajaximpact.php?n=10&id=85&back=/detail_Tutorials.php?id=85 -->
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl">
-<head>
-<title>PLD Security Logs</title>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
-<style type="text/css">
-h2 { text-align: center; }
-body, td { font-family: Verdana; font-size: 9pt; }
-table { border-collapse: collapse; width: 100%; }
-td { padding: 6px 15px; }
-tr.entry { padding: 6px 15px; border-top: 3px solid #ebebe4; border-bottom: 1px solid #ebebe4 }
-tr.branch { padding: 6px 15px; width: 150px; color: red; }
-.thead td, thead td, tfoot td { background-color: #ebebe4 }
-.thead td, thead td { border-bottom: 1px solid #c0c0c0; border-top: 1px solid #c0c0c0; padding: 5px 15px }
-.thead td a, thead td a { color: #000000 }
-tfoot td { border-top: 2px solid #c0c0c0; border-bottom: 1px solid #c0c0c0 }
-tfoot td a { display: block; padding: 2px 5px; border: 1px outset; float: left; border: 1px solid #c0c0c0; background-color: #ffffff; color: #000000; text-decoration: none; margin-left: 5px }
-#phonebookTable thead tr td div {
-	text-align: center;
-	font-weight: bold;
-}
-.status {
-	width: 200px;
-}
-.builder, .spec, .status {
-	width: 100px;
-}
-.recip {
-	width: 80px;
-}
-
-.date {
-	width: 80px;
-	text-align: center;
-}
-.sender {
-	width: 80px;
-}
-.appInfoHead td {
-	text-decoration: underline;
-}
-tr.application:hover td {
-	background: #f2f2f2;
-}
-div#logoPLD {
-	text-align: right;
-}
-
-a, a:visited {
-	color: blue;
-}
-a:hover, a:visited:hover {
-	color: red;
-}
-
-a.mailto, a.mailto:visited {
-	background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAANBAMAAABSlfMXAAAAElBMVEUAAADAwMDIyMjU1NTh4eHq6urvtBmjAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfXBRIQIwkqTPrmAAAANElEQVQI12NgIAIIQgGDsEooEDgZMog6AVlOKoEMoqFOpsEqoSBGqKFwKIQBAtgYihBjhABusBAkFbJeowAAAABJRU5ErkJggg==) right center no-repeat;
-	padding-right: 18px;
-}
-a.mailto:hover, a.mailto:visited:hover {
-	background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAANBAMAAABSlfMXAAAAGFBMVEUAAADAwMDMzMzf39/q6ury8vL5+fn///9jzSKfAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfXBRIQKiMgNYh5AAAAPklEQVQI12NgYGAwFGYAgyDzYlUwrVpeHgRkMQNpIMuAQbgcDAwZRNJBdJkjg4gbiJECZLiAAXEMRUEwEAIApjwY+YHESpgAAAAASUVORK5CYII=);
-}
-#Popup {
-	display: none;
-	position: absolute;
-	padding: 2px;
-	border: 2px solid #c0c0c0;
-	background-color: #ebebe4;
-	color: #000;
-	z-index: 1000;
-	right: auto;
-	bottom: auto;
-	width: auto;
-	max-width: 490px;
-	height: auto;
-	left: 10px;
-	top: 10px;
-}
-.ok { color: green; }
-.fail { color: red; }
-#bottomlink {
-	padding: 15px 15px 15px 15px;
-	text-align: right;
-}
-
-table.sortable thead {
-    background-color:#eee;
-    color:#666666;
-    font-weight: bold;
-    cursor: default;
-}
-</style>
-<script src="sorttable.js"></script>
-</head>
-<body>
-<h2>PLD Security Logs</h2>
-<p align="center"><a href="rss.xml">Get the RSS feed!</a></p>
-<?php
-
-$header = array('Date', 'Spec','CVE Entry','Revision','Resolved with');
-
-$xml = simplexml_load_file("security.xml");
-
-echo "<table border=0 class='sortable'><tr>";
-
-foreach($header as $i)
+error_reporting(0);
+$cache = file('../size.txt');
+if(is_array($cache))
 {
-	echo "<td>$i</td>";
-}
-
-echo "</tr>";
-
-foreach($xml->package as $package)
-{
-	echo "<tr><td>"
-		. $package->date . "</td><td>"
-		. $package->spec . "</td><td>";
-
-	foreach($package->cves->entry as $c)
+	$cache = 'cache/' . trim($cache[0]);
+	$cache_l = 'cache/cache.html';
+	
+	if(!is_file($cache) || !is_link($cache_l))
 	{
-		echo "<a href='http://cve.mitre.org/cgi-bin/cvename.cgi?name=" . $c . "'>" . $c . "</a> ";
-	}
 
-	echo "</td><td>";
-	echo '<a href="http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SPECS/'
-		. $package->spec
-		.'?rev='
-		. urlencode($package->revision)
-		. '">'
-		. $package->revision
-		. "</a>";
-	echo "</td><td>";
+		unlink(readlink($cache_l));
 
-	foreach($package->resolved->entry as $r)
-	{
-		if(!empty($r->autotag))
-		{
-			echo '<a href="http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SPECS/'
-				. $package->spec
-				.'?logsort=rev;only_with_tag='
-				. urlencode($r->autotag)
-				. '">';
-			echo $r->autotag . "</a>: ";
-		}
-		echo  $r->revision . "<br/>";
+		ob_start();
+		include('generate.php');
+		$content = ob_get_clean();
+		file_put_contents($cache, $content);
+		unlink($cache_l);
+
+		symlink($cache, $cache_l);
 	}
-	echo "</td></tr>";
 }
-echo "</table>";
+
+ob_start('ob_gzhandler');
+readfile($cache_l);
 ?>
-<p align="right">
-<img src="http://pl.docs.pld-linux.org/zrzuty_ekr/logo_03.png" alt="PLD" />
-</p>
-</body>
-</html>


More information about the pld-cvs-commit mailing list