<?php

define('_PROJECT_DIR', getcwd() . '/../../');
define('_ROOT_DIR', getcwd() . '/');
define('_SHOP_DIR', getcwd() . '/../');

const _ENGINE_DIR = _PROJECT_DIR . 'engine/';
const _SITE_PATH = '';
const _BASE_DIR = _ENGINE_DIR . 'www/';
const __REAL_CAT_OBJ_ = '_sys_cat';

header("Content-type: text/html; charset=utf-8");
Header('Access-Control-Allow-Origin: *');

require_once(_ENGINE_DIR . 'bootstrap.php');


$obj = new cobject('_sys_city');

$db2 = $obj->getDB()->q($obj->getSelect(' AND `title` LIKE "' . db_escape_string($_GET['str'])  . '%" AND `_sys_enabled` ORDER BY _sys_city.big_city DESC, region_id ASC, `_sys_city`.`title` ASC LIMIT 100'));
while($db2->r()) {
    $obj->lRow($db2);
    $tt[] = $obj->assign("{title} ({city_fullname})|{_sys_city_id}");

}

if ($tt) {
    die(implode("\n", $tt));
} else {
    die('Такой населенный пункт не найден.|0');
}
