Esempio n. 1
0
function bestaddress($guess)
{
    global $conn;
    # Generate a canonical version of the guess
    $canon = canonize($guess);
    # Get every damn address from the database
    $result = mysql_query("SELECT * FROM caladdress", $conn);
    if (!$result) {
        return;
    }
    # Look for the best match
    $bestmatch = 75;
    while ($record = mysql_fetch_array($result)) {
        $match = cmpcanon($canon, $record["canon"]);
        print "<!-- cmpcanon(\"{$canon}\", \"{$record[canon]}\") returned {$match} -->\n";
        if ($match >= $bestmatch) {
            $bestmatch = $match;
            $best = $record;
        }
    }
    # Return the best match.  Note that if no address rates at least 75 then
    # $best will be NULL.
    return $best;
}
Esempio n. 2
0
function bestaddress($guess, $locked)
{
    global $conn;
    # Generate a canonical version of the guess
    $canon = canonize($guess);
    # Get every damn address from the database
    $result = mysql_query("SELECT * FROM caladdress WHERE locked = {$locked}", $conn);
    if (!$result) {
        die(mysql_error());
    }
    # Look for the best match
    $bestmatch = 50;
    while ($record = mysql_fetch_array($result)) {
        $match = cmpcanon($canon, $record["canon"]);
        if ($match >= $bestmatch) {
            $bestmatch = $match;
            $best = $record;
        }
    }
    # Return the best match.  Note that if no address rates at least 75 then
    # $best will be NULL.
    return $best;
}