Re: [PHP-DEV] Re: [PHP-CVS] cvs: php4 /ext/standard file.c

2003-02-10 Thread Ilia A.
Here is the final revision of the patch.

Ilia
Index: ext/standard/file.c
===
RCS file: /repository/php4/ext/standard/file.c,v
retrieving revision 1.300
diff -u -3 -p -r1.300 file.c
--- ext/standard/file.c 9 Feb 2003 23:11:23 -   1.300
+++ ext/standard/file.c 10 Feb 2003 20:39:47 -
@@ -180,6 +180,10 @@ PHP_MINIT_FUNCTION(file)
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_INFO",   
PHP_STREAM_NOTIFY_SEVERITY_INFO, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_WARN",   
PHP_STREAM_NOTIFY_SEVERITY_WARN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_ERR",
PHP_STREAM_NOTIFY_SEVERITY_ERR,  CONST_CS | CONST_PERSISTENT);
+
+   REGISTER_LONG_CONSTANT("FILE_USE_INCLUDE_PATH", PHP_FILE_USE_INCLUDE_PATH, 
+CONST_CS | CONST_PERSISTENT);
+   REGISTER_LONG_CONSTANT("FILE_IGNORE_NEW_LINES", PHP_FILE_IGNORE_NEW_LINES, 
+CONST_CS | CONST_PERSISTENT);
+   REGISTER_LONG_CONSTANT("FILE_SKIP_EMPTY_LINES", PHP_FILE_SKIP_EMPTY_LINES, 
+CONST_CS | CONST_PERSISTENT);

 #ifdef HAVE_FNMATCH
REGISTER_LONG_CONSTANT("FNM_NOESCAPE", FNM_NOESCAPE, CONST_CS | 
CONST_PERSISTENT);
@@ -444,7 +448,7 @@ PHP_FUNCTION(file_get_contents)
 }
 /* }}} */
 
-/* {{{ proto array file(string filename [, bool use_include_path [, bool 
include_new_line [, bool skip_blank_lines]]])
+/* {{{ proto array file(string filename [, int flags])
Read entire file into an array */
 
 #define PHP_FILE_BUF_SIZE  80
@@ -457,20 +461,26 @@ PHP_FUNCTION(file)
register int i = 0;
int target_len, len;
char eol_marker = '\n';
-   zend_bool use_include_path = 0;
-   zend_bool include_new_line = 1;
-   zend_bool skip_blank_lines = 0;
+   long flags = 0;
+   zend_bool use_include_path;
+   zend_bool include_new_line;
+   zend_bool skip_blank_lines;
php_stream *stream;
 
/* Parse arguments */
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|bbb",
-   &filename, &filename_len, &use_include_path, 
&include_new_line, &skip_blank_lines) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &filename, 
+&filename_len, &flags) == FAILURE) {
return;
}
+   if (flags < 0 || flags > 7) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, "'%d' flag is not 
+supported.", flags);
+   RETURN_FALSE;
+   }
+   
+   use_include_path = flags & PHP_FILE_USE_INCLUDE_PATH;
+   include_new_line = !(flags & PHP_FILE_IGNORE_NEW_LINES);
+   skip_blank_lines = flags & PHP_FILE_SKIP_EMPTY_LINES;
 
