Use FSO to modify the folder name for file transfer anti-leech

Source: Internet
Author: User

One of the sudden Inspirations on that day was for anti-leech protection.

For normally uploaded files, leeching increases the burden on your server. The last 164. CC was suspended.

Then think about the countermeasures.ProgramThere are also many, but it is not easy to use, and there is no free ......

Therefore, you can only find a solution first. Now let's take a look at the title and think about anti-leech. It may be a bit eye-catching.

I can modify the name of the folder where the uploaded file is located from time to time, and the program on this site dynamically obtains the folder name. In this way, the site where the file was stolen will not find the file due to a path error, in this way, anti-leech protection is implemented.
So how can I use FSO to modify the folder name?
A simple function:CopyCodeThe Code is as follows: <%
Function fldrename (nowworkflow, newworkflow)
Nowath = server. mappath (nowath)
Newpath = server. mappath (newpath)

Set FSO = Createobject ("scripting. FileSystemObject ")
If not FSO. folderexists (nowists) then
Response. Write ("the folder path to be modified is incorrect or the folder name is incorrect ")
Else
FSO. copyfolder nowder, newusers
FSO. deletefolder (nowder)
End if
Set FSO = nothing

End Function
%>

In general, it is to copy the content of the current folder to the new folder, and then delete the content of the folder to indirectly achieve the purpose of renaming the folder.

This is a paranoid problem, because when you modify the folder name, especially when the content of the folder to be modified is g, the waiting time is a bit different from that of the FTP remote name modification.

Some people say that FSO can be used to directly modify the folder name? Wu mozhi.

Apply this function
<% Call fldrename ("ex01", "ex02") %>

The name of the ex01 folder in the same directory as the program execution file will be changed to ex02.

The following is my local test briefing:

1. This program does not consume program execution time

2. It takes about 50 seconds to rename a 1g folder, that is, the file copy and transfer time on the server.

3. CPU consumption is not too high, about 30%

4. If a sudden shutdown or power loss occurs in the middle of the name change:

A. The new folder is initially created (the new folder is not created). The next time you run the program, an error type occurs: the Microsoft VBScript runtime error (0x800a003a) file already exists, in this case, you can only delete the new folder through FTP and then execute it (try to use FSO to delete the new folder without any effect ).

B. Some files have been copied. When the program is executed next time, the copied folder content is automatically overwritten. The original folder content still exists. The original folder and its files will be deleted only after the copy is completed.

5. Pay attention to the name of the new folder to avoid duplicate names with existing folder names. Of course, you can also use a program to determineCopy codeThe Code is as follows: <%
Function fldrename (nowworkflow, newworkflow)

Nowath = server. mappath (nowath)
Newpath = server. mappath (newpath)

Set FSO = Createobject ("scripting. FileSystemObject ")
If not FSO. folderexists (nowists) then
Response. Write ("the folder path to be modified is incorrect or the folder name is incorrect ")
Else
If FSO. folderexists (newstores) then
Response. Write ("the new folder name you named already exists ")
Else
FSO. copyfolder nowder, newusers
FSO. deletefolder (nowder)
End if
End if
Set FSO = nothing

End Function
%>

6. If database operations and music files are playing in the folder when the folder name is modified, it is displayed that the Microsoft VBScript runtime error (0x800a0046) has no permission, this mainly refers to the problem of deleting the original folder (the music file has been deleted, but the folder has not been deleted ). Only FTP logon is processed. If this folder is a full image file, it can run successfully.

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.