PRO | 39dll: Dateien herunterladen? oO

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • PRO | 39dll: Dateien herunterladen? oO

    Hy!
    Also, ich hab da eine Frage:
    Ist es mit der 39dll, oder mit einer anderen DLL möglich, Dateien aus dem I-Net herunterzuladen?
    Die SuFu hab ich genutzt, die hat mir aber keine Antwort auf meine Frage geliefert.
    Also ich meinte das i-wie so:

    GML-Quellcode

    1. /* Das ist nur ein Beispiel */
    2. file_download("http://domain.de/files/bla.txt","C:\Downloads")


    EDIT: Was ich will ist folgendes:
    Ein Patchsystem für das Spiel, das im Ordner des Games ist.
    Wenn ich drauf klicke soll folgendes passieren:

    GML-Quellcode

    1. file_delete("game.exe");
    2. file_download("http://bla.de/game.exe",working_directory+"\game.exe");
    3. execute_shell(working_directory+"\game.exe",0);


    EDIT2: Hä? Warum hat das GML 'Fenster' denn so komische Farben!? oO

    Danke schon mal! :)
    fabse64 -> haiyyu

    Dieser Beitrag wurde bereits 5 mal editiert, zuletzt von fabse64 ()

  • Dieses script war bei der 39dll dabei:


    Spoiler anzeigen

    GML-Quellcode

    1. /*
    2. argument0 = url to download from
    3. argument1 = local file to save as
    4. returns the error code from the server. 200 is a succesful download.
    5. NOTE: urls with usernames and passwords do not work.
    6. */
    7. var server, file, i, port, tcp, endloop, url, error;
    8. server = "";
    9. file = "/"
    10. port = 80;
    11. i = 0;
    12. error = 200;
    13. if(string_pos("http://", argument0) == 1)argument0 = string_delete(argument0, 1,7)
    14. //get file part of url
    15. i = string_pos("/", argument0);
    16. if(i)
    17. {
    18. file = string_copy(argument0, i, string_length(argument0)-i+1);
    19. argument0 = string_delete(argument0, i, string_length(file));
    20. }
    21. //get port part
    22. i = string_pos(":", argument0);
    23. if(i)
    24. {
    25. port = real(string_copy(argument0, 1, i-1));
    26. argument0 = string_delete(argument0, 1, i);
    27. }
    28. //get server part
    29. server = argument0;
    30. //the code above interpretes the url into a server variable, file variable and port.
    31. tcp = tcpconnect(server, port, 0);
    32. if(!tcp)return false;
    33. setformat(tcp, 1, chr(13) + chr(10)); //set format to text mode to receive one line at a time.
    34. //send get request
    35. clearbuffer();
    36. writechars("GET " + file+ " HTTP/1.1" + chr(13) + chr(10));
    37. writechars("Host: " + server + chr(13) + chr(10));
    38. writechars("Connection: close"+chr(13) + chr(10));
    39. writechars("Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/x-alambik-script, application/x-alambik-alamgram-link, */*"+chr(13)+chr(10));
    40. writechars("Accept-Language: en-us"+chr(13) + chr(10));
    41. writechars("User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322)"+chr(13) + chr(10));
    42. sendmessage(tcp);
    43. //receive file header
    44. //interpret header for any errors.
    45. endloop = false;
    46. while(!endloop)
    47. {
    48. receivemessage(tcp); //receive one line
    49. i = readsep(" "); //read first word
    50. switch(i)
    51. {
    52. //check http error code
    53. case "HTTP/1.1":
    54. case "HTTP/1.0":
    55. error = real(readsep(" "));
    56. if(error != 200 && error != 301)
    57. {
    58. closesocket(tcp);
    59. return error;
    60. }
    61. break;
    62. //if page moved than locate new page and download from it.
    63. case "Location:":
    64. if(error == 301)
    65. {
    66. closesocket(tcp);
    67. url = readsep(chr(13) + chr(10));
    68. return downloadfile(url,argument1);
    69. }
    70. break;
    71. //if blank line (end of header) then exit loop
    72. case "":
    73. endloop = true
    74. break;
    75. }
    76. }
    77. setformat(tcp, 2); //turn off all formatting so we can receive file data.
    78. if(file_exists(argument1))file_delete(argument1);
    79. file = fileopen(argument1, 1);
    80. //start receiving file
    81. while(receivemessage(tcp, 50000) > 0) //receive 50000 bytes
    82. {
    83. filewrite(file); //write file chunk to file.
    84. }
    85. closesocket(tcp);
    86. fileclose(file);
    87. return 200;
    Alles anzeigen

    "Is this one sloshing?"
    Four words you don't want to hear when you pick up a coffin...
  • Benutzer online 1

    1 Besucher