Page 2 of 2

Re: Ftp @ in username problem

Posted: Wed May 21, 2014 9:57 pm
by danielmaximiliano
Hi :

Firefox creates a transaction with the FTP server, it responds with a LOGIN
login.jpg
login.jpg (40.06 KiB) Viewed 4903 times
when trying to enter the username and password responds with a 503 error logging
error 503.jpg
error 503.jpg (31.42 KiB) Viewed 4903 times
No error Harbour as Firefox or any other browser is the same.
did tell me how to create the new account; but where registration requests to that server know your requirements and Connection

Re: Ftp @ in username problem

Posted: Thu May 22, 2014 6:11 am
by hynan
Hi

And sorry, the GOODACCOUNTNAME and NOTGOODACCOUNTNAME was only ment to make a statement
ftp://Eldemo@johnsjn22.twentytwo.axc.nl ... two.axc.nl
working in Chrome 34.0.1847.137 m
not working in IE 11
( can someone please confirm ? )
so also some browsers have problem with the @ i think
attach screenshot ftp
as you can see very simple,
only thing is,
@johnsjn22.twentytwo.axc.nl is forced as part of the username

Thanks and greetings...

Re: Ftp @ in username problem

Posted: Fri May 23, 2014 4:12 pm
by hynan
Hi all,

I still think the
/* Comprobamos si el usuario contiene una @ para forzar el userid */
IF At( "@", cUser ) > 0
oFTP:oUrl:cServer := cServer
oFTP:oUrl:cUserID := cUser
oFTP:oUrl:cPassword := cPassword
ENDIF
is a bug in the above code .OR. in the tipclient source ?
The code is in several samples in the contrib dir and seen some times in this forum,
is there anyway a solution for the future ?
(i wish i could do myself, but i am just beginner) :D
Otherwise i must forget it...

Thanks and Greetings...

Re: Ftp @ in username problem

Posted: Fri May 23, 2014 5:57 pm
by danielmaximiliano
Demo Code FTPclient.prg
#include 'hmg.ch'

#define DISABLE 0
#define ENABLE 1
#define CRLF INetCRLF()

#require "hbtip"

REQUEST __HBEXTERN__HBSSL__
REQUEST HB_GT_WIN_DEFAULT

/*****************************************************************************/
Function Main
/*****************************************************************************/
Public cUSER := ""
Public cSERVER := ""
Public cPASSWORD := ""
Public aFiles
Public cUrl
Public cStr
Public lRetVal := .T.
Public oUrl
Public oFTP
Public cFile := ""
Public lTrace := .T.

SET MULTIPLE OFF
SET NAVIGATION EXTENDED
SETMODE( 25, 80 )
/*
* Send an file or list of files to ftp server
*/
cServer := "ftp://johnsjn22.twentytwo.axc.nl"
cUser := "Eldemo@johnsjn22.twentytwo.axc.nl"
cPassword := "12345"
/*
* An URL:
* http://gian:passwd@www.niccolai.ws/mypa ... =0&avar1=1" onclick="window.open(this.href);return false;" onclick="window.open(this.href);return false;
* ^--^ ^--^ ^----^ ^-------------^ ^----------------------^ ^------------^
* cProto UID PWD cServer cPath cQuery
* ^------------^ ^-------^
* cDirectory cFile
* ^--^ ^--^
* cFname cExt
*/
cUrl := cServer
oUrl := TUrl():New( cUrl )
oFTP := TIPClientFTP():New( oUrl, .T. )
oFTP:nConnTimeout := 20000
oFTP:bUsePasv := .F.

/* Comprobamos si el usuario contiene una @ para forzar el userid */
IF At( "@", cUser ) > 0
oFTP:oUrl:cServer := cServer
oFTP:oUrl:cUserID := cUser
oFTP:oUrl:cPassword := cPassword

ENDIF

IF oFTP:Open( cUrl )
aFiles := Directory( "SelectAFile\*.*" )
IF Len( aFiles ) > 0
FOR EACH cFile IN afiles
? "Filename: " + cFile[ F_NAME ]
IF ! oFtp:UploadFile( cFile[ F_NAME ] )
lRetVal := .F.
EXIT
ELSE
lRetVal := .T.
ENDIF

NEXT
ENDIF
oFTP:Close()
ELSE

MsgBox( "Could not connect to FTP server " , oURL:cServer )
IF oFTP:SocketCon == NIL
cStr += hb_eol() + "Connection not initialized"
ELSEIF hb_inetErrorCode( oFTP:SocketCon ) == 0
cStr += hb_eol() + "Server response:" + " " + oFTP:cReply
ELSE
cStr += hb_eol() + "Error in connection:" + " " + hb_inetErrorDesc( oFTP:SocketCon )
ENDIF
? cStr
lRetVal := .F.
ENDIF

/* Leemos ficheros a enviar */

RETURN lRetVal
No es un Bug dentro de la libreria HBTIP.
sucede que es un error de sitio que asume como nombre de usuario

normalmente esa URL se decompone de esta manera.

