-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pack.cgi
executable file
·94 lines (88 loc) · 2.88 KB
/
pack.cgi
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
#!/usr/bin/perl
#
# SlackPack
# Copyright (C) 2006-2023 Georgi D. Sotirov, [email protected]
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# DESCRIPTION:
# This script displays package data
#
use strict;
use File::Basename;
use lib dirname (__FILE__);
use SlackPack;
use SlackPack::Package;
use SlackPack::Error;
use HTML::Entities;
my $cgi = SlackPack->cgi;
my $template = SlackPack->template;
my $id = $cgi->param('id');
my $dump = $cgi->param('dump') || 0;
my $md5 = $cgi->param('md5') || "";
my $verifymd5 = $cgi->param('verifymd5') || 0;
my $sign = $cgi->param('sign') || 0;
my $warn = $cgi->param('w') || 0;
my $vars = {};
my $pack = new SlackPack::Package($id);
if ( $pack && ! defined $pack->{'error'} ) {
$vars->{'pack'} = $pack;
if ( $dump eq "true" || $dump == 1 ) { # Contents dump
$vars->{'dump'} = $pack->list_contents;
print $cgi->header();
$template->process("pack/contents.html.tmpl", $vars) || ThrowTemplateError($template->error);
}
elsif ( $md5 || $verifymd5 ) { # MD5 verification
$vars->{'checked'} = 0;
if ( $md5 ne "" ) {
$vars->{'checked'} = 1;
$vars->{'correct'} = $pack->verify_md5($md5);
$vars->{'md5'} = $md5;
}
print $cgi->header();
$template->process("pack/verifymd5.html.tmpl", $vars) || ThrowTemplateError($template->error);
}
elsif ( $sign ) {
print $cgi->header();
$template->process("pack/sign.html.tmpl", $vars) || ThrowTemplateError($template->error);
}
else {
$vars->{'warn'} = $warn;
$vars->{'history'} = $pack->get_history;
$vars->{'formats'} = $pack->get_formats;
$vars->{'repo'} = SlackPack::Mirror->get_prime();
print $cgi->header();
$template->process("package.html.tmpl", $vars) || ThrowTemplateError($template->error);
}
}
elsif ( $pack->{error} eq 'NotFound' ) {
$vars->{'id'} = $id;
$vars->{'source'} = $0;
ThrowUserError("package_not_found", $vars);
}
elsif ( $pack->{error} eq 'NoId' ) {
$vars->{'source'} = $0;
ThrowUserError("no_identifier", $vars);
}
elsif ( $pack->{error} eq 'InvalidNumId' ) {
$vars->{'id'} = $id;
$vars->{'source'} = $0;
ThrowUserError("invalid_num_identifier", $vars);
}
else {
$vars->{'id'} = $id;
$vars->{'source'} = $0;
ThrowUserError("invalid_identifier", $vars);
}