minimalist-dong/index.php3

184 lines
5.1 KiB
PHP

<?php
require "minclude/config.inc";
require "minclude/misc.inc";
// If $page is undefined, will use the 'default' entry from config
get_config($page);
// This sets the directory that all the content and include files are
// stored under - usually just changing $blogdir will be enough, but
// the others can be forced to specific values if you need finer control.
//$blogdir="blog";
$articledir="$config[NAME]/content";
$imagedir="$config[NAME]/images";
$sidebardir="$config[NAME]/sidebar";
// If we need to refer back to this page and pass parameters, we need to
// know if the URL itself has any parameters (like "page=xxxx") so we can
// add new ones without disturbing anything.
// I'm assuming there's only one possible reason for a "?" to appear in a
// URL. I think I'm right, but must check the specs one day ...
if (preg_match("/\?/",$config[URL])) {
$switchchar="&";
}
else {
$switchchar="?";
}
// Includes
// Some of these can be removed in some cases, but they shouldn't do any
// harm even if you're not using the features.
// Stuff to handle RDF headline imports
require "minclude/rss-import.inc";
// Code for RDF exports
require "minclude/rss-export.inc";
// This handles any special display modes - only XML right now, but a
// handler for table-free or low/high graphic usage could go here.
switch ($mode) {
case rdf:
case rss:
rssexport();
exit();
default:
break;
}
// The start of the actual HTML is just after this ...
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE><?php print $config[SITETITLE]; ?></TITLE>
<link rel="stylesheet" href="dong.css" type="text/css">
</HEAD>
<BODY>
<h1><?php print "<a href=\"$config[URL]\">$config[SITETITLE]</a>"; ?></h1>
<p class="tagline"><?php print "$config[DESCRIPTION]"; ?></p>
<!-- Main body table start -->
<TABLE class="layout">
<TR> <!-- Row 1 Start -->
<TD class="blog"> <!-- Main body cell -->
<?php
if (!$offset) {
$offset=0;
}
$size=sizeof($articlelist=get_articlelist($offset, $config[ARTICLELIMIT]));
$nextoffset=$offset+$config[ARTICLELIMIT];
$prevoffset=$offset-$config[ARTICLELIMIT];
$nexturl = append_to_url($config[URL],"offset=$nextoffset");
$prevurl = append_to_url($config[URL],"offset=$prevoffset");
$navbar="<p class=\"navbar\">";
if ($prevoffset >= 0) {
$navbar = $navbar." <a href=\"$prevurl\">Next $config[ARTICLELIMIT] Items</a> \n";
}
if ($totalarticles > $nextoffset) {
$navbar = $navbar." <a href=\"$nexturl\">Previous $config[ARTICLELIMIT] Items</a> \n";
}
print "$navbar";
?>
<table class="blog"> <!-- Open the table for the main blog entries -->
<?php
// Main content loop starts here
for ($index=0;$index<$size;$index++) {
$workfile="$articledir/$articlelist[$index]";
$articlefile=fopen ($workfile, "r");
$articlestamp=date("g:i a, l, d F Y", filectime($workfile));
$permalink=$config[URL].$switchchar."showentry=".$articlelist[$index];
$oneline = fgets($articlefile, 300);
print"<tr>\n<td class=\"entryhead\"><h3>$oneline</h3>";
print"<p class=\"entrydate\">$articlestamp</p>\n";
print"<p class=\"permalink\">
<a href=\"$permalink\" title=\"permalink URL\">&para;</a>
</p>\n</td>";
print"<td class=\"entrytext\">";
while (!feof ($articlefile)) {
$oneline = fgets($articlefile, 300);
if ($oneline == "\n") {
$oneline="<p>";
}
elseif (preg_match("|^%%|", $oneline)) {
$oneline = preg_replace("|%%(.*)%%|U", "<img
src=\"$imagedir/\\1\">", $oneline);
}
else {
$oneline = preg_replace("|##(.*)#(.*)##|U", "<a href=\"\\2\">\\1</a>", $oneline);
}
print"$oneline\n";
}
fclose ($articlefile);
print "</td></tr>\n";
} // Main content loop ends
?>
</table> <!-- Close the table for the main blog entries -->
<?php print "$navbar"; ?>
</TD> <!-- End Main body cell -->
<TD class="sidebar"> <!-- Sidebar cell -->
<?php
if(sizeof($public)) {
print"<p class=\"menuhead\">Section Index</p>\n";
while (list($key, $value) = each($public)) {
grab_headlines($value);
}
}
if($rdffile=@fopen ("$sidebardir/rdfsources", "r")) {
print"<p class=\"menuhead\">Other Pages</p>";
while (!feof ($rdffile)) {
$rdfurl = chop(fgets($rdffile, 100));
if ($rdfurl == "") {
break;
}
grab_headlines($rdfurl);
}
fclose ($rdffile);
}
?>
<?php
// Here's where the sidebar links are processed
if($linkfile=@fopen ("$sidebardir/links", "r")) {
print "<p class=\"menuhead\">Links</p>";
while (!feof ($linkfile)) {
$linkname = chop(fgets($linkfile, 100));
if ($linkname == "") {
break;
}
$linkurl = chop(fgets($linkfile, 100));
print"<p class=\"menuoption\"><A HREF=\"$linkurl\">$linkname</A></p>\n";
}
fclose ($linkfile);
}
?>
</TD> <!-- End Sidebar cell -->
</TR> <!-- Row 1 Ends -->
</TABLE> <!-- Main Body table ends -->
<p>This <a href="http://www.grouse.net.au/~mike/index.php3?page=minimalist">
Minimalist Dong</a> weblog is run by
<?php print "<a href=\"$config[EMAIL]\">$config[EMAIL]</a>"; ?>
</BODY>
</HTML>