source: main/tags/2.51-fiji/gsdl/cgi-bin/usabcgi.pm

Last change on this file was 7958, checked in by davidb, 20 years ago

Minor tweak to open statement for gsdlsite.cfg

  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1package usabcgi;
2
3
4sub get_config_info {
5 open FILEIN, ("gsdlsite.cfg")
6 || die "ERROR: Could not open site configuration file\n";
7
8 my $configfile;
9 while(<FILEIN>) {
10 $configfile .= $_;
11 }
12 close(FILEIN);
13
14
15 ($infotype) = @_;
16
17 $configfile =~ /^$infotype\s+(\S+)\s*\n/m;
18 $loc=$1;
19 $loc =~ s/\"//g;
20
21 return ($loc);
22}
23
24sub printscript {
25
26 print "<script type=\"text/javascript\">\n";
27 print "\tfunction showaboutprivacy(url){\n";
28 print "\t\tinfowin=window.open(url,'infowin','toolbars=0, height=600, width=600')\n";
29 print "\t}\n";
30 print "</script>\n";
31}
32
33sub printbanner {
34 ($title)=@_;
35 ($imageloc) = usabcgi::get_config_info("httpimg");
36 if(!($imageloc =~ "http")) {$imageloc="http://".$ENV{HTTP_HOST}.$imageloc;}
37 print "<table width=\"100%\"><tr>\n<td><h1>Greenstone Usability - $title</h1></td>\n";
38 print "<td align=\"right\">";
39 if ($imageloc) { print "<img src=\"$imageloc\/usabbanner.gif\" alt=\"Greenstone koru design\" title=\"Greenstone koru design\">"; }
40 print "</td>\n</tr></table>";
41}
42
43sub printaplinks {
44 print "<p class=\"sans\">\n";
45 print "<a href=\"javascript:showaboutprivacy('http://nzdl2.cs.waikato.ac.nz/dana/gsdl/about.html')\">About</a>\n &#8226; <a href=\"javascript:showaboutprivacy('http://nzdl2.cs.waikato.ac.nz/dana/gsdl/privacy.html')\">Privacy</a>\n";
46
47}
48
49sub printstyle {
50 ($browser) = @_;
51 $browser=~/([^\/]*)\/([0-9]+\.[0-9]+)/;
52 if(($1 ne "Netscape")||($2 > 4.77)){
53 print "<style type=\"text/css\">\n";
54 print "\th1 {font-family: sans-serif; font-size: 20px}\n";
55 print "\th2 {font-family: sans-serif; font-size: 14px; font-weight: bold; color: #009966}\n";
56 print "\tp.sans {font-family: sans-serif}\n";
57 print "\ttd {vertical-align: top}\n";
58 print "\ttd.sans {font-family: sans-serif; width: 50%}\n";
59 print "</style>\n";
60 }
61
62}
63
64sub checkidno {
65 if((!($ENV{QUERY_STRING}=~/\d/)) || ($ENV{QUERY_STRING}=~/\D/) ) {
66 print "<h2>Each report sent has an ID number. This page needs one of those numbers to work.</h2>\n";
67 print "<br><br><p class=\"sans\"><a href=\"mailto:dmn&#064;cs.waikato.ac.nz\">Contact us</a> with any queries about this.\n";
68 print "</body></html>\n";
69 die;
70 }
71}
72
73sub getusabreportdetails {
74 ($etcfileloc) = usabcgi::get_config_info("gsdlhome");
75 if(!($etcfileloc =~/\/$/)) {$etcfileloc.="/";}
76 $etcfileloc .= "etc/usability.txt";
77 open (FILEIN, $etcfileloc) or die "could not open usability.txt\n";
78 while(<FILEIN>){
79 $etcfile.=$_;
80 }
81 close(FILEIN);
82
83 if(!($etcfile=~ / $ENV{QUERY_STRING}\&usabend;/)) {
84 print "<h2>Each report has an ID number. This program needs one of those ID numbers to work, and the ID number provided wasn't found.</h2>\n";
85 print "<br><br><p class=\"sans\"><a href=\"mailto:dmn&#064;cs.waikato.ac.nz\">Contact us</a> with any queries about this.\n";
86 print "</body></html>";
87 die;
88 }
89
90#get the report for whjich details are to be viewed.
91 $etcfile=~/report-id := $ENV{QUERY_STRING}\&usabend\;\n/;
92 $report = $&;
93 $tmp=$';
94 $tmp=~/----------------------?/;
95 $report.=$`;
96 @pairs=split(/\&usabend\;\n/,$report);
97 foreach $pair (@pairs) {
98 ($name, $value)= split(/ := /,$pair);
99
100 #this splits long values up for display purposes
101 @tmplist = split(/ /,$value);
102 foreach $item (@tmplist){
103 if(length $item > 60){
104 $tmp="";
105 while(length $item > 60){
106 $tmp.= substr $item, 0, 60;
107 $tmp.=" ";
108 $item = substr $item, 60;
109 }
110 $tmp.=$item;
111 $item=$tmp;
112 }
113 }
114 $value = join(' ',@tmplist);
115
116 #this adds html tags for breaks
117 $value =~ s/\n/\<br\>\n/g;
118 $reportvals{$name}=$value;
119 }
120 return %reportvals;
121
122}
123
1241;
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
Note: See TracBrowser for help on using the repository browser.