Loading editor/src/webedit_db.cpp +2 −2 Changes for editor/src/webedit_db.cpp: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ void webedit::Database::initTables() { sql << "CREATE TABLE IF NOT EXISTS documents(" << "id " << _db->getUUIDType(sql) << "," << "owner_uid text NOT NULL," << "domain text NOT NULL DEFAULT ''," << "domain varchar(255) NOT NULL DEFAULT ''," << "group_name varchar(255) NOT NULL DEFAULT ''," << "name varchar(255) NOT NULL," << "xml text NOT NULL," Loading Loading @@ -130,7 +130,7 @@ void webedit::Database::initTables() { sql << "CREATE TABLE IF NOT EXISTS ai_chat_messages(" << "owner_uid text NOT NULL," << "messages text NOT NULL DEFAULT '[]'," << "messages text NOT NULL," << "modified timestamp DEFAULT CURRENT_TIMESTAMP," << "PRIMARY KEY (owner_uid)" << ");"; Loading src/blogi.cpp +113 −1 Changes for src/blogi.cpp: 113 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -27,6 +27,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <iostream> #include <fstream> #include <filesystem> #include <memory> #include <algorithm> #include <cctype> #include <string> #include <vector> #include <sstream> #include <cstdlib> #include <signal.h> #include <string.h> Loading Loading @@ -57,6 +65,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <fcntl.h> #include <pwd.h> #include <grp.h> #include <dlfcn.h> #endif #include "session.h" Loading Loading @@ -95,6 +104,95 @@ static std::string cookieDomain(libhttppp::HttpRequest &req) { return h; } static bool isDeployRequestUrl(const std::string &url) { static const std::string deployBase = "/_deploy"; return url == deployBase || url.compare(0, deployBase.length() + 1, deployBase + "/") == 0; } static std::unique_ptr<blogi::PluginApi, blogi::PluginApiDeleter> loadDeployPluginFile(const std::filesystem::path &path) { #ifdef Windows HMODULE handle = LoadLibraryA(path.string().c_str()); if (!handle) return {}; auto *create_plugin = reinterpret_cast<blogi::create_t*>(GetProcAddress(handle, "create")); auto *destroy_plugin = reinterpret_cast<blogi::destroy_t*>(GetProcAddress(handle, "destroy")); if (!create_plugin || !destroy_plugin) { FreeLibrary(handle); return {}; } #else void *handle = dlopen(path.string().c_str(), RTLD_LAZY); if (!handle) return {}; auto *create_plugin = reinterpret_cast<blogi::create_t*>(dlsym(handle, "create")); auto *destroy_plugin = reinterpret_cast<blogi::destroy_t*>(dlsym(handle, "destroy")); if (!create_plugin || !destroy_plugin) { dlclose(handle); return {}; } #endif return std::unique_ptr<blogi::PluginApi, blogi::PluginApiDeleter>( create_plugin(), blogi::PluginApiDeleter(destroy_plugin, handle)); } static bool handleDeployFallback(libhttppp::HttpRequest &curreq, const int tid, blogi::Config &cfg, bool debug) { if (!isDeployRequestUrl(curreq.getRequestURL())) return false; blogi::PluginArgs args; args.config = &cfg; args.debug = debug; args.maxthreads = 0; for (size_t i = 0; i < cfg.getplgdirs(); ++i) { std::filesystem::path dir(cfg.getplgdir(i)); if (!std::filesystem::exists(dir) || !std::filesystem::is_directory(dir)) continue; for (const auto &entry : std::filesystem::directory_iterator(dir)) { if (!entry.is_regular_file()) continue; std::string ext = entry.path().extension().string(); #ifdef Windows if (ext != ".dll") continue; #else if (ext != ".so" && ext != ".dylib") continue; #endif std::string filename = entry.path().filename().string(); std::transform(filename.begin(), filename.end(), filename.begin(), [](unsigned char c) { return static_cast<char>(std::tolower(c)); }); if (filename.find("deploy") == std::string::npos) continue; auto plugin = loadDeployPluginFile(entry.path()); if (!plugin) continue; plugin->setArgs(&args); if (plugin->getName() != "_deploy") continue; if (plugin->Response(tid, curreq)) return true; } } libhttppp::HttpResponse resp; resp.setState(HTTP503); resp.setContentType("text/plain"); const char *body = "Deploy plugin not available."; resp.send(curreq, body, strlen(body)); return true; } blogi::Blogi::Blogi(std::vector<netplus::socket*> serversocket,bool debug) : HttpEvent(serversocket), _debug(debug){ // Helper to initialize a DomainContext from a DomainConfig Loading Loading @@ -2228,8 +2326,15 @@ void blogi::Blogi::sitemapXML(libhttppp::HttpRequest& curreq, const int tid, con }; void blogi::Blogi::RequestEvent(libhttppp::HttpRequest &curreq,const int tid,ULONG_PTR args){ // Resolve which domain context to use for this request DomainContext *ctx = resolveDomain(curreq); if (isDeployRequestUrl(curreq.getRequestURL())) { blogi::Config *deployCfg = ctx ? ctx->config.get() : Blogi::Cfg.get(); if (deployCfg && handleDeployFallback(curreq, tid, *deployCfg, _debug)) return; } // Resolve which domain context to use for this request if (!ctx) { libhttppp::HttpResponse resp; resp.setState(HTTP404); Loading Loading @@ -2623,6 +2728,13 @@ RETRY_REQUEST: void blogi::Blogi::ResponseEvent(libhttppp::HttpRequest& curreq,const int tid,ULONG_PTR args){ DomainContext *ctx = resolveDomain(curreq); if (isDeployRequestUrl(curreq.getRequestURL())) { blogi::Config *deployCfg = ctx ? ctx->config.get() : Blogi::Cfg.get(); if (deployCfg && handleDeployFallback(curreq, tid, *deployCfg, _debug)) return; } if (!ctx) return; auto &PlgArgs = ctx->plgArgs; auto &BlogiPlg = ctx->plugins; Loading Loading
editor/src/webedit_db.cpp +2 −2 Changes for editor/src/webedit_db.cpp: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ void webedit::Database::initTables() { sql << "CREATE TABLE IF NOT EXISTS documents(" << "id " << _db->getUUIDType(sql) << "," << "owner_uid text NOT NULL," << "domain text NOT NULL DEFAULT ''," << "domain varchar(255) NOT NULL DEFAULT ''," << "group_name varchar(255) NOT NULL DEFAULT ''," << "name varchar(255) NOT NULL," << "xml text NOT NULL," Loading Loading @@ -130,7 +130,7 @@ void webedit::Database::initTables() { sql << "CREATE TABLE IF NOT EXISTS ai_chat_messages(" << "owner_uid text NOT NULL," << "messages text NOT NULL DEFAULT '[]'," << "messages text NOT NULL," << "modified timestamp DEFAULT CURRENT_TIMESTAMP," << "PRIMARY KEY (owner_uid)" << ");"; Loading
src/blogi.cpp +113 −1 Changes for src/blogi.cpp: 113 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -27,6 +27,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <iostream> #include <fstream> #include <filesystem> #include <memory> #include <algorithm> #include <cctype> #include <string> #include <vector> #include <sstream> #include <cstdlib> #include <signal.h> #include <string.h> Loading Loading @@ -57,6 +65,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <fcntl.h> #include <pwd.h> #include <grp.h> #include <dlfcn.h> #endif #include "session.h" Loading Loading @@ -95,6 +104,95 @@ static std::string cookieDomain(libhttppp::HttpRequest &req) { return h; } static bool isDeployRequestUrl(const std::string &url) { static const std::string deployBase = "/_deploy"; return url == deployBase || url.compare(0, deployBase.length() + 1, deployBase + "/") == 0; } static std::unique_ptr<blogi::PluginApi, blogi::PluginApiDeleter> loadDeployPluginFile(const std::filesystem::path &path) { #ifdef Windows HMODULE handle = LoadLibraryA(path.string().c_str()); if (!handle) return {}; auto *create_plugin = reinterpret_cast<blogi::create_t*>(GetProcAddress(handle, "create")); auto *destroy_plugin = reinterpret_cast<blogi::destroy_t*>(GetProcAddress(handle, "destroy")); if (!create_plugin || !destroy_plugin) { FreeLibrary(handle); return {}; } #else void *handle = dlopen(path.string().c_str(), RTLD_LAZY); if (!handle) return {}; auto *create_plugin = reinterpret_cast<blogi::create_t*>(dlsym(handle, "create")); auto *destroy_plugin = reinterpret_cast<blogi::destroy_t*>(dlsym(handle, "destroy")); if (!create_plugin || !destroy_plugin) { dlclose(handle); return {}; } #endif return std::unique_ptr<blogi::PluginApi, blogi::PluginApiDeleter>( create_plugin(), blogi::PluginApiDeleter(destroy_plugin, handle)); } static bool handleDeployFallback(libhttppp::HttpRequest &curreq, const int tid, blogi::Config &cfg, bool debug) { if (!isDeployRequestUrl(curreq.getRequestURL())) return false; blogi::PluginArgs args; args.config = &cfg; args.debug = debug; args.maxthreads = 0; for (size_t i = 0; i < cfg.getplgdirs(); ++i) { std::filesystem::path dir(cfg.getplgdir(i)); if (!std::filesystem::exists(dir) || !std::filesystem::is_directory(dir)) continue; for (const auto &entry : std::filesystem::directory_iterator(dir)) { if (!entry.is_regular_file()) continue; std::string ext = entry.path().extension().string(); #ifdef Windows if (ext != ".dll") continue; #else if (ext != ".so" && ext != ".dylib") continue; #endif std::string filename = entry.path().filename().string(); std::transform(filename.begin(), filename.end(), filename.begin(), [](unsigned char c) { return static_cast<char>(std::tolower(c)); }); if (filename.find("deploy") == std::string::npos) continue; auto plugin = loadDeployPluginFile(entry.path()); if (!plugin) continue; plugin->setArgs(&args); if (plugin->getName() != "_deploy") continue; if (plugin->Response(tid, curreq)) return true; } } libhttppp::HttpResponse resp; resp.setState(HTTP503); resp.setContentType("text/plain"); const char *body = "Deploy plugin not available."; resp.send(curreq, body, strlen(body)); return true; } blogi::Blogi::Blogi(std::vector<netplus::socket*> serversocket,bool debug) : HttpEvent(serversocket), _debug(debug){ // Helper to initialize a DomainContext from a DomainConfig Loading Loading @@ -2228,8 +2326,15 @@ void blogi::Blogi::sitemapXML(libhttppp::HttpRequest& curreq, const int tid, con }; void blogi::Blogi::RequestEvent(libhttppp::HttpRequest &curreq,const int tid,ULONG_PTR args){ // Resolve which domain context to use for this request DomainContext *ctx = resolveDomain(curreq); if (isDeployRequestUrl(curreq.getRequestURL())) { blogi::Config *deployCfg = ctx ? ctx->config.get() : Blogi::Cfg.get(); if (deployCfg && handleDeployFallback(curreq, tid, *deployCfg, _debug)) return; } // Resolve which domain context to use for this request if (!ctx) { libhttppp::HttpResponse resp; resp.setState(HTTP404); Loading Loading @@ -2623,6 +2728,13 @@ RETRY_REQUEST: void blogi::Blogi::ResponseEvent(libhttppp::HttpRequest& curreq,const int tid,ULONG_PTR args){ DomainContext *ctx = resolveDomain(curreq); if (isDeployRequestUrl(curreq.getRequestURL())) { blogi::Config *deployCfg = ctx ? ctx->config.get() : Blogi::Cfg.get(); if (deployCfg && handleDeployFallback(curreq, tid, *deployCfg, _debug)) return; } if (!ctx) return; auto &PlgArgs = ctx->plgArgs; auto &BlogiPlg = ctx->plugins; Loading