[PHP] Re: PHP Form email w/attachment

2008-12-18 Thread Carlos Medina

jeffery harris schrieb:
I need to create a php form and mail it to a recipient (that I can do). My 
question is how do I create an area for a file (.doc, or .pdf) to be 
attached emailed along with other form data as well?


-Jeff 




Hi Jeffery,
you need to upload the File with the Form inputfield

accept="text/*">
When the upload is ready, use is_uploaded_file() function to check and 
others to validate the File (important) then move the file with move_ 
uploaded_ file() to the Directory where you want or attach to the mail 
you want.


Kind Regards

Carlos Medina

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



Re: [PHP] PHP Form email w/attachment

2008-12-18 Thread Per Jessen
jeffery harris wrote:

> I need to create a php form and mail it to a recipient (that I can
> do). My question is how do I create an area for a file (.doc, or .pdf)
> to be attached emailed along with other form data as well?
> 

Take a look at an email you've received with an attachment. That's how
you need to format your email-text. 


/Per Jessen, Zürich


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



Re: [PHP] PHP Form email w/attachment

2008-12-18 Thread Richard Heyes
> thank god that some guys make it
> simple for us ;)

You're welcome. :-)

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated December 5th)

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



Re: [PHP] Read/decode barcodes from an image

2008-12-18 Thread Per Jessen
Adam Randall wrote:

> I'm amazed that this either doesn't exist, or is hard to find. I
> basically am looking for a way to read in an image into PHP, or shell
> out to something on the Linux side, and determine, and see if it has a
> barcode in it or not. If it does, I need to decode the barcode so that
> I can identify the page as a separator page or not.
> 
> Basically, what I'm doing is reading in a PDF or TIF which will
> contain multiple pages (probably a lot of pages) and look for a page
> containing a barcode. The barcode will identify the page as a
> separator page which will be used to split the multipage document into
> smaller single or multipage documents.
> 
> Has anyone ever heard of anything that might help me in this process?

I can't say for certain, but have a look at zebra:

http://zebra.sourceforge.net/

Looks like the sort of thing you could use. 


/Per Jessen, Zürich


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



Re: [PHP] fread question

2008-12-18 Thread MikeP
>From my phpinfo:
  magic_quotes_runtime Off

"Robert Cummings"  wrote in message 
news:1229567238.8302.35.ca...@localhost...
> On Wed, 2008-12-17 at 19:54 -0500, MikeP wrote:
>> Hello,
>> I have been trying to use fread to open a file, but it always escapes
>> special characters.
>> How do I open  afile without it modifying my original file:
>>
>> $_POST[$fname] = fread($fileHandle, $_POST[$fname.'_size']);
>> I use this and get slashes everywhere.This kills my REGex that gets coded
>> next.
>
> Check this magically shitty setting in your php.ini:
>
>magic_quotes_runtime
>
> It should be off unless someone with less brains than a turd got a hold
> of your ini file.
>
> Cheers,
> Rob.
> -- 
> http://www.interjinn.com
> Application and Templating Framework for PHP
> 



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



Re: [PHP] fread question

2008-12-18 Thread MikeP
But this one is ON
magic_quotes_gpc
"Robert Cummings"  wrote in message 
news:1229567238.8302.35.ca...@localhost...
> On Wed, 2008-12-17 at 19:54 -0500, MikeP wrote:
>> Hello,
>> I have been trying to use fread to open a file, but it always escapes
>> special characters.
>> How do I open  afile without it modifying my original file:
>>
>> $_POST[$fname] = fread($fileHandle, $_POST[$fname.'_size']);
>> I use this and get slashes everywhere.This kills my REGex that gets coded
>> next.
>
> Check this magically shitty setting in your php.ini:
>
>magic_quotes_runtime
>
> It should be off unless someone with less brains than a turd got a hold
> of your ini file.
>
> Cheers,
> Rob.
> -- 
> http://www.interjinn.com
> Application and Templating Framework for PHP
> 



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



Re: [PHP] fread question

2008-12-18 Thread MikeP
Still having problems:
magic_quotes_runtime is off
BUT
magic_quotes_gpc is on
I cant change them myself so I tried
stripslashes
That doesnt work though:

$_POST[$fname] = fread($fileHandle, $_POST[$fname.'_size']);
$test=$_POST[$fname];
$test3=stripslashes($test);

$test3 and $test are the same.

Any other Ideas?

Thanks
mike



