repod: Fix .nofetch test
[girocco/radio.git] / cgi / delproj.cgi
blob4b679f3e276259232b0dad3433ad4bf1a34aba08
1 #!/usr/bin/perl
2 # (c) Petr Baudis <pasky@suse.cz>
3 # GPLv2
5 use strict;
6 use warnings;
8 use lib ".";
9 use Girocco::CGI;
10 use Girocco::Config;
11 use Girocco::Project;
12 use Girocco::Util;
14 my $gcgi = Girocco::CGI->new('Project Removal');
15 my $cgi = $gcgi->cgi;
17 my $name = $cgi->param('name');
19 unless (defined $name) {
20 print "<p>I need the project name as an argument now.</p>\n";
21 exit;
24 if (!Girocco::Project::valid_name($name)) {
25 print "<p>Invalid project name. Go away, sorcerer.</p>\n";
26 exit;
29 if (!Girocco::Project::does_exist($name)) {
30 print "<p>Sorry but this project does not exist. Now, how did you <em>get</em> here?!</p>\n";
31 exit;
34 if (!Girocco::Project::available($name)) {
35 print "<p>Sorry but your project has not finished mirroring yet. If it takes inordinate amount of time, please tell the administrator.</p>\n";
36 exit;
39 my $proj = Girocco::Project->load($name);
40 $proj or die "not found project $name, that's really weird!";
41 $proj->{cpwd} = $cgi->param('cpwd');
43 if (!$proj->{mirror}) {
44 print "<p>Sorry but you can remove only mirrored projects. Pushed projects cannot be removed. Please tell the administrator if you really want to.</p>\n";
45 exit;
48 if ($proj->has_forks()) {
49 print "<p>Sorry but this project has forks associated. Such projects cannot be removed. Please tell the administrator if you really want to.</p>\n";
50 exit;
53 if ($cgi->param('y0')) {
54 # submitted
55 if (not $proj->authenticate($gcgi)) {
56 exit;
58 $proj->delete;
59 print "<p>Project successfuly deleted. Have a nice day.</p>\n";
60 exit;
63 my $url = $proj->{url};
65 print <<EOT;
66 <p>Please confirm that you are going to remove mirrored project
67 $name ($url) from the site.</p>
68 <form method="post">
69 <input type="hidden" name="name" value="$name" />
70 EOT
71 if ($Girocco::Config::project_passwords) {
72 print <<EOT;
73 <p>Admin password: <input type="password" name="cpwd" /> <sup><a href="pwproj.cgi?name=$name">(forgot password?)</a></sup></p>
74 EOT
76 print <<EOT;
77 <p><input type="submit" name="y0" value="Remove" /></p>
78 </form>
79 EOT