/[wopi]/make_poll.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /make_poll.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by dpavlin, Tue Apr 8 17:53:46 2003 UTC revision 1.2 by dpavlin, Tue Apr 22 18:46:04 2003 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2  #  #
3    
4    use strict;
5    
6  use XML::Parser;  use XML::Parser;
7    use Text::Iconv;
8    
9  use strict;  # output charset
10    my $charset='ISO-8859-2';
11    
12    Text::Iconv->raise_error(0);    # Conversion errors raise exceptions
13    my $from_utf8 = Text::Iconv->new('UTF8', $charset);
14    sub x {
15            return $from_utf8->convert($_[0]);
16    }
17    
18  $|=1;  $|=1;
19    
# Line 64  my $db_user="dpavlin"; Line 74  my $db_user="dpavlin";
74    
75  #------------------------------------------------------------------  #------------------------------------------------------------------
76    
77  my $html_header.=<<'End_of_header;';  sub suck_file {
78  <html>          my $file = shift @_;
79  <head>          open(H,$file) || die "can't open '$file': $!";
80  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">          my $content;
81          <title>proof.anketa</title><link rel="STYLESHEET" type="text/css" href="../stil.css">          while (<H>) { $content .= $_; } ;
82  </head>          close(H);
83            return $content;
84  <body background="../beki.gif" bgcolor="White" leftmargin=0 topmargin=0 marginwidth="0" marginheight="0">  }
   
 <table width="460" cellspacing="0" cellpadding="0" border="0">  
 <tr>  
     <td colspan="2"><img src="head.php" width=460 height=72 alt="" border="0"><br><br></td>  
 </tr>  
 <tr>  
     <td><img src="../klir.gif" width=20 height=1 alt="" border="0"><br>  
         </td>  
     <td><img src="../klir.gif" width=332 height=1 alt="" border="0"><br>        </td>  
 </tr>  
 <form method=post action="##NEXTPAGE##">  
 <input type=hidden name=a value="<?= $a ?>">  
 <input type=hidden name=id value="<?= $id ?>">  
   
 <tr>  
     <td> </td>  
     <td>  
 End_of_header;  
   
 #------------------------------------------------------------------  
   
 my $html_separator=<<'End_of_separator;';  
 <tr>  
     <td></td>  
     <td bgcolor="#006699"><img src="../klir.gif" width=1 height=1 alt="" border="0"><br></td>  
 </tr>  
 End_of_separator;  
   
 #------------------------------------------------------------------  
85    
86  my $html_footer=<<'End_of_footer;';  my $html_header=suck_file("header.html");
87  </td>  my $html_separator=suck_file("separator.html");
88  </tr>  my $html_footer=suck_file("footer.html");
   
 <tr>  
     <td> </td>  
     <td align="right"><br>  
 <input type=submit name="update" value="dalje.">&nbsp;&nbsp;  
 <br><br><br>  
 </td>  
 </tr>  
 </table>  
   
 </body>  
 </html>  
 End_of_footer;  
