<?php
/*********************************************************
程序说明:
功能说明:本程序实现对系统配置每个用户的超时空闲时间进行编辑
调用关系:调用:header.inc
变量说明:
返回值:无
作者:

修改注释:
NO.1
姓名:
时间:
修改说明:
 *********************************************************/
require("../../inc/header.inc");

?>
<body leftmargin="15" rightmargin="10" onload="javascript:adjust_frame('up');" onresize="javascript:adjust_frame('up');" style="background-color:#FFFAF4;overflow:hidden;overflow-x:hidden;overflow-y:hidden;">
<?php
//adjust_head();
//adjust_title_head();
/*
echo "<br>";
echo "<table id=\"table_up\" border=\"0\" width=\"100%\">";
	echo "<tr>";
	echo "<td width=\"50%\" align=\"left\">";
	echo "$strAdvanced > $strOmcUser";
	echo "</td>";
	echo "</tr>";
	echo "</table>";*/
//adjust_title_tail();
adjust_content_head();
echo "<br>";

$DEBUG = 0;
$pubDb		='OMC_PUB';
$table_name	='sysUser'; /*密码强度表*/

if($DEBUG)	echo "userInfo[ID] = $userInfo[ID]<br>";
$confMode=$_REQUEST['confMode'];
$timeOut=$_REQUEST['timeOut']; //字符Unicode类别
if($DEBUG) echo "confMode=$confMode<br>";
$userName=$_REQUEST['userName'];

?>

<script language="JavaScript">

    function question_Validator(theForm)
    {


        if(theForm.timeOut.value==''){
            var AccountEmpty="<?php echo $strTimeCannotBeEmpty; ?>";
            alert(AccountEmpty);
            theForm.timeOut.focus();
            return(false);
        }else{

            if(theForm.timeOut.value <300  || theForm.timeOut.value>3600){
                var TimeConfirm="<?php echo $outtimeInfo; ?>";
                alert(TimeConfirm);
                theForm.timeOut.focus();
                return (false);
            }

	}
        return (true);
    }




</script>

<?php
if ($confMode == 'timeout'){
    ?>
    <form action="<?php echo"$PHP_SELF?table_name=$table_name&userName=$userName"; ?>"  method="POST"  onsubmit="return question_Validator(this)" name="operForm" >

        <table class="formCenter">
            <tr>
                <td colspan=3 vAlign="top"  bgcolor="#E6E6E6" height="12"><b>
                        <?php

                        echo $configTimeout1;   //配置空闲超时时间

                        ?>
                    </b></td>
            </tr>


            <tr>
                <td><?php echo $strName; ?></td>
                <td><?php echo $userName; ?></td>
                <td width="150"></td>
            </tr>

            <tr>
                <td><?php echo $timeoutNum; ?></td>
                <td><input type="text" name="timeOut" id="timeOut" maxlength="16" size="16" value="" class="text"></td><!--类型的输入框-->
                <td width="150"><?php echo $outtimeInfo; ?></td>     
            </tr>




            <tr align="center">
                <td colspan=3  width=600 align=center><p>
                        <?php
                        echo "<input type=\"submit\" name=\"config\"  value=\"$strConfig\" class=\"button\">&nbsp;&nbsp;"; //配置按钮
                        echo "<input type=\"reset\" name=\"reset\" value=\"$strCancel\" class=\"button\">&nbsp;&nbsp;";
                        echo "<input type=\"button\"  value=\"$strReturn\" class=\"button\" onclick=javascript:location.href=\"./userList.php\";>&nbsp;&nbsp;";
                        ?>

                </td>
            </tr>
        </table>
    </form>
    <?php
}
?>

<?php
//配置密码强度


//echo "<br>realName=$realName,userName=$userName,password=$password,privilege=$privilege,updateTime=$updateTime";
$config=$_POST['config'];
if($config){
//获取输入的数据,

    $select_sql ="SELECT  count(*) as number_of_records
			FROM $table_name 
			WHERE timeOut='$timeOut' and userName='$userName'";   //配置并没有改动,则不添?????


    $result = mysqli_query($pubConn,$select_sql);
    $record = @mysqli_fetch_object($result);
    $number_of_records = $record->number_of_records;
    //echo "<br>number_of_records=$number_of_records";
   if($DEBUG) echo "<br>select_sql=$select_sql";

    if($number_of_records){
        echo "<script language=\"javascript\"> ";
        echo "alert('";
        echo "$timeConfigFails";  /*未有改动的地方,请重新配置*/
        echo "'); ";
        echo "</script>";
        echo " <meta http-equiv=\"refresh\" content=\"3; url=./userList.php\"> ";
        adjust_content_tail();
        exit();
    }else{
//		$str_sql="REPLACE INTO $table_name
//			( realName,userName,password,privilege,updateTime)
//			VALUES
//			 ('$realName','$userName',md5('$password'),'$privilege',CURRENT_TIMESTAMP)
//			 ";

//修改空闲超时时间
        $str_sql="UPDATE 
             $table_name
			 set timeout='$timeOut' WHERE userName='$userName'
			 ";



        $result=mysqli_query($pubConn,$str_sql);
        //	echo "sql=$str_sql";
        echo mysqli_error($pubConn);
        if(!$result){
            echo "<script language=\"javascript\"> ";
            echo "alert('";
            echo "$strConfigtimeFails"; /*???????失败*/
            echo "'); ";
            echo "</script>";
            echo " <meta http-equiv=\"refresh\" content=\"5; url=./userList.php\"> ";
            adjust_content_tail();
            exit();
        }else{
            echo "<script language=\"javascript\"> ";
            echo "alert('";
            echo "$strConfigtimeSucceeds";/*配置成功*/
            echo "'); ";
            echo "</script>";
            echo " <meta http-equiv=\"refresh\" content=\"0; url=./userList.php\"> ";
            adjust_content_tail();
            exit();
        }
    }
}

adjust_content_tail();

?>

</html>





