Last active
January 4, 2018 09:26
-
-
Save andreibabor/cdf52f60eac31d58c99e786ff5368d41 to your computer and use it in GitHub Desktop.
Script - show my IP Address
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="application/javascript"> | |
function getIP(json) { | |
alert("My public IP address is: " + json.ip); | |
} | |
</script> | |
<script type="application/javascript" | |
src="http://api.ipify.org?format=jsonp&callback=getIP"> | |
</script> | |
<!-- END: IP Stuff --> |
<script>
jQuery.ajax( {
url: '//freegeoip.net/json/',
type: 'POST',
dataType: 'jsonp',
success: function(location) {
if ( location.ip === '{{ settings.ip_address_1 }}' ||
location.ip === '{{ settings.ip_address_2 }}' ||
location.ip === '{{ settings.ip_address_3 }}' ||
location.ip === '{{ settings.ip_address_4 }}' ||
location.ip === '{{ settings.ip_address_5 }}'
) {
console.log('ip active');
}
else{
console.log('ip disabled');
IPRedirect.init({{ settings | json }});
IPRedirect.run();
}
}
});
</script>
iar in settings-> IP Redirect
{
"type": "header",
"content": "IP addresses"
},
{
"type": "text",
"id": "ip_address_1",
"label": "First IP",
"default": "67.171.183.81"
},
{
"type": "text",
"id": "ip_address_2",
"label": "Second IP",
"default": "10.0.0.97"
},
{
"type": "text",
"id": "ip_address_3",
"label": "Third IP",
"default": "173.11.9.157"
},
{
"type": "text",
"id": "ip_address_4",
"label": "Four IP",
"default": "192.168.1.75"
},
{
"type": "text",
"id": "ip_address_5",
"label": "Five IP",
"default": "192.168.1.254"
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mai multe informatii
https://help.shopify.com/themes/customization/store/get-customers-location#use-the-geolocation-api