Location: PHPKode > scripts > Linker IMG > linker-img/manage/template.php
<?php

//=====================================
// LINKER Category Engine
//=====================================
// Filename : template.php
// Path  : Manage directory
// last update : 2002/03/13
// Desc : Edit template
//=====================================


//=====================================
// File include part & DB Layer
//=====================================

include ("./authen.php");
include ("../function/main_func.php"); 
include ("../$Slang/m_common.php"); 

//=====================================
// View template select form parts
//=====================================


if (!$switch) {


if ($fname) $content = implode("",file("../$Stemplate/$fname",r));
$content = htmlspecialchars($content);


//===========================
// Read Filelist
//===========================

$handle=opendir("../$Stemplate");
while ($file = readdir($handle)) {
	if (is_file("../$Stemplate/$file")) {
		if ($fname == $file) 
		$file_list .= "<option selected>$file</option>\n";
		else
		$file_list .= "<option>$file</option>\n";
		}
}
closedir($handle); 


//=====================================
// Print form
//=====================================

print <<<EOF
<html>
<head>
<LINK rel='stylesheet' type='text/css' href='./linker.css'>
<meta http-equiv='Content-Type' content='text/html; charset=$Scharset'>
</head>
<body bgcolor="#E9E9E9" text='black' link='blue' vlink='purple' alink='red'>
<form action="template.php" method=post>

<table border=0 cellpadding=0 cellspacing=1>
<tr>
<td>

	<table width="100%" border="1"><tr><td bgcolor="#000066" align="center">
	<b><font color="white" size="2">$l_edit_tem</font></b>
	</td></tr></table>

</td>	</tr>

<tr><td width=500>&nbsp;</td></tr>

<tr>
<td bgcolor='#E0E0E0' align=right><font size=2><select name="fname">
<option value='' selected>$l_sel_file1</option>
$file_list </select></font><input type='submit' value='$l_sel_file2' class=cinput></td>
</tr>

<tr>
</form><form action='template.php' method='post'>
<td align='center' height='24' bgcolor='#E0E0E0'>
<font size='2'>
<textarea rows='20' cols='50' name='content' style='width:500px'>$content</textarea><br>
<input type='hidden' name='file_name' value='$fname'>
<input type='hidden' name='switch' value='edit'>

<input type='submit' value='$l_edit_tem' class=cinput>
</font>
</td></form>
    </tr>
</table>
</body>

EOF;
exit;

}

//=====================================
// Edit and Print template result
//=====================================

elseif ($switch=="edit") {

if (!$content) errmsg($l_error_notem);
if (!$file_name) errmsg($l_error_nofname);


$content = stripslashes(trim($content));
$fd = fopen("../$Stemplate/$file_name",w);
fputs($fd,$content);

print <<<EOF
<html>
<head>
<LINK rel='stylesheet' type='text/css' href='./linker.css'>
<meta http-equiv='Content-Type' content='text/html; charset=$Scharset'>
</head>

<body bgcolor="#E9E9E9">
<table width="500" border="1"><tr><td bgcolor="#000066" align="center">
<b><font color="white" size="2">$file_name $l_tem_result</font></b>
</td></tr></table>

</body></html>
EOF;

}
?>
Return current item: Linker IMG