f



guestbook.cgi :p

#!/usr/bin/perl -Tw
use strict;
use CGI qw/:standard escapeHTML/;
use Fcntl qw/:flock/;
$|++;

# Config
my $GUESTBOOK = '/var/www/cgi-bin/guestbook.txt'; 
my $TITLE = 'Guestbook';  # Title of guestbook
my $MAX_MSGS = 5;         # Maximum number of messages displayed
my $MAX_NAME = 50;        # Maximum length of name field
my $MAX_EMAIL = 50;       # Maximum length of email field
my $MAX_COMMENTS = 300;   # Maximum length of comments field
# End Config

# Print header
print header,
      start_html(-title=>$TITLE, -bgcolor=>'white'),
      h1($TITLE);

# Get action
my $action = param('action');

# Check action
if ($action =~ /^sign/i) {
    # Sign guestbook
    sign_guestbook();
} elsif ($action =~ /^view/i) {
    # View guestbook
    view_guestbook();
} else {
    print_form();
}

# End html
print end_html;

#######################################

sub print_form {
    print hr,
          start_form,
          '<STRONG>Name: </STRONG>',
          br,
          textfield(-name=>'name', -size=>50),
          br,
          '<STRONG>E-Mail: </STRONG>',
          br,
          textfield(-name=>'email', -size=>50),
          br,
          '<STRONG>Comments: </STRONG>',
          br,
          textarea(-name=>'comments', -rows=>10,
                   -columns=>50, -wrap=>1),
          br,
          submit(-name=>'action', -value=>'Sign Guestbook'),
          submit(-name=>'action', -value=>'View Guestbook'),
          reset,
          end_form;

}

sub sign_guestbook {
    my $time = localtime;
    my $name = param('name');
    my $email = param('email');
    my $comments = param('comments');

    # Check that name was entered
    if ($name eq '' or $name =~ /^\s+$/) {
        print_error('You must enter a name');
    }

    # Check lenghts of user input
    $name = substr($name, 0, $MAX_NAME);
    $email = substr($email, 0, $MAX_EMAIL);
    $comments = substr($comments, 0, $MAX_COMMENTS);

    # Remove leading/trailing white space
    $comments =~ s/^\s+//;
    $comments =~ s/\s+$//;

    # Escape HTML 
    $name = escapeHTML($name);
    $email = escapeHTML($email);
    $comments = escapeHTML($comments);

    # Deal with line breaks
    $comments =~ s/(?:\015\012?|\012)/<BR>/g;

    open(FILE, ">>$GUESTBOOK") or
      die "Can't open $GUESTBOOK: $!\n";
    flock(FILE, LOCK_EX); # Exclusive lock for writing

    print FILE $time, ':::', $name, ':::', $email, ':::', $comments, "\n";

    flock(FILE, LOCK_UN); # Unlock the file
    close FILE;

    # Check size of message file
    max_msgs();

    my $script = url();
    print hr,
          'Thank you for signing my guestbook',
          p,
          a({-href=>"${script}?action=view"},'View Guestbook');

}

sub view_guestbook {
    my $script = url();

    print a({-href=>$script}, 'Sign Guestbook'),
          hr;

    # Check size of message file
    max_msgs();

    # Read message file
    open(FILE, "$GUESTBOOK") or 
      die "Cannot open $GUESTBOOK: $!\n";
    flock(FILE, LOCK_SH); # Shared lock for reading

    my @messages = <FILE>;

    flock(FILE, LOCK_UN); # Unlock the file
    close (FILE);

    @messages = reverse (@messages);
    foreach my $item (@messages) {
        my($time, $name, $email, $comments) = split(':::', $item);

        # Format fields
        my $f_name = "<STRONG>$name</STRONG>";
        my $f_email = "<A HREF=mailto:$email>$email</A>";

        # Output a record
        print "$time - $f_name - $f_email",
              p(blockquote($comments)),
              hr;
    }

}

sub max_msgs {
    # If more than MAX_MSGS messages, delete oldest

    # Read message file
    open(FILE, "$GUESTBOOK") or 
      die "Cannot open $GUESTBOOK: $!\n";
    flock(FILE, LOCK_SH); # Shared lock for reading

    my @messages = <FILE>;

    flock(FILE, LOCK_UN); # Unlock the file
    close (FILE);


    if(@messages > $MAX_MSGS) {
        open(FILE, ">$GUESTBOOK") or 
          die "Cannot open $GUESTBOOK: $!\n";
        flock(FILE, LOCK_EX); # Exclusive lock for writing

        shift @messages while @messages > $MAX_MSGS;

        print FILE @messages;

        flock(FILE, LOCK_UN); # Unlock the file
        close FILE;
    }


}
    