"Robert Cummings"  wrote in message 
news:1229567238.8302.35.ca...@localhost...
> On Wed, 2008-12-17 at 19:54 -0500, MikeP wrote:
>> Hello,
>> I have been trying to use fread to open a file, but it always escapes
>> special characters.
>> How do I open  afile without it modifying my original file:
>>
>> $_POST[$fname] = fread($fileHandle, $_POST[$fname.'_size']);
>> I use this and get slashes everywhere.This kills my REGex that gets coded
>> next.
>
> Check this magically shitty setting in your php.ini:
>
>magic_quotes_runtime
>
> It should be off unless someone with less brains than a turd got a hold
> of your ini file.
>
> Cheers,
> Rob.
> -- 
> http://www.interjinn.com
> Application and Templating Framework for PHP
> 



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



Re: [PHP] Phpmyadmin password

2008-12-18 Thread Jochem Maas
VamVan schreef:
..

May be u can do a bowl
> fish encryption 

...

> Thanks,
> V

LOL. 'bowl fish' ... 'fish bowl' ... I guess you meant to write 'blow' :-)

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



[PHP] Regex Problem

2008-12-18 Thread MikeP
Hello,
I have  a quirky behavior I'm trying to resolve.
I have a REGEX that will find a function definition in a php file:
.function InsertQuery($table,$fields,$values).
the REGEX is:
$regex='/function [a-z]* *([$a-zA-Z]*)/';
the problem is that:
1. a slash is automattically put in front of the $. This is good but I dont 
know how it gets there.
2.a slash is NOT put in front of the parenthesis. Thats bad
3. If I try to escape the parenthesis with a \ , I get \\.
Help 



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



[PHP] php 5.2.8 error_log - relative paths

2008-12-18 Thread Andre Hübner
Hello,

i use in .htaccess
php_flag log_errors 1
php_value error_log  folder/file

seems to be a new behavior that folder/file must be a absolut value. relativ 
path/file raises an open_basedir error which is set up in httpd.conf
but folder/file is not outside open_basedir and is writeable.

Is this correct?

Thanks,
Andre

RE: [PHP] Regex Problem

2008-12-18 Thread Boyd, Todd M.
> -Original Message-
> From: MikeP [mailto:mpel...@princeton.edu]
> Sent: Thursday, December 18, 2008 8:43 AM
> To: php-general@lists.php.net
> Subject: [PHP] Regex Problem
> 
> Hello,
> I have  a quirky behavior I'm trying to resolve.
> I have a REGEX that will find a function definition in a php file:
> .function InsertQuery($table,$fields,$values).
> the REGEX is:
> $regex='/function [a-z]* *([$a-zA-Z]*)/';
> the problem is that:
> 1. a slash is automattically put in front of the $. This is good but I
> dont
> know how it gets there.
> 2.a slash is NOT put in front of the parenthesis. Thats bad
> 3. If I try to escape the parenthesis with a \ , I get \\.
> Help

Mike,

Certain characters are considered "special" in RegEx. The $ means "end
of the line," so it must be escaped to avoid confusing its meaning. I
was not sure it had to be escaped within a character set [], but that
may very well be the case. Try this:

$regex = '/function\s+[-_a-z0-9]+\s*\((\s*\$?[-_a-z0-9]+\s*,?)*\s*\)/i';

The word "function" is followed by 1 or more spaces (or tabs). The
function name [-_a-z0-9] can be a combination of alpha-numeric
characters, underscore, and dash. Then, there is optional whitespace
between the name of the function and its parameters. The opening
parenthesis "(" for parameters has been escaped (as has the closing
parenthesis). Then, in a repeatable capture group, the parameters can be
grabbed: Indefinite whitespace, an optional $ (because maybe you're not
using a variable, eh?), one or more alpha-numeric, underscore, or dash
characters, followed by indefinite whitespace and an optional comma (if
there are more arguments). After any number of instances of the capture
group, the regex continues by looking for indefinite whitespace followed
by the closing parenthesis for the function text. The "i" switch at the
end simply means that this regex pattern will be treated as
case-insensitive ('APPLE' == 'apple').

If you're not worried about actually splitting up the function
parameters into capture groups, then you can just use a look-ahead to
ensure that you grab everything up till the LAST parenthesis on the
line.

$regex = '/function\s+[-_a-z0-9]+\s*\(.*?\)(?=.*\)[^)]*)/i';

That one probably needs to be tweaked a bit in order to actually grab
the last parenthesis (instead of just checking for its existence). If
you're willing to trust the text you'll be searching through, you can
probably avoid that "last parenthesis" rule altogether, and make a lazy
regex:

$regex = '/function\s+[-_a-z0-9]+\s*\(.*?/i';

Once you get to the opening parenthesis for the function parameters,
that last regex assumes that the rest of the line will also include that
function declaration, and just grabs everything left. If you are using a
regex setup to where the dot marker can also consume newline or carriage
return characters, just throw a "$" at the end of the regex (before the
flags part "/i") in order to tell it just to grab characters until it
reaches the end of the line:

