fixed bug

This commit is contained in:
Your Name 2025-01-25 10:27:33 +03:00
parent 8f882ced2b
commit 3f54bd1a04
5 changed files with 28 additions and 32 deletions

20
img.c
View file

@ -189,7 +189,7 @@ struct DB_STR *new_db_value(char *str) {
*ptr = '\0';
for (size_t i = 0; i < strlen(tok); i++)
if (tok[i] == ',')
if (tok[i] == ',' && tok[i + 1])
db->size++;
size_t allocated = 0;
@ -256,14 +256,14 @@ RDB_CLOSE:
}
struct DB_STR *build_html(FILE *fp, const char *file, const struct UNIQ_TAGS ut, struct DB_STR *db, const size_t page, const size_t pages) {
fprintf(fp, "<html>\n<head>\n<link rel='stylesheet' href='%s'>\n<title>%s</title>\n</head>\n<body>\n<a href='index.html'><img id='logo' src='%s'></a><h1 id='desc'>%s<br>%s/p%zu</h1>\n<center>", CSS, TITLE, LOGO, DESC, file, page);
fprintf(fp, "<html>\n<head>\n<link rel='stylesheet' href='%s'>\n<title>%s</title>\n</head>\n<body>\n<a href='index.html'><img id='logo' src='%s'></a><h1 id='desc'>%s<br>%s/p%zu</h1>\n", CSS, TITLE, LOGO, DESC, file, page);
/* Tags */
fputs("\n<a id='alltags' href='index.html'>all</a>", fp);
fputs("<center><div class='alltags'>\n<a href='index.html'>all</a>", fp);
for (size_t i = 0; i < ut.size; i++)
fprintf(fp, "<a id='alltags' href='%s.html'> %s</a>", ut.tags[i], ut.tags[i]);
fprintf(fp, "<a href='%s.html'> %s</a>", ut.tags[i], ut.tags[i]);
fputs("\n<br><br><br>\n", fp);
fputs("\n</center></div><br><br>\n", fp);
/* Images */
size_t images = 0;
@ -282,9 +282,9 @@ struct DB_STR *build_html(FILE *fp, const char *file, const struct UNIQ_TAGS ut,
}
}
fprintf(fp, "<a href='%s'><img src='%s' alt='%s'></a><br>", p->filename, p->filename, p->filename);
fprintf(fp, "<a href='%s'>\n<img src='%s' alt='%s'></a><br>\n>", p->filename, p->filename, p->filename);
for (size_t i = 0; i < p->size; i++)
fprintf(fp, "<a class='tags' href='%s.html'> %s</a>", p->tags[i], p->tags[i]);
fprintf(fp, "<a href='%s.html'> %s</a>", p->tags[i], p->tags[i]);
fputs("\n<br><br><br>\n", fp);
@ -294,7 +294,7 @@ struct DB_STR *build_html(FILE *fp, const char *file, const struct UNIQ_TAGS ut,
break;
}
fputs("\n<div class='pager'>\n", fp);
fputs("<div class='pager'><center>\n", fp);
for (size_t i = 0; i <= pages; i++) {
if (i == 0) {
if (i == page)
@ -317,7 +317,7 @@ struct DB_STR *build_html(FILE *fp, const char *file, const struct UNIQ_TAGS ut,
}
fprintf(fp, "\n</div>\n</center>\n</body>\n</html>\n");
fprintf(fp, "\n</center></div>\n</body>\n</html>\n");
return p;
}
@ -331,7 +331,7 @@ void build(const char *file, const struct UNIQ_TAGS ut, struct DB_STR *db) {
while (p != NULL) {
struct DB_STR *i = p->next;
if (count == POST_PER_PAGE) {
if (count > POST_PER_PAGE) {
count = 0;
pages++;
}