sir, this code from bahri in c# php something
sir pls help convert it to excel macro
thank you



<html>
<head>
<title>GSM LAC/CID -> loc test</title>
</head>
<body>
<style type="text/css">
body {
font-family: Verdana, Helvetica, Geneva, Arial,
  SunSans-Regular, sans-serif;
font-size:12;
}
td {
font-family: Verdana, Helvetica, Geneva, Arial,
  SunSans-Regular, sans-serif;
font-size:12;
}
</style>
<center>
<table width="450">
<tr><td>
</td></tr>
</table>
<form method="post" action="<?php echo $PHP_SELF;?>">
<table>
<tr>
<td><a href="http://en.wikipedia.org/wiki/List_of_mobile_country_codes";>MCC
- Mobile Country Code</a></td>
<td>
<input type="text" size="5" name="mcc" value="<?php if(isset($mcc)) echo
$mcc; else echo "286"?>"><br />
</td>
<tr>
<td><a href="http://en.wikipedia.org/wiki/Mobile_Network_Code";>MNC - Mobile
Network Code</a></td>
<td>
<input type="text" size="5" name="mnc" value="<?php if(isset($mnc)) echo
$mnc; else echo "01"?>"><br />
</td>
<tr>
<td>LAC - Location Area Code</td>
<td>
<input type="text" size="5" name="lac" value="<?php if(isset($lac)) echo
$lac; else echo "21534"?>"><br />
</td>
</tr>
<td>CID - Cell ID</td>
<td>
<input type="text" size="5" name="cid" value="<?php if(isset($cid)) echo
$cid; else echo "271"?>"><br />
</td>
</tr>
<tr>
<td colspan="2"><center><input type="Submit" value="Check it"></center></td>
</tr>
</table>
</form>
<?php
if (isset($lac) && isset($cid) && isset($mnc) && isset($mcc)) {
$data =
                "\x00\x0e".
                "\x00\x00\x00\x00\x00\x00\x00\x00".
                "\x00\x00".
                "\x00\x00".
                "\x00\x00".
                "\x1b".
                "\x00\x00\x00\x00".
                "\x00\x00\x00\x00".
                "\x00\x00\x00\x00".
                "\x00\x00".
                "\x00\x00\x00\x00".
                "\x00\x00\x00\x00".
                "\x00\x00\x00\x00".
                "\x00\x00\x00\x00".
                "\xff\xff\xff\xff".
                "\x00\x00\x00\x00";

$is_umts_cell = ($cid > 65535);
if ($is_umts_cell) // GSM: 4 hex digits, UTMS: 6 hex digits
$data[0x1c] = 5;
else
$data[0x1c] = 3;

$hexmcc = substr("00000000".dechex($_REQUEST["mcc"]),-8);
$hexmnc = substr("00000000".dechex($_REQUEST["mnc"]),-8);
$hexlac = substr("00000000".dechex($_REQUEST["lac"]),-8);
$hexcid = substr("00000000".dechex($_REQUEST["cid"]),-8);

echo "<p>MCC=$hexmcc MNC=$hexmnc LAC=$hexlac CID=$hexcid";
 $data[0x11] = pack("H*",substr($hexmnc,0,2));
$data[0x12] = pack("H*",substr($hexmnc,2,2));
$data[0x13] = pack("H*",substr($hexmnc,4,2));
$data[0x14] = pack("H*",substr($hexmnc,6,2));

$data[0x15] = pack("H*",substr($hexmcc,0,2));
$data[0x16] = pack("H*",substr($hexmcc,2,2));
$data[0x17] = pack("H*",substr($hexmcc,4,2));
$data[0x18] = pack("H*",substr($hexmcc,6,2));
 $data[0x27] = pack("H*",substr($hexmnc,0,2));
$data[0x28] = pack("H*",substr($hexmnc,2,2));
$data[0x29] = pack("H*",substr($hexmnc,4,2));
$data[0x2a] = pack("H*",substr($hexmnc,6,2));

$data[0x2b] = pack("H*",substr($hexmcc,0,2));
$data[0x2c] = pack("H*",substr($hexmcc,2,2));
$data[0x2d] = pack("H*",substr($hexmcc,4,2));
$data[0x2e] = pack("H*",substr($hexmcc,6,2));

$data[0x1f] = pack("H*",substr($hexcid,0,2));
$data[0x20] = pack("H*",substr($hexcid,2,2));
$data[0x21] = pack("H*",substr($hexcid,4,2));
$data[0x22] = pack("H*",substr($hexcid,6,2));

$data[0x23] = pack("H*",substr($hexlac,0,2));
$data[0x24] = pack("H*",substr($hexlac,2,2));
$data[0x25] = pack("H*",substr($hexlac,4,2));
$data[0x26] = pack("H*",substr($hexlac,6,2));

/* I used file_get_contents() at my laptop webserver, but it seems like the
PHP version
 * at my hosting company is old and it is not supporting that.
 * For the hosting company, here we're using cURL.
 */
$use_curl = true;
if ($use_curl) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.google.com/glm/mmap";);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-type:
application/binary"));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_POST, 1);
$response = curl_exec($ch);
if (curl_errno($ch))
exit("Error: Failed to post data $str curl_errno($ch)");

$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$str = substr($response, $header_size);

curl_close($ch);
} else {
$context = array (
'http' => array (
'method' => 'POST',
'header'=> "Content-type: application/binary\r\n"
. "Content-Length: " . strlen($data) . "\r\n",
'content' => $data
)
);
$xcontext = stream_context_create($context);
$str=file_get_contents("http://www.google.com/glm/mmap";, FALSE, $xcontext);
}
 $opcode1 = ((ord($str[0]) << 8)) | ord($str[1]);
