Просмотр файла public_html/vis/game.php

Размер файла: 6.33Kb
<?php
# Made by: Solo  #
# Site: Wapik.us #
# ICQ: 921937    #
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";
include_once"adm.php";

echo '<div align="center"><b><font color="green">Виселица</font></b></div>';

if (md5($_SESSION['par'])!==$provpar || $_SESSION['log']!==$provlog || $_SESSION['log']=="" || md5($_SESSION['par'])=="")
{
	echo 'Для начала Вам необходимо <a href="../pages/vhod.php12?'.SID.'">авторизоваться</a> или <a href="../pages/registration.php?'.SID.'">зарегистрироваться</a><br>';
	echo '<br><img src="../images/img/homepage.gif" alt=""> <a href="../index.php?'.SID.'">На главную</a>';
	include_once"../themes/".$config_themes."/foot.php";
	exit;
}

if(!isset($_GET['action']))
{
	if(!file_exists(BASEDIR."local/vis/game/".$log.".dat"))
	{
		$bas=file(BASEDIR."local/vis/base.dat");
		$max=count($bas);
		$vibor=rand(0, $max);
		$base=explode("|", $bas[$vibor]);
		$slovo=utf_to_win(trim($base[1]));
		$opis=$base[0];
        $slovo1=eregi_replace("[^*]","*", $slovo);
        $slovo=win_to_utf($slovo);
        $slovo1=win_to_utf($slovo1);
		$file="".$log.":||:".$slovo.":||:".$slovo1.":||:1:||:".$opis.":||:\r\n";
		$fm=fopen(BASEDIR."local/vis/game/".$log.".dat","w+");
		flock($fm,LOCK_EX);
		fputs($fm,$file);
		fflush($fm);
		flock($fm,LOCK_UN);
		fclose($fm);
		chmod(BASEDIR."local/vis/game/".$log.".dat", 0666);
	}
  	$igra=file(BASEDIR."local/vis/game/".$log.".dat");
  	$hod=explode(":||:", $igra[0]);

  //-----------------------------------------------------------//
  //
  if($hod[1]==$hod[2] || (int)$hod[3]>6 && file_exists(BASEDIR."local/vis/game/".$log.".dat"))
  {
 		$fai = @file(BASEDIR."local/vis/prof/".$log.".dat");
		$udi = explode(":||:",$fai[0]);
		if((int)$hod[3]<7)
     	{
      		echo '<font color="green"><b>Вы выиграли!</b></font><br>';
      		$udi[1]++;
      		$mon=$monv;
      		$ball=$ballv;
     	}
		else
     	{
      		echo '<font color="red"><b>Вы проиграли!</b></font><br>';
      		$udi[2]++;
      		$mon=$monp;
      		$ball=$ballp;
        }
     	echo '<img src="img/'.$hod[3].'.gif" alt="'.$hod[3].'"><br>';
     	echo 'Искомое слово: <b>'.$hod[1].'</b><br>';
     	echo 'Получите <b>'.$mon.'</b> монет и <b>'.$ball.'</b> баллов<br>';
		$file="".$log.":||:".$udi[1].":||:".$udi[2].":||:\r\n";
		$fm=fopen(BASEDIR."local/vis/prof/".$log.".dat","w+");
		fputs($fm,$file);
		fflush($fm);
		fclose($fm);
		chmod(BASEDIR."local/vis/prof/".$log.".dat", 0666);

		$fa = @file("../local/profil/".$log.".prof");
		$udata = explode(":||:",$fa[0]);
		$udata[41]=$udata[41]+$mon;
		$udata[36]=$udata[36]+$ball;
		for ($u=0; $u<200; $u++){
		$utext.=$udata[$u].':||:';}
		if($udata[0]!="" && $udata[1]!="" && $udata[4]!="" && $utext!="")
		{
			$fp=fopen(BASEDIR."local/profil/".$log.".prof","a+");
			ftruncate($fp,0);
			fputs($fp,$utext);
			fflush($fp);
			fclose($fp);
  			unset($utext);
		}
		unlink(BASEDIR."local/vis/game/".$log.".dat");
		echo '<br><br><img src="../images/img/homepage.gif" alt=""> <a href="index.php?'.SID.'">В меню</a>';
    	include_once"../themes/".$config_themes."/foot.php";
    	exit;
  }
  //
  //-------------------------------------------------------------------//

  if($_GET['is']=="ugad")
  {
    echo '<font color="green"><b>Буква угадана!</b></font><br>';
  }
  if($_GET['is']=="neugad")
  {
    echo '<font color="red"><b>В слове нет такой буквы!</b></font><br>';
  }
  if($_GET['is']=="no")
  {
    echo '<font color="red"><b>Не введена буква!</b></font><br>';
  }
	echo '<img src="img/'.$hod[3].'.gif" alt="'.$hod[3].'"><br>';
	if($hod[4]!="")
	{
	 echo 'Подсказка: '.$hod[4].'<br>';
	}
	echo '<b>'.$hod[2].'</b><br>';
	echo '<br><form action="game.php?action=hod&amp;'.SID.'" method="post" name="form">';
	echo '<b>Буква: </b>';
	echo '<input type="text" name="buk" maxlength="1" size="1"><br>';
	echo '<input type="submit" value="Проверить"></form>';
}

