Esempio n. 1
0
/**
 * Determines what screen needs to be displayed to 'admin' users. Checks what's set in
 * $Pivot_Vars['func'] and $Pivot_Vars['func'], checks if if the function is set and the user is
 * allowed to go there, and then jumps to that function.
 *
 * Otherwise it displays adminMail(), which is the screen with admin options. Note that the 'overview
 * screen' is shown with the 'menu=main' parameter.
 *
 * @see startAdmin(), adminMain()
 *
 */
function startAdmin()
{
    global $Pivot_Vars, $adminInternal;
    if (isset($adminInternal[$Pivot_Vars['do']])) {
        $func = $adminInternal[$Pivot_Vars['do']];
        if (function_exists($func)) {
            $func();
        } else {
            ErrorOut('Function: <i>' . $adminInternal[$Pivot_Vars['do']] . '</i> does not exist in pv_admin.php.');
        }
    } else {
        adminMain();
    }
}
Esempio n. 2
0
/**
 * 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}");
}
Esempio n. 3
0
function make_default()
{
    global $Weblogs, $Current_weblog, $db, $entry;
    $db = new db();
    $arc_list = "";
    if (file_exists($pivot_dir . "db/ser-archive_overview_cat.php") && file_exists($pivot_dir . "db/ser-archive_overview_cat.php")) {
        $arc_array_cat = load_serialize($pivot_dir . "db/ser-archive_overview_cat.php", TRUE);
        $arc_array_mon = load_serialize($pivot_dir . "db/ser-archive_overview_mon.php", TRUE);
        // if over three three days old.
        if (mktime() - filemtime($pivot_dir . "db/ser-archive_overview_cat.php") > 259200) {
            unlink($pivot_dir . "db/ser-archive_overview_cat.php");
            unlink($pivot_dir . "db/ser-archive_overview_mon.php");
        }
    } else {
        $list_entries = $db->getlist_range("1970-01-01-00-00", "2020-12-31-23-59", "", "", FALSE);
        // iterate through all of the entries, building the arrays for both the
        // per-month and per-category lists..
        foreach ($list_entries as $list_entry) {
            $date = format_date($list_entry['date'], $Weblogs[$Current_weblog]['fulldate_format']);
            $link = make_filelink($list_entry['code']);
            list($ye, $mo) = explode("-", $list_entry['date']);
            if (isset($list_entry['category'])) {
                foreach ($list_entry['category'] as $cat) {
                    $arc_array_cat[$cat][$ye] = 1;
                }
            }
            $arc_array_mon[$ye][$mo] = 1;
        }
        save_serialize($pivot_dir . "db/ser-archive_overview_cat.php", $arc_array_cat, FALSE);
        save_serialize($pivot_dir . "db/ser-archive_overview_mon.php", $arc_array_mon, FALSE);
    }
    $current_cats = find_cats_in_weblog($Current_weblog);
    // build the per-month list
    foreach ($arc_array_mon as $ye => $months) {
        $arc_list .= "<p><b>{$ye}:</b><br />\n";
        ksort($months);
        $temp_arr = array();
        foreach ($months as $mo => $dummy) {
            $temp_arr[] = sprintf("<a href=\"%s/%s/\">%s</a>\n", $ye, $mo, lang('months', -1 + $mo));
        }
        $arc_list .= implode(", ", $temp_arr) . "<br /></p>\n";
    }
    // build the per-category list
    ksort($arc_array_cat);
    if (count($arc_array_cat) > 1) {
        foreach ($arc_array_cat as $cat => $year) {
            if (in_array($cat, $current_cats)) {
                $arc_list .= "<p><b>{$cat}:</b>\n";
                ksort($year);
                $temp_arr = array();
                foreach ($year as $ye => $dummy) {
                    $temp_arr[] = sprintf("<a href=\"%s/%s/\">%s</a>\n", $cat, $ye, $ye);
                }
                $arc_list .= implode(", ", $temp_arr) . "</p>\n";
            }
        }
    }
    // the search template for the current weblog
    if (isset($Weblogs[$Current_weblog]['extra_template']) && $Weblogs[$Current_weblog]['extra_template'] != "") {
        $template_html = load_template($Weblogs[$Current_weblog]['extra_template']);
    } else {
        $template_html = load_template($Weblogs[$Current_weblog]['archive_template']);
    }
    $template_html = replace_subweblogs_templates($template_html, $arc_list);
    $filename = $Weblogs[$Current_weblog]['archive_path'] . make_archive_name();
    if (!$template_html) {
        ErrorOut("Could not load template file: <i>{$template}</i> [does not exist]");
    } else {
        $output = $template_html;
        $output = parse_step4($output);
    }
    echo $output;
    flush();
}
Esempio n. 4
0
StartTable($caption);
DisplaySettings(${$var});
EndForm($next, 1);
$form = ob_get_contents();
ob_end_clean();
$db = new db();
// Use the extra template for the current weblog
if (isset($Weblogs[$Current_weblog]['extra_template']) && $Weblogs[$Current_weblog]['extra_template'] != "") {
    $template_html = load_template($Weblogs[$Current_weblog]['extra_template']);
} else {
    $template_html = load_template($Weblogs[$Current_weblog]['archive_template']);
}
// Match and replace the [[weblog]] tags for the form output
if (preg_match_all('/\\[\\[(sub)?weblog:(.*)?(:[0-9]*)?\\]\\]/siU', $template_html, $match)) {
    if (count($match[1]) == 1) {
        $template_html = str_replace($match[0][0], $form, $template_html);
    } else {
        $template_html = preg_replace("/\\[\\[(sub)?weblog:standard(:[0-9]*)?\\]\\]/siU", $form, $template_html);
        foreach ($match[0] as $name) {
            $template_html = str_replace($name, "", $template_html);
        }
    }
}
if (!$template_html) {
    ErrorOut("Could not load template file: <i>{$template}</i> [does not exist]");
} else {
    $output = $template_html;
    $output = parse_step4($output);
}
echo $output;
flush();
Esempio n. 5
0
/**
 * piv_error prints an error message, does a debug backtrace print out
 * and exits.
 *
 * On the admin pages it will just display the text on the current page and
 * add the page footer (if endpage is equal to 1). On weblog pages it will use
 * the extra page template for the current weblog.
 *
 * @param string $name
 * @param string $message
 * @param boolean $endpage
 */
