-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
83 lines (69 loc) · 2.67 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
<!DOCTYPE HTML>
<html>
<head>
<title>Safe url checker</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="assets/css/main.css" />
</head>
<body class="is-preload">
<!-- Header -->
<header id="header">
<h1>Safe url checker</h1>
<p>A url checker powered by <a href="https://api-aries.online">API Aries</a>.</p>
</header>
<form id="signup-form" method="post" action="api.php">
<input type="text" name="url" id="url" placeholder="Paste URL to check" />
<input type="submit" value="Submit URL" />
</form>
<div id="result-section">
<!-- Results will be displayed here -->
</div>
<!-- Footer -->
<footer id="footer">
<ul class="icons">
<li><a href="#" class="icon brands fa-twitter"><span class="label">Twitter</span></a></li>
<li><a href="#" class="icon brands fa-instagram"><span class="label">Instagram</span></a></li>
<li><a href="#" class="icon brands fa-github"><span class="label">GitHub</span></a></li>
<li><a href="#" class="icon fa-envelope"><span class="label">Email</span></a></li>
</ul>
<ul class="copyright">
<li>© API Aries.</li><li>Credits: <a href="https://api-aries.online">API Aries</a></li>
</ul>
</footer>
<!-- Scripts -->
<script src="assets/js/main.js"></script>
<script>
document.getElementById('signup-form').addEventListener('submit', function (event) {
event.preventDefault();
// Get the URL value from the form
var url = document.getElementById('url').value;
// Make an AJAX request to the PHP script
var xhr = new XMLHttpRequest();
xhr.open('POST', 'api.php', true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function () {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
// Parse the JSON response
var response = JSON.parse(xhr.responseText);
// Update the result section
var resultSection = document.getElementById('result-section');
if (response.error) {
resultSection.innerHTML = 'Error: ' + response.error;
} else {
resultSection.innerHTML = response.safe ?
'' + response.message :
'This URL is not safe. Reason: ' + response.message;
}
} else {
// Handle the error
console.error('Error: ' + xhr.status);
}
}
};
xhr.send('url=' + encodeURIComponent(url));
});
</script>
</body>
</html>