Exemple #1
0
function gpsmap_check_upgrade()
{
    global $config;
    $files = array('gpsmap.php', 'gpstemplates.php', 'poller.php');
    if (isset($_SERVER['PHP_SELF']) && !in_array(basename($_SERVER['PHP_SELF']), $files)) {
        return;
    }
    $current = plugin_gpsmap_version();
    $current = $current['version'];
    $old = read_config_option('plugin_gpsmap_version', TRUE);
    if ($current != $old) {
        include_once $config['base_path'] . '/plugins/gpsmap/includes/database.php';
        gpsmap_upgrade_database();
    }
}
function gpsmap_upgrade_database()
{
    global $config, $database_default, $old;
    include_once $config['library_path'] . '/database.php';
    gpsmap_setup_database();
    if ($old < "1.6") {
        mysql_query("ALTER TABLE `host` CHANGE COLUMN latitude latitude DECIMAL(13,10) NOT NULL;");
        mysql_query("ALTER TABLE `host` ALTER COLUMN latitude SET DEFAULT `0.0000000000`;");
        mysql_query("ALTER TABLE `host` CHANGE COLUMN longitude longitude DECIMAL(13,10) NOT NULL;");
        mysql_query("ALTER TABLE `host` ALTER COLUMN longitude SET DEFAULT `0.0000000000`;");
    }
    include_once $config['base_path'] . '/plugins/gpsmap/setup.php';
    $v = plugin_gpsmap_version();
    $oldv = read_config_option('plugin_gpsmap_version');
}