-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathedit.cgi
More file actions
122 lines (97 loc) · 2.87 KB
/
edit.cgi
File metadata and controls
122 lines (97 loc) · 2.87 KB
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
#!/usr/bin/perl -wT -I.
# vim:ts=8 sw=4 sts=4 ai
=head1 NAME
edit.cgi - CGI script to show and edit data from an SQLite database
=head1 VERSION
This describes version B<0.01> of edit.cgi.
=cut
our $VERSION = '0.01';
=head2 SYNOPSIS
http://www.example.com/edit.cgi?Table=episodes
=head2 DESCRIPTION
CGI script to show and edit data for an SQLite database.
If run with no arguments, will print a form with tables to select from.
Once a table is selected, it prints a form with search criteria;
when the search critera are filled in, it will print a table
of results to edit.
=head2 Configuration
Before the script is run, it needs to be configured. This is done
by setting the correct values in the %InitArgs hash (just below
if you are looking at the source of this file).
The minimum requirement is to set the 'database' value; this must be
the name of the SQLite database file which this script accesses.
See L<SQLite::Work/new> and L<SQLite::Work::CGI/new> for more information
about possible arguments to give.
=cut
our %InitArgs = (
database=>'test1.db',
);
=head2 Author
Kathryn Andersen. <perlkat@katspace.com>
Created: 2005
=cut
require 5.8.3;
$ENV{PATH} = "/bin:/usr/bin:/usr/local/bin";
delete @ENV{ 'IFS', 'CDPATH', 'ENV'};
#------------------------------------------------------------------
# User-customizable Global variables
#------------------------------------------------------------------
# Includes
use SQLite::Work::CGI;
use strict;
#------------------------------------------------------------------
# Global variables
#------------------------------------------------------------------
# Subroutines
#------------------------------------------------------------------
# Main
MAIN: {
# this creates a new CGI object which has already parsed the query
my $tvdb = SQLite::Work::CGI->new(%InitArgs);
if ($tvdb->do_connect())
{
if ($tvdb->{cgi}->param('Table'))
{
if ($tvdb->{cgi}->param('Add'))
{
$tvdb->do_add($tvdb->{cgi}->param('Table'));
}
elsif ($tvdb->{cgi}->param('Add_Row'))
{
$tvdb->do_add_form($tvdb->{cgi}->param('Table'));
}
elsif ($tvdb->{cgi}->param('Edit'))
{
$tvdb->do_select($tvdb->{cgi}->param('Table'),
command=>'Edit');
}
elsif ($tvdb->{cgi}->param('Edit_Row'))
{
$tvdb->do_select($tvdb->{cgi}->param('Table'),
command=>'Edit');
}
elsif ($tvdb->{cgi}->param('Update'))
{
$tvdb->do_single_update($tvdb->{cgi}->param('Table'));
}
elsif ($tvdb->{cgi}->param('Delete'))
{
$tvdb->do_single_delete($tvdb->{cgi}->param('Table'));
}
elsif ($tvdb->{cgi}->param('Delete_Row'))
{
$tvdb->do_single_delete($tvdb->{cgi}->param('Table'));
}
else
{
$tvdb->do_search_form($tvdb->{cgi}->param('Table'),
command=>'Edit');
}
}
else
{
$tvdb->do_table_form('Editing');
}
$tvdb->do_disconnect();
}
}