<?php
// Initializations and default values.
$title = "PHP Demo Webzine";
$slogan = "Illustrating the coolness of PHP since September 2000.";
$cats = file("category.txt");
$elems = count($cats);
if (!isset($topic)) $topic="Main";
$topicfile = "$topic.txt";
if (!isset($base)) $base=0;
if (!isset($numdesc)) $numdesc= ($topic=="Main") ? 10 : 5;
if (!isset($numlist)) $numlist=40;
if (!isset($window)) $window = $base < $numdesc ? $numlist-($base*4) : $numlist;
?>
<html>
<head>
<title><?php echo($title) ?></title>
</head>
<body bgcolor=white vlink="#000080" link="#000080">
<h1><?php echo($title) ?></h1>
<p><i><?php echo($slogan) ?></i></p>
<h3>
<a href="author.php3">Submit a Story!</a>
</h3>
<table><tr><td valign=top>
<table border=1>
<?php
// Menu items on left of page.
for ($i=0; $i<$elems; $i++) {
$item = trim($cats[$i]);
$ifile = ereg_replace(" ","",$item);
$color = ($ifile == $topic) ? "pink" : "silver";
$url = "index.php3?topic=$ifile";
$anchor = " " . ($item != $topic ? "<a href=\"$url\">$item</a>" : "$item") . " ";
echo (" <tr><td bgcolor=\"$color\"><center><b>$anchor</b></center></td></tr>\n");
}
?>
</table>
</td><td><p>
<?php
if (!isset($story)) {
// No story selected, show them the list in this category.
if (file_exists($topicfile)) {
$stories = file($topicfile);
$numstories = count($stories);
} else {
$stories[0] = "0^Submit a Story^^No stories have been written in this "
. "topic yet. Click \"Submit a Story\" to learn more.";
$numstories = 1;
}
if ($numstories>($numlist+$base))
$numstories = $window+$base;
for ($i=$base; $i<$numstories; $i++) {
$storyinfo = split("\^", $stories[$i]);
$storynum = $storyinfo[0];
$storydesc = $storyinfo[1];
$storyimg = $storyinfo[2];
$dtext = $storyinfo[3];
$url = "<a href=\"index.php3?topic=$topic&story=$storynum\">$storydesc</a><br>";
if ($i<$numdesc) {
$url = "<h2>" . $url . "</h2>";
if ($storyimg != "")
$url = "<p><img align=" . ($i%2==1 ? "right" : "left")
. " src=\"$storyimg\"></p>\n"
. $url;
$url = "<hr>" . $url;
} else {
$url = "<h3>" . $url . "</h3>";
}
echo("$url\n");
echo("<p>$dtext</p>\n<p>");
}
} else {
// Story selected, show them the story.
$storyfile = fopen("s$story.txt","r");
fpassthru($storyfile);
//echo ("</p>");
}
?>
</p></td></tr></table>
</body>
</html>
|