예제 #1
0
function geoip_detect_plugin_page()
{
    geoip_detect_set_cron_schedule();
    $ip_lookup_result = false;
    $last_update = 0;
    $message = '';
    switch (@$_POST['action']) {
        case 'update':
            $ret = geoip_detect_update();
            if ($ret === true) {
                $message .= __('Updated successfully.', 'geoip-detect');
            } else {
                $message .= __('Update failed.', 'geoip-detect') . ' ' . $ret;
            }
            break;
        case 'lookup':
            if (isset($_POST['ip'])) {
                $ip = $_POST['ip'];
                $ip_lookup_result = geoip_detect_get_info_from_ip($ip);
            }
            break;
        case 'options':
            $opt_value = isset($_POST['options']['set_css_country']) ? (int) $_POST['options']['set_css_country'] : 0;
            update_option('geoip-detect-set_css_country', $opt_value);
            $opt_value = isset($_POST['options']['data_filename']) ? $_POST['options']['data_filename'] : 'GeoLiteCity.dat';
            update_option('geoip-detect-data_filename', $opt_value);
            break;
    }
    $data_file = geoip_detect_get_abs_db_filename();
    if (file_exists($data_file)) {
        $last_update = filemtime($data_file);
    } else {
        $message .= __('No GeoIP Database found. Click on the button "Update now" or follow the installation instructions.', 'geoip-detect');
        $last_update = 0;
    }
    if (empty($custom_filename)) {
        $next_cron_update = wp_next_scheduled('geoipdetectupdate');
    }
    $options = array();
    $options['set_css_country'] = (int) get_option('geoip-detect-set_css_country');
    $options['data_filename'] = get_option('geoip-detect-data_filename');
    include_once dirname(__FILE__) . '/views/plugin_page.php';
}
예제 #2
0
function geoip_detect_activate()
{
    geoip_detect_set_cron_schedule();
}