<?php

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

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

<!--body start-->
	<?php
    
	//phpinof()
    if( $_GET['action']=="phpinfo" ){
	
		ob_clean();	
		phpinfo();
		exit();
		
    }
        
    //loader
    loader_setting("naver.system");
    
    //服务器变量_开始
    $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 = "不允许上传附件";
    }

    if($_POST['action']=="mysql"){
        $dbhost=$_POST['dbhost'].":".$_POST['dbport'];
        $mytest=@mysql_connect($dbhost,$_POST['dbuser'],$_POST['dbpass']);
        if($mytest){
            $curr_mysql_version = mysql_get_server_info();
            $mysql_info="<span class='text-yes'>恭喜你，连接成功 (MySQL版本:".$curr_mysql_version.")</span>";
        }else{
            $mysql_info="<span class='text-no'>Sorry，连接失败，该用户名可能没有数据库连接权限</span>";
        }
    }
    //服务器变量_结束

    echo '
    
        <form name="form" method="post" action="?">
        <table width="100%" border="0" cellpadding="1" cellspacing="1" class="table">
            <tr class="title">
                <td>MySQL数据库地址</td>
                <td>MySQL用户名</td>
                <td>MySQL密码</td>
                <td>MySQL端口</td>
                <td></td>
            </tr>
            <tr class="line">
                <td>
                    <input name="dbhost" type="text" class="text" id="dbhost" size="20" value="localhost">
                </td>
                
                <td>
                    <input name="dbuser" type="text" class="text" id="dbuser2" size="20">
                </td>
                
                <td>
                <input name="dbpass" type="password" id="dbpass" class="text" size="20">
                </td>
                
                <td><input name="dbport" type="text" class="text" id="dbport" size="10" value="3306"></td>
                
                <td>
					<input name="action" type="hidden" value="mysql">
					<input name="submit" type="submit" value="连接" class="button">
                </td>
            </tr>
            '.($mysql_info?'<tr class="line"><td colspan="5" align="center" class="block">&nbsp;'. $mysql_info .'</td></tr>':'').'					
        </table>
        </form>
    
      <table width="100%" border="0" cellpadding="1" cellspacing="1" class="table">
        <tr class="title">
          <td>服务器参数</td>
          <td>参数值</td>
          <td>PHP基本参数</td>
          <td>支持情况</td>
        </tr>
        <tr class="line">
        <td>VeryIDE 版本</td>
        <td class="text-yes">
            '. $Project["version"]." ".strtoupper($Project["charset"])." ( ".$Product["appname"]." ".$Product["version"]." <span class='text-key'>".$Version[$Licence["type"]]["name"].'</span> ) 
        </td>
        <td>服务器时间</td><td>
        '. date("Y-m-t H:i:s") .'
         </td>
         </tr>
        <tr class="band">
        <td>VeryIDE 空间占用</td>
        <td>'. GetFileSize(GetFolderSize("."),"byte").'
        </td>
        <td>MYSQL版本</td><td>'. $mysql .'</td>
        </tr>
        <tr class="line">
        <td>文件上传</td><td>
        ';
        
        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;
        
        echo '
        </td>
        <td>GD库</td><td>'. $pic .'</td>
        </tr>
        <tr class="band">
        <td>服务器物理路径</td><td>'. iconv("GB2312" , "UTF-8",$_SERVER["DOCUMENT_ROOT"]) .'</td>
        <td>Zend Version</td><td>'. $zendversion .'</td>
                </tr>
                <tr class="line">
        <td>服务器CPU数量</td><td>'. $_ENV["NUMBER_OF_PROCESSORS"] .'</td>
        <td>Session Support</td><td>'. tc(get_magic_quotes_gpc("Session Support")) .'</td>
                </tr>
                <tr class="band">
        <td>服务器语言环境</td>  		<td>'. $server_lan .'</td>
        <td>Dynamic Library</td><td>'. tc(get_magic_quotes_gpc("Dynamic Library Support")) .'</td>
                </tr>
                <tr class="line">
        <td>脚本超时设置</td>  		<td>'. $server_tout." 秒" .'</td>
        <td>Internal Sendmail Support for Windows 4</td><td>'. tc(get_magic_quotes_gpc("Internal Sendmail Support for Windows 4")) .'</td>
                </tr>
                <tr class="band">
        <td>服务端软件系统</td><td>'. $_SERVER["SERVER_SOFTWARE"] .'</td>
        <td>BCMath support</td><td>'. tc(get_magic_quotes_gpc("BCMath support")) .'</td>
                </tr>
                <tr class="line">
        <td>服务器操作系统</td><td title="'. $phpos .'">'. format_substr($phpos,50) .'</td>
        <td>Calendar support</td><td>'. tc(get_magic_quotes_gpc("Calendar support")) .'</td>
                </tr>
                <tr class="band">
        <td>服务器IP地址</td><td>'. $_SERVER["SERVER_ADDR"].":".$_SERVER["SERVER_PORT"] .'</td>
        <td>VARIANT support</td><td>'. tc(get_magic_quotes_gpc("VARIANT support")) .'</td>
                </tr>
                <tr class="line">
        <td>客户端IP地址</td><td>'. GetIP() .'</td>
        <td>FTP support</td><td>'. tc(get_magic_quotes_gpc("FTP support")) .'</td>
            </tr>
            <tr class="band">
              <td>PHP被禁用的函数</td>
              <td>'. $server_func .'</td>
              <td>PCRE (Perl Compatible Regular Expressions) Support</td>
              <td>'. tc(get_magic_quotes_gpc("PCRE (Perl Compatible Regular Expressions) Support")) .'</td>
            </tr>
            <tr class="line">
              <td>Client API version</td>
              <td>'. tc(get_magic_quotes_runtime("Client API version")) .'</td>
              <td>WDDX Support</td>
              <td>'. tc(get_magic_quotes_gpc("WDDX Support")) .'</td>
            </tr>
            <tr class="band">
              <td>SMTP(地址:'. get_cfg_var("SMTP") .')</td>
              <td>'. tc(get_magic_quotes_gpc("smtp")) .'</td>
              <td>XML Support</td>
              <td>'. tc(get_magic_quotes_gpc("XML Support")) .'</td>
            </tr>
            <tr class="line">
              <td>PHP安全模式(Safe_mode)</td>
              <td>';
              echo $server_safe;
              echo '</td>
              <td>服务器技术支持</td>
              <td>'.loader_image("icon/letter.png","E-mail"). " <a href='mailto:".$_SERVER["SERVER_ADMIN"]."'>".$_SERVER["SERVER_ADMIN"]."</a>" .'</td>
            </tr>
            <tr class="band">
              <td>本页服务器路径</td>
              <td title="'. $_SERVER["SCRIPT_FILENAME"] .'">'. format_url($_SERVER["SCRIPT_FILENAME"],30) .'</td>
              <td>对主机进行1+1的100万次计算</td>
              <td>'.( $ttime!="0.0000000秒"?"<span class='text-yes'>".$ttime."</span>":"" ).'
		<input type="submit" value="测试" class="button" name="test" onclick="location.href=\'?action=cost\';" />
		<input type="submit" value="PHPInfo" class="button" name="test" onclick="window.open(\'?action=phpinfo\');" />
		</td>
            </tr>
            
        </table>
    ';
    ?>
<!--body end-->

<?php html_close();?>