posiblemente Google Web Browse busca : para decomponer

Translate Google
Not a Bug HBTIP within the library.
happens to be a site that takes error as username
Eldemo@johnsjn22.twentytwo.axc.nl
URL that usually decomposes in this way.
/*
* An URL:
* http://gian:passwd@www.niccolai.ws/mypa ... =0&avar1=1" onclick="window.open(this.href);return false;" onclick="window.open(this.href);return false;
* ^--^ ^--^ ^----^ ^-------------^ ^----------------------^ ^------------^
* cProto UID PWD cServer cPath cQuery
* ^------------^ ^-------^
* cDirectory cFile
* ^--^ ^--^
* cFname cExt
*/
Browse possibly Google Web searching ":" to decompose

See : C:\harbour\contrib\hbtip\url.prg

and FTPClient HBTIP library

Code: Select all

METHOD New( oUrl, xTrace, oCredentials ) CLASS TIPClientFTP

   ::super:new( oUrl, iif( HB_ISLOGICAL( xTrace ) .AND. xTrace, "ftp", xTrace ), oCredentials )

   ::nDefaultPort := 21
   ::nConnTimeout := 3000
   ::bUsePasv     := .T.
   ::nAccessMode  := TIP_RW  // a read-write protocol
   ::nDefaultSndBuffSize := 65536
   ::nDefaultRcvBuffSize := 65536

   // precompilation of regex for better prestations
   ::RegBytes := hb_regexComp( "\(([0-9]+)[ )a-zA-Z]" )
   ::RegPasv :=  hb_regexComp( "([0-9]*) *, *([0-9]*) *, *([0-9]*) *, *([0-9]*) *, *([0-9]*) *, *([0-9]*)" )

   RETURN Self

METHOD Open( cUrl ) CLASS TIPClientFTP

   IF HB_ISSTRING( cUrl )
      ::oUrl := TUrl():New( cUrl )
   ENDIF

   IF Len( ::oUrl:cUserid ) == 0 .OR. Len( ::oUrl:cPassword ) == 0
      RETURN .F.
   ENDIF

   IF ! ::super:Open()
      RETURN .F.
   ENDIF

   IF ::GetReply()
      ::inetSendAll( ::SocketCon, "USER " + ::oUrl:cUserid + ::cCRLF )
      IF ::GetReply()
         ::inetSendAll( ::SocketCon, "PASS " + ::oUrl:cPassword + ::cCRLF )
         // set binary by default
         IF ::GetReply() .AND. ::TypeI()
            RETURN .T.
         ENDIF
      ENDIF
   ENDIF

   RETURN .F.
is logical and correct treatment of the URL within the library.
a modification to that library to make it compatible with URL like this.

ftp://Eldemo@johnsjn22.twentytwo.axc.nl ... two.axc.nl

Re: Ftp @ in username problem

Posted: Sat May 24, 2014 6:57 am
by hynan
Hi all,

First, thank you ver much for your work and time ;)

Get error when building,
using the default build.bat from HMG
Or is it need to build new library ?
( i have no idea how to do :oops: )
***
Harbour 3.2.0dev (r1312060701)
Copyright (c) 1999-2013, http://harbour-project.org/" onclick="window.open(this.href);return false;

main.prg(76) Error E0030 Syntax error "syntax error at 'NEW'"

main.prg(93) Error E0030 Syntax error "syntax error at 'OPEN'"

2 errors

No code generated.
hbmk2[main]: Error: Running Harbour compiler (embedded). 1
(v:\hmg\harbour\bin\harbour.exe) -n2 main.prg ftp.prg -DHBMK_HAS_HMG=1 -q -oC:\Users\HP\AppData\Local\Temp\hbmk_6q0j5m.dir\ -iv:\hmg\harbour\include -i. -iv:\hmg\include
***

Complete code:
***
#include 'hmg.ch'

#define DISABLE 0
#define ENABLE 1
#define CRLF INetCRLF()

#require "hbtip"

REQUEST __HBEXTERN__HBSSL__
REQUEST HB_GT_WIN_DEFAULT

/*****************************************************************************/
Function Main
/*****************************************************************************/
Public cUSER := ""
Public cSERVER := ""
Public cPASSWORD := ""
Public aFiles
Public cUrl
Public cStr
Public lRetVal := .T.
Public oUrl
Public oFTP
Public cFile := ""
Public lTrace := .T.

SET MULTIPLE OFF
SET NAVIGATION EXTENDED
SETMODE( 25, 80 )

cServer := "ftp://johnsjn22.twentytwo.axc.nl"
cUser := "Eldemo@johnsjn22.twentytwo.axc.nl"
cPassword := "12345"

cUrl := cServer
oUrl := TUrl():New( cUrl )
oFTP := TIPClientFTP():New( oUrl, .T. )
oFTP:nConnTimeout := 20000
oFTP:bUsePasv := .F.

IF At( "@", cUser ) > 0
oFTP:oUrl:cServer := cServer
oFTP:oUrl:cUserID := cUser
oFTP:oUrl:cPassword := cPassword
ENDIF

