Jump to content

Edit History

noflipar

noflipar

On 3/6/2020 at 6:07 PM, gusman126 said:

Yo uso este codigo , la ultima vez en PS 1.6

Lo añado a un modulo y que este enganchado al "header"

Obviamente lo debes cambiar a tus dominios y paises

También hace falta el fichero GeoLiteCity.dat, es el mismo fichero que usa el prestashop para geolocalizar

 


include_once(_PS_GEOIP_DIR_.'geoipcity.inc');
        $gi = geoip_open(realpath(_PS_GEOIP_DIR_.'GeoLiteCity.dat'), GEOIP_STANDARD);
        $records = geoip_record_by_addr($gi, Tools::getRemoteAddr());
        $URL_P = $_SERVER['REQUEST_URI'];
        $pais = $records->country_code;
        
        if ($pais == 'AD' | $pais == 'AT' |
            $pais == 'BE' | $pais == 'BG' |
            $pais == 'HR' | $pais == 'CY' |
            $pais == 'CZ' | $pais == 'DK' |
            $pais == 'EE' | $pais == 'FI' |
            $pais == 'FR' | $pais == 'DE' |
            $pais == 'GR' | $pais == 'HU' |
            $pais == 'IS' | $pais == 'IE' |
            $pais == 'IT' | $pais == 'LT' |
            $pais == 'LU' | $pais == 'MT' |
            $pais == 'NL' | $pais == 'NO' |
            $pais == 'PL' | $pais == 'RO' |
            $pais == 'SK' | $pais == 'SI' |
            $pais == 'SE' | $pais == 'CH' |
            $pais == 'TR' ){
                $pais = 'CE';
            }
           if  (isset($_SERVER['HTTP_USER_AGENT'])  && preg_match('/BotLink|ahoy|AlkalineBOT|anthill|appie|arale|araneo|AraybOt|ariadne|arks|ATN_Worldwide|Atomz
                |bbot|Bjaaland|Ukonline|borg\-bot\/0\.9|boxseabot|bspider|calif|christcrawler|CMC\/0\.01|combine|confuzzledbot|CoolBot|cosmos|PayPal IPN|paypal|PayPal|
                Internet Cruiser Robot|cusco|cyberspyder|cydralspider|desertrealm, desert realm|digger|DIIbot|grabber|downloadexpress|DragonBot|
                dwcp|ecollector|ebiness|elfinbot|esculapio|esther|fastcrawler|FDSE|FELIX IDE|ESI|fido|H�m�h�kki|KIT\-Fireball|fouineur|Freecrawl|
                gammaSpider|gazz|gcreep|golem|googlebot|AdsBot-Google|Googlebot-Image|Googlebot-News|Google-Structured-Data-Testing-Tool|pagespeed|insights|griffon|Gromit|gulliver|gulper|hambot|havIndex|hotwired|htdig|iajabot|INGRID\/0\.1|Informant|
                InfoSpiders|inspectorwww|irobot|Iron33|JBot|jcrawler|Teoma|Jeeves|jobo|image\.kapsi\.net|KDD\-Explorer|ko_yappo_robot|label\-grabber|
                larbin|legs|Linkidator|linkwalker|Lockon|logo_gif_crawler|marvin|mattie|mediafox|MerzScope|NEC\-MeshExplorer|MindCrawler|udmsearch|moget|
                Motor|msnbot|muncher|muninn|MuscatFerret|MwdSearch|sharp\-info\-agent|WebMechanic|NetScoop|newscan\-online|ObjectsSearch|Occam|Orbsearch\/1\.0|
                packrat|pageboy|ParaSite|patric|pegasus|perlcrawler|phpdig|piltdownman|Pimptrain|pjspider|PlumtreeWebAccessor|PortalBSpider|psbot|Getterrobo\-Plus|
                Raven|RHCS|RixBot|roadrunner|Robbie|robi|RoboCrawl|robofox|Scooter|Search\-AU|searchprocess|Senrigan|Shagseeker|sift|SimBot|Site Valet|skymob|
                SLCrawler\/2\.0|slurp|ESI|snooper|solbot|speedy|spider_monkey|SpiderBot\/1\.0|spiderline|nil|suke|http:\/\/www\.sygol\.com|tach_bw|TechBOT|
                templeton|titin|topiclink|UdmSearch|urlck|Valkyrie libwww\-perl|verticrawl|Victoria|void\-bot|Voyager|VWbot_K|crawlpaper|wapspider|WebBandit\/1\.0|
                webcatcher|T\-H\-U\-N\-D\-E\-R\-S\-T\-O\-N\-E|WebMoose|webquest|webreaper|webs|webspider|WebWalker|wget|winona|whowhere|wlm|WOLP|WWWC|none|XGET|
                Nederland\.zoek|AISearchBot|woriobot|NetSeer|Nutch/i', $_SERVER['HTTP_USER_AGENT'] ) ){
           
           }else {                
                $dominiourl =$_SERVER['SERVER_NAME'];
                switch ($pais) {
                    case 'ES':
                        if ($dominiourl != 'dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'usa.dominio.com')
                            header("Location: https://dominio.com".$URL_P."");
                        break;
                    case 'PT':
                        if ($dominiourl != 'dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'usa.dominio.com')
                            header("Location: https://dominio.com".$URL_P."");
                        break;
                    case 'CE' :
                        if ($dominiourl != 'ce.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'usa.dominio.com' || $dominiourl == 'dominio.com')
                            header("Location: https://ce.dominio.com".$URL_P."");
                        break;
                    case 'US':
                        if ($dominiourl != 'usa.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'dominio.com')
                            header("Location: https://usa.dominio.com".$URL_P."");
                        break;
                    case 'MX':
                        if ($dominiourl != 'usa.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'dominio.com')
                            header("Location: https://usa.dominio.com".$URL_P."");
                        break;
                    case 'GB' :
                        if ($dominiourl != 'uk.dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'usa.dominio.com' || $dominiourl == 'dominio.com')
                            header("Location: https://uk.dominio.com".$URL_P."");
                        break;
                    case 'AU':
                        if ($dominiourl != 'usa.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'dominio.com')
                            header("Location: https://usa.dominio.com".$URL_P."");
                        break;
                    default :
                        if ($dominiourl != 'usa.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'dominio.com')
                            header("Location: https://usa.dominio.com".$URL_P."");
                        break;
                } 
            }
    }

 

¿Alguien sabe dónde se encuentra el geoipcity.inc en la versión de prestashop 1.7?

o ¿cómo puedo obtener el pais desde el que se conecta el usuario en la 1.7?

 

 

noflipar

noflipar

On 3/6/2020 at 6:07 PM, gusman126 said:

Yo uso este codigo , la ultima vez en PS 1.6

Lo añado a un modulo y que este enganchado al "header"

Obviamente lo debes cambiar a tus dominios y paises

También hace falta el fichero GeoLiteCity.dat, es el mismo fichero que usa el prestashop para geolocalizar

 


include_once(_PS_GEOIP_DIR_.'geoipcity.inc');
        $gi = geoip_open(realpath(_PS_GEOIP_DIR_.'GeoLiteCity.dat'), GEOIP_STANDARD);
        $records = geoip_record_by_addr($gi, Tools::getRemoteAddr());
        $URL_P = $_SERVER['REQUEST_URI'];
        $pais = $records->country_code;
        
        if ($pais == 'AD' | $pais == 'AT' |
            $pais == 'BE' | $pais == 'BG' |
            $pais == 'HR' | $pais == 'CY' |
            $pais == 'CZ' | $pais == 'DK' |
            $pais == 'EE' | $pais == 'FI' |
            $pais == 'FR' | $pais == 'DE' |
            $pais == 'GR' | $pais == 'HU' |
            $pais == 'IS' | $pais == 'IE' |
            $pais == 'IT' | $pais == 'LT' |
            $pais == 'LU' | $pais == 'MT' |
            $pais == 'NL' | $pais == 'NO' |
            $pais == 'PL' | $pais == 'RO' |
            $pais == 'SK' | $pais == 'SI' |
            $pais == 'SE' | $pais == 'CH' |
            $pais == 'TR' ){
                $pais = 'CE';
            }
           if  (isset($_SERVER['HTTP_USER_AGENT'])  && preg_match('/BotLink|ahoy|AlkalineBOT|anthill|appie|arale|araneo|AraybOt|ariadne|arks|ATN_Worldwide|Atomz
                |bbot|Bjaaland|Ukonline|borg\-bot\/0\.9|boxseabot|bspider|calif|christcrawler|CMC\/0\.01|combine|confuzzledbot|CoolBot|cosmos|PayPal IPN|paypal|PayPal|
                Internet Cruiser Robot|cusco|cyberspyder|cydralspider|desertrealm, desert realm|digger|DIIbot|grabber|downloadexpress|DragonBot|
                dwcp|ecollector|ebiness|elfinbot|esculapio|esther|fastcrawler|FDSE|FELIX IDE|ESI|fido|H�m�h�kki|KIT\-Fireball|fouineur|Freecrawl|
                gammaSpider|gazz|gcreep|golem|googlebot|AdsBot-Google|Googlebot-Image|Googlebot-News|Google-Structured-Data-Testing-Tool|pagespeed|insights|griffon|Gromit|gulliver|gulper|hambot|havIndex|hotwired|htdig|iajabot|INGRID\/0\.1|Informant|
                InfoSpiders|inspectorwww|irobot|Iron33|JBot|jcrawler|Teoma|Jeeves|jobo|image\.kapsi\.net|KDD\-Explorer|ko_yappo_robot|label\-grabber|
                larbin|legs|Linkidator|linkwalker|Lockon|logo_gif_crawler|marvin|mattie|mediafox|MerzScope|NEC\-MeshExplorer|MindCrawler|udmsearch|moget|
                Motor|msnbot|muncher|muninn|MuscatFerret|MwdSearch|sharp\-info\-agent|WebMechanic|NetScoop|newscan\-online|ObjectsSearch|Occam|Orbsearch\/1\.0|
                packrat|pageboy|ParaSite|patric|pegasus|perlcrawler|phpdig|piltdownman|Pimptrain|pjspider|PlumtreeWebAccessor|PortalBSpider|psbot|Getterrobo\-Plus|
                Raven|RHCS|RixBot|roadrunner|Robbie|robi|RoboCrawl|robofox|Scooter|Search\-AU|searchprocess|Senrigan|Shagseeker|sift|SimBot|Site Valet|skymob|
                SLCrawler\/2\.0|slurp|ESI|snooper|solbot|speedy|spider_monkey|SpiderBot\/1\.0|spiderline|nil|suke|http:\/\/www\.sygol\.com|tach_bw|TechBOT|
                templeton|titin|topiclink|UdmSearch|urlck|Valkyrie libwww\-perl|verticrawl|Victoria|void\-bot|Voyager|VWbot_K|crawlpaper|wapspider|WebBandit\/1\.0|
                webcatcher|T\-H\-U\-N\-D\-E\-R\-S\-T\-O\-N\-E|WebMoose|webquest|webreaper|webs|webspider|WebWalker|wget|winona|whowhere|wlm|WOLP|WWWC|none|XGET|
                Nederland\.zoek|AISearchBot|woriobot|NetSeer|Nutch/i', $_SERVER['HTTP_USER_AGENT'] ) ){
           
           }else {                
                $dominiourl =$_SERVER['SERVER_NAME'];
                switch ($pais) {
                    case 'ES':
                        if ($dominiourl != 'dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'usa.dominio.com')
                            header("Location: https://dominio.com".$URL_P."");
                        break;
                    case 'PT':
                        if ($dominiourl != 'dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'usa.dominio.com')
                            header("Location: https://dominio.com".$URL_P."");
                        break;
                    case 'CE' :
                        if ($dominiourl != 'ce.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'usa.dominio.com' || $dominiourl == 'dominio.com')
                            header("Location: https://ce.dominio.com".$URL_P."");
                        break;
                    case 'US':
                        if ($dominiourl != 'usa.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'dominio.com')
                            header("Location: https://usa.dominio.com".$URL_P."");
                        break;
                    case 'MX':
                        if ($dominiourl != 'usa.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'dominio.com')
                            header("Location: https://usa.dominio.com".$URL_P."");
                        break;
                    case 'GB' :
                        if ($dominiourl != 'uk.dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'usa.dominio.com' || $dominiourl == 'dominio.com')
                            header("Location: https://uk.dominio.com".$URL_P."");
                        break;
                    case 'AU':
                        if ($dominiourl != 'usa.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'dominio.com')
                            header("Location: https://usa.dominio.com".$URL_P."");
                        break;
                    default :
                        if ($dominiourl != 'usa.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'dominio.com')
                            header("Location: https://usa.dominio.com".$URL_P."");
                        break;
                } 
            }
    }

 

¿Alguien sabe dónde se encuentra el geoipcity.inc en la versión de prestashop 1.7?

 

 

noflipar

noflipar

On 3/6/2020 at 6:07 PM, gusman126 said:

Yo uso este codigo , la ultima vez en PS 1.6

Lo añado a un modulo y que este enganchado al "header"

Obviamente lo debes cambiar a tus dominios y paises

También hace falta el fichero GeoLiteCity.dat, es el mismo fichero que usa el prestashop para geolocalizar

 


include_once(_PS_GEOIP_DIR_.'geoipcity.inc');
        $gi = geoip_open(realpath(_PS_GEOIP_DIR_.'GeoLiteCity.dat'), GEOIP_STANDARD);
        $records = geoip_record_by_addr($gi, Tools::getRemoteAddr());
        $URL_P = $_SERVER['REQUEST_URI'];
        $pais = $records->country_code;
        
        if ($pais == 'AD' | $pais == 'AT' |
            $pais == 'BE' | $pais == 'BG' |
            $pais == 'HR' | $pais == 'CY' |
            $pais == 'CZ' | $pais == 'DK' |
            $pais == 'EE' | $pais == 'FI' |
            $pais == 'FR' | $pais == 'DE' |
            $pais == 'GR' | $pais == 'HU' |
            $pais == 'IS' | $pais == 'IE' |
            $pais == 'IT' | $pais == 'LT' |
            $pais == 'LU' | $pais == 'MT' |
            $pais == 'NL' | $pais == 'NO' |
            $pais == 'PL' | $pais == 'RO' |
            $pais == 'SK' | $pais == 'SI' |
            $pais == 'SE' | $pais == 'CH' |
            $pais == 'TR' ){
                $pais = 'CE';
            }
           if  (isset($_SERVER['HTTP_USER_AGENT'])  && preg_match('/BotLink|ahoy|AlkalineBOT|anthill|appie|arale|araneo|AraybOt|ariadne|arks|ATN_Worldwide|Atomz
                |bbot|Bjaaland|Ukonline|borg\-bot\/0\.9|boxseabot|bspider|calif|christcrawler|CMC\/0\.01|combine|confuzzledbot|CoolBot|cosmos|PayPal IPN|paypal|PayPal|
                Internet Cruiser Robot|cusco|cyberspyder|cydralspider|desertrealm, desert realm|digger|DIIbot|grabber|downloadexpress|DragonBot|
                dwcp|ecollector|ebiness|elfinbot|esculapio|esther|fastcrawler|FDSE|FELIX IDE|ESI|fido|H�m�h�kki|KIT\-Fireball|fouineur|Freecrawl|
                gammaSpider|gazz|gcreep|golem|googlebot|AdsBot-Google|Googlebot-Image|Googlebot-News|Google-Structured-Data-Testing-Tool|pagespeed|insights|griffon|Gromit|gulliver|gulper|hambot|havIndex|hotwired|htdig|iajabot|INGRID\/0\.1|Informant|
                InfoSpiders|inspectorwww|irobot|Iron33|JBot|jcrawler|Teoma|Jeeves|jobo|image\.kapsi\.net|KDD\-Explorer|ko_yappo_robot|label\-grabber|
                larbin|legs|Linkidator|linkwalker|Lockon|logo_gif_crawler|marvin|mattie|mediafox|MerzScope|NEC\-MeshExplorer|MindCrawler|udmsearch|moget|
                Motor|msnbot|muncher|muninn|MuscatFerret|MwdSearch|sharp\-info\-agent|WebMechanic|NetScoop|newscan\-online|ObjectsSearch|Occam|Orbsearch\/1\.0|
                packrat|pageboy|ParaSite|patric|pegasus|perlcrawler|phpdig|piltdownman|Pimptrain|pjspider|PlumtreeWebAccessor|PortalBSpider|psbot|Getterrobo\-Plus|
                Raven|RHCS|RixBot|roadrunner|Robbie|robi|RoboCrawl|robofox|Scooter|Search\-AU|searchprocess|Senrigan|Shagseeker|sift|SimBot|Site Valet|skymob|
                SLCrawler\/2\.0|slurp|ESI|snooper|solbot|speedy|spider_monkey|SpiderBot\/1\.0|spiderline|nil|suke|http:\/\/www\.sygol\.com|tach_bw|TechBOT|
                templeton|titin|topiclink|UdmSearch|urlck|Valkyrie libwww\-perl|verticrawl|Victoria|void\-bot|Voyager|VWbot_K|crawlpaper|wapspider|WebBandit\/1\.0|
                webcatcher|T\-H\-U\-N\-D\-E\-R\-S\-T\-O\-N\-E|WebMoose|webquest|webreaper|webs|webspider|WebWalker|wget|winona|whowhere|wlm|WOLP|WWWC|none|XGET|
                Nederland\.zoek|AISearchBot|woriobot|NetSeer|Nutch/i', $_SERVER['HTTP_USER_AGENT'] ) ){
           
           }else {                
                $dominiourl =$_SERVER['SERVER_NAME'];
                switch ($pais) {
                    case 'ES':
                        if ($dominiourl != 'dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'usa.dominio.com')
                            header("Location: https://dominio.com".$URL_P."");
                        break;
                    case 'PT':
                        if ($dominiourl != 'dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'usa.dominio.com')
                            header("Location: https://dominio.com".$URL_P."");
                        break;
                    case 'CE' :
                        if ($dominiourl != 'ce.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'usa.dominio.com' || $dominiourl == 'dominio.com')
                            header("Location: https://ce.dominio.com".$URL_P."");
                        break;
                    case 'US':
                        if ($dominiourl != 'usa.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'dominio.com')
                            header("Location: https://usa.dominio.com".$URL_P."");
                        break;
                    case 'MX':
                        if ($dominiourl != 'usa.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'dominio.com')
                            header("Location: https://usa.dominio.com".$URL_P."");
                        break;
                    case 'GB' :
                        if ($dominiourl != 'uk.dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'usa.dominio.com' || $dominiourl == 'dominio.com')
                            header("Location: https://uk.dominio.com".$URL_P."");
                        break;
                    case 'AU':
                        if ($dominiourl != 'usa.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'dominio.com')
                            header("Location: https://usa.dominio.com".$URL_P."");
                        break;
                    default :
                        if ($dominiourl != 'usa.dominio.com' || $dominiourl == 'uk.dominio.com' || $dominiourl == 'ce.dominio.com' || $dominiourl == 'dominio.com')
                            header("Location: https://usa.dominio.com".$URL_P."");
                        break;
                } 
            }
    }

 

¿Que contiene el archivo geoipcity.inc que incluyes en la primera linea?

 

×
×
  • Create New...