- Added opened_path to php_fopen_wrapper() and the URL fopen wrapper (it's not

always properly set, it's a TODO for all of us).  This enables us to implement
  true 'use' support.
@- Added support for the 'use' keyword - behaves like 'require', but will not
@  use the same file more than once (Andi & Zeev, Zend library)
This commit is contained in:
Andi Gutmans committed 1999-11-30 20:18:11 +00:00
1 parent 5463dd5b38
commit 2337d110f9
7 files changed
+23 -20

No files matched your search

+3 -3
View File
@@ -312,7 +312,7 @@ PHP_FUNCTION(imageloadfont) {
#if WIN32|WINNT
fp = fopen(file->value.str.val, "rb");
#else
fp = php3_fopen_wrapper(file->value.str.val, "r", IGNORE_PATH|IGNORE_URL_WIN, &issock, &socketd);
fp = php3_fopen_wrapper(file->value.str.val, "r", IGNORE_PATH|IGNORE_URL_WIN, &issock, &socketd, NULL);
#endif
if (fp == NULL) {
php_error(E_WARNING, "ImageFontLoad: unable to open file");
@@ -416,7 +416,7 @@ void php3_imagecreatefrompng (INTERNAL_FUNCTION_PARAMETERS) {
#if WIN32|WINNT
fp = fopen(file->value.str.val, "rb");
#else
fp = php3_fopen_wrapper(file->value.str.val, "r", IGNORE_PATH|IGNORE_URL_WIN, &issock, &socketd);
fp = php3_fopen_wrapper(file->value.str.val, "r", IGNORE_PATH|IGNORE_URL_WIN, &issock, &socketd, NULL);
#endif
if (!fp) {
php3_strip_url_passwd(fn);
@@ -526,7 +526,7 @@ PHP_FUNCTION(imagecreatefromgif )
#if WIN32|WINNT
fp = fopen(file->value.str.val, "rb");
#else
fp = php3_fopen_wrapper(file->value.str.val, "r", IGNORE_PATH|IGNORE_URL_WIN, &issock, &socketd);
fp = php3_fopen_wrapper(file->value.str.val, "r", IGNORE_PATH|IGNORE_URL_WIN, &issock, &socketd, NULL);
#endif
if (!fp) {
php3_strip_url_passwd(fn);
+2 -2
View File
@@ -925,7 +925,7 @@ PHPAPI int _php_error_log(int opt_err,char *message,char *opt,char *headers){
case 1: /*send an email*/
{
#if HAVE_SENDMAIL
if (!_php3_mail(opt,"PHP3 error_log message",message,headers)){
if (!_php3_mail(opt,"PHP error_log message",message,headers)){
return FAILURE;
}
#else
@@ -939,7 +939,7 @@ PHPAPI int _php_error_log(int opt_err,char *message,char *opt,char *headers){
return FAILURE;
break;
case 3: /*save to a file*/
logfile=php3_fopen_wrapper(opt,"a", (IGNORE_URL|ENFORCE_SAFE_MODE), &issock, &socketd);
logfile=php3_fopen_wrapper(opt,"a", (IGNORE_URL|ENFORCE_SAFE_MODE), &issock, &socketd, NULL);
if(!logfile) {
php_error(E_WARNING,"error_log: Unable to write to %s",opt);
return FAILURE;
+4 -4
View File
@@ -411,7 +411,7 @@ PHP_FUNCTION(get_meta_tags)
}
convert_to_string_ex(filename);
fp = php3_fopen_wrapper((*filename)->value.str.val,"r", use_include_path|ENFORCE_SAFE_MODE, &issock, &socketd);
fp = php3_fopen_wrapper((*filename)->value.str.val,"r", use_include_path|ENFORCE_SAFE_MODE, &issock, &socketd, NULL);
if (!fp && !socketd) {
if (issock != BAD_URL) {
char *tmp = estrdup((*filename)->value.str.val);
@@ -535,7 +535,7 @@ PHP_FUNCTION(file)
}
convert_to_string_ex(filename);
fp = php3_fopen_wrapper((*filename)->value.str.val,"r", use_include_path|ENFORCE_SAFE_MODE, &issock, &socketd);
fp = php3_fopen_wrapper((*filename)->value.str.val,"r", use_include_path|ENFORCE_SAFE_MODE, &issock, &socketd, NULL);
if (!fp && !socketd) {
if (issock != BAD_URL) {
char *tmp = estrdup((*filename)->value.str.val);
@@ -652,7 +652,7 @@ PHP_FUNCTION(fopen)
* We need a better way of returning error messages from
* php3_fopen__wrapper().
*/
fp = php3_fopen_wrapper((*arg1)->value.str.val, p, use_include_path|ENFORCE_SAFE_MODE, &issock, &socketd);
fp = php3_fopen_wrapper((*arg1)->value.str.val, p, use_include_path|ENFORCE_SAFE_MODE, &issock, &socketd, NULL);
if (!fp && !socketd) {
if (issock != BAD_URL) {
char *tmp = estrdup((*arg1)->value.str.val);
@@ -1320,7 +1320,7 @@ PHP_FUNCTION(readfile)
* We need a better way of returning error messages from
* php3_fopen_wrapper().
*/
fp = php3_fopen_wrapper((*arg1)->value.str.val,"r", use_include_path|ENFORCE_SAFE_MODE, &issock, &socketd);
fp = php3_fopen_wrapper((*arg1)->value.str.val,"r", use_include_path|ENFORCE_SAFE_MODE, &issock, &socketd, NULL);
if (!fp && !socketd){
if (issock != BAD_URL) {
char *tmp = estrdup((*arg1)->value.str.val);
+7 -8
View File
@@ -79,7 +79,7 @@
#include <sys/un.h>
#endif
static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, int *issock, int *socketd);
static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, int *issock, int *socketd, char **opened_path);
int _php3_getftpresult(int socketd);
@@ -181,7 +181,7 @@ PHPAPI int _php3_check_open_basedir(char *path)
return 0;
}
PHPAPI FILE *php3_fopen_wrapper(char *path, char *mode, int options, int *issock, int *socketd)
PHPAPI FILE *php3_fopen_wrapper(char *path, char *mode, int options, int *issock, int *socketd, char **opened_path)
{
int cm=2; /* checkuid mode: 2 = if file does not exist, check directory */
PLS_FETCH();
@@ -190,12 +190,12 @@ PHPAPI FILE *php3_fopen_wrapper(char *path, char *mode, int options, int *issock
be runtime enabled, NOT compile time. */
#if PHP3_URL_FOPEN
if (!(options & IGNORE_URL)) {
return php3_fopen_url_wrapper(path, mode, options, issock, socketd);
return php3_fopen_url_wrapper(path, mode, options, issock, socketd, opened_path);
}
#endif
if (options & USE_PATH && PG(include_path) != NULL) {
return php3_fopen_with_path(path, mode, PG(include_path), NULL);
return php3_fopen_with_path(path, mode, PG(include_path), opened_path);
} else {
if(!strcmp(mode,"r") || !strcmp(mode,"r+")) cm=0;
if (options & ENFORCE_SAFE_MODE && PG(safe_mode) && (!_php3_checkuid(path, cm))) {
@@ -427,7 +427,7 @@ PHPAPI FILE *php3_fopen_with_path(char *filename, char *mode, char *path, char *
* Otherwise, fopen is called as usual and the file pointer is returned.
*/
static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, int *issock, int *socketd)
static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, int *issock, int *socketd, char **opened_path)
{
url *resource;
int result;
@@ -590,7 +590,7 @@ static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, i
*socketd = 0;
free_url(resource);
if (location[0] != '\0') {
return php3_fopen_url_wrapper(location, mode, options, issock, socketd);
return php3_fopen_url_wrapper(location, mode, options, issock, socketd, opened_path);
} else {
return NULL;
}
@@ -883,12 +883,11 @@ static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, i
free_url(resource);
*issock = 1;
return (fp);
} else {
PLS_FETCH();
if (options & USE_PATH) {
fp = php3_fopen_with_path((char *) path, mode, PG(include_path), NULL);
fp = php3_fopen_with_path((char *) path, mode, PG(include_path), opened_path);
} else {
int cm=2;
if(!strcmp(mode,"r") || !strcmp(mode,"r+")) cm=0;
+1 -1
View File
@@ -66,7 +66,7 @@
#define IS_SOCKET 1
#define BAD_URL 2
extern PHPAPI FILE *php3_fopen_wrapper(char *filename, char *mode, int options, int *issock, int *socketd);
extern PHPAPI FILE *php3_fopen_wrapper(char *filename, char *mode, int options, int *issock, int *socketd, char **opened_path);
PHPAPI FILE *php3_fopen_for_parser(void);
+2 -2
View File
@@ -573,14 +573,14 @@ PHP_FUNCTION(set_time_limit)
}
static FILE *php_fopen_wrapper_for_zend(const char *filename)
static FILE *php_fopen_wrapper_for_zend(const char *filename, char **opened_path)
{
int issock=0, socketd=0;
int old_chunk_size;
FILE *retval;
old_chunk_size = _php3_sock_set_def_chunk_size(1);
retval=php3_fopen_wrapper((char *) filename, "r", USE_PATH|IGNORE_URL_WIN, &issock, &socketd);
retval=php3_fopen_wrapper((char *) filename, "r", USE_PATH|IGNORE_URL_WIN, &issock, &socketd, opened_path);
_php3_sock_set_def_chunk_size(old_chunk_size);
if (issock) {
+4
View File
@@ -893,6 +893,10 @@ SOURCE=.\NEWS
SOURCE=".\php.ini-dist"
# End Source File
# Begin Source File
SOURCE=".\README.CVS-RULES"
# End Source File
# End Group
# End Target
# End Project