diff options
Diffstat (limited to 'cgi-bin')
-rwxr-xr-x | cgi-bin/card_table.pl | 371 | ||||
-rwxr-xr-x | cgi-bin/designer.sql | 15 | ||||
-rwxr-xr-x | cgi-bin/html/login.html | 41 | ||||
-rwxr-xr-x | cgi-bin/login.pl | 209 | ||||
-rwxr-xr-x | cgi-bin/sketchbook.pl | 142 | ||||
-rwxr-xr-x | cgi-bin/sketchbook_resolver.pl | 49 | ||||
-rwxr-xr-x | cgi-bin/sop_preview_proxy.pl | 28 | ||||
-rwxr-xr-x | cgi-bin/sop_proxy.pl | 18 |
8 files changed, 873 insertions, 0 deletions
diff --git a/cgi-bin/card_table.pl b/cgi-bin/card_table.pl new file mode 100755 index 0000000..a4d26f6 --- /dev/null +++ b/cgi-bin/card_table.pl | |||
@@ -0,0 +1,371 @@ | |||
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 Bit::Vector; | ||
14 | use Image::Magick; | ||
15 | |||
16 | use Compose::local_lib; | ||
17 | use Compose::db_connection; | ||
18 | |||
19 | my $r = Apache::Request->new(Apache->request); | ||
20 | $r->send_http_header('text/javascript'); | ||
21 | |||
22 | my $tt = new Benchmark::Timer; | ||
23 | $tt->start('all'); | ||
24 | |||
25 | my $local_lib = new Compose::local_lib(); | ||
26 | |||
27 | my $dbh = new Compose::db_connection('localhost','aes','apache','webconnect'); | ||
28 | |||
29 | my $form; | ||
30 | foreach my $key (sort $r->param) { | ||
31 | $form->{$key} = $local_lib->fix_spaces($r->param($key)); | ||
32 | } | ||
33 | |||
34 | # table=home | ||
35 | |||
36 | ################################################## | ||
37 | # | ||
38 | # | ||
39 | if ($r->method() eq "GET") { | ||
40 | |||
41 | if ($form->{'table'} eq "") { | ||
42 | |||
43 | my $qry = qq(select distinct select_0 from content_data where site_id=1 and form_id=48 and moderation_status=3 and date_0 <= NOW() ); | ||
44 | my %tables = $dbh->queryDB($qry,'select_0'); | ||
45 | |||
46 | print qq( | ||
47 | [ | ||
48 | ); | ||
49 | my @list=(); | ||
50 | foreach my $table (sort { $a cmp $b } keys %tables) { | ||
51 | push @list,"\t\"$table\""; | ||
52 | } | ||
53 | |||
54 | print join(",\n",@list) . qq( | ||
55 | ] | ||
56 | ); | ||
57 | |||
58 | |||
59 | |||
60 | } elsif ($form->{'table'} ne "") { | ||
61 | |||
62 | my $qry = ""; | ||
63 | |||
64 | my $ckb = "checkbox_1"; | ||
65 | if ($form->{'table'} eq "intro") { | ||
66 | $ckb = "checkbox_0"; | ||
67 | } | ||
68 | |||
69 | my $t = new Benchmark::Timer; | ||
70 | |||
71 | $form->{'num_cards'} = 15; # if ($form->{'num_cards'} eq ""); | ||
72 | $form->{'w'} = 900 if ($form->{'w'} eq "" || $form->{'w'} < 900); | ||
73 | $form->{'h'} = 400 if ($form->{'h'} eq "" || $form->{'h'} < 400); | ||
74 | $form->{'max'} = 20 if ($form->{'max'} eq ""); | ||
75 | |||
76 | # get cards | ||
77 | if ($form->{'table'} eq 'home') { | ||
78 | $qry = qq( | ||
79 | SELECT | ||
80 | content_id, | ||
81 | enc_content_id, | ||
82 | textfield_0 AS title, | ||
83 | select_0 AS category, | ||
84 | checkbox_4 AS protected, | ||
85 | image_1_width AS rotated_width, | ||
86 | image_1_height AS rotated_height, | ||
87 | image_2_width AS zdegree_width, | ||
88 | image_2_height AS zdegree_height, | ||
89 | CONCAT(clients.website.site_url,clients.website.publish_docroot,"/",human_dir,"/index.html") AS page_loc, | ||
90 | CONCAT(clients.website.server_docroot, clients.website.publish_docroot,"/",human_dir,"/orig/",image_1) AS publish_loc, | ||
91 | CONCAT(clients.website.site_url,clients.website.publish_docroot,"/",human_dir,"/orig/",image_1) AS rotated_image, | ||
92 | CONCAT(clients.website.site_url,clients.website.publish_docroot,"/",human_dir,"/orig/",image_2) AS zdegree_image | ||
93 | FROM | ||
94 | content_data, | ||
95 | clients.website | ||
96 | WHERE | ||
97 | clients.website.site_id = content_data.site_id AND | ||
98 | content_data.site_id = 1 AND | ||
99 | form_id = 48 AND | ||
100 | moderation_status >= 3 AND | ||
101 | date_0 <= NOW() AND | ||
102 | checkbox_0 = "Yes" AND | ||
103 | $ckb = "Yes" AND | ||
104 | checkbox_2 != "Yes" AND | ||
105 | !(textfield_5 is NULL or textfield_5 = "") | ||
106 | ORDER BY | ||
107 | last_modified_date | ||
108 | LIMIT | ||
109 | $form->{'num_cards'} | ||
110 | ); | ||
111 | } else { | ||
112 | #$qry = qq( select content_id,enc_content_id,textfield_0 as title, select_0 as category, image_1_height as rotated_height, image_2_width as zdegree_width, image_2_height as zdegree_height, CONCAT(clients.website.site_url,clients.website.publish_docroot,"/",human_dir,"/index.html") as page_loc , CONCAT(clients.website.server_docroot, clients.website.publish_docroot,"/",human_dir,"/orig/",image_1) as publish_loc, CONCAT(clients.website.site_url,clients.website.publish_docroot,"/",human_dir,"/orig/",image_1) as rotated_image, CONCAT(clients.website.site_url,clients.website.publish_docroot,"/",human_dir,"/orig/",image_2) as zdegree_image from content_data,clients.website where clients.website.site_id=content_data.site_id and content_data.site_id=1 and form_id=48 and moderation_status >=3 and date_0 <= NOW() and select_0="$form->{'table'}" and $ckb="Yes" and !(textfield_5 is NULL or textfield_5 = "") and checkbox_2 != "Yes" order by last_modified_date limit $form->{'num_cards'}) ; | ||
113 | |||
114 | $qry = qq( | ||
115 | SELECT | ||
116 | content_id, | ||
117 | enc_content_id, | ||
118 | textfield_0 AS title, | ||
119 | select_0 AS category, | ||
120 | checkbox_4 AS protected, | ||
121 | image_1_width AS rotated_width, | ||
122 | image_1_height AS rotated_height, | ||
123 | image_2_width AS zdegree_width, | ||
124 | image_2_height AS zdegree_height, | ||
125 | CONCAT(clients.website.site_url,clients.website.publish_docroot,"/",human_dir,"/index.html") AS page_loc, | ||
126 | CONCAT(clients.website.server_docroot, clients.website.publish_docroot,"/",human_dir,"/orig/",image_1) AS publish_loc, | ||
127 | CONCAT(clients.website.site_url,clients.website.publish_docroot,"/",human_dir,"/orig/",image_1) AS rotated_image, | ||
128 | CONCAT(clients.website.site_url,clients.website.publish_docroot,"/",human_dir,"/orig/",image_2) AS zdegree_image | ||
129 | FROM | ||
130 | content_data, | ||
131 | clients.website | ||
132 | WHERE | ||
133 | clients.website.site_id = content_data.site_id AND | ||
134 | content_data.site_id = 1 AND | ||
135 | form_id = 48 AND | ||
136 | moderation_status >= 3 AND | ||
137 | date_0 <= NOW() AND | ||
138 | select_0 = "$form->{'table'}" AND | ||
139 | $ckb = "Yes" AND | ||
140 | checkbox_2 != "Yes" AND | ||
141 | !(textfield_5 IS NULL OR textfield_5 = "") | ||
142 | ORDER BY | ||
143 | last_modified_date | ||
144 | LIMIT | ||
145 | $form->{'num_cards'} | ||
146 | ); | ||
147 | |||
148 | } | ||
149 | |||
150 | my %res = $dbh->queryRawDB($qry); | ||
151 | |||
152 | my @master_v = new Bit::Vector($form->{'w'},$form->{'h'}); | ||
153 | my ($hei,$wid); | ||
154 | my @rowM=(); | ||
155 | |||
156 | my $back_image; | ||
157 | if ($form->{'gen'} ne "") { | ||
158 | $back_image = Image::Magick->new(size=>"$form->{'w'} x $form->{'h'}"); | ||
159 | $back_image->ReadImage('xc:white'); | ||
160 | } | ||
161 | |||
162 | my ($idx,$x,$y); | ||
163 | |||
164 | print qq( [ \n); | ||
165 | my $iter = 0; | ||
166 | foreach $idx (sort {$a <=> $b} keys %res) { | ||
167 | |||
168 | my $protected = ($res{$idx}{'protected'} eq 'Yes') ? 'true' : 'false'; | ||
169 | |||
170 | ($x,$y,$back_image) = &place_data(\@master_v,$form->{'w'},$form->{'h'},$res{$idx}{'zdegree_image'},$res{$idx}{'rotated_image'},$res{$idx}{'rotated_width'},$res{$idx}{'rotated_height'},$res{$idx}{'publish_loc'},$back_image,$form->{'gen'},$form->{'max'}); | ||
171 | |||
172 | print qq(\t{ | ||
173 | "cid" : "$res{$idx}{'enc_content_id'}", | ||
174 | "title" : "$res{$idx}{'title'}", | ||
175 | "category" : "$res{$idx}{'category'}", | ||
176 | "locked" : $protected, | ||
177 | "x" : "$x", | ||
178 | "y" : "$y", | ||
179 | "chip" : "$res{$idx}{'rotated_image'}" | ||
180 | }); | ||
181 | print ",\n" if (++$iter != keys(%res)); | ||
182 | } | ||
183 | print qq( \n ]); | ||
184 | |||
185 | if ($form->{'gen'} ne "") { | ||
186 | $back_image->Write("/usr/web/designer/docroot/test.png"); | ||
187 | } | ||
188 | |||
189 | } | ||
190 | |||
191 | } | ||
192 | |||
193 | #$tt->stop('all'); | ||
194 | #print $tt->report() ." <br>"; | ||
195 | #print qq(<img src="/test.png">) if ($form->{'gen'}); | ||
196 | |||
197 | ########################################### | ||
198 | # | ||
199 | |||
200 | sub place_data { | ||
201 | |||
202 | my $master_v = shift; | ||
203 | my $page_width = shift; | ||
204 | my $page_height = shift; | ||
205 | my $image_data_zdegree_image = shift; | ||
206 | my $image_data_rotated_image = shift; | ||
207 | my $image_data_rotated_width = shift; | ||
208 | my $image_data_rotated_height = shift; | ||
209 | my $image_data_publish_loc = shift; | ||
210 | my $back_image = shift; | ||
211 | my $gen_image = shift; | ||
212 | my $max_collide = shift; | ||
213 | |||
214 | my $done = 0; | ||
215 | my $attempts = 0; | ||
216 | |||
217 | my $t = new Benchmark::Timer; | ||
218 | |||
219 | my ($max_x,$max_y,$xpos,$ypos,$vector,$sdone,$start,$attempts,$sattempts,$min,$max,$collisions,$xrand,$yrand ); | ||
220 | |||
221 | while ((!$done) && $attempts < 500) { | ||
222 | |||
223 | $xrand = int(rand($page_width-20-$image_data_rotated_width)+10); | ||
224 | $yrand = int(rand($page_height-20-$image_data_rotated_height)+10); | ||
225 | |||
226 | my $max_collide = int($image_data_rotated_width*$image_data_rotated_height*($max_collide/100)); | ||
227 | |||
228 | $max_x = $xrand+$image_data_rotated_width; | ||
229 | $max_y = $yrand+$image_data_rotated_height; | ||
230 | |||
231 | $t->start('3.1'); | ||
232 | |||
233 | $collisions = 0; | ||
234 | |||
235 | for ($ypos = $yrand;$ypos <= $max_y; $ypos++) { | ||
236 | $vector = @{$master_v}->[$ypos]; | ||
237 | |||
238 | $sdone=0; | ||
239 | $start = $xrand; | ||
240 | $sattempts = 0; | ||
241 | |||
242 | while (!$sdone && $sattempts++ < 20) { | ||
243 | ($min,$max) = $vector->Interval_Scan_inc($start); | ||
244 | |||
245 | if ($max+1 >= $page_width) { | ||
246 | $sdone=1; | ||
247 | } | ||
248 | |||
249 | if ($min < $max_x && $max) { | ||
250 | if ($max > $max_x || $max+1 >= $page_width) { | ||
251 | $collisions += $max_x - $min; | ||
252 | $sdone = 1; | ||
253 | } else { | ||
254 | $collisions += $max - $min; | ||
255 | $start = $max+1; | ||
256 | } | ||
257 | |||
258 | } elsif ($min > $max_x || !$max || !$min) { | ||
259 | $sdone=1; | ||
260 | } | ||
261 | } | ||
262 | } | ||
263 | |||
264 | #$t->stop('3.1'); | ||
265 | #print $t->report() . "<br>"; | ||
266 | |||
267 | |||
268 | if ($collisions < $max_collide) { | ||
269 | |||
270 | # place image in master array | ||
271 | |||
272 | my ($xpos,$ypos); | ||
273 | my $max_x = $xrand+$image_data_rotated_width; | ||
274 | my $max_y = $yrand+$image_data_rotated_height; | ||
275 | |||
276 | #$t->start('5.1'); | ||
277 | |||
278 | my $vector; | ||
279 | for ($ypos = $yrand;$ypos <= $max_y; $ypos++) { | ||
280 | $vector = @{$master_v}->[$ypos]; | ||
281 | $vector->Interval_Fill($xrand,$max_x); | ||
282 | } | ||
283 | |||
284 | #$t->stop('5.1'); | ||
285 | #print $t->report() . "<br>"; | ||
286 | |||
287 | $done = 1; | ||
288 | |||
289 | if ($gen_image) { | ||
290 | my $card_image = Image::Magick->new(); | ||
291 | $card_image->Read($image_data_publish_loc); | ||
292 | $back_image->Composite(image=>$card_image, x=>$xrand,y=>$yrand); | ||
293 | } | ||
294 | |||
295 | } else { | ||
296 | |||
297 | $attempts++; | ||
298 | } | ||
299 | } | ||
300 | |||
301 | #print "ATTEMPTS: $attempts <br>"; | ||
302 | |||
303 | if ($attempts >= 499) { | ||
304 | #print "UNABLE TO PLACE IMAGE <br>"; | ||
305 | } | ||
306 | |||
307 | |||
308 | return ($xrand,$yrand,$back_image); | ||
309 | } | ||
310 | |||
311 | ################################################## | ||
312 | # | ||
313 | |||
314 | sub check_collisions { | ||
315 | |||
316 | my $master_v = shift; | ||
317 | my $width = shift; | ||
318 | my $height = shift; | ||
319 | my $xrand = shift; | ||
320 | my $yrand = shift; | ||
321 | my $max_collide = shift; | ||
322 | my $page_width = shift; | ||
323 | |||
324 | |||
325 | my $t = new Benchmark::Timer; | ||
326 | |||
327 | my $max_x = $xrand+$width; | ||
328 | my $max_y = $yrand+$height; | ||
329 | |||
330 | #$t->start('3.1'); | ||
331 | |||
332 | my $btot = 0; | ||
333 | |||
334 | my ($xpos,$ypos,$vector,$sdone,$start,$attempts,$min,$max); | ||
335 | |||
336 | for ($ypos = $yrand;$ypos <= $max_y; $ypos++) { | ||
337 | $vector = @{$master_v}->[$ypos]; | ||
338 | |||
339 | $sdone=0; | ||
340 | $start = $xrand; | ||
341 | $attempts = 0; | ||
342 | |||
343 | while (!$sdone && $attempts++ < 20) { | ||
344 | ($min,$max) = $vector->Interval_Scan_inc($start); | ||
345 | |||
346 | if ($max+1 >= $page_width) { | ||
347 | $sdone=1; | ||
348 | } | ||
349 | |||
350 | if ($min < $max_x && $max) { | ||
351 | if ($max > $max_x || $max+1 >= $page_width) { | ||
352 | $btot += $max_x - $min; | ||
353 | $sdone = 1; | ||
354 | } else { | ||
355 | $btot += $max - $min; | ||
356 | $start = $max+1; | ||
357 | } | ||
358 | |||
359 | } elsif ($min > $max_x || !$max || !$min) { | ||
360 | $sdone=1; | ||
361 | } | ||
362 | } | ||
363 | } | ||
364 | |||
365 | #$t->stop('3.1'); | ||
366 | #print $t->report() . "<br>"; | ||
367 | |||
368 | return $btot; | ||
369 | |||
370 | } | ||
371 | |||
diff --git a/cgi-bin/designer.sql b/cgi-bin/designer.sql new file mode 100755 index 0000000..aef45ce --- /dev/null +++ b/cgi-bin/designer.sql | |||
@@ -0,0 +1,15 @@ | |||
1 | drop database if exists designer; | ||
2 | create database designer; | ||
3 | |||
4 | use designer; | ||
5 | |||
6 | |||
7 | |||
8 | create TABLE sketchbook ( | ||
9 | id int not NULL auto_increment, | ||
10 | user_id int not NULL, | ||
11 | sketchbook_data text, | ||
12 | INDEX user_id(user_id), | ||
13 | PRIMARY KEY(id) | ||
14 | ); | ||
15 | |||
diff --git a/cgi-bin/html/login.html b/cgi-bin/html/login.html new file mode 100755 index 0000000..5fe2254 --- /dev/null +++ b/cgi-bin/html/login.html | |||
@@ -0,0 +1,41 @@ | |||
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
2 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" > | ||
3 | <head> | ||
4 | <title>Please Log In!</title> | ||
5 | <script type="text/javascript" src="http://materialexperience.santoprene.com/siteflow2/scripts/designer.js"></script> | ||
6 | |||
7 | <style type="text/css"> | ||
8 | @import url('http://www.santoprene.com/siteflow2/styles/designer.css'); | ||
9 | @import url('http://materialexperience.santoprene.com/specialcases.css'); | ||
10 | </style> | ||
11 | </head> | ||
12 | |||
13 | <body> | ||
14 | <h3>Please Log In!</h3> | ||
15 | <h4>You need to be registered and logged in to use certain features of the Material Experience Website.</h4> | ||
16 | |||
17 | <TMPL_VAR NAME="error"> | ||
18 | |||
19 | <p> | ||
20 | If you are not yet registered, <a href="http://www.santoprene.com/cgi-bin/register/account.pl?template=designer_"> | ||
21 | register here!</a> If you have forgotten your password, | ||
22 | <a href="http://www.santoprene.com/cgi-bin/lost_password.pl?tmpl=designer">we can e-mail it to you</a>. | ||
23 | </p> | ||
24 | |||
25 | <form action="/cgi-bin/login.pl" method="post"> | ||
26 | <input type="hidden" name="redir" value="/cgi-bin/sketchbook.pl"> | ||
27 | |||
28 | <p> | ||
29 | <label>Username:</label> | ||
30 | <input type="text" name="user" value="<TMPL_VAR NAME="user">" size="30" /> | ||
31 | </p> | ||
32 | <p> | ||
33 | <label>Password:</label> | ||
34 | <input type="password" name="password" /> | ||
35 | <a href="http://www.santoprene.com/cgi-bin/lost_password.pl?tmpl=designer">Forgot it?</a> | ||
36 | </p> | ||
37 | |||
38 | <p><input type="submit" value="Log In" /></p> | ||
39 | </form> | ||
40 | </body> | ||
41 | </html> | ||
diff --git a/cgi-bin/login.pl b/cgi-bin/login.pl new file mode 100755 index 0000000..81e8bf7 --- /dev/null +++ b/cgi-bin/login.pl | |||
@@ -0,0 +1,209 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | $|=1; | ||
4 | |||
5 | use strict; | ||
6 | |||
7 | use Apache::Request; | ||
8 | use Apache::Constants qw(REDIRECT); | ||
9 | use MIME::Base64 qw(encode_base64 decode_base64); | ||
10 | use HTML::Template; | ||
11 | |||
12 | use Compose::local_lib; | ||
13 | use Compose::site_user_lib; | ||
14 | |||
15 | $Apache::DBI::DEBUG=2; | ||
16 | |||
17 | my $r = Apache::Request->new(Apache->request); | ||
18 | #$r->send_http_header('text/html'); | ||
19 | |||
20 | my $dbh = new Compose::db_connection('localhost','aes','apache','webconnect'); | ||
21 | |||
22 | my $client_lib = new Compose::client_lib(); | ||
23 | my $local_lib = new Compose::local_lib($client_lib,0); | ||
24 | |||
25 | my $client_id = 1; | ||
26 | $client_lib->setup_client($client_id); | ||
27 | |||
28 | |||
29 | my $site_user_lib = new Compose::site_user_lib($client_lib); | ||
30 | |||
31 | $client_lib->{'dbh'}{'debug'} = 2; | ||
32 | |||
33 | my ($form,$PASS); | ||
34 | |||
35 | foreach my $key (sort $r->param) { | ||
36 | $form->{$key} = $local_lib->fix_spaces($r->param($key)); | ||
37 | #print "$key: $form->{$key} <br>"; | ||
38 | } | ||
39 | |||
40 | my %cookiejar = Apache::Cookie->new($r)->parse; | ||
41 | my $newcookie = Apache::Cookie->new($r); | ||
42 | |||
43 | ##################################################### | ||
44 | # Get the username and password from the cookie. | ||
45 | |||
46 | unless ($cookiejar{'Site'} || ($form->{'user'} && $form->{'password'})) { | ||
47 | $r->send_http_header('text/html'); | ||
48 | |||
49 | my $template = HTML::Template->new( filename => "html/login.html", path => [ "$client_lib->{'client'}->{'server_docroot'}" ], die_on_bad_params => 0); | ||
50 | |||
51 | $template->param('user' => $form->{'user'}); | ||
52 | |||
53 | print $template->output(); | ||
54 | |||
55 | exit(0); | ||
56 | } | ||
57 | |||
58 | my %cookie_hash; | ||
59 | |||
60 | if ( $cookiejar{'Site'} ) { | ||
61 | |||
62 | my @values = $cookiejar{'Site'}->value; | ||
63 | |||
64 | for (my $i=0;$i<scalar(@values);$i+=2) { | ||
65 | $cookie_hash{$values[$i]} = $values[$i+1]; | ||
66 | } | ||
67 | } else { | ||
68 | $cookiejar{'Site'} = ""; | ||
69 | } | ||
70 | |||
71 | my $errors = ""; | ||
72 | |||
73 | |||
74 | if ($form->{'user'} && $form->{'password'}) { | ||
75 | |||
76 | my $site_user = &get_user_info($form->{'user'},$dbh); | ||
77 | |||
78 | if (lc $site_user->{'user_name'} eq lc $form->{'user'}) { | ||
79 | if ($site_user->{'user_passwd'} eq $form->{'password'}) { | ||
80 | &bake_cookie($r,$client_lib,$newcookie,\%cookie_hash,$form,$site_user,$dbh); | ||
81 | exit(0); | ||
82 | } else { | ||
83 | $errors .= qq(The password you entered is incorrect. Please try again.<br>); | ||
84 | } | ||
85 | |||
86 | } else { | ||
87 | $errors .= qq(The user name $form->{'user'} does not exist.<br>); | ||
88 | } | ||
89 | |||
90 | } elsif ($cookie_hash{'Site'}) { | ||
91 | |||
92 | |||
93 | my ($user, $password) = split /:/, decode_base64($cookie_hash{'Site'}), 2; | ||
94 | |||
95 | if ($user eq "" ) { | ||
96 | $errors .= qq($cookie_hash{'Site'} Cookie could not be read. <br>); | ||
97 | |||
98 | } else { | ||
99 | |||
100 | my $site_user = &get_user_info($user,$dbh); | ||
101 | |||
102 | if (defined $site_user->{'user_name'} && lc $site_user->{'user_name'} eq lc $user ) { | ||
103 | |||
104 | if ($site_user->{'user_passwd'} eq $password) { | ||
105 | &bake_cookie($r,$client_lib,$newcookie,\%cookie_hash,$form,$site_user,$dbh); | ||
106 | exit(0); | ||
107 | } else { | ||
108 | $errors .= qq(The password you entered is incorrect. Please try again.<br>); | ||
109 | } | ||
110 | |||
111 | } else { | ||
112 | $errors .= qq(The user name $form->{'user'} does not exist.<br>) if ($form->{'user'}); | ||
113 | } | ||
114 | } | ||
115 | } | ||
116 | |||
117 | |||
118 | $r->send_http_header('text/html'); | ||
119 | |||
120 | my $template = HTML::Template->new( filename => "html/login.html", path => [ "$client_lib->{'client'}->{'server_docroot'}" ], die_on_bad_params => 0); | ||
121 | |||
122 | $template->param('user' => $form->{'user'}); | ||
123 | $template->param('error' => "$errors"); | ||
124 | |||
125 | print $template->output(); | ||
126 | |||
127 | |||
128 | |||
129 | ################################### | ||
130 | |||
131 | sub bake_cookie { | ||
132 | |||
133 | my $r = shift; | ||
134 | my $client_lib = shift; | ||
135 | my $cookiejar = shift; | ||
136 | my $cookie_hash = shift; | ||
137 | my $form = shift; | ||
138 | my $site_user = shift; | ||
139 | my $dbh = shift; | ||
140 | |||
141 | if ( ($cookie_hash->{uri} =~ /login.pl/) || $cookie_hash->{uri} eq "") { | ||
142 | $cookie_hash->{uri} = "/"; | ||
143 | } | ||
144 | $cookie_hash->{uri} = $form->{'redir'}; | ||
145 | |||
146 | |||
147 | # We have some valid credientials, so set an authorization cookie. | ||
148 | my @values = ( | ||
149 | uri => $cookie_hash->{uri}, | ||
150 | Cookie => encode_base64(join ":", ($form->{'user'},$form->{'password'})), | ||
151 | ); | ||
152 | |||
153 | my $c = $r->connection; | ||
154 | my $ip = $c->remote_ip; | ||
155 | my $ins = qq(insert into logins (id,username,last_name,first_name,login_date,ip_address) values (NULL,"$site_user->{'user_name'}","$site_user->{'last_name'}","$site_user->{'first_name'}",NOW(),"$ip")); | ||
156 | $dbh->updateDB($ins); | ||
157 | |||
158 | |||
159 | $cookiejar->name('Site'); | ||
160 | $cookiejar->value(\@values); | ||
161 | $cookiejar->path('/'); | ||
162 | $cookiejar->domain('.santoprene.com'); | ||
163 | $cookiejar->bake; | ||
164 | |||
165 | |||
166 | $r->status(REDIRECT); | ||
167 | $r->headers_out->set(Location => $cookie_hash->{uri}); | ||
168 | $r->send_http_header; | ||
169 | |||
170 | |||
171 | |||
172 | } | ||
173 | ####################### | ||
174 | |||
175 | sub get_user_info { | ||
176 | |||
177 | my $uid = shift; | ||
178 | my $dbh = shift; | ||
179 | |||
180 | my ($qry,$gqry,%user_info,%group_info); | ||
181 | |||
182 | %user_info=%group_info=(); | ||
183 | |||
184 | ########################### | ||
185 | # Internet User | ||
186 | |||
187 | |||
188 | $qry = qq(select admin_user_info.*, DATE_FORMAT(created_on,'%c/%y') as format_created_on from admin_user_info where user_name="$uid" and ((registrant=1 and verified=1) or registrant=0) ); | ||
189 | |||
190 | %user_info = $dbh->queryRawDB($qry); | ||
191 | |||
192 | my %USER_INFO; | ||
193 | |||
194 | foreach my $k (keys %{$user_info{'0'}}) { | ||
195 | $USER_INFO{$k} = $user_info{'0'}{$k}; | ||
196 | } | ||
197 | |||
198 | $USER_INFO{'FULL_NAME'} = "$USER_INFO{'first_name'} " if ($USER_INFO{'first_name'} ne ""); | ||
199 | $USER_INFO{'FULL_NAME'} .= "$USER_INFO{'last_name'} " if ($USER_INFO{'last_name'} ne ""); | ||
200 | |||
201 | foreach my $group (keys %group_info) { | ||
202 | $USER_INFO{'group_info'}{$group_info{$group}{'group_id'}} = $group_info{$group}; | ||
203 | $USER_INFO{'groups'}{$group} = 1; | ||
204 | } | ||
205 | |||
206 | return \%USER_INFO; | ||
207 | } | ||
208 | |||
209 | |||
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 | |||
diff --git a/cgi-bin/sketchbook_resolver.pl b/cgi-bin/sketchbook_resolver.pl new file mode 100755 index 0000000..cbf64be --- /dev/null +++ b/cgi-bin/sketchbook_resolver.pl | |||
@@ -0,0 +1,49 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | $|=1; | ||
4 | |||
5 | use strict; | ||
6 | use Apache::Request; | ||
7 | use Apache::Constants qw(REDIRECT); | ||
8 | use Compose::local_lib; | ||
9 | use Compose::db_connection; | ||
10 | |||
11 | my $r = Apache::Request->new(Apache->request); | ||
12 | my $local_lib = new Compose::local_lib(); | ||
13 | my $dbh = new Compose::db_connection('localhost','aes','apache','webconnect'); | ||
14 | my $item = $local_lib->fix_spaces($r->param('card')); | ||
15 | |||
16 | $r->send_http_header('text/javascript'); | ||
17 | |||
18 | if ($r->method() eq "GET") { | ||
19 | my %res = $dbh->queryRawDB(qq( | ||
20 | SELECT | ||
21 | enc_content_id, | ||
22 | textfield_0 AS title, | ||
23 | select_0 AS category, | ||
24 | CONCAT(clients.website.site_url,clients.website.publish_docroot,"/",human_dir,"/index.html") AS page_loc, | ||
25 | CONCAT(clients.website.site_url,clients.website.publish_docroot,"/",human_dir,"/orig/",image_1) AS rotated_image | ||
26 | FROM | ||
27 | content_data, | ||
28 | clients.website | ||
29 | WHERE | ||
30 | clients.website.site_id = content_data.site_id AND | ||
31 | content_data.site_id = 1 AND | ||
32 | form_id = 48 AND | ||
33 | moderation_status >= 3 AND | ||
34 | date_0 <= NOW() AND | ||
35 | enc_content_id = "$item" AND | ||
36 | !(textfield_5 is NULL or textfield_5 = "") AND | ||
37 | checkbox_2 != "Yes" | ||
38 | )); | ||
39 | |||
40 | print qq( | ||
41 | \({ | ||
42 | "cid" : "$res{0}{'enc_content_id'}", | ||
43 | "title" : "$res{0}{'title'}", | ||
44 | "category" : "$res{0}{'category'}", | ||
45 | "url" : "$res{0}{'page_loc'}", | ||
46 | "chip" : "$res{0}{'rotated_image'}" | ||
47 | }\) | ||
48 | ); | ||
49 | } \ No newline at end of file | ||
diff --git a/cgi-bin/sop_preview_proxy.pl b/cgi-bin/sop_preview_proxy.pl new file mode 100755 index 0000000..0694e11 --- /dev/null +++ b/cgi-bin/sop_preview_proxy.pl | |||
@@ -0,0 +1,28 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | # | ||
4 | # Perl Based Same Origin Proxy | ||
5 | # | ||
6 | |||
7 | $|=1; | ||
8 | |||
9 | srand; | ||
10 | use strict; | ||
11 | |||
12 | use Apache::Request; | ||
13 | use LWP::Simple; | ||
14 | use LWP::UserAgent; | ||
15 | |||
16 | my $r = Apache::Request->new(Apache->request); | ||
17 | $r->send_http_header('text/javascript'); | ||
18 | |||
19 | my @url = split(/site=/,$r->parsed_uri()->unparse()); | ||
20 | |||
21 | my $browser = LWP::UserAgent->new; | ||
22 | $browser->credentials( | ||
23 | 'admin.santoprene.com:80', | ||
24 | 'Admin', | ||
25 | 'DESIGNER_SOP_USER' => 'dsop4edit' | ||
26 | ); | ||
27 | |||
28 | print $browser->get($url[1])->content; | ||
diff --git a/cgi-bin/sop_proxy.pl b/cgi-bin/sop_proxy.pl new file mode 100755 index 0000000..4a3b370 --- /dev/null +++ b/cgi-bin/sop_proxy.pl | |||
@@ -0,0 +1,18 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | # | ||
4 | # Perl Based Same Origin Proxy | ||
5 | # | ||
6 | |||
7 | $|=1; | ||
8 | |||
9 | srand; | ||
10 | use strict; | ||
11 | |||
12 | use Apache::Request; | ||
13 | use LWP::Simple; | ||
14 | |||
15 | my $r = Apache::Request->new(Apache->request); | ||
16 | $r->send_http_header('text/javascript'); | ||
17 | |||
18 | print get $r->param('site'); | ||