【php开源代码栏目提醒】:本文主要为网学会员提供template.php,希望对需要template.php网友有所帮助,学习一下!
<?php
if(!defined('ROOT') || !isset($php_self) || !preg_match("/[\/\\\\]admincp\.php$/", $php_self)) {
exit('Access Denied');
}
//鏉冮檺妫鏌?
permission();
if(!$action) {
$action = 'mod';
}
//璇诲彇妯℃澘濂楃郴(鐩綍)
$template_dir = '../';
$file ="index.html";
if($_GET['file']=="1"){
$file="css/root.css";
}else{
$file="index.html";
}
//淇濆瓨鏂囦欢
if($action == 'savefile'){
$filepath = $template_dir.'/'.$file;
if (file_exists($filepath)) {
$content = $_POST['content'];
$fp = @fopen($filepath,'wb');
@fwrite($fp,$content);
@fclose($fp);
redirect('妯℃澘淇敼鎴愬姛', 'admincp.php?go=template');
}
}
//淇敼妯℃澘鏂囦欢
if($action == 'mod'){
$filepath = $template_dir.'/'.$file;
if (file_exists($filepath)) {
$writeable = false;
if(is_writeable($filepath)) {
$writeable = true;
}
$fp = @fopen($filepath,'r');
$contents = @fread($fp, filesize($filepath));
@fclose($fp);
$contents = htmlspecialchars($contents);
}
$subnav = '缂栬緫妯℃澘';
}
$navlink_L = ' » <a href="admincp.php?go=template">妯℃澘绠$悊</a>'.($subnav ? ' » '.$subnav : '');
$smarty->assign("navlink_L", $navlink_L);
$smarty->assign("action", $action);
$smarty->assign("writeable", $writeable);
$smarty->assign("contents", $contents);
$smarty->display("header.dll");
$smarty->display("template.dll");
?>