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";
|
||||
}
|
||||
|
||||
#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');
|
||||
print output_page();
|
||||
|
|
|
@ -68,11 +68,7 @@ if($query->param('id'))
|
|||
$page->{'message'}->{'type'} = "error";
|
||||
$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 XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page');
|
||||
print output_page();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -84,9 +80,5 @@ else
|
|||
$page->{'message'}->{'type'} = "error";
|
||||
$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 XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page');
|
||||
print output_page();
|
||||
}
|
||||
|
|
|
@ -132,3 +132,50 @@ sub urlencode
|
|||
$url =~ s/([^A-Za-z0-9_\$\-.+!*'()])/sprintf("%%%02X", ord($1))/eg;
|
||||
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
|
||||
CGI::Session->name($session_name);
|
||||
$query = new CGI;
|
||||
my $session = new CGI::Session;
|
||||
$session = new CGI::Session;
|
||||
|
||||
@userinfo = get_userinfo_from_sid($session->id);
|
||||
|
||||
|
@ -41,11 +41,4 @@ while (my ($text, $count) = $sth->fetchrow_array())
|
|||
#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', -charset=>'UTF-8');
|
||||
|
||||
#print xml
|
||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
||||
print output_page();
|
||||
|
|
|
@ -26,10 +26,7 @@ if($query->param('action'))
|
|||
$page->{'message'}->{'type'} = "error";
|
||||
$page->{'message'}->{'text'} = "error_already_logged_in";
|
||||
|
||||
#print xml http header along with session cookie
|
||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
||||
|
||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
||||
print output_page();
|
||||
}
|
||||
#if login is requested
|
||||
elsif($query->param('action') eq "login")
|
||||
|
@ -54,10 +51,7 @@ if($query->param('action'))
|
|||
$page->{'message'}->{'type'} = "error";
|
||||
$page->{'message'}->{'text'} = "error_username_password_do_not_match";
|
||||
|
||||
#print xml http header along with session cookie
|
||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
||||
|
||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
||||
print output_page();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -135,10 +129,7 @@ if($query->param('action'))
|
|||
#if not, print login form
|
||||
$page->{'loginform'}->{'action'} = 'openid';
|
||||
|
||||
#print xml http header along with session cookie
|
||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
||||
|
||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
||||
print output_page();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -147,10 +138,7 @@ if($query->param('action'))
|
|||
$page->{'message'}->{'type'} = "error";
|
||||
$page->{'message'}->{'text'} = "error_202c";
|
||||
|
||||
#print xml http header along with session cookie
|
||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
||||
|
||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
||||
print output_page();
|
||||
}
|
||||
}
|
||||
#check if user is logged in
|
||||
|
@ -159,18 +147,12 @@ elsif($userinfo->{'username'})
|
|||
$page->{'message'}->{'type'} = "error";
|
||||
$page->{'message'}->{'text'} = "error_already_logged_in";
|
||||
|
||||
#print xml http header along with session cookie
|
||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
||||
|
||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
||||
print output_page();
|
||||
}
|
||||
else
|
||||
{
|
||||
#if not, print login form
|
||||
$page->{'loginform'} = [''];
|
||||
|
||||
#print xml http header along with session cookie
|
||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
||||
|
||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
||||
print output_page();
|
||||
}
|
||||
|
|
|
@ -15,10 +15,7 @@ if($username)
|
|||
$page->{'message'}->{'type'} = "error";
|
||||
$page->{'message'}->{'text'} = "error_already_registered";
|
||||
|
||||
#print xml http header along with session cookie
|
||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
||||
|
||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
||||
print output_page();
|
||||
}
|
||||
#if username and password are passed put them into the database
|
||||
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'}->{'text'} = "error_passwords_do_not_match";
|
||||
|
||||
#print xml http header along with session cookie
|
||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
||||
|
||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
||||
print output_page();
|
||||
}
|
||||
}
|
||||
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'}->{'text'} = "error_insert_username";
|
||||
|
||||
#print xml http header along with session cookie
|
||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
||||
|
||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
||||
print output_page();
|
||||
}
|
||||
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'}->{'text'} = "error_insert_password";
|
||||
|
||||
#print xml http header along with session cookie
|
||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
||||
|
||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
||||
print output_page();
|
||||
}
|
||||
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'}->{'text'} = "error_repeat_password";
|
||||
|
||||
#print xml http header along with session cookie
|
||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
||||
|
||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
||||
print output_page();
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->{'registerform'} = [''];
|
||||
|
||||
#print xml http header along with session cookie
|
||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
||||
|
||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
||||
print output_page();
|
||||
}
|
||||
|
|
|
@ -103,8 +103,4 @@ else
|
|||
$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 XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
||||
print output_page();
|
||||
|
|
|
@ -89,7 +89,4 @@ else
|
|||
$page->{'message'}->{'text'} = "error_202c";
|
||||
}
|
||||
|
||||
#print xml http header along with session cookie
|
||||
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
|
||||
|
||||
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
||||
print output_page();
|
||||
|
|
|
@ -54,8 +54,5 @@ else
|
|||
$page->{'message'}->{'type'} = "error";
|
||||
$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 XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
||||
print output_page();
|
||||
|
|
|
@ -226,8 +226,4 @@ else
|
|||
$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 XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
|
||||
print output_page();
|
||||
|
|
Loading…
Reference in a new issue