示例#1
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();
}
示例#2
0
/**
 * metaWeblog.newPost
 *
 * @param array $params Contains blog id, username, password, content, and publish status.
 */
function metaweblog_newPost($params)
{
    global $Cfg, $xmlrpcerruser;
    $conv = $params->getParam(0);
    $blogid = $conv->scalarval();
    $conv = $params->getParam(1);
    $user = $conv->scalarval();
    $conv = $params->getParam(2);
    $pass = $conv->scalarval();
    $conv = $params->getParam(3);
    $contentstruct = php_xmlrpc_decode($conv);
    $conv = $params->getParam(4);
    $conv = $conv->scalarval();
    i18n_array_from_utf8($contentstruct, $dummy);
    // Check password
    $login = pivot_get_userid($user, $pass);
    $uid = $login['uid'];
    if ($uid != -1) {
        if (!pivot_user_blog_check($uid, $blogid)) {
            $err = "User " . $user . " does not have access to any category in blog " . $blogid;
        }
    } else {
        $err = $login['err'];
    }
    if ($err) {
        return new xmlrpcresp(0, $xmlrpcerruser + 1, $err);
    } else {
        //Create post and respond
        $title = $contentstruct['title'];
        $content = $contentstruct['description'];
        if (!isset($contentstruct['categories']) || count($contentstruct['categories']) == 0) {
            // Finding (first) allowed category in selected blog
            $categories = array();
            $cats = find_cats_in_weblog($blogid);
            foreach ($cats as $cat) {
                $allowed = explode("|", $Cfg['cat-' . $cat]);
                if (in_array($uid, $allowed)) {
                    $categories[] = $cat;
                    break;
                }
            }
        } else {
            $categories = $contentstruct['categories'];
            // Checking if submitted categories really belong to selected blog.
            $cats = find_cats_in_weblog($blogid);
            foreach ($categories as $key => $value) {
                if (!in_array($value, $cats)) {
                    unset($categories[$key]);
                    debug("Category {$value} doesn't belong to weblog {$blogid}");
                }
            }
            if (count($categories) == 0) {
                $err = "None of the entry's categories belong to the selected blog";
                return new xmlrpcresp(0, $xmlrpcerruser + 1, $err);
            }
        }
        $postid = pivot_new_post($uid, $title, $content, $categories);
        $myResp = new xmlrpcval($postid, "string");
        return new xmlrpcresp($myResp);
    }
}
示例#3
0
function snippet_last_comments()
{
    global $Cfg, $db, $Weblogs, $Current_weblog, $Paths;
    if (isset($Weblogs[$Current_weblog]['lastcomm_format']) && strlen($Weblogs[$Current_weblog]['lastcomm_format']) > 2) {
        $last_comments_format = $Weblogs[$Current_weblog]['lastcomm_format'];
    } else {
        $last_comments_format = "<a href='%url%' title='%date%' %popup%><b>%name%</b></a> (%title%): %comm%<br />";
    }
    if (isset($Weblogs[$Current_weblog]['lastcomm_length']) && $Weblogs[$Current_weblog]['lastcomm_length'] > 0) {
        $last_comments_length = $Weblogs[$Current_weblog]['lastcomm_length'];
    } else {
        $last_comments_length = 100;
    }
    if (isset($Weblogs[$Current_weblog]['lastcomm_trim']) && $Weblogs[$Current_weblog]['lastcomm_trim'] > 0) {
        $last_comments_trim = $Weblogs[$Current_weblog]['lastcomm_trim'];
    } else {
        $last_comments_trim = 16;
    }
    if (isset($Weblogs[$Current_weblog]['lastcomm_amount']) && $Weblogs[$Current_weblog]['lastcomm_amount'] > 0) {
        $last_comments_count = $Weblogs[$Current_weblog]['lastcomm_amount'];
    } else {
        $last_comments_count = 10;
    }
    if (file_exists($Paths['pivot_path'] . "db/ser_lastcomm.php")) {
        $file = array_reverse(load_serialize($Paths['pivot_path'] . "db/ser_lastcomm.php", true, true));
    } else {
        $file = array();
    }
    $cats = find_cats_in_weblog($Current_weblog);
    $output = "";
    $count = 0;
    if (count($file) > 0) {
        foreach ($file as $comment) {
            // if it's in a category that published n the frontpage, and the user is not blocked, we display it.
            if (count(array_intersect($comment['category'], $cats)) > 0 && !ip_check_block(trim($comment['ip'])) && $db->entry_exists($comment['code'])) {
                $id = safe_string($comment["name"], TRUE) . "-" . format_date($comment["date"], "%ye%%month%%day%%hour24%%minute%");
                $url = make_filelink($comment['code'], "", $id);
                $comment['name'] = trimtext(stripslashes($comment['name']), $last_comments_trim);
                $comment['title'] = trimtext(stripslashes($comment['title']), $last_comments_trim);
                // Commenting out mywordwrap since it currently breaks textile commands (and maybe more).
                // $comment['comment'] = mywordwrap($comment['comment'], 18, " ", 1);
                $comment['comment'] = comment_format($comment["comment"]);
                // Remove the [name:1] part in the 'last comments..
                $comment['comment'] = preg_replace("/\\[(.*):([0-9]+)\\]/iU", '', $comment['comment']);
                $comment['comment'] = trimtext(stripslashes($comment['comment']), $last_comments_length);
                // $comment['comment'] = unentify($comment['comment']);
                if ($Weblogs[$Current_weblog]['comment_pop'] == 1) {
                    $popup = sprintf("onclick=\"window.open('%s', 'popuplink', 'width=%s,height=%s,directories=no,location=no,scrollbars=yes,menubar=no,status=yes,toolbar=no,resizable=yes'); return false\"", $url, $Weblogs[$Current_weblog]['comment_width'], $Weblogs[$Current_weblog]['comment_height']);
                } else {
                    $popup = "";
                }
                $thisline = $last_comments_format;
                $thisline = str_replace("%name%", $comment['name'], $thisline);
                $thisline = str_replace("%date%", $comment['date'], $thisline);
                $thisline = str_replace("%title%", $comment['title'], $thisline);
                $thisline = str_replace("%url%", $url, $thisline);
                $thisline = str_replace("%popup%", $popup, $thisline);
                $thisline = str_replace("%comm%", $comment['comment'], $thisline);
                $thisline = format_date($comment["date"], $thisline);
                $output .= "\n" . $thisline;
                $count++;
                if ($count >= $last_comments_count) {
                    return $output;
                }
            }
        }
    }
    return $output;
}