14. Oktober 2009

PHP Script to find streets with value above 10 mio!

This PHP script will help you to find streets which value is above 10 mio!!!
It will automatically save the streets in a text file!
You just have to save this in a text document and execute it as a php file!
And it works for sure!

//
// This script saves all free streets which have a value above 10 mio in a text file.
//
// To use this script, you will need to execute this file as a php data.
// (see [url]http://www.php.net[/url] or windows.php.net/download )
//
// You have to know the coordinates from the area you want to search!
// Its easy if you use google!
//
// Put the upper left corner coordinates in "$from"
//
// and put the lower right corner coordinates in "$to"
//
// now execute this file using php! You don't have to do anything else!
//
// WARNING: To use the links from the text file you have to remove the dots from the coordinates!
//

$from = array( 42.94 , -124.14 ); // Coordinates from the upper left corner
$to = array( 31.35 , -121.23 ); // Coordinates from the lower right corner

// ****************************************************************
// Don't change anything here!
$from[0]=round($from[0]*100);
$from[1]=round($from[1]*100);
$to[0]=round($to[0]*100);
$to[1]=round($to[1]*100);
$lt1 = min($from[0],$to[0]);
$lt2 = max($from[0],$to[0]);
$lg1 = min($from[1],$to[1]);
$lg2 = max($from[1],$to[1]);

function get_content($host,$uri,$postdata="") {
    $da = fsockopen('www.monopolycitystreets.com', 80, $errno, $errstr);
    if (!$da) {
        die("$errstr ($errno)");
    } else {
        $salida ="GET $uri HTTP/1.1\r\n";
        $salida .="Host: $host\r\n";
        $salida .="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 10.00\r\n";
        $salida .="Connection: close\r\n\r\n";
        fwrite($da, $salida);
        while (!feof($da))
            $response.=fgets($da, 128);
        return $response;
    }
}

set_time_limit(0);
echo "Erstelle monopoly_usa1_".$lt1."_".$lg1.".txt".'

';
$lh = fopen("monopoly_usa1_".$lt1."_".$lg1.".txt", 'w');

for ($long=$lg1;$long < $lg2;$long++) {
    $s = 100;
    for ($lat=$lt1;$lat < $lt2; $lat++) {
        if ($s++ > 99) { $s=1; echo sprintf('%1.2f',($lat/100)).','.sprintf('%1.2f',($long/100)).'

'; sleep(10); }
        $url = "/buy/getstreetstobuy?lat=".$lat."00000&lng=".$long."00000";
        $data = get_content("www.monopolycitystreets.com",$url);
        $roads = split("}",$data);

        foreach ($roads AS $road) {
            $name = "";
            $status = "";
            $owner = "";
            $price = "";;
            list($head,$content) = split("\r\n\r\n",$road);
            if (!$content) { $content=$head; }
            $data = split("{",$content);
            if ($data[2]) {
                list($lg,$lt) = split("/",$data[1]);
                $lines = split(",",$data[2]);
            } else {
                list($lg,$lt) = split("/",$data[0]);
                $lines = split(",",$data[1]);
            }
            $lg = str_replace(",","", $lg);
            $lg = substr($lg,1,strlen($lg)-2);
            $lt = str_replace(":","", $lt);
            foreach($lines AS $line) {
                list($id,$var) = split(":",$line);
                if ($id == '"n"') { $name = $var; }
                elseif ($id == '"s"') { $status = $var; }
                elseif ($id == '"o"') { $owner = $var; }
                elseif ($id == '"p"') { $price = $var; }
            }
            if (($status) AND ($status == '"free"')) {
                $preis = intval(str_replace('"', "", $price));
                if ($preis > 10000) {
                    $csv = str_replace("\" "," ", "www.monopolycitystreets.com/game.html#".(str_replace(".","",$lg)/10000000)."z".(str_replace(".","",$lt)/10000000)." \r\n
\t$name \r\n
\t$status \r\n
\t$owner \r\n
\t".$preis."000 \r\n\r\n");

                    fwrite($lh, $csv);
                }

                if ($preis > 1000) {
                    echo "These streets are available:
";
                    echo "Coordinates: ".($lg/10000000).",".($lt/10000000)."
";
                    echo "Name: \t$name
";
                    echo "Status: \t$status
";
                    echo "Owner: \t$owner
";
                    echo "Price: \t".$preis."000

";
                }
            }
        }
    }
}
fclose($lh);
?>

10 Kommentare:

  1. I'm not good at this stuff, can you post one for me?

    AntwortenLöschen
  2. Sorry, but you have to find your own 10 mio streets ;-)

    AntwortenLöschen
  3. I've installed PHP and tried to run the script, but I'm not sure I know what I'm doing. Should it be that easy?

    AntwortenLöschen
  4. I have installed apache and PHP and it is all running properly. Your script doesn't seem to work. Running apache 2.2 and php 5.2

    Any ideas?

    AntwortenLöschen
  5. Got it going, but getting the following errors:

    Undefined variable line 28
    Undefined offset 2: line 57
    Undefined offset lines 61, 62, 68

    AntwortenLöschen
  6. How do we go about putting in the coordinates?
    are you able to find this out from within the game, or is there another method to work out what to enter?
    thankyou

    AntwortenLöschen
  7. How do you go about working out valid coordinates to enter into the script?
    Can you find this with the game, or is there another method to work these values out?

    AntwortenLöschen
  8. At first this script works and Yes it is easy, you just have to execute this file as a php!
    To find the coordinates you can use google earth. P.S. Only if there is a street which value is above 10 mio. a new text file will be created and the street will be saved there, otherwise not!

    AntwortenLöschen
  9. I just get an empty text file, even if searching over a large area.

    AntwortenLöschen
  10. I get an empty text file as well, and some erro messages as mentioned above.

    AntwortenLöschen