php-general Digest 6 Jun 2006 16:47:01 -0000 Issue 4170

2006-06-06 Thread php-general-digest-help

php-general Digest 6 Jun 2006 16:47:01 - Issue 4170

Topics (messages 237441 through 237465):

Re: When is z != z ?
237441 by: Robert Cummings
237452 by: Ford, Mike
237453 by: Finner, Doug
237456 by: Martin Alterisio
237458 by: Rasmus Lerdorf
237459 by: Barry
237460 by: Martin Alterisio
237461 by: Martin Alterisio
237465 by: Robert Cummings

Cannot read variables
237442 by: William Stokes
237448 by: The Panister
237451 by: David Otton
237454 by: William Stokes
237462 by: Adam Zey

Removing an aspect of a variable...
237443 by: Rob W.
237444 by: Rob W.
237445 by: Peter Lauri
237446 by: Robin Vickery
237447 by: Paul Novitski
237450 by: David Otton

Re: Session variables on Windows
237449 by: The Panister

Re: Using variable content to name a class
237455 by: Jochem Maas

Pear DB and memcached
237457 by: Ruben Rubio Rey
237463 by: Ben Ramsey
237464 by: Ruben Rubio Rey

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


--
---BeginMessage---
On Tue, 2006-06-06 at 00:01, Martin Alterisio wrote:
  Because defining ++ and  and  in such a way as to make them behave like
  numbers would have made them not work for alphabetizing.  A string is a
  string, and comparison of strings is alphabetic (for some definition of
  alphabet).  It's more useful to deal with strings as strings than to make
  them quack like numbers.
 
 
 Then, if it's not a math operation, why use a math operator for such
 functionality? In which way is the ++ operator that generates a string

I don't ever remember seeing ++ in math class. I do remember seeing it
in lots of computer classes and to that end it was just an operator
with whatever semantic meaning was applied to it for a given language. I
guess it's usually to increment an integer, but that's just in
general. I mean if we want to get into math operators being used for
string purposes, then we should look at how many languages use the +
operator to concatenate two strings -- by your accounts they should
treat their operands as integers and do a rote addition.

 sequence, useful enough to justify the formal inconsistency between the math
 operators? I still don't see the advantages of having the ++ recognize the
 string as a sequence, and generate the next item in the sequence. I believe
 those decisions should be left to the coder, because he knows what the
 string really represents and which kind of sequence is being used.

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.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'
---End Message---
---BeginMessage---
On 06 June 2006 02:35, tedd wrote:

 
 a b c ... x y z aa ab ac ... yx yy yz za zb zc ... zy zx zz aaa aab
 
 -- it's not!

Yes it is.  The ++ operator generates that sequence when applied to a string, 
and nothing you can say or do will alter that fact.

You're trying to treat the 2nd and 3rd elements of the for () statement as an 
integrated unit, but they're not - the 2nd element generates the elements of 
the sequence in whatever order it generates in, and the 3rd element simply 
applies a test to the generated values and causes the sequence to stop the 
first time the test fails -- it's not in any way a limiter for what values will 
be generated.

Using simple integers, I could code something like this, which would exhibit 
similar properties:

   for ($i=0; $i=($i+7)%100; $i99)

The expression $i=($i+7)%100 is a generator for all integers in the set 
[0,100], but in a non-linear order; the test $i99 will cause the loop to stop 
part way through the generated sequence, before some of the values which would 
satisfy the test have been produced.

 You can't say that a and aaa are members of a set
 identified as  z and then step through 

[PHP] Cannot read variables

2006-06-06 Thread William Stokes
Hello,

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.

I turned to Register Globals on in the php.ini but that didn't help. Any 
ideas?

Thanks
-Will 


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



[PHP] Removing an aspect of a variable...

2006-06-06 Thread Rob W.
Say I have a variable setting an ip address of 192.168.100.0

I want to be able to remove the last to chr's of that variable ie: .0

What would be my best solution to do that?

Re: [PHP] Removing an aspect of a variable...

2006-06-06 Thread Rob W.

Tnx.

- Original Message - 
From: rich gray [EMAIL PROTECTED]

To: Rob W. [EMAIL PROTECTED]
Sent: Tuesday, June 06, 2006 2:44 AM
Subject: Re: [PHP] Removing an aspect of a variable...



substr($variable,0,-2);

Rob W. wrote:

Say I have a variable setting an ip address of 192.168.100.0

I want to be able to remove the last to chr's of that variable ie: .0

What would be my best solution to do that?
  






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



RE: [PHP] Removing an aspect of a variable...

2006-06-06 Thread Peter Lauri
But that will just give you .0. If you have 192.168.100.232 it will return
32. You have to check where the . is and then take the substring from that.
Use strpos or similar for that (I do not know if that can check backwards)

