public static function import_all_db($directory)
 {
     $error = '';
     $dh = opendir($directory);
     //foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $filename)
     while (false !== ($filename = readdir($dh))) {
         if (preg_match('/\\.sql$/', $filename)) {
             $error .= create_db::import_file($directory . $filename);
         }
     }
     return $error;
 }
 private static function update_from_8()
 {
     $Connection = new Connection();
     $error = '';
     // Update table aircraft
     $error .= create_db::import_file('../db/notam.sql');
     if ($error != '') {
         return $error;
     }
     $query = "DELETE FROM config WHERE name = 'last_update_db';\n                        INSERT INTO config (name,value) VALUES ('last_update_db',NOW());\n                        DELETE FROM config WHERE name = 'last_update_notam_db';\n                        INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());";
     try {
         $sth = Connection::$db->prepare($query);
         $sth->execute();
     } catch (PDOException $e) {
         return "error (insert last_update values) : " . $e->getMessage() . "\n";
     }
     $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
     try {
         $sth = Connection::$db->prepare($query);
         $sth->execute();
     } catch (PDOException $e) {
         return "error (update schema_version) : " . $e->getMessage() . "\n";
     }
     return $error;
 }
Example #3
0
    }
} else {
    if (isset($_SESSION['install']) && $_SESSION['install'] == 'database_import') {
        unset($_SESSION['install']);
        if (update_schema::check_version(false) == '0') {
            print '<div class="info column"><ul>';
            foreach ($_SESSION['done'] as $done) {
                print '<li>' . $done . '....<strong>SUCCESS</strong></li>';
            }
            print '<li>Create and import tables....<img src="../images/loading.gif" /></li></ul></div>';
            flush();
            @ob_flush();
            if ($globalDBdriver == 'mysql') {
                $error .= create_db::import_all_db('../db/');
            } elseif ($globalDBdriver == 'pgsql') {
                $error .= create_db::import_all_db('../db/pgsql/');
            }
            if ($error != '') {
                print '<div class="info column"><span class="error"><strong>Error</strong>' . $error . '</span></div>';
                require '../footer.php';
                exit;
            }
            $_SESSION['done'] = array_merge($_SESSION['done'], array('Create and import tables'));
            if ($globalSBS1) {
                $_SESSION['install'] = 'populate';
            } else {
                $_SESSION['install'] = 'sources';
            }
        } else {
            print '<div class="info column"><ul>';
            foreach ($_SESSION['done'] as $done) {
Example #4
0
#!/usr/bin/php
<?php 
require_once '../require/settings.php';
if ($globalInstalled) {
    echo '$globalInstalled must be set to FALSE in require/settings.php';
    exit;
}
require 'class.create_db.php';
echo "Create and import all tables...";
create_db::import_all_db('../db/');
echo "Done !\n";
require 'class.update_db.php';
echo "Populate all tables...\n";
update_db::update_all();
echo "\nInstall waypoints...(VERY slow!)";
update_db::update_waypoints();
echo "Done !\n";
echo "Install airspace...";
update_db::update_airspace();
echo "Done !\n";
echo 'All is now installed ! Thanks' . "\n";
if ($globalSBS1) {
    echo 'You need to run cron-sbs.php as a daemon. You can use init script in the install/init directory.' . "\n";
}
if ($globalACARS) {
    echo 'You need to run cron-acars.php as a daemon. You can use init script in the install/init directory.' . "\n";
}
Example #5
0
 $dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING);
 $dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING);
 $dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING);
 $dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING);
 $dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING);
 $dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING);
 $dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING);
 if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
     $error .= 'Mysql driver for PDO must be loaded';
 }
 if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
     $error .= 'PosgreSQL driver for PDO must be loaded';
 }
 if ($error == '' && isset($_POST['createdb']) && $dbname != '' && $dbuser != '' && $dbuserpass != '') {
     if ($dbroot != '' && $dbrootpass != '') {
         $result = create_db::create_database($dbroot, $dbrootpass, $dbuser, $dbuserpass, $dbname, $dbtype, $dbhost);
         if ($result != '') {
             $error .= $result;
         }
     }
     if ($error == '') {
         //$error .= create_db::import_all_db('../db/');
         $settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname));
     }
 } else {
     $settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname));
 }
 $sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING);
 $siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING);
 $timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING);
 $language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
 private static function update_from_9()
 {
     $Connection = new Connection();
     $query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;\n    \t\t\tALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
     try {
         $sth = $Connection->db->prepare($query);
         $sth->execute();
     } catch (PDOException $e) {
         return "error (add verticalrate column to spotter_live and spotter_output) : " . $e->getMessage() . "\n";
     }
     $error = '';
     // Update table atc
     $error .= create_db::import_file('../db/atc.sql');
     if ($error != '') {
         return $error;
     }
     $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
     try {
         $sth = $Connection->db->prepare($query);
         $sth->execute();
     } catch (PDOException $e) {
         return "error (update schema_version) : " . $e->getMessage() . "\n";
     }
     return $error;
 }
 public static function update_countries()
 {
     global $tmp_dir;
     include_once 'class.create_db.php';
     update_db::gunzip('../db/countries.sql.gz', $tmp_dir . 'countries.sql');
     create_db::import_file($tmp_dir . 'countries.sql');
 }
 private static function update_from_10()
 {
     $Connection = new Connection();
     $query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
     try {
         $sth = $Connection->db->prepare($query);
         $sth->execute();
     } catch (PDOException $e) {
         return "error (add new enum to ATC table) : " . $e->getMessage() . "\n";
     }
     $error = '';
     // Add tables
     $error .= create_db::import_file('../db/aircraft_owner.sql');
     if ($error != '') {
         return $error;
     }
     $error .= create_db::import_file('../db/metar.sql');
     if ($error != '') {
         return $error;
     }
     $error .= create_db::import_file('../db/taf.sql');
     if ($error != '') {
         return $error;
     }
     $error .= create_db::import_file('../db/airport.sql');
     if ($error != '') {
         return $error;
     }
     $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
     try {
         $sth = $Connection->db->prepare($query);
         $sth->execute();
     } catch (PDOException $e) {
         return "error (update schema_version) : " . $e->getMessage() . "\n";
     }
     return $error;
 }