-   stream = php_stream_open_wrapper(filename, "rb", 
-   (use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE | 
REPORT_ERRORS,
-   NULL);
+   stream = php_stream_open_wrapper(filename, "rb", (use_include_path ? USE_PATH 
+: 0) | ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);
if (!stream) {
RETURN_FALSE;
}
Index: ext/standard/file.h
===
RCS file: /repository/php4/ext/standard/file.h,v
retrieving revision 1.74
diff -u -3 -p -r1.74 file.h
--- ext/standard/file.h 9 Feb 2003 20:43:05 -   1.74
+++ ext/standard/file.h 10 Feb 2003 20:39:47 -
@@ -87,6 +87,10 @@ PHPAPI int php_copy_file(char *src, char
 
 #define META_DEF_BUFSIZE 8192
 
+#define PHP_FILE_USE_INCLUDE_PATH 1
+#define PHP_FILE_IGNORE_NEW_LINES 2
+#define PHP_FILE_SKIP_EMPTY_LINES 4
+
 typedef enum _php_meta_tags_token {
TOK_EOF = 0,
TOK_OPENTAG,


-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Re: [PHP-CVS] cvs: php4 /ext/standard file.c

2003-02-10 Thread Wez Furlong
Hey Ilia,

Lets also have either an enum or some real #define'd constants for the
values used in the C code.

eg:

REGISTER_LONG_CONSTANT() and the code that checks for a number should
both be using a symbolic constant rather than a hard-coded number.

--Wez.

On Mon, 10 Feb 2003, Ilia A. wrote:

> Attached is the proposed solution.
>
> Ilia


-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Re: [PHP-CVS] cvs: php4 /ext/standard file.c

2003-02-10 Thread Ilia A.
Attached is the proposed solution.

Ilia
Index: ext/standard/file.c
===
RCS file: /repository/php4/ext/standard/file.c,v
retrieving revision 1.299
diff -u -3 -p -r1.299 file.c
--- ext/standard/file.c 9 Feb 2003 20:43:05 -   1.299
+++ ext/standard/file.c 10 Feb 2003 15:46:19 -
@@ -180,6 +180,10 @@ PHP_MINIT_FUNCTION(file)
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_INFO",   
PHP_STREAM_NOTIFY_SEVERITY_INFO, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_WARN",   
PHP_STREAM_NOTIFY_SEVERITY_WARN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_ERR",
PHP_STREAM_NOTIFY_SEVERITY_ERR,  CONST_CS | CONST_PERSISTENT);
+
+   REGISTER_LONG_CONSTANT("STREAM_USE_INCLUDE_PATH",   1,  CONST_CS | 
+CONST_PERSISTENT);
+   REGISTER_LONG_CONSTANT("STREAM_IGNORE_NEW_LINES",   2,  CONST_CS | 
+CONST_PERSISTENT);
+   REGISTER_LONG_CONSTANT("STREAM_SKIP_EMPTY_LINES",   4,  CONST_CS | 
+CONST_PERSISTENT);

 #ifdef HAVE_FNMATCH
REGISTER_LONG_CONSTANT("FNM_NOESCAPE", FNM_NOESCAPE, CONST_CS | 
CONST_PERSISTENT);
@@ -444,7 +448,7 @@ PHP_FUNCTION(file_get_contents)
 }
 /* }}} */
 
-/* {{{ proto array file(string filename [, bool use_include_path [, bool 
include_new_line [, bool skip_blank_lines]]])
+/* {{{ proto array file(string filename [, int flags])
Read entire file into an array */
 
 #define PHP_FILE_BUF_SIZE  80
@@ -457,20 +461,26 @@ PHP_FUNCTION(file)
register int i = 0;
int target_len, len;
char eol_marker = '\n';
-   zend_bool use_include_path = 0;
-   zend_bool include_new_line = 1;
-   zend_bool skip_blank_lines = 0;
+   long flags = 0;
+   zend_bool use_include_path;
+   zend_bool include_new_line;
+   zend_bool skip_blank_lines;
php_stream *stream;
 
/* Parse arguments */
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|bbb",
-   &filename, &filename_len, &use_include_path, 
&include_new_line, &skip_blank_lines) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &filename, 
+&filename_len, &flags) == FAILURE) {
return;
}
+   if (flags < 0 || flags > 7) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, "'%d' flag is not 
+supported.", flags);
+   RETURN_FALSE;
+   }
+   
+   use_include_path = flags & 1;
+   include_new_line = flags & 2;
+   skip_blank_lines = flags & 4;
 
-   stream = php_stream_open_wrapper(filename, "rb", 
-   (use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE | 
REPORT_ERRORS,
-   NULL);
+   stream = php_stream_open_wrapper(filename, "rb", (use_include_path ? USE_PATH 
+: 0) | ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);
if (!stream) {
RETURN_FALSE;
}


-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Re: [PHP-CVS] cvs: php4 /ext/standard file.c

2003-02-10 Thread Derick Rethans
On Mon, 10 Feb 2003, Ilia A. wrote:

> > We could turn the existing one into a "flags" parameter:
> >
> > 1 - use include path
> > 2 - include new line
> > 4 - skip_blank_lines
> >
> > This would not break BC and we don't need multiple optional
> > parameters.
> 
> Do we want to create constants for each option or simply accept integer 
> values?

constants please :)

Derick

-- 

-
 Derick Rethans http://derickrethans.nl/ 
 PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
-


-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Re: [PHP-CVS] cvs: php4 /ext/standard file.c

2003-02-10 Thread Ilia A.
On February 10, 2003 03:34 am, you wrote:
> On Sun, Feb 09, 2003 at 08:05:14PM -, Ilia Alshanetsky wrote :
> > iliaa   Sun Feb  9 15:05:14 2003 EDT
> >
> >   Modified files:
> > /php4/ext/standard  file.c
> >   Log:
> >   Added feature request #14097 (option allowing file() command not to
> > include line endings in it's output. As well as another option, which
> > allows blank lines to be excluded from the output).
>
> Can we change this to not have two more optional parameters
> but re-use the existing one?
>
> We could turn the existing one into a "flags" parameter:
>
> 1 - use include path
> 2 - include new line
> 4 - skip_blank_lines
>
> This would not break BC and we don't need multiple optional
> parameters.

