Exemple #1
0
 /**
  * Возвращает массив основных событий матча
  * @param $match
  * @return array
  */
 private static function headOfMatchInArray($match)
 {
     $dom = new \DomDocument();
     libxml_use_internal_errors(true);
     $dom->loadHTML($match);
     $dom->preserveWhiteSpace = true;
     $xpath = new \DOMXPath($dom);
     $arr = [];
     $date = '';
     $st = '';
     $gameOff = 0;
     $host = 0;
     $node = $xpath->query(".//*/td[@class='tname-home logo-enable']/span[@class='tname']/a")->item(0);
     //var_dump($node); exit;
     try {
         $arr['host'] = Khlteams::find()->where("name like('%" . self::clearTwoWordsString($node->textContent) . "%')")->one()->id;
         $arr['errors'][] = '';
         //echo "Хозяин ".$node->textContent;
     } catch (ErrorException $e) {
         $arr['host'] = 29;
         //null
         $arr['errors'][] = 'Хозяин не схвачен: ' . $node->textContent;
         //var_dump(self::clearString($node->textContent)); exit;
     }
     $node = $xpath->query(".//*/td[@class='tname-away logo-enable']")->item(0);
     try {
         $arr['guest'] = Khlteams::find()->where("name like('%" . self::clearString($node->firstChild->textContent) . "%')")->one()->id;
         //echo "Гость ". $node->firstChild->textContent;
     } catch (ErrorException $e) {
         $arr['guest'] = 29;
         //null
         $arr['errors'][] = 'Гость не схвачен: ' . $node->firstChild->textContent;
         var_dump($node->textContent);
         exit;
     }
     $node = $xpath->query(".//*/td[@class='current-result']/span[@class='scoreboard']")->item(0);
     $arr['host_g'] = $node->textContent;
     $arr['guest_g'] = $node->nextSibling->nextSibling->textContent;
     $node = $xpath->query(".//*/td[@id='utime']")->item(0);
     $date = explode(' ', $node->textContent);
     $arr['date'] = $date[0];
     $arr['time_beg'] = $date[1];
     $node = $xpath->query(".//*/td[@class='mstat']")->item(0);
     $arr['status'] = $node->textContent;
     $node = $xpath->query(".//*/tr[@class='stage-header']")->item(0);
     $arr['judges'] = substr($node->nextSibling->firstChild->textContent, strpos($node->nextSibling->firstChild->textContent, ':') + 2);
     $st = explode(',', $node->nextSibling->nextSibling->firstChild->textContent);
     $arr['audience'] = (int) self::sOff(substr($st[0], strpos($st[0], ':') + 2));
     if (isset($st[1])) {
         $arr['stadium'] = self::sOff(substr($st[1], strpos($st[1], ':') + 2));
     } else {
         $arr['stadium'] = '?';
     }
     $node = $xpath->query(".//*/table[@id='parts']")->item(2)->firstChild;
     $first = $node->firstChild;
     $i = 0;
     while ($first = $first->nextSibling) {
         if ($first->childNodes) {
             foreach ($first->childNodes as $nodde) {
                 if ($nodde->textContent == "Замены") {
                     $gameOff = 1;
                 }
                 if ($nodde->textContent == "Тренеры") {
                     $gameOff = 0;
                 }
                 if ($nodde->attributes) {
                     foreach ($nodde->attributes as $attr) {
                         if ($attr->value == "summary-vertical fl") {
                             $host = 1;
                         }
                         if ($attr->value == "summary-vertical fr") {
                             $host = 0;
                         }
                     }
                 }
                 //var_dump($nodde->textContent); exit;
                 if ($nodde->childNodes) {
                     foreach ($nodde->childNodes as $child) {
                         if ($child->attributes) {
                             foreach ($child->attributes as $attribute) {
                                 if ($attribute->value == "name") {
                                     // $arr['sost'][$gameOff][] = $child->textContent;
                                     if (preg_match("/(В)/", $child->textContent)) {
                                         $arr['gk'][$gameOff][$host][] = self::cutDotEnd($child->textContent);
                                     }
                                     try {
                                         $arr['sost'][$gameOff][] = Khlplayers::find()->where("name like('%" . self::cutDotEnd($child->textContent) . "%')")->one()->id;
                                     } catch (ErrorException $e) {
                                         //$arr['sost'][$gameOff][] = 947;
                                         //$arr['errors'][] = $child->textContent.' не попал в состав по ошибке';
                                         $new_player = new Khlplayers();
                                         $new_player->name = self::clearTwoWordsString($child->textContent);
                                         if ($host) {
                                             $new_player->team_id = $arr['host'];
                                         } else {
                                             $new_player->team_id = $arr['guest'];
                                         }
                                         $new_player->country_id = 162;
                                         $new_player->save(false);
                                         $arr['sost'][$gameOff][] = $new_player->id;
                                     }
                                 }
                                 if ($attribute->nodeName == "title" && isset($child->firstChild->attributes)) {
                                     foreach ($child->firstChild->attributes as $chAttr) {
                                         if ($chAttr->value == "icon substitution-out") {
                                             $arr['gk_substitution'][$host][] = $attribute->value;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $stats = $xpath->query(".//*/div[@id='tab-statistics-0-statistic']")->item(0)->firstChild;
     //var_dump($stats);
     if ($stats->childNodes) {
         $i = 0;
         foreach ($stats->childNodes as $nodde) {
             //var_dump($nodde);
             if ($nodde->childNodes) {
                 foreach ($nodde->childNodes as $nod) {
                     //echo $i;
                     if ($nod->childNodes) {
                         //var_dump($nod);
                         foreach ($nod->childNodes as $new) {
                             //var_dump($new);
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Броски в створ ворот") {
                                 $arr['shot_in_goals_host'][0] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Броски в створ ворот") {
                                 $arr['shot_in_goals_guest'][0] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Отраженные броски") {
                                 $arr['shot_reflected_host'][0] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Отраженные броски") {
                                 $arr['shot_reflected_guest'][0] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Удаления") {
                                 $arr['removal_host'][0] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Удаления") {
                                 $arr['removal_guest'][0] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Штрафное время") {
                                 $arr['penalty_time_host'][0] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Штрафное время") {
                                 $arr['penalty_time_guest'][0] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Шайбы в большинстве") {
                                 $arr['goals_in_more_host'][0] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Шайбы в большинстве") {
                                 $arr['goals_in_more_guest'][0] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Шайбы в меньшинстве") {
                                 $arr['goals_in_less_host'][0] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Шайбы в меньшинстве") {
                                 $arr['goals_in_less_guest'][0] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Силовые приемы") {
                                 $arr['force_dodge_host'][0] = (int) $new->textContent;
                             } else {
                                 $arr['force_dodge_host'][0] = 0;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Силовые приемы") {
                                 $arr['force_dodge_guest'][0] = (int) $new->textContent;
                             } else {
                                 $arr['force_dodge_guest'][0] = 0;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Выигр. вбрасывания") {
                                 $arr['facedown_vic_host'][0] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Выигр. вбрасывания") {
                                 $arr['facedown_vic_guest'][0] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Голы в пустые ворота") {
                                 $arr['empty_goals_host'][0] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Голы в пустые ворота") {
                                 $arr['empty_goals_guest'][0] = (int) $new->textContent;
                             }
                         }
                     }
                     //$i++;
                 }
             }
         }
     }
     $stats = $xpath->query(".//*/div[@id='tab-statistics-1-statistic']")->item(0)->firstChild;
     //var_dump($stats);
     if ($stats->childNodes) {
         $i = 0;
         foreach ($stats->childNodes as $nodde) {
             //var_dump($nodde);
             if ($nodde->childNodes) {
                 foreach ($nodde->childNodes as $nod) {
                     //echo $i;
                     if ($nod->childNodes) {
                         //var_dump($nod);
                         foreach ($nod->childNodes as $new) {
                             //var_dump($new);
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Броски в створ ворот") {
                                 $arr['shot_in_goals_host'][1] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Броски в створ ворот") {
                                 $arr['shot_in_goals_guest'][1] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Отраженные броски") {
                                 $arr['shot_reflected_host'][1] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Отраженные броски") {
                                 $arr['shot_reflected_guest'][1] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Удаления") {
                                 $arr['removal_host'][1] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Удаления") {
                                 $arr['removal_guest'][1] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Штрафное время") {
                                 $arr['penalty_time_host'][1] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Штрафное время") {
                                 $arr['penalty_time_guest'][1] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Шайбы в большинстве") {
                                 $arr['goals_in_more_host'][1] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Шайбы в большинстве") {
                                 $arr['goals_in_more_guest'][1] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Шайбы в меньшинстве") {
                                 $arr['goals_in_less_host'][1] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Шайбы в меньшинстве") {
                                 $arr['goals_in_less_guest'][1] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Силовые приемы") {
                                 $arr['force_dodge_host'][1] = (int) $new->textContent;
                             } else {
                                 $arr['force_dodge_host'][1] = 0;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Силовые приемы") {
                                 $arr['force_dodge_guest'][1] = (int) $new->textContent;
                             } else {
                                 $arr['force_dodge_guest'][1] = 0;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Выигр. вбрасывания") {
                                 $arr['facedown_vic_host'][1] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Выигр. вбрасывания") {
                                 $arr['facedown_vic_guest'][1] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Голы в пустые ворота") {
                                 $arr['empty_goals_host'][1] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Голы в пустые ворота") {
                                 $arr['empty_goals_guest'][1] = (int) $new->textContent;
                             }
                         }
                     }
                     //$i++;
                 }
             }
         }
     }
     $stats = $xpath->query(".//*/div[@id='tab-statistics-2-statistic']")->item(0)->firstChild;
     //var_dump($stats);
     if ($stats->childNodes) {
         $i = 0;
         foreach ($stats->childNodes as $nodde) {
             //var_dump($nodde);
             if ($nodde->childNodes) {
                 foreach ($nodde->childNodes as $nod) {
                     //echo $i;
                     if ($nod->childNodes) {
                         //var_dump($nod);
                         foreach ($nod->childNodes as $new) {
                             //var_dump($new);
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Броски в створ ворот") {
                                 $arr['shot_in_goals_host'][2] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Броски в створ ворот") {
                                 $arr['shot_in_goals_guest'][2] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Отраженные броски") {
                                 $arr['shot_reflected_host'][2] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Отраженные броски") {
                                 $arr['shot_reflected_guest'][2] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Удаления") {
                                 $arr['removal_host'][2] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Удаления") {
                                 $arr['removal_guest'][2] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Штрафное время") {
                                 $arr['penalty_time_host'][2] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Штрафное время") {
                                 $arr['penalty_time_guest'][2] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Шайбы в большинстве") {
                                 $arr['goals_in_more_host'][2] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Шайбы в большинстве") {
                                 $arr['goals_in_more_guest'][2] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Шайбы в меньшинстве") {
                                 $arr['goals_in_less_host'][2] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Шайбы в меньшинстве") {
                                 $arr['goals_in_less_guest'][2] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Силовые приемы") {
                                 $arr['force_dodge_host'][2] = (int) $new->textContent;
                             } else {
                                 $arr['force_dodge_host'][2] = 0;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Силовые приемы") {
                                 $arr['force_dodge_guest'][2] = (int) $new->textContent;
                             } else {
                                 $arr['force_dodge_guest'][2] = 0;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Выигр. вбрасывания") {
                                 $arr['facedown_vic_host'][2] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Выигр. вбрасывания") {
                                 $arr['facedown_vic_guest'][2] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Голы в пустые ворота") {
                                 $arr['empty_goals_host'][2] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Голы в пустые ворота") {
                                 $arr['empty_goals_guest'][2] = (int) $new->textContent;
                             }
                         }
                     }
                     //$i++;
                 }
             }
         }
     }
     $stats = $xpath->query(".//*/div[@id='tab-statistics-3-statistic']")->item(0)->firstChild;
     //var_dump($stats);
     if ($stats->childNodes) {
         $i = 0;
         foreach ($stats->childNodes as $nodde) {
             //var_dump($nodde);
             if ($nodde->childNodes) {
                 foreach ($nodde->childNodes as $nod) {
                     //echo $i;
                     if ($nod->childNodes) {
                         //var_dump($nod);
                         foreach ($nod->childNodes as $new) {
                             //var_dump($new);
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Броски в створ ворот") {
                                 $arr['shot_in_goals_host'][3] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Броски в створ ворот") {
                                 $arr['shot_in_goals_guest'][3] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Отраженные броски") {
                                 $arr['shot_reflected_host'][3] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Отраженные броски") {
                                 $arr['shot_reflected_guest'][3] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Удаления") {
                                 $arr['removal_host'][3] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Удаления") {
                                 $arr['removal_guest'][3] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Штрафное время") {
                                 $arr['penalty_time_host'][3] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Штрафное время") {
                                 $arr['penalty_time_guest'][3] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Шайбы в большинстве") {
                                 $arr['goals_in_more_host'][3] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Шайбы в большинстве") {
                                 $arr['goals_in_more_guest'][3] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Шайбы в меньшинстве") {
                                 $arr['goals_in_less_host'][3] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Шайбы в меньшинстве") {
                                 $arr['goals_in_less_guest'][3] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Силовые приемы") {
                                 $arr['force_dodge_host'][3] = (int) $new->textContent;
                             } else {
                                 $arr['force_dodge_host'][3] = 0;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Силовые приемы") {
                                 $arr['force_dodge_guest'][3] = (int) $new->textContent;
                             } else {
                                 $arr['force_dodge_guest'][3] = 0;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Выигр. вбрасывания") {
                                 $arr['facedown_vic_host'][3] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Выигр. вбрасывания") {
                                 $arr['facedown_vic_guest'][3] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Голы в пустые ворота") {
                                 $arr['empty_goals_host'][3] = (int) $new->textContent;
                             }
                             if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Голы в пустые ворота") {
                                 $arr['empty_goals_guest'][3] = (int) $new->textContent;
                             }
                         }
                     }
                     //$i++;
                 }
             }
         }
     }
     if (isset($xpath->query(".//*/div[@id='tab-statistics-4-statistic']")->item(0)->firstChild)) {
         $stats = $xpath->query(".//*/div[@id='tab-statistics-4-statistic']")->item(0)->firstChild;
         //var_dump($stats);
         if ($stats->childNodes) {
             $i = 0;
             foreach ($stats->childNodes as $nodde) {
                 //var_dump($nodde);
                 if ($nodde->childNodes) {
                     foreach ($nodde->childNodes as $nod) {
                         //echo $i;
                         if ($nod->childNodes) {
                             //var_dump($nod);
                             foreach ($nod->childNodes as $new) {
                                 //var_dump($new);
                                 if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Броски в створ ворот") {
                                     $arr['shot_in_goals_host'][4] = (int) $new->textContent;
                                 }
                                 if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Броски в створ ворот") {
                                     $arr['shot_in_goals_guest'][4] = (int) $new->textContent;
                                 }
                                 if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Отраженные броски") {
                                     $arr['shot_reflected_host'][4] = (int) $new->textContent;
                                 }
                                 if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Отраженные броски") {
                                     $arr['shot_reflected_guest'][4] = (int) $new->textContent;
                                 }
                                 if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Удаления") {
                                     $arr['removal_host'][4] = (int) $new->textContent;
                                 }
                                 if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Удаления") {
                                     $arr['removal_guest'][4] = (int) $new->textContent;
                                 }
                                 if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Штрафное время") {
                                     $arr['penalty_time_host'][4] = (int) $new->textContent;
                                 }
                                 if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Штрафное время") {
                                     $arr['penalty_time_guest'][4] = (int) $new->textContent;
                                 }
                                 if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Шайбы в большинстве") {
                                     $arr['goals_in_more_host'][4] = (int) $new->textContent;
                                 }
                                 if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Шайбы в большинстве") {
                                     $arr['goals_in_more_guest'][4] = (int) $new->textContent;
                                 }
                                 if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Шайбы в меньшинстве") {
                                     $arr['goals_in_less_host'][4] = (int) $new->textContent;
                                 }
                                 if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Шайбы в меньшинстве") {
                                     $arr['goals_in_less_guest'][4] = (int) $new->textContent;
                                 }
                                 if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Силовые приемы") {
                                     $arr['force_dodge_host'][4] = (int) $new->textContent;
                                 } else {
                                     $arr['force_dodge_host'][4] = 0;
                                 }
                                 if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Силовые приемы") {
                                     $arr['force_dodge_guest'][4] = (int) $new->textContent;
                                 } else {
                                     $arr['force_dodge_guest'][4] = 0;
                                 }
                                 if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Выигр. вбрасывания") {
                                     $arr['facedown_vic_host'][4] = (int) $new->textContent;
                                 }
                                 if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Выигр. вбрасывания") {
                                     $arr['facedown_vic_guest'][4] = (int) $new->textContent;
                                 }
                                 if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->nextSibling) && $new->nextSibling->textContent == "Голы в пустые ворота") {
                                     $arr['empty_goals_host'][4] = (int) $new->textContent;
                                 }
                                 if ($new->nodeName == "td" && strlen($new->textContent) < 3 && isset($new->previousSibling) && $new->previousSibling->textContent == "Голы в пустые ворота") {
                                     $arr['empty_goals_guest'][4] = (int) $new->textContent;
                                 }
                             }
                         }
                         //$i++;
                     }
                 }
             }
         }
     }
     //print_r($arr); exit;
     while ($stats = $stats->nextSibling) {
         // var_dump($stats); exit;
     }
     if (isset($xpath->query(".//*/td[@class='kx o_1']")->item(0)->firstChild->nextSibling)) {
         $bet1 = $xpath->query(".//*/td[@class='kx o_1']")->item(0)->firstChild->nextSibling;
         $arr["bet_vic_host"] = $bet1->textContent;
     } else {
         $arr["bet_vic_host"] = 0;
     }
     if (isset($xpath->query(".//*/td[@class='kx o_0 winner']")->item(0)->firstChild->nextSibling)) {
         $bet2 = $xpath->query(".//*/td[@class='kx o_0 winner']")->item(0)->firstChild->nextSibling;
         $arr["bet_nobody"] = $bet2->textContent;
     } else {
         $arr["bet_nobody"] = 0;
     }
     if (isset($xpath->query(".//*/td[@class='kx o_2']")->item(0)->firstChild->nextSibling)) {
         $bet3 = $xpath->query(".//*/td[@class='kx o_2']")->item(0)->firstChild->nextSibling;
         $arr["bet_vic_guest"] = $bet3->textContent;
     } else {
         $arr["bet_vic_guest"] = 0;
     }
     //var_dump($arr['gk']); exit;
     return $arr;
 }
Exemple #2
0
 public function getGoalKeeper()
 {
     return $this->hasOne(Khlplayers::className(), ['id' => 'gk']);
 }