2007-10-11 17:06:08 +00:00
|
|
|
require "include.pl";
|
|
|
|
require "functions.pl";
|
2007-10-11 14:59:55 +00:00
|
|
|
|
|
|
|
#initialize session data
|
|
|
|
CGI::Session->name($session_name);
|
|
|
|
$query = new CGI;
|
|
|
|
$session = new CGI::Session;
|
|
|
|
|
|
|
|
#check if query is set
|
2007-10-11 17:26:39 +00:00
|
|
|
if($query->param('query'))
|
|
|
|
{
|
2007-10-11 14:59:55 +00:00
|
|
|
my $search_query = $query->param('query');
|
|
|
|
|
2007-10-11 17:06:08 +00:00
|
|
|
$page = XMLin('$gnutube_root/search.xml', ForceArray => 1, KeyAttr => {} );
|
2007-10-11 14:59:55 +00:00
|
|
|
|
|
|
|
#if a username is associated with session id, username is nonempty
|
|
|
|
$page->{username} = get_username_from_sid($session->id);
|
|
|
|
|
|
|
|
$page->{results}->{query} = $query->param('query');
|
|
|
|
|
|
|
|
#connect to db
|
|
|
|
my $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass) or die $dbh->errstr;
|
|
|
|
|
|
|
|
#prepare query
|
|
|
|
my $sth = $dbh->prepare(qq{select title, caption from videos where match(title, caption) against('$search_query') }) or die $dbh->errstr;
|
|
|
|
|
|
|
|
#execute it
|
|
|
|
$sth->execute() or die $dbh->errstr;
|
|
|
|
|
|
|
|
#get every returned value
|
|
|
|
while (my ($title, $caption) = $sth->fetchrow_array())
|
|
|
|
{
|
2007-10-11 16:25:56 +00:00
|
|
|
#really obfuscated array/hash creation
|
2007-10-11 16:29:13 +00:00
|
|
|
push @{ $page->{'results'}->{'result'} },
|
|
|
|
{
|
2007-10-11 17:26:39 +00:00
|
|
|
'thumbnail' => ['./video-stills/225x150/4chan_city_mashup.png'],
|
|
|
|
'rdf:RDF' =>
|
2007-10-11 16:29:13 +00:00
|
|
|
{
|
2007-10-11 17:26:39 +00:00
|
|
|
'cc:Work' =>
|
2007-10-11 16:29:13 +00:00
|
|
|
{
|
2007-10-11 17:26:39 +00:00
|
|
|
'rdf:about' => './videos/1050x700/4chan_city_mashup.ogg',
|
|
|
|
'dc:title' => [$title]
|
2007-10-11 16:29:13 +00:00
|
|
|
},
|
2007-10-11 17:26:39 +00:00
|
|
|
'cc:License' =>
|
2007-10-11 16:29:13 +00:00
|
|
|
{
|
2007-10-11 17:26:39 +00:00
|
|
|
'rdf:about' => 'http://creativecommons.org/licenses/GPL/2.0/'
|
2007-10-11 16:29:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2007-10-11 14:59:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#finish query
|
|
|
|
$sth->finish() or die $dbh->errstr;
|
|
|
|
|
|
|
|
#close db
|
|
|
|
$dbh->disconnect() or die $dbh->errstr;
|
|
|
|
|
|
|
|
#print xml http header along with session cookie
|
|
|
|
print $session->header(-type=>'text/xml');
|
|
|
|
|
|
|
|
#print xml
|
|
|
|
print XMLout($page, KeyAttr => {}, XMLDecl => '<?xml version="1.0" encoding="ISO-8859-1" ?><?xml-stylesheet type="text/xsl" href="./xsl/xhtml.xsl" ?>', RootName => 'page');
|
2007-10-11 17:26:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-11 14:59:55 +00:00
|
|
|
print $session->header();
|
|
|
|
print "no query passed";
|
|
|
|
}
|