OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
php-general Digest 19 Jun 2007 13:29:39 -0000 Issue 4857

php-general-digest-helplists.php.net
Date: Tue Jun 19 2007 - 08:29:39 CDT


php-general Digest 19 Jun 2007 13:29:39 -0000 Issue 4857

Topics (messages 257359 through 257403):

Re: php framework, large site
        257359 by: Robert Cummings
        257368 by: Crayon Shin Chan
        257369 by: Crayon Shin Chan
        257370 by: Robert Cummings
        257373 by: Sancar Saran
        257400 by: tedd

Re: generate images of register definitions
        257360 by: Mike Frysinger
        257374 by: Colin Guthrie

Re: Comparing string to array
        257361 by: Larry Garfield
        257376 by: Richard Davey
        257377 by: Stut
        257381 by: Richard Davey
        257382 by: Stut
        257385 by: Richard Davey
        257390 by: Stut
        257392 by: Richard Davey
        257394 by: Al
        257395 by: Stut
        257398 by: Richard Davey
        257399 by: Richard Davey
        257401 by: Stut

Date
        257362 by: Ron Piggott
        257363 by: Robert Cummings
        257364 by: Larry Garfield
        257378 by: Richard Heyes
        257391 by: Shafiq Rehman
        257393 by: Richard Heyes
        257397 by: Shafiq Rehman

Re: [Updated] Previous and Next Month and Year
        257365 by: Keith Spiller
        257366 by: Robert Cummings

Re: Php script diagnostic app?
        257367 by: Guillaume Theoret

Re: fsocketopen not returning data properly
        257371 by: Tijnema

Re: PHP calling an ISAPI Extension
        257372 by: Tijnema
        257375 by: Jochem Maas

Keeping sessions
        257379 by: Jorge González
        257380 by: Stut
        257383 by: Richard Heyes
        257384 by: Stut
        257386 by: Richard Heyes
        257387 by: Sancar Saran
        257388 by: Stut
        257389 by: Jorge González
        257396 by: Stut
        257402 by: Jorge González
        257403 by: Stut

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


On Mon, 2007-06-18 at 21:12 -0400, Nathan Nobbe wrote:
> On 6/18/07, Crayon Shin Chan <crayon.shin.chan.ukgmail.com> wrote:
>
> > > and you never know a new one could just become the best one.
> >
> > Look, if the OP has what it takes to build "the best" framework he would
> > have just gone ahead and did it instead asking. That is not to say that
> > in future when he has more experience he could not go on to build a
> > kickass framework.
> >
>
> agreed

Ah but it is quite possible that the OP will go ahead and try to build a
framework, he may fail miserably, all the while learning from his
mistakes. Then he may try again and subsequently build a kickass
framework. Since not all paths lead to the same conclusion it is just as
possible that if he doesn't go down this path that he will never create
a kickass framework no matter how many frameworks he studies.

Some of the greatest science comes from those unaware of established
rules and theories.

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

attached mail follows:


On Tuesday 19 June 2007 09:12, Nathan Nobbe wrote:

> it seems to me most people use the terms flavor and distribution
> interchangeably when referring to linux.

Yeah and most people forget that linux (the kernel) is only a tiny part of
a "linux distribution".

> although gentoo linux [the only os i run] is designed on the same
> basic concept of freeBSD it is entirely unique; basically a freeBSD
> rewrite w/ the linux kernel; o, it can run w/ the freeBSD kernel too.
> in effect a completely new breed of os was born; and i didnt catch
> that one on your list; probly because it is essentially "distro Z", so
> to speak.

I use gentoo too. I didn't mention it because it has relatively few
derivatives.

--
Crayon

attached mail follows:


On Tuesday 19 June 2007 09:35, Robert Cummings wrote:

> Ah but it is quite possible that the OP will go ahead and try to build
> a framework, he may fail miserably, all the while learning from his
> mistakes. Then he may try again and subsequently build a kickass
> framework.

In the pragmatic world where you're working on a project, for a living, to
a time schedule, then learning from other people's mistakes is less time
consuming than creating your own mistakes, recognise that they are
mistakes and then learn from them.

Of course if you invoke your "it's only for fun" defence then pragmatism
wouldn't come into it and whatever you do or don't do doesn't really
matter.

> Since not all paths lead to the same conclusion it is just
> as possible that if he doesn't go down this path that he will never
> create a kickass framework no matter how many frameworks he studies.

Now you're trudging into the realms of philosophy, crystal ball gazing and
groundless speculation.

> Some of the greatest science comes from those unaware of established
> rules and theories.

I'm sure most people on the list aren't looking to make revolutionary
advances in php programming. Most are simply looking for practical
answers to practical questions.

--
Crayon

attached mail follows:


On Tue, 2007-06-19 at 13:41 +0800, Crayon Shin Chan wrote:
> On Tuesday 19 June 2007 09:35, Robert Cummings wrote:
>
> > Ah but it is quite possible that the OP will go ahead and try to build
> > a framework, he may fail miserably, all the while learning from his
> > mistakes. Then he may try again and subsequently build a kickass
> > framework.
>
> In the pragmatic world where you're working on a project, for a living, to
> a time schedule, then learning from other people's mistakes is less time
> consuming than creating your own mistakes, recognise that they are
> mistakes and then learn from them.
>
> Of course if you invoke your "it's only for fun" defence then pragmatism
> wouldn't come into it and whatever you do or don't do doesn't really
> matter.

I wouldn't call it a defence. It's a point of view.

> > Since not all paths lead to the same conclusion it is just
> > as possible that if he doesn't go down this path that he will never
> > create a kickass framework no matter how many frameworks he studies.
>
> Now you're trudging into the realms of philosophy, crystal ball gazing and
> groundless speculation.

No, it's simple probability.

> > Some of the greatest science comes from those unaware of established
> > rules and theories.
>
> I'm sure most people on the list aren't looking to make revolutionary
> advances in php programming. Most are simply looking for practical
> answers to practical questions.

And many will encounter serendipity along the way regardless of what
they are looking to achieve.

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

attached mail follows:


Hi, as a creator of the one of those half baked's I want to say someting
about this issue.

People wants own Php framework etc. Because

1-) Documentation.
For my point of view most of unix documentation style was too complex. After
more than 10 years of linux experience I still hate man pages. And some how
(I believe this because of want look like professional/ubergeek/hyper
academic) most language/framework/cms/thisthat in Open Source universe uses
complex documentation model.

Php was non programmers programming language especially for web. Uber
Programmers still rejecting php (because of function naming, not good enough
oo support, etc etc etc). Also there was tons of more polished programming
(and or scripting) language for web (perl, python, ruby) none of them reach
popularty of php. After tons of security problems, misbehaved functions, php
still growing as fast as possible.

It was documentation damn it. No other language has php style documentation.

So ?

Most of php framework's uses complex documentation model and because of this
lost of people can't understand (and improve) those frameworks and implement
own.

