Eliezer Croitoru 16acea4957 1
2024-12-28 00:08:31 +02:00

56 lines
1.5 KiB
PHP

<html>
<head>
<script>
function copyToClipboard(text) {
navigator.clipboard.writeText(text)
.then(() => {
console.log('Text copied to clipboard successfully');
})
.catch((error) => {
console.error('Error copying text to clipboard:', error);
});
}
function copyUrl() {
var urlText = document.getElementById('convertedUrl').textContent;
copyToClipboard(urlText);
setTimeout(function() {
window.close()
}, 100);
}
</script>
</head>
<body onload="copyUrl()">
<?php
function url_to_utf8_string($url) {
$parsed_url = parse_url($url);
$scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
$host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
$port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
$path = isset($parsed_url['path']) ? urldecode($parsed_url['path']) : '';
$query = isset($parsed_url['query']) ? '?' . urldecode($parsed_url['query']) : '';
$fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
$utf8_url = $scheme . $host . $port . $path . $query . $fragment;
return $utf8_url;
}
if (isset($_POST['url'])) {
$input_url = $_POST['url'];
$utf8_url = url_to_utf8_string($input_url);
}
if(isset($_GET['url'])) {
$input_url = $_GET['url'];
$utf8_url = url_to_utf8_string($input_url);
}
?>
<h2>Converted URL:</h2>
<p id="convertedUrl"><?php
if (isset($utf8_url) ) {
echo htmlspecialchars($utf8_url);
}
?></p>
</body>
</html>