1+ <?php
2+ require_once "head.php " ;
3+ require_once "pdo.php " ;
4+ /*
5+ if (isset($_SESSION['email'])) {
6+ $stmt = $pdo->query("SELECT * FROM account");
7+ $accounts = $stmt->fetchAll(PDO::FETCH_ASSOC);
8+
9+ $stmt = $pdo->prepare("SELECT * FROM account WHERE user_id=?");
10+ $stmt->execute([$_SESSION['user_id']]);
11+ $user = $stmt->fetchAll(PDO::FETCH_ASSOC);
12+
13+ $stmt = $pdo->prepare("SELECT * FROM user_status_log where user_Id = :usr");
14+ $stmt->execute(array(':usr' => $_SESSION['user_id']));
15+ $user_status_log = $stmt->fetch();
16+
17+
18+ if ($user[0]['pfp'] != null) {
19+ $userpfp = $user[0]['pfp'];
20+ } else {
21+ $userpfp = $pfpsrc_default;
22+ }
23+
24+ if ($user_status_log != null) {
25+ $stmt = $pdo->prepare("UPDATE user_status_log SET account=?, last_active_date_time=? WHERE user_id=?");
26+ $stmt->execute([$_SESSION['name'], date(DATE_RFC2822), $_SESSION['user_id']]);
27+ } else {
28+ $stmt = $pdo->prepare('INSERT INTO user_status_log (user_id, account, last_active_date_time) VALUES (:usr, :acc, :date)');
29+ $stmt->execute(
30+ array(
31+ ':usr' => $_SESSION['user_id'],
32+ ':acc' => $_SESSION['name'],
33+ ':date' => date(DATE_RFC2822)
34+ )
35+ );
36+ }
37+ }*/
38+ $ stmt = $ pdo ->query ("SELECT * FROM account " );
39+ $ accounts = $ stmt ->fetchAll (PDO ::FETCH_ASSOC );
40+ $ pfpsrc_default = './assets/images/default-user-square.png ' ;
41+ ?>
42+ <!DOCTYPE html>
43+ <html lang="en">
44+
45+ <head>
46+ <title>G4o2 Chat</title>
47+ </head>
48+
49+ <body>
50+ <nav class="navbar navbar-expand-lg bg-dark" data-bs-theme="dark">
51+ <div class="container-fluid">
52+ <a class="navbar-brand" href="#">
53+ <img src="./assets/images/g4o2.jpeg" alt="Logo" width="24" height="24" class="d-inline-block align-text-top">
54+ G4o2 Chat
55+ </a>
56+ <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
57+ <span class="navbar-toggler-icon"></span>
58+ </button>
59+ <div class="collapse navbar-collapse" id="navbarSupportedContent">
60+ <ul class="navbar-nav me-auto mb-2 mb-lg-0">
61+ <li class="nav-item">
62+ <a class="nav-link active" aria-current="page" href="./index.php">Home</a>
63+ </li>
64+ <li class="nav-item">
65+ <a class="nav-link" href="https://github.com/g4o2" target="_blank">Github</a>
66+ </li>
67+ <li class="nav-item dropdown">
68+ <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
69+ Dropdown
70+ </a>
71+ <ul class="dropdown-menu">
72+ <li><a class="dropdown-item" href="#">Action</a></li>
73+ <li><a class="dropdown-item" href="#">Another action</a></li>
74+ <li>
75+ <hr class="dropdown-divider">
76+ </li>
77+ <li><a class="dropdown-item" href="#">Something else here</a></li>
78+ </ul>
79+ </li>
80+ <li class="nav-item">
81+ <a class="nav-link disabled">Account</a>
82+ </li>
83+ </ul>
84+ <a class="btn btn-outline-success" href="./login.php">Login</a>
85+ </div>
86+ </div>
87+ </nav>
88+ <main>
89+ <?php
90+ echo '
91+ <table class="table">
92+ <thead>
93+ <tr>
94+ <th scope="col">#</th>
95+ <th scope="col">Name</th>
96+ <th scope="col">Email</th>
97+ <th scope="col">Last active</th>
98+ </tr>
99+ </thead><tbody> ' ;
100+ foreach ($ accounts as $ account ) {
101+ if ($ account ['pfp ' ] != null ) {
102+ $ pfpsrc = $ account ['pfp ' ];
103+ } else {
104+ $ pfpsrc = $ pfpsrc_default ;
105+ }
106+
107+ $ pfp = "<a class='pfp-link' href='./profile.php?user= {$ account ['user_id ' ]}'><img style='border-radius: 100px; margin-left: 10px; ' height='20px' width='20px' src=' $ pfpsrc'></a> " ;
108+
109+ $ statement = $ pdo ->prepare ("SELECT * FROM user_status_log where user_Id = :usr " );
110+ $ statement ->execute (array (':usr ' => $ account ['user_id ' ]));
111+ $ user_status_log = $ statement ->fetch ();
112+
113+ $ userStatus = "Undefined " ;
114+ if ($ user_status_log != null ) {
115+ $ userStatus = $ user_status_log ['last_active_date_time ' ];
116+ }
117+
118+
119+ if ($ userStatus === "Undefined " ) {
120+ $ diff = "<p class='text-danger'>Null</p> " ;
121+ } else {
122+ $ last_online = $ userStatus ;
123+ $ current_date_time = date (DATE_RFC2822 );
124+ $ last_online = new DateTime ($ last_online );
125+ $ current_date_time = new DateTime ($ current_date_time );
126+
127+ $ diff = $ current_date_time ->diff ($ last_online )->format ("last online %a days %h hours and %i minutes ago " );
128+ $ exploded = explode (" " , $ diff );
129+
130+ if ($ exploded [2 ] == "1 " ) {
131+ $ diff = "<p class='text-warning'> $ exploded [2 ] day ago</p> " ;
132+ } elseif ($ exploded [4 ] == "1 " ) {
133+ $ diff = "<p class='text-warning''> $ exploded [4 ] hour ago</p> " ;
134+ } elseif ($ exploded [7 ] == "1 " ) {
135+ $ diff = "<p class='text-warning''> $ exploded [7 ] minute ago</p> " ;
136+ } elseif ($ exploded [2 ] !== "0 " ) {
137+ $ diff = "<p class='text-warning''> $ exploded [2 ] days ago</p> " ;
138+ } elseif ($ exploded [4 ] !== "0 " ) {
139+ $ diff = "<p class='text-warning''> $ exploded [4 ] hours ago</p> " ;
140+ } elseif ($ exploded [7 ] !== "0 " ) {
141+ $ diff = "<p class='text-warning''> $ exploded [7 ] minutes ago</p> " ;
142+ } else {
143+ $ diff = "<p class='text-success'>Online</p> " ;
144+ }
145+ }
146+ echo "<tr><th scope='row'> " ;
147+ echo ($ account ['user_id ' ]);
148+ echo $ pfp ;
149+ echo ("</th><td> " );
150+ echo "<a href='./profile.php?user= {$ account ['user_id ' ]}' > " . $ account ['name ' ] . "</a> " ;
151+ echo "<td> " ;
152+ if ($ account ['show_email ' ] === "True " ) {
153+ echo ($ account ['email ' ]);
154+ } else {
155+ echo "<p class='text-warning'>Hidden</p> " ;
156+ }
157+ echo ("</td><td> " );
158+ echo $ diff ;
159+ echo ("</td></tr> \n" );
160+ echo ("</td></tr> \n" );
161+ }
162+ echo "<tbody></table> " ;
163+
164+ ?>
165+ </main>
166+ <footer class="text-center text-lg-start bg-light text-muted">
167+ <section class="d-flex justify-content-center justify-content-lg-between p-4 border-bottom">
168+ <div class="me-5 d-none d-lg-block">
169+ <!-- <span>Get connected with us on social networks:</span> -->
170+ <span>Footer</span>
171+ </div>
172+ <div>
173+ <a href="#" class="me-4 text-reset text-decoration-none" target="_blank">
174+ <i class="fab fa-facebook-f"></i>
175+ </a>
176+ <a href="#" class="me-4 text-reset text-decoration-none" target="_blank">
177+ <i class="fab fa-twitter"></i>
178+ </a>
179+ <a href="#" class="me-4 text-reset text-decoration-none" target="_blank">
180+ <i class="fab fa-google"></i>
181+ </a>
182+ <a href="#" class="me-4 text-reset text-decoration-none" target="_blank">
183+ <i class="fab fa-instagram"></i>
184+ </a>
185+ <a href="#" class="me-4 text-reset text-decoration-none" target="_blank">
186+ <i class="fab fa-linkedin"></i>
187+ </a>
188+ <a href="#" class="me-4 text-reset text-decoration-none" target="_blank">
189+ <i class="fab fa-github"></i>
190+ </a>
191+ </div>
192+ </section>
193+ <section class="">
194+ <div class="container text-center text-md-start mt-5">
195+ <div class="row mt-3">
196+ <div class="col-md-3 col-lg-4 col-xl-3 mx-auto mb-4">
197+ <h6 class="text-uppercase fw-bold mb-4">
198+ <i class="fas fa-gem me-3"></i>g4o2 chat
199+ </h6>
200+ <p>
201+ Development of this chat began on 2022/8/23, as a side project of <a href="https://github.com/Maxhu787" target="_blank">g4o2</a>, and has been constantly updated with new and exciting features ever since.
202+ With about 50 users and some contributors that helped with the testing of this chat.
203+
204+ </p>
205+ </div>
206+ <div class="col-md-2 col-lg-2 col-xl-2 mx-auto mb-4">
207+ <h6 class="text-uppercase fw-bold mb-4">
208+ pages
209+ </h6>
210+ <p>
211+ <a href="#" class="text-reset">Home</a>
212+ </p>
213+ <p>
214+ <a href="#" class="text-reset">Chat</a>
215+ </p>
216+ <p>
217+ <a href="#" class="text-reset">Users</a>
218+ </p>
219+ <p>
220+ <a href="#" class="text-reset">Profile</a>
221+ </p>
222+ </div>
223+ <div class="col-md-3 col-lg-2 col-xl-2 mx-auto mb-4">
224+ <h6 class="text-uppercase fw-bold mb-4">
225+ links
226+ </h6>
227+ <p>
228+ <a href="./terms-of-service.php" class="text-reset">Terms of Service</a>
229+ </p>
230+ <p>
231+ <a href="./privacy-policy.php" class="text-reset">Privacy</a>
232+ </p>
233+ <p>
234+ <a href="#" class="text-reset">Settings</a>
235+ </p>
236+ <p>
237+ <a href="#" class="text-reset">Help</a>
238+ </p>
239+ </div>
240+ <div class="col-md-4 col-lg-3 col-xl-3 mx-auto mb-md-0 mb-4">
241+ <h6 class="text-uppercase fw-bold mb-4">Contact</h6>
242+ <!-- <p><i class="fas fa-home me-3"></i> New York, NY 10012, US</p> -->
243+ <p><i class="fas fa-envelope me-3"></i>Maxhu787@gmail.com</p>
244+ <p><i class="fas fa-envelope me-3"></i>g4o2@protonmail.com</p>
245+ <p><i class="fas fa-envelope me-3"></i>g4o3@protonmail.com</p>
246+ <p><i class="fas fa-print me-3"></i> + 01 234 456 89</p>
247+ </div>
248+ </div>
249+ </div>
250+ </section>
251+ <div class="text-center p-4" style="background-color: rgba(0, 0, 0, 0.05);">
252+ © <?= date ("Y " ) ?> Copyright g4o2. All rights reserved.
253+ </div>
254+ </body>
255+
256+ </html>
0 commit comments