Save remote Picture function Modify Genuine _ thief/Collect
Source: Internet
Author: User
Take advantage of today's free, fixed a bit of this function, tested, in the local server through, the Space Business Server can also be used normally, no errors found. My Kaspersky doesn't report poison. ^_^
As long as you modify, this function is placed on which Web site is applicable. Here just to add a picture to illustrate the call method, other location methods similar.
In my native test success, because now not even on the space of the FTP, so no office in the space test, find problems, please come to the group.
First, put the following function to the end of the ft_admin_conn.asp
'==================================
' = function Name: saveimgfile
' = function: Save remote picture
' = parameter description: imgfileurl--remote picture Address
' = Modified Date: 2006-4-19 13:20
' = Program Author: Cold Wind
' = site: http://www.4fnet.com.cn
'==================================
function Saveimgfile (Imgfileurl)
Dim img_type,savepath,imgfiletype,flag,imgbody
Savepath= ". /fuploadfile/"&year" (Now ()) & "-" &month (now ())
Flag=false
Imgfiletype=right (imgfileurl,4) ' Get the format of a remote picture
Img_type= ". Gif|. bmp|. Jpg|. PNG "' setting allows you to save pictures in a local format
Typearr=split (Img_type, "|")
For i=0 to UBound (Typearr)-1
If Imgfiletype=typearr (i) Then
Flag=true
Exit For
End If
Next
If Flag=false then ' if you are not allowed to save to a local picture format, connect only the remote picture
Saveimgfile=imgfileurl
Else
Set Xml_http=server.createobject ("Microsoft.XMLHTTP")
Xml_http.open "Get", Imgfileurl,false
Xml_http.send
Imgbody=xml_http.responsebody
Set xml_http=nothing
Serverpath=server.mappath (Savepath)
Set Filefolder=server.createobject ("Scripting.FileSystemObject")
If Filefolder.folderexists (serverpath) =false Then
Filefolder.createfolder (Serverpath)
End If
Randomize
savepath=savepath& "/" &year (Now ()) &month (today ()) &day (now ()) &hour (now ()) &minute (now ()) &int (10*RND) &imgfiletype
Set Adodbs=server.createobject ("ADODB.stream")
Adodbs.open
Adodbs.type=1
Adodbs.write Imgbody
Adodbs.savetofile (Server.MapPath (Savepath)) ' Save to Local
Adodbs.seteos
Set adodbs=nothing
If Filefolder.fileexists (Server.MapPath (savepath)) =false Then ' If the save succeeds, return the remote address, only makes remote connection, avoids some anti-theft even the website cannot save
Saveimgfile=imgfileurl
Else
Savepath=replace (Savepath, ". /","")
Saveimgfile=savepath
End If
Set filefolder=nothing
End If
End Function
Second, open the admin/admin_pic.asp file
1, find: Add the process of pic_pic=checksql ("Thumbnail image address", Request.Form ("pic"), 1,100) (presumably in line No. 368) Insert the following code:
If left (pic_url,7) = "http://" and Request.Form ("save") = "true" Then
Pic_url=saveimgfile (Pic_url)
Pic_pic=pic_url
End If
Find again: <input type= "Submit" name= "Submit" value= "OK Add" > (presumably on line No. 481) Insert the following code:
<input type= "checkbox" Name= "Save" value= "true" > Save remote Picture at the same time
2, in the Edit picture process (Editpic) in the same place to add the appropriate code can be.
OK, finish.
I hope you can give a return, other use of the picture is the same place to call the method.
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.