sub print_error {
    my $error = shift;
    my $script = url();
    print hr,
          h2('Error'), 
          p($error),
          a({href=>$script}, 'Try Again'),
          end_html;
    die $error;
}

0
3/2/2007 11:43:04 AM
comp.lang.perl.misc 33233 articles. 2 followers. brian (1246) is leader. Post Follow

5 Replies
28243 Views

Similar Articles

[PageSpeed] 5

john.swilting wrote:

> #!/usr/bin/perl -Tw
> use strict;
> use CGI qw/:standard escapeHTML/;
> use Fcntl qw/:flock/;
> $|++;
> 
> # Config
> my $GUESTBOOK = '/var/www/cgi-bin/guestbook.txt';
> my $TITLE = 'Guestbook';  # Title of guestbook
> my $MAX_MSGS = 5;         # Maximum number of messages displayed
> my $MAX_NAME = 50;        # Maximum length of name field
> my $MAX_EMAIL = 50;       # Maximum length of email field
> my $MAX_COMMENTS = 300;   # Maximum length of comments field
> # End Config
> 
> # Print header
> print header,
>       start_html(-title=>$TITLE, -bgcolor=>'white'),
>       h1($TITLE);
> 
> # Get action
> my $action = param('action');
> 
> # Check action
> if ($action =~ /^sign/i) {
>     # Sign guestbook
>     sign_guestbook();
> } elsif ($action =~ /^view/i) {
>     # View guestbook
>     view_guestbook();
> } else {
>     print_form();
> }
> 
> # End html
> print end_html;
> 
> #######################################
> 
> sub print_form {
>     print hr,
>           start_form,
>           '<STRONG>Name: </STRONG>',
>           br,
>           textfield(-name=>'name', -size=>50),
>           br,
>           '<STRONG>E-Mail: </STRONG>',
>           br,
>           textfield(-name=>'email', -size=>50),
>           br,
>           '<STRONG>Comments: </STRONG>',
>           br,
>           textarea(-name=>'comments', -rows=>10,
>                    -columns=>50, -wrap=>1),
>           br,
>           submit(-name=>'action', -value=>'Sign Guestbook'),
>           submit(-name=>'action', -value=>'View Guestbook'),
>           reset,
>           end_form;
> 
> }
> 
> sub sign_guestbook {
>     my $time = localtime;
>     my $name = param('name');
>     my $email = param('email');
>     my $comments = param('comments');
> 
>     # Check that name was entered
>     if ($name eq '' or $name =~ /^\s+$/) {
>         print_error('You must enter a name');
>     }
> 
>     # Check lenghts of user input
>     $name = substr($name, 0, $MAX_NAME);
>     $email = substr($email, 0, $MAX_EMAIL);
>     $comments = substr($comments, 0, $MAX_COMMENTS);
> 
>     # Remove leading/trailing white space
>     $comments =~ s/^\s+//;
>     $comments =~ s/\s+$//;
> 
>     # Escape HTML
>     $name = escapeHTML($name);
>     $email = escapeHTML($email);
>     $comments = escapeHTML($comments);
> 
>     # Deal with line breaks
>     $comments =~ s/(?:\015\012?|\012)/<BR>/g;
> 
>     open(FILE, ">>$GUESTBOOK") or
>       die "Can't open $GUESTBOOK: $!\n";
>     flock(FILE, LOCK_EX); # Exclusive lock for writing
> 
>     print FILE $time, ':::', $name, ':::', $email, ':::', $comments, "\n";
> 
>     flock(FILE, LOCK_UN); # Unlock the file
>     close FILE;
> 
>     # Check size of message file
>     max_msgs();
> 
>     my $script = url();
>     print hr,
>           'Thank you for signing my guestbook',
>           p,
>           a({-href=>"${script}?action=view"},'View Guestbook');
> 
> }
> 
> sub view_guestbook {
>     my $script = url();
> 
>     print a({-href=>$script}, 'Sign Guestbook'),
>           hr;
> 
>     # Check size of message file
>     max_msgs();
> 
>     # Read message file
>     open(FILE, "$GUESTBOOK") or
>       die "Cannot open $GUESTBOOK: $!\n";
>     flock(FILE, LOCK_SH); # Shared lock for reading
> 
>     my @messages = <FILE>;
> 
>     flock(FILE, LOCK_UN); # Unlock the file
>     close (FILE);
> 
>     @messages = reverse (@messages);
>     foreach my $item (@messages) {
>         my($time, $name, $email, $comments) = split(':::', $item);
> 
>         # Format fields
>         my $f_name = "<STRONG>$name</STRONG>";
>         my $f_email = "<A HREF=mailto:$email>$email</A>";
> 
>         # Output a record
>         print "$time - $f_name - $f_email",
>               p(blockquote($comments)),
>               hr;
>     }
> 
> }
> 
> sub max_msgs {
>     # If more than MAX_MSGS messages, delete oldest
> 
>     # Read message file
>     open(FILE, "$GUESTBOOK") or
>       die "Cannot open $GUESTBOOK: $!\n";
>     flock(FILE, LOCK_SH); # Shared lock for reading
> 
>     my @messages = <FILE>;
> 
>     flock(FILE, LOCK_UN); # Unlock the file
>     close (FILE);
> 
> 
>     if(@messages > $MAX_MSGS) {
>         open(FILE, ">$GUESTBOOK") or
>           die "Cannot open $GUESTBOOK: $!\n";
>         flock(FILE, LOCK_EX); # Exclusive lock for writing
> 
>         shift @messages while @messages > $MAX_MSGS;
> 
>         print FILE @messages;
> 
>         flock(FILE, LOCK_UN); # Unlock the file
>         close FILE;
>     }
> 
> 
> }
>     
> sub print_error {
>     my $error = shift;
>     my $script = url();
>     print hr,
>           h2('Error'),
>           p($error),
>           a({href=>$script}, 'Try Again'),
>           end_html;
>     die $error;
> }
I post. it is my code. you can say to me what you think that will make me
progress.
0
john
3/2/2007 11:46:19 AM
john.swilting wrote:


