#!/usr/bin/perl use cPanelUserConfig; use LWP::Simple; use CGI; #################################### #################################### print "Content-type: text/html", "\n\n"; # A critical line for Perl CGI scripting!!! $content = get('https://chesswise.defiantchris.com/index.php/pl/perl-pl');# or die 'Unable to get page'; #################################### # Template configuration $html_template = "Perl"; # uses Perl section menu $default_template_title = "Perl"; # default title in the template to be replaced by the $article_title $article_title = "Odgadnij liczbę"; # new article title #################################### if ($content) { $content =~ /(^.+?
)(.+?)(<\/div>.+$)/s; $top = $1; $bottom = $3; $top =~ s/(

.+?)($default_template_title)(.+?<\/h2>)/$1$article_title$3/s; # change the article title } else { #################################### #################################### # Read top HTML page template $html_template_top = $html_template . "_top_pl.html"; open(TOP, "<./templates/$html_template_top") or die "Cannot open file \'$html_template_top\' $!"; while ($line = ) { $top .= $line; } close TOP; $top =~ s/(

.+?)($default_template_title)(.+?<\/h2>)/$1$article_title$3/s; # change the article title #################################### #################################### # Read bottom HTML page template $html_template_bottom = $html_template . "_bottom_pl.html"; open(BOTTOM, "<./templates/$html_template_bottom") or die "Cannot open file \'$html_template_bottom\' $!"; while ($line = ) { $bottom .= $line; } close BOTTOM; } #################################### #################################### print "$top\n"; #################################### #################################### #### MY PERL CODE COMES IN HERE #### #################################### my $cgi = CGI->new; my %param = map {$_ => scalar $cgi->param($_)} $cgi->param(); # for my $key (sort keys %param) # { # print join ": ", $key, $param{$key}; # print "
\n"; # } # Guess the random number from 0 to $upper_limit! $upper_limit = 200; ############# # INPUT PROCESSING if ($param{'submit'} eq "Sprawdź!") { $random_number = $param{'random_number'}; $user_number = $param{'user_number'}; if ($user_number eq '') { $user_number = 0; } $attempt = $param{'attempt'}; $attempt++; if ($user_number < $random_number) { print "\n\nTwoja liczba $user_number jest zbyt mała! Spróbuj ponownie! Próba nr $attempt
\n\n"; } elsif ($user_number > $random_number) { print "\n\nTwoja liczba $user_number jest zbyt duża! Spróbuj ponownie! Próba nr $attempt
\n\n"; } else { print "\n\nGratulacje!!!\n\nWylosowana liczba to $user_number.\n\nOdgadłeś ją za $attempt. razem!!!

\n\n"; ############# # INPUT FORM print "
\n"; print "\n"; print "\n"; print "
     pokaż kod źródłowy
\n"; print "
\n"; } } else { $random_number = rand($upper_limit+1); $random_number = int($random_number); $user_number = -1; $attempt = 0; } if ($user_number != $random_number) { ############# # INPUT FORM print "
\n"; print "

Odgadnij liczbę całkowitą od 0 do $upper_limit !

\n"; print "\n"; print "\n"; print "\n"; print "
Twoja liczba   
     pokaż kod źródłowy
\n"; print "\n"; print "\n"; print "
\n"; } print "





"; #################################### ########## END OF MY CODE ########## #################################### print "\n"; print "$bottom";