version 1.1.1.1, 2012/02/21 23:48:02
|
version 1.1.1.3, 2013/07/22 01:32:05
|
Line 2
|
Line 2
|
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| PHP Version 5 | |
| PHP Version 5 | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| Copyright (c) 1997-2012 The PHP Group | | | Copyright (c) 1997-2013 The PHP Group | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| This source file is subject to version 3.01 of the PHP license, | |
| 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 | |
| that is bundled with this package in the file LICENSE, and is | |
Line 31
|
Line 31
|
#endif |
#endif |
|
|
#include "php_globals.h" |
#include "php_globals.h" |
#include "safe_mode.h" |
|
|
|
|
|
/* Implementation of the language Header() function */ |
/* Implementation of the language Header() function */ |
Line 123 PHPAPI int php_setcookie(char *name, int name_len, cha
|
Line 122 PHPAPI int php_setcookie(char *name, int name_len, cha
|
} else { |
} else { |
snprintf(cookie, len + 100, "Set-Cookie: %s=%s", name, value ? encoded_value : ""); |
snprintf(cookie, len + 100, "Set-Cookie: %s=%s", name, value ? encoded_value : ""); |
if (expires > 0) { |
if (expires > 0) { |
char *p; | const char *p; |
strlcat(cookie, "; expires=", len + 100); |
strlcat(cookie, "; expires=", len + 100); |
dt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T")-1, expires, 0 TSRMLS_CC); |
dt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T")-1, expires, 0 TSRMLS_CC); |
/* check to make sure that the year does not exceed 4 digits in length */ |
/* check to make sure that the year does not exceed 4 digits in length */ |
Line 132 PHPAPI int php_setcookie(char *name, int name_len, cha
|
Line 131 PHPAPI int php_setcookie(char *name, int name_len, cha
|
efree(dt); |
efree(dt); |
efree(cookie); |
efree(cookie); |
efree(encoded_value); |
efree(encoded_value); |
zend_error(E_WARNING, "Expiry date cannot have a year greater then 9999"); | zend_error(E_WARNING, "Expiry date cannot have a year greater than 9999"); |
return FAILURE; |
return FAILURE; |
} |
} |
strlcat(cookie, dt, len + 100); |
strlcat(cookie, dt, len + 100); |
Line 221 PHP_FUNCTION(setrawcookie)
|
Line 220 PHP_FUNCTION(setrawcookie)
|
PHP_FUNCTION(headers_sent) |
PHP_FUNCTION(headers_sent) |
{ |
{ |
zval *arg1 = NULL, *arg2 = NULL; |
zval *arg1 = NULL, *arg2 = NULL; |
char *file=""; | const char *file=""; |
int line=0; |
int line=0; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|zz", &arg1, &arg2) == FAILURE) |
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|zz", &arg1, &arg2) == FAILURE) |
return; |
return; |
|
|
if (SG(headers_sent)) { |
if (SG(headers_sent)) { |
line = php_get_output_start_lineno(TSRMLS_C); | line = php_output_get_start_lineno(TSRMLS_C); |
file = php_get_output_start_filename(TSRMLS_C); | file = php_output_get_start_filename(TSRMLS_C); |
} |
} |
|
|
switch(ZEND_NUM_ARGS()) { |
switch(ZEND_NUM_ARGS()) { |
Line 278 PHP_FUNCTION(headers_list)
|
Line 277 PHP_FUNCTION(headers_list)
|
} |
} |
array_init(return_value); |
array_init(return_value); |
zend_llist_apply_with_argument(&SG(sapi_headers).headers, php_head_apply_header_list_to_hash, return_value TSRMLS_CC); |
zend_llist_apply_with_argument(&SG(sapi_headers).headers, php_head_apply_header_list_to_hash, return_value TSRMLS_CC); |
|
} |
|
/* }}} */ |
|
|
|
/* {{{ proto long http_response_code([int response_code]) |
|
Sets a response code, or returns the current HTTP response code */ |
|
PHP_FUNCTION(http_response_code) |
|
{ |
|
long response_code = 0; |
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &response_code) == FAILURE) { |
|
return; |
|
} |
|
|
|
if (response_code) |
|
{ |
|
long old_response_code; |
|
|
|
old_response_code = SG(sapi_headers).http_response_code; |
|
SG(sapi_headers).http_response_code = response_code; |
|
|
|
if (old_response_code) { |
|
RETURN_LONG(old_response_code); |
|
} |
|
|
|
RETURN_TRUE; |
|
} |
|
|
|
if (!SG(sapi_headers).http_response_code) { |
|
RETURN_FALSE; |
|
} |
|
|
|
RETURN_LONG(SG(sapi_headers).http_response_code); |
} |
} |
/* }}} */ |
/* }}} */ |
|
|