Вход Регистрация
Файл: manager1/adminka/italy.php
Строк: 2434
<?php
#######################################################
#                            FOOTBALL MANAGER                                       
#                              AUTHOR: VoRoN@                                          
#                  SPECIAL FOR HTTP://wap-FIFA.IN                        
######################################################
#                           Вы не имеете право:                                      
#  1. Вносить изменения в код всего скрипта;                     
#  2. Распространять его (скрипт);                                        
#  3. Продавать его (скрипт).                                                   
#  Права на продажу и распространение этого скрипта  
#  принадлежат Вороне Богдану Викторовичу (VoRoN@) 
#  и защищены согласно                                                            
#  "Закона Украины об авторском праве"!                            
#  ВНИМАНИЕ! Вы можете быть притянуты к                        
#  КРИМИНАЛЬНОЙ ОТВЕТСТВЕННОСТИ!                                 
######################################################                
#                      E-Mail: vbv07@inbox.ru                                        
######################################################
#                              2009 (c)
######################################################
    
require_once"../../template/start.php";
require_once
"../../template/regglobals.php";
require_once
"../../template/config.php";
require_once
"../../template/functions.php";
require_once
"../../template/antidos.php";
require_once
"../../template/cookies.php";
require_once
"../../template/gzip.php";
require_once
"../../template/header.php";
require_once
"../../template/referer.php";
include_once
"../../themes/$config_themes/index.php";
include_once
"../../template/isset.php";
 
echo
'<b><center>*Football MANAGER*ADMIN PANEL*</center></b><br><br>';





