Loading ...
Sorry, an error occurred while loading the content.
 

RE: [PBML] taint mode module?

Expand Messages
  • Franki
    yeah, I was using lib before.. the code is full of if unix and if windows.. and its a long script.. so setting a path variable and having $Bin is handy.. for
    Message 1 of 6 , Mar 2, 2002
      yeah, I was using lib before..

      the code is full of if unix and if windows.. and its a long script..

      so setting a path variable and having $Bin is handy..

      for example, if I am running a script in one directory.. and I want to
      require a file in a directory off the parent directory.

      I can do this:
      $Path =~ s/current_directory//g;

      to make path equal to the parant directory..

      and still have $bin as the cwd..

      its worked for me, is there a better way?

      I'd still love to be able to put taint into an:

      if (operating_system = 'unix'){
      use tainted;
      }

      and have it work for the whole scirpt.. just as taint mode works.. because
      obviously this doesn't.

      if (operating_system = 'unix'){
      #!/usr/bin/perl -T
      }

      if (operating_system = 'win'){
      #!/usr/bin/perl
      }

      shame it doesn't actually...

      I know from the docs that I can use the tainted module to check a var for
      taintedness.. but is there away to apply that to the whole script in the
      same manner that -T does??


      rgds

      Frank

      -----Original Message-----
      From: Charles K. Clarkson [mailto:cclarkson@...]
      Sent: Saturday, 2 March 2002 1:51 PM
      To: perl-beginner@yahoogroups.com
      Subject: Re: [PBML] taint mode module?


      "Franki" <frankieh@...> mentioned:

      : This is what I have now. (what I use to make it more platform
      independent.)
      :
      : $OS = $^O;
      : if ($OS =~ /Win/i){
      : $operating_system = 'win';
      : }
      : else {
      : $operating_system = 'unix';
      : }
      : my $path;
      : use FindBin qw($Bin);
      : $path=$Bin;
      : BEGIN {push @INC, $Bin};
      :
      : if ($operating_system eq 'unix'){
      : require "./config/conf.pl";
      : require "./Escape.pl";
      : }
      : if ($operating_system eq 'win'){
      : require "$path/config/conf.pl";
      : require "$path/Escape.pl";
      : }
      : and that seems to work just fine.. (incidently, should the call to FindBin
      : be in the begin braces as well???)

      It already is. According the the docs, 'use' almost equivalent to
      require
      and
      import wrapped in a BEGIN block :

      use FindBin qw( $Bin ); is almost the same as :

      BEGIN {
      require FindBin;
      import FindBin qw( $Bin );
      }


      BTW, your code executes in this order:

      use FindBin qw($Bin);
      BEGIN {push @INC, $Bin};

      $OS = $^O;
      if ($OS =~ /Win/i){
      $operating_system = 'win';
      } else {
      $operating_system = 'unix';
      }

      my $path = $Bin;
      if ($operating_system eq 'unix') {
      require "./config/conf.pl";
      require "./Escape.pl";
      }
      if ($operating_system eq 'win') {
      require "$path/config/conf.pl";
      require "$path/Escape.pl";
      }

      I'm curious. Why are $OS and $operating_system not lexical variables?
      In fact, why use them at all:

      use FindBin qw($Bin);
      use lib $Bin;

      if ($^O =~ /Win/i) {
      require "./config/conf.pl";
      require "./Escape.pl";
      } else {
      require "$Bin/config/conf.pl";
      require "$Bin/Escape.pl";
      }

      'lib' is similar to what you were doing but deletes possible duplicate
      directiories to prevent memory leaks and "looks" nicer.


      Charles K. Clarkson
      --
      Clarkson Energy Homes, Inc.
      CJ Web Works - Domains for Real Estate Investors.

      E Pluribus Unum -- One from many.




      Unsubscribing info is here:
      http://help.yahoo.com/help/us/groups/groups-32.html

      Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    • Juni Adi
      Hello folks, This is my 1st time dealing with cookie. Basically I just want to know wether it s the first time a client accessing my index.shtml or they just
      Message 2 of 6 , Mar 4, 2002
        Hello folks,
        This is my 1st time dealing with
        cookie. Basically I just want to know wether it's
        the first time a client accessing my index.shtml
        or they just "refresh" the page. Thinking that it
        would be done through cookie thing, I wrote
        cookie.cgi that will be called from index.shtml
        through SSI.

        index.shtml looks like:
        <html>
        <!--#exec cgi="cgi-bin/cookie.cgi" -->
        </html>

        -----end of index.html----

        cookie.cgi looks like:

        #!/usr/bin/perl
        #cookie.cgi
        use CGI;
        $q=new CGI;

        #set cookie
        $me='skiper';
        $path='/';
        $cookie=$q->cookie(-name=>"user_name",-value=>$me, -path=>$path);
        print $q->header(-type=>'text/html',-cookie=>$cookie);

        #accessing cookie (if there is cookie)
        $user=$q->cookie(-name=>'user_name');

        if ($user){
        print "$user\n";
        }
        else{
        print "no cookie\n";
        }

        --- end of cookie.cgi----

        Now comes the problem.
        It seems like it failed to set cookie. When user
        "refresh" index.shtml page (that supposed to
        send back the cookie to the script), the script
        got no cookie at all.

        Then I try to call the script directly from
        URL. First time I call the script, I got "no
        cookie". Then "refresh" the page, and get the
        cookie printed out.

        It would be great if any of you could give me
        explanations.


        Regards
        Juni Adi
        www.arupa.or.id
      • b_harnish
        ... The problem is that when done through SSI, the header information (Content-type, length, ...) has already been sent to the browser, so your script can t do
        Message 3 of 6 , Mar 5, 2002
          --- In perl-beginner@y..., Juni Adi <skiper@a...> wrote:
          > Hello folks,
          > This is my 1st time dealing with
          > cookie. Basically I just want to know wether it's
          > the first time a client accessing my index.shtml
          > or they just "refresh" the page. Thinking that it
          > would be done through cookie thing, I wrote
          > cookie.cgi that will be called from index.shtml
          > through SSI.
          >
          > index.shtml looks like:
          > <html>
          > <!--#exec cgi="cgi-bin/cookie.cgi" -->
          > </html>
          >
          > -----end of index.html----
          >
          > cookie.cgi looks like:
          >
          > #!/usr/bin/perl
          > #cookie.cgi
          > use CGI;
          > $q=new CGI;
          >
          > #set cookie
          > $me='skiper';
          > $path='/';
          > $cookie=$q->cookie(-name=>"user_name",-value=>$me, -path=>$path);
          > print $q->header(-type=>'text/html',-cookie=>$cookie);
          >
          > #accessing cookie (if there is cookie)
          > $user=$q->cookie(-name=>'user_name');
          >
          > if ($user){
          > print "$user\n";
          > }
          > else{
          > print "no cookie\n";
          > }
          >
          > --- end of cookie.cgi----
          >
          > Now comes the problem.
          > It seems like it failed to set cookie. When user
          > "refresh" index.shtml page (that supposed to
          > send back the cookie to the script), the script
          > got no cookie at all.
          >
          > Then I try to call the script directly from
          > URL. First time I call the script, I got "no
          > cookie". Then "refresh" the page, and get the
          > cookie printed out.
          >
          > It would be great if any of you could give me
          > explanations.

          The problem is that when done through SSI, the header information (Content-type, length, ...) has already been sent to the browser, so your script can't do Set-Cookie.

          When you call the script directly, the header info has NOT been sent, and thus, your script can do Set-Cookie, and works fine.

          AFAIK, the only way to set a cookie after the header info has been sent is to use a clientside script (i.e. javascript).

          - Brian
        • Nguyen, David M
          What module do we use to mirror an entire website? Thanks, David
          Message 4 of 6 , Mar 6, 2002
            What module do we use to mirror an entire website?

            Thanks,
            David
          • Juni Adi
            Hello Brian, ... Yes, that s what I did after sending my email. Thanks for the explanations anyway. Juni Adi
            Message 5 of 6 , Mar 6, 2002
              Hello Brian,

              On Tue, 5 Mar 2002, b_harnish wrote:
              |
              |AFAIK, the only way to set a cookie after the
              |header info has been sent is to use a clientside
              |script (i.e. javascript).

              Yes, that's what I did after sending my email.
              Thanks for the explanations anyway.


              Juni Adi
            Your message has been successfully submitted and would be delivered to recipients shortly.