LetoDb -> UDF -> From Php

367 views
Skip to first unread message

Carlitus

unread,
Jan 21, 2019, 12:07:49 PM1/21/19
to Harbour Users
Hi all

I would like to know if someone has tried to connect from php to leto and run UDF (leto_udf). I do not ask for the use of dbf with an rdd from php, since it seems to me that it would not make sense, but if I see a great power in this library, the power to connect with the server leto (from php in this case), execute a udf, and receive the result.

Similar to the concept of a webservice.

I do not know if this topic would be very problematic.


Regards.
Carles

elch

unread,
Jan 22, 2019, 4:28:11 PM1/22/19
to Harbour Users
Hi Carles,

as you ask about LetoDB !, your question goes to Sir Kresin ...


-----
This answer is for LetoDBf, which is different in low-level details,
but basically exposes the same problem.

The module in LetoDBf: "source/phpclient/letocl.php" is never tested by me.
The inherited file was just a tiny bit adapted for the new communication protocol -- nothing therein will work,
as i just saw a bug for letoConnect() in there, so you even cannot connect ( that! may be quick fixed )

---
LETO_UDF( "FUNCTION", x1, ..., xN )
for PHP: Tl;Dr; : impossible

Explanation:
[ note: a "PHB_ITEM" represents in Harbour a PRG-level variable at C-level ]

The arguments ( x1 - xN ) are send as *Harbour* array,
[ therefor this PHB_ITEM is converted to a data-stream by hb_itemSerialize() ]
and then LetoUdf() receives encryted data,
which after decryption represents a serialized PHB_ITEM.

So we would need to do in PHP:
a) Harbour conform serialize the params
b) decrypt and reverse serialize the received data,
plus
c) get the content in received PHB_ITEM depending on its type
[ i.e. with a hb_itemGetCPtr() for a returned string ]

As even a basic PHP_ITEM type is unknown in PHP, its impossible
-- or a years long work to teach PHP understanding Harbour C-level ;-)

best regards
Rolf

Lailton Fernando Mariano

unread,
Jan 22, 2019, 9:51:01 PM1/22/19
to Harbour Users
Carlitus,

I think that you can do it but using harbour with cgi.
I have no experience with leto db but I have a great experience with cgi.
You can contact me and I will be happy in help you ( If you want to test with CGI ).

Regards,
Lailton

alkresin

unread,
Jan 23, 2019, 10:52:12 AM1/23/19
to Harbour Users
I began to write a php client few years ago and had implemented few operations (connection. getting management info, set/get variables) just to check if these will work. It all worked, but I didn't continue, because I hadn't projects, where I could use it.
Implementing of leto_udf() doesn't seem more complicated than leto_varset()/leto_varget(). I will look at it when I have some time.

Regards, Alexander.

Jorge Garate

unread,
Jan 23, 2019, 11:12:14 AM1/23/19
to Harbour Users
Could you upload a practical example with CGI or where to find information? Gracias. Jorge
Message has been deleted

Carlitus

unread,
Jan 23, 2019, 1:15:56 PM1/23/19
to Harbour Users




Hi, 


Rolf
I understand your explanation. I see the complexity in the system
>> or a years long work to teach PHP understanding Harbor C-level ;-)
I am sure that you are an expert, you would be able to do it in less time ... ;-)

Laiton
I think the use of Harbour CGI refers to a server that executes exe for each request and I don't know if this is really what I want, but thanks for your help

Alexander
You are the father of the system. And I think that if the server allows to act with the philosophy of a webservice, it would add a plus to this great system, because you would open to other platforms and technologies the use of the server. I don't know the complexity, but I will wait for your proposal to evaluate the performance of this great system.


Thank you all for your comments.

Regards
Carles.

Mel Smith

unread,
Jan 23, 2019, 8:00:14 PM1/23/19
to Harbour Users
Hi All:

   I have used Harbour as a CGI app for 9 years now, on four different web sites.  My Harbour app runs under Apache 2.2. Apache passes request the my harbour exe, where I do all the forms work, and the dbf work, then send back my response thru Apache to the client's browser. Very Easy and very simple. 

   HOWEVER, you have to learn a bit of HTML, CSS, and Javascript to put more power into your client browser apps. Response to a Client's request is usually never more than 1 second.  All needed form templates are built and filled out in quick time!

   The whosaway.com site contains the simplest of my CGI apps -- just read the request, and return the completed form to the client.