2-) Complexing...
Over time frameworks become more complex... If you are there from start there
was no problem for you and if came here after 4 years you will see lots of
classes and functions to understand to the what the hell goes around there.

Last month our company give try for typo3.

OUCH!!

I'm still tyring to understand what goin there. Function names was very funny.
I still try to understand their system.

According the their web pages in 5.0 they will clean up the system.

.Backward compatibility.
Most of php programmers are non programmers and php can grow up with his
programmer and world of WWW too fast for anything.

Programming c was not so much change last 5 years and programmin php in last 5
years was changed too much. AND if you are my kind (growing with php) your
programing style was dramaticly changed. And if you had so popular framework
you have to give backward support.

And this was increase complexity of some frameworks.

.overused OO
I see some frame works uses $this->$that->$yada->$bada()
Ouch man if we can tolerate this kind of compexity we can even program in
ASM...

3-) This is world of HTML, JS and HTTP. there was lot of way to implement your
idea.

4-) Writing someting in php very easy

5-) Having own framework was coool. ;)

Regards

sancar

attached mail follows:


At 9:35 PM -0400 6/18/07, Robert Cummings wrote:
>Some of the greatest science comes from those unaware of established
>rules and theories.

There's the quote of the day.

Cheers,

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


On 6/9/07, Richard Lynch <ceol-i-e.com> wrote:
> On Sat, June 9, 2007 4:27 pm, Mike Frysinger wrote:
> > anyone know of some software to generate images like this:
> > http://wh0rd.org/register.png
> > idea is i have a list of registers and their bit meanings, and i want
> > to automatically generate images like the above one from this data
> >
> > yes, i can write some custom code in PHP using GD, but i'd much rather
> > use someone else's work than start from scratch
>
> It's remotely possible that you could hack something from JP Graph to
> look not completely unlike that...
>
> Though I suspect you might find it easier to start from scratch,
> honestly...

yeah ive just started from scratch ... here's what ive got so far in
case anyone happens to wander across this ...