$regex = '/function\s+[-_a-z0-9]+\s*\(.*?$/i';

These are all untested, but hopefully I've given you a nudge in the
right direction. If you are still getting strange behavior out of your
PCRE engine, then perhaps you have a different version installed than
what I'm used to--all of the above should work (perhaps with some very
minor changes) in PHP.

HTH,


// Todd

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



RE: [PHP] fread question

2008-12-18 Thread Boyd, Todd M.
> -Original Message-
> From: MikeP [mailto:mpel...@princeton.edu]
> Sent: Thursday, December 18, 2008 7:33 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] fread question
> 
> Still having problems:
> magic_quotes_runtime is off
> BUT
> magic_quotes_gpc is on
> I cant change them myself so I tried
> stripslashes
> That doesnt work though:
> 
> $_POST[$fname] = fread($fileHandle, $_POST[$fname.'_size']);
> $test=$_POST[$fname];
> $test3=stripslashes($test);
> 
> $test3 and $test are the same.
> 
> Any other Ideas?
> 
> "Robert Cummings"  wrote in message
> news:1229567238.8302.35.ca...@localhost...
> > On Wed, 2008-12-17 at 19:54 -0500, MikeP wrote:
> >> Hello,
> >> I have been trying to use fread to open a file, but it always
> escapes
> >> special characters.
> >> How do I open  afile without it modifying my original file:
> >>
> >> $_POST[$fname] = fread($fileHandle, $_POST[$fname.'_size']);
> >> I use this and get slashes everywhere.This kills my REGex that gets
> coded
> >> next.
> >
> > Check this magically shitty setting in your php.ini:
> >
> >magic_quotes_runtime
> >
> > It should be off unless someone with less brains than a turd got a
> hold
> > of your ini file.

The PHP site's page on ini_set() [1] talks a bit about how to set that
particular option in an .htaccess file:

set PHP_INI_PERDIR settings in a .htaccess file with 'php_flag'
like this:

php_flag register_globals off
php_flag magic_quotes_gpc on

If you can get at your .htaccess, maybe you could do it that way (since
I don't believe you can change magic_quotes_gpc using ini_set() or
similar methods).

HTH,


// Todd

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



[PHP] Re: Read/decode barcodes from an image

2008-12-18 Thread Al



Al wrote:

If anything can do it, it'll be ImageMagick

Adam Randall wrote:

I'm amazed that this either doesn't exist, or is hard to find. I
basically am looking for a way to read in an image into PHP, or shell
out to something on the Linux side, and determine, and see if it has a
barcode in it or not. If it does, I need to decode the barcode so that
I can identify the page as a separator page or not.

Basically, what I'm doing is reading in a PDF or TIF which will
contain multiple pages (probably a lot of pages) and look for a page
containing a barcode. The barcode will identify the page as a
separator page which will be used to split the multipage document into
smaller single or multipage documents.

Has anyone ever heard of anything that might help me in this process?

Adam.



Google "imagemagick barcode" and you get 140,000+ hits

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



RE: [PHP] fread question

2008-12-18 Thread Boyd, Todd M.
Hah! Forgot to add the link:

1. http://php.net/ini_set

How would you guys have ever figured out that was the page on PHP's
website you need to visit in order to view information about the
ini_set() function?!

;)


// Todd

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



[PHP] Re: runtime access to static variable

2008-12-18 Thread ceo

> Unfortunately, in the inherited DeployTask::execute(), "self::$STEPS"

> does not refer to UpdateTask::$STEPS, it refers to DeployTask::$STEPS



Use parent::$STEPS and call it done?



Yes, I know, if you add another layer of class in between, then it's not 
parent:: anymore, but it seems a bit less convoluted than the reflection 
solution, to this naive user...



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



[PHP] still can't get a login with session working ... is there another way to mask the url parameter?

2008-12-18 Thread Terion Miller
Still this won't pass the session to the next page is there a way to
pass parameters in the url but mask them? maybe that would be easier, since
I do have code that works passing the adminID on the url ...
can a parameter be hashed after the fact?  I tried echo-ing the fields on
the next page and they are not passing...
my code that still doesn't work:

 0) {
$_SESSION['AdminLogin'] = $row['AdminID'];
header ("Location: Main.php");
} else {
$msg = "Invalid Login";
}
}

?>


Re: [PHP] fread question

2008-12-18 Thread ceo

PHP does *not* do the addslashes on $_POST when you cram something into it in 
your PHP code.



It does it during the process of auto-filling up $_POST.



So either:

A) you have magic_quotes_runtime turned on LOCALLY. Use phpinfo() to see.

B) you actually managed to put the backslashes into your text file.



PS

You really shouldn't be cramming data into $_POST, imho.