-Original Message-
From: Rob W. [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 06, 2006 2:47 PM
To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Subject: Re: [PHP] Removing an aspect of a variable...

Tnx.

- Original Message - 
From: rich gray [EMAIL PROTECTED]
To: Rob W. [EMAIL PROTECTED]
Sent: Tuesday, June 06, 2006 2:44 AM
Subject: Re: [PHP] Removing an aspect of a variable...


 substr($variable,0,-2);
 
 Rob W. wrote:
 Say I have a variable setting an ip address of 192.168.100.0

 I want to be able to remove the last to chr's of that variable ie: .0

 What would be my best solution to do that?
   
 
 


-- 
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



Re: [PHP] Removing an aspect of a variable...

2006-06-06 Thread Robin Vickery

On 06/06/06, Rob W. [EMAIL PROTECTED] wrote:

Say I have a variable setting an ip address of 192.168.100.0

I want to be able to remove the last to chr's of that variable ie: .0

What would be my best solution to do that?



Remove the last two characters of a string?

  $shorterString = substr($string, 0, -2);

Whether that's really what you want to be doing with an IP address is up to you.

-robin

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



Re: [PHP] Removing an aspect of a variable...

2006-06-06 Thread Paul Novitski

At 12:37 AM 6/6/2006, Rob W. wrote:

Say I have a variable setting an ip address of 192.168.100.0

I want to be able to remove the last to chr's of that variable ie: .0

What would be my best solution to do that?



If you want the last two characters you can use substr():

[1] $sResult = substr($sIP, -2);


If you want the string from the last period onward, regardless of 
length, you can use strrpos() and substr():


[2] $iPos = strrpos($sIP, .);
if ($iPos !== FALSE) $sResult = substr($sIP, -$iPos);

Take the time to read about various string functions -- you'll thank yourself.
http://php.net/strings

Paul



[1] substr
http://php.net/substr
see Example 2. Using a negative start

[2] strrpos
http://php.net/strrpos 


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



[PHP] Re: Cannot read variables

2006-06-06 Thread The Panister
Can you show us the script please?

William Stokes [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hello,

 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.

 I turned to Register Globals on in the php.ini but that didn't help. Any
 ideas?

 Thanks
 -Will


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



[PHP] Re: Session variables on Windows

2006-06-06 Thread The Panister
Well Do you have folder called tmp in your root?

ThePanister!

Tom [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Does some well-known problem exist with the session variables in Windows
 servers?
 Because in a system that I have running on a Windows server, sometimes the
 session variables are null causing errors, then I close the browser and
open
 it and in the next intent everything works well... I can't understand
why...
 The same system in a Linux server runs well always ¿?

 Ahead of time, thank you very much,

 Tom.

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



Re: [PHP] Removing an aspect of a variable...

2006-06-06 Thread David Otton
On Tue, 6 Jun 2006 08:52:46 +0100, Robin Vickery wrote:

On 06/06/06, Rob W. [EMAIL PROTECTED] wrote:
 Say I have a variable setting an ip address of 192.168.100.0

 I want to be able to remove the last to chr's of that variable ie: .0

 What would be my best solution to do that?


Remove the last two characters of a string?

   $shorterString = substr($string, 0, -2);

Whether that's really what you want to be doing with an IP address is up to 
you.

substr will remove the last two characters from a string, as mentioned
above.

If you want to remove the last byte from an IP address (which could be
.0, .10, or .100) I would suggest:

$ip = 192.168.100.0;
$ip = explode ('.', $ip);
array_pop ($ip);
$ip = implode ('.', $ip);

With PHP 5.1 and up, explode accepts a negative limit, which would
simplify things.

-- 

http://www.otton.org/

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



Re: [PHP] Cannot read variables

2006-06-06 Thread David Otton
On Tue, 6 Jun 2006 10:36:12 +0300, you 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.

I turned to Register Globals on in the php.ini but that didn't help. Any 
ideas?

Most likely you didn't turn RG on (typo? wrong php.ini?), or didn't
restart.

Try:

print_r ($_POST);
print_r ($_GET);
print_r ($_REQUEST);

to see if your variable is being passed. If it is, PHP isn't set up as
you want it. If it isn't, there's something more fundamental wrong.

-- 

http://www.otton.org/

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



RE: [PHP] When is z != z ?

2006-06-06 Thread Ford, Mike
On 06 June 2006 02:35, tedd wrote:

 
 a b c ... x y z aa ab ac ... yx yy yz za zb zc ... zy zx zz aaa aab
 
 -- it's not!

Yes it is.  The ++ operator generates that sequence when applied to a string, 
and nothing you can say or do will alter that fact.

You're trying to treat the 2nd and 3rd elements of the for () statement as an 
integrated unit, but they're not - the 2nd element generates the elements of 
the sequence in whatever order it generates in, and the 3rd element simply 
applies a test to the generated values and causes the sequence to stop the 
first time the test fails -- it's not in any way a limiter for what values will 
be generated.

Using simple integers, I could code something like this, which would exhibit 
similar properties:

   for ($i=0; $i=($i+7)%100; $i99)

The expression $i=($i+7)%100 is a generator for all integers in the set 
[0,100], but in a non-linear order; the test $i99 will cause the loop to stop 
part way through the generated sequence, before some of the values which would 
satisfy the test have been produced.

 You can't say that a and aaa are members of a set
 identified as  z and then step through all the members of
 that population (an infinite group) and not include aaa --
 UNLESS -- you arbitrarily determine an end point for a much
 smaller sub-set.

See argument above: you're not stepping through all members of the set  z -- 
or even, as in the original loop, = z -- you're stepping through all members 
of the set of strings containing any number of the characters [a-z] in any 
combination, in the order defined by the ++ operator, and terminating on the 
first generated element which is *not* = z.  There's nothing in there that 
says you have to generate *all* strings = z before terminating -- just that 
you stop on generating one that isn't.

 Now, unless, there is something that I don't see, which
 certainly could be the case, then php designers could have
 just as easily ended the loop at z and dispensed with this
 quirk all together.

Well, if the quirk were eliminated by making z++ be the next character in the 
ASCII sequence, the loop would still not end at z -- it would end on 
encountering { (if I remember my ASCII correctly).

 Besides, what's the point of having 676 character between a
 and z? Is there one?

No. And there aren't. There are 676 *strings, of length 1 and 2, as generated 
by the ++ operator.

You have to remember that there is no such type as 'character' in PHP -- just 
strings of length 1.  And strings don't (necessarily) behave like characters.

 But this is the way it is and I except that -- but as Dirty
 Harry once said A man's got to know his limitations -- this
 not only applies to men and programmers, but also for
 languages as well.
 
 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 00-FF code-points.

Well, the PHP manual says: Note that character variables can be incremented 
but not decremented and even so only plain ASCII characters (a-z and A-Z) are 
supported.  If that continues to be the case, then the Unicode argument may be 
moot.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



[PHP] Re: When is z != z ?

2006-06-06 Thread Finner, Doug
I love this thread.  Who'da thunk alphabets could be so much fun?

FWIW:
Different language, different rules - to do 'letter math', letters must
be converted to their ASCII number value, add one, convert back to a
letter.  The set of allowed ASCII numbers is limited to (I think) 256
and 'real' letters are a subset of that collection.
Going from a-z was easy.  Once you hit z, you reverted character 1 to a,
then looped a-z for character 2, repeat as required.

There were only a couple of ways to evaluate a string's 'size';
alphabetical and length.  Each comparison generated different results
and one had to choose the comparison method based on the particular
requirements.  In order to convert a string to some numeric value, I
believe I had to do it letter-by-letter and derive my own 'value' for
the string which would be mostly useless.  

While the specific language methods differ from PHP (the language did
not allow anything like 'a'++ so this particular discussion couldn't
happen), it doesn't seem to me that the philosophical underpinnings are
all that different - letters are special.  They look and behave
differently depending on the particular microscope you happen to be
using.

Anybody want to talk about rounding?  ;-)

Doug

___
This e-mail message has been sent by Kollsman, Inc. and is for the use
of the intended recipients only. The message may contain privileged
or confidential information. If you are not the intended recipient
you are hereby notified that any use, distribution or copying of
this communication is strictly prohibited, and you are requested to
delete the e-mail and any attachments and notify the sender immediately.

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



Re: [PHP] Cannot read variables

2006-06-06 Thread William Stokes
Yess!

Wrong ini file...
There seems to be 3 of them on the same PC for some reason?

-W

David Otton [EMAIL PROTECTED] kirjoitti 
viestissä:[EMAIL PROTECTED]
 On Tue, 6 Jun 2006 10:36:12 +0300, you 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.

I turned to Register Globals on in the php.ini but that didn't help. Any
ideas?

 Most likely you didn't turn RG on (typo? wrong php.ini?), or didn't
 restart.

 Try:

 print_r ($_POST);
 print_r ($_GET);
 print_r ($_REQUEST);

 to see if your variable is being passed. If it is, PHP isn't set up as
 you want it. If it isn't, there's something more fundamental wrong.

 -- 

 http://www.otton.org/ 

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



Re: [PHP] Using variable content to name a class

2006-06-06 Thread Jochem Maas
Dave M G wrote:
 Chris,
 
 Thank you for replying.
 $object = new $className();
 Is this possible?
 If in doubt, test it out ;)
 Yes, it will work.
 Oh, that's actually the code I can use? I just wrote it as an
 explanatory aid, not thinking that it could be literally done like that.
 I assumed there was a specific command I was missing.
 
 Well, anyway, I guess I've stumbled on the right syntax. Thank you for
 pointing it out to me.

also check out call_user_func() and call_user_func_array() - you might
find them handy in certain situations.

 
 -- 
 Dave M G
 

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



Re: [PHP] When is z != z ?

2006-06-06 Thread Martin Alterisio

2006/6/6, Robert Cummings [EMAIL PROTECTED]:


On Tue, 2006-06-06 at 00:01, Martin Alterisio wrote:
  Because defining ++ and  and  in such a way as to make them behave
like
  numbers would have made them not work for alphabetizing.  A string is
a
  string, and comparison of strings is alphabetic (for some definition
of
  alphabet).  It's more useful to deal with strings as strings than to
make
  them quack like numbers.
 

 Then, if it's not a math operation, why use a math operator for such
 functionality? In which way is the ++ operator that generates a string

I don't ever remember seeing ++ in math class. I do remember seeing it
in lots of computer classes and to that end it was just an operator
with whatever semantic meaning was applied to it for a given language. I
guess it's usually to increment an integer, but that's just in
general. I mean if we want to get into math operators being used for
string purposes, then we should look at how many languages use the +
operator to concatenate two strings -- by your accounts they should
treat their operands as integers and do a rote addition.

 sequence, useful enough to justify the formal inconsistency between the
math
 operators? I still don't see the advantages of having the ++ recognize
the
 string as a sequence, and generate the next item in the sequence. I
believe
 those decisions should be left to the coder, because he knows what the
 string really represents and which kind of sequence is being used.

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.

I'm not saying It's wrong let's change it right away!, I completely agree
that these rules can be bent on a not strongly typed language. The point I'm
trying to make, the thing I want to understant without a trace of doubt, is:
is it really worthy the functionality supplied with the string ++ operator
as it is? I don't see its usefullness yet.


[PHP] Pear DB and memcached

2006-06-06 Thread Ruben Rubio Rey

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 OKbR;//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 Cachedbr;
   //echo var_dump($tmp);
   }else{
   $tmp = $db-query($sSQL);
   //echo var_dump($tmp);
   echo bNOT/b Cachedbr;
   memcache_set($MEMCACHE_STR, MD5($sSQL), $tmp, 0, 10);
  
   }

   echo brbr;
   return $tmp;

 }


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