> I post. it is my code. you can say to me what you think that will make me
> progress.
I read posts with small images very to complicate. I cannot do it. somebody
knows
0
john
3/2/2007 11:50:41 AM
john.swilting <john.swilting@wanadoo.fr> wrote in comp.lang.perl.misc:
> john.swilting wrote:
> 
> > #!/usr/bin/perl -Tw
> > use strict;
> > use CGI qw/:standard escapeHTML/;
> > use Fcntl qw/:flock/;
> > $|++;
> > 
> > # Config
> > my $GUESTBOOK = '/var/www/cgi-bin/guestbook.txt';
> > my $TITLE = 'Guestbook';  # Title of guestbook
> > my $MAX_MSGS = 5;         # Maximum number of messages displayed
> > my $MAX_NAME = 50;        # Maximum length of name field
> > my $MAX_EMAIL = 50;       # Maximum length of email field
> > my $MAX_COMMENTS = 300;   # Maximum length of comments field
> > # End Config

[snip more somewhat dated (5.6.1) but reasonably well-written Perl]

> I post. it is my code. you can say to me what you think that will make me
> progress.

John, don't lie!  You know neither enough Perl nor English to be the
author of that code.

Anno
0
anno4000
3/3/2007 1:55:57 PM
anno4000@radom.zrz.tu-berlin.de wrote:
> john.swilting <john.swilting@wanadoo.fr> wrote in comp.lang.perl.misc:
>> john.swilting wrote:
>>
>>> #!/usr/bin/perl -Tw
>>> use strict;
>>> use CGI qw/:standard escapeHTML/;
>>> use Fcntl qw/:flock/;
>>> $|++;
>>>
>>> # Config
>>> my $GUESTBOOK = '/var/www/cgi-bin/guestbook.txt';
>>> my $TITLE = 'Guestbook';  # Title of guestbook
>>> my $MAX_MSGS = 5;         # Maximum number of messages displayed
>>> my $MAX_NAME = 50;        # Maximum length of name field
>>> my $MAX_EMAIL = 50;       # Maximum length of email field
>>> my $MAX_COMMENTS = 300;   # Maximum length of comments field
>>> # End Config
> 
> [snip more somewhat dated (5.6.1) but reasonably well-written Perl]
> 
>> I post. it is my code. you can say to me what you think that will make me
>> progress.
> 
> John, don't lie!  You know neither enough Perl nor English to be the
> author of that code.
> 

Indeed, Googling for the MAX_MSGS line of code suggests it came from 
http://www.telegard.net/