if (
$provlog==$_SESSION['log'] && $provpar==md5($_SESSION['par']) && $_SESSION['log']!="" && md5($_SESSION['par'])!="")
{


if (
$dostup==101 || $dostup==102 || $dostup==103 || $dostup==105)
    {

    if (!isset(
$act) || $act=="")
{
$file=file(BASEDIR."manager1/italy/calendar.dat");

for (
$i=0;$i<count($file);$i++)
{
$ex=explode("|",$file[$i]);
if (
$ex[2]=="" && $ex[3]=="")
{
$n=$i;
echo 
$i.'<br>'; break;
}
}

$jo=array();
$jo2=array();
$m=$n+9;
for (
$j=$n;$j<=$m;$j++)
{
$exp=explode("|",$file[$j]);
echo 
$exp[0].' - '.$exp[1].' ';
$sq1=file(BASEDIR."manager1/italy/$exp[0].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(BASEDIR."manager1/italy/$exp[1].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(BASEDIR."manager1/italy/$exp[0].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];
$ust1=$hhh[5];

$s2=file(BASEDIR."manager1/italy/$exp[1].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];
$ust2=$hhh[5];

$fu=file_get_contents(BASEDIR."manager1/travma.dat");


$ap=0;
if (!
ereg("|GK|",$sq1[0]))
   {
    
$ap=$ap+1;
    }
if (!
ereg("|D|",$sq1[1]))
   {
    
$ap=$ap+1;
    }
if (!
ereg("|D|",$sq1[2]))
   {
    
$ap=$ap+1;
    }
if (!
ereg("|D|",$sq1[3]))
   {
    
$ap=$ap+1;
    }
if (
ereg("|D|",$sq1[7]) || ereg("|GK|",$sq1[7]))
   {
    
$ap=$ap+1;
    }
if (
ereg("|D|",$sq1[8]) || ereg("|GK|",$sq1[8]))
   {
    
$ap=$ap+1;
    }
if (
ereg("|D|",$sq1[9]) || ereg("|GK|",$sq1[9]))
   {
    
$ap=$ap+1;
    }
if (
ereg("|D|",$sq1[10]) || ereg("|GK|",$sq1[10]))
   {
    
$ap=$ap+1;
    }
for (
$o=0;$o<11;$o++)
    {
    
$ty=explode("|",$sq1[$o]);
      if (
ereg($exp[0]."|".$ty[0]."|",$fu))
         {
         
$ap=$ap+1;
         } 
    }


$ap2=0;
if (!
ereg("|GK|",$sq2[0]))
   {
    
$ap2=$ap2+1;
    }
if (!
ereg("|D|",$sq2[1]))
   {
    
$ap2=$ap2+1;
    }
if (!
ereg("|D|",$sq2[2]))
   {
    
$ap2=$ap2+1;
    }
if (!
ereg("|D|",$sq2[3]))
   {
    
$ap2=$ap2+1;
    }
if (
ereg("|D|",$sq2[7]) || ereg("|GK|",$sq2[7]))
   {
    
$ap2=$ap2+1;
    }
if (
ereg("|D|",$sq2[8]) || ereg("|GK|",$sq2[8]))
   {
    
$ap2=$ap2+1;
    }
if (
ereg("|D|",$sq2[9]) || ereg("|GK|",$sq2[9]))
   {
    
$ap2=$ap2+1;
    }
if (
ereg("|D|",$sq2[10]) || ereg("|GK|",$sq2[10]))
   {
    
$ap2=$ap2+1;
    }
for (
$o=0;$o<11;$o++)
    {
    
$ty=explode("|",$sq2[$o]);
      if (
ereg($exp[1]."|".$ty[0]."|",$fu))
         {
         
$ap2=$ap2+1;
         } 
    }




echo 
'['.$xxx1.'|'.$suka1.'|'.$ust1.'] - ['.$xxx2.'|'.$suka2.'|'.$ust2.']   '; if ($ap!==0){echo $ap;} echo '-'; if ($ap2!==0){echo $ap2;} echo'<br>';
   

$res1=0;
$res2=0;

if ((
$xxx1+500)>$xxx2)
   {
   
$res1=$res1+1;
   }

if ((
$xxx2+500)>$xxx1)
   {
   
$res2=$res2+1;
   }

#######


if (($xxx1+1000)>$xxx2)
   {
   
$res1=$res1+3;
   }

if ((
$xxx2+1000)>$xxx1)
   {
   
$res2=$res2+3;
   }

##########


if (($suka1+50)>$suka2)
   {
   
$res1=$res1+1;
   }

if ((
$suka2+50)>$suka1)
   {
   
$res2=$res2+1;
   }

############

if ($ap>=1)
   {
   
$res2=$res2+1;
   }


if (
$ap2>=1)
   {
   
$res1=$res1+1;
   }


 if (
$ap>3)
   {
   
$res2=$res2+3;
   }


if (
$ap2>3)
   {
   
$res1=$res1+3;
   }




#############


if ($ust1>10)
   {
   
$res2=$res2+1;
   }

if (
$ust2>10)
   {
   
$res1=$res1+1;
   }

###########

if ($res1==$res2)
   { 
   
$results=array("0|0","1|1","2|2","3|3");
    
$r=rand(0,3);
   
$rezul=$results[$r]; 
   }




if (
$res1>$res2)
    {
   
$results=array("1|0","2|0","2|1","3|1");
    
$r=rand(0,3);
   
$rezul=$results[$r];
    }



if (
$res1<$res2)
   {
   
$results=array("0|1","0|2","1|2","1|3");
    
$r=rand(0,3);
   
$rezul=$results[$r];
   }


if (
$res1>($res2+2))
   {
   
$results=array("3|0","4|0","4|1","5|1","6|2","5|2");
    
$r=rand(0,3);
   
$rezul=$results[$r];
   }

 if ((
$res1+2)<$res2)
   {
   
$results=array("0|3","0|4","1|4","1|5","2|6","2|5");
    
$r=rand(0,3);
   
$rezul=$results[$r];
   }




$jo[]=$exp[0]; $jo[]=$exp[1];


$exx=explode("|",$rezul);
$jo2[]=$exx[0];  $jo2[]=$exx[1];

}

echo 
'<form action="italy.php?act=go" method="post">
<input type="text" maxlength="20" name="team1" value="'
.$jo[0].'"> - <input type="text" maxlength="20" name="team2" value="'.$jo[1].'"> <input type="text" maxlength="20" size="5 "name="score1" value="'.$jo2[0].'">:<input type="text" maxlength="20" size="5 "name="score2" value="'.$jo2[1].'"><br>
<input type="text" maxlength="20" name="team3" value="'
.$jo[2].'"> - <input type="text" maxlength="20" name="team4" value="'.$jo[3].'"> <input type="text" maxlength="20" size="5 "name="score3" value="'.$jo2[2].'">:<input type="text" maxlength="20" size="5 "name="score4" value="'.$jo2[3].'"><br>
<input type="text" maxlength="20" name="team5" value="'
.$jo[4].'"> - <input type="text" maxlength="20" name="team6" value="'.$jo[5].'"> <input type="text" maxlength="20" size="5 "name="score5" value="'.$jo2[4].'">:<input type="text" maxlength="20" size="5 "name="score6" value="'.$jo2[5].'"><br>
<input type="text" maxlength="20" name="team7" value="'
.$jo[6].'"> - <input type="text" maxlength="20" name="team8" value="'.$jo[7].'"> <input type="text" maxlength="20" size="5 "name="score7" value="'.$jo2[6].'">:<input type="text" maxlength="20" size="5 "name="score8" value="'.$jo2[7].'"><br>
<input type="text" maxlength="20" name="team9" value="'
.$jo[8].'"> - <input type="text" maxlength="20" name="team10" value="'.$jo[9].'"> <input type="text" maxlength="20" size="5 "name="score9" value="'.$jo2[8].'">:<input type="text" maxlength="20" size="5 "name="score10" value="'.$jo2[9].'"><br>
<input type="text" maxlength="20" name="team11" value="'
.$jo[10].'"> - <input type="text" maxlength="20" name="team12" value="'.$jo[11].'"> <input type="text" maxlength="20" size="5 "name="score11" value="'.$jo2[10].'">:<input type="text" maxlength="20" size="5 "name="score12" value="'.$jo2[11].'"><br>
<input type="text" maxlength="20" name="team13" value="'
.$jo[12].'"> - <input type="text" maxlength="20" name="team14" value="'.$jo[13].'"> <input type="text" maxlength="20" size="5 "name="score13" value="'.$jo2[12].'">:<input type="text" maxlength="20" size="5 "name="score14" value="'.$jo2[13].'"><br>
<input type="text" maxlength="20" name="team15" value="'
.$jo[14].'"> - <input type="text" maxlength="20" name="team16" value="'.$jo[15].'"> <input type="text" maxlength="20" size="5 "name="score15" value="'.$jo2[14].'">:<input type="text" maxlength="20" size="5 "name="score16" value="'.$jo2[15].'"><br>
<input type="text" maxlength="20" name="team17" value="'
.$jo[16].'"> - <input type="text" maxlength="20" name="team18" value="'.$jo[17].'"> <input type="text" maxlength="20" size="5 "name="score17" value="'.$jo2[16].'">:<input type="text" maxlength="20" size="5 "name="score18" value="'.$jo2[17].'"><br>
<input type="text" maxlength="20" name="team19" value="'
.$jo[18].'"> - <input type="text" maxlength="20" name="team20" value="'.$jo[19].'"> <input type="text" maxlength="20" size="5 "name="score19" value="'.$jo2[18].'">:<input type="text" maxlength="20" size="5 "name="score20" value="'.$jo2[19].'"><br>
<input type="submit" value="GO!"></form>'
;


}


 if (
$act=="go")
{



$f=file(BASEDIR."manager1/italy/calendar.dat");
   foreach(
$f as $key=>$v)
   {
   
$exp=explode("|",$v);

#################################################

       
if ($exp[0]==$team1 && $exp[1]==$team2)
       {
       
$score1=(int)$score1;   $score2=(int)$score2;

###-------------------------------
if ($score1!==0)
    {
        
$fi=file(BASEDIR."manager1/italy/$team1.dat");
     for (
$k=0;$k<$score1;$k++)
         {
        
$raa=rand(8,10); 
        
$player1=$fi[$raa]; 
    
$rr=explode("|",$player1); 
                               
$filez=file(BASEDIR."manager1/italy/b.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team1."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/b.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team1."|"."rn";
                                       }

                                
$fp=fopen(BASEDIR."manager1/italy/b.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
      }

     }
      if (
$score2!==0)
    {
     
$fi=file(BASEDIR."manager1/italy/$team2.dat");
             for (
$k=0;$k<$score2;$k++)
         {
        
$raa=rand(8,10);
        
$player2=$fi[$raa];
    
$rr=explode("|",$player2); 
                               
$filez=file(BASEDIR."manager1/italy/b.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team2."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/b.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team2."|"."rn";
                                       }
                                
$fp=fopen(BASEDIR."manager1/italy/b.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
           }
     }
if (
$score1!==0)
    {
        
$fi=file(BASEDIR."manager1/italy/$team1.dat");
           for (
$k=0;$k<$score1;$k++)
         {
        
$raa=rand(5,7); 
        
$player1=$fi[$raa]; 
    
$rr=explode("|",$player1);
                               
$filez=file(BASEDIR."manager1/italy/a.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team1."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/a.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team1."|"."rn";
                                       }

                                
$fp=fopen(BASEDIR."manager1/italy/a.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
         
         }
     }
      if (
$score2!==0)
    {
     
$fi=file(BASEDIR."manager1/italy/$team2.dat");
           for (
$k=0;$k<$score2;$k++)
         {
        
$raa=rand(5,7);
        
$player2=$fi[$raa];
    
$rr=explode("|",$player2); 
                               
$filez=file(BASEDIR."manager1/italy/a.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team2."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/a.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team2."|"."rn";
                                       }
                                
$fp=fopen(BASEDIR."manager1/italy/a.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
            }
     }



###-------------------------------
       
$exp[2]==$score1$exp[3]==$score2;
       
$f[$i]=$team1.'|'.$team2.'|'.$score1.'|'.$score2.'|';
                        if (
$score1>$score2)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team1.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }
                        

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team1)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }


                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+2;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+2;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+2;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team1.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team2.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];

                              if (
$mor && $mor<=105
                              {
$mor=$mor-2;}
                               if (
$z>&& $z<=105)
                               {
$z=$z-2;}
                               if (
$u>&& $u<=105)
                               { 
$u=$u+1;} 
                               if (
$pr>&&$pr<=105)
                               {
$pr=$pr-2;}
                               if (
$a>&& $a<=105)
                                { 
$a=$a-2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team2.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team1)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+3$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score1;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                      if (
$ex[2]==$team2)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score2;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                      if (
$score1<$score2)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team2.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
            
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+2;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+2;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+2;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team2.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team1.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team1)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }


                              if (
$mor && $mor<=105
                              {
$mor=$mor-2;}
                               if (
$z>&& $z<=105)
                               {
$z=$z-2;}
                               if (
$u>&& $u<=105)
                               { 
$u=$u+1;} 
                               if (
$pr>&&$pr<=105)
                               {
$pr=$pr-2;}
                               if (
$a>&& $a<=105)
                                { 
$a=$a-2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team1.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team2)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+3$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score2;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                        if (
$ex[2]==$team1)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score1;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                       if (
$score1==$score2)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team1.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team1)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }

          
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+1;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+1;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+1;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+1;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team1.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team2.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+1;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+1;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+1;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+1;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team2.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team1)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+1$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score1;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                        if (
$ex[2]==$team2)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+1$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score2;
                                         
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }





                                
$file=file(BASEDIR."manager1/italy/calendar.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[0]==$team1 && $ex[1]==$team2)
                                         {
                                          
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$score1."|".$score2."|"."rn";
                                         }

                }
                                
$fp=fopen(BASEDIR."manager1/italy/calendar.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
             echo 
$team1.' - '.$team2.' '.$score1.':'.$score2.'<br>';




       }




################################################

              
if ($exp[0]==$team3 && $exp[1]==$team4)
       {
       
$score3=(int)$score3;   $score4=(int)$score4;
###-------------------------------
if ($score3!==0)
    {
        
$fi=file(BASEDIR."manager1/italy/$team3.dat");
     for (
$k=0;$k<$score3;$k++)
         {
        
$raa=rand(8,10); 
        
$player1=$fi[$raa]; 
    
$rr=explode("|",$player1);
                               
$filez=file(BASEDIR."manager1/italy/b.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team3."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/b.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team3."|"."rn";
                                       }

                                
$fp=fopen(BASEDIR."manager1/italy/b.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
         }

     }
      if (
$score4!==0)
    {
     
$fi=file(BASEDIR."manager1/italy/$team4.dat");
     for (
$k=0;$k<$score4;$k++)
         {
        
$raa=rand(8,10);
        
$player2=$fi[$raa];
    
$rr=explode("|",$player2); 
                               
$filez=file(BASEDIR."manager1/italy/b.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team4."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/b.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team4."|"."rn";
                                       }
                                
$fp=fopen(BASEDIR."manager1/italy/b.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
        }
     }
if (
$score3!==0)
    {
        
$fi=file(BASEDIR."manager1/italy/$team3.dat");
     for (
$k=0;$k<$score3;$k++)
         {
        
$raa=rand(5,7); 
        
$player1=$fi[$raa]; 
    
$rr=explode("|",$player1);
                               
$filez=file(BASEDIR."manager1/italy/a.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team3."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/a.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team3."|"."rn";
                                       }

                                
$fp=fopen(BASEDIR."manager1/italy/a.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
        }

     }
      if (
$score4!==0)
    {
     
$fi=file(BASEDIR."manager1/italy/$team4.dat");
     for (
$k=0;$k<$score4;$k++)
         {
        
$raa=rand(5,7);
        
$player2=$fi[$raa];
    
$rr=explode("|",$player2); 
                               
$filez=file(BASEDIR."manager1/italy/a.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team4."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/a.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team4."|"."rn";
                                       }
                                
$fp=fopen(BASEDIR."manager1/italy/a.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
         }
     }



###-------------------------------
       
$exp[2]==$score3$exp[3]==$score4;
       
$f[$i]=$team3.'|'.$team4.'|'.$score3.'|'.$score4.'|';
                        if (
$score3>$score4)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team3.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team3)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }


                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+2;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+2;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+2;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team3.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team4.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];

                              if (
$mor && $mor<=105
                              {
$mor=$mor-2;}
                               if (
$z>&& $z<=105)
                               {
$z=$z-2;}
                               if (
$u>&& $u<=105)
                               { 
$u=$u+1;} 
                               if (
$pr>&&$pr<=105)
                               {
$pr=$pr-2;}
                               if (
$a>&& $a<=105)
                                { 
$a=$a-2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team4.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team3)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+3$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score3;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                      if (
$ex[2]==$team4)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score4;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                      if (
$score3<$score4)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team4.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
        
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+2;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+2;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+2;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team4.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team3.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team3)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }


                              if (
$mor && $mor<=105
                              {
$mor=$mor-2;}
                               if (
$z>&& $z<=105)
                               {
$z=$z-2;}
                               if (
$u>&& $u<=105)
                               { 
$u=$u+1;} 
                               if (
$pr>&&$pr<=105)
                               {
$pr=$pr-2;}
                               if (
$a>&& $a<=105)
                                { 
$a=$a-2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team3.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team4)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+3$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score4;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                        if (
$ex[2]==$team3)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score3;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                       if (
$score3==$score4)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team3.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team3)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }
          
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+1;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+1;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+1;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+1;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team3.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team4.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+1;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+1;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+1;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+1;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team4.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team3)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+1$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score3;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                        if (
$ex[2]==$team4)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+1$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score4;
                                         
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }



                                
$file=file(BASEDIR."manager1/italy/calendar.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[0]==$team3 && $ex[1]==$team4)
                                         {
                                          
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$score3."|".$score4."|"."rn";
                                         }

                }
                                
$fp=fopen(BASEDIR."manager1/italy/calendar.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
             echo 
$team3.' - '.$team4.' '.$score3.':'.$score4.'<br>';



       }

################################################

              
if ($exp[0]==$team5 && $exp[1]==$team6)
       {
       
$score5=(int)$score5;   $score6=(int)$score6;
###-------------------------------
if ($score5!==0)
    {
     for (
$k=0;$k<$score5;$k++)
         {
        
$fi=file(BASEDIR."manager1/italy/$team5.dat");
        
$raa=rand(8,10); 
        
$player1=$fi[$raa]; 
    
$rr=explode("|",$player1);
                               
$filez=file(BASEDIR."manager1/italy/b.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team5."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/b.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team5."|"."rn";
                                       }

                                
$fp=fopen(BASEDIR."manager1/italy/b.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
           }

     }
      if (
$score6!==0)
    {
     
$fi=file(BASEDIR."manager1/italy/$team6.dat");
     for (
$k=0;$k<$score6;$k++)
         {
        
$raa=rand(8,10);
        
$player2=$fi[$raa];
    
$rr=explode("|",$player2); 
                               
$filez=file(BASEDIR."manager1/italy/b.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team6."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/b.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team6."|"."rn";
                                       }
                                
$fp=fopen(BASEDIR."manager1/italy/b.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
        }
     }
if (
$score5!==0)
    {
     for (
$k=0;$k<$score5;$k++)
         {
        
$fi=file(BASEDIR."manager1/italy/$team5.dat");
        
$raa=rand(5,7); 
        
$player1=$fi[$raa]; 
    
$rr=explode("|",$player1);
                               
$filez=file(BASEDIR."manager1/italy/a.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team5."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/a.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team5."|"."rn";
                                       }

                                
$fp=fopen(BASEDIR."manager1/italy/a.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
          }

     }
      if (
$score6!==0)
    {
     
$fi=file(BASEDIR."manager1/italy/$team6.dat");
     for (
$k=0;$k<$score6;$k++)
         {
        
$raa=rand(5,7);
        
$player2=$fi[$raa];
    
$rr=explode("|",$player2); 
                               
$filez=file(BASEDIR."manager1/italy/a.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team6."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/a.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team6."|"."rn";
                                       }
                                
$fp=fopen(BASEDIR."manager1/italy/a.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
          }
     }



###-------------------------------
       
$exp[2]==$score5$exp[3]==$score6;
       
$f[$i]=$team5.'|'.$team6.'|'.$score5.'|'.$score6.'|';
                        if (
$score5>$score6)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team5.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team5)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }


                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+2;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+2;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+2;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team5.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team6.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];

                              if (
$mor && $mor<=105
                              {
$mor=$mor-2;}
                               if (
$z>&& $z<=105)
                               {
$z=$z-2;}
                               if (
$u>&& $u<=105)
                               { 
$u=$u+1;} 
                               if (
$pr>&&$pr<=105)
                               {
$pr=$pr-2;}
                               if (
$a>&& $a<=105)
                                { 
$a=$a-2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team6.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team5)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+3$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score5;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                      if (
$ex[2]==$team6)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score6;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                      if (
$score5<$score6)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team6.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
        
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+2;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+2;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+2;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team6.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team5.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team5)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }

                              if (
$mor && $mor<=105
                              {
$mor=$mor-2;}
                               if (
$z>&& $z<=105)
                               {
$z=$z-2;}
                               if (
$u>&& $u<=105)
                               { 
$u=$u+1;} 
                               if (
$pr>&&$pr<=105)
                               {
$pr=$pr-2;}
                               if (
$a>&& $a<=105)
                                { 
$a=$a-2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team5.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team6)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+3$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score6;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                        if (
$ex[2]==$team5)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score5;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                       if (
$score5==$score6)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team5.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team5)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }

          
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+1;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+1;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+1;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+1;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team5.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team6.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+1;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+1;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+1;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+1;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team6.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team5)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+1$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score5;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                        if (
$ex[2]==$team6)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+1$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score6;
                                         
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                                                
$file=file(BASEDIR."manager1/italy/calendar.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[0]==$team5 && $ex[1]==$team6)
                                         {
                                          
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$score5."|".$score6."|"."rn";
                                         }

                }
                                
$fp=fopen(BASEDIR."manager1/italy/calendar.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
             echo 
$team5.' - '.$team6.' '.$score5.':'.$score6.'<br>';


       }

  
################################################

              
if ($exp[0]==$team7 && $exp[1]==$team8)
       {
       
$score7=(int)$score7;   $score8=(int)$score8;
###-------------------------------
if ($score7!==0)
    {
        
$fi=file(BASEDIR."manager1/italy/$team7.dat");
     for (
$k=0;$k<$score7;$k++)
         {
        
$raa=rand(8,10); 
        
$player1=$fi[$raa]; 
    
$rr=explode("|",$player1);
                               
$filez=file(BASEDIR."manager1/italy/b.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team7."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/b.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team7."|"."rn";
                                       }

                                
$fp=fopen(BASEDIR."manager1/italy/b.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
           }

     }
      if (
$score8!==0)
    {
     
$fi=file(BASEDIR."manager1/italy/$team8.dat");
     for (
$k=0;$k<$score8;$k++)
         {
        
$raa=rand(8,10);
        
$player2=$fi[$raa];
    
$rr=explode("|",$player2); 
                               
$filez=file(BASEDIR."manager1/italy/b.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team8."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/b.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team8."|"."rn";
                                       }
                                
$fp=fopen(BASEDIR."manager1/italy/b.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
           }
     }
if (
$score7!==0)
    {
        
$fi=file(BASEDIR."manager1/italy/$team7.dat");
     for (
$k=0;$k<$score7;$k++)
         {
        
$raa=rand(5,7); 
        
$player1=$fi[$raa]; 
    
$rr=explode("|",$player1);
                               
$filez=file(BASEDIR."manager1/italy/a.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team7."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/a.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team7."|"."rn";
                                       }

                                
$fp=fopen(BASEDIR."manager1/italy/a.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
           }

     }
      if (
$score8!==0)
    {
     
$fi=file(BASEDIR."manager1/italy/$team8.dat");
     for (
$k=0;$k<$score8;$k++)
         {
        
$raa=rand(5,7);
        
$player2=$fi[$raa];
    
$rr=explode("|",$player2); 
                               
$filez=file(BASEDIR."manager1/italy/a.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team8."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/a.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team8."|"."rn";
                                       }
                                
$fp=fopen(BASEDIR."manager1/italy/a.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
           }
     }



###-------------------------------
       
$exp[2]==$score7$exp[3]==$score8;
       
$f[$i]=$team7.'|'.$team8.'|'.$score7.'|'.$score8.'|';
                        if (
$score7>$score8)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team7.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team7)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }

                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+2;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+2;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+2;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team7.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team8.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];

                              if (
$mor && $mor<=105
                              {
$mor=$mor-2;}
                               if (
$z>&& $z<=105)
                               {
$z=$z-2;}
                               if (
$u>&& $u<=105)
                               { 
$u=$u+1;} 
                               if (
$pr>&&$pr<=105)
                               {
$pr=$pr-2;}
                               if (
$a>&& $a<=105)
                                { 
$a=$a-2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team8.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team7)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+3$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score7;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                      if (
$ex[2]==$team8)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score8;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                      if (
$score7<$score8)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team8.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
            
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+2;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+2;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+2;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team8.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team7.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team7)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }


                              if (
$mor && $mor<=105
                              {
$mor=$mor-2;}
                               if (
$z>&& $z<=105)
                               {
$z=$z-2;}
                               if (
$u>&& $u<=105)
                               { 
$u=$u+1;} 
                               if (
$pr>&&$pr<=105)
                               {
$pr=$pr-2;}
                               if (
$a>&& $a<=105)
                                { 
$a=$a-2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team7.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team8)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+3$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score8;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                        if (
$ex[2]==$team7)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score7;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                       if (
$score7==$score8)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team7.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team7)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }
          
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+1;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+1;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+1;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+1;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team7.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team8.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+1;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+1;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+1;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+1;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team8.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team7)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+1$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score7;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                        if (
$ex[2]==$team8)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+1$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score8;
                                         
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                        
$file=file(BASEDIR."manager1/italy/calendar.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[0]==$team7 && $ex[1]==$team8)
                                         {
                                          
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$score7."|".$score8."|"."rn";
                                         }

                }
                                
