2007-10-11 17:06:08 +00:00
|
|
|
require "functions.pl";
|
2007-10-11 14:59:55 +00:00
|
|
|
|
|
|
|
#initialize session data
|
2008-04-15 18:56:13 +00:00
|
|
|
CGI::Session->name($config->{"page_cookie_name"});
|
2007-10-11 14:59:55 +00:00
|
|
|
$query = new CGI;
|
|
|
|
$session = new CGI::Session;
|
|
|
|
|
2007-10-29 15:00:40 +00:00
|
|
|
@userinfo = get_userinfo_from_sid($session->id);
|
2007-10-27 11:59:23 +00:00
|
|
|
|
2008-04-27 00:42:15 +00:00
|
|
|
my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
|
|
|
|
|
2008-04-27 10:39:21 +00:00
|
|
|
my $page = get_page_array(@userinfo);
|
2007-10-26 00:35:29 +00:00
|
|
|
|
2007-10-11 14:59:55 +00:00
|
|
|
#check if query is set
|
2007-12-21 17:39:49 +00:00
|
|
|
if($query->param('query'))
|
2007-10-11 17:26:39 +00:00
|
|
|
{
|
2008-04-29 07:02:07 +00:00
|
|
|
#construct querystring and arguments from user query
|
2008-04-16 21:07:07 +00:00
|
|
|
my ($dbquery, @args) = get_sqlquery($query->param('query'));
|
2008-02-14 22:15:38 +00:00
|
|
|
|
2008-04-29 07:02:07 +00:00
|
|
|
#if successful
|
2008-04-16 21:07:07 +00:00
|
|
|
if($dbquery)
|
2008-02-14 22:15:38 +00:00
|
|
|
{
|
2008-04-29 07:02:07 +00:00
|
|
|
#fill xml with search results
|
2008-04-27 10:39:21 +00:00
|
|
|
$page->appendChild(fill_results($dbquery, @args));
|
|
|
|
$page->setAttribute('query', $query->param('query'));
|
2008-04-27 00:42:15 +00:00
|
|
|
|
2008-04-27 10:39:21 +00:00
|
|
|
$doc->setDocumentElement($page);
|
2008-04-27 00:42:15 +00:00
|
|
|
|
2008-04-29 07:02:07 +00:00
|
|
|
#get all results
|
2008-04-27 00:42:15 +00:00
|
|
|
my @results = $doc->findnodes( "//results/result" );
|
2008-04-16 13:32:20 +00:00
|
|
|
|
2008-04-29 07:02:07 +00:00
|
|
|
#if result count is zero
|
2008-04-27 00:42:15 +00:00
|
|
|
if($#results == -1)
|
2008-02-14 22:15:38 +00:00
|
|
|
{
|
2008-04-16 13:32:20 +00:00
|
|
|
print $query->redirect("index.pl?warning=warning_no_results");
|
2008-02-14 22:15:38 +00:00
|
|
|
}
|
2008-04-29 07:02:07 +00:00
|
|
|
#if there is only one results, redirect to video directly
|
2008-04-27 00:42:15 +00:00
|
|
|
elsif(($#results == 0) and (not $query->param('page') or $query->param('page') == 1))
|
2008-02-14 22:15:38 +00:00
|
|
|
{
|
2008-04-27 00:42:15 +00:00
|
|
|
print $query->redirect(@{$doc->findnodes( "//results/result/rdf:RDF/cc:Work/dc:identifier/text()" )}[0]->data);
|
2008-02-14 22:15:38 +00:00
|
|
|
}
|
2008-04-16 13:32:20 +00:00
|
|
|
else
|
2008-02-14 22:15:38 +00:00
|
|
|
{
|
2008-04-27 00:42:15 +00:00
|
|
|
output_page($doc);
|
2008-02-14 22:15:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-16 13:32:20 +00:00
|
|
|
print $query->redirect("index.pl?error=error_no_query");
|
2008-02-14 22:15:38 +00:00
|
|
|
}
|
2007-10-11 17:26:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-02-14 22:15:38 +00:00
|
|
|
print $query->redirect("index.pl?error=error_no_query");
|
2007-10-11 14:59:55 +00:00
|
|
|
}
|