added browser sniffing to parse xml to xhtml server side
git-svn-id: http://yolanda.mister-muffin.de/svn@202 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
parent
52ba4dadb1
commit
980f33fc1f
11 changed files with 69 additions and 91 deletions
|
@ -98,8 +98,4 @@ else
|
||||||
$page->{'message'}->{'text'} = "error_202c";
|
$page->{'message'}->{'text'} = "error_202c";
|
||||||
}
|
}
|
||||||
|
|
||||||
#print xml http header along with session cookie
|
print output_page();
|
||||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
|
||||||
|
|
||||||
#print xml
|
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
|
||||||
|
|
|
@ -68,11 +68,7 @@ if($query->param('id'))
|
||||||
$page->{'message'}->{'type'} = "error";
|
$page->{'message'}->{'type'} = "error";
|
||||||
$page->{'message'}->{'text'} = "error_202c";
|
$page->{'message'}->{'text'} = "error_202c";
|
||||||
|
|
||||||
#print xml http header along with session cookie
|
print output_page();
|
||||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
|
||||||
|
|
||||||
#print xml
|
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -84,9 +80,5 @@ else
|
||||||
$page->{'message'}->{'type'} = "error";
|
$page->{'message'}->{'type'} = "error";
|
||||||
$page->{'message'}->{'text'} = "error_202c";
|
$page->{'message'}->{'text'} = "error_202c";
|
||||||
|
|
||||||
#print xml http header along with session cookie
|
print output_page();
|
||||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
|
||||||
|
|
||||||
#print xml
|
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page');
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,3 +132,50 @@ sub urlencode
|
||||||
$url =~ s/([^A-Za-z0-9_\$\-.+!*'()])/sprintf("%%%02X", ord($1))/eg;
|
$url =~ s/([^A-Za-z0-9_\$\-.+!*'()])/sprintf("%%%02X", ord($1))/eg;
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub output_page
|
||||||
|
{
|
||||||
|
if($query->http('USER_AGENT') =~ m{(Firefox/[2-3]|MSIE [6-7]|yolanda-upload)})
|
||||||
|
{
|
||||||
|
#print xml
|
||||||
|
return $session->header(
|
||||||
|
-type=>'text/xml',
|
||||||
|
-charset=>'UTF-8'
|
||||||
|
),
|
||||||
|
XMLout(
|
||||||
|
$page,
|
||||||
|
KeyAttr => {},
|
||||||
|
XMLDecl => $XMLDecl,
|
||||||
|
RootName => 'page',
|
||||||
|
AttrIndent => '1'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
use XML::LibXSLT;
|
||||||
|
use XML::LibXML;
|
||||||
|
|
||||||
|
my $parser = XML::LibXML->new();
|
||||||
|
my $xslt = XML::LibXSLT->new();
|
||||||
|
|
||||||
|
my $stylesheet = $xslt->parse_stylesheet($parser->parse_file("$root/xsl/xhtml.xsl"));
|
||||||
|
|
||||||
|
return $session->header(
|
||||||
|
-type=>'text/xml',
|
||||||
|
-charset=>'UTF-8'
|
||||||
|
),
|
||||||
|
$stylesheet->output_string(
|
||||||
|
$stylesheet->transform(
|
||||||
|
$parser->parse_string(
|
||||||
|
XMLout(
|
||||||
|
$page,
|
||||||
|
KeyAttr => {},
|
||||||
|
XMLDecl => $XMLDecl,
|
||||||
|
RootName => 'page',
|
||||||
|
AttrIndent => '1'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ require "functions.pl";
|
||||||
#create or resume session
|
#create or resume session
|
||||||
CGI::Session->name($session_name);
|
CGI::Session->name($session_name);
|
||||||
$query = new CGI;
|
$query = new CGI;
|
||||||
my $session = new CGI::Session;
|
$session = new CGI::Session;
|
||||||
|
|
||||||
@userinfo = get_userinfo_from_sid($session->id);
|
@userinfo = get_userinfo_from_sid($session->id);
|
||||||
|
|
||||||
|
@ -41,11 +41,4 @@ while (my ($text, $count) = $sth->fetchrow_array())
|
||||||
#finish query
|
#finish query
|
||||||
$sth->finish() or die $dbh->errstr;
|
$sth->finish() or die $dbh->errstr;
|
||||||
|
|
||||||
#close db
|
print output_page();
|
||||||
$dbh->disconnect() or die $dbh->errstr;
|
|
||||||
|
|
||||||
#print xml http header along with session cookie
|
|
||||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
|
||||||
|
|
||||||
#print xml
|
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
|
||||||
|
|
|
@ -26,10 +26,7 @@ if($query->param('action'))
|
||||||
$page->{'message'}->{'type'} = "error";
|
$page->{'message'}->{'type'} = "error";
|
||||||
$page->{'message'}->{'text'} = "error_already_logged_in";
|
$page->{'message'}->{'text'} = "error_already_logged_in";
|
||||||
|
|
||||||
#print xml http header along with session cookie
|
print output_page();
|
||||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
|
||||||
|
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
|
||||||
}
|
}
|
||||||
#if login is requested
|
#if login is requested
|
||||||
elsif($query->param('action') eq "login")
|
elsif($query->param('action') eq "login")
|
||||||
|
@ -54,10 +51,7 @@ if($query->param('action'))
|
||||||
$page->{'message'}->{'type'} = "error";
|
$page->{'message'}->{'type'} = "error";
|
||||||
$page->{'message'}->{'text'} = "error_username_password_do_not_match";
|
$page->{'message'}->{'text'} = "error_username_password_do_not_match";
|
||||||
|
|
||||||
#print xml http header along with session cookie
|
print output_page();
|
||||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
|
||||||
|
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -135,10 +129,7 @@ if($query->param('action'))
|
||||||
#if not, print login form
|
#if not, print login form
|
||||||
$page->{'loginform'}->{'action'} = 'openid';
|
$page->{'loginform'}->{'action'} = 'openid';
|
||||||
|
|
||||||
#print xml http header along with session cookie
|
print output_page();
|
||||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
|
||||||
|
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -147,10 +138,7 @@ if($query->param('action'))
|
||||||
$page->{'message'}->{'type'} = "error";
|
$page->{'message'}->{'type'} = "error";
|
||||||
$page->{'message'}->{'text'} = "error_202c";
|
$page->{'message'}->{'text'} = "error_202c";
|
||||||
|
|
||||||
#print xml http header along with session cookie
|
print output_page();
|
||||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
|
||||||
|
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#check if user is logged in
|
#check if user is logged in
|
||||||
|
@ -159,18 +147,12 @@ elsif($userinfo->{'username'})
|
||||||
$page->{'message'}->{'type'} = "error";
|
$page->{'message'}->{'type'} = "error";
|
||||||
$page->{'message'}->{'text'} = "error_already_logged_in";
|
$page->{'message'}->{'text'} = "error_already_logged_in";
|
||||||
|
|
||||||
#print xml http header along with session cookie
|
print output_page();
|
||||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
|
||||||
|
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if not, print login form
|
#if not, print login form
|
||||||
$page->{'loginform'} = [''];
|
$page->{'loginform'} = [''];
|
||||||
|
|
||||||
#print xml http header along with session cookie
|
print output_page();
|
||||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
|
||||||
|
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,10 +15,7 @@ if($username)
|
||||||
$page->{'message'}->{'type'} = "error";
|
$page->{'message'}->{'type'} = "error";
|
||||||
$page->{'message'}->{'text'} = "error_already_registered";
|
$page->{'message'}->{'text'} = "error_already_registered";
|
||||||
|
|
||||||
#print xml http header along with session cookie
|
print output_page();
|
||||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
|
||||||
|
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
|
||||||
}
|
}
|
||||||
#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'))
|
||||||
|
@ -37,10 +34,7 @@ elsif($query->param('user') and $query->param('pass') and $query->param('pass_re
|
||||||
$page->{'message'}->{'type'} = "error";
|
$page->{'message'}->{'type'} = "error";
|
||||||
$page->{'message'}->{'text'} = "error_passwords_do_not_match";
|
$page->{'message'}->{'text'} = "error_passwords_do_not_match";
|
||||||
|
|
||||||
#print xml http header along with session cookie
|
print output_page();
|
||||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
|
||||||
|
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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')))
|
||||||
|
@ -49,10 +43,7 @@ elsif(not $query->param('user') and ($query->param('pass') or $query->param('pas
|
||||||
$page->{'message'}->{'type'} = "error";
|
$page->{'message'}->{'type'} = "error";
|
||||||
$page->{'message'}->{'text'} = "error_insert_username";
|
$page->{'message'}->{'text'} = "error_insert_username";
|
||||||
|
|
||||||
#print xml http header along with session cookie
|
print output_page();
|
||||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
|
||||||
|
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
|
||||||
}
|
}
|
||||||
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')))
|
||||||
{
|
{
|
||||||
|
@ -60,10 +51,7 @@ elsif(not $query->param('pass') and ($query->param('user') or $query->param('pas
|
||||||
$page->{'message'}->{'type'} = "error";
|
$page->{'message'}->{'type'} = "error";
|
||||||
$page->{'message'}->{'text'} = "error_insert_password";
|
$page->{'message'}->{'text'} = "error_insert_password";
|
||||||
|
|
||||||
#print xml http header along with session cookie
|
print output_page();
|
||||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
|
||||||
|
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
|
||||||
}
|
}
|
||||||
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')))
|
||||||
{
|
{
|
||||||
|
@ -71,17 +59,11 @@ elsif(not $query->param('pass_repeat') and ($query->param('user') or $query->par
|
||||||
$page->{'message'}->{'type'} = "error";
|
$page->{'message'}->{'type'} = "error";
|
||||||
$page->{'message'}->{'text'} = "error_repeat_password";
|
$page->{'message'}->{'text'} = "error_repeat_password";
|
||||||
|
|
||||||
#print xml http header along with session cookie
|
print output_page();
|
||||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
|
||||||
|
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$page->{'registerform'} = [''];
|
$page->{'registerform'} = [''];
|
||||||
|
|
||||||
#print xml http header along with session cookie
|
print output_page();
|
||||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
|
||||||
|
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,8 +103,4 @@ else
|
||||||
$page->{'message'}->{'text'} = "error_202c";
|
$page->{'message'}->{'text'} = "error_202c";
|
||||||
}
|
}
|
||||||
|
|
||||||
#print xml http header along with session cookie
|
print output_page();
|
||||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
|
||||||
|
|
||||||
#print xml
|
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
|
||||||
|
|
|
@ -89,7 +89,4 @@ else
|
||||||
$page->{'message'}->{'text'} = "error_202c";
|
$page->{'message'}->{'text'} = "error_202c";
|
||||||
}
|
}
|
||||||
|
|
||||||
#print xml http header along with session cookie
|
print output_page();
|
||||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
|
||||||
|
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
|
||||||
|
|
|
@ -54,8 +54,5 @@ else
|
||||||
$page->{'message'}->{'type'} = "error";
|
$page->{'message'}->{'type'} = "error";
|
||||||
$page->{'message'}->{'text'} = "error_202c";
|
$page->{'message'}->{'text'} = "error_202c";
|
||||||
}
|
}
|
||||||
#print xml http header along with session cookie
|
|
||||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
|
||||||
|
|
||||||
#print xml
|
print output_page();
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
|
||||||
|
|
|
@ -226,8 +226,4 @@ else
|
||||||
$page->{'message'}->{'text'} = "error_202c";
|
$page->{'message'}->{'text'} = "error_202c";
|
||||||
}
|
}
|
||||||
|
|
||||||
#print xml http header along with session cookie
|
print output_page();
|
||||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
|
||||||
|
|
||||||
#print xml
|
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
|
||||||
|
|
Loading…
Reference in a new issue