inactive: Cleanup
[girocco/radio.git] / cgi / delproj.cgi
blob8ce6470a78b983632f567d74de1cf10b1759bf6a
1 #!/usr/bin/perl
2 # (c) Petr Baudis <pasky@suse.cz>
3 # GPLv2
5 use strict;
6 use warnings;
8 use lib qw(/home/repo/repomgr/cgi);
9 use Git::RepoCGI;
11 my $repo = Git::RepoCGI->new('Project Removal');
12 my $cgi = $repo->cgi;
14 my $name = $cgi->param('name');
16 unless (defined $name) {
17 print "<p>I need the project name as an argument now.</p>\n";
18 exit;
21 if (!valid_proj_name($name)) {
22 print "<p>Invalid project name. Go away, sorcerer.</p>\n";
23 exit;
26 if (!Git::RepoCGI::Project::does_exist($name)) {
27 print "<p>Sorry but this project does not exist. Now, how did you <em>get</em> here?!</p>\n";
28 exit;
31 if (!Git::RepoCGI::Project::available($name)) {
32 print "<p>Sorry but your project has not finished mirroring yet. If it takes inordinate amount of time, please tell the administrator.</p>\n";
33 exit;
36 my $proj = Git::RepoCGI::Project->load($name);
37 $proj or die "not found project $name, that's really weird!";
38 $proj->{cpwd} = $cgi->param('cpwd');
40 if (!$proj->{mirror}) {
41 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";
42 exit;
45 if (glob('/srv/git/'.$name.'/*')) {
46 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";
47 exit;
50 if ($cgi->param('y0')) {
51 # submitted
52 if (not $proj->authenticate($repo)) {
53 exit;
55 $proj->delete;
56 print "<p>Project successfuly deleted. Have a nice day.</p>\n";
57 exit;
60 my $url = $proj->{url};
62 print <<EOT;
63 <p>Please confirm that you are going to remove mirrored project
64 $name ($url) from the site.</p>
65 <form method="post">
66 <input type="hidden" name="name" value="$name" />
67 <p>Admin password: <input type="password" name="cpwd" /> <sup><a href="pwproj.cgi?name=$name">(forgot password?)</a></sup></p>
68 <p><input type="submit" name="y0" value="Remove" /></p>
69 </form>
70 EOT