Why all the fuss ??   Harbour is the perfect CGI base !

-Mel

Lailton Fernando Mariano

unread,
Jan 23, 2019, 9:57:34 PM1/23/19
to Harbour Users
I agree :)

It is my app for WEB with HARBOUR!

Screen Shot 2019-01-24 at 00.55.24.png





Harbour is the Power!

Gabriel GMail

unread,
Jan 23, 2019, 10:01:50 PM1/23/19
to harbou...@googlegroups.com
Hello 
how we do to know your work? 
Is it payment? 
looks great
Regards
--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lailton Fernando Mariano

unread,
Jan 23, 2019, 10:08:56 PM1/23/19
to Harbour Users
Hi Gabo,

It is an example DIALOG created by PELLES C and I use it on my Web Application.
The code syntax is based on FiveWin.

Screen Shot 2019-01-24 at 01.04.30.png




The limit is your imagination :)

You can message me on skype "sup...@lailton.com.br" for more details 

Regards,
Lailton

Gabriel GMail

unread,
Jan 23, 2019, 10:25:25 PM1/23/19
to harbou...@googlegroups.com

Laiton

What license is your job is commercial?

Daniele

unread,
Jan 24, 2019, 1:21:53 AM1/24/19
to harbou...@googlegroups.com

Harbour CGI + HTML + Javascript: interactive Agenda...

Dan

Agenda1.png

Carlitus

unread,
Jan 24, 2019, 2:20:59 AM1/24/19
to Harbour Users
Hi

>> Why all the fuss ?? Harbor is the perfect CGI base!

I do not look for a CGI, but I look for ways to connect to servers, to collect data, just like a webservice does. The concept is easy to understand. I'm interested only in the back-end part.

LetoDb / LetoDbf seems to me a possible alternative to be able to work with environments that have dbf and for this reason I asked this question in the forum.

Regards
Carles

Francesco Perillo

unread,
Jan 24, 2019, 5:28:14 AM1/24/19
to harbou...@googlegroups.com
Carles,
look it in another way....

instead of working the letodbf protocol via php, a potentially very dangerous way, you could create some simple CGI scripts on the server and call them to act on the dbf... and you will be able to call the cgi from php, python, go, javascript... whatever language has a http interface...



--

Francesco Perillo

unread,
Jan 24, 2019, 5:29:40 AM1/24/19
to harbou...@googlegroups.com
Lailton, can you please elaborate a bit on the libraries you use on the web side?

elch

unread,
Jan 25, 2019, 6:53:50 AM1/25/19
to Harbour Users
Hi Carles,

on the decision between: fix-it or remove,
i uploaded a fix and bit extension for LetoDBf PHP access.

So yes!, it basically works, likely Alexander wrote.

It is possible (now implemented) to call an UDF function,
**but without any arguments** for that function.
It is further NOT possible to receive any result from UDF function in PHP.
The trick: the Leto_Var*() system can be used for data exchange
between PHP and LetoDB[f], as both sides have access to that.

The whole UDF functionality is strong bound and limited to Harbour.
* Most problem will be a missing 'workarea' in PHP, *
( i mean this 'object' with ALIAS, RECNO, EOF, ... )
So e,g, the UDF in PHP is called without a pre-selected workarea ...

This all is higly inconvenient manually, so PHP access is possible,
but looks like the last way if nothing else is available.

Attached ( reduced! ) screenshot as proove ;-)


best regards
Rolf


###
P.S. to other:
you reported about CGI, or fastCGI ?

For both you don't need LetoDB[f] -- but if the server is visible to the outside world,
Leto client don't need a browser ;-) -- or am i wrong ??
php.jpg

Ash

unread,
Jan 25, 2019, 7:56:39 AM1/25/19
to Harbour Users
Hello Rolf,

For both you don't need LetoDB[f] -- but if the server is visible to the outside world,
Leto client don't need a browser ;-) -- or am i wrong ??

You are correct. Your console.exe is a shining example of that.

Regards.
Ash 
Reply all
Reply to author
Forward
0 new messages