Post by tenochtitlanuk on Mar 12, 2023 13:54:23 GMT -5
I suggested to atomose that if he uses LB rather than JB he could make his games download a hi-score table to display when starting, & upload a user's score to a ftp server when exiting This high-score table would be generated by a program run by him say hourly, that read all new high scores and sorted them.
However I don't want people to know my ( paid for) username and password for the ftp/http server that runs my website, for obvious reasons!!! And yes, I could create and run a local server, ensure its security, and run it 24 h/24 with a static or edirected ISP address- hastle!
However I don't want people to know my ( paid for) username and password for the ftp/http server that runs my website, for obvious reasons!!! And yes, I could create and run a local server, ensure its security, and run it 24 h/24 with a static or edirected ISP address- hastle!
Anyway, as an experiment I created a FREE ftp site courtesy of DriverHQ. Very straightforward to create. The following code shows uploading a file, downloading a file, and also getting the remote directory listing.
PM me if you want to try it, and I'll send the username/password I used. But I'd prefer you set up your own site as you can delete my files or change the password!!
nomainwin
dim error$(6000)
error$( 0) ="No problem.."
error$( 1003) ="user not connected to server"
error$( 1004) ="cannot open file"
error$( 1008) ="action not taken"
error$( 1010) ="server cannot open file"
error$( 3001) ="3001"
error$( 5002) ="5002"
WindowWidth = 800
WindowHeight = 550
global parentftp, port, pasv, ftphost$, login$, password$, initpath$, upload$, serverFile$, backLocal$, TRUE, FALSE, ftpsession
port = 21 'port to use.
pasv = 1 'PASV mode? 1 is yes, 0 is no.
ftphost$ = "ftp.drivehq.com" 'ftp site address.
login$ = "*************" 'ftp site username login.
password$ = "*************" 'ftp site password.
initpath$ = "" 'leave blank if you want the site's default.
upload$ = "exampleN4a.txt" 'full path & file info for local file to upload. NB could all be the same...
serverFile$ = "exampleN4b.txt" 'what file is called on the ftp server.
backLocal$ = "exampleN4c.txt" 'what to call the returned local downloaded file.
TRUE = 1
FALSE = 0
ftpsession = FALSE
button #w.b1, " Upload ", [upload], LR, 550, 50, 110, 30
button #w.b2, "Download", [download], LR, 400, 50, 110, 30
button #w.b3, "Server dir'y", [remoteDir], LR, 250, 50, 110, 30
texteditor #w.te, 10, 10, 740, 400
open "LB" for window as #w
#w "trapclose [quit.main]"
#w "font bold 12"
parentftp =hwnd( #w)
wait
[upload]
call action "upload"
wait
[download]
call action "download"
wait
[remoteDir]
call action "Server dir'y"
wait
sub action command$ ' Implements at present file upload/download ( with renaming if you want) and remote direstory listing.
open "ftp4w32.dll" for dll as #ftp
ftpsession = TRUE
calldll #ftp, "FtpInit", parentftp as long, res as long : #w.te "Initialising "; res; " "; error$( res)
calldll #ftp, "FtpSetSynchronousMode", void as long : #w.te "Mode set async"
calldll #ftp, "FtpSetDefaultPort", port as long, void as long : #w.te "Port set 21"
calldll #ftp, "FtpSetPassiveMode", pasv as long, void as long : #w.te "Mode set passive"
calldll #ftp, "FtpLogin", ftphost$ as struct, login$ as struct, password$ as struct, parentftp as long, 0 as long, res as long: #w.te "Logging in. Returned "; res
'calldll #ftp, "FtpCWD", initpath$ as struct, res as long : #w.te "Change remote working directory " ; res; " "; error$( res); " "
if command$ ="upload" then
calldll #ftp, "FtpSendFile", upload$ as struct, serverFile$ as struct, 0 as long, 0 as long, parentftp as long, 0 as long, res as long:_
#w.te "Sent file "; upload$; " as "; serverFile$; " & received error "; error$( res)
end if
if command$ ="download" then
calldll #ftp, "FtpRecvFile", serverFile$ as struct, backLocal$ as struct, 0 as long, 0 as long, parentftp as long, 0 as long, res as long:_
#w.te "Requesting file "; serverFile$; " for download as "; backLocal$;_
" error ="; res; " "; error$( res)
end if
if command$ ="Server dir'y" then
dirlist$ ="ftplist.tmp": argument$ =""
calldll #ftp, "FtpDir", argument$ as struct, dirlist$ as struct, 1 as long, parentftp as long, 0 as long, res as long:_
#w.te "Dir'y listing..": #w.te argument$
open dirlist$ for input as #fIn
content$ =input$( #fIn, lof( #fIn))
close #fIn
kill dirlist$
#w.te content$
end if
[closeftp]
calldll #ftp, "FtpCloseConnection", void as long: #w.te "Connection closed... ";
calldll #ftp, "FtpRelease", void as long : #w.te " .. and released."
close #ftp
ftpsession = FALSE
#w.te "__________________________________"
#w.te ""
end sub
[quit.main]
close #w
if ftpsession = TRUE then
calldll #ftp, "FtpCloseConnection", void as long
calldll #ftp, "FtpRelease", void as long
close #ftp
end if
end
' Initialising 0 No problem..
' Mode set async
' Port set 21
' Mode set passive
' Logging in. Returned 0
' Sent file exampleN4.txt & received error No problem..
' Dir'y listing..
' drwx------ 1 user group 138 Mar 09 16:06 My Documents
' drwx------ 1 user group 3093195 Mar 09 16:06 My Pictures
' drwx------ 1 user group 111 Mar 11 20:56 tenoch
' drwx------ 1 user group 24332 Mar 09 16:06 wwwhome
' drwx------ 1 user group 0 Mar 12 12:55 drivehqshare
' -rwx------ 1 user group 23 Mar 09 16:53 example.txt
' -rwx------ 1 user group 34 Mar 10 18:49 exampleN.txt
' -rwx------ 1 user group 33 Mar 10 19:32 exampleN2.txt
' -rwx------ 1 user group 44 Mar 11 21:47 exampleN3.txt
' -rwx------ 1 user group 129 Mar 12 12:54 exampleN4.txt
' -rwx------ 1 user group 129 Mar 12 12:55 exampleN4c.txt
' Requesting file exampleN4c.txt for download ; error =0 No problem..
' Connection closed
' .. and released.