Raised This Month: $ Target: $400
 0% 

FTP Upload


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dordnung
Veteran Member
Join Date: Apr 2010
Old 12-13-2010 , 10:19   FTP Upload
Reply With Quote #1

Hey,

is it possible to upload something to an FTP Server?

greetz popo
__________________
dordnung is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 12-13-2010 , 10:50   Re: FTP Upload
Reply With Quote #2

http://www.nsftools.com/tips/RawFTP.htm#STOR
__________________
FaTony is offline
dordnung
Veteran Member
Join Date: Apr 2010
Old 12-13-2010 , 12:58   Re: FTP Upload
Reply With Quote #3

and how can i use it in sourcemod ;D
__________________
dordnung is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 12-13-2010 , 13:14   Re: FTP Upload
Reply With Quote #4

Sockets extension can do it.
__________________
FaTony is offline
dordnung
Veteran Member
Join Date: Apr 2010
Old 12-13-2010 , 16:04   Re: FTP Upload
Reply With Quote #5

Can i work with the "listenexample.sp" in the socket archive?
__________________
dordnung is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 12-13-2010 , 16:05   Re: FTP Upload
Reply With Quote #6

You should understand how FTP works on the packets level.
__________________
FaTony is offline
dordnung
Veteran Member
Join Date: Apr 2010
Old 12-13-2010 , 16:11   Re: FTP Upload
Reply With Quote #7

Mh i don't work with sockets yet, but with FTP Commands, i thought, when i change the "quit" in the "listenexample.sp" with the right FTP command and change the IP + Port, it could work
__________________
dordnung is offline
dordnung
Veteran Member
Join Date: Apr 2010
Old 12-14-2010 , 13:59   Re: FTP Upload
Reply With Quote #8

Ok, i start to code something.
login and set some attributes works nice, but the "STOR" Command not works.
I have to login in the Passive Host, to use this Command, in Filezilla this works nice, but not in my script.

My Script:

PHP Code:
#include <sourcemod>
#include <socket>

new Port 0
new String:Host[20];

public 
OnPluginStart() 
{
    new 
Handle:socket SocketCreate(SOCKET_TCPOnSocketError);
    
    
SocketConnect(socketOnSocketConnectedOnSocketReceiveOnSocketDisconnected"MyHoster"21)
}

public 
OnSocketError(Handle:socket, const errorType, const errorNumany:arg
{
    
LogError("socket error %d (errno %d)"errorTypeerrorNum);
    
CloseHandle(socket);
}

public 
OnSocketConnected(Handle:socketany:arg
{
    
SocketSend(socket"USER MyUserName\r\n");
}

public 
OnSocketConnected2(Handle:socketany:arg
{
    
PrintToServer("works"); // work (;
    
SocketSend(socket"tt\ndfgdfg\nsdfsdf"); // Set the content of the File
}

public 
OnSocketReceive2(Handle:socketString:receiveData[], const dataSizeany:arg
{    
    
PrintToServer("works");  // Doesn't work (;
    
CloseHandle(socket);  // Save the Content
}

public 
OnSocketReceive(Handle:socketString:receiveData[], const dataSizeany:arg
{
    if (!
StrContains(receiveData"331"))
    {
        
SocketSend(socket"PASS myPassword\r\n"); // work (;
    
}
    else if (!
StrContains(receiveData"230"))
    {
        
SocketSend(socket"PASV\r\n"); // work (;
    
}
    else if (!
StrContains(receiveData"250"))
    {
        
SocketSend(socket"TYPE A\r\n"); // work (;
    
}
    else if (!
StrContains(receiveData"200"))
    {
        
SocketSend(socket"STOR somefile.txt");
        
        new 
Handle:socket2 SocketCreate(SOCKET_TCPOnSocketError);
        
SocketConnect(socket2OnSocketConnected2OnSocketReceive2OnSocketDisconnectedHostPort)
    }
    else if (!
StrContains(receiveData"227")) 
    {
        
/* Make the Passive Response to an IP + Port*/
        
        
decl String:buffers[6][10];
        
decl String:CopyReceiver[512];
        
decl String:part[128];
        
        
Format(CopyReceiversizeof(CopyReceiver), receiveData)
        
        
SplitString(CopyReceiver"("partsizeof(part))
        
ReplaceString(CopyReceiversizeof(CopyReceiver), part"")
        
ReplaceString(CopyReceiversizeof(CopyReceiver), ")""")
        
ReplaceString(CopyReceiversizeof(CopyReceiver), "(""")
        
ExplodeString(CopyReceiver","buffers69)
        
Format(Hostsizeof(Host), "%s.%s.%s.%s"buffers[0], buffers[1], buffers[2], buffers[3]);
        
Port = (StringToInt(buffers[4]) * 256 ) + StringToInt(buffers[5])
        
        
SocketSend(socket"CWD aPath\r\n"); // work (;
    
}
}

public 
OnSocketDisconnected2(Handle:socketany:arg
{
    
CloseHandle(socket);

__________________
dordnung is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 12-14-2010 , 14:10   Re: FTP Upload
Reply With Quote #9

You need to transfer whole file by packets.
__________________
FaTony is offline
dordnung
Veteran Member
Join Date: Apr 2010
Old 12-14-2010 , 14:49   Re: FTP Upload
Reply With Quote #10

How do you mean this?
__________________
dordnung is offline
Reply



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 11:19.


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