14 m_needs_access_data =
true;
15 m_needs_change_settings =
true;
20 void WebPage::service(HttpRequest& request, HttpResponse& response) {
21 m_response = &response;
25 response.setHeader(
"Cache-Control",
"private, must-revalidate, max-age=0");
26 response.setHeader(
"Pragma",
"no-cache");
29 if (needsLogin(request,response)) {
33 servicePrivate (request);
35 response.write (m_body);
36 writeFooter (request,response);
39 void WebPage::redirect(
const QString& location) {
40 setStatus(301,
"Moved Permanently");
41 setHeader(
"Location", location.toUtf8());
42 setHeader(
"Content-Type",
"text/html; charset=utf-8");
43 write(tr(
"<h1>Moved Permanently</h1><p>The document has moved <a href=\"%1\">here</a>.</p>\n").arg(location));
46 QString WebPage::percentEncode(
const QString& s) {
47 return QString(s.toUtf8().toPercentEncoding());
50 void WebPage::writeFooter(HttpRequest& request, HttpResponse& response) {
52 response.write(
"</div><!-- content -->\n"
53 "</div><!-- page -->\n"
61 QString body (
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n"
62 " \"http://www.w3.org/TR/html4/strict.dtd\">\n"
64 "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n"
65 "<title>Fotobot</title>\n"
66 "<link href=\"/style.css\" rel=\"stylesheet\" type=\"text/css\">\n"
67 "<script type=\"text/javascript\">\n");
68 body.append(m_javascript);
69 body.append(tr(
"</script>\n"
73 "<div id=\"header\">\n"
76 "<p>Collects data from your photovoltaic plant<br/>Made by <a href=\"http://hobrasoft.cz/\">Hobrasoft s.r.o.</a></p>\n"
77 "<p class=\"clear\"></p></div><!-- logo -->\n"
81 body.append(QString(
"<li><a href=\"/\">%1</a></li>\n").arg(tr(
"Main Page")));
82 body.append(QString(
"<li><a href=\"/export\">%1</a></li>\n").arg(tr(
"Current data")));
83 body.append(QString(
"<li><a href=\"/settings\">%1</a><ul>\n").arg(tr(
"Settings")));
84 body.append(QString(
"<li><a href=\"/lines\">%1</a></li>\n").arg(tr(
"Lines")));
85 body.append(QString(
"<li><a href=\"/invertors\">%1</a></li>\n").arg(tr(
"Invertors")));
86 body.append(QString(
"<li><a href=\"/interfaceboxes\">%1</a></li>\n").arg(tr(
"Interfaceboxes")));
87 body.append(QString(
"<li><a href=\"/interfaceboxes?action=restart\">%1</a></li>\n").arg(tr(
"Interfaceboxes restart")));
88 body.append(QString(
"<li><a href=\"/geocoordinates\">%1</a></li>\n").arg(tr(
"Geographical coordinates")));
90 body.append(QString(
"<li><a href=\"/network\">%1</a></li>\n").arg(tr(
"Network settings")));
92 body.append(QString(
"<li><a href=\"/login?action=chpw\">%1</a></li>\n").arg(tr(
"Change Password")));
93 body.append(QString(
"<li><a href=\"/users\">%1</a></li>\n").arg(tr(
"Users")));
94 body.append(
"</ul></li>\n");
97 if (session.contains(
"username")) {
98 body.append(QString(
"<li><a href=\"/login?logout=true\">%1</a></li>").arg(tr(
"Log out")));
100 body.append(QString(
"<li><a href=\"/login\">%1</a></li>\n").arg(tr(
"Log in")));
103 body.append(
"</ul><p class=\"clear\"></p></div><!-- menu -->\n");
104 body.append(
"</div><!-- header -->\n");
106 QString message = QString::fromUtf8(QByteArray::fromPercentEncoding(request.getParameter(
"message")));
107 if(!message.isEmpty()) {
108 body.append(QString(
"<p class=\"message\">%1</p>").arg(message));
111 body.append(
"<div id=\"content\">");
112 response.write(body.toUtf8());
116 void WebPage::about() {
117 write(QString(
"<h2>%1</h2>\n").arg(tr(
"About")));
118 write(QString(
"<p>%1 %2</p>\n").arg(tr(
"Version")).arg(VERSION));
120 "<p>Application Fotobot is made by <a href=\"http://hobrasoft.cz\">Hobrasoft s.r.o.</a>\n"
121 "It is a part of complex photovoltaic suite:</p>\n"
123 "<li><a href=http://hobrasoft.cz/en/fotomon/fotomon>Fotomon</a> - monitoring, analyses and report making software for central monitoring services.</li>\n"
124 "<li><a href=http://fm.solartec.cz/>Fotoweb</a> - web for photovoltaic system owner, a lot of graphs, businness information and detailed operating log for every photovoltaic plant.</li>\n"
125 "<li><a href=http://hobrasoft.cz/en/fotomon/fotobot>Fotobot</a> - simple but very quick application to collect data from your photovoltaic plant.</li>\n"
126 "<li><a href=http://hobrasoft.cz/en/fotobothw>FotobotHW</a> - small but powerfull computer to collect data from photovoltaic plant. Based on Linux, BeagleBone, Hobrasoft 4 × RS232</li>\n"
128 "<p>Home page: <a href=\"http://hobrasoft.cz/fotobot\">http://hobrasoft.cz/fotobot</a></p>\n"
129 "<p>Application Fotobot is available under <a href=\"http://www.gnu.org/copyleft/gpl.html\">GPL license</a></p>"
static HttpSessionStore * sessionStore
virtual void writeHeader(HttpRequest &request, HttpResponse &response)