include ("config.inc.php");
$connection = @mysql_connect($dbhost, $dbuser, $dbpass)
or die ("Can not connect to database");
$db = @mysql_select_db($dbname, $connection)
or die ("Can not select database.");
// Select content
$sql = @mysql_query("SELECT cat_id, name, content, writer, date, hit, active FROM $t_contents WHERE id = '$cid'")
or die("Can not select content");
while ($row=mysql_fetch_array($sql)) {
$cat_id = $row["cat_id"];
$subject = stripslashes($row["name"]);
$content = stripslashes($row["content"]);
$writer = FindWriter($row["writer"]);
$date = date("j.m.Y", strtotime($row["date"]));
$hit = $row["hit"];
$active = $row["active"];
}
$new_hit = $hit+1;
$sql = @mysql_query("UPDATE $t_contents SET hit = '$new_hit' WHERE id = '$cid'")
or die("Can not select content");
@mysql_close($connection)
or die("Can not close connection");
// Variable for Top navigation bar
$page_name = "contents";
$page_code = $cid;
// Print header
echo PrintTheme("header");
// Select releated links
$rel_links = "
";
$rel_links .= "";
$i = 0;
$connection = @mysql_connect($dbhost, $dbuser, $dbpass)
or die ("Can not connect to database");
$db = @mysql_select_db($dbname, $connection)
or die ("Can not select database.");
$sql_rel = "SELECT co.id, co.name FROM $t_rel cr, $t_contents co WHERE content_id = '$cid' AND co.id=cr.releated_id AND co.active = '1' ORDER BY co.name";
$result_rel = mysql_query($sql_rel);
while (list($cr_id, $cr_subject) = mysql_fetch_row($result_rel)) {
$cr_subject = stripslashes($cr_subject);
$i++;
$rel_links .= "| :: ".Translator($cr_id, "content", $user_lang, "subject", $cr_subject)." | ";
if (is_int($i/3)) {
$rel_links .= "
";
}
}
$rel_links .= "
";
$rel_links .= "
";
// Print content page
$filename = "$theme_root/$user_theme/contents.htm";
$fd = fopen ($filename, "r");
$contents = fread ($fd, filesize ($filename));
fclose ($fd);
// Print content if content is active
if ($active == 1) {
$contents = eregi_replace ("images", "$theme_url/$user_theme/images", $contents);
$contents = eregi_replace ("---SUBJECT---", Translator($cid, "content", $user_lang, "subject", $subject), $contents);
$contents = eregi_replace ("---CONTENT---", Translator($cid, "content", $user_lang, "body", $content), $contents);
$contents = eregi_replace ("---DATE---", $date, $contents);
$contents = eregi_replace ("---WRITER---", $writer, $contents);
$contents = eregi_replace ("---HITS---", "".LANG_HITS.": ".$new_hit, $contents);
$contents = eregi_replace ("---BACKTOCAT---", SelectTopContentCat($cat_id)." >>", $contents);
$contents = eregi_replace ("---LANG_COMMENTS---", LANG_COMMENTS." ".LANG_ADD_COMMENT."", $contents);
if (($action == "addcomment") && (isset($HTTP_COOKIE_VARS["dcp5_member_id"]))) {
$contents .= "";
} else if (($action == "write") && (isset($HTTP_COOKIE_VARS["dcp5_member_id"]))) {
$result = mysql_query("INSERT INTO $t_comments VALUES ('', '$cid', '".$HTTP_COOKIE_VARS["dcp5_member_id"]."', '".htmlspecialchars($comment)."', now(), '1')");
$contents .= LANG_COMMENT_ADDED;
}
$contents = eregi_replace ("---COMMENTS---", ContentComments($cid), $contents);
if ($i > 0) {
$contents = eregi_replace ("---LANG_RELLINKS---", LANG_RELLINKS, $contents);
$contents = eregi_replace ("---RELLINKS---", $rel_links, $contents);
} else {
$contents = eregi_replace ("---LANG_RELLINKS---", "", $contents);
$contents = eregi_replace ("---RELLINKS---", "", $contents);
}
// Print error if content is not active
} else {
$contents = eregi_replace ("images", "$theme_url/$user_theme/images", $contents);
$contents = eregi_replace ("---SUBJECT---", LANG_UNACTIVECONTENT, $contents);
$contents = eregi_replace ("---CONTENT---", LANG_UNACTIVECONTENTERR, $contents);
$contents = eregi_replace ("---DATE---", "", $contents);
$contents = eregi_replace ("---WRITER---", "", $contents);
$contents = eregi_replace ("---HITS---", "", $contents);
$contents = eregi_replace ("---BACKTOCAT---", SelectTopContentCat($cat_id)." >>", $contents);
$contents = eregi_replace ("---LANG_RELLINKS---", "", $contents);
$contents = eregi_replace ("---RELLINKS---", "", $contents);
}
echo $contents;
@mysql_close($connection);
echo PrintTheme("footer");
?>