1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
| #Define file_size 2
#Define file_date 3
#Define file_time 4
#Define file_version 4
Local LcCurrentdir,LcUpdateDir,LcLocalFile,LcFtpFile
LcUpdateDir=Sys(5)+Curdir()+'version'
PC_exe = 'xxx.exe'
FTP_exe = 'version/xxx.exe'
If Adir(pc_arr,PC_exe) # 1
Messagebox('pc deki exe yok',16,'Hata..')
Endif
If Adir(ftp_arr,FTP_exe) # 1
Messagebox('ftp deki exe yok',16,'Hata..')
Endif
=Agetfileversion(pc_ver,PC_exe)
=Agetfileversion(ftp_ver,FTP_exe)
If ftp_arr[file_size] # pc_arr[file_size] Or ;
ftp_arr[file_date] # pc_arr[file_date] Or ;
ftp_arr[file_time] # pc_arr[file_time] Or ;
ftp_arr[file_version] # pc_arr[file_version]
Messagebox('guncelleme gecerli',64,'guncelleme')
Wait Wind "Dosyalar güncelleniyor...." Nowait
* copy from version folder to curdir
Do file_download
Else
Messagebox('Guncelleme gerektiren dosya yok...',64,'guncelleme')
Endif
*...................................................................
Procedure file_download
Do ftp_get With ;
'[url=ftp://ftp.xxx.com]ftp.xxx.com[/url]', 'ddadlakda', 'daldald', 'www.xxx.com/downloads/xxx.exe', 'version/xxx.exe',1
Return
Endproc
*..................................................................
Procedure CheckInternetConnection
Local lcWebadress
lcWebadress="http://www.soykansoft.com"
If CheckInternetConnection(m.lcWebadress)
Messagebox(" internet var...."+ m.lcWebadress ,64,"internet kontrol")
Else
Messagebox(" internet yok...."+ m.lcWebadress ,16,"internet kontrol")
Endif
Endif
***********************************************************************************
Procedure ftp_get
*... FTPGet.PRG ...*
Parameters lcHost, lcUser, lcPwd, lcRemoteFile, lcNewFile, lnXFerType
*.................................................................................
*: Usage: DO ftpget WITH ;
*: '[url=ftp://ftp.host]ftp.host[/url]', 'name', 'password', 'source.file', 'target.file'[, 1 | 2]
*:
*: Where: lcHost = Host computer IP address or name
*: lcUser = user name - anonymous may be used
*: lcPwd = password
*: lcRemoteFile = source file name
*: lcNewFile = target file name
*: lnXFerType = 1 (default) for ascii, 2 for binary
*.................................................................................
*...set up API calls
Declare Integer InternetOpen In wininet;
STRING sAgent, Integer lAccessType, String sProxyName,;
STRING sProxyBypass, String lFlags
Declare Integer InternetCloseHandle In wininet Integer hInet
Declare Integer InternetConnect In wininet.Dll;
INTEGER hInternetSession,;
STRING lcHost,;
INTEGER nServerPort,;
STRING lcUser,;
STRING lcPassword,;
INTEGER lService,;
INTEGER lFlags,;
INTEGER lContext
Declare Integer FtpGetFile In wininet;
INTEGER hftpSession, ;
STRING lcRemoteFile,;
STRING lcNewFile, ;
INTEGER fFailIfExists,;
INTEGER dwFlagsAndAttributes,;
INTEGER dwFlags, ;
INTEGER dwContext
lcHost = Alltrim(lcHost)
lcUser = Alltrim(lcUser)
lcPwd = Alltrim(lcPwd)
lcRemoteFile = Alltrim(lcRemoteFile)
lcNewFile = Alltrim(lcNewFile)
sAgent = "vfp"
sProxyName = Chr(0) &&... no proxy
sProxyBypass = Chr(0) &&... nothing to bypass
lFlags = 0 &&... no flags used
*... initialize access to Inet functions
hOpen = InternetOpen (sAgent, 1,;
sProxyName, sProxyBypass, lFlags)
If hOpen = 0
Wait Window "Unable to get access to WinInet.Dll" Timeout 2
Return
Endif
*... The first '0' says use the default port, usually 21.
hftpSession = InternetConnect (hOpen, lcHost,;
0, lcUser, lcPwd, 1, 0, 0) &&... 1 = ftp protocol
If hftpSession = 0
*... close access to Inet functions and exit
= InternetCloseHandle (hOpen)
Wait Window "Unable to connect to " + lcHost + '.' Timeout 2
Return
Else
Wait Window "Connected to " + lcHost + " as: [" + lcUser + "]" Timeout 1
Endif
*... 0 to automatically overwrite file
*... 1 to fail if file already exists
fFailIfExists = 0
dwContext = 0 &&... used for callback
Wait Window 'Transferring ' + lcRemoteFile + ' to ' + lcNewFile + '...' Nowait
lnResult = FtpGetFile (hftpSession, lcRemoteFile, lcNewFile,;
fFailIfExists, 128, lnXFerType,;
dwContext)
*... 128 = #define FILE_ATTRIBUTE_NORMAL 0x00000080
*... See CreateFile for other attributes
* close handles
= InternetCloseHandle (hftpSession)
= InternetCloseHandle (hOpen)
If lnResult = 1
*... successful download, do what you want here
Wait Window 'Completed.' Timeout 1
* MODI FILE (lcNewFile)
Else
Wait Window "Unable to download selected file" Timeout 2
Endif
Return
Endproc
*** End of ftpGet.PRG ************************************************************* |