<?php
define('THIS_SCRIPT', 'template_maintance');
require 'global.php';
require INC_PATH.'XML2PHPArray.class.php';
require INC_PATH.'filehandle.misc.php';
require INC_PATH.'FileHandler.class.php';
require INC_PATH.'gzdecode.function.php';

checklogin();

header("content-Type: text/html; charset=".$charset);
$lang = load_lang($lang, THIS_SCRIPT);

$action = strtolower(trim($action));
$do_result = array();
if ('do_dump' === $action) {
	$do_result = dumpTemplate($styleid, array('xml_encoding' => 'utf-8', 'dump_file_client' => $_POST['dump_file_client'], 'dump_file_server' => $_POST['dump_file_server'], 'dump_options' => $_POST['dump_options']));
	if (!empty($_POST['dump_file_client']) AND (1 == $do_result['execflag'])) {
		exit;
	}
} elseif ('read_dump' === $action) {
	$do_result = readDump(array('read_from_client' => $_FILES['read_from_client']['tmp_name'], 'read_from_server' => $_POST['read_from_server'], 'isovercast' => $_POST['isovercast']));
} else {
}

head();
if ( strpos($sysinfo['flag'],'21') === false ){
	show_msg($lang['readme_tit'],$lang['error.str1'],0,'','','','');
	exit;
}
readme($lang['tpl.pagetitle'],$lang['page_readme'],$lang['nav']);
if (!empty($do_result)) {
	show_msg($lang['tpl.dump.msgtitle'], $do_result['execmsg'], $do_result['execflag']);
	footer();
	exit;
}
require printout('template_maintance');
footer();


