コード例 #1
0
 public function UpdateOption($optionsKey, $optionsVal, $userId)
 {
     $c = new DataBaseConnector();
     $link = $c->Connect();
     $query = "UPDATE `user_settings` SET `value` = '" . $optionsVal . "' WHERE `name` = '" . $optionsKey . "' AND `user_id` = " . $userId . ";";
     $stmt = $link->prepare($query);
     $stmt->execute();
     $stmt->close();
     $c->Disconnect();
     unset($c);
     return;
 }
コード例 #2
0
 public function GetSearchAlgorithById($id)
 {
     $c = new DataBaseConnector();
     $link = $c->Connect();
     $result = $link->query("SELECT * FROM `search_flights_queries` WHERE `id`=" . $id . ";");
     $alg = null;
     if ($row = $result->fetch_array()) {
         foreach ($row as $key => $val) {
             $alg[$key] = $val;
         }
     }
     $c->Disconnect();
     unset($c);
     return $alg;
 }
コード例 #3
0
ファイル: Airport.php プロジェクト: AlexanderKosianchuk/luch
 public function getAirportByLatAndLong($extLat, $extLong)
 {
     $lat = $extLat;
     $long = $extLong;
     $c = new DataBaseConnector();
     $link = $c->Connect();
     $query = "SELECT `ICAO`,`name` FROM `airports` where\r\n            `runwayStartLat` > ({$lat} - 0.02) and\r\n            `runwayStartLat` < ({$lat} + 0.02) and\r\n            `runwayStartLong` > ({$long} - 0.02) and\r\n            `runwayStartLong` < ({$long} + 0.02) LIMIT 1;";
     $result = $link->query($query);
     $airport = array();
     if ($row = $result->fetch_array()) {
         $airport = array('ICAO' => $row['ICAO'], 'name' => $row['name']);
     }
     $result->free();
     $c->Disconnect();
     unset($c);
     return $airport;
 }
コード例 #4
0
ファイル: Folder.php プロジェクト: AlexanderKosianchuk/luch
 public function DeleteFolder($extFolderId, $extUserId)
 {
     if (is_int($extFolderId) && is_int($extUserId)) {
         $userId = $extUserId;
         $folderId = $extFolderId;
         $query = "DELETE FROM `folders` WHERE (`id` = '" . $folderId . "') " . "AND (`userId` = '" . $userId . "');";
         $c = new DataBaseConnector();
         $link = $c->Connect();
         $stmt = $link->prepare($query);
         $result['status'] = $stmt->execute();
         $result['query'] = $query;
         $stmt->close();
         $c->Disconnect();
         unset($c);
         return $result;
     } else {
         error_log("Incorrect input data. " . "DeleteFolder id - " . json_encode($extFolderId) . ". " . "UserId id - " . json_encode($extUserId) . ". " . "FolderController");
         return false;
     }
 }
コード例 #5
0
ファイル: Bru.php プロジェクト: AlexanderKosianchuk/luch
 public function DeleteBrutypesByAuthor($extAuthor)
 {
     $author = $extAuthor;
     $c = new DataBaseConnector();
     $link = $c->Connect();
     $query = "DELETE FROM `brutypes` WHERE `author` = '" . $author . "';";
     $stmt = $link->prepare($query);
     $stmt->execute();
     $stmt->close();
     $c->Disconnect();
     unset($c);
 }
コード例 #6
0
 public function GetCoordinates($flightId)
 {
     if (!is_int(intval($flightId))) {
         throw new Exception("Incorrect flightId passed into GetCoordinates FlightsController." . $flightId, 1);
     }
     $Fl = new Flight();
     $flight = $Fl->GetFlightInfo($flightId);
     unset($Fl);
     $bruType = $flight['bruType'];
     $apTableName = $flight['apTableName'];
     $bpTableName = $flight['bpTableName'];
     $Bru = new Bru();
     $bruInfo = $Bru->GetBruInfo($bruType);
     unset($Bru);
     $kmlScript = $bruInfo['kml_export_script'];
     $kmlScript = str_replace("[ap]", $apTableName, $kmlScript);
     $kmlScript = str_replace("[bp]", $bpTableName, $kmlScript);
     $c = new DataBaseConnector();
     $link = $c->Connect();
     $info = [];
     $averageLat = 0;
     $averageLong = 0;
     if (!$link->multi_query($kmlScript)) {
         //err log
         error_log("Impossible to execute multiquery: (" . $kmlScript . ") " . $link->error);
     }
     do {
         if ($res = $link->store_result()) {
             while ($row = $res->fetch_array()) {
                 $lat = $row['LAT'];
                 $long = $row['LONG'];
                 $h = $row['H'];
                 $averageLat += $lat;
                 $averageLong += $long;
                 $averageLat /= 2;
                 $averageLong /= 2;
                 if ($h < 0) {
                     $h = 10.0;
                 }
                 $h = round($h, 2);
                 $info[] = [$long, $lat, $h];
             }
             $res->free();
         }
     } while ($link->more_results() && $link->next_result());
     $c->Disconnect();
     unset($c);
     return $info;
 }
