<HTML>
<TITLE>Preview</TITLE>
<BODY>
<center>
<?PHP
require("./data/Default.tpl");

$cat_lines = @file("./data/category.db.php");
foreach($cat_lines as $single_line){
	$cat_arr = explode("|", $single_line);
    $cat[$cat_arr[0]] = $cat_arr[1];
    $cat_icon[$cat_arr[0]]=$cat_arr[2];
}

    if($manual_avatar != ""){ $avatar = $manual_avatar; }
    elseif( $select_avatar != "" and $select_avatar != "none" ){ $avatar = $select_avatar; }
    else{ $avatar = ""; }

	if($if_convert_new_lines	== "yes"){ $n_to_br		= TRUE; }
    if($if_use_html				== "yes"){ $use_html	= TRUE; }

	$full_story  = replace_news("add", $full_story, $n_to_br, $use_html);
	$short_story = replace_news("add", $short_story, $n_to_br, $use_html);
	$title 		 = replace_news("add", $title, TRUE, $use_html);

	if($member_db[4] != ""){
		if($member_db[7] != 1 and $member_db[5] != ""){ $author = "<a href=mailto:$member_db[5]>$member_db[4]</a>"; }
		else{ $author = "$member_db[4]"; }
	}else{
		if($member_db[7] != 1 and $member_db[5] != ""){ $author = "<a href=mailto:$member_db[5]>$member_db[2]</a>"; }
		else{ $author = "$member_db[2]"; }
	}

    $output = $template_active;
    $output = str_replace("{title}", $title, $output);
    $output = str_replace("{date}", date($config_timestamp_active, time()), $output);
    $output = str_replace("{author}", $author, $output);
    if($avatar != ""){$output = str_replace("{avatar}", "<img src=\"$avatar\" border=0>", $output); }
    else{ $output = str_replace("{avatar}", "", $output); }
    $output = str_replace("[link]","<a href=#>", $output);
    $output = str_replace("[/link]","</a>", $output);
    $output = str_replace("{comments-num}", countComments($id), $output);
    $output = str_replace("{short-story}", $short_story, $output);
    $output = str_replace("{full-story}", $full_story, $output);
    if($full_story){
    	$output = str_replace("[full-link]", "<a href=#>", $output); }
	else{
  		$output = preg_replace("'\[full-link\].*?\[/full-link\]'","", $output);
	}
    $output = str_replace("[/full-link]", "</a>", $output);
    $output = str_replace("[com-link]", "<a href=#>", $output);
    $output = str_replace("[/com-link]", "</a>", $output);

	$output = str_replace("{category}", $cat[$category], $output);
	$output = str_replace("{category-id}", $category, $output);
	if($cat_icon[$category] != ""){ $output = str_replace("{category-icon}", "<img border=0 src=\"".$cat_icon[$category]."\">", $output); }
	else{ $output = str_replace("{category-icon}", "", $output); }


				$output = str_replace("{author-name}", $member_db[2], $output);

                if($member_db[5] != ""){
	                $output = str_replace("[mail]","<a href=\"mailto:". $member_db[5] ."\">", $output);
	                $output = str_replace("[/mail]","</a>", $output);
				}else{
	                $output = str_replace("[mail]","", $output);
	                $output = str_replace("[/mail]","", $output);
                }
				$output = str_replace("{news-id}", "ID Unknown", $output);
				$output = str_replace("{archive-id}", $archive, $output);
				$output = str_replace("{php-self}", $PHP_SELF, $output);
				$output = str_replace("{cute-http-path}", $config_http_script_dir, $output);

    $output = replace_news("show", $output);



echo("<fieldset style=\"border-style:solid; border-width:1; border-color:black;\"><legend> <span style=\"font-size: 13px;\">Active News:</span> </legend>".$output."</fieldset>");


if($full_story){

    $output = $template_full;
    $output = str_replace("{title}", $title, $output);
    $output = str_replace("{date}", date($config_timestamp_active, time()), $output);
    $output = str_replace("{author}", $author, $output);
    if($avatar != ""){$output = str_replace("{avatar}", "<img src=\"$avatar\" border=0>", $output); }
    else{ $output = str_replace("{avatar}", "", $output); }
    $output = str_replace("[link]","<a href=#>", $output);
    $output = str_replace("[/link]","</a>", $output);
    $output = str_replace("{comments-num}", countComments($id), $output);
    $output = str_replace("{short-story}", $short_story, $output);
    $output = str_replace("{full-story}", $full_story, $output);
    if($full_story){
    	$output = str_replace("[full-link]", "<a href=#>", $output); }
	else{
  		$output = preg_replace("'\[full-link\].*?\[/full-link\]'","", $output);
	}
    $output = str_replace("[/full-link]", "</a>", $output);
    $output = str_replace("[com-link]", "<a href=#>", $output);
    $output = str_replace("[/com-link]", "</a>", $output);
	$output = str_replace("{category}", $cat[$category], $output);
	$output = str_replace("{category-id}", $category, $output);
	if($cat_icon[$category] != ""){ $output = str_replace("{category-icon}", "<img border=0 src=\"".$cat_icon[$category]."\">", $output); }
	else{ $output = str_replace("{category-icon}", "", $output); }


				$output = str_replace("{author-name}", $member_db[2], $output);

                if($member_db[5] != ""){
	                $output = str_replace("[mail]","<a href=\"mailto:". $member_db[5] ."\">", $output);
	                $output = str_replace("[/mail]","</a>", $output);
				}else{
	                $output = str_replace("[mail]","", $output);
	                $output = str_replace("[/mail]","", $output);
                }
				$output = str_replace("{news-id}", "ID Unknown", $output);
				$output = str_replace("{archive-id}", $archive, $output);
				$output = str_replace("{php-self}", $PHP_SELF, $output);
				$output = str_replace("{cute-http-path}", $config_http_script_dir, $output);

    $output = replace_news("show", $output);

echo("<br /><fieldset style=\"border-style:solid; border-width:1; border-color:black;\"><legend> <span style=\"font-size: 13px;\">Full Story:</span> </legend>".$output."</fieldset>");
}

?>
</center>
</BODY>
</HTML>