<?php
/*
全局变量及函数
*/

require "data.inc.php";
function gettemplate($template,$endung="htm") {
        global $templatefolder;
        if(!$templatefolder) $templatefolder = "templates";
        return str_replace("\"","\\\"",implode("",file($templatefolder."/".$template.".".$endung)));
}
function dooutput($template) {
        global $bgcolor, $tablebg, $tableb, $tablec, $tabled, $tablea, $font, $fontcolor, $fontcolorsec, $fontcolorthi, $fontcolorfour, $bgfixed, $bgimage;
		$bgcolor = "#ffffff";

        $template = str_replace("{pagebgcolor}","$bgcolor",$template);
        $template = str_replace("{tablebordercolor}","$tablebg",$template);
        $template = str_replace("{tablea}","$tablea",$template);
        $template = str_replace("{tableb}","$tableb",$template);
        $template = str_replace("{tablec}","$tablec",$template);
        $template = str_replace("{tabled}","$tabled",$template);
        $template = str_replace("{font}","$font",$template);
        $template = str_replace("{fontcolorfirst}","$fontcolor",$template);
        $template = str_replace("{fontcolorsecond}","$fontcolorsec",$template);
        $template = str_replace("{fontcolorthird}","$fontcolorthi",$template);
        $template = str_replace("{fontcolorfourth}","$fontcolorfour",$template);
        if($bgimage) $hgpicture = " background=\"$bgimage\"";
        $template = str_replace("{hgpicture}","$hgpicture",$template);
        if($bgfixed) $template = str_replace("{bgproperties}"," bgproperties=fixed",$template);
        else $template = str_replace("{bgproperties}","",$template);

        echo $template;
}

function writetofile() {  
global $i,$nname,$email,$name,$title1;
			$file=file("./photo.txt");
			$intt=sizeof($file);
			$f = fopen("./photo.txt","r+");
			$msg = fread($f,filesize("./photo.txt")) ;//读出原有数据
			fclose($f);
if (strlen($title1)<1){$title1="无题";}
			$date1="d".$i; 
			$date2=$$date1;
			$photofile=$nname; 

			$f = fopen("./photo.txt","r+");

			$tx=$file[0]+1;
			$t = date(Y年m月d日H时);
			$line1=$name."||".$email."||".$photofile."||".$home."||".$date2."||".$title1."||".$t."\n";
				fputs($f,$tx."\n");
				fputs($f,$line1);//写入新数据
				fputs($f,$msg);//写入原有数据
				fclose($f);
}


$nowdate = date("Y年m月d日",time());
eval("\$header = \"".gettemplate("header")."\";");
eval("\$footer = \"".gettemplate("footer")."\";");


?>

