<%
Option Explicit
response.charset="gb2312"
session.codepage="936"
dim MainPath,sPath,FullsPath
dim FileLoginName,FileLoginPwd,loginname,loginpwd
FileLoginName="063d19f59db7949b1"
FileLoginPwd="063d19f59db7949b2"
MainPath = "/"

Dim fs, sAction, sFile, sFolder, sFileType, scriptname, dbfile, ReadStream, WriteFile, fileobject,filename
Dim filecollection, file, startpath, lineid, bgcolor, bgcolor_on, bgcolor_off, foldercollection, folder, errornum, errorcode
errornum = 0
errorcode = ""
scriptname=Request.ServerVariables("Script_Name")
sAction = Request.Querystring("action")     

 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 = 31 Then
   If lValue And 1 Then
    LShift = &H80000000
   Else
    LShift = 0
   End If
   Exit Function
  ElseIf iShiftBits < 0 Or iShiftBits > 31 Then
   Err.Raise 6
  End If

  If (lValue And m_l2Power(31 - iShiftBits)) Then
   LShift = ((lValue And m_lOnBits(31 - (iShiftBits + 1))) * m_l2Power(iShiftBits)) Or &H80000000
  Else
   LShift = ((lValue And m_lOnBits(31 - iShiftBits)) * m_l2Power(iShiftBits))
  End If
 End Function

 Private Function RShift(lValue, iShiftBits)
  If iShiftBits = 0 Then
   RShift = lValue
   Exit Function
  ElseIf iShiftBits = 31 Then
   If lValue And &H80000000 Then
    RShift = 1
   Else
    RShift = 0
   End If
   Exit Function
  ElseIf iShiftBits < 0 Or iShiftBits > 31 Then
   Err.Raise 6
  End If
  
  RShift = (lValue And &H7FFFFFFE) \ m_l2Power(iShiftBits)

  If (lValue And &H80000000) Then
   RShift = (RShift Or (&H40000000 \ m_l2Power(iShiftBits - 1)))
  End If
 End Function

 Private Function RotateLeft(lValue, iShiftBits)
  RotateLeft = LShift(lValue, iShiftBits) Or RShift(lValue, (32 - iShiftBits))
 End Function

 Private Function AddUnsigned(lX, lY)
  Dim lX4
  Dim lY4
  Dim lX8
  Dim lY8
  Dim lResult
  
  lX8 = lX And &H80000000
  lY8 = lY And &H80000000
  lX4 = lX And &H40000000
  lY4 = lY And &H40000000
  
  lResult = (lX And &H3FFFFFFF) + (lY And &H3FFFFFFF)
  
  If lX4 And lY4 Then
   lResult = lResult Xor &H80000000 Xor lX8 Xor lY8
  ElseIf lX4 Or lY4 Then
   If lResult And &H40000000 Then
    lResult = lResult Xor &HC0000000 Xor lX8 Xor lY8
   Else
    lResult = lResult Xor &H40000000 Xor lX8 Xor lY8
   End If
  Else
   lResult = lResult Xor lX8 Xor lY8
  End If
  
  AddUnsigned = lResult
 End Function

 Private Function md5_F(x, y, z)
  md5_F = (x And y) Or ((Not x) And z)
 End Function

 Private Function md5_G(x, y, z)
  md5_G = (x And z) Or (y And (Not z))
 End Function

 Private Function md5_H(x, y, z)
  md5_H = (x Xor y Xor z)
 End Function

 Private Function md5_I(x, y, z)
  md5_I = (y Xor (x Or (Not z)))
 End Function

 Private Sub md5_FF(a, b, c, d, x, s, ac)
  a = AddUnsigned(a, AddUnsigned(AddUnsigned(md5_F(b, c, d), x), ac))
  a = RotateLeft(a, s)
  a = AddUnsigned(a, b)
 End Sub

 Private Sub md5_GG(a, b, c, d, x, s, ac)
  a = AddUnsigned(a, AddUnsigned(AddUnsigned(md5_G(b, c, d), x), ac))
  a = RotateLeft(a, s)
  a = AddUnsigned(a, b)
 End Sub

 Private Sub md5_HH(a, b, c, d, x, s, ac)
  a = AddUnsigned(a, AddUnsigned(AddUnsigned(md5_H(b, c, d), x), ac))
  a = RotateLeft(a, s)
  a = AddUnsigned(a, b)
 End Sub

 Private Sub md5_II(a, b, c, d, x, s, ac)
  a = AddUnsigned(a, AddUnsigned(AddUnsigned(md5_I(b, c, d), x), ac))
  a = RotateLeft(a, s)
  a = AddUnsigned(a, b)
 End Sub

 Private Function ConvertToWordArray(sMessage)
  Dim lMessageLength
  Dim lNumberOfWords
  Dim lWordArray()
  Dim lBytePosition
  Dim lByteCount
  Dim lWordCount
  
  Const MODULUS_BITS = 512
  Const CONGRUENT_BITS = 448
  
  lMessageLength = Len(sMessage)
  
  lNumberOfWords = (((lMessageLength + ((MODULUS_BITS - CONGRUENT_BITS) \ BITS_TO_A_BYTE)) \ (MODULUS_BITS \ BITS_TO_A_BYTE)) + 1) * (MODULUS_BITS \ BITS_TO_A_WORD)
  ReDim lWordArray(lNumberOfWords - 1)
  
  lBytePosition = 0
  lByteCount = 0
  Do Until lByteCount >= lMessageLength
   lWordCount = lByteCount \ BYTES_TO_A_WORD
   lBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE
   lWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(Asc(Mid(sMessage, lByteCount + 1, 1)), lBytePosition)
   lByteCount = lByteCount + 1
  Loop

  lWordCount = lByteCount \ BYTES_TO_A_WORD
  lBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE

  lWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(&H80, lBytePosition)

  lWordArray(lNumberOfWords - 2) = LShift(lMessageLength, 3)
  lWordArray(lNumberOfWords - 1) = RShift(lMessageLength, 29)
  
  ConvertToWordArray = lWordArray
 End Function

 Private Function WordToHex(lValue)
  Dim lByte
  Dim lCount
  
  For lCount = 0 To 3
   lByte = RShift(lValue, lCount * BITS_TO_A_BYTE) And m_lOnBits(BITS_TO_A_BYTE - 1)
   WordToHex = WordToHex & Right("0" & Hex(lByte), 2)
  Next
 End Function

 Public Function MD5(sMessage)
  m_lOnBits(0) = CLng(1)
  m_lOnBits(1) = CLng(3)
  m_lOnBits(2) = CLng(7)
  m_lOnBits(3) = CLng(15)
  m_lOnBits(4) = CLng(31)
  m_lOnBits(5) = CLng(63)
  m_lOnBits(6) = CLng(127)
  m_lOnBits(7) = CLng(255)
  m_lOnBits(8) = CLng(511)
  m_lOnBits(9) = CLng(1023)
  m_lOnBits(10) = CLng(2047)
  m_lOnBits(11) = CLng(4095)
  m_lOnBits(12) = CLng(8191)
  m_lOnBits(13) = CLng(16383)
  m_lOnBits(14) = CLng(32767)
  m_lOnBits(15) = CLng(65535)
  m_lOnBits(16) = CLng(131071)
  m_lOnBits(17) = CLng(262143)
  m_lOnBits(18) = CLng(524287)
  m_lOnBits(19) = CLng(1048575)
  m_lOnBits(20) = CLng(2097151)
  m_lOnBits(21) = CLng(4194303)
  m_lOnBits(22) = CLng(8388607)
  m_lOnBits(23) = CLng(16777215)
  m_lOnBits(24) = CLng(33554431)
  m_lOnBits(25) = CLng(67108863)
  m_lOnBits(26) = CLng(134217727)
  m_lOnBits(27) = CLng(268435455)
  m_lOnBits(28) = CLng(536870911)
  m_lOnBits(29) = CLng(1073741823)
  m_lOnBits(30) = CLng(2147483647)
  
  m_l2Power(0) = CLng(1)
  m_l2Power(1) = CLng(2)
  m_l2Power(2) = CLng(4)
  m_l2Power(3) = CLng(8)
  m_l2Power(4) = CLng(16)
  m_l2Power(5) = CLng(32)
  m_l2Power(6) = CLng(64)
  m_l2Power(7) = CLng(128)
  m_l2Power(8) = CLng(256)
  m_l2Power(9) = CLng(512)
  m_l2Power(10) = CLng(1024)
  m_l2Power(11) = CLng(2048)
  m_l2Power(12) = CLng(4096)
  m_l2Power(13) = CLng(8192)
  m_l2Power(14) = CLng(16384)
  m_l2Power(15) = CLng(32768)
  m_l2Power(16) = CLng(65536)
  m_l2Power(17) = CLng(131072)
  m_l2Power(18) = CLng(262144)
  m_l2Power(19) = CLng(524288)
  m_l2Power(20) = CLng(1048576)
  m_l2Power(21) = CLng(2097152)
  m_l2Power(22) = CLng(4194304)
  m_l2Power(23) = CLng(8388608)
  m_l2Power(24) = CLng(16777216)
  m_l2Power(25) = CLng(33554432)
  m_l2Power(26) = CLng(67108864)
  m_l2Power(27) = CLng(134217728)
  m_l2Power(28) = CLng(268435456)
  m_l2Power(29) = CLng(536870912)
  m_l2Power(30) = CLng(1073741824)


  Dim x
  Dim k
  Dim AA
  Dim BB
  Dim CC
  Dim DD
  Dim a
  Dim b
  Dim c
  Dim d
  
  Const S11 = 7
  Const S12 = 12
  Const S13 = 17
  Const S14 = 22
  Const S21 = 5
  Const S22 = 9
  Const S23 = 14
  Const S24 = 20
  Const S31 = 4
  Const S32 = 11
  Const S33 = 16
  Const S34 = 23
  Const S41 = 6
  Const S42 = 10
  Const S43 = 15
  Const S44 = 21

  x = ConvertToWordArray(sMessage)
  
  a = &H67452301
  b = &HEFCDAB89
  c = &H98BADCFE
  d = &H10325476

  For k = 0 To UBound(x) Step 16
   AA = a
   BB = b
   CC = c
   DD = d
  
   md5_FF a, b, c, d, x(k + 0), S11, &HD76AA478
   md5_FF d, a, b, c, x(k + 1), S12, &HE8C7B756
   md5_FF c, d, a, b, x(k + 2), S13, &H242070DB
   md5_FF b, c, d, a, x(k + 3), S14, &HC1BDCEEE
   md5_FF a, b, c, d, x(k + 4), S11, &HF57C0FAF
   md5_FF d, a, b, c, x(k + 5), S12, &H4787C62A
   md5_FF c, d, a, b, x(k + 6), S13, &HA8304613
   md5_FF b, c, d, a, x(k + 7), S14, &HFD469501
   md5_FF a, b, c, d, x(k + 8), S11, &H698098D8
   md5_FF d, a, b, c, x(k + 9), S12, &H8B44F7AF
   md5_FF c, d, a, b, x(k + 10), S13, &HFFFF5BB1
   md5_FF b, c, d, a, x(k + 11), S14, &H895CD7BE
   md5_FF a, b, c, d, x(k + 12), S11, &H6B901122
   md5_FF d, a, b, c, x(k + 13), S12, &HFD987193
   md5_FF c, d, a, b, x(k + 14), S13, &HA679438E
   md5_FF b, c, d, a, x(k + 15), S14, &H49B40821
  
   md5_GG a, b, c, d, x(k + 1), S21, &HF61E2562
   md5_GG d, a, b, c, x(k + 6), S22, &HC040B340
   md5_GG c, d, a, b, x(k + 11), S23, &H265E5A51
   md5_GG b, c, d, a, x(k + 0), S24, &HE9B6C7AA
   md5_GG a, b, c, d, x(k + 5), S21, &HD62F105D
   md5_GG d, a, b, c, x(k + 10), S22, &H2441453
   md5_GG c, d, a, b, x(k + 15), S23, &HD8A1E681
   md5_GG b, c, d, a, x(k + 4), S24, &HE7D3FBC8
   md5_GG a, b, c, d, x(k + 9), S21, &H21E1CDE6
   md5_GG d, a, b, c, x(k + 14), S22, &HC33707D6
   md5_GG c, d, a, b, x(k + 3), S23, &HF4D50D87
   md5_GG b, c, d, a, x(k + 8), S24, &H455A14ED
   md5_GG a, b, c, d, x(k + 13), S21, &HA9E3E905
   md5_GG d, a, b, c, x(k + 2), S22, &HFCEFA3F8
   md5_GG c, d, a, b, x(k + 7), S23, &H676F02D9
   md5_GG b, c, d, a, x(k + 12), S24, &H8D2A4C8A
    
   md5_HH a, b, c, d, x(k + 5), S31, &HFFFA3942
   md5_HH d, a, b, c, x(k + 8), S32, &H8771F681
   md5_HH c, d, a, b, x(k + 11), S33, &H6D9D6122
   md5_HH b, c, d, a, x(k + 14), S34, &HFDE5380C
   md5_HH a, b, c, d, x(k + 1), S31, &HA4BEEA44
   md5_HH d, a, b, c, x(k + 4), S32, &H4BDECFA9
   md5_HH c, d, a, b, x(k + 7), S33, &HF6BB4B60
   md5_HH b, c, d, a, x(k + 10), S34, &HBEBFBC70
   md5_HH a, b, c, d, x(k + 13), S31, &H289B7EC6
   md5_HH d, a, b, c, x(k + 0), S32, &HEAA127FA
   md5_HH c, d, a, b, x(k + 3), S33, &HD4EF3085
   md5_HH b, c, d, a, x(k + 6), S34, &H4881D05
   md5_HH a, b, c, d, x(k + 9), S31, &HD9D4D039
   md5_HH d, a, b, c, x(k + 12), S32, &HE6DB99E5
   md5_HH c, d, a, b, x(k + 15), S33, &H1FA27CF8
   md5_HH b, c, d, a, x(k + 2), S34, &HC4AC5665
  
   md5_II a, b, c, d, x(k + 0), S41, &HF4292244
   md5_II d, a, b, c, x(k + 7), S42, &H432AFF97
   md5_II c, d, a, b, x(k + 14), S43, &HAB9423A7
   md5_II b, c, d, a, x(k + 5), S44, &HFC93A039
   md5_II a, b, c, d, x(k + 12), S41, &H655B59C3
   md5_II d, a, b, c, x(k + 3), S42, &H8F0CCC92
   md5_II c, d, a, b, x(k + 10), S43, &HFFEFF47D
   md5_II b, c, d, a, x(k + 1), S44, &H85845DD1
   md5_II a, b, c, d, x(k + 8), S41, &H6FA87E4F
   md5_II d, a, b, c, x(k + 15), S42, &HFE2CE6E0
   md5_II c, d, a, b, x(k + 6), S43, &HA3014314
   md5_II b, c, d, a, x(k + 13), S44, &H4E0811A1
   md5_II a, b, c, d, x(k + 4), S41, &HF7537E82
   md5_II d, a, b, c, x(k + 11), S42, &HBD3AF235
   md5_II c, d, a, b, x(k + 2), S43, &H2AD7D2BB
   md5_II b, c, d, a, x(k + 9), S44, &HEB86D391
  
   a = AddUnsigned(a, AA)
   b = AddUnsigned(b, BB)
   c = AddUnsigned(c, CC)
   d = AddUnsigned(d, DD)
  Next
  MD5=LCase(WordToHex(b) & WordToHex(c))
 End Function
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
body{font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 12px; text-align:center; margin:0px; padding:0px;} 
a{ color:#000000; text-decoration:none;}
a:link{ color:#000000; text-decoration:none;}
a:hover{ color:#000000; background-color:#cccccc; text-decoration:underline;}

#PageBody{font-family:Verdana, Arial, Helvetica, sans-serif; font-size: 12px; width:700px; text-align:left; border:1px solid #000000;margin:10px auto;}
#index_head{color:#FFFFFF; background-color:#000000; font-weight:bold; height:24px; line-height:24px;width:100%; margin:0px;}
.head_right{color:#FFFF00; float:right; width:50px; text-decoration:underline;}

#index_head a{ color:#FFFF00; text-decoration:none;}
#index_head a:link{ color:#FFFF00; text-decoration:underline;}
#index_head a:hover{ color:#FFFF00; background-color:#999999; text-decoration:none;}

#index_body{line-height:22px;width:100%; background-color:#CCCCCC;vertical-align:top;}
#body_left{width:120px; float:left;}
#body_right{padding:10px; background-color:#FFFFFF;border-left:1px solid #000000; width:555px;height:auto; min-height:500px; float:right;}
#body_left ul{padding-top:10px;}
#body_left ul li{ list-style:square;}
#body_left ul li a{ color:#000000; text-decoration:underline;}
#body_left ul li a:link{ color:#000000; text-decoration:underline;}
#body_left ul li a:hover{ color:#000000; background-color:#999999; text-decoration:underline;}


#body_title{color:#000000; padding-left:20px; width:500px;}
#body_content{color:#000000; padding-left:20px; padding-top:10px; width:500px; height:80px;}
#body_content ul{ margin:0px;}
#body_content ul li{ list-style:none;}

#body_login{color:#000000; font-weight:bold; padding-top:80px; text-align:center;}
#body_login ul li{ list-style:none; height:30px;}
.login_input{width:140px; border:1px solid #666666;}
.input_button{border:1px solid #666666; background-color:#FFFFFF;}

#body_rename{color:#000000; font-weight:bold; padding-top:40px; text-align:left;}
#body_rename ul li{ list-style:none; height:30px;}
.input{border:1px solid #666666; clear:both;}
.button{border:1px solid #666666; background-color:#FFFFFF;}

#errorstr{list-style:armenian; width:400px; margin-top:20px;padding-left:10px;}
#errorstr ul li{list-style:decimal;}

#filelist_t1{width:555px; font-weight:bold; text-align:center;}
#filelist_t1 ul{width:555px; margin:0px;}
#filelist_t1 ul li{list-style:none; float:left;}

.filelist_t2 ul{width:555px; margin:0px;}
.filelist_t2{width:555px;text-align:left;}
.filelist_t2 ul li{list-style:none; float:left; margin:0px; padding:0px;}

.filelist_t3 ul{width:555px; margin:0px;}
.filelist_t3{width:555px;background-color:#F2F2F2;}
.filelist_t3 ul li{list-style:none; float:left; margin:0px;}

.filelist_width1{width:190px;}
.filelist_width2{width:55px; text-align:center;}
.filelist_width3{width:90px;text-align:right;}
.filelist_width4{width:155px;text-align:center;}
.filelist_width5{ width:65px;text-align:center;}
#index_bottom{color:#FFFFFF; background-color:#000000; font-weight:bold; height:24px; line-height:24px; width:100%;text-align:center;}
#index_bottom a{ color:#FFFFFF; text-decoration:none;}
#index_bottom a:link{ color:#FFFFFF; text-decoration:none;}
#index_bottom a:hover{ color:#FFFFFF; background-color:#333333; text-decoration:none;}
</style>
</head>
<body>
<% sPath=""
 sFileType = Request.Querystring("filetype")

 If Request.Querystring("path") <> "" Then 
  sPath = Request.Querystring("path")
  If InStr(sPath,"../") or InStr(sPath,"..\") Then
    errornum = errornum+1
    errorcode = errorcode & "<li><b>error ""../""</b>.only root dir.</li>"
   End If
 End If
 
 FullsPath=MainPath & sPath
 
 If FullsPath=MainPath Then
   sFile = FullsPath & Request.Querystring("file")
   sFolder = FullsPath & Request.Querystring("folder")
 Else
   sFile = FullsPath & "/" & Request.Querystring("file")
   sFolder = FullsPath & "/" & Request.Querystring("folder")
 End If
 session("foldername")=sPath
%>
<div id="PageBody">
<div id="index_head"><div class="head_right"><A href="<%=scriptname%>?path=<%=GotoUpFolder(sPath)%>">Upper</A></div> &nbsp; current:<%=ShowCurrentFolder(sPath)%></div>
<div id="index_body">
 <div id="body_left">
  <ul>
   <li><A href="<%=scriptname%>?">HOME</A></li>
   <li><A href="<%=scriptname%>?action=LoginConfig&path=<%=request.querystring("path")%>">SET</A></li>
   <li><A href="<%=scriptname%>?action=LoginOut">OUT</A></li>
  </ul>
 </div>
 <div id="body_right">
  <%
 If errornum < 1 Then
  Set fs = Server.CreateObject("Scripting.FileSystemObject")
  if Session("FileUserSession")=FileLoginName then
  
   Select Case sAction
   Case "editfile"
    Select Case sFileType
    Case "htm", "asp", "txt", "inc", "html", "shtml", "shtm", "js", "css", "asa", "aspx"
     EditFile
'    Case "mdb", "dat"
'     EditDb
    Case else
     FileTypeUnsupported
    End Select
   Case "savefile"
    SaveFile
   Case "viewfolder"
    Showlist
   Case "deletefile"
    DeleteFile
   Case "deletefolder"
    DeleteFolder
   Case "RenameFolder"
    RenameFolder
   Case "RenameFile"
    RenameFile
   Case "LoginConfig"
    LoginConfig
   Case "LoginOut"
    LoginOut
   Case Else
    Showlist 
   End Select
  elseif sAction="LoginCheck" then
  LoginCheck
  else
   call UserLogin
  end if
    
  Set fs = Nothing
 End If
 if errornum>0 then DisplayErrors 
%>
 </div>
</div>
</div>
</body>
</html>
<%
'*******************************************************
function ShowCurrentFolder(Path)
 dim FullPath
 FullPath = MainPath & Path
 if FullPath = MainPath then
  ShowCurrentFolder="HOME/"
 else
  ShowCurrentFolder="HOME/"&Path&"/"
 end if
end function

'**************************************
function GotoUpFolder(Path)
 dim TempPath,FullPath
 FullPath = MainPath & Path
 if FullPath = MainPath then
  GotoUpFolder=""
 else
  if instr(Path,"/")>0 then
   TempPath=left(Path,instrrev(Path,"/"))
   if TempPath="./" or TempPath="/" then GotoUpFolder=TempPath else GotoUpFolder=left(Path,instrrev(Path,"/")-1)
  else
   GotoUpFolder=""
  end if
 end if
end function

'*******************************************************
Sub LoginOut
 Session("FileUserSession")=""
 response.Redirect(scriptname&"?")
End Sub 

'*******************************************************
Sub DisplayErrors
 Response.Write("<div id=""body_title""><strong>ERROR" & errornum & " DESC:</strong></div>")
 Response.Write "<div id=""errorstr""><ul>" & errorcode & "</ul></div>" & vbCrlf
 Response.Write "<div> &nbsp;  &nbsp;  &nbsp; <A href=""javascript:window.history.go(-1);"">BAK</a> &nbsp; <A href="""& scriptname &"?"">HOME</a></div>" & vbCrlf
End Sub

'*******************************************************
sub UserLogin
 response.Write("<div id=""body_title""><strong>LOGIN</strong></div>")
 response.Write("<div id=""body_login"">")
 response.Write("<form name=""loginform"" action="""& scriptname &"?action=LoginCheck"" method=""post"">")
 response.Write("<ul><li>NAME:<input class=""login_input"" type=""text"" name=""loginname""></li><li>PASS:<input class=""login_input"" type=""password"" name=""loginpwd""></li><li><input type=""submit"" value=""LOGIN"" class=""input_button""> &nbsp; <input type=""reset"" value=""RESET"" class=""input_button""></li></ul></form>")
 response.write("</div>")
end sub

'*******************************************************
sub LoginCheck()
 if session("FileLoginErrStr")="" then session("FileLoginErrStr")=0
 loginname=request.Form("loginname")
 loginpwd=request.Form("loginpwd")

 if loginname="" or loginpwd="" then 
  errornum = errornum+1
  errorcode = errorcode & "<li>ERROR</li>"
  exit sub
 end if
 if session("FileLoginErrStr")>3 then
  errornum = errornum+1
  errorcode = errorcode & "<li>ERROR</li>"
  exit sub
 end if
 if (md5(loginname)&"1")<>FileLoginName or (md5(loginpwd)&"2")<>FileLoginPwd then
  session("FileLoginErrStr")=session("FileLoginErrStr")+1
  errornum = errornum+1
  errorcode = errorcode & "<li>ERROR</li>"
  exit sub
 end if
 Session("FileUserSession")=FileLoginName
 response.Redirect(scriptname&"?")
end sub

Sub LoginConfig
 If Request.Querystring("commit") <> "yes" Then
  response.Write("<div id=""body_title""><strong>SET</strong></div>")
  response.Write("<div id=""body_login"">")
  response.Write("<form name=""loginform"" action="""& scriptname &"?action=LoginConfig&path="& spath &"&commit=yes"" method=""post""><ul>")
  If Request.Querystring("commits")="yes" Then
   response.Write("<li><font color=""red"">OK</font></li>")
  End if
  response.Write("<li>NAME:<input class=""login_input"" type=""text"" name=""loginname""></li><li>PASS:<input class=""login_input"" type=""password"" name=""loginpwd""></li><li><input type=""submit"" value=""SAVE"" class=""input_button""> &nbsp; <input type=""reset"" value=""RESET"" class=""input_button""></li></ul></form>")
  response.write("</div>")
 Else
  loginname=request.Form("loginname")
  loginpwd=request.Form("loginpwd")
  if loginname="" or loginpwd="" then 
   errornum = errornum+1
   errorcode = errorcode & "<li>NO MSG</li>"
   exit sub
  end If
  loginname=md5(loginname)
  loginpwd=md5(loginpwd)
  Session("FileUserSession")=loginname&"1"
  Set ReadStream = fs.OpenTextFile(server.mappath(scriptname))
  Dim ReadTxt
  ReadTxt=ReadStream.ReadAll
  ReadStream.Close
  ReadTxt=Replace(ReadTxt,FileLoginName,loginname&"1")
  ReadTxt=Replace(ReadTxt,FileLoginPwd,loginpwd&"2")
  Set WriteFile = fs.CreateTextFile(server.mappath(scriptname), true)
  WriteFile.Write ReadTxt
  WriteFile.Close
  response.redirect(scriptname&"?action=LoginConfig&path="&spath&"&commits=yes")
 End if
End Sub

'*******************************************************
Sub ShowList
 Response.Write("<div>")
 Response.Write("<div id=""filelist_t1""><ul><li class=""filelist_width1"">NAME</li><li class=""filelist_width2"">CLASS</li><li class=""filelist_width3"">SIZE</li><li class=""filelist_width4"">TIME</li><li  class=""filelist_width5"">SET</li></ul></div>")
 Set fileobject = fs.GetFolder(server.mappath(FullsPath))
 Set foldercollection = fileobject.SubFolders 
 lineid=0
 bgcolor = ""
 bgcolor_off = ""
 bgcolor_on = "#f0f0f0"

 For Each folder in foldercollection
  If lineid = 0 Then
   bgcolor = "filelist_t2"
   lineid = 1
  Else
   bgcolor = "filelist_t3"
   lineid = 0
  End if
  Response.Write("<div class="""& bgcolor &"""><ul>")
  Response.Write("<li class=""filelist_width1"">")
  if sPath="" then
   response.Write("<a href=""" & scriptname & "?action=viewfolder&path=" & sPath & folder.name & """>" & folder.name & "</a>")
  else  
   response.Write("<a href=""" & scriptname & "?action=viewfolder&path=" & sPath & "/" & folder.name & """><font color=""#944007"">" & folder.name & "</font></a>")
  end if
  Response.Write("</li>")
  Response.Write("<li class=""filelist_width2""><font color=""#944007"">FOLDER</font></li>")
  Response.Write("<li class=""filelist_width3"">"& Size(folder.size) &"</li>")
  Response.Write("<li class=""filelist_width4"">"& folder.datelastmodified &"</li>")
  Response.Write("<li class=""filelist_width5""><a href=""" & scriptname & "?action=RenameFolder&path=" & sPath & "&folder=" & folder.name & """>Rename</a> <a href=""" & scriptname & "?action=deletefolder&path=" & sPath & "&folder=" & folder.name & """>DEL</a></li>")
  response.Write("</ul></div>")
 Next
 Set foldercollection=nothing


 Set filecollection = fileobject.Files
  
 For Each file in filecollection 
  If lineid = 0 Then
    bgcolor = "filelist_t2"
    lineid = 1
  Else
    bgcolor = "filelist_t3"
    lineid = 0
  End if 

  Response.Write("<div class="""& bgcolor &"""><ul>")
  Response.Write("<li class=""filelist_width1""><a href=""" & scriptname & "?action=editfile&path=" & sPath & "&file=" & server.URLEncode(file.name) & "&filetype=" & Lcase(fs.GetExtensionName(file.name)) & """>" & file.name & "</a></li>")
  Response.Write("<li class=""filelist_width2"">"& fs.GetExtensionName(file.name) &"</li>")
  Response.Write("<li class=""filelist_width3"">"& Size(file.size) &"</li>")
  Response.Write("<li class=""filelist_width4"">"& file.datelastmodified &"</li>")
  Response.Write("<li class=""filelist_width5""><a href=""" & scriptname & "?action=RenameFile&path=" & sPath & "&file=" & file.name & "&filetype=" & Lcase(fs.GetExtensionName(file.name)) & """>Rename</a> <a href=""" & scriptname & "?action=deletefile&path=" & sPath & "&file=" & file.name & "&filetype=" & Lcase(fs.GetExtensionName(file.name)) & """>DEL</a></li>")
  response.Write("</ul></div>")
  Next
  Response.Write("</div>")
End Sub

'*******************************************************
function Size(itemsize)
  Select case Len(itemsize)
  Case "1", "2", "3" 
    Size=itemsize & " Byte"
  Case "4", "5", "6"
    Size = Round(itemsize/1000) & " Kb"
  Case "7", "8", "9"
    Size = Round(itemsize/1000000) & " Mb"
  End Select
  Response.Write "</td>" &vbCrLf
End function

'*******************************************************
Sub RenameFolder
 response.Write("<div id=""body_title""><strong>FOLDER RENAME</strong></div>")
 If Request.querystring("commit") <> "yes" Then 
  Session("lastpage") = Request.ServerVariables("HTTP_REFERER")
  Response.Write "<div id=""body_title"">RENAME: <strong>" & request.querystring("folder") & "</strong></div>" 
 
  response.Write("<div id=""body_rename"">")
  response.Write("<form name=""form1"" action="""& scriptname &"?action=RenameFolder&path="& spath &"&folder="& request.querystring("folder") &"&commit=yes"" method=""post"">")
  response.Write("<ul><li>NEWNAME:<input class=""input"" type=""text"" name=""NewFolderName"" size=""20""></li><li><input type=""submit"" value=""SAVE"" class=""button""> &nbsp; <input type=""reset"" value=""RESET"" class=""input_button""><input type=""hidden"" value="""& request.querystring("folder") &""" name=""folder""></li></ul></form>")
  response.write("</div>")
 Else
  Dim NewFolderName,slashvalue,folderObject
  NewFolderName=request.form("NewFolderName")
  sFolder=request.form("folder")
  if right(FullsPath,1)="/" then slashvalue="" else slashvalue="/"
  Set folderObject = fs.GetFolder(Server.MapPath(FullsPath&slashvalue&sFolder))
  FolderObject.Name=NewFolderName
  Set folderObject = Nothing
  Response.Redirect("" & Session("lastpage") & "") 
 End If
End Sub

'*******************************************************
Sub RenameFile
 response.Write("<div id=""body_title""><strong>FILE RENAME</strong></div>")
 If Request("commit") <> "yes" Then 
  Session("lastpage") = Request.ServerVariables("HTTP_REFERER")
  Response.Write "<div id=""body_title"">RENAME: <strong>" & request.querystring("file") & "</strong></div>"
  
  response.Write("<div id=""body_rename"">")
  response.Write("<form name=""form1"" action="""& scriptname &"?action=RenameFile&path="& spath &"&folder="& request.querystring("folder") &"&commit=yes"" method=""post"">")
  response.Write("<ul><li>NEWNAME:<input class=""input"" type=""text"" name=""NewFileName"" size=""20""></li><li><input type=""submit"" value=""SAVE"" class=""button""> &nbsp; <input type=""reset"" value=""RESET"" class=""input_button""><input type=""hidden"" value="""& request.querystring("file") &""" name=""filename""></li></ul></form>")
  response.write("</div>")
 Else
  Dim NewFileName,Sfile,slashvalue,FileObject
  NewFileName=request.form("NewFileName")
  Sfile=request.form("filename")
  if right(FullsPath,1)="/" then slashvalue="" else slashvalue="/"
  Set FileObject = fs.GetFile(Server.MapPath(FullsPath&slashvalue&sfile))
  FileObject.Name = NewFileName
  Set FileObject = Nothing
  Response.Redirect("" & Session("lastpage") & "")  
 End If
End Sub


'*******************************************************
Sub EditFile
 Session("lastpage") = Request.ServerVariables("HTTP_REFERER")
 Set ReadStream = fs.OpenTextFile(server.mappath(sFile))
 filename=request.querystring("file")
 response.Write("<div id=""body_title""><strong>EDIT</strong></div>")
 response.Write("<div id=""body_title"">FILE:<strong>"& filename &"</strong></div>")

 response.Write("<div id=""body_content"">")
 response.Write("<form name=""form1"" action="""& scriptname &"?action=savefile&path="& spath &"&file=" & Request.Querystring("File") & "&overwrite=yes"" method=""post"">")
 response.Write("<ul><li>CONTENT:<br /><textarea rows=""20"" cols=""70"" name=""filestuff"" class=""input"">" & Server.htmlencode(ReadStream.ReadAll) & "</textarea></li>")
 response.Write("<li>SAVE AS:<br /><input class=""input"" type=""text"" value="""" name=""NewFileName"" size=""25""><br /><br /></li><li><input type=""submit"" value=""SAVE"" class=""button""> &nbsp; <input type=""reset"" value=""REWRITE"" class=""input_button""><input type=""hidden"" value="""& request.querystring("file") &""" name=""filename""></li></ul></form>")
 response.write("</div>")
End Sub

'*******************************************************
Sub SaveFile
 If right(FullsPath,1)="/" Then
  If Request.Querystring("file") = "" Then
   sFile = FullsPath & Request.Form("file")
  End If
  If Request.Querystring("folder") = "" Then
   sFolder = FullsPath & Request.Form("folder")
  End if
 Else
  If Request.Querystring("file") = "" Then
   sFile = FullsPath & "/" & Request.Form("file")
  End If
  If Request.Querystring("folder") = "" Then
   sFolder = FullsPath & "/" & Request.Form("folder")
  End if
 End If
 session("foldername")=sPath
 if request.form("NewFileName")<>"" Then
  Dim NewFileName,slashvalue,textStreamObject,filestuff,NewPathFileName
  NewFileName=request.form("NewFileName")
  spath=request("path")
  if right(FullsPath,1)="/" then slashvalue="" else slashvalue="/"
  filestuff=request.form("filestuff")
  NewPathFileName= FullsPath&slashvalue&newfilename
  Set textStreamObject = fs.CreateTextFile(server.mappath(NewPathFileName),true,false)
  textStreamObject.write filestuff
  textStreamObject.close
  Response.Redirect("" & Session("lastpage") & "")
 else
  
  If Request.Querystring("overwrite") = "yes" Then
   Set WriteFile = fs.CreateTextFile(server.mappath(sFile), true)
   WriteFile.Write Request.Form("filestuff")
   WriteFile.Close
   Response.Redirect("" & Session("lastpage") & "")
   
  Else
   Session("lastpage") = Request.ServerVariables("HTTP_Referer")
   If fs.FileExists(server.mappath(sFile)) Then
    Session("sFile") = sFile
    spath=request.querystring("path")
    response.Write("<div id=""body_title""><strong>SAVE</strong></div>")
    response.Write("<div id=""body_title"">FOUND:<strong>"& sFile &"</strong></div>")
    response.Write("<div id=""body_content"">")
    response.Write("<form name=""reform1"" action="""& scriptname &"?action=savefile&overwrite=yes&path="& spath &"&file=" & Request.Form("File") & """ method=""post""><ul>")
    Response.Write "<LI><strong>REPLACE?</strong></a>"
    Response.Write "<LI><a href=""javascript:reform1.submit();"">COVER</a> &nbsp; <a href=""javascript:history.back()"">BACK</a><input type=""hidden"" value="""& Request.Form("newfilestuff") &""" name=""filestuff""></LI>"
    Response.Write "</ul></form></div>"
    Session("lastpage") = scriptname&"?action=viewfolder&path="&spath&""
   Else 
    Set WriteFile = fs.CreateTextFile(server.mappath(sFile), false)
    WriteFile.Write Request.Form("newfilestuff")
    WriteFile.Close
    Response.Redirect(scriptname&"?action=viewfolder&path="&spath&"")
   End If
  End If
 end if
End Sub

'*******************************************************
Sub DeleteFolder
 response.Write("<div id=""body_title""><strong>DEL FOLDER</strong></div>")
 If Request.Querystring("commit") <> "yes" Then 
  Session("lastpage") = Request.ServerVariables("HTTP_REFERER")
  Session("sFolder") = sFolder
  response.Write("<div id=""body_title"">DEL:<strong>"& sFolder &"</strong></div>")

  response.Write("<div id=""body_content"">")
  response.Write("<ul>")
  Response.Write "<LI><strong>YES?</strong></a>"
  Response.Write "<LI><a href=""" & scriptname & "?action=deletefolder&path=" & sPath & "&folder=" & sFolder &  "&commit=yes"">DEL</a> &nbsp; <a href=" & Session("lastpage") & ">BAK</a></LI>"
  Response.Write "</ul></div>"

 Else
  Response.Write sPath & "<br>"
  Response.Write sFile & "<br>"
  fs.DeleteFolder(server.mappath(Session("sFolder")))
  Response.Redirect("" & Session("lastpage") & "")
 End If
End Sub

'*******************************************************
Sub DeleteFile
 response.Write("<div id=""body_title""><strong>DEL FILE</strong></div>")
 If Request.Querystring("commit") <> "yes" Then
  Session("lastpage") = Request.ServerVariables("HTTP_REFERER")
  Session("sFile") = sFile
  response.Write("<div id=""body_title"">DEL:<strong>"& sFile &"</strong></div>")

  response.Write("<div id=""body_content"">")
  response.Write("<ul>")
  If sFileType = "jpg" OR sFileType = "gif" Then
   Response.Write "<LI><img src="""& sfile & """ border=""1""></LI>"
  End If
  Response.Write "<LI><strong>YES?</strong></a>"
  Response.Write "<LI><a href=""" & scriptname & "?action=deletefile&path=" & sPath & "&file=" & sFile & "&commit=yes"">DEL</a> &nbsp; <a href=" & Session("lastpage") & ">BAK</a></LI>"
  Response.Write "</ul></div>"
 Else
  fs.DeleteFile(server.mappath(Session("sFile")))
  Response.Redirect("" & Session("lastpage") & "")
 End If
End Sub
%>