| Bourgeois (Nv 1) |
 |
Inscrit le: 03 Jan 2009, 01:00 Messages: 203 Localisation: Paris Logiciel(s) préféré(s): VX Point(s) Fort(s): Ruby Sexe: Masculin Points d'aide: 1/60
Créations :
Voir ses créations
|
Telechargement de fichiers avec RmxpVoila un script permettant le transfert de fichiers directement sur RPGmaker Vous pourrez télécharger des fichiers via un protocole http, donc depuis un site internet, et via un serveur [url=http://ftp." target="_blank"]ftp.[/a] Hop un p'tit screenshot (ne faites pas attention au mapping ^^)  Le script en lui meme: - Code: Tout sélectionner
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # Telechargement de fichiers avec Rmxp # par berka v 2.1 rgss 1 # www.rpgmakervx-fr.com #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # ! Ne pas utiliser de serveur ftp contenant ds données perso et confidentielles # ! ce script possède vos identifiants ftp: un crack du projet les rend publics #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # Ftp : # ▼ Recevoir : # Net::Ftp.download("dos_sur_ftp/fichier.zip","./Graphics") # ▼ Envoyer : # Net::Ftp.upload("./Graphics/fichier.zip","/dos_sur_ftp/fichier.zip") # ▼ Créer un répertoire distant : # Net::Ftp.mkdir("/dos_sur_ftp") # Http : # ▼ recevoir : # Net::Http.download("url","./Graphics") # ▼ total octets téléchargés : # Net::HTTP.transfered # ▼ Taille du fichier : # Net::HTTP.size("test.zip") # ▼ % de progression : # Net::HTTP.progress("test.zip") # ▼ temps de transfert individuel: # Net::HTTP.temps("test.zip") # ▼ fichiers à télécharger : # Net::HTTP.transfers # ▼ fichier téléchargé ? : # Net::HTTP.loaded?("test.zip") #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- module Berka module NetError ErrConIn="Impossible de se connecter à Internet" ErrConFtp="Impossible de se connecter au Ftp" ErrConHttp="Impossible de se connecter au Serveur" ErrNoFFtpIn="Le fichier à recevoir n'existe pas" ErrNoFFtpEx="Le fichier à envoyer n'existe pas" ErrTranHttp="Le téléchargement Http a échoué" ErrDownFtp="Le téléchargement Ftp a échoué" ErrUpFtp="L'envoi Ftp a échoué" ErrNoFile="Aucun fichier à télécharger" ErrMkdir="Impossible de créer le répertoire distant" end end module Net W='wininet' SPC=Win32API.new('kernel32','SetPriorityClass','pi','i').call(-1,128) IOA=Win32API.new(W,'InternetOpenA','plppl','l').call('',0,'','',0) IC=Win32API.new(W,'InternetConnectA','lplpplll','l') print(Berka::NetErrorErr::ConIn)if IOA==0 module FTP FSCD=Win32API.new(W,'FtpSetCurrentDirectoryA','lp','l') FGF=Win32API.new(W,'FtpGetFileA','lppllll','l') FPF=Win32API.new(W,'FtpPutFile','lppll','l') FCD=Win32API.new(W,'FtpCreateDirectoryA','lp','l') module_function def init #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-# ftp="ftp.server.com" # port=21 # A modifier ! identifiant="user" # motdepasse="password" # #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-# @fb=IC.call(IOA,ftp,port,identifiant,motdepasse,1,0,0) ftp,port,identifiant,motdepasse=[nil]*4 # efface les ids par sécurité (print(Berka::NetError::ErrConFtp))if @fb==0 end def download(ext,int='./') init if @fb.nil? c=ext.split('/').pop if FSCD.call(@fb,ext.gsub(c,''))!=0 print(Berka::NetErrorErr::ErrDownFtp)if FGF.call(@fb,c,"#{int}/#{c}",0,32,2,0)==0 else print(Berka::NetErrorErr::ErrNoFFtpIn) end end def mkdir(rep) init if @fb.nil? print(Berka::NetErrorErr::ErrMkdir)if FCD.call(@fb,rep)==0 end def upload(int,ext) init if @fb.nil? if FSCD.call(@fb,ext)&&File.exist?(int) print(Berka::NetErrorErr::ErrUpFtp)if FPF.call(@fb,int,ext,2,0)==0 else print(Berka::NetErrorErr::ErrNoFFtpEx) end end end #-=-=-=-=-=-=-=-=-=-=-=-=-=-=- module HTTP IOU=Win32API.new(W,'InternetOpenUrl','lppllp','l') IRF=Win32API.new(W,'InternetReadFile','lpip','l') ICH=Win32API.new(W,'InternetCloseHandle','l','l') HQI=Win32API.new(W,'HttpQueryInfo','llppp','i') module_function def sizeloaded(i='');@read[i];end def transfered;@dloaded;end def transfers;@dls;end def progress(i='');(@read[i].to_f/@size[i]*100);end def loaded?(i='');@read[i]>=@size[i]rescue nil;end def temps(i='');@tps[i]if loaded?(i);end def size(i='');@size[i];end def download(url,int='./') @dloaded||=0;@dls||={};@i||=-1;@size||={};@read||={};@tps={} a=url.split('/');serv,root,fich=a[2],a[3..a.size].join('/'),a[-1] print(Berka::NetErrorErr::ErrNoFile)if fich.nil? @dls[fich]=Thread.start(url,int){|url,int|txt='';t=Time.now Berka::NetErrorErr::ErrConHttp if(e=IC.call(IOA,serv,80,'','',3,1,0))==0 f=IOU.call(IOA,url,nil,0,0,0) HQI.call(f,5,k="\0"*1024,[k.size-1].pack('l'),nil) @read[fich],@size[fich]=0,k.delete!("\0").to_i loop do buf,n=' '*1024,0 r=IRF.call(f,buf,1024,o=[n].pack('i!')) n=o.unpack('i!')[0] break if r&&n==0 txt << buf[0,n] @read[fich]=txt.size end (File.open(int+fich,'wb')<<txt).close @dloaded+=@read[fich] ICH.call(f);sleep(0.01) @tps[fich]=Time.now-t} end end end
Ce qui est fait: [list][*]Transferts relativement rapides [/*:m][*]Calcul du temps de transfert [/*:m][*]Taille des fichiers [/*:m][li]Progression[/list:u] Et une petite démo [a href="http://www.mediafire.com/download.php?tttn0yjzi52]la démo[/url] Voila tout ! berka
_________________ Twitter: Pensées politiques et juridiques. Réflexions informatiques
|
|