Too confusing for later development/maintenance.

$_POST should be "read only"

Copy the parts of $_POST you want into something else, and add in your file 
contents as well.



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



[PHP] RE: Php question from Newsgroup

2008-12-18 Thread Boyd, Todd M.
Mike -- I've "bottom posted" my reply, as is the convention for this list (and 
most others). Scroll down.



From: Mike Peloso [mailto:mpel...@princeton.edu] 
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:
,/()%...@!',''); //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 


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



Re: [PHP] Read/decode barcodes from an image

2008-12-18 Thread ceo

AIUI:



The barcodes are on faxes and whatnot, with no predictable skew, position, nor 
orientation.



You've tried JOCR/GOCR, and they don't do very well.



Here are your options:

1) Shell out the money for that PaperPort OMNI or whatever it is commercial OCR 
product. It *is* better than JOCR/GOCR, in my experience.

[If you Google for OCR you'll find it, as it's the only/best contender, and 
referenced everywhere.]



2) Roll your own with GD. With sufficient skill and time, you can utilize very 
specific knowledge of your content to do even better than the generalized 
commercial solution. I have done this myself for standardized medical documents 
that were scanned in, getting a percentage point or two better than 1)



No matter what you do, OCR will never ever get you 100%.  You WILL need a human 
oversight process on the results that hand-checks everything, or be prepared to 
accept a (small) failure rate.



Set your [client's] expectations properly, or be doomed to frustration 
[failure].





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



Re: [PHP] still can't get a login with session working ... is there another way to mask the url parameter?

2008-12-18 Thread Ólafur Waage
1st. Replace your $sql query with this

$sql = sprintf("SELECT * FROM admin WHERE UserName = '%s' AND Password
= '%s'", mysql_real_escape_string($UserName),
mysql_real_escape_string($Password));
$result = mysql_query($sql) or die(mysql_error());

Ólafur Waage
olaf...@gmail.com

On Thu, Dec 18, 2008 at 3:56 PM, Terion Miller  wrote:
> Still this won't pass the session to the next page is there a way to
> pass parameters in the url but mask them? maybe that would be easier, since
> I do have code that works passing the adminID on the url ...
> can a parameter be hashed after the fact?  I tried echo-ing the fields on
> the next page and they are not passing...
> my code that still doesn't work:
>
>  // start session
>  session_start();
>  include("inc/dbconn_open.php") ;
>  $errs = error_reporting ('E_ALL');
>
> if (isset($_POST['UserName'])) {$UserName = $_POST['UserName'];} else
> {$UserName = '';}
> if (isset($_POST['Password'])) {$Password = $_POST['Password'];} else
> {$Password = '';}
>
> $msg = '';
>
> if (!empty($UserName)) {
>
>$sql = "SELECT * FROM  admin WHERE  UserName ='$UserName' and Password
> ='$Password' "
>or die(mysql_error());
>$result = mysql_query ($sql);
>$row = mysql_fetch_object ($result);
>If (mysql_num_rows($result) > 0) {
>$_SESSION['AdminLogin'] = $row['AdminID'];
>header ("Location: Main.php");
>} else {
>$msg = "Invalid Login";
>}
> }
>
> ?>
>

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



Re: [PHP] fread question

2008-12-18 Thread MikeP
 you have magic_quotes_runtime turned on LOCALLY. Use phpinfo() to see.
NOmagic_quotes_runtime Off

 you actually managed to put the backslashes into your text file.
NO

.
.
.
.
,/()%...@!',''); //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']));


Neither

 wrote in message 
news:20081218155854.69674.qm...@o2.hostbaby.com...
>
> PHP does *not* do the addslashes on $_POST when you cram something into it 
> in your PHP code.
>
> It does it during the process of auto-filling up $_POST.
>
> So either:
> A) you have magic_quotes_runtime turned on LOCALLY. Use phpinfo() to see.
> B) you actually managed to put the backslashes into your text file.
>
> PS
> You really shouldn't be cramming data into $_POST, imho.
> Too confusing for later development/maintenance.
> $_POST should be "read only"
> Copy the parts of $_POST you want into something else, and add in your 
> file contents as well.
> 



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



RE: [PHP] Read/decode barcodes from an image

