? lala.diff Index: ext/standard/filestat.c =================================================================== RCS file: /repository/php-src/ext/standard/filestat.c,v retrieving revision 1.112.2.7 diff -u -r1.112.2.7 filestat.c --- ext/standard/filestat.c 24 Jun 2003 13:44:57 -0000 1.112.2.7 +++ ext/standard/filestat.c 30 Sep 2003 09:55:51 -0000 @@ -572,7 +572,13 @@ RETURN_FALSE; } - if (php_check_open_basedir_ex(filename, IS_EXISTS_CHECK(type) ? 0 : 1 TSRMLS_CC)) { +/* if (php_check_open_basedir_ex(filename, IS_EXISTS_CHECK(type) ? 0 : 1 TSRMLS_CC)) { + RETURN_FALSE; + } +where did it go ? +*/ + + if (php_check_open_basedir(filename TSRMLS_CC)) { RETURN_FALSE; } @@ -909,10 +915,52 @@ FileFunction(PHP_FN(is_link), FS_IS_LINK) /* }}} */ -/* {{{ proto bool file_exists(string filename) - Returns true if filename exists */ -FileFunction(PHP_FN(file_exists), FS_EXISTS) +/* {{{ proto bool file_exists(string filename [, bool check_include_path] ) + Returns true if filename exists, may also check in include_path */ + +PHP_FUNCTION(file_exists) { + char testf[MAXPATHLEN]; + char *fname, *s, *e; + int flen; + zend_bool check_include = 0; + struct stat sb; + + if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", + &fname, &flen, &check_include) == FAILURE) { + WRONG_PARAM_COUNT; + } + if(!flen) { + RETURN_FALSE; + } + if(VCWD_STAT(fname, &sb) == 0) { + RETURN_TRUE; + } + if (check_include) { + s = PG(include_path); + while(s && *s) { + e = strchr(s, DEFAULT_DIR_SEPARATOR); + if (e != NULL) { + *e = '\0'; + e++; + } + snprintf(testf, MAXPATHLEN, "%s/%s", s, fname); + if(VCWD_STAT(testf, &sb) == 0) { + RETURN_TRUE; + } + s = e; + } + } + RETURN_FALSE; +} + /* }}} */ + /* {{{ proto array lstat(string filename) Give information about a file or symbolic link */