/usr/lib/interchange/features/quickpoll/quickpoll.global is in interchange 5.7.7-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | ActionMap quickpoll <<EOR
sub {
my $path = shift;
$path =~ s{^quickpoll/}{};
use vars qw/$Tag/;
$CGI::values{mv_nextpage} ||= $path;
my $code = $CGI::values{poll};
$code =~ s/\D+//g;
return 1 if $Vend::Session->{quickpoll}{$code}++;
my $answer = $CGI::values{answer};
my $adb = dbref($::Variable->{POLL_ANSWER_TABLE} || 'quickpoll_answer');
my $pdb = dbref($::Variable->{POLL_TABLE} || 'quickpoll');
my $poll = $pdb->row_hash($code)
or do {
::logError("Bad poll %s, no database record", $code);
return 1;
};
my $date = POSIX::strftime('%Y%m%d%H%M%S', localtime());
my $poll_id = $poll->{poll_id} || $code;
my $record = {
answer => $CGI::values{answer},
poll_id => $poll_id,
question_id => $code,
ipaddr => $CGI::remote_addr,
username => $Vend::username,
answer_date => $date,
login_table => $Vend::login_table,
};
$Vend::Session->{quickpoll}{$code} = $adb->set_slice(undef, $record);
return 1;
}
EOR
UserTag poll-answer Order code
UserTag poll-answer addAttr
UserTag poll-answer Routine <<EOR
sub {
my ($code, $opt) = @_;
use vars qw/$Tag/;
my $adb = dbref($::Variable->{POLL_ANSWER_TABLE} || 'quickpoll_answer');
my $pdb = dbref($::Variable->{POLL_TABLE} || 'quickpoll');
my $poll = $pdb->row_hash($code)
or do {
::logError("Bad poll %s, no database record", $code);
return undef;
};
my $answer_ary = Vend::Form::options_to_array($poll->{choices});
my %key;
for(@$answer_ary) {
$key{$_->[0]} = $_->[1];
}
my $tname = $adb->name();
my $q = qq{SELECT answer, COUNT(answer) FROM $tname
WHERE question_id = $code
GROUP BY answer
};
my $ary = $adb->query($q)
or do {
::logError("Bad answers to poll %s, no database return", $code);
return undef;
};
my @out;
push @out, qq{<table>};
my $total = 0;
my @results;
for(@$ary) {
my ($ans, $number) = @$_;
$total += $number;
push @results, [$ans, $number];
}
@results = sort { $b->[1] <=> $a->[1] } @results;
return "No answers yet!" unless $total > 0;
my $tops = $opt->{shown} || 4;
if(@results > $tops) {
my $other = 0;
for(my $i = $tops; $i < @results; $i++) {
$other += $results[$i][1];
}
splice @results, $tops;
push @results, [ $opt->{other_title} || 'Other', $other];
}
for(@results) {
push @$_, int($_->[1] / $total * 100);
}
my @colors = qw(
red
green
blue
orange
yellow
brown
purple
cyan
chartruese
);
if($poll->{colors}) {
my @custom = grep /\w/, split /[\s,\0]+/, $poll->{colors};
for(my $i = 0; $i < @custom; $i++) {
$colors[$i] = $custom[$i];
}
}
for( my $i = 0; $i < @results; $i++) {
my ($answer, $number, $percent) = @{$results[$i]};
$answer = $key{$answer} if $key{$answer};
my $short = $Tag->filter('16.', $answer);
if(length($answer) > length($short)) {
my $encode_answer = HTML::Entities::encode($answer);
my $encode_short = HTML::Entities::encode($short);
$answer = qq{<span title="$encode_answer">$encode_short</span>};
}
else {
HTML::Entities::encode($answer);
}
my $opt = {
hr => 1,
hr_color => $colors[$i],
value => $percent,
};
my $graph = $Tag->ascii_graph($opt);
push @out, <<EOF;
<tr>
<td>$answer</td>
<td>$number</td>
<td>$graph</td>
</tr>
EOF
}
push @out, '</table>';
return join "\n", @out;
}
EOR
UserTag ascii-graph Order value scale
UserTag ascii-graph addAttr
UserTag ascii-graph Routine <<EOR
sub {
my ($value, $scale, $opt) = @_;
unless($opt->{div_per_scale}) {
$opt->{div_per_scale} = ($opt->{image} || $opt->{hr}) ? 100 : 25;
}
$scale ||= 100;
my $factor = $opt->{div_per_scale} / $scale;
my $amount = int($value * $factor);
my $out = '';
return $out unless $amount;
if($opt->{image}) {
$opt->{line_width} ||= 5;
if($opt->{vertical}) {
$out = qq{<img src="$opt->{image}" height=$amount width=$opt->{line_width}>};
}
else {
$out = qq{<img src="$opt->{image}" width=$amount height=$opt->{line_width}>};
}
}
elsif ($opt->{hr}) {
$opt->{hr_color} ||= '#666666';
$opt->{hr_height} ||= 5;
my $shade = $opt->{hr_noshade} ? ' noshade' : '';
$out = qq{<hr align=left size=$opt->{hr_height} width=$amount$shade color="$opt->{hr_color}">};
}
else {
my $char = $opt->{character} || $opt->{char} || '*';
$out = $char x $amount;
}
if($opt->{prepend_value}) {
$out = qq{<table cellspacing=0 cellpadding=0><tr><td width=20 align=right>$value</td><td> </td><td>$out</td></tr></table>};
}
elsif($opt->{append_value}) {
$out = "$out $value";
}
return $out;
}
EOR
|