aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--blog.php360
-rw-r--r--config.php67
2 files changed, 238 insertions, 189 deletions
diff --git a/blog.php b/blog.php
index 23c22fb..367773b 100644
--- a/blog.php
+++ b/blog.php
@@ -1,40 +1,44 @@
<?php
-// blogRight! version 2.1 (2006-03-24)
-// Copyright (C) 2004, 2005, 2006 Wojciech Polak.
+// blogRight! version 2.2 (2008-03-16)
+// Copyright (C) 2004, 2005, 2006, 2007, 2008 Wojciech Polak.
//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2, or (at your option)
-// any later version.
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU 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 General Public License for more details.
//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation,
-// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+// You should have received a copy of the GNU General Public License along
+// with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if (!ereg ("^apache2", @php_sapi_name ()))
+ ob_start ('ob_gzhandler');
require 'config.php';
-if (!isset ($header_file))
- $header_file = 'inc/header.html';
+if (!isset ($CONF)) exit;
+
+if (!isset ($CONF['path.header_file']))
+ $CONF['path.header_file'] = 'inc/header.html';
-if (!isset ($footer_file))
- $footer_file = 'inc/footer.html';
+if (!isset ($CONF['path.footer_file']))
+ $CONF['path.footer_file'] = 'inc/footer.html';
-if (!isset ($charsetEncoding))
- $charsetEncoding = 'UTF-8';
+if (!isset ($CONF['charsetEncoding']))
+ $CONF['charsetEncoding'] = 'UTF-8';
/////////////////////////////
$start_time = microtime ();
-if (isset ($_REQUEST['q']))
+if (isset ($_GET['q']))
{
- $q = $_REQUEST['q'];
+ $q = $_GET['q'];
$result = array ();
ereg ('([0-9]{4})?[-/]?([0-1][0-9])?[-/]?([0-3][0-9])?', $q, $result);
@@ -51,25 +55,26 @@ if (isset ($_REQUEST['q']))
else
{
if (eregi ('^all$', $q))
- unset ($recent);
+ unset ($CONF['recent']);
}
}
/////////////////////////////
-if (isset ($datadir) && $datadir != '')
+if (isset ($CONF['path.data']) && $CONF['path.data'] != '')
{
- $cwd = $datadir;
+ $cwd = $CONF['path.data'];
}
else
{
- $datadir = '';
+ $CONF['path.data'] = '';
$cwd = getcwd ();
}
-if (file_exists ($datadir.$orderfile))
+if (isset ($CONF['orderfile']) &&
+ file_exists ($CONF['path.data'].$CONF['orderfile']))
{
- $lines = file ($datadir.$orderfile);
+ $lines = file ($CONF['path.data'].$CONF['orderfile']);
foreach ($lines as $line)
$searchdirs[] = chop ($line);
$searchdirs = array_unique ($searchdirs);
@@ -91,7 +96,8 @@ else // scan the directory
closedir ($dp);
sort ($searchdirs);
- if ($sortorder == 'desc')
+ if (isset ($CONF['sortorder']) &&
+ $CONF['sortorder'] == 'desc')
$searchdirs = array_reverse ($searchdirs);
}
@@ -101,15 +107,15 @@ $include_files = array ();
foreach ($searchdirs as $dir)
{
- $path = $datadir.$dir;
+ $path = $CONF['path.data'].$dir;
$dirlist = array ();
// ignore hidden files/dirs.
if ($dir[0] != '.' && $dir[0] != '' && is_dir ($path))
{
- if (file_exists ($path.'/'.$orderfile))
+ if (file_exists ($path.'/'.$CONF['orderfile']))
{
- $lines = file ($path.'/'.$orderfile);
+ $lines = file ($path.'/'.$CONF['orderfile']);
foreach ($lines as $line)
$dirlist[] = $path.'/'.chop ($line);
}
@@ -130,14 +136,14 @@ foreach ($searchdirs as $dir)
}
closedir ($dp);
- if ($sortby == 'timestamp')
+ if ($CONF['sortby'] == 'timestamp')
ksort ($dirlist);
else // sort by name
sort ($dirlist);
}
}
- if ($sortorder == 'desc' && !isset ($search_y))
+ if ($CONF['sortorder'] == 'desc' && !isset ($search_y))
$dirlist = array_reverse ($dirlist);
$include_files = array_merge ($include_files, $dirlist);
@@ -151,26 +157,32 @@ $cur_m = date ('m');
function cmonth ($var)
{
- global $cur_y, $cur_m, $suffix;
- if (ereg ("$cur_y/$cur_m-.*$suffix\$", $var))
+ global $cur_y, $cur_m;
+ if (ereg ("$cur_y/$cur_m-.*\.html\$", $var))
return true;
else
return false;
}
-if (isset ($ATOM) || isset ($_REQUEST['atom']) ||
- isset ($RSS) || isset ($_REQUEST['rss'])) {
- $recent = $feedRecent;
+if (isset ($_GET['format'])) {
+ if ($_GET['format'] == 'atom')
+ $ATOM = true;
+ else if ($_GET['format'] == 'rss')
+ $RSS = true;
+}
+
+if (isset ($ATOM) || isset ($RSS)) {
+ $CONF['recent'] = $CONF['feed.recent'];
}
// show only N recent entries or current month
-if (!isset ($search_y) && isset ($recent))
+if (!isset ($search_y) && isset ($CONF['recent']))
{
- if (is_numeric ($recent))
+ if (is_numeric ($CONF['recent']))
{
- $include_files = array_slice ($include_files, 0, $recent);
+ $include_files = array_slice ($include_files, 0, $CONF['recent']);
}
- else if ($recent == 'month')
+ else if ($CONF['recent'] == 'month')
{
$month_files = array_filter ($include_files, 'cmonth');
@@ -181,7 +193,7 @@ if (!isset ($search_y) && isset ($recent))
{
$cur_m = 12;
$cur_y -= 1;
- if ($cur_y < 1983) // set your minimal value ;)
+ if ($cur_y < 1983)
break; // fatal error; anti-loop protection
}
$month_files = array_filter ($include_files, 'cmonth');
@@ -197,9 +209,9 @@ if (!isset ($search_y) && isset ($recent))
$year_array = array (); // Array of years for copyright purposes
-if (isset ($RSS) || isset ($_REQUEST['rss']))
+if (isset ($RSS))
{
- $pubDate = date ("D, d M Y H:i:s O", filemtime ($include_files[0]));
+ $pubDate = gmdate ("D, d M Y H:i:s O", filemtime ($include_files[0]));
$lastModified = gmdate ("D, d M Y H:i:s T", filemtime ($include_files[0]));
$ETag = '"'.md5 ($lastModified).'"';
@@ -214,28 +226,26 @@ if (isset ($RSS) || isset ($_REQUEST['rss']))
exit ();
}
}
- header ("Content-Type: text/xml; charset=$charsetEncoding");
+ header ("Content-Type: text/xml; charset=".$CONF['charsetEncoding']);
header ("Last-Modified: $lastModified");
header ("ETag: $ETag");
- echo '<?xml version="1.0" encoding="'.$charsetEncoding.'"?>'."\n";
- if ($feedStylesheet)
- echo "<?xml-stylesheet href=\"$site/$weblogdir/css/rss.css\" type=\"text/css\"?>\n";
+ echo '<?xml version="1.0" encoding="'.$CONF['charsetEncoding'].'"?>'."\n";
echo '<rss version="2.0">'."\n";
echo " <channel>\n";
- echo " <title>$feedTitle</title>\n";
- echo " <description>$feedDescription</description>\n";
- echo " <link>$site/$weblogdir/</link>\n";
- echo " <copyright>$feedCopyright</copyright>\n";
- echo " <language>$feedLanguage</language>\n";
+ echo " <title>".$CONF['feed.title']."</title>\n";
+ echo " <description>".$CONF['feed.description']."</description>\n";
+ echo " <link>".$CONF['url.site']."/</link>\n";
+ echo " <copyright>".$CONF['feed.copyright']."</copyright>\n";
+ echo " <language>".$CONF['feed.language']."</language>\n";
echo " <pubDate>$pubDate</pubDate>\n";
echo " <docs>http://blogs.law.harvard.edu/tech/rss</docs>\n";
echo " <generator>blogRight!</generator>\n";
- echo " <managingEditor>$feedEditor</managingEditor>\n";
+ echo " <managingEditor>".$CONF['feed.editor']."</managingEditor>\n";
foreach ($include_files as $inc)
{
- if (ereg (".*$suffix\$", basename ($inc)))
+ if (ereg (".*\.html\$", basename ($inc)))
{
$cdd = basename (dirname ($inc)); // current data dir
if (is_numeric ($cdd))
@@ -257,24 +267,27 @@ if (isset ($RSS) || isset ($_REQUEST['rss']))
$pubDate = date ("D, d M Y H:i:s O", $fmtime);
$itemTitle = date ('d M Y', $fmtime);
- $permaLink = date ('Ymd', $fmtime);
+ $permaLink = date ($CONF['permalinkFmt'], $fmtime);
echo " <item>\n";
echo " <title>$itemTitle</title>\n";
- echo " <link>$site/$weblogdir/?q=$permaLink</link>\n";
+ echo " <link>".$CONF['url.site']."/".
+ $CONF['qpattern'].$permaLink."</link>\n";
- if ($feedCDATA) {
+ if ($CONF['feed.CDATA']) {
echo " <description><![CDATA[\n";
- indent_include (9, $inc, $feedCDATA);
+ indent_include (9, $inc, $CONF['feed.CDATA']);
echo " ]]></description>\n";
}
else {
echo " <description>\n";
- indent_include (9, $inc, $feedCDATA);
+ indent_include (9, $inc, $CONF['feed.CDATA']);
echo " </description>\n";
}
- echo " <guid isPermaLink=\"true\">$site/$weblogdir/?q=$permaLink</guid>\n";
+ echo " <guid isPermaLink=\"true\">".
+ $CONF['url.site']."/".$CONF['qpattern'].
+ $permaLink."</guid>\n";
echo " <pubDate>$pubDate</pubDate>\n";
echo " </item>\n";
}
@@ -283,10 +296,10 @@ if (isset ($RSS) || isset ($_REQUEST['rss']))
echo " </channel>\n";
echo "</rss>\n";
}
-else if (isset ($ATOM) || isset ($_REQUEST['atom'])) {
-
- $pubDate = date ('Y-m-d\TH:i:s\Z', filemtime ($include_files[0]));
- $lastModified = date ('Y-m-d\TH:i:s\Z', filemtime ($include_files[0]));
+else if (isset ($ATOM))
+{
+ $pubDate = gmdate ('Y-m-d\TH:i:s\Z', filemtime ($include_files[0]));
+ $lastModified = gmdate ("D, d M Y H:i:s T", filemtime ($include_files[0]));
$ETag = '"'.md5 ($lastModified).'"';
$headers = getallheaders ();
@@ -300,32 +313,31 @@ else if (isset ($ATOM) || isset ($_REQUEST['atom'])) {
exit ();
}
}
- header ("Content-Type: text/xml; charset=$charsetEncoding");
+ header ("Content-Type: text/xml; charset=".$CONF['charsetEncoding']);
header ("Last-Modified: $lastModified");
header ("ETag: $ETag");
- $tagUri = "tag:$feedAuthorEmail,2004:blog";
-
- echo '<?xml version="1.0" encoding="'.$charsetEncoding.'"?>'."\n";
- if ($feedStylesheet)
- echo "<?xml-stylesheet href=\"$site/$weblogdir/css/atom.css\" type=\"text/css\"?>\n";
- echo '<feed xmlns="http://www.w3.org/2005/Atom">'."\n";
- echo " <title>$feedTitle</title>\n";
- echo " <subtitle>$feedDescription</subtitle>\n";
+ echo '<?xml version="1.0" encoding="'.$CONF['charsetEncoding'].'"?>'."\n";
+ echo '<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="'.
+ $CONF['feed.language'].'">'."\n";
+ echo " <title>".$CONF['feed.title']."</title>\n";
+ echo " <subtitle>".$CONF['feed.description']."</subtitle>\n";
echo " <updated>$pubDate</updated>\n";
echo " <author>\n";
- echo " <name>$feedAuthorName</name>\n";
- echo " <email>$feedAuthorEmail</email>\n";
+ echo " <name>".$CONF['feed.authorName']."</name>\n";
+ echo " <email>".$CONF['feed.authorEmail']."</email>\n";
echo " </author>\n";
- echo " <rights>$feedCopyright</rights>\n";
+ echo " <rights>".$CONF['feed.copyright']."</rights>\n";
echo " <generator>blogRight!</generator>\n";
- echo " <id>$tagUri</id>\n";
- echo " <link rel=\"self\" type=\"application/atom+xml\" href=\"$site/$weblogdir/atom/\"/>\n";
- echo " <link rel=\"alternate\" type=\"text/html\" href=\"$site/$weblogdir/\"/>\n";
+ echo " <id>".$CONF['feed.tagUri']."</id>\n";
+ echo " <link rel=\"self\" type=\"application/atom+xml\" href=\"".
+ $CONF['url.site']."/atom/\"/>\n";
+ echo " <link rel=\"alternate\" type=\"text/html\" href=\"".
+ $CONF['url.site']."/\"/>\n";
foreach ($include_files as $inc)
{
- if (ereg (".*$suffix\$", basename ($inc)))
+ if (ereg (".*\.html\$", basename ($inc)))
{
$cdd = basename (dirname ($inc)); // current data dir
if (is_numeric ($cdd))
@@ -347,29 +359,30 @@ else if (isset ($ATOM) || isset ($_REQUEST['atom'])) {
$pubDate = date ('Y-m-d\TH:i:s\Z', $fmtime);
$itemTitle = date ('d M Y', $fmtime);
- $permaLink = date ('Ymd', $fmtime);
+ $permaLink = date ($CONF['permalinkFmt'], $fmtime);
echo " <entry>\n";
- echo " <id>$tagUri/$permaLink</id>\n";
+ echo " <id>".$CONF['feed.tagUri']."/$permaLink</id>\n";
echo " <updated>$pubDate</updated>\n";
echo " <title>$itemTitle</title>\n";
- echo " <link rel=\"alternate\" type=\"text/html\" href=\"$site/$weblogdir/?q=$permaLink\"/>\n";
+ echo " <link rel=\"alternate\" type=\"text/html\" href=\"".
+ $CONF['url.site']."/".$CONF['qpattern'].$permaLink."\"/>\n";
- if ($feedXHTML) {
+ if ($CONF['feed.XHTML']) {
echo " <content type=\"xhtml\" xml:space=\"preserve\">\n";
echo " <div xmlns=\"http://www.w3.org/1999/xhtml\">\n";
- indent_include (6, $inc, $feedXHTML);
+ indent_include (6, $inc, $CONF['feed.XHTML']);
echo " </div>\n";
echo " </content>\n";
}
- else if ($feedCDATA) {
+ else if ($CONF['feed.CDATA']) {
echo " <content type=\"html\" xml:space=\"preserve\"><![CDATA[\n";
- indent_include (6, $inc, $feedCDATA);
+ indent_include (6, $inc, $CONF['feed.CDATA']);
echo " ]]></content>\n";
}
else {
echo " <content type=\"html\" xml:space=\"preserve\">\n";
- indent_include (6, $inc, $feedCDATA);
+ indent_include (6, $inc, $CONF['feed.CDATA']);
echo " </content>\n";
}
@@ -381,9 +394,20 @@ else if (isset ($ATOM) || isset ($_REQUEST['atom'])) {
}
else // HTML
{
- header ("Content-Type: text/html; charset=$charsetEncoding");
- echo '<?xml version="1.0" encoding="'.$charsetEncoding.'"?>'."\n";
- @include ($datadir.$header_file);
+ echo '<?xml version="1.0" encoding="'.$CONF['charsetEncoding'].'"?>'."\n";
+
+ $title = '';
+ if (isset ($search_y)) {
+ $title = $search_y;
+ if (isset ($search_m))
+ $title .= '-'.$search_m;
+ if (isset ($search_d))
+ $title .= '-'.$search_d;
+ }
+
+ @include ($CONF['path.header_file']);
+
+ echo "\n<div id=\"content\" class=\"hfeed\">\n\n";
foreach ($include_files as $inc)
{
@@ -392,15 +416,15 @@ else // HTML
{
if (isset ($search_d))
{
- if (ereg ("^$search_m-$search_d.*$suffix\$", basename ($inc)))
+ if (ereg ("^$search_m-$search_d.*\.html\$", basename ($inc)))
include_file ($inc);
}
else
- if (ereg ("^$search_m-.*$suffix\$", basename ($inc)))
+ if (ereg ("^$search_m-.*\.html\$", basename ($inc)))
include_file ($inc);
}
else
- if (ereg (".*$suffix\$", basename ($inc)))
+ if (ereg (".*\.html\$", basename ($inc)))
include_file ($inc);
}
@@ -417,7 +441,9 @@ else // HTML
else
$copyrightYear = date ('Y');
- @include ($datadir.$footer_file);
+ echo "</div>\n\n"; /* /hfeed */
+
+ @include ($CONF['path.footer_file']);
$duration = microtime_diff ($start_time, microtime ());
$duration = sprintf ("%0.6f", $duration);
@@ -436,20 +462,21 @@ $global_fn = 0; // Global number of the next footnote. This is unique
// Return full url of the script
function script_url ()
{
- global $site, $weblogdir;
- if (isset($_REQUEST['q']))
- return $site.'/'.$weblogdir.'?q='.$_REQUEST['q'];
- return $site.'/'.$weblogdir.'/';
+ global $CONF;
+ if ($CONF['qpattern'] != '' && isset ($_GET['q']))
+ return $CONF['url.site'].'/'.$CONF['qpattern'].$_GET['q'];
+ return $CONF['url.site'].'/';
}
// Save away the collected footnote text and replace it by an appropriate
// link.
function footnote_handler ($matches)
{
- global $site,$global_fn,$local_fn,$footnotes;
+ global $global_fn, $local_fn, $footnotes;
$footnotes[$local_fn++] = $matches[1];
$global_fn++;
- return '<a href="'.script_url().'#footnote'.$global_fn.'" name="FNRET'.$global_fn.'"><sup>'.$local_fn.')</sup></a> ';
+ return '<a href="'.script_url ().'#footnote'.$global_fn.'" name="FNRET'.
+ $global_fn.'"><sup>'.$local_fn.')</sup></a> ';
}
// Process a single input line from the file being included.
@@ -459,10 +486,8 @@ function footnote_handler ($matches)
// for the given input file.
function process_line ($line)
{
- global $site, $photodir, $imagedir, $search_d;
- global $gscript, $defaultGallery, $thumbnailPrefix;
- global $local_fn, $global_fn, $footnotes;
- global $collect;
+ global $CONF, $search_d, $local_fn, $global_fn;
+ global $footnotes, $collect;
if (isset ($collect))
{
@@ -475,8 +500,7 @@ function process_line ($line)
}
$line = preg_replace_callback ('^<footnote>(.*)</footnote>^',
- "footnote_handler",
- $line);
+ "footnote_handler", $line);
if (preg_match ('^<footnote>^', $line))
{
@@ -490,44 +514,58 @@ function process_line ($line)
if (preg_match ('/<img src="(.*?)"(.*?)>/i', $line, $res))
{
- $line = preg_replace ('/<img src="(.*?)"(.*?)>/i',
- '<img src="'.$site.'/'.$imagedir.'/$1" alt="[image]"$2 />', $line);
+ $line = str_replace ('\"', '"',
+ preg_replace ('/<img src="(.*?)"(.*?)>/ie',
+ "str_replace(array('%IMAGE','%PARAMS'),array('\\1','\\2'),'".
+ $CONF['patternURL.img']."')", $line));
}
- else if (preg_match ('/<photo album="(.*?)" src="(.*?)"(.*?)>/i', $line, $res))
+ else if (preg_match ('/<photo album="(.*?)" src="(.*?)"(.*?)>/i',
+ $line, $res))
{
if ($res[1] == 'default')
- $res[1] = $defaultGallery;
+ $res[1] = $CONF['defaultGallery'];
$prefix = dirname (trim ($res[2]));
if ($prefix[0] == '.')
- $prefix = $thumbnailPrefix[$res[1]];
+ $prefix = $CONF['thumbnailPrefix'][$res[1]];
$photo = basename (trim ($res[2]));
+ $thumbnail = $prefix . $photo;
+ $photo = str_replace ('.jpg', '', $photo);
- $line = '<p class="photo"><a href="'.$photodir.'/'.$gscript.'?q='.$res[1].'&amp;photo='.$photo.'">'
- .'<img src="'.$site.'/'.$photodir.'/'.$prefix.$photo.'" alt="[photo]"'.$res[3].' /></a></p>';
+ $line = '<p class="photo">'.
+ str_replace (array ('%ALBUM', '%PHOTO', '%THUMBNAIL', '%PARAMS'),
+ array ($res[1], $photo, $thumbnail, $res[3]),
+ $CONF['patternURL.photos']).'</p>';
}
else if (preg_match ('/<photo src="(.*?)"(.*?)>/i', $line, $res))
{
- $line = '<p class="photo"><a href="'.$photodir.'/photo.php?q='.$res[1].'"><img src="'
- .$site.'/'.$photodir.'/'
- .$thumbnailPrefix['default'].$res[1].'" alt="[photo]"'.$res[2].' /></a></p>';
+ $line = '<p class="photo">'.
+ str_replace (array ('%PHOTO', '%THUMBNAIL', '%PARAMS'),
+ array ($res[1],
+ $CONF['thumbnailPrefix']['default'].$res[1],
+ $res[2]),
+ $CONF['patternURL.photo']).'</p>';
}
- else if (preg_match ('/<gallery album="(.*?)" img="(.*?)"(.*?)>/i', $line, $res))
+ else if (preg_match ('/<gallery album="(.*?)" img="(.*?)"(.*?)>/i',
+ $line, $res))
{
$pdir = dirname (trim ($res[2]));
if ($pdir[0] == '.')
$pdir = '';
$pbase = basename (trim ($res[2]));
-
- $line = '<p class="gallery"><a href="'.$photodir.'/'.$gscript.'?q='.$res[1].'">'
- .'<img src="'.$site.'/'.$photodir;
- if ($pdir)
- $line .= '/'.$pdir;
- $line .= '/'.$thumbnailPrefix['default'].$pbase.'" alt="[gallery]"'
- .$res[3]." /><br />&raquo;</a></p>\n";
+ $thumbnail = '';
+ if ($pdir) $thumbnail .= $pdir.'/';
+ $thumbnail .= $CONF['thumbnailPrefix']['default'].$pbase;
+
+ $line = '<p class="gallery">'.
+ str_replace (array ('%ALBUM', '%THUMBNAIL', '%PARAMS'),
+ array ($res[1], $thumbnail, $res[3]),
+ $CONF['patternURL.gallery'])."</p>\n";
}
-
- $line = preg_replace ('/<a href="(.*?)">/i', '<a href="'.$site.'/$1">', $line);
+ $line = str_replace ('\"', '"',
+ preg_replace ('/<a href="(.*?)">/ie',
+ "str_replace(array('%URI'),array('\\1'),'".
+ $CONF['patternURL.link']."')", $line));
}
return $line;
}
@@ -548,7 +586,8 @@ function process_footnotes ($out, $data)
for ($i = 0; $i < $local_fn; $i++)
{
$n = $global_fn-$local_fn+$i+1;
- $out ($data, '<p><a href="'.script_url().'#FNRET'.$n.'" name="footnote'.$n.'"><sup>'.($i+1).')</sup></a> ');
+ $out ($data, '<p><a href="'.script_url().'#FNRET'.
+ $n.'" name="footnote'.$n.'"><sup>'.($i+1).')</sup></a> ');
$out ($data, $footnotes[$i]);
$out ($data, '</p>');
}
@@ -567,9 +606,7 @@ function printer ($data, $string)
// HTML output
function include_file ($file)
{
- global $site, $photodir, $imagedir, $search_d;
- global $local_fn;
- global $year_array;
+ global $CONF, $search_d, $local_fn, $year_array;
$res = array ();
$cdd = basename (dirname ($file)); // current data dir
@@ -588,24 +625,27 @@ function include_file ($file)
}
$entryDate = mktime (0, 0, 0, $month, $day, $year);
- $permaLink = date ('Ymd', $entryDate);
+ $permaLink = date ($CONF['permalinkFmt'], $entryDate);
+ $pubDate = date ('Y-m-d\TH:i:s\Z', $entryDate);
$entryDate = date ('d M Y', $entryDate);
}
else
{
- $permaLink = date ('Ymd', filemtime ($file));
- $entryDate = date ('d M Y', filemtime ($file));
+ $mt = filemtime ($file);
+ $permaLink = date ($CONF['permalinkFmt'], $mt);
+ $pubDate = gmdate ('Y-m-d\TH:i:s\Z', $mt);
+ $entryDate = date ('d M Y', $mt);
}
$fd = file ($file);
if ($fd)
{
- echo '<div id="e'.$permaLink.'" class="entry">'."\n";
- echo '<div class="entryTitle">';
- echo '<a href="?q='.$permaLink
+ echo '<div id="e'.str_replace ( '/','',$permaLink).'" class="hentry">'."\n";
+ echo '<div class="entry-title">';
+ echo '<a href="./'.$CONF['qpattern'].$permaLink
.'" rel="bookmark" title="'.$entryDate.'">'.$entryDate.'</a>';
echo '</div>'."\n";
- echo '<div class="entryBody">'."\n";
+ echo '<div class="entry-content">'."\n";
unset ($GLOBALS['collect']);
foreach ($fd as $line)
@@ -617,9 +657,13 @@ function include_file ($file)
process_footnotes ('printer', 0);
echo '</div>'."\n";
- echo '<div class="entryFooter">'."\n";
- echo '<a href="?q='.$permaLink.'" rel="bookmark" title="'.$entryDate.
- '" class="permalink">'.$entryDate.'</a>'."\n";
+ echo '<div class="entry-footer">'."\n";
+ echo '<a href="./'.$CONF['qpattern'].
+ $permaLink.'" rel="bookmark" title="'.$entryDate.
+ '"><abbr class="published" title="'.
+ $pubDate.'">'.$entryDate.'</abbr></a>'."\n";
+ echo '<address class="vcard"><span class="fn">'.
+ $CONF['feed.authorName'].'</span></address>';
echo '</div>'."\n";
echo '</div>'."\n\n";
}
@@ -635,15 +679,15 @@ function printer_html ($level, $string)
// Atom/RSS 2.0 output
function indent_include ($level, $file, $unescaped)
{
- global $site, $imagedir, $photodir, $weblogdir, $local_fn;
+ global $local_fn;
$local_fn = 0;
$cdd = basename (dirname ($file)); // current data dir
$fd = file ($file);
if ($fd)
{
+ unset ($GLOBALS['collect']);
foreach ($fd as $line)
{
- unset ($GLOBALS['collect']);
$line = process_line ($line);
if ($line)
{
@@ -662,16 +706,15 @@ function indent_include ($level, $file, $unescaped)
function printCalendar ()
{
- global $calendarEmptyMonths, $calendarVertical;
- global $cwd, $cur_y, $cur_m;
+ global $CONF, $cwd, $cur_y, $cur_m;
echo "<!-- BEGIN CALENDAR -->\n\n";
- if (!isset ($calendarEmptyMonths))
- $calendarEmptyMonths = true;
+ if (!isset ($CONF['calendar.emptyMonths']))
+ $CONF['calendar.emptyMonths'] = true;
- if (!isset ($calendarVertical))
- $calendarVertical = false;
+ if (!isset ($CONF['calendar.vertical']))
+ $CONF['calendar.vertical'] = false;
$searchdirs = array ();
if (!($dp = opendir ($cwd)))
@@ -685,7 +728,7 @@ function printCalendar ()
sort ($searchdirs);
echo "<div id=\"calendar\">\n";
- echo "<table class=\"calendarTable\"><tr>\n";
+ echo "<table class=\"calendar-table\"><tr>\n";
foreach ($searchdirs as $dir)
{
@@ -695,13 +738,14 @@ function printCalendar ()
$dir = basename ($dir);
echo "\n <!-- $dir -->\n";
- echo " <td><div class=\"calendarYear\"><a href=\"?q=$dir\">$dir</a></div>\n";
- echo " <table class=\"calendarMonths\">\n\n";
+ echo " <td><div class=\"calendar-year\"><a href=\"./".
+ $CONF['qpattern'].$dir."/\">$dir</a></div>\n";
+ echo " <table class=\"calendar-months\">\n\n";
$mtab = array ();
while ($name = readdir ($dp))
{
- if (ereg ("^(.*)-(.*)$suffix\$", $name, $res))
+ if (ereg ("^(.*)-(.*)\.html\$", $name, $res))
{
if (!($dir >= $cur_y && $res[1] > $cur_m))
$mtab[0 + $res[1]]++;
@@ -717,13 +761,15 @@ function printCalendar ()
echo " <td>";
if ($mtab[$month])
{
- printf (" <a href=\"?q=%4d%02d\">", $dir, $month);
+ printf (" <a href=\"./".
+ $CONF['qpattern']."%4d/%02d/\">",
+ $dir, $month);
echo strftime ("%b", strtotime ("$dir-$month-1"));
echo "</a> ";
}
else
{
- if ($calendarEmptyMonths)
+ if ($CONF['calendar.emptyMonths'])
echo strftime ("%b", strtotime ("$dir-$month-1"));
else
echo ' &nbsp; ';
@@ -735,7 +781,7 @@ function printCalendar ()
echo " </table></td>\n";
- if ($calendarVertical)
+ if ($CONF['calendar.vertical'])
echo " </tr><tr>\n";
}
@@ -749,9 +795,11 @@ function htmlentities2 ($htmlcode) {
static $entitiesDecoded;
static $utf8Entities;
if (!isset ($htmlEntities))
- $htmlEntities = array_values (get_html_translation_table (HTML_ENTITIES, ENT_QUOTES));
+ $htmlEntities = array_values (get_html_translation_table (HTML_ENTITIES,
+ ENT_QUOTES));
if (!isset ($entitiesDecoded))
- $entitiesDecoded = array_keys (get_html_translation_table (HTML_ENTITIES, ENT_QUOTES));
+ $entitiesDecoded = array_keys (get_html_translation_table (HTML_ENTITIES,
+ ENT_QUOTES));
if (!isset ($utf8Entities)) {
$num = count ($entitiesDecoded);
for ($u = 0; $u < $num; $u++)
diff --git a/config.php b/config.php
index 5b25ec7..7d18740 100644
--- a/config.php
+++ b/config.php
@@ -1,46 +1,47 @@
<?php
-// blogRight! version 2.1
+// blogRight! version 2.2
// BEGIN CONFIG
-$site = 'http://your.site.name';
-$weblogdir = 'blogright';
-$imagedir = 'blogright/graphics';
-$photodir = 'blogright/photos';
-
-$charsetEncoding = 'UTF-8';
-
-$suffix = '.html'; // entries' file extension
-$recent = 'month'; // number of entries shown by default
-$sortby = 'name'; // sort by: 'name', 'timestamp'
-$sortorder = 'desc'; // sorting order: 'asc', 'desc'
-$orderfile = '.order'; // [optional] order file name
-
-$header_file = 'templates/header.html';
-$footer_file = 'templates/footer.html';
+$CONF['url.site'] = 'http://your.site.name/blog';
+$CONF['path.data'] = '/filesystem/path/blog/data/';
+$CONF['path.header_file'] = 'templates/header.html';
+$CONF['path.footer_file'] = 'templates/footer.html';
+$CONF['charsetEncoding'] = 'UTF-8';
+$CONF['recent'] = 'month'; // number of entries shown by default
+$CONF['sortby'] = 'name'; // sort by: 'name', 'timestamp'
+$CONF['sortorder'] = 'desc'; // sorting order: 'asc', 'desc'
+$CONF['orderfile'] = '.order'; // an optional order file name
+$CONF['permalinkFmt'] = 'Y/m/d';
+$CONF['qpattern'] = ''; // empty for PrettyURI, otherwise '?q='
// Webxiangpianbu
-$gscript = ''; // empty means index.(html|php)
-$defaultGallery = 'photoblog';
-$thumbnailPrefix['default'] = 'small/small-';
-$thumbnailPrefix['photoblog'] = 'photoblog/small/small-';
+$CONF['defaultGallery'] = 'photoblog';
+$CONF['thumbnailPrefix'] = array ('default' => 'small/small-',
+ 'photoblog' => 'photoblog/small/small-');
+
+$CONF['patternURL.img'] = '<img src="http://your.site.name/images/%IMAGE" alt="[image]"%PARAMS />';
+$CONF['patternURL.link'] = '<a href="http://your.site.name/%URI">';
+$CONF['patternURL.photo'] = '<a href="photos/%PHOTO"><img src="http://your.site.name/photos/data/%THUMBNAIL" alt="[photo]"%PARAMS /></a>';
+$CONF['patternURL.photos'] = '<a href="photos/%ALBUM/%PHOTO"><img src="http://your.site.name/photos/data/%THUMBNAIL" alt="[photo]"%PARAMS /></a>';
+$CONF['patternURL.gallery'] = '<a href="photos/%ALBUM/"><img src="http://your.site.name/photos/data/%THUMBNAIL" alt="[gallery]"%PARAMS /><br />&#187;</a>';
// RSS/Atom
-$feedStylesheet = true; // $site/$weblogdir/css/(atom|rss).css
-$feedTitle = 'title';
-$feedDescription = "description";
-$feedCopyright = 'Copyright (C) Your Name';
-$feedAuthorName = 'Your Name';
-$feedAuthorEmail = 'Your e-mail address';
-$feedEditor = "$feedAuthorEmail ($feedAuthorName)";
-$feedLanguage = 'en'; // Two-letter language code as per ISO 639
-$feedRecent = '10';
-$feedXHTML = true;
-$feedCDATA = true;
+$CONF['feed.title'] = 'title';
+$CONF['feed.description'] = "description";
+$CONF['feed.copyright'] = 'Copyright (C) Your Name';
+$CONF['feed.authorName'] = 'Your Name';
+$CONF['feed.authorEmail'] = 'Your e-mail address';
+$CONF['feed.editor'] = "Your e-mail address (Your Name)";
+$CONF['feed.tagUri'] = 'tag:EMAIL,YEAR:NAME';
+$CONF['feed.language'] = 'en'; // Two-letter language code as per ISO 639
+$CONF['feed.recent'] = '10';
+$CONF['feed.XHTML'] = true;
+$CONF['feed.CDATA'] = true;
// Calendar
-$calendarEmptyMonths = false;
-$calendarVertical = false;
+$CONF['calendar.emptyMonths'] = false;
+$CONF['calendar.vertical'] = false;
// END CONFIG

Return to:

Send suggestions and report system problems to the System administrator.