function piv_error($name, $message, $endpage = 0)
{
    global $db, $Current_weblog, $Weblogs, $Pivot_Vars;
    if (!isset($db)) {
        $db = new db();
    }
    if (!isset($Current_weblog)) {
        reset($Weblogs);
        if (isset($Pivot_Vars['w'])) {
            $Current_weblog = weblog_from_para($Pivot_Vars['w']);
            if (!$Current_weblog) {
                $Current_weblog = key($Weblogs);
            }
        } else {
            $Current_weblog = key($Weblogs);
        }
    }
    debug_printbacktrace();
    $text = "<div class='pivot-error'>\n<h2>{$name}</h2>\n\n" . "<p>{$message}</p>\n</div>\n";
    if ($endpage == 1 || !defined('LIVEPAGE') && !defined('INWEBLOG')) {
        echo $text;
        PageFooter();
        exit;
    }
    // Use the extra template for the current weblog
    if (isset($Weblogs[$Current_weblog]['extra_template']) && $Weblogs[$Current_weblog]['extra_template'] != "") {
        $template_html = load_template($Weblogs[$Current_weblog]['extra_template']);
    } else {
        $template_html = load_template($Weblogs[$Current_weblog]['archive_template']);
    }
    // Match and replace the [[weblog]] tags for the error output
    $template_html = replace_subweblogs_templates($template_html, $text);
    if (!$template_html) {
        ErrorOut("Could not load template file: <i>{$template}</i> [does not exist]");
    } else {
        $output = $template_html;
        $output = parse_step4($output);
    }
    echo $output;
    flush();
    exit;
}