A sudden inspiration that day was aimed at anti-theft chains
If a file uploaded normally is stolen by someone, it will increase the burden on your server. Last time, 164.cc was hung.
Then think of countermeasures. Currently, there are many anti-theft chain programs, but they are not easy to use, and they are not free...
So, you can only think of a solution yourself first. So, now look at the title and think about the anti-theft chain, maybe you will have some clues.
I can modify the folder name where the uploaded file is located from time to time, and the program of this website dynamically obtains the folder name. In this way, the site that originally stolen files on this website will not find the file due to path errors, thus realizing the anti-theft link.
So, how to use FSO to modify the name of a folder?
A simple function:
The code copy is as follows:
<%
Functionfldrename(nowfld,newfld)
nowfld=server.mappath(nowfld)
newfld=server.mappath(newfld)
Setfso=CreateObject("Scripting.FileSystemObject")
ifnotfso.FolderExists(nowfld)then
response.write("The folder path that needs to be modified is incorrect or the folder name is entered incorrectly")
else
fso.CopyFoldernowfld,newfld
fso.DeleteFolder(nowfld)
endif
setfso=nothing
EndFunction
%>
In general, it is to copy the contents of the current folder into a new folder, and then delete the contents of the folder, thereby indirectly achieving the purpose of renaming the folder.
This is a paranoid problem, because when modifying the folder name, especially when the folder contents of the folder to be modified is G quantity, the waiting time is a bit unprofitable compared to FTP remotely modifying the name.
Some people say that FSO can directly modify the folder name? I don't want to do it.
Apply this function
<%callfldrename("ex01","ex02")%>
The basic meaning is to modify the ex01 folder name in the same directory as the program execution file to ex02
Here is my local test report:
1. This program does not consume program execution time
2. It takes about 50 seconds to perform the indirect name change of 1G folder, which is actually the file copy and transfer time on the server side.
3. CPU consumption is not too high, about 30%
4. If the machine suddenly crashes or power is lost in the middle of the name change, two situations will occur:
a. The new folder is initially created (the new folder is not built), and the next time the program is executed, an error will occur: Microsoft VBScript runtime error (0x800A003A) file already exists. At this time, you can only delete the new folder after FTP (trying to use FSO to delete the new folder is not effective).
b. Some files have been copied. The next time the program is executed, the copied folder content will be automatically overwritten, and the original folder content will still exist. The original folder and its files will be deleted only after copying.
5. At the same time, you need to pay attention to the name of the new folder to avoid duplicating the name of the existing folder. Of course, you can also use the program to judge it.