if($_GET['action']=="hod" && file_exists(BASEDIR."local/vis/game/".$log.".dat"))
{
  $buk=$_POST['buk'];
  $buk=strtr($buk,array("А"=>"а","Б"=>"б","В"=>"в","Г"=>"г","Д"=>"д","Е"=>"е","Ё"=>"ё","Ж"=>"ж","З"=>"з","И"=>"и","Й"=>"й","К"=>"к","Л"=>"л","М"=>"м","Н"=>"н","О"=>"о","П"=>"п","Р"=>"р","С"=>"с","Т"=>"т","У"=>"у","Ф"=>"ф","Х"=>"х","Ц"=>"ц","Ч"=>"ч","Ш"=>"ш","Щ"=>"щ","Ъ"=>"ъ","Ы"=>"ы","Ь"=>"ь","Э"=>"э","Ю"=>"ю","Я"=>"я"));
  $buk=utf_to_win($buk);
  $buk=substr($buk,0,1);
  if($buk=="")
  {
  	header("location: game.php?is=no&".SID);
    exit;
  }
  unset($igra, $hod);
  $igra=file(BASEDIR."local/vis/game/".$log.".dat");
  $hod=explode(":||:", $igra[0]);
  $hod[1]=utf_to_win($hod[1]);
  $hod[2]=utf_to_win($hod[2]);
  $prov=str_replace($buk,"",$hod[1]);

  if($hod[1]!=$prov)
  {
    unset($t);
    for($i=0;$i<strlen($hod[1]);$i++)
    {
      $g=substr($hod[1], $i, 1);
      if($g==$buk)
      {
        $t.=substr($hod[1],$i,1);
      }
      else
      {
        $t.=substr($hod[2],$i,1);
      }
    }
    $hod[1]=win_to_utf($hod[1]);
    $t=win_to_utf($t);
    $file="".$hod[0].":||:".$hod[1].":||:".$t.":||:".$hod[3].":||:".$hod[4].":||:\r\n";
	$fm=fopen(BASEDIR."local/vis/game/".$log.".dat","w+");
	fputs($fm,$file);
	fflush($fm);
	fclose($fm);
	chmod(BASEDIR."local/vis/game/".$log.".dat", 0666);
    header("location: game.php?is=ugad&".SID);
    exit;
  }
  else
  {
    $hod[3]=(int)$hod[3]+1;
    $hod[1]=win_to_utf($hod[1]);
  	$hod[2]=win_to_utf($hod[2]);
    $file="".$hod[0].":||:".$hod[1].":||:".$hod[2].":||:".$hod[3].":||:".$hod[4].":||:\r\n";
	$fm=fopen(BASEDIR."local/vis/game/".$log.".dat","w+");
	fputs($fm,$file);
	fflush($fm);
	fclose($fm);
	chmod(BASEDIR."local/vis/game/".$log.".dat", 0666);
    header("location: game.php?is=neugad&".SID);
    exit;
  }
}

echo '<br><br><img src="../images/img/homepage.gif" alt=""> <a href="index.php?'.SID.'">В меню</a>';
include_once"../themes/".$config_themes."/foot.php";
?>