-
Notifications
You must be signed in to change notification settings - Fork 0
/
delset.cgi
executable file
·48 lines (40 loc) · 1.16 KB
/
delset.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
#!/usr/bin/perl
use DBI;
local ($buffer, @pairs, $pair, $name, $value, %FORM, $method);
$ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/;
if ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
$method = "POST";
} else {
$buffer = $ENV{'QUERY_STRING'};
$method = "GET";
}
# Split into name / value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%(..)/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
my $tablename = $FORM{tablename};
my $hostname = "<INSERT HOSTNAME>";
my $username = "<INSERT USERNAME>";
my $password = "<INSERT PASSWORD>";
my $dbname = "<INSERT DBNAME>";
my $db_handle = DBI->connect("dbi:mysql:database=$dbname;host=$hostname;user=$username;password=$password", {AutoCommit => 1},) or die "Couldn't connect: $DBI::errstr\n";
my $pre = "DROP TABLE `$tablename`";
my $statement = $db_handle->prepare($pre) or die "oh no!";
$statement->execute() or die "oh no!";
$db_handle->commit;
$db_handle->disconnect();
print "Content-type:text/html\n\n";
print <<END;
<html>
<head>
<title>You $method-ed a new card!</title>
</head>
<body>
</body>
</html>
END