<?php

$inIndex = true;
require_once "../lib/setup/databaseInfo.php";
require_once "../lib/database.php";
date_default_timezone_set('UTC');
$objDatabase = new Database();
print "Database update will update the observerobjectlist: remove 'Public' in front of all the public lists and add a new column 'public'<br />\n";
$sql = "ALTER TABLE observerobjectlist ADD COLUMN public SMALLINT NOT NULL DEFAULT 0;";
$objDatabase->execSQL($sql);
// Iterate over all the list entries, set the new public column and remove 'Public' from the name.
$sql = "SELECT * from observerobjectlist;";
$listEntries = $objDatabase->selectRecordsetArray($sql);
$publicList = array();
foreach ($listEntries as $listEntry) {
    if (strpos($listEntry['listname'], "Public: ") !== false) {
        // The list is a public list.
        // We add the name of the list to the publicList array.
        if (!in_array($listEntry['listname'], $publicList)) {
            array_push($publicList, $listEntry['listname']);
        }
    }
}
foreach ($publicList as $listName) {
    // Set the public column to true.
    $sql = "UPDATE observerobjectlist SET public = \"1\" WHERE  listname = \"" . $listName . "\";";
    $objDatabase->execSQL($sql);
    // Change the name of the list.
    $sql = "UPDATE observerobjectlist SET listname = \"" . substr($listName, 8) . "\" WHERE listname = \"" . $listName . "\";";
    $objDatabase->execSQL($sql);
}
<?php

$inIndex = true;
require_once "../lib/setup/databaseInfo.php";
require_once "../lib/database.php";
$objDatabase = new Database();
print "Database update will add the highest altitudes possibilities to the report layouts of the users.\n\n";
$sql = "SELECT DISTINCT observerid, reportname, reportlayout FROM reportlayouts";
$results = $objDatabase->selectRecordsetArray($sql);
while (list($key, $value) = each($results)) {
    echo "Writing data for " . $value['observerid'] . ' ' . $value['reportname'] . ' ' . $value['reportlayout'] . "...\n\n";
    $sql = "INSERT INTO reportlayouts(observerid,reportname,reportlayout,fieldname,fieldline,fieldposition,fieldwidth,fieldheight,fieldstyle,fieldbefore,fieldafter,fieldlegend)\r\n                            VALUES('" . $value['observerid'] . "','" . $value['reportname'] . "','" . $value['reportlayout'] . "','objectmaxaltstarttext',3,20,50,'','','','','');";
    $objDatabase->execSQL($sql);
    $sql = "INSERT INTO reportlayouts(observerid,reportname,reportlayout,fieldname,fieldline,fieldposition,fieldwidth,fieldheight,fieldstyle,fieldbefore,fieldafter,fieldlegend)\r\n                            VALUES('" . $value['observerid'] . "','" . $value['reportname'] . "','" . $value['reportlayout'] . "','objectmaxaltmidtext',3,70,50,'','','','','');";
    $objDatabase->execSQL($sql);
    $sql = "INSERT INTO reportlayouts(observerid,reportname,reportlayout,fieldname,fieldline,fieldposition,fieldwidth,fieldheight,fieldstyle,fieldbefore,fieldafter,fieldlegend)\r\n                            VALUES('" . $value['observerid'] . "','" . $value['reportname'] . "','" . $value['reportlayout'] . "','objectmaxaltendtext',3,120,50,'','','','','');";
    $objDatabase->execSQL($sql);
    $sql = "INSERT INTO reportlayouts(observerid,reportname,reportlayout,fieldname,fieldline,fieldposition,fieldwidth,fieldheight,fieldstyle,fieldbefore,fieldafter,fieldlegend)\r\n                            VALUES('" . $value['observerid'] . "','" . $value['reportname'] . "','" . $value['reportlayout'] . "','objectmaxalt',3,170,50,'','','','','');";
    $objDatabase->execSQL($sql);
}
print "Database update successful.\n";
<?php

$inIndex = true;
require_once "../lib/setup/databaseInfo.php";
require_once "../lib/database.php";
require_once "../lib/atlasses.php";
require_once "../lib/objects.php";
require_once "../lib/setup/language/nl/lang_main.php";
$objDatabase = new Database();
$objAtlas = new Atlasses();
print "Database update will add the interstellarum atlas as one of the standard atlasses.\n";
$sql = "INSERT INTO atlasses VALUES ('Interstellarum');";
$run = mysql_query($sql) or die(mysql_error());
$sql = "ALTER TABLE objects ADD COLUMN Interstellarum VARCHAR(4) NOT NULL DEFAULT 0 ;";
$run = mysql_query($sql) or die(mysql_error());
$result = $objDatabase->selectRecordsetArray("SELECT name, ra, decl FROM objects");
while (list($key, $value) = each($result)) {
    $objDatabase->execSQL("UPDATE objects SET Interstellarum = \"" . $objAtlas->calculateAtlasPage('Interstellarum', $value['ra'], $value['decl']) . "\" WHERE name = \"" . $value['name'] . "\"");
}
print "Database update successful.\n";
?>

<?php

$inIndex = true;
require_once "../lib/setup/databaseInfo.php";
require_once "../lib/database.php";
require_once "../lib/locations.php";
date_default_timezone_set('UTC');
$objDatabase = new Database();
$objLocation = new Locations();
print "Database update will correct all the bad locations.<br />\n";
$locationsToCheck = $objDatabase->selectRecordsetArray("SELECT id FROM locations where checked=\"1\"", 'id');
print sizeof($locationsToCheck);
print "<br />";
if (sizeof($locationsToCheck) > 0) {
    foreach ($locationsToCheck as $location) {
        print $location['id'] . "<br />";
        // We adapt the timezone, elevation and country
        $latitude = $objLocation->getLocationPropertyFromId($location['id'], "latitude");
        $longitude = $objLocation->getLocationPropertyFromId($location['id'], "longitude");
        $url = "https://maps.googleapis.com/maps/api/timezone/json?location=" . $latitude . "," . $longitude . "&timestamp=0";
        $json = file_get_contents($url);
        $obj = json_decode($json);
        if ($obj->status == "OK") {
            $objLocation->setLocationProperty($location['id'], "timezone", $obj->timeZoneId);
            // Get the elevation
            $url = "https://maps.googleapis.com/maps/api/elevation/json?locations=" . $latitude . "," . $longitude;
            $json = file_get_contents($url);
            $obj = json_decode($json);
            if ($obj->status == "OK") {
                $results = $obj->results[0];
                $objLocation->setLocationProperty($location['id'], "elevation", (int) $results->elevation);