Move files

This commit is contained in:
Lncvrt committed 2025-03-02 12:56:14 -07:00
1 parent 30dd940c0e
commit a58ecbb597
43 files changed
+7 -7

No files matched your search

+703
View File
@@ -0,0 +1,703 @@
* {
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
font-weight: normal;
}
body {
background-color: #060606;
color: #fff;
margin: 0;
padding: 0;
display: flex;
align-items: center;
justify-content: normal;
flex-direction: column;
font-size: 0.78vw;
}
body.tint::before {
content: "";
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 99998;
}
#container {
text-align: center;
padding: 1.04vw;
border-radius: 0.52vw;
margin-top: 1.04vw;
background-color: #0E0E0E;
box-shadow: 0 0.21vw 0.42vw rgba(0, 0, 0, 0.1);
justify-content: space-between;
flex: 1;
min-width: 15.62vw;
max-width: 79%;
}
#main-content {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 2.60vw;
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 1.04vw;
width: 100%;
}
.info-group {
display: flex;
justify-content: flex-end;
align-items: center;
margin: 1.04vw;
}
.info-box {
background-color: #131313;
padding: 1.04vw 0.52vw;
border-radius: 0.42vw;
max-width: 20.83vw;
height: auto;
overflow: hidden;
box-shadow: 0 0.21vw 0.42vw rgba(0, 0, 0, 0.1);
margin-left: 0.52vw;
display: flex;
flex-direction: column;
}
.info-box p.big {
font-size: 1.25vw;
line-height: 1.2;
margin-bottom: 0.42vw;
}
.info-box p {
font-size: 1vw;
line-height: 1.2;
margin: 0;
}
#container h1 {
margin-right: auto;
margin-left: 1.30vw;
margin-bottom: 1.04vw;
}
#container h2 {
color: #fff;
font-size: 1.5em;
margin-top: 1.04vw;
margin-bottom: 0.52vw;
}
#uploadStats,
#loginStats {
margin-top: 1.04vw;
width: 90%;
}
#charts-container {
display: flex;
flex: 1;
justify-content: center;
align-items: center;
margin-top: 1.56vw;
}
#canvas-group {
background-color: #131313;
border-radius: 0.52vw;
margin: 0 1.04vw;
}
#canvas-group p {
font-size: 1.30vw;
}
#canvas-group canvas {
max-width: 22vw;
max-height: 22vh;
width: 200%;
height: 100%;
}
#gallery {
text-align: center;
max-width: 90%;
margin-top: 1.04vw;
justify-content: space-between;
display: none;
flex-wrap: wrap;
justify-content: space-around;
}
.gallery-item {
margin: 0.26vw;
position: relative;
flex: 1 1 auto;
background-color: #131313;
box-shadow: 0 0.21vw 0.42vw rgba(0, 0, 0, 0.1);
padding: 0.26vw;
border-radius: 0.52vw;
width: 15vw;
height: 15vw;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
transition: transform 0.3s ease;
overflow: hidden;
}
.gallery-item img {
max-width: 100%;
max-height: 50%;
height: auto;
border-radius: 5px;
}
.gallery-item textarea {
background-color: #222;
color: #fff;
margin: 0;
font-size: 16px;
border-radius: 5px;
resize: none;
overflow: auto;
transition: border-color 0.3s ease;
width: 100%;
height: 100%;
}
.gallery-item textarea:focus {
outline: none;
}
.gallery-item textarea:hover {
border-color: #370664;
}
.gallery-item:hover {
transform: scale(1.015);
}
.gallery-btn {
margin: 5px;
cursor: pointer;
}
.file-info {
margin-top: auto;
text-align: center;
}
.icon-container {
position: absolute;
top: 0.52vw;
right: 0.52vw;
display: flex;
align-items: center;
position: relative;
top: 0;
left: 0;
justify-content: center;
}
.icon-container i {
margin-left: 0.52vw;
cursor: pointer;
}
#sidebar {
display: flex;
flex-direction: column;
align-items: flex-start;
padding: 1.56vw;
background-color: #0E0E0E;
margin-right: auto;
height: 100vh;
position: fixed;
left: 0;
top: 0;
bottom: 0;
}
.sidebar-item {
margin-bottom: 1.56vw;
font-size: 1.56vw;
}
#upload {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
#dropZone {
width: 50%;
height: 30vh;
border: 0.10vw solid #fff;
display: flex;
align-items: center;
justify-content: center;
margin-top: 10%;
cursor: pointer;
background-color: #0E0E0E;
box-shadow: 0 0.21vw 0.42vw rgba(0, 0, 0, 0.1);
border-radius: 0.52vw;
padding: 1.04vw;
text-align: center;
transition: transform 0.3s ease;
}
#dropZone p {
color: #fff;
font-size: 1.04vw;
margin: 0;
}
#dropZone:hover {
transform: scale(1.02)
}
#progressContainer {
width: 50%;
height: 2vh;
border: 0.10vw solid #fff;
display: none;
align-items: center;
justify-content: center;
margin-top: 2%;
background-color: #0E0E0E;
box-shadow: 0 0.21vw 0.42vw rgba(0, 0, 0, 0.1);
border-radius: 0.52vw;
padding: 1.04vw;
}
#progressBar {
margin-bottom: 5%;
}
#progressText, #uploadSpeed {
color: #fff;
font-size: 1.04vw;
margin: 0;
text-align: center;
}
.section {
background-color: #131313;
padding: 1.04vw;
margin-bottom: 1.04vw;
border-radius: 0.42vw;
box-shadow: 0 0.21vw 0.42vw rgba(0, 0, 0, 0.3);
}
.row {
display: flex;
justify-content: space-between;
}
.half-width {
width: calc(50% - 1vw);
margin-right: 0.26vw;
margin-left: 0.26vw;
}
.switch {
position: relative;
display: inline-block;
width: 3.12vw;
height: 1.77vw;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
border-radius: 1.77vw;
}
.slider-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
border: 1px solid #222;
border-radius: 10px;
}
.slider-container p {
font-size: 0.8vw;
margin: 0.2vh 0 0.2vh 0;
}
.slider-label {
margin-right: 0.52vw;
color: #fff;
font-size: 0.8vw;
font-weight: bold;
width: 60%;
}
.slider:before {
position: absolute;
content: "";
height: 1.35vw;
width: 1.35vw;
left: 0.21vw;
bottom: 0.21vw;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
border-radius: 50%;
}
input:checked+.slider {
background-color: #370664;
}
input:focus+.slider {
box-shadow: 0 0 0.05vw #370664;
}
input:checked+.slider:before {
-webkit-transform: translateX(1.35vw);
-ms-transform: translateX(1.35vw);
transform: translateX(1.35vw);
}
.icon-check,
.icon-times {
color: #fff;
position: absolute;
top: 50%;
transform: translateY(-50%);
font-size: 0.52vw;
}
.icon-check {
left: 0.42vw;
opacity: 0;
}
.icon-times {
right: 0.42vw;
}
input:checked~.icon-check {
opacity: 1;
}
input:checked~.icon-times {
opacity: 0;
}
.upload-tools {
display: flex;
justify-content: space-around;
flex-wrap: wrap;
margin-top: 1.04vw;
}
.tool-box {
width: 6.67vw;
height: 6.67vw;
background-color: #333;
border-radius: 0.42vw;
padding: 0.26vw;
text-align: center;
margin: 0.26vw;
}
.tool-title {
margin-top: 0.26vw;
font-size: 1.04vw;
color: #fff;
margin-bottom: 0.52vw;
}
.tool-icon {
font-size: 2.50vw;
color: #fff;
}
button {
display: inline-block;
padding: 0.52vw 1.04vw;
background-color: #3c076e;
color: #fff;
text-decoration: none;
border: none;
border-radius: 0.26vw;
font-size: 0.94vw;
transition: background-color 0.3s, transform 0.3s;
cursor: pointer;
margin: 4px;
}
button:hover {
background-color: #370664;
transform: scale(1.05);
}
.settings-group {
margin-bottom: 1.04vw;
}
.settings-label {
display: block;
margin-bottom: 0.42vw;
font-size: 0.83vw;
}
select {
width: 100%;
padding: 0.42vw 0.52vw;
font-size: 0.73vw;
border: 0.05vw solid #ccc;
border-radius: 0.21vw;
background-color: #131313;
box-sizing: border-box;
color: #fff;
text-align: center;
}
select:hover {
border-color: #370664;
outline: none;
box-shadow: 0 0 0 0.2rem rgba(55, 6, 160, 0.25);
transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.settings-radio-group {
width: 100%;
padding: 0.42vw 0.52vw;
font-size: 0.73vw;
border: 0.05vw solid #ccc;
border-radius: 0.21vw;
background-color: #131313;
box-sizing: border-box;
transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.settings-radio-group:hover {
border-color: #370664;
outline: none;
box-shadow: 0 0 0 0.2rem rgba(55, 6, 160, 0.25);
}
.settings-radio-group .settings-label {
display: block;
font-weight: bold;
margin-bottom: 0.26vw;
}
.settings-radio-group label {
display: inline-block;
margin-right: 0.78vw;
font-size: 0.73vw;
}
.radio-container input[type="radio"] {
display: none;
}
.radio-container .fa-circle,
.radio-container .fa-check-circle {
display: none;
}
.radio-container input[type="radio"]:checked+.fa-circle+.fa-check-circle {
display: inline-block;
}
.radio-container input[type="radio"]:not(:checked)+.fa-circle {
display: inline-block;
}
.radio-container input[type="radio"]:disabled+.fa-circle {
color: #ccc;
}
.radio-container input[type="radio"]:disabled+.fa-circle+.fa-check-circle {
display: none;
}
.input-field {
width: 90%;
padding: 0.52vw;
margin-bottom: 1.04vw;
background-color: #131313;
border: none;
border-radius: 0.42vw;
color: #fff;
font-size: 0.94vw;
}
.input-field:focus {
outline: none;
box-shadow: 0 0 0.52vw rgba(255, 255, 255, 0.25);
}
.form-section {
margin: 1.04vw 0;
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
}
.select-field {
width: 92%;
padding: 0.52vw;
background-color: #131313;
border: none;
border-radius: 0.42vw;
color: #fff;
font-size: 0.94vw;
margin-bottom: 1.04vw;
}
.select-field:focus {
outline: none;
}
#notification-container {
position: fixed;
bottom: 0;
right: 0;
z-index: 10000;
transition: transform 0.5s ease-in-out;
max-width: 100%;
}
.notification {
display: flex;
align-items: center;
justify-content: flex-start;
margin: 10px;
padding: 15px;
color: white;
background-color: #333;
border-radius: 10px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
transition: transform 0.5s ease-in-out;
min-width: 15vw;
min-height: 6.5vh;
max-width: 30vw;
height: auto;
box-sizing: border-box;
}
.notification div:first-child {
border-right: 1px solid white;
padding-right: 10px;
margin-right: 10px;
}
.notification i {
margin-right: 10px;
}
#notification-message {
text-align: center;
margin-left: auto;
margin-right: auto;
}
input {
background-color: #131313;
border: 0.05vw solid #ccc;
border-radius: 0.21vw;
color: #fff;
font-size: 0.83vw;
padding: 0.42vw 0.52vw;
width: 100%;
box-sizing: border-box;
margin: 0.3vh 0 0.3vh 0;
transition: border-color 0.3s ease, box-shadow 0.3s ease;
text-align: center;
}
input:hover {
border-color: #370664;
outline: none;
box-shadow: 0 0 0 0.2rem rgba(55, 6, 160, 0.25);
}
input:focus {
outline: none;
box-shadow: 0 0 0.52vw rgba(255, 255, 255, 0.25);
}
form textarea {
background-color: #131313;
border: 0.05vw solid #ccc;
border-radius: 0.21vw;
color: #fff;
font-size: 0.83vw;
padding: 0.42vw 0.52vw;
width: 100%;
box-sizing: border-box;
margin: 0.3vh 0 0.3vh 0;
transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
#account-information .blur-on-hover {
filter: blur(8px);
font-style: normal;
transition: filter 0.25s ease;
}
#account-information .blur-on-hover:hover {
filter: none;
}
a {
text-decoration: none;
color: #fff;
}
.file-textbox {
width: 50vw;
min-height: 30vh;
max-height: 100vh;
background-color: #222;
color: #fff;
margin: 0;
font-size: 16px;
border-radius: 5px;
resize: none;
overflow: auto;
transition: border-color 0.3s ease;
}
.file-textbox:focus {
outline: none;
}
.file-textbox:hover {
border-color: #370664;
}
+685
View File
@@ -0,0 +1,685 @@
function logout() {
document.cookie = "session=" + "; path=/";
location.reload();
}
function showNotification(message, type) {
var notification = document.createElement('div');
notification.className = 'notification ' + type;
notification.style.display = 'flex';
notification.style.flexDirection = 'row';
notification.style.alignItems = 'center';
var iconDiv = document.createElement('div');
var icon = document.createElement('i');
icon.className = type === 'Success' ? 'fas fa-check' : 'fas fa-times';
icon.style.color = type === 'Success' ? '#4CAF50' : '#f44336';
iconDiv.appendChild(icon);
notification.appendChild(iconDiv);
var textDiv = document.createElement('div');
textDiv.id = 'notification-message';
textDiv.style.display = 'flex';
textDiv.style.flexDirection = 'column';
var titleNode = document.createElement('h4');
titleNode.style.margin = '0';
titleNode.appendChild(document.createTextNode(type));
textDiv.appendChild(titleNode);
var messageNode = document.createElement('div');
messageNode.style.margin = '0';
messageNode.appendChild(document.createTextNode(message));
textDiv.appendChild(messageNode);
notification.appendChild(textDiv);
var container = document.getElementById('notification-container');
container.appendChild(notification);
notification.style.transform = 'translateY(100%)';
setTimeout(function() {
notification.style.transform = 'translateY(0)';
}, 100);
setTimeout(function() {
notification.style.transform = 'translateY(100%)';
setTimeout(function() {
container.removeChild(notification);
}, 500);
}, 5000);
}
function showSuccess(message) {
showNotification(message, 'Success');
}
function showError(message) {
showNotification(message, 'Error');
}
document.addEventListener('DOMContentLoaded', (event) => {
let element = "";
element = document.getElementById('dropZone');
if (element) {
element.addEventListener('click', function() {
document.getElementById('fileInput').click();
});
}
element = document.getElementById('fileInput');
if (element) {
element.addEventListener('change', function(event) {
handleFileUpload(event.target.files[0]);
});
}
element = document.getElementById('dropZone');
if (element) {
element.addEventListener('dragover', function(event) {
event.preventDefault();
event.stopPropagation();
event.target.style.border = '3px solid #09f';
});
}
element = document.getElementById('dropZone');
if (element) {
element.addEventListener('dragleave', function(event) {
event.preventDefault();
event.stopPropagation();
event.target.style.border = '2px dashed #fff';
});
}
element = document.getElementById('dropZone');
if (element) {
element.addEventListener('drop', function(event) {
event.preventDefault();
event.stopPropagation();
event.target.style.border = '2px dashed #fff';
const files = event.dataTransfer.files;
if (files.length) {
handleFileUpload(files[0]);
}
});
}
element = document.getElementById('booleanSetting');
if (element) {
element.addEventListener('change', function () {
let value = this.checked ? true : false;
let label = document.querySelector("p[id='settingName']").innerText.toLowerCase().replace(/ /g, '-');
$.ajax({
url: '/api/dashboard/setPreferences.php',
type: 'POST',
data: {[`${label}`]: value},
success: function(response) {
console.log('Full response:', response);
if (response.success) {
console.log('Settings updated: ', response.response);
showSuccess(response.response);
} else {
console.error('Update failed: ', response.response);
showError(response.response);
}
},
error: function(xhr) {
console.error('Update failed: ', xhr);
if (xhr.responseJSON && xhr.responseJSON.response) {
showError(xhr.responseJSON.response);
} else {
showError(xhr.responseText);
}
}
});
});
}
element1 = document.getElementById('passwordChangeForm');
element2 = document.getElementById('usernameChangeForm');
element3 = document.getElementById('displaynameChangeForm');
if (element1 && element2 && element3) {
$(document).ready(function() {
$('#passwordChangeForm').on('submit', function(e) {
e.preventDefault();
var oldPassword = $('#oldPassword').val();
var newPassword = $('#newPassword').val();
var confirmPassword = $('#confirmPassword').val();
var username = $('#username').val();
$.ajax({
url: '/api/changePassword.php',
type: 'POST',
data: {
username: username,
oldpassword: oldPassword,
newpassword: newPassword,
confirmpassword: confirmPassword
},
success: function(data) {
response = JSON.parse(data);
if (response.success) {
location.reload();
} else {
showError(response.response);
}
},
error: function(error) {
if (error.responseJSON && error.responseJSON.response) {
showError(error.responseJSON.response);
} else {
showError(error);
}
}
});
});
$('#usernameChangeForm').on('submit', function(e) {
e.preventDefault();
var oldUsername = $('#oldUsername').val();
var newUsername = $('#newUsername').val();
var password = $('#usernamepassword').val();
$.ajax({
url: '/api/changeUsername.php',
type: 'POST',
data: {
oldusername: oldUsername,
newusername: newUsername,
password: password
},
success: function(data) {
response = data;
if (response.success) {
showSuccess(response.response);
$('#oldUsername').val(newUsername);
$('#username').html('<strong>Username:</strong> ').append(document.createTextNode(newUsername));
} else {
showError(response.response);
}
},
error: function(jqXHR) {
if (jqXHR.responseJSON && jqXHR.responseJSON.response) {
showError(jqXHR.responseJSON.response);
} else {
showError(jqXHR.responseText);
}
}
});
});
$('#displaynameChangeForm').on('submit', function(e) {
e.preventDefault();
var oldUsername = $('#oldDisplayname').val();
var newUsername = $('#newDisplayname').val();
var username = $('#username').val();
var password = $('#displayusernamepassword').val();
$.ajax({
url: '/api/changeDisplayname.php',
type: 'POST',
data: {
olddisplayname: oldUsername,
newdisplayname: newUsername,
username: username,
password: password
},
success: function(data) {
response = data;
if (response.success) {
showSuccess(response.response);
$('#oldDisplayname').val(newUsername);
$('#displayname').html('<strong>Username:</strong> ').append(document.createTextNode(newUsername));
} else {
showError(response.response);
}
},
error: function(jqXHR) {
if (jqXHR.responseJSON && jqXHR.responseJSON.response) {
showError(jqXHR.responseJSON.response);
} else {
showError(jqXHR.responseText);
}
}
});
});
});
}
});
function deleteFile(deletionKey, imageId) {
const deleteUrl = 'https://upload.xytriza.com/delete/' + deletionKey;
$.ajax({
url: deleteUrl,
type: 'GET',
dataType: 'json',
contentType: 'application/json',
success: function(responseJson) {
console.log('Server response:', responseJson);
const isSuccess = responseJson.success === true || responseJson.success === 'true';
if (isSuccess) {
const galleryItem = document.querySelector('.gallery-item[data-id="' + imageId + '"]');
if (galleryItem) {
galleryItem.remove();
} else {
console.error('Gallery item not found:', deletionKey);
}
console.log('File deleted successfully:', deletionKey);
showSuccess("File deleted Successfuly")
} else {
console.error('Error deleting file:', responseJson.response);
showError("Error deleting file: " + responseJson.response)
}
},
error: function(xhr, status, error) {
console.error('Error deleting file:', error + ' (' + status + ')');
showError('Error deleting file: ' + error + ' (' + status + ')');
}
});
}
function copyToClipboardOld(text, message, type) {
const tempInput = document.createElement('input');
tempInput.value = text;
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand('copy');
document.body.removeChild(tempInput);
console.log('Link copied to clipboard: ', tempInput.value);
if (message) {
if (type == 0) {
showSuccess(message);
} else if (type == 1) {
showError(message);
}
}
}
async function copyToClipboard(text, message, type) {
if (!navigator.clipboard) {
console.error('Clipboard not available');
showError('Copying not supported on this browser.');
return;
}
try {
await navigator.clipboard.writeText(text);
console.log('Link copied to clipboard:', text);
if (message) {
type = type.toString();
if (type === "0" || type === "success") {
showSuccess(message);
} else if (type === "1" || type === "error") {
showError(message);
} else {
console.log('Invalid copy type');
}
}
} catch (err) {
console.error('Failed to copy content:', err);
showError('Failed to copy content: ' + err);
}
}
function downloadFile(fileId, originalName, fileType) {
$.ajax({
url: 'https://files.upload.xytriza.com/' + fileId,
method: 'GET',
xhrFields: {
responseType: 'blob'
},
success: function (data) {
var blob = new Blob([data], {type: fileType});
var url = window.URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = url;
a.download = originalName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
showSuccess("File downloaded successfully")
},
error: function(xhr, status, error) {
console.error('Error downloading file:', error + ' (' + status + ')');
showError('Error downloading file: ' + error + ' (' + status + ')');
}
});
}
function formatDate(dateStr) {
const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
const date = new Date(dateStr);
const year = date.getFullYear();
const month = months[date.getMonth()];
const day = date.getDate();
return `${month} ${day}, ${year}`;
}
function formatAllDates(dateStrArray) {
return dateStrArray.map(dateStr => formatDate(dateStr));
}
function logout() {
document.cookie = "session=" + "; path=/";
location.reload();
}
function saveTimeSettings() {
var country = document.getElementById("country").value
var timezone = document.getElementById("timezone").value
var dateFormatElements = document.getElementsByName("dateFormat");
var timeFormatElements = document.getElementsByName("timeFormat");
var dateFormat = getSelectedRadioValue(dateFormatElements);
var timeFormat = getSelectedRadioValue(timeFormatElements);
$.ajax({
url: 'https://upload.xytriza.com/api/dashboard/setPreferences.php',
type: 'POST',
data: {country: country, timezone: timezone, dateformat: dateFormat, timeformat: timeFormat},
success: function(responseJson) {
console.log('Server response:', responseJson);
const isSuccess = responseJson.success === true || responseJson.success === 'true';
if (isSuccess) {
showSuccess('Saved your preferences');
} else {
showError(responseJson.response);
}
},
error: function(jqXHR, textStatus, errorThrown) {
showError(jqXHR.responseText);
}
});
}
function getSelectedRadioValue(radioElements) {
for (var i = 0; i < radioElements.length; i++) {
if (radioElements[i].checked) {
return radioElements[i].value;
}
}
return null;
}
function logout() {
document.cookie = "session=" + "; path=/";
location.reload();
}
async function handleFileUpload(file) {
let formData = new FormData();
formData.append('file', file);
const xhr = new XMLHttpRequest();
xhr.open('POST', '/api/uploadFile.php', true);
document.getElementById('progressText').style.display = 'block';
xhr.upload.onprogress = function(event) {
if (event.lengthComputable) {
const percentage = Math.round((event.loaded / event.total) * 100);
document.getElementById('progressText').innerText = percentage + '%';
} else {
console.log('Progress event not computable');
}
};
xhr.onload = function() {
if (xhr.status === 200) {
const response = JSON.parse(xhr.responseText);
if (response.success === true) {
copyToClipboard(response.fileUrl, "", 0);
showSuccess('File uploaded successfully. Link copied to clipboard');
} else {
showError(response.response);
}
} else {
console.error('Error:', xhr.statusText);
showError(xhr.statusText);
}
document.getElementById('progressText').style.display = 'none';
};
xhr.send(formData);
}
async function handleUrlUpload() {
const url = document.getElementById('urlInput').value = document.getElementById('urlInput').value.replace('https://upload.xytriza.com/files/', 'https://files.upload.xytriza.com/').replace('http://upload.xytriza.com/files/', 'https://files.upload.xytriza.com/');
const fileName = document.getElementById('fileName').value;
if (!url) {
showError('Please enter a valid URL');
return;
}
const formData = new FormData();
try {
const response = await fetch(url, { mode: 'cors' });
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const blob = await response.blob();
const fileType = blob.type;
const file = new File([blob], fileName, { type: fileType });
formData.append('file', file);
} catch (error) {
showError('Unable to upload file. Make sure the target file has CORS enabled. Error: ' + error);
console.error(error);
}
const xhr = new XMLHttpRequest();
xhr.open('POST', '/api/uploadFile.php', true);
document.getElementById('progressText').style.display = 'block';
xhr.upload.onprogress = function(event) {
if (event.lengthComputable) {
const percentage = Math.round((event.loaded / event.total) * 100);
document.getElementById('progressText').innerText = percentage + '%';
} else {
console.log('Progress event not computable');
}
};
xhr.onload = function() {
if (xhr.status === 200) {
const response = JSON.parse(xhr.responseText);
if (response.success === true) {
copyToClipboard(response.fileUrl, ""), 0;
showSuccess('File uploaded successfully. Link copied to clipboard');
} else {
showError(response.response);
}
} else {
console.error('Error:', xhr.statusText);
showError('An error occurred while uploading the file');
}
document.getElementById('progressText').style.display = 'none';
};
xhr.send(formData);
}
function downloadConfig() {
$.ajax({
url: '/api/dashboard/generateConfig.php',
method: 'GET',
success: function(response) {
var downloadLink = document.createElement('a');
var url = window.URL.createObjectURL(new Blob([JSON.stringify(response)]));
downloadLink.href = url;
downloadLink.download = 'xytrizas-uploading-service.sxcu';
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
showSuccess('Config file downloaded successfully');
},
error: function(jqXHR, textStatus, errorThrown) {
if (jqXHR.responseJSON && jqXHR.responseJSON.response) {
showError(jqXHR.responseJSON.response);
} else {
showError(jqXHR.responseText);
}
}
});
}
function setCookieAndRedirect() {
document.cookie = "redirect_link=" + window.location.href + "; expires=Session; path=/;";
window.location.href = "https://discord.com/api/oauth2/authorize?client_id=1204620985798631464&redirect_uri=https%3A%2F%2Fupload.xytriza.com%2Fapi%2Fdashboard%2FdiscordCallback.php&response_type=code&scope=identify+guilds.join+email";
}
function openFileSettings(fileId, filename, filepassword) {
showError("Feature coming soon!");
return
var fileSettings = document.getElementById('file-settings');
var fileSettingsPassword = document.getElementById('file-settings-password');
var fileSettingsFilename = document.getElementById('file-settings-filename');
var fileSettingsId = document.getElementById('file-settings-id');
document.body.classList.add('tint');
fileSettingsPassword.value = filepassword;
fileSettingsFilename.value = filename;
fileSettingsId.value = fileId;
fileSettings.style.display = 'block';
}
function saveFileSettings() {
var fileSettingsPassword = document.getElementById('file-settings-password');
var fileSettingsFilename = document.getElementById('file-settings-filename');
var fileSettingsId = document.getElementById('file-settings-id');
var fileSettings = document.getElementById('file-settings');
fileSettings.style.display = 'none';
document.body.classList.remove('tint');
$.ajax({
url: '/api/filePreferences.php',
type: 'POST',
data: {
fileId: fileSettingsId.value,
password: fileSettingsPassword.value,
filename: fileSettingsFilename.value
},
success: function(response) {
console.log('Server response:', response);
if (response.success) {
showSuccess('File settings saved successfully');
var galleryItem = document.querySelector('.gallery-item[data-id="' + fileSettingsId.value + '"]');
if (galleryItem) {
var filenameElement = galleryItem.querySelector('a[target="_blank"] p');
if (filenameElement) {
filenameElement.textContent = fileSettingsFilename.value;
}
var settingsButton = galleryItem.querySelector('.fa-cog');
if (settingsButton) {
settingsButton.setAttribute('onclick', 'openFileSettings("' + fileSettingsId.value + '", "' + fileSettingsFilename.value + '", "' + fileSettingsPassword.value + '")');
}
}
} else {
showError(response.response);
}
},
error: function(jqXHR, textStatus, errorThrown) {
showError(jqXHR.responseText);
}
});
}
function closeFileSettings() {
var fileSettings = document.getElementById('file-settings');
fileSettings.style.display = 'none';
document.body.classList.remove('tint');
var fileSettingsPassword = document.getElementById('file-settings-password');
var fileSettingsFilename = document.getElementById('file-settings-filename');
fileSettingsPassword.value = '';
fileSettingsFilename.value = '';
}
function generateAPIKey() {
$.ajax({
url: '/api/dashboard/generateAPIKey.php',
type: 'GET',
success: function(response) {
console.log('Server response:', response);
if (response.success) {
showSuccess('API key regenerated successfully');
} else {
showError(response.response);
}
},
error: function(jqXHR, textStatus, errorThrown) {
showError(jqXHR.responseText);
}
});
}
function copyAPIKey() {
$.ajax({
url: '/api/dashboard/getAPIKey.php',
type: 'GET',
success: function(response) {
console.log('Server response:', response);
if (response.success) {
copyToClipboard(response.api_key, 'API Key copied to clipboard', 0);
} else {
showError(response.response);
}
},
error: function(jqXHR, textStatus, errorThrown) {
showError(jqXHR.responseText);
}
});
}
function deleteAllFiles() {
$.ajax({
url: '/api/deleteAllFiles.php',
type: 'GET',
success: function(response) {
console.log('Server response:', response);
if (response.success) {
showSuccess('All files deleted successfully');
} else {
showError(response.response);
}
},
error: function(jqXHR, textStatus, errorThrown) {
showError(jqXHR.responseText);
}
});
}
test = function() {
$.ajax({
url: '/api/dashboard/setStatus.php',
type: 'GET',
headers: {
'status': 'online'
},
});
setInterval(function() {
$.ajax({
url: '/api/dashboard/setStatus.php',
type: 'GET',
headers: {
'status': 'online'
},
});
}, 120000);
}