$fp=fopen(BASEDIR."manager1/italy/calendar.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
             echo 
$team7.' - '.$team8.' '.$score7.':'.$score8.'<br>';
       }


  
################################################

              
if ($exp[0]==$team9 && $exp[1]==$team10)
       {
       
$score9=(int)$score9;   $score10=(int)$score10;
###-------------------------------
if ($score9!==0)
    {
        
$fi=file(BASEDIR."manager1/italy/$team9.dat");
     for (
$k=0;$k<$score9;$k++)
         {
        
$raa=rand(8,10); 
        
$player1=$fi[$raa]; 
    
$rr=explode("|",$player1);
                               
$filez=file(BASEDIR."manager1/italy/b.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team9."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/b.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team9."|"."rn";
                                       }

                                
$fp=fopen(BASEDIR."manager1/italy/b.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 

          }
     }
      if (
$score10!==0)
    {
     
$fi=file(BASEDIR."manager1/italy/$team10.dat");
     for (
$k=0;$k<$score10;$k++)
         {
        
$raa=rand(8,10);
        
$player2=$fi[$raa];
    
$rr=explode("|",$player2); 
                               
$filez=file(BASEDIR."manager1/italy/b.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team10."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/b.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team10."|"."rn";
                                       }
                                
$fp=fopen(BASEDIR."manager1/italy/b.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
        }
     }
if (
$score9!==0)
    {
        
$fi=file(BASEDIR."manager1/italy/$team9.dat");
     for (
$k=0;$k<$score9;$k++)
         {
        
$raa=rand(5,7); 
        
$player1=$fi[$raa]; 
    
$rr=explode("|",$player1);
                               
$filez=file(BASEDIR."manager1/italy/a.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team9."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/a.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team9."|"."rn";
                                       }

                                
$fp=fopen(BASEDIR."manager1/italy/a.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
         }

     }
      if (
$score10!==0)
    {
     
$fi=file(BASEDIR."manager1/italy/$team10.dat");
     for (
$k=0;$k<$score10;$k++)
         {
        
$raa=rand(5,7);
        
$player2=$fi[$raa];
    
$rr=explode("|",$player2); 
                               
$filez=file(BASEDIR."manager1/italy/a.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team10."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/a.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team10."|"."rn";
                                       }
                                
$fp=fopen(BASEDIR."manager1/italy/a.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
         }
     }



###-------------------------------
       
$exp[2]==$score9$exp[3]==$score10;
       
$f[$i]=$team9.'|'.$team10.'|'.$score9.'|'.$score10.'|';
                        if (
$score9>$score10)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team9.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team9)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }


                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+2;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+2;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+2;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team9.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team10.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];

                              if (
$mor && $mor<=105
                              {
$mor=$mor-2;}
                               if (
$z>&& $z<=105)
                               {
$z=$z-2;}
                               if (
$u>&& $u<=105)
                               { 
$u=$u+1;} 
                               if (
$pr>&&$pr<=105)
                               {
$pr=$pr-2;}
                               if (
$a>&& $a<=105)
                                { 
$a=$a-2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team10.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team9)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+3$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score9;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                      if (
$ex[2]==$team10)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score10;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                      if (
$score9<$score10)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team10.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
            
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+2;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+2;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+2;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team10.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team9.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team9)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }


                              if (
$mor && $mor<=105
                              {
$mor=$mor-2;}
                               if (
$z>&& $z<=105)
                               {
$z=$z-2;}
                               if (
$u>&& $u<=105)
                               { 
$u=$u+1;} 
                               if (
$pr>&&$pr<=105)
                               {
$pr=$pr-2;}
                               if (
$a>&& $a<=105)
                                { 
$a=$a-2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team9.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team10)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+3$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score10;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                        if (
$ex[2]==$team9)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score9;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                       if (
$score9==$score10)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team9.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team9)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }

          
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+1;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+1;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+1;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+1;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team9.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team10.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+1;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+1;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+1;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+1;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team10.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team9)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+1$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score9;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                        if (
$ex[2]==$team10)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+1$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score10;
                                         
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                              

                           
$file=file(BASEDIR."manager1/italy/calendar.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[0]==$team9 && $ex[1]==$team10)
                                         {
                                          
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$score9."|".$score10."|"."rn";
                                         }

                }
                                
