-
Notifications
You must be signed in to change notification settings - Fork 3
/
rebus_util.php
94 lines (88 loc) · 2.17 KB
/
rebus_util.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
require_once 'rebus.php';
function checkPic(&$name)
{
$pic = PICTURE_PATH . $name;
if (is_readable($pic)) {
$name = PICTURE_URL . $name;
return 1;
}
if (is_readable($pic . ".jpg")) {
$name = PICTURE_URL . $name . ".jpg";
return 1;
}
if (is_readable($pic . ".gif")) {
$name = PICTURE_URL . $name . ".gif";
return 1;
}
if (is_readable($pic . ".png")) {
$name = PICTURE_URL . $name . ".png";
return 1;
}
if (is_readable($pic . ".jfif")) {
$name = PICTURE_URL . $name . ".jfif";
return 1;
}
return 0;
}
function getEventNumber($event)
{
$i = 0;
foreach ($GLOBALS['events'] as $e => $ename) {
if ($e == $event) {
return $i;
}
++$i;
}
echo "ERROR: Could not find event '$event'<br>";
}
function getTeamInfo($number)
{
$i = 0;
foreach ($GLOBALS['teams'] as $tname => $v) {
if ($i == $number) {
$flair = count($v) > 2 ? $v[2] : "";
return array('name' => $tname, 'number' => $v[0], 'members' => $v[1], 'flair' => $flair);
}
++$i;
}
}
function getPartEvents($part)
{
$result = array();
if (array_key_exists($part, $GLOBALS['parts'])) {
$events = $GLOBALS['parts'][$part];
foreach ($events as $e) {
if (!is_string($e)) {
}
elseif (preg_match('/\*[a-z]+\*/', $e)) {
}
elseif (array_key_exists($e, $GLOBALS['parts'])) {
$result = array_merge($result, getPartEvents($e));
}
else {
array_push($result, $e);
}
}
}
else {
$result = array($part);
}
$result1 = array();
foreach ($result as $e) {
if (preg_match('/[TF]P [0-9]+$/', $e)) {
if (array_key_exists($e . 'V', $GLOBALS['events'])) {
array_push($result1, $e . 'V');
array_push($result1, $e . 'H');
}
else {
array_push($result1, $e);
}
}
else {
array_push($result1, $e);
}
}
return $result1;
}
?>