added request button, and check to see if it is requestable.
[koha.git] / kohareporter
1 #!/usr/bin/perl -w
2
3 # Copyright 2000-2002 Katipo Communications
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
11 #
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA  02111-1307 USA
19
20 use IO::Socket;
21
22
23
24 $host = 'mail.cmsd.bc.ca';
25 $EOL = "\015\012";
26 $BLANK = $EOL x 2;
27
28
29 my $params='';
30
31 system("clear");
32
33 print qq|
34
35 ============================
36 = Koha Installation Survey =
37 ============================
38
39 Feel free to skip any questions that you do not want to answer.
40
41 There will be a comments section at the end if you would like to provide
42 additional information that does not fit within these questions.
43
44
45 |;
46
47 my $param=askquestion('LibraryName', 'What is the name of your library?');
48 $params.="&$param";
49 $param=askquestion('Location', 'Where is your library located (city, country, etc.)?');
50 $params.="&$param";
51 $param=askquestion('NumberOfBranches', 'How many branches does your library have?');
52 $params.="&$param";
53 $param=askquestion('NumberOfItems', 'How many items in your library collection?');
54 $params.="&$param";
55 $param=askquestion('NumberOfPatrons', 'How many patrons are serviced by your library?');
56 $params.="&$param";
57 $param=askquestion('ProductionOrTesting', 'Are you using Koha in a production environment or just testing?');
58 $params.="&$param";
59 $param=askquestion('WhereDidYouHearAboutKoha', 'Where did you hear about Koha?');
60 $params.="&$param";
61 #$param=askquestion('', '');
62 #$params.="&$param";
63 #
64 #
65
66 print "\n\nAdditional Comments: [leave two blank lines to end]\n";
67
68
69
70 my $additionalcomments='%0D%0D';
71 my $lastlineblank=0;
72 while (<STDIN>) {
73     chomp;
74     unless ($_) {
75         (last) if ($lastlineblank);
76         $lastlineblank=1;
77         $additionalcomments.="$_%0D";
78         next;
79     }
80     $lastlineblank=0;
81     $additionalcomments.="$_%0D";
82 }
83
84 $additionalcomments=urlencode($additionalcomments);
85 $params.="&AdditionalComments=$additionalcomments";
86
87 print "\n\n";
88 print qq|
89 ====================
90 = Survey Completed =
91 ====================
92
93 Thank you for completing our survey.  We will now connect to a web server on
94 $host to transfer your responses.
95
96 Do you wish to continue submitting your survey results ([Y]/N)?  |;
97 my $reply=<STDIN>;
98 if ($reply=~/n/i) {
99     print "Aborting survey submission...\n";
100     sleep 3;
101     exit;
102 }
103
104
105 $remote = IO::Socket::INET->new( Proto     => "tcp",
106                         PeerAddr  => $host,
107                         PeerPort  => "http(80)",
108                        );
109 unless ($remote) { die "cannot connect to http daemon on $host" }
110 $remote->autoflush(1);
111 print $remote "GET /cgi-bin/kohareporter?$params HTTP/1.0" . $BLANK;
112 while ( <$remote> ) { }
113 close $remote;
114  
115
116 sub askquestion {
117     my $name=shift;
118     my $text=shift;
119
120     print $text."  ";
121     my $reply=<STDIN>;
122     chomp $reply;
123     $reply=urlencode($reply);
124     return "$name=$reply";
125 }
126
127 sub urlencode {
128     my $variable=shift;
129     $variable=~s/ /%20/g;
130     $variable=~s/&/%26/g;
131     $variable=~s/=/%3d/g;
132     return $variable;
133 }