$fp=fopen(BASEDIR."manager1/italy/calendar.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
             echo 
$team9.' - '.$team10.' '.$score9.':'.$score10.'<br>';
       }

  
################################################

              
if ($exp[0]==$team11 && $exp[1]==$team12)
       {
       
$score11=(int)$score11;   $score12=(int)$score12;
###-------------------------------
if ($score11!==0)
    {
        
$fi=file(BASEDIR."manager1/italy/$team11.dat");
     for (
$k=0;$k<$score11;$k++)
         {
        
$raa=rand(8,10); 
        
$player1=$fi[$raa]; 
    
$rr=explode("|",$player1);
                               
$filez=file(BASEDIR."manager1/italy/b.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team11."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/b.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team11."|"."rn";
                                       }

                                
$fp=fopen(BASEDIR."manager1/italy/b.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
       }

     }
      if (
$score12!==0)
    {
     
$fi=file(BASEDIR."manager1/italy/$team12.dat");
     for (
$k=0;$k<$score12;$k++)
         {
        
$raa=rand(8,10);
        
$player2=$fi[$raa];
    
$rr=explode("|",$player2); 
                               
$filez=file(BASEDIR."manager1/italy/b.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team12."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/b.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team12."|"."rn";
                                       }
                                
$fp=fopen(BASEDIR."manager1/italy/b.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
          }
     }
if (
$score11!==0)
    {
        
$fi=file(BASEDIR."manager1/italy/$team11.dat");
     for (
$k=0;$k<$score11;$k++)
         {
        
$raa=rand(5,7); 
        
$player1=$fi[$raa]; 
    
$rr=explode("|",$player1);
                               
$filez=file(BASEDIR."manager1/italy/a.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team11."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/a.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team11."|"."rn";
                                       }

                                
$fp=fopen(BASEDIR."manager1/italy/a.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 

        }
     }
      if (
$score12!==0)
    {
     
$fi=file(BASEDIR."manager1/italy/$team12.dat");
     for (
$k=0;$k<$score12;$k++)
         {
        
$raa=rand(5,7);
        
$player2=$fi[$raa];
    
$rr=explode("|",$player2); 
                               
$filez=file(BASEDIR."manager1/italy/a.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team12."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/a.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team12."|"."rn";
                                       }
                                
$fp=fopen(BASEDIR."manager1/italy/a.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
           }
     }



###-------------------------------
       
$exp[2]==$score11$exp[3]==$score12;
       
$f[$i]=$team11.'|'.$team12.'|'.$score11.'|'.$score12.'|';
                        if (
$score11>$score12)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team11.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team11)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }

                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+2;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+2;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+2;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team11.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team12.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];

                              if (
$mor && $mor<=105
                              {
$mor=$mor-2;}
                               if (
$z>&& $z<=105)
                               {
$z=$z-2;}
                               if (
$u>&& $u<=105)
                               { 
$u=$u+1;} 
                               if (
$pr>&&$pr<=105)
                               {
$pr=$pr-2;}
                               if (
$a>&& $a<=105)
                                { 
$a=$a-2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team12.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team11)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+3$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score11;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                      if (
$ex[2]==$team12)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score12;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                      if (
$score11<$score12)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team12.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
            
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+2;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+2;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+2;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team12.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team11.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team11)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }


                              if (
$mor && $mor<=105
                              {
$mor=$mor-2;}
                               if (
$z>&& $z<=105)
                               {
$z=$z-2;}
                               if (
$u>&& $u<=105)
                               { 
$u=$u+1;} 
                               if (
$pr>&&$pr<=105)
                               {
$pr=$pr-2;}
                               if (
$a>&& $a<=105)
                                { 
$a=$a-2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team11.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team12)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+3$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score12;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                        if (
$ex[2]==$team11)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score11;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                       if (
$score11==$score12)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team11.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team11)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }
          
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+1;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+1;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+1;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+1;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team11.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team12.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+1;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+1;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+1;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+1;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team12.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team11)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+1$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score11;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                        if (
$ex[2]==$team12)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+1$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score12;
                                         
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                                  
                                