Do we want to create constants for each option or simply accept integer 
values?

Ilia

-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Re: [PHP-CVS] cvs: php4 /ext/standard file.c

2003-02-10 Thread Derick Rethans
On Mon, 10 Feb 2003, Markus Fischer wrote:

> On Sun, Feb 09, 2003 at 08:05:14PM -, Ilia Alshanetsky wrote : 
> > iliaa   Sun Feb  9 15:05:14 2003 EDT
> > 
> >   Modified files:  
> > /php4/ext/standard  file.c 
> >   Log:
> >   Added feature request #14097 (option allowing file() command not to include
> >   line endings in it's output. As well as another option, which allows blank 
> >   lines to be excluded from the output).
> 
> Can we change this to not have two more optional parameters
> but re-use the existing one?
> 
> We could turn the existing one into a "flags" parameter:
> 
> 1 - use include path
> 2 - include new line
> 4 - skip_blank_lines
> 
> This would not break BC and we don't need multiple optional
> parameters.

+1 on that.

Derick

-- 

-
 Derick Rethans http://derickrethans.nl/ 
 PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
-


-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Re: [PHP-CVS] cvs: php4 /ext/standard file.c

2003-02-10 Thread Markus Fischer
On Sun, Feb 09, 2003 at 08:05:14PM -, Ilia Alshanetsky wrote : 
> iliaa Sun Feb  9 15:05:14 2003 EDT
> 
>   Modified files:  
> /php4/ext/standardfile.c 
>   Log:
>   Added feature request #14097 (option allowing file() command not to include
>   line endings in it's output. As well as another option, which allows blank 
>   lines to be excluded from the output).

Can we change this to not have two more optional parameters
but re-use the existing one?

We could turn the existing one into a "flags" parameter:

1 - use include path
2 - include new line
4 - skip_blank_lines

This would not break BC and we don't need multiple optional
parameters.

- Markus

-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Re: [PHP-CVS] cvs: php4 /ext/standard file.c ftp_fopen_wrapper.c http_fopen_wrapper.c php_fopen_wrapper.c /ext/zlib zlib_fopen_wrapper.c /main memory_streams.c network.c php_streams.h streams.c user_streams.c

2002-03-27 Thread Marcus Börger

Should we have stat also for memory/temp streams? should be no problem but
supporting access/modified time with it would slow down performance as querying
time is timeconsumpting on most systems.

marcus

At 01:49 28.03.2002, you wrote:
>wez Wed Mar 27 19:49:00 2002 EDT
>
>   Modified files:
> /php4/ext/standard  file.c ftp_fopen_wrapper.c http_fopen_wrapper.c
> php_fopen_wrapper.c
> /php4/ext/zlib  zlib_fopen_wrapper.c
> /php4/main  memory_streams.c network.c php_streams.h streams.c
> user_streams.c
>   Log:
>   Phase 3 of OO wrapper cleanup
>   # What was phase 2?
>
>
>--
>PHP CVS Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: Re: [PHP-DEV] Re: [PHP-CVS] cvs: php4 /ext/standard file.c

2001-05-18 Thread usrgre

I agree, though it would be nice to release this soon, however,  it is not worth 
risking the RP. 

-Jason


> 
> From: Andi Gutmans <[EMAIL PROTECTED]>
> Date: 2001/05/18 Fri PM 06:26:49 CDT
> To: "Jason Greene" <[EMAIL PROTECTED]>,<[EMAIL PROTECTED]>
> Subject: Re: [PHP-DEV] Re: [PHP-CVS] cvs: php4 /ext/standard file.c
> 
> At 05:00 PM 5/18/2001 -0500, Jason Greene wrote:
> >I am all for that, but don't forget filestat.c and the macro
> >in php_filestat.h.
> 
> Hmm, that's making me think twice now. Maybe we should just merge Sascha's 
> fixes.
> 
> Andi
> 
> 


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] Re: [PHP-CVS] cvs: php4 /ext/standard file.c

2001-05-18 Thread Andi Gutmans

