-
Notifications
You must be signed in to change notification settings - Fork 16
/
phpModules.pas
767 lines (678 loc) · 21.9 KB
/
phpModules.pas
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
{*******************************************************}
{ PHP4Delphi }
{ PHP - Delphi interface }
{ }
{ Author: }
{ Serhiy Perevoznyk }
{ http://users.chello.be/ws36637 }
{*******************************************************}
{$I PHP.INC}
{ $Id: phpModules.pas,v 6.2 02/2006 delphi32 Exp $ }
unit phpModules;
interface
uses
SyncObjs, Windows, SysUtils, Classes, Forms, Consts,
PHPCommon,
{$IFDEF VERSION6}RTLConsts, Variants,{$ENDIF} ZendAPI, phpAPI, phpFunctions,
ZendTypes, PHPTypes;
type
TOnModuleEvent = procedure(Sender : TObject; TSRMLS_DC : pointer) of object;
TCustomPHPExtension = class(TDataModule)
private
FAbout : TPHPAboutInfo;
FTSRMLS : pointer;
FOnModuleInfo : TOnModuleEvent;
FOnModuleInit : TOnModuleEvent;
FOnModuleShutdown : TOnModuleEvent;
FOnRequestInit : TOnModuleEvent;
FOnRequestShutdown : TOnModuleEvent;
FOnActivation : TNotifyEvent;
FOnDeactivation : TNotifyEvent;
FModuleType : TZendModuleType;
FVersion : string;
FModuleName : string;
FFunctions : TPHPFunctions;
procedure SetFunctions(const Value : TPHPFunctions);
protected
public
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;
procedure puts(str : PChar);
procedure phpwrite(str : PChar; str_len : integer);
procedure phpwrite_h(str : PChar; str_len : integer);
procedure puts_h(str : PChar);
procedure ReportError(ErrType : integer; ErrText : PChar);
function FunctionByName(const AName : string) :TPHPFunction;
property About : TPHPAboutInfo read FAbout write FAbout stored False;
property ModuleType : TZendModuleType read FModuleType write FModuleType default mtPersistent;
property Version : string read FVersion write FVersion;
property Functions : TPHPFunctions read FFunctions write SetFunctions;
property ModuleName : string read FModuleName write FModuleName;
property TSRMLS : pointer read FTSRMLS;
property OnActivation : TNotifyEvent read FOnActivation write FOnActivation;
property OnDeactivation : TNotifyEvent read FOnDeactivation write FOnDeactivation;
property OnModuleInit : TOnModuleEvent read FOnModuleInit write FOnModuleInit;
property OnModuleShutdown : TOnModuleEvent read FOnModuleShutdown write FOnModuleShutdown;
property OnRequestInit : TOnModuleEvent read FOnRequestInit write FOnRequestInit;
property OnRequestShutdown : TOnModuleEvent read FOnRequestShutdown write FOnRequestShutdown;
property OnModuleInfo : TOnModuleEvent read FOnModuleInfo write FOnModuleInfo;
end;
TPHPExtension = class(TCustomPHPExtension)
public
constructor Create(AOwner : TComponent); override;
published
property About;
property ModuleType;
property Version;
property Functions;
property ModuleName;
property OnActivation;
property OnDeactivation;
property OnModuleInit;
property OnModuleShutdown;
property OnRequestInit;
property OnRequestShutdown;
property OnModuleInfo;
end;
TClassRegister = class
CN : string;
CH : integer;
end;
TPHPApplication = class(TComponent)
private
FClassList : TThreadList;
FActiveFunctionName : PChar;
FPHPExtensionClass: TComponentClass;
FCriticalSection: TCriticalSection;
FActivePHPModules: TList;
FInactivePHPModules: TList;
FTitle: string;
FMaxConnections: Integer;
FCacheConnections: Boolean;
FModuleNumber : integer;
FLoading : boolean;
function GetActiveCount: Integer;
function GetInactiveCount: Integer;
procedure SetCacheConnections(Value: Boolean);
protected
function ActivatePHPModule: TPHPExtension; dynamic;
procedure DeactivatePHPModule(DataModule: TPHPExtension); dynamic;
procedure DoHandleException(E: Exception); dynamic;
procedure OnExceptionHandler(Sender: TObject; E: Exception);
{$IFDEF PHP510}
procedure HandleRequest(ht : integer; return_value : pzval; return_value_ptr : ppzval; this_ptr : pzval;
return_value_used : integer; TSRMLS_DC : pointer);
{$ELSE}
procedure HandleRequest(ht : integer; return_value : pzval; this_ptr : pzval;
return_value_used : integer; TSRMLS_DC : pointer);
{$ENDIF}
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Initialize; virtual;
procedure Run; virtual;
procedure CreateForm(InstanceClass: TComponentClass; var Reference);
function GetPHPClass(const AClassName : string) : pzend_class_entry;
function FindPHPClass(const AClassName : string) : pzend_class_entry;
procedure RegisterPHPClass(const AClassName : string; AClassEntry : pzend_class_entry);
procedure UnregisterPHPClasses;
property Title: string read FTitle write FTitle;
property ActiveCount: Integer read GetActiveCount;
property CacheConnections: Boolean read FCacheConnections write SetCacheConnections;
property InactiveCount: Integer read GetInactiveCount;
property MaxConnections: Integer read FMaxConnections write FMaxConnections;
property ModuleNumber : integer read FModuleNumber write FModuleNumber;
property Loading : boolean read FLoading;
end;
function get_module : Pzend_module_entry; cdecl;
var
Application : TPHPApplication = nil;
ModuleEntry : Tzend_module_entry;
module_entry_table : array of zend_function_entry;
app_globals_id : integer;
implementation
resourcestring
SResNotFound = 'Resource %s not found';
procedure php_info_module(zend_module : Pzend_module_entry; TSRMLS_DC : pointer); cdecl;
var
Extension : TPHPExtension;
begin
if Assigned(Application) then
begin
Extension := Application.ActivatePHPModule;
try
if Assigned(Extension.OnModuleInfo) then
begin
Extension.OnModuleInfo(Application, TSRMLS_DC);
end
else
begin
php_info_print_table_start();
php_info_print_table_row(2, PChar(Extension.ModuleName + ' support'), PChar('enabled'));
php_info_print_table_end();
end;
finally
Application.DeactivatePHPModule(Extension);
end;
end;
end;
{Module initialization}
function minit (_type : integer; module_number : integer; TSRMLS_DC : pointer) : integer; cdecl;
var
Extension : TPHPExtension;
begin
if app_globals_id = 0 then
ts_allocate_id(@app_globals_id, sizeof(pointer), nil, nil);
if Assigned(Application) then
begin
Application.ModuleNumber := module_number;
Extension := Application.ActivatePHPModule;
try
if Assigned(Extension.OnModuleInit) then
Extension.OnModuleInit(Application, TSRMLS_DC);
finally
Application.DeactivatePHPModule(Extension);
end;
end;
result := SUCCESS;
end;
{Module shutdown}
function mshutdown (_type : integer; module_number : integer; TSRMLS_DC : pointer) : integer; cdecl;
var
Extension : TPHPExtension;
begin
ts_free_id(app_globals_id);
if Assigned(Application) then
begin
Extension := Application.ActivatePHPModule;
try
if Assigned(Extension.OnModuleShutdown) then
Extension.OnModuleShutdown(Application, TSRMLS_DC);
finally
Application.DeactivatePHPModule(Extension);
end;
end;
result := SUCCESS;
end;
{Request initialization}
function rinit (_type : integer; module_number : integer; TSRMLS_DC : pointer) : integer; cdecl;
var
Extension : TPHPExtension;
idp : pointer;
begin
if Assigned(Application) then
begin
Extension := Application.ActivatePHPModule;
try
if Assigned(Extension.OnRequestInit) then
Extension.OnRequestInit(Application, TSRMLS_DC);
idp := ts_resource_ex(app_globals_id, nil);
integer(idp^) := integer(Extension);
finally
end;
Result := SUCCESS;
end
else
Result := FAILURE;
end;
{Request shutdown}
function rshutdown (_type : integer; module_number : integer; TSRMLS_DC : pointer) : integer; cdecl;
var
Extension : TPHPExtension;
idp : pointer;
id : integer;
begin
Result := SUCCESS;
idp := ts_resource_ex(app_globals_id, nil);
id := integer(idp^);
if Assigned(Application) then
begin
Extension := pointer(id);
try
if Assigned(Extension.OnRequestShutdown) then
Extension.OnRequestShutdown(Application, TSRMLS_DC);
finally
Application.DeactivatePHPModule(Extension);
end;
end;
end;
{$IFDEF PHP510}
procedure DispatchRequest(ht : integer; return_value : pzval; return_value_ptr : ppzval;
this_ptr : pzval; return_value_used : integer; TSRMLS_DC : pointer); cdecl;
begin
ZVAL_NULL(return_value);
if Assigned(Application) then
try
Application.HandleRequest(ht, return_value, return_value_ptr, this_ptr, return_value_used, TSRMLS_DC);
except
end;
end;
{$ELSE}
procedure DispatchRequest(ht : integer; return_value : pzval; this_ptr : pzval;
return_value_used : integer; TSRMLS_DC : pointer); cdecl;
begin
ZVAL_NULL(return_value);
if Assigned(Application) then
try
Application.HandleRequest(ht, return_value, this_ptr, return_value_used, TSRMLS_DC);
except
end;
end;
{$ENDIF}
function get_module : Pzend_module_entry; cdecl;
var
cnt : integer;
Extension : TPHPExtension;
begin
if ModuleEntry.module_started = 1 then
begin
Result := @ModuleEntry;
Exit;
end;
try
if Assigned(Application) then
begin
Application.FLoading := true;
Extension := TPHPExtension(Application.ActivatePHPModule);
ModuleEntry.size := sizeof(Tzend_module_entry);
ModuleEntry.zend_api := ZEND_MODULE_API_NO;
ModuleEntry.zts := USING_ZTS;
{$IFDEF PHP510}
ModuleEntry.Name := estrndup(PChar(Extension.ModuleName), length(extension.ModuleName));
ModuleEntry.version := estrndup(PChar(Extension.Version), length(Extension.Version));
{$ELSE}
ModuleEntry.Name := StrNew(PChar(Extension.ModuleName));
ModuleEntry.version := StrNew(PChar(Extension.Version));
{$ENDIF}
ModuleEntry.module_startup_func := @minit;
ModuleEntry.module_shutdown_func := @mshutdown;
ModuleEntry.request_startup_func := @rinit;
ModuleEntry.request_shutdown_func := @rshutdown;
ModuleEntry.info_func := @php_info_module;
SetLength(module_entry_table, Extension.FFunctions.Count + 1);
for cnt := 0 to Extension.FFunctions.Count - 1 do
begin
{$IFDEF PHP510}
module_entry_table[cnt].fname := estrndup(PChar(Extension.FFunctions[cnt].FunctionName), length(Extension.FFunctions[cnt].FunctionName));
{$ELSE}
module_entry_table[cnt].fname := StrNew(PChar(Extension.FFunctions[cnt].FunctionName));
{$ENDIF}
module_entry_table[cnt].handler := @DispatchRequest;
{$IFDEF PHP4}
module_entry_table[cnt].func_arg_types := nil;
{$ENDIF}
end;
module_entry_table[Extension.FFunctions.Count].fname := nil;
module_entry_table[Extension.FFunctions.Count].handler := nil;
{$IFDEF PHP4}
module_entry_table[Extension.FFunctions.Count].func_arg_types := nil;
{$ENDIF}
ModuleEntry.functions := @module_entry_table[0];
ModuleEntry._type := ORD(Extension.ModuleType) + 1;
Application.DeactivatePHPModule(Extension);
Application.FLoading := false;
Result := @ModuleEntry;
end
else
Result := nil;
except
Result := nil;
end;
end;
{ TCustomPHPExtension }
constructor TCustomPHPExtension.Create(AOwner: TComponent);
begin
inherited CreateNew(AOwner);
FFunctions := TPHPFunctions.Create(Self, TPHPFunction);
FModuleType := mtPersistent;
FVersion := '0.0';
end;
destructor TCustomPHPExtension.Destroy;
begin
if Assigned(OnDestroy) then
try
OnDestroy(Self);
except
end;
FFunctions.Free;
inherited;
end;
function TCustomPHPExtension.FunctionByName(
const AName: string): TPHPFunction;
var
cnt : integer;
begin
Result := nil;
for cnt := 0 to FFunctions.Count - 1 do
begin
if SameText(AName, FFunctions[cnt].FunctionName) then
break;
end;
end;
procedure TCustomPHPExtension.phpwrite(str: PChar; str_len: integer);
begin
php_body_write(str, str_len, FTSRMLS);
end;
procedure TCustomPHPExtension.phpwrite_h(str: PChar; str_len: integer);
begin
php_header_write(str, str_len, FTSRMLS);
end;
procedure TCustomPHPExtension.puts(str: PChar);
begin
php_body_write(str, strlen(str), FTSRMLS);
end;
procedure TCustomPHPExtension.puts_h(str: PChar);
begin
php_header_write(str, strlen(str), FTSRMLS);
end;
procedure TCustomPHPExtension.ReportError(ErrType: integer;
ErrText: PChar);
begin
zend_error(ErrType, ErrText);
end;
procedure TCustomPHPExtension.SetFunctions(const Value: TPHPFunctions);
begin
FFunctions.Assign(Value);
end;
{ TPHPExtension }
constructor TPHPExtension.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
if (ClassType <> TCustomPHPExtension) and not (csDesigning in ComponentState) then
begin
if not InitInheritedComponent(Self, TCustomPHPExtension) then
raise EResNotFound.CreateFmt(SResNotFound, [ClassName]);
try
if Assigned(OnCreate) and OldCreateOrder then OnCreate(Self);
except
Forms.Application.HandleException(Self);
end;
end;
end;
{ TPHPApplication }
procedure DoneVCLApplication;
begin
try
Forms.Application.OnException := nil;
if Forms.Application.Handle <> 0 then ShowOwnedPopups(Forms.Application.Handle, False);
Forms.Application.ShowHint := False;
Forms.Application.Destroying;
Forms.Application.DestroyComponents;
except
end;
end;
procedure DLLExitProc(Reason: Integer); register;
begin
if Reason = DLL_PROCESS_DETACH then DoneVCLApplication;
end;
constructor TPHPApplication.Create(AOwner: TComponent);
begin
inherited;
FLoading := false;
FClassList := TThreadList.Create;
FCriticalSection := TCriticalSection.Create;
FActivePHPModules := TList.Create;
FInactivePHPModules := TList.Create;
FMaxConnections := 32;
FCacheConnections := true;
IsMultiThread := True;
DLLProc := @DLLExitProc;
end;
destructor TPHPApplication.Destroy;
begin
try
FCriticalSection.Free;
FActivePHPModules.Free;
FInactivePHPModules.Free;
UnregisterPHPClasses;
FClassList.Free;
except
on E : Exception do
OutputDebugString(PChar(E.Message));
end;
inherited Destroy;
end;
procedure TPHPApplication.CreateForm(InstanceClass: TComponentClass;
var Reference);
begin
if FPHPExtensionClass = nil then
FPHPExtensionClass := InstanceClass
else
raise Exception.Create('Only one PHP extension allowed');
end;
function TPHPApplication.ActivatePHPModule: TPHPExtension;
begin
FCriticalSection.Enter;
try
Result := nil;
if (FMaxConnections > 0) and (FActivePHPModules.Count >= FMaxConnections) then
raise Exception.Create('Too many active connections');
if FInactivePHPModules.Count > 0 then
begin
Result := FInactivePHPModules[0];
FInactivePHPModules.Delete(0);
FActivePHPModules.Add(Result);
end else if FPHPExtensionClass <> nil then
begin
TComponent(Result) := FPHPExtensionClass.Create(Self);
FActivePHPModules.Add(Result);
if Assigned(Result.FOnActivation) then
Result.FOnActivation(Self);
end else raise Exception.Create('No PHP extensions registered');
finally
FCriticalSection.Leave;
end;
end;
procedure TPHPApplication.DeactivatePHPModule(DataModule: TPHPExtension);
begin
FCriticalSection.Enter;
try
if FActivePHPModules.IndexOf(DataModule) > -1 then
begin
if Assigned(DataModule.FOnDeactivation) then
DataModule.FOnDeactivation(Self);
FActivePHPModules.Remove(DataModule);
if FCacheConnections then
FInactivePHPModules.Add(DataModule)
else DataModule.Free;
end;
finally
FCriticalSection.Leave;
end;
end;
procedure TPHPApplication.DoHandleException(E: Exception);
begin
end;
function TPHPApplication.GetActiveCount: Integer;
begin
FCriticalSection.Enter;
try
Result := FActivePHPModules.Count;
finally
FCriticalSection.Leave;
end;
end;
function TPHPApplication.GetInactiveCount: Integer;
begin
FCriticalSection.Enter;
try
Result := FInactivePHPModules.Count;
finally
FCriticalSection.Leave;
end;
end;
procedure TPHPApplication.Initialize;
begin
// This is a place holder
if InitProc <> nil then TProcedure(InitProc);
end;
procedure TPHPApplication.OnExceptionHandler(Sender: TObject;
E: Exception);
begin
DoHandleException(E);
end;
procedure TPHPApplication.Run;
begin
Forms.Application.OnException := OnExceptionHandler;
end;
procedure TPHPApplication.SetCacheConnections(Value: Boolean);
var
I: Integer;
begin
if Value <> FCacheConnections then
begin
FCacheConnections := Value;
if not Value then
begin
FCriticalSection.Enter;
try
for I := 0 to FInactivePHPModules.Count - 1 do
TPHPExtension(FInactivePHPModules[I]).Free;
FInactivePHPModules.Clear;
finally
FCriticalSection.Leave;
end;
end;
end;
end;
{$IFDEF PHP510}
procedure TPHPApplication.HandleRequest(ht: integer; return_value : pzval; return_value_ptr : ppzval;
this_ptr: pzval; return_value_used: integer; TSRMLS_DC: pointer);
{$ELSE}
procedure TPHPApplication.HandleRequest(ht: integer; return_value : pzval;
this_ptr: pzval; return_value_used: integer; TSRMLS_DC: pointer);
{$ENDIF}
var
DataModule: TPHPExtension;
cnt : integer;
Params : pppointer;
AFunction : TPHPFunction;
i : integer;
pval : pzval;
idp : pointer;
id : integer;
begin
pval := nil;
idp := ts_resource_ex(integer(app_globals_id), nil);
id := integer(idp^);
if id <= 0 then
Exit;
Params := emalloc(ht * sizeOf(ppzval));
try
if ht > 0 then
begin
if ( not (_zend_get_parameters_array_ex(ht, Params, TSRMLS_DC) = SUCCESS )) then
begin
zend_wrong_param_count(TSRMLS_DC);
Exit;
end;
pval := pzval(params^^);
end;
DataModule := TPHPExtension(id);
if DataModule <> nil then
try
DataModule.FTSRMLS := TSRMLS_DC;
FActiveFunctionName := get_active_function_name(TSRMLS_DC);
for cnt := 0 to DataModule.FFunctions.Count - 1 do
begin
if SameText(DataModule.FFunctions[cnt].FunctionName, FActiveFunctionName) then
begin
AFunction := DataModule.FFunctions[cnt];
if Assigned(AFunction.OnExecute) then
begin
if AFunction.Parameters.Count <> ht then
begin
zend_wrong_param_count(TSRMLS_DC);
Exit;
end;
if ht > 0 then begin
for i := 0 to ht - 1 do
begin
if not IsParamTypeCorrect(AFunction.Parameters[i].ParamType, pval) then
begin
zend_error(E_WARNING, PChar(Format('Wrong parameter type for %s()', [get_active_function_name(TSRMLS_DC)])));
Exit;
end;
AFunction.Parameters[i].ZendValue := pval;
inc(integer(params^), sizeof(ppzval));
pval := pzval(params^^);
end;
end;
AFunction.ZendVar.AsZendVariable := return_value;
AFunction.OnExecute(DataModule, AFunction.Parameters, AFunction.ReturnValue, this_ptr, TSRMLS_DC);
if AFunction.ZendVar.ISNull then
variant2zval(AFunction.ReturnValue, return_value);
end;
break;
end;
end;
finally
efree(Params);
end;
except
end;
end;
function TPHPApplication.GetPHPClass(
const AClassName: string): pzend_class_entry;
var
I: Integer;
begin
with FClassList.LockList do
try
for I := 0 to Count - 1 do
begin
if SameText(TClassRegister(Items[I]).CN, AClassName) then
begin
Result := pzend_class_entry(TClassRegister(Items[I]).CH);
Exit;
end;
end;
Result := nil;
finally
FClassList.UnlockList;
end;
end;
procedure ClassNotFound(const ClassName: string);
begin
raise EClassNotFound.CreateFmt(SClassNotFound, [ClassName]);
end;
function TPHPApplication.FindPHPClass(
const AClassName: string): pzend_class_entry;
begin
Result := GetPHPClass(AClassName);
if Result = nil then ClassNotFound(AClassName);
end;
procedure TPHPApplication.RegisterPHPClass(const AClassName: string;
AClassEntry: pzend_class_entry);
var
ClassRegister : TClassRegister;
begin
With FClassList.LockList do
try
if GetPHPClass(AClassName) <> nil then
raise EFilerError.CreateResFmt(@SDuplicateClass, [AClassName]);
ClassRegister := TClassRegister.Create;
ClassRegister.CN := LowerCase(AClassName);
ClassRegister.CH := integer(AClassEntry);
Add(ClassRegister);
finally
FClassList.UnlockList;
end;
end;
procedure TPHPApplication.UnregisterPHPClasses;
var
i : integer;
begin
with FClassList.LockList do
try
for I := 0 to Count - 1 do
TClassRegister(Items[i]).Free;
FClassList.Clear;
finally
FClassList.UnlockList;
end;
end;
exports
get_module;
end.