<?php
/*---------------------------------------------------+
| PHP-Fusion 6 Content Management System
+----------------------------------------------------+
| Copyright © 2002 - 2005 Nick Jones
| http://www.php-fusion.co.uk/
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
+----------------------------------------------------+
| Modified by PHP-Fusion SF Group
| Copyright © 2007 by SF
| http://www.rus-phpfusion.com/
+----------------------------------------------------*/
if (!defined("IN_FUSION")) { header("Location: ../index.php"); exit; }

if (file_exists(LOCALE.LOCALESET."dynamic_titles.php")) {
	include LOCALE.LOCALESET."dynamic_titles.php";
} else { include LOCALE."English/dynamic_titles.php"; }

function dynamic_title($column, $table, $compare1, $compare2, $begin, $alt) {
	global $db_prefix;
	if (!isnum($compare2)) { $compare2 = 0; }
	$result = dbquery("SELECT $column FROM ".$db_prefix."$table WHERE $compare1 = $compare2");
	if ($result) {
		$data = dbarray($result);
		$title = $begin.$data[$column];
	} else {
		$title = $alt;
	}
	return $title;
}

if(FUSION_SELF == "submit.php") {
	if($_GET['stype'] == "l") $title = $locale['DTM_059'];
	if($_GET['stype'] == "n") $title = $locale['DTM_060'];
	if($_GET['stype'] == "a") $title = $locale['DTM_061'];
} elseif(FUSION_SELF == "register.php") {
	$title = $locale['DTM_062'];
} elseif(FUSION_SELF == "search.php") {
	$title = $locale['DTM_063'];
} elseif(FUSION_SELF == "edit_profile.php") {
	$title = $locale['DTM_064'];
} elseif(FUSION_SELF == "members.php") {
	$title = $locale['DTM_065'];
} elseif(FUSION_SELF == "guestbook.php") {
	$title = $locale['DTM_068'];
} elseif(FUSION_SELF == "lostpassword.php") {
	$title = $locale['DTM_066'];
} elseif(FUSION_SELF == "contact.php") {
	$title = $locale['DTM_067'];
} elseif(FUSION_SELF == "post.php") {
	if($_GET['action'] == "newthread") {
		$title = dynamic_title("forum_name", "forums", "forum_id", $_GET['forum_id'], $locale['DTM_020'], $locale['DTM_021']);
	} elseif($_GET['action'] == "edit") {
		$title = dynamic_title("post_subject", "posts", "post_id", $_GET['post_id'], $locale['DTM_026'], $locale['DTM_027']);
	} elseif($_GET['action'] == "reply") {
		$title = dynamic_title("thread_subject", "threads", "thread_id", $_GET['thread_id'], $locale['DTM_032'], $locale['DTM_033']);
	}
} elseif(FUSION_SELF == "postify.php") {
	if($_GET['post'] == "new" && $_GET['error'] == 0) {
		$title = dynamic_title("forum_name", "forums", "forum_id", $_GET['forum_id'], $locale['DTM_022'], $locale['DTM_023']);
	} elseif($_GET['post'] == "new" && $_GET['error'] != 0) {
		$title = dynamic_title("forum_name", "forums", "forum_id", $_GET['forum_id'], $locale['DTM_024'], $locale['DTM_025']);
	} elseif($_GET['post'] == "edit" && $_GET['error'] == 0) {
		$title = dynamic_title("post_subject", "posts", "post_id", $_GET['post_id'], $locale['DTM_028'], $locale['DTM_029']);
	} elseif($_GET['post'] == "edit" && $_GET['error'] != 0) {
		$title = dynamic_title("post_subject", "posts", "post_id", $_GET['post_id'], $locale['DTM_030'], $locale['DTM_031']);
	} elseif($_GET['post'] == "reply" && $_GET['error'] == 0) {
		$title = dynamic_title("thread_subject", "threads", "thread_id", $_GET['thread_id'], $locale['DTM_034'], $locale['DTM_035']);
	} elseif($_GET['post'] == "reply" && $_GET['error'] != 0) {
		$title = dynamic_title("thread_subject", "threads", "thread_id", $_GET['thread_id'], $locale['DTM_036'], $locale['DTM_037']);
	}
} elseif(FUSION_SELF == "messages.php") {
	if(isset($msg_view)) {
		$title = dynamic_title("message_subject", "messages", "message_id", $msg_view, $locale['DTM_044'], $locale['DTM_045']);
	} elseif(isset($msg_reply)) {
		$title = dynamic_title("message_subject", "messages", "message_id", $msg_reply, $locale['DTM_046'], $locale['DTM_047']);
	} elseif(isset($_POST['reply_preview'])) {
		$title = dynamic_title("message_subject", "messages", "message_id", $msg_reply_preview, $locale['DTM_048'], $locale['DTM_049']);
	} elseif(isset($msg_send)) {
		$title = dynamic_title("user_name", "users", "user_id", $msg_send, $locale['DTM_050'], $locale['DTM_051']);
	} elseif(isset($_POST['send_preview'])) {
		$title = dynamic_title("user_name", "users", "user_id", $msg_to, $locale['DTM_052'], $locale['DTM_053']);
	} elseif(isset($folder)) {
		if($folder == "inbox") $title = $locale['DTM_040'];
		elseif($folder == "sentbox") $title = $locale['DTM_041'];
		elseif($folder == "savebox") $title = $locale['DTM_042'];
		elseif($folder == "options") $title = $locale['DTM_043'];
		else $title = $locale['DTM_028'];
	} else {
		$title = $locale['DTM_039'];
	}
} elseif(FUSION_SELF == "photogallery.php") {
	if(isset($album)) {
		$title = dynamic_title("album_title", "photo_albums", "album_id", $album, $locale['DTM_055'], $locale['DTM_056']);
	} elseif(isset($photo)) {
		$title = dynamic_title("photo_title", "photos", "photo_id", $photo, $locale['DTM_057'], $locale['DTM_058']);
	} else {
		$title = $locale['DTM_054'];
	}
} elseif(FUSION_SELF == "index.php") {
	if(BASEDIR.basename(dirname($_SERVER['PHP_SELF']))."/" == FORUM) $title = $locale['DTM_038'];
} else {
	@$page_array = array(
		array("news.php", "news_subject", "news", "news_id", $readmore, $locale['DTM_000'], $locale['DTM_001']),
		array("news_cats.php", "news_cat_name", "news_cats", "news_cat_id", $cat_id, $locale['DTM_002'], $locale['DTM_003']),
		array("articles.php", "article_cat_name", "article_cats", "article_cat_id", $cat_id, $locale['DTM_004'], $locale['DTM_005']),
		array("readarticle.php", "article_subject", "articles", "article_id", $article_id, $locale['DTM_006'], $locale['DTM_007']),
		array("downloads.php", "download_cat_name", "download_cats", "download_cat_id", $cat_id, $locale['DTM_008'], $locale['DTM_009']),
		array("faq.php", "faq_cat_name", "faq_cats", "faq_cat_id", $cat_id, $locale['DTM_010'], $locale['DTM_011']),
		array("profile.php", "user_name", "users", "user_id", $lookup, $locale['DTM_012'], $locale['DTM_013']),
		array("weblinks.php", "weblink_cat_name", "weblink_cats", "weblink_cat_id", $cat_id, $locale['DTM_014'], $locale['DTM_015']),
		array("viewforum.php", "forum_name", "forums", "forum_id", $forum_id, $locale['DTM_016'], $locale['DTM_017']),
		array("viewthread.php", "thread_subject", "threads", "thread_id", $thread_id, $locale['DTM_018'], $locale['DTM_019']),
		array("viewpage.php", "page_title", "custom_pages", "page_id", $page_id, "", "")
	);
	foreach($page_array as $value) {
		if($value[0] == FUSION_SELF && $value[4] > "") {
			$title = dynamic_title($value[1], $value[2], $value[3], $value[4], $value[5],$value[6]);
		} elseif($value[0] == FUSION_SELF) {
				$title = $value[6];
		}
	}
}

if(!empty($title)) $title = $title." - ";

?>