Sign in | Register
$h) if(str_replace(array("_",".html"),array(" ",""),rlp_url_array(4))==$h) break; include("controllers/comp_list.php"); } $guts = preg_replace("/[_-]/"," ",rlp_url_array(3)); $guts = str_replace(".html","",$guts); $yearcheck = substr($guts,-4); if(substr($yearcheck,1,1)==" ") { // year year $yearcheck = substr($guts,-7,4); $bigyear = true; } if(is_numeric($yearcheck)) { // year is present. $year = $yearcheck; if(!empty($bigyear)) { $guts = substr($guts,0,-7); } else { $guts = substr($guts,0,-4); } } $comp = trim($guts); $comp = str_replace(" ","_",$comp); if(isset($year)) { $r=q("select * from comps where comp_name like '{$comp}' and comp_year={$year}"); if( !$r ) { if($comp=="NSWRL") $comp="NSWRFL"; $r=q("select * from comps where comp_name like '{$comp}' and comp_year={$year}"); if( !$r ) { perform404(); return; } } $_GET['comp_id'] = $r[0]['comp_id']; if(empty(rlp_url_array(4))) redirect("/competitions/".$_GET['comp_id']); } else { $r=q("select * from comp_groups where comp_group_name like '{$comp}' limit 0,1"); if( $r ) { $_GET['comp_group']=$r[0]['comp_group_id']; } else { $r=q("select * from comp_codes where name like '{$comp}' limit 0,1"); if( $r ) { $_GET['comp_special_id'] = $r[0]['comp_code']; if(empty(rlp_url_array(4))) redirect("/competitions/".rlp_config()->get('comp_codes')[$r[0]['comp_code']]['clean_url']."/summary.html"); } } } if(!empty($_GET['comp_id'])) rlp_config()->set('admin_menu.Comp Tool', "https://".$_ENV['HOSTNAME_ADMIN']."/massive_comp_input.php?comp_id=".$_GET['comp_id']); // is this a match page? $roundtest = (!empty(rlp_url_array(4))) ? str_replace("_"," ",rlp_url_array(4)) : ""; $round = false; if( (substr($roundtest,0,5)=="Round")||(substr($roundtest,0,4)=="Game") ) { $round = str_replace("Round ","",$roundtest); $round = str_replace("Game ","",$round); $round_results = true; } else { foreach(array_keys(rlp_config()->get('r2desc')) as $rd) { $rdtest = str_replace(array("(",")"),array(" "," "),rlp_config()->get('r2desc')[$rd]); if($roundtest==$rdtest) { $round = $rd; } } } if($round) { $query_extra = " and game_round='{$round}' "; // it's a match. $teams = str_replace("_"," ",rlp_url_array(5)); $page_type = "match"; preg_match( "/(.+)-vs-(.+)/", $teams, $matches ); $team1name = str_replace(" ","_",$matches[1]); $team2name = str_replace(" ","_",$matches[2]); if(substr($team2name,-5)==".html") { redirect(substr($_SERVER['REQUEST_URI'],0,-5)."/summary.html"); } // prelim check, history based on date first $team1 = q("SELECT t.* FROM teams t,team_history th,clean_urls cu WHERE cu.resource_type='team_history' AND cu.resource_id=th.team_history_id AND t.team_id=th.team_id AND cu.path='".str_replace(" ","-",$matches[1])."' AND (th.date_from<='{$year}-12-31' and th.date_to>='{$year}-01-01')"); if( !$team1 ) { $team1 = q("SELECT t.* FROM teams t, clean_urls c where c.path = '".str_replace(" ","-",$matches[1])."' AND c.resource_type='team' AND c.resource_id=t.team_id"); if( !$team1 ) { if($comp) { redirect("/competitions/".$comp."/results.html"); } perform404(); return; } } // prelim check, history based on date first $team2 = q("SELECT t.* FROM teams t,team_history th,clean_urls cu WHERE cu.resource_type='team_history' AND cu.resource_id=th.team_history_id AND t.team_id=th.team_id AND cu.path='".str_replace(" ","-",$matches[2])."' AND (th.date_from<='{$year}-12-31' and th.date_to>='{$year}-01-01')"); if( !$team2 ) { $team2 = q("SELECT t.* FROM teams t, clean_urls c where c.path = '".str_replace(" ","-",$matches[2])."' AND c.resource_type='team' AND c.resource_id=t.team_id"); if( !$team2 ) { if($comp) { redirect("/competitions/".$comp."/results.html"); } perform404(); return; } } $t1 = $team1[0]['team_id']; $t2 = $team2[0]['team_id']; $game = q("select * from games g,comp_games cg WHERE g.game_id=cg.game_id and cg.comp_id={$_GET['comp_id']} {$query_extra} and home_id={$t1} and away_id={$t2}"); if(!$game) { if($team1[1]) { $t1 = $team1[1]['team_id']; $game = q("select * from games g,comp_games cg WHERE g.game_id=cg.game_id and cg.comp_id={$_GET['comp_id']} {$query_extra} and home_id={$t1} and away_id={$t2}"); } } if(!$game) { if($team2[1]) { $t2 = $team2[1]['team_id']; $game = q("select * from games g,comp_games cg WHERE g.game_id=cg.game_id and cg.comp_id={$_GET['comp_id']} {$query_extra} and home_id={$t1} and away_id={$t2}"); } } $team1 = $t1; $team2 = $t2; $_GET['game_id'] = $game[0]['game_id']; $ci = comp_info($_GET['comp_id']); $comp=$_GET['comp_id']; if($ci['type']=="series") include "controllers/summary_series.php"; else if($ci['type']=="tournament") include "controllers/summary_tournament.php"; $title = $ci['name']." ".$ci['year']; if(!empty($ci['year_end'])) $title .= "/".substr($ci['year_end'],2); rlp_config()->set('standalone', true); include("controllers/match.php"); } $page_type = (!empty(rlp_url_array(4))) ? substr(rlp_url_array(4),0,-5) : ""; if(!empty($_GET['comp_id'])) { $ci = comp_info($_GET['comp_id']); if($ci['type']=="season") { redirect("/seasons/".$ci['clean_url']."/".$page_type.".html"); } } if(!empty($_GET['comp_id'])) { include "controllers/summary_tour.php"; return; } include( "controllers/tour_list.php" );