enabled xhtml comments
git-svn-id: http://yolanda.mister-muffin.de/svn@321 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
parent
8d9a158957
commit
6c172e1057
8 changed files with 145 additions and 123 deletions
|
@ -26,18 +26,18 @@ sub get_page_array
|
||||||
#get parameters
|
#get parameters
|
||||||
my (@userinfo) = @_;
|
my (@userinfo) = @_;
|
||||||
|
|
||||||
my $root = XML::LibXML::Element->new( "page" );
|
my $page = XML::LibXML::Element->new( "page" );
|
||||||
|
|
||||||
my ($locale) = $query->http('HTTP_ACCEPT_LANGUAGE') =~ /^([^,]+),.*$/;
|
my ($locale) = $query->http('HTTP_ACCEPT_LANGUAGE') =~ /^([^,]+),.*$/;
|
||||||
$root->setAttribute( "locale", $locale ? $locale : "en_us" );
|
$page->setAttribute( "locale", $locale ? $locale : "en_us" );
|
||||||
|
|
||||||
$root->setAttribute( "username", $userinfo->{'username'} );
|
$page->setAttribute( "username", $userinfo->{'username'} );
|
||||||
$root->setNamespace("http://www.w3.org/1999/xhtml", "xhtml", 0);
|
$page->setNamespace("http://www.w3.org/1999/xhtml", "xhtml", 0);
|
||||||
$root->setNamespace("http://web.resource.org/cc/", "cc", 0);
|
$page->setNamespace("http://web.resource.org/cc/", "cc", 0);
|
||||||
$root->setNamespace("http://purl.org/dc/elements/1.1/", "dc", 0);
|
$page->setNamespace("http://purl.org/dc/elements/1.1/", "dc", 0);
|
||||||
$root->setNamespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf", 0);
|
$page->setNamespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf", 0);
|
||||||
|
|
||||||
return $root;
|
return $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
# index.pl (display custom search)
|
# index.pl (display custom search)
|
||||||
|
|
|
@ -9,9 +9,9 @@ $session = new CGI::Session;
|
||||||
|
|
||||||
my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
|
my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
|
||||||
|
|
||||||
my $root = get_page_array(@userinfo);
|
my $page = get_page_array(@userinfo);
|
||||||
|
|
||||||
$root->appendChild(XML::LibXML::Element->new( "frontpage" ));
|
$page->appendChild(XML::LibXML::Element->new( "frontpage" ));
|
||||||
|
|
||||||
if($query->param('information'))
|
if($query->param('information'))
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ if($query->param('information'))
|
||||||
$message->setAttribute("type", "information");
|
$message->setAttribute("type", "information");
|
||||||
$message->setAttribute("text", $query->param('information'));
|
$message->setAttribute("text", $query->param('information'));
|
||||||
$message->setAttribute("value",$query->param('value'));
|
$message->setAttribute("value",$query->param('value'));
|
||||||
$root->appendChild($message);
|
$page->appendChild($message);
|
||||||
}
|
}
|
||||||
elsif($query->param('error'))
|
elsif($query->param('error'))
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ elsif($query->param('error'))
|
||||||
$message->setAttribute("type", "error");
|
$message->setAttribute("type", "error");
|
||||||
$message->setAttribute("text", $query->param('error'));
|
$message->setAttribute("text", $query->param('error'));
|
||||||
$message->setAttribute("value",$query->param('value'));
|
$message->setAttribute("value",$query->param('value'));
|
||||||
$root->appendChild($message);
|
$page->appendChild($message);
|
||||||
}
|
}
|
||||||
elsif($query->param('warning'))
|
elsif($query->param('warning'))
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,7 @@ elsif($query->param('warning'))
|
||||||
$message->setAttribute("type", "warning");
|
$message->setAttribute("type", "warning");
|
||||||
$message->setAttribute("text", $query->param('warning'));
|
$message->setAttribute("text", $query->param('warning'));
|
||||||
$message->setAttribute("value",$query->param('value'));
|
$message->setAttribute("value",$query->param('value'));
|
||||||
$root->appendChild($message);
|
$page->appendChild($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
my $tagcloud = XML::LibXML::Element->new( "tagcloud" );
|
my $tagcloud = XML::LibXML::Element->new( "tagcloud" );
|
||||||
|
@ -58,7 +58,7 @@ while (my ($text, $count) = $sth->fetchrow_array())
|
||||||
#finish query
|
#finish query
|
||||||
$sth->finish() or die $dbh->errstr;
|
$sth->finish() or die $dbh->errstr;
|
||||||
|
|
||||||
$root->appendChild($tagcloud);
|
$page->appendChild($tagcloud);
|
||||||
|
|
||||||
foreach $strquery ($config->{"search_frontpage_one_query"}, $config->{"search_frontpage_two_query"}, $config->{"search_frontpage_three_query"})
|
foreach $strquery ($config->{"search_frontpage_one_query"}, $config->{"search_frontpage_two_query"}, $config->{"search_frontpage_three_query"})
|
||||||
{
|
{
|
||||||
|
@ -163,9 +163,9 @@ foreach $strquery ($config->{"search_frontpage_one_query"}, $config->{"search_fr
|
||||||
|
|
||||||
$results->appendChild($result);
|
$results->appendChild($result);
|
||||||
}
|
}
|
||||||
$root->appendChild($results);
|
$page->appendChild($results);
|
||||||
}
|
}
|
||||||
|
|
||||||
$doc->setDocumentElement($root);
|
$doc->setDocumentElement($page);
|
||||||
|
|
||||||
output_page($doc);
|
output_page($doc);
|
||||||
|
|
|
@ -7,9 +7,7 @@ $session = new CGI::Session;
|
||||||
|
|
||||||
@userinfo = get_userinfo_from_sid($session->id);
|
@userinfo = get_userinfo_from_sid($session->id);
|
||||||
|
|
||||||
my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
|
#TODO: use $query->http("HTTP_REFERER"); to redirect to the site last visited
|
||||||
|
|
||||||
my $root = get_page_array(@userinfo);
|
|
||||||
|
|
||||||
if($query->param('action') eq "logout")
|
if($query->param('action') eq "logout")
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ $session = new CGI::Session;
|
||||||
|
|
||||||
my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
|
my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
|
||||||
|
|
||||||
my $root = get_page_array(@userinfo);
|
my $page = get_page_array(@userinfo);
|
||||||
|
|
||||||
#check if user is logged in
|
#check if user is logged in
|
||||||
if($username)
|
if($username)
|
||||||
|
@ -17,9 +17,9 @@ if($username)
|
||||||
my $message = XML::LibXML::Element->new( "message" );
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
$message->setAttribute("type", "error");
|
$message->setAttribute("type", "error");
|
||||||
$message->setAttribute("text", "error_already_registered");
|
$message->setAttribute("text", "error_already_registered");
|
||||||
$root->appendChild($message);
|
$page->appendChild($message);
|
||||||
|
|
||||||
$doc->setDocumentElement($root);
|
$doc->setDocumentElement($page);
|
||||||
|
|
||||||
output_page($doc);
|
output_page($doc);
|
||||||
}
|
}
|
||||||
|
@ -36,14 +36,14 @@ 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())
|
||||||
{
|
{
|
||||||
$root->appendChild(XML::LibXML::Element->new( "registerform" ));
|
$page->appendChild(XML::LibXML::Element->new( "registerform" ));
|
||||||
|
|
||||||
my $message = XML::LibXML::Element->new( "message" );
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
$message->setAttribute("type", "error");
|
$message->setAttribute("type", "error");
|
||||||
$message->setAttribute("text", "error_username_already_registered");
|
$message->setAttribute("text", "error_username_already_registered");
|
||||||
$root->appendChild($message);
|
$page->appendChild($message);
|
||||||
|
|
||||||
$doc->setDocumentElement($root);
|
$doc->setDocumentElement($page);
|
||||||
|
|
||||||
output_page($doc);
|
output_page($doc);
|
||||||
}
|
}
|
||||||
|
@ -58,62 +58,62 @@ elsif($query->param('user') and $query->param('pass') and $query->param('pass_re
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$root->appendChild(XML::LibXML::Element->new( "registerform" ));
|
$page->appendChild(XML::LibXML::Element->new( "registerform" ));
|
||||||
|
|
||||||
my $message = XML::LibXML::Element->new( "message" );
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
$message->setAttribute("type", "error");
|
$message->setAttribute("type", "error");
|
||||||
$message->setAttribute("text", "error_passwords_do_not_match");
|
$message->setAttribute("text", "error_passwords_do_not_match");
|
||||||
$root->appendChild($message);
|
$page->appendChild($message);
|
||||||
|
|
||||||
$doc->setDocumentElement($root);
|
$doc->setDocumentElement($page);
|
||||||
|
|
||||||
output_page($doc);
|
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')))
|
||||||
{
|
{
|
||||||
$root->appendChild(XML::LibXML::Element->new( "registerform" ));
|
$page->appendChild(XML::LibXML::Element->new( "registerform" ));
|
||||||
|
|
||||||
my $message = XML::LibXML::Element->new( "message" );
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
$message->setAttribute("type", "error");
|
$message->setAttribute("type", "error");
|
||||||
$message->setAttribute("text", "error_insert_username");
|
$message->setAttribute("text", "error_insert_username");
|
||||||
$root->appendChild($message);
|
$page->appendChild($message);
|
||||||
|
|
||||||
$doc->setDocumentElement($root);
|
$doc->setDocumentElement($page);
|
||||||
|
|
||||||
output_page($doc);
|
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')))
|
||||||
{
|
{
|
||||||
$root->appendChild(XML::LibXML::Element->new( "registerform" ));
|
$page->appendChild(XML::LibXML::Element->new( "registerform" ));
|
||||||
|
|
||||||
my $message = XML::LibXML::Element->new( "message" );
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
$message->setAttribute("type", "error");
|
$message->setAttribute("type", "error");
|
||||||
$message->setAttribute("text", "error_insert_password");
|
$message->setAttribute("text", "error_insert_password");
|
||||||
$root->appendChild($message);
|
$page->appendChild($message);
|
||||||
|
|
||||||
$doc->setDocumentElement($root);
|
$doc->setDocumentElement($page);
|
||||||
|
|
||||||
output_page($doc);
|
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')))
|
||||||
{
|
{
|
||||||
$root->appendChild(XML::LibXML::Element->new( "registerform" ));
|
$page->appendChild(XML::LibXML::Element->new( "registerform" ));
|
||||||
|
|
||||||
my $message = XML::LibXML::Element->new( "message" );
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
$message->setAttribute("type", "error");
|
$message->setAttribute("type", "error");
|
||||||
$message->setAttribute("text", "error_repeat_password");
|
$message->setAttribute("text", "error_repeat_password");
|
||||||
$root->appendChild($message);
|
$page->appendChild($message);
|
||||||
|
|
||||||
$doc->setDocumentElement($root);
|
$doc->setDocumentElement($page);
|
||||||
|
|
||||||
output_page($doc);
|
output_page($doc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$root->appendChild(XML::LibXML::Element->new( "registerform" ));
|
$page->appendChild(XML::LibXML::Element->new( "registerform" ));
|
||||||
|
|
||||||
$doc->setDocumentElement($root);
|
$doc->setDocumentElement($page);
|
||||||
|
|
||||||
output_page($doc);
|
output_page($doc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ $session = new CGI::Session;
|
||||||
|
|
||||||
my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
|
my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
|
||||||
|
|
||||||
my $root = get_page_array(@userinfo);
|
my $page = get_page_array(@userinfo);
|
||||||
|
|
||||||
#check if query is set
|
#check if query is set
|
||||||
if($query->param('query'))
|
if($query->param('query'))
|
||||||
|
@ -18,10 +18,10 @@ if($query->param('query'))
|
||||||
|
|
||||||
if($dbquery)
|
if($dbquery)
|
||||||
{
|
{
|
||||||
$root->appendChild(fill_results($dbquery, @args));
|
$page->appendChild(fill_results($dbquery, @args));
|
||||||
$root->setAttribute('query', $query->param('query'));
|
$page->setAttribute('query', $query->param('query'));
|
||||||
|
|
||||||
$doc->setDocumentElement($root);
|
$doc->setDocumentElement($page);
|
||||||
|
|
||||||
my @results = $doc->findnodes( "//results/result" );
|
my @results = $doc->findnodes( "//results/result" );
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ my @userinfo = get_userinfo_from_sid($session->id);
|
||||||
|
|
||||||
my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
|
my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
|
||||||
|
|
||||||
my $root = get_page_array(@userinfo);
|
my $page = get_page_array(@userinfo);
|
||||||
|
|
||||||
if($userinfo->{'username'})
|
if($userinfo->{'username'})
|
||||||
{
|
{
|
||||||
|
@ -19,12 +19,12 @@ if($userinfo->{'username'})
|
||||||
|
|
||||||
@userinfo = get_userinfo_from_sid($session->id);
|
@userinfo = get_userinfo_from_sid($session->id);
|
||||||
|
|
||||||
$root = get_page_array(@userinfo);
|
$page = get_page_array(@userinfo);
|
||||||
|
|
||||||
my $message = XML::LibXML::Element->new( "message" );
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
$message->setAttribute("type", "information");
|
$message->setAttribute("type", "information");
|
||||||
$message->setAttribute("text", "information_settings_changed");
|
$message->setAttribute("text", "information_settings_changed");
|
||||||
$root->appendChild($message);
|
$page->appendChild($message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,16 +33,16 @@ if($userinfo->{'username'})
|
||||||
{
|
{
|
||||||
my $settings = XML::LibXML::Element->new( "settings" );
|
my $settings = XML::LibXML::Element->new( "settings" );
|
||||||
$settings->setAttribute("pagesize", $userinfo->{'pagesize'});
|
$settings->setAttribute("pagesize", $userinfo->{'pagesize'});
|
||||||
$root->appendChild($settings);
|
$page->appendChild($settings);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
my $message = XML::LibXML::Element->new( "message" );
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
$message->setAttribute("type", "error");
|
$message->setAttribute("type", "error");
|
||||||
$message->setAttribute("text", "error_202c");
|
$message->setAttribute("text", "error_202c");
|
||||||
$root->appendChild($message);
|
$page->appendChild($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
$doc->setDocumentElement($root);
|
$doc->setDocumentElement($page);
|
||||||
|
|
||||||
output_page($doc);
|
output_page($doc);
|
||||||
|
|
166
trunk/video.pl
166
trunk/video.pl
|
@ -9,7 +9,7 @@ $session = new CGI::Session;
|
||||||
|
|
||||||
my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
|
my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
|
||||||
|
|
||||||
my $root = get_page_array(@userinfo);
|
my $page = 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'))
|
||||||
|
@ -54,11 +54,11 @@ if($query->url_param('id'))
|
||||||
{
|
{
|
||||||
if($query->param('embed') eq "video")
|
if($query->param('embed') eq "video")
|
||||||
{
|
{
|
||||||
$root->setAttribute( "embed", "video" );
|
$page->setAttribute( "embed", "video" );
|
||||||
}
|
}
|
||||||
elsif($query->param('embed') eq "preview")
|
elsif($query->param('embed') eq "preview")
|
||||||
{
|
{
|
||||||
$root->setAttribute( "embed", "preview" );
|
$page->setAttribute( "embed", "preview" );
|
||||||
}
|
}
|
||||||
|
|
||||||
#if there was a single result, display the video
|
#if there was a single result, display the video
|
||||||
|
@ -75,78 +75,97 @@ if($query->url_param('id'))
|
||||||
#check if a comment is about to be created
|
#check if a comment is about to be created
|
||||||
if($query->param('comment'))
|
if($query->param('comment'))
|
||||||
{
|
{
|
||||||
#output infobox
|
my $dtd = XML::LibXML::Dtd->new(0, "$root/site/comment.dtd");
|
||||||
my $message = XML::LibXML::Element->new( "message" );
|
$dom = XML::LibXML->new;
|
||||||
$message->setAttribute("type", "information");
|
$dom->clean_namespaces(1);
|
||||||
$message->setAttribute("text", "information_comment_created");
|
eval { $doc = $dom->parse_string("<comment>".$query->param('comment')."</comment>") };
|
||||||
$root->appendChild($message);
|
if ($@)
|
||||||
|
|
||||||
#add to database
|
|
||||||
$dbh->do(qq{insert into comments (userid, videoid, text, timestamp) values (?, ?, ?, unix_timestamp())}, undef,
|
|
||||||
$userinfo->{'id'}, $id, $query->param('comment')) or die $dbh->errstr;
|
|
||||||
|
|
||||||
#send pingbacks to every url in the comment
|
|
||||||
my (@matches) = $query->param('comment') =~ /(http:\/\/\S+)/gi;
|
|
||||||
foreach $match (@matches)
|
|
||||||
{
|
{
|
||||||
#ask for http header only - if pingbacks are implemented right, then we wont need the full site
|
die $@;
|
||||||
my $request = HTTP::Request->new(HEAD => $match);
|
}
|
||||||
my $ua = LWP::UserAgent->new;
|
else
|
||||||
|
{
|
||||||
my $response = $ua->request($request);
|
eval { $doc->validate($dtd) };
|
||||||
|
if ($@)
|
||||||
if ($response->is_success)
|
|
||||||
{
|
{
|
||||||
my $pingbackurl = $response->header("x-pingback");
|
die $@;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#output infobox
|
||||||
|
my $message = XML::LibXML::Element->new( "message" );
|
||||||
|
$message->setAttribute("type", "information");
|
||||||
|
$message->setAttribute("text", "information_comment_created");
|
||||||
|
$page->appendChild($message);
|
||||||
|
|
||||||
#if there was no x-pingback header, fetch the website and search for link element
|
#add to database
|
||||||
if (!$pingbackurl)
|
$dbh->do(qq{insert into comments (userid, videoid, text, timestamp) values (?, ?, ?, unix_timestamp())}, undef,
|
||||||
|
$userinfo->{'id'}, $id, $query->param('comment')) or die $dbh->errstr;
|
||||||
|
|
||||||
|
#send pingbacks to every url in the comment
|
||||||
|
my (@matches) = $query->param('comment') =~ /<a[^>]+href="(http:\/\/\S+)"[^>]*>.+?<\/a>/gi;
|
||||||
|
foreach $match (@matches)
|
||||||
{
|
{
|
||||||
$request = HTTP::Request->new(GET => $match);
|
#ask for http header only - if pingbacks are implemented right, then we wont need the full site
|
||||||
$response = $ua->request($request);
|
my $request = HTTP::Request->new(HEAD => $match);
|
||||||
|
my $ua = LWP::UserAgent->new;
|
||||||
|
|
||||||
|
my $response = $ua->request($request);
|
||||||
|
|
||||||
if ($response->is_success)
|
if ($response->is_success)
|
||||||
{
|
{
|
||||||
($pingbackurl) = $response->content =~ /<link rel="pingback" href="([^"]+)" ?\/?>/;
|
my $pingbackurl = $response->header("x-pingback");
|
||||||
|
|
||||||
|
#if there was no x-pingback header, fetch the website and search for link element
|
||||||
|
if (!$pingbackurl)
|
||||||
|
{
|
||||||
|
$request = HTTP::Request->new(GET => $match);
|
||||||
|
$response = $ua->request($request);
|
||||||
|
|
||||||
|
if ($response->is_success)
|
||||||
|
{
|
||||||
|
($pingbackurl) = $response->content =~ /<link rel="pingback" href="([^"]+)" ?\/?>/;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if requests were successful, send the pingbacks
|
||||||
|
if ($pingbackurl)
|
||||||
|
{
|
||||||
|
#TODO: expand xml entities < > & " in $pingbackurl
|
||||||
|
|
||||||
|
#contruct the xml-rpc request
|
||||||
|
my $xmlpost = ();
|
||||||
|
$xmlpost->{"methodName"} = ["pingback.ping"];
|
||||||
|
push @{$xmlpost->{'params'}->{'param'} },
|
||||||
|
{
|
||||||
|
"value" =>
|
||||||
|
{
|
||||||
|
"string" => [$config->{"url_root"}."/video/".urlencode($title)."/$id/"]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
push @{$xmlpost->{'params'}->{'param'} },
|
||||||
|
{
|
||||||
|
"value" =>
|
||||||
|
{
|
||||||
|
"string" => [$match]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#post a xml-rpc request
|
||||||
|
$request = HTTP::Request->new(POST => $pingbackurl);
|
||||||
|
$request->header('Content-Type' => "application/xml");
|
||||||
|
$request->content(XMLout(
|
||||||
|
$xmlpost,
|
||||||
|
XMLDecl => 1,
|
||||||
|
KeyAttr => {},
|
||||||
|
RootName => 'methodCall'
|
||||||
|
));
|
||||||
|
$ua = LWP::UserAgent->new;
|
||||||
|
$response = $ua->request($request);
|
||||||
|
#TODO: maybe do something on success?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if requests were successful, send the pingbacks
|
|
||||||
if ($pingbackurl)
|
|
||||||
{
|
|
||||||
#TODO: expand xml entities < > & " in $pingbackurl
|
|
||||||
|
|
||||||
#contruct the xml-rpc request
|
|
||||||
my $xmlpost = ();
|
|
||||||
$xmlpost->{"methodName"} = ["pingback.ping"];
|
|
||||||
push @{$xmlpost->{'params'}->{'param'} },
|
|
||||||
{
|
|
||||||
"value" =>
|
|
||||||
{
|
|
||||||
"string" => [$config->{"url_root"}."/video/".urlencode($title)."/$id/"]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
push @{$xmlpost->{'params'}->{'param'} },
|
|
||||||
{
|
|
||||||
"value" =>
|
|
||||||
{
|
|
||||||
"string" => [$match]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#post a xml-rpc request
|
|
||||||
$request = HTTP::Request->new(POST => $pingbackurl);
|
|
||||||
$request->header('Content-Type' => "application/xml");
|
|
||||||
$request->content(XMLout(
|
|
||||||
$xmlpost,
|
|
||||||
XMLDecl => 1,
|
|
||||||
KeyAttr => {},
|
|
||||||
RootName => 'methodCall'
|
|
||||||
));
|
|
||||||
$ua = LWP::UserAgent->new;
|
|
||||||
$response = $ua->request($request);
|
|
||||||
#TODO: maybe do something on success?
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -236,7 +255,7 @@ if($query->url_param('id'))
|
||||||
|
|
||||||
$video->appendChild($rdf);
|
$video->appendChild($rdf);
|
||||||
|
|
||||||
$root->appendChild($video);
|
$page->appendChild($video);
|
||||||
|
|
||||||
#get comments
|
#get comments
|
||||||
my $comments = XML::LibXML::Element->new( "comments" );
|
my $comments = XML::LibXML::Element->new( "comments" );
|
||||||
|
@ -247,17 +266,22 @@ if($query->url_param('id'))
|
||||||
$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())
|
||||||
{
|
{
|
||||||
my $comment = XML::LibXML::Element->new( "comment" );
|
my $dom = XML::LibXML->new;
|
||||||
|
my $doc = $dom->parse_string("<comment>".$text."</comment>");
|
||||||
|
my $comment = $doc->documentElement();
|
||||||
|
foreach $node ($comment->getElementsByTagName("*"))
|
||||||
|
{
|
||||||
|
$node->setNamespace("http://www.w3.org/1999/xhtml", "xhtml");
|
||||||
|
}
|
||||||
$comment->setAttribute('username', $username);
|
$comment->setAttribute('username', $username);
|
||||||
$comment->setAttribute('timestamp', $timestamp);
|
$comment->setAttribute('timestamp', $timestamp);
|
||||||
$comment->setAttribute('id', $commentid);
|
$comment->setAttribute('id', $commentid);
|
||||||
$comment->appendTextChild("text", $text);
|
|
||||||
$comments->appendChild($comment);
|
$comments->appendChild($comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
$root->appendChild($comments);
|
$page->appendChild($comments);
|
||||||
|
|
||||||
$doc->setDocumentElement($root);
|
$doc->setDocumentElement($page);
|
||||||
|
|
||||||
output_page($doc);
|
output_page($doc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,10 +90,10 @@
|
||||||
<!--
|
<!--
|
||||||
comment system is broken (similar to the german online petition system)
|
comment system is broken (similar to the german online petition system)
|
||||||
if a video ever gets OVER NEIN THOUSAND comments, the shit hits the fan
|
if a video ever gets OVER NEIN THOUSAND comments, the shit hits the fan
|
||||||
|
-->
|
||||||
<xsl:call-template name="commentform"/>
|
<xsl:call-template name="commentform"/>
|
||||||
<xsl:call-template name="comments"/>
|
<xsl:call-template name="comments"/>
|
||||||
-->
|
|
||||||
|
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@
|
||||||
<xsl:value-of select="@username" />
|
<xsl:value-of select="@username" />
|
||||||
</a>:
|
</a>:
|
||||||
<br />
|
<br />
|
||||||
<xsl:value-of select="." />
|
<xsl:copy-of select="." />
|
||||||
</div>
|
</div>
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue