--- a/sitemap.xml.php
+++ b/sitemap.xml.php
@@ -1,14 +1,91 @@
";
- echo '' . "\n";
- echo " ".local_url()."index.php1.0\n";
-foreach (scandir("./") as $file) {
- if (strpos($file,".php") !== false && $file != "index.php" && $file != "sitemap.xml.php") echo " ".local_url()."$file0.3\n";
+$result = $conn->query('SELECT title, to_char("lastUpdated",\'YYYY-MM-DD\') AS "lastUpdated" FROM datasets');
+foreach ($result->fetchAll() as $row) {
+ if ($row['title'] == "Contract Notices") {
+ $last_updated['agency'] = $row['lastUpdated'];
+ $last_updated['supplier'] = $row['lastUpdated'];
+ $last_updated['category'] = $row['lastUpdated'];
+ $last_updated['SON'] = $row['lastUpdated'];
+ }
}
- echo '';
+if (isset($_REQUEST['section']) == false) {
+ echo '';
+ foreach ($sections as $section) {
+ $pages = 0;
+ $i = 0;
+ if ($section == 'supplier') $pages = 1;
+ do {
+ echo "
+ " . local_url() . "sitemap.xml.php?section=$section&page=$i
+ " . $last_updated[$section] . '';
+ $i++;
+ } while ($i <= $pages);
+ }
+ echo '';
+} else {
+ echo '' . "\n";
+ if ($_REQUEST['section'] == "page") {
+ echo " " . local_url() . "index.php1.0\n";
+ foreach (scandir("./") as $file) {
+ if (strpos($file, ".php") !== false && $file != "index.php" && $file != "sitemap.xml.php") echo " " . local_url() . "$file0.3\n";
+ }
+ }
+ if ($_REQUEST['section'] == "agency") {
+ $result = $conn->query('SELECT DISTINCT "agencyName" FROM contractnotice');
+ foreach ($result->fetchAll() as $row) {
+ echo " " . local_url() . "displayAgency.php?agency=" . urlencode($row['agencyName']) . "
+ " . $last_updated['agency'] . "\n";
+ }
+ }
+ if ($_REQUEST['section'] == "supplier") {
+ $start = $_REQUEST['page'] * 40000;
+ $result = $conn->prepare('SELECT DISTINCT ON ("supplierID") (
+ CASE WHEN "supplierABN" != 0 THEN "supplierABN"::TEXT ELSE lower("supplierName") END) AS "supplierID", "supplierABN", "supplierName"
+ FROM contractnotice
+ order by "supplierID"
+ LIMIT 40000 OFFSET :start
+');
+ $result->execute(array(':start' => $start));
+ foreach ($result->fetchAll() as $row) {
+
+ $supplier = urlencode(stripslashes($row['supplierABN'] . '-' . $row['supplierName']));
+ echo " " . local_url() . "displaySupplier.php?supplier=$supplier
+ " . $last_updated['supplier'] . "\n";
+ }
+ }
+ if ($_REQUEST['section'] == "category") {
+ $result = $conn->query('SELECT DISTINCT category FROM contractnotice;');
+ foreach ($result->fetchAll() as $row) {
+
+ echo " " . local_url() . "displayCategory.php?category=" . urlencode($row['category']) . "
+ " . $last_updated['category'] . "\n";
+
+ }
+ }
+ if ($_REQUEST['section'] == "SON") {
+ $result = $conn->query('SELECT DISTINCT "SONID" FROM contractnotice;');
+ foreach ($result->fetchAll() as $row) {
+
+ echo " " . local_url() . "displaySON.php?SONID=" . urlencode($row['SONID']) . "
+ " . $last_updated['SON'] . "\n";
+
+ }
+ }
+ echo '';
+}
?>