// index.php -- main PHP file for aprendizdetodo.com
// including topic subdirectories (art, austin, books, etc.)
//
// Sample invocations:
// http://aprendizdetodo.com
// http://aprendizdetodo.com?pagenum=2
// http://aprendizdetodo.com/art
// http://aprendizdetodo.com/art?pagenum=2
// http://aprendizdetodo.com/art?item=20030730
// http://aprendizdetodo.com?index=date
// http://aprendizdetodo.com?index=title
//
// History:
// 2003.08.14 Rewrite to merge top- and sub-level index.php files
// and to use CSS.
// 2004.02.10 Added META robots tags to send spiders to individual
// posts, not index pages.
//-----------------------------------------------------------------------
// INITIALIZATION
$cats = array( 'art', 'austin', 'books', 'causes', 'chuckles', 'garden',
'kids', 'language', 'movies', 'music', 'time', 'toys', 'travel' );
$catpat = '(' . join($cats,'|') . ')';
$catadj = array(
// We use these to override the category name in "___ links"
// e.g., "Movie links" not "Movies links"
"books" => "Reading",
"causes" => "Peacenik greenie liberal",
"chuckles" => "Knee-slappin'",
"garden" => "Gardening",
"kids" => "Kiddie",
"movies" => "Movie",
"time" => "Entropy",
);
$cattags = array(
// These go in a TopMenu at the beginning of Content
"" => "Weekly rat especial", // Default
"art" => "I don't know what I like but I know about art",
"austin" => "Keep Austin Blogging",
"books" => "Inside of a dog it's too dark to read",
"causes" => "Just 'cause",
"chuckles" => "Heh",
"garden" => "The best thing to see in a garden is your shadow",
"kids" => "Darling daughters, whirly girlies, maari dikri, mis escuincles",
"language" => "Language: a dialect with an army",
"movies" => "The smell of the crowd",
"music" => "It don't mean a thing",
"time" => "You're older than you ever were and now you're even older",
"toys" => "Things to want and buy",
"travel" => "Itchy gringo",
);
// DETERMINE CONTEXT:
// Are we at in a particular category (AKA view) or at the top level?
$uri = getenv('REQUEST_URI');
if (preg_match("/^\/($catpat)/", $uri, $match)) {
// We're in a category
$category = $match[1];
$uccat = ucfirst($category);
// Don't know why, but when HostingMatters turned on PHPsuexec,
// URL arguments like $item became undefined. :-( Fix that.
if ( ! defined ("item") ) {
$item = $_REQUEST["item"];
}
// For consistency, operate in the root directory regardless
chdir('..');
}
if ( ! defined ("pagenum") ) {
$pagenum = $_REQUEST["pagenum"];
}
// More initialization (this required us to chdir to root if nec'y)
require "blogstuff.php";
// If this is an individual entry, snarf it in its entirety and
// extract item title (e.g., "Hello Kitty guitar" or "Uma on boys").
if ($category && $item) {
$itemerr = '';
$itemtitle = "";
if (file_exists("$category/$item.ssi")) {
if ($fh = fopen("$category/$item.ssi", 'r')) {
$itembody = join(file("$category/$item.ssi"), "");
if ($itembody) {
// We key on '
' or or
preg_match('/<(h2 class=\"blogtitle\"|strong|b)>([^<]*)<\/(h2|strong|b)>/i',
$itembody, $matches);
$itemtitle = $matches[2];
if (! $itemtitle) { $itemerr = "No title."; }
fclose($fh);
} else {
$itemerr = "Couldn't read: $php_errormsg";
}
} else {
$itemerr = "Couldn't open: $php_errormsg";
}
} else {
$itemerr = "File not found.";
}
}
// Compose title for header.
if ($itemtitle) {
$title = "Prentiss Riddle: $uccat: $itemtitle";
} elseif ($index == "date") {
$title = "Prentiss Riddle: aprendiz de todo: archive by date";
} elseif ($index == "title") {
$title = "Prentiss Riddle: aprendiz de todo: archive by title";
} else {
if ($category) {
$title = "Prentiss Riddle: $uccat";
} else {
$title = "Prentiss Riddle: aprendiz de todo, maestro de nada";
}
if ($pagenum > 1) {
$title = $title . ": page $pagenum";
}
}
// Compose text and tagline for banner.
if ($category) {
$bannertext = "Prentiss Riddle: $uccat";
$tagline = "aprendiz de todo, maestro de nada";
} else {
$bannertext = "aprendiz de todo, maestro de nada";
$tagline = "You are in a maze of twisty little weblogs all alike.";
}
// Hallelujah -- finally we can start pumping HTML...
?>
echo $title; ?>
// STYLESHEETS
// We have two stylesheets here, one for ordinary use and one for old
// legacy browsers like Netscape 4. This trick comes from Jeffrey Zeldman's
// "Designing With Web Standards" (2003), pp. 230-231.
?>
// DON'T TURN THESE ON YET!
//
?>
// Meta robots tags:
// Keep Google from sending everybody to index pages -- except top index page
// See:
// http://www.scribbling.net/entry/394/
// http://www.scribbling.net/nine_things_you_can_do_to_make_your_web_site_better
if (! $item && ($category || $index == "title" || $index == "date")) {
echo "\n";
} else {
echo "\n";
}
?>
// TODO: meta tags
if ($category=="art" && $item=="20030120") {
echo "\n";
echo "\n";
}
?>
# DEBUG
print " \n";
if ($index == "title") {
# Archives are generated statically -- just include them
include "titles.ssi";
} elseif ($index == "date") {
# Archives are generated statically -- just include them
include "dates.ssi";
} elseif ($item) {
if (empty($itemerr)) {
echo "
\n";
// Try to match newsid. Examples:
// $newsid = '';
// $newsid = '43RL8.75290$4i.7961081@bin2.nnrp.aus1.giganews.com';
preg_match('/\$newsid\s*=\s*[\'"](.*?)[\'"]\s*;/',
$itembody, $matches);
if ($newsid = $matches[1]) { newslink($matches[1]); }
echo "
\n";
$commentID = "$category$item";
include "comments.php";
} else {
echo "Sorry, couldn't show you $category/$item. $itemerr\n";
}
} else {
# When $category is null, this defaults to top-page view
showitems($category, $pagenum, $perpage);
}
?>
divbox(); ?>
Latest comments
include "lastdisc.ssi" ?>
if ($category) {
# sidebar content for category page
if (file_exists("$category/sidebar-top.php")) {
include "$category/sidebar-top.php";
}
if (file_exists("$category/links.ssi")) {
divbox();
print "
";
if ($catadj[$category]) {
# Override the name of the category with a better
# adjective (e.g., "Reading links" not "Books links")
print "$catadj[$category] links";
} else {
print "$uccat links";
}
print "
\n";
include "$category/links.ssi";
print " \n";
}
if (file_exists("$category/sidebar-bottom.php")) {
include "$category/sidebar-bottom.php";
}
} else {
# sidebar content for main page
divbox();
?>