At 12:04 AM 5/19/2001 +0200, Sascha Schumann wrote:
>On Fri, 18 May 2001, Andi Gutmans wrote:
>
> > I was just about to do an automatic merge of this fix to the PHP_4_0_6
> > branch when I saw that the merge will also merge the stat() update which
> > creates associative keys too (cvs update -j 1.159 file.c after an update -r
> > PHP_4_0_6).
> > Any objections to me merging that one too? I think it would be good to have
> > it in 4.0.6.
> > If people mind I can just merge this one by hand.
>
> You might want to wait for another bug-fix.  If a client
> interrupts a download, PHPWRITE() won't return, so that we
> have no chance of unmapping the file.  Can someone remind me
> whether RSHUTDOWN functions are called after
> php_handle_aborted_connection()?

Yeah. It's supposed to be called.

Andi


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] Re: [PHP-CVS] cvs: php4 /ext/standard file.c

2001-05-18 Thread Andi Gutmans

At 05:00 PM 5/18/2001 -0500, Jason Greene wrote:
>I am all for that, but don't forget filestat.c and the macro
>in php_filestat.h.

Hmm, that's making me think twice now. Maybe we should just merge Sascha's 
fixes.

Andi


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] Re: [PHP-CVS] cvs: php4 /ext/standard file.c

2001-05-18 Thread Jason Greene

I am all for that, but don't forget filestat.c and the macro
in php_filestat.h.

Thanks,
Jason

- Original Message - 
From: "Andi Gutmans" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, May 18, 2001 3:08 PM
Subject: [PHP-DEV] Re: [PHP-CVS] cvs: php4 /ext/standard file.c 


