function getStandings($allSchools) { $all_records = []; $all_leagues = []; $brk = []; $ccc_nrw = []; $ccc_nrb = []; $ccc_crw = []; $ccc_crb = []; $ccc_srw = []; $ccc_srb = []; $cra = []; $csc_west = []; $csc_central = []; $csc_east = []; $ecc_lg = []; $ecc_md = []; $ecc_sm = []; $fciac_east = []; $fciac_central = []; $fciac_west = []; $nvl_brass = []; $nvl_copper = []; $nccc = []; $scc_ham = []; $scc_hou = []; $scc_oro = []; $scc_qui = []; $shr = []; $swc_colonial = []; $swc_patriot = []; $db_standings = new Database(); // foreach ($allSchools as $team) { $getTeamRecord = "CALL getRecord('{$team['0']}')"; $record = $db_standings->getData($getTeamRecord); $record = getRecords($record, $team); if ($record[1] == 'Berkshire') { array_push($brk, $record); } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'North Region White') { array_push($ccc_nrw, $record); } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'North Region Blue') { array_push($ccc_nrb, $record); } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'Central Region White') { array_push($ccc_crw, $record); } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'Central Region Blue') { array_push($ccc_crb, $record); } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'South Region White') { array_push($ccc_srw, $record); } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'South Region Blue') { array_push($ccc_srb, $record); } elseif ($record[1] == 'Capital Region Athletic') { array_push($cra, $record); } elseif ($record[1] == 'Constitution State' && $record[2] == 'West') { array_push($csc_west, $record); } elseif ($record[1] == 'Constitution State' && $record[2] == 'Central') { array_push($csc_central, $record); } elseif ($record[1] == 'Constitution State' && $record[2] == 'East') { array_push($csc_east, $record); } elseif ($record[1] == 'Eastern Connecticut' && $record[2] == 'Large') { array_push($ecc_lg, $record); } elseif ($record[1] == 'Eastern Connecticut' && $record[2] == 'Medium') { array_push($ecc_md, $record); } elseif ($record[1] == 'Eastern Connecticut' && $record[2] == 'Small') { array_push($ecc_sm, $record); } elseif ($record[1] == 'Fairfield County Interscholastic Athletic' && $record[2] == 'East') { array_push($fciac_east, $record); } elseif ($record[1] == 'Fairfield County Interscholastic Athletic' && $record[2] == 'Central') { array_push($fciac_central, $record); } elseif ($record[1] == 'Fairfield County Interscholastic Athletic' && $record[2] == 'West') { array_push($fciac_west, $record); } elseif ($record[1] == 'Naugatuck Valley' && $record[2] == 'Brass') { array_push($nvl_brass, $record); } elseif ($record[1] == 'Naugatuck Valley' && $record[2] == 'Copper') { array_push($nvl_copper, $record); } elseif ($record[1] == 'North Central Connecticut') { array_push($nccc, $record); } elseif ($record[1] == 'Southern Connecticut' && $record[2] == 'Hammonasset') { array_push($scc_ham, $record); } elseif ($record[1] == 'Southern Connecticut' && $record[2] == 'Housatonic') { array_push($scc_hou, $record); } elseif ($record[1] == 'Southern Connecticut' && $record[2] == 'Oronoque') { array_push($scc_oro, $record); } elseif ($record[1] == 'Southern Connecticut' && $record[2] == 'Quinnipiac') { array_push($scc_qui, $record); } elseif ($record[1] == 'Shoreline') { array_push($shr, $record); } elseif ($record[1] == 'South West' && $record[2] == 'Colonial') { array_push($swc_colonial, $record); } elseif ($record[1] == 'South West' && $record[2] == 'Patriot') { array_push($swc_patriot, $record); } else { array_push($all_records, $record); } // usort($brk, make_comparer([9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); // Sort ccc arrays by overal w, l usort($ccc_nrw, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($ccc_nrb, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($ccc_crw, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($ccc_crb, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($ccc_srw, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($ccc_srb, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); // Sort cra arrays by overal w, l usort($cra, make_comparer([9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); // Sort csc arrays by overal w, l usort($csc_west, make_comparer([9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($csc_central, make_comparer([9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($csc_east, make_comparer([9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); // Sort ecc arrays by overal w, l usort($ecc_lg, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($ecc_md, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($ecc_sm, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); // Sort fcica arrays by overal w, l usort($fciac_east, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($fciac_central, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($fciac_west, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); // Sort nccc arrays by overal w, l usort($nccc, make_comparer([9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); // Sort nvl arrays by overal w, l usort($nvl_brass, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($nvl_copper, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); // Sort scc arrays by overal w, l usort($scc_ham, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($scc_hou, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($scc_oro, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($scc_qui, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); // Sort shr arrays by overal w, l usort($shr, make_comparer([9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); // Sort swc arrays by overal w, l usort($swc_colonial, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($swc_patriot, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); // Combine divisions into league array $ccc = [$ccc_nrw, $ccc_nrb, $ccc_crw, $ccc_crb, $ccc_srw, $ccc_srb]; $csc = [$csc_west, $csc_central, $csc_east]; $ecc = [$ecc_lg, $ecc_md, $ecc_sm]; $fciac = [$fciac_west, $fciac_central, $fciac_east]; $nvl = [$nvl_brass, $nvl_copper]; $scc = [$scc_ham, $scc_hou, $scc_oro, $scc_qui]; $swc = [$swc_colonial, $swc_patriot]; // Combine sorted divisions into all leagues array $all_leagues = ['berkshire' => $brk, 'capital region athletic' => $cra, 'central connecticut' => $ccc, 'constitution state' => $csc, 'eastern connecticut' => $ecc, 'fairfield county interscholastic athletic' => $fciac, 'north central connecticut' => $nccc, 'naugatuck valley' => $nvl, 'shoreline' => $shr, 'southern connecticut' => $scc, 'south west' => $swc]; } return $all_leagues; }
<?php /********************************* Author: Corey Muniz Controller for the Admin Panel *********************************/ require_once "models/User.php"; require_once "models/db.php"; require_once "models/PasswordHash.php"; include_once "models/championList.php"; include_once "models/twitchModel.php"; $twitch = new twitch(); $champObj = new championList(); $champObj->generateChampionList(); usort($champObj->championList, make_comparer('name')); session_start(); $user = new User(); if (isset($_SESSION['user'])) { $user = $_SESSION['user']; } else { header("Location: loginCheckCtrl"); die; } $guy = $user; if ($_POST) { $sent = false; $twitchErr = false; $summonerErr = false; $passwordErr = false; if (isset($guy->id)) { if (isset($_POST['password']) && isset($_POST['password2'])) {
function getStandings($allSchools) { $all_records = []; $all_leagues = []; $ccc_d1e = []; $ccc_d1w = []; $ccc_d2e = []; $ccc_d2w = []; $ccc_d3e = []; $ccc_d3w = []; $csc = []; $ecc_d1 = []; $ecc_d2 = []; $fciac_d1 = []; $fciac_d2 = []; $nvl_brass = []; $nvl_copper = []; $nvl_iron = []; $peq_east = []; $peq_south = []; $peq_west = []; $scc_d1e = []; $scc_d1w = []; $scc_d2e = []; $scc_d2w = []; $swc_colonial = []; $swc_patriot = []; $db_standings = new Database(); // foreach ($allSchools as $team) { $getTeamRecord = "CALL getRecord('{$team['0']}')"; $record = $db_standings->getData($getTeamRecord); $record = getRecords($record, $team); if ($record[1] == 'Central Connecticut' && $record[2] == 'Div I East') { array_push($ccc_d1e, $record); } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'Div I West') { array_push($ccc_d1w, $record); } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'Div II East') { array_push($ccc_d2e, $record); } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'Div II West') { array_push($ccc_d2w, $record); } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'Div III East') { array_push($ccc_d3e, $record); } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'Div III West') { array_push($ccc_d3w, $record); } elseif ($record[1] == 'Constitution State') { array_push($csc, $record); } elseif ($record[1] == 'Eastern Connecticut' && $record[2] == 'Div I') { array_push($ecc_d1, $record); } elseif ($record[1] == 'Eastern Connecticut' && $record[2] == 'Div II') { array_push($ecc_d2, $record); } elseif ($record[1] == 'Fairfield County Interscholastic Athletic' && $record[2] == 'Div I') { array_push($fciac_d1, $record); } elseif ($record[1] == 'Fairfield County Interscholastic Athletic' && $record[2] == 'Div II') { array_push($fciac_d2, $record); } elseif ($record[1] == 'Naugatuck Valley' && $record[2] == 'Brass') { array_push($nvl_brass, $record); } elseif ($record[1] == 'Naugatuck Valley' && $record[2] == 'Copper') { array_push($nvl_copper, $record); } elseif ($record[1] == 'Naugatuck Valley' && $record[2] == 'Iron') { array_push($nvl_iron, $record); } elseif ($record[1] == 'Pequot' && $record[2] == 'East') { array_push($peq_east, $record); } elseif ($record[1] == 'Pequot' && $record[2] == 'South') { array_push($peq_south, $record); } elseif ($record[1] == 'Pequot' && $record[2] == 'West') { array_push($peq_west, $record); } elseif ($record[1] == 'Southern Connecticut' && $record[2] == 'Div I East') { array_push($scc_d1e, $record); } elseif ($record[1] == 'Southern Connecticut' && $record[2] == 'Div I West') { array_push($scc_d1w, $record); } elseif ($record[1] == 'Southern Connecticut' && $record[2] == 'Div II East') { array_push($scc_d2e, $record); } elseif ($record[1] == 'Southern Connecticut' && $record[2] == 'Div II West') { array_push($scc_d2w, $record); } elseif ($record[1] == 'South West' && $record[2] == 'Colonial') { array_push($swc_colonial, $record); } elseif ($record[1] == 'South West' && $record[2] == 'Patriot') { array_push($swc_patriot, $record); } else { array_push($all_records, $record); } // Sort ccc arrays by overal w, l usort($ccc_d1e, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($ccc_d1w, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($ccc_d2e, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($ccc_d2w, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($ccc_d3e, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($ccc_d3w, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); // Sort csc arrays by overal w, l usort($csc, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); // Sort ecc arrays by overal w, l usort($ecc_d1, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($ecc_d2, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); // Sort fcica arrays by overal w, l usort($fciac_d1, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($fciac_d2, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); // Sort nvl arrays by overal w, l usort($nvl_brass, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($nvl_copper, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($nvl_iron, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); // Sort peq arrays by overal w, l usort($peq_east, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($peq_south, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($peq_west, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); // Sort scc arrays by overal w, l usort($scc_d1e, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($scc_d1w, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($scc_d2e, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($scc_d2w, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); // Sort swc arrays by overal w, l usort($swc_colonial, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); usort($swc_patriot, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC])); // Combine divisions into league array $ccc = [$ccc_d1e, $ccc_d1w, $ccc_d2e, $ccc_d2w, $ccc_d3e, $ccc_d3w]; $ecc = [$ecc_d1, $ecc_d2]; $fciac = [$fciac_d1, $fciac_d2]; $nvl = [$nvl_brass, $nvl_copper, $nvl_iron]; $peq = [$peq_east, $peq_south, $peq_west]; $scc = [$scc_d1e, $scc_d1w, $scc_d2e, $scc_d2w]; $swc = [$swc_colonial, $swc_patriot]; // Combine sorted divisions into all leagues array $all_leagues = ['central connecticut' => $ccc, 'constitution state' => $csc, 'eastern connecticut' => $ecc, 'fairfield county interscholastic athletic' => $fciac, 'naugatuck valley' => $nvl, 'pequot' => $peq, 'southern connecticut' => $scc, 'south west' => $swc]; } return $all_leagues; }
public function mode($address="/",$userId=false,$knowExists=false,$providedPerms=false){ if($userId===false) $userId=$this->parent->user_user->currentId; $address=$this->filter_address($address); if($address!=='/' && $knowExists!==true){ //make sure this is just a single item $curItem=pull_item($this->get($address,false,true,true)); if($curItem===false){ $this->error_message('Item not found!'); return false; } } if($providedPerms===false){ $current=$this->load_user_perms($address,$userId,true); }elseif(is_array($providedPerms)){ $current=array(); //provided Permissions will be for many items possibly, so sort it out! foreach($providedPerms as $cPerm){ if(strlen($cPerm['address'])<=strlen($address) && substr($address,0,strlen($cPerm['address']))===$cPerm['address']){ $current[]=$cPerm; } } } if($userId===0) return $current; //determine the final mode $mode=0; $modeAddress=''; $modeAccessor=false; //sort by depth foreach($current as $i=>$perm){ $current[$i]['depth']=$perm['address']==='/' ? -1 : substr_count($perm['address'],'/')-1; } usort($current, make_comparer('depth')); //loop through each permission, from the root to the item foreach($current as $perm){ $permRoles=$this->mode_to_roles($perm['mode']); //ownership is everything if($permRoles['o']) return array_sum($this->modes); //determine if more specific permission if(strlen($modeAddress)<strlen($perm['address']) || ($modeAddress===$perm['address'] && ( $modeAccessor===false || $perm['access_id']>0 || ($modeAccessor<=0 && $perm['access_id']<$modeAccessor && $perm['mode']>$mode)) ) ){ $mode=$perm['mode']; $modeAccessor=$perm['access_id']; $modeAddress=$perm['address']; } } //echo $mode; return $mode; }
function sort_by_attr($key,$data){ uasort($data, make_comparer($key)); return $data; }