php-general Digest 10 Nov 2010 19:36:43 -0000 Issue 7031

Topics (messages 309422 through 309431):

Re: Updating a GET variable
        309422 by: Tamara Temple
        309423 by: Tamara Temple
        309427 by: Marc Guay
        309428 by: Marc Guay
        309429 by: Tamara Temple

Re: Chat
        309424 by: Warren Windvogel
        309425 by: Ken Guest
        309426 by: Warren Windvogel

Re: Template engines
        309430 by: tedd

Re: Help with variable variables not being set for a multi-dimensional array
        309431 by: David Harkness

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---

On Nov 9, 2010, at 2:47 PM, Marc Guay wrote:

What's wrong with just putting the url parameters in the link that you know
you need, one by one?

I have a footer that I include on every page and would like it to
adapt to whatever situation it finds itself in.  Is your suggestion,
to do the following for the existing example:

echo "<a href='index.php?name=".$_GET['name']."&this=". $_GET['this']."&lang=en'>Flip</a>";


Also, don't just output the values sent to the server, as that's an attack waiting to happen.

Are you referring to echoing the SCRIPT_NAME and QUERY STRING values
into the href attribute?

I would add the parameter you want to $_GET ($_GET['lang']='en') and use http_build_query on $_GET if you really want to include the whole query string in the call:

$_GET['lang']='en';
echo '<a href="index.php?'.http_build_query($_GET).'">Flip</a>";



--- End Message ---
--- Begin Message ---
Begin forwarded message:

From: Tamara Temple <tamouse.li...@gmail.com>
Date: November 10, 2010 12:05:32 AM CST
To: PHP General <php-gene...@lists.php.net>
Subject: Re: [PHP] Updating a GET variable


On Nov 9, 2010, at 2:47 PM, Marc Guay wrote:

What's wrong with just putting the url parameters in the link that you know
you need, one by one?

I have a footer that I include on every page and would like it to
adapt to whatever situation it finds itself in.  Is your suggestion,
to do the following for the existing example:

echo "<a href='index.php?name=".$_GET['name']."&this=". $_GET['this']."&lang=en'>Flip</a>";


Also, don't just output the values sent to the server, as that's an attack waiting to happen.

Are you referring to echoing the SCRIPT_NAME and QUERY STRING values
into the href attribute?

I would add the parameter you want to $_GET ($_GET['lang']='en') and use http_build_query on $_GET if you really want to include the whole query string in the call:

$_GET['lang']='en';
echo '<a href="index.php?'.http_build_query($_GET).'">Flip</a>"

Woops, just realized a problem with this. If the values in $_GET are URL encode, http_build_query will encode them again, so you have to decode them first:

foreach($_GET as $k => $v) $qs[$k] = URLDecode($v);
$qs['lang'] = 'en';
echo '<a href="index.php?'.http_build_query($qa).'">Flip</a>';


--- End Message ---
--- Begin Message ---
> <?php
> Session_start();
> $_SESSION['language'] = "en";
> You can set the session variable to the current get or maintain the original
> passed.

I think you may have misunderstood.  The problem is holding onto the
existing GET variables in the URL while manipulating or adding one of
them... and doing it dynamically no matter what the existing
parameters are.

My partciular problem scenario is this:

directions.php?mode=DRIVING&lat=45.514516&long=-73.611056&zip=H4N+2W2&lang=en

I would like the user to be able to switch between two languages via
the $_GET['lang'] var.


As for

> Dear god, why would you butcher php like that?

Your example is just as ugly as mine and in my editor is actually
worse because the SERVER vars aren't highlighted.   Thanks anyways.


Marc

--- End Message ---
--- Begin Message ---
> foreach($_GET as $k => $v) $qs[$k] = URLDecode($v);
> $qs['lang'] = 'en';
> echo '<a href="index.php?'.http_build_query($qa).'">Flip</a>';

Hi Tamara,

Thanks for the tips.  Do you see any advantage of this method over
using a small POST form besides the styling problems I'll run into
trying to make the submit button look like an achor?

Marc

--- End Message ---
--- Begin Message ---

On Nov 10, 2010, at 8:58 AM, Marc Guay wrote:

foreach($_GET as $k => $v) $qs[$k] = URLDecode($v);
$qs['lang'] = 'en';
echo '<a href="index.php?'.http_build_query($qa).'">Flip</a>';

Hi Tamara,

Thanks for the tips.  Do you see any advantage of this method over
using a small POST form besides the styling problems I'll run into
trying to make the submit button look like an achor?

The main advantage I see is that you're application doesn't have to become bi-modal, with looking for variables on both the query string and in the post data, then deciding which to use.
--- End Message ---
--- Begin Message ---
On 09/11/2010 18:32, Steve Staples wrote:
On Tue, 2010-11-09 at 16:51 +0100, Dušan Novaković wrote:
Hello there,

I have to make chat for website that has around 10 000 users (small
social network). So before I start, I would like to hear different
opinions. Important thing is to have in mind that in one moment you
can have over 1 000 users using chat.
So, if you have time fill free to write you experience in this field,
suggestions, etc.

