Loading .kdev4/libhttppp.kdev4 +3 −0 Changes for .kdev4/libhttppp.kdev4: 3 added lines, 0 removed lines. Original line number Diff line number Diff line [Buildset] BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x12\x00l\x00i\x00b\x00h\x00t\x00t\x00p\x00p\x00p) [CMake] Build Directory Count=1 Current Build Directory Index-Host System=0 Loading examples/httpsysinfo.cpp +37 −44 Changes for examples/httpsysinfo.cpp: 37 added lines, 44 removed lines. Original line number Diff line number Diff line Loading @@ -51,6 +51,12 @@ #include <sys/resource.h> #endif // !Windows #define INDEXPAGE "<!DOCTYPE html><html lang=\"en\" ><head><title>sysinfo</title></head><body style=\"color:rgb(239, 240, 241); background:rgb(79, 83, 88);\">\ <div id=\"mainbar\" style=\"border-radius: 38px; background:rgb(35, 38, 41); width:1280px; margin:0px auto;\">\ <div id=\"headerimage\"><img alt=\"headerimage\" src=\"images/header.png\"></div>\ <div id=\"sysinfo\" style=\"padding:40px 20px;\"><span class=\"sysheader\">System Info:</span><br>\ </div></div></body></html>" class HtmlTable{ public: HtmlTable(const char *id=NULL){ Loading Loading @@ -132,51 +138,40 @@ class HtmlContent{ }; class IndexPage{ class Sysinfo{ public: IndexPage(){ _Index << "<!DOCTYPE html><html lang=\"en\" ><head><title>sysinfo</title> </head><body style=\"color:rgb(239, 240, 241); background:rgb(79, 83, 88);\">" << "<div id=\"mainbar\" style=\"border-radius: 38px; background:rgb(35, 38, 41); width:1280px; margin:0px auto;\">" << "<div id=\"headerimage\"><img alt=\"headerimage\" src=\"images/header.png\"></div>" << "<div id=\"sysinfo\" style=\"padding:40px 20px;\"><span>System Info:</span><br>"; TimeInfo(); KernelInfo(); _Index << "</div></div></body></html>"; } void TimeInfo() { void TimeInfo(libhtmlpp::HtmlElement &index) { std::time_t t = std::time(0); std::tm* mytime = std::localtime(&t); _Index << "<h2>Date & Time:</h2>"; _Index << "<span>Date:" << (unsigned long)mytime->tm_mday << "." libhtmlpp::HtmlString html; html << "<span>Date & Time:</span>"; html << "<span>Date:" << (unsigned long)mytime->tm_mday << "." << (unsigned long)mytime->tm_mon << "." << (unsigned long)mytime->tm_year << " </span>" << "<span>Time:" << (unsigned long)mytime->tm_hour << ":" << (unsigned long)mytime->tm_min << ":" << (unsigned long)mytime->tm_sec << "</span>"; } void KernelInfo(){ #ifndef Windows struct utsname usysinfo; uname(&usysinfo); HtmlTable htmltable; htmltable.createRow() << "<td>Operating system</td><td>" << usysinfo.sysname <<"</td>"; htmltable.createRow() << "<td>Release Version</td><td>" << usysinfo.release <<"</td>"; htmltable.createRow() << "<td>Hardware</td><td>" << usysinfo.machine <<"</td>"; _Index << "<h2>KernelInfo:</h2>"; std::string table; htmltable.getTable(table); _Index << table; #endif } libhtmlpp::HtmlElement *sysdiv=nullptr; sysdiv=index.getElementbyID("sysinfo"); if(sysdiv) sysdiv->appendChild(html.parse()); } // void KernelInfo(){ // #ifndef Windows // struct utsname usysinfo; // uname(&usysinfo); // HtmlTable htmltable; // htmltable.createRow() << "<td>Operating system</td><td>" << usysinfo.sysname <<"</td>"; // htmltable.createRow() << "<td>Release Version</td><td>" << usysinfo.release <<"</td>"; // htmltable.createRow() << "<td>Hardware</td><td>" << usysinfo.machine <<"</td>"; // _Index << "<h2>KernelInfo:</h2>"; // std::string table; // htmltable.getTable(table); // _Index << table; // #endif // } void getIndexPage(std::string &index){ index=_Index.str(); } private: std::stringstream _Index; }; class Controller : public netplus::event { Loading @@ -196,20 +191,18 @@ public: std::cout << cururl << std::endl; if(strncmp(cururl,"/",strlen(cururl))==0){ curres.setContentType("text/html"); IndexPage idx; std::string html; libhtmlpp::HtmlPage index; idx.getIndexPage(html); index.loadString(html); index.printHtml(html); libhtmlpp::HtmlPage page; libhtmlpp::HtmlElement *index=page.loadString(INDEXPAGE)->parse(); Sysinfo sys; sys.TimeInfo(*index); libhtmlpp::print(index,nullptr,html); curres.send(curcon,html.c_str(),html.length()); }else if(strncmp(cururl,"/images/header.png",16)==0){ }else if(strncmp(cururl,"/images/header.png",18)==0){ curres.setContentType("image/png"); curres.setContentLength(header_png_size); curres.send(curcon,(const char*)header_png,header_png_size); }else if(strncmp(cururl,"/favicon.ico ",12)==0){ curres.setContentType("image/ico"); curres.setContentLength(favicon_ico_size); curres.send(curcon,(const char*)favicon_ico,favicon_ico_size); }else{ curres.setState(HTTP404); Loading Loading
.kdev4/libhttppp.kdev4 +3 −0 Changes for .kdev4/libhttppp.kdev4: 3 added lines, 0 removed lines. Original line number Diff line number Diff line [Buildset] BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x12\x00l\x00i\x00b\x00h\x00t\x00t\x00p\x00p\x00p) [CMake] Build Directory Count=1 Current Build Directory Index-Host System=0 Loading
examples/httpsysinfo.cpp +37 −44 Changes for examples/httpsysinfo.cpp: 37 added lines, 44 removed lines. Original line number Diff line number Diff line Loading @@ -51,6 +51,12 @@ #include <sys/resource.h> #endif // !Windows #define INDEXPAGE "<!DOCTYPE html><html lang=\"en\" ><head><title>sysinfo</title></head><body style=\"color:rgb(239, 240, 241); background:rgb(79, 83, 88);\">\ <div id=\"mainbar\" style=\"border-radius: 38px; background:rgb(35, 38, 41); width:1280px; margin:0px auto;\">\ <div id=\"headerimage\"><img alt=\"headerimage\" src=\"images/header.png\"></div>\ <div id=\"sysinfo\" style=\"padding:40px 20px;\"><span class=\"sysheader\">System Info:</span><br>\ </div></div></body></html>" class HtmlTable{ public: HtmlTable(const char *id=NULL){ Loading Loading @@ -132,51 +138,40 @@ class HtmlContent{ }; class IndexPage{ class Sysinfo{ public: IndexPage(){ _Index << "<!DOCTYPE html><html lang=\"en\" ><head><title>sysinfo</title> </head><body style=\"color:rgb(239, 240, 241); background:rgb(79, 83, 88);\">" << "<div id=\"mainbar\" style=\"border-radius: 38px; background:rgb(35, 38, 41); width:1280px; margin:0px auto;\">" << "<div id=\"headerimage\"><img alt=\"headerimage\" src=\"images/header.png\"></div>" << "<div id=\"sysinfo\" style=\"padding:40px 20px;\"><span>System Info:</span><br>"; TimeInfo(); KernelInfo(); _Index << "</div></div></body></html>"; } void TimeInfo() { void TimeInfo(libhtmlpp::HtmlElement &index) { std::time_t t = std::time(0); std::tm* mytime = std::localtime(&t); _Index << "<h2>Date & Time:</h2>"; _Index << "<span>Date:" << (unsigned long)mytime->tm_mday << "." libhtmlpp::HtmlString html; html << "<span>Date & Time:</span>"; html << "<span>Date:" << (unsigned long)mytime->tm_mday << "." << (unsigned long)mytime->tm_mon << "." << (unsigned long)mytime->tm_year << " </span>" << "<span>Time:" << (unsigned long)mytime->tm_hour << ":" << (unsigned long)mytime->tm_min << ":" << (unsigned long)mytime->tm_sec << "</span>"; } void KernelInfo(){ #ifndef Windows struct utsname usysinfo; uname(&usysinfo); HtmlTable htmltable; htmltable.createRow() << "<td>Operating system</td><td>" << usysinfo.sysname <<"</td>"; htmltable.createRow() << "<td>Release Version</td><td>" << usysinfo.release <<"</td>"; htmltable.createRow() << "<td>Hardware</td><td>" << usysinfo.machine <<"</td>"; _Index << "<h2>KernelInfo:</h2>"; std::string table; htmltable.getTable(table); _Index << table; #endif } libhtmlpp::HtmlElement *sysdiv=nullptr; sysdiv=index.getElementbyID("sysinfo"); if(sysdiv) sysdiv->appendChild(html.parse()); } // void KernelInfo(){ // #ifndef Windows // struct utsname usysinfo; // uname(&usysinfo); // HtmlTable htmltable; // htmltable.createRow() << "<td>Operating system</td><td>" << usysinfo.sysname <<"</td>"; // htmltable.createRow() << "<td>Release Version</td><td>" << usysinfo.release <<"</td>"; // htmltable.createRow() << "<td>Hardware</td><td>" << usysinfo.machine <<"</td>"; // _Index << "<h2>KernelInfo:</h2>"; // std::string table; // htmltable.getTable(table); // _Index << table; // #endif // } void getIndexPage(std::string &index){ index=_Index.str(); } private: std::stringstream _Index; }; class Controller : public netplus::event { Loading @@ -196,20 +191,18 @@ public: std::cout << cururl << std::endl; if(strncmp(cururl,"/",strlen(cururl))==0){ curres.setContentType("text/html"); IndexPage idx; std::string html; libhtmlpp::HtmlPage index; idx.getIndexPage(html); index.loadString(html); index.printHtml(html); libhtmlpp::HtmlPage page; libhtmlpp::HtmlElement *index=page.loadString(INDEXPAGE)->parse(); Sysinfo sys; sys.TimeInfo(*index); libhtmlpp::print(index,nullptr,html); curres.send(curcon,html.c_str(),html.length()); }else if(strncmp(cururl,"/images/header.png",16)==0){ }else if(strncmp(cururl,"/images/header.png",18)==0){ curres.setContentType("image/png"); curres.setContentLength(header_png_size); curres.send(curcon,(const char*)header_png,header_png_size); }else if(strncmp(cururl,"/favicon.ico ",12)==0){ curres.setContentType("image/ico"); curres.setContentLength(favicon_ico_size); curres.send(curcon,(const char*)favicon_ico,favicon_ico_size); }else{ curres.setState(HTTP404); Loading