BRT2010 Posted April 13, 2010 Share Posted April 13, 2010 Hi guys, I have already posted about a php script, that would turn CellID information into Lat/Long, but obviously the topic itself had scared off potential answerers. Let me try again. I have found a Python2 script that takes net, cid, lac information, passes it to google maps and brings back the lat/long coordinates, that I need so much. net, cid, lac = 25002, 9164, 4000 import urllib a = '000E00000000000000000000000000001B0000000000000000000000030000' b = hex(cid)[2:].zfill( + hex(lac)[2:].zfill( c = hex(divmod(net,100)[1])[2:].zfill( + hex(divmod(net,100)[0])[2:].zfill( string = (a + b + c + 'FFFFFFFF00000000').decode('hex') data = urllib.urlopen('http://www.google.com/glm/mmap',string) r = data.read().encode('hex') print float(int(r[14:22],16))/1000000, float(int(r[22:30],16))/1000000 It's very simple, but unfortunately I don't understated that HEX stuff, what it is and how it form. Maybe someone could please help me transform this code into PHP ? Thanks! Link to comment https://forums.phpfreaks.com/topic/198387-need-help-turning-a-simple-python-code-into-php/ Share on other sites More sharing options...
TeddyKiller Posted April 13, 2010 Share Posted April 13, 2010 I can't help. Although.. here is my best shot. I know some of the code is variables, the ones in which I thought were, I put on the $. Hope I'm on the right track.. $net = 25002; $cid = 9164; $lac = 4000; import urllib; $a = '000E00000000000000000000000000001B000000000000000 0000000030000'; $b = hex($cid)[2:].zfill( + hex($lac)[2:].zfill(; $c = hex(divmod($net,100)[1])[2:].zfill( + hex(divmod($net,100)[0])[2:].zfill(; string = ($a + $b + $c + 'FFFFFFFF00000000').decode($hex); try { $data = urllib.urlopen('http://www.google.com/glm/mmap', string); $r = $data.read().encode($hex); if(len($r) > 14) { echo float(int($r[14:22],16))/1000000, float(int($r[22:30],16))/1000000; } else { echo 'no data in google'; } } catch { echo 'connect error'; } Link to comment https://forums.phpfreaks.com/topic/198387-need-help-turning-a-simple-python-code-into-php/#findComment-1040997 Share on other sites More sharing options...
BRT2010 Posted April 13, 2010 Author Share Posted April 13, 2010 thanks for the input. <?php $net = 25002; $cid = 9164; $lac = 4000; $a = '000E00000000000000000000000000001B0000000000000000000000030000' $b = hex($cid)[2:].zfill( + hex($lac)[2:].zfill( $c = hex(divmod($net,100)[1])[2:].zfill( + hex(divmod($net,100)[0])[2:].zfill( $string = ($a + $b + $c + 'FFFFFFFF00000000').decode('hex') $data = 'http://www.google.com/glm/mmap'.$string $r = $data.read().encode('hex') print float(int($r[14:22],16))/1000000, float(int($r[22:30],16))/1000000 ?> currently got that far. seems there's a problem with "hex($cid)[2:].zfill( + hex($lac)[2:].zfill("... Link to comment https://forums.phpfreaks.com/topic/198387-need-help-turning-a-simple-python-code-into-php/#findComment-1041007 Share on other sites More sharing options...
TeddyKiller Posted April 13, 2010 Share Posted April 13, 2010 Well you'll need some semi colons. I'l not sure what a hex is, it could be regex? I'm not sure. Look up.. Python hex, on google. See if you can come up with what it is. Link to comment https://forums.phpfreaks.com/topic/198387-need-help-turning-a-simple-python-code-into-php/#findComment-1041084 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.