2008-12-18 Thread Boyd, Todd M.
> -Original Message-
> From: c...@l-i-e.com [mailto:c...@l-i-e.com]
> Sent: Thursday, December 18, 2008 10:06 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] Read/decode barcodes from an image
> 
> The barcodes are on faxes and whatnot, with no predictable skew,
> position, nor orientation.
> 
> You've tried JOCR/GOCR, and they don't do very well.
> 
> Here are your options:
> 1) Shell out the money for that PaperPort OMNI or whatever it is
> commercial OCR product. It *is* better than JOCR/GOCR, in my
> experience.
> [If you Google for OCR you'll find it, as it's the only/best
contender,
> and referenced everywhere.]
> 
> 2) Roll your own with GD. With sufficient skill and time, you can
> utilize very specific knowledge of your content to do even better than
> the generalized commercial solution. I have done this myself for
> standardized medical documents that were scanned in, getting a
> percentage point or two better than 1)
> 
> No matter what you do, OCR will never ever get you 100%.  You WILL
need
> a human oversight process on the results that hand-checks everything,
> or be prepared to accept a (small) failure rate.
> 
> Set your [client's] expectations properly, or be doomed to frustration
> [failure].

I had always thought that faxes were a big no-no for character
recognition software? I know that we can't use it for one of our OCR
solutions because it is just too... well, crappy. The image quality is
nowhere near what it should be for a successful OCR pass.

As for client expectations: hell yes--tell them not to use a fax machine
in the digital age. Scan the document and e-mail it or something. Where
I work, we've done away with 90% of any fax machine usage in order to
have documents that can be used by our OCR solution.

My 2c,


// Todd

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



RE: [PHP] Read/decode barcodes from an image

2008-12-18 Thread ceo

Certainly if the quality of the input can be improved by using some digital 
transfer that is not a fax, go for it...



I assumed the OP already knew that, but perhaps not.



The fax is going to cost you a LOT of accuracy, probably too much to make OCR 
even viable, really, but it depends on the faxes involved.  If it's always the 
same two fax machines, and they are both set at image quality and have good 
feeders, you *might* get halfway decent quality out of them.



If you're talking random faxes from random people, then forget about OCR. Not 
gonna work.



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



[PHP] Re: Php question from Newsgroup

2008-12-18 Thread MikeP

""Boyd, Todd M.""  wrote in message 
news:33bde0b2c17eef46acbe00537cf2a190037b7...@exchcluster.ccis.edu...
Mike -- I've "bottom posted" my reply, as is the convention for this list 
(and most others). Scroll down.



From: Mike Peloso [mailto:mpel...@princeton.edu]
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:
,/()%...@!',''); //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



Re: [PHP] Regex Problem

2008-12-18 Thread MikeP

""Boyd, Todd M.""  wrote in message 
news:33bde0b2c17eef46acbe00537cf2a190037b7...@exchcluster.ccis.edu...
> -Original Message-
> From: MikeP [mailto:mpel...@princeton.edu]
> Sent: Thursday, December 18, 2008 8:43 AM
> To: php-general@lists.php.net
> Subject: [PHP] Regex Problem
>
> Hello,
> I have  a quirky behavior I'm trying to resolve.
> I have a REGEX that will find a function definition in a php file:
> .function InsertQuery($table,$fields,$values).
> the REGEX is:
> $regex='/function [a-z]* *([$a-zA-Z]*)/';
> the problem is that:
> 1. a slash is automattically put in front of the $. This is good but I
> dont
> know how it gets there.
> 2.a slash is NOT put in front of the parenthesis. Thats bad
> 3. If I try to escape the parenthesis with a \ , I get \\.
> Help

Mike,

Certain characters are considered "special" in RegEx. The $ means "end
of the line," so it must be escaped to avoid confusing its meaning. I
was not sure it had to be escaped within a character set [], but that
may very well be the case. Try this:

$regex = '/function\s+[-_a-z0-9]+\s*\((\s*\$?[-_a-z0-9]+\s*,?)*\s*\)/i';

The word "function" is followed by 1 or more spaces (or tabs). The
function name [-_a-z0-9] can be a combination of alpha-numeric
characters, underscore, and dash. Then, there is optional whitespace
between the name of the function and its parameters. The opening
parenthesis "(" for parameters has been escaped (as has the closing
parenthesis). Then, in a repeatable capture group, the parameters can be
grabbed: Indefinite whitespace, an optional $ (because maybe you're not
using a variable, eh?), one or more alpha-numeric, underscore, or dash
characters, followed by indefinite whitespace and an optional comma (if
there are more arguments). After any number of instances of the capture
group, the regex continues by looking for indefinite whitespace followed
by the closing parenthesis for the function text. The "i" switch at the
end simply means that this regex pattern will be treated as
case-insensitive ('APPLE' == 'apple').

If you're not worried about actually splitting up the function
parameters into capture groups, then you can just use a look-ahead to
ensure that you grab everything up till the LAST parenthesis on the
line.

$regex = '/function\s+[-_a-z0-9]+\s*\(.*?\)(?=.*\)[^)]*)/i';

That one probably needs to be tweaked a bit in order to actually grab
the last parenthesis (instead of just checking for its existence). If
you're willing to trust the text you'll be searching through, you can
probably avoid that "last parenthesis" rule altogether, and make a lazy
regex:

$regex = '/function\s+[-_a-z0-9]+\s*\(.*?/i';

Once you get to the opening parenthesis for the function parameters,
that last regex assumes that the rest of the line will also include that
function declaration, and just grabs everything left. If you are using a
regex setup to where the dot marker can also consume newline or carriage
return characters, just throw a "$" at the end of the regex (before the
flags part "/i") in order to tell it just to grab characters until it
reaches the end of the line:

$regex = '/function\s+[-_a-z0-9]+\s*\(.*?$/i';

These are all untested, but hopefully I've given you a nudge in the
right direction. If you are still getting strange behavior out of your
PCRE engine, then perhaps you have a different version installed than
what I'm used to--all of the above should work (perhaps with some very
minor changes) in PHP.