Re: [PHP] When is z != z ?

2006-06-06 Thread Rasmus Lerdorf

Martin Alterisio wrote:

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.

I'm not saying It's wrong let's change it right away!, I completely agree
that these rules can be bent on a not strongly typed language. The point 
I'm
trying to make, the thing I want to understant without a trace of doubt, 
is:

is it really worthy the functionality supplied with the string ++ operator
as it is? I don't see its usefullness yet.


It has been in PHP from the very beginning.  So 10+ years.  In that time 
it has been sparingly used, granted, but at the same time it really 
hasn't gotten in the way and removing it would break a number of legacy 
applications.


There were a lot more operators that worked on strings in the early 
days.  '*' would do a cross-product, for example, treating the two 
string operands as vectors and returning a vector orthogonal to both of 
these.  But I got tired of trying to explain to people what a cross 
product was and how strings mapped to vectors in Euclidean space and 
removed that.  You could also at one point do abc-b to get ac.


-Rasmus

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



Re: [PHP] When is z != z ?

2006-06-06 Thread Barry

Martin Alterisio schrieb:


is it really worthy the functionality supplied with the string ++ operator
as it is? I don't see its usefullness yet.


guess you want to order something by name not by number which might be 
false in some cases (1,10,2,20,21 ... and so on).


