Raised This Month: $89 Target: $400
 22% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
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:
    59 
    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, 1810 views)
    File Type: cfg RemoteTargets.cfg (191 Bytes, 1446 views)
    File Type: smx tEasyFTP.smx (7.8 KB, 1351 views)
    File Type: sp Get Plugin or Get Source (tEasyFTP.sp - 1191 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
    Peace-Maker
    SourceMod Plugin Approver
    Join Date: Aug 2008
    Location: Germany
    Old 12-21-2011 , 20:16   Re: [ANY] tEasyFTP v0.0.1 (2011-07-24)
    Reply With Quote #2

    I'm acutally using this btw. Nice work!
    You got some typos in your plugin. (Declaring the UploadFile native without the underscore and missing a ! before FileExists(remotetargets.cfg...)

    It's working fine for the binary data i'm using it for even and especially on mapchanges.

    More suggestions:
    Adding those options in CurlUploadFile
    PHP Code:
    curl_easy_setopt_int(hCurlCURLOPT_FTP_CREATE_MISSING_DIRSCURLFTP_CREATE_DIR);
    curl_easy_setopt_int(hCurlCURLOPT_USE_SSLCURLUSESSL_TRY); 
    Supporting a "any:data" parameter in the UploadFile native which just gets added to the hTrie_UploadEntry trie on call and passed to the callback forward.

    And that +1 in your getFileBasename function seems out of place. Shouldn't that be inside the []?
    __________________

    Last edited by Peace-Maker; 12-21-2011 at 20:19.
    Peace-Maker is offline
    McFlurry
    Veteran Member
    Join Date: Mar 2010
    Location: RemoveEdict(0);
    Old 12-21-2011 , 20:51   Re: [ANY] tEasyFTP v0.0.1 (2011-07-24)
    Reply With Quote #3

    Ooh, very nice. This looks like something I'll use in the future. Nice work.
    Edit: Downloading a file from ftp would be very useful.
    __________________

    Last edited by McFlurry; 12-21-2011 at 21:09.
    McFlurry is offline
    Send a message via Skype™ to McFlurry
    Thrawn2
    Veteran Member
    Join Date: Apr 2009
    Old 12-29-2011 , 13:56   Re: [ANY] tEasyFTP v0.0.2 (2011-12-29)
    Reply With Quote #4

    Updated to 0.0.2
    • Added any:data parameter
    • Added 'ssl' and 'CreateMissingDirs' option to RemoteTargets
    • Fixed other issues reported by Peace-Maker

    Edit: Also fixed the missing parameter for the forward.
    __________________
    einmal mit profis arbeiten. einmal.

    Last edited by Thrawn2; 12-29-2011 at 15:11.
    Thrawn2 is offline
    minimoney1
    SourceMod Donor
    Join Date: Dec 2010
    Old 01-01-2012 , 18:58   Re: [ANY] tEasyFTP v0.0.2 (2011-12-29)
    Reply With Quote #5

    The plugin gives me the error of it being not able to resolve my host name but I can perfectly connect to it through Filezilla.
    Sorry for posting twice but I guess this is more related to the FTP part (tEasyFTP) rather than the demo plugin.
    minimoney1 is offline
    Thrawn2
    Veteran Member
    Join Date: Apr 2009
    Old 01-01-2012 , 19:37   Re: [ANY] tEasyFTP v0.0.2 (2011-12-29)
    Reply With Quote #6

    Quote:
    Originally Posted by minimoney1 View Post
    The plugin gives me the error of it being not able to resolve my host name but I can perfectly connect to it through Filezilla.
    You've started filezilla on your gameserver (via rdp to windows?) and tried connecting to your ftp and that worked fine? Then we have a problem... Or did you use FileZilla on your desktop machine?
    I'm assuming the latter and the next assumption is that your gameserver is rented from some random game server hosting company - they don't allow shell access probably. Might it be possible that they don't allow outgoing connections other than the ones made by the gameserver on its own either? Then it's not this plugins problem

    If i'm completely on the wrong path here, please correct me with some more details. I'm specifically curious on this: What error does it give when you try it with the IP directly? It probably won't be "can't resolve host" ?
    __________________
    einmal mit profis arbeiten. einmal.
    Thrawn2 is offline
    minimoney1
    SourceMod Donor
    Join Date: Dec 2010
    Old 01-01-2012 , 21:45   Re: [ANY] tEasyFTP v0.0.2 (2011-12-29)
    Reply With Quote #7

    Nope, yes you're right it's rented from a gameserver company, Gameservers.com to be exact.
    I've tried using the IP for the host and it gives the same error. The problem also is that even when I try it on SRCDS on my own computer (just for testing purposes), it gives me the same error.
    This applies for both having the host field as the IP and the domain.
    minimoney1 is offline
    Peace-Maker
    SourceMod Plugin Approver
    Join Date: Aug 2008
    Location: Germany
    Old 01-05-2012 , 21:15   Re: [ANY] tEasyFTP v0.0.2 (2011-12-29)
    Reply With Quote #8

    Awesome stuff
    __________________
    Peace-Maker is offline
    Peace-Maker
    SourceMod Plugin Approver
    Join Date: Aug 2008
    Location: Germany
    Old 01-11-2012 , 17:01   Re: [ANY] tEasyFTP v0.0.2 (2011-12-29)
    Reply With Quote #9

    Uh, i'll check that too ;)
    Code:
    L 01/10/2012 - 12:43:33: [SM] Native "AddToForward" reported: Plugin handle 6e006e is invalid (error 1)
    L 01/10/2012 - 12:43:33: [SM] Displaying call stack trace for plugin "tEasyFTP.smx":
    L 01/10/2012 - 12:43:33: [SM]   [0]  Line 302, C:\Users\Jannik\Desktop\Plugins\wcfanplugins\wcfansourcetvmanager\addons\sourcemod\scripting\tEasyFTP.sp::onComplete()
    Looks like i reloaded the plugin midupload :O
    __________________

    Last edited by Peace-Maker; 01-11-2012 at 17:02.
    Peace-Maker is offline
    Thrawn2
    Veteran Member
    Join Date: Apr 2009
    Old 01-11-2012 , 18:45   Re: [ANY] tEasyFTP v0.0.2 (2011-12-29)
    Reply With Quote #10

    Quote:
    Originally Posted by Peace-Maker View Post
    Looks like i reloaded the plugin midupload :O
    fixed. will be in the next version.
    thx for reporting.
    __________________
    einmal mit profis arbeiten. einmal.
    Thrawn2 is offline
    Reply


    Thread Tools
    Display Modes

    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 06:10.


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