$file=file(BASEDIR."manager1/italy/calendar.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[0]==$team11 && $ex[1]==$team12)
                                         {
                                          
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$score11."|".$score12."|"."rn";
                                         }

                }
                                
$fp=fopen(BASEDIR."manager1/italy/calendar.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
             echo 
$team11.' - '.$team12.' '.$score11.':'.$score12.'<br>';
       }

  
################################################

              
if ($exp[0]==$team13 && $exp[1]==$team14)
       {
       
$score13=(int)$score13;   $score14=(int)$score14;
###-------------------------------
if ($score13!==0)
    {
        
$fi=file(BASEDIR."manager1/italy/$team13.dat");
     for (
$k=0;$k<$score13;$k++)
         {
        
$raa=rand(8,10); 
        
$player1=$fi[$raa]; 
    
$rr=explode("|",$player1);
                               
$filez=file(BASEDIR."manager1/italy/b.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team13."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/b.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team13."|"."rn";
                                       }

                                
$fp=fopen(BASEDIR."manager1/italy/b.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 

          }
     }
      if (
$score14!==0)
    {
     
$fi=file(BASEDIR."manager1/italy/$team14.dat");
     for (
$k=0;$k<$score14;$k++)
         {
        
$raa=rand(8,10);
        
$player2=$fi[$raa];
    
$rr=explode("|",$player2); 
                               
$filez=file(BASEDIR."manager1/italy/b.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team14."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/b.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team14."|"."rn";
                                       }
                                
$fp=fopen(BASEDIR."manager1/italy/b.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
          }
     }
if (
$score13!==0)
    {
        
$fi=file(BASEDIR."manager1/italy/$team13.dat");
     for (
$k=0;$k<$score13;$k++)
         {
        
$raa=rand(5,7); 
        
$player1=$fi[$raa]; 
    
$rr=explode("|",$player1);
                               
$filez=file(BASEDIR."manager1/italy/a.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team13."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/a.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team13."|"."rn";
                                       }

                                
$fp=fopen(BASEDIR."manager1/italy/a.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
        }

     }
      if (
$score14!==0)
    {
     
$fi=file(BASEDIR."manager1/italy/$team14.dat");
     for (
$k=0;$k<$score14;$k++)
         {
        
$raa=rand(5,7);
        
$player2=$fi[$raa];
    
$rr=explode("|",$player2); 
                               
$filez=file(BASEDIR."manager1/italy/a.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team14."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/a.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team14."|"."rn";
                                       }
                                
$fp=fopen(BASEDIR."manager1/italy/a.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
          }
     }



###-------------------------------
       
$exp[2]==$score13$exp[3]==$score14;
       
$f[$i]=$team13.'|'.$team14.'|'.$score13.'|'.$score14.'|';
                        if (
$score13>$score14)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team13.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team13)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }

                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+2;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+2;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+2;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team13.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team14.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];

                              if (
$mor && $mor<=105
                              {
$mor=$mor-2;}
                               if (
$z>&& $z<=105)
                               {
$z=$z-2;}
                               if (
$u>&& $u<=105)
                               { 
$u=$u+1;} 
                               if (
$pr>&&$pr<=105)
                               {
$pr=$pr-2;}
                               if (
$a>&& $a<=105)
                                { 
$a=$a-2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team14.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team13)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+3$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score13;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                      if (
$ex[2]==$team14)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score14;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                      if (
$score13<$score14)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team14.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
            
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+2;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+2;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+2;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team14.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team13.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team13)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }

                              if (
$mor && $mor<=105
                              {
$mor=$mor-2;}
                               if (
$z>&& $z<=105)
                               {
$z=$z-2;}
                               if (
$u>&& $u<=105)
                               { 
$u=$u+1;} 
                               if (
$pr>&&$pr<=105)
                               {
$pr=$pr-2;}
                               if (
$a>&& $a<=105)
                                { 
$a=$a-2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team13.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team14)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+3$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score14;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                        if (
$ex[2]==$team13)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score13;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                       if (
$score13==$score14)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team13.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team13)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }

          
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+1;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+1;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+1;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+1;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team13.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team14.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+1;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+1;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+1;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+1;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team14.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team13)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+1$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score13;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                        if (
$ex[2]==$team14)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+1$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score14;
                                         
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                                
$file=file(BASEDIR."manager1/italy/calendar.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[0]==$team13 && $ex[1]==$team14)
                                         {
                                          
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$score13."|".$score14."|"."rn";
                                         }

                }
                                
