diff options
-rw-r--r-- | blog.php | 69 |
1 files changed, 50 insertions, 19 deletions
@@ -1,10 +1,10 @@ | |||
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | // blogRight! version 2.2 (2008-03-16) | 3 | // blogRight! version 2.5 (2010-04-19) |
4 | // Copyright (C) 2004, 2005, 2006, 2007, 2008 Wojciech Polak. | 4 | // Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Wojciech Polak. |
5 | // | 5 | // |
6 | // This program is free software; you can redistribute it and/or modify it | 6 | // This program is free software; you can redistribute it and/or modify it |
7 | // under the terms of the GNU General Public License as published by the | 7 | // under the terms of the GNU General Public License as published by the |
8 | // Free Software Foundation; either version 3 of the License, or (at your | 8 | // Free Software Foundation; either version 3 of the License, or (at your |
9 | // option) any later version. | 9 | // option) any later version. |
10 | // | 10 | // |
@@ -68,12 +68,16 @@ if (isset ($CONF['path.data']) && $CONF['path.data'] != '') | |||
68 | else | 68 | else |
69 | { | 69 | { |
70 | $CONF['path.data'] = ''; | 70 | $CONF['path.data'] = ''; |
71 | $cwd = getcwd (); | 71 | $cwd = getcwd (); |
72 | } | 72 | } |
73 | 73 | ||
74 | $feed_titles_idx = array (); | ||
75 | if (isset ($CONF['feed.titles.idx'])) | ||
76 | @include $CONF['path.data'].$CONF['feed.titles.idx']; | ||
77 | |||
74 | if (isset ($CONF['orderfile']) && | 78 | if (isset ($CONF['orderfile']) && |
75 | file_exists ($CONF['path.data'].$CONF['orderfile'])) | 79 | file_exists ($CONF['path.data'].$CONF['orderfile'])) |
76 | { | 80 | { |
77 | $lines = file ($CONF['path.data'].$CONF['orderfile']); | 81 | $lines = file ($CONF['path.data'].$CONF['orderfile']); |
78 | foreach ($lines as $line) | 82 | foreach ($lines as $line) |
79 | $searchdirs[] = chop ($line); | 83 | $searchdirs[] = chop ($line); |
@@ -263,28 +267,30 @@ if (isset ($RSS)) | |||
263 | } | 267 | } |
264 | else { | 268 | else { |
265 | $fmtime = filemtime ($inc); | 269 | $fmtime = filemtime ($inc); |
266 | } | 270 | } |
267 | 271 | ||
268 | $pubDate = date ("D, d M Y H:i:s O", $fmtime); | 272 | $pubDate = date ("D, d M Y H:i:s O", $fmtime); |
269 | $itemTitle = date ('d M Y', $fmtime); | 273 | $idx = substr ($inc, strlen ($cwd)); |
274 | $itemTitle = isset ($feed_titles_idx[$idx]) ? $feed_titles_idx[$idx] : | ||
275 | date ('d M Y', $fmtime); | ||
270 | $permaLink = date ($CONF['permalinkFmt'], $fmtime); | 276 | $permaLink = date ($CONF['permalinkFmt'], $fmtime); |
271 | 277 | ||
272 | echo " <item>\n"; | 278 | echo " <item>\n"; |
273 | echo " <title>$itemTitle</title>\n"; | 279 | echo " <title>$itemTitle</title>\n"; |
274 | echo " <link>".$CONF['url.site']."/". | 280 | echo " <link>".$CONF['url.site']."/". |
275 | $CONF['qpattern'].$permaLink."</link>\n"; | 281 | $CONF['qpattern'].$permaLink."</link>\n"; |
276 | 282 | ||
277 | if ($CONF['feed.CDATA']) { | 283 | if ($CONF['feed.CDATA']) { |
278 | echo " <description><![CDATA[\n"; | 284 | echo " <description><![CDATA[\n"; |
279 | indent_include (9, $inc, $CONF['feed.CDATA']); | 285 | indent_include (0, $inc, $CONF['feed.CDATA']); |
280 | echo " ]]></description>\n"; | 286 | echo "]]></description>\n"; |
281 | } | 287 | } |
282 | else { | 288 | else { |
283 | echo " <description>\n"; | 289 | echo " <description>\n"; |
284 | indent_include (9, $inc, $CONF['feed.CDATA']); | 290 | indent_include (0, $inc, $CONF['feed.CDATA']); |
285 | echo " </description>\n"; | 291 | echo " </description>\n"; |
286 | } | 292 | } |
287 | 293 | ||
288 | echo " <guid isPermaLink=\"true\">". | 294 | echo " <guid isPermaLink=\"true\">". |
289 | $CONF['url.site']."/".$CONF['qpattern']. | 295 | $CONF['url.site']."/".$CONF['qpattern']. |
290 | $permaLink."</guid>\n"; | 296 | $permaLink."</guid>\n"; |
@@ -355,37 +361,39 @@ else if (isset ($ATOM)) | |||
355 | } | 361 | } |
356 | else { | 362 | else { |
357 | $fmtime = filemtime ($inc); | 363 | $fmtime = filemtime ($inc); |
358 | } | 364 | } |
359 | 365 | ||
360 | $pubDate = date ('Y-m-d\TH:i:s\Z', $fmtime); | 366 | $pubDate = date ('Y-m-d\TH:i:s\Z', $fmtime); |
361 | $itemTitle = date ('d M Y', $fmtime); | 367 | $idx = substr ($inc, strlen ($cwd)); |
368 | $itemTitle = isset ($feed_titles_idx[$idx]) ? $feed_titles_idx[$idx] : | ||
369 | date ('d M Y', $fmtime); | ||
362 | $permaLink = date ($CONF['permalinkFmt'], $fmtime); | 370 | $permaLink = date ($CONF['permalinkFmt'], $fmtime); |
363 | 371 | ||
364 | echo " <entry>\n"; | 372 | echo " <entry>\n"; |
365 | echo " <id>".$CONF['feed.tagUri']."/$permaLink</id>\n"; | 373 | echo " <id>".$CONF['feed.tagUri']."/$permaLink</id>\n"; |
366 | echo " <updated>$pubDate</updated>\n"; | 374 | echo " <updated>$pubDate</updated>\n"; |
367 | echo " <title>$itemTitle</title>\n"; | 375 | echo " <title>$itemTitle</title>\n"; |
368 | echo " <link rel=\"alternate\" type=\"text/html\" href=\"". | 376 | echo " <link rel=\"alternate\" type=\"text/html\" href=\"". |
369 | $CONF['url.site']."/".$CONF['qpattern'].$permaLink."\"/>\n"; | 377 | $CONF['url.site']."/".$CONF['qpattern'].$permaLink."\"/>\n"; |
370 | 378 | ||
371 | if ($CONF['feed.XHTML']) { | 379 | if ($CONF['feed.XHTML']) { |
372 | echo " <content type=\"xhtml\" xml:space=\"preserve\">\n"; | 380 | echo " <content type=\"xhtml\" xml:space=\"preserve\">\n"; |
373 | echo " <div xmlns=\"http://www.w3.org/1999/xhtml\">\n"; | 381 | echo " <div xmlns=\"http://www.w3.org/1999/xhtml\">\n"; |
374 | indent_include (6, $inc, $CONF['feed.XHTML']); | 382 | indent_include (0, $inc, $CONF['feed.XHTML']); |
375 | echo " </div>\n"; | 383 | echo " </div>\n"; |
376 | echo " </content>\n"; | 384 | echo " </content>\n"; |
377 | } | 385 | } |
378 | else if ($CONF['feed.CDATA']) { | 386 | else if ($CONF['feed.CDATA']) { |
379 | echo " <content type=\"html\" xml:space=\"preserve\"><![CDATA[\n"; | 387 | echo " <content type=\"html\" xml:space=\"preserve\"><![CDATA[\n"; |
380 | indent_include (6, $inc, $CONF['feed.CDATA']); | 388 | indent_include (0, $inc, $CONF['feed.CDATA']); |
381 | echo " ]]></content>\n"; | 389 | echo "]]></content>\n"; |
382 | } | 390 | } |
383 | else { | 391 | else { |
384 | echo " <content type=\"html\" xml:space=\"preserve\">\n"; | 392 | echo " <content type=\"html\" xml:space=\"preserve\">\n"; |
385 | indent_include (6, $inc, $CONF['feed.CDATA']); | 393 | indent_include (0, $inc, $CONF['feed.CDATA']); |
386 | echo " </content>\n"; | 394 | echo " </content>\n"; |
387 | } | 395 | } |
388 | 396 | ||
389 | echo " </entry>\n"; | 397 | echo " </entry>\n"; |
390 | } | 398 | } |
391 | } | 399 | } |
@@ -414,21 +422,21 @@ else // HTML | |||
414 | // the query engine... | 422 | // the query engine... |
415 | if (isset ($search_m)) | 423 | if (isset ($search_m)) |
416 | { | 424 | { |
417 | if (isset ($search_d)) | 425 | if (isset ($search_d)) |
418 | { | 426 | { |
419 | if (ereg ("^$search_m-$search_d.*\.html\$", basename ($inc))) | 427 | if (ereg ("^$search_m-$search_d.*\.html\$", basename ($inc))) |
420 | include_file ($inc); | 428 | include_file ($inc, 'd'); |
421 | } | 429 | } |
422 | else | 430 | else |
423 | if (ereg ("^$search_m-.*\.html\$", basename ($inc))) | 431 | if (ereg ("^$search_m-.*\.html\$", basename ($inc))) |
424 | include_file ($inc); | 432 | include_file ($inc, 'm'); |
425 | } | 433 | } |
426 | else | 434 | else |
427 | if (ereg (".*\.html\$", basename ($inc))) | 435 | if (ereg (".*\.html\$", basename ($inc))) |
428 | include_file ($inc); | 436 | include_file ($inc, 'y'); |
429 | } | 437 | } |
430 | 438 | ||
431 | // Calculate a copyright footnote. | 439 | // Calculate a copyright footnote. |
432 | $copyrightYear = ''; | 440 | $copyrightYear = ''; |
433 | if (count ($year_array)) | 441 | if (count ($year_array)) |
434 | { | 442 | { |
@@ -601,15 +609,15 @@ function printer ($data, $string) | |||
601 | echo $string; | 609 | echo $string; |
602 | } | 610 | } |
603 | 611 | ||
604 | ///////////////////////////// | 612 | ///////////////////////////// |
605 | 613 | ||
606 | // HTML output | 614 | // HTML output |
607 | function include_file ($file) | 615 | function include_file ($file, $type) |
608 | { | 616 | { |
609 | global $CONF, $search_d, $local_fn, $year_array; | 617 | global $CONF, $search_y, $search_m, $local_fn, $year_array; |
610 | $res = array (); | 618 | $res = array (); |
611 | $cdd = basename (dirname ($file)); // current data dir | 619 | $cdd = basename (dirname ($file)); // current data dir |
612 | 620 | ||
613 | $local_fn = 0; | 621 | $local_fn = 0; |
614 | if (is_numeric ($cdd)) | 622 | if (is_numeric ($cdd)) |
615 | { | 623 | { |
@@ -656,17 +664,40 @@ function include_file ($file) | |||
656 | } | 664 | } |
657 | process_footnotes ('printer', 0); | 665 | process_footnotes ('printer', 0); |
658 | echo '</div>'."\n"; | 666 | echo '</div>'."\n"; |
659 | 667 | ||
660 | echo '<div class="entry-footer">'."\n"; | 668 | echo '<div class="entry-footer">'."\n"; |
661 | echo '<a href="./'.$CONF['qpattern']. | 669 | echo '<a href="./'.$CONF['qpattern']. |
662 | $permaLink.'" rel="bookmark" title="'.$entryDate. | 670 | $permaLink.'" class="bookmark" rel="bookmark" title="'. |
663 | '"><abbr class="published" title="'. | 671 | $entryDate.'"><abbr class="published" title="'. |
664 | $pubDate.'">'.$entryDate.'</abbr></a>'."\n"; | 672 | $pubDate.'">'.$entryDate.'</abbr></a>'."\n"; |
665 | echo '<address class="vcard"><span class="fn">'. | 673 | echo '<address class="vcard"><span class="fn">'. |
666 | $CONF['feed.authorName'].'</span></address>'; | 674 | $CONF['feed.authorName'].'</span></address>'; |
675 | |||
676 | /* disqus support */ | ||
677 | if (isset ($CONF['disqus.account']) && $CONF['disqus.account'] != '') { | ||
678 | if ($type == 'd') { | ||
679 | echo "\n"; | ||
680 | echo '<div id="disqus_thread"></div>'; | ||
681 | echo '<script type="text/javascript" src="http://disqus.com/forums/'. | ||
682 | $CONF['disqus.account'].'/embed.js"></script>'; | ||
683 | if (isset ($CONF['disqus.showNoScript'])) { | ||
684 | echo '<noscript><div><a href="http://'.$CONF['disqus.account']. | ||
685 | '.disqus.com/?url=ref">View the forum thread.</a></div></noscript>'; | ||
686 | } | ||
687 | echo '<a href="http://disqus.com" class="dsq-brlink">'. | ||
688 | 'comments powered by <span class="logo-disqus">Disqus</span>'. | ||
689 | '</a>'."\n"; | ||
690 | } | ||
691 | else if (isset ($CONF['recent']) && | ||
692 | (!isset ($search_y) || isset ($search_m))) { | ||
693 | echo '<a href="./'.$CONF['qpattern'].$permaLink. | ||
694 | '#disqus_thread" title="View comments">Comments</a>'."\n"; | ||
695 | } | ||
696 | } | ||
697 | |||
667 | echo '</div>'."\n"; | 698 | echo '</div>'."\n"; |
668 | echo '</div>'."\n\n"; | 699 | echo '</div>'."\n\n"; |
669 | } | 700 | } |
670 | } | 701 | } |