@@ -141,28 +141,26 @@ PHP_FUNCTION(apache_child_terminate)
141
141
Get and set Apache request notes */
142
142
PHP_FUNCTION (apache_note )
143
143
{
144
- zval * * arg_name , * * arg_val ;
145
- char * note_val ;
144
+ char * note_name , * note_val ;
145
+ long note_name_len , note_val_len ;
146
+ char * old_val ;
146
147
int arg_count = ZEND_NUM_ARGS ();
147
148
148
- if (arg_count < 1 || arg_count > 2 ||
149
- zend_get_parameters_ex (arg_count , & arg_name , & arg_val ) == FAILURE ) {
150
- WRONG_PARAM_COUNT ;
149
+ if (zend_parse_parameters (arg_count TSRMLS_CC , "s|s" , & note_name , & note_name_len , & note_val , & note_val_len ) == FAILURE ) {
150
+ return ;
151
151
}
152
-
153
- convert_to_string_ex (arg_name );
154
- note_val = (char * ) table_get (((request_rec * )SG (server_context ))-> notes , (* arg_name )-> value .str .val );
155
-
152
+
153
+ old_val = (char * ) table_get (((request_rec * )SG (server_context ))-> notes , note_name );
154
+
156
155
if (arg_count == 2 ) {
157
- convert_to_string_ex (arg_val );
158
- table_set (((request_rec * )SG (server_context ))-> notes , (* arg_name )-> value .str .val , (* arg_val )-> value .str .val );
156
+ table_set (((request_rec * )SG (server_context ))-> notes , note_name , note_val );
159
157
}
160
158
161
- if (note_val ) {
162
- RETURN_STRING (note_val , 1 );
163
- } else {
164
- RETURN_FALSE ;
159
+ if (old_val ) {
160
+ RETURN_STRING (old_val , 1 );
165
161
}
162
+
163
+ RETURN_FALSE ;
166
164
}
167
165
/* }}} */
168
166
@@ -310,37 +308,42 @@ PHP_MINFO_FUNCTION(apache)
310
308
*/
311
309
PHP_FUNCTION (virtual )
312
310
{
313
- zval * * filename ;
311
+ char * filename ;
312
+ long filename_len ;
314
313
request_rec * rr = NULL ;
315
314
316
- if (ZEND_NUM_ARGS () != 1 || zend_get_parameters_ex ( 1 , & filename ) == FAILURE ) {
317
- WRONG_PARAM_COUNT ;
315
+ if (zend_parse_parameters ( ZEND_NUM_ARGS () TSRMLS_CC , "s" , & filename , & filename_len ) == FAILURE ) {
316
+ return ;
318
317
}
319
- convert_to_string_ex (filename );
320
318
321
- if (!(rr = sub_req_lookup_uri ((* filename )-> value .str .val , ((request_rec * ) SG (server_context ))))) {
322
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "Unable to include '%s' - URI lookup failed" , (* filename )-> value .str .val );
323
- if (rr ) destroy_sub_req (rr );
319
+ if (!(rr = sub_req_lookup_uri (filename , ((request_rec * ) SG (server_context ))))) {
320
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "Unable to include '%s' - URI lookup failed" , filename );
321
+ if (rr )
322
+ destroy_sub_req (rr );
324
323
RETURN_FALSE ;
325
324
}
326
325
327
326
if (rr -> status != 200 ) {
328
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "Unable to include '%s' - error finding URI" , (* filename )-> value .str .val );
329
- if (rr ) destroy_sub_req (rr );
327
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "Unable to include '%s' - error finding URI" , filename );
328
+ if (rr )
329
+ destroy_sub_req (rr );
330
330
RETURN_FALSE ;
331
331
}
332
332
333
333
php_end_ob_buffers (1 TSRMLS_CC );
334
334
php_header (TSRMLS_C );
335
335
336
336
if (run_sub_req (rr )) {
337
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "Unable to include '%s' - request execution failed" , (* filename )-> value .str .val );
338
- if (rr ) destroy_sub_req (rr );
337
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "Unable to include '%s' - request execution failed" , filename );
338
+ if (rr )
339
+ destroy_sub_req (rr );
339
340
RETURN_FALSE ;
340
- } else {
341
- if (rr ) destroy_sub_req (rr );
342
- RETURN_TRUE ;
343
341
}
342
+
343
+ if (rr )
344
+ destroy_sub_req (rr );
345
+
346
+ RETURN_TRUE ;
344
347
}
345
348
/* }}} */
346
349
@@ -351,14 +354,14 @@ PHP_FUNCTION(virtual)
351
354
Fetch all HTTP request headers */
352
355
PHP_FUNCTION (apache_request_headers )
353
356
{
354
- array_header * env_arr ;
355
- table_entry * tenv ;
356
- int i ;
357
-
358
- array_init (return_value );
359
- env_arr = table_elts (((request_rec * ) SG (server_context ))-> headers_in );
360
- tenv = (table_entry * )env_arr -> elts ;
361
- for (i = 0 ; i < env_arr -> nelts ; ++ i ) {
357
+ array_header * env_arr ;
358
+ table_entry * tenv ;
359
+ int i ;
360
+
361
+ array_init (return_value );
362
+ env_arr = table_elts (((request_rec * ) SG (server_context ))-> headers_in );
363
+ tenv = (table_entry * )env_arr -> elts ;
364
+ for (i = 0 ; i < env_arr -> nelts ; ++ i ) {
362
365
if (!tenv [i ].key ||
363
366
(PG (safe_mode ) &&
364
367
!strncasecmp (tenv [i ].key , "authorization" , 13 ))) {
@@ -375,14 +378,14 @@ PHP_FUNCTION(apache_request_headers)
375
378
Fetch all HTTP response headers */
376
379
PHP_FUNCTION (apache_response_headers )
377
380
{
378
- array_header * env_arr ;
379
- table_entry * tenv ;
380
- int i ;
381
-
382
- array_init (return_value );
383
- env_arr = table_elts (((request_rec * ) SG (server_context ))-> headers_out );
384
- tenv = (table_entry * )env_arr -> elts ;
385
- for (i = 0 ; i < env_arr -> nelts ; ++ i ) {
381
+ array_header * env_arr ;
382
+ table_entry * tenv ;
383
+ int i ;
384
+
385
+ array_init (return_value );
386
+ env_arr = table_elts (((request_rec * ) SG (server_context ))-> headers_out );
387
+ tenv = (table_entry * )env_arr -> elts ;
388
+ for (i = 0 ; i < env_arr -> nelts ; ++ i ) {
386
389
if (!tenv [i ].key ) continue ;
387
390
if (add_assoc_string (return_value , tenv [i ].key , (tenv [i ].val == NULL ) ? "" : tenv [i ].val , 1 )== FAILURE ) {
388
391
RETURN_FALSE ;
@@ -395,13 +398,13 @@ PHP_FUNCTION(apache_response_headers)
395
398
Set an Apache subprocess_env variable */
396
399
PHP_FUNCTION (apache_setenv )
397
400
{
398
- int var_len , val_len ;
401
+ long var_len , val_len ;
399
402
zend_bool top = 0 ;
400
403
char * var = NULL , * val = NULL ;
401
404
request_rec * r = (request_rec * ) SG (server_context );
402
405
403
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "ss|b" , & var , & var_len , & val , & val_len , & top ) == FAILURE ) {
404
- RETURN_FALSE ;
406
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "ss|b" , & var , & var_len , & val , & val_len , & top ) == FAILURE ) {
407
+ return ;
405
408
}
406
409
407
410
while (top ) {
@@ -418,20 +421,22 @@ PHP_FUNCTION(apache_setenv)
418
421
Perform a partial request of the given URI to obtain information about it */
419
422
PHP_FUNCTION (apache_lookup_uri )
420
423
{
421
- zval * * filename ;
424
+ char * filename ;
425
+ long filename_len ;
422
426
request_rec * rr = NULL ;
423
427
424
- if (ZEND_NUM_ARGS () != 1 || zend_get_parameters_ex ( 1 , & filename ) == FAILURE ) {
425
- WRONG_PARAM_COUNT ;
428
+ if (zend_parse_parameters ( ZEND_NUM_ARGS () TSRMLS_CC , "s" , & filename , & filename_len ) == FAILURE ) {
429
+ return ;
426
430
}
427
- convert_to_string_ex (filename );
428
431
429
- if (!(rr = sub_req_lookup_uri (( * filename ) -> value . str . val , ((request_rec * ) SG (server_context ))))) {
430
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "URI lookup failed '%s'" , ( * filename ) -> value . str . val );
432
+ if (!(rr = sub_req_lookup_uri (filename , ((request_rec * ) SG (server_context ))))) {
433
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "URI lookup failed '%s'" , filename );
431
434
RETURN_FALSE ;
432
435
}
436
+
433
437
object_init (return_value );
434
438
add_property_long (return_value ,"status" , rr -> status );
439
+
435
440
if (rr -> the_request ) {
436
441
add_property_string (return_value ,"the_request" , rr -> the_request , 1 );
437
442
}
@@ -462,6 +467,7 @@ PHP_FUNCTION(apache_lookup_uri)
462
467
if (rr -> boundary ) {
463
468
add_property_string (return_value ,"boundary" , rr -> boundary , 1 );
464
469
}
470
+
465
471
add_property_long (return_value ,"no_cache" , rr -> no_cache );
466
472
add_property_long (return_value ,"no_local_copy" , rr -> no_local_copy );
467
473
add_property_long (return_value ,"allowed" , rr -> allowed );
@@ -492,19 +498,20 @@ This function is most likely a bad idea. Just playing with it for now.
492
498
493
499
PHP_FUNCTION (apache_exec_uri )
494
500
{
495
- zval * * filename ;
501
+ char * filename ;
502
+ long filename_len ;
496
503
request_rec * rr = NULL ;
497
504
TSRMLS_FETCH ();
498
505
499
- if (ZEND_NUM_ARGS () != 1 || zend_get_parameters_ex ( 1 , & filename ) == FAILURE ) {
500
- WRONG_PARAM_COUNT ;
506
+ if (zend_parse_parameters ( ZEND_NUM_ARGS () TSRMLS_CC , "s" , & filename , & filename_len ) == FAILURE ) {
507
+ return ;
501
508
}
502
- convert_to_string_ex (filename );
503
509
504
- if (!(rr = ap_sub_req_lookup_uri (( * filename ) -> value . str . val , ((request_rec * ) SG (server_context ))))) {
505
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "URI lookup failed" , ( * filename ) -> value . str . val );
510
+ if (!(rr = ap_sub_req_lookup_uri (filename , ((request_rec * ) SG (server_context ))))) {
511
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "URI lookup failed" , filename );
506
512
RETURN_FALSE ;
507
513
}
514
+
508
515
RETVAL_LONG (ap_run_sub_req (rr ));
509
516
ap_destroy_sub_req (rr );
510
517
}
@@ -518,9 +525,9 @@ PHP_FUNCTION(apache_get_version)
518
525
519
526
if (apv && * apv ) {
520
527
RETURN_STRING (apv , 1 );
521
- } else {
522
- RETURN_FALSE ;
523
528
}
529
+
530
+ RETURN_FALSE ;
524
531
}
525
532
/* }}} */
526
533
0 commit comments