In http://www.telegard.net/tgfaq.html Tim Strike (apparently the current 
maintainer or owner of this code) says

"I have no intentions of releasing any of the source code that I produce"

"The Telegard 2.5g source code is floating around on various BBS and 
internet sites around the world. ... The legality of this source code is 
also in question"
0
RedGrittyBrick
3/3/2007 4:11:52 PM
On Mar 2, 5:46 am, "john.swilting" <john.swilt...@wanadoo.fr> wrote:
> john.swilting wrote:
> I post. it is my code. you can say to me what you think that will make me
> progress.

I think GuestBooks are dumb. The only 'people' who love to sign them
are housewives who own 6+ cats, 13 year old girls, spambots, and
probably Tad.

I also think flat file databases are a thing of 1997. They are slow,
less than effective and productive, and allow for to many security
holes and bugs.

I also think CGI.pm is worthless when it comes to printing HTML. John,
get up with the times! Check out some template modules that enables
the templates to be cached and ready on the fly! These days are all
about REAL database driven sites that use templates. Check out MayPole
or Catalyst.

Oh and... don't waste your time with guest book scripts!

Oh and... use English;

0
krakle
3/3/2007 10:21:14 PM
Reply:

Similar Artilces:

deisng perl perl programmibng langs in perl
then liberate big war zones with notes on their download pages. -r www.thevoid1.net/ ...

what's wrong calling a Perl/CGI script in Perl/CGI script under Tomcat server?
Hi all, I have small doubt, the following code works fine in Apache server. But not completely in Tomcat. Why?? ------------------------ #!C:\Perl\bin\perl.exe # hello.pl use CGI; $cgi = new CGI; print $cgi->header; printf "Hello world"; system("perl Hi.pl"); ------------------------ #!C:\Perl\bin\perl.exe # hi.pl print "Hi"; ------------------------ When I tried in Tomcat, the script prints only Hello world Why? What's wrong? kath. kath wrote: > I have small doubt, the following code works fine in Apache server. > But not completely in Tom...

p or ~p
My logic is a little fuzzy. In a legally-inadmissable setting a woman signed 4 letters to me. Because of recency, the last I can identify as 'e'. One I could not verify this morning. The other two were either {'r', 'a'} or {'a', 'r}. Order matters. Has anyone seen a treatment of the word problem with fuzzy logic in c? EC Elijah Cardon posted: > My logic is a little fuzzy. So is your language. > In a legally-inadmissable setting a woman > signed 4 letters to me. Be specific. (1) A letter of the alphabet (2) A letter which a person writes to another person > Because of recency, the last I can identify as 'e'. Makes no sense whatsoever, but I vaguely get the idea that you're trying to convey that the most recent letter is more memorable than the previous ones. > One I could not verify this morning. One of what? The letters? > The other two were either {'r', 'a'} or {'a', 'r'}. Oh, so you're talking about letters of the alphabet? > Order matters. Has anyone seen a treatment of the word problem with > fuzzy logic in c? Four letters. One of them is 'e'. There's an 'a' directly beside an 'r'. Shouldn't be hard to code: int ContainsE(char const *p) { for(;;) { switch(*p++) { case 'e': return 1; case 0: return 0; } } } int HasAbesideR...

Convert perl/ cgi web app to standalone perl app
I have a perl/cgi web application, running on ana pache server. The web application has radiobuttons, textfields, combo boxes, submit buttons etc. I want to write a standalone perl version. Can this be done and if so how ? Thanks. learnerplates wrote: > I have a perl/cgi web application, running on ana pache server. > The web application has radiobuttons, textfields, combo boxes, submit > buttons etc. > I want to write a standalone perl version. Can this be done Yes, can't see why not. But why do you want to do it? > and if so how ? By replacing the CGI parameters wit...

CGI: Execute a perl script inside another perl script
Hello, I am using perl scripts as CGI. What I want to do is to call another perl script where I only set environment variables (envCGI.pl). If I set these variables in my initial perl script, it works well (I get my HTML page) but if I call the other perl script, I get: [12/Jan/2005:10:43:22] failure ( 632): for host 10.70.176.104 trying to POST /surcouf.cgi, cgi_scan_headers reports: HTTP4044: the CGI program C:\Perl\bin\perl.exe did not produce a valid header (program terminated without a valid CGI header. Check for core dump or other abnormal termination). Here is my perl script: #!C:...

Perl CGI
Hi, I am a newbie to Perl CGI. I am developing an application with a web front end and C language module at the backend. The interface between them is a UDP socket. I am using Perl to construct the HTML pages. Here is what I do. 1) Show a web page and accept values from the web-user. 2) When the User presses "Submit", I construct a message and send it across the UDP socket to the backend. 3) I wait for the response from the backend. If the response is an error (could be because of wrong values entered by the user), I clean up the existing page and show a new page displaying an appropriate error message. 4) When I try to show the error html page, the contents always get appended to the existing html page. 5) How can I clear a html page and display a new one? I tried print $query->end_html and followed it up with a $query->start_html. Didnt work. Please help me. Thanks. haribalram@yahoo.com (Hari) wrote in message news:<9fb02734.0401190136.736a7dee@posting.google.com>... > I am a newbie to Perl CGI. When learning several new things at once (HTTP, HTML, CGI, Perl) it may help to learn them one at a time. Your question has nothing to do with Perl or CGI. Your question has to do with HTML and the HTTP request cycle. > 4) When I try to show the error html page, the contents always get > appended to the existing html page. > 5) How can I clear a html page and display a new one? I tried print > $query->end_html and followed it ...

