geo插件问题(vqmod无法写入手动写入等等)

GeoIPTools230.2.ocmod插件问题(vqmod无法写入手动写入等等)

 

1步

在 catalog/controller/common/header.php  文件中添加代码  (vqcache  modify  源文件)

 

1)在 代码 function index() {  前(上一行) 添加一下代码

// Clear Thinking: geo_ip_tools.xml

public function getZones() {

$this->load->model(‘localisation/zone’);

$zones = $this->model_localisation_zone->getZonesByCountryId($this->request->get[‘country_id’]);

echo json_encode($zones);

}

public function setLocation() {

$this->load->model(‘module/geo_ip_tools’);

if (isset($this->request->get[‘geocode’])) {

$location = $this->model_module_geo_ip_tools->getBrowserLocation($this->request->get[‘geocode’]);

} else {

$location = array(

‘country_id’ => (isset($this->request->post[‘popup_country’])) ? $this->request->post[‘popup_country’] : ”,

‘zone_id’ => (isset($this->request->post[‘popup_zone’])) ? $this->request->post[‘popup_zone’] : ”,

‘city’ => (isset($this->request->post[‘popup_city’])) ? $this->request->post[‘popup_city’] : ”,

‘postcode’ => (isset($this->request->post[‘popup_postcode’])) ? $this->request->post[‘popup_postcode’] : ”,

‘disable_popup’ => true,

);

}

$this->model_module_geo_ip_tools->setLocation($location);

$redirect = $this->model_module_geo_ip_tools->checkLocation($location);

if (!empty($this->request->post[‘popup_currency’])) {

$this->session->data[‘currency’] = $this->request->post[‘popup_currency’];

}

if (!empty($this->request->post[‘popup_language’])) {

$this->session->data[‘language’] = $this->request->post[‘popup_language’];

}

$popup_redirect = (!empty($this->request->post[‘popup_redirect’])) ? $this->request->post[‘popup_redirect’] : $this->config->get(‘config_url’);

if (!$redirect) {

$redirect = $popup_redirect;

}

header(‘Location: ‘ . str_replace(‘&’, ‘&’, str_replace(‘*’, substr($popup_redirect, 1), $redirect)), true);

exit();

}

// end: geo_ip_tools.xml

 

  • 在代码  (‘common/header’) 后(下一行)  添加以下代码

// Clear Thinking: geo_ip_tools.xml

$ignore_user_agents = explode(“\n”, $this->config->get(‘geo_ip_tools_ignore_user_agents’));

$ignore_user_agents = array_map(‘trim’, $ignore_user_agents);

if (!empty($this->request->server[‘REMOTE_ADDR’]) && $this->config->get(‘geo_ip_tools_status’) && !in_array($this->request->server[‘HTTP_USER_AGENT’], $ignore_user_agents)) {

if ($this->config->get(‘geo_ip_tools_testing_mode’)) {

$message = “\n” . ‘—————————— Starting Test ‘ . date(‘Y-m-d G:i:s’) . ‘ ——————————‘;

file_put_contents(DIR_LOGS . ‘geo_ip_tools.messages’, print_r($message, true) . “\n”, FILE_APPEND|LOCK_EX);

}

$this->load->model(‘module/geo_ip_tools’);

$redirect = ”;

$data[‘geo_ip_tools_popup’] = ”;

$data[‘request_browser_location’] = $this->config->get(‘geo_ip_tools_browser’);

if (empty($this->session->data[‘geoip_data’])) {

$location = $this->model_module_geo_ip_tools->getLocation($this->request->server[‘REMOTE_ADDR’]);

$this->model_module_geo_ip_tools->setLocation($location);

$redirect = $this->model_module_geo_ip_tools->checkLocation($location);

} elseif ($this->config->get(‘geo_ip_tools_popup’) && empty($this->session->data[‘geoip_data’][‘location’][‘disable_popup’])) {

$this->session->data[‘geoip_data’][‘location’][‘disable_popup’] = true;

$data[‘location’] = $this->session->data[‘geoip_data’][‘location’];

$data = array_merge($data, $this->load->language(‘account/address’));

$data[‘geo_ip_tools_popup’] = $this->config->get(‘geo_ip_tools_popup_text_’ . $this->session->data[‘language’]);

$data[‘geo_ip_tools_popup’] = str_replace(‘[ip]’, $this->request->server[‘REMOTE_ADDR’], $data[‘geo_ip_tools_popup’]);

$data[‘geo_ip_tools_popup’] = html_entity_decode($data[‘geo_ip_tools_popup’], ENT_QUOTES, ‘UTF-8’);

$this->load->model(‘localisation/country’);

$data[‘countries’] = $this->model_localisation_country->getCountries();

$this->load->model(‘localisation/currency’);

$data[‘currencies’] = $this->model_localisation_currency->getCurrencies();

$data[‘session_currency’] = $this->session->data[‘currency’];

$this->load->model(‘localisation/language’);

$data[‘languages’] = $this->model_localisation_language->getLanguages();

$data[‘session_language’] = $this->session->data[‘language’];

foreach (array(‘country’, ‘zone’, ‘city’, ‘postcode’, ‘currency’, ‘language’) as $field) {

$data[$field . ‘_field’] = $this->config->get(‘geo_ip_tools_’ . $field . ‘_field_’ . $data[‘session_language’]);

}

} else {

$redirect = $this->model_module_geo_ip_tools->checkBlocks();

}

if ($redirect) {

header(‘Location: ‘ . str_replace(‘&’, ‘&’, str_replace(‘*’, substr($this->request->server[‘REQUEST_URI’], 1), $redirect)), true);

exit();

}

if (version_compare(VERSION, ‘2.0’, ‘<‘)) $this->data = array_merge($this->data, $data);

}

// end: geo_ip_tools.xml

 

 

 

2步

在 catalog/controller/error/not_found.php 文件 (vqcache  modify 源文件) 中执行一下操作

 

  • 将$this->language->get(‘heading_title’) 代码全部替换成

(!empty($this->session->data[‘geoip_data’][‘blocked_message’]) ? substr($this->session->data[‘geoip_data’][‘blocked_message’], 0, strpos($this->session->data[‘geoip_data’][‘blocked_message’], “\n”)) : $this->language->get(‘heading_title’))

 

  • 将 $this->language->get(‘text_error’) 代码  全部替换成

(!empty($this->session->data[‘geoip_data’][‘blocked_message’]) ? nl2br(html_entity_decode(substr($this->session->data[‘geoip_data’][‘blocked_message’], strpos($this->session->data[‘geoip_data’][‘blocked_message’], “\n”)), ENT_QUOTES, ‘UTF-8’)) : $this->language->get(‘text_error’))

 

 

 

3步

 

将 catalog/view/theme/*/template/common/header.tpl  文件 中执行一下操作  (vq modify 源代码)  注意* 表示你的当前模板名

 

  • 在 </head> 代码 前(上一行)  添加

<meta name=”viewport” content=”width=device-width, initial-scale=1.0″ />

<script type=”text/javascript”>

function showPopup() {

$(‘#modal-overlay, #geo-ip-tools-popup’).show();

}

<?php if (empty($request_browser_location)) { ?>

$(document).ready(function(){

showPopup();

});

<?php } else { ?>

$(document).ready(function(){

if (navigator.geolocation) {

navigator.geolocation.getCurrentPosition(setBrowserLocation, showPopup, {maximumAge: 60*60*1000});

} else {

showPopup();

}

});

function setBrowserLocation(geocode) {

$.get(‘index.php?route=common/header/setLocation&geocode=’ + geocode.coords.latitude + ‘,’ + geocode.coords.longitude);

}

<?php } ?>

</script>

 

  • 在 <body  后 (下一行)  添加以下代码

<?php

if (!empty($geo_ip_tools_popup)) {

include(‘catalog/view/theme/default/template/module/geo_ip_tools_popup.tpl’);

}

?>

 

 

 

 

注意  如果插件还是不能用的话,可能出现以下的特殊情况(模板本身重写了这三个文件的某些)QQ图片20180614221842

 

看看是不是该模板的,这三个文件,在别处还有重写。。。。。(在源代码里找这三个同名文件,然后执行上面的修改)

Comments

发表回复

Your email address will not be published. Name and email are required