Hide URL parameters

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob Bedford

    #1

    Hide URL parameters

    I've my site wich uses POST forms and javascript (see below). Since it's
    online, some people have called saying that some parts of my site are
    unavailable.

    I've seen that the part not accessable are the one redirected by Javascript:

    echo("<body bgcolor=\"#5555 55\"
    onLoad='documen t.forms[\"FormNext\"].submit()';>
    <form name=\"FormNext \" method=\"POST\" action=\"edit.p hp?".SID."\">
    <input type=\"hidden\" name=\"PrevPage \"
    value=\"".$HTTP _SERVER_VARS['PHP_SELF']."\">
    ....

    I've many param to pass to the edit.php, and I must avoid some of them being
    too visible, that's why I've take the POST forms. Now, I can't get further.
    So I decided to go "GET", but it's there any way to pass the entire params
    in some crypted way:
    say edit.php?data=c sdkykljr3q9sajd sd<ckmcdkasmcs

    and in my edit.php, a function uncrypting the code passed in data.

    Any example would greately be appreciated.

    Thanks

    Bob


  • Kevin Thorpe

    #2
    Re: Hide URL parameters

    Bob Bedford wrote:
    [color=blue]
    > I've my site wich uses POST forms and javascript (see below). Since it's
    > online, some people have called saying that some parts of my site are
    > unavailable.
    >
    > I've seen that the part not accessable are the one redirected by
    > Javascript:
    >
    > echo("<body bgcolor=\"#5555 55\"
    > onLoad='documen t.forms[\"FormNext\"].submit()';>
    > <form name=\"FormNext \" method=\"POST\" action=\"edit.p hp?".SID."\">
    > <input type=\"hidden\" name=\"PrevPage \"
    > value=\"".$HTTP _SERVER_VARS['PHP_SELF']."\">
    > ...
    >
    > I've many param to pass to the edit.php, and I must avoid some of them
    > being too visible, that's why I've take the POST forms. Now, I can't get
    > further. So I decided to go "GET", but it's there any way to pass the
    > entire params in some crypted way:
    > say edit.php?data=c sdkykljr3q9sajd sd<ckmcdkasmcs
    >
    > and in my edit.php, a function uncrypting the code passed in data.[/color]

    Surely this is a prime case for using sessions. You're already passing
    SID so you must use them.

    Comment

    • Markus Ernst

      #3
      Re: Hide URL parameters

      Bob Bedford wrote:[color=blue]
      > I've my site wich uses POST forms and javascript (see below). Since
      > it's online, some people have called saying that some parts of my
      > site are unavailable.
      >
      > I've seen that the part not accessable are the one redirected by
      > Javascript:
      > echo("<body bgcolor=\"#5555 55\"
      > onLoad='documen t.forms[\"FormNext\"].submit()';>
      > <form name=\"FormNext \" method=\"POST\"
      > action=\"edit.p hp?".SID."\"> <input type=\"hidden\"
      > name=\"PrevPage \" value=\"".$HTTP _SERVER_VARS['PHP_SELF']."\">
      > ...
      >
      > I've many param to pass to the edit.php, and I must avoid some of
      > them being too visible, that's why I've take the POST forms. Now, I
      > can't get further. So I decided to go "GET", but it's there any way
      > to pass the entire params in some crypted way:
      > say edit.php?data=c sdkykljr3q9sajd sd<ckmcdkasmcs
      >
      > and in my edit.php, a function uncrypting the code passed in data.[/color]

      You could put all variables into an array, and then use serialize() and
      base64_encode() to encode (not encrypt) it. You can also encrypt it of
      course, but that does not make sense as anybody can just disable Javascript
      and then read the HTML source of the form, so this is only for a very
      low-level security anyway.

      But why would you make a script that does nothing but a client-side
      redirect? It would be much easier and safer to just call edit.php directly,
      so the variables do not get to the client at all.

      --
      Markus



      Comment

      • Bob Bedford

        #4
        Re: Hide URL parameters

        [color=blue]
        > Surely this is a prime case for using sessions. You're already passing
        > SID so you must use them.
        >[/color]

        It's there any limitation (KB, number) of params in the Session variable ?
        because on some pages I've up to 30 parameters.

        Thanks for your help.

        Bob


        Comment

        • Kevin Thorpe

          #5
          Re: Hide URL parameters

          Bob Bedford wrote:
          [color=blue]
          >[color=green]
          >> Surely this is a prime case for using sessions. You're already passing
          >> SID so you must use them.
          >>[/color]
          >
          > It's there any limitation (KB, number) of params in the Session variable
          > ? because on some pages I've up to 30 parameters.[/color]

          You should be ok up to very large arrays. What php does (on Linux/Apache
          anyway) is serialize() the $_SESSION array any write it into your /tmp
          directory. I hold piles of stuff in there and haven't had any problems.

          Comment

          • Bob Bedford

            #6
            Re: Hide URL parameters

            [color=blue]
            > But why would you make a script that does nothing but a client-side
            > redirect? It would be much easier and safer to just call edit.php
            > directly, so the variables do not get to the client at all.[/color]
            I've my form, wich action target is itself. If the desired things are done,
            then I allow the user to go further.

            Let's explain:

            <form method="post" action="<?php echo($HTTP_SERV ER_VARS['PHP_SELF']); ?>">
            <input type="hidden".. ..
            </form>

            switch ($HTTP_POST_VAR S["SubmitButt on"]){
            //validation OK ???? continue
            //insert datas in mysql
            //redirect
            echo("<form action=\"nextpa ge.php\"...>... ..");

            I've choosen this method as depending on what the validation type is, I may
            redirect to 2 or more forms, and those form are accessable from many pages,
            so I would be lost and have to update at least 2 pages if I had a new page
            to create. By this way I only update 1 page. I haven't found any way to
            redirect server side with POST datas.


            Comment

            • Chung Leong

              #7
              Re: Hide URL parameters

              "Bob Bedford" <bedford1@YouKn owWhatToDoHereh otmail.com> wrote in message
              news:416a929c$0 $28016$5402220f @news.sunrise.c h...[color=blue]
              >[color=green]
              > > But why would you make a script that does nothing but a client-side
              > > redirect? It would be much easier and safer to just call edit.php
              > > directly, so the variables do not get to the client at all.[/color]
              > I've my form, wich action target is itself. If the desired things are[/color]
              done,[color=blue]
              > then I allow the user to go further.
              >
              > Let's explain:
              >
              > <form method="post" action="<?php echo($HTTP_SERV ER_VARS['PHP_SELF']);[/color]
              ?>">[color=blue]
              > <input type="hidden".. ..
              > </form>
              >
              > switch ($HTTP_POST_VAR S["SubmitButt on"]){
              > //validation OK ???? continue
              > //insert datas in mysql
              > //redirect
              > echo("<form action=\"nextpa ge.php\"...>... ..");
              >
              > I've choosen this method as depending on what the validation type is, I[/color]
              may[color=blue]
              > redirect to 2 or more forms, and those form are accessable from many[/color]
              pages,[color=blue]
              > so I would be lost and have to update at least 2 pages if I had a new page
              > to create. By this way I only update 1 page. I haven't found any way to
              > redirect server side with POST datas.
              >[/color]

              Use the HTTP status code 307 to redirect a POST.

              header("HTTP/1.0 307 Temporary Redirect");
              header("Locatio n: $url");


              Might not work in some non-standard browsers, however.


              Comment

              • Bob Bedford

                #8
                Re: Hide URL parameters

                "Kevin Thorpe" <kevin@pricetra k.com> a écrit dans le message de news:
                416a8f41$0$9832 $afc38c87@news. easynet.co.uk.. .[color=blue]
                > Bob Bedford wrote:
                >[color=green]
                >>[color=darkred]
                >>> Surely this is a prime case for using sessions. You're already passing
                >>> SID so you must use them.
                >>>[/color]
                >>
                >> It's there any limitation (KB, number) of params in the Session variable
                >> ? because on some pages I've up to 30 parameters.[/color]
                >
                > You should be ok up to very large arrays. What php does (on Linux/Apache
                > anyway) is serialize() the $_SESSION array any write it into your /tmp
                > directory. I hold piles of stuff in there and haven't had any problems.
                >[/color]
                As I understand, and after a little look, I may do something like:

                $_SESSION['Var1'] = $value1
                $_SESSION['Var2'] = $value2
                ....
                header("Locatio n: NextPage.php?". SID);

                and in NextPage.php I'll have every var without need to use POST or GET ?

                Bob


                Comment

                • Michael Fesser

                  #9
                  Re: Hide URL parameters

                  .oO(Chung Leong)
                  [color=blue]
                  >Use the HTTP status code 307 to redirect a POST.
                  >
                  >header("HTTP/1.0 307 Temporary Redirect");
                  >header("Locati on: $url");[/color]

                  RFC 2616, 10.3.8:

                  "If the 307 status code is received in response to a request other than
                  GET or HEAD, the user agent MUST NOT automatically redirect the request
                  unless it can be confirmed by the user, since this might change the
                  conditions under which the request was issued."

                  Micha

                  Comment

                  • Kevin Thorpe

                    #10
                    Re: Hide URL parameters

                    Bob Bedford wrote:[color=blue]
                    > "Kevin Thorpe" <kevin@pricetra k.com> a écrit dans le message de news:
                    > 416a8f41$0$9832 $afc38c87@news. easynet.co.uk.. .
                    >[color=green]
                    >> Bob Bedford wrote:
                    >>[color=darkred]
                    >>>
                    >>>> Surely this is a prime case for using sessions. You're already passing
                    >>>> SID so you must use them.
                    >>>>
                    >>>
                    >>> It's there any limitation (KB, number) of params in the Session
                    >>> variable ? because on some pages I've up to 30 parameters.[/color]
                    >>
                    >>
                    >> You should be ok up to very large arrays. What php does (on
                    >> Linux/Apache anyway) is serialize() the $_SESSION array any write it
                    >> into your /tmp directory. I hold piles of stuff in there and haven't
                    >> had any problems.
                    >>[/color]
                    > As I understand, and after a little look, I may do something like:
                    >
                    > $_SESSION['Var1'] = $value1
                    > $_SESSION['Var2'] = $value2
                    > ...
                    > header("Locatio n: NextPage.php?". SID);
                    >
                    > and in NextPage.php I'll have every var without need to use POST or GET ?[/color]

                    in NextPage.php you can then read $_SESSION['Var1'] and
                    $_SESSION['Var2']. The only things you need to pass in the url are those
                    which vary from link to link.

                    You shouldn't need to pass SID explicitly anyway. If cookies are enabled
                    on the browser then SID is passed via that. If the ini param
                    enable_trans_si d is enabled then browsers without cookies will have it
                    appended to urls automatically.

                    Comment

                    • Bob Bedford

                      #11
                      Re: Hide URL parameters

                      > in NextPage.php you can then read $_SESSION['Var1'] and[color=blue]
                      > $_SESSION['Var2']. The only things you need to pass in the url are those
                      > which vary from link to link.
                      >
                      > You shouldn't need to pass SID explicitly anyway. If cookies are enabled
                      > on the browser then SID is passed via that. If the ini param
                      > enable_trans_si d is enabled then browsers without cookies will have it
                      > appended to urls automatically.[/color]

                      Great, thanks for the info. Very helpfull !!!!

                      Cheers.

                      Bob

                      Comment

                      • Chung Leong

                        #12
                        Re: Hide URL parameters

                        "Michael Fesser" <netizen@gmx.ne t> wrote in message
                        news:qtdnm0pf4a hsoqppgi3ngmdbf 3be0arcg3@4ax.c om...[color=blue]
                        > .oO(Chung Leong)
                        >[color=green]
                        > >Use the HTTP status code 307 to redirect a POST.
                        > >
                        > >header("HTTP/1.0 307 Temporary Redirect");
                        > >header("Locati on: $url");[/color]
                        >
                        > RFC 2616, 10.3.8:
                        >
                        > "If the 307 status code is received in response to a request other than
                        > GET or HEAD, the user agent MUST NOT automatically redirect the request
                        > unless it can be confirmed by the user, since this might change the
                        > conditions under which the request was issued."
                        >
                        > Micha[/color]

                        IE ignores this stupid requirement in the RFC, hence it's irrelevant.


                        Comment

                        • Michael Fesser

                          #13
                          Re: Hide URL parameters

                          .oO(Chung Leong)
                          [color=blue]
                          >"Michael Fesser" <netizen@gmx.ne t> wrote
                          >[color=green]
                          >> RFC 2616, 10.3.8:
                          >>
                          >> "If the 307 status code is received in response to a request other than
                          >> GET or HEAD, the user agent MUST NOT automatically redirect the request
                          >> unless it can be confirmed by the user, since this might change the
                          >> conditions under which the request was issued."[/color]
                          >
                          >IE ignores this stupid requirement in the RFC[/color]

                          Why stupid?
                          [color=blue]
                          >hence it's irrelevant.[/color]

                          The classic knockout argument, "it works in IE so it can't be wrong".
                          Would you also recommend to use a Location-header with a relative URL,
                          just because it works in most browsers? What about other browsers?

                          Micha

                          Comment

                          • John Dunlop

                            #14
                            Re: Hide URL parameters

                            Michael Fesser wrote:
                            [color=blue]
                            > .oO(Chung Leong)[/color]
                            [color=blue][color=green]
                            > > IE ignores this stupid requirement in the RFC[/color]
                            >
                            > Why stupid?
                            >[color=green]
                            > >hence it's irrelevant.[/color]
                            >
                            > The classic knockout argument, "it works in IE so it can't be wrong".[/color]

                            Chung's sly joke was lost somewhere.

                            Oh well; the weekend's nearing!

                            --
                            Jock

                            Comment

                            Working...