Recommendation for a small web framework like Perl's CGI::Application to run as CGI?
I need to make a small, relatively low-traffic site that users can create accounts on and log into. Scripts must run as cgi (no mod_python or FastCGI is available). Can anyone recommend a small and simple web framework for Python, maybe similar to Perl's CGI::Application? Or would it just be better to roll my own? > I need to make a small, relatively low-traffic site that users can > create accounts on and log into. Scripts must run as cgi (no > mod_python or FastCGI is available). Can anyone recommend a small and > simple web framework for Python, maybe similar to Perl's...

Perl-Cgi Newbee!
Hi all and thanks in advance of any help given!. I have a perl-cgi program, and it takes data passed to it from a HTML form and processes it. The program can check to make sure the fields are filled in and are valid, but I need to check the actual e-mail address to conferm that it is one that the program is suppose to send to!, see below for better understanding!:- @myArray=(nowhere.com.uk, somewhere.com.au, somewhereelse.com.us); #yack yack yack!!! ($emailName, $emailAddress)=split(/@/, $form{$email}, 2); ________________________ the $emailName & $emailAddress are being set right, but...

Perl/CGI or PHP ?
I have some experience of Perl/CGI (always more to learn) and very little of PHP, but I understand that PHP provides a very good interface to MySQL databases via phpmyadmin. I have used this interface. As far as I can see and have cursorily read, Perl/CGI and PHP operate by different mechanisms. PHP is embedded into the HTML or XHTML pages in a similar way to Visual Basic. Perl/CGI operates by processing on the server side and producing html output as a response. Effectively one writes a perl script using CGI interface and plonks that it the cgi-bin with the right permissions set, then either access that cgi script directly or via form submission. At least that's the way I have used it. Data entered in the form can be accessed in a Perl/CGI script but I don't have any detail on how the mechanism works. I suspect that is at the HTTP/CGI/Perl interfaces. How does the same work for PHP ? If you were to start a project from scratch what would be the factors which would make you choose Perl/CGI or PHP? Are these two technologies distinct or can they be intermingled? Lesley ...

