-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathip-address.html
More file actions
338 lines (303 loc) · 15.6 KB
/
ip-address.html
File metadata and controls
338 lines (303 loc) · 15.6 KB
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="images/logo.png">
<link rel="apple-touch-icon" href="images/logo.png">
<title>IP Address Tools - Developer Toolkit | DevDunia</title>
<meta name="description" content="Check your IP address and lookup information about any IP. Free online IP address tools for developers.">
<script src="https://cdn.tailwindcss.com"></script>
<style>
body {
background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}
</style>
</head>
<body class="h-screen lg:ml-72">
<!-- Background: Consistent Subtle Dark Gradient -->
<div class="fixed inset-0 -z-10 bg-gradient-to-br from-gray-900 via-slate-900 to-gray-900"></div>
<!-- Main Container -->
<div class="main-content">
<div class="relative z-10 container mx-auto px-4 pt-16 pb-24 sm:px-6 lg:px-8">
<!-- Page Header -->
<div class="text-center mb-12">
<h1 class="text-3xl sm:text-4xl font-bold mb-4 tracking-tight
text-transparent bg-clip-text bg-gradient-to-r from-red-400 to-pink-500">
IP Address Tools
</h1>
<p class="text-lg text-gray-400 max-w-2xl mx-auto">
Check your IP address and lookup information about any IP.
</p>
</div>
<!-- Tool Container -->
<div class="max-w-4xl mx-auto">
<div class="bg-slate-800/70 backdrop-blur-md rounded-lg shadow-lg border border-slate-700/60 p-6">
<!-- My IP Section -->
<div class="mb-8">
<h3 class="text-lg font-semibold text-gray-300 mb-4">Your Public IP Address</h3>
<div class="bg-slate-700/50 border border-slate-600 rounded-lg p-4">
<div class="flex items-center justify-between">
<div>
<p class="text-sm text-gray-400 mb-1">Public IP</p>
<p id="my-ip" class="text-xl font-mono text-blue-400">Loading...</p>
</div>
<button id="copy-my-ip" class="px-3 py-1 bg-slate-600 hover:bg-slate-700 text-white text-sm rounded transition-colors duration-200">
Copy
</button>
</div>
</div>
</div>
<!-- IP Lookup Section -->
<div class="mb-6">
<label for="ip-input" class="block text-sm font-medium text-gray-300 mb-2">
IP Address Lookup
</label>
<div class="flex gap-3">
<input
type="text"
id="ip-input"
class="flex-1 px-4 py-3 bg-slate-700/50 border border-slate-600 rounded-lg text-gray-200 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-red-500 focus:border-transparent font-mono text-sm"
placeholder="Enter IP address (e.g., 8.8.8.8)"
>
<button id="lookup-btn" class="px-6 py-3 bg-red-600 hover:bg-red-700 text-white font-medium rounded-lg transition-colors duration-200 flex items-center space-x-2">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path>
</svg>
<span>Lookup</span>
</button>
</div>
</div>
<!-- Error Display -->
<div id="error-display" class="hidden mb-6 p-4 bg-red-900/50 border border-red-600/50 rounded-lg">
<div class="flex items-center space-x-2">
<svg class="w-5 h-5 text-red-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
<span id="error-message" class="text-red-300"></span>
</div>
</div>
<!-- IP Information -->
<div id="ip-info" class="hidden">
<h3 class="text-lg font-semibold text-gray-300 mb-4">IP Information</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="bg-slate-700/50 p-4 rounded-lg">
<h4 class="font-semibold text-blue-400 mb-2">IP Address</h4>
<p id="ip-address" class="text-blue-300 font-mono text-sm"></p>
</div>
<div class="bg-slate-700/50 p-4 rounded-lg">
<h4 class="font-semibold text-green-400 mb-2">Country</h4>
<p id="country" class="text-green-300 font-mono text-sm"></p>
</div>
<div class="bg-slate-700/50 p-4 rounded-lg">
<h4 class="font-semibold text-purple-400 mb-2">Region</h4>
<p id="region" class="text-purple-300 font-mono text-sm"></p>
</div>
<div class="bg-slate-700/50 p-4 rounded-lg">
<h4 class="font-semibold text-orange-400 mb-2">City</h4>
<p id="city" class="text-orange-300 font-mono text-sm"></p>
</div>
<div class="bg-slate-700/50 p-4 rounded-lg">
<h4 class="font-semibold text-cyan-400 mb-2">ISP</h4>
<p id="isp" class="text-cyan-300 font-mono text-sm"></p>
</div>
<div class="bg-slate-700/50 p-4 rounded-lg">
<h4 class="font-semibold text-yellow-400 mb-2">Organization</h4>
<p id="org" class="text-yellow-300 font-mono text-sm"></p>
</div>
</div>
</div>
<!-- IP Tools -->
<div class="mt-8">
<h3 class="text-lg font-semibold text-gray-300 mb-4">IP Tools</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="bg-slate-700/50 p-4 rounded-lg">
<h4 class="font-semibold text-gray-300 mb-2">IP to Binary</h4>
<div class="flex gap-2">
<input type="text" id="ip-to-binary-input" placeholder="192.168.1.1" class="flex-1 px-3 py-2 bg-slate-600 border border-slate-500 rounded text-gray-200 text-sm font-mono">
<button id="ip-to-binary-btn" class="px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm rounded transition-colors duration-200">
Convert
</button>
</div>
<div id="ip-to-binary-result" class="mt-2 text-blue-300 font-mono text-sm hidden"></div>
</div>
<div class="bg-slate-700/50 p-4 rounded-lg">
<h4 class="font-semibold text-gray-300 mb-2">Binary to IP</h4>
<div class="flex gap-2">
<input type="text" id="binary-to-ip-input" placeholder="11000000.10101000.00000001.00000001" class="flex-1 px-3 py-2 bg-slate-600 border border-slate-500 rounded text-gray-200 text-sm font-mono">
<button id="binary-to-ip-btn" class="px-3 py-2 bg-green-600 hover:bg-green-700 text-white text-sm rounded transition-colors duration-200">
Convert
</button>
</div>
<div id="binary-to-ip-result" class="mt-2 text-green-300 font-mono text-sm hidden"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Footer include -->
<div id="footer"></div>
<script>
fetch("footer.html")
.then(response => response.text())
.then(data => {
document.getElementById("footer").innerHTML = data;
})
.catch(err => console.error("Failed to load footer:", err));
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
const myIpElement = document.getElementById('my-ip');
const copyMyIpBtn = document.getElementById('copy-my-ip');
const ipInput = document.getElementById('ip-input');
const lookupBtn = document.getElementById('lookup-btn');
const errorDisplay = document.getElementById('error-display');
const errorMessage = document.getElementById('error-message');
const ipInfo = document.getElementById('ip-info');
const ipToBinaryInput = document.getElementById('ip-to-binary-input');
const ipToBinaryBtn = document.getElementById('ip-to-binary-btn');
const ipToBinaryResult = document.getElementById('ip-to-binary-result');
const binaryToIpInput = document.getElementById('binary-to-ip-input');
const binaryToIpBtn = document.getElementById('binary-to-ip-btn');
const binaryToIpResult = document.getElementById('binary-to-ip-result');
// Get user's public IP
async function getMyIP() {
try {
const response = await fetch('https://api.ipify.org?format=json');
const data = await response.json();
myIpElement.textContent = data.ip;
} catch (error) {
myIpElement.textContent = 'Unable to fetch IP';
}
}
// Copy my IP
copyMyIpBtn.addEventListener('click', function() {
const ip = myIpElement.textContent;
if (ip && ip !== 'Loading...' && ip !== 'Unable to fetch IP') {
navigator.clipboard.writeText(ip).then(() => {
this.textContent = 'Copied!';
this.classList.add('bg-green-600');
setTimeout(() => {
this.textContent = 'Copy';
this.classList.remove('bg-green-600');
}, 2000);
});
}
});
// IP Lookup
lookupBtn.addEventListener('click', async function() {
const ip = ipInput.value.trim();
if (!ip) {
showError('Please enter an IP address');
return;
}
if (!isValidIP(ip)) {
showError('Please enter a valid IP address');
return;
}
try {
// Using a free IP geolocation API
const response = await fetch(`https://ipapi.co/${ip}/json/`);
const data = await response.json();
if (data.error) {
showError(data.reason || 'Unable to lookup IP information');
return;
}
displayIPInfo(data);
hideError();
} catch (error) {
showError('Unable to lookup IP information');
}
});
// IP to Binary
ipToBinaryBtn.addEventListener('click', function() {
const ip = ipToBinaryInput.value.trim();
if (!ip) {
return;
}
if (!isValidIP(ip)) {
ipToBinaryResult.textContent = 'Invalid IP address';
ipToBinaryResult.classList.remove('hidden');
return;
}
const binary = ipToBinary(ip);
ipToBinaryResult.textContent = binary;
ipToBinaryResult.classList.remove('hidden');
});
// Binary to IP
binaryToIpBtn.addEventListener('click', function() {
const binary = binaryToIpInput.value.trim();
if (!binary) {
return;
}
try {
const ip = binaryToIP(binary);
binaryToIpResult.textContent = ip;
binaryToIpResult.classList.remove('hidden');
} catch (error) {
binaryToIpResult.textContent = 'Invalid binary format';
binaryToIpResult.classList.remove('hidden');
}
});
// Helper functions
function showError(message) {
errorMessage.textContent = message;
errorDisplay.classList.remove('hidden');
ipInfo.classList.add('hidden');
}
function hideError() {
errorDisplay.classList.add('hidden');
}
function displayIPInfo(data) {
document.getElementById('ip-address').textContent = data.ip || 'N/A';
document.getElementById('country').textContent = data.country_name || 'N/A';
document.getElementById('region').textContent = data.region || 'N/A';
document.getElementById('city').textContent = data.city || 'N/A';
document.getElementById('isp').textContent = data.org || 'N/A';
document.getElementById('org').textContent = data.org || 'N/A';
ipInfo.classList.remove('hidden');
}
function isValidIP(ip) {
const ipRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
return ipRegex.test(ip);
}
function ipToBinary(ip) {
return ip.split('.').map(octet => {
return parseInt(octet).toString(2).padStart(8, '0');
}).join('.');
}
function binaryToIP(binary) {
const octets = binary.split('.');
if (octets.length !== 4) {
throw new Error('Invalid binary format');
}
return octets.map(octet => {
if (octet.length !== 8 || !/^[01]+$/.test(octet)) {
throw new Error('Invalid binary format');
}
return parseInt(octet, 2);
}).join('.');
}
// Initialize
getMyIP();
});
</script>
</div>
</div>
<!-- Sidebar Scripts -->
<!-- Include Final Sidebar -->
<div id="sidebar-container"></div>
<script>
// Load final_sidebar.html content
fetch('final_sidebar.html')
.then(response => response.text())
.then(html => {
document.getElementById('sidebar-container').innerHTML = html;
})
.catch(error => {
console.error('Error loading sidebar:', error);
});
</script>
</body>
</html>