-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
111 lines (98 loc) · 3.58 KB
/
index.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
session_start();
include 'php/config.php';
// Fetch NBA articles
$apiHost = 'nba-latest-news.p.rapidapi.com';
$apiKey = '049f002b9cmsh19ee321223a76dfp1a96e8jsn2efebdd5f8cf';
$articles = [];
try {
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://$apiHost/articles",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"x-rapidapi-host: $apiHost",
"x-rapidapi-key: $apiKey"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
throw new Exception("cURL Error: $err");
}
$articles = json_decode($response, true);
} catch (Exception $e) {
error_log($e->getMessage());
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WinShare</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" href="./assets/MainPage.css">
<link rel="stylesheet" href="./assets/navbar.css">
<link rel="stylesheet" href="./assets/miniLeaderboard.css">
<script type="module" src="./assets/MainPage.js" defer></script>
<script type="module" src="./assets/miniLeaderboard.js" defer></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</head>
<body>
<?php include 'php/header.php'; ?>
<?php if (isset($_SESSION['user_id'])): ?>
<div class="alert alert-success" role="alert">
Welcome, <?= $_SESSION['username']; ?>!
</div>
<?php endif; ?>
<div id="Page">
<div id="LeftColumn">
<h3><a href="./Leaderboard/leaderboard.php">Top Players Leaderboard</a></h3>
<table id="miniLeaderboard">
<tbody>
</tbody>
</table>
<div class="image-container-left">
<img src="./assets/Photos/Harden.png" alt="Basketball Image Harden" class="background-image-left">
</div>
</div>
<div id="MiddleColumn">
<h3>NBA Matches - <?php echo date('F j, Y'); ?></h3>
<div id="Upcoming_Matches">
<h4>Upcoming/In Progress Matches</h4>
</div>
<div class="divider">Played Games</div>
<div id="Recent_Results">
<h4>Recent Results</h4>
</div>
</div>
<div id="RightColumn">
<h3>Latest News Articles</h3>
<?php if (!empty($articles)) : ?>
<ul id="newsList">
<?php foreach (array_slice($articles, 0, 3) as $article) : ?>
<li>
<a href="<?= htmlspecialchars($article['url']) ?>" target="_blank">
<?= htmlspecialchars($article['title']) ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php else : ?>
<p>No articles available at the moment.</p>
<?php endif; ?>
<div class="image-container">
<img src="./assets/Photos/MainPageBron.png" alt="Basketball Image" class="background-image">
</div>
</div>
</body>
</html>
<script>
function navigateToTeamPage(teamName, teamId) {
window.location.href = `Team/Team.php?teamName=${teamName}&id=${teamId}`;
}
</script>
</body>
</html>