Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/02/2006, 04:04
Alert
 
Fecha de Ingreso: junio-2004
Mensajes: 72
Antigüedad: 20 años, 10 meses
Puntos: 2
Exclamación Pasar Codigo de PHP a ASP , kien me ayuda

Hola como estan, les comento encontre un codigo en PHP lo cual lo testie y funca lo mas bien, el tema es que quiero pasarlo a ASP no me da estar instalando el modulo de php por un solo Script. hace unos meces paso algo similar, en donde alguien necesitaba pasar un codigo a ASP, no recuerdo quien hiso el trabajo, les pongo el codigo para ver si pueden ayudarme, Gracias de antemano

Código:
<?php

$addr = getenv("REMOTE_ADDR");
echo "Your IP, IPv4: " . $addr . "<br />\n";

$ip = sprintf("%u", ip2long($addr));
echo "Your IP, numerical: " . $ip . "<br /><br />\n";

$time_start = microtime_float();

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

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

$time_end = microtime_float();
$time = substr($time_end - $time_start, 0, 7);
echo "Array with " . $row . " start ips loaded in $time seconds<br /><br />\n";

$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);
echo "Row with your ip (# " . $row_lower . ") located after $time seconds<br /><br />\n";

rewind($handle);
$row = 1;
while ($row <= $row_lower) {
  $buffer = fgets($handle, 4096);
  $row++;
}
$buffer = str_replace("\"", "", $buffer);
$ipdata = explode(",", $buffer);
echo "Data retrieved from the csv file:<br />\n";
echo "ipstart = " . $ipdata[0] . "<br />\n";
echo "ipend = " . $ipdata[1] . "<br />\n";
echo "registry = " . $ipdata[2] . "<br />\n";
echo "assigned = " . date('j.n.Y', $ipdata[3]) . "<br />\n";
echo "iso2 = " . $ipdata[4] . "<br />\n";
echo "iso3 = " . $ipdata[5] . "<br />\n";
echo "country = " . $ipdata[6] . "<br /><br />\n";

fclose($handle);

$time_end = microtime_float();
$time = substr($time_end - $time_start, 0, 7);
echo "Executing the whole script took $time seconds\n";

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

?>
Agradesco cualkier ayuda que me puedan dar, Muchas gracias