$reg = new register("WDOG_CTL", "Watchdog Control Register",
0xFFC00200, 0x0AD0, 16,
    array(
        array(15, 15, "WDRO", "0 - Watchdog timer has not expired\n1 -
Watchdog timer has expired", W1C),
        array(11, 4, "WDEN", "0xAD - Counter disabled\nAll other
values - Counter enabled"),
        array(2, 1, "WDEV", "00 - Generate reset event\n01 - Generate
NMI\n10 - Generate GP interrupt\n11 - Disable event generation")
    )
);
register_to_png($reg);

http://wh0rd.org/register2.png

maybe i'll start a cheesy sf project for it
-mike

attached mail follows:


Mike Frysinger wrote:
> On 6/9/07, Richard Lynch <ceol-i-e.com> wrote:
>> On Sat, June 9, 2007 4:27 pm, Mike Frysinger wrote:
>> > anyone know of some software to generate images like this:
>> > http://wh0rd.org/register.png
>> > idea is i have a list of registers and their bit meanings, and i want
>> > to automatically generate images like the above one from this data
>> >
>> > yes, i can write some custom code in PHP using GD, but i'd much rather
>> > use someone else's work than start from scratch
>>
>> It's remotely possible that you could hack something from JP Graph to
>> look not completely unlike that...
>>
>> Though I suspect you might find it easier to start from scratch,
>> honestly...
>
> yeah ive just started from scratch ... here's what ive got so far in
> case anyone happens to wander across this ...
>
> $reg = new register("WDOG_CTL", "Watchdog Control Register",
> 0xFFC00200, 0x0AD0, 16,
> array(
> array(15, 15, "WDRO", "0 - Watchdog timer has not expired\n1 -
> Watchdog timer has expired", W1C),
> array(11, 4, "WDEN", "0xAD - Counter disabled\nAll other
> values - Counter enabled"),
> array(2, 1, "WDEV", "00 - Generate reset event\n01 - Generate
> NMI\n10 - Generate GP interrupt\n11 - Disable event generation")
> )
> );
> register_to_png($reg);
>
> http://wh0rd.org/register2.png
>
> maybe i'll start a cheesy sf project for it

That looks pretty damn good :)

Just a pity I can't think of a reason for me to use it! :p

Col

attached mail follows:


Perhaps you're looking for in_array()?

On Monday 18 June 2007, Richard Davey wrote:
> Hi all,
>
> Ok it's 2am, my brain has gone to mush and I am having trouble
> figuring out an easy way to do this, can anyone shed some light?
>
> Take a peek at the following code:
>
> // START
> <pre>
> <?php
> print_r($_POST);
>
> $userparam = "test['sam'][]";
>
> // How to check if $userparam exists in the $_POST array
> // and get all the values from it?
>
> // Obviously this won't work, but you get the idea:
> if (isset($_POST[$userparam]))
> {
> echo 'yeah';
> $values = $_POST[$userparam];
> }
> else
> {
> echo 'nah';
> }
> ?>
> </pre>
>
> <form method="post">
>
> <input type="checkbox" name="test['bob'][]" value="red">red<br>
> <input type="checkbox" name="test['bob'][]" value="green">green<br>
> <input type="checkbox" name="test['bob'][]" value="blue">blue<br>
> <input type="checkbox" name="test['sam'][]" value="red2">red2<br>
> <input type="checkbox" name="test['sam'][]" value="green2">green2<br>
> <input type="checkbox" name="test['sam'][]" value="blue2">blue2<br>
>
> <input type="submit">
>
> </form>
> // END
>
> From the code above I'm trying to figure out how to tell if the
> $userparam exists in the $_POST array. PHP automatically expands the
> form element name into multi-dim arrays within $_POST, so a simple
> 'isset' as shown in the code above won't play because it's got a
> totally useless array key passed to it.
>
> I need a way to turn the string:
>
> "test['sam'][]"
>
> into something I can look into $_POST for.
>
> Any ideas? The coffee boost is wearing off, but I want to get this
> licked tonight :-\
>
> Cheers,
>
> Rich
> --
> Zend Certified Engineer
> http://www.corephp.co.uk
>
> "Never trust a computer you can't throw out of a window"

--
Larry Garfield AIM: LOLG42
larrygarfieldtech.com ICQ: 6817012

"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson

attached mail follows:


Hi Larry,

Tuesday, June 19, 2007, 2:55:07 AM, you wrote:

> Perhaps you're looking for in_array()?

If only it was that simple! But pray tell how an in_array search is
going to find:

$userparam = "test['bob'][]";

within:

Array
(
    [test] => Array
        (
            ['bob'] => Array
                (
                    [0] => red
                    [1] => green
                    [2] => blue
                )
        )
)

?

The problem is that $userparam in the example above needs to be
expanded out into a form that $_POST can be searched for it. Or vica
versa.

Cheers,

Rich
--
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

attached mail follows:


Richard Davey wrote:
> Hi all,
>
> Ok it's 2am, my brain has gone to mush and I am having trouble
> figuring out an easy way to do this, can anyone shed some light?
>
> Take a peek at the following code:
>
> // START
> <pre>
> <?php
> print_r($_POST);
>
> $userparam = "test['sam'][]";
>
> // How to check if $userparam exists in the $_POST array
> // and get all the values from it?
>
> // Obviously this won't work, but you get the idea:
> if (isset($_POST[$userparam]))
> {
> echo 'yeah';
> $values = $_POST[$userparam];
> }
> else
> {
> echo 'nah';
> }
> ?>
> </pre>
>
> <form method="post">
>
> <input type="checkbox" name="test['bob'][]" value="red">red<br>
> <input type="checkbox" name="test['bob'][]" value="green">green<br>
> <input type="checkbox" name="test['bob'][]" value="blue">blue<br>
> <input type="checkbox" name="test['sam'][]" value="red2">red2<br>
> <input type="checkbox" name="test['sam'][]" value="green2">green2<br>
> <input type="checkbox" name="test['sam'][]" value="blue2">blue2<br>
>
> <input type="submit">
>
> </form>
> // END
>
> From the code above I'm trying to figure out how to tell if the
> $userparam exists in the $_POST array. PHP automatically expands the
> form element name into multi-dim arrays within $_POST, so a simple
> 'isset' as shown in the code above won't play because it's got a
> totally useless array key passed to it.
>
> I need a way to turn the string:
>
> "test['sam'][]"
>
> into something I can look into $_POST for.
>
> Any ideas? The coffee boost is wearing off, but I want to get this
> licked tonight :-\

Do you have control over what $userparam looks like? I'm not entirely
sure what you're after due to the [] on the end of it, but I'm going to
assume you want to know if any of the 'sam' checkboxes were ticked.
Maybe the following is a possibility...

$userparam = "test.sam";

// How to check if $userparam exists in the $_POST array
// and get all the values from it?

$idx = '[\''.implode('\'][\']', explode('.', $userparam)).'\']';
eval('$isset = isset($_POST'.$idx.');');

// Obviously this won't work, but you get the idea:
if ($isset)
{
     echo 'yeah';
     eval('$values = $_POST'.$idx.';');
}
else
{
     echo 'nah';
}

Untested, and remember that eval is pure evil.

If you can't control $userparam and it has to look like you have it then
you're parsing of it is a little more involved, but still fairly simple.

What are you actually trying to do? Where will $userparam actually come
from? There is almost certainly a better way to do this, but without
knowing all the details I'd be peeing in the wind.

-Stut

--
http://stut.net/

attached mail follows:


Hi Stut,

Tuesday, June 19, 2007, 10:16:02 AM, you wrote:

> If you can't control $userparam and it has to look like you have it then
> you're parsing of it is a little more involved, but still fairly simple.

> What are you actually trying to do? Where will $userparam actually come
> from? There is almost certainly a better way to do this, but without
> knowing all the details I'd be peeing in the wind.

Thank you for your code so far. Here is a more detailed explanation of
what I'm trying to do:

The designers here can create forms with whatever form elements they
like on them. They can name the form elements with any valid name. As
you know sometimes it is useful to give the form elements names which
will convert them into arrays in PHP, i.e.:

<input type="checkbox" name="test[color][]" value="red2">red2<br>
<input type="checkbox" name="test[color][]" value="green2">green2<br>
<input type="checkbox" name="test[color][]" value="blue2">blue2<br>

So $_POST['test']['color'] would contain an array of all the checked
values.

So far so good. The problem comes in that I don't know what the form
elements will be named, but I still need to check to see if they exist
within the $_POST array.

So knowing that $input_name = 'test[color][]' I then need to see if
$_POST['test']['color'] exists and get the value if it does.

To make matters worse it's perfectly legal to have a form element
named like:

<input type="checkbox" name="test['bob']['jazz'][]" value="red">red
<input type="checkbox" name="test['bob']['jazz'][]" value="green">green
<input type="checkbox" name="test['bob']['jazz'][]" value="blue">blue

Which when bought back into PHP will come out as:

array(1) {
  ["test"]=>
  array(2) {
    ["'bob'"]=>
    array(1) {
      ["'jazz'"]=>
      array(3) {
        [0]=>
        string(3) "red"
        [1]=>
        string(5) "green"
        [2]=>
        string(4) "blue"
      }
    }

Does that make it any clearer?

I have been playing with the RecursiveIteratorIterator this morning in
an attempt to solve it, but the results from that are less than
useless :(

I'm happy to try and explore the RAW post value instead if that would
be easier. I just figured there must be an easier way?

Here is the complete page you can test with:

-------------------------------- START
<pre>
<?php
    var_dump($_POST);

    $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($_POST));

    while($iterator->valid())
    {
        echo $iterator->key() . ' -- ' . $iterator->current();
        
        echo "\n";

        $iterator->next();
    }
    
    $userparam = "test['bob'][jazz][]";
    // How to determine if $userparam exists in $_POST
?>
</pre>

<form method="post">

<input type="checkbox" name="test['bob'][jazz][]" value="red">red<br>
<input type="checkbox" name="test['bob'][jazz][]" value="green">green<br>
<input type="checkbox" name="test['bob'][jazz][]" value="blue">blue<br>
<input type="checkbox" name="test[sam][]" value="red2">red2<br>
<input type="checkbox" name="test[sam][]" value="green2">green2<br>
<input type="checkbox" name="test[sam][]" value="blue2">blue2<br>

<input type="submit">

</form>
-------------------------------- END

Remember the whole crux of this problem is that I have no control over
what the form name will be. It will be *valid*, but that is all. They
could nest the resulting array as deep in $_POST as they like.

Cheers,

Rich
--
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

attached mail follows:


Richard Davey wrote:
> Hi Stut,
>
> Tuesday, June 19, 2007, 10:16:02 AM, you wrote:
>
>> If you can't control $userparam and it has to look like you have it then
>> you're parsing of it is a little more involved, but still fairly simple.
>
>> What are you actually trying to do? Where will $userparam actually come
>> from? There is almost certainly a better way to do this, but without
>> knowing all the details I'd be peeing in the wind.
>
> Thank you for your code so far. Here is a more detailed explanation of
> what I'm trying to do:
>
> The designers here can create forms with whatever form elements they
> like on them. They can name the form elements with any valid name. As
> you know sometimes it is useful to give the form elements names which
> will convert them into arrays in PHP, i.e.:
>
> <input type="checkbox" name="test[color][]" value="red2">red2<br>
> <input type="checkbox" name="test[color][]" value="green2">green2<br>
> <input type="checkbox" name="test[color][]" value="blue2">blue2<br>
>
> So $_POST['test']['color'] would contain an array of all the checked
> values.
>
> So far so good. The problem comes in that I don't know what the form
> elements will be named, but I still need to check to see if they exist
> within the $_POST array.
>
> So knowing that $input_name = 'test[color][]' I then need to see if
> $_POST['test']['color'] exists and get the value if it does.
>
> To make matters worse it's perfectly legal to have a form element
> named like:
>
> <input type="checkbox" name="test['bob']['jazz'][]" value="red">red
> <input type="checkbox" name="test['bob']['jazz'][]" value="green">green
> <input type="checkbox" name="test['bob']['jazz'][]" value="blue">blue
>
> Which when bought back into PHP will come out as:
>
> array(1) {
> ["test"]=>
> array(2) {
> ["'bob'"]=>
> array(1) {
> ["'jazz'"]=>
> array(3) {
> [0]=>
> string(3) "red"
> [1]=>
> string(5) "green"
> [2]=>
> string(4) "blue"
> }
> }
>
> Does that make it any clearer?
>
> I have been playing with the RecursiveIteratorIterator this morning in
> an attempt to solve it, but the results from that are less than
> useless :(
>
> I'm happy to try and explore the RAW post value instead if that would
> be easier. I just figured there must be an easier way?
>
> Here is the complete page you can test with:
>
> -------------------------------- START
> <pre>
> <?php
> var_dump($_POST);
>
> $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($_POST));
>
> while($iterator->valid())
> {
> echo $iterator->key() . ' -- ' . $iterator->current();
>
> echo "\n";
>
> $iterator->next();
> }
>
> $userparam = "test['bob'][jazz][]";
> // How to determine if $userparam exists in $_POST
> ?>
> </pre>
>
> <form method="post">
>
> <input type="checkbox" name="test['bob'][jazz][]" value="red">red<br>
> <input type="checkbox" name="test['bob'][jazz][]" value="green">green<br>
> <input type="checkbox" name="test['bob'][jazz][]" value="blue">blue<br>
> <input type="checkbox" name="test[sam][]" value="red2">red2<br>
> <input type="checkbox" name="test[sam][]" value="green2">green2<br>
> <input type="checkbox" name="test[sam][]" value="blue2">blue2<br>
>
> <input type="submit">
>
> </form>
> -------------------------------- END
>
> Remember the whole crux of this problem is that I have no control over
> what the form name will be. It will be *valid*, but that is all. They
> could nest the resulting array as deep in $_POST as they like.

If you have no control over what the fields in the form will be, what
are you doing with the data? Surely if you're writing logic that
requires you to know what the fields are called, you need to have
control over it.

On the other hand, if you're just squidging the data somewhere can't you
just iterate over the contents of $_POST?

I understand now that you're not in control of the form. What are you
doing with the data that's submitted?

-Stut

--
http://stut.net/

attached mail follows:


Hi Stut,

Tuesday, June 19, 2007, 12:09:12 PM, you wrote:

> If you have no control over what the fields in the form will be, what
> are you doing with the data? Surely if you're writing logic that
> requires you to know what the fields are called, you need to have
> control over it.

Here, this should help expand it further:

$icecream = $form->addSelectList('list', "icecream[flavor][]", 1, true, 'xml', 'icecream.xml', '//flavour');

The above code will add a select list into the current form (the
contents of which come from the icecream.xml file, using the xpath
query at the end, but this isn't relevant to the problem)

The 2nd parameter is the form name. In this instance the flavors from
the multi-select list will come into $_POST in: icecream[flavor]

When the form is submitted I take all of these form elements, and if
they exist in the filtered $_POST array, I re-populate them on error.

If the input name is just 'icecream' then you can do a simple:

if (isset($_POST[$input_name]))

.. and get the submitted value back.

If the input name is 'icecream[flavor][]' the above will no longer
work.

The problem is finding a way to expand the input name (which is a
string) into a format that $_POST can be searched for. Or do the
reverse, iterate through $_POST to find a match for the input name and
get that value.

Cheers,

Rich
--
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

attached mail follows:


Richard Davey wrote:
> Hi Stut,
>
> Tuesday, June 19, 2007, 12:09:12 PM, you wrote:
>
>> If you have no control over what the fields in the form will be, what
>> are you doing with the data? Surely if you're writing logic that
>> requires you to know what the fields are called, you need to have
>> control over it.
>
> Here, this should help expand it further:
>
> $icecream = $form->addSelectList('list', "icecream[flavor][]", 1, true, 'xml', 'icecream.xml', '//flavour');
>
> The above code will add a select list into the current form (the
> contents of which come from the icecream.xml file, using the xpath
> query at the end, but this isn't relevant to the problem)
>
> The 2nd parameter is the form name. In this instance the flavors from
> the multi-select list will come into $_POST in: icecream[flavor]
>
> When the form is submitted I take all of these form elements, and if
> they exist in the filtered $_POST array, I re-populate them on error.
>
> If the input name is just 'icecream' then you can do a simple:
>
> if (isset($_POST[$input_name]))
>
> .. and get the submitted value back.
>
> If the input name is 'icecream[flavor][]' the above will no longer
> work.
>
> The problem is finding a way to expand the input name (which is a
> string) into a format that $_POST can be searched for. Or do the
> reverse, iterate through $_POST to find a match for the input name and
> get that value.

Try this overly commented snippet on for size...

http://dev.stut.net/php/davey.php

-Stut

--
http://stut.net/

attached mail follows:


Hi Stut,

Tuesday, June 19, 2007, 1:16:54 PM, you wrote:

>> The problem is finding a way to expand the input name (which is a
>> string) into a format that $_POST can be searched for. Or do the
>> reverse, iterate through $_POST to find a match for the input name and
>> get that value.

> Try this overly commented snippet on for size...
> http://dev.stut.net/php/davey.php

Very nice, thank you. I was hoping there would be a way to do it
without resorting to eval(), but if even you can't figure out how, I'm
not going to waste any more time trying to either :)

I loved this part:

// The target - offensive American spelling!

:)

Cheers,

Rich
--
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

attached mail follows:


preg_grep() or

foreach($_POST as $value){

        if(empty($value)) continue;
        $good_stuff[] = $value;
}

Richard Davey wrote:
> Hi all,
>
> Ok it's 2am, my brain has gone to mush and I am having trouble
> figuring out an easy way to do this, can anyone shed some light?
>
> Take a peek at the following code:
>
> // START
> <pre>
> <?php
> print_r($_POST);
>
> $userparam = "test['sam'][]";
>
> // How to check if $userparam exists in the $_POST array
> // and get all the values from it?
>
> // Obviously this won't work, but you get the idea:
> if (isset($_POST[$userparam]))
> {
> echo 'yeah';
> $values = $_POST[$userparam];
> }
> else
> {
> echo 'nah';
> }
> ?>
> </pre>
>
> <form method="post">
>
> <input type="checkbox" name="test['bob'][]" value="red">red<br>
> <input type="checkbox" name="test['bob'][]" value="green">green<br>
> <input type="checkbox" name="test['bob'][]" value="blue">blue<br>
> <input type="checkbox" name="test['sam'][]" value="red2">red2<br>
> <input type="checkbox" name="test['sam'][]" value="green2">green2<br>
> <input type="checkbox" name="test['sam'][]" value="blue2">blue2<br>
>
> <input type="submit">
>
> </form>
> // END
>
> From the code above I'm trying to figure out how to tell if the
> $userparam exists in the $_POST array. PHP automatically expands the
> form element name into multi-dim arrays within $_POST, so a simple
> 'isset' as shown in the code above won't play because it's got a
> totally useless array key passed to it.
>
> I need a way to turn the string:
>
> "test['sam'][]"
>
> into something I can look into $_POST for.
>
> Any ideas? The coffee boost is wearing off, but I want to get this
> licked tonight :-\
>
> Cheers,
>
> Rich

attached mail follows:


Richard Davey wrote:
> Hi Stut,
>
> Tuesday, June 19, 2007, 1:16:54 PM, you wrote:
>
>>> The problem is finding a way to expand the input name (which is a
>>> string) into a format that $_POST can be searched for. Or do the
>>> reverse, iterate through $_POST to find a match for the input name and
>>> get that value.
>
>> Try this overly commented snippet on for size...
>> http://dev.stut.net/php/davey.php
>
> Very nice, thank you. I was hoping there would be a way to do it
> without resorting to eval(), but if even you can't figure out how, I'm
> not going to waste any more time trying to either :)

You probably could by breaking it into each part and then using a loop
to descend to the right place, but I don't think that's going to be any
better than using eval.

I'm assuming the source for $target is trusted. If not then you'll want
to sanitise it further by removing anything that's not a-z, 0-9 and []
just to ensure no dodgy code can be inserted.

> I loved this part:
>
> // The target - offensive American spelling!
>
> :)
>
> Cheers,

No probs.

-Stut

--
http://stut.net/

attached mail follows:


Hi Al,

Tuesday, June 19, 2007, 1:46:47 PM, you wrote:

> preg_grep() or

> foreach($_POST as $value){

> if(empty($value)) continue;
> $good_stuff[] = $value;
> }

A classic case of not reading the post fully methinks.

Cheers,

Rich
--
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

attached mail follows:


Hi Stut,

Tuesday, June 19, 2007, 1:49:53 PM, you wrote:

>> Very nice, thank you. I was hoping there would be a way to do it
>> without resorting to eval(), but if even you can't figure out how, I'm
>> not going to waste any more time trying to either :)

> You probably could by breaking it into each part and then using a loop
> to descend to the right place, but I don't think that's going to be any
> better than using eval.

I was wondering about doing something like this:

Recurse through $_POST, grabbing all of the keys, and then building a
string from them, something like:

icecream_batch2_flavours

and then storing the value of 'flavours' in a new array with the above
as the key.

Then I could manipulate the form input name:

name="icecream[batch2][flavours][]"
or
name="icecream['batch2']['flavours'][]"

To resemble the above key relatively simply.

Cheers,

Rich
--
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

attached mail follows:


Richard Davey wrote:
> Hi Stut,
>
> Tuesday, June 19, 2007, 1:49:53 PM, you wrote:
>
>>> Very nice, thank you. I was hoping there would be a way to do it
>>> without resorting to eval(), but if even you can't figure out how, I'm
>>> not going to waste any more time trying to either :)
>
>> You probably could by breaking it into each part and then using a loop
>> to descend to the right place, but I don't think that's going to be any
>> better than using eval.
>
> I was wondering about doing something like this:
>
> Recurse through $_POST, grabbing all of the keys, and then building a
> string from them, something like:
>
> icecream_batch2_flavours
>
> and then storing the value of 'flavours' in a new array with the above
> as the key.
>
> Then I could manipulate the form input name:
>
> name="icecream[batch2][flavours][]"
> or
> name="icecream['batch2']['flavours'][]"
>
> To resemble the above key relatively simply.

Not quite what I was thinking of.

More like this: http://dev.stut.net/php/davey2.php

-Stut

--
http://stut.net/

attached mail follows:


If

$expiry_date = "2007-10-17";

How do I add 7 days to this? I know the strtotime("+7 days"); command,
but don't know how to make it work with a date that isn't today.

(Please respond directly to my e-mail address)

Ron

attached mail follows:


On Mon, 2007-06-18 at 21:57 -0400, Ron Piggott wrote:
> If
>
> $expiry_date = "2007-10-17";
>
> How do I add 7 days to this? I know the strtotime("+7 days"); command,
> but don't know how to make it work with a date that isn't today.

You would do:

    strtotime( '+7 days', $time );

The $time is a unix timestamp... so you'll need to convert $expiry_date
to a unix timestamp. You can take a look at the mktime() function for
more information.

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

attached mail follows:


On Monday 18 June 2007, Robert Cummings wrote:
> On Mon, 2007-06-18 at 21:57 -0400, Ron Piggott wrote:
> > If
> >
> > $expiry_date = "2007-10-17";
> >
> > How do I add 7 days to this? I know the strtotime("+7 days"); command,
> > but don't know how to make it work with a date that isn't today.
>
> You would do:
>
> strtotime( '+7 days', $time );
>
> The $time is a unix timestamp... so you'll need to convert $expiry_date
> to a unix timestamp. You can take a look at the mktime() function for
> more information.

Just be meta about it.

strtotime('+7 days', strtotime($expiry_date));

Ta da! :-)

(Note: strtotime() is probably not the fastest to execute way of doing it, but
it's the fastest to write. Choose wisely.)

--
Larry Garfield AIM: LOLG42
larrygarfieldtech.com ICQ: 6817012

"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson

attached mail follows:


Larry Garfield wrote:
> (Note: strtotime() is probably not the fastest to execute way of doing it, but
> it's the fastest to write. Choose wisely.)

Is it? How about:

$timestamp = strtotime($expiry_date) + (86400 * 7);

--
Richard Heyes
0844 801 1072
http://www.websupportsolutions.co.uk
Knowledge Base and HelpDesk software

attached mail follows:


Hello,

There's another way out there using mysql

SELECT DATE_ADD('$expiry_date', INTERVAL 7 DAY) as fDate

but off course not a recommended way. In fact you can use it update query
(update tbl_name set expiry_date = date_add('$expiry_date', INTERVAL 7 DAY)
where user ='$user')

--
Shafiq Rehman (ZCE)
http://www.phpgurru.com | http://shafiq.pk
Cell: +92 300 423 9385

On 6/19/07, Richard Heyes <richardhphpguru.org> wrote:
>
> Larry Garfield wrote:
> > (Note: strtotime() is probably not the fastest to execute way of doing
> it, but
> > it's the fastest to write. Choose wisely.)
>
> Is it? How about:
>
> $timestamp = strtotime($expiry_date) + (86400 * 7);
>
> --
> Richard Heyes
> 0844 801 1072
> http://www.websupportsolutions.co.uk
> Knowledge Base and HelpDesk software
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


Shafiq Rehman wrote:
> Hello,
>
> There's another way out there using mysql
>
> SELECT DATE_ADD('$expiry_date', INTERVAL 7 DAY) as fDate
>
> but of course not a recommended way.

So why suggest it?

> In fact you can use it update query
> (update tbl_name set expiry_date = date_add('$expiry_date', INTERVAL 7 DAY)
> where user ='$user')

Seriously, no.

--
Richard Heyes
0844 801 1072
http://www.websupportsolutions.co.uk
Knowledge Base and HelpDesk software

attached mail follows:


On 6/19/07, Richard Heyes <richardhphpguru.org> wrote:
>
> Shafiq Rehman wrote:
> > Hello,
> >
> > There's another way out there using mysql
> >
> > SELECT DATE_ADD('$expiry_date', INTERVAL 7 DAY) as fDate
> >
> > but of course not a recommended way.
>
> So why suggest it?

just to share the knowledge

> In fact you can use it update query
> > (update tbl_name set expiry_date = date_add('$expiry_date', INTERVAL 7
> DAY)
> > where user ='$user')
>
> Seriously, no.
>
> --
> Richard Heyes
> 0844 801 1072
> http://www.websupportsolutions.co.uk
> Knowledge Base and HelpDesk software
>

--
Shafiq Rehman (ZCE)
http://www.phpgurru.com | http://shafiq.pk
Cell: +92 300 423 9385

attached mail follows:


Hi Guys,

RE: [Updated] Previous and Next Month and Year

Here is part of my code:

  $month = 6;
  // Current month value, but changes changes with next/prev links.
  // Value used by a mini calendar script "phpcalendar"...
  // Originally derived via: $month = date('n', time());
  // And updated with $month = $month +1 for next month
  // And $month = $month -1 for next month
  // So the value will be 1 through 12 for current year's months.
  // And 0, -1, -2 etc. for last year and 13, 14 etc. for next year.

  $prev_month = date('F Y', mktime(0, 0, 0, date("m")-$month, date("d"),
date("Y")));
  $next_month = date('F Y', mktime(0, 0, 0, date("m")+$month, date("d"),
date("Y")));

  echo "Month: $month <br /> \n";
  echo "Prev: $prev_month <br /> \n";
  echo "Next: $next_month <br /> \n";

The result:
  Month: 6
  Prev: December 2006
  Next: December 2007

The desired results would be:
  Month: 6
  Prev: May 2007
  Next: July 2007

And needs to bear in mind the year...

The phpcalendar script is working perfectly with my own next
and prev month links using $month +1 and $month -1. So I am
trying to get my Event boxes to work in the same way listing
the previous month, current month and next month.

Thanks,

Keith

attached mail follows:


On Mon, 2007-06-18 at 21:36 -0600, Keith Spiller wrote:
> Hi Guys,
>
> RE: [Updated] Previous and Next Month and Year
>
> Here is part of my code:
>
> $month = 6;
> // Current month value, but changes changes with next/prev links.
> // Value used by a mini calendar script "phpcalendar"...
> // Originally derived via: $month = date('n', time());
> // And updated with $month = $month +1 for next month
> // And $month = $month -1 for next month
> // So the value will be 1 through 12 for current year's months.
> // And 0, -1, -2 etc. for last year and 13, 14 etc. for next year.
>
> $prev_month = date('F Y', mktime(0, 0, 0, date("m")-$month, date("d"),
> date("Y")));
> $next_month = date('F Y', mktime(0, 0, 0, date("m")+$month, date("d"),
> date("Y")));
>
> echo "Month: $month <br /> \n";
> echo "Prev: $prev_month <br /> \n";
> echo "Next: $next_month <br /> \n";
>
> The result:
> Month: 6
> Prev: December 2006
> Next: December 2007
>
> The desired results would be:
> Month: 6
> Prev: May 2007
> Next: July 2007
>
> And needs to bear in mind the year...
>
> The phpcalendar script is working perfectly with my own next
> and prev month links using $month +1 and $month -1. So I am
> trying to get my Event boxes to work in the same way listing
> the previous month, current month and next month.

<?php

$now = time();

echo date( 'F Y', $now )."\n";
echo date( 'F Y', strtotime( '-1 month', $now ) )."\n";
echo date( 'F Y', strtotime( '+1 month', $now ) )."\n";

?>

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

attached mail follows:


Thanks a lot for that post Paul.

It brings up a question though. You said to never ever use that on a
production server (an important disclaimer!) so I was wondering what
people here used to log and simulate loads. I've used OpenSTA (
http://opensta.org/ ) and I was pleased with the results but it only
works with windows. What do you guys generally use under linux? Just
squid? Something else?

I suppose I can just set up a windows box if I have to since OpenSTA
acts as a transparent gateway but if there's a good linux solution out
there for recording usage and playing it back concurrently I'd like to
hear about it. With OpenSTA to create a test script it's as easy as
clicking the record button to create the script and stop when you're
done. Then you can go in and manually edit the script if you like and
you can play it back as many times as you'd like concurrently (thereby
simulating many users). Anyone know of anything like this?

Thanks

On 6/18/07, Paul Scott <pscottuwc.ac.za> wrote:
>
> On Mon, 2007-06-18 at 06:39 +0200, Paul Scott wrote:
> > If you would like a more detailed HOWTO, please let me know, and I will
> > write up something for you.
>
> http://fsiu.uwc.ac.za/index.php?module=blog&action=viewsingle&postid=gen9Srv59Nme5_9262_1182142431&userid=3897070607
>
> --Paul
>
>
> All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


On 6/19/07, Dan <frozendicegmail.com> wrote:
> I'm having trouble with sockets in PHP, if anyone has the time to help out
> that would be awesome.
> I am trying to get the result of a post

There are a lot of people that are probably willing to help, but what
is your exact problem?

>
> echo httpSocketConnection("www.google.com", "POST", "/search", "q=test",
> "80");
>
> This should post to google.com with a query of test. Then give me the
> response. The function I'm using is below.

Google doesn't wants a POST request, make it a GET request and it should work.

>
> Here's the function's code:
>
<snip>

You copied this straight from the web? If so, then there are probably
no bugs in it.

Tijnema

attached mail follows:


On 6/19/07, Jim Lucas <listscmsws.com> wrote:
> Dan wrote:
> > I wish I could, I can't count on the script being on a linux machine. I
> > also can't expect people to rebuild PHP with the curl library just to
> > use my script. Is there any other way to do a post to a page from a php
> > function?
> >
> > - Daniel
> >
> > "Jim Lucas" <listscmsws.com> wrote in message
> > news:46770D93.6010003cmsws.com...
> >> Dan wrote:
> >>> I would normaly do it with an AJAX call but I need to do a post from
> >>> WITHIN a PHP function, so when it's doing php stuff
> >>> ex.
> >>> function something()
> >>> {
> >>> echo 'whatever';
> >>> $response = post some data to a ISAPI Extension eg. post to
> >>> http://domain.com/scripts/app.dll
> >>> return $response . "other data";
> >>> }
> >>>
> >>>
> >>> ""Jay Blanchard"" <jblanchardpocket.com> wrote in message
> >>> news:56608562F6D5D948B22F5615E3F57E690245F0ACYGEX01WAL.onecall.local...
> >>> [snip]
> >>> I'm in need of a way to contact an ISAPI Extension from a PHP function.
> >>> Does anyone know how I would be able to do this? Usually you would post
> >>> a
> >>> page to their URL/actionname. Can I do a POST from a PHP function
> >>> without
> >>> reloading the page, and get a result back? That's one tall order.
> >>> Anyone
> >>> want to give it a shot?
> >>> [/snip]
> >>>
> >>> Do the POST with an AJAX call
> >>
> >> perform an ajax call the a php script that calls curl to do a post to
> >> the ISAPI extension
> >>
> >> --
> >> Jim Lucas
> >>
> >> "Some men are born to greatness, some achieve greatness,
> >> and some have greatness thrust upon them."
> >>
> >> Twelfth Night, Act II, Scene V
> >> by William Shakespeare
> >
> The only method that I am aware of is the fsockopen method you mention in your other email
>
> --
> Jim Lucas

Yes, and what's wrong with it?
<?php
$post_data = "form_a=1&form_b=4";
$fp = fsockopen("www.domain.com",80);
fwrite($fp,"POST /scripts/app.dll HTTP/1.1\r\nHost:
www.domain.com\r\nContent-Length:
".strlen($post_data)."\r\n\r\n".$post_data);
$result = fread($fp,102400); // Reads 100KB, change if you need more
?>

That's not too long is it?

Tijnema
>

attached mail follows:


Dan wrote:
> For example, I could use function fsockopen but that seems like it would
> probably be pretty slow doing all that, and if there's a php function or
> small script that would be preferable over the 50/60 lines you would
> need to do it properly with fsockopen.

with the caveat that it'll only work as a GET request (which probably means no cigar for you),
and requires that your php is setup to allow open urls (ini setting 'allow_url_fopen')

$response = file_get_contents('http://your.iis.machine/some/path/some_isapi.dll?foo=bar');

otherwise the fsockopen() route is all that seems to be open to you, given that curl reliance
is a no-no. - the biggest factor in the response speed is likely to be the server at the other
end (assuming the network connection between the 2 machines is generally ok), so if things
are slow you might consider caching the results locally (again, assuming that this is feasable.)

is the isapi extension on the same machine?
if so maybe it has a COM interface with which you can talk to it?

        http://php.net/com

no idea if that is feasible - I've never really used IIS, let alone had to deal with isapi extensions.

>
> - Daniel
>
> ""Jay Blanchard"" <jblanchardpocket.com> wrote in message
> news:56608562F6D5D948B22F5615E3F57E690245F0ACYGEX01WAL.onecall.local...
> [snip]
> I'm in need of a way to contact an ISAPI Extension from a PHP function.
> Does anyone know how I would be able to do this? Usually you would post
> a
> page to their URL/actionname. Can I do a POST from a PHP function
> without
> reloading the page, and get a result back? That's one tall order.
> Anyone
> want to give it a shot?
> [/snip]
>
> Do the POST with an AJAX call

attached mail follows:


Hi all !

In a web server cluster, how do you do guys keep the php sessions? I
mean, with Apache and mod_proxy_balanced you could have a cluster with
apache backend webservers but If a user is logged into an php app then
this user goes always to the same backend server and if that server goes
down then the session is invalid.

How to deal with sessions?

thanks in advance! cheers

attached mail follows:


Jorge González wrote:
> In a web server cluster, how do you do guys keep the php sessions? I
> mean, with Apache and mod_proxy_balanced you could have a cluster with
> apache backend webservers but If a user is logged into an php app then
> this user goes always to the same backend server and if that server goes
> down then the session is invalid.
>
> How to deal with sessions?

Several options exist, but the most common is to store session data in a
database that can be accessed by all of the web servers. Alternatives
include using memcached but recently I read something that suggested
that can be problematic.

I believe the cluster support in Zend Platform includes this
functionality, so depending on your budget that may also be an option.

-Stut

--
http://stut.net/

attached mail follows:


Stut wrote:
> Jorge González wrote:
>
>> In a web server cluster, how do you do guys keep the php sessions? I
>> mean, with Apache and mod_proxy_balanced you could have a cluster with
>> apache backend webservers but If a user is logged into an php app then
>> this user goes always to the same backend server and if that server
>> goes down then the session is invalid.
>>
>> How to deal with sessions?
>
>
> Several options exist, but the most common is to store session data in a
> database that can be accessed by all of the web servers. Alternatives
> include using memcached but recently I read something that suggested
> that can be problematic.
>
> I believe the cluster support in Zend Platform includes this
> functionality, so depending on your budget that may also be an option.

Just a note: you could have either one of the web servers acting as the
"session" server which the other web servers use or, if need be, a
dedicated "session" server. I wouldn't imagine you'd need that though
unless your site's really busy.

--
Richard Heyes
0844 801 1072
http://www.websupportsolutions.co.uk
Knowledge Base and HelpDesk software

attached mail follows:


Richard Heyes wrote:
> Stut wrote:
>> Jorge González wrote:
>>
>>> In a web server cluster, how do you do guys keep the php sessions? I
>>> mean, with Apache and mod_proxy_balanced you could have a cluster
>>> with apache backend webservers but If a user is logged into an php
>>> app then this user goes always to the same backend server and if that
>>> server goes down then the session is invalid.
>>>
>>> How to deal with sessions?
>>
>> Several options exist, but the most common is to store session data in
>> a database that can be accessed by all of the web servers.
>> Alternatives include using memcached but recently I read something
>> that suggested that can be problematic.
>>
>> I believe the cluster support in Zend Platform includes this
>> functionality, so depending on your budget that may also be an option.
>
> Just a note: you could have either one of the web servers acting as the
> "session" server which the other web servers use or, if need be, a
> dedicated "session" server. I wouldn't imagine you'd need that though
> unless your site's really busy.

What do you mean by "session server"? How are you accessing the session
data on another server?

-Stut

--
http://stut.net/

attached mail follows:


> What do you mean by "session server"?

I server dedicated (or it can also act as a web server, or the main web
server) to storing sessions.

> How are you accessing the session data on another server?

Usually by way of a database.

--
Richard Heyes
0844 801 1072
http://www.websupportsolutions.co.uk
Knowledge Base and HelpDesk software

attached mail follows:


On Tuesday 19 June 2007 14:15:00 Stut wrote:
> Richard Heyes wrote:
> > Stut wrote:
> >> Jorge González wrote:
> >>> In a web server cluster, how do you do guys keep the php sessions? I
> >>> mean, with Apache and mod_proxy_balanced you could have a cluster
> >>> with apache backend webservers but If a user is logged into an php
> >>> app then this user goes always to the same backend server and if that
> >>> server goes down then the session is invalid.
> >>>
> >>> How to deal with sessions?
> >>
> >> Several options exist, but the most common is to store session data in
> >> a database that can be accessed by all of the web servers.
> >> Alternatives include using memcached but recently I read something
> >> that suggested that can be problematic.
> >>
> >> I believe the cluster support in Zend Platform includes this
> >> functionality, so depending on your budget that may also be an option.
> >
> > Just a note: you could have either one of the web servers acting as the
> > "session" server which the other web servers use or, if need be, a
> > dedicated "session" server. I wouldn't imagine you'd need that though
> > unless your site's really busy.
>
> What do you mean by "session server"? How are you accessing the session
> data on another server?
>
> -Stut
>
> --
> http://stut.net/

Via Memcached or mysql server which only holds session data.

Regards

Sancar

attached mail follows:


Richard Heyes wrote:
>> What do you mean by "session server"?
>
> I server dedicated (or it can also act as a web server, or the main web
> server) to storing sessions.
>
> > How are you accessing the session data on another server?
>
> Usually by way of a database.

Ok, that's basically what I suggested. Just wanted to make sure there
wasn't another way I wasn't aware of.

-Stut

--
http://stut.net/

attached mail follows:


Ok, you both are right but not what I need because web servers is for
shared hosting with PHP then each user choose the way to develop their
apps. Then one user maybe store sessions in DB but another one not. This
should be on Apache or OS side. It's because I talk about ldirector, LVS
and so

I know this is a PHP and not an Apache list but maybe someone is doing
this with web hosting...

cheers!

Stut escribió:
> Richard Heyes wrote:
>> Stut wrote:
>>> Jorge González wrote:
>>>
>>>> In a web server cluster, how do you do guys keep the php sessions?
>>>> I mean, with Apache and mod_proxy_balanced you could have a cluster
>>>> with apache backend webservers but If a user is logged into an php
>>>> app then this user goes always to the same backend server and if
>>>> that server goes down then the session is invalid.
>>>>
>>>> How to deal with sessions?
>>>
>>> Several options exist, but the most common is to store session data
>>> in a database that can be accessed by all of the web servers.
>>> Alternatives include using memcached but recently I read something
>>> that suggested that can be problematic.
>>>
>>> I believe the cluster support in Zend Platform includes this
>>> functionality, so depending on your budget that may also be an option.
>>
>> Just a note: you could have either one of the web servers acting as
>> the "session" server which the other web servers use or, if need be,
>> a dedicated "session" server. I wouldn't imagine you'd need that
>> though unless your site's really busy.
>
> What do you mean by "session server"? How are you accessing the
> session data on another server?
>
> -Stut
>

attached mail follows:


Jorge González wrote:
> Ok, you both are right but not what I need because web servers is for
> shared hosting with PHP then each user choose the way to develop their
> apps. Then one user maybe store sessions in DB but another one not. This
> should be on Apache or OS side. It's because I talk about ldirector, LVS
> and so
>
> I know this is a PHP and not an Apache list but maybe someone is doing
> this with web hosting...

Not only is this a PHP list, but your problem is a PHP problem. I'm
shocked. No, really.

Apache does *not* get involved in sessions. Not at all.

You could put in a custom session handler using a prepended file. See
the php.ini configuration option auto_prepend_file. I think there are
also extensions available that drop in to replace the session extension
- suggest you search the PECL site for those (http://pecl.php.net/). Of
course you need to be aware that any PHP script can override both of
these options.

Just to clarify, you're building a shared hosting system that load
balances all sites across a cluster of web servers? If not, please
explain what it is you're actually trying to do.

-Stut

--
http://stut.net/

attached mail follows:


Stut escribió:
> Jorge González wrote:
>> Ok, you both are right but not what I need because web servers is for
>> shared hosting with PHP then each user choose the way to develop
>> their apps. Then one user maybe store sessions in DB but another one
>> not. This should be on Apache or OS side. It's because I talk about
>> ldirector, LVS and so
>>
>> I know this is a PHP and not an Apache list but maybe someone is
>> doing this with web hosting...
>
> Not only is this a PHP list, but your problem is a PHP problem. I'm
> shocked. No, really.
Ok :)
>
> Apache does *not* get involved in sessions. Not at all.
Well the question is I was dealing with an Apache mod_proxy_balanced and
plans to use LVS or ldirector for balancing between backend servers. I
didn't know about other solutions.
>
> You could put in a custom session handler using a prepended file. See
> the php.ini configuration option auto_prepend_file. I think there are
> also extensions available that drop in to replace the session
> extension - suggest you search the PECL site for those
> (http://pecl.php.net/). Of course you need to be aware that any PHP
> script can override both of these options.
Well, I'll see later, sounds great.
>
> Just to clarify, you're building a shared hosting system that load
> balances all sites across a cluster of web servers? If not, please
> explain what it is you're actually trying to do.
yes, that is, and sessions are important. Users's session must be
persistent in all cases: web server down, user jumpig between backend
web servers, etc
>
> -Stut
>

attached mail follows:


Jorge González wrote:
> Stut escribió:
>> Jorge González wrote:
>>> Ok, you both are right but not what I need because web servers is for
>>> shared hosting with PHP then each user choose the way to develop
>>> their apps. Then one user maybe store sessions in DB but another one
>>> not. This should be on Apache or OS side. It's because I talk about
>>> ldirector, LVS and so
>>>
>>> I know this is a PHP and not an Apache list but maybe someone is
>>> doing this with web hosting...
>>
>> Not only is this a PHP list, but your problem is a PHP problem. I'm
>> shocked. No, really.
> Ok :)

Indeed it is.

>> Apache does *not* get involved in sessions. Not at all.
> Well the question is I was dealing with an Apache mod_proxy_balanced and
> plans to use LVS or ldirector for balancing between backend servers. I
> didn't know about other solutions.

That doesn't change the fact that Apache does not get involved in
sessions. Nor does mod_proxy_balanced, LVS or ldirector. Sessions are a
PHP entity. The only part of them that leaves the PHP part of the
solution is the session identifier which travels in cookies and/or URLs.

>> Just to clarify, you're building a shared hosting system that load
>> balances all sites across a cluster of web servers? If not, please
>> explain what it is you're actually trying to do.
> yes, that is, and sessions are important. Users's session must be
> persistent in all cases: web server down, user jumpig between backend
> web servers, etc

In that case you need to make sure you explain to your users/customers
that they cannot use a custom session handler and expect it to work.

-Stut

--
http://stut.net/