папки с паролями
This commit is contained in:
244
index.c
244
index.c
@@ -12,6 +12,7 @@
|
||||
#define MAX_ENTRIES 1000
|
||||
#define TEMPLATE_PATH "/home/romkazvo/www/cgi-bin/template.html"
|
||||
#define OUTPUT_BUFFER_SIZE 65536
|
||||
#define PASSWD_FILE "/home/romkazvo/www/cgi-bin/.htpasswd"
|
||||
|
||||
typedef struct {
|
||||
char name[256];
|
||||
@@ -20,6 +21,7 @@ typedef struct {
|
||||
char icon[8];
|
||||
char encoded_path[1024];
|
||||
char file_url[1024];
|
||||
int is_protected;
|
||||
} entry_t;
|
||||
|
||||
// Быстрый буферизированный вывод
|
||||
@@ -58,6 +60,53 @@ void buffer_free(buffer_t *buf) {
|
||||
free(buf->data);
|
||||
}
|
||||
|
||||
// Функция проверки пароля для папки
|
||||
int check_folder_password(const char *folder_name, const char *password) {
|
||||
FILE *f = fopen(PASSWD_FILE, "r");
|
||||
if (!f) return 1; // Если нет файла с паролями - доступ разрешен
|
||||
|
||||
char line[512];
|
||||
while (fgets(line, sizeof(line), f)) {
|
||||
// Убираем перевод строки
|
||||
line[strcspn(line, "\r\n")] = 0;
|
||||
|
||||
char *colon = strchr(line, ':');
|
||||
if (!colon) continue;
|
||||
|
||||
*colon = '\0';
|
||||
char *folder = line;
|
||||
char *pass = colon + 1;
|
||||
|
||||
if (strcmp(folder, folder_name) == 0) {
|
||||
fclose(f);
|
||||
return strcmp(pass, password) == 0;
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
return 1; // Папка не найдена в списке - доступ разрешен
|
||||
}
|
||||
|
||||
// Проверяет, защищена ли папка паролем
|
||||
int is_folder_protected(const char *folder_name) {
|
||||
FILE *f = fopen(PASSWD_FILE, "r");
|
||||
if (!f) return 0;
|
||||
|
||||
char line[512];
|
||||
while (fgets(line, sizeof(line), f)) {
|
||||
line[strcspn(line, "\r\n")] = 0;
|
||||
char *colon = strchr(line, ':');
|
||||
if (!colon) continue;
|
||||
|
||||
*colon = '\0';
|
||||
if (strcmp(line, folder_name) == 0) {
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* get_file_icon(const char* filename) {
|
||||
const char *ext = strrchr(filename, '.');
|
||||
if (!ext) return "📄";
|
||||
@@ -90,21 +139,18 @@ const char* get_file_icon(const char* filename) {
|
||||
return "📄";
|
||||
}
|
||||
|
||||
// Проверяет, можно ли открыть файл в браузере
|
||||
int is_previewable(const char* filename) {
|
||||
const char *ext = strrchr(filename, '.');
|
||||
if (!ext) return 0;
|
||||
|
||||
ext++;
|
||||
|
||||
// Изображения
|
||||
if (strcasecmp(ext, "jpg") == 0 || strcasecmp(ext, "jpeg") == 0 ||
|
||||
strcasecmp(ext, "png") == 0 || strcasecmp(ext, "gif") == 0 ||
|
||||
strcasecmp(ext, "webp") == 0 || strcasecmp(ext, "bmp") == 0 ||
|
||||
strcasecmp(ext, "svg") == 0 || strcasecmp(ext, "ico") == 0)
|
||||
return 1;
|
||||
|
||||
// Текстовые файлы
|
||||
if (strcasecmp(ext, "txt") == 0 || strcasecmp(ext, "md") == 0 ||
|
||||
strcasecmp(ext, "html") == 0 || strcasecmp(ext, "htm") == 0 ||
|
||||
strcasecmp(ext, "css") == 0 || strcasecmp(ext, "js") == 0 ||
|
||||
@@ -112,17 +158,14 @@ int is_previewable(const char* filename) {
|
||||
strcasecmp(ext, "csv") == 0)
|
||||
return 1;
|
||||
|
||||
// PDF
|
||||
if (strcasecmp(ext, "pdf") == 0)
|
||||
return 1;
|
||||
|
||||
// Аудио
|
||||
if (strcasecmp(ext, "mp3") == 0 || strcasecmp(ext, "wav") == 0 ||
|
||||
strcasecmp(ext, "ogg") == 0 || strcasecmp(ext, "flac") == 0 ||
|
||||
strcasecmp(ext, "m4a") == 0 || strcasecmp(ext, "aac") == 0)
|
||||
return 1;
|
||||
|
||||
// Видео
|
||||
if (strcasecmp(ext, "mp4") == 0 || strcasecmp(ext, "webm") == 0 ||
|
||||
strcasecmp(ext, "ogv") == 0 || strcasecmp(ext, "mov") == 0 ||
|
||||
strcasecmp(ext, "avi") == 0 || strcasecmp(ext, "mkv") == 0)
|
||||
@@ -254,6 +297,37 @@ void print_breadcrumb(buffer_t *buf, const char *display_path) {
|
||||
buffer_append(buf, "\n</div>\n");
|
||||
}
|
||||
|
||||
void print_password_form(buffer_t *buf, const char *folder_name) {
|
||||
buffer_append(buf, "<div class=\"password-form-container\">\n");
|
||||
buffer_append(buf, " <div class=\"password-form\">\n");
|
||||
buffer_append(buf, " <div class=\"lock-icon\">🔒</div>\n");
|
||||
buffer_append(buf, " <h2>Папка защищена паролем</h2>\n");
|
||||
buffer_append(buf, " <p>Введите пароль для доступа к папке <strong>");
|
||||
buffer_append(buf, folder_name);
|
||||
buffer_append(buf, "</strong></p>\n");
|
||||
buffer_append(buf, " <form method=\"GET\" action=\"/cgi-bin/index.cgi\">\n");
|
||||
buffer_append(buf, " <input type=\"hidden\" name=\"path\" value=\"");
|
||||
char encoded_path[1024];
|
||||
url_encode(folder_name, encoded_path, sizeof(encoded_path));
|
||||
buffer_append(buf, encoded_path);
|
||||
buffer_append(buf, "\">\n");
|
||||
buffer_append(buf, " <input type=\"password\" name=\"password\" placeholder=\"Введите пароль\" required>\n");
|
||||
buffer_append(buf, " <button type=\"submit\">Войти</button>\n");
|
||||
buffer_append(buf, " </form>\n");
|
||||
buffer_append(buf, " <p class=\"error-msg\">");
|
||||
|
||||
// Проверяем, была ли ошибка ввода пароля
|
||||
char *query_string = getenv("QUERY_STRING");
|
||||
if (query_string && strstr(query_string, "error=1")) {
|
||||
buffer_append(buf, "❌ Неверный пароль! Попробуйте снова.");
|
||||
}
|
||||
|
||||
buffer_append(buf, "</p>\n");
|
||||
buffer_append(buf, " <a href=\"/cgi-bin/index.cgi\" class=\"back-link\">← Вернуться на главную</a>\n");
|
||||
buffer_append(buf, " </div>\n");
|
||||
buffer_append(buf, "</div>\n");
|
||||
}
|
||||
|
||||
void print_content(buffer_t *buf, const char *base_path, const char *display_path) {
|
||||
DIR *dir;
|
||||
struct dirent *entry;
|
||||
@@ -265,6 +339,46 @@ void print_content(buffer_t *buf, const char *base_path, const char *display_pat
|
||||
int dir_count = 0, file_count = 0;
|
||||
long long total_size = 0;
|
||||
|
||||
// Проверяем, не защищена ли текущая папка паролем
|
||||
char folder_name[256] = "";
|
||||
if (display_path && display_path[0]) {
|
||||
char *last_slash = strrchr(display_path, '/');
|
||||
if (last_slash) {
|
||||
strcpy(folder_name, last_slash + 1);
|
||||
} else {
|
||||
strcpy(folder_name, display_path);
|
||||
}
|
||||
|
||||
// Проверяем пароль
|
||||
char *query_string = getenv("QUERY_STRING");
|
||||
char *password = NULL;
|
||||
if (query_string) {
|
||||
char *pass_start = strstr(query_string, "password=");
|
||||
if (pass_start) {
|
||||
pass_start += 9;
|
||||
char *pass_end = strchr(pass_start, '&');
|
||||
int pass_len = pass_end ? pass_end - pass_start : strlen(pass_start);
|
||||
if (pass_len > 0 && pass_len < 256) {
|
||||
char pass_buf[256];
|
||||
strncpy(pass_buf, pass_start, pass_len);
|
||||
pass_buf[pass_len] = '\0';
|
||||
// URL декодируем пароль
|
||||
char decoded_pass[256];
|
||||
url_decode_enhanced(pass_buf, decoded_pass, sizeof(decoded_pass));
|
||||
password = decoded_pass;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_folder_protected(folder_name)) {
|
||||
if (!password || !check_folder_password(folder_name, password)) {
|
||||
// Показываем форму ввода пароля
|
||||
print_password_form(buf, folder_name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dir = opendir(base_path);
|
||||
if (!dir) {
|
||||
char alt_path[1024];
|
||||
@@ -298,6 +412,14 @@ void print_content(buffer_t *buf, const char *base_path, const char *display_pat
|
||||
continue;
|
||||
if (strcmp(entry->d_name, "cgi-bin") == 0)
|
||||
continue;
|
||||
// Скрываем файл с паролями (на всякий случай, если кто-то сможет получить доступ)
|
||||
if (strcmp(entry->d_name, ".htpasswd") == 0)
|
||||
continue;
|
||||
if (strcmp(entry->d_name, ".htaccess") == 0)
|
||||
continue;
|
||||
// Скрываем все файлы, начинающиеся с точки
|
||||
if (entry->d_name[0] == '.')
|
||||
continue;
|
||||
|
||||
snprintf(full_path, sizeof(full_path), "%s/%s", base_path, entry->d_name);
|
||||
|
||||
@@ -308,9 +430,16 @@ void print_content(buffer_t *buf, const char *base_path, const char *display_pat
|
||||
if (S_ISDIR(file_stat.st_mode)) {
|
||||
entries[entry_count].is_dir = 1;
|
||||
entries[entry_count].size = 0;
|
||||
strcpy(entries[entry_count].icon, "📁");
|
||||
|
||||
// Предварительно кодируем путь для папок
|
||||
// Проверяем, защищена ли папка
|
||||
if (is_folder_protected(entry->d_name)) {
|
||||
strcpy(entries[entry_count].icon, "🔒");
|
||||
entries[entry_count].is_protected = 1;
|
||||
} else {
|
||||
strcpy(entries[entry_count].icon, "📁");
|
||||
entries[entry_count].is_protected = 0;
|
||||
}
|
||||
|
||||
char new_path[2048];
|
||||
snprintf(new_path, sizeof(new_path), "%s%s%s", display_path,
|
||||
display_path[0] ? "/" : "", entries[entry_count].name);
|
||||
@@ -321,8 +450,8 @@ void print_content(buffer_t *buf, const char *base_path, const char *display_pat
|
||||
entries[entry_count].is_dir = 0;
|
||||
entries[entry_count].size = file_stat.st_size;
|
||||
strcpy(entries[entry_count].icon, get_file_icon(entry->d_name));
|
||||
entries[entry_count].is_protected = 0;
|
||||
|
||||
// Предварительно формируем URL для файлов
|
||||
snprintf(entries[entry_count].file_url, sizeof(entries[0].file_url),
|
||||
"%s%s%s", display_path, display_path[0] ? "/" : "", entries[entry_count].name);
|
||||
|
||||
@@ -349,7 +478,7 @@ void print_content(buffer_t *buf, const char *base_path, const char *display_pat
|
||||
|
||||
buffer_append(buf, "<ul>\n");
|
||||
|
||||
// Вывод папок с предварительно закодированными путями
|
||||
// Вывод папок
|
||||
if (dir_count > 0) {
|
||||
char section_title[128];
|
||||
snprintf(section_title, sizeof(section_title), " <li class=\"section-title\">📁 Папки (%d)</li>\n", dir_count);
|
||||
@@ -358,24 +487,49 @@ void print_content(buffer_t *buf, const char *base_path, const char *display_pat
|
||||
for (int i = 0; i < entry_count; i++) {
|
||||
if (entries[i].is_dir) {
|
||||
buffer_append(buf, " <li>\n");
|
||||
char dir_link[512];
|
||||
snprintf(dir_link, sizeof(dir_link),
|
||||
" <a class=\"dir-link\" href=\"/cgi-bin/index.cgi?path=%s\">\n",
|
||||
entries[i].encoded_path);
|
||||
buffer_append(buf, dir_link);
|
||||
buffer_append(buf, " <span class=\"file-icon\">");
|
||||
buffer_append(buf, entries[i].icon);
|
||||
buffer_append(buf, "</span>\n");
|
||||
buffer_append(buf, " <span class=\"file-name\">");
|
||||
buffer_append(buf, entries[i].name);
|
||||
buffer_append(buf, "</span>\n");
|
||||
buffer_append(buf, " </a>\n");
|
||||
|
||||
if (entries[i].is_protected) {
|
||||
// Защищенная папка
|
||||
buffer_append(buf, " <div class=\"file-row\">\n");
|
||||
buffer_append(buf, " <a class=\"dir-link protected-folder\" href=\"javascript:void(0)\" onclick=\"showPasswordForm('");
|
||||
buffer_append(buf, entries[i].encoded_path);
|
||||
buffer_append(buf, "', '");
|
||||
buffer_append(buf, entries[i].name);
|
||||
buffer_append(buf, "')\">\n");
|
||||
buffer_append(buf, " <span class=\"file-icon\">🔒</span>\n");
|
||||
buffer_append(buf, " <span class=\"file-name\">");
|
||||
buffer_append(buf, entries[i].name);
|
||||
buffer_append(buf, " <span style=\"font-size:0.7rem;color:var(--text-muted);\">(защищена)</span></span>\n");
|
||||
buffer_append(buf, " </a>\n");
|
||||
buffer_append(buf, " <div class=\"file-controls\">\n");
|
||||
buffer_append(buf, " <button class=\"preview-btn\" onclick=\"showPasswordForm('");
|
||||
buffer_append(buf, entries[i].encoded_path);
|
||||
buffer_append(buf, "', '");
|
||||
buffer_append(buf, entries[i].name);
|
||||
buffer_append(buf, "')\" title=\"Ввести пароль\">🔑</button>\n");
|
||||
buffer_append(buf, " </div>\n");
|
||||
buffer_append(buf, " </div>\n");
|
||||
} else {
|
||||
// Обычная папка
|
||||
char dir_link[512];
|
||||
snprintf(dir_link, sizeof(dir_link),
|
||||
" <a class=\"dir-link\" href=\"/cgi-bin/index.cgi?path=%s\">\n",
|
||||
entries[i].encoded_path);
|
||||
buffer_append(buf, dir_link);
|
||||
buffer_append(buf, " <span class=\"file-icon\">");
|
||||
buffer_append(buf, entries[i].icon);
|
||||
buffer_append(buf, "</span>\n");
|
||||
buffer_append(buf, " <span class=\"file-name\">");
|
||||
buffer_append(buf, entries[i].name);
|
||||
buffer_append(buf, "</span>\n");
|
||||
buffer_append(buf, " </a>\n");
|
||||
}
|
||||
buffer_append(buf, " </li>\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Вывод файлов с предварительно сформированными URL
|
||||
// Вывод файлов
|
||||
if (file_count > 0) {
|
||||
char section_title[128];
|
||||
snprintf(section_title, sizeof(section_title), " <li class=\"section-title\">📄 Файлы (%d)</li>\n", file_count);
|
||||
@@ -389,7 +543,6 @@ void print_content(buffer_t *buf, const char *base_path, const char *display_pat
|
||||
buffer_append(buf, " <li>\n");
|
||||
buffer_append(buf, " <div class=\"file-row\">\n");
|
||||
|
||||
// Основная ссылка для скачивания
|
||||
buffer_append(buf, " <a class=\"file-link\" href=\"/");
|
||||
buffer_append(buf, entries[i].file_url);
|
||||
buffer_append(buf, "\" download>\n");
|
||||
@@ -403,7 +556,6 @@ void print_content(buffer_t *buf, const char *base_path, const char *display_pat
|
||||
|
||||
buffer_append(buf, " <div class=\"file-controls\">\n");
|
||||
|
||||
// Кнопка предпросмотра (если поддерживается)
|
||||
if (is_previewable(entries[i].name)) {
|
||||
buffer_append(buf, " <button class=\"preview-btn\" onclick=\"openPreview('/");
|
||||
buffer_append(buf, entries[i].file_url);
|
||||
@@ -454,7 +606,6 @@ void print_template(const char *base_path, const char *display_path) {
|
||||
}
|
||||
fclose(file);
|
||||
|
||||
// Один быстрый вывод вместо множества printf
|
||||
fwrite(output.data, 1, output.size, stdout);
|
||||
buffer_free(&output);
|
||||
}
|
||||
@@ -490,6 +641,47 @@ int main() {
|
||||
safe_path_join(base_path, sizeof(base_path), "/home/romkazvo/www", safe_display_path);
|
||||
}
|
||||
}
|
||||
|
||||
// Обработка неправильного пароля
|
||||
if (strstr(query_string, "password=")) {
|
||||
char *error = strstr(query_string, "error=1");
|
||||
if (!error) {
|
||||
// Проверяем пароль для текущей папки
|
||||
char folder_name[256] = "";
|
||||
if (display_path[0]) {
|
||||
char *last_slash = strrchr(display_path, '/');
|
||||
if (last_slash) {
|
||||
strcpy(folder_name, last_slash + 1);
|
||||
} else {
|
||||
strcpy(folder_name, display_path);
|
||||
}
|
||||
|
||||
if (is_folder_protected(folder_name)) {
|
||||
char *pass_start = strstr(query_string, "password=");
|
||||
if (pass_start) {
|
||||
pass_start += 9;
|
||||
char *pass_end = strchr(pass_start, '&');
|
||||
int pass_len = pass_end ? pass_end - pass_start : strlen(pass_start);
|
||||
if (pass_len > 0 && pass_len < 256) {
|
||||
char pass_buf[256];
|
||||
strncpy(pass_buf, pass_start, pass_len);
|
||||
pass_buf[pass_len] = '\0';
|
||||
char decoded_pass[256];
|
||||
url_decode_enhanced(pass_buf, decoded_pass, sizeof(decoded_pass));
|
||||
|
||||
if (!check_folder_password(folder_name, decoded_pass)) {
|
||||
// Неверный пароль - редирект с error=1
|
||||
char encoded_path[1024];
|
||||
url_encode(display_path, encoded_path, sizeof(encoded_path));
|
||||
printf("Location: /cgi-bin/index.cgi?path=%s&error=1\n\n", encoded_path);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print_template(base_path, display_path);
|
||||
|
||||
725
template.html
Executable file → Normal file
725
template.html
Executable file → Normal file
@@ -1,313 +1,412 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0">
|
||||
<title>Trashbox</title>
|
||||
<link rel="shortcut icon" href="/logo.png" type="image/png">
|
||||
<link rel="stylesheet" href="/cgi-bin/style.cgi">
|
||||
<meta property="og:image" content="https://home.mashup.su/og.png" />
|
||||
<meta property="og:image:width" content="600" />
|
||||
<meta property="og:image:height" content="315" />
|
||||
<meta property="og:locale" content="ru_RU" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:title" content="Файлопомойка от RomkaZVO" />
|
||||
<meta property="og:description" content="Моя личная помоечка" />
|
||||
<meta property="og:url" content="https://home.mashup.su/" />
|
||||
<meta property="og:site_name" content="Помойка от RomkaZVO" />
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
<meta name="twitter:title" content="Файлопомойка от RomkaZVO" />
|
||||
<meta name="twitter:description" content="Моя личная помоечка" />
|
||||
<meta name="twitter:image" content="https://home.mashup.su/og.png" />
|
||||
<meta name="description" content="Моя личная помоечка" />
|
||||
<meta name="keywords" content="RomkaZVO, mashup, mashup su, файлы, обмен, скачать, загрузить" />
|
||||
|
||||
<script>
|
||||
function getCookie(name) {
|
||||
const value = `; ${document.cookie}`;
|
||||
const parts = value.split(`; ${name}=`);
|
||||
if (parts.length === 2) return parts.pop().split(';').shift();
|
||||
}
|
||||
|
||||
(function() {
|
||||
const savedTheme = getCookie('theme');
|
||||
if (savedTheme === 'dark') {
|
||||
document.documentElement.classList.add('dark-theme');
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<button class="theme-toggle" onclick="toggleTheme()">🌙</button>
|
||||
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>Trashbox</h1>
|
||||
<div style="margin-top: 0.5rem; opacity: 0.9; font-size: 1.1rem;">
|
||||
Моя личная помоечка
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<!--BREADCRUMB-->
|
||||
<!--CONTENT-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="footer-content">
|
||||
<span>Навайбкодил с любовью ❤️</span>
|
||||
<a href="https://romkazvo.ru" target="_blank" class="footer-link">RomkaZVO</a><br>
|
||||
Сделано при помощи BusyBox httpd и Nginx для SSL<br>
|
||||
Боже, храни Китай партия за DeepSeek
|
||||
</div>
|
||||
|
||||
<div id="status" style="margin-top: 1rem; font-size: 0.8rem; opacity: 0.7; line-height: 1.4;">
|
||||
Загрузка статистики...
|
||||
</div>
|
||||
|
||||
<script>
|
||||
fetch('/cgi-bin/status.cgi')
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
document.getElementById('status').innerHTML = data;
|
||||
})
|
||||
.catch(err => {
|
||||
document.getElementById('status').innerHTML = 'Ошибка загрузки статуса';
|
||||
});
|
||||
</script>
|
||||
</footer>
|
||||
|
||||
<button class="scroll-top" onclick="scrollToTop()">↑</button>
|
||||
|
||||
<div id="previewModal" class="preview-modal">
|
||||
<div class="preview-content" id="previewContent">
|
||||
<div class="preview-header">
|
||||
<h3 class="preview-title" id="previewTitle">Предпросмотр файла</h3>
|
||||
<button class="close-preview" onclick="closePreview()">×</button>
|
||||
</div>
|
||||
<iframe id="previewFrame" class="preview-iframe" sandbox="allow-scripts allow-same-origin"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function scrollToTop() {
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener('scroll', function() {
|
||||
const scrollBtn = document.querySelector('.scroll-top');
|
||||
if (window.scrollY > 300) {
|
||||
scrollBtn.classList.add('visible');
|
||||
} else {
|
||||
scrollBtn.classList.remove('visible');
|
||||
}
|
||||
});
|
||||
|
||||
function toggleTheme() {
|
||||
const isDark = document.body.classList.contains('dark-theme');
|
||||
const newTheme = isDark ? 'light' : 'dark';
|
||||
|
||||
document.body.classList.toggle('dark-theme');
|
||||
document.documentElement.classList.toggle('dark-theme');
|
||||
|
||||
const button = document.querySelector('.theme-toggle');
|
||||
button.textContent = isDark ? '🌙' : '☀️';
|
||||
|
||||
const date = new Date();
|
||||
date.setFullYear(date.getFullYear() + 1);
|
||||
document.cookie = `theme=${newTheme}; expires=${date.toUTCString()}; path=/`;
|
||||
}
|
||||
|
||||
function openPreview(fileUrl) {
|
||||
const modal = document.getElementById('previewModal');
|
||||
const frame = document.getElementById('previewFrame');
|
||||
const content = document.getElementById('previewContent');
|
||||
const title = document.getElementById('previewTitle');
|
||||
|
||||
const fileName = fileUrl.split('/').pop();
|
||||
title.textContent = `Предпросмотр: ${fileName}`;
|
||||
|
||||
const fileExt = fileName.split('.').pop().toLowerCase();
|
||||
const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp', 'svg', 'ico'];
|
||||
const textTypes = ['txt', 'md', 'html', 'htm', 'css', 'js', 'json', 'xml', 'csv'];
|
||||
const audioTypes = ['mp3', 'wav', 'ogg', 'flac', 'm4a', 'aac'];
|
||||
const videoTypes = ['mp4', 'webm', 'ogv', 'mov', 'avi', 'mkv'];
|
||||
const isPDF = fileExt === 'pdf';
|
||||
|
||||
frame.style.display = 'block';
|
||||
frame.src = '';
|
||||
|
||||
let imgContainer = document.getElementById('previewImageContainer');
|
||||
if (!imgContainer) {
|
||||
imgContainer = document.createElement('div');
|
||||
imgContainer.id = 'previewImageContainer';
|
||||
imgContainer.className = 'preview-image-container';
|
||||
content.appendChild(imgContainer);
|
||||
}
|
||||
imgContainer.style.display = 'none';
|
||||
imgContainer.innerHTML = '';
|
||||
|
||||
if (imageTypes.includes(fileExt)) {
|
||||
frame.style.display = 'none';
|
||||
imgContainer.style.display = 'flex';
|
||||
|
||||
const img = document.createElement('img');
|
||||
img.src = fileUrl;
|
||||
img.alt = fileName;
|
||||
img.className = 'preview-image';
|
||||
|
||||
img.onload = function() {
|
||||
adjustModalForImage(this);
|
||||
};
|
||||
|
||||
img.onerror = function() {
|
||||
console.error('Failed to load image:', fileUrl);
|
||||
frame.style.display = 'block';
|
||||
imgContainer.style.display = 'none';
|
||||
frame.src = fileUrl;
|
||||
};
|
||||
|
||||
imgContainer.appendChild(img);
|
||||
|
||||
content.style.width = '90vw';
|
||||
content.style.height = '90vh';
|
||||
content.style.maxWidth = 'none';
|
||||
content.style.maxHeight = 'none';
|
||||
|
||||
} else {
|
||||
frame.style.display = 'block';
|
||||
imgContainer.style.display = 'none';
|
||||
|
||||
if (textTypes.includes(fileExt)) {
|
||||
content.style.width = '80vw';
|
||||
content.style.height = '70vh';
|
||||
content.style.maxWidth = '800px';
|
||||
content.style.maxHeight = '600px';
|
||||
} else if (audioTypes.includes(fileExt)) {
|
||||
content.style.width = '500px';
|
||||
content.style.height = '300px';
|
||||
content.style.maxWidth = '90vw';
|
||||
content.style.maxHeight = '400px';
|
||||
} else if (videoTypes.includes(fileExt)) {
|
||||
content.style.width = '90vw';
|
||||
content.style.height = '80vh';
|
||||
content.style.maxWidth = '1200px';
|
||||
content.style.maxHeight = '800px';
|
||||
} else if (isPDF) {
|
||||
content.style.width = '90vw';
|
||||
content.style.height = '90vh';
|
||||
content.style.maxWidth = '1200px';
|
||||
content.style.maxHeight = '900px';
|
||||
frame.classList.add('pdf');
|
||||
} else {
|
||||
content.style.width = '80vw';
|
||||
content.style.height = '80vh';
|
||||
content.style.maxWidth = '1000px';
|
||||
content.style.maxHeight = '800px';
|
||||
}
|
||||
|
||||
frame.src = fileUrl;
|
||||
}
|
||||
|
||||
modal.style.display = 'block';
|
||||
document.body.style.overflow = 'hidden';
|
||||
}
|
||||
|
||||
|
||||
function adjustModalForImage(img) {
|
||||
const content = document.getElementById('previewContent');
|
||||
const maxWidth = window.innerWidth * 0.95;
|
||||
const maxHeight = window.innerHeight * 0.95;
|
||||
|
||||
const imgWidth = img.naturalWidth;
|
||||
const imgHeight = img.naturalHeight;
|
||||
|
||||
console.log(`Image size: ${imgWidth}x${imgHeight}, Screen limits: ${maxWidth}x${maxHeight}`);
|
||||
|
||||
let scale = 1;
|
||||
|
||||
if (imgWidth > maxWidth) {
|
||||
scale = Math.min(scale, maxWidth / imgWidth);
|
||||
}
|
||||
if (imgHeight > maxHeight) {
|
||||
scale = Math.min(scale, maxHeight / imgHeight);
|
||||
}
|
||||
|
||||
const displayWidth = imgWidth * scale;
|
||||
const displayHeight = imgHeight * scale;
|
||||
|
||||
console.log(`Display size: ${displayWidth}x${displayHeight}, Scale: ${scale}`);
|
||||
|
||||
content.style.width = (displayWidth + 20) + 'px';
|
||||
content.style.height = (displayHeight + 80) + 'px';
|
||||
|
||||
content.style.margin = 'auto';
|
||||
content.style.position = 'absolute';
|
||||
content.style.left = '50%';
|
||||
content.style.top = '50%';
|
||||
content.style.transform = 'translate(-50%, -50%)';
|
||||
}
|
||||
|
||||
function closePreview() {
|
||||
const modal = document.getElementById('previewModal');
|
||||
const frame = document.getElementById('previewFrame');
|
||||
const content = document.getElementById('previewContent');
|
||||
|
||||
modal.style.display = 'none';
|
||||
frame.src = '';
|
||||
frame.classList.remove('pdf');
|
||||
|
||||
content.style.width = '';
|
||||
content.style.height = '';
|
||||
content.style.maxWidth = '';
|
||||
content.style.maxHeight = '';
|
||||
content.style.margin = '';
|
||||
content.style.position = '';
|
||||
content.style.left = '';
|
||||
content.style.top = '';
|
||||
content.style.transform = '';
|
||||
|
||||
const imgContainer = document.getElementById('previewImageContainer');
|
||||
if (imgContainer) {
|
||||
imgContainer.style.display = 'none';
|
||||
imgContainer.innerHTML = '';
|
||||
}
|
||||
|
||||
document.body.style.overflow = 'auto';
|
||||
}
|
||||
|
||||
document.getElementById('previewModal').addEventListener('click', function(e) {
|
||||
if (e.target === this) {
|
||||
closePreview();
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('keydown', function(e) {
|
||||
if (e.key === 'Escape') {
|
||||
closePreview();
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const savedTheme = getCookie('theme');
|
||||
const button = document.querySelector('.theme-toggle');
|
||||
|
||||
if (savedTheme === 'dark') {
|
||||
document.body.classList.add('dark-theme');
|
||||
button.textContent = '☀️';
|
||||
} else {
|
||||
document.body.classList.remove('dark-theme');
|
||||
button.textContent = '🌙';
|
||||
}
|
||||
|
||||
document.body.classList.add('loaded');
|
||||
});
|
||||
|
||||
document.addEventListener('touchstart', function() {}, { passive: true });
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0">
|
||||
<title>Trashbox</title>
|
||||
<link rel="shortcut icon" href="/logo.png" type="image/png">
|
||||
<link rel="stylesheet" href="/cgi-bin/style.cgi">
|
||||
<meta property="og:image" content="https://home.mashup.su/og.png" />
|
||||
<meta property="og:image:width" content="600" />
|
||||
<meta property="og:image:height" content="315" />
|
||||
<meta property="og:locale" content="ru_RU" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:title" content="Файлопомойка от RomkaZVO" />
|
||||
<meta property="og:description" content="Моя личная помоечка" />
|
||||
<meta property="og:url" content="https://home.mashup.su/" />
|
||||
<meta property="og:site_name" content="Помойка от RomkaZVO" />
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
<meta name="twitter:title" content="Файлопомойка от RomkaZVO" />
|
||||
<meta name="twitter:description" content="Моя личная помоечка" />
|
||||
<meta name="twitter:image" content="https://home.mashup.su/og.png" />
|
||||
<meta name="description" content="Моя личная помоечка" />
|
||||
<meta name="keywords" content="RomkaZVO, mashup, mashup su, файлы, обмен, скачать, загрузить" />
|
||||
|
||||
<script>
|
||||
// Отключаем все alert на странице (на случай, если где-то закрались)
|
||||
window.alert = function() {
|
||||
console.log('Alert был заблокирован');
|
||||
};
|
||||
|
||||
function getCookie(name) {
|
||||
const value = `; ${document.cookie}`;
|
||||
const parts = value.split(`; ${name}=`);
|
||||
if (parts.length === 2) return parts.pop().split(';').shift();
|
||||
}
|
||||
|
||||
(function() {
|
||||
const savedTheme = getCookie('theme');
|
||||
if (savedTheme === 'dark') {
|
||||
document.documentElement.classList.add('dark-theme');
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<button class="theme-toggle" onclick="toggleTheme()">🌙</button>
|
||||
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>Trashbox</h1>
|
||||
<div style="margin-top: 0.5rem; opacity: 0.9; font-size: 1.1rem;">
|
||||
Моя личная помоечка
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<!--BREADCRUMB-->
|
||||
<!--CONTENT-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="footer-content">
|
||||
<span>Навайбкодил с любовью ❤️</span>
|
||||
<a href="https://romkazvo.ru" target="_blank" class="footer-link">RomkaZVO</a><br>
|
||||
Сделано при помощи BusyBox httpd и Nginx для SSL<br>
|
||||
Боже, храни Китай партия за DeepSeek
|
||||
</div>
|
||||
|
||||
<div id="status" style="margin-top: 1rem; font-size: 0.8rem; opacity: 0.7; line-height: 1.4;">
|
||||
Загрузка статистики...
|
||||
</div>
|
||||
|
||||
<script>
|
||||
fetch('/cgi-bin/status.cgi')
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
document.getElementById('status').innerHTML = data;
|
||||
})
|
||||
.catch(err => {
|
||||
document.getElementById('status').innerHTML = 'Ошибка загрузки статуса';
|
||||
});
|
||||
</script>
|
||||
</footer>
|
||||
|
||||
<button class="scroll-top" onclick="scrollToTop()">↑</button>
|
||||
|
||||
<div id="previewModal" class="preview-modal">
|
||||
<div class="preview-content" id="previewContent">
|
||||
<div class="preview-header">
|
||||
<h3 class="preview-title" id="previewTitle">Предпросмотр файла</h3>
|
||||
<button class="close-preview" onclick="closePreview()">×</button>
|
||||
</div>
|
||||
<iframe id="previewFrame" class="preview-iframe" sandbox="allow-scripts allow-same-origin"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
window.showPasswordForm = function(encodedPath, folderName) {
|
||||
const modal = document.getElementById('previewModal');
|
||||
const content = document.getElementById('previewContent');
|
||||
const title = document.getElementById('previewTitle');
|
||||
const frame = document.getElementById('previewFrame');
|
||||
|
||||
if (!modal || !content || !title || !frame) {
|
||||
console.error('Modal elements not found!');
|
||||
return;
|
||||
}
|
||||
|
||||
frame.style.display = 'none';
|
||||
|
||||
title.textContent = '🔒 Введите пароль для папки: ' + folderName;
|
||||
|
||||
const oldContainer = document.getElementById('passwordFormContainer');
|
||||
if (oldContainer) {
|
||||
oldContainer.remove();
|
||||
}
|
||||
|
||||
const container = document.createElement('div');
|
||||
container.id = 'passwordFormContainer';
|
||||
container.style.cssText = 'display:flex;justify-content:center;align-items:center;padding:2rem;flex-grow:1;min-height:300px;';
|
||||
|
||||
container.innerHTML = `
|
||||
<div style="background:var(--bg-secondary);border:1px solid var(--border-color);border-radius:12px;padding:2rem;max-width:400px;width:100%;text-align:center;box-shadow:0 4px 20px rgba(0,0,0,0.1);">
|
||||
<div style="font-size:3rem;margin-bottom:1rem;">🔒</div>
|
||||
<h2 style="font-size:1.3rem;margin-bottom:0.5rem;color:var(--text-primary);">Защищенная папка</h2>
|
||||
<p style="color:var(--text-secondary);margin-bottom:1.5rem;font-size:0.95rem;">
|
||||
Введите пароль для доступа к <strong style="color:var(--text-primary);word-break:break-all;">${folderName}</strong>
|
||||
</p>
|
||||
<form method="GET" action="/cgi-bin/index.cgi" onsubmit="return validatePasswordForm(this)">
|
||||
<input type="hidden" name="path" value="${encodedPath}">
|
||||
<input type="password" name="password" placeholder="Введите пароль" required style="width:100%;padding:0.75rem 1rem;border:2px solid var(--border-color);border-radius:8px;font-size:1rem;background:var(--bg-primary);color:var(--text-primary);transition:border-color 0.2s ease;box-sizing:border-box;">
|
||||
<button type="submit" style="width:100%;padding:0.75rem;background:var(--accent-blue);color:white;border:none;border-radius:8px;font-size:1rem;font-weight:600;cursor:pointer;transition:background 0.2s ease;margin-top:0.75rem;">Войти</button>
|
||||
</form>
|
||||
<p class="error-msg" style="color:#dc3545;font-size:0.9rem;min-height:1.5rem;margin:0.5rem 0;"></p>
|
||||
<button onclick="closePreview()" style="background:transparent;border:none;color:var(--text-secondary);cursor:pointer;font-size:0.9rem;margin-top:0.5rem;">✖ Закрыть</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
content.appendChild(container);
|
||||
|
||||
content.style.width = '500px';
|
||||
content.style.height = 'auto';
|
||||
content.style.maxWidth = '90vw';
|
||||
content.style.maxHeight = 'auto';
|
||||
content.style.margin = 'auto';
|
||||
content.style.position = 'absolute';
|
||||
content.style.left = '50%';
|
||||
content.style.top = '50%';
|
||||
content.style.transform = 'translate(-50%, -50%)';
|
||||
|
||||
modal.style.display = 'block';
|
||||
document.body.style.overflow = 'hidden';
|
||||
|
||||
setTimeout(() => {
|
||||
const input = container.querySelector('input[type="password"]');
|
||||
if (input) input.focus();
|
||||
}, 100);
|
||||
};
|
||||
|
||||
window.validatePasswordForm = function(form) {
|
||||
const password = form.querySelector('input[type="password"]').value;
|
||||
const errorMsg = form.parentElement.querySelector('.error-msg');
|
||||
if (!password || password.length < 1) {
|
||||
if (errorMsg) {
|
||||
errorMsg.textContent = '❌ Пожалуйста, введите пароль';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
window.scrollToTop = function() {
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
};
|
||||
|
||||
window.addEventListener('scroll', function() {
|
||||
const scrollBtn = document.querySelector('.scroll-top');
|
||||
if (window.scrollY > 300) {
|
||||
scrollBtn.classList.add('visible');
|
||||
} else {
|
||||
scrollBtn.classList.remove('visible');
|
||||
}
|
||||
});
|
||||
|
||||
window.toggleTheme = function() {
|
||||
const isDark = document.body.classList.contains('dark-theme');
|
||||
const newTheme = isDark ? 'light' : 'dark';
|
||||
|
||||
document.body.classList.toggle('dark-theme');
|
||||
document.documentElement.classList.toggle('dark-theme');
|
||||
|
||||
const button = document.querySelector('.theme-toggle');
|
||||
button.textContent = isDark ? '🌙' : '☀️';
|
||||
|
||||
const date = new Date();
|
||||
date.setFullYear(date.getFullYear() + 1);
|
||||
document.cookie = 'theme=' + newTheme + '; expires=' + date.toUTCString() + '; path=/';
|
||||
};
|
||||
|
||||
window.openPreview = function(fileUrl) {
|
||||
const modal = document.getElementById('previewModal');
|
||||
const frame = document.getElementById('previewFrame');
|
||||
const content = document.getElementById('previewContent');
|
||||
const title = document.getElementById('previewTitle');
|
||||
|
||||
const oldContainer = document.getElementById('passwordFormContainer');
|
||||
if (oldContainer) {
|
||||
oldContainer.remove();
|
||||
}
|
||||
|
||||
frame.style.display = 'block';
|
||||
|
||||
const fileName = fileUrl.split('/').pop();
|
||||
title.textContent = 'Предпросмотр: ' + fileName;
|
||||
|
||||
const fileExt = fileName.split('.').pop().toLowerCase();
|
||||
const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp', 'svg', 'ico'];
|
||||
const textTypes = ['txt', 'md', 'html', 'htm', 'css', 'js', 'json', 'xml', 'csv'];
|
||||
const audioTypes = ['mp3', 'wav', 'ogg', 'flac', 'm4a', 'aac'];
|
||||
const videoTypes = ['mp4', 'webm', 'ogv', 'mov', 'avi', 'mkv'];
|
||||
const isPDF = fileExt === 'pdf';
|
||||
|
||||
frame.src = '';
|
||||
|
||||
let imgContainer = document.getElementById('previewImageContainer');
|
||||
if (!imgContainer) {
|
||||
imgContainer = document.createElement('div');
|
||||
imgContainer.id = 'previewImageContainer';
|
||||
imgContainer.className = 'preview-image-container';
|
||||
content.appendChild(imgContainer);
|
||||
}
|
||||
imgContainer.style.display = 'none';
|
||||
imgContainer.innerHTML = '';
|
||||
|
||||
if (imageTypes.includes(fileExt)) {
|
||||
frame.style.display = 'none';
|
||||
imgContainer.style.display = 'flex';
|
||||
|
||||
const img = document.createElement('img');
|
||||
img.src = fileUrl;
|
||||
img.alt = fileName;
|
||||
img.className = 'preview-image';
|
||||
|
||||
img.onload = function() {
|
||||
adjustModalForImage(this);
|
||||
};
|
||||
|
||||
img.onerror = function() {
|
||||
console.error('Failed to load image:', fileUrl);
|
||||
frame.style.display = 'block';
|
||||
imgContainer.style.display = 'none';
|
||||
frame.src = fileUrl;
|
||||
};
|
||||
|
||||
imgContainer.appendChild(img);
|
||||
|
||||
content.style.width = '90vw';
|
||||
content.style.height = '90vh';
|
||||
content.style.maxWidth = 'none';
|
||||
content.style.maxHeight = 'none';
|
||||
content.style.margin = '2% auto';
|
||||
content.style.position = 'relative';
|
||||
content.style.left = 'auto';
|
||||
content.style.top = 'auto';
|
||||
content.style.transform = 'none';
|
||||
|
||||
} else {
|
||||
frame.style.display = 'block';
|
||||
imgContainer.style.display = 'none';
|
||||
|
||||
if (textTypes.includes(fileExt)) {
|
||||
content.style.width = '80vw';
|
||||
content.style.height = '70vh';
|
||||
content.style.maxWidth = '800px';
|
||||
content.style.maxHeight = '600px';
|
||||
} else if (audioTypes.includes(fileExt)) {
|
||||
content.style.width = '500px';
|
||||
content.style.height = '300px';
|
||||
content.style.maxWidth = '90vw';
|
||||
content.style.maxHeight = '400px';
|
||||
} else if (videoTypes.includes(fileExt)) {
|
||||
content.style.width = '90vw';
|
||||
content.style.height = '80vh';
|
||||
content.style.maxWidth = '1200px';
|
||||
content.style.maxHeight = '800px';
|
||||
} else if (isPDF) {
|
||||
content.style.width = '90vw';
|
||||
content.style.height = '90vh';
|
||||
content.style.maxWidth = '1200px';
|
||||
content.style.maxHeight = '900px';
|
||||
frame.classList.add('pdf');
|
||||
} else {
|
||||
content.style.width = '80vw';
|
||||
content.style.height = '80vh';
|
||||
content.style.maxWidth = '1000px';
|
||||
content.style.maxHeight = '800px';
|
||||
}
|
||||
|
||||
content.style.margin = '2% auto';
|
||||
content.style.position = 'relative';
|
||||
content.style.left = 'auto';
|
||||
content.style.top = 'auto';
|
||||
content.style.transform = 'none';
|
||||
|
||||
frame.src = fileUrl;
|
||||
}
|
||||
|
||||
modal.style.display = 'block';
|
||||
document.body.style.overflow = 'hidden';
|
||||
};
|
||||
|
||||
window.adjustModalForImage = function(img) {
|
||||
const content = document.getElementById('previewContent');
|
||||
const maxWidth = window.innerWidth * 0.95;
|
||||
const maxHeight = window.innerHeight * 0.95;
|
||||
|
||||
const imgWidth = img.naturalWidth;
|
||||
const imgHeight = img.naturalHeight;
|
||||
|
||||
let scale = 1;
|
||||
|
||||
if (imgWidth > maxWidth) {
|
||||
scale = Math.min(scale, maxWidth / imgWidth);
|
||||
}
|
||||
if (imgHeight > maxHeight) {
|
||||
scale = Math.min(scale, maxHeight / imgHeight);
|
||||
}
|
||||
|
||||
const displayWidth = imgWidth * scale;
|
||||
const displayHeight = imgHeight * scale;
|
||||
|
||||
content.style.width = (displayWidth + 20) + 'px';
|
||||
content.style.height = (displayHeight + 80) + 'px';
|
||||
content.style.margin = 'auto';
|
||||
content.style.position = 'absolute';
|
||||
content.style.left = '50%';
|
||||
content.style.top = '50%';
|
||||
content.style.transform = 'translate(-50%, -50%)';
|
||||
};
|
||||
|
||||
window.closePreview = function() {
|
||||
const modal = document.getElementById('previewModal');
|
||||
const frame = document.getElementById('previewFrame');
|
||||
const content = document.getElementById('previewContent');
|
||||
|
||||
modal.style.display = 'none';
|
||||
frame.src = '';
|
||||
frame.classList.remove('pdf');
|
||||
frame.style.display = 'block';
|
||||
|
||||
const oldContainer = document.getElementById('passwordFormContainer');
|
||||
if (oldContainer) {
|
||||
oldContainer.remove();
|
||||
}
|
||||
|
||||
content.style.width = '';
|
||||
content.style.height = '';
|
||||
content.style.maxWidth = '';
|
||||
content.style.maxHeight = '';
|
||||
content.style.margin = '';
|
||||
content.style.position = '';
|
||||
content.style.left = '';
|
||||
content.style.top = '';
|
||||
content.style.transform = '';
|
||||
|
||||
const imgContainer = document.getElementById('previewImageContainer');
|
||||
if (imgContainer) {
|
||||
imgContainer.style.display = 'none';
|
||||
imgContainer.innerHTML = '';
|
||||
}
|
||||
|
||||
const title = document.getElementById('previewTitle');
|
||||
title.textContent = 'Предпросмотр файла';
|
||||
|
||||
document.body.style.overflow = 'auto';
|
||||
};
|
||||
|
||||
document.getElementById('previewModal').addEventListener('click', function(e) {
|
||||
if (e.target === this) {
|
||||
closePreview();
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('keydown', function(e) {
|
||||
if (e.key === 'Escape') {
|
||||
closePreview();
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const savedTheme = getCookie('theme');
|
||||
const button = document.querySelector('.theme-toggle');
|
||||
|
||||
if (savedTheme === 'dark') {
|
||||
document.body.classList.add('dark-theme');
|
||||
button.textContent = '☀️';
|
||||
} else {
|
||||
document.body.classList.remove('dark-theme');
|
||||
button.textContent = '🌙';
|
||||
}
|
||||
|
||||
document.body.classList.add('loaded');
|
||||
});
|
||||
|
||||
document.addEventListener('touchstart', function() {}, { passive: true });
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user