-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteam.php
More file actions
196 lines (178 loc) · 7.42 KB
/
team.php
File metadata and controls
196 lines (178 loc) · 7.42 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php
include_once "api-keys.php";
$teams = array(
"NASH Team" => array(
"Team Directors" => array(
"Nikhil Behari, Logistics Director" => "behari.jpg",
"Jack Kenna, Publicity Director" => "kenna.jpg",
"Griffin McVay, Mission Director" => "mcvay.jpg",
"Margo Weller, Mission Director" => "weller.jpg",
"Luke Trueman, Players' Union Leader" => "trueman.jpg"
),
"Team Members" => array(
"Jess Barry, Mission Team" => "barry.jpg",
"Sam Buirge, Mission Team" => "buirge.jpg",
"Ryan Earle, Mission Team" => "earle.jpg",
"Jenna Edelmann, Mission Team" => "edelmann.jpg",
"Naomi Heisstand, Mission Team" => "heisstand.jpg",
"Breanna Jones, Publicity Team" => "jones.jpg",
"Christopher Lee, Logistics Team" => "lee.jpg",
"Valerie Malachin, Mission Team" => "malachin.jpg",
"Ritika Nagpal, Mission Team" => "nagpal.jpg",
"Jayne Simon, Mission Team" => "simon.jpg",
"Zach Trdinich, Publicity Team" => "trdinich.jpg",
"Luke Turkovich, Logistics Team" => "turkovich.jpg",
"Jon Van Kirk, Mission Team" => "vankirk.jpg",
"Jeremiah Zemet, Mission Team" => "zemet.jpg"
)
),
"NAI Team" => array(
"Team Directors" => array(
"Grace Welsh, NAI Director" => "welsh.jpg",
"RJ Swanson, NAI Director" => "swanson.jpg"
),
"Team Members" => array(
"Andrew Baierl, Logistics Team" => "baierl.jpg",
"Grace Baierl, Mission Team" => "baierl_2.jpg",
"Meghna Behari, Logistics Team" => "behari_2.jpg",
"John Catanzaro, Logistics Team" => "catanzaro.jpg",
"Charlie Deible, Logistics Team" => "deible.jpg",
"Patrick Fenlon, Logistics Team" => "fenlon.jpg",
"Josh Galecki, Logistics Team" => "galecki.jpg",
"Andrew Johnson, Logistics Team" => "johnson.jpg",
"Vicki Lee, Publicity Team" => "lee_2.jpg",
"Ana Key, Logistics Team" => "key.jpg",
"Angelina Lowe, Logistics Team" => "lowe.jpg",
"Jake Mellinger, Players' Union" => "mellinger.jpg",
"Nicholas Palermo, Publicity Team" => "palermo.jpg",
"Jacob Pan, Publicity Team" => "pan.jpg",
"Caroline Radocaj, Publicity Team" => "radocaj.jpg",
"Natalie Shoup, Players' Union" => "shoup.jpg",
"Andrew Solman, Logistics Team" => "solman.jpg",
"Lydia Thomas, Players' Union" => "thomas.jpg",
"Rose Timmer, Mission Team" => "timmer.jpg",
"Grace Waldee, Mission Team" => "waldee.jpg"
)
)
);
$ids = [2757838540, 1636704312, 1045293290, 1380804866, 2405315112, 601340706, 2332523996, 381211050, 496475347, 2902146421, 1024988798, 2510451658, 2402095411, 1674638335, 2576757000, 324719303, 40125872];
//$twitterResults = performPost("https://api.twitter.com/1.1/users/lookup.json", array("user_id" => implode(",",user_id)));
//url is string, data is array
function performPost($url,$data,$bearer_token){
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => 'Authorization: Bearer '.$bearer_token,
'method' => 'POST',
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
return $result;
}
function getTwitterFromAPI(){
global $ids, $twitter_consumer_key, $twitter_secret_key;
$app_key = $twitter_consumer_key;
$app_token = $twitter_secret_key;
//These are our constants.
$api_base = 'https://api.twitter.com/';
$bearer_token_creds = base64_encode($app_key.':'.$app_token);
//Get a bearer token.
$opts = array(
'http'=>array(
'method' => 'POST',
'header' => 'Authorization: Basic '.$bearer_token_creds."\r\n".
'Content-Type: application/x-www-form-urlencoded;charset=UTF-8',
'content' => 'grant_type=client_credentials'
)
);
$context = stream_context_create($opts);
$json = file_get_contents($api_base.'oauth2/token',false,$context);
$result = json_decode($json,true);
if (!is_array($result) || !isset($result['token_type']) || !isset($result['access_token'])) {
die("Something went wrong. This isn't a valid array: ".$json);
}
if ($result['token_type'] !== "bearer") {
die("Invalid token type. Twitter says we need to make sure this is a bearer.");
}
//Set our bearer token. Now issued, this won't ever* change unless it's invalidated by a call to /oauth2/invalidate_token.
//*probably - it's not documentated that it'll ever change.
$bearer_token = $result['access_token'];
//Try a twitter API request now.
$opts = array(
'http'=>array(
'method' => 'GET',
'header' => 'Authorization: Bearer '.$bearer_token
)
);
$context = stream_context_create($opts);
$options = array(
'user_id' => implode(',',$ids)
);
$json = performPost($api_base.'1.1/users/lookup.json',$options, $bearer_token);
return $json;
}
//save the data and retrieve from memcache if we can to speed up operations
$memcache = new Memcache;
$data = $memcache->get("people");
if($data === false){
$data = getTwitterFromAPI();
$memcache->set("people", $data, 86400);
}
$twitterResults = json_decode($data, true);
function getIDLocation($id){
global $ids, $twitterResults;
$count = 0;
foreach($ids as $number){
if($twitterResults[$count]["id"] == $id){
return $count;
}
$count++;
}
}
include 'template-upper.php';
?>
<h1 style='text-align:center;color:#3cf;font-family: HelveticaNeueCondensedBold;'>2017-2018 NA Project Water Teams</h1>
<h5 style='text-align:center;'>Looking for Project Water Administration? Click <a href="https://projectwater.org/team">here</a>.</h5>
<?php
$counter = 0;
$lastDidEnd = false;
foreach($teams as $year=>$yearTeams){
echo "<h2 style='text-align:center;text-decoration:underline'>" . $year . "</h2>";
foreach($yearTeams as $teamName=>$people) {
echo "<h3 style='text-align:center;'>" . $teamName . "</h3>";
foreach($people as $name=>$id){
if($counter == 0){
echo '<div class="row">';
$lastDidEnd = false;
}
$counter++;
echo '<div class="col-md-3 col-xs-6"><div class="thumbnail down"><img src="';
$intTest = (int)$id;
if(gettype($id) == "integer" || $intTest != 0)
echo str_replace("_normal", "", $twitterResults[getIDLocation($id)]["profile_image_url_https"]);
else
echo 'img/team/2017_team/' . $id;
echo '" style="border-radius:5px;"><div style="margin-top:-23px;">';
if(gettype($id) == "integer" || $intTest != 0)
echo '<a href="https://twitter.com/' . $twitterResults[getIDLocation($id)]["screen_name"] . '">' . $name . '</a>';
else
echo $name;
echo "</div></div></div>";
if($counter == 4){
echo '</div>';
$counter = 0;
$lastDidEnd = true;
}
}
if(!$lastDidEnd)
echo '</div>';
$counter = 0;
}
echo "<hr>";
}
echo "<center>Special thanks to <a href='http://www.kayceeorwigphotography.com' target='_blank'>Kaycee Orwig</a> for taking our team pics!</center>";
echo "<center>Check out all of our past years' NA Project Water teams <a href='http://www.naprojectwater.com/allteams'>here!</a></center>";
include 'template-lower.php';
?>