There it might be useful.

Well i don think it is wrong behavior in that way.

because having looping from a till z you wil get aa after z  so that 
means aa is higher as z internally.


but looping till aa dont brings out a-z like you get a-y when you loop 
till z (remember: for $i = a; $i = z; $i++ gives the chars a-yz z right 
followed by aa)


Well if you implement something like that into a programming language it 
should at least have some kind of logic behavior. Don't you think?


--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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



Re: [PHP] When is z != z ?

2006-06-06 Thread Martin Alterisio

2006/6/6, Barry [EMAIL PROTECTED]:


Martin Alterisio schrieb:

 is it really worthy the functionality supplied with the string ++
operator
 as it is? I don't see its usefullness yet.

guess you want to order something by name not by number which might be
false in some cases (1,10,2,20,21 ... and so on).

There it might be useful.

Well i don think it is wrong behavior in that way.

because having looping from a till z you wil get aa after z  so that
means aa is higher as z internally.

but looping till aa dont brings out a-z like you get a-y when you loop
till z (remember: for $i = a; $i = z; $i++ gives the chars a-yz z right
followed by aa)

Well if you implement something like that into a programming language it
should at least have some kind of logic behavior. Don't you think?



That's okay, but not where my doubts are. I have not objections to the
comparison made alphabetically. What I doubt is the usefullness of
generating sequences with ++.


Re: [PHP] When is z != z ?

2006-06-06 Thread Martin Alterisio

2006/6/6, Rasmus Lerdorf [EMAIL PROTECTED]:


Martin Alterisio wrote:
 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.

 I'm not saying It's wrong let's change it right away!, I completely
agree
 that these rules can be bent on a not strongly typed language. The point
 I'm
 trying to make, the thing I want to understant without a trace of doubt,
 is:
 is it really worthy the functionality supplied with the string ++
operator
 as it is? I don't see its usefullness yet.

It has been in PHP from the very beginning.  So 10+ years.  In that time
it has been sparingly used, granted, but at the same time it really
hasn't gotten in the way and removing it would break a number of legacy
applications.



Well, that's enough reason to me, although a pain in the ass, backward
compatibility is an important issue. There will be plenty of opportunities
in future versions to revise this, for now my mind is at ease.

There were a lot more operators that worked on strings in the early

days.  '*' would do a cross-product, for example, treating the two
string operands as vectors and returning a vector orthogonal to both of
these.  But I got tired of trying to explain to people what a cross
product was and how strings mapped to vectors in Euclidean space and
removed that.  You could also at one point do abc-b to get ac.

-Rasmus



