-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindiv_proj.php
92 lines (80 loc) · 2.92 KB
/
indiv_proj.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Project Details</title>
<link rel="stylesheet" href="./indiv_proj.css">
</head>
<body>
<?php
require_once('header.php');
?>
<div class="wrapper">
<div class="compcontainer">
<?php
if (isset($_GET['repo'])) {
$repoName = $_GET['repo'];
$repoUrl = "https://api.github.com/repos/OpenLake/$repoName";
$contributorsUrl = "https://api.github.com/repos/OpenLake/$repoName/contributors";
$apiKey = "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";
// Fetch repository details
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $repoUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: token {$apiKey}",
"User-Agent: My-App",
]);
$repoResponse = curl_exec($ch);
$repoHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// Fetch contributors
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $contributorsUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: token {$apiKey}",
"User-Agent: My-App",
]);
$contributorsResponse = curl_exec($ch);
$contributorsHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($repoHttpCode === 200 && $contributorsHttpCode === 200) {
$repoDetails = json_decode($repoResponse, true);
$contributors = json_decode($contributorsResponse, true);
// Display repository details
echo '<h1 class="repo-name">' . $repoDetails['name'] . '</h1>';
echo '<br>';
echo '<p class="repo-description">' . $repoDetails['description'] . '</p>';
echo '<p class="repo-description">URL: <a href="' . $repoDetails['html_url'] . '">' . $repoDetails['html_url'] . '</a></p>';
echo '<br>';
// Display contributors
echo '<h2 class="contributors-title">Contributors:</h2>';
if (!empty($contributors)) {
echo '<ul class="contributors-list">';
foreach ($contributors as $contributor) {
echo '<li class="contributor">';
echo 'Name: <span class="contributor-name">' . $contributor['login'] . '</span><br>';
echo 'URL: <a class="contributor-url" href="' . $contributor['html_url'] . '">' . $contributor['html_url'] . '</a>';
echo '</li>';
}
echo '</ul>';
} else {
echo '<p class="no-contributors">No contributors found.</p>';
}
} else {
echo '<p class="error-message">Failed to fetch repository details. Error: ' . $repoHttpCode . '</p>';
}
} else {
echo '<p class="error-message">No repository specified.</p>';
}
?>
</div>
</div>
<br><br><br>
<?php
require_once('footer.php');
?>
</body>
</html>