забыл хлам удалить

This commit is contained in:
2026-07-24 02:42:54 +08:00
parent 30504ce9f4
commit 8ff33b3814
7 changed files with 0 additions and 1170 deletions

View File

@@ -1,16 +0,0 @@
#!/bin/bash
echo "Building Trashbox CGI scripts..."
echo "Building index.cgi..."
gcc -Wall -O2 -o index.cgi index.c -DBASE_WWW_PATH='"/home/romkazvo/www"' -DTEMPLATE_PATH='"/home/romkazvo/www/cgi-bin/template.html"'
echo "Building style.cgi..."
gcc -Wall -O2 -o style.cgi style.c -DCSS_PATH='"/home/romkazvo/www/cgi-bin/style.css"'
echo "Building status.cgi..."
gcc -Wall -O2 -o status.cgi status.c
echo "Setting permissions..."
chmod +x *.cgi
echo "Build complete"

1061
index.c

File diff suppressed because it is too large Load Diff

BIN
index.cgi

Binary file not shown.

View File

@@ -1,55 +0,0 @@
// /home/romkazvo/www/cgi-bin/status.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/resource.h>
long get_nginx_memory() {
long total_kb = 0;
char command[] = "ps -o rss= -C nginx 2>/dev/null";
FILE *ps = popen(command, "r");
if (!ps) return 0;
char line[64];
while (fgets(line, sizeof(line), ps)) {
long kb;
if (sscanf(line, "%ld", &kb) == 1) {
total_kb += kb;
}
}
pclose(ps);
return total_kb;
}
int get_process_memory(const char *process_name, long *memory_kb) {
char command[256];
snprintf(command, sizeof(command), "ps -o rss= -C %s 2>/dev/null | head -1", process_name);
FILE *ps = popen(command, "r");
if (!ps) return 0;
int result = fscanf(ps, "%ld", memory_kb);
pclose(ps);
return result == 1;
}
int main() {
printf("Content-type: text/plain; charset=utf-8\n\n");
// Получаем память процессов
long busybox_kb = 0, nginx_kb = 0;
get_process_memory("busybox", &busybox_kb);
nginx_kb = get_nginx_memory();
// Выводим в одну строку
printf("BusyBox: %ld KB | Nginx: %ld MB | Всего: %.1f MB",
busybox_kb,
nginx_kb / 1024,
(busybox_kb + nginx_kb) / 1024.0);
return 0;
}

Binary file not shown.

38
style.c
View File

@@ -1,38 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
int main() {
// Проверяем, существует ли файл стилей
char css_path[1024] = "/home/romkazvo/www/cgi-bin/style.css";
struct stat st;
if (stat(css_path, &st) != 0) {
printf("Status: 404 Not Found\n");
printf("Content-type: text/plain\n\n");
printf("CSS file not found\n");
return 1;
}
// Отдаем CSS с правильными заголовками
printf("Content-type: text/css\n");
printf("Cache-Control: public, max-age=3600\n\n"); // Кэшируем на 1 час
FILE *css_file = fopen(css_path, "r");
if (!css_file) {
printf("Status: 500 Internal Server Error\n");
printf("Content-type: text/plain\n\n");
printf("Cannot open CSS file\n");
return 1;
}
char buffer[4096];
size_t bytes_read;
while ((bytes_read = fread(buffer, 1, sizeof(buffer), css_file)) > 0) {
fwrite(buffer, 1, bytes_read, stdout);
}
fclose(css_file);
return 0;
}

BIN
style.cgi

Binary file not shown.