|
|
|
@ -49,6 +49,7 @@ |
|
|
|
|
|
|
|
#include "safe_mode.h" |
|
|
|
#include "php_link.h" |
|
|
|
#include "php_string.h" |
|
|
|
|
|
|
|
/* {{{ proto string readlink(string filename) |
|
|
|
Return the target of a symbolic link */ |
|
|
|
@ -115,6 +116,8 @@ PHP_FUNCTION(symlink) |
|
|
|
int ret; |
|
|
|
char source_p[MAXPATHLEN]; |
|
|
|
char dest_p[MAXPATHLEN]; |
|
|
|
char dirname[MAXPATHLEN]; |
|
|
|
size_t len; |
|
|
|
|
|
|
|
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &topath, &frompath) == FAILURE) { |
|
|
|
WRONG_PARAM_COUNT; |
|
|
|
@ -122,7 +125,15 @@ PHP_FUNCTION(symlink) |
|
|
|
convert_to_string_ex(topath); |
|
|
|
convert_to_string_ex(frompath); |
|
|
|
|
|
|
|
if (!expand_filepath(Z_STRVAL_PP(frompath), source_p TSRMLS_CC) || !expand_filepath(Z_STRVAL_PP(topath), dest_p TSRMLS_CC)) { |
|
|
|
if (!expand_filepath(Z_STRVAL_PP(frompath), source_p TSRMLS_CC)) { |
|
|
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such file or directory"); |
|
|
|
RETURN_FALSE; |
|
|
|
} |
|
|
|
|
|
|
|
memcpy(dirname, source_p, sizeof(source_p)); |
|
|
|
len = php_dirname(dirname, strlen(dirname)); |
|
|
|
|
|
|
|
if (!expand_filepath_ex(Z_STRVAL_PP(topath), dest_p, dirname, len TSRMLS_CC)) { |
|
|
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such file or directory"); |
|
|
|
RETURN_FALSE; |
|
|
|
} |
|
|
|
|