Hallo,
ich habe ein Moorhennespiel auf meine Homepage
gestellt, dass den Highscore speichern soll.
es läuft bei einem Freund, der 150 MB Webspace
mit CGI bei Strato hat.
Allerdings speichert es irgendwie nicht.
Ich poste es einfach mal, vielleicht entdeckt ihr
ja den Fehler (Oder liegt es am Strato Account?):
Aufruf des Speicher CGI-Scripts:
------------- schnipp ---------------------
<html>
<HEAD><meta http-equiv="expires" content="0">
<meta name="robots" content="NOINDEX,NOFOLLOW">
<title>Moorhenne - www.BernhardHoffmann.de</title>
<!-- Ein kleines Breakoutspiel. www.BernhardHoffmann.de - Webmaster@BernhardHoffmann.de -->
<style type="text/css">
<!--
BODY { FONT-FAMILY: arial,sans-serif }
A:hover {color:green}
-->
</style>
</Head>
<body bgcolor="#f4f4f4" link="blue" text="black" vlink="blue" alink="green">
<font size="6" color="#000080" face="Arial, Helvetica, sans-serif">Moorhenne</font><br>
<br>
<br>
<br>
<APPLET code="moorhenne.class" width=400 height=250 MAYSCRIPT>
<param name="highscore" value="true">
<param name=hurl value="high.txt">
<param name=hcgi value="high.pl">
Sorry ! Kein Java !
</applet>
------------- schnipp ---------------------
Das Speichercgi selbst, gespeichert als
"High.pl":
------------- schnipp ---------------------
#!/usr/local/bin/perl
##########################################################
# #
# Moorhenne-Highscore CGI: 1.5 #
# Last Modified: 22.Apr.00 #
# Written By: Thomas Pfeifer #
# http://thopf.purespace.de/start.htm #
# #
##########################################################
# #
Please read liesmich.txt / readme.txt first !
# #
##########################################################
# #
Re-distribution of this program is strictly prohibited
without the written consent of Thomas Pfeifer.
# #
##########################################################
#========================================
# V A R I A B L E S T O E D I T
Check the Perl-path at the top
Perl-Pfad am Anfang überprüfen
(evtl. Server Administator fragen !)
The file that hold the Highscores
The directory must be chmoded to read/write(644)
Die Datei welche die Highscores speichert
Auch hier evtl. Server-Administrator fragen
$highfile="high.txt";
logfile
Die Log-Datei
$logfile="log.txt";
#========================================
CGI-lib needed
use CGI param,referer,remote_host,request_method,user_agent;
$anz=50;
$score=param("score");
$name=param("name");
$time=param("fps");
$ref=param("ref");
$ver=param("v");
($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
if ($sec < 10) { $sec = "0$sec"; }
if ($min < 10) { $min = "0$min"; }
if ($hour < 10) { $hour = "0$hour"; }
if ($mday < 10) { $mday = "0$mday"; }
$year += 1900;
$date = ($mday+1).".".($mon+1).".".($year)." ".$hour.":".$min.":".$sec;
$log=$date.",".request_method().",".remote_host().",".referer().",".user_agent().",".$score.",".$name.",".$time.",".$ref.",".$ver;
Simple HTTP-Header
print "Content-type: text/plain\n\n";
get Highscores
open (HIGH,"$highfile") || ($log.="\nError open: $highfile");
@lines=<HIGH>;
close(HIGH);
cut returns
chomp(@lines);
POST Variables and Version Check
if ($score>0 && $name && $time && $ver>=127 && $score<800) {
# generate Hash
$namelen=length($name);
$hash=0;
for ($i=0;$i<$namelen;$i++) {
$hash+=ord(substr($name,$i,1))-$i;
}
# encode hash
$hash=$hash^$score^1828;
#test Hash
$_=$name;
#forbidden names
#i dont like URLs in my Highscore
if(/www/i || /.de/i || /.com/i || /.net/i || /.to/i || /sex/i || /porn/i || /fick/i || /fuck/i || /.vu/i || /.ch/i || /.at/i) {
$log.="\nbad name: $_";
} else {
if ($hash==$time) {
#put in the score
$n=-1;
for ($i=0;$i<$anz*2;$i+=2) {
if ($lines[$i+1]<=0) {
$lines[$i]="nobody";
$lines[$i+1]="0";
}
if ($lines[$i] eq $name && $lines[$i+1]==$score) {
$n=-2;
$log.="\ninList";
}
if ($score>=$lines[$i+1] && $n==-1) {
$n=$i;
}
}
if ($n>=0) {
splice @lines,$n,0,$score;
splice @lines,$n,0,$name;
}
open (OUT,">$highfile") || ($log.="\nError write $highfile");
for ($i=0;$i<$anz*2;$i++) {
print OUT "$lines[$i]\n";
}
close(OUT);
} else {
$log.="\nwrong hash: $time $hash";
}
}
} else {
$log.="\nheader error";
}
print out the Scores
for ($i=0;$i<$anz*2;$i++) {
print "$lines[$i]\n";
}
write and print log
open (LOG,">>$logfile") || print STDERR "\nError write $logfile : $log";
print LOG "$log\n";
close (LOG);
print $log;
------------- schnipp ---------------------
Danke mal im Voraus.
MfG TheWinner
selfhtmlforum1@schallmauerstreicher.de