Loading plugins/content/content.cpp +11 −12 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ namespace blogi { libhttppp::HTTPException excep; libhtmlpp::HtmlString condat; condat << "<div><div id=\"contentidx\">"; char url[512]; std::string sid; blogi::SQL sql; Loading @@ -80,7 +82,7 @@ namespace blogi { } std::string meta; condat << "<div id=\"contentidx\">"; if(Args->auth->isLoggedIn(tid,curreq,sid)){ condat << "<div class=\"blog_adminmenu\">" << "<ul>" Loading Loading @@ -147,6 +149,7 @@ namespace blogi { condat << "</ul></div>"; } libhtmlpp::HtmlString out; if(page->getElementbyID("main")) Loading @@ -163,7 +166,7 @@ namespace blogi { void contentPage(const int tid,libhttppp::HttpRequest* curreq,libhtmlpp::HtmlElement &page) { libhttppp::HTTPException excep; libhtmlpp::HtmlString *condat = new libhtmlpp::HtmlString; libhtmlpp::HtmlString condat; char url[512]; std::string sid; Loading @@ -179,21 +182,20 @@ namespace blogi { if(Args->database[tid]->exec(&sql,res)<1){ delete condat; excep[libhttppp::HTTPException::Critical] << "No entry found for content id: " << cid; throw excep; } *condat << "<div id=\"content\">"; condat << "<div id=\"content\">"; if (Args->auth->isLoggedIn(tid,curreq,sid)) { *condat << "<div class=\"blog_adminmenu\">" condat << "<div class=\"blog_adminmenu\">" << "<ul>" << "<li><a href=\"" << Args->config->buildurl("content/edit/",url,512) << cid << "\">Bearbeiten</a></li>" << "<li><a href=\"" << Args->config->buildurl("content/del/",url,512) << cid << "\">Loeschen</a></li>" << "</ul>" << "</div>"; } *condat << "<div class=\"blog_entry\">" condat << "<div class=\"blog_entry\">" << "<span class=\"title\">" << res[0][1] << "</span>" << "<div class=\"text\">" << res[0][2] << "</div>" << "<span class=\"author\">verfasst von " << res[0][3] << " am "<< res[0][4] <<" </span>" Loading @@ -202,15 +204,12 @@ namespace blogi { libhtmlpp::HtmlString out; try{ page.getElementbyID("main")->insertChild(condat->parse()); page.getElementbyID("main")->insertChild(condat.parse()); }catch(libhtmlpp::HTMLException &e){ delete condat; excep[libhttppp::HTTPException::Error] << e.what(); throw excep; } delete condat; Args->theme->printSite(tid,out,&page,curreq->getRequestURL(),Args->auth->isLoggedIn(tid,curreq,sid)); libhttppp::HttpResponse resp; Loading plugins/media/redis.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ size_t blogi::RedisStore::getSize(int tid,const char* key){ redisReply *rep=(redisReply*)redisCommand(_RedisCTX[tid],"STRLEN %s",key); if(!rep || rep->type != REDIS_REPLY_INTEGER){ freeReplyObject(rep); libhttppp::HTTPException e; e[libhttppp::HTTPException::Error] << "media plugin err: wrong redis reply in getsize !"; throw e; Loading @@ -96,6 +97,7 @@ void blogi::RedisStore::load(int tid,libhttppp::HttpRequest *req,const char *key redisReply *rep=(redisReply*)redisCommand(_RedisCTX[tid],"GETRANGE %s %d %d",key,pos,pos+blocksize); if(_RedisCTX[tid]->err!=REDIS_OK){ freeReplyObject(rep); libhttppp::HTTPException e; e[libhttppp::HTTPException::Error] << "media plugin err: " << _RedisCTX[tid]->errstr; throw e; Loading src/blogi.cpp +14 −15 Original line number Diff line number Diff line Loading @@ -62,9 +62,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "sqlite.cpp" blogi::Blogi::Blogi(Config *blgcfg,netplus::socket *serversocket) : HttpEvent(serversocket){ blogi::Blogi::Blogi(Config *blgcfg,netplus::socket *serversocket,bool debug) : HttpEvent(serversocket){ PlgArgs = new PluginArgs; PlgArgs->debug=debug; PlgArgs->config=blgcfg; PlgArgs->database=new Database*[threads]; Loading @@ -83,7 +84,7 @@ blogi::Blogi::Blogi(Config *blgcfg,netplus::socket *serversocket) : HttpEvent(se tplcfg.Theme=tplcfg.config->gettemplate(); tplcfg.TDatabase=PlgArgs->database; PlgArgs->theme=new Template(tplcfg); PlgArgs->theme=new Template(tplcfg,debug); PlgArgs->theme->renderPage(0,"index.html",Page,Index); Loading Loading @@ -140,12 +141,12 @@ void blogi::Blogi::loginPage(libhttppp::HttpRequest *curreq,const int tid){ libhtmlpp::HtmlString out; std::shared_ptr<libhtmlpp::HtmlElement> index; libhtmlpp::HtmlElement index; if(curreq->isMobile()) *index=MIndex; index=MIndex; else *index=Index; index=Index; if (username.empty() || password.empty()) { libhtmlpp::HtmlString condat; Loading @@ -158,14 +159,14 @@ void blogi::Blogi::loginPage(libhttppp::HttpRequest *curreq,const int tid){ << "</form>" << "</div>"; if(index->getElementbyID("main")) index->getElementbyID("main")->insertChild(condat.parse()); if(index.getElementbyID("main")) index.getElementbyID("main")->insertChild(condat.parse()); for(blogi::Plugin::PluginData *curplg=BlogiPlg->getFirstPlugin(); curplg; curplg=curplg->getNextPlg()){ curplg->getInstace()->Rendering(tid,curreq,&*index); curplg->getInstace()->Rendering(tid,curreq,&index); } PlgArgs->theme->printSite(tid,out,&*index,curreq->getRequestURL(),false); PlgArgs->theme->printSite(tid,out,&index,curreq->getRequestURL(),false); libhttppp::HttpResponse curres; curres.setState(HTTP200); curres.setVersion(HTTPVERSION(1.1)); Loading Loading @@ -413,13 +414,13 @@ void blogi::Blogi::ResponseEvent(libhttppp::HttpRequest* curreq,const int tid,vo class HttpConD : public libhttppp::HttpD { public: HttpConD(blogi::Config *blgcfg) HttpConD(blogi::Config *blgcfg,bool debug) : HttpD(blgcfg->gethttpaddr(),blgcfg->gethttpport(),blgcfg->gethttpmaxcon(),blgcfg->getsslcertpath(),blgcfg->getsslkeypath()){ libhttppp::HTTPException httpexception; try { blogi::Session session; try{ blogi::Blogi blg(blgcfg,getServerSocket()); blogi::Blogi blg(blgcfg,getServerSocket(),debug); #ifndef Windows struct passwd *pwd=getpwnam("blogi"); seteuid(pwd->pw_uid); Loading Loading @@ -492,12 +493,10 @@ int main(int argc, char** argv){ int pid = daemon(1,1); if(pid==0){ HttpConD blogiD(cins); }else if(pid>0){ HttpConD blogiD(cins,false); } }else{ HttpConD blogiD(cins); HttpConD blogiD(cins,true); } #else HttpConD blogiD(cins); Loading src/blogi.h +1 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace blogi { class Blogi : public libhttppp::HttpEvent { public: Blogi(Config *blgcfg,netplus::socket *serversocket); Blogi(Config *blgcfg,netplus::socket *serversocket,bool debug); ~Blogi(); void loginPage(libhttppp::HttpRequest *curreq,const int tid); void logoutPage(libhttppp::HttpRequest *curreq,const int tid); Loading src/plugin.h +1 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ namespace blogi { Editor *edit; Config *config; int maxthreads; bool debug; }; class PluginApi { Loading Loading
plugins/content/content.cpp +11 −12 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ namespace blogi { libhttppp::HTTPException excep; libhtmlpp::HtmlString condat; condat << "<div><div id=\"contentidx\">"; char url[512]; std::string sid; blogi::SQL sql; Loading @@ -80,7 +82,7 @@ namespace blogi { } std::string meta; condat << "<div id=\"contentidx\">"; if(Args->auth->isLoggedIn(tid,curreq,sid)){ condat << "<div class=\"blog_adminmenu\">" << "<ul>" Loading Loading @@ -147,6 +149,7 @@ namespace blogi { condat << "</ul></div>"; } libhtmlpp::HtmlString out; if(page->getElementbyID("main")) Loading @@ -163,7 +166,7 @@ namespace blogi { void contentPage(const int tid,libhttppp::HttpRequest* curreq,libhtmlpp::HtmlElement &page) { libhttppp::HTTPException excep; libhtmlpp::HtmlString *condat = new libhtmlpp::HtmlString; libhtmlpp::HtmlString condat; char url[512]; std::string sid; Loading @@ -179,21 +182,20 @@ namespace blogi { if(Args->database[tid]->exec(&sql,res)<1){ delete condat; excep[libhttppp::HTTPException::Critical] << "No entry found for content id: " << cid; throw excep; } *condat << "<div id=\"content\">"; condat << "<div id=\"content\">"; if (Args->auth->isLoggedIn(tid,curreq,sid)) { *condat << "<div class=\"blog_adminmenu\">" condat << "<div class=\"blog_adminmenu\">" << "<ul>" << "<li><a href=\"" << Args->config->buildurl("content/edit/",url,512) << cid << "\">Bearbeiten</a></li>" << "<li><a href=\"" << Args->config->buildurl("content/del/",url,512) << cid << "\">Loeschen</a></li>" << "</ul>" << "</div>"; } *condat << "<div class=\"blog_entry\">" condat << "<div class=\"blog_entry\">" << "<span class=\"title\">" << res[0][1] << "</span>" << "<div class=\"text\">" << res[0][2] << "</div>" << "<span class=\"author\">verfasst von " << res[0][3] << " am "<< res[0][4] <<" </span>" Loading @@ -202,15 +204,12 @@ namespace blogi { libhtmlpp::HtmlString out; try{ page.getElementbyID("main")->insertChild(condat->parse()); page.getElementbyID("main")->insertChild(condat.parse()); }catch(libhtmlpp::HTMLException &e){ delete condat; excep[libhttppp::HTTPException::Error] << e.what(); throw excep; } delete condat; Args->theme->printSite(tid,out,&page,curreq->getRequestURL(),Args->auth->isLoggedIn(tid,curreq,sid)); libhttppp::HttpResponse resp; Loading
plugins/media/redis.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ size_t blogi::RedisStore::getSize(int tid,const char* key){ redisReply *rep=(redisReply*)redisCommand(_RedisCTX[tid],"STRLEN %s",key); if(!rep || rep->type != REDIS_REPLY_INTEGER){ freeReplyObject(rep); libhttppp::HTTPException e; e[libhttppp::HTTPException::Error] << "media plugin err: wrong redis reply in getsize !"; throw e; Loading @@ -96,6 +97,7 @@ void blogi::RedisStore::load(int tid,libhttppp::HttpRequest *req,const char *key redisReply *rep=(redisReply*)redisCommand(_RedisCTX[tid],"GETRANGE %s %d %d",key,pos,pos+blocksize); if(_RedisCTX[tid]->err!=REDIS_OK){ freeReplyObject(rep); libhttppp::HTTPException e; e[libhttppp::HTTPException::Error] << "media plugin err: " << _RedisCTX[tid]->errstr; throw e; Loading
src/blogi.cpp +14 −15 Original line number Diff line number Diff line Loading @@ -62,9 +62,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "sqlite.cpp" blogi::Blogi::Blogi(Config *blgcfg,netplus::socket *serversocket) : HttpEvent(serversocket){ blogi::Blogi::Blogi(Config *blgcfg,netplus::socket *serversocket,bool debug) : HttpEvent(serversocket){ PlgArgs = new PluginArgs; PlgArgs->debug=debug; PlgArgs->config=blgcfg; PlgArgs->database=new Database*[threads]; Loading @@ -83,7 +84,7 @@ blogi::Blogi::Blogi(Config *blgcfg,netplus::socket *serversocket) : HttpEvent(se tplcfg.Theme=tplcfg.config->gettemplate(); tplcfg.TDatabase=PlgArgs->database; PlgArgs->theme=new Template(tplcfg); PlgArgs->theme=new Template(tplcfg,debug); PlgArgs->theme->renderPage(0,"index.html",Page,Index); Loading Loading @@ -140,12 +141,12 @@ void blogi::Blogi::loginPage(libhttppp::HttpRequest *curreq,const int tid){ libhtmlpp::HtmlString out; std::shared_ptr<libhtmlpp::HtmlElement> index; libhtmlpp::HtmlElement index; if(curreq->isMobile()) *index=MIndex; index=MIndex; else *index=Index; index=Index; if (username.empty() || password.empty()) { libhtmlpp::HtmlString condat; Loading @@ -158,14 +159,14 @@ void blogi::Blogi::loginPage(libhttppp::HttpRequest *curreq,const int tid){ << "</form>" << "</div>"; if(index->getElementbyID("main")) index->getElementbyID("main")->insertChild(condat.parse()); if(index.getElementbyID("main")) index.getElementbyID("main")->insertChild(condat.parse()); for(blogi::Plugin::PluginData *curplg=BlogiPlg->getFirstPlugin(); curplg; curplg=curplg->getNextPlg()){ curplg->getInstace()->Rendering(tid,curreq,&*index); curplg->getInstace()->Rendering(tid,curreq,&index); } PlgArgs->theme->printSite(tid,out,&*index,curreq->getRequestURL(),false); PlgArgs->theme->printSite(tid,out,&index,curreq->getRequestURL(),false); libhttppp::HttpResponse curres; curres.setState(HTTP200); curres.setVersion(HTTPVERSION(1.1)); Loading Loading @@ -413,13 +414,13 @@ void blogi::Blogi::ResponseEvent(libhttppp::HttpRequest* curreq,const int tid,vo class HttpConD : public libhttppp::HttpD { public: HttpConD(blogi::Config *blgcfg) HttpConD(blogi::Config *blgcfg,bool debug) : HttpD(blgcfg->gethttpaddr(),blgcfg->gethttpport(),blgcfg->gethttpmaxcon(),blgcfg->getsslcertpath(),blgcfg->getsslkeypath()){ libhttppp::HTTPException httpexception; try { blogi::Session session; try{ blogi::Blogi blg(blgcfg,getServerSocket()); blogi::Blogi blg(blgcfg,getServerSocket(),debug); #ifndef Windows struct passwd *pwd=getpwnam("blogi"); seteuid(pwd->pw_uid); Loading Loading @@ -492,12 +493,10 @@ int main(int argc, char** argv){ int pid = daemon(1,1); if(pid==0){ HttpConD blogiD(cins); }else if(pid>0){ HttpConD blogiD(cins,false); } }else{ HttpConD blogiD(cins); HttpConD blogiD(cins,true); } #else HttpConD blogiD(cins); Loading
src/blogi.h +1 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace blogi { class Blogi : public libhttppp::HttpEvent { public: Blogi(Config *blgcfg,netplus::socket *serversocket); Blogi(Config *blgcfg,netplus::socket *serversocket,bool debug); ~Blogi(); void loginPage(libhttppp::HttpRequest *curreq,const int tid); void logoutPage(libhttppp::HttpRequest *curreq,const int tid); Loading
src/plugin.h +1 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ namespace blogi { Editor *edit; Config *config; int maxthreads; bool debug; }; class PluginApi { Loading