function &getTemplateList()
{
	global $dv, $db;
	return $db->getResultSet("SELECT styleid, name, ename, stype, tpl_type FROM {$dv}styles WHERE stype='0'");
}
function simpleMapPath($path)
{
	global $_SERVER;
	if (empty($path)) {
		return false;
	}
	$path = preg_replace('#(?:\\+)|(?:/+)#i', '/', $path);
	if ($path{0} === '/') {
		$documentroot = realpath(str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']));
		return $documentroot.$path;
	} elseif(substr($path, 0, 3) === '../') {
		return $path;
	} else {
		return ROOT_PATH.$path;
	}
}
function dumpTemplate($styleid = 0, $opts = array())
{
	global $lang, $dv, $db;
	$wherestmt = '';
	if (is_array($styleid)) {
		$styleidlist = implode(',', $styleid);
		if (!checkIDList($styleidlist)) {
			return array('execflag' => 0, 'execmsg' => $lang['tpl.dump.error1']);
		}
		$wherestmt = ' styleid IN({$styleidlist}) AND ';
	} elseif (is_numeric($styleid)) {
		if ($styleid > 0) {
			$wherestmt = " styleid='{$styleid}' AND ";
		}
	} else {
		return array('execflag' => 0, 'execmsg' => $lang['tpl.dump.error1']);
	}

	if (empty($opts['dump_file_client']) AND empty($opts['dump_file_server'])) {
		return array('execflag' => 0, 'execmsg' => $lang['tpl.dump.error3']);
	}

	if ($query = $db->query("SELECT styleid,name,ename,content,directory,copyright,stype,tpl_type,parentid,charset FROM {$dv}styles WHERE {$wherestmt} stype='0'")) {
		if ($db->num_rows($query) > 0) {
		//Start 选项参数初始化
			//Start dump file setting
			{
				if (!empty($opts['dump_file_client'])) {
				//Start dump file header setting
					header('Content-Type:unknow/unknow');
					header("Content-Disposition:attachment;filename={$opts['dump_file_client']}");
					header('Cache-Control: must-revalidate, post-check=0, pre-check=0');// HTTP/1.1
					header("Cache-Control: no-store, no-cache, must-revalidate");
					header("Cache-Control: post-check=0, pre-check=0", false);
				//End dump file header setting
				} else {
					$dumpfileserver = $opts['dump_file_server'];
					if (!touch($dumpfileserver) OR !chmod($dumpfileserver, 0777)) {
						return array('execflag' => 0, 'execmsg' => $lang['tpl.dump.error4']);
					}
				}
			}
			//End dump file setting
			if (!isset($opts['xml_version'])) {
				$opts['xml_version'] = '1.0';
			}
			if (!isset($opts['xml_encoding'])) {
				$opts['xml_encoding'] = 'utf-8';
			}
			$opts['dump_identify'] = array('version' => '2.0.0', 'copyright' => 'Powered By Dvbbs.php Version 2.0.0.Copyright (c) 2001-2005 AspSky.Net. All Rights Reserved.', 'description' => '');
			if (isset($opts['dump_description'])) {
				$opts['dump_identify']['description'] = $opts['dump_description'];
			}
			if (!isset($opts['dump_description'])) {
				$opts['dump_description'] = '';
			}
			if (!isset($opts['usegzencode'])) {
				$opts['usegzencode'] = true;
			}
			if (!isset($opts['dump_options'])) {
				$opts['dump_options'] = 3;
			}
			$dumpstylecss = (1 == (1 & $opts['dump_options']) ? true : false);
			$dumplanguage = (2 == (2 & $opts['dump_options']) ? true : false);
		//End 选项参数初始化
		//Start 压缩设置
			$decodemethod = 'base64_decode';
			$enablegzencode = false;
			if ((true === $opts['usegzencode']) AND function_exists('gzencode')) {
				$enablegzencode = true;
				$decodemethod .= ',gzdecode';
			}
		//End 压缩设置
			$dumpbuffer = "<?xml version=\"{$opts['xml_version']}\" encoding=\"{$opts['xml_encoding']}\"?>\r\n<Dv_Templates identify=\"".base64_encode(serialize($opts['dump_identify']))."\" decodemethod=\"{$decodemethod}\">";
			while ($rstpl = $db->fetch_array($query)) {
				$dumpbuffer .= "\r\n\t<template styleid=\"{$rstpl['styleid']}\" name=\"".urlencode($rstpl['name'])."\" ename=\"".urlencode($rstpl['ename'])."\" directory=\"".urlencode($rstpl['directory'])."\" copyright=\"".urlencode($rstpl['copyright'])."\" stype=\"".urlencode($rstpl['stype'])."\" tpl_type=\"".urlencode($rstpl['tpl_type'])."\" parentid=\"".urlencode($rstpl['parentid'])."\" charset=\"".urlencode($rstpl['charset'])."\">";
				if (false !== ($content = unserialize(base64_decode($rstpl['content'])))) {
					foreach ($content AS $tplname => $tpldesc) {
						if (1 == intval($rstpl['tpl_type'])) {
							$tplfile = simpleMapPath($rstpl['directory'].'/'.$rstpl['ename'].'.'.$tplname.'.tpl.php');
						} else {
							$tplfile = simpleMapPath($rstpl['directory'].'/'.$rstpl['ename'].'/'.$tplname.'.tpl.php');
						}
						if (true === $enablegzencode) {
							$tplfilecontents = base64_encode(gzencode(FileHandler::file_get_contents($tplfile)));
						} else {
							$tplfilecontents = base64_encode(FileHandler::file_get_contents($tplfile));
						}
						$dumpbuffer .= "\r\n\t\t<tplfile tplname=\"".urlencode($tplname)."\" description=\"".urlencode($tpldesc)."\"><![CDATA[{$tplfilecontents}]]></tplfile>";
					}
				} else {
					$dumpbuffer .= "\r\n\t\t<tplfile></tplfile>";
				}
			//Start 输出语言包
				$languagebuffer = "\r\n\t\t<language></language>";
				if (true === $dumplanguage) {
					if ($querylang = $db->query("SELECT styleid,name,ename,content,directory,copyright,stype,tpl_type,parentid, charset FROM {$dv}styles WHERE stype='1' AND parentid='{$rstpl['styleid']}'")) {
						if ($db->num_rows($querylang) > 0) {
							while ($rslang = $db->fetch_array($querylang)) {
								$dumpbuffer .= "\r\n\t\t<language styleid=\"{$rslang['styleid']}\" name=\"".urlencode($rslang['name'])."\" ename=\"".urlencode($rslang['ename'])."\" directory=\"".urlencode($rslang['directory'])."\" copyright=\"".urlencode($rslang['copyright'])."\" stype=\"".urlencode($rslang['stype'])."\" tpl_type=\"".urlencode($rstpl['tpl_type'])."\" parentid=\"".urlencode($rslang['parentid'])."\" charset=\"".urlencode($rslang['charset'])."\">";
								if (false !== ($content = unserialize(base64_decode($rslang['content'])))) {
									foreach ($content AS $tplname => $tpldesc) {
										$langfile = simpleMapPath($rslang['directory'].'/'.$rslang['ename'].'/'.$tplname.'.lang.php');
										if (true === $enablegzencode) {
											$langfilecontents = base64_encode(gzencode(FileHandler::file_get_contents($langfile)));
										} else {
											$langfilecontents = base64_encode(FileHandler::file_get_contents($langfile));
										}
										$dumpbuffer .= "\r\n\t\t\t<tplfile tplname=\"".urlencode($tplname)."\" description=\"".urlencode($tpldesc)."\"><![CDATA[{$langfilecontents}]]></tplfile>";
									}
								} else {
								}
								$dumpbuffer .= "\r\n\t\t</language>";
							}
						}
					}
				}
				$dumpbuffer .= $languagebuffer;
			//End 输出语言包
			//Start 输出CSS样式
				$stylecssbuffer = "\r\n\t\t<stylecss></stylecss>";
				if (true === $dumpstylecss) {
					if ($querystylecss = $db->query("SELECT styleid,name,ename,content,directory,copyright,stype,tpl_type,parentid, charset FROM {$dv}styles WHERE stype='2' AND parentid='{$rstpl['styleid']}'")) {
						if ($db->num_rows($querystylecss) > 0) {
							while ($rsstylecss = $db->fetch_array($querystylecss)) {
								$dumpbuffer .= "\r\n\t\t<stylecss styleid=\"{$rsstylecss['styleid']}\" name=\"".urlencode($rsstylecss['name'])."\" ename=\"".urlencode($rsstylecss['ename'])."\" directory=\"".urlencode($rsstylecss['directory'])."\" copyright=\"".urlencode($rsstylecss['copyright'])."\" stype=\"".urlencode($rsstylecss['stype'])."\" tpl_type=\"".urlencode($rstpl['tpl_type'])."\" parentid=\"".urlencode($rsstylecss['parentid'])."\" charset=\"".urlencode($rsstylecss['charset'])."\">";
								if (true === $enablegzencode) {
									$content = base64_encode(gzencode($rsstylecss['content']));
								} else {
									$content = base64_encode($rsstylecss['content']);
								}
								$dumpbuffer .= "<content>{$content}</content>\r\n\t\t</stylecss>";
							}
						}
					}
				}
				$dumpbuffer .= $stylecssbuffer;
			//End 输出CSS样式
				$dumpbuffer .= "\r\n\t</template>\r\n\t<template></template>";
			}
			$dumpbuffer .= "\r\n</Dv_Templates>";
			if (!empty($dumpfileserver) AND is_file($dumpfileserver)) {
				if (false !== FileHandler::file_put_contents($dumpfileserver, $dumpbuffer)) {
					@chmod($dumpfileserver, 0777);
					return array('execflag' => 1, 'execmsg' => str_replace('{$TPL_filename}', $dumpfileserver, $lang['tpl.dump.str1']));
				} else {
					return array('execflag' => 0, 'execmsg' => $lang['tpl.dump.error4']);
				}
			} else {
				print $dumpbuffer;
				return array('execflag' => 1, 'execmsg' => $lang['tpl.dump.str2']);
			}
		} else {
			return array('execflag' => 0, 'execmsg' => $lang['tpl.dump.error2']);
		}
	}
	return array('execflag' => 0, 'execmsg' => $lang['tpl.dump.error5']);
}

function _tpldirProcess(&$tplinfo,$isovercast)//风格模板/语言包目录处理函数
{
	global $lang, $dv, $db;
	static $issafemode = null;
	if (null === $issafemode) {
		$issafemode = @ini_get('safe_mode') ? true : false;
	}
	
	if (2 != intval($tplinfo['stype'])) {
		if (1 == $tplinfo['tpl_type']) {
			$destdir = simpleMapPath($tplinfo['directory'].'/');
		} else {
			$destdir = simpleMapPath($tplinfo['directory'].'/'.$tplinfo['ename']);
		}
	} else {
		$destdir = simpleMapPath($tplinfo['directory']);
	}

	if (is_dir($destdir)) {
		if (true === $isovercast) {//覆盖模板，删除该目录下的所有文件和目录，并保留该目录
			$v = FileHandler::recursion_removedir($destdir, 1);
			if ((false === $v) OR ($v['subfilecount'] != $v['subfileremovednum'])) {
				return array('execflag' => 0, 'execmsg' => str_replace('{$TPL_destdir}', $destdir, $lang['tpl.import.error9']));
			}
		} else {
			$ename = trim($db->scalar("SELECT MAX(ename) FROM {$dv}styles WHERE ename REGEXP '^".$db->escape_string($tplinfo['ename'])."_[0-9]+$'"));
			if ('' === $ename) {
				$newnum = 1;
			} else {
				list(, $newnum) = explode('_', $ename);
				$newnum = intval($newnum) + 1;
			}
			$newename = "{$tplinfo['ename']}_$newnum";
			if ($tplinfo['ename'] == $tplinfo['name']) {
				$tplinfo['name'] = $newename;
			}
			$tplinfo['oldename'] = $tplinfo['ename'];
			$tplinfo['ename'] = $newename;
			if (0 == intval($tplinfo['tpl_type']) AND 2 != intval($tplinfo['stype'])) {
				$destdir = simpleMapPath($tplinfo['directory'].'/'.$tplinfo['ename']);
			}
			if (2 == intval($tplinfo['stype'])) {
				if (!empty($tplinfo['parentref']['oldename']) AND false !== strpos($tplinfo['directory'], $tplinfo['parentref']['oldename'].'/')) {
					$tplinfo['directory'] = str_replace($tplinfo['parentref']['oldename'].'/', $tplinfo['parentref']['ename'].'/', $tplinfo['directory']);
					$destdir = simpleMapPath($tplinfo['directory']);
				}
			}
		}
	}

	if (!is_dir($destdir)) {
		if (true === $issafemode) {
			return array('execflag' => 0, 'execmsg' => str_replace('{$TPL_mkdir}', $destdir, $lang['tpl.import.error5']));
		} elseif (!mkdir($destdir, 0777)) {
			return array('execflag' => 0, 'execmsg' => str_replace('{$TPL_mkdir}', $destdir, $lang['tpl.import.error6']));
		}
	}

	if (!FileHandler::_dir_is_writable($destdir)) {
		return array('execflag' => 0, 'execmsg' => str_replace('{$TPL_mkdir}', $destdir, $lang['tpl.import.error7']));
	}
	return array('execflag' => 1, 'directory' => $destdir);
}
function _tpl_attributes_filter(&$attributes)
{
	if (!empty($attributes)) {
		foreach ($attributes AS $key => $val) {
			$attributes[$key] = urldecode($val);
		}//end foreach
	}
}//end function _tpl_attributes_filter
function readDump($opts = array())
{
	global $lang, $dv, $db;

	$datafile = '';
	if (!empty($opts['read_from_client'])) {
		$datafile = $opts['read_from_client'];
		if (!FileHandler::is_uploaded_file(str_replace('\\\\', '\\', $datafile))) {
			return array('execflag' => 0, 'execmsg' => $lang['tpl.import.error2']);
		}
	} elseif (!empty($opts['read_from_server'])) {
		$datafile = $opts['read_from_server'];
		if (!is_file($datafile) OR !is_readable($datafile)) {
			return array('execflag' => 0, 'execmsg' => $lang['tpl.import.error3']);
		}
	} else {
		return array('execflag' => 0, 'execmsg' => $lang['tpl.import.error1']);
	}

	if (!isset($opts['isovercast']) OR (0 >= $opts['isovercast'])) {
		$opts['isovercast'] = false;
	} else {
		$opts['isovercast'] = true;
	}
	$isovercast = $opts['isovercast'];

	$xmlObj =& new XML2PHPArray();
	$xmlObj->registerAttributesFilter('_tpl_attributes_filter');
	$xmlObj->parse_file($datafile, '');
	$tplcache =& $xmlObj->phparray;

	if (empty($tplcache)) {
		return array('execflag' => 0, 'execmsg' => $lang['tpl.import.error4']);
	}

	$identify = unserialize(base64_decode($tplcache['identify']));
	if (!$identify) {
		return array('execflag' => 0, 'execmsg' => $lang['tpl.import.error10']);
	}
	if ($identify['version'] > '2.0.0') {
		return array('execflag' => 0, 'execmsg' => $lang['tpl.import.error11']);
	}

	if (!empty($tplcache['decodemethod'])) {
		$decodemethod = explode(',', $tplcache['decodemethod']);
	}
	if (is_array($decodemethod)) {
		foreach ($decodemethod AS $method) {
			if (!function_exists($method)) {
				return array('execflag' => 0, 'execmsg' => $lang['tpl.import.error15']);
			}
		}
	} else {
		return array('execflag' => 0, 'execmsg' => $lang['tpl.import.error16']);
	}

	$arrayexecsql = array();
	if (true !== $isovercast) {
		$tplparentid = $db->scalar("SELECT MAX(styleid) FROM {$dv}styles");
		if (!is_numeric($tplparentid)) {
			$tplparentid = 1;
		}
	}

	foreach ($tplcache['template'] AS $rstpl) {
		if (empty($rstpl)) {
			continue;
		}
		if (!is_numeric($rstpl['styleid'])) {
			continue;
		}
	//Start 模板目录处理部分
		$processresult = _tpldirProcess($rstpl, $isovercast);
		if (0 == $processresult['execflag']) {
			return $processresult;
		} else {
			$tpldir = $processresult['directory'];
		}
	//End 模板目录处理部分
	//Start SQL语句构造部分
		if (true === $isovercast) {//覆盖模板，删除数据库对应的数据
			$arrayexecsql[] = "DELETE FROM {$dv}styles WHERE styleid='{$rstpl['styleid']}' AND stype='0'";
			$arrayexecsql[] = "DELETE FROM {$dv}styles WHERE name='{$rstpl['name']}' AND ename='{$rstpl['ename']}' AND directory='{$rstpl['directory']}' AND stype='{$rstpl['stype']}' AND charset='{$rstpl['charset']}'";
			$arrayexecsql[] = "DELETE FROM {$dv}styles WHERE parentid='{$rstpl['styleid']}' AND stype<>0";
			$tplparentid = $rstpl['styleid'];
		} else {
			$tplparentid++;
		}
		//Start content字段及模板页面文件数据处理部分
			$tplcontent = array();
			if (!empty($rstpl['tplfile']) AND is_array($rstpl['tplfile'])) {
				foreach ($rstpl['tplfile'] AS $tplfiles) {
					if (1 == intval($rstpl['tpl_type'])) {
						$tplfile = $tpldir.$rstpl['ename'].'.'.$tplfiles['tplname'].'.tpl.php';
					} else {
						$tplfile = $tpldir.'/'.$tplfiles['tplname'].'.tpl.php';
					}
					if (FileHandler::touch($tplfile)) {
						@chmod($tplfile, 0777);
						$filecontents =& $tplfiles['value'];
						foreach ($decodemethod AS $method) {
							$filecontents = $method($filecontents);
						}
						FileHandler::file_put_contents($tplfile, $filecontents);
						@chmod($tplfile, 0777);
					} else {
					print '$tplfile:'.$tplfile.'<br />';
						return array('execflag' => 0, 'execmsg' => $lang['tpl.import.error12']);
					}
					$tplcontent[$tplfiles['tplname']] = $tplfiles['description'];
				}
			}
		//End content字段及模板页面文件数据处理部分
		$arrayexecsql[] = "INSERT INTO {$dv}styles(name, ename, content, directory, copyright, stype, tpl_type, parentid, charset) VALUES('{$rstpl['name']}', '{$rstpl['ename']}', '".$db->escape_string(base64_encode(serialize($tplcontent)))."', '{$rstpl['directory']}', '{$rstpl['copyright']}', '{$rstpl['stype']}', '{$rstpl['tpl_type']}', '{$rstpl['parentid']}', '{$rstpl['charset']}')";

		//Start 语言包数据的导入
			$parentidcount = 0;
			if (!empty($rstpl['language']) AND is_array($rstpl['language'])) {
				foreach ($rstpl['language'] AS $rslanguage) {
					if (empty($rslanguage)) {
						continue;
					}
					$rslanguage['parentref'] = & $rstpl;
				//Start 语言包目录处理部分
					$processresult = _tpldirProcess($rslanguage, $isovercast);
					if (0 === $processresult['execflag']) {
						return $processresult;
					} else {
						$langdir = $processresult['directory'];
					}
				//End 语言包目录处理部分
				//Start content字段及语言包页面文件数据处理部分
					$langcontent = array();
					if (!empty($rslanguage['tplfile']) AND is_array($rslanguage['tplfile'])) {
						foreach ($rslanguage['tplfile'] AS $tplfiles) {
							$langfile = $langdir.'/'.$tplfiles['tplname'].'.lang.php';
							if (1 == intval($rstpl['tpl_type']) AND 0 == intval($rstpl['stype'])) {
								print $langfile.'<br />';
							}
							if (FileHandler::touch($langfile)) {
								@chmod($langfile, 0777);
								$filecontents =& $tplfiles['value'];
								foreach ($decodemethod AS $method) {
									$filecontents = $method($filecontents);
								}
								FileHandler::file_put_contents($langfile, $filecontents);
								@FileHandler::chmod($langfile, 0777);
							} else {
								return array('execflag' => 0, 'execmsg' => $lang['tpl.import.error13']);
							}
							$langcontent[$tplfiles['tplname']] = $tplfiles['description'];
						}
					}
				//End content字段及语言包页面文件数据处理部分
					$arrayexecsql[] = "INSERT INTO {$dv}styles(name, ename, content, directory, copyright, stype, parentid, charset) VALUES('{$rslanguage['name']}', '{$rslanguage['ename']}', '".$db->escape_string(base64_encode(serialize($langcontent)))."', '{$rslanguage['directory']}', '{$rslanguage['copyright']}', '{$rslanguage['stype']}', '{$tplparentid}', '{$rslanguage['charset']}')";
					$parentidcount++;
				}
			}
		//End 语言包数据的导入

		//Start CSS样式表数据的导入
			if (!empty($rstpl['stylecss'])) {
				foreach ($rstpl['stylecss'] AS $rsstylecss) {
					if (empty($rsstylecss)) {
						continue;
					}
					$rsstylecss['parentref'] = & $rstpl;
					$processresult = _tpldirProcess($rsstylecss, false);
					if (0 === $processresult['execflag']) {
						return $processresult;
					} else {
						$cssdir = $processresult['directory'];
					}
					$cssfile = $cssdir.'/'.$rsstylecss['ename'].'.css';
					if (!is_dir($cssdir) OR !touch($cssfile)) {
						@chmod($cssfile, 0777);
						return array('execflag' => 0, 'execmsg' => str_replace('{$TPL_cssdir}', $cssdir,$lang['tpl.import.error14']));
					}
					$csscontent = array();
					if (!empty($rsstylecss['content'])) {
						$csscontent =& $rsstylecss['content'];
						foreach ($decodemethod AS $method) {
							$csscontent = $method($csscontent);
						}
						$csscontent = unserialize(base64_decode($csscontent));
						if(false !== $csscontent AND !empty($csscontent['.css'])) {
							FileHandler::file_put_contents($cssfile, $csscontent['.css']);
							@chmod($cssfile, 0777);
						}
					}
					$arrayexecsql[] = "INSERT INTO {$dv}styles(name, ename, content, directory, copyright, stype, parentid, charset) VALUES('{$rsstylecss['name']}', '{$rsstylecss['ename']}', '".$db->escape_string(base64_encode(serialize($csscontent)))."', '{$rsstylecss['directory']}', '{$rsstylecss['copyright']}', '{$rsstylecss['stype']}', '{$tplparentid}', '{$rsstylecss['charset']}')";
					$parentidcount++;
				}
			}
			if (true !== $isovercast) {
				$tplparentid += $parentidcount;
			}
		//End  CSS样式表数据的导入
	//End SQL语句构造部分
	}
	if (!empty($arrayexecsql)) {
		foreach ($arrayexecsql AS $stmt) {
			$db->query($stmt);
		}
		(true === $isovercast) AND ($inserted_tpl_id = $db->scalar("SELECT MAX(styleid) FROM {$dv}styles WHERE stype='0'")) AND ($db->query("UPDATE {$dv}styles SET styleid='".$tplparentid."' WHERE styleid='".$inserted_tpl_id."'"));
		require_once INC_PATH.'BoardCache.class.php';
		$syscache =& new BoardCache($db);
		$syscache->createForumSetting();
		$syscache->createstylecss();
		unset($syscache);
		return array('execflag' => 1, 'execmsg' => $lang['tpl.import.str1']);
	} else {
		return array('execflag' => 0, 'execmsg' => $lang['tpl.import.error8']);
	}
}
?>