<?php
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
$set['title']='Мой тамагочи';
include_once '../sys/inc/thead.php';
title();
aut();
only_reg();
err();
$ust = 1;
$tam=mysql_fetch_assoc(mysql_query("SELECT * FROM `tamag` WHERE `id_user` = '".$user['id']."' LIMIT 1"));
if($tam['ustamag'] ==0) {
mysql_query("INSERT INTO `tamag` (`id_user` ,`ustamag` ) VALUES(".$user['id']." , ".$ust.")");
header('Location: my.php');exit;
}
if (isset($_GET['ed']) and $_GET['ed']=='ed1') {
if($tam['eda'] != 100) {
mysql_query("UPDATE `tamag` SET `eda` = 100 , `raz` = `raz` + 1 WHERE `id_user` = '" . $user['id'] . "' LIMIT 1");
header('Location: my.php');exit;
}
}
if (isset($_GET['ed2']) and $_GET['ed2']=='ed12') {
if($user['money'] >5) {
mysql_query("UPDATE `tamag` SET `eda` = 100 , `raz` = `raz` + 1 WHERE `id_user` = '" . $user['id'] . "' LIMIT 1");
mysql_query("UPDATE `user` SET `money` = `money` - 5 WHERE `id` = '" . $user['id'] . "' LIMIT 1");
$_SESSION['message'] = 'Успешно! + 1 к развитию!';
header("Location: ?");
exit;
} else {
$_SESSION['err'] = 'Не достаточно монет!';
}
header('Location: ?'); exit;
}
Echo '<center><div class="nav2"><img src="img/razv.png" width="15px"/>Развитие ('.$tam['raz'].') <img src="img/eda.png" width="15px"/>Сытость ('.$tam['eda'].')<br><img src="img/1.png" width="20%"/></div></center>';
Echo '<div class="nav2">';
if($tam['eda'] != 100) {
Echo '<img src="img/eda.png" width="15px"/> <a href = "?ed=ed1">Покормить</a>';
} else {
Echo '<img src="img/eda.png" width="15px"/> <a href = "?ed2=ed12">Покормить </a> 5 монет';
}
Echo '</div>';
Echo '<div class="nav2"><img src="/tamagochi/img/1.png" width="15px"/> <a href = "rating.php">Топ лидеры</a></div>';
Echo '<div class="nav2"><img src="/tamagochi/img/1.png" width="15px"/> <a href = "info.php">Информация</a></div>';
include_once '../sys/inc/tfoot.php';