|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 7 Jun 2006 05:14:19 -0000 Issue 4171
php-general-digest-help
lists.php.net
Date: Wed Jun 07 2006 - 00:14:19 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 7 Jun 2006 05:14:19 -0000 Issue 4171
Topics (messages 237466 through 237529):
1,600,000 ÃÒª×èÍÍÕàÁÅì ¤Ñ´ÊÃÃàÃÕ§ÅӴѺÍÑ¡ÉÃÊдǡÊÓËÃѺ¢ÂÒ¸ØÃ¡Ô¨¢Í§·èÒ¹ ¾ÃéÍÁ·Ñé§á¶Áâ»Ãá¡ÃÁ·Ñ¹ÊÁѨҡµèÒ§»ÃÐà·ÈÍÕ¡ËÅÒÂÍÂèÒ§ ÃÒ¤Ò¶Ù¡ÁÒ¡ËÒäÁèä´éÍÕ¡áÅéÇ ¨Ó˹èÒ¨ӹǹ¨Ó¡Ñ´
237466 by: 1,600,000 ÃÒª×èÍÍÕàÁÅì ¤Ñ´ÊÃÃàÃÕ§ÅӴѺÍÑ¡ÉÃÊдǡÊÓËÃѺ¢ÂÒ¸ØÃ¡Ô¨¢Í§·èÒ¹ ¾ÃéÍÁ·Ñé§á¶Áâ»Ãá¡ÃÁ·Ñ¹ÊÁѨҡµèÒ§»ÃÐà·ÈÍÕ¡ËÅÒÂÍÂèÒ§ ÃÒ¤Ò¶Ù¡ÁÒ¡ËÒäÁèä´éÍÕ¡áÅéÇ ¨Ó˹èÒ¨ӹǹ¨Ó¡Ñ´
Re: When is "z" != "z" ?
237467 by: tedd
237468 by: Martin Alterisio
237469 by: Adam Zey
237471 by: Robert Cummings
237472 by: Robert Cummings
237473 by: Paul Novitski
237474 by: tedd
237477 by: Martin Alterisio
237480 by: tedd
237482 by: Martin Alterisio
237483 by: Robert Cummings
237484 by: John Nichel
237487 by: Martin Alterisio
237490 by: tedd
237492 by: Robert Cummings
237496 by: Martin Alterisio
237499 by: Robert Cummings
237521 by: Richard Lynch
237526 by: Rasmus Lerdorf
237527 by: Robert Cummings
Getting totals
237470 by: Rob W.
237476 by: Jochem Maas
237486 by: Rob W.
237489 by: Rabin Vincent
237518 by: Richard Lynch
237519 by: Rafael
237523 by: Rob W.
237524 by: Rob W.
237525 by: Paul Novitski
237528 by: Rabin Vincent
237529 by: Rob W.
Weird Safari Stalling Issues Sessions?
237475 by: Paul Nowosielski
237485 by: tedd
237494 by: Jochem Maas
237510 by: Paul Nowosielski
237517 by: Richard Lynch
Controlling DomDocument's load and loadHTMLFile Request
237478 by: Shu Chow
237479 by: Shu Chow
237481 by: Jochem Maas
237502 by: Rasmus Lerdorf
237504 by: Jochem Maas
237516 by: Richard Lynch
Re: Cannot read variables
237488 by: Jochem Maas
237522 by: Richard Lynch
Sessions
237491 by: Oliver Block
237493 by: Jay Blanchard
237497 by: Oliver Block
237515 by: Richard Lynch
Re: How do I make a HTML tree for a set of nodes?
237495 by: Jochem Maas
Control GET data
237498 by: Steffen Mazanek
237500 by: John Nichel
237501 by: Brad Bonkoski
237509 by: tedd
237512 by: Richard Lynch
starting shell script on server: defer acces when running
237503 by: Roel Dillen
237505 by: Jochem Maas
237514 by: Richard Lynch
Re: [BULK] Re: [PHP] Controlling DomDocument's load and loadHTMLFile Request
237506 by: Shu Chow
Re: .htaccess - change index.php to index.abc
237507 by: Jochem Maas
237513 by: Richard Lynch
Replacing text of a DOM text node
237508 by: Frank Arensmeier
237511 by: Jochem Maas
Re: Pear DB and memcached
237520 by: Richard Lynch
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
1,600,000 ÃÒª×èÍÍÕàÁÅì ¤Ñ´ÊÃÃàÃÕ§ÅӴѺÍÑ¡ÉÃÊдǡÊÓËÃѺ¢ÂÒ¸ØÃ¡Ô¨¢Í§·èÒ¹ ¾ÃéÍÁ·Ñé§á¶Áâ»Ãá¡ÃÁ·Ñ¹ÊÁѨҡµèÒ§»ÃÐà·ÈÍÕ¡ËÅÒÂÍÂèÒ§ ÃÒ¤Ò¶Ù¡ÁÒ¡ËÒäÁèä´éÍÕ¡áÅéÇ ¨Ó˹èÒ¨ӹǹ¨Ó¡Ñ´
µÔ´¨ÃÇ´ãËé¸ØÃ¡Ô¨¢Í§·èÒ¹´éÇ¡ÒûÃЪÒÊÑÁ¾Ñ¹¸ì¸ØÃ¡Ô¨·Ò§ÍÕàÁÅì
â´Âµé¹·Ø¹·ÕèµèÓáÅмŵͺÃѺ·Õè´Õ·ÕèÊØ´
´éÇÂÍÕàÁÅì 1.6 ÅéÒ¹àÁÅì
á¶Áâ»Ãá¡ÃÁ
- Êè§àÁÅì¤Ø³ÀÒ¾ÊÙ§¨Ò¡µèÒ§»ÃÐà·È µÑÇàµçÁãªé§Ò¹ä´éµÅÍ´
- â»Ãá¡ÃÁ´Ù´àÁÅì¤Ø³ÀÒ¾ÊÙ§¨Ò¡µèÒ§»ÃÐà·È µÑÇàµçÁãªé§Ò¹ä´éµÅÍ´
- µÑÇ¡ÃͧÍÕàÁÅì ¤Ø³ÀÒ¾ÊÙ§¨Ò¡µèÒ§»ÃÐà·È µÑÇàµçÁãªé§Ò¹ä´éµÅÍ´
ÇÔ¸Õ¡ÒèѴÊè§ÊÔ¹¤éÒ Êè§ EMS ·èÒ¹¨Ðä´éÃѺÊÔ¹¤éÒÀÒÂã¹ 1-2 Çѹ
ËÃ×Í ´ÒǹìâËÅ´ÀÒÂã¹ 1-2 ª.Á. ãªéä´éàÅÂ
ÃÒ¤Ò 790 ºÒ·
ʹã¨â·Ã 06-7815050
ÍÕàÁÅì pkhotboom
yahoo.com
attached mail follows:
Rasmus:
At 6:54 PM -0700 6/5/06, Rasmus Lerdorf wrote:
>tedd wrote:
>>For example, the Unicode issue was raised during this discussion -- if php doesn't consider the numeric relationship of characters, then I see a big problem waiting in the wings. Because if we're having these types of discussions with just considering 00-7F characters, then I can only guess at what's going to happen when we start considering 000000-FFFFFF code-points.
>>
>>Now, was that enough said? :-)
>
>I don't think you really understand this. < and > are collation operators when they operate on strings. They have absolutely nothing to do with the numeric values of the characters.
What's to understand? It's the pecking order of strings -- it's the system of how one sorts strings. It's the way I tried to order my books in college. We've been doing it all our life and now you think I don't understand how to sort stuff? It's not the "white and colored" clothes thing my wife keeps talking about, is it?
Look, I understand collation. I also understand that collation is different for different languages and for different needs. In some cases, greatly different.
The point of this discussion was how php collates/sorts or otherwise orders characters/strings when given the operation to increment from "a" to "z".
As this thread has demonstrated, there's a wide range of expectations as to how that should happen.
The reference you provided touches upon some of the problems that collation faces when trying to develop collation systems for different needs. This discussion was no different.
>It just so happens that in English iso-8859-1 there is a 1:1 relationship between the numeric values and the collation order, but you can think of that as dumb luck.
No, English iso-8859-1 was designed to conform to the ASCII standard-- the same as Unicode and other standards that followed. It's not dumb luck to make "standards" backward compatible, it's by good design.
Considering that you're dealing with English iso-8895 and ASCII (developed by "American" Standard Code), then I think the connection between numeric values and collation went hand-in-hand by design. It was not by accident.
It's just too bad that the "powers-the-be" at the time didn't realize that 7-bit wouldn't cover everything to come in the near future.
>To better understand this, I suggest you start reading here:
>
> http://icu.sourceforge.net/userguide/Collate_Intro.html
>
>Note one of the points on that page. That in Lithuanian 'y' falls between 'i' and 'k'. So even without going into Unicode and just using low-ascii, you have these issues.
I don't have these issues because I'm not Lithuanian. If a Lithuanian php programmer wants "y" to fall between "i" and "k" in a loop, then good luck -- for I can't get it to stop when it passes "z" -- which I think it should.
But, as I am aware, there is no low-ASCII, there is no high-ASCII, there is simply ASCII. While it is common to use the term of extended-ASCII, it's a misnomer because American Standards Association had nothing to do with establishing/defining any character above DEC 126.
The above example you referenced is simply one of many and demonstrates that the "collation" problem is very complex. You should look into how Unicode performs canonical ordering in combining characters such as using an accent, umlaut, or cedilla as well as how that combination affects collation in different languages as stated in your reference. You will see that canonical ordering algorithm is numeric.
Yes, I'm very aware of Unicode. I'm aware enough to know that they have assigned numerical equivalents to every glyph known to man including those combining glyphs such as those mentioned above to produce combination characters. When I say every "glyph known to man", that includes much more than language specific glyphs.
I'm also aware of IDNS and how they implement Unicode, which is not inclusive. Take for example case mapping which IDNS simply translates all of what they perceive to be uppercase to lowercase. Some characters are combination characters when lowercase and a single character when uppercase, thus there is no lowercase representation for the uppercase character. Oops, I just lost the 16th century (Roller Ball).
Now, I can appreciate the problems facing php considering that it has to deal with not only Unicode, but with also with the IDNS when addressing Unicode and the Internet. But that problem is not going to be solved by ignoring that Unicode code-points have numeric (and other) values. I would think that serious collation systems use numeric values in some fashion in their algorithms -- don't they? If not, please explain how they detect differences between characters and group them into collation tables.
>Now, until we get to PHP 6, we don't have decent Unicode support and we don't have LOCALE-aware operators. You will have to manually use strcoll() to get them, but that is going to change and you will have the ICU collation algorithms available and for Unicode strings it will be automatic. You can still have binary-strings if you don't want locale-aware collation, of course.
Well, good luck with that.
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
2006/6/6, Robert Cummings <robert
interjinn.com>:
>
> On Tue, 2006-06-06 at 09:46, Martin Alterisio wrote:
> > 2006/6/6, Robert Cummings <robert
interjinn.com>:
> >
> > > In C++ they do leave it to the coder, and well, we all know what a
> mess
> > > it can be deciphering overloaded operators in C++ (or maybe we ALL
> > > don't). At any rate, the PHP overlords made a choice, and IMHO the
> best
> > > choice. For such a fringe issue I don't see what the argument is all
> > > about. If you want the functionality you get in C by incrementing a
> > > char, then use the chr() function on an integer.
> > >
> > >
> > You're right about ++ operator not to be considered a math operator, my
> > mistake. What I should have said is that the usual connotation and
> expected
> > behaviour of ++ and the comparison operators is to give iteration
> > capabilities to a certain data type, as used in a for statement. For
> that to
> > happen certain constrains must be true for these operators, one of them
> > being: any < ++any, which is not true for the way these operators behave
> in
> > php.
>
> You must have missed this post:
>
> http://marc.theaimsgroup.com/?l=php-general&m=114945456908350&w=2
>
>
Yes, I haven't read that post. That algorithm has an error, an overflow on a
signed char, and that's implementation issue not a design issue.
PS: It's a little bit rude to say "you *must* have missed" but I understand
that it wasn't your intention.
attached mail follows:
tedd wrote:
> for I can't get it to stop when it passes "z" -- which I think it should.
But, people have posted code solutions for you to do exactly what you
want. So have I. Here it is again:
foreach (range('a', 'z') as $char)
{
echo $char;
}
I don't mean to sound harsh, but why are you still complaining about it?
You've been shown to do exactly what you want, why is it still a problem?
Heck, if you still really want to do < and > with strings, you can
easily write your own functions to compare two strings using your own
requirements.
Regards, Adam Zey.
attached mail follows:
On Tue, 2006-06-06 at 13:05, tedd wrote:
>
> I don't have these issues because I'm not Lithuanian. If a Lithuanian php
> programmer wants "y" to fall between "i" and "k" in a loop, then good
> luck -- for I can't get it to stop when it passes "z" -- which I think
> it should.
This isbecause you're using the wrong tool for the job. Don't blame the
tool, blame the user of the tool. if you want to loop from 'a' to 'z'
then use chr() and ord().
<?php
for( $i = ord( 'a' ); $i <= ord( 'z' ); $i++ )
{
echo "Nuff said!\n";
}
?>
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. |
`------------------------------------------------------------'
attached mail follows:
On Tue, 2006-06-06 at 13:11, Martin Alterisio wrote:
> 2006/6/6, Robert Cummings <robert
interjinn.com>:
> >
> > On Tue, 2006-06-06 at 09:46, Martin Alterisio wrote:
> > > 2006/6/6, Robert Cummings <robert
interjinn.com>:
> > >
> > > > In C++ they do leave it to the coder, and well, we all know what a
> > mess
> > > > it can be deciphering overloaded operators in C++ (or maybe we ALL
> > > > don't). At any rate, the PHP overlords made a choice, and IMHO the
> > best
> > > > choice. For such a fringe issue I don't see what the argument is all
> > > > about. If you want the functionality you get in C by incrementing a
> > > > char, then use the chr() function on an integer.
> > > >
> > > >
> > > You're right about ++ operator not to be considered a math operator, my
> > > mistake. What I should have said is that the usual connotation and
> > expected
> > > behaviour of ++ and the comparison operators is to give iteration
> > > capabilities to a certain data type, as used in a for statement. For
> > that to
> > > happen certain constrains must be true for these operators, one of them
> > > being: any < ++any, which is not true for the way these operators behave
> > in
> > > php.
> >
> > You must have missed this post:
> >
> > http://marc.theaimsgroup.com/?l=php-general&m=114945456908350&w=2
> >
> >
> Yes, I haven't read that post. That algorithm has an error, an overflow on a
> signed char, and that's implementation issue not a design issue.
Actually it's a design issue. C uses a numeric datatype that is bound by
a specific number of bits. It could just have well have been designed
with a numeric datatype that had arbitrary length. The design decision
was made to keep it close to the machine. However, the point I was
making is that dealing with fringe cases is a necessity when you want to
ensure your code is robust.
> PS: It's a little bit rude to say "you *must* have missed" but I understand
> that it wasn't your intention.
Sorry, didn't mean to be rude :)
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. |
`------------------------------------------------------------'
attached mail follows:
At 10:38 AM 6/4/2006, tedd wrote:
>for ($i="a"; $i<"z"; $i++)
> {
> echo($i);
> }
>
>-- it stops at "y"
>
>But, if you use --
>
>for ($i="a"; $i<="z"; $i++)
> {
> echo($i);
> }
>
>-- it prints considerably more characters after "z" than what one
>would normally expect -- why is that?
Tedd,
The discussion of PHP strings has been interesting; thanks for sparking that.
Of course, your subject line to the contrary, it's not that "z" !=
"z", it's that storing an alphabetic character assumed to be a single
byte in a variable and then incrementing it can result in a two-byte
result. I find it plausible that the statement $a = "a" produces a
two-byte result in the first place, we just don't notice it because
the second byte is turned sideways and is very, very skinny.
I assume you know (but I'll state it anyway for the record) that to
avoid the problems you've encountered by trying to treat apparently
multi-byte PHP string variables like one-byte numerics, you can
simply use numerics themselves:
for ($i = ord("a"); $i <= ord("z"); $i++)
{
echo chr($i);
}
ord() and chr() being the PHP functions to yield the numeric value of
a character and the ASCII character of a numeric value:
http://php.net/ord & http://php.net/chr
To save that hard-working server a few machine cycles, one would
presumably store ord("z") in a variable before the loop began and
test for that each iteration.
Warm regards,
Paul
attached mail follows:
At 1:14 PM -0400 6/6/06, Adam Zey wrote:
>tedd wrote:
>>for I can't get it to stop when it passes "z" -- which I think it should.
>
>But, people have posted code solutions for you to do exactly what you want. So have I. Here it is again:
>
>foreach (range('a', 'z') as $char)
>{
> echo $char;
>}
>
>I don't mean to sound harsh, but why are you still complaining about it? You've been shown to do exactly what you want, why is it still a problem?
>
>Heck, if you still really want to do < and > with strings, you can easily write your own functions to compare two strings using your own requirements.
>
>Regards, Adam Zey.
Adam:
I don't mean to sound harsh either, but you're missing the topic here. I have already said that I found a solution (I said that in day of my first post) -- I'm not here asking for another one.
If php is supposed to be open source, doesn't that mean that people can voice their opinion on what they observe and expect?
Somehow I thought that a loop going from "a" to "z" would produce 26 elements and was surprised to find it produced 676. Now, you want to beat me up because I'm discussing it?
How about the next time you find something unexpected and want to discus it -- remind me and I accuse you of complaining.
No offense meant.
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
2006/6/6, Robert Cummings <robert
interjinn.com>:
>
> On Tue, 2006-06-06 at 13:11, Martin Alterisio wrote:
> > 2006/6/6, Robert Cummings <robert
interjinn.com>:
> > >
> > > On Tue, 2006-06-06 at 09:46, Martin Alterisio wrote:
> > > > 2006/6/6, Robert Cummings <robert
interjinn.com>:
> > > >
> > > > > In C++ they do leave it to the coder, and well, we all know what a
> > > mess
> > > > > it can be deciphering overloaded operators in C++ (or maybe we ALL
> > > > > don't). At any rate, the PHP overlords made a choice, and IMHO the
> > > best
> > > > > choice. For such a fringe issue I don't see what the argument is
> all
> > > > > about. If you want the functionality you get in C by incrementing
> a
> > > > > char, then use the chr() function on an integer.
> > > > >
> > > > >
> > > > You're right about ++ operator not to be considered a math operator,
> my
> > > > mistake. What I should have said is that the usual connotation and
> > > expected
> > > > behaviour of ++ and the comparison operators is to give iteration
> > > > capabilities to a certain data type, as used in a for statement. For
> > > that to
> > > > happen certain constrains must be true for these operators, one of
> them
> > > > being: any < ++any, which is not true for the way these operators
> behave
> > > in
> > > > php.
> > >
> > > You must have missed this post:
> > >
> > > http://marc.theaimsgroup.com/?l=php-general&m=114945456908350&w=2
> > >
> > >
> > Yes, I haven't read that post. That algorithm has an error, an overflow
> on a
> > signed char, and that's implementation issue not a design issue.
>
> Actually it's a design issue. C uses a numeric datatype that is bound by
> a specific number of bits. It could just have well have been designed
> with a numeric datatype that had arbitrary length. The design decision
> was made to keep it close to the machine. However, the point I was
> making is that dealing with fringe cases is a necessity when you want to
> ensure your code is robust.
I haven't thought this carefully, you're right to point that is a design
issue since compilers and interpreters have to take into account the actual
data representation in the design stage. Still, an overload is an known
issue and that can be caught easily. If you assume that the ++ and
comparison operator can be used with any type of object in a for loop, and
they don't follow the expected contrains an iterator shoud have then the
problem will be less apparent, as the issue is not considered a misuse but a
normal function of the data type.
attached mail follows:
>Tedd,
>
>The discussion of PHP strings has been interesting; thanks for sparking that.
>
>Of course, your subject line to the contrary, it's not that "z" != "z", it's that storing an alphabetic character assumed to be a single byte in a variable and then incrementing it can result in a two-byte result. I find it plausible that the statement $a = "a" produces a two-byte result in the first place, we just don't notice it because the second byte is turned sideways and is very, very skinny.
>
>I assume you know (but I'll state it anyway for the record) that to avoid the problems you've encountered by trying to treat apparently multi-byte PHP string variables like one-byte numerics, you can simply use numerics themselves:
>
> for ($i = ord("a"); $i <= ord("z"); $i++)
> {
> echo chr($i);
> }
>
>ord() and chr() being the PHP functions to yield the numeric value of a character and the ASCII character of a numeric value:
>http://php.net/ord & http://php.net/chr
>
>To save that hard-working server a few machine cycles, one would presumably store ord("z") in a variable before the loop began and test for that each iteration.
>
>Warm regards,
>Paul
Paul:
And I thank you for your reply -- you've been much kinder than most (on and off-list). :-)
True the subject line was a bit misleading, but that was intentional. Bait causes more fish to rise.
I've received the answer several times over since I posted the problem, but I wasn't looking for a solution because I already had one.
What I was looking for was an explanation, which I "got". I hope the answer remains with me longer than the bandages do. Asking questions in this group is like trying to feed alligators while being waist-deep in the swamp. :-)
Thanks.
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
2006/6/6, tedd <tedd
sperling.com>:
>
> If php is supposed to be open source, doesn't that mean that people can
> voice their opinion on what they observe and expect?
I second that. I believe being open-source doesn't mean "Yay, it's free!"
but "Cool, someone is listening to us!"
attached mail follows:
On Tue, 2006-06-06 at 14:06, Martin Alterisio wrote:
> 2006/6/6, Robert Cummings <robert
interjinn.com>:
> >
> > > > You must have missed this post:
> > > >
> > > > http://marc.theaimsgroup.com/?l=php-general&m=114945456908350&w=2
> > > >
> > > >
> > > Yes, I haven't read that post. That algorithm has an error, an overflow
> > on a
> > > signed char, and that's implementation issue not a design issue.
> >
> > Actually it's a design issue. C uses a numeric datatype that is bound by
> > a specific number of bits. It could just have well have been designed
> > with a numeric datatype that had arbitrary length. The design decision
> > was made to keep it close to the machine. However, the point I was
> > making is that dealing with fringe cases is a necessity when you want to
> > ensure your code is robust.
>
>
> I haven't thought this carefully, you're right to point that is a design
> issue since compilers and interpreters have to take into account the actual
> data representation in the design stage. Still, an overload is an known
> issue and that can be caught easily. If you assume that the ++ and
> comparison operator can be used with any type of object in a for loop, and
> they don't follow the expected contrains an iterator shoud have then the
> problem will be less apparent, as the issue is not considered a misuse but a
> normal function of the data type.
So there you go, by your own words, knowing the way the system works and
the edge cases is integral to proper use of the language. Thus when
'z'++ == 'aa' the semantics while not necessarily ubiquitous, fall under
the language's well defined modus operandi :)
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. |
`------------------------------------------------------------'
attached mail follows:
tedd wrote:
<snip>
> And I thank you for your reply -- you've been much kinder than most (on and off-list). :-)
>
> True the subject line was a bit misleading, but that was intentional. Bait causes more fish to rise.
>
> I've received the answer several times over since I posted the problem, but I wasn't looking for a solution because I already had one.
>
> What I was looking for was an explanation, which I "got". I hope the answer remains with me longer than the bandages do. Asking questions in this group is like trying to feed alligators while being waist-deep in the swamp. :-)
>
Ah, got it. You wanted one thing, but asked another to 'bait' people.
Didn't like the explanation you got, thought you knew better, and
dismissed it. Got 'hurt' that people got tired of your badgering, and
the list is mean to you? Well, that's easily solved. One more *plonk*
in my killfile, and you'll have one less person to worry about being
mean to you.
--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
jnichel
dotcomholdingsofbuffalo.com
attached mail follows:
2006/6/6, Robert Cummings <robert
interjinn.com>:
>
> On Tue, 2006-06-06 at 14:06, Martin Alterisio wrote:
> > 2006/6/6, Robert Cummings <robert
interjinn.com>:
> > >
> > > > > You must have missed this post:
> > > > >
> > > > > http://marc.theaimsgroup.com/?l=php-general&m=114945456908350&w=2
> > > > >
> > > > >
> > > > Yes, I haven't read that post. That algorithm has an error, an
> overflow
> > > on a
> > > > signed char, and that's implementation issue not a design issue.
> > >
> > > Actually it's a design issue. C uses a numeric datatype that is bound
> by
> > > a specific number of bits. It could just have well have been designed
> > > with a numeric datatype that had arbitrary length. The design decision
> > > was made to keep it close to the machine. However, the point I was
> > > making is that dealing with fringe cases is a necessity when you want
> to
> > > ensure your code is robust.
> >
> >
> > I haven't thought this carefully, you're right to point that is a design
> > issue since compilers and interpreters have to take into account the
> actual
> > data representation in the design stage. Still, an overload is an known
> > issue and that can be caught easily. If you assume that the ++ and
> > comparison operator can be used with any type of object in a for loop,
> and
> > they don't follow the expected contrains an iterator shoud have then the
> > problem will be less apparent, as the issue is not considered a misuse
> but a
> > normal function of the data type.
>
> So there you go, by your own words, knowing the way the system works and
> the edge cases is integral to proper use of the language. Thus when
> 'z'++ == 'aa' the semantics while not necessarily ubiquitous, fall under
> the language's well defined modus operandi :)
You lost me there. Can you explain it a little bit further?
attached mail follows:
At 2:20 PM -0400 6/6/06, John Nichel wrote:
>tedd wrote:
><snip>
>>And I thank you for your reply -- you've been much kinder than most (on and off-list). :-)
>>
>>True the subject line was a bit misleading, but that was intentional. Bait causes more fish to rise.
>>
>>I've received the answer several times over since I posted the problem, but I wasn't looking for a solution because I already had one.
>>
>>What I was looking for was an explanation, which I "got". I hope the answer remains with me longer than the bandages do. Asking questions in this group is like trying to feed alligators while being waist-deep in the swamp. :-)
>>
>
>Ah, got it. You wanted one thing, but asked another to 'bait' people. Didn't like the explanation you got, thought you knew better, and dismissed it. Got 'hurt' that people got tired of your badgering, and the list is mean to you? Well, that's easily solved. One more *plonk* in my killfile, and you'll have one less person to worry about being mean to you.
>
>--
>John C. Nichel IV
John:
I hope you're not serious, are you?
The last thing I want to do is to offend or annoy anyone -- if I have done something wrong, please accept my most sincere apology.
When I said to bait, I meant to make the topic of interest -- much like a headline.
Are far as being "beat-up", no one in this group has done anything that I found remotely offensive or objectionable. I said that to be humorous. Sorry, sometimes humor doesn't translate well without visual clues.
In any event, if anyone has found my comments or observations objectionable or annoying, please accept my apology.
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
On Tue, 2006-06-06 at 14:31, Martin Alterisio wrote:
> 2006/6/6, Robert Cummings <robert
interjinn.com>:
> >
> > On Tue, 2006-06-06 at 14:06, Martin Alterisio wrote:
> > > 2006/6/6, Robert Cummings <robert
interjinn.com>:
> > > >
> > > > > > You must have missed this post:
> > > > > >
> > > > > > http://marc.theaimsgroup.com/?l=php-general&m=114945456908350&w=2
> > > > > >
> > > > > >
> > > > > Yes, I haven't read that post. That algorithm has an error, an
> > overflow
> > > > on a
> > > > > signed char, and that's implementation issue not a design issue.
> > > >
> > > > Actually it's a design issue. C uses a numeric datatype that is bound
> > by
> > > > a specific number of bits. It could just have well have been designed
> > > > with a numeric datatype that had arbitrary length. The design decision
> > > > was made to keep it close to the machine. However, the point I was
> > > > making is that dealing with fringe cases is a necessity when you want
> > to
> > > > ensure your code is robust.
> > >
> > >
> > > I haven't thought this carefully, you're right to point that is a design
> > > issue since compilers and interpreters have to take into account the
> > actual
> > > data representation in the design stage. Still, an overload is an known
> > > issue and that can be caught easily. If you assume that the ++ and
> > > comparison operator can be used with any type of object in a for loop,
> > and
> > > they don't follow the expected contrains an iterator shoud have then the
> > > problem will be less apparent, as the issue is not considered a misuse
> > but a
> > > normal function of the data type.
> >
> > So there you go, by your own words, knowing the way the system works and
> > the edge cases is integral to proper use of the language. Thus when
> > 'z'++ == 'aa' the semantics while not necessarily ubiquitous, fall under
> > the language's well defined modus operandi :)
>
> You lost me there. Can you explain it a little bit further?
You said:
"Still, an overload is an known issue and that can be caught
easily."
It follows that you need information about the overload to handle it.
It is a known issue in PHP that incrementing 'z' by 1 produces 'aa'
It follows that knowing that 'z' incremented by 1 produces 'aa' can be
caught easily.
It follows that if it can be caught easily, it can be handled easily.
Thus it finally follows your own words:
"as the issue is not considered a misuse but a normal function
of the data type"
Normal in PHP is exactly the behaviour that PHP deemed many years ago
for it to follow.
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. |
`------------------------------------------------------------'
attached mail follows:
2006/6/6, Robert Cummings <robert
interjinn.com>:
>
> On Tue, 2006-06-06 at 14:31, Martin Alterisio wrote:
> > 2006/6/6, Robert Cummings <robert
interjinn.com>:
> > >
> > > On Tue, 2006-06-06 at 14:06, Martin Alterisio wrote:
> > > > 2006/6/6, Robert Cummings <robert
interjinn.com>:
> > > > >
> > > > > > > You must have missed this post:
> > > > > > >
> > > > > > >
> http://marc.theaimsgroup.com/?l=php-general&m=114945456908350&w=2
> > > > > > >
> > > > > > >
> > > > > > Yes, I haven't read that post. That algorithm has an error, an
> > > overflow
> > > > > on a
> > > > > > signed char, and that's implementation issue not a design issue.
> > > > >
> > > > > Actually it's a design issue. C uses a numeric datatype that is
> bound
> > > by
> > > > > a specific number of bits. It could just have well have been
> designed
> > > > > with a numeric datatype that had arbitrary length. The design
> decision
> > > > > was made to keep it close to the machine. However, the point I was
> > > > > making is that dealing with fringe cases is a necessity when you
> want
> > > to
> > > > > ensure your code is robust.
> > > >
> > > >
> > > > I haven't thought this carefully, you're right to point that is a
> design
> > > > issue since compilers and interpreters have to take into account the
> > > actual
> > > > data representation in the design stage. Still, an overload is an
> known
> > > > issue and that can be caught easily. If you assume that the ++ and
> > > > comparison operator can be used with any type of object in a for
> loop,
> > > and
> > > > they don't follow the expected contrains an iterator shoud have then
> the
> > > > problem will be less apparent, as the issue is not considered a
> misuse
> > > but a
> > > > normal function of the data type.
> > >
> > > So there you go, by your own words, knowing the way the system works
> and
> > > the edge cases is integral to proper use of the language. Thus when
> > > 'z'++ == 'aa' the semantics while not necessarily ubiquitous, fall
> under
> > > the language's well defined modus operandi :)
> >
> > You lost me there. Can you explain it a little bit further?
>
> You said:
>
> "Still, an overload is an known issue and that can be caught
> easily."
>
> It follows that you need information about the overload to handle it.
>
> It is a known issue in PHP that incrementing 'z' by 1 produces 'aa'
>
> It follows that knowing that 'z' incremented by 1 produces 'aa' can be
> caught easily.
>
> It follows that if it can be caught easily, it can be handled easily.
>
> Thus it finally follows your own words:
>
> "as the issue is not considered a misuse but a normal function
> of the data type"
>
> Normal in PHP is exactly the behaviour that PHP deemed many years ago
> for it to follow.
>
Thanks, I got it now.
What I meant as "known issue" is that the program is notified of the
occurrence of such problem. When the 'z' is incremented into 'aa' you're
stepping back in the sequence order but nothing is said or notified in any
way. The coder who explicitly wants to use such feature may handle the issue
without a problem, but when you work on the basis that you can receive any
kind of sequence, range, or iterator you can't know for sure that this
happens. Consider this example:
function orderedSequence($start, $end) {
$orderedSequence = array();
for ($i = $start; $i <= $end; $i++) {
$orderedSequence[] = $i;
}
return $orderedSequence;
}
Supposedly this function would return an ordered sequence of objects, which
implement iteration, between $start and $end. Under the mentioned
circumstances the function would fail to return an ordered sequence. Still,
this kind of "generic" behaviour it something that isn't useful in PHP,
since there isn't operator overloading. Anyway PHP5 has some features that
point that generics will be used (correct if i'm wrong here, that's what I
thought when I saw iterators in the SPL) and I think that we won't be able
to use native operators to create proper iterators on strings with the
current functionality assigned to them.
Well, my arguments are starting to sound much more like ranting that
anything else. Sorry if they weren't appropiate.
attached mail follows:
On Tue, 2006-06-06 at 15:11, Martin Alterisio wrote:
> 2006/6/6, Robert Cummings <robert
interjinn.com>:
>
> > > You lost me there. Can you explain it a little bit further?
> >
> > You said:
> >
> > "Still, an overload is an known issue and that can be caught
> > easily."
> >
> > It follows that you need information about the overload to handle it.
> >
> > It is a known issue in PHP that incrementing 'z' by 1 produces 'aa'
> >
> > It follows that knowing that 'z' incremented by 1 produces 'aa' can be
> > caught easily.
> >
> > It follows that if it can be caught easily, it can be handled easily.
> >
> > Thus it finally follows your own words:
> >
> > "as the issue is not considered a misuse but a normal function
> > of the data type"
> >
> > Normal in PHP is exactly the behaviour that PHP deemed many years ago
> > for it to follow.
> >
>
> Thanks, I got it now.
>
> What I meant as "known issue" is that the program is notified of the
> occurrence of such problem. When the 'z' is incremented into 'aa' you're
> stepping back in the sequence order but nothing is said or notified in any
> way. The coder who explicitly wants to use such feature may handle the issue
> without a problem, but when you work on the basis that you can receive any
> kind of sequence, range, or iterator you can't know for sure that this
> happens. Consider this example:
>
> function orderedSequence($start, $end) {
> $orderedSequence = array();
> for ($i = $start; $i <= $end; $i++) {
> $orderedSequence[] = $i;
> }
> return $orderedSequence;
> }
>
> Supposedly this function would return an ordered sequence of objects, which
> implement iteration, between $start and $end. Under the mentioned
> circumstances the function would fail to return an ordered sequence. Still,
> this kind of "generic" behaviour it something that isn't useful in PHP,
> since there isn't operator overloading. Anyway PHP5 has some features that
> point that generics will be used (correct if i'm wrong here, that's what I
> thought when I saw iterators in the SPL) and I think that we won't be able
> to use native operators to create proper iterators on strings with the
> current functionality assigned to them.
>
> Well, my arguments are starting to sound much more like ranting that
> anything else. Sorry if they weren't appropiate.
No problem, doesn't really sound like ranting to me. But I think the
main problem some people are having is understanding that there are two
sequences in question here and not one. There is the sequence generated
by the incrementation operator, and there is the sequence of all
possible strings in their sorted order. Combining the semantics of the
two sequences does not necessarily leave you with the semantics of one
or the other.
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. |
`------------------------------------------------------------'
attached mail follows:
On Mon, June 5, 2006 9:00 pm, tedd wrote:
>>Does that make more sense?
>
> Maybe to you, but not me.
a
b
c
.
.
.
x
y
z
aa
ab
ac
.
.
.
ax
ay
az
ba
bb
bc
.
.
.
aaa
.
.
.
zzz
aaaa
.
.
.
zzzz
.
.
.
aaaaaaaaaaaaaaaaaaaa
.
.
.
zzzzzzzzzzzzzzzzzzzz
It's just like 1 thru 9 followed by 10, except that it is NOT an
ordered set in terms of < and >
> In my last post I showed an "actual sequence" which is debatable. It
> could be interpreted that the infinite set starts at "a, aa, aaa,... "
> and never reaches "b". Oddly enough, this could be viewed in all sorts
> of ways. It's probably best if we don't look at characters as numbers.
EXACTLY!
They aren't numbers.
So doing ++ to one of them, doesn't necessarily end up with an ordered
set.
Rasmus chose to make ++ be useful for generating sensible sequential
file names, not sensible ordered strings.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Richard Lynch wrote:
> On Mon, June 5, 2006 9:00 pm, tedd wrote:
>>> Does that make more sense?
>> Maybe to you, but not me.
>
> a
> b
> c
> .
> .
> .
> x
> y
> z
> aa
> ab
> ac
> .
> .
> .
> ax
> ay
> az
> ba
> bb
> bc
> .
> .
> .
> aaa
> .
> .
> .
> zzz
> aaaa
> .
> .
> .
> zzzz
> .
> .
> .
> aaaaaaaaaaaaaaaaaaaa
> .
> .
> .
> zzzzzzzzzzzzzzzzzzzz
>
> It's just like 1 thru 9 followed by 10, except that it is NOT an
> ordered set in terms of < and >
>
>> In my last post I showed an "actual sequence" which is debatable. It
>> could be interpreted that the infinite set starts at "a, aa, aaa,... "
>> and never reaches "b". Oddly enough, this could be viewed in all sorts
>> of ways. It's probably best if we don't look at characters as numbers.
>
> EXACTLY!
>
> They aren't numbers.
>
> So doing ++ to one of them, doesn't necessarily end up with an ordered
> set.
>
> Rasmus chose to make ++ be useful for generating sensible sequential
> file names, not sensible ordered strings.
Well, it does other sequences too and the first priority is always to
try to convert to a number. For example, try incrementing the following
strings: "1", "1.5", "0xf8", "10e2"
These all end up being converted to numbers (integers or floats as
appropriate) and hopefully they end up with the value everyone would
expect. Since the Web by definition is untyped, all we get passed
around between the browser and the server are strings, so we need to
make "123" passed as a string behave as the number 123 as much as we
can. Otherwise we would spend a lot of time type juggling. Having
"123"++ not end up being 124 but instead do something to increment the
ascii values behind the string instead would create chaos.
So, given that in any instance where we can convert the string to a
number ++ logically increments that number by 1 spot in the numeric
sequence. It follows that anywhere we can determine a logical sequence
for the string, ++ should increment that sequence. The other option
would be that anything that can't be converted to a number would end up
being 0, and "whatever"++ would always be 1.
Or we try to do something a bit more creative which always runs the risk
of surprising people. In this case "a2"++ becomes "a3" and "c9"++
becomes "d0". If we have a character that doesn't infer any sort of
logical sequence, like "&" then the ++ does nothing. So "&"++ stays at
"&". However "&3" becomes "&4" and "&b"++ becomes "&c". "99z"++
becomes "100a" and "1z9z9z"++ becomes "2a0a0a" and yes, of course "z"++
becomes "aa" which is what caused this entire thread.
-Rasmus
attached mail follows:
On Tue, 2006-06-06 at 22:53, Rasmus Lerdorf wrote:
> Richard Lynch wrote:
>
> Or we try to do something a bit more creative which always runs the risk
> of surprising people. In this case "a2"++ becomes "a3" and "c9"++
> becomes "d0". If we have a character that doesn't infer any sort of
> logical sequence, like "&" then the ++ does nothing. So "&"++ stays at
> "&". However "&3" becomes "&4" and "&b"++ becomes "&c". "99z"++
> becomes "100a" and
Funky stuff.
> "1z9z9z"++ becomes "2a0a0a" and yes, of course "z"++
Good thing Tedd didn't come across the above one by accident *lol*.
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. |
`------------------------------------------------------------'
attached mail follows:
Ok, Here is my next problem.
Inside my database, I have a list of ip's of about 10 blocks
192.168.100.0 all the way though 255
along with
192.168.101.0 though 255
and
192.168.102.0 though 255
and soforth
My problem is, is i'm trying to figure out a pattern to match so I can count how many ip's are in each block and display them.
So far what I have gotten is a stristr match but it's not working correctly. I have a variable that basically weed's out the last digits of the ip it's self from help previously
So my code so far is:
if (stristr($block,$address)) {
$count_ip++;
}
$block would == 192.168.100
$address would == 192.168.100.0 - 255
Any help would be appricated.
attached mail follows:
without actually thinking about your problem I guess that these funcs
(the first is most like useful, the second show [at least] how the first
can be used and the last func is just for fun) might help you somehow
(apologies if If I'm way off base):
ALSO: if anyone has a cleaner/faster/better way of doing this
then I'm intersted to learn :-)
/* 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;
}
Rob W. wrote:
> Ok, Here is my next problem.
>
> Inside my database, I have a list of ip's of about 10 blocks
>
> 192.168.100.0 all the way though 255
> along with
> 192.168.101.0 though 255
> and
> 192.168.102.0 though 255
> and soforth
>
> My problem is, is i'm trying to figure out a pattern to match so I can count how many ip's are in each block and display them.
>
> So far what I have gotten is a stristr match but it's not working correctly. I have a variable that basically weed's out the last digits of the ip it's self from help previously
>
> So my code so far is:
>
> if (stristr($block,$address)) {
> $count_ip++;
> }
>
> $block would == 192.168.100
> $address would == 192.168.100.0 - 255
>
> Any help would be appricated.
attached mail follows:
Acutall no, Because in my database is is all them blocks but each ip in all
them blocks has a seperate entry in a column. So in listing the whole column
in my mysql request, i need a line that will weed out and count how many
ip's are in a block.
----- Original Message -----
From: <replies-lists-php
listmail.innovate.net>
To: "Rob W." <rob
fiberuplink.com>
Sent: Tuesday, June 06, 2006 1:16 PM
Subject: Re: [PHP] Getting totals
>i may be missing something in your description, but does turning the
> first and last ipnumber in a block into its integer representation, and
> then doing the math (subtraction) to get the ipnumber count per block,
> accomplish what you're after?
>
>
> - Rick
>
>
> ------------ Original Message ------------
>> Date: Tuesday, June 06, 2006 12:15:27 PM -0500
>> From: "Rob W." <rob
fiberuplink.com>
>> To: php-general
lists.php.net
>> Subject: [PHP] Getting totals
>>
>> Ok, Here is my next problem.
>>
>> Inside my database, I have a list of ip's of about 10 blocks
>>
>> 192.168.100.0 all the way though 255
>> along with
>> 192.168.101.0 though 255
>> and
>> 192.168.102.0 though 255
>> and soforth
>>
>> My problem is, is i'm trying to figure out a pattern to match so I
>> can count how many ip's are in each block and display them.
>>
>> So far what I have gotten is a stristr match but it's not working
>> correctly. I have a variable that basically weed's out the last
>> digits of the ip it's self from help previously
>>
>> So my code so far is:
>>
>> if (stristr($block,$address)) {
>> $count_ip++;
>> }
>>
>> $block would == 192.168.100
>> $address would == 192.168.100.0 - 255
>>
>> Any help would be appricated.
>
> ---------- End Original Message ----------
>
>
>
attached mail follows:
On 6/6/06, Rob W. <rob
fiberuplink.com> wrote:
> So far what I have gotten is a stristr match but it's not working correctly. I have a variable that basically weed's out the last digits of the ip it's self from help previously
>
> So my code so far is:
>
> if (stristr($block,$address)) {
> $count_ip++;
> }
You've got the parameters mixed up. strstr is (haystack,
needle) so you need strstr($address, $block). php.net/stristr.
Rabin
attached mail follows:
On Tue, June 6, 2006 12:15 pm, Rob W. wrote:
> Ok, Here is my next problem.
>
> Inside my database, I have a list of ip's of about 10 blocks
Some databases, such as PostgreSQL, have native data format of IP and
functions to deal with them...
I don't suppose you are using one of those? :-)
> 192.168.100.0 all the way though 255
> along with
> 192.168.101.0 though 255
> and
> 192.168.102.0 though 255
> and soforth
>
> My problem is, is i'm trying to figure out a pattern to match so I can
> count how many ip's are in each block and display them.
Your Regex should probably be pretty simple...
Something like:
([[::digit::]])\.([[::digit::]])\.([[::digit::]])\.([[::digit::]])
Though god only knows what your db needs to grok that, or if it even
CAN do that...
> So far what I have gotten is a stristr match but it's not working
> correctly. I have a variable that basically weed's out the last digits
> of the ip it's self from help previously
>
> So my code so far is:
Oh.
Well if you want to do this in PHP in a loop, instead of in the DB
like it should be done, check out http://php.net/preg_match and find
an example of IP quads in there somewhere.
> if (stristr($block,$address)) {
> $count_ip++;
> }
>
> $block would == 192.168.100
> $address would == 192.168.100.0 - 255
>
> Any help would be appricated.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Well, if I understood correctly, and the IP's first 3 segments are all
of the same length, the you could do something like this (MySQL)
SELECT
SUBSTRING(ip, 1, 11) AS ip,
COUNT(1) AS cantidad
FROM tabla
GROUP BY ip
Now, if you don't intend to do this in SQL, then you could try some of
the other suggestions.
Rob W. wrote:
> Ok, Here is my next problem.
>
> Inside my database, I have a list of ip's of about 10 blocks
>
> 192.168.100.0 all the way though 255 along with 192.168.101.0 though
> 255 and 192.168.102.0 though 255 and soforth
>
> My problem is, is i'm trying to figure out a pattern to match so I
> can count how many ip's are in each block and display them.
>
> So far what I have gotten is a stristr match but it's not working
> correctly. I have a variable that basically weed's out the last
> digits of the ip it's self from help previously
>
> So my code so far is:
>
> if (stristr($block,$address)) { $count_ip++; }
>
> $block would == 192.168.100 $address would == 192.168.100.0 - 255
>
> Any help would be appricated.
--
Atentamente / Sincerely,
J. Rafael Salazar Magaña
attached mail follows:
if (strstr(192.168.100,192.168.100.10)) {
$inc++;
}
echo "$inc";
That returns nothing. What am i still doing wrong?
----- Original Message -----
From: "Rabin Vincent" <rabin
rab.in>
To: "Rob W." <rob
fiberuplink.com>
Cc: <php-general
lists.php.net>
Sent: Tuesday, June 06, 2006 1:36 PM
Subject: Re: [PHP] Getting totals
> On 6/6/06, Rob W. <rob
fiberuplink.com> wrote:
>> So far what I have gotten is a stristr match but it's not working
>> correctly. I have a variable that basically weed's out the last digits of
>> the ip it's self from help previously
>>
>> So my code so far is:
>>
>> if (stristr($block,$address)) {
>> $count_ip++;
>> }
>
> You've got the parameters mixed up. strstr is (haystack,
> needle) so you need strstr($address, $block). php.net/stristr.
>
> Rabin
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
attached mail follows:
Sorry for the miss understanding, That's the way the viarable will look, i'm
putting it in as a viariable.
if (strstr($block,$address)) {
$inc++;
}
----- Original Message -----
From: "Richard Lynch" <ceo
l-i-e.com>
To: "Rob W." <rob
fiberuplink.com>
Sent: Tuesday, June 06, 2006 8:58 PM
Subject: Re: [PHP] Getting totals
>
> Put quotes or apostrophes on the strings...
> if (strstr('192.168.100','192.168.100.10')) {
>
> On Tue, June 6, 2006 8:46 pm, Rob W. wrote:
>> if (strstr(192.168.100,192.168.100.10)) {
>> $inc++;
>> }
>> echo "$inc";
>>
>> That returns nothing. What am i still doing wrong?
>>
>> ----- Original Message -----
>> From: "Rabin Vincent" <rabin
rab.in>
>> To: "Rob W." <rob
fiberuplink.com>
>> Cc: <php-general
lists.php.net>
>> Sent: Tuesday, June 06, 2006 1:36 PM
>> Subject: Re: [PHP] Getting totals
>>
>>
>>> On 6/6/06, Rob W. <rob
fiberuplink.com> wrote:
>>>> So far what I have gotten is a stristr match but it's not working
>>>> correctly. I have a variable that basically weed's out the last
>>>> digits of
>>>> the ip it's self from help previously
>>>>
>>>> So my code so far is:
>>>>
>>>> if (stristr($block,$address)) {
>>>> $count_ip++;
>>>> }
>>>
>>> You've got the parameters mixed up. strstr is (haystack,
>>> needle) so you need strstr($address, $block). php.net/stristr.
>>>
>>> Rabin
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>>
>>
>> --
>> 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
>
>
>
>
attached mail follows:
At 06:46 PM 6/6/2006, Rob W. wrote:
>if (strstr(192.168.100,192.168.100.10)) {
> $inc++;
>}
>echo "$inc";
>
>That returns nothing. What am i still doing wrong?
I would use quotation marks to explicitly type these as strings:
strstr("192.168.100","192.168.100.10")
Paul
attached mail follows:
On 6/7/06, Rob W. <rob
fiberuplink.com> wrote:
> Sorry for the miss understanding, That's the way the viarable will look, i'm
> putting it in as a viariable.
>
> if (strstr($block,$address)) {
> $inc++;
> }
>
Like I said before, strstr's argument list is haystack (what to
search in) first and then needle (what to search for). Therefore,
you need to have:
strstr($address, $block);
Rabin
attached mail follows:
I got the fix, strstr didnt work right because it was relaying more than
just what I was thinking.
Here is the fix.
$value=array(strstr($block, $address));
foreach ($value as $var) {
$block_total_ip++;
}
----- Original Message -----
From: "Rabin Vincent" <rabin
rab.in>
To: "Rob W." <rob
fiberuplink.com>
Cc: <php-general
lists.php.net>
Sent: Tuesday, June 06, 2006 11:38 PM
Subject: Re: [PHP] Getting totals
> On 6/7/06, Rob W. <rob
fiberuplink.com> wrote:
>> Sorry for the miss understanding, That's the way the viarable will look,
>> i'm
>> putting it in as a viariable.
>>
>> if (strstr($block,$address)) {
>> $inc++;
>> }
>>
>
> Like I said before, strstr's argument list is haystack (what to
> search in) first and then needle (what to search for). Therefore,
> you need to have:
>
> strstr($address, $block);
>
> Rabin
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
attached mail follows:
Dear All,
I'm having a very frustrating issue w/ Apples Safari web browser.
The browser will stall when I try and initiate a sessions on login .
So on our login page we validate the username and password and start the
session.
When a Safari user attempts to login the Safari wheel just spins and spins.
I've restarted the browser, cleared the cache , cookies and history to no
avail. Putting in a bad username password causes no lockup and the proper
"bad auth" page is shown.
I've added:
// attempt to fix Safari issue
header ('Expires: 0');
header ('Pragma: no-cache');
to the header and still no luck.
I've found many similar incidents on the WWW with no real solutions.
Has anyone had similar issues and found a workaround for this problem?
I believe this is a Safari issue and not a PHP problem. But I'm hoping
someone has created a solution w/ PHP.
Best Regards,
--
Paul Nowosielski
Webmaster
attached mail follows:
At 11:55 AM -0600 6/6/06, Paul Nowosielski wrote:
>Dear All,
>
>I'm having a very frustrating issue w/ Apples Safari web browser.
>The browser will stall when I try and initiate a sessions on login .
>So on our login page we validate the username and password and start the
>session.
>
>When a Safari user attempts to login the Safari wheel just spins and spins.
>I've restarted the browser, cleared the cache , cookies and history to no
>avail. Putting in a bad username password causes no lockup and the proper
>"bad auth" page is shown.
>
>I've added:
>
>// attempt to fix Safari issue
>header ('Expires: 0');
>header ('Pragma: no-cache');
>
>to the header and still no luck.
>
>I've found many similar incidents on the WWW with no real solutions.
>
>Has anyone had similar issues and found a workaround for this problem?
>I believe this is a Safari issue and not a PHP problem. But I'm hoping
>someone has created a solution w/ PHP.
>
>Best Regards,
>--
>Paul Nowosielski
Paul:
I use Safari and don't have any problems whatsoever with php, sessions, or login's.
Check out:
http://xn--ovg.com
I have examples there and they work -- at least for me. Try them out and see if they work for you. If you want the code, I'll provide.
Just let me know.
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
tedd wrote:
>
> I use Safari
...
<thefarside>
slowly but surely it's became evident that tedd had masochistic tendencies.
</thefarside>
;-)
attached mail follows:
On Tuesday 06 June 2006 12:26, tedd wrote:
> At 11:55 AM -0600 6/6/06, Paul Nowosielski wrote:
> >Dear All,
> >
> >I'm having a very frustrating issue w/ Apples Safari web browser.
> >The browser will stall when I try and initiate a sessions on login .
> >So on our login page we validate the username and password and start the
> >session.
> >
> >When a Safari user attempts to login the Safari wheel just spins and
> > spins. I've restarted the browser, cleared the cache , cookies and
> > history to no avail. Putting in a bad username password causes no lockup
> > and the proper "bad auth" page is shown.
> >
> >I've added:
> >
> >// attempt to fix Safari issue
> >header ('Expires: 0');
> >header ('Pragma: no-cache');
> >
> >to the header and still no luck.
> >
> >I've found many similar incidents on the WWW with no real solutions.
> >
> >Has anyone had similar issues and found a workaround for this problem?
> >I believe this is a Safari issue and not a PHP problem. But I'm hoping
> >someone has created a solution w/ PHP.
> >
> >Best Regards,
> >--
> >Paul Nowosielski
>
> Paul:
>
> I use Safari and don't have any problems whatsoever with php, sessions, or
> login's.
>
> Check out:
>
> http://xn--ovg.com
>
> I have examples there and they work -- at least for me. Try them out and
> see if they work for you. If you want the code, I'll provide.
>
> Just let me know.
>
> tedd
> --
> ---------------------------------------------------------------------------
>--------- http://sperling.com http://ancientstones.com
> http://earthstones.com
Tedd,
Thank you for the reply.
The weird thing is my session code works great. Until a few months ago it
worked great in Safari also.
All the code I generate is tested in Safari,IE and Firefox.
I'm assuming this is a Safari related issue. But I was hoping someone had
a workaround or had seen similar issues.
So if anyone has seen this or has sometype of solution please let me know.
Thank you,
--
Paul Nowosielski
Webmaster
attached mail follows:
On Tue, June 6, 2006 12:55 pm, Paul Nowosielski wrote:
> I'm having a very frustrating issue w/ Apples Safari web browser.
> The browser will stall when I try and initiate a sessions on login .
> So on our login page we validate the username and password and start
> the
> session.
>
> When a Safari user attempts to login the Safari wheel just spins and
> spins.
> I've restarted the browser, cleared the cache , cookies and history to
> no
> avail. Putting in a bad username password causes no lockup and the
> proper
> "bad auth" page is shown.
>
> I've added:
>
> // attempt to fix Safari issue
> header ('Expires: 0');
> header ('Pragma: no-cache');
>
> to the header and still no luck.
>
> I've found many similar incidents on the WWW with no real solutions.
>
> Has anyone had similar issues and found a workaround for this problem?
> I believe this is a Safari issue and not a PHP problem. But I'm hoping
> someone has created a solution w/ PHP.
What all headers are you sending?...
Try simplifying those down and re-testing.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Is there any way to alter the header of DomDocument's load/loadHTMLFile
request? I have a file that will display certain content for certain
user agents. I'd like to be able to spoof the UA of the request.
TIA,
attached mail follows:
Is there any way to alter the header of DomDocument's load/loadHTMLFile
request? I have a file that will display certain content for certain
user agents. I'd like to be able to spoof the UA of the request.
TIA,
attached mail follows:
Shu Chow wrote:
> Is there any way to alter the header of DomDocument's load/loadHTMLFile
> request? I have a file that will display certain content for certain
> user agents. I'd like to be able to spoof the UA of the request.
don't know about that (I have my doubts) - but you could write a wrapper
script on the receiving end that sppofs the UA and includes the real file
being called; and then call the spoofing script with DomDocument->loadHTMLfile()
...just an idea.
>
> TIA,
>
attached mail follows:
Shu Chow wrote:
> Is there any way to alter the header of DomDocument's load/loadHTMLFile
> request? I have a file that will display certain content for certain
> user agents. I'd like to be able to spoof the UA of the request.
Ah, a good question the answer to which demonstrates the magic of PHP
5's stream contexts which is meant to solve this exact problem.
The example in the documentation is even exactly the user-agent one. See:
http://php.net/libxml_set_streams_context
-Rasmus
attached mail follows:
Rasmus Lerdorf wrote:
> Shu Chow wrote:
>> Is there any way to alter the header of DomDocument's
>> load/loadHTMLFile request? I have a file that will display certain
>> content for certain user agents. I'd like to be able to spoof the UA
>> of the request.
>
> Ah, a good question the answer to which demonstrates the magic of PHP
> 5's stream contexts which is meant to solve this exact problem.
>
> The example in the documentation is even exactly the user-agent one. See:
>
> http://php.net/libxml_set_streams_context
>
> -Rasmus
holy crap - someone has done a mega job of padding out the streams related docs :-)
or at least so it seems to me (since I last attempted to get a good understanding or
streams ... rather than relying on Richard Lynch's efforts ;-)
guess it's time to dive back into the streams magic and see if some of it sticks :-)
>
attached mail follows:
On Tue, June 6, 2006 3:16 pm, Jochem Maas wrote:
> Rasmus Lerdorf wrote:
>> Shu Chow wrote:
>>> Is there any way to alter the header of DomDocument's
>>> load/loadHTMLFile request? I have a file that will display certain
>>> content for certain user agents. I'd like to be able to spoof the
>>> UA
>>> of the request.
>>
>> Ah, a good question the answer to which demonstrates the magic of
>> PHP
>> 5's stream contexts which is meant to solve this exact problem.
>>
>> The example in the documentation is even exactly the user-agent one.
>> See:
>>
>> http://php.net/libxml_set_streams_context
>>
>> -Rasmus
>
> holy crap - someone has done a mega job of padding out the streams
> related docs :-)
> or at least so it seems to me (since I last attempted to get a good
> understanding or
> streams ... rather than relying on Richard Lynch's efforts ;-)
now that's scary, considering how confused I got by the stream
rewriters, remappers, redirectors, and whatnot...
Though if the docs are expanded, that would help TONS.
Big thanks to SOMEBODY "out there"
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Adam Zey wrote:
...
>>>
>>> http://www.otton.org/
>
> Turn off register globals. Now. It is a HUGE security hole.
it is NOT by definition a security hole - the problem arises from scripts
that don't bother to initialize all their variable before using them,
which allows blackhats to possibly interfere with the intended functionality
of a script.
e.g.
<?
// myfile.php
if (chkCleanRequired()) {
$delete = true;
}
if ($delete) doDeleteRoutines();
?>
which could be hacked like so (if register_globals was on):
somedomain.tld/myfile.php?delete=1
that said having register_globals turned on is bad practice -
turning it off and using $_GET, $_POST and $_REQUEST is preferred and
offers a buffer against silly mistakes related to not initializing
variables properly ...
in addition a number of members of the core php
dev team are in the process of finalizing a data filtering extension
[which I believe will be included in php by default] that will take
data filtering to a whole other level in php ... soon even the use of
the raw data in $_POST, $_GET, et al will be discouraged in favor of
using the api provided by the filter extension... I'm so looking forward to
that :-)
>
> You do NOT need it turned on to use $_GET or the other superglobals, and
> there is in fact no reason at all to EVER turn it on. The only
> conceivable reason that someone would enable it is for an old badly
> written script, and in that case one has to question why they are
> running an old badly written script :)
there are plenty of legacy codebases out there that rely on register_globals
AND are quite adequate regarding protection from potential problems arising
from register_globals being turned on.
>
> Regards, Adam Zey.
>
attached mail follows:
On Tue, June 6, 2006 2:36 am, William Stokes wrote:
> I just set up a test box for PHP/MySQL on a WinXP box and now I'm
> having
> trouble with variables passed to browser from a link.
>
> For example I have a link that outputs this:
> http://localhost/index.php?team=CF10b. Now the CF10b cannot be user in
> the
> code like it should.
Perhaps because you used 'team' and not 'user'...
echo $_GET['team'] should work for you.
> I turned to Register Globals on in the php.ini but that didn't help.
> Any
> ideas?
As said before, turn them back OFF!
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Hi,
is there any easy way to use differnt sessions on the same domain? I didn't
really dig for a solution, but if anybody has one ready?
Best Regards,
Oliver
attached mail follows:
[snip]
is there any easy way to use differnt sessions on the same domain? I
didn't
really dig for a solution, but if anybody has one ready?
[/snip]
Yes. http://www.php.net/session
attached mail follows:
Am Dienstag, 6. Juni 2006 20:51 schrieb Jay Blanchard:
> Yes. http://www.php.net/session
session_set_cookie_params() ?
attached mail follows:
On Tue, June 6, 2006 1:43 pm, Oliver Block wrote:
> is there any easy way to use differnt sessions on the same domain? I
> didn't
> really dig for a solution, but if anybody has one ready?
<?php
session_name("MY_session_data_needs_to_be_separate");
session_start();
?>
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Niels wrote:
> Hi,
>
>
> I have a set of nodes. Each node has a parent and so the set can be thought
> of as a tree. I want to show that tree somehow on a webpage, served by PHP.
> I cannot use Dot/Graphwiz for various reasons. What I'm looking for is an
> output of DIVs or tablecells, showing the nodes and their connections. It's
> not a trivial task, IMO, but doable. Possibly somebody has already made
> something similiar, but I can't find anything on Google. Can anybody point
> me to helpful information?
I might be late to the party but have you thought of trying the YAHOO UI lib
(treeview widget) it even allows you to dynamically load subbranches as they are
expanded (AJAX lovelyness):
http://developer.yahoo.com/yui/treeview/
I have used (and extended) the treeview code with great success (ok so I'm biased ;-)
- if nothing else the guys at YAHOO have done a great job in showing how one can use
prototyping (more or less the javascript equivalent to classes) to build [very] robust
javascript libraries.
<testament to="YAHOO JS Lib being rather good">
I have made the YAHOO javascript lib(s) part of my core [reusable] js codebase - the
only downside is that its a bit embarrassing hwo the YAHOO stuff has made alot of my
own js code redundant :-P
<testament>
<disclaimer>I have nothing to do with YAHOO apart from occasionally harassing
one of their system architects (sorry Rasmus) about things not related to YAHOO</disclaimer>
>
> Thanks,
> Niels
>
attached mail follows:
Hello,
I want to provide two input text fields lastname and firstname and if the user
pushes the submit button the generated url should be ...?name=firstname_lastname.
Is this possible and how?
Thank you for helping a php newbie.
Steffen Mazanek
--
Hermann-Löns-Straße 3
53840 Troisdorf
www.steffen-mazanek.de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQBEhyb4D8Khkc4IBakRAnYsAKCf9zOef0H5TCF0v9i1wPSnZ2X53QCgnAa8
XZI/VPCB+gMLcdaMRuCGd7k=
=XMjl
-----END PGP SIGNATURE-----
attached mail follows:
Steffen Mazanek wrote:
> Hello,
>
> I want to provide two input text fields lastname and firstname and if the user
> pushes the submit button the generated url should be ...?name=firstname_lastname.
>
> Is this possible and how?
Yes and JavaScript
> Thank you for helping a php newbie.
>
You're welcome, but it's not php.
--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
jnichel
dotcomholdingsofbuffalo.com
attached mail follows:
Why are you forcing the input into the GET variable or the URL string?
Why not just use the post from the form variable??
As for you question...
the answer is yes:
make the submit button a button and onclick="javascript_function()"
Javascript_function() {
val1 = document.getElementbyId("lastname").value;
val2 = document.getelemntById("first_name").value
var url ="somepage.php?name="+val2+"_"+val1;
window.location = url;
}
again...if you have a form, use the post variables!
-Brad|****|
Steffen Mazanek wrote:
>Hello,
>
>I want to provide two input text fields lastname and firstname and if the user
>pushes the submit button the generated url should be ...?name=firstname_lastname.
>
>Is this possible and how?
>
>Thank you for helping a php newbie.
>
>Steffen Mazanek
>
>
attached mail follows:
At 9:20 PM +0200 6/7/06, Steffen Mazanek wrote:
>Hello,
>
>I want to provide two input text fields lastname and firstname and if the user
>pushes the submit button the generated url should be ...?name=firstname_lastname.
>
>Is this possible and how?
>
>Thank you for helping a php newbie.
>
>Steffen Mazanek
>--
>Hermann-Löns-Straße 3
>53840 Troisdorf
>
>www.steffen-mazanek.de
>
>Attachment converted: main:Untitled 1 ( / ) (0054518D)
Steffen:
If I understand you correctly, what you describe is a GET. You can see an example here:
http://xn--ovg.com/orm/post_get1.php
and a copy of the code here:
http://www.weberdev.com/get_example-4345.html
It's a very simple example. If you need help, please ask.
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
On Tue, June 6, 2006 4:55 pm, tedd wrote:
> At 9:20 PM +0200 6/7/06, Steffen Mazanek wrote:
>>I want to provide two input text fields lastname and firstname and if
>> the user
>>pushes the submit button the generated url should be
>> ...?name=firstname_lastname.
>>
>>Is this possible and how?
I think all the OP needs is:
<form method="get" ...>
rather than all the convoluted solutions provided so far. :-)
There is still no PHP involved, mind.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
I have a shell script I want to run which generates an html page after it
runs some tests on the software I am writing.
I call the script with exec(…);
The tests take more than 2 minutes to complete.
If I try to run more than one test at the same time: trouble.
I want to solve this by checking somehow whether the tests are running.
If so, then the php code just waits until the running test are complete,
referring the second user to the same results page as the first.
Ideas anyone?
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.8.2/356 - Release Date: 5/06/2006
attached mail follows:
Roel Dillen wrote:
> I have a shell script I want to run which generates an html page after it
> runs some tests on the software I am writing.
>
> I call the script with exec(…);
>
> The tests take more than 2 minutes to complete.
>
> If I try to run more than one test at the same time: trouble.
>
>
>
> I want to solve this by checking somehow whether the tests are running.
>
> If so, then the php code just waits until the running test are complete,
> referring the second user to the same results page as the first.
>
>
>
> Ideas anyone?
>
a file used as a lock file? (have the shell script remove the file
when it's done) - possibly in combo with flock()? if the lock file
exists (or cannot be created because it already exists - depending on how
you fancy implmenting it) then don't try to run the script.
have the shell script check the process list for itself and return
straight away with an error (or some useful message) if it finds its self?
- my gut says this is the more robust/nicer method.
er .... um ... nope no more ideas here :-)
attached mail follows:
On Tue, June 6, 2006 3:10 pm, Roel Dillen wrote:
> I have a shell script I want to run which generates an html page after
> it
> runs some tests on the software I am writing.
>
> I call the script with exec(…);
>
> The tests take more than 2 minutes to complete.
>
> If I try to run more than one test at the same time: trouble.
>
>
>
> I want to solve this by checking somehow whether the tests are
> running.
>
> If so, then the php code just waits until the running test are
> complete,
> referring the second user to the same results page as the first.
<?php
if (
file_exists("/var/shared/locks/" . __FILE__)){
exit; //already running
}
touch("/var/shared/locks/" . __FILE__);
//rest of script here
unlink("/var/shared/locks/" . __FILE__);
?>
You can also incorporate http://php.net/filemtime to automatically
remove locks that are older than, say, an hour, so that aborted/killed
scripts don't stay locked up.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Exactly what I needed. Thank you!
Rasmus Lerdorf wrote:
> Shu Chow wrote:
>> Is there any way to alter the header of DomDocument's
>> load/loadHTMLFile request? I have a file that will display certain
>> content for certain user agents. I'd like to be able to spoof the UA
>> of the request.
>
> Ah, a good question the answer to which demonstrates the magic of PHP
> 5's stream contexts which is meant to solve this exact problem.
>
> The example in the documentation is even exactly the user-agent one. See:
>
> http://php.net/libxml_set_streams_context
>
> -Rasmus
attached mail follows:
Joe Wollard wrote:
> If you don't want to change the names of the files themselve from .php to
> .abc then you'd need to use something like mod_rewrite for apache's HTTPD.
> I'm not entirely certain as to how you'd do this, but I've included what I
> normally use to hide index.php in the url. If possible I'd put this in
> httpd.conf instead of .htaccess - there are performance concerns that
> may be
> involved there. Anyway, I hope this gets you started or sparks an idea from
> another list member.
>
> <Directory /var/www/html/>
> RewriteEngine on
> RewriteBase /
>
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
off the top of my head, the following rule would
translate 'afilenamestub.foo' (where 'foo' can be any extension,
and 'afilenamestub' can contain dots) to 'afilenamestub.php':
RewriteRule ^(.*)\.[^.]*$ $1.php [L,QSA]
combined with the RewriteConds given above (to only rewrite
when a file doesn't exist and/or isn't a dir)
no warranty is available - I happily lose days trying to get RewriteRules
running and tuned :-P chances are it requires tweaking to get working.
> RewriteRule ^(.*)$ index.php/$1 [L,QSA]
> </Directory>
..
attached mail follows:
On Tue, June 6, 2006 3:38 pm, Jochem Maas wrote:
> no warranty is available - I happily lose days trying to get
> RewriteRules
> running and tuned :-P chances are it requires tweaking to get working.
Which is one of the reasons I abandoned mod_rewrite as a solution for
URL-munging.
MUCH easier to use .htaccess and Files/ForceType to get what I want to
be PHP, and then to access $_SERVER['PATH_INFO'] to get the
URL-parameters.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Hello!
Basically, I am working on a script that is supposed to convert table
data from metric to imperial data. I want to pare XHTML pages
(containing up to three different tables) with the PHP DOM functions
in order to be able to access and manipulate the tables one by one.
Parsing and retrieving table headers and cells is not the problem.
The problem right now is how to replace data in the headers.
Here is a rather simplified example of a table I want to convert:
Header contains: Product | Lenght <br /> mm | Width <br />mm |
Weight <br /> kg
As you can see, table headers can contain one or more words and a
(optional) line break. Currently, I am able to get all headers as a
list of nodes from where I can access all headers one by one. But
when I try to replace some content like this:
# $nodeElement contains the current text node from a header
$str = "some new content";
$new_header_element = $doc -> createTextNode ( $str );
$nodeElement -> parentNode -> replaceChild ( $new_element,
$nodeElement );
.. I am able to replace e.g. "Product", "Length" or "Width". I am not
able to access / replace anything after the line-break. Why? I have
already tested to get to this content with $nodeElement ->
childNodes; but this will throw an error.
Hopefully, I was able to explain my problem to you... OOP and
especially working with the DOM functions are still very new to me,
so please be patient with me.
If anyone has an idea, I would love to hear about it. Otherwise,
there might be someone how can point me to some good on-line
documentation / tutorials regarding PHP DOM functions.
Thank you and good night.
/frank
attached mail follows:
Frank Arensmeier wrote:
> Hello!
>
> Basically, I am working on a script that is supposed to convert table
> data from metric to imperial data. I want to pare XHTML pages
> (containing up to three different tables) with the PHP DOM functions in
> order to be able to access and manipulate the tables one by one. Parsing
> and retrieving table headers and cells is not the problem. The problem
> right now is how to replace data in the headers.
>
> Here is a rather simplified example of a table I want to convert:
>
> Header contains: Product | Lenght <br /> mm | Width <br />mm | Weight
> <br /> kg
>
> As you can see, table headers can contain one or more words and a
> (optional) line break. Currently, I am able to get all headers as a list
> of nodes from where I can access all headers one by one. But when I try
> to replace some content like this:
>
> # $nodeElement contains the current text node from a header
not all of it - because the 'current' text is actual a series of
text and xml nodes (each <br /> and the text between being a seperate node)
>
> $str = "some new content";
> $new_header_element = $doc -> createTextNode ( $str );
> $nodeElement -> parentNode -> replaceChild ( $new_element, $nodeElement );
you'll need to remove all children of parentNode and then append the new node
(for arguments sake - you could do it another way but the result would/should be
the same) because the contents of the 'Header' (the parentNode) is actually a
set of nodes:
i.e. this:
Product | Lenght <br /> mm | Width <br />mm | Weight
ammounts to this (pseudo markup):
<textNode/><xmlNode/><textNode/><xmlNode/><textNode/>
and you are currently replacing only the first [text]node
hth
>
> .. I am able to replace e.g. "Product", "Length" or "Width". I am not
> able to access / replace anything after the line-break. Why? I have
> already tested to get to this content with $nodeElement -> childNodes;
> but this will throw an error.
>
> Hopefully, I was able to explain my problem to you... OOP and especially
> working with the DOM functions are still very new to me, so please be
> patient with me.
>
> If anyone has an idea, I would love to hear about it. Otherwise, there
> might be someone how can point me to some good on-line documentation /
> tutorials regarding PHP DOM functions.
>
> Thank you and good night.
> /frank
>
> --PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
attached mail follows:
Resources cannot be stored from script to script.
PHP cleans them up and nukes their contents at script end.
This is what all the "frameworks" folks are trying to "fix"...
:-) :-) :-)
On Tue, June 6, 2006 8:55 am, Ruben Rubio Rey wrote:
> Hi,
>
> Im having a trouble using memcached with pear db.
>
> When im using memcache to store and retrieve an string, all works
> fine.
> When Im using memcache to store a pear db resulset, it does not work!!
>
> This retrieves data but pear::db does not understand it.
> I really dont know
>
> Any ideas?
> Thanks in advance
>
> Code:
>
> $sql = "SELECT * FROM anytable";
> $myownqry= cachedSQL($sql);
>
> while ($rs_qryPhoto =& $myownqry->fetchRow()) {
> echo "OK<bR>"; //When variable is taken from cache, nothink is
> shown!!!
> }
>
>
> $MEMCACHE_CONNECTED=0;
> $MEMCACHE_STR="";
> function memcachedConnect(){
>
> global $MEMCACHE_CONNECTED,$MEMCACHE_STR;
>
> if(!($MEMCACHE_CONNECTED)){
> $MEMCACHE_CONNECTED=1;
> $MEMCACHE_STR = memcache_connect('192.168.2.8', 11211);
> }
>
> }
>
> function cachedSQL($sSQL) {
> global $db,$MEMCACHE_CONNECTED,$MEMCACHE_STR;
> memcachedConnect();
>
> if($tmp=memcache_get($MEMCACHE_STR,MD5($sSQL))){
> echo "Cached<br>";
> //echo var_dump($tmp);
> }else{
> $tmp = $db->query($sSQL);
> //echo var_dump($tmp);
> echo "<b>NOT</b> Cached<br>";
> memcache_set($MEMCACHE_STR, MD5($sSQL), $tmp, 0, 10);
>
> }
> echo "<br><br>";
> return $tmp;
>
> }
>
>
> --
> 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
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]