/** * Reordena el orden de salida de una manga al azar * @param {int} $jornada ID de jornada * @param {int} $manga ID de manga * @return {string} nuevo orden de salida */ function random($mode = 8) { // fase 1 aleatorizamos la manga $orden = $this->getOrden(); $this->myLogger->debug("OrdenSalida::Random() Manga:{$this->manga['ID']} Orden inicial: \n{$orden}"); // buscamos los perros de la categoria seleccionada $listas = $this->splitPerrosByMode($orden, $mode); if ($listas[1] !== "") { // si hay datos, reordena; si no no hagas nada $str2 = implode(",", aleatorio(explode(",", $listas[1]))); $str = "BEGIN,{$listas[2]},{$str2},END"; $this->setOrden($str); } /* $str=getInnerString($orden,"BEGIN,",",END"); if ($str!=="") { // si hay datos, reordena; si no no hagas nada $str2 = implode(",",aleatorio(explode(",", $str))); $str="BEGIN,$str2,END"; $this->setOrden($str); } */ $orden = $this->getOrden(); $this->myLogger->debug("OrdenSalida::Random() Manga:{$this->manga['ID']} Orden final: \n{$orden}"); // fase 2: aleatorizamos los equipos de la jornada $orden = $this->getOrdenEquipos(); $this->myLogger->debug("OrdenSalida::RandomTeam() Manga:{$this->manga['ID']} Orden inicial: \n{$orden}"); $str = getInnerString($orden, "BEGIN,", ",END"); if ($str !== "") { // si hay datos, reordena; si no no hagas nada $str2 = implode(",", aleatorio(explode(",", $str))); $str = "BEGIN,{$str2},END"; $this->setOrdenEquipos($str); } $ordenequipos = $this->getOrdenEquipos(); $this->myLogger->debug("OrdenSalida::RandomTeam() Manga:{$this->manga['ID']} Orden final: \n{$ordenequipos}"); return $orden; }
$markerEnd = '<!-- end gameDay -->'; //strip off the first character and add it back so first instance of pattern doesn't match during replace $content = substr($content, 1, strlen($content)); $content = '<' . str_replace('<h4 class="games-date">', $markerEnd . '<h4 class="games-date">', $content) . $markerEnd; $content = str_replace('<h4 class="games-date">', $markerStart . '<h4 class="games-date">', $content); $gameDayHtml = explode($markerEnd . $markerStart, $content); //print_r($gameDayHtml); //exit; for ($i = 0; $i < sizeof($gameDayHtml); $i++) { //get the date $matches = array(); $startStr = '<h4 class="games-date">'; $endStr = '</h4>'; $find = '|' . $startStr . '(.*?)' . $endStr . '|is'; preg_match_all($find, $gameDayHtml[$i], $matches); $gameDate = getInnerString($matches[0][0], $startStr, $endStr); $matches = array(); $find = '|<p id=".*?-statusText">(.*?)</p>.*?<a href="/nfl/clubhouse\\?team=(.*?)">(.*?)</a>.*?<li class="final" id=".*?-aTotal">(.*?)</li>.*?<a href="/nfl/clubhouse\\?team=(.*?)">(.*?)</a>.*?<li class="final" id=".*?-hTotal">(.*?)</li>|is'; preg_match_all($find, $gameDayHtml[$i], $matches); //print_r($matches); //exit; $count = count($matches[1]); for ($j = 0; $j < $count; $j++) { $gameTimeEastern = $gameDate . ' ' . $matches[1][$j]; $gameTimeEastern = str_replace(' ET', '', $gameTimeEastern); $gameTimeEastern = date('Y-m-d H:i:00', strtotime($gameTimeEastern)); //$overtime = (($matches[1][$j] == 'Final/OT') ? 1 : 0); $away_team = strtoupper($matches[2][$j]); $away_team_name = $matches[3][$j]; $home_team = strtoupper($matches[5][$j]); $home_team_name = $matches[6][$j];