php - Strict standards: Non-static method CountryDetector::countryMatches() should not be called statically in -


i trying restrict countries , it's redirecting restricted country users perfectly. but, when user not restrict country, website loading following error message showing on top side of website.

strict standards: non-static method countrydetector::countrymatches() should not called statically in c:\wamp\www\final\country\countrydetector.class.php on line 61

i calling class on index.php file this:

<?php     include('/country/countrydetector.class.php');     countrydetector::redirect("de", "http://google.com"); ?> 

and class library using is:

<?php       include("countrydetector.interface.php");      /**      * class lookup's country code redirects (include files, or callbacks) user desired content want.      * function of class google redirects users countries support google       * e.g. in uk when enter google.com redirected google.co.uk , excatly       * can countrydetector      *      * class builded in static context purpose of best usage       class countrydetector implements countrydetectorinterface     {         private static $current_country;          private static $include_done;           /** defined countries */         private static $balkans = array("al", "ba","hr", "rs", "me", "bg", "mk", "gr");          private static $europe = array("al", "ad", "am", "at", "az", "by", "be", "ba", "bg", "hr", "cy", "cz", "cs", "dk", "ee", "fi", "fr", "fx", "ge", "de", "gr", "hu", "is", "ie", "it", "kz", "lv", "li", "lt", "lu", "mk", "mt", "md", "mc", "me", "nl", "no", "pl", "pt", "ro", "ru", "sm", "rs", "si", "es", "se", "ch", "tr", "ua", "uk", "va");          private static $middleeast = array("tr", "bh", "kw", "om", "qa", "sa", "ae", "ye", "ps", "iq", "il. jo", "lb", "sy", "ir", "cy", "eg");          private static $asia = array("af", "am", "az", "bh", "bd", "bt", "io", "dn", "kh", "cn", "cx", "cc", "ge", "hk", "in", "id", "ir", "iq", "il", "jp", "jo", "kz", "kp", "kr", "kw", "kg", "la", "lb", "mo", "my", "mv", "mn", "np", "om", "pk", "ps", "ph", "qa", "ru", "sa", "sg", "lk", "sy", "tw", "tj", "th", "tp", "ae", "uz", "vn", "ye");          private static $america = array("us", "bz", "cr", "sv", "gt", "hn", "ni", "pa", "mx", "ht", "cu", "ar", "bo", "br", "cl", "co", "ec", "fk", "gf", "gy", "py", "pe", "sr", "uy", "ve");          private static $northamerica = array("us");          private static $southamerica = array("ar", "bo", "br", "cl", "co", "ec", "fk", "gf", "gy", "py", "pe", "sr", "uy", "ve");          private static $centralamerica = array("bz", "cr", "sv", "gt", "hn", "ni", "pa", "mx", "ht", "cu");          private static $caribbean = array("ai", "ag", "aw", "bs", "bb", "vg", "ky", "cu", "dm", "do", "gd", "gp", "ht", "jm", "mq", "ms", "an", "pr", "kn", "lc", "vc", "tt", "tc", "vi");           /**          * redirect url based on country code          *          * @param $country - country want apply rule          * @param $url - if country matches redirected url          *          * @return void          */          public static function redirect($country, $url, $except = null)         {             self::_lookup();              $matches = self::countrymatches($country, $except);              if( $matches )             {                 if( !@header("location: $url") )                 {                     print('<script type="text/javascript"> window.location = "'.$url.'"; </script>');                 }                            }         }           /**          * use reserved word `include` require file based on country code          *          * @param $country - country want apply rule          * @param $include_path - if country matches included selected file          *          * @return void          */          public static function includefile($country, $include_path, $except = null)         {             self::_lookup();              $matches = self::countrymatches($country, $except);              if( $matches )             {                 include($include_path);             }         }           /**          * include once - include 1 time file          *          * @param $country - country want apply rule          * @param $include_path - if country matches included selected file          *          * @return void          */          public static function includefileonce($country, $include_path, $except = null)         {             if( !self::$include_done )             {                 self::_lookup();                  $matches = self::countrymatches($country, $except);                  if( $matches )                 {                     include($include_path);                     self::$include_done = true;                 }             }         }           /**          * call's specified function based on country code          *          * @param $country - country want apply rule          * @param $callback_func - if country matches function named $callback_func() called (with no parameters)          *          * @return void          */          public static function callback($country, $callback_func, $except = null)         {             self::_lookup();              $matches = self::countrymatches($country, $except);              if( $matches )             {                 call_user_func($callback_func);             }         }           /**          * lookup's country (based on ip)          *          * @return void          */          private static function _lookup()         {             if( !self::$current_country )             {                 $remote_addr = $_server['remote_addr'];                 $api_url = str_replace("#remote_addr#", $remote_addr, self::ip_api_url);                  $ch = curl_init();                 curl_setopt($ch, curlopt_url, $api_url);                 curl_setopt($ch, curlopt_returntransfer, true);                 $country_code = curl_exec($ch);                 curl_close($ch);                  self::$current_country = strtoupper($country_code);                          }         }           /**          * check if country matches country parameter          *          * @return boolean - true if matches, false if not          */          private function countrymatches($country, $except)         {             $cs = $country;              if( ! is_array($country) )             {                 switch( strtoupper($country) )                 {                     case "america":                         $country = self::$america;                         break;                      case "asia":                         $country = self::$asia;                         break;                      case "balkans":                     case "balkan":                         $country = self::$balkans;                         break;                      case "caribbean":                         $country = self::$caribbean;                         break;                      case "centralamerica":                         $country = self::$centralamerica;                         break;                      case "europe":                         $country = self::$europe;                         break;                      case "middleeast":                     case "middle east":                         $country = self::$middleeast;                         break;                      case "northamerica":                     case "united states":                         $country = self::$northamerica;                         break;                      case "southamerica":                     case "latin america":                         $country = self::$southamerica;                         break;                      default:                         $country = array($country);                 }             }              if( is_array($except) )             {                 foreach($except $except_country)                 {                     if( $except_country == self::$current_country )                         return false;                 }             }              if( $cs == "*" || strtoupper($cs) == "international" )                 return true;              if( in_array(self::$current_country, $country) && !in_array($except, $country) )             {                 return true;             }              return false;         }           /* v1.1 */          // country code of current country         public static function getcountrycode()         {             if( ! self::$current_country)             {                 self::_lookup();             }              return self::$current_country;         }          public static function is($country_code)         {             if( ! self::$current_country)             {                 self::_lookup();             }              $cc = strtolower(self::$current_country);             $country_code = strtolower($country_code);              return $cc == $country_code;         }     }    ?> 

your method countymatches not declared statically, private static function countrymatches($country, $except)


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -