Last 10 Posts [ In reverse order ] |
lknokl | Posted: 3/6/2008, 15:03 CITAZIONE (lknokl @ 2/6/2008, 11:29) intendi per esempio modificare il sorgente di una pagina presente sul web? oppure per esempio sostituire un normale file....in tutti e due i casi devi comunque avere accesso all'ftp della makkina su cui la pagina e hostata....se vuoi trovi la udf per l'ftp sul sito ufficiale di autoit leggi qualke post sopra |
Crazy_Mauro | Posted: 3/6/2008, 13:07 CITAZIONE (RedSkull92 @ 2/6/2008, 19:37) L'unico modo per modificare un file hostato è avere accesso ftp quindi tramite la libreria ftp.au3 puoi farlo. per leggere il hostato puoi farlo tramite la libreria IE.au3 o INET Grazie ma dove posso trovare questa libreria (ftp.au3)? ho cercato cn google ma non ho trovato niente.. ___________________________________ Trovata grazie a tutti per l'aiuto Comunque se qualcun'altro ne avesse bisogno: SPOILER (clicca per visualizzare) ;=============================================================================== ; ; Function Name: _FTPOpen() ; Description: Opens an FTP session. ; Parameter(s): $s_Agent - Random name. ( like "myftp" ) ; $l_AccessType - I dont got a clue what this does. ; $s_ProxyName - ProxyName. ; $s_ProxyBypass - ProxyByPasses's. ; $l_Flags - Special flags. ; Requirement(s): DllCall, wininet.dll ; Return Value(s): On Success - Returns an indentifier. ; On Failure - 0 and sets @ERROR ; Author(s): Wouter van Kesteren. ; ;=============================================================================== Func _FTPOpen($s_Agent, $l_AccessType = 1, $s_ProxyName = '', $s_ProxyBypass = '', $l_Flags = 0) Local $ai_InternetOpen = DllCall('wininet.dll', 'long', 'InternetOpen', 'str', $s_Agent, 'long', $l_AccessType, 'str', $s_ProxyName, 'str', $s_ProxyBypass, 'long', $l_Flags) If @error OR $ai_InternetOpen[0] = 0 Then SetError(-1) Return 0 EndIf Return $ai_InternetOpen[0] EndFunc ;==> _FTPOpen() ;=============================================================================== ; ; Function Name: _FTPConnect() ; Description: Connects to an FTP server. ; Parameter(s): $l_InternetSession - The Long from _FTPOpen() ; $s_ServerName - Server name/ip. ; $s_Username - Username. ; $s_Password - Password. ; $i_ServerPort - Server port ( 0 is default (21) ) ; $l_Service - I dont got a clue what this does. ; $l_Flags - Special flags. ; $l_Context - I dont got a clue what this does. ; Requirement(s): DllCall, wininet.dll ; Return Value(s): On Success - Returns an indentifier. ; On Failure - 0 and sets @ERROR ; Author(s): Wouter van Kesteren ; ;=============================================================================== Func _FTPConnect($l_InternetSession, $s_ServerName, $s_Username, $s_Password, $i_ServerPort = 0, $l_Service = 1, $l_Flags = 0, $l_Context = 0) Local $ai_InternetConnect = DllCall('wininet.dll', 'long', 'InternetConnect', 'long', $l_InternetSession, 'str', $s_ServerName, 'int', $i_ServerPort, 'str', $s_Username, 'str', $s_Password, 'long', $l_Service, 'long', $l_Flags, 'long', $l_Context) If @error OR $ai_InternetConnect[0] = 0 Then SetError(-1) Return 0 EndIf Return $ai_InternetConnect[0] EndFunc ;==> _FTPConnect() ;=============================================================================== ; ; Function Name: _FTPPutFile() ; Description: Puts an file on an FTP server. ; Parameter(s): $l_FTPSession - The Long from _FTPConnect() ; $s_LocalFile - The local file. ; $s_RemoteFile - The remote Location for the file. ; $l_Flags - Special flags. ; $l_Context - I dont got a clue what this does. ; Requirement(s): DllCall, wininet.dll ; Return Value(s): On Success - 1 ; On Failure - 0 ; Author(s): Wouter van Kesteren ; ;=============================================================================== Func _FTPPutFile($l_FTPSession, $s_LocalFile, $s_RemoteFile, $l_Flags = 0, $l_Context = 0) Local $ai_FTPPutFile = DllCall('wininet.dll', 'int', 'FtpPutFile', 'long', $l_FTPSession, 'str', $s_LocalFile, 'str', $s_RemoteFile, 'long', $l_Flags, 'long', $l_Context) If @error OR $ai_FTPPutFile[0] = 0 Then SetError(-1) Return 0 EndIf Return $ai_FTPPutFile[0] EndFunc ;==> _FTPPutFile() ;=============================================================================== ; ; Function Name: _FTPDelFile() ; Description: Delete an file from an FTP server. ; Parameter(s): $l_FTPSession - The Long from _FTPConnect() ; $s_RemoteFile - The remote Location for the file. ; Requirement(s): DllCall, wininet.dll ; Return Value(s): On Success - 1 ; On Failure - 0 ; Author(s): Wouter van Kesteren ; ;=============================================================================== Func _FTPDelFile($l_FTPSession, $s_RemoteFile) Local $ai_FTPPutFile = DllCall('wininet.dll', 'int', 'FtpDeleteFile', 'long', $l_FTPSession, 'str', $s_RemoteFile) If @error OR $ai_FTPPutFile[0] = 0 Then SetError(-1) Return 0 EndIf Return $ai_FTPPutFile[0] EndFunc ;==> _FTPDelFile() ;=============================================================================== ; ; Function Name: _FTPRenameFile() ; Description: Renames an file on an FTP server. ; Parameter(s): $l_FTPSession - The Long from _FTPConnect() ; $s_Existing - The old file name. ; $s_New - The new file name. ; Requirement(s): DllCall, wininet.dll ; Return Value(s): On Success - 1 ; On Failure - 0 ; Author(s): Wouter van Kesteren ; ;=============================================================================== Func _FTPRenameFile($l_FTPSession, $s_Existing, $s_New) Local $ai_FTPRenameFile = DllCall('wininet.dll', 'int', 'FtpRenameFile', 'long', $l_FTPSession, 'str', $s_Existing, 'str', $s_New) If @error OR $ai_FTPRenameFile[0] = 0 Then SetError(-1) Return 0 EndIf Return $ai_FTPRenameFile[0] EndFunc ;==> _FTPRenameFile() ;=============================================================================== ; ; Function Name: _FTPMakeDir() ; Description: Makes an Directory on an FTP server. ; Parameter(s): $l_FTPSession - The Long from _FTPConnect() ; $s_Remote - The file name to be deleted. ; Requirement(s): DllCall, wininet.dll ; Return Value(s): On Success - 1 ; On Failure - 0 ; Author(s): Wouter van Kesteren ; ;=============================================================================== Func _FTPMakeDir($l_FTPSession, $s_Remote) Local $ai_FTPMakeDir = DllCall('wininet.dll', 'int', 'FtpCreateDirectory', 'long', $l_FTPSession, 'str', $s_Remote) If @error OR $ai_FTPMakeDir[0] = 0 Then SetError(-1) Return 0 EndIf Return $ai_FTPMakeDir[0] EndFunc ;==> _FTPMakeDir() ;=============================================================================== ; ; Function Name: _FTPDelDir() ; Description: Delete's an Directory on an FTP server. ; Parameter(s): $l_FTPSession - The Long from _FTPConnect() ; $s_Remote - The Directory to be deleted. ; Requirement(s): DllCall, wininet.dll ; Return Value(s): On Success - 1 ; On Failure - 0 ; Author(s): Wouter van Kesteren ; ;=============================================================================== Func _FTPDelDir($l_FTPSession, $s_Remote) Local $ai_FTPDelDir = DllCall('wininet.dll', 'int', 'FtpRemoveDirectory', 'long', $l_FTPSession, 'str', $s_Remote) If @error OR $ai_FTPDelDir[0] = 0 Then SetError(-1) Return 0 EndIf Return $ai_FTPDelDir[0] EndFunc ;==> _FTPDelDir() ;=============================================================================== ; ; Function Name: _FTPClose() ; Description: Closes the _FTPOpen session. ; Parameter(s): $l_InternetSession - The Long from _FTPOpen() ; Requirement(s): DllCall, wininet.dll ; Return Value(s): On Success - 1 ; On Failure - 0 ; Author(s): Wouter van Kesteren ; ;=============================================================================== Func _FTPClose($l_InternetSession) Local $ai_InternetCloseHandle = DllCall('wininet.dll', 'int', 'InternetCloseHandle', 'long', $l_InternetSession) If @error OR $ai_InternetCloseHandle[0] = 0 Then SetError(-1) Return 0 EndIf Return $ai_InternetCloseHandle[0] EndFunc ;==> _FTPClose() ;=============================================================================== ; ; Function Name: _FtpSetCurrentDir() ; Description: Set Current Directory on an FTP server. ; Parameter(s): $l_FTPSession - The Long from _FTPConnect() ; $s_Remote - The Directory to be set. ; Requirement(s): DllCall, wininet.dll ; Return Value(s): On Success - 1 ; On Failure - 0 ; Author(s): Beast ; ;=============================================================================== Func _FtpSetCurrentDir($l_FTPSession, $s_Remote) Local $ai_FTPSetCurrentDir = DllCall('wininet.dll', 'int', 'FtpSetCurrentDirectory', 'long', $l_FTPSession, 'str', $s_Remote) If @error OR $ai_FTPSetCurrentDir[0] = 0 Then SetError(-1) Return 0 EndIf Return $ai_FTPSetCurrentDir[0] EndFunc;==> _FtpSetCurrentDir() ; define some constants - can be used with _FTPPutFile and _FTPGetFile and ftp open flags Const $INTERNET_FLAG_PASSIVE = 0x08000000 Const $INTERNET_FLAG_TRANSFER_ASCII = 0x00000001 Const $INTERNET_FLAG_TRANSFER_BINARY = 0x00000002 Const $INTERNET_DEFAULT_FTP_PORT = 21 Const $INTERNET_SERVICE_FTP = 1 ;=============================================================================== ; ; Function Name: _FTPCommand() ; Description: Sends a command to an FTP server. ; Parameter(s): $l_FTPSession - The Long from _FTPOpen() ; $s_FTPCommand - Commad string to send to FTP Server ; $l_ExpectResponse - Data socket for response in Async mode ; $s_Context - A pointer to a variable that contains an application-defined ; value used to identify the application context in callback operations ; $s_Handle - A pointer to a handle that is created if a valid data socket is opened. ; The $s_ExpectResponse parameter must be set to TRUE for phFtpCommand to be filled. ; ; Requirement(s): DllCall, wininet.dll ; Return Value(s): On Success - Returns an indentifier. ; On Failure - 0 and sets @ERROR ; Author(s): Bill Mezian ; ; Command Examples: depends on server syntax. The following is for ; Binary transfer, ASCII transfer, Passive transfer mode (used with firewalls) ; 'type I' 'type A' 'pasv' ; ;=============================================================================== Func _FTPCommand($l_FTPSession, $s_FTPCommand, $l_Flags = 0x00000001, $l_ExpectResponse = 0, $l_Context = 0, $s_Handle = '') Local $ai_FTPCommand = DllCall('wininet.dll', 'int', 'FtpCommand', 'long', $l_FTPSession, 'long', $l_ExpectResponse, 'long', $l_Flags, 'str', $s_FTPCommand, 'long', $l_Context, 'str', $s_Handle) If @error OR $ai_FTPCommand[0] = 0 Then SetError(-1) Return 0 EndIf ;Return $s_return Return $ai_FTPCommand[0] EndFunc;==> _FTPCommand() ;=================================================================================================== ; ; Function Name: _FTPPutFolderContents() ; Description: Puts an folder on an FTP server. Recursivley if selected ; Parameter(s): $l_InternetSession - The Long from _FTPConnect() ; $s_LocalFolder - The local folder i.e. "c:\temp". ; $s_RemoteFolder - The remote folder i.e. '/website/home'. ; $b_RecursivePut - Recurse through sub-dirs. 0=Non recursive, 1=Recursive ; Requirement(s): DllCall, wininet.dll ; Author(s): Stumpii ; ;=================================================================================================== Func _FTPPutFolderContents($l_InternetSession, $s_LocalFolder, $s_RemoteFolder, $b_RecursivePut) ; Shows the filenames of all files in the current directory. $search = FileFindFirstFile($s_LocalFolder & "\*.*") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop If StringInStr(FileGetAttrib($s_LocalFolder & "\" & $file), "D") Then _FTPMakeDir($l_InternetSession, $s_RemoteFolder & "/" & $file) If $b_RecursivePut Then _FTPPutFolderContents($l_InternetSession, $s_LocalFolder & "\" & $file, $s_RemoteFolder & "/" & $file, $b_RecursivePut) EndIf Else _FTPPutFile($l_InternetSession, $s_LocalFolder & "\" & $file, $s_RemoteFolder & "/" & $file, 0, 0) EndIf WEnd ; Close the search handle FileClose($search) EndFunc ;==>_FTPPutFolderContents Func _FTPListFiles($l_FTPSession, $l_Flags = 0, $l_Context = 0) $str = "dword;int64;int64;int64;dword;dword;dword;dword;char[256];char[14]" $WIN32_FIND_DATA = DllStructCreate($str) Local $callFindFirst = DllCall('wininet.dll', 'int', 'FtpFindFirstFile', 'long', $l_FTPSession, 'str', "", 'ptr', DllStructGetPtr($WIN32_FIND_DATA), 'long', $l_Flags, 'long', $l_Context) If Not $callFindFirst[0] Then MsgBox(0, "Folder Empty", "No Files Found ") SetError(-1) Return 0 EndIf $ret = "" While 1 If DllStructGetData($WIN32_FIND_DATA, 1) <> 16 Then $ret = $ret & DllStructGetData($WIN32_FIND_DATA, 9) & "|" Local $callFindNext = DllCall('wininet.dll', 'int', 'InternetFindNextFile', 'long', $callFindFirst[0], 'ptr', DllStructGetPtr($WIN32_FIND_DATA)) If Not $callFindNext[0] Then ExitLoop EndIf WEnd $WIN32_FIND_DATA = 0 Return StringTrimRight($ret, 1) EndFunc ;==>_FTPListFiles ;=============================================================================== ; ; Function Name: _FTPGetFile() ; Description: Get file from a FTP server. ; Parameter(s): $l_FTPSession - The Long from _FTPConnect() ; $s_LocalFile - The local file. ; $s_RemoteFile - The remote Location for the file. ; $l_Flags - Special flags. ; $l_Context - I dont got a clue what this does. ; Requirement(s): DllCall, wininet.dll ; Return Value(s): On Success - 1 ; On Failure - 0 ; Author(s): Wouter van Kesteren ; ;=============================================================================== Func _FTPGetFile($l_FTPSession, $s_LocalFile, $s_RemoteFile, $l_Flags = 0, $l_Context = 0) Local $ai_FTPGetFile = DllCall('wininet.dll', 'int', 'FtpGetFile', 'long', $l_FTPSession, 'str', $s_LocalFile, 'str', $s_RemoteFile, 'long', $l_Flags, 'long', $l_Context) If @error OR $ai_FTPGetFile[0] = 0 Then SetError(-1) Return 0 EndIf Return $ai_FTPGetFile[0] EndFunc;==> _FTPGetFile() ;=============================================================================== ; Function Name: _FTPGetLinkStringInfo() ; Description: Gets Information about an ftp string (ie. "ftp://user:pass@servername:port/path/" or "servername:port/path" ; Parameter(s): $s_FTPLink - [in]The string to get the information from (ie. "ftp://user:pass@servername:port/") ; $s_ServerName - [in/out] Name of the Server (ie. name.host.net) ; $s_Username - [in/out] Name of the user if found in $s_FTPLink ; $s_Password - [in/out] Password for user if found in $s_FTPLink ; $i_ServerPort - [in/out] Port toi connect on if found in $s_FTPLink (Default: 21) ; Requirement(s): None ; Return Value(s): On Success - Returns the path from $s_FTPLink ; - Sets Extended to 1 for $s_FTPLink to ahve form of "ftp://...../" ; - Sets Extended to 2 for $s_FTPLink to ahve form of " name.host.net...." ; On Failure - 0 and @error = -1 ;=============================================================================== Func _FTPGetLinkStringInfo($s_FTPLink,ByRef $s_ServerName, ByRef $s_Username, ByRef $s_Password, ByRef $i_ServerPort) Local $errFlag = 0,$extFlag = 0 Local $s_ServerPort,$s_FTPPath If StringInStr($s_FTPLink,"ftp://") Then ;Written as Link ie. ftp://user:pass@servername:port/path/) $extFlag = 2 If StringInStr($s_FTPLink,"@") Then ;has info about username and password (ie. ftp://user:pass@servername/) $s_Username = StringMid($s_FTPLink,StringInStr($s_FTPLink,"ftp://") + 6,StringInStr($s_FTPLink,":",0,2) - StringInStr($s_FTPLink,"ftp://") - 6) $s_Password = StringMid($s_FTPLink,StringInStr($s_FTPLink,":",0,2) + 1,StringInStr($s_FTPLink,"@") - StringInStr($s_FTPLink,":",0,2)-1) If StringInStr($s_FTPLink,":",0,3) Then ;has info about port (ftp://user:pass@servername:port or ftp://user:pass@servername:port/) If StringInStr($s_FTPLink,"/",0,3) Then ;trailing slash exists or a path was included (ie. ftp://user:pass@servername:port/path/) $s_ServerName = StringMid($s_FTPLink,StringInStr($s_FTPLink,"@") + 1,StringInStr($s_FTPLink,":",0,3) - StringInStr($s_FTPLink,"@") - 1) $s_ServerPort = StringMid($s_FTPLink,StringInStr($s_FTPLink,":",0,3) + 1,StringInStr($s_FTPLink,"/",0,3) - StringInStr($s_FTPLink,"ftp://")-1) $i_ServerPort = Number($s_ServerPort) $s_FTPPath = StringMid($s_FTPLink,StringInStr($s_FTPLink,"/",0,3)) ;including root "/" Else ;no trailing slash (ftp://user:pass@servername:port) $s_ServerName = StringMid($s_FTPLink,StringInStr($s_FTPLink,"@") + 1,StringInStr($s_FTPLink,":",0,3) - StringInStr($s_FTPLink,"@")-1) $s_ServerPort = StringMid($s_FTPLink,StringInStr($s_FTPLink,":",0,3) + 1) $i_ServerPort = Number($s_ServerPort) $s_FTPPath = "/" EndIf Else ; no info about port assume default: 21 (ftp://user:pass@servername or ftp://user:pass@servername/) $i_ServerPort = 21 If StringInStr($s_FTPLink,"/",0,3) Then ;trailing slash exists or a path was included (ie. ftp://user:pass@servername/path/) $s_ServerName = StringMid($s_FTPLink,StringInStr($s_FTPLink,"@") + 1,StringInStr($s_FTPLink,"/",0,3) - StringInStr($s_FTPLink,"@")-1) $s_FTPPath = StringMid($s_FTPLink,StringInStr($s_FTPLink,"/",0,3)) ;including root "/" Else ;no trailing slash (ftp://user:pass@servername) $s_ServerName = StringMid($s_FTPLink,StringInStr($s_FTPLink,"@") + 1) $s_FTPPath = "/" EndIf EndIf Else ;no info about username and password (ie. ftp://servername/ or ftp://servername:port) If StringInStr($s_FTPLink,":",0,2) Then ;has info about port (ftp://servername:port or ftp://servername:port/) If StringInStr($s_FTPLink,"/",0,3) Then ;trailing slash exists or a path was included (ie. ftp://servername:port/path/) $s_ServerName = StringMid($s_FTPLink,StringInStr($s_FTPLink,"ftp://") + 6,StringInStr($s_FTPLink,":",0,2) - StringInStr($s_FTPLink,"ftp://")-6) $s_ServerPort = StringMid($s_FTPLink,StringInStr($s_FTPLink,":",0,2) + 1,StringInStr($s_FTPLink,"/",0,3) - StringInStr($s_FTPLink,"ftp://")-1) $i_ServerPort = Number($s_ServerPort) $s_FTPPath = StringMid($s_FTPLink,StringInStr($s_FTPLink,"/",0,3)) ;including root "/" Else ;no trailing slash (ftp://servername:port) $s_ServerName = StringMid($s_FTPLink,StringInStr($s_FTPLink,"ftp://") + 6,StringInStr($s_FTPLink,":",0,2) - StringInStr($s_FTPLink,"ftp://")-6) $s_ServerPort = StringMid($s_FTPLink,StringInStr($s_FTPLink,":",0,2) + 1) $i_ServerPort = Number($s_ServerPort) $s_FTPPath = "/" EndIf Else ; no info about port assume default: 21 (ie. ftp://servername or ftp://servername/) $i_ServerPort = 21 If StringInStr($s_FTPLink,"/",0,3) Then ;trailing slash exists or a path was included (ie. ftp://servername/path/) $s_ServerName = StringMid($s_FTPLink,StringInStr($s_FTPLink,"ftp://") + 6,StringInStr($s_FTPLink,"/",0,3) - StringInStr($s_FTPLink,"ftp://")-6) $s_FTPPath = StringMid($s_FTPLink,StringInStr($s_FTPLink,"/",0,3)) ;including root "/" Else ;no trailing slash (ftp://servername) $s_ServerName = StringMid($s_FTPLink,StringInStr($s_FTPLink,"ftp://") + 6,StringInStr($s_FTPLink,"/",0,3) - StringInStr($s_FTPLink,"ftp://")-6) $s_FTPPath = "/" EndIf EndIf EndIf ElseIf StringInStr($s_FTPLink,".") Then ;Written with ftp servername not as Link ie. servername:port/path $extFlag = 1 If StringInStr($s_FTPLink,":") Then ;port number exists servername:port or servername:port/path $s_ServerName = StringMid($s_FTPLink,1,StringInStr($s_FTPLink,":") - 1) If StringInStr($s_FTPLink,"/") Then ;path info exists servername:port/path $s_ServerPort = StringMid($s_FTPLink,StringInStr($s_FTPLink,":") + 1,StringInStr($s_FTPLink,"/") - StringInStr($s_FTPLink,":")-1) $i_ServerPort = Number($s_ServerPort) $s_FTPPath = StringMid($s_FTPLink,StringInStr($s_FTPLink,"/")) Else ;no slash found servername:port $s_ServerPort = StringMid($s_FTPLink,StringInStr($s_FTPLink,":") + 1) $i_ServerPort = Number($s_ServerPort) $s_FTPPath = "/" EndIf Else ; no port info assume default: 21 (ie. servername or servername/path) $i_ServerPort = 21 If StringInStr($s_FTPLink,"/") Then ;path info exists $s_ServerName = StringMid($s_FTPLink,1,StringInStr($s_FTPLink,"/") - 1) $s_FTPPath = StringMid($s_FTPLink,StringInStr($s_FTPLink,"/")) Else $s_ServerName = $s_FTPLink $s_FTPPath = "/" EndIf EndIf Else ;might not be a string containg ftp information $extFlag = 0 $errFlag = -1 $s_FTPPath = 0 EndIf SetExtended($extFlag) SetError($errFlag) Return $s_FTPPath EndFunc ;=============================================================================== ; Function Name: _FTPOpenFile() ; Description: Initiates access to a remote file on an FTP server for reading or writing. Use _FTPCloseFile() ; to close the ftp file. ; Parameter(s): $hConnect - The long from _FTPConnect() ; $lpszFileName - String of the ftp file to open ; $dwAccess - GENERIC_READ or GENERIC_WRITE (Default is GENERIC_READ) ; $dwFlags - Settings for the transfer see notes below (Default is 2 for FTP_TRANSFER_TYPE_BINARY) ; $dwContext - (Not Used) See notes below ; Requirement(s): DllCall, wininet.dll ; Return Value(s): On Success - Returns the handle to ftp file for read/write with _FTPReadFile() ; On Failure - 0 and Sets @error = -1 ;Notes: ;~ hConnect ;~ [in] Handle to an FTP session. ;~ lpszFileName ;~ [in] Pointer to a null-terminated string that contains the name of the file to be accessed. ;~ dwAccess ;~ [in] File access. This parameter can be GENERIC_READ or GENERIC_WRITE, but not both. ;~ dwFlags ;~ [in] Conditions under which the transfers occur. The application should select one transfer type and any of ; the flags that indicate how the caching of the file will be controlled. ;~ The transfer type can be one of the following values. ;~ FTP_TRANSFER_TYPE_ASCII Transfers the file using FTP's ASCII (Type A) transfer method. Control and ; formatting information is converted to local equivalents. ;~ FTP_TRANSFER_TYPE_BINARY Transfers the file using FTP's Image (Type I) transfer method. The file is ; transferred exactly as it exists with no changes. This is the default transfer method. ;~ FTP_TRANSFER_TYPE_UNKNOWN Defaults to FTP_TRANSFER_TYPE_BINARY. ;~ INTERNET_FLAG_TRANSFER_ASCII Transfers the file as ASCII. ;~ INTERNET_FLAG_TRANSFER_BINARY Transfers the file as binary. ;~ The following values are used to control the caching of the file. The application can use one or more of these values. ;~ INTERNET_FLAG_HYPERLINK Forces a reload if there was no Expires time and no LastModified time returned from the server ; when determining whether to reload the item from the network. ;~ INTERNET_FLAG_NEED_FILE Causes a temporary file to be created if the file cannot be cached. ;~ INTERNET_FLAG_RELOAD Forces a download of the requested file, object, or directory listing from the origin server, ; not from the cache. ;~ INTERNET_FLAG_RESYNCHRONIZE Reloads HTTP resources if the resource has been modified since the last time it was ; downloaded. All FTP and Gopher resources are reloaded. ;~ dwContext ;~ [in] Pointer to a variable that contains the application-defined value that associates this search with any ; application data. This is only used if the application has already called InternetSetStatusCallback to set ; up a status callback function. ;=============================================================================== Func _FTPOpenFile($hConnect,$lpszFileName,$dwAccess = 0x80000000,$dwFlags = 2,$dwContext = 0) Local $ai_FTPOpenFile = DllCall('wininet.dll', 'hwnd', 'FtpOpenFile', _ 'hwnd', $hConnect, _ ;HINTERNET hConnect 'str', $lpszFileName, _ ;LPCTSTR lpszFileName 'udword', $dwAccess , _ ;DWORD dwAccess 'dword', $dwFlags, _ ;DWORD dwFlags 'dword',$dwContext) ;DWORD_PTR dwContext If @error OR $ai_FTPOpenFile[0] == 0 Then SetError(-1) Return 0 EndIf Return $ai_FTPOpenFile[0] EndFunc ;=============================================================================== ; Function Name: _FTPReadFile() ; Description: Reads data from a handle opened by _FTPOpenFile() ; Parameter(s): $h_File - Handle returned by _FTPOpenFile to the ftp file ; $dwNumberOfBytesToRead - Number of bytes to read ; Requirement(s): DllCall, wininet.dll ; Return Value(s): On Success - Returns the binary/string read. ; On Failure - 0 and Sets @error = -1 for end-of-file, @error = 1 for other errors ;Notes: (InternetReadFile() parameters) ;~ hFile ;~ [in] Handle returned from a previous call to InternetOpenUrl, FtpOpenFile, GopherOpenFile, or HttpOpenRequest. ;~ lpBuffer ;~ [out] Pointer to a buffer that receives the data. ;~ dwNumberOfBytesToRead ;~ [in] Number of bytes to be read. ;~ lpdwNumberOfBytesRead ;~ [out] Pointer to a variable that receives the number of bytes read. InternetReadFile sets this value to zero before doing any work or error checking. ;=============================================================================== Func _FTPReadFile($h_File,$dwNumberOfBytesToRead) Local $s_FileRead = "" $lpBuffer = DllStructCreate("byte[" & $dwNumberOfBytesToRead & "]") $lpdwNumberOfBytesRead = DllStructCreate("long") Local $ai_FTPReadFile = DllCall('wininet.dll', 'int', 'InternetReadFile', _ 'hwnd', $h_File, _ ;HINTERNET hFile 'ptr', DllStructGetPtr($lpBuffer), _ ;LPVOID lpBuffer 'dword', $dwNumberOfBytesToRead, _ ;DWORD dwNumberOfBytesToRead 'ptr',DllStructGetPtr($lpdwNumberOfBytesRead)) ;LPDWORD lpdwNumberOfBytesRead If @error OR $ai_FTPReadFile[0] == 0 Then If DllStructGetData($lpdwNumberOfBytesRead,1) == 0 Then $lpBuffer = 0 $lpdwNumberOfBytesRead = 0 SetError(-1) Return 0 Else $lpBuffer = 0 $lpdwNumberOfBytesRead = 0 SetError(1) Return 0 EndIf EndIf $s_FileRead = DllStructGetData($lpBuffer,1) ;index is omitted so the entire array is written into $s_FileRead as a BinaryString $lpBuffer = 0 $lpdwNumberOfBytesRead = 0 Return $s_FileRead EndFunc ;=============================================================================== ; Function Name: _FTPCloseFile() ; Description: Closes the Handle returned by _FTPOpenFile. ; Parameter(s): $l_InternetSession - The handles from _FTPOpenFile.() ; Requirement(s): DllCall, wininet.dll ; Return Value(s): On Success - 1 ; On Failure - 0 Sets @error = -1 ;=============================================================================== Func _FTPCloseFile($l_InternetSession) Local $ai_InternetCloseHandle = DllCall('wininet.dll', 'int', 'InternetCloseHandle', 'hwnd', $l_InternetSession) If @error OR $ai_InternetCloseHandle[0] = 0 Then SetError(-1) Return 0 EndIf Return $ai_InternetCloseHandle[0] EndFunc Fonte: http://www.bytesintheveins.com/forum/viewtopic.php?t=4148 |
lknokl | Posted: 3/6/2008, 09:01 quoto! |
RedSkull92 | Posted: 2/6/2008, 18:37 L'unico modo per modificare un file hostato è avere accesso ftp quindi tramite la libreria ftp.au3 puoi farlo. per leggere il hostato puoi farlo tramite la libreria IE.au3 o INET |
MatteoJug | Posted: 2/6/2008, 17:46 Per leggerlo potresti fare: CODICE InetGet("file",@tempdir & "/~tmp_file.tmp") $read=Fileread(@tempdir & "/~tmp_file.tmp") Filedelete(@tempdir & "/~tmp_file.tmp") SPOILER (clicca per visualizzare) Sostituisci "file" con l'URL del file |
Crazy_Mauro | Posted: 2/6/2008, 17:26 CITAZIONE (lknokl @ 2/6/2008, 11:29) intendi per esempio modificare il sorgente di una pagina presente sul web? oppure per esempio sostituire un normale file....in tutti e due i casi devi comunque avere accesso all'ftp della makkina su cui la pagina e hostata....se vuoi trovi la udf per l'ftp sul sito ufficiale di autoit volevo aver la possibilità di modificare il codice sorgente di una pagina web presente su un mio host. Volevo anche chiedere se è possibile far leggere un file sempre presente nel web. una specie di fileread però su una pagina web o un file di testo. |
lknokl | Posted: 2/6/2008, 10:29 intendi per esempio modificare il sorgente di una pagina presente sul web? oppure per esempio sostituire un normale file....in tutti e due i casi devi comunque avere accesso all'ftp della makkina su cui la pagina e hostata....se vuoi trovi la udf per l'ftp sul sito ufficiale di autoit |
Crazy_Mauro | Posted: 31/5/2008, 17:32 E' possibile con autoit fare una funzione che permette la scrittura su un file presente nel web? Scusate questa domanda ma non sono ancora molto esperto al riguardo. |