FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
php-src/main/main.c at master · EndlessCoding/php-src · GitHub
EndlessCoding
/
php-src
Public
forked from
php/php-src
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
php-src
/
main
/
main.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
2643 lines (2306 loc) · 76 KB
Breadcrumbs
php-src
/
main
/
main.c
Copy path
File metadata and controls
2643 lines (2306 loc) · 76 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2013 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@zend.com> |
| Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
| Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
/* {{{ includes
*/
#define
ZEND_INCLUDE_FULL_WINDOWS_HEADERS
#include
"php.h"
#include
<stdio.h>
#include
<fcntl.h>
#ifdef
PHP_WIN32
#include
"win32/time.h"
#include
"win32/signal.h"
#include
"win32/php_win32_globals.h"
#include
"win32/winutil.h"
#include
<process.h>
#elif
defined(
NETWARE
)
#include
<sys/timeval.h>
#ifdef
USE_WINSOCK
#include
<novsock2.h>
#endif
#endif
#if
HAVE_SYS_TIME_H
#include
<sys/time.h>
#endif
#if
HAVE_UNISTD_H
#include
<unistd.h>
#endif
#if
HAVE_SIGNAL_H
#include
<signal.h>
#endif
#if
HAVE_SETLOCALE
#include
<locale.h>
#endif
#include
"zend.h"
#include
"zend_extensions.h"
#include
"php_ini.h"
#include
"php_globals.h"
#include
"php_main.h"
#include
"fopen_wrappers.h"
#include
"ext/standard/php_standard.h"
#include
"ext/standard/php_string.h"
#include
"ext/date/php_date.h"
#include
"php_variables.h"
#include
"ext/standard/credits.h"
#ifdef
PHP_WIN32
#include
<io.h>
#include
"win32/php_registry.h"
#include
"ext/standard/flock_compat.h"
#endif
#include
"php_syslog.h"
#include
"Zend/zend_exceptions.h"
#if
PHP_SIGCHILD
#include
<sys/types.h>
#include
<sys/wait.h>
#endif
#include
"zend_compile.h"
#include
"zend_execute.h"
#include
"zend_highlight.h"
#include
"zend_indent.h"
#include
"zend_extensions.h"
#include
"zend_ini.h"
#include
"zend_dtrace.h"
#include
"php_content_types.h"
#include
"php_ticks.h"
#include
"php_streams.h"
#include
"php_open_temporary_file.h"
#include
"SAPI.h"
#include
"rfc1867.h"
#if
HAVE_MMAP
||
defined(
PHP_WIN32
)
# if
HAVE_UNISTD_H
# include
<unistd.h>
# if
defined(
_SC_PAGESIZE
)
# define
REAL_PAGE_SIZE
sysconf(_SC_PAGESIZE);
# elif
defined(
_SC_PAGE_SIZE
)
# define
REAL_PAGE_SIZE
sysconf(_SC_PAGE_SIZE);
# endif
# endif
# if
HAVE_SYS_MMAN_H
# include
<sys/mman.h>
# endif
# ifndef
REAL_PAGE_SIZE
# ifdef
PAGE_SIZE
# define
REAL_PAGE_SIZE
PAGE_SIZE
# else
# define
REAL_PAGE_SIZE
4096
# endif
# endif
#endif
/* }}} */
#ifndef
S_ISREG
#define
S_ISREG
(
mode
) (((mode) & S_IFMT) == S_IFREG)
#endif
PHPAPI
int
(
*
php_register_internal_extensions_func
)(
TSRMLS_D
)
=
php_register_internal_extensions
;
#ifndef
ZTS
php_core_globals
core_globals
;
#else
PHPAPI
int
core_globals_id
;
#endif
#ifdef
PHP_WIN32
#include
"win32_internal_function_disabled.h"
static
php_win32_disable_functions
(
TSRMLS_D
)
{
int
i
;
if
(
EG
(
windows_version_info
).
dwMajorVersion
<
5
) {
for
(
i
=
0
;
i
<
function_name_cnt_5
;
i
++
) {
if
(
zend_hash_del
(
CG
(
function_table
),
function_name_5
[
i
],
strlen
(
function_name_5
[
i
])
+
1
)
==
FAILURE
) {
php_printf
(
"Unable to disable function '%s'\n"
,
function_name_5
[
i
]);
return
FAILURE
;
}
}
}
if
(
EG
(
windows_version_info
).
dwMajorVersion
<
6
) {
for
(
i
=
0
;
i
<
function_name_cnt_6
;
i
++
) {
if
(
zend_hash_del
(
CG
(
function_table
),
function_name_6
[
i
],
strlen
(
function_name_6
[
i
])
+
1
)
==
FAILURE
) {
php_printf
(
"Unable to disable function '%s'\n"
,
function_name_6
[
i
]);
return
FAILURE
;
}
}
}
return
SUCCESS
;
}
#endif
#define
SAFE_FILENAME
(
f
) ((f)?(f):"-")
/* {{{ PHP_INI_MH
*/
static
PHP_INI_MH
(
OnSetPrecision
)
{
int
i
=
atoi
(
new_value
);
if
(
i
>=
0
) {
EG
(
precision
)
=
i
;
return
SUCCESS
;
}
else
{
return
FAILURE
;
}
}
/* }}} */
/* {{{ PHP_INI_MH
*/
static
PHP_INI_MH
(
OnChangeMemoryLimit
)
{
if
(
new_value
) {
PG
(
memory_limit
)
=
zend_atol
(
new_value
,
new_value_length
);
}
else
{
PG
(
memory_limit
)
=
1
<<
30
;
/* effectively, no limit */
}
return
zend_set_memory_limit
(
PG
(
memory_limit
));
}
/* }}} */
/* {{{ php_disable_functions
*/
static
void
php_disable_functions
(
TSRMLS_D
)
{
char
*
s
=
NULL
,
*
e
;
if
(!
*
(
INI_STR
(
"disable_functions"
))) {
return
;
}
e
=
PG
(
disable_functions
)
=
strdup
(
INI_STR
(
"disable_functions"
));
if
(
e
==
NULL
) {
return
;
}
while
(
*
e
) {
switch
(
*
e
) {
case
' '
:
case
','
:
if
(
s
) {
*
e
=
'\0'
;
zend_disable_function
(
s
,
e
-
s
TSRMLS_CC
);
s
=
NULL
;
}
break
;
default
:
if
(!
s
) {
s
=
e
;
}
break
;
}
e
++
;
}
if
(
s
) {
zend_disable_function
(
s
,
e
-
s
TSRMLS_CC
);
}
}
/* }}} */
/* {{{ php_disable_classes
*/
static
void
php_disable_classes
(
TSRMLS_D
)
{
char
*
s
=
NULL
,
*
e
;
if
(!
*
(
INI_STR
(
"disable_classes"
))) {
return
;
}
e
=
PG
(
disable_classes
)
=
strdup
(
INI_STR
(
"disable_classes"
));
while
(
*
e
) {
switch
(
*
e
) {
case
' '
:
case
','
:
if
(
s
) {
*
e
=
'\0'
;
zend_disable_class
(
s
,
e
-
s
TSRMLS_CC
);
s
=
NULL
;
}
break
;
default
:
if
(!
s
) {
s
=
e
;
}
break
;
}
e
++
;
}
if
(
s
) {
zend_disable_class
(
s
,
e
-
s
TSRMLS_CC
);
}
}
/* }}} */
/* {{{ php_binary_init
*/
static
void
php_binary_init
(
TSRMLS_D
)
{
char
*
binary_location
;
#ifdef
PHP_WIN32
binary_location
=
(
char
*
)
malloc
(
MAXPATHLEN
);
if
(
GetModuleFileName
(
0
,
binary_location
,
MAXPATHLEN
)
==
0
) {
free
(
binary_location
);
PG
(
php_binary
)
=
NULL
;
}
#else
if
(
sapi_module
.
executable_location
) {
binary_location
=
(
char
*
)
malloc
(
MAXPATHLEN
);
if
(!
strchr
(
sapi_module
.
executable_location
,
'/'
)) {
char
*
envpath
,
*
path
;
int
found
=
0
;
if
((
envpath
=
getenv
(
"PATH"
))
!=
NULL
) {
char
*
search_dir
,
search_path
[
MAXPATHLEN
];
char
*
last
=
NULL
;
struct
stat
s
;
path
=
estrdup
(
envpath
);
search_dir
=
php_strtok_r
(
path
,
":"
,
&
last
);
while
(
search_dir
) {
snprintf
(
search_path
,
MAXPATHLEN
,
"%s/%s"
,
search_dir
,
sapi_module
.
executable_location
);
if
(
VCWD_REALPATH
(
search_path
,
binary_location
)
&&
!
VCWD_ACCESS
(
binary_location
,
X_OK
)
&&
VCWD_STAT
(
binary_location
,
&
s
)
==
0
&&
S_ISREG
(
s
.
st_mode
)) {
found
=
1
;
break
;
}
search_dir
=
php_strtok_r
(
NULL
,
":"
,
&
last
);
}
efree
(
path
);
}
if
(!
found
) {
free
(
binary_location
);
binary_location
=
NULL
;
}
}
else
if
(!
VCWD_REALPATH
(
sapi_module
.
executable_location
,
binary_location
)
||
VCWD_ACCESS
(
binary_location
,
X_OK
)) {
free
(
binary_location
);
binary_location
=
NULL
;
}
}
else
{
binary_location
=
NULL
;
}
#endif
PG
(
php_binary
)
=
binary_location
;
}
/* }}} */
/* {{{ PHP_INI_MH
*/
static
PHP_INI_MH
(
OnUpdateTimeout
)
{
if
(
stage
==
PHP_INI_STAGE_STARTUP
) {
/* Don't set a timeout on startup, only per-request */
EG
(
timeout_seconds
)
=
atoi
(
new_value
);
return
SUCCESS
;
}
zend_unset_timeout
(
TSRMLS_C
);
EG
(
timeout_seconds
)
=
atoi
(
new_value
);
zend_set_timeout
(
EG
(
timeout_seconds
),
0
);
return
SUCCESS
;
}
/* }}} */
/* {{{ php_get_display_errors_mode() helper function
*/
static
int
php_get_display_errors_mode
(
char
*
value
,
int
value_length
)
{
int
mode
;
if
(!
value
) {
return
PHP_DISPLAY_ERRORS_STDOUT
;
}
if
(
value_length
==
2
&&
!
strcasecmp
(
"on"
,
value
)) {
mode
=
PHP_DISPLAY_ERRORS_STDOUT
;
}
else
if
(
value_length
==
3
&&
!
strcasecmp
(
"yes"
,
value
)) {
mode
=
PHP_DISPLAY_ERRORS_STDOUT
;
}
else
if
(
value_length
==
4
&&
!
strcasecmp
(
"true"
,
value
)) {
mode
=
PHP_DISPLAY_ERRORS_STDOUT
;
}
else
if
(
value_length
==
6
&&
!
strcasecmp
(
value
,
"stderr"
)) {
mode
=
PHP_DISPLAY_ERRORS_STDERR
;
}
else
if
(
value_length
==
6
&&
!
strcasecmp
(
value
,
"stdout"
)) {
mode
=
PHP_DISPLAY_ERRORS_STDOUT
;
}
else
{
mode
=
atoi
(
value
);
if
(
mode
&&
mode
!=
PHP_DISPLAY_ERRORS_STDOUT
&&
mode
!=
PHP_DISPLAY_ERRORS_STDERR
) {
mode
=
PHP_DISPLAY_ERRORS_STDOUT
;
}
}
return
mode
;
}
/* }}} */
/* {{{ PHP_INI_MH
*/
static
PHP_INI_MH
(
OnUpdateDisplayErrors
)
{
PG
(
display_errors
)
=
(
zend_bool
)
php_get_display_errors_mode
(
new_value
,
new_value_length
);
return
SUCCESS
;
}
/* }}} */
/* {{{ PHP_INI_DISP
*/
static
PHP_INI_DISP
(
display_errors_mode
)
{
int
mode
,
tmp_value_length
,
cgi_or_cli
;
char
*
tmp_value
;
TSRMLS_FETCH
();
if
(
type
==
ZEND_INI_DISPLAY_ORIG
&&
ini_entry
->
modified
) {
tmp_value
=
(
ini_entry
->
orig_value
?
ini_entry
->
orig_value
:
NULL
);
tmp_value_length
=
ini_entry
->
orig_value_length
;
}
else
if
(
ini_entry
->
value
) {
tmp_value
=
ini_entry
->
value
;
tmp_value_length
=
ini_entry
->
value_length
;
}
else
{
tmp_value
=
NULL
;
tmp_value_length
=
0
;
}
mode
=
php_get_display_errors_mode
(
tmp_value
,
tmp_value_length
);
/* Display 'On' for other SAPIs instead of STDOUT or STDERR */
cgi_or_cli
=
(!
strcmp
(
sapi_module
.
name
,
"cli"
)
||
!
strcmp
(
sapi_module
.
name
,
"cgi"
));
switch
(
mode
) {
case
PHP_DISPLAY_ERRORS_STDERR
:
if
(
cgi_or_cli
) {
PUTS
(
"STDERR"
);
}
else
{
PUTS
(
"On"
);
}
break
;
case
PHP_DISPLAY_ERRORS_STDOUT
:
if
(
cgi_or_cli
) {
PUTS
(
"STDOUT"
);
}
else
{
PUTS
(
"On"
);
}
break
;
default
:
PUTS
(
"Off"
);
break
;
}
}
/* }}} */
/* {{{ PHP_INI_MH
*/
static
PHP_INI_MH
(
OnUpdateErrorLog
)
{
/* Only do the safemode/open_basedir check at runtime */
if
((
stage
==
PHP_INI_STAGE_RUNTIME
||
stage
==
PHP_INI_STAGE_HTACCESS
)
&&
new_value
&&
strcmp
(
new_value
,
"syslog"
)) {
if
(
PG
(
open_basedir
)
&&
php_check_open_basedir
(
new_value
TSRMLS_CC
)) {
return
FAILURE
;
}
}
OnUpdateString
(
entry
,
new_value
,
new_value_length
,
mh_arg1
,
mh_arg2
,
mh_arg3
,
stage
TSRMLS_CC
);
return
SUCCESS
;
}
/* }}} */
/* {{{ PHP_INI_MH
*/
static
PHP_INI_MH
(
OnUpdateMailLog
)
{
/* Only do the safemode/open_basedir check at runtime */
if
((
stage
==
PHP_INI_STAGE_RUNTIME
||
stage
==
PHP_INI_STAGE_HTACCESS
)
&&
new_value
) {
if
(
PG
(
open_basedir
)
&&
php_check_open_basedir
(
new_value
TSRMLS_CC
)) {
return
FAILURE
;
}
}
OnUpdateString
(
entry
,
new_value
,
new_value_length
,
mh_arg1
,
mh_arg2
,
mh_arg3
,
stage
TSRMLS_CC
);
return
SUCCESS
;
}
/* }}} */
/* {{{ PHP_INI_MH
*/
static
PHP_INI_MH
(
OnChangeMailForceExtra
)
{
/* Don't allow changing it in htaccess */
if
(
stage
==
PHP_INI_STAGE_HTACCESS
) {
return
FAILURE
;
}
return
SUCCESS
;
}
/* }}} */
/* defined in browscap.c */
PHP_INI_MH
(
OnChangeBrowscap
);
/* Need to be read from the environment (?):
* PHP_AUTO_PREPEND_FILE
* PHP_AUTO_APPEND_FILE
* PHP_DOCUMENT_ROOT
* PHP_USER_DIR
* PHP_INCLUDE_PATH
*/
/* Windows and Netware use the internal mail */
#if
defined(
PHP_WIN32
)
||
defined(
NETWARE
)
# define
DEFAULT_SENDMAIL_PATH
NULL
#elif
defined(
PHP_PROG_SENDMAIL
)
# define
DEFAULT_SENDMAIL_PATH
PHP_PROG_SENDMAIL " -t -i "
#else
# define
DEFAULT_SENDMAIL_PATH
"/usr/sbin/sendmail -t -i"
#endif
/* {{{ PHP_INI
*/
PHP_INI_BEGIN
()
PHP_INI_ENTRY_EX
(
"highlight.comment"
,
HL_COMMENT_COLOR
,
PHP_INI_ALL
,
NULL
,
php_ini_color_displayer_cb
)
PHP_INI_ENTRY_EX
(
"highlight.default"
,
HL_DEFAULT_COLOR
,
PHP_INI_ALL
,
NULL
,
php_ini_color_displayer_cb
)
PHP_INI_ENTRY_EX
(
"highlight.html"
,
HL_HTML_COLOR
,
PHP_INI_ALL
,
NULL
,
php_ini_color_displayer_cb
)
PHP_INI_ENTRY_EX
(
"highlight.keyword"
,
HL_KEYWORD_COLOR
,
PHP_INI_ALL
,
NULL
,
php_ini_color_displayer_cb
)
PHP_INI_ENTRY_EX
(
"highlight.string"
,
HL_STRING_COLOR
,
PHP_INI_ALL
,
NULL
,
php_ini_color_displayer_cb
)
STD_PHP_INI_BOOLEAN
(
"asp_tags"
,
"0"
,
PHP_INI_SYSTEM
|
PHP_INI_PERDIR
,
OnUpdateBool
,
asp_tags
,
zend_compiler_globals
,
compiler_globals
)
STD_PHP_INI_ENTRY_EX
(
"display_errors"
,
"1"
,
PHP_INI_ALL
,
OnUpdateDisplayErrors
,
display_errors
,
php_core_globals
,
core_globals
,
display_errors_mode
)
STD_PHP_INI_BOOLEAN
(
"display_startup_errors"
,
"0"
,
PHP_INI_ALL
,
OnUpdateBool
,
display_startup_errors
,
php_core_globals
,
core_globals
)
STD_PHP_INI_BOOLEAN
(
"enable_dl"
,
"1"
,
PHP_INI_SYSTEM
,
OnUpdateBool
,
enable_dl
,
php_core_globals
,
core_globals
)
STD_PHP_INI_BOOLEAN
(
"expose_php"
,
"1"
,
PHP_INI_SYSTEM
,
OnUpdateBool
,
expose_php
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"docref_root"
,
""
,
PHP_INI_ALL
,
OnUpdateString
,
docref_root
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"docref_ext"
,
""
,
PHP_INI_ALL
,
OnUpdateString
,
docref_ext
,
php_core_globals
,
core_globals
)
STD_PHP_INI_BOOLEAN
(
"html_errors"
,
"1"
,
PHP_INI_ALL
,
OnUpdateBool
,
html_errors
,
php_core_globals
,
core_globals
)
STD_PHP_INI_BOOLEAN
(
"xmlrpc_errors"
,
"0"
,
PHP_INI_SYSTEM
,
OnUpdateBool
,
xmlrpc_errors
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"xmlrpc_error_number"
,
"0"
,
PHP_INI_ALL
,
OnUpdateLong
,
xmlrpc_error_number
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"max_input_time"
,
"-1"
,
PHP_INI_SYSTEM
|
PHP_INI_PERDIR
,
OnUpdateLong
,
max_input_time
,
php_core_globals
,
core_globals
)
STD_PHP_INI_BOOLEAN
(
"ignore_user_abort"
,
"0"
,
PHP_INI_ALL
,
OnUpdateBool
,
ignore_user_abort
,
php_core_globals
,
core_globals
)
STD_PHP_INI_BOOLEAN
(
"implicit_flush"
,
"0"
,
PHP_INI_ALL
,
OnUpdateBool
,
implicit_flush
,
php_core_globals
,
core_globals
)
STD_PHP_INI_BOOLEAN
(
"log_errors"
,
"0"
,
PHP_INI_ALL
,
OnUpdateBool
,
log_errors
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"log_errors_max_len"
,
"1024"
,
PHP_INI_ALL
,
OnUpdateLong
,
log_errors_max_len
,
php_core_globals
,
core_globals
)
STD_PHP_INI_BOOLEAN
(
"ignore_repeated_errors"
,
"0"
,
PHP_INI_ALL
,
OnUpdateBool
,
ignore_repeated_errors
,
php_core_globals
,
core_globals
)
STD_PHP_INI_BOOLEAN
(
"ignore_repeated_source"
,
"0"
,
PHP_INI_ALL
,
OnUpdateBool
,
ignore_repeated_source
,
php_core_globals
,
core_globals
)
STD_PHP_INI_BOOLEAN
(
"report_memleaks"
,
"1"
,
PHP_INI_ALL
,
OnUpdateBool
,
report_memleaks
,
php_core_globals
,
core_globals
)
STD_PHP_INI_BOOLEAN
(
"report_zend_debug"
,
"1"
,
PHP_INI_ALL
,
OnUpdateBool
,
report_zend_debug
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"output_buffering"
,
"0"
,
PHP_INI_PERDIR
|
PHP_INI_SYSTEM
,
OnUpdateLong
,
output_buffering
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"output_handler"
,
NULL
,
PHP_INI_PERDIR
|
PHP_INI_SYSTEM
,
OnUpdateString
,
output_handler
,
php_core_globals
,
core_globals
)
STD_PHP_INI_BOOLEAN
(
"register_argc_argv"
,
"1"
,
PHP_INI_PERDIR
|
PHP_INI_SYSTEM
,
OnUpdateBool
,
register_argc_argv
,
php_core_globals
,
core_globals
)
STD_PHP_INI_BOOLEAN
(
"auto_globals_jit"
,
"1"
,
PHP_INI_PERDIR
|
PHP_INI_SYSTEM
,
OnUpdateBool
,
auto_globals_jit
,
php_core_globals
,
core_globals
)
STD_PHP_INI_BOOLEAN
(
"short_open_tag"
,
DEFAULT_SHORT_OPEN_TAG
,
PHP_INI_SYSTEM
|
PHP_INI_PERDIR
,
OnUpdateBool
,
short_tags
,
zend_compiler_globals
,
compiler_globals
)
STD_PHP_INI_BOOLEAN
(
"sql.safe_mode"
,
"0"
,
PHP_INI_SYSTEM
,
OnUpdateBool
,
sql_safe_mode
,
php_core_globals
,
core_globals
)
STD_PHP_INI_BOOLEAN
(
"track_errors"
,
"0"
,
PHP_INI_ALL
,
OnUpdateBool
,
track_errors
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"unserialize_callback_func"
,
NULL
,
PHP_INI_ALL
,
OnUpdateString
,
unserialize_callback_func
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"serialize_precision"
,
"17"
,
PHP_INI_ALL
,
OnUpdateLongGEZero
,
serialize_precision
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"arg_separator.output"
,
"&"
,
PHP_INI_ALL
,
OnUpdateStringUnempty
,
arg_separator
.
output
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"arg_separator.input"
,
"&"
,
PHP_INI_SYSTEM
|
PHP_INI_PERDIR
,
OnUpdateStringUnempty
,
arg_separator
.
input
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"auto_append_file"
,
NULL
,
PHP_INI_SYSTEM
|
PHP_INI_PERDIR
,
OnUpdateString
,
auto_append_file
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"auto_prepend_file"
,
NULL
,
PHP_INI_SYSTEM
|
PHP_INI_PERDIR
,
OnUpdateString
,
auto_prepend_file
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"doc_root"
,
NULL
,
PHP_INI_SYSTEM
,
OnUpdateStringUnempty
,
doc_root
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"default_charset"
,
SAPI_DEFAULT_CHARSET
,
PHP_INI_ALL
,
OnUpdateString
,
default_charset
,
sapi_globals_struct
,
sapi_globals
)
STD_PHP_INI_ENTRY
(
"default_mimetype"
,
SAPI_DEFAULT_MIMETYPE
,
PHP_INI_ALL
,
OnUpdateString
,
default_mimetype
,
sapi_globals_struct
,
sapi_globals
)
STD_PHP_INI_ENTRY
(
"error_log"
,
NULL
,
PHP_INI_ALL
,
OnUpdateErrorLog
,
error_log
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"extension_dir"
,
PHP_EXTENSION_DIR
,
PHP_INI_SYSTEM
,
OnUpdateStringUnempty
,
extension_dir
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"sys_temp_dir"
,
NULL
,
PHP_INI_SYSTEM
,
OnUpdateStringUnempty
,
sys_temp_dir
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"include_path"
,
PHP_INCLUDE_PATH
,
PHP_INI_ALL
,
OnUpdateStringUnempty
,
include_path
,
php_core_globals
,
core_globals
)
PHP_INI_ENTRY
(
"max_execution_time"
,
"30"
,
PHP_INI_ALL
,
OnUpdateTimeout
)
STD_PHP_INI_ENTRY
(
"open_basedir"
,
NULL
,
PHP_INI_ALL
,
OnUpdateBaseDir
,
open_basedir
,
php_core_globals
,
core_globals
)
STD_PHP_INI_BOOLEAN
(
"file_uploads"
,
"1"
,
PHP_INI_SYSTEM
,
OnUpdateBool
,
file_uploads
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"upload_max_filesize"
,
"2M"
,
PHP_INI_SYSTEM
|
PHP_INI_PERDIR
,
OnUpdateLong
,
upload_max_filesize
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"post_max_size"
,
"8M"
,
PHP_INI_SYSTEM
|
PHP_INI_PERDIR
,
OnUpdateLong
,
post_max_size
,
sapi_globals_struct
,
sapi_globals
)
STD_PHP_INI_ENTRY
(
"upload_tmp_dir"
,
NULL
,
PHP_INI_SYSTEM
,
OnUpdateStringUnempty
,
upload_tmp_dir
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"max_input_nesting_level"
,
"64"
,
PHP_INI_SYSTEM
|
PHP_INI_PERDIR
,
OnUpdateLongGEZero
,
max_input_nesting_level
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"max_input_vars"
,
"1000"
,
PHP_INI_SYSTEM
|
PHP_INI_PERDIR
,
OnUpdateLongGEZero
,
max_input_vars
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"user_dir"
,
NULL
,
PHP_INI_SYSTEM
,
OnUpdateString
,
user_dir
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"variables_order"
,
"EGPCS"
,
PHP_INI_SYSTEM
|
PHP_INI_PERDIR
,
OnUpdateStringUnempty
,
variables_order
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"request_order"
,
NULL
,
PHP_INI_SYSTEM
|
PHP_INI_PERDIR
,
OnUpdateString
,
request_order
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"error_append_string"
,
NULL
,
PHP_INI_ALL
,
OnUpdateString
,
error_append_string
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"error_prepend_string"
,
NULL
,
PHP_INI_ALL
,
OnUpdateString
,
error_prepend_string
,
php_core_globals
,
core_globals
)
PHP_INI_ENTRY
(
"SMTP"
,
"localhost"
,
PHP_INI_ALL
,
NULL
)
PHP_INI_ENTRY
(
"smtp_port"
,
"25"
,
PHP_INI_ALL
,
NULL
)
STD_PHP_INI_BOOLEAN
(
"mail.add_x_header"
,
"0"
,
PHP_INI_SYSTEM
|
PHP_INI_PERDIR
,
OnUpdateBool
,
mail_x_header
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"mail.log"
,
NULL
,
PHP_INI_SYSTEM
|
PHP_INI_PERDIR
,
OnUpdateMailLog
,
mail_log
,
php_core_globals
,
core_globals
)
PHP_INI_ENTRY
(
"browscap"
,
NULL
,
PHP_INI_SYSTEM
,
OnChangeBrowscap
)
PHP_INI_ENTRY
(
"memory_limit"
,
"128M"
,
PHP_INI_ALL
,
OnChangeMemoryLimit
)
PHP_INI_ENTRY
(
"precision"
,
"14"
,
PHP_INI_ALL
,
OnSetPrecision
)
PHP_INI_ENTRY
(
"sendmail_from"
,
NULL
,
PHP_INI_ALL
,
NULL
)
PHP_INI_ENTRY
(
"sendmail_path"
,
DEFAULT_SENDMAIL_PATH
,
PHP_INI_SYSTEM
,
NULL
)
PHP_INI_ENTRY
(
"mail.force_extra_parameters"
,
NULL
,
PHP_INI_SYSTEM
|
PHP_INI_PERDIR
,
OnChangeMailForceExtra
)
PHP_INI_ENTRY
(
"disable_functions"
,
""
,
PHP_INI_SYSTEM
,
NULL
)
PHP_INI_ENTRY
(
"disable_classes"
,
""
,
PHP_INI_SYSTEM
,
NULL
)
PHP_INI_ENTRY
(
"max_file_uploads"
,
"20"
,
PHP_INI_SYSTEM
|
PHP_INI_PERDIR
,
NULL
)
STD_PHP_INI_BOOLEAN
(
"allow_url_fopen"
,
"1"
,
PHP_INI_SYSTEM
,
OnUpdateBool
,
allow_url_fopen
,
php_core_globals
,
core_globals
)
STD_PHP_INI_BOOLEAN
(
"allow_url_include"
,
"0"
,
PHP_INI_SYSTEM
,
OnUpdateBool
,
allow_url_include
,
php_core_globals
,
core_globals
)
STD_PHP_INI_BOOLEAN
(
"enable_post_data_reading"
,
"1"
,
PHP_INI_SYSTEM
|
PHP_INI_PERDIR
,
OnUpdateBool
,
enable_post_data_reading
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"realpath_cache_size"
,
"16K"
,
PHP_INI_SYSTEM
,
OnUpdateLong
,
realpath_cache_size_limit
,
virtual_cwd_globals
,
cwd_globals
)
STD_PHP_INI_ENTRY
(
"realpath_cache_ttl"
,
"120"
,
PHP_INI_SYSTEM
,
OnUpdateLong
,
realpath_cache_ttl
,
virtual_cwd_globals
,
cwd_globals
)
STD_PHP_INI_ENTRY
(
"user_ini.filename"
,
".user.ini"
,
PHP_INI_SYSTEM
,
OnUpdateString
,
user_ini_filename
,
php_core_globals
,
core_globals
)
STD_PHP_INI_ENTRY
(
"user_ini.cache_ttl"
,
"300"
,
PHP_INI_SYSTEM
,
OnUpdateLong
,
user_ini_cache_ttl
,
php_core_globals
,
core_globals
)
STD_PHP_INI_BOOLEAN
(
"exit_on_timeout"
,
"0"
,
PHP_INI_ALL
,
OnUpdateBool
,
exit_on_timeout
,
php_core_globals
,
core_globals
)
#ifdef
PHP_WIN32
STD_PHP_INI_BOOLEAN
(
"windows.show_crt_warning"
,
"0"
,
PHP_INI_ALL
,
OnUpdateBool
,
windows_show_crt_warning
,
php_core_globals
,
core_globals
)
#endif
PHP_INI_END
()
/* }}} */
/* True globals (no need for thread safety */
/* But don't make them a single int bitfield */
static
int
module_initialized
=
0
;
static
int
module_startup
=
1
;
static
int
module_shutdown
=
0
;
/* {{{ php_during_module_startup */
static
int
php_during_module_startup
(
void
)
{
return
module_startup
;
}
/* }}} */
/* {{{ php_during_module_shutdown */
static
int
php_during_module_shutdown
(
void
)
{
return
module_shutdown
;
}
/* }}} */
/* {{{ php_get_module_initialized
*/
PHPAPI
int
php_get_module_initialized
(
void
)
{
return
module_initialized
;
}
/* }}} */
/* {{{ php_log_err
*/
PHPAPI
void
php_log_err
(
char
*
log_message
TSRMLS_DC
)
{
int
fd
=
-1
;
time_t
error_time
;
if
(
PG
(
in_error_log
)) {
/* prevent recursive invocation */
return
;
}
PG
(
in_error_log
)
=
1
;
/* Try to use the specified logging location. */
if
(
PG
(
error_log
)
!=
NULL
) {
#ifdef
HAVE_SYSLOG_H
if
(!
strcmp
(
PG
(
error_log
),
"syslog"
)) {
php_syslog
(
LOG_NOTICE
,
"%s"
,
log_message
);
PG
(
in_error_log
)
=
0
;
return
;
}
#endif
fd
=
VCWD_OPEN_MODE
(
PG
(
error_log
),
O_CREAT
|
O_APPEND
|
O_WRONLY
,
0644
);
if
(
fd
!=
-1
) {
char
*
tmp
;
int
len
;
char
*
error_time_str
;
time
(
&
error_time
);
#ifdef
ZTS
if
(!
php_during_module_startup
()) {
error_time_str
=
php_format_date
(
"d-M-Y H:i:s e"
,
13
,
error_time
,
1
TSRMLS_CC
);
}
else
{
error_time_str
=
php_format_date
(
"d-M-Y H:i:s e"
,
13
,
error_time
,
0
TSRMLS_CC
);
}
#else
error_time_str
=
php_format_date
(
"d-M-Y H:i:s e"
,
13
,
error_time
,
1
TSRMLS_CC
);
#endif
len
=
spprintf
(
&
tmp
,
0
,
"[%s] %s%s"
,
error_time_str
,
log_message
,
PHP_EOL
);
#ifdef
PHP_WIN32
php_flock
(
fd
,
2
);
#endif
php_ignore_value
(
write
(
fd
,
tmp
,
len
));
efree
(
tmp
);
efree
(
error_time_str
);
close
(
fd
);
PG
(
in_error_log
)
=
0
;
return
;
}
}
/* Otherwise fall back to the default logging location, if we have one */
if
(
sapi_module
.
log_message
) {
sapi_module
.
log_message
(
log_message
TSRMLS_CC
);
}
PG
(
in_error_log
)
=
0
;
}
/* }}} */
/* {{{ php_write
wrapper for modules to use PHPWRITE */
PHPAPI
int
php_write
(
void
*
buf
,
uint
size
TSRMLS_DC
)
{
return
PHPWRITE
(
buf
,
size
);
}
/* }}} */
/* {{{ php_printf
*/
PHPAPI
int
php_printf
(
const
char
*
format
, ...)
{
va_list
args
;
int
ret
;
char
*
buffer
;
int
size
;
TSRMLS_FETCH
();
va_start
(
args
,
format
);
size
=
vspprintf
(
&
buffer
,
0
,
format
,
args
);
ret
=
PHPWRITE
(
buffer
,
size
);
efree
(
buffer
);
va_end
(
args
);
return
ret
;
}
/* }}} */
/* {{{ php_verror */
/* php_verror is called from php_error_docref<n> functions.
* Its purpose is to unify error messages and automatically generate clickable
* html error messages if correcponding ini setting (html_errors) is activated.
* See: CODING_STANDARDS for details.
*/
PHPAPI
void
php_verror
(
const
char
*
docref
,
const
char
*
params
,
int
type
,
const
char
*
format
,
va_list
args
TSRMLS_DC
)
{
char
*
buffer
=
NULL
,
*
docref_buf
=
NULL
,
*
target
=
NULL
;
char
*
docref_target
=
""
,
*
docref_root
=
""
;
char
*
p
;
int
buffer_len
=
0
;
const
char
*
space
=
""
;
const
char
*
class_name
=
""
;
const
char
*
function
;
int
origin_len
;
char
*
origin
;
char
*
message
;
int
is_function
=
0
;
/* get error text into buffer and escape for html if necessary */
buffer_len
=
vspprintf
(
&
buffer
,
0
,
format
,
args
);
if
(
PG
(
html_errors
)) {
size_t
len
;
char
*
replace
=
php_escape_html_entities
(
buffer
,
buffer_len
,
&
len
,
0
,
ENT_COMPAT
,
NULL
TSRMLS_CC
);
efree
(
buffer
);
buffer
=
replace
;
buffer_len
=
len
;
}
/* which function caused the problem if any at all */
if
(
php_during_module_startup
()) {
function
=
"PHP Startup"
;
}
else
if
(
php_during_module_shutdown
()) {
function
=
"PHP Shutdown"
;
}
else
if
(
EG
(
current_execute_data
)
&&
EG
(
current_execute_data
)
->
opline
&&
EG
(
current_execute_data
)
->
opline
->
opcode
==
ZEND_INCLUDE_OR_EVAL
) {
switch
(
EG
(
current_execute_data
)
->
opline
->
extended_value
) {
case
ZEND_EVAL
:
function
=
"eval"
;
is_function
=
1
;
break
;
case
ZEND_INCLUDE
:
function
=
"include"
;
is_function
=
1
;
break
;
case
ZEND_INCLUDE_ONCE
:
function
=
"include_once"
;
is_function
=
1
;
break
;
case
ZEND_REQUIRE
:
function
=
"require"
;
is_function
=
1
;
break
;
case
ZEND_REQUIRE_ONCE
:
function
=
"require_once"
;
is_function
=
1
;
break
;
default
:
function
=
"Unknown"
;
}
}
else
{
function
=
get_active_function_name
(
TSRMLS_C
);
if
(!
function
||
!
strlen
(
function
)) {
function
=
"Unknown"
;
}
else
{
is_function
=
1
;
class_name
=
get_active_class_name
(
&
space
TSRMLS_CC
);
}
}
/* if we still have memory then format the origin */
if
(
is_function
) {
origin_len
=
spprintf
(
&
origin
,
0
,
"%s%s%s(%s)"
,
class_name
,
space
,
function
,
params
);
}
else
{
origin_len
=
spprintf
(
&
origin
,
0
,
"%s"
,
function
);
}
if
(
PG
(
html_errors
)) {
size_t
len
;
char
*
replace
=
php_escape_html_entities
(
origin
,
origin_len
,
&
len
,
0
,
ENT_COMPAT
,
NULL
TSRMLS_CC
);
efree
(
origin
);
origin
=
replace
;
}
/* origin and buffer available, so lets come up with the error message */
if
(
docref
&&
docref
[
0
]
==
'#'
) {
docref_target
=
strchr
(
docref
,
'#'
);
docref
=
NULL
;
}
/* no docref given but function is known (the default) */
if
(!
docref
&&
is_function
) {
int
doclen
;
while
(
*
function
==
'_'
) {
function
++
;
}
if
(
space
[
0
]
==
'\0'
) {
doclen
=
spprintf
(
&
docref_buf
,
0
,
"function.%s"
,
function
);
}
else
{
doclen
=
spprintf
(
&
docref_buf
,
0
,
"%s.%s"
,
class_name
,
function
);
}
while
((
p
=
strchr
(
docref_buf
,
'_'
))
!=
NULL
) {
*
p
=
'-'
;
}
docref
=
php_strtolower
(
docref_buf
,
doclen
);
}
/* we have a docref for a function AND
* - we show errors in html mode AND
* - the user wants to see the links
*/
if
(
docref
&&
is_function
&&
PG
(
html_errors
)
&&
strlen
(
PG
(
docref_root
))) {
if
(
strncmp
(
docref
,
"http://"
,
7
)) {
/* We don't have 'http://' so we use docref_root */
char
*
ref
;
/* temp copy for duplicated docref */
docref_root
=
PG
(
docref_root
);
ref
=
estrdup
(
docref
);
if
(
docref_buf
) {
efree
(
docref_buf
);
}
docref_buf
=
ref
;
/* strip of the target if any */
p
=
strrchr
(
ref
,
'#'
);
if
(
p
) {
target
=
estrdup
(
p
);
if
(
target
) {
docref_target
=
target
;
*
p
=
'\0'
;
}
}
/* add the extension if it is set in ini */
if
(
PG
(
docref_ext
)
&&
strlen
(
PG
(
docref_ext
))) {
spprintf
(
&
docref_buf
,
0
,
"%s%s"
,
ref
,
PG
(
docref_ext
));
efree
(
ref
);
}
docref
=
docref_buf
;
}
/* display html formatted or only show the additional links */
if
(
PG
(
html_errors
)) {
spprintf
(
&
message
,
0
,
"%s [<a href='%s%s%s'>%s</a>]: %s"
,
origin
,
docref_root
,
docref
,
docref_target
,
docref
,
buffer
);
}
else
{
spprintf
(
&
message
,
0
,
"%s [%s%s%s]: %s"
,
origin
,
docref_root
,
docref
,
docref_target
,
buffer
);
}
if
(
target
) {
efree
(
target
);
}
}
else
{
spprintf
(
&
message
,
0
,
"%s: %s"
,
origin
,
buffer
);
}
efree
(
origin
);
if
(
docref_buf
) {
efree
(
docref_buf
);
}
if
(
PG
(
track_errors
)
&&
module_initialized
&&
(!
EG
(
user_error_handler
)
||
!(
EG
(
user_error_handler_error_reporting
)
&
type
))) {
if
(!
EG
(
active_symbol_table
)) {
zend_rebuild_symbol_table
(
TSRMLS_C
);
}
if
(
EG
(
active_symbol_table
)) {
zval
*
tmp
;
ALLOC_INIT_ZVAL
(
tmp
);
ZVAL_STRINGL
(
tmp
,
buffer
,
buffer_len
,
1
);
zend_hash_update
(
EG
(
active_symbol_table
),
"php_errormsg"
,
sizeof
(
"php_errormsg"
), (
void
*
*
)
&
tmp
,
sizeof
(
zval
*
),
NULL
);
}
}
efree
(
buffer
);
php_error
(
type
,
"%s"
,
message
);
efree
(
message
);
}
/* }}} */
/* {{{ php_error_docref0 */
/* See: CODING_STANDARDS for details. */
PHPAPI
void
php_error_docref0
(
const
char
*
docref
TSRMLS_DC
,
int
type
,
const
char
*
format
, ...)
{
va_list
args
;
va_start
(
args
,
format
);
php_verror
(
docref
,
""
,
type
,
format
,
args
TSRMLS_CC
);
va_end
(
args
);
}
/* }}} */
/* {{{ php_error_docref1 */
/* See: CODING_STANDARDS for details. */
PHPAPI
void
php_error_docref1
(
const
char
*
docref
TSRMLS_DC
,
const
char
*
param1
,
int
type
,
const
char
*
format
, ...)
{
va_list
args
;
va_start
(
args
,
format
);
php_verror
(
docref
,
param1
,
type
,
format
,
args
TSRMLS_CC
);
va_end
(
args
);
}
/* }}} */
/* {{{ php_error_docref2 */
/* See: CODING_STANDARDS for details. */
PHPAPI
void
php_error_docref2
(
const
char
*
docref
TSRMLS_DC
,
const
char
*
param1
,
const
char
*
param2
,
int
type
,
const
char
*
format
, ...)
{
char
*
params
;
va_list
args
;
spprintf
(
&
params
,
0
,
"%s,%s"
,
param1
,
param2
);
va_start
(
args
,
format
);
php_verror
(
docref
,
params
?
params
:
"..."
,
type
,
format
,
args
TSRMLS_CC
);
va_end
(
args
);
if
(
params
) {
efree
(
params
);
}
}
/* }}} */
#ifdef
PHP_WIN32
#define
PHP_WIN32_ERROR_MSG_BUFFER_SIZE
512
PHPAPI
void
php_win32_docref2_from_error
(
DWORD
error
,
const
char
*
param1
,
const
char
*
param2
TSRMLS_DC
) {
if
(
error
==
0
) {
php_error_docref2
(
NULL
TSRMLS_CC
,
param1
,
param2
,
E_WARNING
, "%
s
",
strerror
(
errno
));
}
else
{
char
buf
[
PHP_WIN32_ERROR_MSG_BUFFER_SIZE
+
1
];
int
buf_len
;
FormatMessage
(
FORMAT_MESSAGE_FROM_SYSTEM
,
NULL
,
error
,
0
,
buf
,
PHP_WIN32_ERROR_MSG_BUFFER_SIZE
,
NULL
);
buf_len
=
strlen
(
buf
);
if
(
buf_len
>=
2
) {
buf
[
buf_len
-
1
]
=
'\0'
;
buf
[
buf_len
-
2
]
=
'\0'
;
}
php_error_docref2
(
NULL
TSRMLS_CC
,
param1
,
param2
,
E_WARNING
,
"%s (code: %lu)"
, (
char
*
)
buf
,
error
);
}
}
#undef
PHP_WIN32_ERROR_MSG_BUFFER_SIZE
#endif
/* {{{ php_html_puts */
PHPAPI
void
php_html_puts
(
const
char
*
str
,
uint
size
TSRMLS_DC
)
{
zend_html_puts
(
str
,
size
TSRMLS_CC
);
}
/* }}} */
/* {{{ php_error_cb
extended error handling function */
static
void
php_error_cb
(
int
type
,
const
char
*
error_filename
,
const
uint
error_lineno
,
const
char
*
format
,
va_list
args
)
{
char
*
buffer
;
int
buffer_len
,
display
;
TSRMLS_FETCH
();
buffer_len
=
vspprintf
(
&
buffer
,
PG
(
log_errors_max_len
),
format
,
args
);
/* check for repeated errors to be ignored */
if
(
PG
(
ignore_repeated_errors
)
&&
PG
(
last_error_message
)) {
/* no check for PG(last_error_file) is needed since it cannot
* be NULL if PG(last_error_message) is not NULL */
if
(
strcmp
(
PG
(
last_error_message
),
buffer
)
||
(!
PG
(
ignore_repeated_source
)
&&
((
PG
(
last_error_lineno
)
!=
(
int
)
error_lineno
)
||
strcmp
(
PG
(
last_error_file
),
error_filename
)))) {
display
=
1
;
}
else
{
display
=
0
;
}
}
else
{
display
=
1
;
}
/* store the error if it has changed */
if
(
display
) {
#ifdef
ZEND_SIGNALS
HANDLE_BLOCK_INTERRUPTIONS
();
#endif
if
(
PG
(
last_error_message
)) {
free
(
PG
(
last_error_message
));
PG
(
last_error_message
)
=
NULL
;
}
if
(
PG
(
last_error_file
)) {
free
(
PG
(
last_error_file
));
PG
(
last_error_file
)
=
NULL
;
}
#ifdef
ZEND_SIGNALS
HANDLE_UNBLOCK_INTERRUPTIONS
();
#endif
if
(!
error_filename
) {
error_filename
=
"Unknown"
;
}
PG
(
last_error_type
)
=
type
;
PG
(
last_error_message
)
=
strdup
(
buffer
);
PG
(
last_error_file
)
=
strdup
(
error_filename
);
PG
(
last_error_lineno
)
=
error_lineno
;
}
/* according to error handling mode, suppress error, throw exception or show it */
if
(
EG
(
error_handling
)
!=
EH_NORMAL
) {
switch
(
type
) {
case
E_ERROR
:
case
E_CORE_ERROR
:
case
E_COMPILE_ERROR
:
case
E_USER_ERROR
:
View remainder of file in raw view
Back
|
FazBrowse Home
|
New Git URL