HTH,


// Todd

GOT IT!!

Thanks. 



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



[PHP] CLI in background on windows

2008-12-18 Thread Fanda
Hi,
I am looking for some method, how to run php cli script on background in 
windows. It should be started by windows task manager.

Do you have any idea?
Thans, Fanda 



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



RE: [PHP] CLI in background on windows

2008-12-18 Thread Boyd, Todd M.
> -Original Message-
> From: Fanda [mailto:d...@sidak.net]
> Sent: Thursday, December 18, 2008 10:50 AM
> To: php-general@lists.php.net
> Subject: [PHP] CLI in background on windows
> 
> Hi,
> I am looking for some method, how to run php cli script on background
> in
> windows. It should be started by windows task manager.
> 
> Do you have any idea?

I assume by "task manager" you mean "task scheduler"? The Task Manager
is more of a process listing, like "ps" or "top" in Linux.

In the Windows command-line interface (cmd.exe), type "start /?" to give
you an idea of what your options are. As far as "in the background"
goes, Vista's task scheduler can hide the programs it executes from
being viewed by the user. Pre-vista, I think you can just minimize it
(unless it's run on a different account on the same machine other than
the one logged in)...

start /min /b php myscript.php

The "/b" option MIGHT prevent pre-Vista machines from showing the user
that a task is being executed. If it doesn't, then at least "/min" will
keep the window minimized rather than slapping them in the face with it.

HTH,


// Todd

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



Re: [PHP] Phpmyadmin password

2008-12-18 Thread VamVan
Yeah true thanks for pointing out. Thats what I meant !!! :)

Blowfish (http://en.wikipedia.org/wiki/Blowfish_(cipher))

On Thu, Dec 18, 2008 at 6:11 AM, Jochem Maas  wrote:

> VamVan schreef:
> ..
>
> May be u can do a bowl
> > fish encryption
>
> ...
>
> > Thanks,
> > V
>
> LOL. 'bowl fish' ... 'fish bowl' ... I guess you meant to write 'blow' :-)
>


Re: [PHP] Good PHP book?

2008-12-18 Thread franzemmanuel

Robert Cummings a écrit :

On Wed, 2008-12-17 at 10:47 +, Richard Heyes wrote:

Floppies hold 1.4 megs now?  Mine don't and they're even dual-sided. :(

What are "Floppies"? Is it a reference to a particular male problem?


If so, then I want to know what dual sided means?

Cheers,
Rob.

and me High Density !!! :)

Truely,
Zeuf

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



[PHP] Variable Scope problem passing function parameters

2008-12-18 Thread Jim McIntyre

I'm new to PHP 5 and classes, but I've done a lot of ActionScript.

I'm trying to use PHPMailer inside my own class (a service for AMFPHP). 
I'm having problems getting the data that'spassed into my class's send() 
method to the instance of the PHPMailer.


Basically, I have this:

class EmailAMF {
  public function send ($from, $to, $subject, $body) {
require('class.phpmailer.php');

$phpMail = new PHPMailer();
$phpMail->From = $from;
$phpMail->AddAddress($this->to);
$phpMail->Subject = $subject;
$phpMail->Body = $body;
return $phpMail->Send();

  }
}

