当前位置: 首页>>代码示例>>PHP>>正文


PHP OperationsData::addAirport方法代码示例

本文整理汇总了PHP中OperationsData::addAirport方法的典型用法代码示例。如果您正苦于以下问题:PHP OperationsData::addAirport方法的具体用法?PHP OperationsData::addAirport怎么用?PHP OperationsData::addAirport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OperationsData的用法示例。


在下文中一共展示了OperationsData::addAirport方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: RetrieveAirportInfo

 /**
  * Retrieve Airport Information
  */
 public static function RetrieveAirportInfo($icao)
 {
     $icao = strtoupper($icao);
     if (Config::Get('AIRPORT_LOOKUP_SERVER') == 'geonames') {
         $url = Config::Get('GEONAME_API_SERVER') . '/searchJSON?maxRows=1&style=medium&featureCode=AIRP&type=json&q=' . $icao;
     } elseif (Config::Get('AIRPORT_LOOKUP_SERVER') == 'phpvms') {
         $url = Config::Get('PHPVMS_API_SERVER') . '/index.php/airport/get/' . $icao;
     }
     # Updated to use CodonWebServer instead of simplexml_load_url() straight
     #	Could cause errors
     $file = new CodonWebService();
     $contents = @$file->get($url);
     $reader = json_decode($contents);
     if ($reader->totalResultsCount == 0 || !$reader) {
         return false;
     } else {
         if (isset($reader->geonames)) {
             $apt = $reader->geonames[0];
         } elseif (isset($reader->airports)) {
             $apt = $reader->airports[0];
         }
         if (!isset($apt->jeta)) {
             $apt->jeta = '';
         }
         // Add the AP
         $data = array('icao' => $icao, 'name' => $apt->name, 'country' => $apt->countryName, 'lat' => $apt->lat, 'lng' => $apt->lng, 'hub' => false, 'fuelprice' => $apt->jeta);
         OperationsData::addAirport($data);
     }
     return self::GetAirportInfo($icao);
 }
开发者ID:phpmods,项目名称:phpvms_5.5.x,代码行数:33,代码来源:OperationsData.class.php

示例2: importairports

    public function importairports()
    {
        if (!file_exists($_FILES['uploadedfile']['tmp_name'])) {
            $this->render('airport_import_form.php');
            return;
        }
        echo '<h3>Processing Import</h3>';
        # Get the column headers
        $allaircraft = OperationsData::getAllAirports(false);
        $headers = array();
        $dbcolumns = DB::get_cols();
        foreach ($dbcolumns as $col) {
            $headers[] = $col->name;
        }
        $temp_name = $_FILES['uploadedfile']['tmp_name'];
        $new_name = CACHE_PATH . '/' . $_FILES['uploadedfile']['name'];
        if (!move_uploaded_file($temp_name, $new_name)) {
            $this->render('core_error.php');
            $this->set('message', 'Shit the bed?');
            return false;
        }
        $fp = fopen($new_name, 'r');
        if (isset($_POST['header'])) {
            $skip = true;
        }
        $added = 0;
        $updated = 0;
        $total = 0;
        echo '<div style="overflow: auto; height: 400px; 
					border: 1px solid #666; margin-bottom: 20px; 
					padding: 5px; padding-top: 0px; padding-bottom: 20px;">';
        if (isset($_POST['erase_airports'])) {
            OperationsData::deleteAllAirports();
            echo "Deleting All Airports<br />";
        }
        while ($fields = fgetcsv($fp, 1000, ',')) {
            // Skip the first line
            if ($skip == true) {
                $skip = false;
                continue;
            }
            //Check for empty lines, continue
            if (empty($fields)) {
                continue;
            }
            //Create Varibles...
            $icao = $fields[0];
            $name = $fields[1];
            $country = $fields[2];
            $lat = $fields[3];
            $lng = $fields[4];
            $hub = $fields[5];
            $fuelprice = $fields[6];
            $chartlink = $fields[7];
            //Since we need the values filled in, if not, then continue
            if (empty($icao) || empty($lat) || empty($lng)) {
                continue;
            }
            # Enabled or not
            if ($hub == '1') {
                $hub = true;
            } else {
                $hub = false;
            }
            //Build Array, seem can't use the array merge for some reason...
            $data = array('icao' => $fields[0], 'name' => $fields[1], 'country' => $fields[2], 'lat' => $fields[3], 'lng' => $fields[4], 'hub' => $hub, 'fuelprice' => $fields[6], 'chartlink' => $fields[7]);
            # Does this airport exist?
            $aiport_info = OperationsData::getAirportInfo($icao);
            if ($aiport_info) {
                echo "Editing {$icao} - {$name}<br>";
                OperationsData::editAirport($data);
                $updated++;
            } else {
                echo "Adding {$icao} - {$name}<br>";
                OperationsData::addAirport($data);
                $added++;
            }
            $total++;
        }
        //You should always close a file before deleting otherwise it will spit the unlink error due to permissions
        fclose($fp);
        unlink($new_name);
        echo "The import process is complete, added {$added} airports, updated {$updated}, for a total of {$total}<br />";
    }
开发者ID:phpmods,项目名称:phpvms_5.5.x,代码行数:84,代码来源:Import.php


注:本文中的OperationsData::addAirport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。