89    
90  #------------------------------------------------------------------  #------------------------------------------------------------------
91    
# Line 260  End_of_common; Line 228  End_of_common;
228    
229  #------------------------------------------------------------------  #------------------------------------------------------------------
230    
231  my $head_php.=<<'End_of_head;';  my $head_php=suck_file("head.php");
   
         Header("Content-type: image/gif");  
         header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past  
         header ("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); // always modified  
         header ("Cache-Control: no-cache, must-revalidate");    // HTTP/1.1  
         header ("Pragma: no-cache");                            // HTTP/1.0  
         $string=implode($argv," ");  
         $im = imagecreatefromgif("head.gif");  
         $red = ImageColorAllocate($im, 255, 0, 0);  
         $black = ImageColorAllocate($im, 0, 0, 0);  
         $px = (imagesx($im)-7.5*strlen($string))/2;  
         if (! isset($pcnt)) {  
                 $pcnt=floor(substr(basename($HTTP_REFERER),0,2)/$max_page*100);  
         }  
         ImageTTFText($im, 6, 0, 10, 65, $black, dirname($PATH_TRANSLATED)."/head.ttf", "Ispunili ste ".sprintf("%02d",$pcnt)."% ankete");  
         $w=80;  
         ImageRectangle($im,149,60,151+$w,66,$black);  
         ImageFilledRectangle($im,150,61,150+floor($pcnt*$w/100),65,$red);  
         ImageGif($im);  
         ImageDestroy($im);  
   
 End_of_head;  
232    
233  #------------------------------------------------------------------  #------------------------------------------------------------------
234    
235  my $html_kraj=<<'End_of_kraj;';  my $html_kraj=suck_file("thanks.html");
 <html>  
 <head>  
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">  
         <title>wopi.poll</title><link rel="STYLESHEET" type="text/css" href="../stil.css">  
 </head>  
   
 <body background="../beki.gif" bgcolor="White" leftmargin=0 topmargin=0 marginwidth="0" marginheight="0">  
   
 <table width="460" cellspacing="0" cellpadding="0" border="0">  
 <tr>  
     <td colspan="2"><img src="head.php?pcnt=100" width=460 height=72 alt="" border="0"><br><br></td>  
 </tr>  
 <tr>  
     <td><img src="../klir.gif" width=20 height=1 alt="" border="0"><br>  
         </td>  
     <td><img src="../klir.gif" width=332 height=1 alt="" border="0"><br>        </td>  
 </tr>  
     <td><img src="../klir.gif" width=20 height=1 alt="" border="0"><br>  
         </td>  
     <td><img src="../klir.gif" width=332 height=1 alt="" border="0"><br>        </td>  
 </tr>  
 <tr>  
     <td> </td>  
     <td><br>  
 <p><b>  
 Hvala vam na sudjelovanju u anketi!  
 </b></p>  
 <br><br>  
 Zahvaljujemo se na vašem vremenu. Nadamo se da ćete i vi biti  
 među sretnim dobitnicima.  
 <br>  
 <br>  
 Do slijedeće ankete i nagradne igre srdačno vas pozdravljamo.  
 <br>  
 <br>Hvala.  
 <br>  
 <br>  
 <a href="http://www.proof.hr"><tt>proof.</tt></a>  
 </td>  
 </tr>  
 <tr>  
     <td></td>  
     <td bgcolor="#006699"><img src="../klir.gif" width=1 height=1 alt="" border="0"><br></td>  
 </tr>  
 <tr>  
     <td align="right" valign="top"></td>  
     <td> </td>  
     <td align="right"><br>  
 <br>  
 </td>  
 </tr>  
 </table>  
   
 </body>  
 </html>  
 End_of_kraj;  
236    
237  #------------------------------------------------------------------  #------------------------------------------------------------------
238    
# Line 447  close(PAGE); Line 337  close(PAGE);
337  $page_nr++;  $page_nr++;
338  open(PAGE, ">$dir/$next_fn") or die "Couldn't open $next_fn for writing:\n$!";  open(PAGE, ">$dir/$next_fn") or die "Couldn't open $next_fn for writing:\n$!";
339  print PAGE php_header($page_nr,@last_sql_update);  print PAGE php_header($page_nr,@last_sql_update);
340  print PAGE $html_kraj;  print PAGE "$html_header $html_kraj $html_footer";
341  close(PAGE);  close(PAGE);
342    
343  # dump sql structure  # dump sql structure
# Line 466  print PHP '?>'; Line 356  print PHP '?>';
356  close(PHP);  close(PHP);
357    
358  open(PHP,">$dir/head.php") || die "head.php: $!";  open(PHP,">$dir/head.php") || die "head.php: $!";
359  print PHP '<? $max_page="'.($page_nr+1).'";';  my $max_page = $page_nr + 1;
360    $head_php=~ s/##MAXPAGE##/$max_page/;
361    $head_php=~ s/##TEXT##/Ispunili ste %02d%% ankete/;
362  print PHP $head_php;  print PHP $head_php;
 print PHP '?>';  
363  close(PHP);  close(PHP);
364    
365  ################  ################
# Line 788  sub pit { Line 679  sub pit {
679                  my ($xp, $text) = @_;                  my ($xp, $text) = @_;
680    
681                  if (defined $text) {                  if (defined $text) {
682                          $body.=$text;                          $body.=x($text);
683                  } else {                  } else {
684                          $body.="</p>";                          $body.="</p>";
685                  }                  }
# Line 805  sub podpit { Line 696  sub podpit {
696                  my ($xp, $text) = @_;                  my ($xp, $text) = @_;
697    
698                  if (defined $text) {                  if (defined $text) {
699                          $body.=$text;                          $body.=x($text);
700                  } else {                  } else {
701                          $body.="</table>";                          $body.="</table>";
702                  }                  }
# Line 824  sub odg { Line 715  sub odg {
715                  my ($xp, $text) = @_;                  my ($xp, $text) = @_;
716    
717                  if (defined $text) {                  if (defined $text) {
718                          $body .= $text;                          $body .= x($text);
719                  } else {                  } else {
720                          $body .= "</p>";                          $body .= "</p>";
721                  }                  }
# Line 845  sub php { Line 736  sub php {
736                          $text=~s/ le / <= /g;                          $text=~s/ le / <= /g;
737                          $text=~s/ gt / > /g;                          $text=~s/ gt / > /g;
738                          $text=~s/ ge / >= /g;                          $text=~s/ ge / >= /g;
739                          $body.=$text;                          $body.=x($text);
740                  } else {                  } else {
741                          $body.="\n?>\n";                          $body.="\n?>\n";
742                  }                  }
# Line 867  sub dropdown { Line 758  sub dropdown {
758                          $text=~s/^\s*//g;                          $text=~s/^\s*//g;
759                          $text=~s/^[\d\.\s]+//g;                          $text=~s/^[\d\.\s]+//g;
760                          $text=~s/\s*$//g;                          $text=~s/\s*$//g;
761                          push @dropdown_data,$text if ($text ne "");                          push @dropdown_data,x($text) if ($text ne "");
762                  } else {                  } else {
763                          my $opt;                          my $opt;
764                          my $id=1;                          my $id=1;
# Line 897  sub textbox { Line 788  sub textbox {
788                  my $size=$attref->{size};                  my $size=$attref->{size};
789                  $size = 25 if (! defined $size || $size == 0);  # default                  $size = 25 if (! defined $size || $size == 0);  # default
790                  my $p=new_pit();                  my $p=new_pit();
791                  $body.="<input type=text name=$p size=$size >\n";                  $body.="<input type=text name=$p size=".x($size)." >\n";
792                  push @sql_create,"$p text";                  push @sql_create,"$p text";
793                  push @sql_update,"$p='\$$p'";                  push @sql_update,"$p='\$$p'";
794          }          }
# Line 935  sub radiobuttons { Line 826  sub radiobuttons {
826                          $text=~s/^\s*//g;                          $text=~s/^\s*//g;
827                          $text=~s/^[\d\.\s]+//g;                          $text=~s/^[\d\.\s]+//g;
828                          $text=~s/\s*$//g;                          $text=~s/\s*$//g;
829                          push @radiobuttons_data,$text if ($text ne "");                          push @radiobuttons_data,x($text) if ($text ne "");
830                  } else {                  } else {
831                          my $opt;                          my $opt;
832                          my $p=new_pit();                          my $p=new_pit();
# Line 980  sub checkboxes { Line 871  sub checkboxes {
871                          $text=~s/^\s*//g;                          $text=~s/^\s*//g;
872                          $text=~s/^[\d\.\s]+//g;                          $text=~s/^[\d\.\s]+//g;
873                          $text=~s/\s*$//g;                          $text=~s/\s*$//g;
874                          push @checkboxes_data,$text if ($text ne "");                          push @checkboxes_data,x($text) if ($text ne "");
875                  } else {                  } else {
876                          my $opt;                          my $opt;
877                          my $base_p=new_pit();                          my $base_p=new_pit();
# Line 999  sub checkboxes { Line 890  sub checkboxes {
890                                  if (defined($opt) && $opt ne "") {                                  if (defined($opt) && $opt ne "") {
891                                          $p=$base_p."_".$id;                                          $p=$base_p."_".$id;
892                                          $id++;                                          $id++;
893                                          $body .= $before if ($before);                                          $body .= x($before) if ($before);
894                                          $body.="<input type=checkbox name=$p>";                                          $body.="<input type=checkbox name=$p>";
895                                          $body .= $middle if ($middle);                                          $body .= x($middle) if ($middle);
896                                          $body .= "$opt" if (! $hide_description);                                          $body .= "$opt" if (! $hide_description);
897                                          $body .= $after if ($after);                                          $body .= x($after) if ($after);
898                                          $body.="\n";                                          $body.="\n";
899    
900                                          push @sql_create,"$p boolean";                                          push @sql_create,"$p boolean";

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.26