1

Konu: Web'teki bir dosyanın oluşturulma tarihini öğrenmek

Herkese iyi pazarlar.
Web'te bir dosyam var.   www.xxxxx.com/xxxx/xxxxxx.exe   buradaki xxxxxx.exe dosyasının tarihini foxpro içinden kodla öğrenebilir miyim? Bu özelliği programın yeni sürümünü kontrol etmek amacıyla kullanmak istiyorum. Kullanıcı programı çalıştırdığında mevcut exe nin tarihini web'teki dosyanın tarihi ile kontrol edip, eğer web'teki dosya daha yeni tarihli ise güncelleme için kullanıcıya uyarı mesajı vermek istiyorum.

2

Re: Web'teki bir dosyanın oluşturulma tarihini öğrenmek

agetfileversion() sana yardimci olur,
asagidaki her 2 exe karsilastirilarak ftp ile download islemi baslatiliyor.buradan yola cikarak ftp serverdaki dosya ile local deki dosya karsilastirilarak guncelleme uyarisi yapilabilir...

Visual Fox Pro
#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 *************************************************************

3

Re: Web'teki bir dosyanın oluşturulma tarihini öğrenmek

Soykan bey, kodu çalıştıramadım. pc_arr, ftp_arr hatası veriyor.