Raised This Month: $32 Target: $400
 8% 

[ANY] tEasyFTP v0.0.2 (2011-12-29)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author
Thrawn2
Veteran Member
Join Date: Apr 2009
Plugin ID:
2455
Plugin Version:
0.0.2
Plugin Category:
Technical/Development
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
    22 
    Plugin Description:
    Provides natives for easy FTP access.
    Old 07-24-2011 , 11:43   [ANY] tEasyFTP v0.0.2 (2011-12-29)
    Reply With Quote #1

    This requires the cURL extension to compile and use!

    Currently i've only implemented uploading file(s) to a ftp server, but i might also add some other stuff over time.
    This can't be considered stable (yet). Don't trust it. I might even change the natives... you have been warned.

    It uses a configuration scheme similar to databases.cfg. It expects a file RemoteTargets.cfg in your config folder that looks like this:
    Code:
    "RemoteTargets"
    {
    	"example"
    	{
    		"host"		"example.com"
    		"port"		"21"
    		"user"		"ftpuser"
    		"password"	"ftppass"
    		"path"		"/"
    		"ssl"		"try"
    		
    		"CreateMissingDirs"	"1"		
    	}
    }
    You could then use this native + callback to upload a file to that target:
    PHP Code:
    functag EasyFTP_FileUploaded public(const String:sTarget[], const String:sLocalFile[], const String:sRemoteFile[], iErrorCodeany:data);
    native EasyFTP_UploadFile(const String:sTarget[], const String:sLocalFile[], const String:sRemoteFile[], EasyFTP_FileUploaded:funcany:data 0); 
    Example:
    PHP Code:
    EasyFTP_UploadFile("demos""myDemoFile.dem""/"EasyFTP_CallBack); 
    and
    PHP Code:
    public EasyFTP_CallBack(const String:sTarget[], const String:sLocalFile[], const String:sRemoteFile[], iErrorCodeany:data)
    {
        if(
    iErrorCode == 0)        // These are the cURL error codes
        
    {
            
    PrintToServer("Success. File %s uploaded to %s."sLocalFilesTarget);    
        } else {
            
    PrintToServer("Failed uploading %s to %s."sLocalFilesTarget);    
        }

    This will upload the file myDemoFile.dem to the demos target and report the result using PrintToServer.

    Changelog:
    Can be found on github.

    Some Notes:
    • A target does not need to have a path specification. This is meant for the consumer of your plugin to configure where he wants the files to be put. The remoteFile you are specifying in your code is appended to that path.
    • You can omit leading slashes.
    • If you specify a trailing slash for the remote file, it uses the same basename as the local file.
      For example EasyFTP_UploadFile("demos", "/srcfolder/mydemo.dem", "/asdf/", CallbackFunc); uploads to /asdf/mydemo.dem.
    • This plugin queues your upload commands, so only one file will be transferred at a time and the queues will be processed in the order they appear in the config file - which means files will not necessarily be uploaded in the order you've added them if you are uploading them to different queues.
      This also means that an queue that always has a job in it blocks all following queues, which is a bug i have to fix. As long as you are operating on a single target or only on targets that don't tend to have an upload running all the time, you should be fine.

    Known Bugs/Issues
    • I've only tested this with binary transfers, no idea what happens when transfering an ASCII file, but i guess you should be fine.
    • The method this plugin reads binary data is awful, but i couldn't manage to not get 4 byte blocks by ReadFile(). Suggestions are very welcome.
    Attached Files
    File Type: inc tEasyFTP.inc (365 Bytes, 3227 views)
    File Type: cfg RemoteTargets.cfg (191 Bytes, 2790 views)
    File Type: smx tEasyFTP.smx (7.8 KB, 2423 views)
    File Type: sp Get Plugin or Get Source (tEasyFTP.sp - 2424 views - 10.4 KB)
    __________________
    einmal mit profis arbeiten. einmal.

    Last edited by Thrawn2; 12-29-2011 at 15:15. Reason: Updated to 0.0.2
    Thrawn2 is offline
     



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 12:45.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode