Exemplo n.º 1
0
 public function onBeforeStartComponent()
 {
     $db = JFactory::getDBO();
     $session = JFactory::getSession();
     $user_region = $session->get('user_region', 0);
     $phone_code = $session->get('phone_code', '');
     if (empty($user_region)) {
         $user_region = 0;
         require_once dirname(__FILE__) . '/helpers/geo.php';
         $SxGeo = new SxGeo(dirname(__FILE__) . '/helpers/SxGeoCity.dat', SXGEO_BATCH | SXGEO_MEMORY);
         $data = $SxGeo->getCityFull($_SERVER['HTTP_X_REAL_IP']);
         $region = isset($data['region']['name_ru']) ? $data['region']['name_ru'] : '';
         if ($region != '') {
             $query = $db->getQuery(true);
             $query->select('id')->from('#__ksenmart_regions')->where('title=' . $db->quote($region));
             $db->setQuery($query, 0, 1);
             $user_region = (int) $db->loadResult();
         }
         $session->set('user_region', $user_region);
         $country = isset($data['country']['name_ru']) ? $data['country']['name_ru'] : '';
         if ($country != '') {
             $query = $db->getQuery(true);
             $query->select('phone_code')->from('#__ksenmart_countries')->where('title=' . $db->quote($country));
             $db->setQuery($query, 0, 1);
             $phone_code = $db->loadResult();
         }
         $session->set('phone_code', $phone_code);
         unset($SxGeo);
     }
 }
Exemplo n.º 2
0
 /**
  * @return array
  */
 public function getCityFull()
 {
     if (!$this->SxGeo) {
         $this->loadSxGeo();
     }
     return $this->SxGeo->getCityFull($this->getUserIp());
 }
Exemplo n.º 3
0
 public function index($page, $city = null)
 {
     //var_dump($city);
     if ($this->session->userdata('city') == '') {
         include $_SERVER['DOCUMENT_ROOT'] . "/geo/SxGeo.php";
         $SxGeo = new SxGeo($_SERVER['DOCUMENT_ROOT'] . '/geo/SxGeoCity.dat');
         $ip = $_SERVER['REMOTE_ADDR'];
         $cityByIp = $SxGeo->getCityFull($ip);
         $city = $cityByIp['city'];
         $this->load->library('geo');
         $cityInfo = $this->geo->getCityIdByRussianName($city['name_ru']);
     } else {
         $cityBySlug = $this->model_pages->getCityIdBySlug($this->session->userdata('city'));
         $cityInfo = $this->model_pages->getCityInfoById($cityBySlug);
         $city = $cityInfo['slug'];
     }
     //var_dump($cityByIp);
     $data['city_name'] = $cityInfo['name_vp'];
     $data['city_exist'] = $cityInfo['name'];
     $data['city'] = $city;
     $data['city_name_pp'] = $cityInfo['name_pp'];
     $data['newPos'] = $this->getNewPositions();
     //var_dump($this->session->userdata());
     $data['siteRoot'] = '/';
     $data['base_url'] = '/' . $city . '/';
     $data['addonFiles'] = '<link href="' . $data['siteRoot'] . '/frontend/qroomblock/css/modal.css" rel="stylesheet">';
     $data['addonScripts'] = '';
     $data['page'] = $this->model_pages->getPageByUrl($page);
     //$data['page'] = str_replace('*nic*', , );
     if ($page == 'megaquest') {
         $name = '';
         if ($this->session->userdata('user_name') != "") {
             switch ($this->session->userdata('user_type')) {
                 case 2:
                     $table = 'mako_Costumers';
                     break;
                 case 1:
                     $table = 'mako_userTable';
                     break;
             }
             $name = $this->model_pages->getUserNameByEmail($table, $this->session->userdata('user_name'));
             $data['page'] = str_replace('*nic*', $name, $data['page']);
         }
         //var_dump($name);
         $data['description'] = "Я на квестура – " . $name . ". Хочу участвовать в Мегаквесте Екабу. Поддержи меня лайком! #мегаквестекабу";
     }
     //var_dump($this->session->userdata());
     $this->load->view('header', $data);
     $this->load->view('pageView', $data);
     $this->load->view('footer');
 }
Exemplo n.º 4
0
 public static function getCityByIP($ip = null)
 {
     require_once _PS_ROOT_DIR_ . "/tools/SxGeo/SxGeo.php";
     if (!$ip) {
         if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
             $ip = $_SERVER['HTTP_CLIENT_IP'];
         } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
             $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
         } else {
             $ip = $_SERVER['REMOTE_ADDR'];
         }
         //Марик НЕ ЗАБУДЬ УБРАТЬ БЛЯТЬ
         //$ip = '46.162.1.95';
     }
     if ($ip == '127.0.0.1') {
         $ip = '46.162.1.95';
     }
     $SxGeo = new SxGeo(_PS_ROOT_DIR_ . '/tools/SxGeo/SxGeoCity.dat', SXGEO_BATCH | SXGEO_MEMORY);
     // Самый быстрый режим
     $city = $SxGeo->getCityFull($ip);
     return $city;
 }
