Skip to content

Instantly share code, notes, and snippets.

jQuery.fn.center = function () {
this.css("position","absolute");
this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) + $(window).scrollTop()) + "px");
this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) + $(window).scrollLeft()) + "px");
return this;
}
@borzov
borzov / get_country_by_ip.php
Created May 12, 2013 06:07
PHP: Determination of the country by IP
function get_country($ip_addr) {
$curlopt_useragent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0';
$url = 'http://www.geoplugin.net/php.gp?ip=' . $ip_addr;
$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_URL, $url);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch1);
$geoplugin = unserialize($result);
if ($geoplugin[geoplugin_countryCode] != '') {