halli hallo,
hab nen php highscore script.
Die gewinner sollen sich mit ihrer E-Mail adresse eintragen. Leider ist dieses sonderzeichen aber nicht möglich. was mach ich falsch.
Bitte hilft mir, grüße technics
<?php
$name_max = 50;
$display_max = 100;
function error_msg($msg) {
exit("success=0&errorMsg=$msg");
}
@$player_name = $HTTP_POST_VARS['name'];
@$player_score = $HTTP_POST_VARS['score'];
@$game_name = $HTTP_POST_VARS['game'];
if (!isset($game_name)) error_msg('Kein Zugriff auf den Highscore möglich.');
$filename = 'tetris_highscores.txt';
if (isset($player_score) && is_numeric($player_score) && isset($player_name) && strlen($player_name) > 0 && strlen($player_name) <= $name_max) {
$file = fopen($filename, 'r+') or error_msg('Highscore konnte nicht geladen werden.');
if (flock($file, LOCK_EX | LOCK_NB)) {
$content = fread($file, filesize($filename));
$newline = '';
$ranked = false;
$i = 1;
$pairs = explode('&', $content);
foreach ($pairs as $pair) {
@list($nm, $val) = explode('=', $pair);
if ($i <= $display_max && strlen($val) > 0) {
if (substr($nm, 0, 4) == 'name') $this_name = $val;
else {
$this_score = $val;
if (!$ranked && ((int)$player_score) > ((int)$this_score)) {
$newline .= "&name$i=$player_name&score$i=$player_score";
$ranked = true;
$i++;
}
$newline .= "&name$i=$this_name&score$i=$this_score";
$i++;
}
}
}
if (strlen($newline) > 0) {
ftruncate($file, 0);
rewind($file);
fwrite($file, $newline) or error_msg('Highscore konnte nicht gespeichert werden.');
}
echo 'success=1&errorMsg=OK&maxScore=' . $display_max . $newline;
}
else error_msg('Highscore konnte nicht gespeichert werden.');
fclose($file);
}
else {
@$file = fopen($filename, 'r') or error_msg('Highscore konnte nicht geladen werden.');
$content = fread($file, filesize($filename));
echo 'success=1&errorMsg=OK&maxScore=' . $display_max . $content;
fclose($file);
}
?>
hab nen php highscore script.
Die gewinner sollen sich mit ihrer E-Mail adresse eintragen. Leider ist dieses sonderzeichen aber nicht möglich. was mach ich falsch.
Bitte hilft mir, grüße technics
<?php
$name_max = 50;
$display_max = 100;
function error_msg($msg) {
exit("success=0&errorMsg=$msg");
}
@$player_name = $HTTP_POST_VARS['name'];
@$player_score = $HTTP_POST_VARS['score'];
@$game_name = $HTTP_POST_VARS['game'];
if (!isset($game_name)) error_msg('Kein Zugriff auf den Highscore möglich.');
$filename = 'tetris_highscores.txt';
if (isset($player_score) && is_numeric($player_score) && isset($player_name) && strlen($player_name) > 0 && strlen($player_name) <= $name_max) {
$file = fopen($filename, 'r+') or error_msg('Highscore konnte nicht geladen werden.');
if (flock($file, LOCK_EX | LOCK_NB)) {
$content = fread($file, filesize($filename));
$newline = '';
$ranked = false;
$i = 1;
$pairs = explode('&', $content);
foreach ($pairs as $pair) {
@list($nm, $val) = explode('=', $pair);
if ($i <= $display_max && strlen($val) > 0) {
if (substr($nm, 0, 4) == 'name') $this_name = $val;
else {
$this_score = $val;
if (!$ranked && ((int)$player_score) > ((int)$this_score)) {
$newline .= "&name$i=$player_name&score$i=$player_score";
$ranked = true;
$i++;
}
$newline .= "&name$i=$this_name&score$i=$this_score";
$i++;
}
}
}
if (strlen($newline) > 0) {
ftruncate($file, 0);
rewind($file);
fwrite($file, $newline) or error_msg('Highscore konnte nicht gespeichert werden.');
}
echo 'success=1&errorMsg=OK&maxScore=' . $display_max . $newline;
}
else error_msg('Highscore konnte nicht gespeichert werden.');
fclose($file);
}
else {
@$file = fopen($filename, 'r') or error_msg('Highscore konnte nicht geladen werden.');
$content = fread($file, filesize($filename));
echo 'success=1&errorMsg=OK&maxScore=' . $display_max . $content;
fclose($file);
}
?>
Kommentar