/** * @return bool */ protected function matchCountry() { $accessControlScope = $this->getAccessControlScope(); $ip = $accessControlScope->getIp(); $ipGeo = new myIPGeocoder(); $country = $ipGeo->iptocountry($ip); $country = trim(strtolower($country), " \n\r\t"); $countryList = explode(",", strtolower($this->countryList)); return in_array($country, $countryList); }
public function setCountyByIp($ip) { //long2ip ( $user->getRegistrationIp() ) ; // for first time use, geocode registration IP address $myGeoCoder = new myIPGeocoder(); $country_code = $myGeoCoder->iptocountry($ip); if ($country_code == null || $country_code == "" || $country_code == "ZZ") { $country_code = "US"; } //if we can't identify, assume the US if ($this->getCountry() == "") { $this->setCountry($country_code); } return $this->getCountry(); }
public function execute() { $this->forceSystemAuthentication(); $secret = ""; $str = $this->getP("str"); $algo = $this->getP("algo", "wiki_decode"); $res = ""; $key = null; if ($algo == "wiki_encode") { $res = str_replace(array("|", "/"), array("|01", "|02"), base64_encode(serialize($str))); } elseif ($algo == "wiki_decode") { $res = @unserialize(base64_decode(str_replace(array("|02", "|01"), array("/", "|"), $str))); } elseif ($algo == "wiki_decode_no_serialize") { $res = base64_decode(str_replace(array("|02", "|01"), array("/", "|"), $str)); } elseif ($algo == "base64_encode") { $res = base64_encode($str); } elseif ($algo == "base64_decode") { $res = base64_decode($str); } elseif ($algo == "base64_3des_encode") { $key = $this->getP("des_key"); echo "[{$key}]"; $input = $str; $td = mcrypt_module_open('tripledes', '', 'ecb', ''); $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); $key = substr($key, 0, mcrypt_enc_get_key_size($td)); mcrypt_generic_init($td, $key, $iv); $encrypted_data = mcrypt_generic($td, $input); mcrypt_generic_deinit($td); mcrypt_module_close($td); $res = base64_encode($encrypted_data); $this->des_key = $key; } elseif ($algo == "base64_3des_decode") { $key = $this->getP("des_key"); echo "[{$key}]"; $input = base64_decode($str); $td = mcrypt_module_open('tripledes', '', 'ecb', ''); $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); $key = substr($key, 0, mcrypt_enc_get_key_size($td)); mcrypt_generic_init($td, $key, $iv); $encrypted_data = mdecrypt_generic($td, $input); mcrypt_generic_deinit($td); mcrypt_module_close($td); $res = $encrypted_data; $this->des_key = $key; } elseif ($algo == "ks") { $ks = ks::fromSecureString($str); $res = print_r($ks, true); if ($ks != null) { $expired = $ks->valid_until; $expired_str = self::formatThisData($expired); $now = time(); $now_str = self::formatThisData($now); $res .= "<br>" . "valid until: " . $expired_str . "<br>now: {$now} ({$now_str})"; } } elseif ($algo == "kwid") { $kwid_str = @base64_decode($str); if (!$kwid_str) { // invalid string return ""; } /* $kwid = new kwid(); list ( $kwid->kshow_id , $kwid->partner_id , $kwid->subp_id ,$kwid->article_name ,$kwid->widget_id , $kwid->hash ) = @explode ( self::KWID_SEPARATOR , $str ); */ $cracked = @explode("|", $kwid_str); $names = array("kshow_id", "partner_id", "subp_id", "article_name", "widget_id", "hash"); $combined = array_combine($names, $cracked); $secret = $this->getP("secret"); $md5 = md5($combined["kshow_id"] . $combined["partner_id"] . $combined["subp_id"] . $combined["article_name"] . $combined["widget_id"] . $secret); $combined["secret"] = $secret; $combined["calculated hash"] = substr($md5, 1, 10); $res = print_r($combined, true); } elseif ($algo == "ip") { $ip_geo = new myIPGeocoder(); if ($str) { $remote_addr = $str; } else { $remote_addr = requestUtils::getRemoteAddress(); } $res = $ip_geo->iptocountry($remote_addr); } $this->key = $key; $this->secret = $secret; $this->str = $str; $this->res = $res; $this->algo = $algo; }
protected static function getCountry() { if (is_null(self::$_country)) { require_once dirname(__FILE__) . '/../../alpha/apps/kaltura/lib/myIPGeocoder.class.php'; $ipAddress = infraRequestUtils::getRemoteAddress(); $geoCoder = new myIPGeocoder(); self::$_country = $geoCoder->getCountry($ipAddress); } return self::$_country; }
/** * from ip to country * @action iptocountry * @param string $remote_addr * @return string * */ public function iptocountryAction($remote_addr) { $ip_geo = new myIPGeocoder(); $res = $ip_geo->iptocountry($remote_addr); return $res; }
public static function getIpCountry() { $remote_addr = self::getRemoteAddress(); // TODO that's the only reason to keep it in alpha $ip_geo = new myIPGeocoder(); $country = $ip_geo->iptocountry($remote_addr); return $country; }
public static function getIpCountry() { $remote_addr = self::getRemoteAddress(); $ip_geo = new myIPGeocoder(); $country = $ip_geo->iptocountry($remote_addr); return $country; }