So schwer ist das doch nicht,
PHP-Code:
<?php
function mywrite($file, $towrite, $mode, $cacheit=0, $cr=1, $recht=0644)
{
$config['basedir'] = './';
$set_chmod = 0;
if(stristr($file,"./"))
{
$config['basedir'] = "";
}
if(!file_exists($file))
{
$set_chmod = 1;
}
$fp = fopen($config['basedir'].$file,$mode.'b') or die("fopen file error...!");
flock($fp,LOCK_EX);
if(!is_array($towrite))
{
if($cr == 1)
{
$towrite = trim($towrite)."\n";
}
fwrite($fp,$towrite);
}
else
{
foreach($towrite as $element)
{
if($cr == 1)
{
$element = trim($element)."\n";
}
fwrite($fp,$element);
}
}
flock($fp,LOCK_UN); fclose($fp);
if($set_chmod == 1)
{
@chmod($config['basedir'].$file, $recht);
}
if($cacheit == 1)
{
unset($_SESSION['cache']['files'][$file]);
$_SESSION['cache']['files'][$file] = @file($config['basedir'].$file);
}
}
function writehead()
{
global $config;
echo '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset='.$config['header_char_set'].'">
<title>'.$config['header'].'</title>
</head>
<body>';
}
function writefooter()
{
echo '
</body>
</html>';
}
/*
*
* Kurze Definition einiger Inhalte
* Und Los geht`s
*
*/
$dateiinhalt = "1\t".time();
$config['header_char_set'] = 'utf-8';
$config['header'] = 'Klickcounter 2 Teams';
// Ausgabe HTML-Kopf
writehead();
// Werte in Datei schreiben, wenn ein Button gedrückt wurde
if(isset($_POST['teama']) and ($_POST['teama'] != ''))
{
mywrite("tmp/teama", $dateiinhalt, 'a');
}
if(isset($_POST['teamb']) and ($_POST['teamb'] != ''))
{
mywrite("tmp/teamb", $dateiinhalt, 'a');
}
// Daten aus bestehenden Dateien auslesen
$punkteA = array();
$punkteB = array();
if(file_exists("tmp/teama"))
{
$punkteA = file("tmp/teama");
}
if(file_exists("tmp/teamb"))
{
$punkteB = file("tmp/teamb");
}
// Formular Buttons beschriften
$valA = "Team-A: ".array_sum($punkteA);
$valB = "Team-B: ".array_sum($punkteB);
// Formular ausgeben
?>
<form method="POST" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>">
<input type="submit" name="teama" value="<?php echo $valA; ?>"> <input type="submit" name="teamb" value="<?php echo $valB; ?>">
</form>
<?php
// HTML schliessen
writefooter();
Eventuellen Ballast musst du selber aus den Funktionen fuddeln, ich habe sie nur kurz mit Copy/Paste übernommen.