<?php
@chdir("../");
include_once("config.php");
$content = $_GET['content'];
$id = $_GET['id'];

$items = explode("|",$content);
$out = "";
foreach($items as $item)
{
	$item = trim($item);
	if (!$item) continue;
	if ($item == "lastblog")
	{
		require("class/lastblog.php");
		$out.="var lastblog = '".deal_content($lastblog_data)."';\n";
	}
	else if ($item == "lastremark")
	{
		require("class/lastremark.php");
		$out.="var lastremark = '".deal_content($lastRemark_data)."';\n";
	}
	else if ($item == "hotestblog")
	{
		require("class/hotestblog.php");
		$out.="var hotestblog = '".deal_content($hotestblog_data)."';\n";
	}
	else if ($item == "archive")
	{
		require("class/archive.php");
		$out.="var archive= '".deal_content($archive_data)."';\n";
	}
	else if ($item == "calendar")
	{
		require("class/calendar.php");
		$out.="var calendar = '".deal_content($calendar)."';\n";
	}
	else if ($item == "nextblog" && $id)
	{
		$blog = $DB->fetch_one_array("SELECT * FROM `".$mysql_prefix."blog` WHERE id>$id AND draft=0 ORDER BY id ASC LIMIT 1");
		if (is_array($blog))
		{
			$path = getHtmlPath($blog['id']);
			$path = ($makehtml) ? $path : "index.php?id=".$blog['id'];
			$out.="var nextblog = '".deal_content("<a href='{$blogurl}{$path}' title='".$blog['title']."' >".$blog['title']."</a>")."';\n";
		}
		else	$out.="var nextblog = '没有下一篇日志';\n";
	}
	else if ($item == "previousblog" && $id)
	{
		$blog = $DB->fetch_one_array("SELECT * FROM `".$mysql_prefix."blog` WHERE id<$id AND draft=0 ORDER BY id DESC LIMIT 1");
		if (is_array($blog))
		{
			$path = getHtmlPath($blog['id']);
			$path = ($makehtml) ? $path : "index.php?id=".$blog['id'];
			$out.="var previousblog = '".deal_content("<a href='{$blogurl}{$path}' title='".$blog['title']."' >".$blog['title']."</a>")."';\n";
		}
		else	$out.="var previousblog = '没有上一篇日志';\n";
	}
}
echo $out;

function deal_content($s)
{
	$s = addslashes($s);
	$s = str_replace(array("\r","\n"),"",$s);
	return $s;
}
?>