コード例 #1
0
ファイル: version-check.php プロジェクト: alx/blogsfera
function fs_get_latest_ip2c_db_version_message()
{
    $current_version = fs_get_current_ip2c_db_version();
    $url = sprintf(FS_IP2COUNTRY_DB_VER_CHECK_URL, $current_version);
    $type = 'ip-to-country-db';
    $error = '';
    $info = fs_lazy_get_latest_version_info($url, $type, 60 * 24 * 14, $error);
    if (!empty($error)) {
        return $error;
    }
    $ver = isset($info[$type]) ? $info[$type]['version'] : "";
    if ($info != null && ver_comp($current_version, $ver) < 0) {
        return '<br/>' . fs_r('A new version of the IP-to-country database is available! you can update it from the settings tab');
    } else {
        return "";
    }
}
コード例 #2
0
ファイル: page-settings.php プロジェクト: alx/blogsfera
</h3>
			<?php 
    $msg = fs_r('Automatically check if there is a new version of FireStats (recommended)');
    fs_create_checkbox('firestats_version_check_enabled', $msg, 'true', true);
    ?>
		</td>
	</tr>
		<tr>
			<td class="config_cell" colspan="2">
				<h3><?php 
    fs_e('IP-to-country database');
    ?>
</h3>
				<ul>
				<li><?php 
    echo sprintf(fs_r('IP-to-country database version : %s'), '<b id="ip2c_database_version">' . fs_get_current_ip2c_db_version() . '</b>');
    ?>
</li>
				<li>
				<?php 
    $msg = fs_r('Automatically check if there is a new version of IP-to-country database');
    fs_create_checkbox('ip-to-country-db_version_check_enabled', $msg, 'true', true);
    ?>
				</li>
				<li><?php 
    fs_e('Update IP-to-country database now (only if needed)');
    ?>
					<button class="button" onclick="sendRequest('action=updateIP2CountryDB')">
						<?php 
    fs_e('Update');
    ?>
コード例 #3
0
ファイル: ajax-handler.php プロジェクト: alx/blogsfera
function fs_ajax_update_ip_to_country(&$response)
{
    if (!fs_ajax_assert_admin($response)) {
        return;
    }
    require_once dirname(__FILE__) . '/version-check.php';
    $file_type = '';
    $url = '';
    $version = '';
    $info = null;
    $error = null;
    $need_update = fs_is_ip2country_db_need_update($url, $file_type, $version, $info, $error);
    if ($need_update) {
        require_once dirname(__FILE__) . '/ip2country.php';
        $res = fs_update_ip2country_db($url, $file_type, $version);
        $ok = $res['status'] == 'ok';
        if ($ok) {
            $response['status'] = 'ok';
            $response['message'] = $res['message'];
            $response['fields']['ip2c_database_version'] = fs_get_current_ip2c_db_version();
            $response['fields']['new_ip2c_db_notification'] = '';
        } else {
            ajax_error($response, $res['message']);
        }
    } else {
        $response['status'] = 'ok';
        $response['message'] = fs_r("IP-to-country database is already up-to-date");
    }
    if (!empty($error)) {
        $response['status'] = 'error';
        $ip2c_dir = FS_ABS_PATH . '/lib/ip2c/';
        $response['message'] = fs_r('An error has occured while trying to update the IP-to-country database') . "<br/>";
        if (isset($info['ip-to-country-db']['zip_url'])) {
            $url = $info['ip-to-country-db']['zip_url'];
            $href = sprintf("<a href='{$url}'>%s</a>", fs_r('file'));
            $response['message'] .= sprintf(fs_r('You can update the database manually by downloading this %s and extracting it into %s'), $href, $ip2c_dir);
        } else {
            $url = FS_IP2COUNTRY_DB_VER_CHECK_URL;
            $href = sprintf("<a href='{$url}'>%s</a>", fs_r('this'));
            $response['message'] .= sprintf(fs_r('You can update the database manually by opening %s and downloading the <b>zip_url</b>, and extracting it into %s'), $href, $ip2c_dir);
        }
        $response['message'] .= '</b><br/><br/>' . fs_r('Error') . ': ' . $error;
    }
}