ASP + serv-u code to implement FTP

Source: Internet
Author: User
Tags copy ftp implement ini lowercase md5 md5 encryption
Serv-u <!--#include file= "md5.asp"-->
<%
'**************************************************
' * Author: awaysrain (absolute 0 degrees) *
' * Completion time: 2003-10-10 *
' * Test environment: win2000server,serv-u 4.2-beta Version *
'**************************************************
Dim Inipath,inifilename,inistr,tmpstr,n
Dim username,password,tmp

UserName = "myfso222" User name
PassWord = "Awaysrain" ' Password
TMP = "AI" randomly generates two lowercase letters (should be randomly generated, but I omitted here)
PassWord = tmp & UCase (MD5 (passWord)) ' Password, is MD5 encrypted, using the MD5 encryption program, the specific algorithm is randomly generated two-bit lowercase letters, and then connect with your password after the MD5 encryption, The randomly generated passwords and MD5 encrypted results are stored as passwords, for example, the following Awaysrain users, my password for the Awaysrain first randomly generated two-bit lowercase letter ai, And my password awaysrain connection get Aiawaysrain aiawaysrain MD5 encryption get 9118bfd94a9ce9cf37ae5baa947ed596 the results of randomly generated two-bit lowercase letters AI and MD5 encrypted 9118BFD94A9CE9CF 37ae5baa947ed596 Connection Get password ai9118bfd94a9ce9cf37ae5baa947ed596

Inipath= the path to the "D:\Program files\serv-u" INI file
Inifilename = filename of "Servudaemon.ini" ini

Set fso=server.createobject ("Scripting.FileSystemObject")
Set Servuini = fso. OpenTextFile (IniPath & "\" & Inifilename,1,false)

Inistr = ""
n = 0
Addeduserlist = False

Set tf = fso. CreateTextFile (IniPath & "\" & Inifilename & ". _awaysrain.tmp", True)
' Generate a new temporary INI file

Do as not Servuini.atendofstream
TMPSTR = Servuini.readline

If Instr ("awaysrain| |" & Tmpstr, "awaysrain| | User ") >0 Then
' Record the original number of users
n = n+1
End If

If Instr ("awaysrain| |" & Tmpstr, "awaysrain| | [user= ") >0 and not addeduserlist Then
' Add the current user to the section of the user list
n = n +1
Tf. WriteLine ("User" & N & "=" & UserName & "|1|0")
Addeduserlist = True
End If
Tf. WriteLine (TMPSTR)
Loop
Servuini.close

' Add new user information, content can be new in serv-u and control INI file

Tf. WriteLine ("[user=" & UserName & "|1]") ' username
Tf. WriteLine ("password=" & Password) ' Password
Tf. WriteLine ("homedir=e:\temp") ' Home directory
Tf. WriteLine ("Relpaths=1") ' locks the user to the home directory
Tf. WriteLine ("maxusersloginperip=1") ' same IP logon number
Tf. WriteLine ("speedlimitdown=102400") ' Max download speed
Tf. WriteLine ("timeout=600") ' Idle timeout (seconds)
Tf. WriteLine ("access1=e:\temp| RLP ")" accessible directory, can not be a, such as ' access2=e:\temp1| RLP '

Tf. Close
'--------------------back up the original INI file--------------------------
Set f1 = fso. GetFile (IniPath & "\" & Inifilename)
F1. Copy (IniPath & "\" & Inifilename & ". _awaysrain.bak")
F1. Delete
'--------------------change the generated temporary INI file to a formal INI--------------------------
Set f1 = fso. GetFile (IniPath & "\" & Inifilename & ". _awaysrain.tmp")
F1. Copy (IniPath & "\" & Inifilename)
F1. Delete

Set FSO = Nothing
%>

Note: The above code assumes that the format in Servudaemon.ini has only one domain and has at least one user

The Servudaemon.ini file structure for the test is as follows:
==================================
[Domain1]
User1=222|1|0
User2=myfso111|1|0
[User=222|1]
Password=hwb1ecf70cdaf5dae2b981ae394eefcdc0
Homedir=e:\temp
Relpaths=1
timeout=600
access1=e:\temp| RLP
[User=myfso111|1]
password=ai9118bfd94a9ce9cf37ae5baa947ed596
Homedir=e:\temp
Relpaths=1
timeout=600
access1=e:\temp| RLP

The resulting file structure is as follows
==================================
[Domain1]
User1=222|1|0
User2=myfso111|1|0
User3=myfso222|1|0
[User=222|1]
Password=hwb1ecf70cdaf5dae2b981ae394eefcdc0
Homedir=e:\temp
Relpaths=1
timeout=600
access1=e:\temp| RLP
[User=myfso111|1]
password=ai9118bfd94a9ce9cf37ae5baa947ed596
Homedir=e:\temp
Relpaths=1
timeout=600
access1=e:\temp| RLP
[User=myfso222|1]
password=ai9118bfd94a9ce9cf37ae5baa947ed596
Homedir=e:\temp
Relpaths=1
timeout=600
access1=e:\temp| RLP


Attached md5.asp
==========================================
<%
Private Const Bits_to_a_byte = 8
Private Const Bytes_to_a_word = 4
Private Const Bits_to_a_word = 32

Private M_lonbits (30)
Private M_l2power (30)

Private Function LShift (LValue, Ishiftbits)
If ishiftbits = 0 Then
LShift = LValue
Exit Function
ElseIf ishiftbits = Then
If LValue and 1 Then
LShift = &



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.