-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
120 lines (105 loc) · 3.69 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
<?php
error_reporting(0);
include 'authspire.php';
include 'details.php';
if (isset($_SESSION['user_username']))
{
header("Location: /main.php");
exit();
}
$authSpireAPI = new authSpire\api($app_name, $userid, $secret, $currentVersion, $publicKey);
if(!$_SESSION['initialized'])
{
$authSpireAPI->init();
}
?>
<html>
<head>
<title>AuthSpire API example</title>
<link rel="stylesheet" href="https://authspire.com/style/style.css" type="text/css">
<link rel="icon" type="image/x-icon" href="../images/logofav.ico">
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="sweetalert2.all.min.js"></script>
</head>
<body id="bodyLogin">
<div id="box-register" style="height:700px;">
<form id="form-login" method="post">
<h2>AuthSpire PHP</h2>
<div id="inputBox">
<input maxlength="256" type="text" id="username" name="username" onkeyup='saveValue(this);'>
<span>Username</span>
<i></i>
</div>
<div id="inputBox">
<input maxlength="256" type="password" name="password">
<span>Password</span>
<i></i>
</div>
<div id="inputBox">
<input maxlength="256" type="text" name="license">
<span>License</span>
<i></i>
</div>
<div id="inputBox">
<input maxlength="256" type="text" name="email">
<span>Email</span>
<i></i>
</div>
<br>
<button style="height:50px; background:#5c5c8a; border:#5c5c8a; color:#FFF;" name="register" maxlength="256">
<span>Register</span>
</button>
<br>
<button style="height:50px; background:#5c5c8a; border:#5c5c8a; color:#FFF;" name="login" maxlength="256">
<span>Login</span>
</button>
<br>
<button style="height:50px; background:#5c5c8a; border:#5c5c8a; color:#FFF;" name="license_only" maxlength="256">
<span>License</span>
</button>
</div>
</div>
</div>
<?php
if (isset($_POST['login'])) {
// login with username and password
if($authSpireAPI->login($_POST['username'], $_POST['password'])) {
echo "<meta http-equiv='Refresh' Content='2; url=main.php'>";
echo '<script type="text/JavaScript">
Swal.fire({
title: "Login successful!",
icon: "success",
timer: 5000,
})
</script>';
}
}
if (isset($_POST['register'])) {
// register using username, password, license and email
if($authSpireAPI->register($_POST['username'], $_POST['password'], $_POST['license'], $_POST['email'])) {
echo "<meta http-equiv='Refresh' Content='2; url=main.php'>";
echo '<script type="text/JavaScript">
Swal.fire({
title: "Account registered!",
icon: "success",
timer: 5000,
})
</script>';
}
}
if (isset($_POST['license_only'])) {
// register using username, password, license and email
if($authSpireAPI->license($_POST['license'])) {
echo "<meta http-equiv='Refresh' Content='2; url=main.php'>";
echo '<script type="text/JavaScript">
Swal.fire({
title: "Login successful!",
icon: "success",
timer: 5000,
})
</script>';
}
}
?>
</body>
</html>