diff --git a/winixd/core/app.cpp b/winixd/core/app.cpp index 308bb8c..29aa9f1 100644 --- a/winixd/core/app.cpp +++ b/winixd/core/app.cpp @@ -940,6 +940,7 @@ void App::ReadRequest() CheckIE(); CheckKonqueror(); + CheckHtmx(); if( cur.request->using_ssl ) log << log3 << "App: connection secure through SSL" << logend; @@ -1125,6 +1126,15 @@ void App::CheckSSL() } + +void App::CheckHtmx() +{ + // fastcgi will change the header to hx_request + cur.request->is_htmx_request = (cur.request->headers_in.has_key(L"HX-Request") || cur.request->headers_in.has_key(L"hx_request")); +} + + + void App::SetSubdomain() { CreateSubdomain(config.base_url.c_str(), cur.request->env_http_host.c_str(), cur.request->subdomain); @@ -1801,7 +1811,7 @@ size_t output_size = 0; source = &json_out_stream.Str(); // json_out_stream was prepared by CreateJSONAnswer() } else - if( cur.request->headers_in.has_key(L"HX-Request") || cur.request->headers_in.has_key(L"hx_request") ) // fastcgi will change the header to hx_request + if( cur.request->is_htmx_request ) { source = CreateFrameAnswer(); diff --git a/winixd/core/app.h b/winixd/core/app.h index 3bef5c8..b154f66 100644 --- a/winixd/core/app.h +++ b/winixd/core/app.h @@ -230,6 +230,7 @@ private: void CheckKonqueror(); void CheckRequestMethod(); void CheckSSL(); + void CheckHtmx(); void SetSubdomain(); diff --git a/winixd/core/request.cpp b/winixd/core/request.cpp index 9c72c9f..8f8729a 100644 --- a/winixd/core/request.cpp +++ b/winixd/core/request.cpp @@ -134,6 +134,7 @@ void Request::Clear() send_as_attachment = false; using_ssl = false; + is_htmx_request = false; start_time = 0; start_date.Clear(); diff --git a/winixd/core/request.h b/winixd/core/request.h index 0022bb0..cc745f4 100644 --- a/winixd/core/request.h +++ b/winixd/core/request.h @@ -170,6 +170,8 @@ struct Request // true if we are using an encrypted connection (SSL) bool using_ssl; + // true if the request is being made by ajax by htmx library + bool is_htmx_request; /* request input variables representing the winix filesystem diff --git a/winixd/functions/functions.cpp b/winixd/functions/functions.cpp index bd35fe2..e891ea4 100644 --- a/winixd/functions/functions.cpp +++ b/winixd/functions/functions.cpp @@ -539,11 +539,18 @@ bool Functions::CheckAntispamCounter() // !!uwaga zwracana wartosc zmieniona (true/false) // !! IMPROVE ME in emacs.cpp there is a similar function -bool Functions::CheckAbuse() +bool Functions::CheckAbuse(SLog * slog) { if( !system->rebus.CheckRebus() ) { cur->request->status = WINIX_ERR_INCORRECT_REBUS; + + if( slog ) + { + // put to locale + (*slog) << logerror << T(L"rebus_need_to_solve") << logend; + } + return true; } @@ -566,7 +573,6 @@ return false; - // returning true if the 'url' has to be changed void Functions::ReadItemUrlSubject(Item & item, Item::Type item_type) { diff --git a/winixd/functions/functions.h b/winixd/functions/functions.h index b784d19..1d1ebaa 100644 --- a/winixd/functions/functions.h +++ b/winixd/functions/functions.h @@ -176,7 +176,7 @@ public: void CheckGetPostTimes(time_t difference = 10); - bool CheckAbuse(); + bool CheckAbuse(SLog * slog = nullptr); // !! dac lepsze nazwy void ReadItemFilterHtml(Item & item); diff --git a/winixd/html/fun_cat.html b/winixd/html/fun_cat.html index 725a879..5b1db4f 100644 --- a/winixd/html/fun_cat.html +++ b/winixd/html/fun_cat.html @@ -1,8 +1,10 @@ [if item_content_type_is "other"][item_print_content][else] +[if false] [if mount_page_arg_is "subject"][if mount_page_arg_is "info"]

[else]

[end][item_subject]

[end] [if mount_page_arg_is "info"][include "item_info.html"][end] - +[end] + [if one item_filetype_is_image] [item_subject] diff --git a/winixd/html/fun_reply.html b/winixd/html/fun_reply.html index 10d9af3..63fec65 100644 --- a/winixd/html/fun_reply.html +++ b/winixd/html/fun_reply.html @@ -1,9 +1,11 @@ -
+

{thread_header_reply}

-
+[# it would be better to have to 'item' objects: one for item_url and the other for item_content] +[# this will be added when ezc will have its own objects templates] + [if thread_mount_arg_is "subject"]
@@ -26,7 +28,7 @@ [if mount_type_is "thread"][end]
- +
@@ -74,3 +76,14 @@
+ + +
+ +[if any winix_has_htmx winix_is_htmx_request winix_has_uikit] + +[end] + diff --git a/winixd/html/fun_run.html b/winixd/html/fun_run.html index d19b5c7..1c00cf1 100644 --- a/winixd/html/fun_run.html +++ b/winixd/html/fun_run.html @@ -1,7 +1,8 @@ [if item_content_type_is "other"][item_run][else]
- + + [if false] [if mount_page_arg_is "subject"]

[item_subject]

[end] @@ -9,6 +10,7 @@ [if mount_page_arg_is "info"] [include "item_info.html"] [end] + [end] [item_run] diff --git a/winixd/html/fun_showthreads.html b/winixd/html/fun_showthreads.html index ea2d349..186749f 100644 --- a/winixd/html/fun_showthreads.html +++ b/winixd/html/fun_showthreads.html @@ -1,4 +1,4 @@ -
+
[if mount_page_arg_is "subject"][dir_last_subject][end] [if mount_page_arg_is "info"][include "dir_last_info.html"][end] @@ -16,7 +16,7 @@ {thread_tab_title}{thread_tab_author}{thread_tab_replies}{thread_tab_last_post} [for thread_sort_tab] - [thread_sort_tab_subject] [# dodac sprawdzanie subject empty] + [thread_sort_tab_subject] [# dodac sprawdzanie subject empty] [thread_sort_tab_user][thread_sort_tab_replies] [thread_sort_tab_last_item_date_modification_nice] ([thread_sort_tab_last_item_user]) @@ -27,11 +27,3 @@
-[if false] -[if any winix_has_htmx winix_is_htmx_request winix_has_uikit] - -[end] -[end] diff --git a/winixd/html/fun_thread.html b/winixd/html/fun_thread.html index badebfb..c327edd 100644 --- a/winixd/html/fun_thread.html +++ b/winixd/html/fun_thread.html @@ -1,4 +1,4 @@ -
+
[if mount_page_arg_is "subject"][item_subject][end] [if false] @@ -55,4 +55,24 @@
+[if winix_function_param_is "scrolltop"] +
+ [if winix_has_uikit] + + [end] +[end] + +[if winix_function_param_is "scrolldown"] +
+ + [if winix_has_uikit] + + [end] +[end] diff --git a/winixd/locale/en b/winixd/locale/en index 1403f6a..331bf2a 100644 --- a/winixd/locale/en +++ b/winixd/locale/en @@ -108,6 +108,7 @@ add_page = Add page edit_page = Edit page rebus_how_is_it = Rebus: How is it +rebus_need_to_solve = Solve the rebus please! edit_ticket_header = Edit ticket create_ticket_header = Create a new ticket @@ -542,7 +543,7 @@ notify_footer4 = in your user control panel. # IMPROVE ME now they are not used, and should be moved to slog winix_err_3 = Incorrect directory. winix_err_18 = You are suspected to be a spammer, you cannot send anything without logging first. -winix_err_19 = Solve the rebus please! + winix_err_25 = Passwords are different! winix_err_26 = A password should consist of at least five characters. diff --git a/winixd/locale/pl b/winixd/locale/pl index 9f6f100..10f80c9 100644 --- a/winixd/locale/pl +++ b/winixd/locale/pl @@ -113,6 +113,8 @@ add_page = Dodaj stronę edit_page = Edytuj stronę rebus_how_is_it = Rebus: Ile to jest +rebus_need_to_solve = Proszę rozwiązać rebus! + edit_ticket_header = Edytuj zgłoszenie create_ticket_header = Nowe zgłoszenie @@ -558,7 +560,7 @@ notify_footer4 = w swoim panelu użytkownika. # those errors are taken automatically by [winix_err_msg_from_locales] winix_err_3 = Nieprawidłowy katalog. winix_err_18 = Jesteś podejrzany jako spamer, nie możesz nic wysłać do czasu zalogowania się! -winix_err_19 = Proszę rozwiązać rebus! + winix_err_25 = Podane hasła różnią się od siebie! winix_err_26 = Hasło powinno składać się z co najmniej pięciu znaków. diff --git a/winixd/plugins/thread/createthread.cpp b/winixd/plugins/thread/createthread.cpp index c393223..9f4043b 100644 --- a/winixd/plugins/thread/createthread.cpp +++ b/winixd/plugins/thread/createthread.cpp @@ -95,6 +95,10 @@ void CreateThread::SendNotify(const Item & item) void CreateThread::MakePost() { + // is it a correct bahavior to set spam_score in session? + // after the first mistake the person will not be allowed to post anything + cur->session->spam_score = 0; + cur->request->item.Clear(); functions->ReadItem(cur->request->item, Item::file); functions->SetUser(cur->request->item); diff --git a/winixd/plugins/thread/reply.cpp b/winixd/plugins/thread/reply.cpp index b9dadec..9532da2 100644 --- a/winixd/plugins/thread/reply.cpp +++ b/winixd/plugins/thread/reply.cpp @@ -112,6 +112,10 @@ void Reply::MakePost() // !! jak bedzie dostepne assert // ASSERT(files_dir) + // is it a correct bahavior to set spam_score in session? + // after the first mistake the person will not be allowed to post anything + cur->session->spam_score = 0; + thread = Thread::get_thread(model_connector, cur->request->item.id); if( !thread.found() ) @@ -143,8 +147,18 @@ void Reply::MakePost() cur->request->last_item = &cur->request->item; cur->request->item.item_content.guest_name.clear(); - if( functions->CheckAbuse() ) + if( functions->CheckAbuse(&slog) ) + { + // temporary: to show values in the html form + // this will be changed when a new ezc objects will be implemented + // there'll be two objects: one registered as [item..] and the other registered as [answer..] + // (one for url and the other for content) + cur->request->item.item_content.content_raw = answer.item_content.content_raw; + cur->request->item.item_content.content_raw_type = answer.item_content.content_raw_type; + cur->request->item.item_content.guest_name = answer.item_content.guest_name; + return; + } plugin->Call(WINIX_PL_THREAD_PREPARE_TO_REPLY_IN_THREAD, &answer); @@ -157,7 +171,17 @@ void Reply::MakePost() if( cur->request->status == WINIX_ERR_OK ) { log << log2 << "Reply: added an answer in a thread" << logend; - thread_info->MakeRedirectIfPossible(cur->request->item); + + const wchar_t * postfix = nullptr; + + if( cur->request->IsParam(L"scrollup") ) + postfix = L"/-/scrollup"; + + if( cur->request->IsParam(L"scrolldown") ) + postfix = L"/-/scrolldown"; + + thread_info->MakeRedirectIfPossible(cur->request->item, postfix); + SendNotify(cur->request->item); } else @@ -172,12 +196,14 @@ void Reply::MakeGet() { /* * workaround: - * html form showed the nick name from item + * html form showed the nick name from item (and content) * this will be removed when new ezc object templates will be implemented * we can provide two item templates: one for [item_url] and the rest for the html form * [item_url] is used in */ cur->request->item.item_content.guest_name.clear(); + cur->request->item.item_content.content_raw.clear(); + } diff --git a/winixd/plugins/thread/threadinfo.cpp b/winixd/plugins/thread/threadinfo.cpp index 48ffa97..6a75ac9 100644 --- a/winixd/plugins/thread/threadinfo.cpp +++ b/winixd/plugins/thread/threadinfo.cpp @@ -194,7 +194,7 @@ void ThreadInfo::Repair() -void ThreadInfo::MakeRedirectIfPossible(const Item & item) +void ThreadInfo::MakeRedirectIfPossible(const Item & item, const wchar_t * postfix) { PluginRes res = plugin->Call(WINIX_PL_THREAD_CAN_MAKE_REDIRECT); @@ -204,7 +204,7 @@ void ThreadInfo::MakeRedirectIfPossible(const Item & item) return; } - system->RedirectTo(item); + system->RedirectTo(item, postfix); } diff --git a/winixd/plugins/thread/threadinfo.h b/winixd/plugins/thread/threadinfo.h index 3904e74..edbd404 100644 --- a/winixd/plugins/thread/threadinfo.h +++ b/winixd/plugins/thread/threadinfo.h @@ -99,7 +99,7 @@ public: // repairing the database void Repair(); - void MakeRedirectIfPossible(const Item & item); + void MakeRedirectIfPossible(const Item & item, const wchar_t * postfix = nullptr); private: diff --git a/winixd/templates/winix.cpp b/winixd/templates/winix.cpp index 7654291..823e365 100644 --- a/winixd/templates/winix.cpp +++ b/winixd/templates/winix.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2008-2018, Tomasz Sowa + * Copyright (c) 2008-2021, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -377,11 +377,7 @@ void winix_locale_tab_name(Info & i) void winix_is_htmx_request(Info & i) { - if( cur->request->headers_in.has_key(L"HX-Request") || cur->request->headers_in.has_key(L"hx_request") ) - { - // fastcgi will change the header to hx_request - i.res = true; - } + i.res = cur->request->is_htmx_request; }