Beispiel #1
0
function get_geo($modin, $geo_field = NULL, $update = NULL, $limit = '1000', $offset = '0')
{
    global $dbcon;
    $type = $_REQUEST['type'];
    if ($update) {
        $up_sql = ' and ' . $geo_field . ' != "" ';
    }
    $sql = "select * from userdata where modin =" . $modin . $up_sql . " limit {$offset}, {$limit}";
    $R = $dbcon->Execute($sql) or die("Error getting udm data " . $sql . $dbcon->ErrorMsg());
    $t = 0;
    $x = 0;
    while (!$R->EOF) {
        $t++;
        $geo = new Geo($dbcon);
        $geo->City = $R->Fields("City");
        $geo->State = $R->Fields("State");
        $geo->Street = $R->Fields("Street");
        $geo->Zip = $R->Fields("Zip");
        if ($geo->Street) {
            $geo->geocoder_getdata();
        }
        ///if ( ($R->Fields("City")) &&  ($R->Fields("State")) &&  ($type == 'City') && (!$geo->lat) ) {
        //	$geo->city_lookup();
        //}
        if ($geo->lat && $geo->long) {
            $sql = "update userdata set " . $geo_field . " = '" . $geo->lat . "," . $geo->long . "' where id = " . $R->Fields("id");
            $dbcon->Execute($sql) or die("Error updating udm " . $sql . $dbcon->ErrorMsg());
            echo $R->Fields("id") . ": " . $geo->lat . $geo->long . "<br>";
            $x++;
        } else {
            $html .= "<a href = 'modinput4_view.php?uid=" . $R->Fields("id") . "&modin=" . $modin . "'>" . $R->Fields("Street") . " " . $R->Fields("City") . " " . $R->Fields("State") . " " . $R->Fields("Zip") . " </a><br>";
        }
        $R->MoveNext();
    }
    $out = "Found {$x} address of {$t} <br><br>Failed Addresses<br> {$html}";
    return $out;
}