-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions-general.php
executable file
·73 lines (67 loc) · 1.71 KB
/
functions-general.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
function showHeader($plain = false) {
if($plain) {
require_once("header_wide.php");
} else {
require_once("header.php");
}
}
function showFooter($plain = false) {
if($plain) {
require_once("footer_wide.php");
} else {
require_once("footer.php");
}
}
function makeMatchup($id, $type, $homeSchoolID) {
$rs2 = mysql_query("SELECT * FROM meet_school JOIN school ON meet_school.school_id=school.id WHERE meet_id=$id");
$schools = array();
while($school = mysql_fetch_object($rs2)) {
if($school->id == $homeSchoolID) {
$school->name = "<b>" . $school->name . "</b>";
array_unshift($schools, $school);
} else {
//push it!
array_push($schools, $school);
}
}
$matchup = array();
switch($type) {
case "triple":
$matchup[0][] = $schools[0];
$matchup[0][] = $schools[1];
$matchup[1][] = $schools[0];
$matchup[1][] = $schools[2];
$matchup[2][] = $schools[1];
$matchup[2][] = $schools[2];
break;
case "double":
$matchup[0][] = $schools[0];
$matchup[0][] = $schools[1];
$matchup[1][] = $schools[0];
$matchup[1][] = $schools[2];
break;
case "single":
$matchup[0][] = $schools[0];
$matchup[0][] = $schools[1];
break;
}
return $matchup;
}
function inMatchup($matchup, $school1_id, $school2_id) {
foreach($matchup as $match) {
if($match[0]->id == $school1_id && $match[1]->id == $school2_id || $match[1]->id == $school1_id && $match[0]->id == $school2_id) {
return true;
}
}
return false;
}
function protect($admin = false) {
global $_SESSION;
if(!isset($_SESSION['user_id'])) {
header("Location: index.php");
} else if ($admin && $_SESSION['school_id'] != 0) {
die("Administrator only.");
}
}
?>