As far as I can tell, it sends an essentially blank email to nobody (but 
returns true.


If I replace any of my function variables with strings, like this:

   $phpMail->AddAddress('m...@example.com');

the email actually "gets" that data.

What am I missing?

Thanks,
Jim

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



Re: [PHP] Variable Scope problem passing function parameters

2008-12-18 Thread metastable
Jim McIntyre wrote:
> I'm new to PHP 5 and classes, but I've done a lot of ActionScript.
>
> I'm trying to use PHPMailer inside my own class (a service for
> AMFPHP). I'm having problems getting the data that'spassed into my
> class's send() method to the instance of the PHPMailer.
>
> Basically, I have this:
>
> class EmailAMF {
>   public function send ($from, $to, $subject, $body) {
> require('class.phpmailer.php');
>
> $phpMail = new PHPMailer();
> $phpMail->From = $from;
> $phpMail->AddAddress($this->to);
> $phpMail->Subject = $subject;
> $phpMail->Body = $body;
> return $phpMail->Send();
>
>   }
> }
>
> As far as I can tell, it sends an essentially blank email to nobody
> (but returns true.
>
> If I replace any of my function variables with strings, like this:
>
>$phpMail->AddAddress('m...@example.com');
>
> the email actually "gets" that data.
>
> What am I missing?
>
> Thanks,
> Jim
>
$this -> to

it has no meaning in the scope of your class.






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



Re: [PHP] Variable Scope problem passing function parameters

2008-12-18 Thread Jim McIntyre

metastable wrote:

Jim McIntyre wrote:

$phpMail = new PHPMailer();
$phpMail->From = $from;
$phpMail->AddAddress($this->to);
$phpMail->Subject = $subject;
$phpMail->Body = $body;
return $phpMail->Send();



$this -> to

it has no meaning in the scope of your class.


Apparently, neither do the other variable names. If I replace that with 
a string containing my email address, it sends an email... but 
everything else in the email is blank - no body, no subject, etc.


How do I reference the arguments passed to the function when setting 
properties or calling methods of the instance of PHPMailer?


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



[PHP] SOLVED Re: [PHP] Variable Scope problem passing function parameters

2008-12-18 Thread Jim McIntyre



Jim McIntyre wrote:

metastable wrote:

Jim McIntyre wrote:

$phpMail = new PHPMailer();
$phpMail->From = $from;
$phpMail->AddAddress($this->to);
$phpMail->Subject = $subject;
$phpMail->Body = $body;
return $phpMail->Send();


Never mind - I found the problem. It was a lowly typo. Ugh.

-Jim

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



Re: [PHP] CLI in background on windows

2008-12-18 Thread Fanda
 Yes, it should be "task scheduler". :-) My Windows is in czech, sorry. I was 
trying commands you suggested before, but black window always blinks on screen.

My soulution is to create new windows user and run my tasks under this user. In 
such case tasks run is not visible...

Thanks for your tips,

Fanda



""Boyd, Todd M.""  píse v diskusním príspevku 
news:33bde0b2c17eef46acbe00537cf2a190037b7...@exchcluster.ccis.edu...

> -Original Message-
> From: Fanda [mailto:d...@sidak.net]
> Sent: Thursday, December 18, 2008 10:50 AM
> To: php-general@lists.php.net
> Subject: [PHP] CLI in background on windows
> 
> Hi,
> I am looking for some method, how to run php cli script on background
> in
> windows. It should be started by windows task manager.
> 
> Do you have any idea?

I assume by "task manager" you mean "task scheduler"? The Task Manager
is more of a process listing, like "ps" or "top" in Linux.

In the Windows command-line interface (cmd.exe), type "start /?" to give
you an idea of what your options are. As far as "in the background"
goes, Vista's task scheduler can hide the programs it executes from
being viewed by the user. Pre-vista, I think you can just minimize it
(unless it's run on a different account on the same machine other than
the one logged in)...

start /min /b php myscript.php

The "/b" option MIGHT prevent pre-Vista machines from showing the user
that a task is being executed. If it doesn't, then at least "/min" will
keep the window minimized rather than slapping them in the face with it.

HTH,


// Todd

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



[PHP] utf8 php howto?

2008-12-18 Thread Daniel Kolbo

Hello,

I have a text file encoded in utf-8.
i am using fopen/fgets/echo etc..

how do i display these utf8 characters from the file on the web?

I have tried different combinations of
header("Content-Type: text/html; charset=iso-8859-1");
header("Content-Type: text/html; charset=utf-8")
and
utf8_decode/utf8_encode functions

I can't seem to get the characters from the file to display as 
non-giberish on the web.


if i set the charset=utf8, and type the unique characters in directly to 
my document (hard coded) and save the document as utf8, then the 
characters display properly on the web.


examples:
1) save file as utf-8, web produces correct characters


[type special characters here using russian keyboard layout]


2) save file as ASCI, web produces [giberish]





3) save file as utf-8, web produces [giberish]





Thanks for your help,
dK



Re: [PHP] utf8 php howto?

2008-12-18 Thread Daniel Kolbo

Daniel Kolbo wrote:

Hello,

I have a text file encoded in utf-8.
i am using fopen/fgets/echo etc..

how do i display these utf8 characters from the file on the web?

I have tried different combinations of
header("Content-Type: text/html; charset=iso-8859-1");
header("Content-Type: text/html; charset=utf-8")
and
utf8_decode/utf8_encode functions