コード例 #7
0
ファイル: Channel.php プロジェクト: AlexanderKosianchuk/luch
 public function GetParamMinMax($extApTableName, $extParamCode)
 {
     $apTableName = $extApTableName;
     $paramCode = $extParamCode;
     $minMax = array();
     $c = new DataBaseConnector();
     $link = $c->Connect();
     $query = "SELECT MIN(`" . $paramCode . "`), MAX(`" . $paramCode . "`) FROM `" . $apTableName . "` WHERE 1;";
     $result = $link->query($query);
     $row = $result->fetch_array();
     $minMax['min'] = $row["MIN(`" . $paramCode . "`)"];
     $minMax['max'] = $row["MAX(`" . $paramCode . "`)"];
     $result->free();
     $c->Disconnect();
     return $minMax;
 }
コード例 #8
0
 public function SearchByAlgorithm($algId, $flightsArr)
 {
     $foundFlights = [];
     $SF = new SearchFlights();
     $searchAlg = $SF->GetSearchAlgorithById($algId);
     unset($SF);
     $F = new Flight();
     if ($searchAlg) {
         foreach ($flightsArr as $flightid) {
             $query = $searchAlg['alg'];
             $flightInfo = $F->GetFlightInfo($flightid);
             $apTableName = $flightInfo['apTableName'];
             $bpTableName = $flightInfo['bpTableName'];
             $query = str_replace("[ap]", $apTableName, $query);
             $query = str_replace("[bp]", $bpTableName, $query);
             foreach ($flightInfo as $flightInfoKey => $flightInfoVal) {
                 $query = str_replace("[" . $flightInfoKey . "]", $flightInfoVal, $query);
             }
             $c = new DataBaseConnector();
             $link = $c->Connect();
             if (!$link->multi_query($query)) {
                 //err log
                 error_log("Impossible to execute multiquery: (" . $query . ") " . $link->error);
             }
             do {
                 if ($res = $link->store_result()) {
                     $resultArr = array();
                     if ($row = $res->fetch_array()) {
                         $foundFlights[] = $flightInfo;
                     }
                     $res->free();
                 }
             } while ($link->more_results() && $link->next_result());
             $c->Disconnect();
             unset($c);
         }
     }
     unset($F);
     return $foundFlights;
 }
コード例 #9
0
 public function createTemplate($templateName, $templateItems, $tableName, $username)
 {
     $this->DeleteTemplate($tableName, $templateName, $username);
     $c = new DataBaseConnector();
     $link = $c->Connect();
     foreach ($templateItems as $item) {
         $query = "INSERT INTO `" . $tableName . "` " . "(`name`, `paramCode`, `minYaxis`, `maxYaxis`, `user`) " . "VALUES ('" . $templateName . "','" . $item['paramCode'] . "', '" . $item['minYaxis'] . "', '" . $item['maxYaxis'] . "', '" . $username . "');";
         $stmt = $link->prepare($query);
         $stmt->execute();
     }
     $c->Disconnect();
     unset($c);
 }
コード例 #10
0
ファイル: Frame.php プロジェクト: AlexanderKosianchuk/luch
 public function GetNormalizedFrame($extTableName, $extId)
 {
     $tableName = $extTableName;
     $id = $extId;
     $c = new DataBaseConnector();
     $link = $c->Connect();
     $query = "SELECT * FROM " . $tableName . " WHERE id = " . $id . ";";
     $result = $link->query($query);
     $normFrame = array();
     while ($row = $result->fetch_array()) {
         for ($i = 0; $i < count($row) / 2; $i++) {
             array_push($normFrame, $row[$i]);
         }
     }
     $c->Disconnect();
     unset($c);
     return $normFrame;
 }
コード例 #11
0
 public function UpdateUserComment($excTableName, $excId, $userComment)
 {
     $c = new DataBaseConnector();
     $link = $c->Connect();
     $query = "UPDATE `" . $excTableName . "` SET `userComment` = '" . $userComment . "' WHERE id='" . $excId . "';";
     $stmt = $link->prepare($query);
     $stmt->execute();
     $stmt->close();
     $c->Disconnect();
     unset($c);
 }
コード例 #12
0
ファイル: Flight.php プロジェクト: AlexanderKosianchuk/luch
 public function GetMaxFlightId()
 {
     $query = "SELECT MAX(`id`) FROM `flights` WHERE 1;";
     $c = new DataBaseConnector();
     $link = $c->Connect();
     $result = $link->query($query);
     $maxId = 1;
     if ($row = $result->fetch_array()) {
         $maxId = $row['MAX(`id`)'];
     }
     $result->free();
     $c->Disconnect();
     unset($c);
     return $maxId;
 }
コード例 #13
0
ファイル: User.php プロジェクト: AlexanderKosianchuk/luch
 public function RegisterUserAction($extAction, $extStatus, $extUserId, $extSenderId, $extSenderName, $extTargetId, $extTargetName)
 {
     $action = $extAction;
     $status = $extStatus;
     $userId = $extUserId;
     $senderId = $extSenderId;
     $senderName = $extSenderName;
     $targetId = $extTargetId;
     $targetName = $extTargetName;
     $c = new DataBaseConnector();
     $link = $c->Connect();
     $query = "INSERT INTO `user_activity` (`action`,`status`, `userId`, `senderId`, `senderName`, `targetId`, `targetName`)\r\n                VALUES ('" . $action . "', '" . $status . "', '" . $userId . "', " . "'" . $senderId . "','" . $senderName . "','" . $targetId . "', '" . $targetName . "');";
     $stmt = $link->prepare($query);
     $executionStatus = $stmt->execute();
     $stmt->close();
     $c->Disconnect();
     unset($c);
     return $executionStatus;
 }