Exemplo n.º 5
0
 /**
  * @param string $ip
  *
  * @return array|bool
  */
 public function getCityFull($ip = '')
 {
     return $this->sxGeo->getCityFull($this->getIp($ip));
 }
Exemplo n.º 6
0
 protected function find($ip = null)
 {
     $geo = new SxGeo($this->db_location);
     $location = $geo->getCityFull($ip);
     return $location;
 }
Exemplo n.º 7
0
 /**
  * @return array
  */
 public function getCityFull()
 {
     return $this->SxGeo->getCityFull($this->getUserIp());
 }
Exemplo n.º 8
0
<?php

// Пример работы с классом SxGeo v2.2
header('Content-type: text/plain; charset=utf8');
// Подключаем SxGeo.php класс
include "SxGeo.php";
// Создаем объект
// Первый параметр - имя файла с базой (используется оригинальная бинарная база SxGeo.dat)
// Второй параметр - режим работы:
//     SXGEO_FILE   (работа с файлом базы, режим по умолчанию);
//     SXGEO_BATCH (пакетная обработка, увеличивает скорость при обработке множества IP за раз)
//     SXGEO_MEMORY (кэширование БД в памяти, еще увеличивает скорость пакетной обработки, но требует больше памяти)
$SxGeo = new SxGeo('SxGeoCity.dat');
//$SxGeo = new SxGeo('SxGeoCity.dat', SXGEO_BATCH | SXGEO_MEMORY); // Самый производительный режим, если нужно обработать много IP за раз
$ip = $_SERVER['REMOTE_ADDR'];
var_export($SxGeo->getCityFull($ip));
// Вся информация о городе
var_export($SxGeo->get($ip));
// Краткая информация о городе или код страны (если используется база SxGeo Country)
var_export($SxGeo->about());
// Информация о базе данных
Exemplo n.º 9
0
 public function index($city = false, $page = 1, $sort = "rating", $filter = null)
 {
     //var_dump($_GET);
     $data['sort'] = $sort;
     if ($sort == "costASC") {
         $sort = "cost ASC";
     }
     if ($sort == "costDESC") {
         $sort = "cost DESC";
     }
     $cityCheck = $this->model_welcome->checkCity($city);
     if (!$cityCheck) {
         $this->session->set_userdata('city', '');
         show_404();
         die;
     }
     if (isset($_GET['ref'])) {
         $this->session->set_userdata('ref', $_GET['ref']);
     }
     if (!$city) {
         //var_dump($this->session->userdata('city'));
         if ($this->session->userdata('city')) {
             $city = $this->session->userdata('city');
         }
         //redirect('/ekb/', 'refresh');
     }
     if (!file_exists($city . '/')) {
         $city = $city;
         //$this->city = $this->session->userdata('city');
     }
     $this->session->set_userdata('city', '');
     include $_SERVER['DOCUMENT_ROOT'] . "/geo/SxGeo.php";
     $SxGeo = new SxGeo($_SERVER['DOCUMENT_ROOT'] . '/geo/SxGeoCity.dat');
     $ip = $_SERVER['REMOTE_ADDR'];
     if ($this->session->userdata('city') == 'uploads') {
         $this->session->set_userdata('city', '');
         $city = '';
     }
     //var_dump($city, $this->session->userdata('city'));
     $cityByIp = $SxGeo->getCityFull($ip);
     //var_dump($cityByIp);
     //var_dump($cityByIp);
     $slug = $this->model_welcome->getSlugByName($cityByIp['city']['name_ru']);
     if ($slug['name'] == '') {
         $slug['name'] = 'Москва';
         $slug['slug'] = 'moscow';
     } elseif (!$slug) {
         $slug['name'] = 'Москва';
         $slug['slug'] = 'moscow';
     }
     //$slug['name'] = 'Москва';
     //$slug['slug'] = 'moscow';
     $data['mayBeCity'] = $slug;
     $this->load->library('geo');
     $data['allCity'] = $this->geo->getAllCity();
     $cityInfo = $this->geo->getCityIdByName($city);
     $this->session->set_userdata('city', $city);
     if (!$city) {
         $city = $cityInfo['slug'];
     } else {
         $data['title'] = "Квесты в реальности " . $cityInfo['name_pp'] . " - Questura.ru";
     }
     //var_dump($city,$cityInfo);
     //var_dump($city, $this->session->userdata('city'));
     //var_dump($cityInfo);
     //var_dump($page);
     $idsArray = $this->model_welcome->getUsersByCity($cityInfo['id_region']);
     if (is_array($idsArray)) {
         $ids = implode(' , ', $idsArray);
         $data['rooms'] = $this->model_welcome->getRoomsByUsers($ids, null, $page, $sort, $filter);
     } else {
         $ids = '';
         $data['rooms'] = array();
     }
     $data['roomsCount'] = $this->model_welcome->getCountRoomsByUsers($ids);
     $data['AllroomsCount'] = $this->model_welcome->getCountRoomsByUsers($ids, null, $filter);
     //var_dump($data['roomsCount']);
     if ($this->onPage > $data['roomsCount']) {
         $data['roomsCount'] = false;
     }
     //var_dump($this->onPage,$data['roomsCount']);
     if (!$idsArray || count($idsArray) == 0) {
         //show_404();
         //die();
     }
     //var_dump($cityInfo);
     if ($cityInfo['name_vp'] == '') {
         $cityInfo['name_vp'] = 'Вашего города';
     }
     if ($cityInfo['name_pp'] == '') {
         $cityInfo['name_pp'] = 'в вашем городе';
     }
     $data['city_parentId'] = $cityInfo['id_parent'];
     $data['city_id'] = $cityInfo['id_region'];
     $data['city_name'] = $cityInfo['name_vp'];
     $data['city_name_pp'] = $cityInfo['name_pp'];
     $data['city_exist'] = $cityInfo['name'];
     //var_dump($city);
     //$sort = false;
     switch ($sort) {
         case 'enters':
             $data['titleOnPage'] = 'Популярные квесты ' . $data['city_name'];
             break;
         case 'id':
             $data['titleOnPage'] = 'Новые квесты ' . $data['city_name'];
             break;
         default:
             $data['titleOnPage'] = 'Лучшие квесты ' . $data['city_name'];
     }
     //var_dump($sort);
     $data['city'] = $city;
     $data['base_url'] = '/' . $city . '/';
     $data['siteRoot'] = '';
     $data['newPos'] = $this->getNewPositions();
     //$this->model_welcome->getNew($data['city_id']);
     //var_dump($data['newPos']);
     $data['addonFiles'] = '';
     $data['addonScripts'] = '<script src="' . $data['siteRoot'] . '/frontend/header/js/showmore.js"></script>';
     $hasSort = '';
     if ($data['sort'] != 'rating') {
         $hasSort = $data['sort'] . '/';
     }
     if ($filter) {
         $hasSort = 'quest/' . $filter;
     }
     $this->load->library('pagination');
     $config['base_url'] = '/' . $city . '/' . $hasSort;
     $config['total_rows'] = $data['AllroomsCount'];
     $config['per_page'] = 12;
     $config['first_link'] = '';
     $config['last_link'] = '';
     $config['num_tag_open'] = '<li>';
     $config['num_tag_close'] = '</li>';
     $config['cur_tag_open'] = '<li class="active"><a href="#">';
     $config['cur_tag_close'] = '</a></li>';
     $this->pagination->initialize($config);
     $data['pages'] = $this->pagination->create_links();
     //$data['user_name'] = $this->model_welcome->getUserNameByEmail();
     //var_dump($data['pages']);
     $this->load->view('header', $data);
     $this->load->view('welcome_message', $data);
     $this->load->view('footer');
 }