I can't seem to get the characters from the file to display as 
non-giberish on the web.


if i set the charset=utf8, and type the unique characters in directly 
to my document (hard coded) and save the document as utf8, then the 
characters display properly on the web.


examples:
1) save file as utf-8, web produces correct characters


[type special characters here using russian keyboard layout]


2) save file as ASCI, web produces [giberish]





3) save file as utf-8, web produces [giberish]





Thanks for your help,
dK



found a solution:

save the .php file as ASCII





thanks,
dK


[PHP] SimpleXML - issue with getting data out of the object returned

2008-12-18 Thread Dan Joseph
Hi,

I have a basic XML document that I am grabbing with simplexml_load_string(),
here is the print_r:

SimpleXMLElement Object
(
[Package] => SimpleXMLElement Object
(
[PackageID] => 804
[PackageName] => Silver
[BandwidthGB] => 20
[WebStorageMB] => 5120
[DBStorageMB] => 250
[POPMailBoxes] => 50
[WebStorageUnits] => 5
[BandwidthUnits] => 1
[DBStorageUnits] => 1
[POPUnits] => 5
[DomainHeaders] => 50
[DBType] => MSSQL
[OSType] => Windows
[Enabled] => True
)

[Count] => 1
)

When I try and access $x->Package->PackageID I don't get 804, I get:

SimpleXMLElement Object
(
[0] => 804
)

Could someone tell me how I just get the value 804 out of there?

-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."


Re: [PHP] SimpleXML - issue with getting data out of the object returned

2008-12-18 Thread German Geek
Tim-Hinnerk Heuer

http://www.ihostnz.com


On Fri, Dec 19, 2008 at 3:50 PM, Dan Joseph  wrote:

> Hi,
>
> I have a basic XML document that I am grabbing with
> simplexml_load_string(),
> here is the print_r:
>
> SimpleXMLElement Object
> (
>[Package] => SimpleXMLElement Object
>(
>[PackageID] => 804
>[PackageName] => Silver
>[BandwidthGB] => 20
>[WebStorageMB] => 5120
>[DBStorageMB] => 250
>[POPMailBoxes] => 50
>[WebStorageUnits] => 5
>[BandwidthUnits] => 1
>[DBStorageUnits] => 1
>[POPUnits] => 5
>[DomainHeaders] => 50
>[DBType] => MSSQL
>[OSType] => Windows
>[Enabled] => True
>)
>
>[Count] => 1
> )
>
> When I try and access $x->Package->PackageID I don't get 804, I get:
>
> SimpleXMLElement Object
>(
>[0] => 804
>)
>
Had that problem before:
$val = (string) $x->Package->PackageID;
or
$val = (int) $x->Package->PackageID;

or whatever type you want. ;)

>
> Could someone tell me how I just get the value 804 out of there?
>
> --
> -Dan Joseph
>
> www.canishosting.com - Plans start @ $1.99/month.
>
> "Build a man a fire, and he will be warm for the rest of the day.
> Light a man on fire, and will be warm for the rest of his life."
>


Re: [PHP] SimpleXML - issue with getting data out of the object returned

2008-12-18 Thread Dan Joseph
On Thu, Dec 18, 2008 at 10:01 PM, German Geek  wrote:

> $val = (string) $x->Package->PackageID;
> or
> $val = (int) $x->Package->PackageID;
>
>
Ha... I would have never figured that out...  Thank you to you both!  That
did the trick.

-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."


[PHP] Re: CLI in background on windows

2008-12-18 Thread Ondrej Kulaty
What about to try run it as service? I don't know exactly how to do that but 
service programs run in background on my Win XP

""Fanda""  pí¹e v diskusním pøíspìvku 
news:7d.3d.09584.c2f7a...@pb1.pair.com...
> Hi,
> I am looking for some method, how to run php cli script on background in 
> windows. It should be started by windows task manager.
>
> Do you have any idea?
> Thans, Fanda
> 



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



Re: [PHP] Re: CLI in background on windows

2008-12-18 Thread Daniel Kolbo


Ondrej Kulaty wrote:
What about to try run it as service? I don't know exactly how to do that but 
service programs run in background on my Win XP


""Fanda""  pí¹e v diskusním pøíspìvku 
news:7d.3d.09584.c2f7a...@pb1.pair.com...
  

Hi,
I am looking for some method, how to run php cli script on background in 
windows. It should be started by windows task manager.


Do you have any idea?
Thans, Fanda




  

Just did a quick search:
http://www.tacktech.com/display.cfm?ttid=197
looking at other services, they have parameters so you could probably do 
this with php.exe

pretty cool idea...hmm...what can i do with this.
note: start->run:services.msc will open your services manager
hTh
dK