HBTIP... GREAT!!!

Discuss anything else that does not suite other forums.

Moderator: Rathinagiri

User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

HBTIP... GREAT!!!

Post by Roberto Lopez »

Hi All,

As I've said in other post, I'm working on an Internet project (a database application/website) and I need FTP access from a client (HMG) application.

Sadly Matteo Baccan socket lib has only basic support for FTP (only login and list). So, I've searched for an alternative and dig (again) on HBTIP.

I've amazed with superb support for FTP. Only in minutes, I've managed to login, create and delete folders and files in an extremely easy way.

Of course... HBTIP is included and linked by default in HMG from some time ago.

This is the one on two FTP console demos bundled with HBTIP (Harbour) source:

Code: Select all

/*
 * $Id: ftpadv.prg 8734 2008-06-15 21:11:36Z vszakats $
 */

/******************************************
* TIP test
* FTP Advanced operations Test
*****/

PROCEDURE MAIN( cUrl )
   LOCAL oCon, oUrl

   oUrl := tURL():New( cUrl )
   IF Empty( oUrl )
      ? "Invalid url " + cUrl
      ?
      QUIT
   ENDIF

   IF oUrl:cProto != "ftp"
      ? 'This is a "DELE" test for ftp.'
      ? 'Use an ftp address with a file that you can delete.'
      ?
      QUIT
   END

   oCon := TipClientFtp():New( oUrl )
   oCon:nConnTimeout := 20000
   ? "Connecting with", oUrl:cServer
   IF oCon:Open( cUrl )
      ? "Connection eshtablished"
      ? "Deleting", oUrl:cPath
      IF oCon:CWD( oUrl:cPath )
         ? "CWD success"
         IF oCon:Dele( oUrl:cFile )
            ? "DELE success"
         ELSE
            ? "DELE Faliure (server reply:", oCon:cReply + ")"
         ENDIF
      ELSE
         ? "CWD Faliure (server reply:", oCon:cReply + ")"
      ENDIF

      oCon:Close()
   ELSE
      ? "Can't connect with", oUrl:cServer
      IF oCon:SocketCon == NIL
         ? "Connection not initiated"
      ELSEIF hb_InetErrorCode( oCon:SocketCon ) == 0
         ? "Server sayed:", oCon:cReply
      ELSE
         ? "Error in connection:", hb_InetErrorDesc( oCon:SocketCon )
      ENDIF
   END

   ? "Done"
   ?
RETURN
Please, consider that you must 'construct' the url this way:

Code: Select all

ftp://user:passwd@<ftpserver>/[<path>]

Regards,

Roberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: HBTIP... GREAT!!!

Post by Rathinagiri »

Thanks a lot Roberto.

HMG's Web presence is need of the hour. This is also a way of it.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: HBTIP... GREAT!!!

Post by Roberto Lopez »

rathinagiri wrote:Thanks a lot Roberto.

HMG's Web presence is need of the hour. This is also a way of it.
Yes... don't matter if we like it or not :)

Another interesting thing I've found (and using) is that you could make an HMG client app to be used as web browser replacement to send forms (via GET or POST) to a web server.

So, for the same web app you could use a web browser or HMG client transparently to the server.

Here is another HBTIP (console) sample (bundled with Harbour sources) that send a request to Google and handles the response:

Code: Select all

/*
 * $Id: loadhtml.prg 8734 2008-06-15 21:11:36Z vszakats $
 */

// Sends a query to Google and displays the Links from the response HTML page

PROCEDURE Main
   LOCAL oHttp, cHtml, hQuery, aLink, oNode, oDoc

   oHttp:= TIpClientHttp():new( "http://www.google.de/search" )
   
   // build the Google query
   hQUery := hb_Hash()
   hb_hSetCaseMatch( hQuery, .F. )

   hQuery["q"]    := "xHarbour"
   hQuery["hl"]   := "en"
   hQuery["btnG"] := "Google+Search"

   // add query data to the TUrl object
   oHttp:oUrl:addGetForm( hQuery )

   // Connect to the HTTP server
   IF .NOT. oHttp:open()
      ? "Connection error:", oHttp:lastErrorMessage()
      QUIT
   ENDIF

   // download the Google response
   cHtml   := oHttp:readAll()
   oHttp:close()
   ? Len(cHtml), "bytes received "

   oDoc := THtmlDocument():new( cHtml )

   oDoc:writeFile( "Google.html" )

   // ":a" retrieves the first <a href="url"> text </a> tag
   oNode := oDoc:body:a
   ? oNode:getText(""), oNode:href

   // ":divs(5)" returns the 5th <div> tag
   oNode := oDoc:body:divs(5)

   // "aS" is the plural of "a" and returns all <a href="url"> tags
   aLink := oNode:aS

   FOR EACH oNode IN aLink
      ? HtmlToOem( oNode:getText("") ), oNode:href
   NEXT
RETURN
Regards,

Roberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: HBTIP... GREAT!!!

Post by esgici »

Roberto Lopez wrote: ...
... you could make an HMG client app to be used as web browser replacement to send forms (via GET or POST) to a web server.

