7
7
* READ HERE TO LEARN ABOUT KEYAUTH FUNCTIONS https://github.com/KeyAuth/KeyAuth-PHP-Example#keyauthapp-instance-definition
8
8
*
9
9
*/
10
- error_reporting (0 );
10
+
11
+ /*error_reporting(E_ALL);
12
+ ini_set('display_errors', 1); You can use this code for better error handling - recommended for local testing only*/
11
13
12
14
require '../keyauth.php ' ;
13
15
require '../credentials.php ' ;
14
16
15
- session_start ();
17
+ if (session_status () !== PHP_SESSION_ACTIVE ) {
18
+ session_start ();
19
+ }
16
20
17
21
if (!isset ($ _SESSION ['user_data ' ])) // if user not logged in
18
22
{
@@ -41,11 +45,21 @@ function findSubscription($name, $list)
41
45
$ lastLogin = $ _SESSION ["user_data " ]["lastlogin " ];
42
46
43
47
if (isset ($ _POST ['logout ' ])) {
48
+ $ KeyAuthApp ->logout ();
44
49
session_destroy ();
45
50
header ("Location: ../ " );
46
51
exit ();
47
52
}
53
+
54
+ if (isset ($ _POST ['enable2fa ' ])) {
55
+ $ KeyAuthApp ->enable2fa ($ _POST ['2facode ' ]);
56
+ }
57
+
58
+ if (isset ($ _POST ['disable2fa ' ])) {
59
+ $ KeyAuthApp ->disable2fa ($ _POST ['2facode ' ]);
60
+ }
48
61
?>
62
+ <!DOCTYPE html>
49
63
<html lang="en" class="bg-[#09090d] text-white overflow-x-hidden">
50
64
51
65
<head>
@@ -55,33 +69,72 @@ function findSubscription($name, $list)
55
69
<link rel="stylesheet" href="https://cdn.keyauth.cc/v3/dist/output.css">
56
70
</head>
57
71
58
- <body>
59
- <?php
60
- $ KeyAuthApp ->log ("New login from: " . $ username ); // sends a log to the KeyAuth logs page https://keyauth.cc/app/?page=logs.
61
- ?>
62
-
63
- <form method="post">
72
+ <body class="min-h-screen bg-[#09090d] text-white">
73
+ <div class="container mx-auto px-4">
74
+ <!-- Header -->
75
+ <header class="flex justify-end py-4">
76
+ <form method="post">
64
77
<button
65
- class="inline-flex text-white bg-red-700 hover:opacity-60 focus:ring-0 font-medium rounded-lg text-sm px-5 py-2.5 mb-2 transition duration-200 "
66
- name="logout ">
67
- Logout
78
+ name="logout "
79
+ class="inline-flex text-white bg-red-700 hover:opacity-60 focus:ring-0 font-medium rounded-lg text-sm px-5 py-2.5 transition duration-200 ">
80
+ Logout
68
81
</button>
69
- </form>
70
-
71
- <p class="text-md">Logged in as <?= $ username ; ?> </p>
72
- <p class="text-md">IP <?= $ ip ; ?> </p>
73
- <p class="text-md">Creation Date <?= date ('Y-m-d H:i:s ' , $ creationDate ) ?> </p>
74
- <p class="text-md">Last Login <?= date ('Y-m-d H:i:s ' , $ lastLogin ) ?> </p>
75
- <p class="text-md">Does subscription with name <code
76
- style="background-color: #1a56db;border-radius: 3px;font-family: courier, monospace;padding: 0 3px;">default</code>
77
- exist: <?= ((findSubscription ("default " , $ _SESSION ["user_data " ]["subscriptions " ]) ? 1 : 0 ) ? 'yes ' : 'no ' ); ?>
78
- </p>
79
-
80
- <?php
81
- for ($ i = 0 ; $ i < count ($ subscriptions ); $ i ++) {
82
- echo "# " . $ i + 1 . " Subscription: " . $ subscriptions [$ i ]->subscription . " - Subscription Expires: " . "<script>document.write(convertTimestamp( " . $ subscriptions [$ i ]->expiry . "));</script> " ;
83
- }
84
- ?>
85
- </body>
82
+ </form>
83
+ </header>
84
+
85
+ <!-- Main section for user data -->
86
+ <main class="flex flex-col items-center justify-center py-8">
87
+ <div class="text-center mb-8">
88
+ <p class="text-md"><b>Logged in as:</b> <?= $ username ; ?> </p>
89
+ <p class="text-md">
90
+ <b>IP:</b>
91
+ <span class="inline-block ml-1 filter blur-sm hover:blur-none transition duration-300">
92
+ <?= $ ip ; ?>
93
+ </span>
94
+ </p>
95
+ <p class="text-md"><b>Creation Date:</b> <?= date ('Y-m-d H:i:s ' , $ creationDate ); ?> </p>
96
+ <p class="text-md"><b>Last Login:</b> <?= date ('Y-m-d H:i:s ' , $ lastLogin ); ?> </p>
97
+ <p class="text-md">
98
+ <b>Does subscription with name:</b>
99
+ <code class="bg-blue-800 rounded-md font-mono px-1">default</code>
100
+ exist: <?= ((findSubscription ("default " , $ _SESSION ["user_data " ]["subscriptions " ]) ? 1 : 0 ) ? 'yes ' : 'no ' ); ?>
101
+ </p>
102
+ <?php
103
+ for ($ i = 0 ; $ i < count ($ subscriptions ); $ i ++) {
104
+ echo "<p class='text-md'># " . ($ i +1 ) . " Subscription: " . $ subscriptions [$ i ]->subscription . " - Subscription Expires: <script>document.write(convertTimestamp( " . $ subscriptions [$ i ]->expiry . "));</script></p> " ;
105
+ }
106
+ ?>
107
+ </div>
108
+ </main>
86
109
110
+ <!-- 2FA Section-->
111
+ <section class="max-w-lg mx-auto pb-8">
112
+ <form method="post">
113
+ <div class="relative mb-4">
114
+ <input type="text" id="2facode" name="2facode"
115
+ class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white bg-transparent rounded-lg border border-gray-300 appearance-none focus:ring-0 peer"
116
+ autocomplete="on">
117
+ <label for="2facode"
118
+ class="absolute text-sm text-gray-400 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#09090d] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 left-1">
119
+ 2FA Code
120
+ </label>
121
+ </div>
122
+
123
+ <div class="flex justify-around">
124
+ <button
125
+ name="enable2fa"
126
+ class="inline-flex text-white bg-blue-700 hover:opacity-60 focus:ring-0 font-medium rounded-lg text-sm px-5 py-2.5 transition duration-200">
127
+ Enable 2FA
128
+ </button>
129
+
130
+ <button
131
+ name="disable2fa"
132
+ class="inline-flex text-white bg-red-700 hover:opacity-60 focus:ring-0 font-medium rounded-lg text-sm px-5 py-2.5 transition duration-200 ml-2">
133
+ Disable 2FA
134
+ </button>
135
+ </div>
136
+ </form>
137
+ </section>
138
+ </div>
139
+ </body>
87
140
</html>
0 commit comments