include("wc/_common.php");
include("_template_renderer.php");
$qs = ""; if (isset($_SERVER['QUERY_STRING'])) $qs = trim($_SERVER['QUERY_STRING']);
$content_id = trim(req("id"));
if (!$content_id && $qs) $content_id = trim($qs);
$r =$db->getrst("select * from ".$content_table_name."_pages where `alias`='".addslashes($content_id)."' or id=".num($content_id));
$content_id = num(@$r->id);
if (!$content_id) {
$r->close();
if ($current_menu)
$qs = $db->scalar("select `startpage` from ".$content_table_name."_views where `title`='".addslashes($current_menu)."'");
else
$qs = get_setting("home_page");
$content_id = 0;
for( $i = strlen($qs)-1; $i>0; $i--) {
$c = substr($qs, $i, 1);
if ($c>='0' && $c<='9') $content_id = num(substr($qs, $i));
else break;
}
if ($content_id==0 && strlen($qs)>0) redirect(str_replace("[[root_rel]]", $site_http_path, $qs));
$r = $db->getrst("select * from ".$content_table_name."_pages where `alias`='".addslashes($content_id)."' or id=".num($content_id));
}
$content_options = "";
if ($r->eof()) {
$content_id = 0;
$content_print = 0;
$content_title = "";
$content_data = "Извините, запрошенный файл или страница не найден(а).
We are sorry, the requested page as not been found.";
$content_description = $content_data;
$content_keywords = $content_data;
$content_mime = "text/html";
$content_length = strlen($content_data);
$content_extras = "";
}
else {
$content_id = $r->id;
$content_print = 0;
if ($r->fields["options"]) $content_print = (!(strpos($r->fields["options"],"[print]")===false));
$content_title = trim($r->fields["title"]);
$content_description = trim($r->fields["description"]);
$content_keywords = trim($r->fields["keywords"]);
$content_data = $r->fields["content"];
$content_mime = "text/html";
$content_length = num($r->fields["length"]);
$content_extras = trim($r->fields["extras"]);
$content_options = trim($r->fields["options"]);
$content_date = trim($r->fields["modified_at"]);
$content_data = render_html_page($content_id, $content_data);
}
if (!$content_mime) $content_mime=="text/html";
$r->close(); unset($r);
headers_out(); echo render_template("print.tmpl");
$db->close(); unset($db);
?>