Re: [PHP] Will this do what I think it will?

2003-03-14 Thread CPT John W. Holmes
How didn't it work? How did you test it? I'd be more than willing to help
you test it, but everything is sort of vague right now.

---John Holmes...

- Original Message -
From: Dennis Gearon [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, March 14, 2003 12:20 AM
Subject: Re: [PHP] Will this do what I think it will?


 Well,
 it didn't work, and I wrote it because I'm unfamiliar with regex's.

 John W. Holmes wrote:
 
   I call this file 'clean_gpc.php'.
  
   Will it:
 // trim all control codes and spaces from ends of string
 // standardize Window's CRLF in middle of string to \n
 // standardize Apple's  LF   in middle of string to \n
 // remove all control characters BELOW \n
 // remove all control characters ABOVE \n
 // compresse run on spaces to a single space
 // compresse run on carriage returns to a max of 2
 
  Sure... why not. Honestly, why did you write this email? You wasted a
  couple hundred people's time when you could have just run the function
  yourself.
 
  ---John W. Holmes...
 
  PHP Architect - A monthly magazine for PHP Professionals. Get your copy
  today. http://www.phparch.com/


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



[PHP] Will this do what I think it will?

2003-03-13 Thread Dennis Gearon
I call this file 'clean_gpc.php'.

Will it:
// trim all control codes and spaces from ends of string
  // standardize Window's CRLF in middle of string to \n
  // standardize Apple's  LF   in middle of string to \n
  // remove all control characters BELOW \n
  // remove all control characters ABOVE \n
  // compresse run on spaces to a single space
  // compresse run on carriage returns to a max of 2

?PHP
if( !defined( GPC_CLEANED ) ){
define( GPC_CLEANED, TRUE );

function clean_gpc( $x ) {
if (is_array($x)) {
while ( list( $key,$value ) = each( $x )) {
if ( $value ) clean_gpc( $x[$key] );
}
   } else {
   $x = trim($X,\x00..\x20);
  // trims all control codes and spaces from ends of string
   $x = preg_replace(\r\n, \n, $x );
  // standardizes Window's CRLF in middle of string to \n
   $x = preg_replace(\r,   \n, $x );
  // standardizes Apple's  LF   in middle of string to \n
   $x = preg_replace(\x00..\x09,   , $x );
  // removes all control characters BELOW \n
   $x = preg_replace(\x0A..\x1F,   , $x );
  // removes all control characters ABOVE \n
   $x = preg_replace(' +', ' ', $x );
  // compresses run on spaces to a single space
   $x = preg_replace('\n+\n', '\n\n', $x );
  // compresses run on carriage returns to a max of 2
   }
}
clean_gpc($HTTP_GET_VARS);
clean_gpc($HTTP_POST_VARS);
clean_gpc($HTTP_COOKIES_VARS);
//clean_gpc($HTTP_SESSION_VARS);
}
?



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



RE: [PHP] Will this do what I think it will?

2003-03-13 Thread John W. Holmes
 I call this file 'clean_gpc.php'.
 
 Will it:
   // trim all control codes and spaces from ends of string
   // standardize Window's CRLF in middle of string to \n
   // standardize Apple's  LF   in middle of string to \n
   // remove all control characters BELOW \n
   // remove all control characters ABOVE \n
   // compresse run on spaces to a single space
   // compresse run on carriage returns to a max of 2

Sure... why not. Honestly, why did you write this email? You wasted a
couple hundred people's time when you could have just run the function
yourself. 

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



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