Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 726381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:26:43+00:00 2026-05-14T06:26:43+00:00

Sorry to bother again, but I really need help transforming this Python2 code into

  • 0

Sorry to bother again, but I really need help transforming this Python2 code into PHP.

net, cid, lac = 25002, 9164, 4000
import urllib

a = '000E00000000000000000000000000001B0000000000000000000000030000'
b = hex(cid)[2:].zfill(8) + hex(lac)[2:].zfill(8)
c = hex(divmod(net,100)[1])[2:].zfill(8) + hex(divmod(net,100)[0])[2:].zfill(8)
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

Would be great if someone could help, thanks in advance!

EDIT:

I see. Can you edit your post to include what you’ve translated so far please.

<?php

$net = 25002;
$cid = 9164;
$lac = 4000;

$a = '000E00000000000000000000000000001B0000000000000000000000030000'
$b = hex($cid)[2:].zfill(8) + hex($lac)[2:].zfill(8)
$c = hex(divmod($net,100)[1])[2:].zfill(8) + hex(divmod($net,100)[0])[2:].zfill(8)
$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

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:26:44+00:00Added an answer on May 14, 2026 at 6:26 am

    Because the World of Warcraft servers are down during my lunch break:

    // net, cid, lac = 25002, 9164, 4000
    $net = 25002;
    $cid = 9164;
    $lac = 4000;
    
    // import urllib
    
    //a = '000E00000000000000000000000000001B0000000000000000000000030000'
    $a = '000E00000000000000000000000000001B0000000000000000000000030000';
    
    //b = hex(cid)[2:].zfill(8) + hex(lac)[2:].zfill(8)
    $b = sprintf("%08x%08x", $cid, $lac);
    
    //c = hex(divmod(net,100)[1])[2:].zfill(8) + hex(divmod(net,100)[0])[2:].zfill(8)
    $c = sprintf("%08x%08x", $net % 100, floor($net / 100));
    
    //string = (a + b + c + 'FFFFFFFF00000000').decode('hex')
    $string = $a . $b . $c . 'FFFFFFFF00000000';
    $newstring = '';
    for( $i = 0, $count = strlen($string); $i < $count; $i++ ) {
     $newstring .= sprintf("%c", hexdec($string{$i} . $string{++$i}));
    }
    
    //data = urllib.urlopen('http://www.google.com/glm/mmap',string)
    $ch = curl_init('http://www.google.com/glm/mmap');
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $newstring);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    //r = data.read().encode('hex')
    $r = curl_exec($ch);
    
    //print float(int(r[14:22],16))/1000000, float(int(r[22:30],16))/1000000
    $r = array_pop(unpack("H*", $r));
    printf("%f, %f", hexdec(substr($r, 14, 8)) / 1000000, hexdec(substr($r, 22, 8)) / 1000000);
    

    I would love to see more elegant hex conversion, though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 497k
  • Answers 497k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer As long as you stick to WS-I-based SOAP standards, then… May 16, 2026 at 11:57 am
  • Editorial Team
    Editorial Team added an answer No, No and No. They are including it because its… May 16, 2026 at 11:57 am
  • Editorial Team
    Editorial Team added an answer The reason you are seeing this behaviour is because the… May 16, 2026 at 11:57 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Sorry to bother you guys again, but here's my dilemma. There must be a
Sorry about this long block of code, but I think it makes sense to
Sorry to bother everyone again. For some reason when I try to run the
Sorry, but I know nothing at all about fonts, so I hope that this
I've come to bother you all with another probably really simple C question. Using
Sorry if this has been asked, I am not sure how to best word
Sorry, this is quite a special topic so this may not be of interest
sorry for being dumb here, but I failed to see why these tools can
Sorry for what seems like a silly question: But I've never, ever worked with
Sorry if this seems like a silly question - I am an amateur when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.