分类: BSD
2006-06-13 11:29:03
FreeBSD全能服务器安装手册之文件服务器篇之C用户密码自主管理篇
##############################增加FTP密码自助修改功能#########################
%%%%%%%%%%%%%%%%%%%%%config.php%%%%%%%%%%%%%%%%%%%%%
$local="localhost";
$u_name="ftp";
$cpasswd="e89120d9dfeb";
$db_name="ftpusers";
//用户名、密码、数据库名字请自行修改为自己的
?>
function local(){
global $local;
return $local;
}
function u_name(){
global $u_name;
return $u_name;
}
function passwd(){
global $cpasswd;
return $cpasswd;
}
function db_name(){
global $db_name;
return $db_name;
}
?>
%%%%%%%%%%%%%%%%%%%%connect.php%%%%%%%%%%%%%%%%%%%%%
$connectino=mysql_connect(local(),u_name(),passwd()) or die ("数据库连接失败");
$select=mysql_select_db(db_name()) or die ("数据库打开失败");
?>
%%%%%%%%%%%%%%%%%%%index.php%%%%%%%%%%%%%%%%%%%%%%%
require("config.php");
if(!empty($_GET["action"])) {
if($_GET["action"]=="edit"){
require("connect.php");
$flag=0;
if(empty($_POST['passwd'])){
$flag=1;
echo "";
}
if(empty($_POST['passwd1'])){
$flag=1;
echo "";
}
if(empty($_POST['passwd2'])){
$flag=1;
echo "";
}
if((strlen($_POST["passwd1"])<1)||(strlen($_POST["passwd1"])>100)){
$flag=1;
echo "";
}
if((strlen($_POST["passwd2"])<1)||(strlen($_POST["passwd2"])>100)){
$flag=1;
echo "";
}
if($_POST["passwd1"]!=$_POST["passwd2"]){
$flag=1;
echo "";
}
$passwd_old=md5($_POST['passwd']);
$passwd_new=md5($_POST['passwd1']);
if($flag==0){
$sql="select * from users where User='".$_POST['User']."' and Password='".$passwd_old."'";
$result=mysql_query($sql);
$myrow1=mysql_num_rows($result);
if($myrow1==0){
echo "";
}else{
$sql ="update users set Password='".$passwd_new."' where User='".$_POST['User']."'";
$resulta=mysql_query($sql);
echo "修改成功!";
}
}
}
}else{
?>
提交"> 还原">
修改FTP服务器登陆密码 用户名: 原密码: 新密码: 密码确认:
}
?>
%%%%%%%%%%%%%%%%%建立对应连接或虚拟主机%%%%%%%%%%%%%%%%%
编辑httpd.conf
ee /usr/local/etc/apache/httpd.conf
添加虚拟主机 passwd.chb.com
DocumentRoot /home/passwd
ServerName passwd.chb.com
allow from all
Options +Indexes
当然DNS里也要添加相应指向
测试FTP密码自助修改功能