Exemplo n.º 1
0
 public function parseStations(array $stationsUrl)
 {
     $client = new Client();
     $response = $client->get($stationsUrl['url']);
     $body = $response->getBody()->getContents();
     preg_match_all('/data-link=\\".*\\"/', $body, $ulBlock);
     $rating = 1;
     foreach ($ulBlock[0] as $station) {
         preg_match('/http[^\\"]*/', $station, $source);
         preg_match('/name=".*[^\\"]*/', $station, $fullName);
         preg_match('/[A-ZА-Я][^\\-\\"|\\d|(]*/', $fullName[0], $name);
         preg_match('/\\d[^\\s|F]*/', $fullName[0], $frequency);
         preg_match('/\\(\\w*[^\\)]*/', $fullName[0], $city);
         $stationSource = $source[0];
         $stationName = trim($name[0]);
         $stationFrequency = !empty($frequency) ? $frequency[0] : null;
         $stationCity = !empty($city) ? substr($city[0], 1) : null;
         if (empty(Stations::where('name', '=', $stationName)->get()->toArray())) {
             $result = Stations::insert(['source' => $stationSource, 'name' => $stationName, 'frequency' => $stationFrequency, 'city' => $stationCity, 'rating' => $rating, 'country' => $stationsUrl['countryId']]);
             if (isset($result)) {
                 echo "Insert station " . $stationName . "\r\n";
                 $rating++;
             }
         }
     }
     echo "\r\n" . "Finish parsing!" . "\r\n\r\n";
 }
Exemplo n.º 2
0
 public function getStationCountKids()
 {
     $stations = Stations::find()->where(['id_city' => $this->id_city])->all();
     $result = 0;
     foreach ($stations as $stat) {
         $result += $stat->countKidsNow;
     }
     return $result;
 }
Exemplo n.º 3
0
 public function actionDelete($id)
 {
     $model = Stations::findOne($id);
     if (!empty($model)) {
         $model->record_status = STATUS_DELETED;
         if ($model->save()) {
             return $this->redirect(['station/index']);
         }
     }
 }
Exemplo n.º 4
0
 public function actionIndex()
 {
     $lst = Lines::find()->where([RECORD_STATUS => STATUS_NORMAL])->orderBy(NAME)->all();
     $lstStation = [];
     if (count($lst) > 0) {
         foreach ($lst as $item) {
             $stations = Stations::find()->where([LINE_ID => $item->id, RECORD_STATUS => STATUS_NORMAL])->all();
             if (count($stations) > 0) {
                 array_push($lstStation, ['line' => $item, 'stations' => $stations]);
             }
         }
     }
     return $this->render('index', ['listLine' => $lst, 'listStation' => $lstStation]);
 }
Exemplo n.º 5
0
 function actionSetComment()
 {
     $mentor = Mentor::findOne(['token' => $this->get["token"]]);
     $station = Stations::findOne(['hash' => $this->get["hash"]]);
     $kids = Kids::findOne(['qr' => $this->get["qr"]]);
     if (!$mentor) {
         $r = $this->setError(205);
     } elseif (!$station) {
         $r = $this->setError(101);
     } elseif (!$kids) {
         $r = $this->setError(301);
     } else {
         $r["status"] = "ok";
         $comment_kids = new CommentKids();
         $comment_kids->id_kids = $kids->id;
         $comment_kids->id_mentor = $mentor->id;
         $comment_kids->id_station = $station->id;
         $comment_kids->date = time();
         $comment_kids->text = $this->get["text"];
         $comment_kids->save();
     }
     //$comment_kids = new CommentKids;
     return json_encode($r);
 }
Exemplo n.º 6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getStations()
 {
     return $this->hasMany(Stations::className(), ['line_id' => 'id']);
 }
Exemplo n.º 7
0
 public function index()
 {
     $stations = Stations::where('available', '=', 1)->orderBy('id', 'asc')->get()->toArray();
     return view('stations.index', ['stations' => $stations]);
 }
Exemplo n.º 8
0
 public function getStationList()
 {
     $allStations = Stations::find()->asArray()->orderBy("p_nom DESC")->all();
     return $allStations;
     // arrayHelper::map($allStations, 'p_nom', 'kod_stan','name_stan','vr_ch','vr_n','rast_ch','ot','kput','podhod','kod_uchast','k_dor','kod_otd','pr_kn_uch','pr_dop_puti');
 }