Re: Php question from Newsgroup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



""Boyd, Todd M."" <tmboyd1@xxxxxxxx> wrote in message 
news:33BDE0B2C17EEF46ACBE00537CF2A190037B7E96@xxxxxxxxxxxxxxxxxxxxxxx
Mike -- I've "bottom posted" my reply, as is the convention for this list 
(and most others). Scroll down.

----

From: Mike Peloso [mailto:mpeloso@xxxxxxxxxxxxx]
Sent: Thursday, December 18, 2008 9:56 AM
To: Boyd, Todd M.
Subject: Php question from Newsgroup

Todd,
I have attached a few jpgs to show the problems I am having (With both of my 
recent posts)
Any questions you can call me.
The first one shows the value of the php file I am trying to parse.( I cant 
set any of those directives,) I can't set php.ini per dir
The second shows what your REGEX looks like as its being sent to: 
preg_match_all($regex, $test2, $result, PREG_PATTERN_ORDER);
As you can see there is a whole lot of escaping going on here.
Thanks
Mike

Heres all the code:
<?php
process_uploaded_file('letter');
function process_uploaded_file($fname) {
// Assumes set of $_POST variables in the form: name, name_fname, name_size, 
name_type
$_POST[$fname.'_fname'] = $_FILES[$fname]['name'];
$_POST[$fname.'_size'] = $_FILES[$fname]['size'];
$_POST[$fname.'_type'] = $_FILES[$fname]['type'];
$_POST[$fname.'_fname'] = strtr($_POST[$fname.'_fname'],' 
%&*;:"{}[]|\<>,/()%$#@!','________________________'); //fix special chars in 
name
$_POST[$fname.'_fname'] = strtr($_POST[$fname.'_fname'],"'","_");
$fileHandle = fopen($_FILES[$fname]['tmp_name'], "r");
$_POST[$fname] =stripslashes(fread($fileHandle, $_POST[$fname.'_size']));
$test=$_POST[$fname];
$test3=stripslashes($test);
//$regex='/function [a-z]* *([$a-zA-Z]*)/';
//$regex='/function [a-z]* *(?$[a-z]*)?/';
$regex = '/function\s+[-_a-z0-9]+\s*\((\s*$\?[-_a-z0-9]+\s*,?)*\s*\)/i';

$functions=do_reg($regex,$test);
}

function do_reg($regex,$test)
{ $test2=preg_quote($test);
preg_match_all($regex, $test2, $result, PREG_PATTERN_ORDER);
return $result = $result[0];
}
?>

----

Mike,

You are using preg_quote(). This will add slashes to every "special" RegEx 
character in your pattern (i.e., parentheses and dollar signs, etc.). Try 
performing your RegEx search without using preg_quote() and let me know if 
it does any better. Also--try to keep your replies on the PHP List, as the 
information in them can be used by others on their own projects.

// Todd
Were getting there....
The only fuction i get is one without any parameters.
I'll play with it, but if you see an error in your regex let me know.
Thanks
Mike 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux