-
Notifications
You must be signed in to change notification settings - Fork 0
/
match.php
143 lines (123 loc) · 6.02 KB
/
match.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
<?php
require_once('functions.php');
$current_page = htmlspecialchars("https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]", ENT_QUOTES, 'UTF-8');
header('X-Frame-Options: DENY');
header('X-XSS-Protection: 1; mode=block');
header('X-Content-Type-Options: nosniff');
header('Strict-Transport-Security: max-age=63072000');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="HandheldFriendly" content="True" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#c7ecee">
<link rel="shortcut icon" type="image/x-icon" href="/media/favicon.ico" />
<link rel="icon" type="image/png" sizes="196x196" href="/media/192.png" />
<link rel="apple-touch-icon" href="/media/180.png" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="application-name" content="Cricket" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-title" content="Cricket" />
<title>Get Match ID 🏏</title>
<meta name="description" content="Get Real-time Live Cricket Score Update without refreshing the page.">
<?php $current_page = htmlspecialchars("https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]", ENT_QUOTES, 'UTF-8');
echo '<link rel="canonical" href="' . $current_page . '" />';
?>
<meta property="og:site_name" content="Get Match ID 🏏">
<meta property="og:type" content="website">
<meta property="og:title" content="Get Match ID 🏏">
<meta property="og:description" content="Get Real-time Live Cricket Score Update without refreshing the page.">
<meta property="og:url" content="<?php echo $current_page; ?>">
<meta property="og:image" content="<?php echo getFullUrl() . '/media/random-score.jpg'; ?>">
<meta property="og:image:alt" content="Live Cricket Score 🏏" />
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:title" content="Get Match ID 🏏">
<meta name="twitter:description" content="Get Real-time Live Cricket Score Update without refreshing the page.">
<meta name="twitter:url" content="<?php echo $current_page; ?>">
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="<?php echo getFullUrl() . '/media/random-score.jpg'; ?>">
<link rel="preconnect" href="https://cdnjs.cloudflare.com">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.4/css/bulma.min.css" integrity="sha512-HqxHUkJM0SYcbvxUw5P60SzdOTy/QVwA1JJrvaXJv4q7lmbDZCmZaqz01UPOaQveoxfYRv1tHozWGPMcuTBuvQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="style.css">
</head>
<body>
<section class="section">
<div class="container content">
<div class="columns is-centered">
<div class="column is-half">
<div id="quote-card" class="card is-rounded">
<div class="card-content">
<div id="quote-container">
<h1 class="title is-size-5">Fetch ID from URL</h1>
<hr>
<div class="notification is-danger" id="error-notification" style="display: none;"></div>
<div class="notification is-link" id="loading-notification" style="display: none;">Loading...</div>
<form id="fetchForm">
<div class="field">
<label class="label">Enter URL:</label>
<div class="control">
<input class="input is-rounded" type="text" id="urlInput" placeholder="Enter URL">
</div>
</div>
<div class="field">
<div class="control">
<button class="button is-warning is-rounded read-score" type="submit" id="fetchButton">Fetch ID</button>
</div>
</div>
</form>
<div id="result" style="display: none;">
<br>
<div class="notification is-warning" id="success-notification"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<script>
document.getElementById('fetchForm').addEventListener('submit', async function(event) {
event.preventDefault();
const url = document.getElementById('urlInput').value.trim();
const errorNotification = document.getElementById('error-notification');
const loadingNotification = document.getElementById('loading-notification');
const successNotification = document.getElementById('success-notification');
const resultSection = document.getElementById('result');
errorNotification.style.display = 'none';
loadingNotification.style.display = 'block';
successNotification.style.display = 'none';
resultSection.style.display = 'none';
if (!url) {
errorNotification.innerText = 'Please enter a URL.';
errorNotification.style.display = 'block';
loadingNotification.style.display = 'none';
return;
}
try {
const response = await fetch(`/api/id.php?url=${encodeURIComponent(url)}`);
const data = await response.json();
if (!response.ok) {
throw new Error(data.message || 'Failed to fetch data.');
}
if (!data.success) {
throw new Error(data.message || 'An error occurred while fetching data.');
}
successNotification.innerHTML = `<span>${data.message}</span>`;
successNotification.style.display = 'block';
resultSection.style.display = 'block';
} catch (error) {
errorNotification.innerText = error.message || 'An error occurred.';
errorNotification.style.display = 'block';
} finally {
loadingNotification.style.display = 'none';
}
});
</script>
</body>
</html>