diff options
Diffstat (limited to 'cgi-bin/sketchbook.pl')
-rwxr-xr-x | cgi-bin/sketchbook.pl | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/cgi-bin/sketchbook.pl b/cgi-bin/sketchbook.pl new file mode 100755 index 0000000..8103bd4 --- /dev/null +++ b/cgi-bin/sketchbook.pl | |||
@@ -0,0 +1,142 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | $|=1; | ||
4 | |||
5 | srand; | ||
6 | |||
7 | use strict; | ||
8 | |||
9 | use Apache::Request; | ||
10 | use Apache::Constants qw(REDIRECT); | ||
11 | use Benchmark::Timer; | ||
12 | use HTML::Template; | ||
13 | use MIME::Base64 qw(encode_base64 decode_base64); | ||
14 | use Compose::local_lib; | ||
15 | use Compose::db_connection; | ||
16 | |||
17 | my $r = Apache::Request->new(Apache->request); | ||
18 | |||
19 | my $local_lib = new Compose::local_lib(); | ||
20 | |||
21 | my $dbh_aes = new Compose::db_connection('localhost','aes','apache','webconnect'); | ||
22 | my $dbh = new Compose::db_connection('localhost','designer','apache','webconnect'); | ||
23 | |||
24 | my $form; | ||
25 | foreach my $key (sort $r->param) { | ||
26 | $form->{$key} = $local_lib->fix_spaces($r->param($key)); | ||
27 | } | ||
28 | |||
29 | my %cookiejar = Apache::Cookie->new($r)->parse; | ||
30 | my $newcookie = Apache::Cookie->new($r); | ||
31 | my ($user, $password, %user_info, $qry, %user_info, %cookie_hash); | ||
32 | |||
33 | ################################################## | ||
34 | # | ||
35 | unless ($cookiejar{'Site'}) { | ||
36 | print "Content-type: text/html\n"; | ||
37 | print "Status: 403\n"; | ||
38 | exit(0); | ||
39 | ################################################## | ||
40 | # | ||
41 | } elsif ( $cookiejar{'Site'} ) { | ||
42 | |||
43 | my @values = $cookiejar{'Site'}->value; | ||
44 | |||
45 | for (my $i=0;$i<scalar(@values);$i+=2) { | ||
46 | #print qq($values[$i] : $values[$i+1] <br>); | ||
47 | $cookie_hash{$values[$i]} = $values[$i+1]; | ||
48 | } | ||
49 | |||
50 | ($user, $password) = split /:/, decode_base64($cookie_hash{'Cookie'}), 2; | ||
51 | |||
52 | $qry = qq(select * from admin_user_info where user_name="$user"); | ||
53 | |||
54 | %user_info = $dbh_aes->queryRawDB($qry); | ||
55 | |||
56 | if ($user_info{'0'}{'id'} eq "") { | ||
57 | print "Content-type: text/html\n"; | ||
58 | print "Status: 403\n"; | ||
59 | exit(0); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | |||
64 | |||
65 | ################################################## | ||
66 | # | ||
67 | if ($r->method() eq "GET") { | ||
68 | |||
69 | $qry = qq(select * from sketchbook where user_id="$user_info{'0'}{'id'}"); | ||
70 | |||
71 | my %data = $dbh->queryRawDB($qry); | ||
72 | |||
73 | if ($data{'0'}{'sketchbook_data'} eq "") { | ||
74 | if ($form->{'interactive'} ne "false") { | ||
75 | $r->send_http_header('text/html'); | ||
76 | print qq{ | ||
77 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
78 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> | ||
79 | <head> | ||
80 | <title>Logged In</title> | ||
81 | <style type="text/css"> | ||
82 | \@import url('http://www.santoprene.com/siteflow2/styles/designer.css'); | ||
83 | \@import url('http://materialexperience.santoprene.com/specialcases.css'); | ||
84 | </style> | ||
85 | </head> | ||
86 | |||
87 | <body> | ||
88 | <h1>Logged In</h1> | ||
89 | <p>Thanks for logging in. You can close this card now.</p> | ||
90 | </body> | ||
91 | </html><div style="display: none"> | ||
92 | }; | ||
93 | } else { | ||
94 | print "Status: 404\n"; | ||
95 | print "Content-type: text/html\n"; | ||
96 | } | ||
97 | |||
98 | exit(0); | ||
99 | } else { | ||
100 | if ($form->{'interactive'} ne "false") { | ||
101 | $r->send_http_header('text/html'); | ||
102 | print qq{ | ||
103 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
104 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> | ||
105 | <head> | ||
106 | <title>Logged In</title> | ||
107 | <style type="text/css"> | ||
108 | \@import url('http://www.santoprene.com/siteflow2/styles/designer.css'); | ||
109 | \@import url('http://materialexperience.santoprene.com/specialcases.css'); | ||
110 | </style> | ||
111 | </head> | ||
112 | |||
113 | <body> | ||
114 | <h1>Logged In</h1> | ||
115 | <p>Thanks for logging in. You can close this card now.</p> | ||
116 | </body> | ||
117 | </html><div style="display: none"> | ||
118 | }; | ||
119 | } else { | ||
120 | $r->send_http_header('text/javascript'); | ||
121 | print "$data{'0'}{'sketchbook_data'}\n"; | ||
122 | } | ||
123 | } | ||
124 | |||
125 | ################################################## | ||
126 | # | ||
127 | } else { | ||
128 | |||
129 | if ($form->{'sketchbook_data'} ne "") { | ||
130 | my $upd = qq(delete from sketchbook where user_id="$user_info{'0'}{'id'}"); | ||
131 | $dbh->updateDB($upd); | ||
132 | |||
133 | $form->{'sketchbook_data'} =~ s/"/\\"/g; | ||
134 | |||
135 | my $upd = qq(insert into sketchbook (sketchbook_data,user_id) values ("$form->{'sketchbook_data'}","$user_info{'0'}{'id'}")); | ||
136 | my %data = $dbh->queryRawDB($upd); | ||
137 | } | ||
138 | |||
139 | print "Content-type: text/html\n\n"; | ||
140 | |||
141 | } | ||
142 | |||