Пример #1
0
function snippet_archiveprevious($text = "")
{
    global $Cfg, $db, $Weblogs, $Current_weblog, $Archive_array, $archive_array_prev, $Pivot_Vars, $Paths;
    if ($text == "") {
        $text = lang('weblog_text', 'previous_archive');
    }
    if (!defined('LIVEPAGE')) {
        // in 'normal' archive pages'..
        if (!isset($db->entry)) {
            return "";
        }
        // get the filename for the current archive..
        $current_archive = make_archive_name();
        $id = $db->entry['code'];
        // get the archive_array, if it's not done yet.
        if (!isset($Archive_array)) {
            make_archive_array();
        }
        // we make another array where we number the archives. As far as i know this is
        // the only decent way to find the next or previous entries..
        // sometime i will want to cache this for performance
        $counter = 0;
        // 2004/11/23 =*=*= JM - foreach() test
        if (is_array($Archive_array[$Current_weblog])) {
            foreach ($Archive_array[$Current_weblog] as $this_key => $this_val) {
                $temp_arr[$counter] = $this_key;
                if ($this_key == $current_archive) {
                    $this_count = $counter;
                }
                $counter++;
            }
        }
        // then, we'll pick out the next one in the array (remember, the array
        // is in reverse chronological order)
        if (isset($temp_arr[$this_count - 1])) {
            $prev_arc = $temp_arr[$this_count - 1];
            $target = set_target('', 'target="_self"');
            $date = $Archive_array[$Current_weblog][$prev_arc];
            $link = make_archive_link($date);
            $text = format_date($date, $text);
            $link = sprintf("<a href=\"%s\" %s>%s</a>", $link, $target, $text);
            return $link;
        } else {
            return "";
        }
    } else {
        // display link for pages in 'live archives'
        // guessstimate the current sybweblog.
        reset($Weblogs[$Current_weblog]['sub_weblog']);
        $my_subweblog = current($Weblogs[$Current_weblog]['sub_weblog']);
        $show = $my_subweblog['num_entries'];
        if (!isset($Pivot_Vars['o']) || empty($Pivot_Vars['o']) || $Pivot_Vars['o'] <= 0) {
            $offset = -1;
        } else {
            if ($Pivot_Vars['o'] < $show) {
                $offset = 0;
            } else {
                $offset = $Pivot_Vars['o'] - $show;
            }
        }
        // if it's the first one, we don't have to show it.
        if ($offset >= 0) {
            if ($Cfg['mod_rewrite'] == 0) {
                $url = $Paths['pivot_url'] . "archive.php?c=%s&amp;o=%s";
            } else {
                $url = $Paths['log_url'] . "category/%s/?o=%s";
            }
            $link = sprintf($url, para_category($Pivot_Vars['c']), $offset);
            if (para_weblog_needed($Current_weblog)) {
                $link .= '&amp;w=' . para_weblog($Current_weblog);
            } elseif (isset($_GET['w']) && !empty($_GET['w'])) {
                $link .= '&amp;w=' . htmlspecialchars($_GET['w']);
            }
            if (isset($_GET['t']) && !empty($_GET['t'])) {
                $link .= '&amp;t=' . htmlspecialchars($_GET['t']);
            }
            $target = set_target('', 'target="_self"');
            $link = sprintf("<a href=\"%s\" %s>%s</a>", $link, $target, $text);
        } else {
            $link = "";
        }
        return $link;
    }
}
Пример #2
0
/**
 * The screen that's shown when you click 'rebuild index'.
 *
 */
function build_index()
{
    global $config_array, $Archive_array;
    PageHeader(lang('adminbar', 'buildindex'), 1);
    PageAnkeiler(lang('adminbar', 'buildindex') . ' &raquo; ' . lang('adminbar', 'buildindex_title'));
    @set_time_limit(0);
    // Force the archive index and tag index file to be updated
    @unlink('db/ser-archives.php');
    // Make a new archive array.
    $Archive_array = make_archive_array();
    // Force the tag index to be updated
    @unlink('db/ser_tags.php');
    $dir = dir('db/tagdata/');
    while (false !== ($entry = $dir->read())) {
        if (getextension($entry) == "cache") {
            unlink('db/tagdata/' . $entry);
        }
    }
    $dir->close();
    echo "<p>" . lang('adminbar', 'buildindex_start') . "<br />\n";
    flush();
    $db = new db();
    $db->generate_index();
    echo "<br /><br />\n\n<b>" . str_replace("%num%", timetaken(), lang('adminbar', 'buildindex_finished')) . "</b><br /><br /></p>\n";
    // stuff stops here..
    PageFooter();
}
Пример #3
0
/**
 * Screen that's shown when rebuilding all pages.
 */
function regen()
{
    global $Cfg, $db, $Weblogs, $Pivot_Vars, $VerboseGenerate, $Allow_RSS, $totalfiles, $done_archives, $archive_array_next, $archive_array_prev, $Archive_array;
    PageHeader(lang('adminbar', 'regen_title'), 1);
    PageAnkeiler(lang('userbar', 'admin') . ' &raquo; ' . lang('adminbar', 'regen_title'));
    // initialise the threshold..
    if (isset($Cfg['rebuild_threshold']) && $Cfg['rebuild_threshold'] > 4) {
        $threshold = $Cfg['rebuild_threshold'];
    } else {
        $threshold = 28;
    }
    $db = new db();
    // also force the archive index file to be updated
    @unlink('db/ser-archives.php');
    // Make a new archive array.
    $Archive_array = make_archive_array();
    // ugly hack, to get a big slice of mem back..
    $entries_arr = $db->getcodes_range("0000-00-00-00-00", "2010-01-01-00-00", "", "", FALSE);
    $totalfiles = 0;
    $count = 0;
    if (isset($Pivot_Vars['count'])) {
        $count = $Pivot_Vars['count'];
        $totalfiles = $Pivot_Vars['totalfiles'];
        reset($entries_arr);
        do {
            next($entries_arr);
            $key = key($entries_arr);
            //echo "(k $key)";
        } while ($key < $Pivot_Vars['count']);
    }
    do {
        $key = key($entries_arr);
        $loopentry = current($entries_arr);
        // Generate only archive pages and static entry pages, not
        // frontpage or RSS.
        generate_pages($loopentry, TRUE, FALSE, TRUE, FALSE, FALSE);
        $count++;
        if ($count % 10 == 0) {
            printf("%1.2f sec: Processed %d entries.." . "<br />\n", timetaken('int'), $count);
            flush();
        }
        // server friendly generate all..
        if (timetaken("int") > $threshold) {
            $myurl = sprintf("index.php?session=%s&menu=admin&func=admin&do=regen&count=%s&totalfiles=%s", $Pivot_Vars['session'], $count, $totalfiles);
            printf('<script> self.location = "%s"; </script>', $myurl);
            die;
        }
    } while (next($entries_arr));
    printf("<br />A total of <b>%s</b> entries have been processed, and <b>%s</b> files have been created" . "<br />\n", $count, $totalfiles);
    // Generate frontpages and feeds.
    echo "<p>" . lang('adminbar', 'buildfrontpage_title') . "</p>";
    $VerboseGenerate = true;
    $Allow_RSS = true;
    foreach ($Weblogs as $name => $weblog) {
        generate_frontpage($name);
    }
    echo "<p>" . lang('general', 'done') . "</p>";
    PageFooter();
}