function GeoLoc($ipaddr)
{
    if (!is_file("/usr/share/GeoIP/GeoIPCity.dat")) {
        UpdateGeoip();
        if (!is_file("/usr/share/GeoIP/GeoIPCity.dat")) {
            return array();
        }
    }
    if (isset($GLOBALS["GEO"][$ipaddr])) {
        $country = $GLOBALS["GEO"][$ipaddr];
    }
    if (!function_exists("geoip_record_by_name")) {
        return;
    }
    $record = geoip_record_by_name($ipaddr);
    if ($record) {
        $country = $record["country_name"];
        $GLOBALS["GEO"][$ipaddr] = $country;
    }
    return $country;
}
示例#2
0
        $file = "last-100-mails-" . md5($FILTERBY) . ".html";
        break;
    case null:
        $sql = "SELECT * FROM smtp_logs WHERE LENGTH(delivery_user)>0 ORDER BY time_connect DESC LIMIT 0,{$ini->_params["ENGINE"]["LIMIT"]}";
        $file = "last-100-mails.html";
        break;
    default:
        $sql = "SELECT * FROM smtp_logs WHERE LENGTH(delivery_user)>0 AND bounce_error='{$num}' ORDER BY time_connect DESC LIMIT 0,{$ini->_params["ENGINE"]["LIMIT"]}";
        $file = "last-100-mails-" . md5($FILTERBY) . ".html";
        break;
}
BuildHeader($sql, $file, $maxmail, $FILTERBY);
RTMevents("RTMMailConfig OK");
UpdateDiscards();
RTMevents("UpdateDiscards() OK");
UpdateGeoip();
RTMevents("UpdateGeoip() OK");
@unlink("/etc/artica-postfix/croned.2/" . md5(__FILE__));
@file_put_contents("/etc/artica-postfix/croned.2/" . md5(__FILE__), date('Y-m-d H:i:s'));
die;
function BuildHeader($sql_query, $html_file = "last-100-mails.html", $maxmail, $subtitle = null)
{
    $date_start = time();
    $q = new mysql();
    $results = $q->QUERY_SQL($sql_query, "artica_events");
    if (!$q->ok) {
        RTMevents("Wrong sql query {$q->mysql_error}");
        return null;
    }
    $count = 0;
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
示例#3
0
function GeoIP($servername)
{
    if (strpos($servername, ".") == 0) {
        return array();
    }
    if (!is_file("/usr/share/GeoIP/GeoIPCity.dat")) {
        UpdateGeoip();
        if (!is_file("/usr/share/GeoIP/GeoIPCity.dat")) {
            return array();
        }
    }
    if (!function_exists("geoip_record_by_name")) {
        if ($GLOBALS["VERBOSE"]) {
            echo "geoip_record_by_name no such function\n";
        }
        return array();
    }
    $site_IP = gethostbyname($servername);
    if ($site_IP == null) {
        events("GeoIP():: {$site_IP} is Null");
        return array();
    }
    if (!preg_match("#[0-9]+\\.[0-9]+\\.[0-9]+#", $site_IP)) {
        events("GeoIP():: {$site_IP} ->gethostbyname()");
        $site_IP = gethostbyname($site_IP);
        events("GeoIP():: {$site_IP}");
    }
    if (isset($GLOBALS["COUNTRIES"][$site_IP])) {
        if (trim($GLOBALS["COUNTRIES"][$site_IP]) != null) {
            events("GeoIP():: {$site_IP} {$GLOBALS["COUNTRIES"][$site_IP]}/{$GLOBALS["CITIES"][$site_IP]}");
            if ($GLOBALS["VERBOSE"]) {
                echo "{$site_IP}:: MEM={$GLOBALS["COUNTRIES"][$site_IP]}\n";
            }
            return array($GLOBALS["COUNTRIES"][$site_IP], $GLOBALS["CITIES"][$site_IP]);
        }
    }
    $record = geoip_record_by_name($site_IP);
    if ($record) {
        $Country = $record["country_name"];
        $city = $record["city"];
        $GLOBALS["COUNTRIES"][$site_IP] = $Country;
        $GLOBALS["CITIES"][$site_IP] = $city;
        events("GeoIP():: {$site_IP} {$Country}/{$city}");
        return array($GLOBALS["COUNTRIES"][$site_IP], $GLOBALS["CITIES"][$site_IP]);
    } else {
        events("GeoIP():: {$site_IP} No record");
        if ($GLOBALS["VERBOSE"]) {
            echo "{$site_IP}:: No record\n";
        }
        return array();
    }
    return array();
}