$fp=fopen(BASEDIR."manager1/italy/calendar.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
             echo 
$team13.' - '.$team14.' '.$score13.':'.$score14.'<br>';
       }

    
################################################

              
if ($exp[0]==$team15 && $exp[1]==$team16)
       {
       
$score15=(int)$score15;   $score16=(int)$score16;
###-------------------------------
if ($score15!==0)
    {
        
$fi=file(BASEDIR."manager1/italy/$team15.dat");
     for (
$k=0;$k<$score15;$k++)
         {
        
$raa=rand(8,10); 
        
$player1=$fi[$raa]; 
    
$rr=explode("|",$player1);
                               
$filez=file(BASEDIR."manager1/italy/b.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team15."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/b.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team15."|"."rn";
                                       }

                                
$fp=fopen(BASEDIR."manager1/italy/b.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
            }

     }
      if (
$score16!==0)
    {
     
$fi=file(BASEDIR."manager1/italy/$team16.dat");
     for (
$k=0;$k<$score16;$k++)
         {
        
$raa=rand(8,10);
        
$player2=$fi[$raa];
    
$rr=explode("|",$player2); 
                               
$filez=file(BASEDIR."manager1/italy/b.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team16."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/b.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team16."|"."rn";
                                       }
                                
$fp=fopen(BASEDIR."manager1/italy/b.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
         }
     }
if (
$score15!==0)
    {
        
$fi=file(BASEDIR."manager1/italy/$team15.dat");
     for (
$k=0;$k<$score15;$k++)
         {
        
$raa=rand(5,7); 
        
$player1=$fi[$raa]; 
    
$rr=explode("|",$player1);
                               
$filez=file(BASEDIR."manager1/italy/a.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team15."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/a.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team15."|"."rn";
                                       }

                                
$fp=fopen(BASEDIR."manager1/italy/a.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
          }

     }
      if (
$score16!==0)
    {
     
$fi=file(BASEDIR."manager1/italy/$team16.dat");
     for (
$k=0;$k<$score16;$k++)
         {
        
$raa=rand(5,7);
        
$player2=$fi[$raa];
    
$rr=explode("|",$player2); 
                               
$filez=file(BASEDIR."manager1/italy/a.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team16."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/a.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team16."|"."rn";
                                       }
                                
$fp=fopen(BASEDIR."manager1/italy/a.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
           }
     }



###-------------------------------
       
$exp[2]==$score15$exp[3]==$score16;
       
$f[$i]=$team15.'|'.$team16.'|'.$score15.'|'.$score16.'|';
                        if (
$score15>$score16)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team15.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team15)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }

                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+2;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+2;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+2;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team15.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team16.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];

                              if (
$mor && $mor<=105
                              {
$mor=$mor-2;}
                               if (
$z>&& $z<=105)
                               {
$z=$z-2;}
                               if (
$u>&& $u<=105)
                               { 
$u=$u+1;} 
                               if (
$pr>&&$pr<=105)
                               {
$pr=$pr-2;}
                               if (
$a>&& $a<=105)
                                { 
$a=$a-2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team16.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team15)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+3$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score15;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                      if (
$ex[2]==$team16)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score16;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                      if (
$score15<$score16)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team16.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
        
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+2;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+2;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+2;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team16.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team15.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team15)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }


                              if (
$mor && $mor<=105
                              {
$mor=$mor-2;}
                               if (
$z>&& $z<=105)
                               {
$z=$z-2;}
                               if (
$u>&& $u<=105)
                               { 
$u=$u+1;} 
                               if (
$pr>&&$pr<=105)
                               {
$pr=$pr-2;}
                               if (
$a>&& $a<=105)
                                { 
$a=$a-2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team15.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team16)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+3$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score16;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                        if (
$ex[2]==$team15)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score15;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                       if (
$score15==$score16)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team15.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team15)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }

          
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+1;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+1;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+1;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+1;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team15.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team16.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+1;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+1;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+1;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+1;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team16.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team15)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+1$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score15;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                        if (
$ex[2]==$team16)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+1$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score16;
                                         
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                                   
$file=file(BASEDIR."manager1/italy/calendar.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[0]==$team15 && $ex[1]==$team16)
                                         {
                                          
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$score15."|".$score16."|"."rn";
                                         }

                }
                                
