phpDocumentor pond
[ class tree: pond ] [ index: pond ] [ all elements ]

Source for file _blog_main.inc.php

Documentation is available at _blog_main.inc.php

  1. <?php
  2. /**
  3.  * This file loads and initializes the blog to be displayed.
  4.  *
  5.  * This file is part of the Quam Plures project - {@link http://quamplures.net/}.
  6.  * See also {@link https://launchpad.net/quam-plures}.
  7.  *
  8.  * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
  9.  * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}.
  10.  *  Parts of this file are copyright (c)2004-2005 by Daniel HAHLER - {@link http://thequod.de/contact}.
  11.  *
  12.  * @license http://quamplures.net/license.html GNU General Public License (GPL)
  13.  *
  14.  *  {@internal Open Source relicensing agreement:
  15.  *  Daniel HAHLER grants Francois PLANQUE the right to license
  16.  *  Daniel HAHLER's contributions to this file and the b2evolution project
  17.  *  under any OSI approved OSS license (http://www.opensource.org/licenses/).
  18.  *  }}}
  19.  *
  20.  *  {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  21.  * @author blueyed: Daniel HAHLER
  22.  * @author fplanque: Francois PLANQUE
  23.  *
  24.  * @package pond
  25.  */
  26.  
  27. if!defined('QP_CONFIG_LOADED') ) die'Please, do not access this page directly.' );
  28.  
  29. /**
  30.  * Initialize everything:
  31.  */
  32. require_once dirname(__FILE__).'/_main.inc.php';
  33.  
  34. load_funcs('templates/_template.funcs.php');
  35. load_class('items/model/_itemlist.class.php');
  36.  
  37. $Timer->start'_blog_main.inc' );
  38.  
  39.  
  40. /*
  41.  * blog ID. This is a little bit special.
  42.  *
  43.  * In most cases $blog should be set by a stub file and the param() call below will just check that it's an integer.
  44.  *
  45.  * Note we do NOT memorize the param as we don't want it in regenerate_url() calls.
  46.  * Whenever we do, index.php will already have called param() with memorize=true
  47.  *
  48.  * In some cases $blog will not have been set before and it will be set with the param() call below.
  49.  * Currently, this only happens with the old /qp_srvc/ RSS stubs.
  50.  */
  51. param'blog''integer'''false );
  52.  
  53. // Getting current blog info:
  54. $BlogCache get_Cache'BlogCache' );
  55. /**
  56.  * @var Blog 
  57.  */
  58. $Blog $BlogCache->get_by_ID$blogfalsefalse );
  59. ifempty$Blog ) )
  60. {
  61.     require $templates_path.'_404_blog_not_found.main.php'// error & exit
  62.     // EXIT.
  63. }
  64.  
  65.  
  66. // Init $disp
  67. param'disp''string''posts'true );
  68. $disp_detail '';
  69.  
  70.  
  71. /*
  72.  * _______________________________ Locale / Charset for the Blog _________________________________
  73.  *
  74.     TODO: blueyed>> This should get moved as default to the locale detection in _main.inc.php,
  75.             as we only want to activate the I/O charset, which is probably the user's..
  76.             It prevents using a locale/charset in the front office, apart from the one given as default for the blog!!
  77. fp>there is no blog defined in _main and there should not be any
  78. blueyed> Sure, but that means we should either split it, or use the locale here only, if there's no-one given with higher priority.
  79. */
  80. // Activate matching locale:
  81. $Debuglog->add'Activating blog locale: '.$Blog->get('locale')'locale' );
  82. locale_activate$Blog->get('locale') );
  83.  
  84.  
  85. // Re-Init charset handling, in case current_charset has changed:
  86. ifinit_charsets$current_charset ) )
  87. {
  88.   // Reload Blog(s) (for encoding of name, tagline etc):
  89.   $BlogCache->clear();
  90.  
  91.   $Blog $BlogCache->get_by_ID$blog );
  92. }
  93.  
  94.  
  95. /*
  96.  * _____________________________ Extra path info decoding ________________________________
  97.  *
  98.  * This will translate extra path into 'regular' params.
  99.  *
  100.  * Decoding should try to work like this:
  101.  *
  102.  * baseurl/blog-urlname/junk/.../junk/post-title    -> points to a single post (no ending slash)
  103.  * baseurl/blog-urlname/junk/.../junk/p142          -> points to a single post
  104.  * baseurl/blog-urlname/2006/                       -> points to a yearly archive because of ending slash + 4 digits
  105.  * baseurl/blog-urlname/2006/12/                    -> points to a monthly archive
  106.  * baseurl/blog-urlname/2006/12/31/                 -> points to a daily archive
  107.  * baseurl/blog-urlname/2006/w53/                   -> points to a weekly archive
  108.  * baseurl/blog-urlname/junk/.../junk/chap-urlname/ -> points to a single chapter/category (because of ending slash)
  109.  * Note: category names cannot be named like this [a-z][0-9]+
  110.  */
  111. ifisset$resolve_extra_path ) ) $resolve_extra_path true}
  112. if$resolve_extra_path )
  113. {
  114.     // Check and Remove blog base URI from ReqPath:
  115.     $blog_baseuri substr$Blog->gen_baseurl()strlen$Blog->get('baseurlroot') ) );
  116.     $Debuglog->add'blog_baseuri: "'.$blog_baseuri.'"''params' );
  117.  
  118.     // Remove trailer:
  119.     $blog_baseuri_regexp preg_replace'¤(\.php[0-9]?)?/?$¤'''$blog_baseuri );
  120.     // Readd possibilities in order to get a broad match:
  121.     $blog_baseuri_regexp '¤^'.preg_quote$blog_baseuri_regexp ).'(\.php[0-9]?)?/(.+)$¤';
  122.  
  123.     ifpreg_match$blog_baseuri_regexp$ReqPath$matches ) )
  124.     // We have extra path info
  125.         $path_string $matches[2];
  126.  
  127.         $Debuglog->add'Extra path info found! path_string=' $path_string 'params' );
  128.  
  129.         // Replace encoded ";" and ":" with regular chars (used for tags)
  130.         // TODO: dh> why not urldecode it altogether? fp> would prolly make sense but requires testing -- note: check with tags (move urldecode from tags up here)
  131.         // TODO: PHP5: use str_ireplace
  132.         $path_string str_replace(
  133.             array('%3b''%3B''%3a''%3A'),
  134.             array(';'';'':'':'),
  135.             $path_string );
  136.  
  137.         // Slice the path:
  138.         $path_elements preg_split'~/~'$path_string20PREG_SPLIT_NO_EMPTY );
  139.  
  140.         ifisset$path_elements[0)
  141.             && $path_elements[0== $Blog->stub
  142.                 || $path_elements[0== $Blog->urlname
  143.                 || $path_elements[0== 'index.php' ) )
  144.         // Ignore stub files, blog url names, and index.php
  145.             array_shift$path_elements );
  146.             $Debuglog->add'Ignoring stub filename, blog urlname, or index.php in extra path info' 'params' );
  147.         }
  148.  
  149.         ifisset$path_elements[0)
  150.             && substr_count$path_elements[0]'.' != )
  151.             && is_file$basepath.$path_elements[0) )
  152.         // Ignore filenames that exist in root
  153.             array_shift$path_elements );
  154.             $Debuglog->add'Ignoring filenames that exist as installation root files in extra path info' 'params' );
  155.         }
  156.  
  157.         // Do we still have extra path info to decode?
  158.         ifcount($path_elements) )
  159.         {
  160.             // TODO: dh> add plugin hook here, which would allow to handle path elements (name spaces in clean URLs), and to override internal functionality (e.g. handle tags in a different way).
  161.             // Is this a tag ("prefix-only" mode)?
  162.             if$Blog->get_setting('tag_links'== 'prefix-only'
  163.                 && count($path_elements== 2
  164.                 && $path_elements[0== $Blog->get_setting('tag_prefix')
  165.                 && isset($path_elements[1]) )
  166.             {
  167.                 $tag strip_tags(urldecode($path_elements[1]));
  168.  
  169.                 // # of posts per page for tag page:
  170.                 if$posts $Blog->get_setting'tag_posts_per_page' ) )
  171.                 // use blog default
  172.                     $posts $Blog->get_setting'posts_per_page' );
  173.                 }
  174.             }
  175.             else
  176.             {
  177.                 // Does the pathinfo end with a / or a ; ?
  178.                 $last_char substr$path_string-);
  179.                 $last_part $path_elements[count$path_elements )-1];
  180.                 $last_len  strlen$last_part );
  181.                 if( ( $last_char == '-' && $tags_dash_fix || $last_len != 40 ) ) || $last_char == ':'|| $last_char == ';' )
  182.                 {    // - : or ; -> We'll consider this to be a tag page
  183.                     $tag substr$last_part0-);
  184.                     $tag urldecode($tag);
  185.                     $tag strip_tags($tag);    // security
  186.  
  187.                     // # of posts per page:
  188.                     if$posts $Blog->get_setting'tag_posts_per_page' ) )
  189.                     // use blog default
  190.                         $posts $Blog->get_setting'posts_per_page' );
  191.                     }
  192.                 }
  193.                 elseif( ( $tags_dash_fix && $last_char == '-' && $last_len == 40 || $last_char != '/' )
  194.                 {    // NO ENDING SLASH or ends with a dash, is 40 chars long and $tags_dash_fix is true
  195.                     // -> We'll consider this to be a ref to a post.
  196.                     $Debuglog->add'We consider this o be a ref to a post - last char: '.$last_char'params' );
  197.  
  198.                     // Set a lot of defaults as if we had received a complex URL:
  199.                     $m '';
  200.                     $more 1// Display the extended entries' text
  201.                     $c 1;    // Display comments
  202.                     $tb 1;   // Display trackbacks
  203.  
  204.                     ifpreg_match'#^p([0-9]+)$#'$last_part$req_post ) )
  205.                     // The last param is of the form p000
  206.                         $p $req_post[1];        // Post to display
  207.                     }
  208.                     else
  209.                     // Last param is a string, we'll consider this to be a post urltitle
  210.                         $title $last_part;
  211.                     }
  212.                 }
  213.                 else
  214.                 {    // ENDING SLASH -> we are looking for a daterange OR a chapter:
  215.                     $Debuglog->add'Last part: '.$last_part 'params' );
  216.                     ifpreg_match'|^w?[0-9]+$|'$last_part ) )
  217.                     // Last part is a number or a "week" number:
  218.                         $i=0;
  219.                         $Debuglog->add'Last part is a number or a "week" number: '.$path_elements[$i'params' );
  220.                         ifisset$path_elements[$i) )
  221.                         {
  222.                             ifis_numeric$path_elements[$i) )
  223.                             // We'll consider this to be the year
  224.                                 $m $path_elements[$i++];
  225.                                 $Debuglog->add'Setting year from extra path info. $m=' $m 'params' );
  226.  
  227.                                 // Also use the prefered posts per page for archives (may be NULL, in which case the blog default will be used later on)
  228.                                 if$posts $Blog->get_setting'archive_posts_per_page' ) )
  229.                                 // use blog default
  230.                                     $posts $Blog->get_setting'posts_per_page' );
  231.                                 }
  232.  
  233.                                 ifisset$path_elements[$i&& is_numeric$path_elements[$i) )
  234.                                 // We'll consider this to be the month
  235.                                     $m .= $path_elements[$i++];
  236.                                     $Debuglog->add'Setting month from extra path info. $m=' $m 'params' );
  237.  
  238.                                     ifisset$path_elements[$i&& is_numeric$path_elements[$i) )
  239.                                     // We'll consider this to be the day
  240.                                         $m .= $path_elements[$i++];
  241.                                         $Debuglog->add'Setting day from extra path info. $m=' $m 'params' );
  242.                                     }
  243.                                 }
  244.                                 elseifisset$path_elements[$i&& substr$path_elements[$i]0== 'w' )
  245.                                 // We consider this a week number
  246.                                     $w substr$path_elements[$i]1);
  247.                                 }
  248.                             }
  249.                             else
  250.                             {    // We did not get a number/year...
  251.                                 $disp '404';
  252.                                 $disp_detail '404-malformed_url-missing_year';
  253.                             }
  254.                         }
  255.                     }
  256.                     elseifpreg_match'|^[A-Za-z0-9\-_]+$|'$last_part ) )    // UNDERSCORES for catching OLD URLS!!!
  257.                     {    // We are pointing to a chapter/category:
  258.                         $ChapterCache get_Cache'ChapterCache' );
  259.                         /**
  260.                          * @var Chapter 
  261.                          */
  262.                         $Chapter $ChapterCache->get_by_urlname$last_partfalse );
  263.                         ifempty$Chapter ) )
  264.                         {    // We could not match a chapter...
  265.                             // We are going to consider this to be a post title with a misplaced trailing slash.
  266.                             // That happens when upgrading from WP for example.
  267.                             $title $last_part// Will be sought later
  268.                             $already_looked_into_chapters true;
  269.                         }
  270.                         else
  271.                         {    // We could match a chapter from the extra path:
  272.                             $cat $Chapter->ID;
  273.                             // Also use the prefered posts per page for a cat
  274.                             if$posts $Blog->get_setting'chapter_posts_per_page' ) )
  275.                             // use blog default
  276.                                 $posts $Blog->get_setting'posts_per_page' );
  277.                             }
  278.                         }
  279.                     }
  280.                     else
  281.                     {    // We did not get anything we can decode...
  282.                         $disp '404';
  283.                         $disp_detail '404-malformed_url-bad_char';
  284.                     }
  285.                 }
  286.             }
  287.         }
  288.  
  289.     }
  290. }
  291.  
  292.  
  293. /*
  294.  * ____________________________ Query params ____________________________
  295.  *
  296.  * Note: if the params have been set by the extra-path-info above, param() will not touch them.
  297.  */
  298. param'p''integer'''true );            // Specific post number to display
  299. param'title''string'''true );        // urtitle of post to display
  300. param'redir''string''yes'false );    // Do we allow redirection to canonical URL? (allows to force a 'single post' URL for commenting)
  301. param'preview''integer'0true );        // Is this preview ?
  302. param'stats''integer');                // Deprecated but might still be used by spambots
  303. param'cat''integer'''true );        // Chapter ID
  304.  
  305. // In case these were not set by the stub:
  306. if!isset($timestamp_min) ) $timestamp_min '';
  307. if!isset($timestamp_max) ) $timestamp_max '';
  308.  
  309.  
  310. /*
  311.  * ____________________________ Get specific Item if requested ____________________________
  312.  */
  313. if!empty($p|| !empty($title) )
  314. // We are going to display a single post
  315.     // Make sure the single post we're requesting (still) exists:
  316.     $ItemCache get_Cache'ItemCache' );
  317.     if!empty($p) )
  318.     {    // Get from post ID:
  319.         $Item $ItemCache->get_by_ID$pfalse );
  320.     }
  321.     else
  322.     {    // Get from post title:
  323.         $orig_title $title;
  324.         $title preg_replace'/[^A-Za-z0-9_]/''-'$title );
  325.         $Item $ItemCache->get_by_urltitle$titlefalse );
  326.     }
  327.     ifempty$Item ) )
  328.     {    // Post doesn't exist!
  329.  
  330.         // fp> TODO: ->viewing_allowed() for draft, private, protected and deprecated...
  331.  
  332.         $title_fallback false;
  333.         $tag_fallback $tags_dash_fix && substr$orig_title-== '-' && strlen$orig_title == 40 );
  334.  
  335.         if$tag_fallback && !empty($title&& empty($already_looked_into_chapters) )
  336.         {    // Let's try to fall back to a category/chapter...
  337.             $ChapterCache get_Cache'ChapterCache' );
  338.             /**
  339.              * @var Chapter 
  340.              */
  341.             $Chapter $ChapterCache->get_by_urlname$titlefalse );
  342.             if!empty$Chapter ) )
  343.             {    // We could match a chapter from the extra path:
  344.                 $cat $Chapter->ID;
  345.                 $title_fallback true;
  346.                 $title NULL;
  347.                 // Also use the prefered posts per page for a cat
  348.                 if$posts $Blog->get_setting'chapter_posts_per_page' ) )
  349.                 // use blog default
  350.                     $posts $Blog->get_setting'posts_per_page' );
  351.                 }
  352.             }
  353.         }
  354.  
  355.         if!empty($title) )
  356.         {    // Let's try to fall back to a tag...
  357.             if$tag_fallback )
  358.             {
  359.                 $title substr$orig_title0-);
  360.             }
  361.             if$Blog->get_tag_post_count$title ) )
  362.             // We could match a tag from the extra path:
  363.                 $tag $title;
  364.                 $title_fallback true;
  365.                 $title NULL;
  366.             }
  367.         }
  368.  
  369.         if$title_fallback )
  370.         {    // We were not able to fallback to anythign meaningful:
  371.             $disp '404';
  372.             $disp_detail '404-post_not_found';
  373.         }
  374.     }
  375. }
  376. else ifempty$cat ) )
  377. {    // We are pointing to a chapter/category (by ID):
  378.     $ChapterCache get_Cache'ChapterCache' );
  379.     /**
  380.      * @var Chapter 
  381.      */
  382.     $Chapter $ChapterCache->get_by_ID$catfalse );
  383.  
  384.     if$Chapter )
  385.     {    // Category not found, bail out:
  386.         $disp '404';
  387.         $disp_detail '404-category-not-found';
  388.     }
  389. }
  390.  
  391.  
  392. /*
  393.  * ____________________________ "Clean up" the request ____________________________
  394.  *
  395.  * Make sure that:
  396.  * 1) disp is set to "single" if single post requested
  397.  * 2) URL is canonical if:
  398.  *    - some content was requested in a weird/deprecated way
  399.  *    - or if content identifiers have changed
  400.  */
  401. if$stats || $disp == 'stats' )
  402. {    // This used to be a spamfest...
  403.     require $templates_path.'_410_stats_gone.main.php'// error & exit
  404.     // EXIT.
  405. }
  406. elseif!empty($preview) )
  407. {    // Preview
  408.     $disp 'single';
  409.     // Consider this as an admin hit!
  410.     $Hit->referer_type 'admin';
  411. }
  412. elseif$disp == 'posts' && !empty($Item) )
  413. // We are going to display a single post
  414.     // if( in_array( $Item->ptyp_ID, array( 1000, 1500, 1520, 1530, 1570 ) ) ) // pages and intros
  415.     if$Item->ptyp_ID == 1000 )
  416.     {
  417.         $disp 'page';
  418.     }
  419.     else
  420.     {
  421.         $disp 'single';
  422.     }
  423.  
  424.     // fp> note: the redirecting code that was here moved to template_init() with the other redirecting code.
  425.     // That feels more consistent and may also allow some templates to handle redirects differently (framing?)
  426.     // I hope I didn't screw that up... but it felt like the historical reasons for this to be here no longer applied.
  427. }
  428.  
  429.  
  430. /*
  431.  * ______________________ DETERMINE WHICH TEMPLATE TO USE FOR DISPLAY _______________________
  432.  */
  433.  
  434. /**
  435.  * Check if a temporary template has been requested (used for RSS syndication
  436.  * for example).
  437.  *
  438.  * This will be handled like any other template.
  439.  * tempskin is also checked for b2evolution backward compatibility.
  440.  *
  441.  * @todo maybe restrict that to authorized users?
  442.  */
  443. ifparam'viewmode''string'param'tempskin''string' )true !== '' )
  444. {
  445.     $template $viewmode;
  446. }
  447.  
  448. ifisset$template ) )
  449. {    // A template has been requested by folder_name (url or stub):
  450.  
  451.     // Check validity of requested template name:
  452.     ifpreg_match'~([^-A-Za-z0-9._]|\.\.)~'$template ) )
  453.     {
  454.         debug_die'The requested template name is invalid.' );
  455.     }
  456.  
  457.     $TemplateCache get_cache'TemplateCache' );
  458.     $Template $TemplateCache->new_objNULL$template );
  459.  
  460.     if$Template->type == 'feed' )
  461.     {    // Check if we actually allow the display of the feed; last chance to revert to 404 displayed in default template.
  462.         // Note: Templates with the type "feed" can always be accessed, even when they're not installed.
  463.         if$Blog->get_setting('feed_content'== 'none' )
  464.         // We don't want to provide feeds; revert to 404!
  465.             unset$template );
  466.             unset$Template );
  467.             $disp '404';
  468.             $disp_detail '404-feeds-disabled';
  469.         }
  470.     }
  471.     elseiftemplate_exists$template && template_installed$template ) )
  472.     {    // The requested template is not a feed template and exists in the file system, but isn't installed:
  473.         debug_diesprintfT_'The template [%s] is not installed on this system.' )htmlspecialchars$template ) ) );
  474.     }
  475.     else ifempty$viewmode ) )
  476.     // By definition, we want to see the temporary template (if we don't use feedburner... )
  477.         $redir 'no';
  478.     }
  479. }
  480.  
  481. if!isset$template && !empty($Blog->template_ID) )    // Note: if $template is set to '', then we want to do a "no template" display
  482. // Use default template from the database
  483.     $TemplateCache get_cache'TemplateCache' );
  484.     $Template $TemplateCache->get_by_ID$Blog->template_ID );
  485.     $template $Template->folder;
  486. }
  487.  
  488. // Because a lot of bloggers will delete templates, we have to make this fool proof with extra checking:
  489. if!empty$template && !template_exists$template ) )
  490. // We want to use a template, but it doesn't exist!
  491.     $err_msg sprintfT_('The template [%s] set for blog [%s] does not exist. It must be properly set in the <a %s>blog properties</a> or properly overriden in a stub file.'),
  492.         htmlspecialchars($template),
  493.         $Blog->dget('shortname'),
  494.         'href="'.$admin_url.'?ctrl=coll_settings&amp;tab=template&amp;blog='.$Blog->ID.'"' );
  495.     debug_die$err_msg );
  496. }
  497.  
  498.  
  499. $Timer->pause'_blog_main.inc');
  500.  
  501.  
  502. /*
  503.  * _______________________________ READY TO DISPLAY _______________________________
  504.  *
  505.  * At this point $template holds the name of the template we want to use, or '' for no template!
  506.  */
  507.  
  508.  
  509. // Trigger plugin event:
  510. // fp> TODO: please doc with example of what this can be used for
  511. $Plugins->trigger_event'BeforeBlogDisplay'array('template'=>$template) );
  512.  
  513.  
  514. if!empty$template ) )
  515. // We want to display with a template now:
  516.  
  517.     // Instanciate PageCache:
  518.     load_class'_core/model/_pagecache.class.php' );
  519.     $PageCache new PageCache$Blog );
  520.     // Check for cached content & Start caching if needed
  521.     // Note: there are some redirects inside the templates themselves for canonical URLs,
  522.     // If we have a cache hit, the redirect won't take place until the cache expires -- probably ok.
  523.     // If we start collecting and a redirect happens, the collecting will just be lost and that's what we want.
  524.     if$PageCache->check() )
  525.     {    // Cache miss, we have to generate:
  526.  
  527.         if$template_provided_by_plugin template_provided_by_plugin($template) )
  528.         {
  529.             $Plugins->call_method$template_provided_by_plugin'DisplayTemplate'$tmp_params array('template'=>$template) );
  530.         }
  531.         else
  532.         {
  533.             // Path for the current template:
  534.             $ads_current_template_path $templates_path.$template.'/';
  535.  
  536.             $disp_handlers array(
  537.                     '404'            => '404_not_found.main.php',
  538.                     'arcdir'         => 'arcdir.main.php',
  539.                     'catdir'         => 'catdir.main.php',
  540.                     'comments'       => 'comments.main.php',
  541.                     'credits'        => 'credits.main.php',
  542.                     'feedback-popup' => 'feedback_popup.main.php',
  543.                     'mediaidx'       => 'mediaidx.main.php',
  544.                     'msgform'        => 'msgform.main.php',
  545.                     'page'           => 'page.main.php',
  546.                     'posts'          => 'posts.main.php',
  547.                     'profile'        => 'profile.main.php',
  548.                     'single'         => 'single.main.php',
  549.                     'subs'           => 'subs.main.php',
  550.                     // All others will default to index.main.php
  551.                 );
  552.  
  553.             if!empty($disp_handlers[$disp]) )
  554.             {
  555.                 iffile_exists$disp_handler $ads_current_template_path.$disp_handlers[$disp) )
  556.                 {    // The template has a customized page handler for this display:
  557.                     $Debuglog->add('blog_main: include '.rel_path_to_base($disp_handler).' (custom to this template)''template');
  558.                     require $disp_handler;
  559.                 }
  560.                 else
  561.                 {    // Use the default handler from the templates dir:
  562.                     $Debuglog->add('blog_main: include '.rel_path_to_base($ads_current_template_path.'index.main.php').' (default handler)''template');
  563.                     require $ads_current_template_path.'index.main.php';
  564.                 }
  565.             }
  566.             else
  567.             {    // Use the default handler from the templates dir:
  568.                 $Debuglog->add('blog_main: include '.rel_path_to_base($ads_current_template_path.'index.main.php').' (default index handler)''template');
  569.                 require $ads_current_template_path.'index.main.php';
  570.             }
  571.         }
  572.  
  573.         // Save collected cached data if needed:
  574.         $PageCache->end_collect();
  575.     }
  576.  
  577.     // We probably don't want to return to the caller if we have displayed a template...
  578.     // That is useful if the caller implements a custom display but we still use templates for RSS/ Atom etc..
  579.     exit(0);
  580. }
  581. else
  582. {    // We don't use a template. Hopefully the caller will do some displaying.
  583.     // Set a few vars with default values, just in case...
  584.     $ads_current_template_path $srvc_path;
  585.  
  586.     // We'll just return to the caller now... (if we have not used a template, the caller should do the display after this)
  587. }
  588.  
  589.  
  590. ?>