Размер файла: 4.71Kb
<?php
include_once'../system/xcms_core.php';$title='Выбор города';
if($_COOKIE['style']=='web')require_once '../system/web_head.php'; else require_once '../system/head.php';
if($user){
echo'<div class="menu" style="text-align:center;"><a href="/my/edit/profile">Профиль</a> | <a href="/my/edit/avatar">Аватар</a> | <a href="/my/edit/status">Статус</a> | Город</div>
<div class="touch menu"><a href="/my/edit/city/search" style="text-align:center;">Поиск города</a></div>';
switch($act){
case 'search':
if(!empty($_POST['text'])){
$text=protect($_POST['text']);
$text_strl=strlen($text);
if($text_strl>$da['min_simb']){
$total=$db->query("select `city_id` from `city` where `name` like '%$text%'")->rowCount();
if($total){
$sql=$db->query("select * from `city` where `name` like '%$text' order by `name` asc");
echo'<div class="touch">';
while($res=$sql->fetch(PDO::FETCH_ASSOC)){
$str=$db->query("select `name` from `country` where `country_id`='$res[country_id]'")->fetch(PDO::FETCH_ASSOC);
$reg=$db->query("select `name` from `region` where `region_id`='$res[region_id]'")->fetch(PDO::FETCH_ASSOC);
echo'<div class="menu"><a href="/my/edit/city/city'.$res['city_id'].'">'.$res['name'].' ('.$str['name'].', '.$reg['name'].')</a></div>';
}
echo'</div>';
}else{echo'<div class="menu">Город не найден</div>';}
}else{echo'<div class="menu">Мин. длина текста - '.$da['min_simb'].' символов</div>';}
}else{
echo'<form action="#" method="post"><div class="menu">
Название города: <input type="text" name="text"><input type="submit" value="Искать">
</div></form>';
}
back('/my/edit/city');
break;
case 'city':
$q=$db->query("select * from `city` where `city_id`='$id'")->fetch(PDO::FETCH_ASSOC);
if($q){
$db->prepare("update `user` set `city`='$id', `country`='$q[country_id]' where `id`='$user[id]'")->execute();
echo'<div class="menu">Город выбран → <a href="/profile'.$user['id'].'">Далее</a></div>';
}else{echo'<div class="menu">Ошибка</div>';}
back('/my/edit/city');
break;
case 'region':
$q=$db->query("select * from `region` where `region_id`='$id'")->fetch(PDO::FETCH_ASSOC);
if($q){
$total=$db->query("select `city_id` from `city` where `region_id`='$id'")->rowCount();
if($total){
$k_page=k_page($total,$set['p_str']);$page=page($k_page);$start=$set['p_str']*$page-$set['p_str'];
$sql=$db->query("select * from `city` where `region_id`='$id' order by `name` asc limit $start, $set[p_str]");
echo'<div class="touch">';
while($res=$sql->fetch(PDO::FETCH_ASSOC))
echo'<div class="menu"><a href="/my/edit/city/city'.$res['city_id'].'">'.$res['name'].'</a></div>';
echo'</div>';
if ($k_page>1)str('/my/edit/city/region'.$id.'/',$k_page,$page);
}else{echo'<div class="menu">Пусто</div>';}
}else{echo'<div class="menu">Ошибка</div>';}
back('/my/edit/city');
break;
case 'country':
$q=$db->query("select * from `country` where `country_id`='$id'")->fetch(PDO::FETCH_ASSOC);
if($q){
$total=$db->query("select `region_id` from `region` where `country_id`='$id'")->rowCount();
if($total){
$k_page=k_page($total,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$sql=$db->query("select * from `region` where `country_id`='$id' order by `name` asc limit $start, $set[p_str]");
echo'<div class="touch">';
while($res=$sql->fetch(PDO::FETCH_ASSOC))
echo'<div class="menu"><a href="/my/edit/city/region'.$res['region_id'].'">'.$res['name'].'</a></div>';
echo'</div>';
if ($k_page>1)str('/my/edit/city/'.$id.'/',$k_page,$page);
}else{echo'<div class="menu">Пусто</div>';}
}else{echo'<div class="menu">Ошибка</div>';}
back('/my/edit/city');
break;
default:
$total=$db->query("select `country_id` from `country`")->rowCount();
if($total){
$k_page=k_page($total,$set['p_str']);$page=page($k_page);$start=$set['p_str']*$page-$set['p_str'];
$sql=$db->query("select * from `country` order by `name` asc limit $start, $set[p_str]");
echo'<div class="touch">';
while($res=$sql->fetch(PDO::FETCH_ASSOC)){
echo'<div class="menu"><a href="/my/edit/city/'.$res['country_id'].'">'.$res['name'].'</a></div>';
}
echo'</div>';
if ($k_page>1)str('/my/edit/city/',$k_page,$page);
}else{echo'<div class="menu">Пусто</div>';}
back('/profile'.$user['id']);
}
}else{echo'<div class="menu">Ошибка</div>';}
if($_COOKIE['style']=='web')require_once '../system/web_foot.php'; else require_once '../system/foot.php';
?>