<?php
require(dirname(__FILE__) .'/check.php');
$skin->CheckIframe();

/* **** 版权所有 ****

 程序开发：网钛科技
 网钛CMS官网：http://otcms.com
 网钛IDC官网：http://idccms.com
 ＱＱ：877873666
 微信：QQ877873666
 邮箱：877873666@qq.com

 **** 版权所有 **** */


//打开用户表，并检测用户是否登录
$MB->Open('','login');

$skin->WebTop();

echo('
<script language="javascript" type="text/javascript" src="js/share.js"></script>
');


switch($mudi){
	default:
		$MB->IsAdminRight('alertBack');
		manage();
		break;

}

$skin->WebBottom();

$MB->Close();
$DB->Close();





function manage(){
	global $DB,$skin,$mudi,$sysAdminArr;

	$dataMode		= OT::GetStr('dataMode');
	$dataModeStr	= OT::GetStr('dataModeStr');
	$dataType		= OT::GetStr('dataType');
	$dataTypeCN		= '特定文档查看';	// OT::GetStr('dataTypeCN');
	$fileName		= OT::GetStr('fileName');
	$fileContent	= '';
	$fileAlert		= '';

	if (in_array($fileName,array('robots.txt', '.htaccess', 'nginx.conf', 'web.config', 'softErr.log', 'web_config[x]rewrite.config', 'wap[x]web.config', 'wap[x].htaccess'))){
		if ($fileName == 'softErr.log'){
			$filePath = OT_ROOT . OT_dbDir . $fileName;
		}else{
			$filePath = OT_ROOT . str_replace('[x]','/',$fileName);
		}
		if (file_exists($filePath)){
			$filesize = filesize($filePath);
			if ($filesize > 3*1024*1024){
				$fileContent = '【文件 '. File::SizeUnit($filesize) .'，超过 3 MB，仅显示最后 10000 行】'. PHP_EOL . File::ReadEnd($filePath, 10000, 'det');
			}else{
				$fileContent = File::Read($filePath);
			}
			if ( in_array($fileName,array('softErr.log','robots.txt')) ){
				$fileContent = Str::GB2UTF($fileContent);
			}
		}else{
			$fileAlert = '该文件不存在，请编辑，系统会自动创建。';
		}
	}elseif ($fileName == 'local'){
		// $fileContent .= '【POST】'. PHP_EOL . print_r($_POST,true) . PHP_EOL . PHP_EOL;
		// $fileContent .= '【GET】'. PHP_EOL . print_r($_GET,true) . PHP_EOL . PHP_EOL;
		$fileContent .= '【session】'. PHP_EOL . print_r($_SESSION,true) . PHP_EOL . PHP_EOL;
		$fileContent .= '【cookies】'. PHP_EOL . print_r($_COOKIE,true);
	}else{
		$fileName = '';
	}

	$optionStr = '';
	if (file_exists(OT_ROOT .'web.config')){
		$optionStr .= '<option value="web.config" '. Is::Selected($fileName,'web.config') .'>web.config(IIS站点配置)</option>';
	}
	if (file_exists(OT_ROOT .'wap/web.config')){
		$optionStr .= '<option value="wap[x]web.config" '. Is::Selected($fileName,'wap[x]web.config') .'>wap/web.config(手机版IIS站点配置)</option>';
	}
	if (file_exists(OT_ROOT .'wap/.htaccess')){
		$optionStr .= '<option value="wap[x].htaccess" '. Is::Selected($fileName,'wap[x].htaccess') .'>wap/.htaccess(apache环境-手机版伪静态规则)</option>';
	}

	$skin->TableTop('share_show.gif','',$dataTypeCN);
		echo('
		<!-- <form name="addform" method="post" action="editFile_deal.asp?mudi=deal" onsubmit="return CheckForm()">
		<input type="hidden" id="dataType" name="dataType" value="'. $dataType .'" />
		<input type="hidden" id="dataTypeCN" name="dataTypeCN" value="'. $dataTypeCN .'" />
		<input type="hidden" id="dataMode" name="dataMode" value="'. $dataMode .'" />
		<input type="hidden" id="dataModeStr" name="dataModeStr" value="'. $dataModeStr .'" />
		<script language="javascript" type="text/javascript">document.write(\'<input type="hidden" name="backURL" value="\'+ document.location.href +\'" />\')</script> -->
		<table width="99%" align="center" cellpadding="0" cellspacing="0" summary="" class="padd3">
		<tr>
			<td style="width:7%;"></td>
			<td style="width:93%;"></td>
		</tr>
		<tr>
			<td class="font1_2" align="right">文件：</td>
			<td class="font1_2">
				<select id="fileName" name="fileName" onchange=\'document.location.href="'. OT::GetParam(array('fileName')) .'&fileName="+ this.value;\'>
					<option value="">请选择</option>
					<option value="softErr.log" '. Is::Selected($fileName,'softErr.log') .'>softErr.log(程序错误日志)</option>
					<option value="robots.txt" '. Is::Selected($fileName,'robots.txt') .'>robots.txt(搜索蜘蛛遵循协议)</option>
					<option value=".htaccess" '. Is::Selected($fileName,'.htaccess') .'>.htaccess(apache环境-伪静态规则)</option>
					<option value="nginx.conf" '. Is::Selected($fileName,'nginx.conf') .'>nginx.conf(nginx环境-伪静态规则)</option>
					<option value="web_config[x]rewrite.config" '. Is::Selected($fileName,'web_config[x]rewrite.config') .'>web_config/rewrite.config(IIS站点配置-伪静态规则)</option>
					'. $optionStr .'
					<option value="local" '. Is::Selected($fileName,'local') .'>本机信息</option>
				</select>
				<span class="font2_2">&ensp;&ensp;&ensp;&ensp;'. $fileAlert .'</span>
			</td>
		</tr>
		<tr>
			<td class="font1_2" align="right" valign="top" style="padding-top:6px;">内容：</td>
			<td class="font1_2">
				<textarea id="fileContent" name="fileContent" size="50" style="width:900px;height:350px;">'. $fileContent .'</textarea>
			</td>
		</tr>
		</table>
		<table style="height:16px;" cellpadding="0" cellspacing="0" summary=""><tr><td></td></tr></table>

		<!-- <center><input type="image" src="'. AdmTpl::ImgSrc('button_save') .'" /></center>
		</form> -->
		');
	$skin->TableBottom();

}

?>