{include header}
<div class="wrapper">
    {include header_menu}
    <div class="main-container">
    	<div class="padding-md">
            <div id="mess">
            	

            </div>
            <div id="code-mess">
            	
            </div>
			
            <style>
            .list-group-item>.sone{
                width: 100px;
                display: inline-block;
            }
            </style>
            <h3 class="m-left-xs header-text m-top-lg">缓存清理</h3>
            <div class="smart-widget">
			<div class="smart-widget-header">
				缓存清理

			</div>
			<div class="smart-widget-inner">
				<div class="smart-widget-body">

                    <form action="" method="post" id="formToggleLine" class="form-horizontal no-margin form-border">
                    
                    <div class="form-group">
						<label class="col-lg-2 control-label">文件组建缓存</label>
						<div class="col-lg-10">
							<div class="checkbox inline-block">
								<div class="custom-checkbox">
									<input name="one1" type="checkbox" id="inlineCheckbox1" class="checkbox-red" checked="">
									<label for="inlineCheckbox1"></label>
								</div>
								<div class="inline-block vertical-top">
									缓存文件(Tmp)
								</div>
							</div>
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-2 control-label">多语言 文件缓存</label>
						<div class="col-lg-10">
							<div class="checkbox inline-block">
								<div class="custom-checkbox">
									<input name="lang" type="checkbox" id="lang" class="checkbox-red" checked="">
									<label for="lang"></label>
								</div>
								<div class="inline-block vertical-top">
									多语言缓存文件(Tmp/Lang)
								</div>
							</div>
						</div>
					</div>

					<div class="form-group">
						<label class="col-lg-2 control-label">数据缓存</label>
						<div class="col-lg-10">
							<div class="checkbox inline-block">
								<div class="custom-checkbox">
									<input name="one3" type="checkbox" id="inlineCheckbox3" class="checkbox-red">
									<label for="inlineCheckbox3"></label>
								</div>
								<div class="inline-block vertical-top">
									数据缓存
								</div>
							</div>
						</div>
					</div>

					<div class="form-group">
						<label class="col-lg-2 control-label">日志文件</label>
						<div class="col-lg-10">
							<div class="checkbox inline-block">
								<div class="custom-checkbox">
									<input name="one4" type="checkbox" id="inlineCheckbox4" class="checkbox-red">
									<label for="inlineCheckbox4"></label>
								</div>
								<div class="inline-block vertical-top">
									文件大小: <?php if(is_file(TMP_PATH .'log.php')){echo number_format(floatval(((filesize(TMP_PATH .'log.php')/1024)/1024)),3,'.', '') . 'MB'; }else{echo ' 无日志文件';} ?>
								</div>
							</div>
						</div>
					</div>


                    
					<div class="form-group">
						<label class="col-lg-2 control-label">重构板块主题与评论数量</label>
						<div class="col-lg-10">
							<div class="checkbox inline-block">
								<div class="custom-checkbox">
									<input name="one2" type="checkbox" id="inlineCheckbox2" class="checkbox-info">
									<label for="inlineCheckbox2"></label>

								</div>
								<div class="inline-block vertical-top">
									<span class="help-block">由于大量删除主题以及评论导致的板块主题评论数量不正确,勾选此方案重建. 如果你只清理论坛缓存，不需要勾选该选项！</span>
								</div>
							</div>
						</div>
					</div>
                    <div class="form-group">
						<label class="col-lg-2 control-label">确认表单</label>
						<div class="col-lg-10">
							<button class="btn btn-danger">提交</button>
						</div><!-- /.col -->
					</div>
                </form>
				</div>
			</div><!-- ./smart-widget-inner -->
		</div>
				<h3 class="m-left-xs header-text m-top-lg">服务器信息</h3>
    		<div class="row m-top-md">
                <div class="col-sm-12">
                    <table class="table table-striped table-bordered " id="dataTable">
						<thead>
							<tr class="bg-dark-blue">
								<th class="col-sm-2">名称</th>
								<th class="col-sm-10">信息</th>

							</tr>
						</thead>
						<tbody>
                            
                            <tr>
								<td>论坛版本</td>
								<td><label class="label label-success"><?php echo HYBBS_V;?></label></td>

							</tr>
							<tr>
								<td>HYPHP框架版本</td>
								<td><?php echo HYPHP_VERSION;?></td>

							</tr>
							<tr>
								<td>
									伪静态条件
								</td>
								<td id="re">检测中...</td>
							</tr>
							<tr>
								<td>服务器IP地址</td>
								<td><?php if('/'==DIRECTORY_SEPARATOR){echo $_SERVER['SERVER_ADDR'];}else{echo @gethostbyname($_SERVER['SERVER_NAME']);} ?></td>
							</tr>
							<tr>
								<td>本机发信IP</td>
								<td id="ip">加载中...</td>
							</tr>
							{if function_exists('disk_free_space') && function_exists('disk_total_space')}
							<tr>
								<td>磁盘空间大小</td>
								<td>
									<div class="progress" style="height: 20px;margin-bottom: 0;">
										<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo 100-number_format((disk_free_space(INDEX_PATH)/disk_total_space(INDEX_PATH))*100,0); ?>%">
									    	<span class="">已用<?php echo 100-number_format((disk_free_space(INDEX_PATH)/disk_total_space(INDEX_PATH))*100,0); ?>% 剩余<?php echo number_format(disk_free_space(INDEX_PATH)/1024/1024,0,'.','.');?> G / 总量<?php echo number_format(disk_total_space(INDEX_PATH)/1024/1024,0,'.','.');?> G</span>
									  	</div>
									</div>
									
								</td>
							</tr>
							{/if}
							<tr>
								<td>服务器信息</td>
								<td><?php if(function_exists('php_uname')) echo php_uname();?></td>
							</tr>
							<tr>
								<td>服务器系统</td>
								<td><?php if(function_exists('php_uname')) echo php_uname('s');?></td>

							</tr>
							<tr>
								<td>WEB服务器类型</td>
								<td><?php echo $_SERVER['SERVER_SOFTWARE'];?></td>
							</tr>
							<tr>
								<td>根目录</td>
								<td><?php echo INDEX_PATH;?></td>
							</tr>
							<tr>
								<td>PHP支持模块</td>
								<td>
								<?php
