replace xml::simple with xml::libxml
git-svn-id: http://yolanda.mister-muffin.de/svn@319 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
parent
bdfef043e0
commit
dfd08fd2dd
8 changed files with 473 additions and 320 deletions
|
@ -86,12 +86,5 @@ if($query->param('id'))
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@userinfo = get_userinfo_from_sid($session->id);
|
print $query->redirect("index.pl?error=error_202c");
|
||||||
|
|
||||||
@page = get_page_array(@userinfo);
|
|
||||||
|
|
||||||
$page->{'message'}->{'type'} = "error";
|
|
||||||
$page->{'message'}->{'text'} = "error_202c";
|
|
||||||
|
|
||||||
print output_page();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,18 +25,19 @@ sub get_page_array
|
||||||
{
|
{
|
||||||
#get parameters
|
#get parameters
|
||||||
my (@userinfo) = @_;
|
my (@userinfo) = @_;
|
||||||
|
|
||||||
($page->{'locale'}) = $query->http('HTTP_ACCEPT_LANGUAGE') =~ /^([^,]+),.*$/;
|
|
||||||
if (!$page->{'locale'})
|
|
||||||
{
|
|
||||||
$page->{'locale'} = "en_us";
|
|
||||||
}
|
|
||||||
|
|
||||||
$page->{'username'} = $userinfo->{'username'};
|
|
||||||
$page->{'xmlns:dc'} = $config->{"xml_namespace_dc"};
|
|
||||||
$page->{'xmlns:cc'} = $config->{"xml_namespace_cc"};
|
|
||||||
$page->{'xmlns:rdf'} = $config->{"xml_namespace_rdf"};
|
|
||||||
|
|
||||||
|
my $root = XML::LibXML::Element->new( "page" );
|
||||||
|
|
||||||
|
my ($locale) = $query->http('HTTP_ACCEPT_LANGUAGE') =~ /^([^,]+),.*$/;
|
||||||
|
$root->setAttribute( "locale", $locale ? $locale : "en_us" );
|
||||||
|
|
||||||
|
$root->setAttribute( "username", $userinfo->{'username'} );
|
||||||
|
$root->setNamespace("http://www.w3.org/1999/xhtml", "xhtml", 0);
|
||||||
|
$root->setNamespace("http://web.resource.org/cc/", "cc", 0);
|
||||||
|
$root->setNamespace("http://purl.org/dc/elements/1.1/", "dc", 0);
|
||||||
|
$root->setNamespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf", 0);
|
||||||
|
|
||||||
|
return $root;
|
||||||
}
|
}
|
||||||
|
|
||||||
# index.pl (display custom search)
|
# index.pl (display custom search)
|
||||||
|
@ -45,7 +46,9 @@ sub get_page_array
|
||||||
sub fill_results
|
sub fill_results
|
||||||
{
|
{
|
||||||
my ($dbquery, @args) = @_;
|
my ($dbquery, @args) = @_;
|
||||||
|
|
||||||
|
my $results = XML::LibXML::Element->new( "results" );
|
||||||
|
|
||||||
#prepare query
|
#prepare query
|
||||||
my $sth = $dbh->prepare($dbquery) or die $dbh->errstr;
|
my $sth = $dbh->prepare($dbquery) or die $dbh->errstr;
|
||||||
|
|
||||||
|
@ -72,10 +75,10 @@ sub fill_results
|
||||||
#execute it
|
#execute it
|
||||||
$sth->execute(@args) or die $dbquery;
|
$sth->execute(@args) or die $dbquery;
|
||||||
|
|
||||||
$page->{'results'}->{'lastpage'} = $lastpage;
|
$results->setAttribute('lastpage', $lastpage);
|
||||||
$page->{'results'}->{'currentpage'} = $currentpage;
|
$results->setAttribute('currentpage', $currentpage);
|
||||||
$page->{'results'}->{'resultcount'} = $resultcount eq '0E0' ? 0 : $resultcount;
|
$results->setAttribute('resultcount', $resultcount eq '0E0' ? 0 : $resultcount);
|
||||||
$page->{'results'}->{'pagesize'} = $pagesize;
|
$results->setAttribute('pagesize', $pagesize);
|
||||||
|
|
||||||
#get every returned value
|
#get every returned value
|
||||||
while (my ($id, $title, $description, $publisher, $timestamp, $creator,
|
while (my ($id, $title, $description, $publisher, $timestamp, $creator,
|
||||||
|
@ -83,40 +86,92 @@ sub fill_results
|
||||||
$license, $filesize, $duration, $width, $height, $fps, $viewcount,
|
$license, $filesize, $duration, $width, $height, $fps, $viewcount,
|
||||||
$downloadcount) = $sth->fetchrow_array())
|
$downloadcount) = $sth->fetchrow_array())
|
||||||
{
|
{
|
||||||
#before code cleanup, this was a really obfuscated array/hash creation
|
my $result = XML::LibXML::Element->new( "result" );
|
||||||
push @{ $page->{'results'}->{'result'} },
|
$result->setAttribute( "thumbnail", $config->{"url_root"}."/video-stills/thumbnails/$id" );
|
||||||
{
|
$result->setAttribute( "preview", $config->{"url_root"}."/video-stills/previews/$id" );
|
||||||
'thumbnail' => $config->{"url_root"}."/video-stills/thumbnails/$id",
|
$result->setAttribute( "duration", $duration );
|
||||||
'preview' => $config->{"url_root"}."/video-stills/previews/$id",
|
$result->setAttribute( "viewcount", $viewcount );
|
||||||
'duration' => $duration,
|
|
||||||
'viewcount' => $viewcount,
|
my $rdf = XML::LibXML::Element->new( "RDF" );
|
||||||
'rdf:RDF' =>
|
$rdf->setNamespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf");
|
||||||
{
|
|
||||||
'cc:Work' =>
|
my $work = XML::LibXML::Element->new( "Work" );
|
||||||
{
|
$work->setNamespace( "http://web.resource.org/cc/", "cc");
|
||||||
'rdf:about' => $config->{"url_root"}."/download/$id/",
|
$work->setNamespace( "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf", 0);
|
||||||
'dc:title' => [$title],
|
$work->setAttributeNS( "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "about", $config->{"url_root"}."/download/$id/" );
|
||||||
'dc:creator' => [$creator],
|
|
||||||
'dc:subject' => [$subject],
|
$node = XML::LibXML::Element->new( "coverage" );
|
||||||
'dc:description' => [$description],
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
'dc:publisher' => [$publisher],
|
$node->appendText($coverage);
|
||||||
'dc:date' => [$timestamp],
|
$work->appendChild($node);
|
||||||
'dc:identifier' => [$config->{"url_root"}."/video/".urlencode($title)."/$id/"],
|
|
||||||
'dc:source' => [$source],
|
$node = XML::LibXML::Element->new( "creator" );
|
||||||
'dc:language' => [$language],
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
'dc:coverage' => [$coverage],
|
$node->appendText($creator);
|
||||||
'dc:rights' => [$rights]
|
$work->appendChild($node);
|
||||||
},
|
|
||||||
'cc:License' =>
|
$node = XML::LibXML::Element->new( "date" );
|
||||||
{
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
'rdf:about' => 'http://creativecommons.org/licenses/GPL/2.0/'
|
$node->appendText($date);
|
||||||
}
|
$work->appendChild($node);
|
||||||
}
|
|
||||||
};
|
$node = XML::LibXML::Element->new( "description" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->appendText($description);
|
||||||
|
$work->appendChild($node);
|
||||||
|
|
||||||
|
$node = XML::LibXML::Element->new( "identifier" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->appendText($config->{"url_root"}."/video/".urlencode($title)."/$id/");
|
||||||
|
$work->appendChild($node);
|
||||||
|
|
||||||
|
$node = XML::LibXML::Element->new( "language" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->appendText($language);
|
||||||
|
$work->appendChild($node);
|
||||||
|
|
||||||
|
$node = XML::LibXML::Element->new( "publisher" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->appendText($publisher);
|
||||||
|
$work->appendChild($node);
|
||||||
|
|
||||||
|
$node = XML::LibXML::Element->new( "rights" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->appendText($rights);
|
||||||
|
$work->appendChild($node);
|
||||||
|
|
||||||
|
$node = XML::LibXML::Element->new( "source" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->appendText($source);
|
||||||
|
$work->appendChild($node);
|
||||||
|
|
||||||
|
$node = XML::LibXML::Element->new( "subject" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->appendText($subjcet);
|
||||||
|
$work->appendChild($node);
|
||||||
|
|
||||||
|
$node = XML::LibXML::Element->new( "title" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->appendText($title);
|
||||||
|
$work->appendChild($node);
|
||||||
|
|
||||||
|
my $license = XML::LibXML::Element->new( "License" );
|
||||||
|
$license->setNamespace("http://web.resource.org/cc/", "cc");
|
||||||
|
$license->setNamespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf", 0);
|
||||||
|
$license->setAttributeNS( "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "about", "http://creativecommons.org/licenses/GPL/2.0/" );
|
||||||
|
|
||||||
|
$rdf->appendChild($work);
|
||||||
|
$rdf->appendChild($license);
|
||||||
|
|
||||||
|
$result->appendChild($rdf);
|
||||||
|
|
||||||
|
$results->appendChild($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#finish query
|
#finish query
|
||||||
$sth->finish() or die $dbh->errstr;
|
$sth->finish() or die $dbh->errstr;
|
||||||
|
|
||||||
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_sqlquery
|
sub get_sqlquery
|
||||||
|
@ -226,6 +281,7 @@ sub urlencode
|
||||||
|
|
||||||
sub output_page
|
sub output_page
|
||||||
{
|
{
|
||||||
|
my $doc = shift;
|
||||||
my $parser = XML::LibXML->new();
|
my $parser = XML::LibXML->new();
|
||||||
my $xslt = XML::LibXSLT->new();
|
my $xslt = XML::LibXSLT->new();
|
||||||
|
|
||||||
|
@ -233,68 +289,45 @@ sub output_page
|
||||||
my $param_xslt = $query->param('xslt');
|
my $param_xslt = $query->param('xslt');
|
||||||
$param_xslt =~ s/[^\w]//gi;
|
$param_xslt =~ s/[^\w]//gi;
|
||||||
|
|
||||||
# "null" is a debuggin option, make it so that this doesn't show up in the final product
|
if( -f "$root/xsl/$param_xslt.xsl")
|
||||||
if($param_xslt eq "null")
|
|
||||||
{
|
{
|
||||||
return $session->header(
|
$xsltpath = "$root/xsl/$param_xslt.xsl"
|
||||||
-type=>'application/xml',
|
|
||||||
-charset=>'UTF-8',
|
|
||||||
),
|
|
||||||
XMLout(
|
|
||||||
$page,
|
|
||||||
KeyAttr => {},
|
|
||||||
RootName => 'page'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( -f "$root/xsl/$param_xslt.xsl")
|
$xsltpath = "$root/xsl/xhtml.xsl";
|
||||||
{
|
}
|
||||||
$xsltpath = "$root/xsl/$param_xslt.xsl"
|
|
||||||
}
|
#TODO: preload xslt stylesheet
|
||||||
else
|
my $stylesheet = $xslt->parse_stylesheet($parser->parse_file($xsltpath));
|
||||||
{
|
|
||||||
$xsltpath = "$root/xsl/xhtml.xsl";
|
|
||||||
}
|
|
||||||
|
|
||||||
my $stylesheet = $xslt->parse_stylesheet($parser->parse_file($xsltpath));
|
|
||||||
|
|
||||||
$output = $stylesheet->transform(
|
$output = $stylesheet->transform($doc);
|
||||||
$parser->parse_string(
|
|
||||||
XMLout(
|
if($param_xslt eq "xspf")
|
||||||
$page,
|
{
|
||||||
KeyAttr => {},
|
return $session->header(
|
||||||
RootName => 'page'
|
-type=>$stylesheet->media_type,
|
||||||
)
|
-charset=>$stylesheet->output_encoding,
|
||||||
)
|
-attachment=>$query->param('query').".xspf",
|
||||||
);
|
),
|
||||||
|
$output->toString;
|
||||||
if($param_xslt eq "xspf")
|
#$stylesheet->output_as_bytes($output); <= for future use with XML::LibXSLT (>= 1.62)
|
||||||
{
|
}
|
||||||
return $session->header(
|
elsif($param_xslt eq "pr0n")
|
||||||
-type=>$stylesheet->media_type,
|
{
|
||||||
-charset=>$stylesheet->output_encoding,
|
return $session->header(
|
||||||
-attachment=>$query->param('query').".xspf",
|
-status=>'402 Payment required',
|
||||||
),
|
-cost=>'$9001.00', # OVER NEIN THOUSAND
|
||||||
$output->toString;
|
)
|
||||||
#$stylesheet->output_as_bytes($output); <= for future use with XML::LibXSLT (>= 1.62)
|
}
|
||||||
}
|
else
|
||||||
elsif($param_xslt eq "pr0n")
|
{
|
||||||
{
|
return $session->header(
|
||||||
return $session->header(
|
-type=>$stylesheet->media_type,
|
||||||
-status=>'402 Payment required',
|
-charset=>$stylesheet->output_encoding,
|
||||||
-cost=>'$9001.00', # OVER NEIN THOUSAND
|
"x-pingback"=>$config->{"url_root"}."/pingback.pl"
|
||||||
)
|
),
|
||||||
}
|
print $output->toString;
|
||||||
else
|
#$stylesheet->output_as_bytes($output); <= for future use with XML::LibXSLT (>= 1.62)
|
||||||
{
|
|
||||||
return $session->header(
|
|
||||||
-type=>$stylesheet->media_type,
|
|
||||||
-charset=>$stylesheet->output_encoding,
|
|
||||||
"x-pingback"=>$config->{"url_root"}."/pingback.pl"
|
|
||||||
),
|
|
||||||
$output->toString;
|
|
||||||
#$stylesheet->output_as_bytes($output); <= for future use with XML::LibXSLT (>= 1.62)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
156
trunk/index.pl
156
trunk/index.pl
|
@ -7,29 +7,38 @@ $session = new CGI::Session;
|
||||||
|
|
||||||
@userinfo = get_userinfo_from_sid($session->id);
|
@userinfo = get_userinfo_from_sid($session->id);
|
||||||
|
|
||||||
@page = get_page_array(@userinfo);
|
my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
|
||||||
|
|
||||||
$page->{frontpage} = [''];
|
my $root = get_page_array(@userinfo);
|
||||||
|
|
||||||
|
$root->appendChild(XML::LibXML::Element->new( "frontpage" ));
|
||||||
|
|
||||||
if($query->param('information'))
|
if($query->param('information'))
|
||||||
{
|
{
|
||||||
$page->{'message'}->{'type'} = "information";
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
$page->{'message'}->{'text'} = $query->param('information');
|
$message->setAttribute("type", "information");
|
||||||
$page->{'message'}->{'value'} = $query->param('value');
|
$message->setAttribute("text", $query->param('information'));
|
||||||
|
$message->setAttribute("value",$query->param('value'));
|
||||||
|
$root->appendChild($message);
|
||||||
}
|
}
|
||||||
elsif($query->param('error'))
|
elsif($query->param('error'))
|
||||||
{
|
{
|
||||||
$page->{'message'}->{'type'} = "error";
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
$page->{'message'}->{'text'} = $query->param('error');
|
$message->setAttribute("type", "error");
|
||||||
$page->{'message'}->{'value'} = $query->param('value');
|
$message->setAttribute("text", $query->param('error'));
|
||||||
|
$message->setAttribute("value",$query->param('value'));
|
||||||
|
$root->appendChild($message);
|
||||||
}
|
}
|
||||||
elsif($query->param('warning'))
|
elsif($query->param('warning'))
|
||||||
{
|
{
|
||||||
$page->{'message'}->{'type'} = "warning";
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
$page->{'message'}->{'text'} = $query->param('warning');
|
$message->setAttribute("type", "warning");
|
||||||
$page->{'message'}->{'value'} = $query->param('value');
|
$message->setAttribute("text", $query->param('warning'));
|
||||||
|
$message->setAttribute("value",$query->param('value'));
|
||||||
|
$root->appendChild($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $tagcloud = XML::LibXML::Element->new( "tagcloud" );
|
||||||
|
|
||||||
#prepare query
|
#prepare query
|
||||||
my $sth = $dbh->prepare(qq{select text, count from tagcloud }) or die $dbh->errstr;
|
my $sth = $dbh->prepare(qq{select text, count from tagcloud }) or die $dbh->errstr;
|
||||||
|
@ -40,20 +49,25 @@ $sth->execute() or die $dbh->errstr;
|
||||||
#get every returned value
|
#get every returned value
|
||||||
while (my ($text, $count) = $sth->fetchrow_array())
|
while (my ($text, $count) = $sth->fetchrow_array())
|
||||||
{
|
{
|
||||||
#push the new value to the $page->tagcloud array
|
my $tag = XML::LibXML::Element->new( "tag" );
|
||||||
push @{ $page->{tagcloud}->{tag} }, { text => [$text =~ / / ? "\"$text\"" : $text], count => [$count] };
|
$tag->appendTextChild("text", $text);
|
||||||
|
$tag->appendTextChild("count", $count);
|
||||||
|
$tagcloud->appendChild($tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
#finish query
|
#finish query
|
||||||
$sth->finish() or die $dbh->errstr;
|
$sth->finish() or die $dbh->errstr;
|
||||||
|
|
||||||
|
$root->appendChild($tagcloud);
|
||||||
|
|
||||||
#TODO: make this configureable
|
#TODO: make this configureable
|
||||||
@querystrings = ("* orderby:timestamp sort:descending", "*", "*");
|
@querystrings = ("* orderby:timestamp sort:descending", "*", "*");
|
||||||
|
|
||||||
foreach $strquery (@querystrings)
|
foreach $strquery (@querystrings)
|
||||||
{
|
{
|
||||||
#new results block
|
#new results block
|
||||||
push @{$page->{'results'} }, { "query" => $strquery };
|
my $results = XML::LibXML::Element->new( "results" );
|
||||||
|
$results->setAttribute( "query", $strquery );
|
||||||
|
|
||||||
#get query string and args
|
#get query string and args
|
||||||
my ($dbquery, @args) = get_sqlquery($strquery);
|
my ($dbquery, @args) = get_sqlquery($strquery);
|
||||||
|
@ -71,36 +85,90 @@ foreach $strquery (@querystrings)
|
||||||
$license, $filesize, $duration, $width, $height, $fps, $viewcount,
|
$license, $filesize, $duration, $width, $height, $fps, $viewcount,
|
||||||
$downloadcount) = $sth->fetchrow_array())
|
$downloadcount) = $sth->fetchrow_array())
|
||||||
{
|
{
|
||||||
push @{$page->{'results'}[$#{$page->{'results'} }]->{'result'}},
|
my $result = XML::LibXML::Element->new( "result" );
|
||||||
{
|
$result->setAttribute( "thumbnail", $config->{"url_root"}."/video-stills/thumbnails/$id" );
|
||||||
'thumbnail' => $config->{"url_root"}."/video-stills/thumbnails/$id",
|
$result->setAttribute( "preview", $config->{"url_root"}."/video-stills/previews/$id" );
|
||||||
'preview' => $config->{"url_root"}."/video-stills/previews/$id",
|
$result->setAttribute( "duration", $duration );
|
||||||
'duration' => $duration,
|
$result->setAttribute( "viewcount", $viewcount );
|
||||||
'viewcount' => $viewcount,
|
|
||||||
'rdf:RDF' =>
|
my $rdf = XML::LibXML::Element->new( "RDF" );
|
||||||
{
|
$rdf->setNamespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf");
|
||||||
'cc:Work' =>
|
|
||||||
{
|
my $work = XML::LibXML::Element->new( "Work" );
|
||||||
'rdf:about' => $config->{"url_root"}."/download/$id/",
|
$work->setNamespace( "http://web.resource.org/cc/", "cc");
|
||||||
'dc:title' => [$title],
|
$work->setNamespace( "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf", 0);
|
||||||
'dc:creator' => [$creator],
|
$work->setAttributeNS( "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "about", $config->{"url_root"}."/download/$id/" );
|
||||||
'dc:subject' => [$subject],
|
|
||||||
'dc:description' => [$description],
|
$node = XML::LibXML::Element->new( "coverage" );
|
||||||
'dc:publisher' => [$publisher],
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
'dc:date' => [$timestamp],
|
$node->appendText($coverage);
|
||||||
'dc:identifier' => [$config->{"url_root"}."/video/".urlencode($title)."/$id/"],
|
$work->appendChild($node);
|
||||||
'dc:source' => [$source],
|
|
||||||
'dc:language' => [$language],
|
$node = XML::LibXML::Element->new( "creator" );
|
||||||
'dc:coverage' => [$coverage],
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
'dc:rights' => [$rights]
|
$node->appendText($creator);
|
||||||
},
|
$work->appendChild($node);
|
||||||
'cc:License' =>
|
|
||||||
{
|
$node = XML::LibXML::Element->new( "date" );
|
||||||
'rdf:about' => 'http://creativecommons.org/licenses/GPL/2.0/'
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
}
|
$node->appendText($date);
|
||||||
}
|
$work->appendChild($node);
|
||||||
};
|
|
||||||
|
$node = XML::LibXML::Element->new( "description" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->appendText($description);
|
||||||
|
$work->appendChild($node);
|
||||||
|
|
||||||
|
$node = XML::LibXML::Element->new( "identifier" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->appendText($config->{"url_root"}."/video/".urlencode($title)."/$id/");
|
||||||
|
$work->appendChild($node);
|
||||||
|
|
||||||
|
$node = XML::LibXML::Element->new( "language" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->appendText($language);
|
||||||
|
$work->appendChild($node);
|
||||||
|
|
||||||
|
$node = XML::LibXML::Element->new( "publisher" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->appendText($publisher);
|
||||||
|
$work->appendChild($node);
|
||||||
|
|
||||||
|
$node = XML::LibXML::Element->new( "rights" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->appendText($rights);
|
||||||
|
$work->appendChild($node);
|
||||||
|
|
||||||
|
$node = XML::LibXML::Element->new( "source" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->appendText($source);
|
||||||
|
$work->appendChild($node);
|
||||||
|
|
||||||
|
$node = XML::LibXML::Element->new( "subject" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->appendText($subjcet);
|
||||||
|
$work->appendChild($node);
|
||||||
|
|
||||||
|
$node = XML::LibXML::Element->new( "title" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->appendText($title);
|
||||||
|
$work->appendChild($node);
|
||||||
|
|
||||||
|
my $license = XML::LibXML::Element->new( "License" );
|
||||||
|
$license->setNamespace("http://web.resource.org/cc/", "cc");
|
||||||
|
$license->setNamespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf", 0);
|
||||||
|
$license->setAttributeNS( "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "about", "http://creativecommons.org/licenses/GPL/2.0/" );
|
||||||
|
|
||||||
|
$rdf->appendChild($work);
|
||||||
|
$rdf->appendChild($license);
|
||||||
|
|
||||||
|
$result->appendChild($rdf);
|
||||||
|
|
||||||
|
$results->appendChild($result);
|
||||||
}
|
}
|
||||||
|
$root->appendChild($results);
|
||||||
}
|
}
|
||||||
|
|
||||||
print output_page();
|
$doc->setDocumentElement($root);
|
||||||
|
|
||||||
|
output_page($doc);
|
||||||
|
|
|
@ -7,7 +7,9 @@ $session = new CGI::Session;
|
||||||
|
|
||||||
@userinfo = get_userinfo_from_sid($session->id);
|
@userinfo = get_userinfo_from_sid($session->id);
|
||||||
|
|
||||||
@page = get_page_array(@userinfo);
|
my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
|
||||||
|
|
||||||
|
my $root = get_page_array(@userinfo);
|
||||||
|
|
||||||
if($query->param('action') eq "logout")
|
if($query->param('action') eq "logout")
|
||||||
{
|
{
|
||||||
|
@ -20,10 +22,7 @@ if($query->param('action') eq "logout")
|
||||||
#check if user is logged in
|
#check if user is logged in
|
||||||
elsif($userinfo->{'username'})
|
elsif($userinfo->{'username'})
|
||||||
{
|
{
|
||||||
$page->{'message'}->{'type'} = "error";
|
print $query->redirect("/index.pl?error=error_already_logged_in");
|
||||||
$page->{'message'}->{'text'} = "error_already_logged_in";
|
|
||||||
|
|
||||||
print output_page();
|
|
||||||
}
|
}
|
||||||
#if password is empty and username begins with http:// then it's an openid login
|
#if password is empty and username begins with http:// then it's an openid login
|
||||||
elsif($query->param('pass') eq '' and $query->param('user')=~m/^http:\/\//)
|
elsif($query->param('pass') eq '' and $query->param('user')=~m/^http:\/\//)
|
||||||
|
@ -35,33 +34,22 @@ elsif($query->param('pass') eq '' and $query->param('user')=~m/^http:\/\//)
|
||||||
args => $query,
|
args => $query,
|
||||||
consumer_secret => $session->id, #is this save? don't know...
|
consumer_secret => $session->id, #is this save? don't know...
|
||||||
required_root => $config->{"url_root"} );
|
required_root => $config->{"url_root"} );
|
||||||
|
|
||||||
#is an openid passed?
|
#claim identity
|
||||||
if($query->param('user'))
|
$claimed = $con->claimed_identity($query->param('user'));
|
||||||
|
if(!defined($claimed))
|
||||||
{
|
{
|
||||||
#claim identity
|
print $query->redirect("/index.pl?error=error_openid_".$con->errcode);
|
||||||
$claimed = $con->claimed_identity($query->param('user'));
|
|
||||||
if(!defined($claimed))
|
|
||||||
{
|
|
||||||
print $query->redirect("/index.pl?error=error_openid_".$con->errcode);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#try to set the check_url
|
|
||||||
$check_url = $claimed->check_url(
|
|
||||||
return_to => $config->{"url_root"}."login.pl?action=openid", #on success return to this address
|
|
||||||
trust_root => $config->{"url_root"}); #this is the string the user will be asked to trust
|
|
||||||
|
|
||||||
#redirect to openid server to check claim
|
|
||||||
print $query->redirect($check_url);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if not, print login form
|
#try to set the check_url
|
||||||
$page->{'loginform'} = [''];
|
$check_url = $claimed->check_url(
|
||||||
|
return_to => $config->{"url_root"}."login.pl?action=openid", #on success return to this address
|
||||||
print output_page();
|
trust_root => $config->{"url_root"}); #this is the string the user will be asked to trust
|
||||||
|
|
||||||
|
#redirect to openid server to check claim
|
||||||
|
print $query->redirect($check_url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#we return from an identity check
|
#we return from an identity check
|
||||||
|
@ -132,17 +120,10 @@ elsif($query->param('pass') ne '' and $query->param('user')!~m/^http:\/\// and $
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if not, print error
|
print $query->redirect("index.pl?error=error_username_password_do_not_match");
|
||||||
$page->{'message'}->{'type'} = "error";
|
|
||||||
$page->{'message'}->{'text'} = "error_username_password_do_not_match";
|
|
||||||
|
|
||||||
print output_page();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if not, print login form
|
print $query->redirect("index.pl");
|
||||||
$page->{'loginform'} = [''];
|
|
||||||
|
|
||||||
print output_page();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,15 +7,21 @@ $session = new CGI::Session;
|
||||||
|
|
||||||
@userinfo = get_userinfo_from_sid($session->id);
|
@userinfo = get_userinfo_from_sid($session->id);
|
||||||
|
|
||||||
@page = get_page_array(@userinfo);
|
my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
|
||||||
|
|
||||||
|
my $root = get_page_array(@userinfo);
|
||||||
|
|
||||||
#check if user is logged in
|
#check if user is logged in
|
||||||
if($username)
|
if($username)
|
||||||
{
|
{
|
||||||
$page->{'message'}->{'type'} = "error";
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
$page->{'message'}->{'text'} = "error_already_registered";
|
$message->setAttribute("type", "error");
|
||||||
|
$message->setAttribute("text", "error_already_registered");
|
||||||
|
$root->appendChild($message);
|
||||||
|
|
||||||
print output_page();
|
$doc->setDocumentElement($root);
|
||||||
|
|
||||||
|
output_page($doc);
|
||||||
}
|
}
|
||||||
#if username and password are passed put them into the database
|
#if username and password are passed put them into the database
|
||||||
elsif($query->param('user') and $query->param('pass') and $query->param('pass_repeat'))
|
elsif($query->param('user') and $query->param('pass') and $query->param('pass_repeat'))
|
||||||
|
@ -30,11 +36,16 @@ elsif($query->param('user') and $query->param('pass') and $query->param('pass_re
|
||||||
#if something was returned the selected username already exists
|
#if something was returned the selected username already exists
|
||||||
if($sth->fetchrow_array())
|
if($sth->fetchrow_array())
|
||||||
{
|
{
|
||||||
$page->{'registerform'} = [''];
|
$root->appendChild(XML::LibXML::Element->new( "registerform" ));
|
||||||
$page->{'message'}->{'type'} = "error";
|
|
||||||
$page->{'message'}->{'text'} = "error_username_already_registered";
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
|
$message->setAttribute("type", "error");
|
||||||
print output_page();
|
$message->setAttribute("text", "error_username_already_registered");
|
||||||
|
$root->appendChild($message);
|
||||||
|
|
||||||
|
$doc->setDocumentElement($root);
|
||||||
|
|
||||||
|
output_page($doc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -47,40 +58,62 @@ elsif($query->param('user') and $query->param('pass') and $query->param('pass_re
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$page->{'registerform'} = [''];
|
$root->appendChild(XML::LibXML::Element->new( "registerform" ));
|
||||||
$page->{'message'}->{'type'} = "error";
|
|
||||||
$page->{'message'}->{'text'} = "error_passwords_do_not_match";
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
|
$message->setAttribute("type", "error");
|
||||||
print output_page();
|
$message->setAttribute("text", "error_passwords_do_not_match");
|
||||||
|
$root->appendChild($message);
|
||||||
|
|
||||||
|
$doc->setDocumentElement($root);
|
||||||
|
|
||||||
|
output_page($doc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif(not $query->param('user') and ($query->param('pass') or $query->param('pass_repeat')))
|
elsif(not $query->param('user') and ($query->param('pass') or $query->param('pass_repeat')))
|
||||||
{
|
{
|
||||||
$page->{'registerform'} = [''];
|
$root->appendChild(XML::LibXML::Element->new( "registerform" ));
|
||||||
$page->{'message'}->{'type'} = "error";
|
|
||||||
$page->{'message'}->{'text'} = "error_insert_username";
|
|
||||||
|
|
||||||
print output_page();
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
|
$message->setAttribute("type", "error");
|
||||||
|
$message->setAttribute("text", "error_insert_username");
|
||||||
|
$root->appendChild($message);
|
||||||
|
|
||||||
|
$doc->setDocumentElement($root);
|
||||||
|
|
||||||
|
output_page($doc);
|
||||||
}
|
}
|
||||||
elsif(not $query->param('pass') and ($query->param('user') or $query->param('pass_repeat')))
|
elsif(not $query->param('pass') and ($query->param('user') or $query->param('pass_repeat')))
|
||||||
{
|
{
|
||||||
$page->{'registerform'} = [''];
|
$root->appendChild(XML::LibXML::Element->new( "registerform" ));
|
||||||
$page->{'message'}->{'type'} = "error";
|
|
||||||
$page->{'message'}->{'text'} = "error_insert_password";
|
|
||||||
|
|
||||||
print output_page();
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
|
$message->setAttribute("type", "error");
|
||||||
|
$message->setAttribute("text", "error_insert_password");
|
||||||
|
$root->appendChild($message);
|
||||||
|
|
||||||
|
$doc->setDocumentElement($root);
|
||||||
|
|
||||||
|
output_page($doc);
|
||||||
}
|
}
|
||||||
elsif(not $query->param('pass_repeat') and ($query->param('user') or $query->param('pass')))
|
elsif(not $query->param('pass_repeat') and ($query->param('user') or $query->param('pass')))
|
||||||
{
|
{
|
||||||
$page->{'registerform'} = [''];
|
$root->appendChild(XML::LibXML::Element->new( "registerform" ));
|
||||||
$page->{'message'}->{'type'} = "error";
|
|
||||||
$page->{'message'}->{'text'} = "error_repeat_password";
|
|
||||||
|
|
||||||
print output_page();
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
|
$message->setAttribute("type", "error");
|
||||||
|
$message->setAttribute("text", "error_repeat_password");
|
||||||
|
$root->appendChild($message);
|
||||||
|
|
||||||
|
$doc->setDocumentElement($root);
|
||||||
|
|
||||||
|
output_page($doc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$page->{'registerform'} = [''];
|
$root->appendChild(XML::LibXML::Element->new( "registerform" ));
|
||||||
|
|
||||||
print output_page();
|
$doc->setDocumentElement($root);
|
||||||
|
|
||||||
|
output_page($doc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,30 +7,35 @@ $session = new CGI::Session;
|
||||||
|
|
||||||
@userinfo = get_userinfo_from_sid($session->id);
|
@userinfo = get_userinfo_from_sid($session->id);
|
||||||
|
|
||||||
@page = get_page_array(@userinfo);
|
my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
|
||||||
|
|
||||||
|
my $root = get_page_array(@userinfo);
|
||||||
|
|
||||||
#check if query is set
|
#check if query is set
|
||||||
if($query->param('query'))
|
if($query->param('query'))
|
||||||
{
|
{
|
||||||
$page->{'results'}->{'query'} = $query->param('query');
|
|
||||||
|
|
||||||
my ($dbquery, @args) = get_sqlquery($query->param('query'));
|
my ($dbquery, @args) = get_sqlquery($query->param('query'));
|
||||||
|
|
||||||
if($dbquery)
|
if($dbquery)
|
||||||
{
|
{
|
||||||
fill_results($dbquery, @args);
|
$root->appendChild(fill_results($dbquery, @args));
|
||||||
|
$root->setAttribute('query', $query->param('query'));
|
||||||
|
|
||||||
if(@{$page->{'results'}->{'result'}} == 0)
|
$doc->setDocumentElement($root);
|
||||||
|
|
||||||
|
my @results = $doc->findnodes( "//results/result" );
|
||||||
|
|
||||||
|
if($#results == -1)
|
||||||
{
|
{
|
||||||
print $query->redirect("index.pl?warning=warning_no_results");
|
print $query->redirect("index.pl?warning=warning_no_results");
|
||||||
}
|
}
|
||||||
elsif((@{$page->{'results'}->{'result'}} == 1) and (not $query->param('page') or $query->param('page') == 1))
|
elsif(($#results == 0) and (not $query->param('page') or $query->param('page') == 1))
|
||||||
{
|
{
|
||||||
print $query->redirect($page->{'results'}->{'result'}[0]->{'rdf:RDF'}->{'cc:Work'}->{'dc:identifier'}[0]);
|
print $query->redirect(@{$doc->findnodes( "//results/result/rdf:RDF/cc:Work/dc:identifier/text()" )}[0]->data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print output_page();
|
output_page($doc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -5,7 +5,11 @@ CGI::Session->name($config->{"page_cookie_name"});
|
||||||
$query = new CGI;
|
$query = new CGI;
|
||||||
$session = new CGI::Session;
|
$session = new CGI::Session;
|
||||||
|
|
||||||
@userinfo = get_userinfo_from_sid($session->id);
|
my @userinfo = get_userinfo_from_sid($session->id);
|
||||||
|
|
||||||
|
my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
|
||||||
|
|
||||||
|
my $root = get_page_array(@userinfo);
|
||||||
|
|
||||||
if($userinfo->{'username'})
|
if($userinfo->{'username'})
|
||||||
{
|
{
|
||||||
|
@ -13,23 +17,32 @@ if($userinfo->{'username'})
|
||||||
{
|
{
|
||||||
$dbh->do(qq{update users set pagesize = ? where id = ?}, undef, $query->param('pagesize'), $userinfo->{'id'} ) or die $dbh->errstr;
|
$dbh->do(qq{update users set pagesize = ? where id = ?}, undef, $query->param('pagesize'), $userinfo->{'id'} ) or die $dbh->errstr;
|
||||||
|
|
||||||
$page->{'message'}->{'type'} = "information";
|
@userinfo = get_userinfo_from_sid($session->id);
|
||||||
$page->{'message'}->{'text'} = "information_settings_changed";
|
|
||||||
|
$root = get_page_array(@userinfo);
|
||||||
|
|
||||||
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
|
$message->setAttribute("type", "information");
|
||||||
|
$message->setAttribute("text", "information_settings_changed");
|
||||||
|
$root->appendChild($message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@userinfo = get_userinfo_from_sid($session->id);
|
|
||||||
|
|
||||||
@page = get_page_array(@userinfo);
|
|
||||||
|
|
||||||
if($userinfo->{'username'})
|
if($userinfo->{'username'})
|
||||||
{
|
{
|
||||||
$page->{'settings'}->{'pagesize'} = $userinfo->{'pagesize'};
|
my $settings = XML::LibXML::Element->new( "settings" );
|
||||||
|
$settings->setAttribute("pagesize", $userinfo->{'pagesize'});
|
||||||
|
$root->appendChild($settings);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$page->{'message'}->{'type'} = "error";
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
$page->{'message'}->{'text'} = "error_202c";
|
$message->setAttribute("type", "error");
|
||||||
|
$message->setAttribute("text", "error_202c");
|
||||||
|
$root->appendChild($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
print output_page();
|
$doc->setDocumentElement($root);
|
||||||
|
|
||||||
|
output_page($doc);
|
||||||
|
|
189
trunk/video.pl
189
trunk/video.pl
|
@ -7,7 +7,9 @@ $session = new CGI::Session;
|
||||||
|
|
||||||
@userinfo = get_userinfo_from_sid($session->id);
|
@userinfo = get_userinfo_from_sid($session->id);
|
||||||
|
|
||||||
@page = get_page_array(@userinfo);
|
my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
|
||||||
|
|
||||||
|
my $root = get_page_array(@userinfo);
|
||||||
|
|
||||||
#check if id or title is passed
|
#check if id or title is passed
|
||||||
if($query->url_param('id'))
|
if($query->url_param('id'))
|
||||||
|
@ -52,11 +54,11 @@ if($query->url_param('id'))
|
||||||
{
|
{
|
||||||
if($query->param('embed') eq "video")
|
if($query->param('embed') eq "video")
|
||||||
{
|
{
|
||||||
$page->{'embed'} = "video";
|
$root->setAttribute( "embed", "video" );
|
||||||
}
|
}
|
||||||
elsif($query->param('embed') eq "preview")
|
elsif($query->param('embed') eq "preview")
|
||||||
{
|
{
|
||||||
$page->{'embed'} = "preview";
|
$root->setAttribute( "embed", "preview" );
|
||||||
}
|
}
|
||||||
|
|
||||||
#if there was a single result, display the video
|
#if there was a single result, display the video
|
||||||
|
@ -74,8 +76,10 @@ if($query->url_param('id'))
|
||||||
if($query->param('comment'))
|
if($query->param('comment'))
|
||||||
{
|
{
|
||||||
#output infobox
|
#output infobox
|
||||||
$page->{'message'}->{'type'} = "information";
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
$page->{'message'}->{'text'} = "information_comment_created";
|
$message->setAttribute("type", "information");
|
||||||
|
$message->setAttribute("text", "information_comment_created");
|
||||||
|
$root->appendChild($message);
|
||||||
|
|
||||||
#add to database
|
#add to database
|
||||||
$dbh->do(qq{insert into comments (userid, videoid, text, timestamp) values (?, ?, ?, unix_timestamp())}, undef,
|
$dbh->do(qq{insert into comments (userid, videoid, text, timestamp) values (?, ?, ?, unix_timestamp())}, undef,
|
||||||
|
@ -148,94 +152,117 @@ if($query->url_param('id'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#before code cleanup, this was a really obfuscated array/hash creation
|
my $video = XML::LibXML::Element->new( "video" );
|
||||||
push @{ $page->{'video'} },
|
$video->setAttribute('thumbnail', $config->{"url_root"}."/video-stills/thumbnails/$id");
|
||||||
{
|
$video->setAttribute('preview', $config->{"url_root"}."/video-stills/previews/$id");
|
||||||
'thumbnail' => $config->{"url_root"}."/video-stills/thumbnails/$id",
|
$video->setAttribute('filesize', $filesize);
|
||||||
'preview' => $config->{"url_root"}."/video-stills/previews/$id",
|
$video->setAttribute('duration', $duration);
|
||||||
'filesize' => $filesize,
|
$video->setAttribute('width', $width);
|
||||||
'duration' => $duration,
|
$video->setAttribute('height', $height);
|
||||||
'width' => $width,
|
$video->setAttribute('fps', $fps);
|
||||||
'height' => $height,
|
$video->setAttribute('viewcount', $viewcount);
|
||||||
'fps' => $fps,
|
$video->setAttribute('downloadcount', $downloadcount);
|
||||||
'viewcount' => $viewcount,
|
|
||||||
'downloadcount' => $downloadcount,
|
my $rdf = XML::LibXML::Element->new( "RDF" );
|
||||||
'rdf:RDF' =>
|
$rdf->setNamespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf");
|
||||||
{
|
|
||||||
'cc:Work' =>
|
my $work = XML::LibXML::Element->new( "Work" );
|
||||||
{
|
$work->setNamespace( "http://web.resource.org/cc/", "cc");
|
||||||
'rdf:about' => $config->{"url_root"}."/download/$id/",
|
$work->setNamespace( "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf", 0);
|
||||||
'dc:title' => [$title],
|
$work->setAttributeNS( "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "about", $config->{"url_root"}."/download/$id/" );
|
||||||
'dc:creator' => [$creator],
|
|
||||||
'dc:subject' => [$subject],
|
$node = XML::LibXML::Element->new( "coverage" );
|
||||||
'dc:description' => [$description],
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
'dc:publisher' => [$publisher],
|
$node->appendText($coverage);
|
||||||
'dc:date' => [$timestamp],
|
$work->appendChild($node);
|
||||||
'dc:identifier' => [$config->{"url_root"}."/video/".urlencode($title)."/$id/"],
|
|
||||||
'dc:source' => [$source],
|
$node = XML::LibXML::Element->new( "creator" );
|
||||||
'dc:language' => [$language],
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
'dc:coverage' => [$coverage],
|
$node->appendText($creator);
|
||||||
'dc:rights' => [$rights]
|
$work->appendChild($node);
|
||||||
},
|
|
||||||
'cc:License' =>
|
$node = XML::LibXML::Element->new( "date" );
|
||||||
{
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
'rdf:about' => $license,
|
$node->appendText($date);
|
||||||
# ↓↓ dummy code because josch is too lazy for DOIN IT RITE ↓↓
|
$work->appendChild($node);
|
||||||
'cc:permits' =>
|
|
||||||
{
|
$node = XML::LibXML::Element->new( "description" );
|
||||||
'rdf:resource' => "http://web.resource.org/cc/Reproduction"
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
},
|
$node->appendText($description);
|
||||||
'cc:permits' =>
|
$work->appendChild($node);
|
||||||
{
|
|
||||||
'rdf:resource' => "http://web.resource.org/cc/Distribution"
|
$node = XML::LibXML::Element->new( "identifier" );
|
||||||
},
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
'cc:permits' =>
|
$node->appendText($config->{"url_root"}."/video/".urlencode($title)."/$id/");
|
||||||
{
|
$work->appendChild($node);
|
||||||
'rdf:resource' => "http://web.resource.org/cc/DerivativeWorks"
|
|
||||||
},
|
$node = XML::LibXML::Element->new( "language" );
|
||||||
'cc:requires' =>
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
{
|
$node->appendText($language);
|
||||||
'rdf:resource' => "http://web.resource.org/cc/Notice"
|
$work->appendChild($node);
|
||||||
},
|
|
||||||
'cc:requires' =>
|
$node = XML::LibXML::Element->new( "publisher" );
|
||||||
{
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
'rdf:resource' => "http://web.resource.org/cc/ShareAlike"
|
$node->appendText($publisher);
|
||||||
},
|
$work->appendChild($node);
|
||||||
'cc:prohibits' =>
|
|
||||||
{
|
$node = XML::LibXML::Element->new( "rights" );
|
||||||
'rdf:resource' => "http://web.resource.org/cc/CommercialUse"
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
},
|
$node->appendText($rights);
|
||||||
'cc:prohibits' =>
|
$work->appendChild($node);
|
||||||
{
|
|
||||||
'rdf:resource' => "http://web.resource.org/cc/DerivativeWorks"
|
$node = XML::LibXML::Element->new( "source" );
|
||||||
}
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
# ↑↑ dummy code because josch is too lazy for DOIN IT RITE ↑↑
|
$node->appendText($source);
|
||||||
# sadly, i dunno how to add multiple tags with the same name
|
$work->appendChild($node);
|
||||||
}
|
|
||||||
}
|
$node = XML::LibXML::Element->new( "subject" );
|
||||||
};
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->appendText($subjcet);
|
||||||
|
$work->appendChild($node);
|
||||||
|
|
||||||
|
$node = XML::LibXML::Element->new( "title" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->appendText($title);
|
||||||
|
$work->appendChild($node);
|
||||||
|
|
||||||
|
my $license = XML::LibXML::Element->new( "License" );
|
||||||
|
$license->setNamespace("http://web.resource.org/cc/", "cc");
|
||||||
|
$license->setNamespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf", 0);
|
||||||
|
$license->setAttributeNS( "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "about", "http://creativecommons.org/licenses/GPL/2.0/" );
|
||||||
|
|
||||||
|
$rdf->appendChild($work);
|
||||||
|
$rdf->appendChild($license);
|
||||||
|
|
||||||
|
$video->appendChild($rdf);
|
||||||
|
|
||||||
|
$root->appendChild($video);
|
||||||
|
|
||||||
#get comments
|
#get comments
|
||||||
|
my $comments = XML::LibXML::Element->new( "comments" );
|
||||||
|
|
||||||
$sth = $dbh->prepare(qq{select comments.id, comments.text, users.username, from_unixtime( comments.timestamp )
|
$sth = $dbh->prepare(qq{select comments.id, comments.text, users.username, from_unixtime( comments.timestamp )
|
||||||
from comments, users where
|
from comments, users where
|
||||||
comments.videoid=? and users.id=comments.userid}) or die $dbh->errstr;
|
comments.videoid=? and users.id=comments.userid}) or die $dbh->errstr;
|
||||||
$sth->execute($id) or die $dbh->errstr;
|
$sth->execute($id) or die $dbh->errstr;
|
||||||
while (my ($commentid, $text, $username, $timestamp) = $sth->fetchrow_array())
|
while (my ($commentid, $text, $username, $timestamp) = $sth->fetchrow_array())
|
||||||
{
|
{
|
||||||
push @{ $page->{'comments'}->{'comment'} }, {
|
my $comment = XML::LibXML::Element->new( "comment" );
|
||||||
'text' => [$text],
|
$comment->setAttribute('username', $username);
|
||||||
'username' => $username,
|
$comment->setAttribute('timestamp', $timestamp);
|
||||||
'timestamp' => $timestamp,
|
$comment->setAttribute('id', $commentid);
|
||||||
'id' => $commentid
|
$comment->appendTextChild("text", $text);
|
||||||
};
|
$comments->appendChild($comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
print output_page();
|
$root->appendChild($comments);
|
||||||
|
|
||||||
|
$doc->setDocumentElement($root);
|
||||||
|
|
||||||
|
output_page($doc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$page->{'message'}->{'type'} = "error";
|
print $query->redirect("index.pl?error=error_202c");
|
||||||
$page->{'message'}->{'text'} = "error_202c";
|
|
||||||
print output_page();
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue