<?
define('PROTECTOR', 1);

$headmod = 'portal';//фикс. места

$textl='Портал';
@include('files/db.php');
@include('files/auth.php');
@include('files/func.php');
going();
ryd();
place_okr();
place_tower();
@include('files/core.php');
@include('files/head.php');
@include('files/zag.php');

switch($_GET[mod]){

default:
echo"<b>Города:</b><br/>$div";
$req = mysql_query("SELECT * FROM `portal` WHERE `incity` = '$udata[city]'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
While($mag = mysql_fetch_array($req))
{
echo"<img src='pic/main/gate.png' alt='*'/> <a href=\"portal.php?mod=go&amp;id=$mag[id]&amp;tip=city\">$mag[name]</a> [<img src='pic/up.png' alt='*'/>$mag[lvl] ] ($mag[money] монет)<br/>";}}else{
echo"Нет активных порталов<br/>";}
break;

case 'go':
$req = mysql_query("SELECT * FROM `portal` WHERE `incity` = '$udata[city]' and id='$_GET[id]'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
$mag = mysql_fetch_array($req);
if($udata[money]<$mag[money]){
echo'Нехватает денег!<br/>';
}elseif($udata[lvl]<$mag[lvl]){
echo'Маленький уровень!<br/>';}else{
switch($_GET[tip]){
default:
echo'Ошибка!Несуществует такого портала!';
include('files/down.php');exit;
break;
case 'city':
$udata[money]=$udata[money]-$mag[money];
mysql_query("UPDATE `users` SET `money` = '$udata[money]',`city`='$mag[city]' WHERE `usr` = '$log'");
echo"Вы прибыли в $mag[name]!<br/>";
echo"<a href=\"gorod.php?\">Далее</a>";
include('files/down.php');exit;
break;
}}}else{
echo"<b>Нет такого портала!</b><br/>";}
echo"<a href=\"portal.php?\">Назад</a>";
break;}
include('files/down.php');
?>