
<?php // ccr.php - country code redirect require_once('geoplugin.class.php'); $geoplugin = new geoPlugin(); $geoplugin->locate(); $country_code = $geoplugin->countryCode; switch($country_code) { case 'US': exit; case 'CA': header('Location: http://strona.com/index_ca.php'); exit; case 'GB': exit; case 'NL': header('Location: http://strona.com/index_nl.php'); exit; case 'AU': exit; case 'NZ': header('Location: http://strona.com/newzealand.php'); exit; case 'PL': exit; case 'BE': header('Location: http://strona.com/index_be.php'); exit; case 'FI': exit; case 'DE': header('Location: http://strona.com/index_de.php'); exit; case 'DK': exit; case 'IE': header('Location: http://strona.com/index_ie.php'); exit; case 'NO': exit; case 'FR': header('Location: http://strona.com/index_fr.php'); exit; default: // exceptions exit; } ?>
oraz geoplugin.class.php
<?php /* This PHP class is free software: you can redistribute it and/or modify the code under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. However, the license header, copyright and author credits must not be modified in any form and always be displayed. This class is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @author geoPlugin (gp_support@geoplugin.com) @copyright Copyright geoPlugin (gp_support@geoplugin.com) $version 1.01 This PHP class uses the PHP Webservice of http://www.geoplugin.com/ to geolocate IP addresses Geographical location of the IP address (visitor) and locate currency (symbol, code and exchange rate) are returned. See http://www.geoplugin.com/webservices/php for more specific details of this free service */ class geoPlugin { //the geoPlugin server var $host = 'http://www.geoplugin.net/php.gp?ip={IP}&base_currency={CURRENCY}'; //the default base currency var $currency = 'USD'; //initiate the geoPlugin vars var $ip = null; var $city = null; var $region = null; var $areaCode = null; var $dmaCode = null; var $countryCode = null; var $countryName = null; var $continentCode = null; var $latitude = null; var $longitude = null; var $currencyCode = null; var $currencySymbol = null; var $currencyConverter = null; function geoPlugin() { } function locate($ip = null) { $ip = $_SERVER['REMOTE_ADDR']; } $response = $this->fetch($host); //set the geoPlugin vars $this->ip = $ip; $this->city = $data['geoplugin_city']; $this->region = $data['geoplugin_region']; $this->areaCode = $data['geoplugin_areaCode']; $this->dmaCode = $data['geoplugin_dmaCode']; $this->countryCode = $data['geoplugin_countryCode']; $this->countryName = $data['geoplugin_countryName']; $this->continentCode = $data['geoplugin_continentCode']; $this->latitude = $data['geoplugin_latitude']; $this->longitude = $data['geoplugin_longitude']; $this->currencyCode = $data['geoplugin_currencyCode']; $this->currencySymbol = $data['geoplugin_currencySymbol']; $this->currencyConverter = $data['geoplugin_currencyConverter']; } function fetch($host) { if ( function_exists('curl_init') ) { //use cURL to fetch data $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $host); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'geoPlugin PHP Class v1.0'); $response = curl_exec($ch); curl_close ($ch); //fall back to fopen() } else { trigger_error ('geoPlugin class Error: Cannot retrieve data. Either compile PHP with cURL support or enable allow_url_fopen in php.ini ', E_USER_ERROR); return; } return $response; } function convert($amount, $float=2, $symbol=true) { //easily convert amounts to geolocated currency. return $amount; } trigger_error ('geoPlugin class Warning: The amount passed to geoPlugin::convert is not numeric.', E_USER_WARNING); return $amount; } if ( $symbol === true ) { } else { } } function nearby($radius=10, $limit=null) { } $host = "http://www.geoplugin.net/extras/nearby.gp?lat=" . $this->latitude . "&long=" . $this->longitude . "&radius={$radius}"; $host .= "&limit={$limit}"; } } ?>
Ogólnie nie wiem jak zrobić do tego kod żeby dodatkowo wykrywał czy użytkownik jest z telefony/tabletu czy innego urządzenia... zakładając że użytkownik jest z uk i wchodzi z tabletu to przekierowuje go do odpowiedniego landing page strony .
Z góry dzięki za pomoc, nie mam pomysłu jak to zrobić, szukałem w necie przekierowania na mobilne strony ale nie wiem jak to wkomponować żeby przekierowanie było definiowane krajem.
EDIT //
Zapłacę 5 $ / paypal