That's quite an anecdote, why isn't it somewhere in the php website or
manual? It's nice to know the humans behind the soft ^_^

That kind of operation might have been useful with arrays, as some other
operations to work with them as if they were sets (inclusion, union,
difference, etc). Yes, we have functions for that but apply a few of them
inside an if statement and I start to have LISP nightmares with all those
parenthesis.


Re: [PHP] Cannot read variables

2006-06-06 Thread Adam Zey

William Stokes wrote:

Yess!

Wrong ini file...
There seems to be 3 of them on the same PC for some reason?

-W

David Otton [EMAIL PROTECTED] kirjoitti 
viestissä:[EMAIL PROTECTED]

On Tue, 6 Jun 2006 10:36:12 +0300, you 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.

I turned to Register Globals on in the php.ini but that didn't help. Any
ideas?

Most likely you didn't turn RG on (typo? wrong php.ini?), or didn't
restart.

Try:

print_r ($_POST);
print_r ($_GET);
print_r ($_REQUEST);

to see if your variable is being passed. If it is, PHP isn't set up as
you want it. If it isn't, there's something more fundamental wrong.

--

http://www.otton.org/ 


Turn off register globals. Now. It is a HUGE security hole.

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 :)


Regards, Adam Zey.

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



[PHP] Re: Pear DB and memcached

2006-06-06 Thread Ben Ramsey

On 6/6/06 9:55 AM, Ruben Rubio Rey wrote:

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


This is because $db-query returns a resource, which is a reference to 
the data and not the data itself.


For example, let's say you're using the MySQL driver for PEAR::DB, then 
when you call $db-query(), it uses mysql_query(). This function will 
return a resource. When you store the resource to the memcache server 
and then later retrieve it, it no longer maintains its reference to the 
data.


If you want to store the data to the cache, I suggest you use getAll() 
to retrieve an array of data and then store that to the memcache server:


$db-setFetchMode(DB_FETCHMODE_ASSOC);
$data = $db-getAll($sSQL);
memcache_set($MEMCACHE_STR, MD5($sSQL), $data, 0, 10);

Now, your result set is stored properly on the memcache server.

--
Ben Ramsey
http://benramsey.com/

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



Re: [PHP] Re: Pear DB and memcached

2006-06-06 Thread Ruben Rubio Rey

Ben Ramsey wrote:


On 6/6/06 9:55 AM, Ruben Rubio Rey wrote:


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



This is because $db-query returns a resource, which is a reference to 
the data and not the data itself.


For example, let's say you're using the MySQL driver for PEAR::DB, 
then when you call $db-query(), it uses mysql_query(). This function 
will return a resource. When you store the resource to the memcache 
server and then later retrieve it, it no longer maintains its 
reference to the data.


If you want to store the data to the cache, I suggest you use getAll() 
to retrieve an array of data and then store that to the memcache server:


$db-setFetchMode(DB_FETCHMODE_ASSOC);
$data = $db-getAll($sSQL);
memcache_set($MEMCACHE_STR, MD5($sSQL), $data, 0, 10);

Now, your result set is stored properly on the memcache server.

Yes, it has sense. I have been working arround it but I didn't found the 
solution. I ll try it tomorrow I ll tell what has happen!!!


Thanks a lot men!

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



Re: [PHP] When is z != z ?

