summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--htdocs/config.php.defaults28
-rw-r--r--htdocs/index.php16
-rw-r--r--utils/forms.php2
-rw-r--r--utils/imagecache.php5
-rw-r--r--utils/modules/events.php53
-rw-r--r--utils/modules/news.php49
-rw-r--r--utils/modules/rss.php114
-rw-r--r--utils/rss.php54
8 files changed, 230 insertions, 91 deletions
diff --git a/htdocs/config.php.defaults b/htdocs/config.php.defaults
deleted file mode 100644
index 84d7c52..0000000
--- a/htdocs/config.php.defaults
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-/* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-
-$PAGE_DIR = "../pages";
-$DATA_DIR = "../data";
-$ALBUMS_DIR = "gfx/albums";
-$ICONS_DIR = "gfx/icons";
-$MEMBERS_DIR = "gfx/members";
-$UTIL_DIR = "../utils";
-$MODULES_DIR = $UTIL_DIR . "/modules";
-
-$MODULES = array("news", "events", "pages", "gallery", "config", "icons", "members");
-
-$DEFAULT_PAGE = "news";
-
-$ADMIN_TIMEOUT = 60*60; // 60 min timeout
-
-$PRELOAD = array("gfx/biography_hover.jpg",
- "gfx/contact_hover.jpg",
- "gfx/discography_hover.jpg" ,
- "gfx/downloads_hover.jpg",
- "gfx/gallery_hover.jpg",
- "gfx/guestbook_hover.jpg",
- "gfx/live_hover.jpg",
- "gfx/members_hover.jpg",
- "gfx/news_hover.jpg",
- "gfx/shop_hover.jpg");
-?> \ No newline at end of file
diff --git a/htdocs/index.php b/htdocs/index.php
index 823c388..a550f77 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -1,7 +1,17 @@
<?php
$start_time = microtime(true);
-include_once("config.php");
+if(file_exists("config.php")) include_once("config.php");
+
+if(!isset($DATA_DIR)) $DATA_DIR = "../data";
+if(!isset($ALBUMS_DIR)) $ALBUMS_DIR = "gfx/albums";
+if(!isset($ICONS_DIR)) $ICONS_DIR = "gfx/icons";
+if(!isset($MEMBERS_DIR)) $MEMBERS_DIR = "gfx/members";
+if(!isset($UTIL_DIR)) $UTIL_DIR = "../utils";
+if(!isset($MODULES_DIR)) $MODULES_DIR = $UTIL_DIR . "/modules";
+if(!isset($IMAGECACHE)) $IMAGECACHE = $DATA_DIR . "/imagecache";
+if(!isset($ADMIN_TIMEOUT)) $ADMIN_TIMEOUT = 60*60; // 60 min timeout
+if(!isset($JPEG_CACHE_QUALITY)) $JPEG_CACHE_QUALITY = 85;
if($mode == "imagecache") {
include_once($UTIL_DIR. "/imagecache.php");
@@ -41,7 +51,7 @@ if($config->value('splash') == "true") {
<link href="/favicon.ico" rel="shortcut icon"/>
<link rel="stylesheet" type="text/css" href="<?php echo $config->value('css'); ?>" media="screen"/>
</head>
-<body>
+<body class="splashbody">
<div class="splash">
<?php
$p = $pages->getPage($config->value('splashpage'));
@@ -56,7 +66,6 @@ if($config->value('splash') == "true") {
}
}
-
?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
@@ -70,7 +79,6 @@ if($config->value('splash') == "true") {
<link rel="author" title="Bent Bisballe Nyeng" href="http://www.aasimon.org"/>
<link href="/favicon.ico" rel="shortcut icon"/>
<link rel="stylesheet" type="text/css" href="<?php echo $config->value('css'); ?>" media="screen"/>
-<!-- <link rel="stylesheet" type="text/css" href="handheld.css" media="handheld"/> -->
<link rel="stylesheet" type="text/css" href="admin.css" media="screen"/>
<script type="text/javascript">
// <!--
diff --git a/utils/forms.php b/utils/forms.php
index 0268315..39e1a4c 100644
--- a/utils/forms.php
+++ b/utils/forms.php
@@ -1,4 +1,4 @@
-<?php
+<?php /* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
include_once($UTIL_DIR."/convert.php");
diff --git a/utils/imagecache.php b/utils/imagecache.php
index a4a7792..347e946 100644
--- a/utils/imagecache.php
+++ b/utils/imagecache.php
@@ -1,6 +1,7 @@
-<?php
+<?php /* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+
+global $UTIL_DIR, $MODULES_DIR;
-include_once("config.php");
include_once($UTIL_DIR . "/modules.php");
class ImageSize {
diff --git a/utils/modules/events.php b/utils/modules/events.php
index be11dcf..3bccce6 100644
--- a/utils/modules/events.php
+++ b/utils/modules/events.php
@@ -21,23 +21,22 @@ class Event {
fwrite($fp, "</event>\n");
}
- public function show()
+ public function show($eventpage)
{
- global $ICONS_DIR, $EVENT_PAGE;
- $icons = new Icons($ICONS_DIR."/");
- $icon = $icons->icons[$this->flyer];
-
$content = Markdown(htmlspecialchars_decode($this->description));
$str = "<div class=\"event\">\n";
$str .= " <div class=\"event_time\">" . date("D M jS Y", $this->time) . "</div>\n";
$str .= " <div class=\"event_title\">\n";
- $str .= " <a href=\"?page=".$EVENT_PAGE."&amp;eventid=".$this->time."\">".
+ $str .= " <a href=\"?page=".$eventpage."&amp;eventid=".$this->time."\">".
htmlspecialchars_decode($this->title, ENT_QUOTES) . "</a>\n";
$str .= "</div>\n";
$str .= " <div class=\"event_description\">" . $content . "</div>\n";
/*
if($this->flyer) {
+ global $ICONS_DIR;
+ $icons = new Icons($ICONS_DIR."/");
+ $icon = $icons->icons[$this->flyer];
$str .= " <img class=\"event_flyer\" alt=\"flyer\" src=\"".$icon->prefix.$icon->file."\"/>\n";
}
*/
@@ -58,12 +57,32 @@ class Events {
private $file;
private $events = array();
+ public $eventpage;
// Admin config
public $admin_title = "Events";
public $admin_submodules = array("Add Event" => "add",
"Edit Event" => "edit",
- "Delete Event" => "delete");
+ "Delete Event" => "delete",
+ "Config" => "config");
+
+ public function admin_config($action, $vars)
+ {
+ switch($action) {
+ case "update":
+ $this->eventpage = $vars["eventpage"];
+ // echo "The title has now been changed to \"". $this->value("title") . "\"";
+ $this->write();
+ break;
+
+ default:
+ $form = new Form("update");
+ $form->addWidget(new LineEdit("Event page:", "eventpage", $this->eventpage));
+ $form->addWidget(new Button("Update"));
+ $form->render();
+ break;
+ }
+ }
public function admin_add($action, $vars)
{
@@ -83,7 +102,7 @@ class Events {
$vars["description"], $vars["icon"]);
echo "<div class=\"preview\">\n";
echo "<div class=\"content\">\n";
- echo $event->show();
+ echo $event->show($this->eventpage);
echo "</div>\n";
echo "</div>\n";
echo "<p>Looking ok?</p>";
@@ -134,7 +153,7 @@ class Events {
$vars["description"], $vars["icon"]);
echo "<div class=\"preview\">\n";
echo "<div class=\"content\">\n";
- echo $event->show();
+ echo $event->show($this->eventpage);
echo "</div>\n";
echo "</div>\n";
echo "<p>Looking ok?</p>";
@@ -227,6 +246,9 @@ class Events {
public function admin($sub, $action, $vars)
{
switch($sub) {
+ case "config":
+ $this->admin_config($action, $vars);
+ break;
case "add":
$this->admin_add($action, $vars);
break;
@@ -269,7 +291,7 @@ class Events {
if($single == true) {
if($eventid && $this->events[$eventid]) {
- $str .= $this->events[$eventid]->show();
+ $str .= $this->events[$eventid]->show($this->eventpage);
} else {
$str .= "<strong>No such show!</strong>\n";
}
@@ -308,7 +330,7 @@ class Events {
foreach($this->events as $event) {
$foundany = true;
- $str .= $event->show();
+ $str .= $event->show($this->eventpage);
$number--;
if(!$number) return $str;
}
@@ -332,7 +354,7 @@ class Events {
foreach($this->events as $event) {
if($event->time >= time()) {
$foundany = true;
- $str .= $event->show();
+ $str .= $event->show($this->eventpage);
$number--;
}
if(!$number) return $str;
@@ -354,7 +376,7 @@ class Events {
foreach($this->events as $event) {
if($event->time <= time()) {
- $str .= $event->show();
+ $str .= $event->show($this->eventpage);
$number--;
}
if(!$number) return $str;
@@ -373,7 +395,7 @@ class Events {
$fp = fopen($this->file, "w");
fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
- fwrite($fp, "<events>\n");
+ fwrite($fp, "<events eventpage=\"".xmlenc($this->eventpage)."\">\n");
foreach($this->events as $event) {
$event->write($fp);
}
@@ -389,6 +411,9 @@ class Events {
$dom->load($this->file);
$params = $dom->getElementsByTagName('event');
+ $events = $dom->documentElement;
+ $this->eventpage = $events->getAttribute('eventpage');
+
foreach ($params as $param) {
$event = new Event($param->getAttribute('title'),
$param->getAttribute('time'),
diff --git a/utils/modules/news.php b/utils/modules/news.php
index 032c342..b59b7fd 100644
--- a/utils/modules/news.php
+++ b/utils/modules/news.php
@@ -17,9 +17,9 @@ class NewsEntry {
public $userid;
public $icon;
- public function show()
+ public function show($newspage)
{
- global $users, $DATA_DIR, $ICONS_DIR, $NEWS_PAGE;
+ global $users, $DATA_DIR, $ICONS_DIR;
if(!isset($users)) $users = new Users($DATA_DIR . "/users.xml");
@@ -35,7 +35,7 @@ class NewsEntry {
$str .= " <div class=\"news_time\">" .
date("D M jS Y G:i", $this->time) . "</div>\n";
$str .= " <div class=\"news_title\">\n";
- $str .= " <a href=\"?page=".$NEWS_PAGE."&amp;newsid=".$this->time."\">" .
+ $str .= " <a href=\"?page=".$newspage."&amp;newsid=".$this->time."\">" .
htmlspecialchars_decode($this->title, ENT_QUOTES) . "</a>\n";
$str .= " </div>\n";
$str .= " <div class=\"news_user\">By: " . $userid . "</div>\n";
@@ -80,13 +80,32 @@ class News {
private $file;
private $news = array();
+ public $newspage;
// Admin config
public $admin_title = "News";
public $admin_submodules = array("New entry" => "new",
"Edit entry" => "edit",
- "Delete entry" => "delete");
+ "Delete entry" => "delete",
+ "Config" => "config");
+ public function admin_config($action, $vars)
+ {
+ switch($action) {
+ case "update":
+ $this->newspage = $vars["newspage"];
+ $this->write();
+ break;
+
+ default:
+ $form = new Form("update");
+ $form->addWidget(new LineEdit("News page (single):", "newspage", $this->newspage));
+ $form->addWidget(new Button("Update"));
+ $form->render();
+ break;
+ }
+ }
+
public function admin_add($action, $vars)
{
global $UID, $ICONS_DIR;
@@ -109,7 +128,7 @@ class News {
$UID, $vars["icon"]);
echo "<div class=\"preview\">\n";
echo "<div class=\"content\">\n";
- echo $n->show();
+ echo $n->show($this->newspage);
echo "</div>\n";
echo "</div>\n";
echo "<p>Looking ok?</p>";
@@ -166,7 +185,7 @@ class News {
$vars["category"], $vars["description"], $UID, $vars["icon"]);
echo "<div class=\"preview\">\n";
echo "<div class=\"content\">\n";
- echo $n->show();
+ echo $n->show($this->newspage);
echo "</div>\n";
echo "</div>\n";
echo "<p>Looking ok?</p>";
@@ -265,6 +284,10 @@ class News {
public function admin($sub, $action, $vars)
{
switch($sub) {
+ case "config":
+ $this->admin_config($action, $vars);
+ break;
+
case "new":
$this->admin_add($action, $vars);
break;
@@ -308,7 +331,7 @@ class News {
if($single) {
if($newsid && $this->news[$newsid]) {
// $str .= $this->show($number, $module);
- $str .= $this->news[$newsid]->show();
+ $str .= $this->news[$newsid]->show($this->newspage);
} else {
$str .= "<strong>No such news entry!</strong>\n";
}
@@ -328,7 +351,7 @@ class News {
foreach($this->news as $newsentry) {
if($newsentry->category == $category || $category == "all") {
- $str .= $newsentry->show();
+ $str .= $newsentry->show($this->newspage);
$number--;
}
if(!$number) return $str;
@@ -343,10 +366,12 @@ class News {
public function write()
{
+ global $DATA_DIR;
+
$fp = fopen($this->file, "w");
fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
- fwrite($fp, "<news>\n");
+ fwrite($fp, "<news newspage=\"".xmlenc($this->newspage)."\">\n");
foreach($this->news as $newsentry) {
$newsentry->write($fp);
}
@@ -354,7 +379,7 @@ class News {
fclose($fp);
- $rss = new RSS($this->file, "rss.xml");
+ $rss = new RSS($this->file, $DATA_DIR."/rss.xml");
$rss->write();
}
@@ -363,6 +388,10 @@ class News {
$dom = new DomDocument;
$dom->preserveWhiteSpace = FALSE;
$dom->load($this->file);
+
+ $n = $dom->documentElement;
+ $this->newspage = $n->getAttribute('newspage');
+
$params = $dom->getElementsByTagName('newsentry');
foreach ($params as $param) {
diff --git a/utils/modules/rss.php b/utils/modules/rss.php
new file mode 100644
index 0000000..02501b3
--- /dev/null
+++ b/utils/modules/rss.php
@@ -0,0 +1,114 @@
+<?php /* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+
+global $UTIL_DIR;
+
+include_once($UTIL_DIR . "/convert.php");
+
+class RSSConfig {
+ private $file;
+ private $configs = array();
+
+ public $title;
+ public $url;
+ public $description;
+ public $editoremail;
+ public $webmasteremail;
+ public $target;
+
+ // Admin config
+ public $admin_title = "RSS Config";
+ public $admin_submodules = array("Config" => "config");
+
+ public function admin_config($action, $vars)
+ {
+ switch($action) {
+ case "update":
+ $this->title = $vars["title"];
+ $this->url = $vars["url"];
+ $this->description = $vars["description"];
+ $this->editoremail = $vars["editoremail"];
+ $this->webmasteremail = $vars["webmasteremail"];
+ $this->target = $vars["target"];
+ $this->write();
+ break;
+
+ default:
+ $form = new Form("update");
+ $form->addWidget(new LineEdit("Title:", "title", $this->title));
+ $form->addWidget(new LineEdit("Base URL:", "url", $this->url));
+ $form->addWidget(new LineEdit("Description:", "description", $this->description));
+ $form->addWidget(new LineEdit("Editor Email:", "editoremail", $this->editoremail));
+ $form->addWidget(new LineEdit("Webmaster Email:", "webmasteremail", $this->webmasteremail));
+ $form->addWidget(new LineEdit("Target file:", "target", $this->target));
+ $form->addWidget(new Button("Update"));
+ $form->render();
+ break;
+ }
+ }
+
+ public function admin($sub, $action, $vars)
+ {
+ switch($sub) {
+ case "config":
+ $this->admin_config($action, $vars);
+ break;
+ }
+ }
+
+ public function write()
+ {
+ $fp = fopen($this->file, "w");
+ fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+
+ fwrite($fp, "<rss title=\"".xmlenc($this->title)."\"\n");
+ fwrite($fp, " url=\"".xmlenc($this->url)."\"\n");
+ fwrite($fp, " description=\"".xmlenc($this->description)."\"\n");
+ fwrite($fp, " editoremail=\"".xmlenc($this->editoremail)."\"\n");
+ fwrite($fp, " webmasteremail=\"".xmlenc($this->webmasteremail)."\"\n");
+ fwrite($fp, " target=\"".xmlenc($this->target)."\">\n");
+ fwrite($fp, "</rss>\n");
+
+ fclose($fp);
+ }
+
+ private function read()
+ {
+ $dom = new DomDocument;
+ $dom->preserveWhiteSpace = TRUE;
+ $dom->load($this->file);
+
+ $rss = $dom->documentElement;
+ $this->title = $rss->getAttribute('title');
+ $this->url = $rss->getAttribute('url');
+ $this->description = $rss->getAttribute('description');
+ $this->editoremail = $rss->getAttribute('editoremail');
+ $this->webmasteremail = $rss->getAttribute('webmasteremail');
+ $this->target = $rss->getAttribute('target');
+ }
+
+ public function value($name, $default = "")
+ {
+ if(isset($this->configs[$name])) return $this->configs[$name];
+ return $default;
+ }
+
+ public function setValue($name, $value)
+ {
+ $this->configs[$name] = $value;
+ }
+
+ public function RSSConfig($file)
+ {
+ $this->file = $file;
+ if(file_exists($file)) $this->read();
+ }
+
+}
+
+function rss_init()
+{
+ global $DATA_DIR;
+ return new RSSConfig($DATA_DIR . "/rss.xml");
+}
+
+?> \ No newline at end of file
diff --git a/utils/rss.php b/utils/rss.php
index bed69ce..8eec881 100644
--- a/utils/rss.php
+++ b/utils/rss.php
@@ -1,7 +1,9 @@
<?php
+global $MODULE_DIR, $UTIL_DIR;
-include_once("convert.php");
+include_once($UTIL_DIR . "/convert.php");
include_once($UTIL_DIR . "/markdown.php");
+include_once($MODULES_DIR . "/rss.php");
class RSSEntry {
public $title;
@@ -9,18 +11,6 @@ class RSSEntry {
public $description;
public $category;
- /*
- public function show()
- {
- echo "<div class=\"news_entry\">\n";
- echo " <div class=\"news_title\">" .
- htmlspecialchars_decode($this->title, ENT_QUOTES) . "</div>\n";
- echo " <div class=\"news_time\">" . date("D M jS Y G:i", $this->time) . "</div>\n";
- echo " <div class=\"news_description\">" .
- htmlspecialchars_decode($this->description, ENT_QUOTES) . "</div>\n";
- echo "</div>\n";
- }
- */
public function RSSEntry($title, $time, $category, $description)
{
$this->title = $title;
@@ -32,9 +22,11 @@ class RSSEntry {
class RSS {
+ private $configfile;
+ private $config;
private $newsfile;
- private $rssfile;
private $news = array();
+ private $newspage;
public function add($newsentry) {
$key = $newsentry->time;
@@ -47,38 +39,31 @@ class RSS {
public function write()
{
- global $RSS_TITLE;
- global $RSS_URL;
- global $RSS_DESCRIPTION;
- global $RSS_EDITOR;
- global $RSS_WEBMASTER;
- global $RSS_TARGET_PAGE;
-
- $fp = fopen($this->rssfile, "w");
+ $fp = fopen($this->config->target, "w");
fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
fwrite($fp, "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n");
fwrite($fp, " <channel>\n");
- fwrite($fp, " <title>".$RSS_TITLE."</title>\n");
- fwrite($fp, " <atom:link href=\"".$RSS_URL."/rss.xml\" rel=\"self\" type=\"application/rss+xml\" />\n");
- fwrite($fp, " <link>".$RSS_URL."</link>\n");
- fwrite($fp, " <description>".$RSS_DESCRIPTION."</description>\n");
+ fwrite($fp, " <title>".$this->config->title."</title>\n");
+ fwrite($fp, " <atom:link href=\"".$this->config->url."/rss.xml\" rel=\"self\" type=\"application/rss+xml\" />\n");
+ fwrite($fp, " <link>".$this->config->url."</link>\n");
+ fwrite($fp, " <description>".$this->config->description."</description>\n");
fwrite($fp, " <language>en-us</language>\n");
fwrite($fp, " <pubDate>".$this->date(time())."</pubDate>\n");
fwrite($fp, " <lastBuildDate>".$this->date(time())."</lastBuildDate>\n");
fwrite($fp, " <docs>http://blogs.law.harvard.edu/tech/rss</docs>\n");
fwrite($fp, " <generator>ExecutionRoom CMS</generator>\n");
- fwrite($fp, " <managingEditor>".$RSS_EDITOR."</managingEditor>\n");
- fwrite($fp, " <webMaster>".$RSS_WEBMASTER."</webMaster>\n");
+ fwrite($fp, " <managingEditor>".$this->config->editoremail."</managingEditor>\n");
+ fwrite($fp, " <webMaster>".$this->config->webmasteremail."</webMaster>\n");
$i = 0;
foreach($this->news as $newsentry) {
fwrite($fp, " <item>\n");
fwrite($fp, " <title>".$newsentry->title."</title>\n");
- fwrite($fp, " <link>".$RSS_URL."/?page=".$RSS_TARGET_PAGE."&amp;newsid=".$newsentry->time."</link>\n");
+ fwrite($fp, " <link>".$this->config->url."/?page=".$this->newspage."&amp;newsid=".$newsentry->time."</link>\n");
$content = htmlspecialchars(Markdown(htmlspecialchars_decode($newsentry->description), true));
fwrite($fp, " <description>".$content."</description>\n");
fwrite($fp, " <pubDate>".$this->date($newsentry->time)."</pubDate>\n");
- fwrite($fp, " <guid>".$RSS_URL."/?page=".$RSS_TARGET_PAGE."&amp;newsid=".$newsentry->time."</guid>\n");
+ fwrite($fp, " <guid>".$this->config->url."/?page=".$this->newspage."&amp;newsid=".$newsentry->time."</guid>\n");
fwrite($fp, " </item>\n");
$i++;
if($i > 6) break;
@@ -92,10 +77,15 @@ class RSS {
private function read()
{
+ $this->config = new RSSConfig($this->configfile);
$dom = new DomDocument;
$dom->preserveWhiteSpace = FALSE;
$dom->load($this->newsfile);
+
+ $n = $dom->documentElement;
+ $this->newspage = $n->getAttribute('newspage');
+
$params = $dom->getElementsByTagName('newsentry');
foreach ($params as $param) {
@@ -110,10 +100,10 @@ class RSS {
krsort($this->news);
}
- public function RSS($newsfile, $rssfile)
+ public function RSS($newsfile, $configfile)
{
$this->newsfile = $newsfile;
- $this->rssfile = $rssfile;
+ $this->configfile = $configfile;
$this->read();
}