View file wap/flag.php

File size: 1.45Kb
<?php
 $hits = $_GET["hits"];
 $who = $_GET["who"];
  if($who==""||$who==0)
  {
    $mnick = $_POST["mnick"];
    $who = getuid_nick($mnick);
  }
  
 $uid = getuid_hits($hits);


 $uipadd = mysql_fetch_array(mysql_query("SELECT ipadd FROM mx_users WHERE id='".$who."'"));

 $addr = $uipadd[0];

 $ip = sprintf("%u", ip2long($addr));

 $time_start = microtime_float();

 $handle = fopen("ip2country/ip2country.csv", "r");

 $row = 1;
while (($buffer = fgets($handle, 4096)) !== FALSE) {
  $array[$row] = substr($buffer, 1, strpos($buffer, ",") - 1);
  $row++;
}

 $time_end = microtime_float();
 $time = substr($time_end - $time_start, 0, 7);

 $row_lower = '0';
 $row_upper = $row;
while (($row_upper - $row_lower) > 1) {
  $row_midpt = (int) (($row_upper + $row_lower) / 2);
  if ($ip >= $array[$row_midpt]) {
    $row_lower = $row_midpt;
  } else {
    $row_upper = $row_midpt;
  }
}

 $time_end = microtime_float();
 $time = substr($time_end - $time_start, 0, 7);

rewind($handle);
$row = 1;
while ($row <= $row_lower) {
  $buffer = fgets($handle, 4096);
  $row++;
}
$buffer = str_replace("\"", "", $buffer);
$ipdata = explode(",", $buffer);

$iso2 = $ipdata[4];

$country = $ipdata[6];

fclose($handle);

$time_end = microtime_float();
$time = substr($time_end - $time_start, 0, 7);

function microtime_float()
{
   list($usec, $sec) = explode(" ", microtime());
   return ((float)$usec + (float)$sec);
}

?>