Files
web.ems/wxc2_omc/security/userManage/batchAddConf.php
agtuser 16a3fd1e1b init
2024-11-11 17:56:00 +08:00

199 lines
5.1 KiB
PHP
Executable File

<?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'];
$sysUser="sysUser";
?>
<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);
}
function changeAgentContent(){
document.getElementById("inputFileAgent").value = document.getElementById("impFile").value;
}
</script>
<?php
if ($confMode == 'BatchAdd'){
?>
<form action="<?php echo"$PHP_SELF?table_name=$table_name"; ?>" enctype="multipart/form-data" method="POST" name="subsData" >
<table bgcolor="#FFFFEF" border="1" width="100%" cellpadding="2" cellspacing="0" bordercolor="#666666" bordercolordark="#FFFFFF" >
<tr bgcolor="#E6E6E6">
<td width=100% colspan=2 align=center>
<font size=3><b>
<?php echo $batchAddUser;
?>
</b></font>
</td>
</tr>
<tr>
<td colspan=2>
<font color="#0000FF" size=2><?php echo "$strAddRecordNum <= 100";?></font>
</td>
</tr>
<tr>
<td><?php echo "$strSelectFile";?>:</td>
<td>
<input type="file" name="impFile" id="impFile" style="display:none" onchange="changeAgentContent()">
<input type="text" value="" readonly id="inputFileAgent" />
<input type="button" onclick="document.getElementById('impFile').click()" value="<?php echo $strBrowse;?>" class="button"/>
<input type="hidden" name="MAX_FILE_SIZE" value="20971520"><!-- MAX_FILE_SIZE = 20M -->
</td>
</tr>
<tr>
<td colspan=2>
<input type="submit" name="Submit" id="Submit" value="<?php echo $strSubmit; ?>" class="button">
</td>
</tr>
</table>
</form>
<?php
echo "<font color=red>$impRemark</font>";
}
/* $content = @file_get_contents($txt);
if ($content === false) {
echo '无法读取文件内容';
} elseif (strlen($content) === 0) {
echo '文件没有内容';
} else {
echo '不是空文件';
}*/
if( $_FILES['impFile']['name']){
$test=file_get_contents($_FILES['impFile']['tmp_name']);
if($DEBUG){
echo mb_detect_encoding($test, array('GB2312','GBK','UTF-16','UCS-2','UTF-8','BIG5','ASCII'));
print_r(explode(",",$test));
}
$array=explode(",",$test);
$newArr=array_chunk($array,4);
// print_r($array);
// echo print_r($newArr[1][0]);
// echo sizeof($newArr);
// echo sizeof($array);
// foreach($newArr[0] as $value)
if(sizeof($array)%4==0){
for($i=0;$i<sizeof($newArr);$i++){
if(sizeof($newArr[$i])){
$realName=$newArr[$i][0];
$userName=$newArr[$i][1];
$password=$newArr[$i][2];
$privilege=$newArr[$i][3];
$salt=rand(1000,9999); //生成4位随机字符串
$realPwd=md5($password.$salt);
$batchSql="INSERT INTO $sysUser (realName,userName,password,privilege,updateTime,salt)VALUES('$realName','$userName','$realPwd','$privilege',CURRENT_TIMESTAMP,'$salt')";
//echo $batchSql;
// debug_log("/tmp/test.txt", $batchSql);
mysqli_query($pubConn,$batchSql);
$errStr= mysqli_error($pubConn);
if ($errStr!=null)
{
// echo "batchSql=$batchSql<br>";
echo mysqli_error($pubConn);
}else {
$j=$i+1;
}
}
}//end for
echo "<script>
alert('$totalNum:$j');
</script>";
echo " <meta http-equiv=\"refresh\" content=\"3; url=./userList.php\"> ";
}else{
echo "<script>
alert('$checkImport');
history.go(-1);
</script>";
}
}
?>
</html>