2006-06-06 Thread Robert Cummings
On Tue, 2006-06-06 at 09:46, Martin Alterisio wrote:
 2006/6/6, Robert Cummings [EMAIL PROTECTED]:

  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-generalm=114945456908350w=2

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.  |
`'

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



[PHP] 1,600,000 ��ª��������� �Ѵ������§�ӴѺ�ѡ���дǡ����Ѻ���¸�áԨ�ͧ��ҹ ��������������������ѹ���¨ҡ��ҧ�������ա�������ҧ �ҤҶ١�ҡ���������ա���� ��˹��¨ӹǹ�ӡѴ

2006-06-06 Thread 1,600,000 ��ª��������� �Ѵ������§�ӴѺ�ѡ���дǡ����Ѻ���¸�áԨ�ͧ��ҹ ��������������������ѹ���¨ҡ��ҧ�������ա�������ҧ �ҤҶ١�ҡ���������ա���� ��˹��¨ӹǹ�ӡѴ
1,600,000 ÃÒª×èÍÍÕàÁÅì ¤Ñ´ÊÃÃàÃÕ§ÅӴѺÍÑ¡ÉÃÊдǡÊÓËÃѺ¢ÂÒ¸ØáԨ¢Í§·èÒ¹ 
¾ÃéÍÁ·Ñé§á¶Áâ»Ãá¡ÃÁ·Ñ¹ÊÁѨҡµèÒ§»ÃÐà·ÈÍÕ¡ËÅÒÂÍÂèÒ§ ÃÒ¤Ò¶Ù¡ÁÒ¡ËÒäÁèä´éÍÕ¡áÅéÇ 
¨Ó˹èÒ¨ӹǹ¨Ó¡Ñ´
µÔ´¨ÃÇ´ãËé¸ØáԨ¢Í§·èÒ¹´éÇ¡ÒûÃЪÒÊÑÁ¾Ñ¹¸ì¸ØáԨ·Ò§ÍÕàÁÅì 
â´Âµé¹·Ø¹·ÕèµèÓáÅмŵͺÃѺ·Õè´Õ·ÕèÊØ´
´éÇÂÍÕàÁÅì 1.6 ÅéÒ¹àÁÅì 
á¶Áâ»Ãá¡ÃÁ
- Êè§àÁÅì¤Ø³ÀÒ¾ÊÙ§¨Ò¡µèÒ§»ÃÐà·È µÑÇàµçÁãªé§Ò¹ä´éµÅÍ´ 
- â»Ãá¡ÃÁ´Ù´àÁÅì¤Ø³ÀÒ¾ÊÙ§¨Ò¡µèÒ§»ÃÐà·È µÑÇàµçÁãªé§Ò¹ä´éµÅÍ´ 
- µÑÇ¡ÃͧÍÕàÁÅì ¤Ø³ÀÒ¾ÊÙ§¨Ò¡µèÒ§»ÃÐà·È µÑÇàµçÁãªé§Ò¹ä´éµÅÍ´ 

ÇÔ¸Õ¡ÒèѴÊè§ÊÔ¹¤éÒ Êè§ EMS ·èÒ¹¨Ðä´éÃѺÊÔ¹¤éÒÀÒÂã¹ 1-2 Çѹ
ËÃ×Í ´ÒǹìâËÅ´ÀÒÂã¹ 1-2 ª.Á. ãªéä´éàÅÂ

ÃÒ¤Ò 790 ºÒ·
ʹã¨â·Ã 06-7815050
ÍÕàÁÅì  [EMAIL PROTECTED]

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



Re: [PHP] When is z != z ?

2006-06-06 Thread tedd
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 00-FF 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 

Re: [PHP] When is z != z ?

2006-06-06 Thread Martin Alterisio

2006/6/6, Robert Cummings [EMAIL PROTECTED]:


On Tue, 2006-06-06 at 09:46, Martin Alterisio wrote:
 2006/6/6, Robert Cummings [EMAIL PROTECTED]:

  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-generalm=114945456908350w=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.


Re: [PHP] When is z != z ?

2006-06-06 Thread Adam Zey

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.

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



[PHP] Getting totals

2006-06-06 Thread Rob W.
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.

Re: [PHP] When is z != z ?

2006-06-06 Thread Robert Cummings
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.  |
`'

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



Re: [PHP] When is z != z ?

2006-06-06 Thread Robert Cummings
On Tue, 2006-06-06 at 13:11, Martin Alterisio wrote:
 2006/6/6, Robert Cummings [EMAIL PROTECTED]:
 
  On Tue, 2006-06-06 at 09:46, Martin Alterisio wrote:
   2006/6/6, Robert Cummings [EMAIL PROTECTED]:
  
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-generalm=114945456908350w=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.  |
`'

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



Re: [PHP] When is z != z ?

2006-06-06 Thread Paul Novitski

At 10:38 AM 6/4/2006, tedd wrote:

for ($i=a; $iz; $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 


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



Re: [PHP] When is z != z ?

2006-06-06 Thread tedd
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

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



[PHP] Weird Safari Stalling Issues Sessions?

2006-06-06 Thread Paul Nowosielski
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

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



Re: [PHP] Getting totals

2006-06-06 Thread Jochem Maas
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.

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



Re: [PHP] When is z != z ?

2006-06-06 Thread Martin Alterisio

2006/6/6, Robert Cummings [EMAIL PROTECTED]:


On Tue, 2006-06-06 at 13:11, Martin Alterisio wrote:
 2006/6/6, Robert Cummings [EMAIL PROTECTED]:
 
  On Tue, 2006-06-06 at 09:46, Martin Alterisio wrote:
   2006/6/6, Robert Cummings [EMAIL PROTECTED]:
  
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-generalm=114945456908350w=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.


[PHP] Controlling DomDocument's load and loadHTMLFile Request

2006-06-06 Thread Shu Chow
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,

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



[PHP] Controlling DomDocument's load and loadHTMLFile Request

2006-06-06 Thread Shu Chow
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,

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



Re: [PHP] When is z != z ?

2006-06-06 Thread tedd
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

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



Re: [PHP] Controlling DomDocument's load and loadHTMLFile Request

2006-06-06 Thread Jochem Maas
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,
 

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



Re: [PHP] When is z != z ?

2006-06-06 Thread Martin Alterisio

2006/6/6, tedd [EMAIL PROTECTED]:


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!


Re: [PHP] When is z != z ?

2006-06-06 Thread Robert Cummings
On Tue, 2006-06-06 at 14:06, Martin Alterisio wrote:
 2006/6/6, Robert Cummings [EMAIL PROTECTED]:
 
You must have missed this post:
   
http://marc.theaimsgroup.com/?l=php-generalm=114945456908350w=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.  |
`'

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



Re: [PHP] When is z != z ?

2006-06-06 Thread John Nichel

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
[EMAIL PROTECTED]

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



Re: [PHP] Weird Safari Stalling Issues Sessions?

