From 823ab006aaa504aaaa9be5e9b5c27cbdf3df28cc Mon Sep 17 00:00:00 2001 From: Nick White Date: Sun, 23 Aug 2009 02:41:10 +0100 Subject: Initial commit of website code --- includes/default.css | 70 +++++++++++++++++++++++++++++++++++++++ includes/footer.php | 39 ++++++++++++++++++++++ includes/header.php | 48 +++++++++++++++++++++++++++ includes/rss.php | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++ includes/tarball.php | 41 +++++++++++++++++++++++ 5 files changed, 291 insertions(+) create mode 100644 includes/default.css create mode 100644 includes/footer.php create mode 100644 includes/header.php create mode 100644 includes/rss.php create mode 100644 includes/tarball.php (limited to 'includes') diff --git a/includes/default.css b/includes/default.css new file mode 100644 index 0000000..a98ab34 --- /dev/null +++ b/includes/default.css @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2009 Nick White + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +body +{ + font-family: sans-serif; + max-width: 75%; + margin: auto; +} + +h1 +{ + text-align: center; + font-size: 1.6em; +} + +h2 +{ + font-size: 1.2em; + font-weight: normal; + border-bottom: thin solid black; +} + +h3 +{ + font-size: 1.1em; + font-weight: normal; +} + +a { text-decoration: none; } + +a:hover { color: #5555dd; } + +p a:hover { text-decoration: underline; } + +div#footer +{ + border-top: thin solid black; + margin: 6ex auto 1ex; + font-size: xx-small; +} + +div#copyright +{ + border: thin solid #777; + background-color: #ddd; + color: black; + padding: 0.4ex 1em; + margin: auto 2%; +} + +div#copyright p +{ + margin-top: 0.2ex; + margin-bottom: 0.2ex; +} diff --git a/includes/footer.php b/includes/footer.php new file mode 100644 index 0000000..056c6b1 --- /dev/null +++ b/includes/footer.php @@ -0,0 +1,39 @@ +. + */ + +$moddate = filemtime($_SERVER['DOCUMENT_ROOT'] . "/text/" . $_SERVER['PHP_SELF']); +$moddate = date("d/m/Y", $moddate); + +?> + + + + + + diff --git a/includes/header.php b/includes/header.php new file mode 100644 index 0000000..b9c59fc --- /dev/null +++ b/includes/header.php @@ -0,0 +1,48 @@ +. + */ + +header("Vary: Accept"); +if (stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml")) + header("Content-Type: application/xhtml+xml; charset=utf-8"); +else + header("Content-Type: text/html; charset=utf-8"); + +function xhtml_header($title) +{ + $newtitle = str_replace("&", "&", stripslashes($title)); + + print(' + + + + + + ' . $newtitle . ' + + + + + + + + +

' . $newtitle . '

'); + +} +?> diff --git a/includes/rss.php b/includes/rss.php new file mode 100644 index 0000000..d752f26 --- /dev/null +++ b/includes/rss.php @@ -0,0 +1,93 @@ +. + */ + +header("Content-Type: application/rss+xml"); + +function extract_description($body) +{ + $body = explode("\n", $body); + $description = strip_tags($body[0]); /* use first line of body */ + return $description; +} + +function rss_header($metadatafile) +{ + print("\n"); + print("\n"); + + /* get variables to use for channel metadata */ + include($_SERVER['DOCUMENT_ROOT'] . $metadatafile); + + print("\n"); + print("\t" . $title . "\n"); + print("\t" . "http://" . $_SERVER['HTTP_HOST'] . "\n"); + $description = extract_description($body); + print("\t" . $description . "\n"); + print("\t" . date("r") . "\n"); + if (isset($copyright) && !empty($copyright)) + print("\t" . $copyright . "\n"); + if (empty($language) || !isset($language)) + $language = "en"; + print("\t" . $language . "\n"); +} + +function create_item($dir, $file, $full=0) +{ + unset($title, $body, $description, $language, $category, $pubdate); + print("\t\n"); + include($_SERVER['DOCUMENT_ROOT'] . "/" . $dir . "/" . $file); + print("\t\t" . $title . "\n"); + print("\t\t" . "http://" . $_SERVER['SERVER_NAME'] . "/" . $dir . "/" . $file . "\n"); + print("\t\t" . "http://" . $_SERVER['SERVER_NAME'] . "/" . $dir . "/" . $file . "\n"); + $pubdate = filemtime($dir . "/" . $file); + $pubdate = date("r", $pubdate); + print("\t\t" . $pubdate . "\n"); + $category = ereg_replace("^text", "", $dir); /* dir after text */ + if (!empty($category)) + print("\t\t" . $category . "\n"); + if ($full) + print("\t\t" . strip_tags($body) . "\n"); + else + print("\t\t" . extract_description($body) . "\n"); + print("\t\n"); +} + +function create_items_from_dir($dir, $full=0) +{ + if ($handle = opendir($dir)) { + while (false !== ($file = readdir($handle))) { + if (!is_dir($file)) { + if ($file[0] != "." && ereg(".php$", $file)) + create_item($dir, $file, $full); + } + else { + if ($file[0] != ".") + create_items_from_dir($dir . "/" . $file, $full); + } + } + closedir($handle); + } +} + +function rss_footer() +{ + print("\n"); + print("\n"); +} + +?> diff --git a/includes/tarball.php b/includes/tarball.php new file mode 100644 index 0000000..737aefa --- /dev/null +++ b/includes/tarball.php @@ -0,0 +1,41 @@ +. + */ + +function return_tarball($name, $contents) +{ + require("Archive/Tar.php"); + + $mimetype = "application/x-tar"; + $extension = "tar.bz2"; + + $timestamp = strftime('%F'); + + /* Use output buffering (ob_start and ob_end_flush) to ensure that the + * tarball data sent to stdout doesn't interfere with the headers. */ + ob_start(); + header('Content-Type: ' . $mimetype); + header('Content-Disposition: attachment; filename="' . $name . '-' . $timestamp . '.' . $extension . '"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + ob_end_flush(); + + $tarball = new Archive_Tar("php://stdout", "bz2"); + + $tarball->create($contents); +} -- cgit v1.2.3