欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

用php写的serv-u的web申请账号的程序

程序员文章站 2022-11-01 13:01:06
<?
//sign.php
//系统适用于win2000
$path="e:\\serv-u\\servudaemon.ini";//用户文件的路径
$fabu="e:\\web\\";//总web路径
if($add)
{
$fp1=fopen($path,"r+");
$str=fread($fp1, filesize($path));
$fp=fopen($path,"a");
flock($fp,3);
$us="=".$userid;
$start=strpos($str,$us);
if($start)
    {
echo "对不起,该用户已经存在";
    }else{
$start1=strpos($str,"user1");
if($start1){
$start=$start1+6;
$end=strpos($str,"|",$start);
$firstusername=substr($str,$start,$end-$start);
$start2=strpos($str,"[user=".$firstusername."|1]");
$usernum=count(split("\r\n",substr($str,$start1,$start2-$start1)));
        }else
        {
$usernum=1;
        }
$userinfo="user".$usernum."=".$userid."|1|0"."\r\n";
$userpath=$fabu.$userid;
@mkdir($userpath,0700);
$maxsize=$size*1024;
$userp="[user=".$userid."|1]"."\r\n";
$userp.="password=".$password."\r\n";
$userp.="homedir=".$userpath."\r\n";
$userp.="relpaths=1"."\r\n";
$userp.="diskquota=1|".$maxsize."|0"."\r\n";
$userp.="maxusersloginperip=2"."\r\n";
$userp.="timeout=600"."\r\n";
$userp.="access1=".$userpath."|rwamlcdp"."\r\n";

if($start2){
$content=substr($str,$start2,strlen($str)-$start2);
$content.=$userp;
$userinfo.=$content;
    fseek($fp1,$start2,seek_set);
    fputs($fp1,$userinfo);
}else
        {
fputs($fp,$userinfo);
fputs($fp,$userp);
        }
//echo $firstusername;
//echo $start;
//echo "<br>";
//echo $end;


            }
fclose($fp);
fclose($fp1);
}
?>



<form method=post action="sign.php">
账号:<input type="text" name="userid" size=10 maxlength=20 ><br>密码:
<input type="password" name="password" size=10 maxlength=20 ><br>空间大小:<input type="text" name="size" size=4 maxlength=4> m<br><input type="submit" name="add" value="增加用户">
</form>