Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.17 KB | None | 0 0
  1. <?php
  2. function check($data){
  3.     $sql = new FCMS_MySql_Con();
  4.     $res = mysql_query("SELECT country FROM geoip WHERE country = '$data'",$sql->GetMyConnection()) or die('Error : ' . mysql_error());
  5. if(!mysql_num_rows($res)){
  6.     $output  = "not found";
  7.     }else{
  8.     $output  = "found";
  9.     }
  10.     return  $output;
  11. }
  12. echo check('AU');
  13. $record = geoip_record_by_name('203.219.47.182');
  14. if($record){
  15.    //print("<br/><font color='red'>Two letter continent code:</font> ".check("AU"));
  16.     print("<br/><font color='red'>Two letter country code:</font> ".$record[country_code]);
  17.     print("<br/><font color='red'>Three letter country code:</font> ".$record[country_code3]);
  18.     print("<br/><font color='red'>The country name:</font> ".$record[country_name]);
  19.     print("<br/><font color='red'>The region code:</font> ".$record[region]);
  20.     print("<br/><font color='red'>The city:</font>  ".$record[city]);
  21.     print("<br/><font color='red'>The Postal Code, FSA or Zip Code.:</font> ".$record[postal_code]);
  22.     print("<br/><font color='red'>The Latitude as signed double:</font> ".$record[latitude]);
  23.     print("<br/><font color='red'>The Longitude as signed double: </font> ".$record[longitude]);
  24.     print("<br/><font color='red'>Designated Market Area code (USA and Canada only):</font> ".$record[dma_code]);
  25.     print("<br/><font color='red'>The PSTN area code (ex: 212):</font> ".$record[area_code]);
  26. }
  27.  
  28.  
  29. class FCMS_MySql_Con {
  30.    
  31. var $g_link = false;
  32. var $db_host = "localhost:3306";
  33. var $db_user = "root";
  34. var $db_password = "";
  35. var $db_name = "";
  36. function CheckSql(){
  37. if (!isset($this->g_link)) {
  38.     $this->g_link = false;
  39.     }
  40.     return $this->g_link;
  41. }
  42.  
  43. function GetMyConnection(){
  44. if($this->g_link){
  45.   return $this->g_link;
  46. }
  47.    $this->g_link = mysql_connect($this->db_host, $this->db_user, $this->db_password) or die('Could not connect to mysql server. ERROR:'.mysql_error() );
  48.    mysql_select_db($this->db_name, $this->g_link) or die('Could not select database. ERROR:'.mysql_error() );
  49.    return $this->g_link;
  50. }
  51.  
  52. function CleanUpDB(){
  53.         if( $this->g_link != false ){
  54.             mysql_close($this->g_link);
  55.         }
  56.         return $this->g_link = false;
  57.     }
  58.    
  59. }
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement