diff --git a/Debug/main.cpp.o b/Debug/main.cpp.o index 41ff6db..c2a0402 100644 Binary files a/Debug/main.cpp.o and b/Debug/main.cpp.o differ diff --git a/Debug/main.cpp.o.d b/Debug/main.cpp.o.d index 2223d3f..98d55e9 100644 --- a/Debug/main.cpp.o.d +++ b/Debug/main.cpp.o.d @@ -8,10 +8,14 @@ Debug/main.cpp.o: main.cpp ../ServerCore/includes ../ServerCore/EPoll.h \ ../ServerCore/CommandList.h ../ServerCore/EPoll.h \ ../ServerCore/Exception.h ../ServerCore/File.h ../ServerCore/Log.h \ ../ServerCore/IPAddress.h HTTPService.h ../ServerCore/Service.h \ - HTTPSessions.h ../ServerCore/Header.h ../ServerCore/Response.h \ - PageList.h ../ServerCore/CommandList.h ../ServerCore/Session.h __index.h \ - HTTPPage.h HTTPSession.h __setupadmin.h __favicon_ico.h HTTPHandler.h \ - ../ServerCore/Command.h + HTTPSessions.h HTTPRequest.h ../CoreUtils/PString.h \ + ../CoreUtils/includes ../CoreUtils/IMFMessage.h ../CoreUtils/PString.h \ + ../CoreUtils/IMFHeader.h ../CoreUtils/IMFRequest.h \ + ../CoreUtils/IMFBody.h ../CoreUtils/IMFRequest.h \ + ../CoreUtils/IMFResponse.h ../CoreUtils/IMFMessage.h HTTPPageList.h \ + ../ServerCore/Session.h __index.h HTTPPage.h HTTPSession.h __script.h \ + __editview.h __style.h __setupadmin.h __favicon_ico.h __welcome.h \ + __mainmenu.h __newview.h HTTPHandler.h ../ServerCore/Command.h ../ServerCore/includes: @@ -63,13 +67,29 @@ HTTPService.h: HTTPSessions.h: -../ServerCore/Header.h: +HTTPRequest.h: -../ServerCore/Response.h: +../CoreUtils/PString.h: -PageList.h: +../CoreUtils/includes: -../ServerCore/CommandList.h: +../CoreUtils/IMFMessage.h: + +../CoreUtils/PString.h: + +../CoreUtils/IMFHeader.h: + +../CoreUtils/IMFRequest.h: + +../CoreUtils/IMFBody.h: + +../CoreUtils/IMFRequest.h: + +../CoreUtils/IMFResponse.h: + +../CoreUtils/IMFMessage.h: + +HTTPPageList.h: ../ServerCore/Session.h: @@ -79,10 +99,22 @@ HTTPPage.h: HTTPSession.h: +__script.h: + +__editview.h: + +__style.h: + __setupadmin.h: __favicon_ico.h: +__welcome.h: + +__mainmenu.h: + +__newview.h: + HTTPHandler.h: ../ServerCore/Command.h: diff --git a/HTTPHandler.cpp b/HTTPHandler.cpp index 75ae597..afc4d59 100644 --- a/HTTPHandler.cpp +++ b/HTTPHandler.cpp @@ -1,34 +1,35 @@ #include "HTTPHandler.h" #include "HTTPSession.h" #include "HTTPService.h" +#include "HTTPRequest.h" +#include "PString.h" #include "Log.h" namespace http { int HTTPHandler::processCommand(std::string request, core::Session *session, std::stringstream &data) { - core::Header header(request); - core::Response response; + coreutils::PString request1(request); + HTTPRequest httpRequest(request1); - core::Log(core::LOG_DEBUG_1) << "Request: " << request; + core::Log(core::LOG_DEBUG_2) << "Host value is " << httpRequest.getHeader("Host"); + core::Log(core::LOG_DEBUG_3) << "Request: " << request; - HTTPSession *httpSession = ((HTTPService &)session->service).httpSessions.findSessionByHeader(header, response); + HTTPSession *httpSession = ((HTTPService &)session->service).httpSessions.findSessionByHeader(httpRequest); std::stringstream content; - if(((HTTPService &)session->service).pageList.processRequest(header.getPath() + " ", session, httpSession, content)) { - response.setProtocol(header.requestProtocol()); - response.setCode("200"); - response.setText("OK"); - response.setMimeType("text/html"); - data << response.getResponse(content.str()); + if(((HTTPService &)session->service).pageList.processRequest(httpRequest.request.getURI(), session, httpSession, httpRequest, content)) { + httpRequest.response.setProtocol(httpRequest.request.getProtocol()); + httpRequest.response.setCode("200"); + httpRequest.response.setText("OK"); + data << httpRequest.response.getResponse(content.str()); } else { - response.setProtocol(header.requestProtocol()); - response.setCode("404"); - response.setText("Not Found"); - response.setMimeType("text/html"); - data << response.getResponse(content.str()); + httpRequest.response.setProtocol(httpRequest.request.getProtocol()); + httpRequest.response.setCode("404"); + httpRequest.response.setText("Not Found"); + data << httpRequest.response.getResponse(content.str()); } return true; diff --git a/HTTPHandler.h b/HTTPHandler.h index 4788925..a1a3c50 100644 --- a/HTTPHandler.h +++ b/HTTPHandler.h @@ -3,8 +3,6 @@ #include "Command.h" #include "Session.h" -#include "Header.h" -#include "Response.h" #include "Log.h" namespace http { diff --git a/HTTPPage.h b/HTTPPage.h index d915524..1ed6a86 100644 --- a/HTTPPage.h +++ b/HTTPPage.h @@ -2,13 +2,29 @@ #define __HTTPPage_h__ #include "HTTPSession.h" +#include "Log.h" namespace http { class HTTPPage : public core::Object { - public: - virtual int processCommand(std::string request, core::Session *session, HTTPSession *httpSession, std::stringstream &data) { + public: + bool check(std::string request) { + if(request != "") { + if(name.length() > 0) { + if(name == request) + return true; + } + return false; + } + return false; + } + + virtual int processCommand(std::string request, + core::Session *session, + HTTPSession *httpSession, + HTTPRequest &httpRequest, + std::stringstream &data) { return false; } diff --git a/HTTPPageList.cpp b/HTTPPageList.cpp index fc3a778..20f0db7 100644 --- a/HTTPPageList.cpp +++ b/HTTPPageList.cpp @@ -2,10 +2,10 @@ namespace http { - bool HTTPPageList::processRequest(std::string request, core::Session *session, HTTPSession *httpSession, std::stringstream &data) { + bool HTTPPageList::processRequest(std::string request, core::Session *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) { for(auto *page : pages) { if(page->check(request)) { - page->processCommand(request, session, httpSession, data); + page->processCommand(request, session, httpSession, httpRequest, data); return true; } } @@ -13,8 +13,8 @@ namespace http { } void HTTPPageList::add(HTTPPage &page, std::string name) { - page.setName(name); - pages.push_back(&command); + page.name = name; + pages.push_back(&page); } diff --git a/HTTPPageList.h b/HTTPPageList.h index 5aceb2a..6342f1f 100644 --- a/HTTPPageList.h +++ b/HTTPPageList.h @@ -2,9 +2,16 @@ #define __HTTPPageList_h__ #include "Session.h" +#include "HTTPRequest.h" #include "__index.h" +#include "__script.h" +#include "__editview.h" +#include "__style.h" #include "__setupadmin.h" #include "__favicon_ico.h" +#include "__welcome.h" +#include "__mainmenu.h" +#include "__newview.h" namespace http { @@ -12,12 +19,18 @@ namespace http { public: HTTPPageList() { - add(index, "/ "); - add(setupadmin, "/setupadmin "); + add(index, "/"); + add(script, "/script"); + add(editview, "/editview"); + add(style, "/style"); + add(setupadmin, "/setupadmin"); add(favicon_ico, "/favicon.ico"); + add(welcome, "/welcome"); + add(mainmenu, "/mainmenu"); + add(newview, "/newview"); } - bool processRequest(std::string request, core::Session *session, HTTPSession *httpSession, std::stringstream &data); + bool processRequest(std::string request, core::Session *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data); void add(HTTPPage &page, std::string name = ""); @@ -28,8 +41,14 @@ namespace http { private: __index index; + __script script; + __style style; + __editview editview; __setupadmin setupadmin; __favicon_ico favicon_ico; + __welcome welcome; + __mainmenu mainmenu; + __newview newview; }; diff --git a/HTTPRequest.h b/HTTPRequest.h new file mode 100644 index 0000000..c176139 --- /dev/null +++ b/HTTPRequest.h @@ -0,0 +1,27 @@ +#ifndef __HTTPRequest_h__ +#define __HTTPRequest_h__ + +#include "PString.h" +#include "IMFMessage.h" +#include "IMFRequest.h" +#include "IMFResponse.h" + +namespace http { + + class HTTPRequest : public coreutils::IMFMessage { + + public: + HTTPRequest(); + HTTPRequest(coreutils::PString &in) { + request = coreutils::IMFRequest(in); + parse(in); + } + + coreutils::IMFRequest request; + coreutils::IMFResponse response; + + }; + +} + +#endif diff --git a/HTTPServer.mk b/HTTPServer.mk index 3065547..9fefb24 100644 --- a/HTTPServer.mk +++ b/HTTPServer.mk @@ -5,16 +5,16 @@ ## Debug ProjectName :=HTTPServer ConfigurationName :=Debug -WorkspacePath :=/home/barant -ProjectPath :=/home/barant/barant/HTTPServer +WorkspacePath :=/home/bradarant/barant +ProjectPath :=/home/bradarant/barant/HTTPServer IntermediateDirectory :=./Debug OutDir := $(IntermediateDirectory) CurrentFileName := CurrentFilePath := CurrentFileFullPath := -User :=root -Date :=05/31/19 -CodeLitePath :=/home/barant/.codelite +User :=Brad Arant +Date :=10/07/19 +CodeLitePath :=/home/bradarant/.codelite LinkerName :=/usr/bin/x86_64-linux-gnu-g++ SharedObjectLinkerName :=/usr/bin/x86_64-linux-gnu-g++ -shared -fPIC ObjectSuffix :=.o @@ -36,12 +36,12 @@ ObjectsFileList :="HTTPServer.txt" PCHCompileFlags := MakeDirCommand :=mkdir -p LinkOptions := -IncludePath := $(IncludeSwitch). $(IncludeSwitch). $(IncludeSwitch)../ServerCore/ +IncludePath := $(IncludeSwitch). $(IncludeSwitch). $(IncludeSwitch)../ServerCore/ $(IncludeSwitch)../CoreUtils IncludePCH := RcIncludePath := -Libs := $(LibrarySwitch)ServerCore $(LibrarySwitch)pthread $(LibrarySwitch)uuid -ArLibs := "ServerCore" "pthread" "uuid" -LibPath := $(LibraryPathSwitch). $(LibraryPathSwitch)../ServerCore/Debug/ +Libs := $(LibrarySwitch)ServerCore $(LibrarySwitch)CoreUtils $(LibrarySwitch)pthread $(LibrarySwitch)uuid +ArLibs := "ServerCore" "CoreUtils" "pthread" "uuid" +LibPath := $(LibraryPathSwitch). $(LibraryPathSwitch)../ServerCore/Debug/ $(LibraryPathSwitch)../CoreUtils/Debug ## ## Common variables @@ -92,7 +92,7 @@ PreBuild: ## Objects ## $(IntermediateDirectory)/main.cpp$(ObjectSuffix): main.cpp $(IntermediateDirectory)/main.cpp$(DependSuffix) - $(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/barant/HTTPServer/main.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/main.cpp$(ObjectSuffix) $(IncludePath) + $(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/HTTPServer/main.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/main.cpp$(ObjectSuffix) $(IncludePath) $(IntermediateDirectory)/main.cpp$(DependSuffix): main.cpp @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/main.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/main.cpp$(DependSuffix) -MM main.cpp @@ -100,7 +100,7 @@ $(IntermediateDirectory)/main.cpp$(PreprocessSuffix): main.cpp $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/main.cpp$(PreprocessSuffix) main.cpp $(IntermediateDirectory)/HTTPSession.cpp$(ObjectSuffix): HTTPSession.cpp $(IntermediateDirectory)/HTTPSession.cpp$(DependSuffix) - $(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/barant/HTTPServer/HTTPSession.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/HTTPSession.cpp$(ObjectSuffix) $(IncludePath) + $(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/HTTPServer/HTTPSession.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/HTTPSession.cpp$(ObjectSuffix) $(IncludePath) $(IntermediateDirectory)/HTTPSession.cpp$(DependSuffix): HTTPSession.cpp @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/HTTPSession.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/HTTPSession.cpp$(DependSuffix) -MM HTTPSession.cpp @@ -108,7 +108,7 @@ $(IntermediateDirectory)/HTTPSession.cpp$(PreprocessSuffix): HTTPSession.cpp $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/HTTPSession.cpp$(PreprocessSuffix) HTTPSession.cpp $(IntermediateDirectory)/HTTPSessions.cpp$(ObjectSuffix): HTTPSessions.cpp $(IntermediateDirectory)/HTTPSessions.cpp$(DependSuffix) - $(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/barant/HTTPServer/HTTPSessions.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/HTTPSessions.cpp$(ObjectSuffix) $(IncludePath) + $(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/HTTPServer/HTTPSessions.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/HTTPSessions.cpp$(ObjectSuffix) $(IncludePath) $(IntermediateDirectory)/HTTPSessions.cpp$(DependSuffix): HTTPSessions.cpp @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/HTTPSessions.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/HTTPSessions.cpp$(DependSuffix) -MM HTTPSessions.cpp @@ -116,7 +116,7 @@ $(IntermediateDirectory)/HTTPSessions.cpp$(PreprocessSuffix): HTTPSessions.cpp $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/HTTPSessions.cpp$(PreprocessSuffix) HTTPSessions.cpp $(IntermediateDirectory)/HTTPHandler.cpp$(ObjectSuffix): HTTPHandler.cpp $(IntermediateDirectory)/HTTPHandler.cpp$(DependSuffix) - $(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/barant/HTTPServer/HTTPHandler.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/HTTPHandler.cpp$(ObjectSuffix) $(IncludePath) + $(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/HTTPServer/HTTPHandler.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/HTTPHandler.cpp$(ObjectSuffix) $(IncludePath) $(IntermediateDirectory)/HTTPHandler.cpp$(DependSuffix): HTTPHandler.cpp @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/HTTPHandler.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/HTTPHandler.cpp$(DependSuffix) -MM HTTPHandler.cpp @@ -124,7 +124,7 @@ $(IntermediateDirectory)/HTTPHandler.cpp$(PreprocessSuffix): HTTPHandler.cpp $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/HTTPHandler.cpp$(PreprocessSuffix) HTTPHandler.cpp $(IntermediateDirectory)/HTTPPageList.cpp$(ObjectSuffix): HTTPPageList.cpp $(IntermediateDirectory)/HTTPPageList.cpp$(DependSuffix) - $(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/barant/HTTPServer/HTTPPageList.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/HTTPPageList.cpp$(ObjectSuffix) $(IncludePath) + $(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/HTTPServer/HTTPPageList.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/HTTPPageList.cpp$(ObjectSuffix) $(IncludePath) $(IntermediateDirectory)/HTTPPageList.cpp$(DependSuffix): HTTPPageList.cpp @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/HTTPPageList.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/HTTPPageList.cpp$(DependSuffix) -MM HTTPPageList.cpp diff --git a/HTTPServer.project b/HTTPServer.project index 4d284f3..4e90b45 100644 --- a/HTTPServer.project +++ b/HTTPServer.project @@ -17,6 +17,13 @@ + + + + + + + @@ -34,10 +41,13 @@ + + + diff --git a/HTTPServer.txt b/HTTPServer.txt index bbfbe1f..3174362 100644 --- a/HTTPServer.txt +++ b/HTTPServer.txt @@ -1 +1 @@ -./Debug/main.cpp.o ./Debug/HTTPSession.cpp.o ./Debug/HTTPSessions.cpp.o ./Debug/HTTPHandler.cpp.o +./Debug/main.cpp.o ./Debug/HTTPSession.cpp.o ./Debug/HTTPSessions.cpp.o ./Debug/HTTPHandler.cpp.o ./Debug/HTTPPageList.cpp.o diff --git a/HTTPSession.cpp b/HTTPSession.cpp index 54984b4..2b5b254 100644 --- a/HTTPSession.cpp +++ b/HTTPSession.cpp @@ -2,6 +2,11 @@ namespace http { + HTTPSession::HTTPSession() { + sessionId = ""; + } + + HTTPSession::HTTPSession(std::string sessionId) { this->sessionId = sessionId; } diff --git a/HTTPSession.h b/HTTPSession.h index 0820860..2e9e7a8 100644 --- a/HTTPSession.h +++ b/HTTPSession.h @@ -1,16 +1,20 @@ #ifndef __HTTPSession_h__ #define __HTTPSession_h__ -#include "Response.h" +#include "includes" namespace http { class HTTPSession { public: + HTTPSession(); HTTPSession(std::string sessionId); std::string getSessionId(); + jet::Variables sessionVariables; + jet::Variables cgiFormVariables; + private: std::string sessionId; diff --git a/HTTPSessions.cpp b/HTTPSessions.cpp index 197bb9a..0b37319 100644 --- a/HTTPSessions.cpp +++ b/HTTPSessions.cpp @@ -5,19 +5,27 @@ namespace http { - HTTPSession * HTTPSessions::findSessionByHeader(core::Header &header, core::Response &response) { - std::string sessionId = header.getCookie("sessionId"); - HTTPSession *session = findSessionById(sessionId, response); + HTTPSession * HTTPSessions::findSessionByHeader(HTTPRequest &httpRequest) { + std::string sessionId = httpRequest.getHeaderKeyPairValue("Cookie", "sessionId"); + HTTPSession *session = findSessionById(sessionId, httpRequest); return session; } - HTTPSession * HTTPSessions::findSessionById(std::string sessionId, core::Response &response) { + HTTPSession * HTTPSessions::findSessionById(std::string sessionId, HTTPRequest &httpRequest) { HTTPSession *httpSession; if(sessionId.length() > 0) { - httpSession = (HTTPSession *)sessions.find(sessionId)->second; + std::map::iterator ix; + ix = sessions.find(sessionId); + httpSession = ix->second; + if(ix == sessions.end()) { + httpSession = createHTTPSession(); + httpRequest.response.setCookie("sessionId", httpSession->getSessionId()); + } + core::Log(core::LOG_DEBUG_1) << "http session: " << "(" << sessionId << ") " << httpSession; + } else { httpSession = createHTTPSession(); - response.setCookie("sessionId", httpSession->getSessionId()); + httpRequest.response.setCookie("sessionId", httpSession->getSessionId()); } return httpSession; } diff --git a/HTTPSessions.h b/HTTPSessions.h index 7645fa9..3e904a2 100644 --- a/HTTPSessions.h +++ b/HTTPSessions.h @@ -1,8 +1,7 @@ #ifndef __HTTPSessions_h__ #define __HTTPSessions_h__ -#include "Header.h" -#include "Response.h" +#include "HTTPRequest.h" namespace http { @@ -11,8 +10,8 @@ namespace http { class HTTPSessions { public: - HTTPSession * findSessionByHeader(core::Header &header, core::Response &response); - HTTPSession * findSessionById(std::string sessionId, core::Response &response); + HTTPSession * findSessionByHeader(HTTPRequest &httpRequest); + HTTPSession * findSessionById(std::string sessionId, HTTPRequest &httpRequest); private: HTTPSession * createHTTPSession(); diff --git a/Release/main.cpp.o b/Release/main.cpp.o index 24af4fa..d49486f 100644 Binary files a/Release/main.cpp.o and b/Release/main.cpp.o differ diff --git a/Release/main.cpp.o.d b/Release/main.cpp.o.d index 626f018..28a48a1 100644 --- a/Release/main.cpp.o.d +++ b/Release/main.cpp.o.d @@ -7,9 +7,11 @@ Release/main.cpp.o: main.cpp ../ServerCore/includes ../ServerCore/EPoll.h \ ../ServerCore/TCPServerSocket.h ../ServerCore/Service.h \ ../ServerCore/CommandList.h ../ServerCore/EPoll.h \ ../ServerCore/Exception.h ../ServerCore/File.h ../ServerCore/Log.h \ - ../ServerCore/IPAddress.h HTTPService.h ../ServerCore/Service.h _GET.h \ - ../ServerCore/Command.h ../ServerCore/Session.h ../ServerCore/Header.h \ - ../ServerCore/Response.h _POST.h + ../ServerCore/IPAddress.h HTTPService.h ../ServerCore/Service.h \ + HTTPSessions.h ../ServerCore/Header.h ../ServerCore/Response.h \ + HTTPPageList.h ../ServerCore/Session.h __index.h HTTPPage.h \ + HTTPSession.h __script.h __style.h __setupadmin.h __favicon_ico.h \ + __welcome.h HTTPHandler.h ../ServerCore/Command.h ../ServerCore/includes: @@ -59,14 +61,32 @@ HTTPService.h: ../ServerCore/Service.h: -_GET.h: - -../ServerCore/Command.h: - -../ServerCore/Session.h: +HTTPSessions.h: ../ServerCore/Header.h: ../ServerCore/Response.h: -_POST.h: +HTTPPageList.h: + +../ServerCore/Session.h: + +__index.h: + +HTTPPage.h: + +HTTPSession.h: + +__script.h: + +__style.h: + +__setupadmin.h: + +__favicon_ico.h: + +__welcome.h: + +HTTPHandler.h: + +../ServerCore/Command.h: diff --git a/__editbiew.js b/__editbiew.js new file mode 100644 index 0000000..fcabf39 --- /dev/null +++ b/__editbiew.js @@ -0,0 +1,307 @@ + + + var mainpage; + var result; + var mousedownx; + var mousedowny; + var mouseDownWidth; + var mouseDownHeight; + var ismousedown = false; + var dragobject; + var dragHint = "move"; + var data; + var showGrid = false; + var snapToGrid = false; + var gridSize = 10; + var selected; + var itemparameters; + + function init() { + mainpage = document.getElementById("mainpage"); + data = document.getElementById("data"); + itemparameters = document.getElementById("itemparameters"); + var gridsize = document.getElementById("gridsize"); + gridsize.value = gridSize; + drawGrid(); + } + + function drawGrid() { + var grid = document.getElementById("grid"); + var context = grid.getContext("2d"); + if(showGrid == true) { + context.clearRect(0,0,grid.width,grid.height); + context.globalAlpha = 0.2; + context.lineWidth = 0.5; + for(ix = 0; ix < grid.width; ix += gridSize) { + context.beginPath(); + context.moveTo(ix, 0); + context.lineTo(ix, grid.height); + context.stroke(); + context.beginPath(); + context.moveTo(0, ix); + context.lineTo(grid.width, ix); + context.stroke(); + } + } else { + context.clearRect(0,0,grid.width,grid.height); + } + } + + function setDragHint(hint) { + dragHint = hint; + } + + function getMouseX(e) { + return e.clientX - mainpage.offsetLeft - parseFloat(mainpage.style.borderWidth); + } + + function getMouseY(e) { + return e.clientY - mainpage.offsetTop - parseFloat(mainpage.style.borderWidth); + } + + function mousedown(obj, e) { + var mouseX = getMouseX(e); + var mouseY = getMouseY(e); + mousedownx = mouseX - obj.offsetLeft; + mousedowny = mouseY - obj.offsetTop; + mouseDownLeft = parseFloat(obj.style.left); + mouseDownTop = parseFloat(obj.style.top); + mouseDownWidth = parseFloat(obj.style.width); + mouseDownHeight = parseFloat(obj.style.height); + dragobject = obj; + selected = obj; + ismousedown = true; + displayParameters(); + } + + function mouseup() { + ismousedown = false; + dragobject = null; + console.log(mainpage.innerHTML); + } + + function mousemove(e) { + var mouseX = getMouseX(e); + var mouseY = getMouseY(e); + if(ismousedown) { + + if(dragHint == "move") { + if(snapToGrid == false) { + dragobject.style.left = (mouseX - mousedownx) + "px"; + dragobject.style.top = (mouseY - mousedowny) + "px"; + } else { + dragobject.style.left = (Math.round((mouseX - mousedownx) / gridSize) * gridSize) + "px"; + dragobject.style.top = (Math.round((mouseY - mousedowny) / gridSize) * gridSize) + "px"; + } + if((mouseX - mousedownx) < 0) + dragobject.style.left = "0px"; + if((mouseY - mousedowny) < 0) + dragobject.style.top = "0px"; + if((mouseX - mousedownx + parseFloat(dragobject.style.width)) > parseFloat(mainpage.style.width)) + dragobject.style.left = (mouseX - mousedownx) + "px"; + } else if(dragHint == "rightbottomresize") { + dragobject.style.width = (mouseX - mouseDownLeft) + "px"; + dragobject.style.height = (mouseY - mouseDownTop) + "px"; + } else if(dragHint == "rightresize") { + if(snapToGrid == false) { + dragobject.style.width = (mouseX - mouseDownLeft) + "px"; + } else { + dragobject.style.width = (Math.round((mouseX - mouseDownLeft) / gridSize) * gridSize) + "px"; + } + } else if(dragHint == "bottomresize") { + if(snapToGrid == false) { + dragobject.style.height = (mouseY - mouseDownTop) + "px"; + } else { + dragobject.style.height = (Math.round((mouseY - mouseDownTop) / gridSize) * gridSize) + "px"; + } + } else if(dragHint == "leftresize") { + dragobject.style.left = mouseX + "px"; + dragobject.style.width = (mouseDownWidth + (mouseDownLeft - mouseX)) + "px"; + } else if(dragHint == "topresize") { + dragobject.style.top = mouseY + "px"; + dragobject.style.height = (mouseDownHeight + (mouseDownTop - mouseY)) + "px"; + } + + data.innerHTML = "

" + dragobject.nodeName + "
" + + "Action: " + dragHint + "
" + + "MouseLocation: " + mouseX + ":" + mouseY + "
" + + "MouseOver Location: " + (mouseX - dragobject.offsetLeft) + ":" + (mouseY - dragobject.offsetTop) + "
" + + "Location: " + dragobject.style.left + ":" + dragobject.style.top + "
" + + "Size: " + dragobject.style.width + ":" + dragobject.style.height + "
" + + "

"; + + + } else { + var mouseabove = document.elementFromPoint(mouseX + mainpage.offsetLeft, mouseY + mainpage.offsetTop); + + if((mouseabove.id != "mainpage") && (mouseabove.id != "grid")) { + + data.innerHTML = "

" + mouseabove.nodeName + "
" + + "Action: " + dragHint + "
" + + "MouseLocation: " + mouseX + ":" + mouseY + "
" + + "MouseOver Location: " + (mouseX - mouseabove.offsetLeft) + ":" + (mouseY - mouseabove.offsetTop) + "
" + + "Location: " + mouseabove.style.left + ":" + mouseabove.style.top + "
" + + "Size: " + mouseabove.style.width + ":" + mouseabove.style.height + "
" + + "

"; + + if((mouseabove.nodeName == "DIV") || + (mouseabove.nodeName == "IMG") || + (mouseabove.nodeName == "BUTTON") || + (mouseabove.nodeName == "INPUT") || + (mouseabove.nodeName == "SPAN")) { + + if((parseFloat(mouseabove.style.width) <= (mouseX - mouseabove.offsetLeft)) && + (parseFloat(mouseabove.style.height) <= (mouseY - mouseabove.offsetTop))) { + mouseabove.style.cursor = "nwse-resize"; + dragHint = "rightbottomresize"; + } else if((parseFloat(mouseabove.style.left) <= (mouseX - mouseabove.offsetLeft)) && + ((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseY - mouseabove.offsetTop))) { + mouseabove.style.cursor = "nesw-resize"; + dragHint = "righttopresize"; + } else if(((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseX - mouseabove.offsetLeft)) && + (parseFloat(mouseabove.style.height) <= (mouseY - mouseabove.offsetTop))) { + mouseabove.style.cursor = "nesw-resize"; + dragHint = "leftbottomresize"; + } else if(parseFloat(mouseabove.style.width) <= (mouseX - mouseabove.offsetLeft)) { + mouseabove.style.cursor = "ew-resize"; + dragHint = "rightresize"; + } else if(parseFloat(mouseabove.style.height) <= (mouseY - mouseabove.offsetTop)) { + mouseabove.style.cursor = "ns-resize"; + dragHint = "bottomresize"; + } else if((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseX - mouseabove.offsetLeft)) { + mouseabove.style.cursor = "ew-resize"; + dragHint = "leftresize"; + } else if((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseY - mouseabove.offsetTop)) { + mouseabove.style.cursor = "ns-resize"; + dragHint = "topresize"; + } else { + mouseabove.style.cursor = "move"; + dragHint = "move"; + } + } else { + mouseabove.style.cursor = "default"; + } + } else { + mouseabove.style.cursor = "default"; + dragHint = ""; + data.innerHTML = "

"; + } + } + displayParameters(); + } + + function displayParameters() { + + itemparameters.innerHTML = "

" + selected.nodeName + ": " + selected.id + "
" + + "Location: " + selected.style.left + ":" + selected.style.top + "
" + + "Size: " + selected.style.width + ":" + selected.style.height + "
" + + "

"; + + } + + + + + + + + +
+ +
+ + View Editor + +
+ + + + + + + + + +
+
+ +
+
+ +
+
+ + This is a text label + + + +
+
+ + +
+ + OPTIONS + +
+ +
+ Show Grid
+ Snap To Grid
+ Grid Size:
+
+ +
+ +
+

NO DATA

+
+ +
+
+ + +
+ + Toolbar + +
+ + +
+
+ +
+ + + + + + \ No newline at end of file diff --git a/__editview.h b/__editview.h new file mode 100644 index 0000000..726bd0d --- /dev/null +++ b/__editview.h @@ -0,0 +1,223 @@ +#ifndef ____editview_h__ +#define ____editview_h__ + +#include "HTTPPage.h" + +namespace http { + + class __editview : public HTTPPage { + + int processCommand(std::string request, core::Session *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { + + data << "" << std::endl; + data << "" << std::endl; + data << " var mainpage;" << std::endl; + data << " var result;" << std::endl; + data << " var mousedownx;" << std::endl; + data << " var mousedowny;" << std::endl; + data << " var mouseDownWidth;" << std::endl; + data << " var mouseDownHeight;" << std::endl; + data << " var ismousedown = false;" << std::endl; + data << " var dragobject;" << std::endl; + data << " var dragHint = \"move\";" << std::endl; + data << " var data;" << std::endl; + data << " var showGrid = false;" << std::endl; + data << " var snapToGrid = false;" << std::endl; + data << " var gridSize = 10;" << std::endl; + data << " var selected;" << std::endl; + data << " var itemparameters;" << std::endl; + data << "" << std::endl; + data << " function init() {" << std::endl; + data << " mainpage = document.getElementById(\"mainpage\");" << std::endl; + data << " data = document.getElementById(\"data\");" << std::endl; + data << " itemparameters = document.getElementById(\"itemparameters\");" << std::endl; + data << " var gridsize = document.getElementById(\"gridsize\");" << std::endl; + data << " gridsize.value = gridSize;" << std::endl; + data << " drawGrid();" << std::endl; + data << " }" << std::endl; + data << " " << std::endl; + data << " function drawGrid() {" << std::endl; + data << " var grid = document.getElementById(\"grid\");" << std::endl; + data << " var context = grid.getContext(\"2d\");" << std::endl; + data << " if(showGrid == true) {" << std::endl; + data << " context.clearRect(0,0,grid.width,grid.height);" << std::endl; + data << " context.globalAlpha = 0.2;" << std::endl; + data << " context.lineWidth = 0.5; " << std::endl; + data << " for(ix = 0; ix < grid.width; ix += gridSize) {" << std::endl; + data << " context.beginPath();" << std::endl; + data << " context.moveTo(ix, 0);" << std::endl; + data << " context.lineTo(ix, grid.height);" << std::endl; + data << " context.stroke();" << std::endl; + data << " context.beginPath();" << std::endl; + data << " context.moveTo(0, ix);" << std::endl; + data << " context.lineTo(grid.width, ix);" << std::endl; + data << " context.stroke(); " << std::endl; + data << " }" << std::endl; + data << " } else {" << std::endl; + data << " context.clearRect(0,0,grid.width,grid.height);" << std::endl; + data << " }" << std::endl; + data << " }" << std::endl; + data << "" << std::endl; + data << " function setDragHint(hint) {" << std::endl; + data << " dragHint = hint;" << std::endl; + data << " }" << std::endl; + data << " " << std::endl; + data << " function getMouseX(e) {" << std::endl; + data << " return e.clientX - mainpage.offsetLeft - parseFloat(mainpage.style.borderWidth);" << std::endl; + data << " }" << std::endl; + data << " " << std::endl; + data << " function getMouseY(e) {" << std::endl; + data << " return e.clientY - mainpage.offsetTop - parseFloat(mainpage.style.borderWidth);" << std::endl; + data << " }" << std::endl; + data << "" << std::endl; + data << " function mousedown(obj, e) {" << std::endl; + data << " var mouseX = getMouseX(e);" << std::endl; + data << " var mouseY = getMouseY(e);" << std::endl; + data << " mousedownx = mouseX - obj.offsetLeft;" << std::endl; + data << " mousedowny = mouseY - obj.offsetTop;" << std::endl; + data << " mouseDownLeft = parseFloat(obj.style.left);" << std::endl; + data << " mouseDownTop = parseFloat(obj.style.top);" << std::endl; + data << " mouseDownWidth = parseFloat(obj.style.width);" << std::endl; + data << " mouseDownHeight = parseFloat(obj.style.height);" << std::endl; + data << " dragobject = obj;" << std::endl; + data << " selected = obj;" << std::endl; + data << " ismousedown = true;" << std::endl; + data << " displayParameters();" << std::endl; + data << " }" << std::endl; + data << " " << std::endl; + data << " function mouseup() {" << std::endl; + data << " ismousedown = false;" << std::endl; + data << " dragobject = null;" << std::endl; + data << " console.log(mainpage.innerHTML);" << std::endl; + data << " }" << std::endl; + data << "" << std::endl; + data << " function mousemove(e) {" << std::endl; + data << " var mouseX = getMouseX(e);" << std::endl; + data << " var mouseY = getMouseY(e);" << std::endl; + data << " if(ismousedown) {" << std::endl; + data << " " << std::endl; + data << " if(dragHint == \"move\") {" << std::endl; + data << " if(snapToGrid == false) {" << std::endl; + data << " dragobject.style.left = (mouseX - mousedownx) + \"px\";" << std::endl; + data << " dragobject.style.top = (mouseY - mousedowny) + \"px\";" << std::endl; + data << " } else {" << std::endl; + data << " dragobject.style.left = (Math.round((mouseX - mousedownx) / gridSize) * gridSize) + \"px\";" << std::endl; + data << " dragobject.style.top = (Math.round((mouseY - mousedowny) / gridSize) * gridSize) + \"px\";" << std::endl; + data << " }" << std::endl; + data << " if((mouseX - mousedownx) < 0)" << std::endl; + data << " dragobject.style.left = \"0px\";" << std::endl; + data << " if((mouseY - mousedowny) < 0)" << std::endl; + data << " dragobject.style.top = \"0px\";" << std::endl; + data << " if((mouseX - mousedownx + parseFloat(dragobject.style.width)) > parseFloat(mainpage.style.width)) " << std::endl; + data << " dragobject.style.left = (mouseX - mousedownx) + \"px\"; " << std::endl; + data << " } else if(dragHint == \"rightbottomresize\") { " << std::endl; + data << " dragobject.style.width = (mouseX - mouseDownLeft) + \"px\";" << std::endl; + data << " dragobject.style.height = (mouseY - mouseDownTop) + \"px\";" << std::endl; + data << " } else if(dragHint == \"rightresize\") { " << std::endl; + data << " if(snapToGrid == false) {" << std::endl; + data << " dragobject.style.width = (mouseX - mouseDownLeft) + \"px\"; " << std::endl; + data << " } else {" << std::endl; + data << " dragobject.style.width = (Math.round((mouseX - mouseDownLeft) / gridSize) * gridSize) + \"px\"; " << std::endl; + data << " }" << std::endl; + data << " } else if(dragHint == \"bottomresize\") { " << std::endl; + data << " if(snapToGrid == false) {" << std::endl; + data << " dragobject.style.height = (mouseY - mouseDownTop) + \"px\";" << std::endl; + data << " } else {" << std::endl; + data << " dragobject.style.height = (Math.round((mouseY - mouseDownTop) / gridSize) * gridSize) + \"px\";" << std::endl; + data << " }" << std::endl; + data << " } else if(dragHint == \"leftresize\") { " << std::endl; + data << " dragobject.style.left = mouseX + \"px\";" << std::endl; + data << " dragobject.style.width = (mouseDownWidth + (mouseDownLeft - mouseX)) + \"px\";" << std::endl; + data << " } else if(dragHint == \"topresize\") { " << std::endl; + data << " dragobject.style.top = mouseY + \"px\";" << std::endl; + data << " dragobject.style.height = (mouseDownHeight + (mouseDownTop - mouseY)) + \"px\";" << std::endl; + data << " }" << std::endl; + data << " " << std::endl; + data << " data.innerHTML = \"

\" + dragobject.nodeName + \"
\" + " << std::endl; + data << " \"Action: \" + dragHint + \"
\" +" << std::endl; + data << " \"MouseLocation: \" + mouseX + \":\" + mouseY + \"
\" +" << std::endl; + data << " \"MouseOver Location: \" + (mouseX - dragobject.offsetLeft) + \":\" + (mouseY - dragobject.offsetTop) + \"
\" + " << std::endl; + data << " \"Location: \" + dragobject.style.left + \":\" + dragobject.style.top + \"
\" + " << std::endl; + data << " \"Size: \" + dragobject.style.width + \":\" + dragobject.style.height + \"
\" + " << std::endl; + data << " \"

\";" << std::endl; + data << " " << std::endl; + data << "" << std::endl; + data << " } else {" << std::endl; + data << " var mouseabove = document.elementFromPoint(mouseX + mainpage.offsetLeft, mouseY + mainpage.offsetTop);" << std::endl; + data << "" << std::endl; + data << " if((mouseabove.id != \"mainpage\") && (mouseabove.id != \"grid\")) {" << std::endl; + data << " " << std::endl; + data << " data.innerHTML = \"

\" + mouseabove.nodeName + \"
\" + " << std::endl; + data << " \"Action: \" + dragHint + \"
\" +" << std::endl; + data << " \"MouseLocation: \" + mouseX + \":\" + mouseY + \"
\" +" << std::endl; + data << " \"MouseOver Location: \" + (mouseX - mouseabove.offsetLeft) + \":\" + (mouseY - mouseabove.offsetTop) + \"
\" + " << std::endl; + data << " \"Location: \" + mouseabove.style.left + \":\" + mouseabove.style.top + \"
\" + " << std::endl; + data << " \"Size: \" + mouseabove.style.width + \":\" + mouseabove.style.height + \"
\" + " << std::endl; + data << " \"

\";" << std::endl; + data << " " << std::endl; + data << " if((mouseabove.nodeName == \"DIV\") || " << std::endl; + data << " (mouseabove.nodeName == \"IMG\") || " << std::endl; + data << " (mouseabove.nodeName == \"BUTTON\") ||" << std::endl; + data << " (mouseabove.nodeName == \"INPUT\") ||" << std::endl; + data << " (mouseabove.nodeName == \"SPAN\")) {" << std::endl; + data << " " << std::endl; + data << " if((parseFloat(mouseabove.style.width) <= (mouseX - mouseabove.offsetLeft)) && " << std::endl; + data << " (parseFloat(mouseabove.style.height) <= (mouseY - mouseabove.offsetTop))) {" << std::endl; + data << " mouseabove.style.cursor = \"nwse-resize\";" << std::endl; + data << " dragHint = \"rightbottomresize\"; " << std::endl; + data << " } else if((parseFloat(mouseabove.style.left) <= (mouseX - mouseabove.offsetLeft)) && " << std::endl; + data << " ((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseY - mouseabove.offsetTop))) {" << std::endl; + data << " mouseabove.style.cursor = \"nesw-resize\";" << std::endl; + data << " dragHint = \"righttopresize\"; " << std::endl; + data << " } else if(((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseX - mouseabove.offsetLeft)) && " << std::endl; + data << " (parseFloat(mouseabove.style.height) <= (mouseY - mouseabove.offsetTop))) {" << std::endl; + data << " mouseabove.style.cursor = \"nesw-resize\";" << std::endl; + data << " dragHint = \"leftbottomresize\"; " << std::endl; + data << " } else if(parseFloat(mouseabove.style.width) <= (mouseX - mouseabove.offsetLeft)) {" << std::endl; + data << " mouseabove.style.cursor = \"ew-resize\";" << std::endl; + data << " dragHint = \"rightresize\";" << std::endl; + data << " } else if(parseFloat(mouseabove.style.height) <= (mouseY - mouseabove.offsetTop)) {" << std::endl; + data << " mouseabove.style.cursor = \"ns-resize\";" << std::endl; + data << " dragHint = \"bottomresize\";" << std::endl; + data << " } else if((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseX - mouseabove.offsetLeft)) {" << std::endl; + data << " mouseabove.style.cursor = \"ew-resize\";" << std::endl; + data << " dragHint = \"leftresize\";" << std::endl; + data << " } else if((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseY - mouseabove.offsetTop)) {" << std::endl; + data << " mouseabove.style.cursor = \"ns-resize\";" << std::endl; + data << " dragHint = \"topresize\";" << std::endl; + data << " } else {" << std::endl; + data << " mouseabove.style.cursor = \"move\";" << std::endl; + data << " dragHint = \"move\";" << std::endl; + data << " }" << std::endl; + data << " } else {" << std::endl; + data << " mouseabove.style.cursor = \"default\";" << std::endl; + data << " }" << std::endl; + data << " } else {" << std::endl; + data << " mouseabove.style.cursor = \"default\";" << std::endl; + data << " dragHint = \"\";" << std::endl; + data << " data.innerHTML = \"

\";" << std::endl; + data << " }" << std::endl; + data << " }" << std::endl; + data << " displayParameters();" << std::endl; + data << " }" << std::endl; + data << " " << std::endl; + data << " function displayParameters() {" << std::endl; + data << "" << std::endl; + data << " itemparameters.innerHTML = \"

\" + selected.nodeName + \": \" + selected.id + \"
\" + " << std::endl; + data << " \"Location: \" + selected.style.left + \":\" + selected.style.top + \"
\" + " << std::endl; + data << " \"Size: \" + selected.style.width + \":\" + selected.style.height + \"
\" + " << std::endl; + data << " \"

\";" << std::endl; + data << "" << std::endl; + data << " }" << std::endl; + data << "" << std::endl; + + httpRequest.response.addHeader("Content-Type", "script/javascript"); + + return 0; + } + + }; + +} + +#endif diff --git a/__favicon_ico.h b/__favicon_ico.h index b9fa891..bf53117 100644 --- a/__favicon_ico.h +++ b/__favicon_ico.h @@ -7,78 +7,150 @@ namespace http { class __favicon_ico : public HTTPPage { - int processCommand(std::string request, core::Session *session, HTTPSession *httpSession, std::stringstream &data) override { + int processCommand(std::string request, + core::Session *session, + HTTPSession *httpSession, + HTTPRequest &httpRequest, + std::stringstream &data) override { - data << std::string(header_data); - + data << std::string(header_data, 806); + + httpRequest.response.addHeader("Content-Type", "image/x-icon"); return true; } - char *header_data = - "````````````````````````````````````````^PH_U/([J-@W@<4T3[4R+*TQ" - "+ZTQ6+(X@,4T-JXQ)*HQ" - ")JHQ/*\\RBLHUP.8Y]P@_`````````0X`KMPW):HQ)*HQ;[XS^@H_````````````" - "````````_PT_=+`T)*HQ+*PQTO$[````````^0D_I-\\,T_`X`````W_H\\)*HQ)*HQP>4Y)*HQ)*HQO^8Y````````A<@U)*HQ:KPS`P\\`" - "UO,[)*HQ)*HQYOX]````[`0^+*LQ)*HQI=0Y````_@T_-*TQ)*HQ)*HQ)*HQ)*HQ)*HQ" - ")*HQ)*HQ)*HQ)*HQ)*HQ;;XS`P```P\\`I-8W)*HQ=L$T````````F=$V)*HQA\\DU" - "+:TQ)*HQP>8Y````]@@_)*HQ)*HQ6+8Y````]@@_)*HQ)*HQ>L,TG-,VE,\\V)*HQ)*HQ)*HQ)*HQ)*HQ)*HQ" - ")*HQ)*HQ)*HQ)*HQ)*HQ):HQL=\\XM-`X@,4T)*HQ0K,R````````JMDW)*HQ7KLS" - "4[8S)*HQMM`X`````0X`+JTQ)*HQO.0Y````_@T_-*TQ)*HQ)*HQ)*HQ)*HQ)*HQ" - ")*HQ)*HQ)*HQ)*HQ)*HQ;;XS````````I-`[````^0D_+:LQ)*HQQ.DY" - "UO0[)*HQ)*HQYOX]````[`0^+*LQ)*HQI=\\,T_`X`````W_D\\)*HQ)*HQP>XZ````````" - "````````_PT_=;`T)*HQ+*LQTO$[````````^0D_I=\ -

You have successfully set up a JETServer.\ -
Session Id: " << httpSession->getSessionId() << "\ -
The configuration has not yet been established for this web site.

\ - \ -
"; - + data << "" << std::endl; + data << " " << std::endl; + data << " " << std::endl; + data << " " << std::endl; + data << " " << std::endl; + data << " " << std::endl; + data << " " << std::endl; + + data << "" << std::endl; + data << "
If you see this then something is wrong.
" << std::endl; + data << " " << std::endl; + data << "" << std::endl; + + httpRequest.response.addHeader("Content-Type", "text/html"); return true; } }; diff --git a/__mainmenu.h b/__mainmenu.h new file mode 100644 index 0000000..cdeb963 --- /dev/null +++ b/__mainmenu.h @@ -0,0 +1,33 @@ +#ifndef ____mainmenu_h__ +#define ____mainmenu_h__ + +#include "HTTPPage.h" + +namespace http { + + class __mainmenu : public HTTPPage { + + int processCommand(std::string request, + core::Session *session, + HTTPSession *httpSession, + HTTPRequest &httpRequest, + std::stringstream &data) override { + + data << "
" << std::endl; + data << "
" << std::endl; + data << " Setup Server Parameters" << std::endl; + data << "
" << std::endl; + data << "
" << std::endl; + data << " View and Layout Designer" << std::endl; + data << "
" << std::endl; + data << "
" << std::endl; + + httpRequest.response.addHeader("Content-Type", "text/html"); + + return true; + } + }; +} + +#endif diff --git a/__newview.h b/__newview.h new file mode 100644 index 0000000..6db8cc6 --- /dev/null +++ b/__newview.h @@ -0,0 +1,113 @@ +#ifndef ____newview_h__ +#define ____newview_h__ + +#include "HTTPPage.h" + +namespace http { + + class __newview : public HTTPPage { + + int processCommand(std::string request, + core::Session *session, + HTTPSession *httpSession, + HTTPRequest &httpRequest, + std::stringstream &data) override { + + data << "
" << std::endl; + data << "" << std::endl; + data << "
" << std::endl; + data << "" << std::endl; + data << " View Editor" << std::endl; + data << "" << std::endl; + data << "
" << std::endl; + data << "" << std::endl; + data << " " << std::endl; + data << "" << std::endl; + data << " " << std::endl; + data << "" << std::endl; + data << " " << std::endl; + data << " " << std::endl; + data << " " << std::endl; + data << "" << std::endl; + data << "
" << std::endl; + data << "
" << std::endl; + data << "" << std::endl; + data << "
" << std::endl; + data << "
" << std::endl; + data << "" << std::endl; + data << "
" << std::endl; + data << "
" << std::endl; + data << " " << std::endl; + data << " This is a text label" << std::endl; + data << "" << std::endl; + data << " " << std::endl; + data << "" << std::endl; + data << "
" << std::endl; + data << "
" << std::endl; + data << "" << std::endl; + data << "" << std::endl; + data << "
" << std::endl; + data << "" << std::endl; + data << " OPTIONS" << std::endl; + data << "" << std::endl; + data << "
" << std::endl; + data << "" << std::endl; + data << "
" << std::endl; + data << " Show Grid
" << std::endl; + data << " Snap To Grid
" << std::endl; + data << " Grid Size:
" << std::endl; + data << "
" << std::endl; + data << "" << std::endl; + data << "
" << std::endl; + data << "" << std::endl; + data << "
" << std::endl; + data << "

NO DATA

" << std::endl; + data << "
" << std::endl; + data << "" << std::endl; + data << "
" << std::endl; + data << "
" << std::endl; + data << "" << std::endl; + data << "" << std::endl; + data << "
" << std::endl; + data << "" << std::endl; + data << " Toolbar" << std::endl; + data << "" << std::endl; + data << "
" << std::endl; + data << " " << std::endl; + data << "" << std::endl; + data << "
" << std::endl; + data << "
" << std::endl; + data << " " << std::endl; + data << "
" << std::endl; + data << "" << std::endl; + data << " " << std::endl; + + httpRequest.response.addHeader("Content-Type", "text/html"); + return 0; + } + + }; + +} + +#endif diff --git a/__script.h b/__script.h new file mode 100644 index 0000000..81a7753 --- /dev/null +++ b/__script.h @@ -0,0 +1,54 @@ +#ifndef ____script_h__ +#define ____script_h__ + +#include "HTTPPage.h" + +namespace http { + + class __script : public HTTPPage { + + int processCommand(std::string request, core::Session *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { + + data << "function serverSend(url, type, receiver, formData, callback) {" << std::endl; + data << " var server = new XMLHttpRequest();" << std::endl; + data << " server.onload = function() {" << std::endl; + data << " if(server.readyState == 4 && server.status == 200)" << std::endl; + data << " callback(server.responseText, receiver);" << std::endl; + data << " };" << std::endl; + data << " server.open(type, url, true);" << std::endl; + data << " server.send(formData);" << std::endl; + data << "}" << std::endl; + + data << "function getPage(url, receiver) {" << std::endl; + data << " serverSend(url, \"GET\", receiver, null, function(data, receiver) {" << std::endl; + data << " var panel1 = document.getElementById(receiver);" << std::endl; + data << " panel1.innerHTML = data;" << std::endl; + data << " });" << std::endl; + data << "}" << std::endl; + + data << "function process(url, formName, receiver) {" << std::endl; + data << " var formElement = document.querySelector(\"form[name='\" + formName + \"']\");" << std::endl; + data << " var formData = new FormData(formElement);" << std::endl; + data << " serverSend(url, \"POST\", receiver, formData, function(data, receiver) {" << std::endl; + data << " var panel1 = document.getElementById(receiver);" << std::endl; + data << " panel1.innerHTML = data;" << std::endl; + data << " });" << std::endl; + data << "}" << std::endl; + +// data << "var setInnerHTML = function(elm, html) {" << std::endl; +// data << " lm.innerHTML = html;" << std::endl; +// data << " Array.from(elm.querySelectorAll("script")).forEach( oldScript => {" << std::endl; +// data << " const newScript = document.createElement("script");" << std::endl; +// data << " Array.from(oldScript.attributes)" << std::endl; +// data << " .forEach( attr => newScript.setAttribute(attr.name, attr.value) );" << std::endl; +// data << " newScript.appendChild(document.createTextNode(oldScript.innerHTML));" << std::endl; +// data << " oldScript.parentNode.replaceChild(newScript, oldScript);" << std::endl; + + httpRequest.response.addHeader("Content-Type", "text/javascript"); + + return true; + } + }; +} + +#endif diff --git a/__setupadmin.h b/__setupadmin.h index 0db3c8f..b21f541 100644 --- a/__setupadmin.h +++ b/__setupadmin.h @@ -5,15 +5,29 @@ namespace http { class __setupadmin : public HTTPPage { - int processCommand(std::string request, core::Session *session, HTTPSession *httpSession, std::stringstream &data) override { + int processCommand(std::string request, core::Session *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { - data << "\ -

Please enter credential information\ - for the security officer.
\ -
Session Id: " << httpSession->getSessionId() << "\ -
The configuration has not yet been established for this web site.

\ - \ -
"; + data << "
" << std::endl; + data << "

Please enter credential information" << std::endl; + data << " for the security officer, then press Set Admin Profile button below:" << std::endl; + data << "

" << std::endl; + data << "
User Name:
" << std::endl; + data << " " << std::endl; + data << "
" << std::endl; + data << "
" << std::endl; + data << "
Password:
" << std::endl; + data << " " << std::endl; + data << "
" << std::endl; + data << "
" << std::endl; + data << "
Verify Password:
" << std::endl; + data << " " << std::endl; + data << "
" << std::endl; + data << "

Session Id: " << httpSession->getSessionId() << "" << std::endl; + data << "
The configuration has not yet been established for this web site.

" << std::endl; + data << " " << std::endl; + data << "
" << std::endl; + + httpRequest.response.addHeader("Content-Type", "text/html"); return true; } diff --git a/__style.h b/__style.h new file mode 100644 index 0000000..0a79a19 --- /dev/null +++ b/__style.h @@ -0,0 +1,29 @@ +#ifndef ____style_h__ +#define ____style_h__ + +#include "HTTPPage.h" + +namespace http { + + class __style : public HTTPPage { + + int processCommand(std::string request, core::Session *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) override { + + data << "body {background: #006;" << std::endl; + data << " color: #fff;" << std::endl; + data << " }" << std::endl; + + data << ".window {background: #668;" << std::endl; + data << " color: #fff;" << std::endl; + data << " border: 1pt solid #f00;" << std::endl; + data << " width: 400px;" << std::endl; + data << " padding: 15px;" << std::endl; + data << " }" << std::endl; + + httpRequest.response.addHeader("Content-Type", "text/css"); + return true; + } + }; +} + +#endif diff --git a/__welcome.h b/__welcome.h new file mode 100644 index 0000000..2db4843 --- /dev/null +++ b/__welcome.h @@ -0,0 +1,30 @@ +#ifndef ____welcome_h__ +#define ____welcome_h__ + +#include "HTTPPage.h" + +namespace http { + + class __welcome : public HTTPPage { + + int processCommand(std::string request, + core::Session *session, + HTTPSession *httpSession, + HTTPRequest &httpRequest, + std::stringstream &data) override { + + data << "
\ +

You have successfully set up a JETServer.\ +
Session Id: " << httpSession->getSessionId() << "\ +
The configuration has not yet been established for this web site.

\ + \ +
"; + + httpRequest.response.addHeader("Content-Type", "text/html"); + + return true; + } + }; +} + +#endif