SAS with Perl CGI
Hello, I have installed (on windows XP) Perl and a Apache Server. I have a cgi script that allow me to launch a SAS program now, but I don't manage to have the result of the sas program on the web page... I have heard about stdout but I don't know how to make sas know where it has to write (i have put "file stdout" on a data step but it donesn't work...) (i launch sas using the system( ) command) Thanks for your answers ...

Perl CGI Issue
Hello, I'm having an issue with a perl CGI script. The code looks like this: #!/usr/bin/perl use CGI; use IO::Handle; $|=1; [... snip ...] # Redirect the user to the appropriate output page. $io = new IO::Handle; if ($io->fdopen(fileno(STDOUT),"w")) { $io->print("Output:output.php?load=$sum/$pdbid.html\n"); $io->flush() || die $!; } system("cmd & perl backend.pl $pdbid $sum"); # takes about 4 minutes to run My web page makes an AJAX post to this cgi script to start the "backend" process. Since that process takes a few minutes, I would like the user to be taken to a waiting page. However, I need to pass that $sum variable back to the page. In my head, this code should print the output message to stdout, start the backend.pl script in the background, exit and then send the contents of stdout down to the web page. In actuality what happens is there is a delay of several minutes before the output message is sent to the page. However, it is not the full amount of time required to run backend.pl. It seems to be pretty consistently about half of the required time. The page then gets the output message, and redirects to the waiting page and works fine from thereon out. Does anyone know how I can get that output message to my webpage immediately? As you can see I've tried flushing stdout several different ways with no luck. Also, if there is a better group for me to post to, that would be appreci...

Perl, javascript and CGI
Hi, I have the following scenario in a system that we run. From a webpage using javascript I am able to invoke a *.ipl script on the server and pass parameters as well: javascript param parsing: parameters = new Object(); parameters.iw_arrArtikelIDs = arrArtikelsToExtract; callServer("test.ipl", parameters, true); *.ipl param extraction: my${cgi} = new CGI(); my $arrArtikelIDs = ${cgi}->param('iw_arrArtikelIDs'); The issue here is that arrArtikelsToExtract is a java array containing ID's that I need to process in the *.ipl script. I can't seem to get it to wo...

.htaccess and perl cgi
I am trying to create a generic interface that will manage various ..htaccess protected directories. In the ideal world, the .htaccess would trigger a cgi script that would take login information and store it to a file, or block access all together. For example, anytime someone logs in, the .htaccess file should direct the user name and IP address to be stored in a log file through this cgi. A cron could be scheduled to determine if the same user name accesses the site frequently throughout the day from several IP addresses, thus signifying abuse. Now, I know I can put a cgi script in the pr...

Php or Perl for CGI?
Hi. I'm trying to learn how to implement CGI on my site, and would like to know what are the advantages of using Perl over PHP, if any. Thanks in advance. Ziggi On Sun, 14 Sep 2003 15:38:44 +0100, "Ziggi" <one_ziggi@hotmail.com> wrote: >Hi. I'm trying to learn how to implement CGI on my site, Don't. CGI is pretty much obsolete and mod_perl or similar is a more modern (and desptie that, a better) way of doing it. >and would like to >know what are the advantages of using Perl over PHP, if any. Biggest advantage is for people who already know one or the other. Perl is useful for non-web tasks too. PHP is somewhat easier to learn. Perl has much better access to obscure aspects of filesystems. This can get serious if you're dealing with complex multi-user systems or huge storage arrays. Andy Dingley wrote: > Perl is useful for non-web tasks too. So is PHP. I have written a whole host of command line tools, and daemons with PHP. PHP may not be as obvious a choice but it stands up VERY well. > PHP is somewhat easier to learn. It is a much cleaner language IMHO. > Perl has much better access to obscure aspects of filesystems. This > can get serious if you're dealing with complex multi-user systems or > huge storage arrays. I haven't found this, but that is probably my own bias. -- /---+----+----+----+----+----+----++----+----+----+----+----+----+---\ I pham.nuwen3d6@libertydice.org II No nat...

learning perl and cgi
Hello group, I'm interested in starting to learn Perl and CGI. I'm not having any problems with that. However, setting everything up is not clear to me. What should I do to run my CGI scripts on my computer, with my browser. I need to be able to run these CGI scripts on my own browser, so I can test what I'm doing. I'm not interested in getting and account yet, I just want to run it on my machine. Is there a way to do this, or buying an account is mandatory? Also, am I required to install Unix? (I use XP right now) I actually have zillions of questions but I'll read and...

CGI perl upload
Hi, i work on perl cgi script, that upload file on server. I will heave also transfer statistics for it (so i save into extern *.txt file some information like name, size in bytes, uploded bytes (progress bar), time duration, etc...). Problem is, that file is uploded for 2 times... Here is my script: ------------------------------------------------------------------------------------------ #!/usr/bin/perl $ROOT = $ENV{DOCUMENT_ROOT}; use CGI; my $query = new CGI; $Nazov = $query->param("Subor"); $File = $query->upload("Subor"); my ($fstats_dev, $fstats_ino, $fstats_mode, $fstats_nlink, $fstats_uid, $fstats_gid, $fstats_rdev, $fstats_size, $fstats_atime, $fstats_mtime, $fstats_ctime, $fstats_blksize, $fstats_blocks) = stat($File); $transfered = 0; $TimeBegin = time(); $Timer = 0; open(OUTFILE,">$ROOT/$Nazov"); binmode(OUTFILE); while ($bytesread = read($File,$buffer,1024)) { print OUTFILE $buffer; # print statistics to file open(TXTFILE,">$ROOT/test.txt"); $transfered += $bytesread; print TXTFILE "TRANSFERRING\n"; print TXTFILE $Nazov."\n"; print TXTFILE $transfered."\n"; print TXTFILE $fstats_size."\n"; $Timer = time() - $TimeBegin; print TXTFILE $Timer; close(TXTFILE); } close (OUTFILE); # print only finall statitics open(TXTFILE,">$ROOT/test.txt"); $transfered += $bytesread; print TXTFILE ...

WebExplorer as Perl-CGI
Does anybody know a freeware/opensource Perl-CGI that acts like a regular file-explorer? The internet project I am working on will be hosted on a regular shared-hosting environment based on Red Hat Linux 7.3 (no root access, but own perl-cgi permitted). It requires some sort of web-based file-explorer so that users can upload and download even large files: the user browses to a certain URL, types in his passwd and can then browse in the existing files on the remote host, download them and upload new ones. That is what I am hoping for... Does anybody know a program like this? Tnx Matthias ...

Problems with PERL CGI
Hi all, I am trying to compile a CGI code on webserver but unfortunately have hit some issues. For some weird reason my print messages to STDERR are been printed to STDOUT, which in this case become the webpage. Also, my new webpage seems to be working fine but if I refresh my page instead of showing the HTML text it shows me the actual code. I am not sure if above 2 problems are related but have been pulling my hair due to these for last few days. Any help or ideas on these would really be appreciated. thanks adi adi wrote: > Re: Problems with PERL CGI It's Perl, not PERL >...

perl
I wrote a perl program that retrieves data from MySQL database and do some complex formating to export. In the program I used some scalar variables to hold temporary intermediate data (~2MB). While this program works fine on command line (takes more than 10 minutes). When I adept it as a CGI program, it works only when a small data set is selected; When larger data set is selected, it fails without error (return a blank page on web; no error to the Apache server error log). I wonder what could be the problem? I suspect the internal scalar variable may exceed some sort of internal memory limit but I really don't know -- therefore seem advice from experts on what should I look into? Thanks in advance! Zhiliang Zhiliang Hu <zhilianghu@gmail.com> wrote in news:c360f580-5dab-4794-a259- 09dbc7cbc750@56g2000hsm.googlegroups.com: > I wrote a perl program that retrieves data from MySQL database and do > some complex formating to export. In the program I used some scalar > variables to hold temporary intermediate data (~2MB). > > While this program works fine on command line (takes more than 10 > minutes). When I adept it as a CGI program, it works only when a small > data set is selected; When larger data set is selected, it fails > without error (return a blank page on web; no error to the Apache > server error log). > > I wonder what could be the problem? See http://www.stonehenge.com/merlyn/LinuxMag/col39.html Sinan -- A. ...

Perl CGI no longer used?
I am starting to wonder if Perl CGI is used anymore, because the basic CGI module doesn't seem to function any longer. I tried writing a simple CGI script for Perl, using examples from the web, and I found that the code oddly enough doesn't work. I'm using the CGI module, as follows: #!/usr/bin/perl use DBI; use CGI; my $query = new CGI; print $query->header ( ); my $tt = $query->param("tt"); print "tt = "; print $tt; My form definitely passes tt in the URL as a Get parameter, yet the Perl script prints nothing for tt. What is going wrong here? Has CGI...

cron manipulation and perl-cgi
Hi, I am trying to develop a webpage with login,password and Unix box name as input fields which will post to a perl script that would do the following in CRON: - Allow you to access and LOGIN to specific UNIX boxes - Display the entries - Allow Editing of an entry - Allow searching for a specific entry - The returned page for each entry must display the page in "laymen's" english, not cryptically as found in CRON (In other words a conversion must take place to and from the format in CRON) - Upon entering the data it should submit convert the entry from laymens' display, send it to the system, and issue the "CRONTAB Filename" command to upload it for that specific USERID/PASSWORD. I need to know ideas on how i can go about implementing this. Any Modules that exist which implement some or all of the tasks or just some ideas how this can be done ? Please advise and i appreciate your time a lot Thanks Sid siddhartha mulpuru wrote: > Hi, > > I am trying to develop a webpage with login,password and Unix box name > as input fields which will post to a perl script that would do the > following in CRON: > - Allow you to access and LOGIN to specific UNIX boxes I'd advise against sending passwords for your UNIX boxes as http parameters. I recommend establishing a "trusted host" setup for the server & user ID of your CGI program, so that you can execute commands on the UNIX hosts _only_ from that host/user com...

perl cgi script
I have cgi script which is written in perl. The script contains text field, radio group and submit button. And I like to add a button for reloading. Please help. Thanks ck ckck <greenkeekee@gmail.com> wrote: >I have cgi script which is written in perl. The script contains text >field, radio group and submit button. And I like to add a button for >reloading. Please help. >Thanks A name sake of yours just asked exactly the same question (with exactly the same missing information) in CLP.misc. You may want to see there and ask him about the responses he got. jue ...

safe cgi programming in perl?
Hi all, please excuse the long post, but this is the longest perl script I've ever written. My main concern is with untainting data and using backtics for system commands. I read most of the documentation, but confess the perlsec leaves me a little confused as to the best way to write to files, etc. I'm using -Tw on the shabang line, plus "use strict" I threw this in, but I am not sure if it is neccessary: $ENV{PATH} = "/bin:/usr/bin"; delete @ENV{ 'IFS', 'CDPATH', 'ENV', 'BASH_ENV' }; I'm only using mkdir, open and rm with ...

Problems with CGI::Session in Perl
Hi, I'm trying to set up sessions in perl. session1.cgi defines a new session and sets a cookie. In session2.cgi, the correct session id is returned from the cookie, but when I initialize the session, a new session is created. The example is below. Any help would be appreciated! Thanks, - David session1.cgi: #!/usr/bin/perl use CGI::Session; use CGI; $cgi = new CGI; $session = new CGI::Session(undef,undef,{Dire�ctory=>'/tmp/sessions'}); $cookie = $cgi->cookie(CGISESSID => $session->id); print $cgi->header( -cookie=>$cookie ); $sid=$session->id; print "Session ID is $sid<br>"; print '<a href="session2.cgi">Link to session2.cgi</a>'; exit; session2.cgi #!/usr/bin/perl print "Content-type: text/html\n\n"; use CGI::Session; use CGI; $cgi = new CGI; $sid=$cgi->cookie("CGISESSID")�; $session = new CGI::Session(undef,$sid,{Direc�tory=>'/tmp/sessions'}); print "Original Session ID is $sid<br>"; $sid = $session->id(); print "New Session ID $sid<br>"; exit; "David Staschover" <davezx1@yahoo.com> wrote: > Hi, > > I'm trying to set up sessions in perl. > > session1.cgi defines a new session and sets a cookie. In session2.cgi, > the correct session id is returned from the cookie, but when I initialize > the session, a new session is created. Is anything actually getting created in /tmp/s...

Web resources about - guestbook.cgi :p - comp.lang.perl.misc

Guestbook - Wikipedia, the free encyclopedia
A guestbook (also guest book , visitor log , visitors' book , visitors' album ) is a paper or electronic means for a visitor to acknowledge a ...

7.30/letters Guestbook Letters - The 7.30 Report
The 7.30 Report is the ABC's national flagship current affairs program. Find transcripts from the program, contact details and submit your comments ...

Why we should leave Justin Bieber alone about what he wrote in the guestbook at the Anne Frank Museum ...
He wrote: "Truly inspiring to be able to come here. Anne was a great girl. Hopefully she would have been a belieber." Writing about this causes ...

Obama signs Hall of Fame's guestbook: "Go Sox!"
Obama signs Hall of Fame's guestbook: "Go Sox!"

Justin Bieber Visits Anne Frank House, Leaves Gross Message in Guestbook
Child musician and professional Twitter trending topic, Justin Bieber has upset the world after a recent visit to the Anne Frank House. There ...

Royal Baby Guestbook - ABCNews - ABC News
Sign the Royal Baby Guestbook and give Kate and William a gift! Browse through others' gifts and messages for Kate and William's baby at ABCNews.com ...

Just opened up the guestbook at the very isolated cabin we'll be staying at for the next week... - Imgur ...
The most viral images on the internet, curated in real time by a dedicated community through commenting, voting and sharing.

Guestbook
A community where iOS developers and users can interact, share info, blog, and release the latest and greatest tweaks, hacks, and mods.

You are invited to sign the guestbook celebrating the life of Bob Barry, Jr.
OKLAHOMA CITY Even though we are saddened at the sudden loss of our friend Bob Barry, Jr., we wish to celebrate his life. His legacy was built ...

Matrix67: My Blog » GuestBook
一同学收到某纸条表白,上面写了电话号码..但是被加密了,求解.. 号码后四位保密。 151X07Y**** X=I for you Y=X+1 求问一下。。

Resources last updated: 3/29/2016 8:43:42 AM