$opcode2 = ord($str[2]);

if (($opcode1 != 0x0e) || ($opcode2 != 0x1b))
exit("<p>Error: Invalid opcode $opcode1 $opcode2. Maybe the LAC/CID is
invalid");

$retcode = ((ord($str[3]) << 24) | (ord($str[4]) << 16) | (ord($str[5]) <<
8) | (ord($str[6])));
if ($retcode != 0)
exit("<p>Error: Invalid return code $retcode. Maybe the LAC/CID is
invalid");

$lat = ((ord($str[7]) << 24) | (ord($str[8]) << 16) | (ord($str[9]) << 8) |
(ord($str[10]))) / 1000000;
$lon = ((ord($str[11]) << 24) | (ord($str[12]) << 16) | (ord($str[13]) <<
8) | (ord($str[14]))) / 1000000;

// exit script if cannot geocode cell e.g. not on google's database
if ($lat == 0 and $lon == 0)
exit('ERROR: cannot determine cell tower location from cell LAC: ' .
$_REQUEST["lac"] . ', ' . 'CID: ' . $_REQUEST["cid"]);

$addr = $lat . ',' . $lon;
$t = urlencode(" (MCC=$mcc MNC=$mnc LAC=$lac CID=$cid)");
echo "<p><a href='http://maps.google.com/maps?q=$addr$t'
target='_top'>Lat=$lat Lon=$lon</a>";
}
?>

<p>
<iframe
width="425" height="350" frameborder="0" scrolling="no" marginheight="0"
marginwidth="0"
src="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=<?php
if(isset($addr)) echo $addr; else echo '41.038526,28.985649
'?>&ie=UTF8&ll=<?php
if(isset($addr)) echo $addr; else echo '41.038526,28.985649'?>&sll=<?php
if(isset($addr)) echo $addr; else echo
'41.038526,28.985649'?>&t=h&z=12&output=embed"></iframe>

<p>&nbsp;
<p>&nbsp;
<p>
<font size="1">Prince Daya</font>

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

Reply via email to