Просмотр файла 2/3020.ru/users/profile/form/content/geo.php

Размер файла: 5.71Kb
<?php
  
ACCESS('users');
  
IF ($account['ID'] != $user['ID']){
  
  REDIRECT('/');
  
}
  
ECHO "<div class='navigation'>";
ECHO "<a href='/'>".ICONS('home', 25, 'fa-fw')."</a>";
ECHO "".ICONS('angle-right', 22, 'fa-fw')."";
ECHO "<a href='/id".$account['ID']."'>".TEXT_ABSOLUTE($account['LOGIN'])."</a>";
ECHO "".ICONS('angle-right', 22, 'fa-fw')."";
ECHO "<a href='/users/profile/?path=form&id=".$account['ID']."'>".LG('Личная информация')."</a>";
ECHO "".ICONS('angle-right', 22, 'fa-fw')."";
ECHO "".LG('Место проживания')."";
ECHO "</div>";

/*
-------------------------------
Выбор города/населенного пункта
-------------------------------
*/

IF (GET('get') == 'city' && ISSET($_SESSION['country']) && DB::GET_COLUMN("SELECT COUNT(*) FROM `COUNTRY` WHERE `ID` = '".INTVAL($_SESSION['country'])."' LIMIT 1") == 1 && ISSET($_SESSION['region']) && DB::GET_COLUMN("SELECT COUNT(*) FROM `REGION` WHERE `ID` = '".INTVAL($_SESSION['region'])."' AND `ID_COUNTRY` = '".INTVAL($_SESSION['country'])."' LIMIT 1") == 1){
  
  ECHO "<div class='list-body'>";
  
  ECHO "<div class='list-menu'>";
  ECHO "<b>".LG('Выберите город')."/".LG('населенный пункт')."</b>";
  ECHO "</div>";
  
  IF (GET('city_id') && DB::GET_COLUMN("SELECT COUNT(*) FROM `CITY` WHERE `ID` = '".INTVAL(GET('city_id'))."' AND `ID_REGION` = '".INTVAL($_SESSION['region'])."' LIMIT 1") == 1 && DB::GET_COLUMN("SELECT COUNT(*) FROM `REGION` WHERE `ID` = '".INTVAL($_SESSION['region'])."' AND `ID_COUNTRY` = '".INTVAL($_SESSION['country'])."' LIMIT 1") == 1 && DB::GET_COLUMN("SELECT COUNT(*) FROM `COUNTRY` WHERE `ID` = '".INTVAL($_SESSION['country'])."' LIMIT 1") == 1){
    
    $city = DB::GET_STRING("SELECT `NAME` FROM `CITY` WHERE `ID` = '".INTVAL(GET('city_id'))."' LIMIT 1");
    $region = DB::GET_STRING("SELECT `NAME` FROM `REGION` WHERE `ID` = '".INTVAL($_SESSION['region'])."' LIMIT 1");
    $country = DB::GET_STRING("SELECT `NAME` FROM `COUNTRY` WHERE `ID` = '".INTVAL($_SESSION['country'])."' LIMIT 1");
    
    DB::GET_SET("UPDATE `USERS_SETTINGS` SET `CITY` = '".ADSL($city['NAME'])."', `REGION` = '".ADSL($region['NAME'])."', `COUNTRY` = '".ADSL($country['NAME'])."' WHERE `USER_ID` = '".$account['ID']."' LIMIT 1");
    
    SUCCESS('Изменения успешно приняты', 'session');    
    REDIRECT('/users/profile/?path=form&id='.$account['ID'].'');
    
  }
  
  $data = DB::GET_STRING_ALL("SELECT * FROM `CITY` WHERE `ID_REGION` = '".INTVAL($_SESSION['region'])."' ORDER BY `ID` ASC");
  
  WHILE ($list = $data->FETCH()){
    
    ECHO "<a href='/users/profile/?path=form&id=".$account['ID']."&section=geo&city_id=".$list['ID']."&get=city'><div class='list-menu hover'>";
    
    ECHO "".TEXT_ABSOLUTE($list['NAME'])."";
    
    ECHO "</div></a>";
  
  }
  
  ECHO "</div>";
  
  ECHO "<div class='list'>";
  ECHO "<a href='/users/profile/?path=form&id=".$account['ID']."&section=geo&get=region'>".ICONS('arrow-left', 15, 'fa-fw')." ".LG('Назад')."</a>";
  ECHO "</div>";
  
}ELSEIF (GET('get') == 'region' && ISSET($_SESSION['country']) && DB::GET_COLUMN("SELECT COUNT(*) FROM `COUNTRY` WHERE `ID` = '".INTVAL($_SESSION['country'])."' LIMIT 1") == 1){

/*
-------------
Выбор региона
-------------
*/
  
  ECHO "<div class='list-body'>";
  
  ECHO "<div class='list-menu'>";
  ECHO "<b>".LG('Выберите регион')."</b>";
  ECHO "</div>";
  
  IF (GET('region_id') && DB::GET_COLUMN("SELECT COUNT(*) FROM `REGION` WHERE `ID` = '".INTVAL(GET('region_id'))."' AND `ID_COUNTRY` = '".INTVAL($_SESSION['country'])."' LIMIT 1") == 1){
    
    $_SESSION['region'] = INTVAL(GET('region_id'));
    
    REDIRECT('/users/profile/?path=form&id='.$account['ID'].'&section=geo&get=city');
    
  }
  
  $data = DB::GET_STRING_ALL("SELECT * FROM `REGION` WHERE `ID_COUNTRY` = '".INTVAL($_SESSION['country'])."' ORDER BY `ID` ASC");
  
  WHILE ($list = $data->FETCH()){
    
    ECHO "<a href='/users/profile/?path=form&id=".$account['ID']."&section=geo&region_id=".$list['ID']."&get=region'><div class='list-menu hover'>";
    
    ECHO "".TEXT_ABSOLUTE($list['NAME'])."";
    
    ECHO "</div></a>";
  
  }
  
  ECHO "</div>";
  
  ECHO "<div class='list'>";
  ECHO "<a href='/users/profile/?path=form&id=".$account['ID']."&section=geo'>".ICONS('arrow-left', 15, 'fa-fw')." ".LG('Назад')."</a>";
  ECHO "</div>";
  
}ELSE{

/*
------------
Выбор страны
------------
*/
  
  ECHO "<div class='list-body'>";
  
  ECHO "<div class='list-menu'>";
  ECHO "<b>".LG('Выберите страну')."</b>";
  ECHO "</div>";
  
  IF (GET('country_id') && DB::GET_COLUMN("SELECT COUNT(*) FROM `COUNTRY` WHERE `ID` = '".INTVAL(GET('country_id'))."' LIMIT 1") == 1){
    
    $_SESSION['country'] = INTVAL(GET('country_id'));
    
    REDIRECT('/users/profile/?path=form&id='.$account['ID'].'&section=geo&get=region');
    
  }
  
  $data = DB::GET_STRING_ALL("SELECT * FROM `COUNTRY` ORDER BY `ID` ASC");
  
  WHILE ($list = $data->FETCH()){
    
    ECHO "<a href='/users/profile/?path=form&id=".$account['ID']."&section=geo&country_id=".$list['ID']."'><div class='list-menu hover'>";
    
    ECHO "<img src='/style/country/".$list['ID'].".png'> ".TEXT_ABSOLUTE($list['NAME'])."";
    
    ECHO "</div></a>";
  
  }
  
  ECHO "</div>";
  
}

ECHO "<div class='navigation'>";
ECHO "<a href='/'>".ICONS('home', 25, 'fa-fw')."</a>";
ECHO "".ICONS('angle-right', 22, 'fa-fw')."";
ECHO "<a href='/id".$account['ID']."'>".TEXT_ABSOLUTE($account['LOGIN'])."</a>";
ECHO "".ICONS('angle-right', 22, 'fa-fw')."";
ECHO "<a href='/users/profile/?path=form&id=".$account['ID']."'>".LG('Личная информация')."</a>";
ECHO "".ICONS('angle-right', 22, 'fa-fw')."";
ECHO "".LG('Место проживания')."";
ECHO "</div>";
  
?>