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

RE: [PBML] script question

Expand Messages
  • Rich Foreman
    Andy, I changed it as follows and now it works to read the data, but it will not save any changes.. Any clue: You can try it at
    Message 1 of 7 , Jul 13 3:10 PM
    • 0 Attachment
      Andy,

      I changed it as follows and now it works to read the data, but it will not
      save any changes.. Any clue: You can try it at
      www.icegators.com/cgi-bin/schedule/schedule.cgi

      Thanks,

      Rich

      Updated script:

      #!/usr/local/bin/perl
      ##################################################
      ## schedule.cgi (C)2000-01 icegators.com ##
      ##################################################
      ## Rich Foreman (http://www.acshosting.com) ##
      ## ##
      ## IceGators Schedule ##
      ## ##
      ## COPYRIGHT NOTICE: ##
      ## ##
      ## Copyright 1999-00 Rich Foreman. ##
      ## All Rights Reserved. ##
      ## ##
      ## All files associated with this program ##
      ## fall under this copyright notice. ##
      ## ##
      ## Selling the code ##
      ## (in whole or in part) for this program ##
      ## without prior written consent is expressly ##
      ## forbidden. Obtain permission before ##
      ## redistributing this program over the ##
      ## Internet or in any other medium. ##
      ## ##
      ## Modification to the code are permitted ##
      ## so long as the modified code is not sold ##
      ## or redistributed without prior written ##
      ## consent. In all cases copyright and header ##
      ## must remain intact. ##
      ## ##
      ## All violaters will be prosecuted. ##
      ## ##
      ## This program is distributed "as is" and ##
      ## without warranty of any kind, either express ##
      ## or implied. (Some states do not allow the ##
      ## limitation or exclusion of liability for ##
      ## incidental or consequential damages, so this ##
      ## notice may not apply to you.) In no event ##
      ## shall the liability of Rich Foreman for any ##
      ## damages, losses and/or causes of action ##
      ## exceed the total amount paid by the user for ##
      ## this software. ##
      ## ##
      ##################################################

      &parseform;
      $command = "$ENV{'QUERY_STRING'}";

      $action = $FORM{'action'};

      if($action eq "svsched") { &svsched; }
      else { &change; }

      sub parseform {
      read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
      @sets = split(/&/, $buffer);
      foreach $set (@sets)
      {
      ($name, $value) = split(/=/, $set);
      $value =~ tr/+/ /;
      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
      $value =~ s/^( +)//;
      $value =~ s/( +)$//;
      unless($name eq "message" || $name eq "auto" || $name eq "autores" || $name
      eq "listcont") {
      $value =~ s/(\t|\r|\n)//g;
      }
      $FORM{$name} = $value;
      }
      }

      sub change {
      open(LIST,
      "/usr/local/etc/httpd/cgi-bin/schedule/data/lists/20002001Schedule");
      @list = <LIST>;
      close(LIST);
      print "Content-type:text/html\n\n";
      print qq|

      <html>

      <head>
      <title>IceGators Schedule</title>
      </head>

      <body>

      <div align="center">
      <center>
      <table border="0" width="90%" cellspacing="0" cellpadding="2">
      <tr>
      <td width="100%" bgcolor="#000066"><font face="Arial"
      color="#FFFFFF"><b>IceGators Schedule - Make Schedule
      Changes</b></font></td>
      </tr>
      <tr>
      <td width="100%">
      <blockquote>
      <p><br>
      <font face="Arial" size="2">Please edit
      below:
      </font></p>
      <center>
      <form method="POST"
      action="http://www.icegators.com/cgi-bin/schedule/schedule.cgi">
      <input type="hidden" name="pass" value="$FORM{'pass'}"><input type="hidden"
      name="action" value="svsched">
      <input type="hidden" name="list" value="$FORM{'list'}">
      <textarea rows="15"
      name="listcont" cols="100">|;
      foreach $line (@list) {
      chop($line);
      print "$line\n";
      }
      print qq|
      </textarea>
      <p><input type="submit" value="Save"></p>
      </form>
      </center>
      </blockquote>
      </td>
      </tr>
      </center>
      <tr>
      <td width="100%" bgcolor="#000066">
      <p align="right"><font face="Arial" size="2"
      color="#FFFFFF">©2000-2001 Rich Foreman</font></td>
      </tr>
      </table>
      </div>

      </body>

      </html>
      |;
      exit;
      }

      sub svsched {
      open(LIST,
      "/usr/local/etc/httpd/cgi-bin/schedule/data/lists/20002001Schedule");
      flock LIST, 2;
      @list = split(/\n/,$FORM{'listcont'});
      foreach $line (@list) {
      chomp($line);
      print LIST "$line\n";
      }
      close(LIST);
      print "Content-type:text/html\n\n";
      print qq|

      <html>

      <head>
      <title>IceGators Schedule</title>
      </head>

      <body>

      <div align="center">
      <center>
      <table border="0" width="90%" cellspacing="0" cellpadding="2">
      <tr>
      <td width="100%" bgcolor="#000066"><font face="Arial"
      color="#FFFFFF"><b>IceGators Schedule - Make Schedule
      Changes</b></font></td>
      </tr>
      <tr>
      <td width="100%">
      <blockquote>
      <p><br>
      <font face="Arial" size="2">The schedule has been
      saved.</font></p>
      </blockquote>
      </td>
      </tr>
      </center>
      <tr>
      <td width="100%" bgcolor="#000066">
      <p align="right"><font face="Arial" size="2"
      color="#FFFFFF">©2000-2001 Rich Foreman</font></td>
      </tr>
      </table>
      </div>

      </body>

      </html>

      |;
      exit;
      }
    • Andy Dougherty
      ... Sigh. Had you followed my very first suggestion to use -w, perl would have told you the error. Was it really that hard to put a -w on the #! line? ...
      Message 2 of 7 , Jul 14 8:17 AM
      • 0 Attachment
        On Thu, 13 Jul 2000, Rich Foreman wrote:

        > Andy,
        >
        > I changed it as follows and now it works to read the data, but it will not
        > save any changes.. Any clue: You can try it at
        > www.icegators.com/cgi-bin/schedule/schedule.cgi

        Sigh. Had you followed my very first suggestion to use -w, perl
        would have told you the error. Was it really that hard to put a -w
        on the #! line?

        The immediate problem is here:

        > sub svsched {
        > open(LIST,
        > "/usr/local/etc/httpd/cgi-bin/schedule/data/lists/20002001Schedule");

        You open the file for INPUT. Then,

        > print LIST "$line\n";

        you try to use that filehandle for OUTPUT. That won't work.

        Had you used perl -w, you would have gotten the error message

        Filehandle main::LIST opened only for input

        That's the sort of thing I meant by advising you to use -w to let perl
        help you help yourself.

        --
        Andy Dougherty doughera@...
        Dept. of Physics
        Lafayette College, Easton PA 18042
      • Rich Foreman
        I thought this list was for beginners.. Yes, I see that I opened it for input, but I still don t get how to make it save the changes I made. Since I really
        Message 3 of 7 , Jul 14 10:50 AM
        • 0 Attachment
          I thought this list was for beginners.. Yes, I see that I opened it for
          input, but I still don't get how to make it save the changes I made. Since
          I really don't understand how to open a file for reading or writing, the -w
          didn't help me too much...

          I'm not trying to become a Perl programmer here, just trying to make these
          guys schedule work a little easier...

          Thanks,

          Rich

          -----Original Message-----
          From: Andy Dougherty [mailto:doughera@...]
          Sent: Friday, July 14, 2000 10:17 AM
          To: perl-beginner@egroups.com
          Subject: RE: [PBML] script question


          On Thu, 13 Jul 2000, Rich Foreman wrote:

          > Andy,
          >
          > I changed it as follows and now it works to read the data, but it will not
          > save any changes.. Any clue: You can try it at
          > www.icegators.com/cgi-bin/schedule/schedule.cgi

          Sigh. Had you followed my very first suggestion to use -w, perl
          would have told you the error. Was it really that hard to put a -w
          on the #! line?

          The immediate problem is here:

          > sub svsched {
          > open(LIST,
          > "/usr/local/etc/httpd/cgi-bin/schedule/data/lists/20002001Schedule");

          You open the file for INPUT. Then,

          > print LIST "$line\n";

          you try to use that filehandle for OUTPUT. That won't work.

          Had you used perl -w, you would have gotten the error message

          Filehandle main::LIST opened only for input

          That's the sort of thing I meant by advising you to use -w to let perl
          help you help yourself.

          --
          Andy Dougherty doughera@...
          Dept. of Physics
          Lafayette College, Easton PA 18042


          ------------------------------------------------------------------------
          Still looking for the complete Application Server solution?
          Find answers and a $75 gift certificate at the Intraware App Server
          Webinar. Sign up at:
          http://click.egroups.com/1/6756/2/_/12898/_/963588135/
          ------------------------------------------------------------------------
        • Rich Foreman
          Sorry about my earlier response... I figured it out. I needed to open the file like this to edit it: open(LIST,
          Message 4 of 7 , Jul 14 11:16 AM
          • 0 Attachment
            Sorry about my earlier response... I figured it out. I needed to open the
            file like this to edit it:

            open(LIST,
            ">/usr/local/etc/httpd/cgi-bin/schedule/data/lists/20002001Schedule");

            I got that working perfectly now. Thanks for the help.

            Now for the remaining question... the data in the file looks like this:

            10102000|LA|MIS|W|2|0

            which is:

            Date|AwayTeam|HomeTeam|WinLoss|AwayScore|HomeScore

            Where can I find out how to write another script that required this file,
            and also defines teams with URL's, such as:

            LA=http://www.icegators.com/logos/small/la.gif
            MIS=http://www.icegators.com/logos/small/mis.gif

            etc.....

            and use the date to determine the last game and next game so that I can
            print them as an HTML output when running the script as an SSI...

            I really need a sort of easy tutorial on this type of action... including
            how to define that the data in the pipes in the output for the file, like:

            $date|$awayt|$ahomet|$wl|$aways|$homes

            so that the script can tell what goes where in the HTML file....

            Thanks,

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