$fp=fopen(BASEDIR."manager1/italy/calendar.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
             echo 
$team15.' - '.$team16.' '.$score15.':'.$score16.'<br>';
       }


    
################################################

              
if ($exp[0]==$team17 && $exp[1]==$team18)
       {
       
$score17=(int)$score17;   $score18=(int)$score18;
###-------------------------------
if ($score17!==0)
    {
        
$fi=file(BASEDIR."manager1/italy/$team17.dat");
     for (
$k=0;$k<$score17;$k++)
         {
        
$raa=rand(8,10); 
        
$player1=$fi[$raa]; 
    
$rr=explode("|",$player1);
                               
$filez=file(BASEDIR."manager1/italy/b.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team17."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/b.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team17."|"."rn";
                                       }

                                
$fp=fopen(BASEDIR."manager1/italy/b.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
        }

     }
      if (
$score18!==0)
    {
     
$fi=file(BASEDIR."manager1/italy/$team18.dat");
     for (
$k=0;$k<$score18;$k++)
         {
        
$raa=rand(8,10);
        
$player2=$fi[$raa];
    
$rr=explode("|",$player2); 
                               
$filez=file(BASEDIR."manager1/italy/b.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team18."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/b.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team18."|"."rn";
                                       }
                                
$fp=fopen(BASEDIR."manager1/italy/b.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
         }
     }
if (
$score17!==0)
    {
        
$fi=file(BASEDIR."manager1/italy/$team17.dat");
     for (
$k=0;$k<$score17;$k++)
         {
        
$raa=rand(5,7); 
        
$player1=$fi[$raa]; 
    
$rr=explode("|",$player1);
                               
$filez=file(BASEDIR."manager1/italy/a.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team17."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/a.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team17."|"."rn";
                                       }

                                
$fp=fopen(BASEDIR."manager1/italy/a.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
         }

     }
      if (
$score18!==0)
    {
     
$fi=file(BASEDIR."manager1/italy/$team18.dat");
     for (
$k=0;$k<$score18;$k++)
         {
        
$raa=rand(5,7);
        
$player2=$fi[$raa];
    
$rr=explode("|",$player2); 
                               
$filez=file(BASEDIR."manager1/italy/a.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team18."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/a.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team18."|"."rn";
                                       }
                                
$fp=fopen(BASEDIR."manager1/italy/a.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
           }
     }



###-------------------------------
       
$exp[2]==$score17$exp[3]==$score18;
       
$f[$i]=$team17.'|'.$team18.'|'.$score17.'|'.$score18.'|';
                        if (
$score17>$score18)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team17.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team17)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }

                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+2;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+2;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+2;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team17.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team18.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];

                              if (
$mor && $mor<=105
                              {
$mor=$mor-2;}
                               if (
$z>&& $z<=105)
                               {
$z=$z-2;}
                               if (
$u>&& $u<=105)
                               { 
$u=$u+1;} 
                               if (
$pr>&&$pr<=105)
                               {
$pr=$pr-2;}
                               if (
$a>&& $a<=105)
                                { 
$a=$a-2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team18.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team17)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+3$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score17;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                      if (
$ex[2]==$team18)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score18;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                      if (
$score17<$score18)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team18.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
        
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+2;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+2;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+2;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team18.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team17.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team17)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }


                              if (
$mor && $mor<=105
                              {
$mor=$mor-2;}
                               if (
$z>&& $z<=105)
                               {
$z=$z-2;}
                               if (
$u>&& $u<=105)
                               { 
$u=$u+1;} 
                               if (
$pr>&&$pr<=105)
                               {
$pr=$pr-2;}
                               if (
$a>&& $a<=105)
                                { 
$a=$a-2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team17.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team18)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+3$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score18;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                        if (
$ex[2]==$team17)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score17;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                       if (
$score17==$score18)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team17.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team17)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }

          
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+1;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+1;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+1;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+1;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team17.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team18.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+1;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+1;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+1;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+1;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team18.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team17)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+1$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score17;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                        if (
$ex[2]==$team18)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+1$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score18;
                                         
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                                
$file=file(BASEDIR."manager1/italy/calendar.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[0]==$team17 && $ex[1]==$team18)
                                         {
                                          
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$score17."|".$score18."|"."rn";
                                         }

                }
                                
$fp=fopen(BASEDIR."manager1/italy/calendar.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
             echo 
$team17.' - '.$team18.' '.$score17.':'.$score18.'<br>';
       }

     
