to jest moja strona
<?
function file_GetLine ($filename, $index) {
$file = fopen ($filename, "r");
$line = -1;
while (!feof ($file)) {
$buffer = fgets($file, 4096);
$line++;
if ($line == $index) {
fclose ($file);
return $buffer;
}
}
fclose ($file);
}
function file_InsertLine ($filename, $line) {
$fp = fopen ($filename, "a");
flock($fp, LOCK_EX);
fputs ($fp, $line . "rn");
flock($fp, LOCK_UN);
fclose ($fp);
}
function file_ReadFromFile ($filename) {
$fp = fopen ($filename, "r");
$file = fread($fp, filesize ($filename));
fclose ($fp);
return $file;
}
function Voted() {
$votes = file('poll.txt');
for($q=0;$q<count($votes);$q++) {
$vote = explode('`', $votes[$q]);
if ($_SERVER['REMOTE_ADDR'] == $vote[1]) {
return 1;
}
}
return 0;
}
function GetA($index) {
return file_GetLine('poll_a.txt', $index);
}
echo(file_ReadFromFile('poll_q.txt') . '
');
$as = file('poll_a.txt');
$voted = Voted();
if($voted == 1) {
$votes = file('poll.txt');
for($q=0;$q<count($votes);$q++) {
$vote = explode('`', $votes[$q]);
$w = $vote[0];
$v[$w]++;
}
for ($q=0;$q $value) {
if ($value > $max) { $max = $value; }
}
if ($max < 25) { $e = 2; }
if ($max < 10) { $e = 4; }
if ($max < 5) { $e = 10; }
foreach($v as $key => $value) {
echo(GetA($key) . ' - ' . $value . '
');
$width = $value * $e;
if ($width > 50) { $width = 50; }
echo('
');
}
} else {
echo('');
}
?>
Darmowy hosting zapewnia PRV.PL