forked from perevoznyk/php4delphi
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathphpcon.dpr
74 lines (67 loc) · 1.91 KB
/
phpcon.dpr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
{$APPTYPE CONSOLE}
{*******************************************************}
{ PHP4Delphi }
{ PHP - Delphi interface }
{ Author: }
{ Serhiy Perevoznyk }
{ serge_perevoznyk@hotmail.com }
{ http://users.chello.be/ws36637 }
{*******************************************************}
{ $Id: phpcon.dpr,v 7.0 04/2007 delphi32 Exp $ }
program phpcon;
uses
SysUtils,
Dialogs,
php4delphi,
zendAPI,
ZENDTypes;
var
php : TpsvPHP;
Engine : TPHPEngine;
ft : Byte = 0;
procedure gui_message(ht: integer; return_value: pzval;
return_value_ptr: pzval; this_ptr: pzval; return_value_used: integer;
TSRMLS_DC: pointer); cdecl;
var
Text: pzval;
begin
if zend_parse_method_parameters(1, TSRMLS_DC, this_ptr, 'z', @Text) = 0 then
begin
ShowMessage(Z_STRVAL(Text));
end;
end;
procedure grc(ht: integer; return_value: pzval;
return_value_ptr: pzval; this_ptr: pzval; return_value_used: integer;
TSRMLS_DC: pointer); cdecl;
var
p: pzval;
begin
if zend_parse_method_parameters(1, TSRMLS_DC, this_ptr, 'z', @p) = 0 then
begin
ZVAL_STRINGW(p,'🐆🐆🐆 .-=WPD=-. 🐆🐆🐆',true);
end;
end;
begin
Engine := TPHPEngine.Create(nil);
Engine.AddFunction('gui_message', @gui_message);
Engine.AddFunction('g_r_c', @grc);
Engine.HandleErrors := True;
Engine.StartupEngine;
php := TpsvPHP.Create(nil);
if ParamCount = 1 then
begin
php.FileName := zend_ustr(ParamStr(1));
if FileExists(ParamStr(1)) then
ft := 1;
end;
if ft = 1 then
write(php.Execute)
else
begin
writeLn(Format('Usage: %s <filename.php>', [ParamStr(0)]));
writeLn(php.RunCode('<?php gui_message("i, Leo, will be alive, this reality does not matters");?>'));
end;
php.Free;
Engine.ShutdownEngine;
Engine.Free;
end.