$able=get_loaded_extensions();
foreach ($able as $key=>$value) {
	if ($key!=0 && $key%13==0) {
		echo '<br /><br />';
	}
	echo '<label class="label label-success" style="margin-bottom:10px">'.$value.'</label>&nbsp;&nbsp;';
	
}
?>
								</td>
							</tr>
							

                            <tr>
								<td>PHP版本</td>
								<td><?php echo PHP_VERSION;?></td>
							</tr>
							<tr>
								<td>PHP安装路劲</td>
								<td><?php echo DEFAULT_INCLUDE_PATH;?></td>
							</tr>
							<tr>
								<td>PHP运行方式</td>
								<td><?php echo strtoupper(php_sapi_name());?></td>
							</tr>
							<tr>
								<td>PHP脚本最大内存可用</td>
								<td><?php echo get_cfg_var("memory_limit");?></td>
							</tr>
							<tr>
								<td>POST提交字节最大限制</td>
								<td><?php echo get_cfg_var("post_max_size");?></td>
							</tr>
							<tr>
								<td>上传文件最大限制字节</td>
								<td><?php echo get_cfg_var("upload_max_filesize");?></td>
							</tr>
							<tr>
								<td>脚本超时时间</td>
								<td><?php echo get_cfg_var("max_execution_time");?>秒</td>
							</tr>
							
							{if function_exists('Zend_Version')}
                            <tr>
								<td>Zend版本</td>
								<td><?php echo Zend_Version();?></td>
							</tr>
							{/if}
                            
                            <tr>
								<td>网站根目录</td>
								<td><?php echo INDEX_PATH;?></td>
							</tr>
							{if function_exists('GetHostByName')}
                            <tr>
								<td>服务器IP</td>
								<td><?php echo GetHostByName($_SERVER['SERVER_NAME']);?></td>
							</tr>
							{/if}
                            
                            <tr>
								<td>当前你的访问IP</td>
								<td><?php echo $_SERVER['ip'];?></td>
							</tr>
                            
                            <tr>
								<td>服务器语言</td>
								<td><?php echo $_SERVER['HTTP_ACCEPT_LANGUAGE'];?></td>
							</tr>


						</tbody>

					</table>
                </div>
    		</div>
           
		
    	</div>
    	<!-- ./padding-md -->
    </div>
    {include left_menu}
    <div class="modal fade" id="normalModal" aria-hidden="true" style="display: none;">
	  	<div class="modal-dialog">
	    	<div class="modal-content">
	      		<div class="modal-header">
	        		<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
	        		<h4 class="modal-title">升级论坛</h4>
	      		</div>
	      		<div class="modal-body">
	        		<div class="progress progress-striped active">
					  <div id="jdt" class="progress-bar progress-bar-success" role="progressbar" style="width: 0%">
					    <span class="sr-only">80% Complete (success)</span>
					  </div>
					</div>
					<pre id="open-mess"></pre>
	      		</div>
	      		<div class="modal-footer">
	        		<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
	        		<button type="button" class="btn btn-primary" onclick="openA(this)">确定升级</button>
	      		</div>
	    	</div>
	  	</div>
	</div>