2006-06-06 Thread tedd
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

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



Re: [PHP] Getting totals

2006-06-06 Thread Rob W.
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: [EMAIL PROTECTED]

To: Rob W. [EMAIL PROTECTED]
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. [EMAIL PROTECTED]
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 --





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



Re: [PHP] When is z != z ?

2006-06-06 Thread Martin Alterisio

2006/6/6, Robert Cummings [EMAIL PROTECTED]:


On Tue, 2006-06-06 at 14:06, Martin Alterisio wrote:
 2006/6/6, Robert Cummings [EMAIL PROTECTED]:
 
You must have missed this post:
   
http://marc.theaimsgroup.com/?l=php-generalm=114945456908350w=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?


Re: [PHP] Cannot read variables

2006-06-06 Thread Jochem Maas
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.
 

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



Re: [PHP] Getting totals

2006-06-06 Thread Rabin Vincent

On 6/6/06, Rob W. [EMAIL PROTECTED] 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



Re: [PHP] When is z != z ?

2006-06-06 Thread tedd
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

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



[PHP] Sessions

2006-06-06 Thread Oliver Block
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

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



Re: [PHP] When is z != z ?

2006-06-06 Thread Robert Cummings
On Tue, 2006-06-06 at 14:31, Martin Alterisio wrote:
 2006/6/6, Robert Cummings [EMAIL PROTECTED]:
 
  On Tue, 2006-06-06 at 14:06, Martin Alterisio wrote:
   2006/6/6, Robert Cummings [EMAIL PROTECTED]:
   
  You must have missed this post:
 
  http://marc.theaimsgroup.com/?l=php-generalm=114945456908350w=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.  |
`'

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



RE: [PHP] Sessions

2006-06-06 Thread Jay Blanchard
[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

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



Re: [PHP] Weird Safari Stalling Issues Sessions?

2006-06-06 Thread Jochem Maas
tedd wrote:
 
 I use Safari 

...

thefarside
slowly but surely it's became evident that tedd had masochistic tendencies.
/thefarside

;-)

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



Re: [PHP] How do I make a HTML tree for a set of nodes?

2006-06-06 Thread Jochem Maas
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

disclaimerI 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
 

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



Re: [PHP] When is z != z ?

2006-06-06 Thread Martin Alterisio

2006/6/6, Robert Cummings [EMAIL PROTECTED]:


On Tue, 2006-06-06 at 14:31, Martin Alterisio wrote:
 2006/6/6, Robert Cummings [EMAIL PROTECTED]:
 
  On Tue, 2006-06-06 at 14:06, Martin Alterisio wrote:
   2006/6/6, Robert Cummings [EMAIL PROTECTED]:
   
  You must have missed this post:
 
 
http://marc.theaimsgroup.com/?l=php-generalm=114945456908350w=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.


Re: [PHP] Sessions

2006-06-06 Thread Oliver Block
Am Dienstag, 6. Juni 2006 20:51 schrieb Jay Blanchard:
 Yes. http://www.php.net/session

session_set_cookie_params() ?

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



[PHP] Control GET data

2006-06-06 Thread Steffen Mazanek
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


pgpEwVnKO3Apv.pgp
Description: PGP signature


Re: [PHP] When is z != z ?

2006-06-06 Thread Robert Cummings
On Tue, 2006-06-06 at 15:11, Martin Alterisio wrote:
 2006/6/6, Robert Cummings [EMAIL PROTECTED]:

   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.  |
`'

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



Re: [PHP] Control GET data

2006-06-06 Thread John Nichel

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
[EMAIL PROTECTED]

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



Re: [PHP] Control GET data

2006-06-06 Thread Brad Bonkoski

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
 



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



Re: [PHP] Controlling DomDocument's load and loadHTMLFile Request

2006-06-06 Thread Rasmus Lerdorf

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

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



[PHP] starting shell script on server: defer acces when running

2006-06-06 Thread Roel Dillen
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
 


Re: [PHP] Controlling DomDocument's load and loadHTMLFile Request

2006-06-06 Thread Jochem Maas
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 :-)

 

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



Re: [PHP] starting shell script on server: defer acces when running

2006-06-06 Thread Jochem Maas
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 :-)

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



[PHP] Re: [BULK] Re: [PHP] Controlling DomDocument's load and loadHTMLFile Request

2006-06-06 Thread Shu Chow

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


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



Re: [PHP] .htaccess - change index.php to index.abc

2006-06-06 Thread Jochem Maas
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

..

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



[PHP] Replacing text of a DOM text node

2006-06-06 Thread Frank Arensmeier

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

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



Re: [PHP] Control GET data

2006-06-06 Thread tedd
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

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



Re: [PHP] Weird Safari Stalling Issues Sessions?

2006-06-06 Thread Paul Nowosielski
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

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



Re: [PHP] Replacing text of a DOM text node

2006-06-06 Thread Jochem Maas
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
 

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



Re: [PHP] Control GET data

2006-06-06 Thread Richard Lynch
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

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



Re: [PHP] .htaccess - change index.php to index.abc

2006-06-06 Thread Richard Lynch
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

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



Re: [PHP] starting shell script on server: defer acces when running

