Размер файла: 4.81Kb
<?php
define('_IN_JOHNCMS', 1);
$textl = 'Менеджер';
require_once ("../incfiles/core.php");
require_once ("../incfiles/head.php");
require_once ("../manager1/function.php");
echo 'Good!!!';
$championship = array('a', 'b', 'c', 'd', 'e','f', 'g', 'h');
for ($cval1 = 0; $cval1 < count($championship); $cval1++) {
$cval = $championship[$cval1];
$t = file('../manager1/cl/calendar_' . $cval . '.dat');
$stats = array();
$club_count = 0; # количество команд в лиге
for ($i = 0; $i < count($t); $i++) {
$tmp = explode('|', $t[$i]);
if ($stats[$tmp[0]]['games'] == "") {
$stats[$tmp[0]]['games'] = 0;
$stats[$tmp[0]]['points'] = 0;
$stats[$tmp[0]]['MZ'] = 0;
$stats[$tmp[0]]['MP'] = 0;
$stats[$tmp[0]]['win'] = 0;
$stats[$tmp[0]]['draw'] = 0;
$stats[$tmp[0]]['loss'] = 0;
$stats[$tmp[0]]['name'] = $tmp[0];
}
if ($stats[$tmp[1]]['games'] == "") {
$stats[$tmp[1]]['games'] = 0;
$stats[$tmp[1]]['points'] = 0;
$stats[$tmp[1]]['MZ'] = 0;
$stats[$tmp[1]]['MP'] = 0;
$stats[$tmp[1]]['win'] = 0;
$stats[$tmp[1]]['draw'] = 0;
$stats[$tmp[1]]['loss'] = 0;
$stats[$tmp[1]]['name'] = $tmp[1];
}
if ($tmp[2] !== "" && $tmp[3] !== "") {
$stats[$tmp[0]]['games'] = $stats[$tmp[0]]['games'] + 1;
$stats[$tmp[1]]['games'] = $stats[$tmp[1]]['games'] + 1;
$stats[$tmp[0]]['MZ'] = $stats[$tmp[0]]['MZ'] + $tmp[2];
$stats[$tmp[1]]['MZ'] = $stats[$tmp[1]]['MZ'] + $tmp[3];
$stats[$tmp[0]]['MP'] = $stats[$tmp[0]]['MP'] + $tmp[3];
$stats[$tmp[1]]['MP'] = $stats[$tmp[1]]['MP'] + $tmp[2];
if ($tmp[2] > $tmp[3]) {
$stats[$tmp[0]]['points'] = $stats[$tmp[0]]['points'] + 3;
$stats[$tmp[0]]['win'] = $stats[$tmp[0]]['win'] + 1;
$stats[$tmp[1]]['loss'] = $stats[$tmp[1]]['loss'] + 1;
}
if ($tmp[2] < $tmp[3]) {
$stats[$tmp[1]]['points'] = $stats[$tmp[1]]['points'] + 3;
$stats[$tmp[1]]['win'] = $stats[$tmp[1]]['win'] + 1;
$stats[$tmp[0]]['loss'] = $stats[$tmp[0]]['loss'] + 1;
}
if ($tmp[2] == $tmp[3]) {
$stats[$tmp[0]]['points'] = $stats[$tmp[0]]['points'] + 1;
$stats[$tmp[1]]['points'] = $stats[$tmp[1]]['points'] + 1;
$stats[$tmp[0]]['draw'] = $stats[$tmp[0]]['draw'] + 1;
$stats[$tmp[1]]['draw'] = $stats[$tmp[1]]['draw'] + 1;
}
}
$club_count++;
}
$club_count = (sqrt($club_count * 4 + 1) + 1) / 2;
rsort($stats);
for ($j = 0; $j <= $club_count; $j++)
for ($i = 0; $i < $club_count; $i++) {
if ($stats[$i]['points'] < $stats[$i + 1]['points']) {
$stats[100] = $stats[$i];
$stats[$i] = $stats[$i + 1];
$stats[$i + 1] = $stats[100];
unset($stats[100]);
} else
if ($stats[$i]['points'] == $stats[$i + 1]['points'] && ($stats[$i]['MZ'] - $stats[$i]['MP']) <
($stats[$i + 1]['MZ'] - $stats[$i + 1]['MP'])) {
$stats[100] = $stats[$i];
$stats[$i] = $stats[$i + 1];
$stats[$i + 1] = $stats[100];
unset($stats[100]);
}
}
$fp = fopen('../manager1/cl/' . $cval . '.dat', 'w+');
flock($fp, LOCK_EX);
ftruncate($fp, 0);
foreach ($stats as $key => $val) {
if ($val['name'] != "")
fputs($fp, $val['name'] . '|' . $val['games'] . '|' . $val['MZ'] . '|' . $val['MP'] .
'|' . $val['win'] . '|' . $val['draw'] . '|' . $val['loss'] . '|' . $val['points'] .
"|\r\n") or die("ERROR!!!");
}
fflush($fp);
flock($fp, LOCK_UN);
fclose($fp);
}
echo '[<a href="main.php">В панель управления</a>]<br/>';
require_once ("../incfiles/end.php");