# remove last element if not repairing/overinstalling same version
if (strnatcmp($current_ver, $new_ver) != 0) {
    array_pop($default_data_files);
}
$update = new Update();
$update->scanUpdates();
if ($cli) {
    if ($update->lastUpdate != $update->updateTo) {
        echo 'This will apply ' . (sizeof($default_data_files) ? ' version updates "' . implode('", "', $default_data_files) . '" and ' : NULL) . 'updates ' . ($update->lastUpdate + 1) . ' through ' . $update->updateTo . ' to Saurus CMS, import dictonary files and syncronise extensions.' . "\n";
        new Log(array('action' => 'update', 'type' => 'NOTICE', 'message' => 'Update started'));
        if (sizeof($default_data_files)) {
            echo 'Version updates: ' . implode(', ', $default_data_files);
            $update->runVersionUpdates($default_data_files);
            echo '.' . "\n";
        }
        $update->runUpdates();
        echo 'Synchronising extensions';
        $update->synchroniseExtensions();
        echo '.' . "\n";
        echo 'Importing glossaries';
        $update->importGlossaries();
        echo '.' . "\n";
        echo 'Clearing caches';
        $update->clearCaches();
        echo '.' . "\n";
        new Log(array('action' => 'update', 'type' => 'NOTICE', 'message' => 'Update finished'));
        echo 'Finished.' . "\n";
    } else {
        echo 'There are no new updates, the last update applied was "Update ' . $update->lastUpdate . '"' . "\n";
    }
} else {