php-general Digest 4 Aug 2006 16:55:10 -0000 Issue 4274
Topics (messages 240095 through 240130):
Re: The difference between ereg and preg?
240095 by: Chris
240096 by: Dave Goodchild
240097 by: Dave M G
240098 by: Ford, Mike
240099 by: Dave M G
240100 by: Robin Vickery
240101 by: Jochem Maas
240103 by: Ford, Mike
240105 by: Jochem Maas
240107 by: Jochem Maas
240116 by: Dave M G
240117 by: Jochem Maas
240126 by: Adam Zey
240127 by: Adam Zey
Problem with wrapper script for Tidy
240102 by: Frank Arensmeier
OT promotion & candidates needed
240104 by: Jay Blanchard
240109 by: Jochem Maas
Regular Expresson for checking password strength
240106 by: James Nunnerley
240115 by: Al
240124 by: Adam Zey
Newbie Form Question
240108 by: David Ellsworth
240111 by: Jay Blanchard
240112 by: Duncan Hill
240113 by: Russell Jones
240114 by: David Ellsworth
240118 by: David Ellsworth
Re: PAYPAL TRANSACTION.
240110 by: Shafiq Rehman
writing to fild on another server
240119 by: blackwater dev
240120 by: Brad Bonkoski
240121 by: Duncan Hill
240122 by: Paul Scott
240123 by: Robert Cummings
240125 by: Ray Hauge
php behind firewall
240128 by: Andrew Senyshyn
240129 by: Jochem Maas
240130 by: John Nichel
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
php-general@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
Dave M G wrote:
PHP List,
Recently I wrote a piece of code to scrape data from an HTML page.
Part of that code deleted all the unwanted text from the very top of the
page, where it says "<!DOCTYPE", all the way down to the first instance
of a "<ul>" tag.
That code looks like this:
ereg_replace("<!DOCTYPE(.*)<ul>", "", $htmlPage);
It works fine. But I noticed that on almost all the tutorial pages I
looked at, they just about always used preg_replace, and not ereg_replace.
It seemed that the main difference was that preg_replace required
forward slashes around the regular expression, like so:
preg_replace("/<!DOCTYPE(.*)<ul>/", "", $htmlPage);
But that didn't work, and returned an error.
Since ereg was working, though, I figured I would just stick with it.
Still, I thought it worth asking:
Is there any reason why either ereg or preg would be more desirable over
the other?
Why does the ereg work for the command above, but preg not?
! in perl regular expressions means "not" so you need to escape it:
\!
pcre expressions are very close to the same as in perl, so you can
easily move the regular expression from one language to the other
(whether that's good or not is another thing). If you have any perl
experience, they are easier to understand. If you don't, they are a
little harder to understand to start off with but are more powerful once
you work them out.
The ereg functions are simpler to use but miss a lot of functionality.
Also according to this page:
http://www.php.net/~derick/meeting-notes.html#move-ereg-to-pecl
ereg will be moved to pecl which means it will be less available (ie
most hosts won't install / enable it).
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
On 04/08/06, Chris <[EMAIL PROTECTED]> wrote:
Dave M G wrote:
> PHP List,
>
> Recently I wrote a piece of code to scrape data from an HTML page.
>
> Part of that code deleted all the unwanted text from the very top of the
> page, where it says "<!DOCTYPE", all the way down to the first instance
> of a "<ul>" tag.
> Is there any reason why either ereg or preg would be more desirable over
> the other?
>
Ereg uses POSIX regular expressions which only work on textual data and
include locale functionalily. preg uses PCRE, which work on binary as well
as textual data and is a more sophisticated regex engine, incorporating
minimal matching, backreferences, inline options, lookahead/lookbehind
assertions, conditional expressions and so on.
They are often faster than the POSIX equivalents also.
--
http://www.web-buddha.co.uk
http://www.projectkarma.co.uk
--- End Message ---
--- Begin Message ---
Chris, Ligaya, Dave,
Thank you for responding. I understand the difference in principle
between ereg and preg much better now.
Chris wrote:
! in perl regular expressions means "not" so you need to escape it:
\!
Still, when including that escape character, the following preg
expression does not find any matching text:
preg_replace("/<\!DOCTYPE(.*)<ul>/", "", $htmlPage);
Whereas this ereg expression does find a match:
ereg_replace("<!DOCTYPE(.*)<ul>", "", $htmlPage);
What do I need to do to make the preg expression succeed just as the
ereg expression does?
Thank you for your time and advice.
--
Dave M G
--- End Message ---
--- Begin Message ---
On 04 August 2006 10:52, Dave M G wrote:
> Chris, Ligaya, Dave,
>
> Thank you for responding. I understand the difference in principle
> between ereg and preg much better now.
>
> Chris wrote:
> > ! in perl regular expressions means "not" so you need to escape it:
> > \!
AFAIR, that's only true in the (?! assertion sequence.
> Still, when including that escape character, the following preg
> expression does not find any matching text:
> preg_replace("/<\!DOCTYPE(.*)<ul>/", "", $htmlPage);
>
> Whereas this ereg expression does find a match:
> ereg_replace("<!DOCTYPE(.*)<ul>", "", $htmlPage);
>
> What do I need to do to make the preg expression succeed just as the
> ereg expression does?
By default, . in preg_* patterns does not match newlines. If you are matching
in a multiline string, use the s modifier to change this:
preg_replace("/<!DOCTYPE(.*)<ul>/s", "", $htmlPage);
You also don't need the parentheses -- these will capture the entire matched
expression for use in backreferences, but as you don't have any it's then
immediately thrown away. So just use:
preg_replace("/<!DOCTYPE.*<ul>/s", "", $htmlPage);
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
To view the terms under which this email is distributed, please go to
http://disclaimer.leedsmet.ac.uk/email.htm
--- End Message ---
--- Begin Message ---
Jochem,
Thank you for responding.
does this one work?:
preg_replace('#^<\!DOCTYPE(.*)<ul[^>]*>#is', '', $htmlPage);
Yes, that works. I don't think I would have every figured that out on my
own - it's certainly much more complicated than the ereg equivalent.
If I may push for just one more example of how to properly use regular
expressions with preg:
It occurs to me that I've been assuming that with regular expressions I
could only remove or change specified text.
What if I wanted to get rid of everything *other* than the specified text?
Can I form an expression that would take $htmlPage and delete everything
*except* text that is between a <li> tag and a <br> tag?
Or is that something that requires much more than a single use of
preg_replace?
--
Dave M G
--- End Message ---
--- Begin Message ---
On 04/08/06, Dave M G <[EMAIL PROTECTED]> wrote:
It seemed that the main difference was that preg_replace required
forward slashes around the regular expression, like so:
preg_replace("/<!DOCTYPE(.*)<ul>/", "", $htmlPage);
It requires delimiters - slashes are conventional, but other
characters can be used.
But that didn't work, and returned an error.
What you've written here shouldn't return you an error - what did the
message say?
I suspect you were trying to match until </ul> rather than <ul> and
the pcre engine thought the forward slash was the end of your regular
expression.
Part of that code deleted all the unwanted text from the very top of the
page, where it says "<!DOCTYPE", all the way down to the first instance
of a "<ul>" tag.
It won't quite do that.
The (.*) matches as much as possible (it's called greedy matching) -
so it'll match and replace all the way down to the *last* instance of
a "<ul>" tag.
To make it match for the shortest length possible, put a question-mark
after the ".*" like so:
preg_replace("/<!DOCTYPE(.*?)<ul>/", "", $htmlPage);
Since ereg was working, though, I figured I would just stick with it.
Still, I thought it worth asking:
Is there any reason why either ereg or preg would be more desirable over
the other?
pcre has a performance advantage, has more features and can use the
many regexps written for perl with few or no changes.
ereg is a posix standard.
-robin
--- End Message ---
--- Begin Message ---
Dave M G wrote:
> Chris, Ligaya, Dave,
>
> Thank you for responding. I understand the difference in principle
> between ereg and preg much better now.
>
> Chris wrote:
>> ! in perl regular expressions means "not" so you need to escape it:
>> \!
> Still, when including that escape character, the following preg
> expression does not find any matching text:
> preg_replace("/<\!DOCTYPE(.*)<ul>/", "", $htmlPage);
does this one work?:
preg_replace('#^<\!DOCTYPE(.*)<ul[^>]*>#is', '', $htmlPage);
>
> Whereas this ereg expression does find a match:
> ereg_replace("<!DOCTYPE(.*)<ul>", "", $htmlPage);
>
> What do I need to do to make the preg expression succeed just as the
> ereg expression does?
>
> Thank you for your time and advice.
>
> --
> Dave M G
>
--- End Message ---
--- Begin Message ---
On 04 August 2006 11:30, Dave M G wrote:
> Jochem,
>
> Thank you for responding.
>
> >
> > does this one work?:
> > preg_replace('#^<\!DOCTYPE(.*)<ul[^>]*>#is', '', $htmlPage);
>
> Yes, that works. I don't think I would have every figured
> that out on my
> own - it's certainly much more complicated than the ereg equivalent.
>
> If I may push for just one more example of how to properly
> use regular
> expressions with preg:
>
> It occurs to me that I've been assuming that with regular expressions
> I could only remove or change specified text.
>
> What if I wanted to get rid of everything *other* than the specified
> text?
>
> Can I form an expression that would take $htmlPage and delete
> everything *except* text that is between a <li> tag and a <br> tag?
That's where capturing expressions and backreferences come in handy:
preg_replace ("/.*<li>(.*)<br>.*/", "$1", $htmlPage);
(add qualifiers and other options to taste, as before!)
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
To view the terms under which this email is distributed, please go to
http://disclaimer.leedsmet.ac.uk/email.htm
--- End Message ---
--- Begin Message ---
Dave M G wrote:
> Jochem,
>
> Thank you for responding.
>
>>
>> does this one work?:
>> preg_replace('#^<\!DOCTYPE(.*)<ul[^>]*>#is', '', $htmlPage);
>
> Yes, that works. I don't think I would have every figured that out on my
> own - it's certainly much more complicated than the ereg equivalent.
1. the '^' at the start of the regexp states 'must match start of the string
(or line in multiline mode)'
2. the 'i' after the the closing regexp delimiter states 'match
case-insensitively'
3. the 's' after the the closing regexp delimiter states 'the dot also matches
newlines'
4. the '<u[^>]*>' matches a UL tag with any number of attributes ... the
'[^>]*' matches a number
of characters that are not a '>' character - the square brackets denote a
character class (in
this cass with just one character in it) and the '^' at the start of the
character class
definition negates the class (i.e. turns the character class definition to mean
every character
*not* defined in the class)
PCRE is alot more powerful [imho], the downside it it has more modifiers
and syntax to control the meaning of the patterns...
read and become familiar with these 2 pages:
http://php.net/manual/en/reference.pcre.pattern.modifiers.php
http://php.net/manual/en/reference.pcre.pattern.syntax.php
and remember that writing patterns is often quite a complex - when you build one
just take i one 'assertion' at a time, ie. build the pattern up step by step...
if you give it a good go and get stuck, then there is always the list.
>
> If I may push for just one more example of how to properly use regular
> expressions with preg:
>
> It occurs to me that I've been assuming that with regular expressions I
> could only remove or change specified text.
essentially regexps are pattern syntax for asserting where something matches
a pattern (or not) - there are various functions that allow you to act upon the
results of the pattern matching depending on your needs (see below)
>
> What if I wanted to get rid of everything *other* than the specified text?
>
> Can I form an expression that would take $htmlPage and delete everything
> *except* text that is between a <li> tag and a <br> tag?
yes but you wouldn't use preg_replace() but rather preg_match() or
preg_match_all()
which gives you back an array (via 3rd/4th[?] reference argument) which contains
the texts that matched (and therefore want to keep).
>
> Or is that something that requires much more than a single use of
> preg_replace?
>
> --
> Dave M G
>
--- End Message ---
--- Begin Message ---
Ford, Mike wrote:
> On 04 August 2006 11:30, Dave M G wrote:
>
>> Jochem,
>>
...
>
> That's where capturing expressions and backreferences come in handy:
>
> preg_replace ("/.*<li>(.*)<br>.*/", "$1", $htmlPage);
>
> (add qualifiers and other options to taste, as before!)
ah yes, good point - you can do it with preg_replace() (I only mentioned
preg_match() (et al) - guess I left my regexp hat at home today. :-)
>
> Cheers!
>
> Mike
>
> ---------------------------------------------------------------------
> Mike Ford, Electronic Information Services Adviser,
> Learning Support Services, Learning & Information Services,
> JG125, James Graham Building, Leeds Metropolitan University,
> Headingley Campus, LEEDS, LS6 3QS, United Kingdom
> Email: [EMAIL PROTECTED]
> Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
>
>
> To view the terms under which this email is distributed, please go to
> http://disclaimer.leedsmet.ac.uk/email.htm
>
--- End Message ---
--- Begin Message ---
Jochem,
Thank you for responding, and for explaining more about regular expressions.
yes but you wouldn't use preg_replace() but rather preg_match() or
preg_match_all()
which gives you back an array (via 3rd/4th[?] reference argument) which contains
the texts that matched (and therefore want to keep).
I looked up preg_match_all() on php.net, and, in combination with what
was said before, came up with this syntax:
preg_match_all( "#^<li[^>]*>(.*)<br[^>]*>#is", $response, $wordList,
PREG_PATTERN_ORDER );
var_dump($wordList);
The idea is to catch all text between <li> and <br> tags.
Unfortunately, the result I get from var_dump is:
array(2) { [0]=> array(0) { } [1]=> array(0) { } }
In other words, it made no matches.
The text being searched is an entire web page which contains the following:
(Please note the following includes utf-8 encoded Japanese text.
Apologies if it comes out as ASCII gibberish)
<FONT color="red">日本語</FONT>は<FONT color="red">簡単</FONT>だよ<br>
<ul><li> 日本語 【にほんご】 (n) Japanese language; (P); EP <br>
<li> 簡単 【かんたん】 (adj-na,n) simple; (P); EP <br>
</ul><p>
So, my preg_match_all search should have found:
日本語 【にほんご】 (n) Japanese language; (P); EP
簡単 【かんたん】 (adj-na,n) simple; (P); EP
I've checked and rechecked my syntax, and I can't see why it would fail.
Have I messed up the regular expression, or the use of preg_match_all?
--
Dave M G
--- End Message ---
--- Begin Message ---
Dave M G wrote:
> Jochem,
>
> Thank you for responding, and for explaining more about regular
> expressions.
>
>> yes but you wouldn't use preg_replace() but rather preg_match() or
>> preg_match_all()
>> which gives you back an array (via 3rd/4th[?] reference argument)
>> which contains
>> the texts that matched (and therefore want to keep).
> I looked up preg_match_all() on php.net, and, in combination with what
> was said before, came up with this syntax:
>
> preg_match_all( "#^<li[^>]*>(.*)<br[^>]*>#is", $response, $wordList,
^--- remove the caret as you dont want to only match when
the line
starts with <li> (the <li> can be anywhere on the line)
I'll assume you also have the mb extension setup.
> PREG_PATTERN_ORDER );
> var_dump($wordList);
>
> The idea is to catch all text between <li> and <br> tags.
>
> Unfortunately, the result I get from var_dump is:
>
> array(2) { [0]=> array(0) { } [1]=> array(0) { } }
>
> In other words, it made no matches.
>
> The text being searched is an entire web page which contains the following:
> (Please note the following includes utf-8 encoded Japanese text.
> Apologies if it comes out as ASCII gibberish)
>
> <FONT color="red">日本語</FONT>は<FONT color="red">簡単</FONT>だよ<br>
> <ul><li> 日本語 【にほんご】 (n) Japanese language; (P); EP <br>
> <li> 簡単 【かんたん】 (adj-na,n) simple; (P); EP <br>
> </ul><p>
>
> So, my preg_match_all search should have found:
>
> 日本語 【にほんご】 (n) Japanese language; (P); EP
> 簡単 【かんたん】 (adj-na,n) simple; (P); EP
>
> I've checked and rechecked my syntax, and I can't see why it would fail.
>
> Have I messed up the regular expression, or the use of preg_match_all?
>
> --
> Dave M G
>
--- End Message ---
--- Begin Message ---
Dave M G wrote:
PHP List,
Recently I wrote a piece of code to scrape data from an HTML page.
Part of that code deleted all the unwanted text from the very top of the
page, where it says "<!DOCTYPE", all the way down to the first instance
of a "<ul>" tag.
That code looks like this:
ereg_replace("<!DOCTYPE(.*)<ul>", "", $htmlPage);
It works fine. But I noticed that on almost all the tutorial pages I
looked at, they just about always used preg_replace, and not ereg_replace.
It seemed that the main difference was that preg_replace required
forward slashes around the regular expression, like so:
preg_replace("/<!DOCTYPE(.*)<ul>/", "", $htmlPage);
But that didn't work, and returned an error.
Since ereg was working, though, I figured I would just stick with it.
Still, I thought it worth asking:
Is there any reason why either ereg or preg would be more desirable over
the other?
Why does the ereg work for the command above, but preg not?
Thank you for any advice.
--
Dave M G
Everybody missed one important difference. The PCRE module is compiled
into PHP by default. The POSIX module is not included by default.
Therefore it's not safe to use the POSIX regular expression module if
you intend to deploy your code on another system.
Regards, Adam.
--- End Message ---
--- Begin Message ---
Dave M G wrote:
PHP List,
Recently I wrote a piece of code to scrape data from an HTML page.
Part of that code deleted all the unwanted text from the very top of the
page, where it says "<!DOCTYPE", all the way down to the first instance
of a "<ul>" tag.
That code looks like this:
ereg_replace("<!DOCTYPE(.*)<ul>", "", $htmlPage);
It works fine. But I noticed that on almost all the tutorial pages I
looked at, they just about always used preg_replace, and not ereg_replace.
It seemed that the main difference was that preg_replace required
forward slashes around the regular expression, like so:
preg_replace("/<!DOCTYPE(.*)<ul>/", "", $htmlPage);
But that didn't work, and returned an error.
Since ereg was working, though, I figured I would just stick with it.
Still, I thought it worth asking:
Is there any reason why either ereg or preg would be more desirable over
the other?
Why does the ereg work for the command above, but preg not?
Thank you for any advice.
--
Dave M G
Everybody missed one important difference. The PCRE module is compiled
into PHP by default. The POSIX module is not included by default.
Therefore it's not safe to use the POSIX regular expression module if
you intend to deploy your code on another system.
Regards, Adam.
--- End Message ---
--- Begin Message ---
Hello.
Since my ISP does not provide the tidy module for Apache, I tested
writing a wrapper script for a locally installed tidy binary. In
general, the script is triggered by a modification to the .htaccess
file like so:
AddHandler server-parsed .php
Action server-parsed /tidy_wrapper.php5
All php pages are by that means "treated" by the script
tidy_wrapper.php5.
Here is the code for tidy_wrapper.php5:
<?php
chdir ( dirname ( $_SERVER['PATH_TRANSLATED'] ) );
ob_start();
include ( $_SERVER['PATH_TRANSLATED'] );
$output = ob_get_contents();
ob_end_clean();
// Including a line with the commend "<!-- NO TIDY !-->" will turn
off tidy conversion
if ( !stristr ( $output, "<!-- NO TIDY !-->" ) ) {
$localfile = tempnam ( '../tmp', "tmp" );
$handle = fopen($localfile, "w");
fwrite($handle, $output);
fclose($handle);
$command = '/Library/WebServer/CGI-Executables/tidy -iq --show-
errors 0 --show-warnings 0 -wrap 100 ' . $localfile . ' 2>&1';
exec ( $command, $output_exec );
echo implode ( "\n", $output_exec );
unlink ( $localfile );
} else {
echo $output;
}
exit;
?>
Although the script is actually working fine, there is at least one
downside: speed. As you can see, the output buffer must be written to
a file in order to be processed by tidy. I was not able to get tidy
to accept a string for processing. Doing so, tidy throws en error. I
have looked through tidy documentation without finding any clues. I
would appreciate any hints. Any ideas for a walk-around for that file
saving-thing would be welcome!
Otherwise, I strongly feel that this script might become/be a
security hole. Because it does not validate the included PHP code, it
could be misused for doing bad stuff, or am I wrong? Once more, any
suggestions are welcome.
regards,
/frank
--- End Message ---
--- Begin Message ---
Good news/kinda' bad news (but not really); I am proud to say that I
have been promoted to Director of IT in my little corner of the world.
This creates an immediate opening for a creative applications developer
with PHP, MySQL, Oracle, the usual web skills/experience in the San
Antonio, Texas area. C++ a definite plus, Unix/Linux too. If your code
samples contain no comments you need not apply. Position requires the
wearing of many hats and the ability to learn and process quickly.
Thanks!
--- End Message ---
--- Begin Message ---
Jay Blanchard wrote:
> Good news/kinda' bad news (but not really); I am proud to say that I
> have been promoted to Director of IT in my little corner of the world.
did they give you some pointy hair to go with that title? ;-)
congrats btw :-)
> This creates an immediate opening for a creative applications developer
> with PHP, MySQL, Oracle, the usual web skills/experience in the San
> Antonio, Texas area. C++ a definite plus, Unix/Linux too. If your code
> samples contain no comments you need not apply. Position requires the
> wearing of many hats and the ability to learn and process quickly.
>
> Thanks!
>
--- End Message ---
--- Begin Message ---
I want to have a regular expression that check the following criteria are
met by $password:
- contains at least 6 characters (any)
- has at least 1 letter
- has at least 1 number
- other 6 characters can be anything...
I'm happy to work out the structure of a postcode etc, but to be honest I'm
still fairly new to working with regular expressions.
What the best/easiest way to check whether a variable contains a range? It
might be RegExp don't do this?
Cheers
Nunners
--- End Message ---
--- Begin Message ---
James Nunnerley wrote:
I want to have a regular expression that check the following criteria are
met by $password:
- contains at least 6 characters (any)
- has at least 1 letter
- has at least 1 number
- other 6 characters can be anything...
I'm happy to work out the structure of a postcode etc, but to be honest I'm
still fairly new to working with regular expressions.
What the best/easiest way to check whether a variable contains a range? It
might be RegExp don't do this?
Cheers
Nunners
It can be done; but, it's simpler to simply to make an if() with
(strlen($password) > 5) && (strlen($password) < max) && pre_match("%[a-z]+%i"%, $password)
&& preg_match("%\d+%", $password)
--- End Message ---
--- Begin Message ---
Al wrote:
James Nunnerley wrote:
I want to have a regular expression that check the following criteria are
met by $password:
- contains at least 6 characters (any)
- has at least 1 letter
- has at least 1 number
- other 6 characters can be anything...
I'm happy to work out the structure of a postcode etc, but to be
honest I'm
still fairly new to working with regular expressions.
What the best/easiest way to check whether a variable contains a
range? It
might be RegExp don't do this?
Cheers
Nunners
It can be done; but, it's simpler to simply to make an if() with
(strlen($password) > 5) && (strlen($password) < max) &&
pre_match("%[a-z]+%i"%, $password) && preg_match("%\d+%", $password)
Some mistakes there:
1) You want to assign strlen to a variable before the if, since you're
calling it twice in the if. I'm not certain how fast strlen is, but it's
usually a bad idea to repeat useless function calls like that.
2) Isn't your second function call supposed to be preg_match, and not
pre_match?
Regards, Adam Zey.
--- End Message ---
--- Begin Message ---
I was wondering how simple it would be to set up a script to provide a
subscribe/unsubscribe form for a list serve. The form would send an email to
the subscribe address or unsubscribe address as selected.
Thanks
David
--- End Message ---
--- Begin Message ---
[snip]
I was wondering how simple it would be to set up a script to provide a
subscribe/unsubscribe form for a list serve. The form would send an
email to
the subscribe address or unsubscribe address as selected.
[/snip]
I wondered about that the other day myself and came to the conclusion
that it would be really simple. It must be, others have done it.
--- End Message ---
--- Begin Message ---
On Friday 04 August 2006 13:27, Jay Blanchard wrote:
> [snip]
> I was wondering how simple it would be to set up a script to provide a
> subscribe/unsubscribe form for a list serve. The form would send an
> email to
> the subscribe address or unsubscribe address as selected.
> [/snip]
>
> I wondered about that the other day myself and came to the conclusion
> that it would be really simple. It must be, others have done it.
Not terribly difficult at all. One SMTP library for PHP and you're away.
--- End Message ---
--- Begin Message ---
In most cases, your PHP build is set up with mail() attached to whatever
SMTP you have on the server.
you would just use the following...
mail($recipientemail,$subject,$message);
On 8/4/06, Duncan Hill <[EMAIL PROTECTED]> wrote:
On Friday 04 August 2006 13:27, Jay Blanchard wrote:
> [snip]
> I was wondering how simple it would be to set up a script to provide a
> subscribe/unsubscribe form for a list serve. The form would send an
> email to
> the subscribe address or unsubscribe address as selected.
> [/snip]
>
> I wondered about that the other day myself and came to the conclusion
> that it would be really simple. It must be, others have done it.
Not terribly difficult at all. One SMTP library for PHP and you're away.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Yes, the list serve software has the opt-in/confirmation stuff covered. I'm
just trying to get the sub/unsub form on the website going.
Thanks
David
On 8/4/06 8:40 AM, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> are you doing your own mailing list management, or using a package that
> includes an explicit subscribe/unsubscribe confirmation capability?
>
> if you're doing your own list management, then you need to design an
> explicit opt-in/-out system. i.e., no e-mail address is added to (or
> removed from) the list until the user has responded to a
> specific/unique/non-guessable confirmation bit that is included in the
> confirming message that is sent to them (or some other form of explicit
> confirmation). doing this isn't that hard, but far more than a simple
> form.
>
> if you're using an existing mailing list management package (that
> includes opt-in/-out confirmation capabilities) and you're simply
> feeding the initial subscribe/unsubscribe request to that facility,
> then this is probably fairly easy.
>
> [it is unwise (and if this is in the US context, be aware of the
> requirements of the can-spam law) to set up a mailing list that does
> not include opt-in/-out confirmation requirements.]
>
> - Rick
>
> ------------ Original Message ------------
>> Date: Friday, August 04, 2006 08:14:58 AM -0400
>> From: David Ellsworth <[EMAIL PROTECTED]>
>> To: php-general@lists.php.net
>> Subject: [PHP] Newbie Form Question
>>
>> I was wondering how simple it would be to set up a script to provide a
>> subscribe/unsubscribe form for a list serve. The form would send an
>> email to the subscribe address or unsubscribe address as selected.
>>
>> Thanks
>>
>> David
>>
--- End Message ---
--- Begin Message ---
what I need is what I would use after the form is submitted - responding to
whether the form sent the value (post likely from a dropdown field) of
"subscribe" or unsubscribe" to the posted page for processing.
On 8/4/06 8:52 AM, "Duncan Hill" <[EMAIL PROTECTED]> wrote:
> On Friday 04 August 2006 13:27, Jay Blanchard wrote:
>> [snip]
>> I was wondering how simple it would be to set up a script to provide a
>> subscribe/unsubscribe form for a list serve. The form would send an
>> email to
>> the subscribe address or unsubscribe address as selected.
>> [/snip]
>>
>> I wondered about that the other day myself and came to the conclusion
>> that it would be really simple. It must be, others have done it.
>
> Not terribly difficult at all. One SMTP library for PHP and you're away.
--- End Message ---
--- Begin Message ---
On 7/31/06, Chris <[EMAIL PROTECTED]> wrote:
BBC wrote:
> Hi list..
>
> Please any one point me to the web which talk about making transaction
with paypal step by step. Some body offered me the source
> code and tutorial but until know he or she didn't send me.
http://www.paypal.com
I'm sure someone here has used / set up paypal but they provide complete
instructions on everything you need to do.
If you have any problems, that's what their support team is for.
--
Postgresql & php tutorials
http://www.designmagick.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Hi,
You can find PHP code examples for paypal integration at
https://www.paypal.com/cgi-bin/webscr?cmd=p/pdn/software_dev_kit_php-outside
--
Shafiq Rehman
Sr. Web Engineer
http://www.phpgurru.com
--- End Message ---
--- Begin Message ---
I have a web server and an images server. My web server doesn't have
enought space for the images, hence the images server. I have to download
properties from a realty database hourly and the data goes in to a db on my
webserver while the image needs to be taken from a MSSQL db and written to
the images server as an actual .jpg or .gif file. Fopen, however, won't let
me write using the http protocol. How can I open and write files between
servers?
Thanks!
--- End Message ---
--- Begin Message ---
blackwater dev wrote:
I have a web server and an images server. My web server doesn't have
enought space for the images, hence the images server. I have to
download
properties from a realty database hourly and the data goes in to a db
on my
webserver while the image needs to be taken from a MSSQL db and
written to
the images server as an actual .jpg or .gif file. Fopen, however,
won't let
me write using the http protocol. How can I open and write files between
servers?
Thanks!
Couple of options come to mind, and I'm sure there are many others...
Option 1: nfs mount / share your partition drive(s) on your web server.
Option 2: Write the files out locally and then have a backend process
that moves them to the image server.
--- End Message ---
--- Begin Message ---
On Friday 04 August 2006 15:50, blackwater dev wrote:
> I have a web server and an images server. My web server doesn't have
> enought space for the images, hence the images server. I have to download
> properties from a realty database hourly and the data goes in to a db on my
> webserver while the image needs to be taken from a MSSQL db and written to
> the images server as an actual .jpg or .gif file. Fopen, however, won't
> let me write using the http protocol. How can I open and write files
NFS/CIFS mount?
Write locally, scripted FTP across?
Write locally, scripted rsync across?
--- End Message ---
--- Begin Message ---
On Fri, 2006-08-04 at 10:50 -0400, blackwater dev wrote:
> Fopen, however, won't let
> me write using the http protocol. How can I open and write files between
> servers?
This scenario would be one of the times that I would use LOB's for the
image data. That way you could simply drop in another SQL server when
you start running out of space with 0 downtime.
That being said, why not try a SOAP webservice or a FTP PUT?
We use SOAP where there are no FP servers, and on the local network it
does well with 100MB+ files. I think also fopen and fput do remote
connections, but I may be wrong there.
--Paul
All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm
--- End Message ---
--- Begin Message ---
On Fri, 2006-08-04 at 10:50 -0400, blackwater dev wrote:
> I have a web server and an images server. My web server doesn't have
> enought space for the images, hence the images server. I have to download
> properties from a realty database hourly and the data goes in to a db on my
> webserver while the image needs to be taken from a MSSQL db and written to
> the images server as an actual .jpg or .gif file. Fopen, however, won't let
> me write using the http protocol. How can I open and write files between
> servers?
You mean the http protocol won't let you write. At any rate, you can try
using ftp instead of http (you'll need to make sure it's set up on the
images server). Alternatively you can use a network file system or use
CURL or low level sockets to POST them to your images server.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
On Friday 04 August 2006 10:07, Robert Cummings wrote:
> You mean the http protocol won't let you write. At any rate, you can try
> using ftp instead of http (you'll need to make sure it's set up on the
> images server). Alternatively you can use a network file system or use
> CURL or low level sockets to POST them to your images server.
>
That's what I was thinking if you wanted to keep it all HTTP. You could have
an script on the images server that you submit the file to through a POST.
Then the script would move it to the appropriate place. Remember to keep
security in mind though.
--
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099
--- End Message ---
--- Begin Message ---
Hi all,
I need to get local user IP, but server with apache and php is in
another subnetwork.
So from server environment I can get only router's IP.
The only solution that I see - is getting with some magic algorithm
local IP from brouser and sending it to server.
My application is for intranet, so I don't see any reason to make users
authorization.
Any ideas for this?
thanks beforehand
--- End Message ---
--- Begin Message ---
Andrew Senyshyn wrote:
> Hi all,
>
> I need to get local user IP, but server with apache and php is in
> another subnetwork.
> So from server environment I can get only router's IP.
> The only solution that I see - is getting with some magic algorithm
> local IP from brouser and sending it to server.
> My application is for intranet, so I don't see any reason to make users
> authorization.
> Any ideas for this?
you can't always get the real users IP because of proxies, anonimizers,
firewalls/gateways
[on the user end] (and don't bother using an IP as an absolute indicator when
validating a
session - you can use it as one of a number of metrics - for instance AOL users
have their
IP addresses changed roughly every 300 milliseconds).
nonetheless here are a couple of funcs that might help you (at least to
understand
what is possible it terms of trying to determine a users IP):
/* Determine if an ip is in a net.
* E.G. 120.120.120.120 in 120.120.0.0/16
*/
function isIPInSubnet($ip, $net, $mask)
{
$firstpart = substr(str_pad(decbin(ip2long($net)), 32, "0", STR_PAD_LEFT)
,0 , $mask);
$firstip = substr(str_pad(decbin(ip2long($ip)), 32, "0", STR_PAD_LEFT),
0, $mask);
return (strcmp($firstpart, $firstip) == 0);
}
/* This function check if a ip is in an array of nets (ip and mask) */
function isPrivateIP($theip)
{
foreach (array("10.0.0.0/8",
"172.16.0.0/12",
"192.168.0.0/16") as $subnet)
{
list($net, $mask) = explode('/', $subnet);
if(isIPInSubnet($theip,$net,$mask)) {
return true;
}
}
return false;
}
/* Building the ip array with the HTTP_X_FORWARDED_FOR and REMOTE_ADDR HTTP
vars.
* With this function we get an array where first are the ip's listed in
* HTTP_X_FORWARDED_FOR and the last ip is the REMOTE_ADDR
*/
function getRequestIPs()
{
$ipList = array();
foreach (array('HTTP_X_FORWARDED_FOR', 'HTTP_FORWARDED_FOR', 'REMOTE_ADDR')
as $key) {
if (isset($_SERVER[$key]) && $_SERVER[$key]) {
$ipList = array_merge($ipList, explode(',', $_SERVER[$key]));
break;
}
}
return $ipList;
}
/* try hard to determine whAt the users/clients public IP address is */
function getRequestIP($allowPrivIPs = false)
{
foreach (getRequestIPs() as $ip) {
if($ip && ($allowPrivIPs === true || !isPrivateIP($ip))) {
return $ip;
}
}
return 'unknown';
}
> thanks beforehand
>
--- End Message ---
--- Begin Message ---
Jochem Maas wrote:
Andrew Senyshyn wrote:
Hi all,
I need to get local user IP, but server with apache and php is in
another subnetwork.
So from server environment I can get only router's IP.
The only solution that I see - is getting with some magic algorithm
local IP from brouser and sending it to server.
My application is for intranet, so I don't see any reason to make users
authorization.
Any ideas for this?
you can't always get the real users IP because of proxies, anonimizers,
firewalls/gateways
[on the user end] (and don't bother using an IP as an absolute indicator when
validating a
Wait, are you telling me that I can't auth my customers based on IP
alone? Great, now how do I let them view their sensitive data? ;)
session - you can use it as one of a number of metrics - for instance AOL users
have their
IP addresses changed roughly every 300 milliseconds).
Gawd, AOL causes us so many headaches with that crap.
--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]
--- End Message ---