-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetModelInfo.cgi
More file actions
33 lines (27 loc) · 910 Bytes
/
getModelInfo.cgi
File metadata and controls
33 lines (27 loc) · 910 Bytes
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
#!/usr/bin/perl -wT
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $CGI = CGI->new;
use JSON;
use Data::Dumper;
my $params = $CGI->Vars;
print "Content-Type: application/json\n\n";
use DBI;
use DBD::mysql;
#require './lib/mysqlCredentials.pl';
#my ($username, $password) = mysqlCredentials();
if (exists $params->{modelID} and $params->{modelID} ne '') {
my $db = DBI->connect("dbi:mysql:gmlc-modelinfo:localhost:3306", 'mysqluser', '') || die "cannot connect";
my $query = $db->prepare("select * from `ModelInfo` where `modelID` = ?");
$query->execute($params->{modelID});
$result = $query->fetchrow_hashref();
$db->disconnect();
if (!$result) {
$result = {"modelID" => "...NOT FOUND...", "modelName" => "", "authorName"=>"", "authorOrg"=>""};
}
}
else {
$result = {"modelID" => "", "modelName" => "", "authorName"=>"", "authorOrg"=>""};
}
my $json = JSON->new;
print $json->encode($result);