So, for the same web app you could use a web browser or HMG client transparently to the server.
...
Excessive ! :shock:

Now, I am thinking that does I am a REAL Harbour user ?

Regards

--

esgici
Viva INTERNATIONAL HMG :D
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: HBTIP... GREAT!!!

Post by Roberto Lopez »

esgici wrote:
Roberto Lopez wrote: ...
... you could make an HMG client app to be used as web browser replacement to send forms (via GET or POST) to a web server.

So, for the same web app you could use a web browser or HMG client transparently to the server.
...
Excessive ! :shock:

Now, I am thinking that does I am a REAL Harbour user ?

Regards

--

esgici
The world has changed :)

We must try to keep the best of xBase, but we must create useful applications too.

Using the (omnipresent) PHP+MYSQL web server technology to access databases via the Internet is a very very useful and easy thing, and despite a couple of simple PHP routines your app will be pure HMG :)

Regards,

Roberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: HBTIP... GREAT!!!

Post by Rathinagiri »

Roberto Lopez wrote:
Using the (omnipresent) PHP+MYSQL web server technology to access databases via the Internet is a very very useful and easy thing, and despite a couple of simple PHP routines your app will be pure HMG :)

Regards,

Roberto.
Great words from a great man.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: HBTIP... GREAT!!!

Post by esgici »

Roberto Lopez wrote: The world has changed :)
And continue changing with an extreme speed :(
We must try to keep the best of xBase, but we must create useful applications too.
You are absolutely right as always.
Using the (omnipresent) PHP+MYSQL web server technology to access databases via the Internet is a very very useful and easy thing


Since you say "it will be easy" I believe you :D
and despite a couple of simple PHP routines your app will be pure HMG :)
This is the best news :D

If we achieve building an web based application, we can build also apps to run in an "intranet", right ?

Since a long time we had worked for "networked" apps. When Novel has been obsoleted ( by Windows :( ) our works also obsoleted :cry: . Basically an intranet is a company based network, I think.

Best Regards

--

esgici
Viva INTERNATIONAL HMG :D
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: HBTIP... GREAT!!!

Post by Roberto Lopez »

esgici wrote: If we achieve building an web based application, we can build also apps to run in an "intranet", right ?

Since a long time we had worked for "networked" apps. When Novel has been obsoleted ( by Windows :( ) our works also obsoleted :cry: . Basically an intranet is a company based network, I think.

esgici
The 'problem' right now, is that 'company' people want to access their data from office PCs but they want to access to it from public machines connected to Internet too (or from their own notebooks connected via wi-fi to the Internet).

Usually, part of the information must be accessible via the general public via a web site too.

And its really easy, the problem is that you require knowledge (at least) in web servers, sql and php.

I recommend you 'EasyPHP'. It is a nice package containing Apache, MySql and PHP. All products are bundled in the same package and start working from the start with zero configuration.

For PHP part, please take a look at the manuals at php.net.

Moreover, there are lots of free hosting services offering Apache, MySql and PHP, so the practice online is not a problem.

Regards,

Roberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
apais
Posts: 440
Joined: Fri Aug 01, 2008 6:03 pm
DBs Used: DBF
Location: uruguay
Contact:

Re: HBTIP... GREAT!!!

Post by apais »

Hola Roberto:

Data transportation is independent from it's utilization or format.
Just because you use a public net (wan) to transport your data doesn't mean you must use public tools to view/update it.
See Leto db server. You can have your dbfs in a machine across the world via the public internet. If you use html/php must be because you want a universal or cross-platform client program, but that is a diferent kind of animal.
With the advent of multithreading in Harbour it will be possible to have real custom data servers. Two programs can talk to each other and exchange data in a propietary and xbase compatible format. I'm doing that from many years with Xbase++.
No meant to attack anyone, just clarifying concepts to all.

HTH
Angel Pais
Angel Pais
Web Apps consultant/architect/developer.
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: HBTIP... GREAT!!!

Post by Roberto Lopez »

apais wrote:Hola Roberto:

Data transportation is independent from it's utilization or format.
Just because you use a public net (wan) to transport your data doesn't mean you must use public tools to view/update it.
See Leto db server. You can have your dbfs in a machine across the world via the public internet. If you use html/php must be because you want a universal or cross-platform client program, but that is a diferent kind of animal.
With the advent of multithreading in Harbour it will be possible to have real custom data servers. Two programs can talk to each other and exchange data in a propietary and xbase compatible format. I'm doing that from many years with Xbase++.
No meant to attack anyone, just clarifying concepts to all.

HTH
Angel Pais
I know letodb. I'we downloaded and reviewed. It appears to be a good thing, but... I like the idea of intechangeability between web browsers and HMG desktop applications being this, transparent for the server.

Moreover, not all of hosting services allows you to install your own binaries or (at least) usually need a more expensive hosting plan to allow that (specially Windows).

Using PHP + MySql on the server side, you can be sure that your server side code will run on any place, and any situation and (as I've said) you can access to it via HMG desktop apps or web browsers.

Regards,

Roberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
Post Reply