################################################

              
if ($exp[0]==$team19 && $exp[1]==$team20)
       {
       
$score19=(int)$score19;   $score20=(int)$score20;
###-------------------------------
if ($score19!==0)
    {
        
$fi=file(BASEDIR."manager1/italy/$team19.dat");
     for (
$k=0;$k<$score19;$k++)
         {
        
$raa=rand(8,10); 
        
$player1=$fi[$raa]; 
    
$rr=explode("|",$player1);
                               
$filez=file(BASEDIR."manager1/italy/b.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team19."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/b.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team19."|"."rn";
                                       }

                                
$fp=fopen(BASEDIR."manager1/italy/b.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
         }

     }
      if (
$score20!==0)
    {
     
$fi=file(BASEDIR."manager1/italy/$team20.dat");
     for (
$k=0;$k<$score20;$k++)
         {
        
$raa=rand(8,10);
        
$player2=$fi[$raa];
    
$rr=explode("|",$player2); 
                               
$filez=file(BASEDIR."manager1/italy/b.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team20."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/b.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team20."|"."rn";
                                       }
                                
$fp=fopen(BASEDIR."manager1/italy/b.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
        }
     }
if (
$score19!==0)
    {
        
$fi=file(BASEDIR."manager1/italy/$team19.dat");
     for (
$k=0;$k<$score19;$k++)
         {
        
$raa=rand(5,7); 
        
$player1=$fi[$raa]; 
    
$rr=explode("|",$player1);
                               
$filez=file(BASEDIR."manager1/italy/a.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team19."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/a.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team19."|"."rn";
                                       }

                                
$fp=fopen(BASEDIR."manager1/italy/a.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
         }

     }
      if (
$score20!==0)
    {
     
$fi=file(BASEDIR."manager1/italy/$team20.dat");
     for (
$k=0;$k<$score20;$k++)
         {
        
$raa=rand(5,7);
        
$player2=$fi[$raa];
    
$rr=explode("|",$player2); 
                               
$filez=file(BASEDIR."manager1/italy/a.dat");
                   for(
$i=0;$i<count($filez);$i++)
                               {
                                
$exu=explode("|",$filez[$i]);
                                        if (
$exu[1]==$rr[0])
                                         {
                                          
$exu[0]=(int)$exu[0]; $exu[0]=$exu[0]+1;
                                          
$filez[$i]=$exu[0]."|".$rr[0]."|".$team20."|"."rn";
                                         }
                }
                  
$rub=file_get_contents(BASEDIR."manager1/italy/a.dat");
                  if (!
ereg('|'.$rr[0].'|',$rub))
                      {
                                        
$filez[$i]="1|".$rr[0]."|".$team20."|"."rn";
                                       }
                                
$fp=fopen(BASEDIR."manager1/italy/a.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($filez);$i++)
                                  {
                                  
fputs($fp,$filez[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp); 
         }
     }



###-------------------------------
       
$exp[2]==$score19$exp[3]==$score20;
       
$f[$i]=$team19.'|'.$team20.'|'.$score19.'|'.$score20.'|';
                        if (
$score19>$score20)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team19.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team19)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }

                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+2;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+2;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+2;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team19.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team20.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];

                              if (
$mor && $mor<=105
                              {
$mor=$mor-2;}
                               if (
$z>&& $z<=105)
                               {
$z=$z-2;}
                               if (
$u>&& $u<=105)
                               { 
$u=$u+1;} 
                               if (
$pr>&&$pr<=105)
                               {
$pr=$pr-2;}
                               if (
$a>&& $a<=105)
                                { 
$a=$a-2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team20.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team19)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+3$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score19;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                      if (
$ex[2]==$team20)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score20;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                      if (
$score19<$score20)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team20.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
        
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+2;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+2;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+2;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team20.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team19.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team19)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }


                              if (
$mor && $mor<=105
                              {
$mor=$mor-2;}
                               if (
$z>&& $z<=105)
                               {
$z=$z-2;}
                               if (
$u>&& $u<=105)
                               { 
$u=$u+1;} 
                               if (
$pr>&&$pr<=105)
                               {
$pr=$pr-2;}
                               if (
$a>&& $a<=105)
                                { 
$a=$a-2;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team19.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team20)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+3$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score20;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                        if (
$ex[2]==$team19)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score19;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                       if (
$score19==$score20)
                        {
                        
$rest=file(BASEDIR."manager1/italy/$team19.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

            
$stad=file(BASEDIR."manager1/stadiums.dat");
                        for (
$k=0;$k<count($stad);$k++)
                            {
                
$se=explode("|",$stad[$k]);
                                    if (
$se[0]==$team19)
                                        {
                                        
$mest=$se[1];
                                        }
                            }

                        
$money=(int)$ex[0];   $mest=(int)$mest;
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
              if (
$mest<$fans)
                             {
            
$money=$money+$mest;
                  }
                           if (
$mest>=$fans)
                             {
                        
$money=$money+$fans;
                             }

          
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+1;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+1;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+1;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+1;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team19.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);
                        
                        
$rest=file(BASEDIR."manager1/italy/$team20.txt");
                        foreach (
$rest as $key=>$val)
                        {
                        
$ex=explode("|",$val);
                        }

                        
$money=(int)$ex[0];
                        
$fans=(int)$ex[1]; $mor=(int)$ex[3]; $z=(int)$ex[4]; $u=(int)$ex[5];
                        
$pr=(int)$ex[6]; $a=(int)$ex[9];
          
                              if (
$mor >= -&& $mor<=98
                              {
$mor=$mor+1;}
                               if (
$z >= -&& $z<=98)
                               {
$z=$z+1;}
                               if (
$u>=-10 && $u<=98)
                               { 
$u=$u+1;} 
                               if (
$pr>=-&&$pr<=98)
                               {
$pr=$pr+1;}
                               if (
$a>=-&& $a<=98)
                                { 
$a=$a+1;}
                        
$fp=fopen(BASEDIR."manager1/italy/$team20.txt","a+");
                        
flock ($fp,LOCK_EX);
                        
ftruncate ($fp,0);
                        
fputs($fp,$money."|".$fans."|".$ex[2]."|".$mor."|".$z."|".$u."|".$pr."|".$ex[7]."|".$ex[8]."|".$a."|");
                        
fflush ($fp);
                        
flock ($fp,LOCK_UN);
                        
fclose($fp);

                               
$file=file(BASEDIR."manager1/italy/t.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[2]==$team19)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+1$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score19;
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                                        if (
$ex[2]==$team20)
                                         {
                                          
$ex[0]=(int)$ex[0]; $ex[0]=$ex[0]+1$ex[1]=(int)$ex[1]; $ex[1]=$ex[1]+$score20;
                                         
$file[$i]=$ex[0]."|".$ex[1]."|".$ex[2]."|"."rn";
                                         }
                }
                                
$fp=fopen(BASEDIR."manager1/italy/t.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
                        }
                                  
$file=file(BASEDIR."manager1/italy/calendar.dat");
                   for(
$i=0;$i<count($file);$i++)
                               {
                                
$ex=explode("|",$file[$i]);
                                        if (
$ex[0]==$team19 && $ex[1]==$team20)
                                         {
                                          
                                          
$file[$i]=$ex[0]."|".$ex[1]."|".$score19."|".$score20."|"."rn";
                                         }

                }
                                
$fp=fopen(BASEDIR."manager1/italy/calendar.dat","a+");
                                
ftruncate ($fp,0);
                                  for (
$i=0;$i<count($file);$i++)
                                  {
                                  
fputs($fp,$file[$i]);
                          }
                                  
fflush ($fp);
                                  
flock ($fp,LOCK_UN);
                                  
fclose($fp);
             echo 
$team19.' - '.$team20.' '.$score19.':'.$score20.'<br>';
       }








   }

                                 
$fp=fopen(BASEDIR."manager1/italy/prev.dat","a+");
                                
ftruncate ($fp,0);
                           
fputs($fp,$team1." - ".$team2." ".$score1.":".$score2."rn");
fputs($fp,$team3." - ".$team4." ".$score3.":".$score4."rn");
fputs($fp,$team5." - ".$team6." ".$score5.":".$score6."rn");
fputs($fp,$team7." - ".$team8." ".$score7.":".$score8."rn");
fputs($fp,$team9." - ".$team10." ".$score9.":".$score10."rn");
fputs($fp,$team11." - ".$team12." ".$score11.":".$score12."rn");
fputs($fp,$team13." - ".$team14." ".$score13.":".$score14."rn");
fputs($fp,$team15." - ".$team16." ".$score15.":".$score16."rn");
fputs($fp,$team17." - ".$team18." ".$score17.":".$score18."rn");
fputs($fp,$team19." - ".$team20." ".$score19.":".$score20."rn");

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


}






echo 
'<hr>[<a href="index.php">В АДМИНКУ</a>]<br>';
    
    }else{ echo 
'ВЫ НЕ МОЖЕТЕ ПРОСМАТРИВАТЬ АДМИН-ПАНЕЛЬ ИЗ-ЗА ОГРАНИЧЕНИЙ!!!<br>'; }










}else{
echo 
'<br>Вы не авторизованы! Чтобы начать игру необходимо<br>';
echo 
'<b><a href="../pages/vhod.php?'.SID.'">Авторизоваться</a></b> или в начале <b><a href="../pages/registration.php?'.SID.'">Зарегистрироваться</a><br><br>';
}




echo
'<br><a href="../../index.php?'.SID.'">На главную</a>'
include_once
"../../themes/$config_themes/foot.php";
?>
Онлайн: 0
Реклама