IF oFTP:Open( cUrl )
aFiles := Directory( "SelectAFile\*.*" )
IF Len( aFiles ) > 0
FOR EACH cFile IN afiles
? "Filename: " + cFile[ F_NAME ]
IF ! oFtp:UploadFile( cFile[ F_NAME ] )
lRetVal := .F.
EXIT
ELSE
lRetVal := .T.
ENDIF
NEXT
ENDIF
oFTP:Close()
ELSE
MsgBox( "Could not connect to FTP server " , oURL:cServer )
IF oFTP:SocketCon == NIL
cStr += hb_eol() + "Connection not initialized"
ELSEIF hb_inetErrorCode( oFTP:SocketCon ) == 0
cStr += hb_eol() + "Server response:" + " " + oFTP:cReply
ELSE
cStr += hb_eol() + "Error in connection:" + " " + hb_inetErrorDesc( oFTP:SocketCon )
ENDIF
? cStr
lRetVal := .F.
ENDIF

RETURN lRetVal
*---------------------------------------------------------------------------*
METHOD New( oUrl, xTrace, oCredentials ) CLASS TIPClientFTP

::super:new( oUrl, iif( HB_ISLOGICAL( xTrace ) .AND. xTrace, "ftp", xTrace ), oCredentials )

::nDefaultPort := 21
::nConnTimeout := 3000
::bUsePasv := .T.
::nAccessMode := TIP_RW // a read-write protocol
::nDefaultSndBuffSize := 65536
::nDefaultRcvBuffSize := 65536

// precompilation of regex for better prestations
::RegBytes := hb_regexComp( "\(([0-9]+)[ )a-zA-Z]" )
::RegPasv := hb_regexComp( "([0-9]*) *, *([0-9]*) *, *([0-9]*) *, *([0-9]*) *, *([0-9]*) *, *([0-9]*)" )

RETURN Self

METHOD Open( cUrl ) CLASS TIPClientFTP

IF HB_ISSTRING( cUrl )
::oUrl := TUrl():New( cUrl )
ENDIF

IF Len( ::oUrl:cUserid ) == 0 .OR. Len( ::oUrl:cPassword ) == 0
RETURN .F.
ENDIF

IF ! ::super:Open()
RETURN .F.
ENDIF

IF ::GetReply()
::inetSendAll( ::SocketCon, "USER " + ::oUrl:cUserid + ::cCRLF )
IF ::GetReply()
::inetSendAll( ::SocketCon, "PASS " + ::oUrl:cPassword + ::cCRLF )
// set binary by default
IF ::GetReply() .AND. ::TypeI()
RETURN .T.
ENDIF
ENDIF
ENDIF

RETURN .F.

*---------------------------------------------------------------------------*
***

Thanks and greetings...

Re: Ftp @ in username problem

Posted: Tue May 27, 2014 5:46 pm
by hynan
Hi all,

Can somebody please confirm the syntax error
***
main.prg(76) Error E0030 Syntax error "syntax error at 'NEW'"

main.prg(93) Error E0030 Syntax error "syntax error at 'OPEN'"
***
ik also did install 3.3.0 to be sure,
version.txt gives 3.3.0
build.log gives 3.2.0
***
Harbour 3.2.0dev (r1405061532)
Copyright (c) 1999-2014, http://harbour-project.org/" onclick="window.open(this.href);return false;

main.prg(76) Error E0030 Syntax error "syntax error at 'NEW'"

main.prg(93) Error E0030 Syntax error "syntax error at 'OPEN'"

2 errors

No code generated.
hbmk2[main]: Error: Running Harbour compiler (embedded). 1
(v:\hmg\harbour\bin\harbour.exe) -n2 main.prg -DHBMK_HAS_HMG=1 -q -oC:\Users\HP\AppData\Local\Temp\hbmk_udu5t0.dir\ -iv:\hmg\harbour\include -i. -iv:\hmg\include
***

Thanks and greetings...

Re: Ftp @ in username problem

Posted: Tue May 27, 2014 11:13 pm
by danielmaximiliano
Hello Hynan:

these new methods need to have the upper class,

Code: Select all

CREATE CLASS TIPClient
   METHOD New( oUrl, xTrace, oCredentials )
   METHOD Open( cUrl )
ENDCLASS

METHOD New( oUrl, xTrace, oCredentials ) CLASS TIPClient
ENDCLASS

METHOD New( oUrl, xTrace, oCredentials ) CLASS TIPClient
ENDCLASS


CREATE CLASS TIPClientFTP FROM TIPClient
   METHOD New( oUrl, xTrace, oCredentials )
   METHOD Open( cUrl )
   METHOD New2( oUrl, xTrace, oCredentials )    // You method
   METHOD Open2( cUrl )                                 // You method
ENDCLASS

METHOD Open2( cUrl ) CLASS TIPClientFTP
RETURN .F.

METHOD New2( oUrl, xTrace, oCredentials ) CLASS TIPClientFTP
RETURN .F.

compile Lib