<?php

/*
*	Copyright VeryIDE,2007-2010
*	http://www.veryide.com/
*
*	$Id: veryide.server.php,v2 12:21 2008-8-2 Lay $
*/

require '../../include/loader.php';
html_start("服务器信息 - VeryIDE");
?>

<!--body start-->
    
        <script type="text/javascript">
        //if( parent.parent.Mo.store.model == "modern" ){
                Mo("#wrapper").attr({"class":"snugly"});
        //}
        </script>
    
    <div id="box">
    
	<?php
    
	//phpinof()
    if( $_GET['action']=="phpinfo" ){
	
		ob_clean();	
		phpinfo();
		exit();
		
    }
        
    //服务器变量_开始
    $phpver=PHP_VERSION;
    $phpos=php_uname();//also PHP_OS
    $server_soft=getenv(server_software);
    $server_ptc=getenv(server_protocol);
    $server_lan=getenv(HTTP_ACCEPT_LANGUAGE);
    $server_addr=getenv(SERVER_ADDR);
    $server_host=getenv(HTTP_HOST);
    $server_port=getenv(SERVER_PORT);
    $server_admin=getenv(SERVER_ADMIN);
    $server_disk_space = intval(@diskfreespace("/") / (1024 * 1024));
    $server_time=date("n月j日H点i分s秒");
    $server_list=(__FILE__);
    $server_cgi=getenv(GATEWAY_INTERFACE);
    $server_tout=get_cfg_var("max_execution_time");
    $server_func=get_cfg_var("disable_functions");
    $server_user=get_current_user();

    if (get_cfg_var("register_globals")=="1"){
        $server_env="ON";
    }else{
        $server_env="OFF";
    }
    if($server_func){
        $server_func=str_replace(" "," ",$server_func);
        $server_func=str_replace(","," ",$server_func);
    }else{
        $server_func="无被禁函数";
    }
    if(get_cfg_var("safemode")){
        $server_safe="是";
    }else{
        $server_safe="否";
    }

    //连接数据库
    @$connect=@mysql_connect(VI_DBHOST.":".VI_DBPORT,VI_DBUSER,VI_DBPASS);

    //代码区
    if($_GET["action"]=='cost'){
        for($i=0;$i<4;$i++){
            $nowtime = explode(" ", microtime());
            
            $starttime = $nowtime[1] + $nowtime[0];
            {
                for($c=0;$c<1000001;$c++){
                    $g=1+1;
                }
                $nowtime = explode(" ", microtime());
                $endtime = $nowtime[1] + $nowtime[0];
                $totaltime = ($endtime - $starttime);
                $costtime[$i] = number_format($totaltime, 7).'秒';
            }
        }
    }
            
    if(function_exists("imageline")){
        $pic=loader_image("valid.gif","支持");
    }else{
        $pic=loader_image("invalid.gif","不支持");
    }

    if(function_exists("zend_version")){
        $zendversion="<span class='yes'>".zend_version()."</span>";
    }else{
        $zendversion="<span class='no'>不支持</span>";
    }
                
    $time=$costtime[1]+$costtime[2]+$costtime[3]+$costtime[4]+$costtime[5];
    $ttime=number_format($time/5, 7).'秒';
                
    if(function_exists("mysql_get_server_info")) {

        $curr_mysql_version = mysql_get_server_info();
        if(substr($curr_mysql_version, 0, 4) == "3.22") {
            $msg .= "<font color=\"#FF0000\">您的 MySQL 版本低于 3.23,运行效率可能会受到影响.</font>\t";
        }
    } else {
        $curr_mysql_version = "未知";
        $msg .= "您的 PHP 版本较老, MySQL 版本检查函数无法使用.\t";
    }
                
    if (!$connect){
        $mysql="<span class='no'>空间不支持数据库或者设置错误！</span>";
    }else {
        $mysql="<span class='yes'>$curr_mysql_version</span>";
        global $mysql;
    }
                
    function tc($temp){
        if($temp==1){
            return loader_image("valid.gif","支持");
        }else{
            return loader_image("invalid.gif","不支持");
        }
    }
                
    if(isset($HTTP_COOKIE_VARS)) $testcookie="通过";
    else $testcookie="不通过";
                
    if(get_cfg_var(file_uploads)){
        $max_size = get_cfg_var(upload_max_filesize);
        $server_upload_status = "允许/最大 $max_size";
    } else {
        $server_upload_status = "不允许上传附件";
    }
    //服务器变量_结束
    ?>
    
    <div class="item">系统基本信息</div>
    
    <table width="100%" border="0" cellpadding="1" cellspacing="1" class="table">
        <tr class="title">
			<td>VeryIDE 版本</td>
			<td>VeryIDE 空间占用</td>
			<td>基准目录</td>
			<td>绝对地址</td>
			<td>本地目录</td>
			<td>UCS 编码</td>
			<td>数据库编码</td>
        </tr>
        <tr class="line">
			<td class="text-yes"><?php echo $_G['product']['appname']." ".$_G['product']['version']." <span class='text-key'>（".$_G['version'][$_G['licence']['type']]["name"].' - '.strtoupper($_G['product']['charset']).' - '.$_G['product']['build'];?>）</span></td>
			<td class="text-yes"><?php echo sizecount(GetFolderSize("."));?></td>
			<td class="text-yes"><?php echo VI_BASE;?></td>
			<td class="text-yes"><?php echo VI_HOST;?></td>
			<td class="text-yes"><?php echo VI_ROOT;?></td>
			<td class="text-yes"><?php echo VI_UCS;?></td>
			<td class="text-yes"><?php echo VI_DBCHARSET;?></td>
        </tr>
    </table>
    
     <div class="item"><a class="y" href="?action=phpinfo" target="_blank">详细信息 <?php echo loader_image("link.gif","详细信息");?></a>当前环境信息</div>
    
        <table width="100%" border="0" cellpadding="1" cellspacing="1" class="table">
        <tr class="title">
          <td>参数</td>
          <td>信息</td>
          <td>参数</td>
          <td>信息</td>
        </tr>
        <tr class="line">
        <td>服务器时间</td>
        <td class="text-yes"><?php echo date("Y-m-t H:i:s");?></td>
        <td>MySQL 版本</td>
        <td class="text-yes"><?php echo $mysql;?></td>
        </tr>
        <tr class="band">
        <td>文件上传</td>
        <td class="text-yes">
        <?php 
        
        if(get_cfg_var(file_uploads))
        {
            $max_size = get_cfg_var(upload_max_filesize);
            $server_upload_status = "允许/最大 $max_size";

        } else {
            $server_upload_status = "不允许上传附件";
        }
        echo $server_upload_status;?>
        </td>
        <td>Zend 版本</td>
        <td class="text-yes"><?php echo $zendversion;?></td>
        </tr>
        <tr class="line">
        <td>服务器语言环境</td>
        <td class="text-gray"><?php echo $server_lan;?></td>
        <td>服务端软件系统</td>
        <td class="text-gray"><?php echo $_SERVER["SERVER_SOFTWARE"];?></td>
        </tr>
        <tr class="band">
        <td>脚本超时设置</td>
        <td class="text-gray"><?php echo $server_tout." 秒";?></td>
        <td>服务器操作系统</td>
        <td class="text-gray"><?php echo $phpos;?></td>        
        </tr>
        <tr class="line">
        <td>服务器IP地址</td><td><?php echo $_SERVER["SERVER_ADDR"].":".$_SERVER["SERVER_PORT"];?></td>
        <td>客户端IP地址</td><td><?php echo GetIP();?></td>
        </tr>
        <tr class="band">
        <td>PHP安全模式(Safe_mode)</td>
        <td><?php echo $server_safe;?></td>
        <td>PHP被禁用的函数</td>
        <td><?php echo $server_func;?></td>
        </tr>
        <tr class="line">
          <td>Iconv</td>
          <td><?php echo tc(function_exists("iconv"));?></td>
          <td>XML</td>
          <td><?php echo tc( class_exists('DOMDocument') );?></td>
        </tr>
        <tr class="band">
          <td>GD 库</td><td><?php echo $pic;?></td>
          <td>Mcrypt</td><td><?php echo tc(function_exists("mcrypt_module_open"));?></td>
        </tr>
    </table>
    
    <table width="100%" border="0">
    	<tr>
        <td width="40%" valign="top">
        
        	<div class="item">系统配置读写权限</div>
        
            <table width="100%" border="0" cellpadding="1" cellspacing="1" class="table">
                <tr class="title">
                  <td width="70%">文件地址</td>
                  <td width="30%">支持读写</td>
                  
                </tr>
                <?php
                
                $list = loop_file( VI_ROOT.'config', array('adsense.php','version.php'), array('php') );
                
                foreach( $list as $file ){
                        
                        echo '<tr class="'.zebra( $i, array( "line" , "band" ) ).'">';
                                
                        echo '<td>'.VI_BASE.'config/'.$file.'</td><td>'.( is_writable(VI_ROOT.'config/'.$file) ? '<img src="'.VI_BASE.'image/valid.gif" title="支持" alt="支持" class=""  />' : '<img src="'.VI_BASE.'image/invalid.gif" title="不支持" alt="不支持" class=""  />' ).'</td>'; 
                        
                       echo '</tr>';
                        
                }
                ?>     
            </table>
            
            <div class="item">系统目录读写权限</div>
            
            <table width="100%" border="0" cellpadding="1" cellspacing="1" class="table">
                <tr class="title">
                  <td width="70%">文件地址</td>
                  <td width="30%">支持读写</td>
                </tr>
                <?php
				$i = 0;
                foreach($_G['project']['check']	 as $dir){
                        
                        //当前模块目录
                        $base = VI_ROOT.$dir;
                        
                        echo '<tr class="'.zebra( $i, array( "line" , "band" ) ).'">';    
                        
                        if( file_exists($base) ){
                                
                                echo '<td>'.VI_BASE.$dir.'</td><td>'.( is_writable($base) ? '<img src="'.VI_BASE.'image/valid.gif" title="支持" alt="支持" class=""  />' : '<img src="'.VI_BASE.'image/invalid.gif" title="不支持" alt="不支持" class=""  />' ).'</td>'; 
                        
                        }else{                        
                                echo '<td>'.$base.'</td><td>不存在</td>';
                        }
                        
                         echo '</tr>';
                        
                }
                ?>     
            </table>
        
        </td>
        <td width="1%"></td>
        <td width="59%" valign="top">
        
            <div class="item">模块配置读写权限</div>

            <table width="100%" border="0" cellpadding="1" cellspacing="1" class="table">
                <tr class="title">
                  <td width="20%">文件地址</td>
                  <td width="20%">支持读写</td>
                  <td width="20%">文件地址</td>
                  <td width="20%">支持读写</td>
                </tr>
                <?php
				$i = 0;
                foreach($_CACHE['system']['module'] as $appid=>$val){
                        
                        //当前模块目录
                        $base = VI_ROOT.$_G['project']['module'].$appid;
                        
                        //当前模块目录
                        $sett = $base.'/setting.php';
                        
                        //当前模块目录
                        $navi = $base.'/navigate.php';
                        
                        if( file_exists($sett) || file_exists($navi) ){
                        
                                echo '<tr class="'.zebra( $i, array( "line" , "band" ) ).'">';                        
                                
                                //有配置项
                                if( file_exists($sett) ) {                        
                                        echo '<td>'.VI_BASE.''.$_G['project']['module'].$appid.'/setting.php</td><td>'.( is_writable($sett) ? '<img src="'.VI_BASE.'image/valid.gif" title="支持" alt="支持" class=""  />' : '<img src="'.VI_BASE.'image/invalid.gif" title="不支持" alt="不支持" class=""  />' ).'</td>';                        
                                }else{
                                        echo '<td></td><td></td>';
                                }
                                
                                //有配置项
                                if( file_exists($navi) ) {                        
                                        echo '<td>'.VI_BASE.''.$_G['project']['module'].$appid.'/navigate.php</td><td>'.( is_writable($navi) ? '<img src="'.VI_BASE.'image/valid.gif" title="支持" alt="支持" class=""  />' : '<img src="'.VI_BASE.'image/invalid.gif" title="不支持" alt="不支持" class=""  />' ).'</td>';
                                }else{
                                        echo '<td></td><td></td>';
                                }
                                
                                echo '</tr>';
                        
                        }
                        
                }
                ?>     
                </table>
                  
        </td>
        </tr>
    </table>
    
    </div>
    
<!--body end-->

<?php html_close();?>