Exemplo n.º 10
0
 public function getLocation($ip)
 {
     return $this->sxGeo->getCityFull($ip);
 }
Exemplo n.º 11
0
/**
 * Returns extended city info array for given IP address
 *
 * Sample array:
 * (
 *  [regid] => 9737
 *  [cc] => 185
 *  [fips] => 66
 *  [lat] => 60.076238
 *  [lon] => 30.121382
 *  [country] => RU
 *  [city] => Санкт-Петербург
 *  [region_name] => Санкт-Петербург
 *  [timezone] =>
 * )
 * @param string $ip IP address in xxx.xxx.xxx.xxx notation
 * @return array Array with city info
 */
function sx_getCityInfoExt($ip = null)
{
    global $SxCity, $sx_bulkmode, $sx_city, $sx_ip;
    if (is_null($ip)) {
        $ip = $sx_ip;
    }
    if (!$SxCity) {
        $SxCity = new SxGeo('plugins/sxgeo/data/SxGeoCity.dat');
    }
    // Режим по умолчанию, файл бд SxGeo.dat
    $sx_city['ext_info'] = $result = @$SxCity->getCityFull($ip);
    // возвращает полную информацию о городе и регионе
    if (!$sx_bulkmode) {
        unset($SxCity);
    }
    return $result;
}