summaryrefslogtreecommitdiff
path: root/cgi-bin/sketchbook_resolver.pl
blob: cbf64be7d59949b581f1d400848f048b0afe8038 (plain)
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
#!/usr/bin/perl

$|=1;

use strict;
use Apache::Request;
use Apache::Constants qw(REDIRECT);
use Compose::local_lib;
use Compose::db_connection;

my $r         = Apache::Request->new(Apache->request);
my $local_lib = new Compose::local_lib();
my $dbh       = new Compose::db_connection('localhost','aes','apache','webconnect');
my $item      = $local_lib->fix_spaces($r->param('card'));

$r->send_http_header('text/javascript');

if ($r->method() eq "GET") {
	my %res = $dbh->queryRawDB(qq(
		SELECT 
			enc_content_id,
			textfield_0 AS title, 
			select_0    AS category, 
			CONCAT(clients.website.site_url,clients.website.publish_docroot,"/",human_dir,"/index.html")    AS page_loc, 
			CONCAT(clients.website.site_url,clients.website.publish_docroot,"/",human_dir,"/orig/",image_1) AS rotated_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
			enc_content_id = "$item"                       AND
			!(textfield_5 is NULL or textfield_5 = "")     AND
			checkbox_2 != "Yes" 
	));

	print qq(
\({
	"cid"      : "$res{0}{'enc_content_id'}",
	"title"    : "$res{0}{'title'}",
	"category" : "$res{0}{'category'}",
	"url"      : "$res{0}{'page_loc'}",
	"chip"     : "$res{0}{'rotated_image'}"
}\)
	);
}