View file manager1/tov.php

File size: 45.67Kb
<?php
/*
////////////////////////////////////////////////////////////////////////////////
//                  Футбольный менеджер  для  JohnCMS                         //
//                             Модификация                                    //
////////////////////////////////////////////////////////////////////////////////
// Anubis(Юрий) (379-619-623)           - [email protected]                //
//                             Wap site - http://mobisports.ru                //
////////////////////////////////////////////////////////////////////////////////
*/
define('_IN_JOHNCMS', 1);
$textl = 'Менеджер';
require_once ("../incfiles/core.php");
require_once ("../incfiles/head.php");

if (!$user_id) {
    echo '<div class="rmenu"><p>Доступ в менеджер открыт только <a href="../login.php">авторизованным</a> посетителям</p></div>';
    require_once ("../incfiles/end.php");
    exit;
}
echo '<div class="phdr"><center>Тов. матчи</center></div><br/>';

    ########
        //Вставляю список команд и лигу
    require_once ("team.php");
    ################

    if (!isset($act) || $act == "") {
        echo '[<a href="tov.php?act=mne">Предложения мне</a>]';
        $file = file("tp.dat");
        $k = 0;
        for ($i = 0; $i < count($file); $i++) {
            $ex = explode("|", $file[$i]);
            if ($ex[1] == $club) {
                $k = $k + 1;
            }
        }

        echo '[' . $k . ']<br/>';
        echo '[<a href="tov.php?act=go">Сделать предложение</a>]<br/>';

        echo '[<a href="tov.php?act=moi">Мои предложения</a>]';
        $file = file("tp.dat");
        $k = 0;
        for ($i = 0; $i < count($file); $i++) {
            $ex = explode("|", $file[$i]);
            if ($ex[0] == $club) {
                $k = $k + 1;
            }
        }

        echo '[' . $k . ']<br/>';
        echo '[<a href="tov.php?act=my">Мои тов. игры</a>]';
        $file = file("tov.dat");
        $k = 0;
        for ($i = 0; $i < count($file); $i++) {
            $ex = explode("|", $file[$i]);
            if ($ex[0] == $club || $ex[1] == $club) {
                $k = $k + 1;
            }
        }

        echo '[' . $k . ']<br/>';
        echo '[<a href="tov.php?act=all">Все тов. игры</a>]';
        $file = file("tov.dat");
        $k = count($file);
        echo '[' . $k . ']<br/>';
    }

    if ($act == "mne") {
        $file = file("tp.dat");
        for ($i = 0; $i < count($file); $i++) {
            $ex = explode("|", $file[$i]);
            if ($ex[1] == $club) {
                echo $ex[0] . '[<a href="?act=mneyes&amp;one=' . $ex[0] . '&amp;two=' . $ex[1] .
                    '">Прин.</a>]';

                echo '[<a href="?act=mneno&amp;one=' . $ex[0] . '&amp;two=' . $ex[1] .
                    '">Откл.</a>]<br/>';

            }
        }
        echo '<br/>[<a href="tov.php">Назад</a>]<br/>';
    }

    if ($act == "mneyes") {
        $one = htmlspecialchars($_GET['one']);
        $one = trim($one);
        $one = substr($one, 0, 20);
        $two = htmlspecialchars($_GET['two']);
        $two = trim($two);
        $two = substr($two, 0, 20);


        $str = file_get_contents("tp.dat");
        if (ereg($one . '\|' . $two . '\|', $str)) {
            $file = file("tp.dat");
            foreach ($file as $k => $v) {
                $ex = explode("|", $v);
                if ($ex[0] == $one && $ex[1] == $two) {


                    $sq1 = file("$ex[2]/$one.dat");
                    $suma = array();
                    $sumax = array();
                    for ($k = 0; $k <= 10; $k++) {
                        $eee = explode("|", $sq1[$k]);
                        $eee[3] = (int)$eee[3];
                        $eee[4] = (int)$eee[4];
                        $eee[5] = (int)$eee[5];
                        $eee[6] = (int)$eee[6];
                        $eee[7] = (int)$eee[7];
                        $eee[8] = (int)$eee[8];
                        $suma[$k] = $eee[3] + $eee[4] + $eee[5] + $eee[6] + $eee[7] + $eee[8];

                    }
                    $xxx1 = $suma[0] + $suma[1] + $suma[2] + $suma[3] + $suma[4] + $suma[5] + $suma[6] +
                        $suma[7] + $suma[8] + $suma[9] + $suma[10];
                    $sq2 = file("$ex[3]/$two.dat");
                    for ($g = 0; $g <= 10; $g++) {
                        $eee = explode("|", $sq2[$g]);
                        $eee[3] = (int)$eee[3];
                        $eee[4] = (int)$eee[4];
                        $eee[5] = (int)$eee[5];
                        $eee[6] = (int)$eee[6];
                        $eee[7] = (int)$eee[7];
                        $eee[8] = (int)$eee[8];
                        $sumax[$g] = $eee[3] + $eee[4] + $eee[5] + $eee[6] + $eee[7] + $eee[8];
                    }
                    $xxx2 = $sumax[0] + $sumax[1] + $sumax[2] + $sumax[3] + $sumax[4] + $sumax[5] +
                        $sumax[6] + $sumax[7] + $sumax[8] + $sumax[9] + $sumax[10];
                    echo '    ';


                    $s1 = file("$ex[2]/$one.txt");
                    $hhh = explode("|", $s1[0]);
                    $hhh[3] = (int)$hhh[3];
                    $hhh[4] = (int)$hhh[4];
                    $hhh[6] = (int)$hhh[6];
                    $hhh[9] = (int)$hhh[9];
                    $suka1 = $hhh[3] + $hhh[4] + $hhh[6] + $hhh[9];


                    $s2 = file("$ex[3]/$two.txt");
                    $hhh = explode("|", $s2[0]);
                    $hhh[3] = (int)$hhh[3];
                    $hhh[4] = (int)$hhh[4];
                    $hhh[6] = (int)$hhh[6];
                    $hhh[9] = (int)$hhh[9];
                    $suka2 = $hhh[3] + $hhh[4] + $hhh[6] + $hhh[9];


                    $k1 = "0";
                    $k2 = "0";


                    if ($xxx1 > $xxx2) {
                        $k1 = "1";
                    } else {
                        $k2 = "1";
                    }


                    $arr = array("1:0", "2:0", "3:0", "2:1", "3:1", "3:2");
                    $arr2 = array("0:1", "0:2", "0:3", "1:2", "1:3", "2:3");


                    ###---
                    if ($k1 == "1" && $k2 == "0") {
                        $r = rand(0, 5);
                        echo '<br/>' . $one . ' vs ' . $two . ' ' . $arr[$r] . '<br/>';
                        if ($arr[$r] == "1:0") {
                            $fi1 = file("$ex[2]/$one.dat");
                            $raa1 = rand(8, 10);
                            $x = explode("|", $fi1[$raa1]);
                            echo 'Голы: ' . $x[0] . '<br/>';
                            $sq = file("tp.dat");

                            for ($i = 0; $i < count($sq); $i++) {
                                if (ereg($one . '\|' . $two . '\|', $sq[$i])) {
                                    $num = $i;
                                }
                            }
                            $new = $sq[$num];
                            unset($sq[$num]);

                            $fp = fopen("tp.dat", "a+");
                            flock($fp, LOCK_EX);
                            ftruncate($fp, 0);
                            for ($i = 0; $i <= count($sq); $i++) {
                                fputs($fp, $sq[$i]);
                            }
                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                            echo '[<a href="tov.php">Назад</a>]<br/>';
                            $fp = fopen("tov.dat", "a+");
                            flock($fp, LOCK_EX);

                            fputs($fp, $one . "|" . $two . "|" . $arr[$r] . "|" . $x[0] . "|" . "\r\n");

                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);

                        }
                        if ($arr[$r] == "2:0") {
                            $fi1 = file("$ex[2]/$one.dat");
                            $raa1 = rand(8, 10);
                            $raa2 = rand(8, 10);
                            $x = explode("|", $fi1[$raa1]);
                            $x2 = explode("|", $fi1[$raa2]);
                            echo 'Голы: ' . $x[0] . ', ' . $x2[0] . '<br/>';
                            $sq = file("tp.dat");

                            for ($i = 0; $i < count($sq); $i++) {
                                if (ereg($one . '\|' . $two . '\|', $sq[$i])) {
                                    $num = $i;
                                }
                            }
                            $new = $sq[$num];
                            unset($sq[$num]);

                            $fp = fopen("tp.dat", "a+");
                            flock($fp, LOCK_EX);
                            ftruncate($fp, 0);
                            for ($i = 0; $i <= count($sq); $i++) {
                                fputs($fp, $sq[$i]);
                            }
                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                            echo '[<a href="tov.php">Назад</a>]<br/>';
                            $fp = fopen("tov.dat", "a+");
                            flock($fp, LOCK_EX);


                            fputs($fp, $one . "|" . $two . "|" . $arr[$r] . "|" . $x[0] . "|" . $x2[0] . "|" .
                                "\r\n");

                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                        }
                        if ($arr[$r] == "3:0") {
                            $fi1 = file("$ex[2]/$one.dat");
                            $raa1 = rand(8, 10);
                            $raa2 = rand(8, 10);
                            $raa3 = rand(8, 10);
                            $x = explode("|", $fi1[$raa1]);
                            $x2 = explode("|", $fi1[$raa2]);
                            $x3 = explode("|", $fi1[$raa3]);
                            echo 'Голы: ' . $x[0] . ', ' . $x2[0] . ', ' . $x3[0] . '<br/>';
                            $sq = file("tp.dat");

                            for ($i = 0; $i < count($sq); $i++) {
                                if (ereg($one . '\|' . $two . '\|', $sq[$i])) {
                                    $num = $i;
                                }
                            }
                            $new = $sq[$num];
                            unset($sq[$num]);

                            $fp = fopen("tp.dat", "a+");
                            flock($fp, LOCK_EX);
                            ftruncate($fp, 0);
                            for ($i = 0; $i <= count($sq); $i++) {
                                fputs($fp, $sq[$i]);
                            }
                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                            echo '[<a href="tov.php">Назад</a>]<br/>';
                            $fp = fopen("tov.dat", "a+");
                            flock($fp, LOCK_EX);


                            fputs($fp, $one . "|" . $two . "|" . $arr[$r] . "|" . $x[0] . "|" . $x2[0] . "|" .
                                $x3[0] . "|" . "\r\n");

                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                        }
                        if ($arr[$r] == "2:1") {
                            $fi1 = file("$ex[2]/$one.dat");
                            $fi2 = file("$ex[3]/$two.dat");
                            $raa1 = rand(8, 10);
                            $raa2 = rand(8, 10);
                            $raa3 = rand(8, 10);
                            $x = explode("|", $fi1[$raa1]);
                            $x2 = explode("|", $fi1[$raa2]);
                            $x3 = explode("|", $fi2[$raa3]);
                            echo 'Голы:<br/>' . $x[0] . ', ' . $x2[0] . '<br/>' . $x3[0] . '<br/>';
                            $sq = file("tp.dat");

                            for ($i = 0; $i < count($sq); $i++) {
                                if (ereg($one . '\|' . $two . '\|', $sq[$i])) {
                                    $num = $i;
                                }
                            }
                            $new = $sq[$num];
                            unset($sq[$num]);

                            $fp = fopen("tp.dat", "a+");
                            flock($fp, LOCK_EX);
                            ftruncate($fp, 0);
                            for ($i = 0; $i <= count($sq); $i++) {
                                fputs($fp, $sq[$i]);
                            }
                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                            echo '[<a href="tov.php">Назад</a>]<br/>';
                            $fp = fopen("tov.dat", "a+");
                            flock($fp, LOCK_EX);


                            fputs($fp, $one . "|" . $two . "|" . $arr[$r] . "|" . $x[0] . "|" . $x2[0] . "|" .
                                $x3[0] . "|" . "\r\n");

                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                        }
                        if ($arr[$r] == "3:1") {
                            $fi1 = file("$ex[2]/$one.dat");
                            $fi2 = file("$ex[3]/$two.dat");
                            $raa1 = rand(8, 10);
                            $raa2 = rand(8, 10);
                            $raa3 = rand(8, 10);
                            $raa4 = rand(8, 10);
                            $x = explode("|", $fi1[$raa1]);
                            $x2 = explode("|", $fi1[$raa2]);
                            $x3 = explode("|", $fi1[$raa3]);
                            $x4 = explode("|", $fi2[$raa4]);
                            echo 'Голы:<br/>' . $x[0] . ', ' . $x2[0] . ', ' . $x3[0] . '<br/>' . $x4[0] .
                                '<br/>';
                            $sq = file("tp.dat");

                            for ($i = 0; $i < count($sq); $i++) {
                                if (ereg($one . '\|' . $two . '\|', $sq[$i])) {
                                    $num = $i;
                                }
                            }
                            $new = $sq[$num];
                            unset($sq[$num]);

                            $fp = fopen("tp.dat", "a+");
                            flock($fp, LOCK_EX);
                            ftruncate($fp, 0);
                            for ($i = 0; $i <= count($sq); $i++) {
                                fputs($fp, $sq[$i]);
                            }
                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                            echo '[<a href="tov.php">Назад</a>]<br/>';
                            $fp = fopen("tov.dat", "a+");
                            flock($fp, LOCK_EX);


                            fputs($fp, $one . "|" . $two . "|" . $arr[$r] . "|" . $x[0] . "|" . $x2[0] . "|" .
                                $x3[0] . "|" . $x4[0] . "|" . "\r\n");

                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                        }
                        if ($arr[$r] == "3:2") {
                            $fi1 = file("$ex[2]/$one.dat");
                            $fi2 = file("$ex[3]/$two.dat");
                            $raa1 = rand(8, 10);
                            $raa2 = rand(8, 10);
                            $raa3 = rand(8, 10);
                            $raa4 = rand(8, 10);
                            $raa5 = rand(8, 10);
                            $x = explode("|", $fi1[$raa1]);
                            $x2 = explode("|", $fi1[$raa2]);
                            $x3 = explode("|", $fi1[$raa3]);
                            $x4 = explode("|", $fi2[$raa4]);
                            $x5 = explode("|", $fi2[$raa5]);
                            echo 'Голы:<br/>' . $x[0] . ', ' . $x2[0] . ', ' . $x3[0] . '<br/>' . $x4[0] .
                                ', ' . $x5[0] . '<br/>';
                            $sq = file("tp.dat");

                            for ($i = 0; $i < count($sq); $i++) {
                                if (ereg($one . '\|' . $two . '\|', $sq[$i])) {
                                    $num = $i;
                                }
                            }
                            $new = $sq[$num];
                            unset($sq[$num]);

                            $fp = fopen("tp.dat", "a+");
                            flock($fp, LOCK_EX);
                            ftruncate($fp, 0);
                            for ($i = 0; $i <= count($sq); $i++) {
                                fputs($fp, $sq[$i]);
                            }
                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                            echo '[<a href="tov.php">Назад</a>]<br/>';
                            $fp = fopen("tov.dat", "a+");
                            flock($fp, LOCK_EX);


                            fputs($fp, $one . "|" . $two . "|" . $arr[$r] . "|" . $x[0] . "|" . $x2[0] . "|" .
                                $x3[0] . "|" . $x4[0] . "|" . $x5[0] . "|" . "\r\n");

                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                        }


                    }
                    ###---
                    ###---
                    if ($k2 == "1" && $k1 == "0") {
                        $r = rand(0, 5);
                        echo '<br/>' . $one . ' vs ' . $two . ' ' . $arr2[$r] . '<br/>';
                        if ($arr2[$r] == "0:1") {
                            $fi1 = file("$ex[3]/$two.dat");
                            $raa1 = rand(8, 10);
                            $x = explode("|", $fi1[$raa1]);
                            echo 'Голы: ' . $x[0] . '<br/>';
                            $sq = file("tp.dat");

                            for ($i = 0; $i < count($sq); $i++) {
                                if (ereg($one . '\|' . $two . '\|', $sq[$i])) {
                                    $num = $i;
                                }
                            }
                            $new = $sq[$num];
                            unset($sq[$num]);

                            $fp = fopen("tp.dat", "a+");
                            flock($fp, LOCK_EX);
                            ftruncate($fp, 0);
                            for ($i = 0; $i <= count($sq); $i++) {
                                fputs($fp, $sq[$i]);
                            }
                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                            echo '[<a href="tov.php">Назад</a>]<br/>';
                            $fp = fopen("tov.dat", "a+");
                            flock($fp, LOCK_EX);


                            fputs($fp, $one . "|" . $two . "|" . $arr2[$r] . "|" . $x[0] . "|" . "\r\n");

                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                        }
                        if ($arr2[$r] == "0:2") {
                            $fi1 = file("$ex[3]/$two.dat");
                            $raa1 = rand(8, 10);
                            $raa2 = rand(8, 10);
                            $x = explode("|", $fi1[$raa1]);
                            $x2 = explode("|", $fi1[$raa2]);
                            echo 'Голы: ' . $x[0] . ', ' . $x2[0] . '<br/>';
                            $sq = file("tp.dat");

                            for ($i = 0; $i < count($sq); $i++) {
                                if (ereg($one . '\|' . $two . '\|', $sq[$i])) {
                                    $num = $i;
                                }
                            }
                            $new = $sq[$num];
                            unset($sq[$num]);

                            $fp = fopen("tp.dat", "a+");
                            flock($fp, LOCK_EX);
                            ftruncate($fp, 0);
                            for ($i = 0; $i <= count($sq); $i++) {
                                fputs($fp, $sq[$i]);
                            }
                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                            echo '[<a href="tov.php">Назад</a>]<br/>';
                            $fp = fopen("tov.dat", "a+");
                            flock($fp, LOCK_EX);


                            fputs($fp, $one . "|" . $two . "|" . $arr2[$r] . "|" . $x[0] . "|" . $x2[0] .
                                "|" . "\r\n");

                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                        }
                        if ($arr2[$r] == "0:3") {
                            $fi1 = file("$ex[3]/$two.dat");
                            $raa1 = rand(8, 10);
                            $raa2 = rand(8, 10);
                            $raa3 = rand(8, 10);
                            $x = explode("|", $fi1[$raa1]);
                            $x2 = explode("|", $fi1[$raa2]);
                            $x3 = explode("|", $fi1[$raa3]);
                            echo 'Голы: ' . $x[0] . ', ' . $x2[0] . ', ' . $x3[0] . '<br/>';
                            $sq = file("tp.dat");

                            for ($i = 0; $i < count($sq); $i++) {
                                if (ereg($one . '\|' . $two . '\|', $sq[$i])) {
                                    $num = $i;
                                }
                            }
                            $new = $sq[$num];
                            unset($sq[$num]);

                            $fp = fopen("tp.dat", "a+");
                            flock($fp, LOCK_EX);
                            ftruncate($fp, 0);
                            for ($i = 0; $i <= count($sq); $i++) {
                                fputs($fp, $sq[$i]);
                            }
                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                            echo '[<a href="tov.php">Назад</a>]<br/>';

                            $fp = fopen("tov.dat", "a+");
                            flock($fp, LOCK_EX);


                            fputs($fp, $one . "|" . $two . "|" . $arr2[$r] . "|" . $x[0] . "|" . $x2[0] .
                                "|" . $x3[0] . "|" . "\r\n");

                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                        }
                        if ($arr2[$r] == "1:2") {
                            $fi1 = file("$ex[3]/$two.dat");
                            $fi2 = file("$ex[2]/$one.dat");
                            $raa1 = rand(8, 10);
                            $raa2 = rand(8, 10);
                            $raa3 = rand(8, 10);
                            $x = explode("|", $fi1[$raa1]);
                            $x2 = explode("|", $fi1[$raa2]);
                            $x3 = explode("|", $fi2[$raa3]);
                            echo 'Голы:<br/>' . $x[0] . ', ' . $x2[0] . '<br/>' . $x3[0] . '<br/>';
                            $sq = file("tp.dat");

                            for ($i = 0; $i < count($sq); $i++) {
                                if (ereg($one . '\|' . $two . '\|', $sq[$i])) {
                                    $num = $i;
                                }
                            }
                            $new = $sq[$num];
                            unset($sq[$num]);

                            $fp = fopen("tp.dat", "a+");
                            flock($fp, LOCK_EX);
                            ftruncate($fp, 0);
                            for ($i = 0; $i <= count($sq); $i++) {
                                fputs($fp, $sq[$i]);
                            }
                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                            echo '[<a href="tov.php">Назад</a>]<br/>';
                            $fp = fopen("tov.dat", "a+");
                            flock($fp, LOCK_EX);


                            fputs($fp, $one . "|" . $two . "|" . $arr2[$r] . "|" . $x[0] . "|" . $x2[0] .
                                "|" . $x3[0] . "|" . "\r\n");

                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                        }
                        if ($arr2[$r] == "1:3") {
                            $fi1 = file("$ex[3]/$two.dat");
                            $fi2 = file("$ex[2]/$one.dat");
                            $raa1 = rand(8, 10);
                            $raa2 = rand(8, 10);
                            $raa3 = rand(8, 10);
                            $raa4 = rand(8, 10);
                            $x = explode("|", $fi1[$raa1]);
                            $x2 = explode("|", $fi1[$raa2]);
                            $x3 = explode("|", $fi1[$raa3]);
                            $x4 = explode("|", $fi2[$raa4]);
                            echo 'Голы:<br/>' . $x[0] . ', ' . $x2[0] . ', ' . $x3[0] . '<br/>' . $x4[0] .
                                '<br/>';
                            $sq = file("tp.dat");

                            for ($i = 0; $i < count($sq); $i++) {
                                if (ereg($one . '\|' . $two . '\|', $sq[$i])) {
                                    $num = $i;
                                }
                            }
                            $new = $sq[$num];
                            unset($sq[$num]);

                            $fp = fopen("tp.dat", "a+");
                            flock($fp, LOCK_EX);
                            ftruncate($fp, 0);
                            for ($i = 0; $i <= count($sq); $i++) {
                                fputs($fp, $sq[$i]);
                            }
                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                            echo '[<a href="tov.php">Назад</a>]<br/>';
                            $fp = fopen("tov.dat", "a+");
                            flock($fp, LOCK_EX);


                            fputs($fp, $one . "|" . $two . "|" . $arr2[$r] . "|" . $x[0] . "|" . $x2[0] .
                                "|" . $x3[0] . "|" . $x4[0] . "|" . "\r\n");

                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                        }
                        if ($arr2[$r] == "2:3") {
                            $fi1 = file("$ex[3]/$two.dat");
                            $fi2 = file("$ex[2]/$one.dat");
                            $raa1 = rand(8, 10);
                            $raa2 = rand(8, 10);
                            $raa3 = rand(8, 10);
                            $raa4 = rand(8, 10);
                            $raa5 = rand(8, 10);
                            $x = explode("|", $fi1[$raa1]);
                            $x2 = explode("|", $fi1[$raa2]);
                            $x3 = explode("|", $fi1[$raa3]);
                            $x4 = explode("|", $fi2[$raa4]);
                            $x5 = explode("|", $fi2[$raa5]);
                            echo 'Голы:<br/>' . $x[0] . ', ' . $x2[0] . ', ' . $x3[0] . '<br/>' . $x4[0] .
                                ', ' . $x5[0] . '<br/>';
                            $sq = file("tp.dat");

                            for ($i = 0; $i < count($sq); $i++) {
                                if (ereg($one . '\|' . $two . '\|', $sq[$i])) {
                                    $num = $i;
                                }
                            }
                            $new = $sq[$num];
                            unset($sq[$num]);

                            $fp = fopen("tp.dat", "a+");
                            flock($fp, LOCK_EX);
                            ftruncate($fp, 0);
                            for ($i = 0; $i <= count($sq); $i++) {
                                fputs($fp, $sq[$i]);
                            }
                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                            echo '[<a href="tov.php">Назад</a>]<br/>';
                            $fp = fopen("tov.dat", "a+");
                            flock($fp, LOCK_EX);


                            fputs($fp, $one . "|" . $two . "|" . $arr2[$r] . "|" . $x[0] . "|" . $x2[0] .
                                "|" . $x3[0] . "|" . $x4[0] . "|" . $x5[0] . "|" . "\r\n");

                            fflush($fp);
                            flock($fp, LOCK_UN);
                            fclose($fp);
                        }


                    }
                    ###---


                }
            }


        } else {
            echo 'ОШИБКА ВВОДА!<br/>';
        }

    }


    if ($act == "mneno") {
        $one = htmlspecialchars($_GET['one']);
        $one = trim($one);
        $one = substr($one, 0, 20);
        $two = htmlspecialchars($_GET['two']);
        $two = trim($two);
        $two = substr($two, 0, 20);
        $str = file_get_contents("tp.dat");
        $sq = file("tp.dat");
        if (ereg($one . '\|' . $two . '\|', $str)) {
            for ($i = 0; $i < count($sq); $i++) {
                if (ereg($one . '\|' . $two . '\|', $sq[$i])) {
                    $num = $i;
                }
            }
            $new = $sq[$num];
            unset($sq[$num]);

            $fp = fopen("tp.dat", "a+");
            flock($fp, LOCK_EX);
            ftruncate($fp, 0);
            for ($i = 0; $i <= count($sq); $i++) {
                fputs($fp, $sq[$i]);
            }
            fflush($fp);
            flock($fp, LOCK_UN);
            fclose($fp);
            echo 'Предложение отклонено!<br/>[<a href="tov.php">Назад</a>]<br/>';


        } else {
            echo 'ОШИБКА ВВОДА!<br/>[<a href="tov.php">Назад</a>]<br/>';
        }

    }


    if ($act == "go") {
        $sq = file("clubs.dat") or die("FATAL ERROR!!!!");
        echo '<form action="tov.php?act=goes" method="post"><select name="xxx">';
        for ($i = 0; $i <= count($sq); $i++) {
            $ex = explode("|", $sq[$i]);
            echo '<option value="' . $ex[0] . '">' . $ex[0] . '</option>';
        }
        echo '</select><br />
		  <input name="" type="submit" value="Предложить" /></form>';

    }

    if ($act == "goes") {
        $xxx = htmlspecialchars($_POST['xxx']);
        $xxx = trim($xxx);
        $xxx = substr($xxx, 0, 20);

        $file = file("clubs.dat");
        for ($i = 0; $i < count($file); $i++) {
            $ex = explode("|", $file[$i]);
            if ($ex[0] == $xxx && $ex[1] == "") {
                Header('Location:tov.php?act=nomanager');
                exit;
            }
        }

        $file = file("tp.dat");
        for ($i = 0; $i < count($file); $i++) {
            $ex = explode("|", $file[$i]);
            if ($ex[0] == $club && $ex[1] == $xxx) {
                Header('Location:tov.php?act=no');
                exit;
            }
        }


        if ($xxx == $club) {
            Header('Location:tov.php?act=bred');
            exit;
        }

        $k = 0;
        $file = file("tov.dat");
        for ($i = 0; $i < count($file); $i++) {
            $ex = explode("|", $file[$i]);
            if ($ex[0] == $club || $ex[1] == $club) {
                $k = $k + 1;
            }
        }
        if ($k >= 20) {
            Header('Location:tov.php?act=vse');
            exit;
        }


        if ($xxx !== "Atalanta" && $xxx !== "Parma" && $xxx !== "Cagliari" && $xxx !==
            "Reggina" && $xxx !== "Lecce" && $xxx !== "Fiorentina" && $xxx !== "Genoa" && $xxx
            !== "Inter" && $xxx !== "Juventus" && $xxx !== "Lazio" && $xxx !== "Chievo" && $xxx
            !== "Milan" && $xxx !== "Napoli" && $xxx !== "Palermo" && $xxx !== "Bologna" &&
            $xxx !== "Roma" && $xxx !== "Sampdoria" && $xxx !== "Siena" && $xxx !==
            "Udinese" && $xxx !== "Catania" && $xxx !== "Arsenal" && $xxx !== "Aston_Villa" &&
            $xxx !== "Portsmouth" && $xxx !== "Blackburn" && $xxx !== "Bolton" && $xxx
            !== "Chelsea" && $xxx !== "Stock_City" && $xxx !== "Everton" && $xxx !==
            "Fullham" && $xxx !== "Liverpool" && $xxx !== "Manchester_City" && $xxx !==
            "Manchester_United" && $xxx !== "Blackpool" && $xxx !== "Newcastle" && $xxx !==
            "Middlesbrough" && $xxx !== "West_Bromvich" && $xxx !== "Sunderland" && $xxx !==
            "Tottenham" && $xxx !== "Hall_City" && $xxx !== "Wigan" && $xxx !== "Barcelona" &&
            $xxx !== "Valencia" && $xxx !== "Real_M" && $xxx !== "Sevilla" && $xxx !==
            "Atletico_M" && $xxx !== "Deportivo" && $xxx !== "Villarreal" && $xxx !==
            "Malaga" && $xxx !== "Betis" && $xxx !== "Getafe" && $xxx !== "Racing" && $xxx
            !== "Sporting_G" && $xxx !== "Athletic_B" && $xxx !== "Almeria" && $xxx !==
            "Numancia" && $xxx !== "Recreativo" && $xxx !== "Valladolid" && $xxx !==
            "Espanyol" && $xxx !== "Mallorca" && $xxx !== "Osasuna" && $xxx !== "Hoffenheim" &&
            $xxx !== "Bayern_M" && $xxx !== "Arminia" && $xxx !== "Hamburger" && $xxx !==
            "Bayer_L" && $xxx !== "Borussia_D" && $xxx !== "Schalke" && $xxx !== "Werder" &&
            $xxx !== "Wolfsburg" && $xxx !== "Stuttgart" && $xxx !== "Cologne" && $xxx !==
            "Eintracht" && $xxx !== "Hannover_96" && $xxx !== "Bochum" && $xxx !==
            "Energie_Cottbus" && $xxx !== "Hertha" && $xxx !== "Karlsruher" && $xxx !==
            "Borussia_M" && $xxx !== "Rubin" && $xxx !== "CSKA_M" && $xxx !== "Dynamo_M" &&
            $xxx !== "Amkar" && $xxx !== "Zenit" && $xxx !== "Krylia_Sovetov" && $xxx !==
            "Lokomotiv_M" && $xxx !== "Spartak_M" && $xxx !== "Khimki" && $xxx !== "Terek" &&
            $xxx !== "Luch-Energiya" && $xxx !== "Spartak_N" && $xxx !== "Moscow" && $xxx !== "Anji" &&
            $xxx !== "Saturn" && $xxx !== "Shinnik" && $xxx !== "Arsenal_K" && $xxx !==
            "Chornomorets" && $xxx !== "Dnepr" && $xxx !== "Dynamo_K" && $xxx !== "Illichivets" &&
            $xxx !== "Karpaty" && $xxx !== "Lviv" && $xxx !== "Kryvbas" && $xxx !==
            "Kharkiv" && $xxx !== "Metalist_K" && $xxx !== "Metalurg_D" && $xxx !==
            "Metalurg_Z" && $xxx !== "Shakhtar" && $xxx !== "Tavriya" && $xxx !== "Vorskla" &&
            $xxx !== "Zorya" && $xxx !== "V.Setubal" && $xxx !== "V.Guimaraes" && $xxx !== 
            "Sporting" && $xxx !== "Rio_Ave" && $xxx !== "Porto" && $xxx !== "P.Ferreira" && $xxx !==
            "Olhanense" && $xxx !== "Nacional" && $xxx !== "Maritimo" && $xxx !== "Leiria" && $xxx !==
            "G.Vicente" && $xxx !== "Feirense" && $xxx !== "Braga" && $xxx !== "Benfica" && $xxx !== 
            "Beira-Mar" && $xxx !== "Academica" && $xxx !== "Arles_Avignon" && $xxx !== "Auxerre" &&
            $xxx !== "Bordeaux" && $xxx !== "Caen" && $xxx !== "Lens" && $xxx !== "Lille" && 
            $xxx !== "Lorient" && $xxx !== "Lyon" && $xxx !== "Marseille" && $xxx !== "Monaco" && 
            $xxx !== "Montpellie" && $xxx !== "Nancy" && $xxx !== "Nice" && $xxx !== "PSG" && $xxx !==
            "Renn" && $xxx !== "Saint-Etienne" && $xxx !== "Sochaux" && $xxx !==
            "Stade_Brestois" && $xxx !== "Toulouse" && $xxx !== "Valenciennes") {
            Header('Location:tov.php?act=error');
            exit;
        }


        if ($xxx == "Atalanta" || $xxx == "Parma" || $xxx == "Cagliari" || $xxx == "Reggina" ||
            $xxx == "Lecce" || $xxx == "Fiorentina" || $xxx == "Genoa" || $xxx == "Inter" ||
            $xxx == "Juventus" || $xxx == "Lazio" || $xxx == "Chievo" || $xxx == "Milan" ||
            $xxx == "Napoli" || $xxx == "Palermo" || $xxx == "Bologna" || $xxx == "Roma" ||
            $xxx == "Sampdoria" || $xxx == "Siena" || $xxx == "Udinese" || $xxx ==
            "Catania") {
            $c2 = "italy";
        }
        if ($xxx == "Arsenal" || $xxx == "Aston_Villa" || $xxx == "Portsmouth" || $xxx ==
            "Blackburn" || $xxx == "Bolton" || $xxx == "Chelsea" || $xxx == "Stock_City" ||
            $xxx == "Everton" || $xxx == "Fullham" || $xxx == "Liverpool" || $xxx ==
            "Manchester_City" || $xxx == "Manchester_United" || $xxx == "Blackpool" || $xxx ==
            "Newcastle" || $xxx == "Middlesbrough" || $xxx == "West_Bromvich" || $xxx ==
            "Sunderland" || $xxx == "Tottenham" || $xxx == "Hall_City" || $xxx == "Wigan") {
            $c2 = "england";
        }
        if ($xxx == "Barcelona" || $xxx == "Valencia" || $xxx == "Real_M" || $xxx ==
            "Sevilla" || $xxx == "Atletico_M" || $xxx == "Deportivo" || $xxx == "Villarreal" ||
            $xxx == "Malaga" || $xxx == "Betis" || $xxx == "Getafe" || $xxx == "Racing" ||
            $xxx == "Sporting_G" || $xxx == "Athletic_B" || $xxx == "Almeria" || $xxx ==
            "Numancia" || $xxx == "Recreativo" || $xxx == "Valladolid" || $xxx == "Espanyol" ||
            $xxx == "Mallorca" || $xxx == "Osasuna") {
            $c2 = "spain";
        }
        if ($xxx == "Hoffenheim" || $xxx == "Bayern_M" || $xxx == "Arminia" || $xxx ==
            "Hamburger" || $xxx == "Bayer_L" || $xxx == "Borussia_D" || $xxx == "Schalke" ||
            $xxx == "Werder" || $xxx == "Wolfsburg" || $xxx == "Stuttgart" || $xxx ==
            "Cologne" || $xxx == "Eintracht" || $xxx == "Hannover_96" || $xxx ==
            "Bochum" || $xxx == "Energie_Cottbus" || $xxx == "Hertha" || $xxx ==
            "Karlsruher" || $xxx == "Borussia_M") {
            $c2 = "germany";
        }
        if ($xxx == "Rubin" || $xxx == "CSKA_M" || $xxx == "Dynamo_M" || $xxx == "Amkar" ||
            $xxx == "Zenit" || $xxx == "Krylia_Sovetov" || $xxx == "Lokomotiv_M" || $xxx ==
            "Spartak_M" || $xxx == "Khimki" || $xxx == "Terek" || $xxx == "Luch-Energiya" || $xxx ==
            "Spartak_N" || $xxx == "Moscow" || $xxx == "Anji" || $xxx == "Saturn" || $xxx ==
            "Shinnik") {
            $c2 = "russia";
        }
        if ($xxx == "Arsenal_K" || $xxx == "Chornomorets" || $xxx == "Dnepr" || $xxx ==
            "Dynamo_K" || $xxx == "Illichivets" || $xxx == "Karpaty" || $xxx == "Lviv" || $xxx ==
            "Kryvbas" || $xxx == "Kharkiv" || $xxx == "Metalist_K" || $xxx ==
            "Metalurg_D" || $xxx == "Metalurg_Z" || $xxx == "Shakhtar" || $xxx == "Tavriya" ||
            $xxx == "Vorskla" || $xxx == "Zorya") {
            $c2 = "ukraine";
        }
        if ($xxx == "V.Setubal" || $xxx == "V.Guimaraes" || $xxx == "Sporting" || $xxx ==
            "Rio_Ave" || $xxx == "Porto" || $xxx == "P.Ferreira" || $xxx == "Olhanense" || $xxx ==
            "Nacional" || $xxx == "Maritimo" || $xxx == "Leiria" || $xxx ==
            "G.Vicente" || $xxx == "Feirense" || $xxx == "Braga" || $xxx == "Benfica" ||
            $xxx == "Beira-Mar" || $xxx == "Academica") {
            $c2 = "portugal";
        }
        if ($xxx == "Arles_Avignon" || $xxx == "Auxerre" || $xxx == "Bordeaux" || $xxx ==
            "Caen" || $xxx == "Lens" || $xxx == "Lille" || $xxx == "Lorient" ||
            $xxx == "Lyon" || $xxx == "Marseille" || $xxx == "Monaco" || $xxx ==
            "Montpellie" || $xxx == "Nancy" || $xxx == "Nice" || $xxx ==
            "PSG" || $xxx == "Renn" || $xxx == "Saint-Etienne" || $xxx ==
            "Sochaux" || $xxx == "Stade_Brestois" || $xxx == "Toulouse" || $xxx == "Valenciennes") {
            $c2 = "france";
        }

        $fp = fopen("tp.dat", "a+");
        flock($fp, LOCK_EX);


        fputs($fp, $club . "|" . $xxx . "|" . $c . "|" . $c2 . "|" . "\r\n");

        fflush($fp);
        flock($fp, LOCK_UN);
        fclose($fp);

        echo 'Вы успешно сделали предложение о тов. матче для ' . $xxx .
            '<br/>[<a href="tov.php">Тов. матчи</a>]<br/>';

    }

    if ($act == "bred") {
        echo '<br/>Нельзя делать предложение самому себе!<br/>[<a href="tov.php?act=go">Назад</a>]<br/>';
    }
    if ($act == "vse") {
        echo '<br/>Вы не можете сделать это предложение: Вы уже сыграли 20 игр!<br/>[<a href="tov.php?act=go">Назад</a>]<br/>';
    }
    if ($act == "error") {
        echo '<br/>Вы неправильно ввели название клуба! Будьте внимательны! Если название клуба состоит из двох слов, то между ними нужно ставить символ нижнего подчеркивания. Первая буква должна быть заглавной.<br/>[<a href="tov.php?act=go">Назад</a>]<br/>';
    }

    if ($act == "nomanager") {
        echo '<br/>Вы не можете сделать предложение этой команде: у команды нету менеджера.<br/>[<a href="tov.php?act=go">Назад</a>]<br/>';
    }
    if ($act == "no") {
        echo '<br/>Вы уже делали предложение этой команде.<br/>[<a href="tov.php?act=go">Назад</a>]<br/>';
    }


    if ($act == "moi") {
        $file = file("tp.dat");
        for ($i = 0; $i < count($file); $i++) {
            $ex = explode("|", $file[$i]);
            if ($ex[0] == $club) {
                echo $ex[0] . ' - ' . $ex[1] . '[<a href=tov.php?act=moino&one=' . $ex[0] .
                    '&two=' . $ex[1] . '>Откл.</a>]<br/>';

            }
        }
        echo '<br/>[<a href="tov.php">Назад</a>]<br/>';
    }

    if ($act == "moino") {
        $one = htmlspecialchars($_GET['one']);
        $one = trim($one);
        $one = substr($one, 0, 20);
        $two = htmlspecialchars($_GET['two']);
        $two = trim($two);
        $two = substr($two, 0, 20);
        $str = file_get_contents("tp.dat");
        $sq = file("tp.dat");
        if (ereg($one . '\|' . $two . '\|', $str)) {
            for ($i = 0; $i < count($sq); $i++) {
                if (ereg($one . '\|' . $two . '\|', $sq[$i])) {
                    $num = $i;
                }
            }
            $new = $sq[$num];
            unset($sq[$num]);

            $fp = fopen("tp.dat", "a+");
            flock($fp, LOCK_EX);
            ftruncate($fp, 0);
            for ($i = 0; $i <= count($sq); $i++) {
                fputs($fp, $sq[$i]);
            }
            fflush($fp);
            flock($fp, LOCK_UN);
            fclose($fp);
            echo 'Предложение отклонено!<br/>[<a href="tov.php">Назад</a>]<br/>';


        } else {
            echo 'ОШИБКА ВВОДА!<br/>[<a href="tov.php">Назад</a>]<br/>';
        }
    }

    if ($act == "my") {
        $file = file("tov.dat");
        for ($i = 0; $i < count($file); $i++) {
            $ex = explode("|", $file[$i]);
            if ($ex[0] == $club || $ex[1] == $club) {
                echo $ex[0] . '-' . $ex[1] . ' ' . $ex[2] . '<br/>';
                echo 'Голы: ';
                if (isset($ex[3])) {
                    echo $ex[3] . ', ';
                }
                if (isset($ex[4])) {
                    echo $ex[4] . ', ';
                }
                if (isset($ex[5])) {
                    echo $ex[5] . ', ';
                }
                if (isset($ex[6])) {
                    echo $ex[6] . ', ';
                }
                if (isset($ex[7])) {
                    echo $ex[7];
                }
                echo '<br/><center>---</center><br/>';
            }
        }
        echo '<br/>[<a href="tov.php">Назад</a>]<br/>';
    }


    if ($act == "all") {
        $file = file("tov.dat");
        for ($i = 0; $i < count($file); $i++) {
            $ex = explode("|", $file[$i]);

            echo $ex[0] . '-' . $ex[1] . ' ' . $ex[2] . '<br/>';
            echo 'Голы: ';
            if (isset($ex[3])) {
                echo $ex[3] . ', ';
            }
            if (isset($ex[4])) {
                echo $ex[4] . ', ';
            }
            if (isset($ex[5])) {
                echo $ex[5] . ', ';
            }
            if (isset($ex[6])) {
                echo $ex[6] . ', ';
            }
            if (isset($ex[7])) {
                echo $ex[7];
            }
            echo '<br/><center>---</center><br/>';

        }
        echo '<br/>[<a href="tov.php">Назад</a>]<br/>';
    }

echo '[<a href="main.php">В панель управления</a>]<br/>';
require_once ("../incfiles/end.php");