-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest.php
185 lines (143 loc) · 7.65 KB
/
Test.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
<?php
require_once __DIR__ . "/vendor/autoload.php";
use Hasirciogli\ProAuth\Config\DatabaseConfig;
use Hasirciogli\ProAuth\Models\LanguageModel;
use Hasirciogli\SessionWrapper\Session;
use Hasirciogli\ProAuth\Models\HashModel;
if ($_POST) {
$ClientId = $_POST["client_id"] ?? "";
$ClientSecret = $_POST["client_secret"] ?? "";
$RedirectTo = $_POST["redirect_to"] ?? "";
$Lang = $_POST["lang"] ?? "";
$HashTr = $ClientId . $RedirectTo . $ClientSecret;
$Hash = base64_encode(pack("H*", sha1($HashTr)));
$ClientId = urlencode($ClientId);
$RedirectTo = urlencode($RedirectTo);
$Hash = urlencode($Hash);
$Ruri = "http://localhost:1167/proauth0/authenticate?client_id=$ClientId&redirect_to=$RedirectTo&hash=$Hash&lang=$Lang";
}
$AuthorizationToken = $_GET["authorizationtoken"] ?? null;
$StaticImages = "http://public-cdn.hasirciogli.com";
$Phrases = LanguageModel::cfun()->GetLanguagePhrases($_GET["lang"] ?? "tr");
$Session = new Session(DatabaseConfig::cfun());
$CsrfToken = $Session->Get("csrf-token");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio,line-clamp"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"
integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<link rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" />
<title>
<?php echo $Phrases["auth_login_with_sitename"]; ?>
</title>
<script>
tailwind.config = {
darkMode: 'class',
}
</script>
<script>
$(document).ready(() => {
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark')
$("#light_mode_btn")[0].classList.remove("hidden");
} else {
document.documentElement.classList.remove('dark')
$("#dark_mode_btn")[0].classList.remove("hidden");
}
$("#dark_mode_btn").click(() => {
document.documentElement.classList.add('dark')
$("#dark_mode_btn")[0].classList.add("hidden");
$("#light_mode_btn")[0].classList.remove("hidden");
localStorage.theme = "dark";
});
$("#light_mode_btn").click(() => {
document.documentElement.classList.remove('dark')
$("#light_mode_btn")[0].classList.add("hidden");
$("#dark_mode_btn")[0].classList.remove("hidden");
localStorage.theme = "light";
});
});
</script>
<style>
body * {
@apply transition-colors duration-300;
}
</style>
</head>
<body class="bg-gray-200 dark:bg-zinc-800 transition-colors">
<input type="hidden" name="csrf-token" id="csrf-token" value="<?php echo $CsrfToken; ?>">
<div class="absolute flex w-fit h-fit top-0 right-0 z-[10] p-5 transition-colors">
<span id="dark_mode_btn"
class="hidden material-symbols-outlined select-none rounded-md bg-zinc-600 text-white p-[.3rem] hover:cursor-pointer hover:shadow-md shadow-sm shadow-zinc-500 hover:shadow-zinc-400 duration-200 ease-in-out">
dark_mode
</span>
<span id="light_mode_btn"
class="hidden material-symbols-outlined select-none rounded-md bg-zinc-200 text-black p-[.3rem] hover:cursor-pointer hover:shadow-md shadow-sm shadow-zinc-500 hover:shadow-zinc-400 duration-200 ease-in-out">
light_mode
</span>
</div>
<div class="flex w-full h-screen items-center justify-center z-[5] transition-colors">
<div
class="w-full md:w-[26rem] h-fit --min-h-[22rem] text-xs dark:text-zinc-200 bg-white text-zinc-700 dark:bg-[#272829] rounded border dark:border-zinc-600 shadow-md transition-300">
<div class="p-[.3rem] border-b border-b-zinc-300 dark:border-b-zinc-600">
<strong class="dark:text-zinc-300">ProAuth0</strong>
<span class="dark:text-zinc-300">TEST SAYFASI</span>
</div>
<div class="w-full text-center text-2xl font-semibold font-monospace mt-10 transition-colors">
<?php echo $Phrases["auth_welcome_back"]; ?>
</div>
<?php if ($_POST && $Ruri) {
echo "<a href=\"$Ruri\">Authenticate</a>";
} ?>
<script>
$(document).ready(() => {
$("#submit-grant").click(() => {
if (window.confirm("<?php echo $AuthorizationToken ?? "-1"; ?>"))
$.ajax({
url: "http://localhost:1167/proauth0/authorize",
method: "POST",
data: {
authorization_token: "<?php echo $AuthorizationToken ?? "-1"; ?>",
},
success: (res, status) => {
console.log(res);
if (!res.status) {
return alert(res.err);
} else {
alert("SUCC");
}
}
})
});
});
</script>
<form method="post" action="/t" class="flex flex-col w-full h-full gap-4 mt-4 p-4 transition-colors">
<input type="text" placeholder="client_id" name="client_id" id="client_id"
value="63e00a9a600045babdb935d63e00a9a600045b8563e00a9a600045b935d63e00a9a0a9a1b64c"
class="rounded bg-transparent w-full text-sm transition-colors">
<input type="text" placeholder="client_secret" name="client_secret" id="client_secret"
value="63e0063e00a9a600045babdb935d63e00a9a6000063e00a9a600045babdb935d63e00a9a6000"
class="rounded bg-transparent w-full text-sm transition-colors">
<input type="text" placeholder="lang" name="lang" id="lang"
class="rounded bg-transparent w-full text-sm transition-colors" value="tr">
<input type="text" placeholder="redirect_to" name="redirect_to" id="redirect_to"
class="rounded bg-transparent w-full text-sm transition-colors" value="http://localhost:5555/t">
<div class="flex w-full justify-between transition-colors">
<input id="submit-grant" type="button"
class="p-3 py-2 text-white dark:text-zinc-200 font-normal font-arial text-xs bg-zinc-800 dark:bg-zinc-600 hover:bg-blue-600 dark:hover:bg-blue-600 hover:cursor-pointer rounded duration-200 transition-colors"
value="Grant">
<input id="submit-login" type="submit"
class="p-3 py-2 text-white dark:text-zinc-200 font-normal font-arial text-xs bg-zinc-800 dark:bg-zinc-600 hover:bg-blue-600 dark:hover:bg-blue-600 hover:cursor-pointer rounded duration-200 transition-colors"
value="<?php echo $Phrases["auth_submit_value_1"]; ?>">
</div>
</form>
</div>
</div>
</body>
</html>