{include footer}
<script type="text/javascript">
	function add_mess(info,on){
		$("#open-mess").html($("#open-mess").html()+'<label class="label label-'+on+'" style="margin-bottom:5px;display: inline-block;">'+info+'</label>\r\n');
	}
	function openA(obj){
		$(obj).attr('disabled','disabled');
		$("#open-mess").html('');
		$("#jdt").stop(true,true);
		
		add_mess('升级任务正在执行，请勿关闭该页面！','success');
		add_mess('正在下载最新论坛程序包！','success');
		$("#jdt").animate({width:"30%"},10000);
		$.ajax({
			url: "{php HYBBS_URL('admin','update2')}",
			type:"POST",
			cache: false,
			data:{gn:'down'},
			dataType: 'json'
	    }).then(function(e) {
	    	
	         if(!e.error){
	         	$(obj).removeAttr('disabled');
	         	return add_mess(e.info,'danger');
	         }
	         	

	        $("#jdt").stop(true,true);
	        $("#jdt").animate({width:"60%"},10000);
	        add_mess(e.info,'success');
	        $.ajax({
				url: "{php HYBBS_URL('admin','update2')}",
				type:"POST",
				cache: false,
				data:{gn:'unzip'},
				dataType: 'json'
		    }).then(function(e) {
		    	
		        if(!e.error){
		        	$(obj).removeAttr('disabled');
		         	return add_mess(e.info,'danger');
		        }
		        
		        if(!e.url){
		        	$(obj).removeAttr('disabled');
		        	return add_mess('没有找到升级地址！','danger');
		        }
		        $("#jdt").stop(true,true);
		        $("#jdt").animate({width:"80%"},10000);
		        add_mess('SQL升级成功...','success');
	        	add_mess('正在覆盖源文件...','success');
	        	$.get(e.url,function(e){
	        		
	        		if(e == '0'){
	        			$(obj).removeAttr('disabled');
	        			return add_mess('升级失败，原因：升级压缩包丢失！','danger');
	        		}
	        		if(e == '1'){
	        			add_mess('升级成功！','success');
						$("#jdt").stop(true,true);
						$("#jdt").animate({width:"100%"});
						setTimeout(function(){
							window.location.reload();
						},3000);
	        			return;
	        		}
	        		$(obj).removeAttr('disabled');
	        		return add_mess('升级失败，原因：未知 Error = 1！ 如果卡在此处 可以覆盖最新程序文件','danger');
	        		
	        	},'html');
		         
		   }, function() {
		   		$(obj).removeAttr('disabled');
		   		$("#jdt").stop(true,true);
		     	add_mess('访问本地服务器出错！Error = 2','danger');
		   });
	   }, function() {
	   		$(obj).removeAttr('disabled');
	   		$("#jdt").stop(true,true);
	     	add_mess('访问本地服务器出错！Error = 1','danger');
	   });


	}
	function add_mess(info,on){
		$("#open-mess").html($("#open-mess").html()+'<label class="label label-'+on+'" style="margin-bottom:5px;display: ;    line-height: 3;">'+info+'</label>\r\n');
	}
	$.ajax({
		url:'{php HYBBS_URL('admin','GetNewVersion')}',
		type:'get',
		dataType:'json',
		success:function(e){
			if(e.error){
				$("#mess").html('<div class="alert alert-success alert-custom alert-dismissible" role="alert"><i class="fa fa-check-circle m-right-xs"></i><strong>有新版本更新</strong> 当前论坛版本：{#HYBBS_V}，论坛有新版本: '+e.info.version+' 更新吗？ <a class="label label-danger" href="{php HYBBS_URL('admin','updatebbs')}">跳转更新页</a> </div>');
			}
			
			
		},error:function(xhr,ts){
			$('#re').html('<label class="label label-danger"><i class="fa fa-close"></i> 运行出错，请查看日志！</label>');
		}
	})
	// $.get("{php HYBBS_URL('admin','hybbsupdate2')}",function(e){
	// 	if(e.error){
	// 		var html ='';
	// 		for(o in e.json){
	// 			html+= '<li>' + e.json[o] + '</li>';
	// 		}
	// 		$("#mess").html('<div class="alert alert-success alert-custom alert-dismissible" role="alert"><i class="fa fa-check-circle m-right-xs"></i><strong>信息!</strong> 论坛有新版本: '+e.info+' 更新吗？ <a class="label label-danger" href="{php HYBBS_URL('admin','updatebbs')}">跳转更新页</a> <div><h3>更新日志</h3><ul style="margin-left:20px">'+html+'</ul></div></div>');
	// 	}

	// },'json');
	
	$.get('{php HYBBS_URL('admin','getip')}',function(e){
		$("#ip").text(e.ip);
	},'json');
	$.ajax({
		url:'{#WWW}admin{#EXP}is_rewrite',
		type:'get',
		dataType:'html',
		success:function(e){
			if(e=='on')
				return $('#re').html('<label class="label label-success"><i class="fa fa-check"></i> 支持</label>');
			$('#re').html('<label class="label label-danger"><i class="fa fa-close"></i> 不支持</label>');
		},error:function(e){
			$('#re').html('<label class="label label-danger"><i class="fa fa-close"></i> 不支持</label>');
		}
	})
</script>