> I was just about to do an automatic merge of this fix to the PHP_4_0_6 
> branch when I saw that the merge will also merge the stat() update which 
> creates associative keys too (cvs update -j 1.159 file.c after an update -r 
> PHP_4_0_6).
> Any objections to me merging that one too? I think it would be good to have 
> it in 4.0.6.
> If people mind I can just merge this one by hand.
> 
> Andi
> 
> At 05:48 PM 5/18/2001 +, Sascha Schumann wrote:
> >sas Fri May 18 10:48:43 2001 EDT
> >
> >   Modified files:
> > /php4/ext/standard  file.c
> >   Log:
> >   Files should be shared among processes.
> >
> >
> >Index: php4/ext/standard/file.c
> >diff -u php4/ext/standard/file.c:1.158 php4/ext/standard/file.c:1.159
> >--- php4/ext/standard/file.c:1.158  Sat May 12 14:48:39 2001
> >+++ php4/ext/standard/file.cFri May 18 10:48:43 2001
> >@@ -21,7 +21,7 @@
> > +--+
> >   */
> >
> >-/* $Id: file.c,v 1.158 2001/05/12 21:48:39 wez Exp $ */
> >+/* $Id: file.c,v 1.159 2001/05/18 17:48:43 sas Exp $ */
> >
> >  /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
> >
> >@@ -1546,7 +1546,7 @@
> > if (sbuf.st_size > sizeof(buf)) {
> > off = ftell(fp);
> > len = sbuf.st_size - off;
> >-   p = mmap(0, len, PROT_READ, MAP_PRIVATE, fd, off);
> >+   p = mmap(0, len, PROT_READ, MAP_SHARED, fd, off);
> > if (p != (void *) MAP_FAILED) {
> > PHPWRITE(p, len);
> > munmap(p, len);
> >
> >
> >
> >--
> >PHP CVS Mailing List (http://www.php.net/)
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> 
> -- 
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> 


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] Re: [PHP-CVS] cvs: php4 /ext/standard file.c

2001-05-18 Thread Sascha Schumann

On Fri, 18 May 2001, Andi Gutmans wrote:

> I was just about to do an automatic merge of this fix to the PHP_4_0_6
> branch when I saw that the merge will also merge the stat() update which
> creates associative keys too (cvs update -j 1.159 file.c after an update -r
> PHP_4_0_6).
> Any objections to me merging that one too? I think it would be good to have
> it in 4.0.6.
> If people mind I can just merge this one by hand.

You might want to wait for another bug-fix.  If a client
interrupts a download, PHPWRITE() won't return, so that we
have no chance of unmapping the file.  Can someone remind me
whether RSHUTDOWN functions are called after
php_handle_aborted_connection()?

- Sascha Experience IRCG
  http://schumann.cx/http://schumann.cx/ircg


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] Re: [PHP-CVS] cvs: php4 /ext/standard file.c

2001-05-18 Thread Andi Gutmans

I was just about to do an automatic merge of this fix to the PHP_4_0_6 
branch when I saw that the merge will also merge the stat() update which 
creates associative keys too (cvs update -j 1.159 file.c after an update -r 
PHP_4_0_6).
Any objections to me merging that one too? I think it would be good to have 
it in 4.0.6.
If people mind I can just merge this one by hand.

Andi

At 05:48 PM 5/18/2001 +, Sascha Schumann wrote:
>sas Fri May 18 10:48:43 2001 EDT
>
>   Modified files:
> /php4/ext/standard  file.c
>   Log:
>   Files should be shared among processes.
>
>
>Index: php4/ext/standard/file.c
>diff -u php4/ext/standard/file.c:1.158 php4/ext/standard/file.c:1.159
>--- php4/ext/standard/file.c:1.158  Sat May 12 14:48:39 2001
>+++ php4/ext/standard/file.cFri May 18 10:48:43 2001
>@@ -21,7 +21,7 @@
> +--+
>   */
>
>-/* $Id: file.c,v 1.158 2001/05/12 21:48:39 wez Exp $ */
>+/* $Id: file.c,v 1.159 2001/05/18 17:48:43 sas Exp $ */
>
>  /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
>
>@@ -1546,7 +1546,7 @@
> if (sbuf.st_size > sizeof(buf)) {
> off = ftell(fp);
> len = sbuf.st_size - off;
>-   p = mmap(0, len, PROT_READ, MAP_PRIVATE, fd, off);
>+   p = mmap(0, len, PROT_READ, MAP_SHARED, fd, off);
> if (p != (void *) MAP_FAILED) {
> PHPWRITE(p, len);
> munmap(p, len);
>
>
>
>--
>PHP CVS Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] RE: [PHP-CVS] cvs: php4 /ext/standard file.c file.h

2001-02-11 Thread Sean R. Bright

Well, I was trying to fix one bug, not introduce others.  If you read the
documentation for get_meta_tags you will see that it returns an associative
array that is keyed by the value of the NAME attribute while the value is
the data within the CONTENT attribute.

If other members of the developers list would like to suggest a solution for
this problem, I would be more than happy to implement it.  Right now I don't
know how to add what you are asking for without breaking existing PHP code.

Sean

> -Original Message-
> From: Colin Viebrock [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, February 11, 2001 10:52 PM
> To: Sterling Hughes
> Cc: Sean Bright; [EMAIL PROTECTED]
> Subject: Re: [PHP-CVS] cvs: php4 /ext/standard file.c file.h
>
>
> [Sun, 11 Feb 2001] Sterling Hughes said:
>
> >
> > > elixer Sat Feb 10 18:38:40 2001 EDT
> > >
> > >   Modified files:
> > > /php4/ext/standard file.c file.h
> > >   Log:
> > >   Fix for bug #4556
> > >   # This is pretty much a total rewrite of get_meta_tags
> using a simple
> > >   # handwritten tokenizer.  It might be overkill, but it works.
> >
> > I'd say this is news worthy...
> >
> > Can you add an entry into the NEWS file.
>
>
> I agree.  However, on first glance, it only seems to grab the
> meta-tags
> that have the NAME/CONTENT attributes, not the HTTP-EQUIV/CONTENT
> attributes.  This was a major drawback of the original code (IMHO).
>
> I wrote my own get_metatags function in PHP.  Find the code below.  If
> someone likes this and wants to convert it into C ...
>
>  function get_metatags($url) {
>
> if (substr($url,0,7)=='http://') {
> $url = substr($url,7);
> }
>
> if( !($fp = fopen('http://'.$url, 'r')) ) {
> return false;
> } else {
>
> $file = '';
> while (!feof($fp) && !stristr($file,'') ) {
> $file.= fgets($fp, 80);
> }
> fclose($fp);
>
> $file = str_replace("\r", '', $file);
> $file = str_replace("\n", '', $file);
>
> $result = array();
> preg_match_all('//i', $file, $temp);
>
> if (is_array($temp[1])) {
>
> foreach($temp[1] as $key=>$match) {
>
> $t = $n = $c = '';
> if (preg_match('/name=("|\')(.*?)\\1/i',
> $match, $b)) {
> $t = 'NAME';
> $n = $b[2];
> } else if
> (preg_match('/http-equiv=("|\')(.*?)\\1/i', $match, $b)) {
> $t = 'HTTP-EQUIV';
> $n = $b[2];
> }
>
> if (preg_match('/content=("|\')(.*?)\\1/i',
> $match, $b)) {
> $c = $b[2];
> }
>
> if ($t && $n && $c) {
> $result[] = array(
> 'type'  => $t,
> 'meta_name' => $n,
> 'meta_content'  => $c
> );
> }
> }
> }
> return $result;
> }
> }
> ?>
>
>
> - Colin
>
>
> --
> PHP CVS Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail:
> [EMAIL PROTECTED]
>
>


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]