-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
658 lines (564 loc) · 16.4 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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
<?php
$servername = "localhost";
$username = "root";
$password = "";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Create database
$sql = "CREATE DATABASE IF NOT EXISTS githuboauth;";
if ($conn->query($sql) === TRUE) {
echo "";
} else {
echo "Error creating database: " . $conn->error;
}
$conn->close();
?>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "githuboauth";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// sql to create table
$sql = "CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`oauth_provider` enum('github','facebook','google','twitter') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'github',
`oauth_uid` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`username` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`location` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`picture` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`link` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`created` datetime NOT NULL DEFAULT current_timestamp(),
`modified` datetime NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`)
)";
if ($conn->query($sql) === TRUE) {
echo "";
} else {
echo "Error creating table: " . $conn->error;
}
$conn->close();
?>
<?php
session_start();
// Include configuration file
require_once 'config.php';
// Include and initialize user class
require_once 'User.class.php';
$user = new User();
$output = "";
if (isset($accessToken)) {
// Get the user profile data from Github
$gitUser = $gitClient->getAuthenticatedUser($accessToken);
if (!empty($gitUser)) {
// Getting user profile details
$gitUserData = array();
$gitUserData['oauth_uid'] = !empty($gitUser->id) ? $gitUser->id : '';
$gitUserData['name'] = !empty($gitUser->name) ? $gitUser->name : '';
$gitUserData['username'] = !empty($gitUser->login) ? $gitUser->login : '';
$gitUserData['email'] = !empty($gitUser->email) ? $gitUser->email : '';
$gitUserData['location'] = !empty($gitUser->location) ? $gitUser->location : '';
$gitUserData['picture'] = !empty($gitUser->avatar_url) ? $gitUser->avatar_url : '';
$gitUserData['link'] = !empty($gitUser->html_url) ? $gitUser->html_url : '';
// Insert or update user data to the database
$gitUserData['oauth_provider'] = 'github';
$userData = $user->checkUser($gitUserData);
// Storing user data in the session
$_SESSION['userData'] = $userData;
// Render Github profile data
$GLOBALS['output'] .= '<div class="total"
style=" background : rgb(27,27,27);"><div class="Heading"><h2><h1 class="git" style="font-size: 45px;color: #F2AA4CFF;font-weight: 150;">GitHub</h1> <h2 class="git2">Account Details</h2></h2></div>';
$GLOBALS['output'] .= '<div class="ac-data">';
$GLOBALS['output'] .= '<div class="wrapperxx"><div class="img1" style=" margin-right: 10%;
border: 2px solid crimson;
border-radius: 100%;"><img src="' . $userData['picture'] . '" height=200 width=200 class="profileimg" ></div><div class="containerxx"
style=" border: 2px solid crimson;
width: 35%;
margin: 50px;
border-radius: 7px;
height: 50%;
color:white;
padding:10px;
padding-bottom:30px;
background: rgb(25, 24, 24);
font-size: 25px;">';
$GLOBALS['output'] .= '<div class="box"><p><b>ID:</b> ' . $userData['oauth_uid'] . '</p></div>';
$GLOBALS['output'] .= '<div class="box"><p><b>Name:</b> ' . $userData['name'] . '</p></div>';
$GLOBALS['output'] .= '<div class="box"><p><b>Login Username:</b> ' . $userData['username'] . '</p></div>';
$GLOBALS['output'] .= '<div class="box"><p><b>Email:</b> ' . $userData['email'] . '</p></div>';
$GLOBALS['output'] .= '<div class="box"><p><b>Location:</b> ' . $userData['location'] . '</p></div></div></div>';
$GLOBALS['output'] .= '<div class="Shellstyle"><p><b>Profile Link:</b><button class="bottombtn" style=" margin: 3px;
padding: 3px;
border: 2px solid crimson;
color: white;
text-decoration: none;
background: crimson;
border-radius: 7px;
margin-left: 10px;"> <a href="' . $userData['link'] . '" target="_blank">Click to visit</a></p></div>';
$GLOBALS['output'] .= '<div class="Shellstyle"><p>Proceed to Gists <button class="bottombtn" style=" margin: 3px;
padding: 3px;
border: 2px solid crimson;
color: white;
text-decoration: none;
background: crimson;
border-radius: 7px;
margin-left: 10px;"><a href="shell.php">Gists</a></p></button></div>';
$GLOBALS['output'] .= '<div class="Shellstyle"><p>Logout from Github<button class="bottombtn" style=" margin: 3px;
padding: 3px;
border: 2px solid crimson;
color: white;
text-decoration: none;
background: crimson;
border-radius: 7px;
margin-left: 10px;"> <a href="logout.php">LogOut</a></p></button></div></div>';
$GLOBALS['output'] .= '</div><div class="last-container">
<ul>
<li><a href="https://instagram.com/festeve360?igshid=YmMyMTA2M2Y=" target="_blank"><i
class="fa-brands fa-instagram all-icons"></i></a></li>
<li><a href="mailto:shivesh.pandey0409@gmail.com" target="_blank"><i class="fa-solid fa-envelope all-icons"></i></a></li>
<li><a href="https://www.twitter.com/festeve360" target="_blank"><i class="fa-brands fa-twitter-square all-icons"></i></a></li>
</ul>
<script src="tsparticles.engine.min.js"></script>
<footer class="center">
Copyright ©www.CodeSpace.com. All rights reserved
</footer>
</div>';
$_SESSION['output'] = $GLOBALS['output'];
} else {
$GLOBALS['output'] = '<h3 style="color:crimson">Something went wrong, please try again!</h3>';
$_SESSION['output'] = $GLOBALS['output'];
}
} elseif (isset($_GET['code'])) {
// Verify the state matches the stored state
if (!$_GET['state'] || $_SESSION['state'] != $_GET['state']) {
header("Location: " . $_SERVER['PHP_SELF']);
}
// Exchange the auth code for a token
$accessToken = $gitClient->getAccessToken($_GET['state'], $_GET['code']);
header("Location: " . $_SERVER['PHP_SELF']);
$_SESSION['access_token'] = $accessToken;
// header('Location: ./');
} else {
// Generate a random hash and store in the session for security
$_SESSION['state'] = hash('sha256', microtime(true) . rand() . $_SERVER['REMOTE_ADDR']);
// Remove access token from the session
unset($_SESSION['access_token']);
// Get the URL to authorize
$authUrl = $gitClient->getAuthorizeURL($_SESSION['state']);
// Render Github login button
$GLOBALS['output'] = '<a href="' . htmlspecialchars($authUrl) . '"><div class="loginGit">Login</div></a>';
}
function getOutput()
{
return $GLOBALS['output'];
}
?>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Code Space</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" />
<script src="https://kit.fontawesome.com/5d50a14114.js" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tsparticles/2.5.1/tsparticles.min.js"
integrity="sha512-+YPbXItNhUCZR3fn5KeWPtJrXuoqRYQ4Gd1rIjEFG+h8UJYekebhOMh84vv7q+Y1sy5kdIIVtfftehCiigriMQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/typed.js/2.0.11/typed.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.1/jquery.waypoints.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"></script>
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css" />
</head>
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&family=Ubuntu:wght@400;500;700&display=swap');
/* CSS */
.button-24 {
background: #FF4742;
border: 1px solid #FF4742;
border-radius: 6px;
box-shadow: rgba(0, 0, 0, 0.1) 1px 2px 4px;
box-sizing: border-box;
color: #FFFFFF;
cursor: pointer;
display: inline-block;
font-family: nunito,roboto,proxima-nova,"proxima nova",sans-serif;
font-size: 16px;
font-weight: 800;
line-height: 16px;
min-height: 40px;
outline: 0;
padding: 12px 14px;
text-align: center;
text-rendering: geometricprecision;
text-transform: none;
user-select: none;
-webkit-user-select: none;
touch-action: manipulation;
vertical-align: middle;
}
.button-24:hover,
.button-24:active {
background-color: initial;
background-position: 0 0;
color: #FF4742;
}
.button-24:active {
opacity: .5;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
text-decoration: none;
}
html {
scroll-behavior: smooth;
}
img.profileimg {
border-radius: 100%;
}
/* all similar content styling codes */
section {
padding: 100px 0;
}
.max-width {
max-width: 1300px;
padding: 0 80px;
margin: auto;
}
.about,
.services,
.skills,
.teams,
.contact,
footer {
font-family: 'Poppins', sans-serif;
}
.about .about-content,
.services .serv-content,
.skills .skills-content,
.contact .contact-content {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
}
section .title {
position: relative;
text-align: center;
font-size: 40px;
font-weight: 500;
margin-bottom: 60px;
padding-bottom: 20px;
font-family: 'Ubuntu', sans-serif;
}
section .title::before {
content: "";
position: absolute;
bottom: 0px;
left: 50%;
width: 180px;
height: 3px;
background: #111;
transform: translateX(-50%);
}
section .title::after {
position: absolute;
bottom: -8px;
left: 50%;
font-size: 20px;
color: crimson;
padding: 0 5px;
background: #fff;
transform: translateX(-50%);
}
.loginGit {
z-index: 1000;
text-decoration: none;
font-family: "Ubuntu";
color: crimson;
font-size: 35px;
font-weight: 600;
position: absolute;
top: 3%;
right: 4%;
}
.loginGit:hover {
color: white;
}
/* navbar styling */
.navbar {
position: fixed;
width: 100%;
z-index: 999;
padding: 30px 0;
font-family: 'Ubuntu', sans-serif;
transition: all 0.3s ease;
}
.navbar.sticky {
padding: 15px 0;
background: crimson;
}
.navbar .max-width {
display: flex;
align-items: center;
justify-content: space-between;
}
.navbar .logo a {
color: #fff;
font-size: 35px;
font-weight: 600;
}
.navbar .logo a span {
color: crimson;
transition: all 0.3s ease;
}
.navbar.sticky .logo a span {
color: #fff;
}
.navbar .menu li {
list-style: none;
display: inline-block;
}
.navbar .menu li a {
display: block;
color: #fff;
font-size: 18px;
font-weight: 500;
margin-left: 25px;
transition: color 0.3s ease;
}
.navbar .menu li a:hover {
color: crimson;
}
.navbar.sticky .menu li a:hover {
color: #fff;
}
/* menu btn styling */
.menu-btn {
color: #fff;
font-size: 23px;
cursor: pointer;
display: none;
}
.scroll-up-btn {
position: fixed;
height: 45px;
width: 42px;
background: crimson;
right: 30px;
bottom: 10px;
text-align: center;
line-height: 45px;
color: #fff;
z-index: 9999;
font-size: 30px;
border-radius: 6px;
border-bottom-width: 2px;
cursor: pointer;
opacity: 0;
pointer-events: none;
transition: all 0.3s ease;
}
/* home section styling */
.home {
display: flex;
background: url("images/banner.jpg") no-repeat center;
height: 100vh;
color: rgb(255, 255, 255);
min-height: 500px;
background-size: cover;
background-attachment: fixed;
font-family: 'Ubuntu', sans-serif;
}
.home .max-width {
width: 100%;
display: flex;
}
.home .max-width .row {
margin-right: 0;
}
.home .home-content .text-1 {
font-size: 30px;
}
.home .home-content .text-1 span {
color: crimson;
font-weight: 500;
}
.home .home-content .text-2 {
font-size: 75px;
font-weight: 600;
margin-left: -3px;
}
.home .home-content .text-3 {
font-size: 40px;
margin: 5px 0;
}
.home .home-content .text-3 span {
color: crimson;
font-weight: 500;
}
.home .home-content a {
display: inline-block;
background: crimson;
color: #fff;
font-size: 25px;
padding: 12px 36px;
margin-top: 20px;
font-weight: 400;
border-radius: 6px;
border: 2px solid crimson;
transition: all 0.3s ease;
}
.home .home-content a:hover {
color: crimson;
background: none;
}
.Heading {
color: rgb(228, 76, 76);
text-align: center;
padding: 5px;
}
.Shellstyle {
color: white;
text-align: center;
margin-top: 5px;
font-weight: 100;
font-size: 20px;
}
.bottombtn {
margin-left: 3px;
padding: 2px;
color: rgb(232, 159, 159);
}
.bottombtn:hover {
color: crimson;
}
.img1 {
border-radius: 10%;
}
.box {
margin-left: 30%;
margin-top: 5px;
font-weight: 50;
margin-bottom: 5px;
}
.wrapperxx {
display: flex;
flex-direction: row;
margin: auto;
align-items: center;
margin-left: auto;
justify-content: center;
}
.total {
/* background-color: rgb(205, 212, 219); */
background: url("images/banner2.jpg") no-repeat center;
height: 75%;
}
footer {
/* background: black; */
color: white;
padding: 9px 20px;
}
.last-container {
background-color: black;
}
.last-container ul {
display: flex;
justify-content: center;
align-items: center;
}
.all-icons {
font-size: 2rem;
padding: 5px 50px;
filter: invert(50%);
transition: .2s;
}
.all-icons:hover {
font-size: 2.5rem;
filter: invert(100%);
}
.center {
text-align: center;
}
.git {
font-size: 30px;
color: black;
font-weight: 150;
}
.git2 {
font-size: 15px;
font-weight: 700;
}
</style>
<body>
<div class="scroll-up-btn">
<i class="fas fa-angle-up"></i>
</div>
<nav class="navbar">
<div class="max-width">
<div class="logo"><a href="#">Code<span>Space</span></a></div>
<!-- <ul class="menu">
<?php
echo '<li><a href="' . htmlspecialchars($authUrl) . '" class="menu-btn">Log-in</a></li>';
?>
</ul> -->
<div class="menu-btn">
<i class="fas fa-bars"></i>
</div>
</div>
</nav>
<!-- home section start -->
<section class="home" id="home">
<div class="max-width">
<div class="home-content">
<div class="text-1">Hello, <span class="typing"></span> </div>
<div class="text-2">Welcome to Coding space </div>
<div class="text-3">Here you can <span class="typing1"></span> </div>
</div>
</div>
</section>
<div>
<!-- Display login button / GitHub profile information -->
<?php echo getOutput(); ?>
</div>
</body>
<script>
$(document).ready(function() {
$(window).scroll(function() {
// sticky navbar on scroll script
if (this.scrollY > 20) {
$('.navbar').addClass("sticky");
} else {
$('.navbar').removeClass("sticky");
}
});
var typed = new Typed(".typing", {
strings: ["Welcome to Code Space", "Start You Journey Here"],
typeSpeed: 100,
backSpeed: 60,
loop: true
});
var typed = new Typed(".typing1", {
strings: ["Convert Ideas To Reality", "Test Your Thoughts"],
typeSpeed: 100,
backSpeed: 62,
loop: true
});
});
</script>
</html>