Thnx,
Dusan



--


Please consider the environment before printing this email.

I did that for a site for my buddy... i tried a few different ways, and
the current way seems to work decently... but i've been thinking about
altering it...

what i did for that one, is it inserts into a database what the person
wrote, then on eth other side, it pulls every x seconds from the db, and
using ajax adds to the<div>.   it is a pain in the ass, but yeah, it
works.  I also had a flag for "typing" indicator.

i am sure there are many different ways to do this, but posting to a db,
and pulling from the db seemed to be the logical way to do it when i did
that...    my buddies old way of doing it, is at http://radiokaos.com
it just posts to the db, and then refreshed the iframe every 20 seconds
or something.

I use an Openfire server with the Smack client. Its really simple, well documented and works really well.

Kind regards
Warren

--- End Message ---
--- Begin Message ---
> On Tue, 2010-11-09 at 16:51 +0100, Dušan Novaković wrote:
>>
>>
>>> Hello there,
>>>
>>> I have to make chat for website that has around 10 000 users (small
>>> social network). So before I start, I would like to hear different
>>> opinions. Important thing is to have in mind that in one moment you
>>> can have over 1 000 users using chat.
>>> So, if you have time fill free to write you experience in this field,
>>> suggestions, etc.
>>>
>>

I'd suggest looking into jabber

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


-- 
http://blogs.linux.ie/kenguest/

--- End Message ---
--- Begin Message ---
On 10/11/2010 13:11, Ken Guest wrote:

        On Tue, 2010-11-09 at 16:51 +0100, Dušan Novaković wrote:

            Hello there,

            I have to make chat for website that has around 10 000
            users (small
            social network). So before I start, I would like to hear
            different
            opinions. Important thing is to have in mind that in one
            moment you
            can have over 1 000 users using chat.
            So, if you have time fill free to write you experience in
            this field,
            suggestions, etc.



I'd suggest looking into jabber

Yep, Openfire is a jabber/xmpp server. There are however many other alternatives.

Kind regards
Warren


--- End Message ---
--- Begin Message ---
At 11:38 AM -0500 11/9/10, Robert Cummings wrote:
On 10-11-09 11:18 AM, tedd wrote:
At 10:57 AM -0500 11/9/10, Robert Cummings wrote:
On 10-11-09 10:42 AM, tedd wrote:

I don't have to try them all, just the most popular. If the most
popular doesn't work for me, then I don't need to try any others.

That's all well and good, but the argument being used is a
generalization which at best is wrong. I don't care what you use,
but FUD doesn't help anything.

Cheers,
Rob.


I disagree and what I said is not FUD.

If we took the time to *not* generalize, then we would be up to our
collective butts in evaluations of everything, while getting nothing
accomplished.

Generalization is a way to navigate the massive amounts of data we
are bombarded with each day. Do I want to spend/waste time evaluating
all templates to the nth degree? I think not.

Instead, I research ideas and see if they meet with my way of doing
things. If they do, then I incorporate them into my method -- if not,
then I pass.

I have changed my methods many times to accommodate new technologies
and new ways of doing things, but that does not mean that I always
incorporate everything that comes along. Templates are one of those
things that do not fit in my way of doing things and I do not need to
investigate all template systems to arrive at that conclusion. As
such, there is nothing wrong with my evaluation method for it works
for me.

I think the key quote here is "your way". Others will certainly have different mileage (as has already been expressed), thus your generalization still rings false. It's only a generalization for you and others of like mind... which is terribly partisan :)

Cheers,
Rob.

And, in this case, "your way" is to disagree with "my way". :-)

In the end, we all have our methods of navigating information. If we didn't we wouldn't be as far along as we are.

Cheers,

tedd

--
-------
http://sperling.com/

--- End Message ---
--- Begin Message ---
On Tue, Nov 9, 2010 at 6:55 PM, Daevid Vincent <dae...@daevid.com> wrote:

> I've used variable variables before but for some reason I can't figure this
> snippet out. Why doesn't $ini_file get set (or appended to).
>

AFAIK variable variables can only reference actual variables--not array
subscripts or other non-variable syntax elements such as "->" or "::".
eval() can do this because it parses the code as PHP. Variable variables
take the *variable name* contained in the variable and look it up in the
current scope. This is a variable name:

    ini_array

This is not:

    ini_array['agis_core']['adapter']

I think you can use references here to do what you need. Warning: I only
tested the basics of this in the interpreter without running this exact
code.

    public function explode_ini()
    {
        $ini_array = array();

        foreach($this->ini_array as $heading => $key_vals)
        {
            foreach ($key_vals as $k => $v)
            {
                $path = &$ini_array[$heading];
                $subsection = explode('.', $k);
                foreach ($subsection as $ss)
                    $path = &$path[$ss];
                $path = $v;
                unset($path);
            }
        }

        $this->ini_array = $ini_array;
    }

David

--- End Message ---

Reply via email to