-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.php
More file actions
101 lines (95 loc) · 3.74 KB
/
dashboard.php
File metadata and controls
101 lines (95 loc) · 3.74 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
<?php
require_once 'includes/auth.php';
require_once 'includes/database.php';
require_once 'includes/repository.php';
// Initialize database if needed
initDatabase();
// Handle login/register/logout
if (isset($_POST['action'])) {
switch ($_POST['action']) {
case 'login':
if (login($_POST['username'], $_POST['password'])) {
header('Location: dashboard.php');
exit;
}
$error = "Invalid login credentials";
break;
case 'register':
if (register($_POST['username'], $_POST['password'])) {
header('Location: dashboard.php?msg=registered');
exit;
}
$error = "Registration failed";
break;
case 'logout':
logout();
header('Location: dashboard.php');
exit;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>GitPlace</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<?php include 'includes/header.php'; ?>
<?php if (!isLoggedIn()): ?>
You are not supposed to be here lmao.
<?php else: ?>
<div class="repository-list">
<h1>Your Repositories</h1>
<form action="new_repo.php" method="get" style="padding-bottom: 24px;">
<button type="submit" class="btn-primary">New Repository</button>
</form>
<?php
$userRepos = listUserRepositories($_SESSION['user_id'], $_SESSION['username']);
if (empty($userRepos)): ?>
<p>You don't have any repositories yet.</p>
<?php else: ?>
<div class="grid-container">
<?php foreach ($userRepos as $repo): ?>
<div class="repo-card">
<a href="files.php?repo=<?php echo urlencode($repo['name']); ?>">
<?php echo htmlspecialchars($repo['name']); ?>
</a>
<?php if ($repo['description']): ?>
<p class="repo-description">
<?php echo htmlspecialchars($repo['description']); ?>
</p>
<?php endif; ?>
<span class="repo-visibility <?php echo $repo['is_public'] ? '' : 'private'; ?>">
<?php echo $repo['is_public'] ? 'Public' : 'Private'; ?>
</span>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<!-- <h1>Public Repositories</h1>
<?php
$publicRepos = listPublicRepositories();
if (empty($publicRepos)): ?>
<p>No public repositories available.</p>
<?php else: ?>
<ul>
<?php foreach ($publicRepos as $repo): ?>
<li class="repo-card">
<a href="files.php?user=<?php echo urlencode($repo['username']); ?>&repo=<?php echo urlencode($repo['name']); ?>">
<?php echo htmlspecialchars($repo['username'] . '/' . $repo['name']); ?>
</a>
<?php if ($repo['description']): ?>
<p class="repo-description">
<?php echo htmlspecialchars($repo['description']); ?>
</p>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?> -->
</div>
<?php endif; ?>
</body>
</html>