2006-06-06 Thread Richard Lynch
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

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



Re: [PHP] Sessions

2006-06-06 Thread Richard Lynch
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

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



Re: [PHP] Controlling DomDocument's load and loadHTMLFile Request

2006-06-06 Thread Richard Lynch
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

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



Re: [PHP] Weird Safari Stalling Issues Sessions?

2006-06-06 Thread Richard Lynch
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

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



Re: [PHP] Getting totals

2006-06-06 Thread Richard Lynch
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

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



[PHP] Re: Getting totals

2006-06-06 Thread Rafael
	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

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



Re: [PHP] Pear DB and memcached

2006-06-06 Thread Richard Lynch
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 OKbR;//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 Cachedbr;
 //echo var_dump($tmp);
 }else{
 $tmp = $db-query($sSQL);
 //echo var_dump($tmp);
 echo bNOT/b Cachedbr;
 memcache_set($MEMCACHE_STR, MD5($sSQL), $tmp, 0, 10);

 }
 echo brbr;
 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


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



Re: [PHP] When is z != z ?

2006-06-06 Thread Richard Lynch
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

   .
   .
   .

   .
   .
   .

   .
   .
   .


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

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



Re: [PHP] Cannot read variables

2006-06-06 Thread Richard Lynch
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

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



Re: [PHP] Getting totals

2006-06-06 Thread Rob W.

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 [EMAIL PROTECTED]

To: Rob W. [EMAIL PROTECTED]
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. [EMAIL PROTECTED] 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



Re: [PHP] Getting totals

2006-06-06 Thread Rob W.
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 [EMAIL PROTECTED]

To: Rob W. [EMAIL PROTECTED]
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 [EMAIL PROTECTED]
To: Rob W. [EMAIL PROTECTED]
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. [EMAIL PROTECTED] 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






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



Re: [PHP] Getting totals

2006-06-06 Thread Paul Novitski

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 


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



Re: [PHP] When is z != z ?

2006-06-06 Thread Rasmus Lerdorf

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

   .
   .
   .

   .
   .
   .

   .
   .
   .


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

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



Re: [PHP] When is z != z ?

2006-06-06 Thread Robert Cummings
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.  |
`'

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



Re: [PHP] Getting totals

2006-06-06 Thread Rabin Vincent

On 6/7/06, Rob W. [EMAIL PROTECTED] 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



Re: [PHP] Getting totals

2006-06-06 Thread Rob W.
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 [EMAIL PROTECTED]

To: Rob W. [EMAIL PROTECTED]
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. [EMAIL PROTECTED] 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





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



[PHP] Problem with form

2006-06-06 Thread Rodrigo de Oliveira Costa

Guys I'm getting the following problem:

I have a form that asks for one variable that goes into the input box,
this box is named chapter, and the box is in a form that is submited
to another php, and this php should receive this variable and I should
be abble to access it thru $chapter, but when I try to use the
variable $chapter I get the following error:

Notice: Undefined variable: chapter in c:\arquivos de
programas\easyphp1-8\www\teste.php on line 6

This variable is concatenated into a string and is used to retrieve a
certain page from a domain, if I initialize the variable in the second
php script it goes ok, but if I try to use the one that should be
passed thru the form I get the error above. Does anybody know what I'm
doing wrong?

The second script is bellow so you can understand my problem thank you guys:

?
//$chapter = 1;
$urlChapter = '/'.$chapter.'/';
$url = http://www.domain.com/s/2784825.$urlChapter;;
$texto = file($url);
$result2 = count($texto);
$i = 0;
while ($i  $result2)
{
 echo $texto[$i];
 $i++;
}
?

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



Re: [PHP] Problem with form

2006-06-06 Thread Robert Cummings
On Wed, 2006-06-07 at 01:14, Rodrigo de Oliveira Costa wrote:
 Guys I'm getting the following problem:
 
 I have a form that asks for one variable that goes into the input box,
 this box is named chapter, and the box is in a form that is submited
 to another php, and this php should receive this variable and I should
 be abble to access it thru $chapter, but when I try to use the
 variable $chapter I get the following error:
 
 Notice: Undefined variable: chapter in c:\arquivos de
 programas\easyphp1-8\www\teste.php on line 6
 
 This variable is concatenated into a string and is used to retrieve a
 certain page from a domain, if I initialize the variable in the second
 php script it goes ok, but if I try to use the one that should be
 passed thru the form I get the error above. Does anybody know what I'm
 doing wrong?
 
 The second script is bellow so you can understand my problem thank you guys:
 
 ?
 //$chapter = 1;
 $urlChapter = '/'.$chapter.'/';
 $url = http://www.domain.com/s/2784825.$urlChapter;;
 $texto = file($url);
 $result2 = count($texto);
 $i = 0;
 while ($i  $result2)
 {
   echo $texto[$i];
   $i++;
 }
 ?

You are relying on register_globals being set to on. Instead use the
more secure method of retrieving your submitted data from $_GET or
$_POST (depending on which method your form is set to use). You can
also use $_REQUEST if you don't care from whence the data was submitted
(but you should care :).

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.  |
`'

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