php-general Digest 4 Feb 2006 12:56:13 -0000 Issue 3944
Topics (messages 229858 through 229870):
Re: Truncate words in multiple paragraphs
229858 by: php-mail
Re: Passing Credentials
229859 by: Richard Lynch
Re: Till Drawers
229860 by: Kevin Waterson
Re: Other than default grey button
229861 by: Richard Lynch
Re: Regular expression
229862 by: Richard Lynch
229863 by: php-mail
Re: pcntl_fork?
229864 by: Richard Lynch
Re: [Off] Cheap SSL certificates?
229865 by: Kevin McBride
229868 by: Rory Browne
229869 by: Kevin McBride
229870 by: John Nichel
REGEX query
229866 by: phplists
229867 by: David Tulloh
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 ---
Nuts
Missed the need to preserve line breaks
Sorry
Dan
-----Original Message-----
From: tedd [mailto:[EMAIL PROTECTED]
Sent: 03 February 2006 23:06
To: php-general@lists.php.net
Subject: Re: [PHP] Truncate words in multiple paragraphs
>Hi :)
>
>I am using the following function (that I found in the user comments
>on php.net manual) for trimming the number of words accepted via a
>form field
>
>// Truncation is by word limit, not character limit. So if you limit
>// to 255, then it will cut off a text item to 255 words, not 255
characters
>function trim_text ($string, $truncation=250) {
> $string = preg_split("/\s+/",$string,($truncation+1));
> unset($string[(sizeof($string)-1)]);
> return implode(' ',$string);
>}
>
>This works well, except it is also removing any line breaks. For
instance...
>
>-snip-
>
>I'd like to (need to) retain the line breaks. Any suggestions?
>
>Thanks,
>verdon
verdon:
I had the same problem and fixed it with this:
// remove all linefeeds and replace with new paragraph
$pattern = "\n";
$replace = "</p><p>";
$des = eregi_replace($pattern, $replace, $des);
Then in your html, use:
<p><?php echo($des); ?></p>
Worked for me.
tedd
--
----------------------------------------------------------------------------
----
http://sperling.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
__________ NOD32 1.1393 (20060203) Information __________
This message was checked by NOD32 antivirus system.
http://www.eset.com
--- End Message ---
--- Begin Message ---
On Mon, January 30, 2006 12:43 pm, News1 wrote:
> I would prefer to have to log into my server and from there have these
> credentials passed along to the web cameras.
http://php.net/curl
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
This one time, at band camp, Oli Howson <[EMAIL PROTECTED]> wrote:
> I'm interested in the possibility of connecting a computer running A
> PHP server to a till drawer and have the server able to open the
> drawer. Anyone know how this would work?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
I simple wrote a small C program that basically sent a bell, 0x07
and it opened my cash drawer. In php I just did system('bell'); and
it worked fine.
Kevin
--
"Democracy is two wolves and a lamb voting on what to have for lunch.
Liberty is a well-armed lamb contesting the vote."
--- End Message ---
--- Begin Message ---
Use a TYPE="IMAGE" but have the SRC="../images/button.php?text=Move"
Then have PHP generate the button to have whatever text comes in from
$_GET['text']
http://php.net/gd
On Mon, January 30, 2006 8:11 am, Jevos, Peter wrote:
>
> Hi all
>
> I'd like to ask you one ( probably ) simple question. I'm using
> webmail
> and I want to use other than default php grey button.
> I found on the pages how to use image instead of the default button.
> So
> I changed
>
> INPUT TYPE="submit" NAME="move_button" VALUE="Move"
>
> to
>
> INPUT TYPE="image'" NAME="move_button" VALUE="Move"
> SRC="../images/button.jpg" width="19" height="50"
>
> It works but I found the other important problem. This is image. What
> happend when I change the language ? Nothing cause this is permanent
> image and text "Move" is replaced by image
>
> So what should I do to change design of the button without using image
> ?
>
> Thanks a lot for an answers
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
$last_comma = strrpos($string, ",");
$string = substr($string, 0, $last_comma) . ' and ' . substr($string,
$last_comma);
I probably have a one-off error in there somewhere, or swapped the
order of args in strrpos, but you get the idea.
http://php.net/strrpos
On Mon, January 30, 2006 8:09 am, Barry wrote:
> Simple reg help please
>
> i want to match the last "," in "a,b,c,d" and replace it with " and "
>
> i tried ereg_replace(",([a-zA-z])*$"," and ",$string);
>
> but i forgot how to add the "d" which is also matched now back to the
> " and "
>
> Can you give any good reg_exp sites where to learn it?
> Its long ago since i used reg exp and i lost the hang of it... :(
>
> btw. any sites that have reg_exp that works witht PHP would be fine.
> i know http://www.regular-expressions.info/tutorial.html
> But that examples dont work with preg_match and ereg.
>
> Thanks ^_^
>
> --
> Smileys rule (cX.x)C --o(^_^o)
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
Ok I may actually have an answer here...
<?
$str = 'hubble, bubble, toil, trouble';
function andificate($str)
{
return preg_replace('/([\s]?,[\s]?)(\w+)$/', ' and \\2', $str);
}
echo andificate($str);
?>
Gives:
hubble, bubble, toil and trouble
Accepts spaces before and/or after commas or neither... preserves spaces
Hope this one works (and that I've read the post right :-/)
Dan
--
-----Original Message-----
From: Richard Lynch [mailto:[EMAIL PROTECTED]
Sent: 03 February 2006 23:34
To: Barry
Cc: php-general@lists.php.net
Subject: Re: [PHP] Regular expression
$last_comma = strrpos($string, ",");
$string = substr($string, 0, $last_comma) . ' and ' . substr($string,
$last_comma);
I probably have a one-off error in there somewhere, or swapped the
order of args in strrpos, but you get the idea.
http://php.net/strrpos
On Mon, January 30, 2006 8:09 am, Barry wrote:
> Simple reg help please
>
> i want to match the last "," in "a,b,c,d" and replace it with " and "
>
> i tried ereg_replace(",([a-zA-z])*$"," and ",$string);
>
> but i forgot how to add the "d" which is also matched now back to the
> " and "
>
> Can you give any good reg_exp sites where to learn it?
> Its long ago since i used reg exp and i lost the hang of it... :(
>
> btw. any sites that have reg_exp that works witht PHP would be fine.
> i know http://www.regular-expressions.info/tutorial.html
> But that examples dont work with preg_match and ereg.
>
> Thanks ^_^
>
> --
> Smileys rule (cX.x)C --o(^_^o)
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Like Music?
http://l-i-e.com/artists.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
__________ NOD32 1.1393 (20060203) Information __________
This message was checked by NOD32 antivirus system.
http://www.eset.com
--- End Message ---
--- Begin Message ---
On Mon, January 30, 2006 5:33 am, Peter Hoskin wrote:
> I have written a script to parse a large amount of XML data and insert
> it into SQL... deals with approx 80,000 rows each time I run it. I
> cannot successfully complete this script without running out of
> memory.
> Is pcntl_fork suitable to overcome this?
Probably not...
> I have been playing with pcntl_fork and became completely stuck trying
> to select data from a database and spawn a new fork for each row.
> Later
> I'll have to use something like shmop so each child knows what row its
> working on, and will do a series of xml parsing based on supplied
> data..
> a simple example of forking with a foreach this way would be
> appreciated
Woof. A new process getting forked for each row is going to swamp
your machine with processes very very very rapidly...
First, though, are you running this from the command line CLI interface?
Just supply a custom php.ini with "memory_limit = 16M" or whatever it
takes to get the job done and call it quits.
If you're trying to run pctl_fork from a web application, you're
doomed anyway -- It's not suitable in that environment.
You probably could re-write the script to not need so much RAM, by
using fopen/fgets to read one LINE at a time, and deal with it, and
then move on to the next line.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
And in the real world, where browsers just blindly chase down CAs and
the basic Security Model is "you pay us $200, and we make sure you
are who you say you are, and then we trust you" what real difference
does it make?
Users can remove untrustworthy CA certs from their browsers.
There are certainly a zillion sites *I* do not trust that have
high-priced CA-certified SSL certs...
And Joe Sixpack and Betty Buick just look for the little lock symbol
to be closed, and guage trustworthiness only on there being no popups
warning them it's not secure, and that the site "looks" professional,
and a "brand-name" on the logo/domain.
That's why there are organizations like WebTrust - to perform audits as
to how personal data is used.
So, why exactly would I pay for a $200 background check on myself,
when I already trust myself? Why not pay $70 for an SSL with no
background check on myself, so long as it makes Joe Sixpack and Betty
Buick happy, if it's got 99% ubiquity?
As I said above, users may delete the CA cert from their browser. This
means that the CA you pay $70 to would not be trusted - period. One
day, many users will know the fact that the certificate should be
checked before sensitive information is sent through the SSL connection.
I'm often curious why exactly people think the SSL / CA system is so
great, when it seems a whole lot like the Emporer's Clothes to me, or
some kind of weird Ponzi scheme to line the pockets of a handful of
companies, with very very very little added-value to the end user.
It appears that you never applied for a certificate before, or applied
for certs from CAs that don't verify information. Identification is
extremerly important when it comes to knowing whether or not to trust
the given public key.
I am not trying to humiliate you, but you may want to study about
cryptography and its use for the internet. I operate my own
web/e-mail server (and have been doing so for some time), and so, I know
how important it is to make sure a trustworthy CA signs a public key.
Cheers,
- KJM
--- End Message ---
--- Begin Message ---
> It appears that you never applied for a certificate before, or applied
> for certs from CAs that don't verify information. Identification is
> extremerly important when it comes to knowing whether or not to trust
> the given public key.
Repeating your point doesn't make it more valid. I'm not trying to
humilate you, but Richard discredited what you said, by saying that
99% of visitors don't check who the cert is issued by anyway.
> I am not trying to humiliate you, but you may want to study about
> cryptography and its use for the internet. I operate my own
> web/e-mail server (and have been doing so for some time), and so, I know
> how important it is to make sure a trustworthy CA signs a public key.
You know how important it is to *YOU* how important a trustworthy CA
is. You don't seem to know how important it is to anyone else. Granted
people *should* ( if they're worried about their encrypted information
falling into the wrong hands ) check who certs are issued by, but
personally I don't care enough about my webmail password to sift
through my pre-installed CA list, and determine which CA's I do, or do
not trust.
> I operate my own web/e-mail server
No offense, but so what? Do you think that makes you different from
most people here, many of whom administrate web, email, database, dns,
etc? You're on a technical list, and people who admin servers are the
norm rather than the exeception. I'm sorry if that seems a bit blunt,
but I thought the last reply was a bit arrogant.
--- End Message ---
--- Begin Message ---
Rory Browne wrote:
>>I operate my own web/e-mail server
No offense, but so what? Do you think that makes you different from
most people here, many of whom administrate web, email, database,
dns, etc? You're on a technical list, and people who admin servers
are the norm rather than the exeception. I'm sorry if that seems a
bit blunt, but I thought the last reply was a bit arrogant.
My last response was an attempt to be informative on the basis of my
experience with digital certificates. I do understand that discrediting
comments will be posted against me, and that I have a privilege to reply
back to the comments. So, I replied back on Richard's message to say
why I thought he was wrong, itemizing points just like you did.
Regarding this SSL thread, my main point was: have your public key
signed by the right CA. Doing so prepares the web server for the
possible day when users finally decide to trust only certificates issued
by a CA that does go through verification procedures.
If one wants to believe my comments, that's fine. If one does not want
to believe my comments, that's fine too. I learn from all comments just
like everyone else does, and I understand that sometimes, I am wrong. :)
- KJM
--- End Message ---
--- Begin Message ---
> Richard Lynch wrote:
>> And in the real world, where browsers just blindly chase down CAs and
>> the basic Security Model is "you pay us $200, and we make sure you
>> are who you say you are, and then we trust you" what real difference
>> does it make?
>
> Users can remove untrustworthy CA certs from their browsers.
>
>> There are certainly a zillion sites *I* do not trust that have
>> high-priced CA-certified SSL certs...
>>
>> And Joe Sixpack and Betty Buick just look for the little lock symbol
>> to be closed, and guage trustworthiness only on there being no popups
>> warning them it's not secure, and that the site "looks" professional,
>> and a "brand-name" on the logo/domain.
>
> That's why there are organizations like WebTrust - to perform audits as
> to how personal data is used.
>
>> So, why exactly would I pay for a $200 background check on myself,
>> when I already trust myself? Why not pay $70 for an SSL with no
>> background check on myself, so long as it makes Joe Sixpack and Betty
>> Buick happy, if it's got 99% ubiquity?
>
> As I said above, users may delete the CA cert from their browser. This
> means that the CA you pay $70 to would not be trusted - period. One
> day, many users will know the fact that the certificate should be
> checked before sensitive information is sent through the SSL connection.
>
>> I'm often curious why exactly people think the SSL / CA system is so
>> great, when it seems a whole lot like the Emporer's Clothes to me, or
>> some kind of weird Ponzi scheme to line the pockets of a handful of
>> companies, with very very very little added-value to the end user.
>
> It appears that you never applied for a certificate before, or applied
> for certs from CAs that don't verify information. Identification is
> extremerly important when it comes to knowing whether or not to trust
> the given public key.
I appears that you haven't been around here long.
> I am not trying to humiliate you, but you may want to study about
> cryptography and its use for the internet. I operate my own
> web/e-mail server (and have been doing so for some time), and so, I know
> how important it is to make sure a trustworthy CA signs a public key.
Ohhhh, your own web and email server? Okay, show of hands; how many
people on this list *do not* run their own servers?
--
John C. Nichel IV
Programmer/System Admin
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Hi,
I'm still trying to get to grips with REGEX and have hit a hurdle with
the following:
I have this bit of text:
(\(EX\) RV-6 )
I want to remove the '\(EX\)' part of it
so leaving just: ( RV-6 )
Any suggestions would be most appreciated.
Thanks
Alexis
--- End Message ---
--- Begin Message ---
I assume that the text inside can change around a fair bit. If the
string is of a fixed with or simple format you can just use substr() and
friends, it's simpler and faster.
That said, there is really two approaches that I can see with this string.
You can match on the spaces to extract the 'RV-6', something like
'/\s\S+\s/' should do the trick, that pulls out some non-whitespace
characters from between two whitespace characters, including the
whitespace characters. Then just add the () on again afterwards.
The other approach would be to use preg_replace to get rid of the \(EX\)
portion by replacing it with an empty string. Personally I would
probably use the first technique as I generally don't like using replace
functions in this way. A pattern which should match is '/\\\(.*?\)\\/',
the mess of \ is because \ ( and ) all need to be escaped with a \.
David
phplists wrote:
> Hi,
>
> I'm still trying to get to grips with REGEX and have hit a hurdle with
> the following:
>
> I have this bit of text:
> (\(EX\) RV-6 )
>
> I want to remove the '\(EX\)' part of it
> so leaving just: ( RV-6 )
>
> Any suggestions would be most appreciated.
>
> Thanks
> Alexis
>
--- End Message ---