function start_b2()
{
    global $row, $id, $postdata, $authordata, $day, $preview, $page, $pages, $multipage, $more, $numpages;
    global $preview_userid, $preview_date, $preview_content, $preview_title, $preview_category, $preview_notify, $preview_make_clickable, $preview_autobr;
    global $pagenow;
    global $HTTP_GET_VARS;
    if (!$preview) {
        $id = $row->ID;
        $postdata = get_postdata2($id);
    } else {
        $id = 0;
        $postdata = array('ID' => 0, 'Author_ID' => $HTTP_GET_VARS['preview_userid'], 'Date' => $HTTP_GET_VARS['preview_date'], 'Content' => $HTTP_GET_VARS['preview_content'], 'Title' => $HTTP_GET_VARS['preview_title'], 'Category' => $HTTP_GET_VARS['preview_category'], 'Notify' => 1, 'Clickable' => 1, 'Karma' => 0);
        if (!empty($HTTP_GET_VARS['preview_autobr'])) {
            $postdata['Content'] = autobrize($postdata['Content']);
        }
    }
    $authordata = get_userdata($postdata['Author_ID']);
    $day = mysql2date('d.m.y', $postdata['Date']);
    $currentmonth = mysql2date('m', $postdata['Date']);
    $numpages = 1;
    if (!$page) {
        $page = 1;
    }
    if (isset($p)) {
        $more = 1;
    }
    $content = $postdata['Content'];
    if (preg_match('/<!--nextpage-->/', $postdata['Content'])) {
        if ($page > 1) {
            $more = 1;
        }
        $multipage = 1;
        $content = stripslashes($postdata['Content']);
        $content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content);
        $content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content);
        $content = str_replace("<!--nextpage-->\n", '<!--nextpage-->', $content);
        $pages = explode('<!--nextpage-->', $content);
        $numpages = count($pages);
    } else {
        $pages[0] = stripslashes($postdata['Content']);
        $multipage = 0;
    }
    return true;
}
示例#2
0
function rss_update($blog_ID, $num_posts = "", $file = "./b2rss.xml")
{
    global $use_rss, $b2_version, $querystring_start, $querystring_equal, $querystring_separator;
    global $admin_email, $blogname, $siteurl, $blogfilename, $blogdescription, $posts_per_rss, $rss_language;
    global $tableposts, $postdata, $row;
    if ($rss_language == '') {
        $rss_language = 'en';
    }
    if ($use_rss) {
        $num_posts = $num_posts == "" ? $posts_per_rss : 5;
        $date_now = gmdate("D, d M Y H:i:s") . " GMT";
        # let's build the rss file
        $rss = '';
        $rss .= '<?xml version="1.0"?' . ">\n";
        $rss .= "<!-- generator=\"b2/{$b2_version}\" -->\n";
        $rss .= "<rss version=\"0.92\">\n";
        $rss .= "\t<channel>\n";
        $rss .= "\t\t<title>" . convert_chars(strip_tags(get_bloginfo("name")), "unicode") . "</title>\n";
        $rss .= "\t\t<link>" . convert_chars(strip_tags(get_bloginfo("url")), "unicode") . "</link>\n";
        $rss .= "\t\t<description>" . convert_chars(strip_tags(get_bloginfo("description")), "unicode") . "</description>\n";
        $rss .= "\t\t<lastBuildDate>{$date_now}</lastBuildDate>\n";
        $rss .= "\t\t<docs>http://backend.userland.com/rss092</docs>\n";
        $rss .= "\t\t<managingEditor>{$admin_email}</managingEditor>\n";
        $rss .= "\t\t<webMaster>{$admin_email}</webMaster>\n";
        $rss .= "\t\t<language>{$rss_language}</language>\n";
        $now = date('Y-m-d H:i:s', time() + $time_difference * 3600);
        $sql = "SELECT * FROM {$tableposts} WHERE post_date <= '{$now}' AND post_category > 0 ORDER BY post_date DESC LIMIT {$num_posts}";
        $result = mysql_query($sql) or die("Your SQL query: <br />{$sql}<br /><br />MySQL said:<br />" . mysql_error());
        while ($row = mysql_fetch_object($result)) {
            $id = $row->ID;
            $postdata = get_postdata2($id);
            $rss .= "\t\t<item>\n";
            $rss .= "\t\t\t<title>" . convert_chars(strip_tags(get_the_title()), "unicode") . "</title>\n";
            //		we could add some specific RSS here, but not yet. uncomment if you wish, it's functionnal
            //			$rss .= "\t\t\t<category>".convert_chars(strip_tags(get_the_category()),"unicode")."</category>\n";
            $content = stripslashes($row->post_content);
            $content = explode("<!--more-->", $content);
            $content = $content[0];
            $rss .= "\t\t\t<description>" . convert_chars(make_url_footnote($content), "unicode") . "</description>\n";
            $rss .= "\t\t\t<link>" . htmlentities("{$siteurl}/{$blogfilename}" . $querystring_start . 'p' . $querystring_equal . $row->ID . $querystring_separator . 'c' . $querystring_equal . '1') . "</link>\n";
            $rss .= "\t\t</item>\n";
        }
        $rss .= "\t</channel>\n";
        $rss .= "</rss>";
        $f = @fopen("{$file}", "w+");
        if ($f) {
            @fwrite($f, $rss);
            @fclose($f);
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}