/**
 * Generates an archive for a given weblog and date.
 */
function generate_archive($weblog, $date)
{
    global $Current_weblog, $Weblogs, $done_archives, $totalfiles, $set_output_paths, $template_html;
    // make a key for this archive
    $archive_key = $weblog . "-" . make_archive_name($date);
    $filename = $Weblogs[$weblog]['archive_path'] . make_archive_name($date);
    // return, if this archive has already been made.
    if (isset($done_archives[$archive_key]) && $done_archives[$archive_key]) {
        return;
        // also return, if the file for this archive was modified within the
        // latest 15 seconds. This save *a lot* of processing.
    } elseif (time() - filemtime($filename) < 15) {
        return;
    } else {
        $done_archives[$archive_key] = TRUE;
    }
    // switch to weblog's language
    LoadWeblogLanguage($Weblogs[$weblog]['language']);
    $template_html = load_template($Weblogs[$weblog]['archive_template']);
    $template_html = str_replace("[[weblog", "[[archive", $template_html);
    $template_html = str_replace("[[subweblog", "[[archive", $template_html);
    // should be unset before each archive and frontpage..
    $set_output_paths = FALSE;
    if (!$template_html) {
        ErrorOut("Could not load template file: <i>{$template}</i> [does not exist]");
    } else {
        $output = "[[tick]]" . $template_html;
        $output = parse_step4($output);
        $output = tidy_html($output);
        if (strstr($filename, ".php")) {
            $output = prepend_spamblock_code($output);
        }
    }
    //make sure the directory exists
    makedir($Weblogs[$weblog]['archive_path']);
    debug("Write archive file: {$filename}");
    write_file($filename, $output);
    $totalfiles++;
    debug("total_a: {$date}");
}
Exemple #2
0
        reset($Weblogs);
        $Current_weblog = key($Weblogs);
    } else {
        $override_weblog = weblog_from_para($Pivot_Vars['w']);
        if (!$override_weblog) {
            piv_error("Weblog doesn't exist", "Selected weblog \"" . htmlspecialchars($Pivot_Vars['w']) . "\" doesn't exist.");
        } else {
            $Current_weblog = $override_weblog;
        }
    }
} else {
    reset($Weblogs);
    $Current_weblog = key($Weblogs);
}
// Display the search results.
LoadWeblogLanguage($Weblogs[$Current_weblog]['language']);
$db = new db();
$result = "\n<div class='pivot-search-result'>\n";
$result .= search_result();
$result .= "<!-- Search took " . timetaken() . " seconds -->\n";
$result .= "</div>\n";
unset($db->entry);
// Set the template for the tags page
if (!isset($Pivot_Vars['t']) || empty($Pivot_Vars['t'])) {
    if (isset($Weblogs[$Current_weblog]['extra_template']) && $Weblogs[$Current_weblog]['extra_template'] != "") {
        $template = $Weblogs[$Current_weblog]['extra_template'];
    } else {
        $template = $Weblogs[$Current_weblog]['archive_template'];
    }
} else {
    $template = $Pivot_Vars['t'];