Hallo Leute
Ich habe hier ein Problem mit meiner ShoutBox, die Ulmaute werden in der ShoutBox nicht korrekt ausgegeben ich bekomme bei z.B. ö = ö raus.
Habe schon alles ausprobiert, bekomme es nicht hin.
Ich nutze utf-8 als Zeichnsatz, dieser ist fest und wird im ganzen Projekt benutzt nur Perl weigert sich irgendwie
Das Script:
Und das Ajax für den Refresh usw...
Eventuell weiß ja jemand woran es liegt?
Danke!
Gruß
Belee
Ich habe hier ein Problem mit meiner ShoutBox, die Ulmaute werden in der ShoutBox nicht korrekt ausgegeben ich bekomme bei z.B. ö = ö raus.
Habe schon alles ausprobiert, bekomme es nicht hin.
Ich nutze utf-8 als Zeichnsatz, dieser ist fest und wird im ganzen Projekt benutzt nur Perl weigert sich irgendwie

Das Script:
Code:
#!/usr/bin/perl -w
$0 =~ /^(.*)[\/\\].*/ && chdir ($1) ;
use HTML::Entities ;
use CGI::Carp qw(fatalsToBrowser) ;
use strict qw(vars) ;
use CGI ;
my $query = new CGI ;
my %PARA = &shoutget() ;
if ($PARA{'func'}) {
&{$PARA{'func'}}() ;
} else {
&shoutin() ;
}
sub shoutout {
open (DAT,"< ./shoutbox.txt") || die "FILE-OPEN_ERROR : ./shoutbox.txt : $!" ;
my @data=<DAT> ;
close(DAT) ;
print $query->header(-type=>'text/html',-expires=>'Mon, 26 Jul 1997 05:00:00 GMT',-Cache-Control=>'no-store, no-cache, must-revalidate',-Cache-Control=>'post-check=0, pre-check=0',-Pragma=>'no-cache');
print reverse @data ;
}
sub shoutin {
my $sname = &shout_enc($query->param('sbname')) ;
my $stext = &shout_enc($query->param('sbtext')) ;
if ($sname && $stext) {
open (DAT,"< ./shoutbox.txt") || die "FILE-OPEN_ERROR : ./shoutbox.txt : $!" ;
flock(DAT,2) ;
my @data=<DAT> ;
close(DAT) ;
open (DAT,"> ./shoutbox.txt") || die "FILE-OPEN_ERROR : ./shoutbox.txt : $!" ;
flock(DAT,2) ;
print DAT @data[$#data-9..$#data] ;
print DAT qq(<span class="shoutname">$sname:</span> $stext<br />\n) ;
close(DAT) ;
my ($min,$hour,$mday,$mon,$year) = &shoutdate() ;
open (DAT,">> ./logs/$year$mon$mday.txt") || die "FILE-OPEN_ERROR : ./logs/$year$mon$mday.txt : $!" ;
flock(DAT,2) ;
print DAT qq($hour:$min|$query->param('sbname')|$query->param('sbtext')|$ENV{'REMOTE_ADDR'}|\n) ;
close(DAT) ;
}
print $query->header(-type=>'text/html',-expires=>'Mon, 26 Jul 1997 05:00:00 GMT',-Cache-Control=>'no-store, no-cache, must-revalidate',-Cache-Control=>'post-check=0, pre-check=0',-Pragma=>'no-cache');
print "shoutbox" ;
}
sub shout_enc {
my $enc = shift ;
$enc =~ s/[\r\n]//g ;
$enc =~ s/^\s+//g ;
$enc =~ s/\s+$//g ;
$enc =~ s/<([^>]|\n)*>//g ;
$enc = encode_entities($enc) ;
return($enc) ;
}
sub shoutget {
my %PARA ;
foreach ( split(/\&/ , $ENV{'QUERY_STRING'}) ) {
my ($feldname,$wert) = split(/=/) ;
$PARA{$feldname} = $wert ;
$PARA{$feldname} =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg ;
$PARA{$feldname} =~ tr/\+/ / ;
}
return(%PARA) ;
}
sub shoutdate {
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time) ;
$year += 1900 ;
$mon = sprintf "%02d" , $mon+1 ;
$mday = sprintf "%02d" , $mday ;
$min = sprintf "%02d" , $min ;
return ($min,$hour,$mday,$mon,$year) ;
}
Und das Ajax für den Refresh usw...
Code:
var scriptURL = '../cgi-bin/shoutbox.cgi' ;
var scriptREFRESH = 5 ;
var xmlHttp = false;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
loadShoutbox();
setInterval( "loadShoutbox()" , scriptREFRESH*1000 );
function loadShoutbox() {
if (xmlHttp) {
var timestamp = new Date().getTime() ;
xmlHttp.open('GET' , scriptURL + '?func=shoutout&nocache=' + timestamp , true) ;
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
document.getElementById("shoutbox_outputtext").innerHTML = xmlHttp.responseText ;
}
}
xmlHttp.send(null) ;
}
}
function saveShoutbox() {
if (xmlHttp) {
var timestamp = new Date().getTime() ;
xmlHttp.open('POST', scriptURL) ;
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded') ;
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
document.ShoutboxForm.shouttext.value = '' ;
if (!document.ShoutboxForm.shoutname.value) {
document.ShoutboxForm.shoutname.focus() ;
} else {
document.ShoutboxForm.shouttext.focus() ;
}
loadShoutbox() ;
}
}
xmlHttp.send('sbname='+document.ShoutboxForm.shoutname.value+'&sbtext='+document.ShoutboxForm.shouttext.value+'&nocache='+timestamp) ;
}
}
Eventuell weiß ja jemand woran es liegt?
Danke!
Gruß
Belee