<commit_before><?php

    /////////////////////////////////////////////////////////////////////////////////////
    //                            ADS-B RECEIVER PORTAL                                //
    // =============================================================================== //
    // Copyright and Licensing Information:                                            //
    //                                                                                 //
    // The MIT License (MIT)                                                           //
    //                                                                                 //
    // Copyright (c) 2015-2016 <NAME>                                     //
    //                                                                                 //
    // Permission is hereby granted, free of charge, to any person obtaining a copy    //
    // of this software and associated documentation files (the "Software"), to deal   //
    // in the Software without restriction, including without limitation the rights    //
    // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell       //
    // copies of the Software, and to permit persons to whom the Software is           //
    // furnished to do so, subject to the following conditions:                        //
    //                                                                                 //
    // The above copyright notice and this permission notice shall be included in all  //
    // copies or substantial portions of the Software.                                 //
    //                                                                                 //
    // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR      //
    // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,        //
    // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE     //
    // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER          //
    // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,   //
    // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE   //
    // SOFTWARE.                                                                       //
    /////////////////////////////////////////////////////////////////////////////////////

    require_once('../classes/common.class.php');
    require_once('../classes/settings.class.php');

    $common = new common();
    $settings = new settings();

    // The most current stable release.
    $thisVersion = "2.0.1";

    // Begin the upgrade process if this release is newer than what is installed.
    if ($common->getSetting("version") == $thisVersion) {
        header ("Location: /");
    }

    $error = FALSE;
    #errorMessage = "No error message returned.";

    try {
        // Change tables containing datetime data to datetime.
        if ($settings::db_driver != "xml") {

            // ALter MySQL tables.
            if ($settings::db_driver != "mysql") {
                $dbh = $common->pdoOpen();

                $sql = "ALTER TABLE ".$settings::db_prefix."aircraft MODIFY firstSeen DATETIME NOT NULL";
                $sth = $dbh->prepare($sql);
                $sth->execute();
                $sth = NULL;

                $sql = "ALTER TABLE adsb_aircraft MODIFY lastSeen DATETIME NOT NULL";
                $sth = $dbh->prepare($sql);
                $sth->execute();
                $sth = NULL;

                $sql = "ALTER TABLE adsb_blogPosts MODIFY date DATETIME NOT NULL";
                $sth = $dbh->prepare($sql);
                $sth->execute();
                $sth = NULL;

                $sql = "ALTER TABLE adsb_flights MODIFY firstSeen DATETIME NOT NULL";
                $sth = $dbh->prepare($sql);
                $sth->execute();
                $sth = NULL;

                $sql = "ALTER TABLE adsb_flights MODIFY firstSeen DATETIME NOT NULL";
                $sth = $dbh->prepare($sql);
                $sth->execute();
                $sth = NULL;

                $sql = "ALTER TABLE adsb_positions MODIFY time DATETIME NOT NULL";
                $sth = $dbh->prepare($sql);
                $sth->execute();
                $sth = NULL;

                $dbh = NULL;
            }

            // Convert times to GMT.

            $dbh = $common->pdoOpen();
            $sql = "SELECT id, firstSeen, lastSeen FROM ".$settings::db_prefix."aircraft";
            $sth = $dbh->prepare($sql);
            $sth->execute();
            $aircraft = $sth->fetchAll();
            $sth = NULL;
            $dbh = NULL;

            foreach ($aircraft as $airframe) {
                $dbh = $common->pdoOpen();
                $sql = "UPDATE ".$settings::db_prefix."aircraft SET firstSeen = :firstSeen, lastSeen = :lastSeen WHERE id = :id";
                $sth = $dbh->prepare($sql);
                $sth->bindParam(':firstSeen',  gmdate("Y-m-d H:i:s", $airframe["firstSeen"]), PDO::PARAM_STR);
                $sth->bindParam(':lastSeen', gmdate("Y-m-d H:i:s", $airframe["lastSeen"]), PDO::PARAM_STR);
                $sth->bindParam(':id', $airframe["id"], PDO::PARAM_INT);
                $sth->execute();
                $sth = NULL;
                $dbh = NULL;
            }

            $dbh = $common->pdoOpen();
            $sql = "SELECT id, date FROM ".$settings::db_prefix."blogPosts";
            $sth = $dbh->prepare($sql);
            $sth->execute();
            $blogPosts = $sth->fetchAll();
            $sth = NULL;
            $dbh = NULL;

            foreach ($blogPosts as $post) {
                $dbh = $common->pdoOpen();
                $sql = "UPDATE ".$settings::db_prefix."blogPosts SET date = :date WHERE id = :id";
                $sth = $dbh->prepare($sql);
                $sth->bindParam(':date', gmdate("Y-m-d H:i:s", $post["date"]), PDO::PARAM_STR);
                $sth->bindParam(':id', $post["id"], PDO::PARAM_INT);
                $sth->execute();
                $sth = NULL;
                $dbh = NULL;
            }

            $dbh = $common->pdoOpen();
            $sql = "SELECT id, firstSeen, lastSeen FROM ".$settings::db_prefix."flights";
            $sth = $dbh->prepare($sql);
            $sth->execute();
            $flights = $sth->fetchAll();
            $sth = NULL;
            $dbh = NULL;

            foreach ($flights as $flight) {
                $dbh = $common->pdoOpen();
                $sql = "UPDATE ".$settings::db_prefix."flights SET firstSeen = :firstSeen, lastSeen = lastSeen WHERE id = :id";
                $sth = $dbh->prepare($sql);
                $sth->bindParam(':firstSeen', gmdate("Y-m-d H:i:s", $flight["firstSeen"]), PDO::PARAM_STR);
                $sth->bindParam(':lastSeen', gmdate("Y-m-d H:i:s", $flight["lastSeen"]), PDO::PARAM_STR);
                $sth->bindParam(':id', $flight["id"], PDO::PARAM_INT);
                $sth->execute();
                $sth = NULL;
                $dbh = NULL;
            }

            $dbh = $common->pdoOpen();
            $sql = "SELECT id, time FROM ".$settings::db_prefix."positions";
            $sth = $dbh->prepare($sql);
            $sth->execute();
            $positionss = $sth->fetchAll();
            $sth = NULL;
            $dbh = NULL;

            foreach ($positions as $position) {
                $dbh = $common->pdoOpen();
                $sql = "UPDATE ".$settings::db_prefix."positions SET time = :time WHERE id = :id";
                $sth = $dbh->prepare($sql);
                $sth->bindParam(':time', gmdate("Y-m-d H:i:s", $position["time"]), PDO::PARAM_STR);
                $sth->bindParam(':id', $position["id"], PDO::PARAM_INT);
                $sth->execute();
                $sth = NULL;
                $dbh = NULL;
            }
        }

        // Add timezone setting.
        $common->addSetting("timeZone", date_default_timezone_get());<commit_msg>Noted and commented out time convertions.<commit_after><?php

    /////////////////////////////////////////////////////////////////////////////////////
    //                            ADS-B RECEIVER PORTAL                                //
    // =============================================================================== //
    // Copyright and Licensing Information:                                            //
    //                                                                                 //
    // The MIT License (MIT)                                                           //
    //                                                                                 //
    // Copyright (c) 2015-2016 <NAME>                                     //
    //                                                                                 //
    // Permission is hereby granted, free of charge, to any person obtaining a copy    //
    // of this software and associated documentation files (the "Software"), to deal   //
    // in the Software without restriction, including without limitation the rights    //
    // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell       //
    // copies of the Software, and to permit persons to whom the Software is           //
    // furnished to do so, subject to the following conditions:                        //
    //                                                                                 //
    // The above copyright notice and this permission notice shall be included in all  //
    // copies or substantial portions of the Software.                                 //
    //                                                                                 //
    // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR      //
    // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,        //
    // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE     //
    // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER          //
    // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,   //
    // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE   //
    // SOFTWARE.                                                                       //
    /////////////////////////////////////////////////////////////////////////////////////

    require_once('../classes/common.class.php');
    require_once('../classes/settings.class.php');

    $common = new common();
    $settings = new settings();

    // The most current stable release.
    $thisVersion = "2.0.1";

    // Begin the upgrade process if this release is newer than what is installed.
    if ($common->getSetting("version") == $thisVersion) {
        header ("Location: /");
    }

    $error = FALSE;
    #errorMessage = "No error message returned.";

    try {
        // Change tables containing datetime data to datetime.
        if ($settings::db_driver != "xml") {

            // ALter MySQL tables.
            if ($settings::db_driver != "mysql") {
                $dbh = $common->pdoOpen();

                $sql = "ALTER TABLE ".$settings::db_prefix."aircraft MODIFY firstSeen DATETIME NOT NULL";
                $sth = $dbh->prepare($sql);
                $sth->execute();
                $sth = NULL;

                $sql = "ALTER TABLE adsb_aircraft MODIFY lastSeen DATETIME NOT NULL";
                $sth = $dbh->prepare($sql);
                $sth->execute();
                $sth = NULL;

                $sql = "ALTER TABLE adsb_blogPosts MODIFY date DATETIME NOT NULL";
                $sth = $dbh->prepare($sql);
                $sth->execute();
                $sth = NULL;

                $sql = "ALTER TABLE adsb_flights MODIFY firstSeen DATETIME NOT NULL";
                $sth = $dbh->prepare($sql);
                $sth->execute();
                $sth = NULL;

                $sql = "ALTER TABLE adsb_flights MODIFY firstSeen DATETIME NOT NULL";
                $sth = $dbh->prepare($sql);
                $sth->execute();
                $sth = NULL;

                $sql = "ALTER TABLE adsb_positions MODIFY time DATETIME NOT NULL";
                $sth = $dbh->prepare($sql);
                $sth->execute();
                $sth = NULL;

                $dbh = NULL;
            }

            // Convert times to GMT.
            
            // You may wish to uncomment this block of code in order to convert existing times
            // stored in the database to UTC/GMT time. Before doing so it is recommended that
            // you set the setting max_execution_time setting to a large amount of time in your
            // php.ini file. Depending on the amount of flight data logged this may take quite
            // some time for this upgrade script to complete so be patient and let it run it's
            // course. Afterwards set the max_execution_time back to it previous setting.

            /*
            $dbh = $common->pdoOpen();
            $sql = "SELECT id, firstSeen, lastSeen FROM ".$settings::db_prefix."aircraft";
            $sth = $dbh->prepare($sql);
            $sth->execute();
            $aircraft = $sth->fetchAll();
            $sth = NULL;
            $dbh = NULL;

            foreach ($aircraft as $airframe) {
                $dbh = $common->pdoOpen();
                $sql = "UPDATE ".$settings::db_prefix."aircraft SET firstSeen = :firstSeen, lastSeen = :lastSeen WHERE id = :id";
                $sth = $dbh->prepare($sql);
                $sth->bindParam(':firstSeen',  gmdate("Y-m-d H:i:s", $airframe["firstSeen"]), PDO::PARAM_STR);
                $sth->bindParam(':lastSeen', gmdate("Y-m-d H:i:s", $airframe["lastSeen"]), PDO::PARAM_STR);
                $sth->bindParam(':id', $airframe["id"], PDO::PARAM_INT);
                $sth->execute();
                $sth = NULL;
                $dbh = NULL;
            }

            $dbh = $common->pdoOpen();
            $sql = "SELECT id, date FROM ".$settings::db_prefix."blogPosts";
            $sth = $dbh->prepare($sql);
            $sth->execute();
            $blogPosts = $sth->fetchAll();
            $sth = NULL;
            $dbh = NULL;

            foreach ($blogPosts as $post) {
                $dbh = $common->pdoOpen();
                $sql = "UPDATE ".$settings::db_prefix."blogPosts SET date = :date WHERE id = :id";
                $sth = $dbh->prepare($sql);
                $sth->bindParam(':date', gmdate("Y-m-d H:i:s", $post["date"]), PDO::PARAM_STR);
                $sth->bindParam(':id', $post["id"], PDO::PARAM_INT);
                $sth->execute();
                $sth = NULL;
                $dbh = NULL;
            }

            $dbh = $common->pdoOpen();
            $sql = "SELECT id, firstSeen, lastSeen FROM ".$settings::db_prefix."flights";
            $sth = $dbh->prepare($sql);
            $sth->execute();
            $flights = $sth->fetchAll();
            $sth = NULL;
            $dbh = NULL;

            foreach ($flights as $flight) {
                $dbh = $common->pdoOpen();
                $sql = "UPDATE ".$settings::db_prefix."flights SET firstSeen = :firstSeen, lastSeen = lastSeen WHERE id = :id";
                $sth = $dbh->prepare($sql);
                $sth->bindParam(':firstSeen', gmdate("Y-m-d H:i:s", $flight["firstSeen"]), PDO::PARAM_STR);
                $sth->bindParam(':lastSeen', gmdate("Y-m-d H:i:s", $flight["lastSeen"]), PDO::PARAM_STR);
                $sth->bindParam(':id', $flight["id"], PDO::PARAM_INT);
                $sth->execute();
                $sth = NULL;
                $dbh = NULL;
            }

            $dbh = $common->pdoOpen();
            $sql = "SELECT id, time FROM ".$settings::db_prefix."positions";
            $sth = $dbh->prepare($sql);
            $sth->execute();
            $positionss = $sth->fetchAll();
            $sth = NULL;
            $dbh = NULL;

            foreach ($positions as $position) {
                $dbh = $common->pdoOpen();
                $sql = "UPDATE ".$settings::db_prefix."positions SET time = :time WHERE id = :id";
                $sth = $dbh->prepare($sql);
                $sth->bindParam(':time', gmdate("Y-m-d H:i:s", $position["time"]), PDO::PARAM_STR);
                $sth->bindParam(':id', $position["id"], PDO::PARAM_INT);
                $sth->execute();
                $sth = NULL;
                $dbh = NULL;
            }
            */
        }

        // Add timezone setting.
        $common->addSetting("timeZone", date_default_timezone_get());
{'fraction_non_alphanumeric': 0.15960638425537022, 'fraction_numerical': 0.0013200528021120844, 'mean_word_length': 1.2878517501715854, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 111, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 46, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3815393', 'n_tokens_mistral': 4524, 'n_tokens_neox': 4239, 'n_words': 1159}