82
83
"Content-Type: " << (mimetype?mimetype:"text/html") << "\r\n\r\n";
83
84
SendRawData(s.data(), s.length(), MSG_MORE);
86
void maintenance::SendDecoration(bool bBegin, const char *szDecoFile)
92
if(szDecoFile && m_deco.initFromFile((acfg::confdir+sPathSep+szDecoFile).c_str()))
93
mark=strchr(m_deco.c_str(), '~');
95
// deco file specified and loaded?
99
m_deco.erase(mark-m_deco.rptr());
101
m_deco.drop(mark-m_deco.rptr()+1);
102
string sDeco(m_deco.rptr(), m_deco.size());
107
SendMsg(bBegin?"<html><body>":"</html></body>");
113
class authbounce : public tWUIPage
87
class tAuthRequest : public tWUIPage
117
authbounce(int fd) : tWUIPage(fd)
123
void Action(const MYSTD::string & src)
90
tAuthRequest(int fd) : tWUIPage(fd)
126
93
void Run(const string &)
128
95
const char authmsg[] = "HTTP/1.1 401 Not Authorized\r\nWWW-Authenticate: "
129
96
"Basic realm=\"Apt-Cacher NG administration area\"\r\n"
130
97
"Connection: Close\r\n"
131
"Content-Type: text/html\r\nContent-Length:81\r\n\r\n"
98
"Content-Type: text/plain\r\nContent-Length:81\r\n\r\n"
132
99
"Not Authorized. Please contact Apt-Cacher NG administrator for further questions.";
133
100
SendRawData(authmsg, sizeof(authmsg)-1, 0);
138
void DispatchAndRunMaintTask(const MYSTD::string &cmd, int conFD, const char * szAuthLine)
140
tWUIPage *pWorker(NULL);
144
// not effective, why? signal(SIGPIPE, SIG_IGN);
148
//std::cout << "vgl: " << authLine << " und " << acfg::adminauth << "\n";
150
// admin actions are passed with GET parameters, appended after ?
151
if(cmd.find('?')!=stmiss)
153
if( ! acfg::adminauth.empty() && acfg::adminauth!=szAuthLine )
154
pWorker = new authbounce(conFD);
155
else if(cmd.find("doExpire=")!=stmiss ||
156
cmd.find("justShow=")!=stmiss ||
157
cmd.find("justRemove=")!=stmiss)
158
pWorker = new expiration(conFD);
159
else if(cmd.find("doImport=")!=stmiss)
160
pWorker=new pkgimport(conFD);
161
else if(cmd.find("doCount=")!=stmiss)
162
pWorker = new tStaticFileSend(conFD, "report.html", "text/html", "200");
164
else if (cmd==acfg::reportpage)
165
pWorker = new tStaticFileSend(conFD, "report.html", "text/html", "200");
166
else if (cmd == "/style.css")
167
pWorker = new tStaticFileSend(conFD, "style.css", "text/css", "200");
169
pWorker = new tStaticFileSend(conFD, "userinfo.html", "text/html", "404");
180
void tWUIPage::SetStyle(string &s)
104
class authbounce : public tWUIPage
185
if( ! buf.initFromFile( (acfg::confdir+SZPATHSEP "style.css").c_str()) )
188
while(stmiss != (pos = s.find("$STYLE", pos)))
190
//cerr << "replacing " << s.substr(pos, 6) << " with " << buf.c_str()<<endl;
191
s.replace(pos, 6, buf.c_str());
107
authbounce(int fd) : tWUIPage(fd)
110
void Run(const string &)
112
const char authmsg[] = "HTTP/1.1 200 Not Authorized\r\n"
113
"Connection: Close\r\n"
114
"Content-Type: text/plain\r\nContent-Length: 102\r\n\r\n"
115
"Not Authorized. To start this action, an administrator password must be set and "
116
"you must be logged in.";
117
SendRawData(authmsg, sizeof(authmsg)-1, 0);
196
121
string & tWUIPage::GetHostname()
169
void DispatchAndRunMaintTask(MYSTD::string &cmd, int conFD, const char * szAuthLine)
171
tWUIPage *pWorker(NULL);
176
if(cmd.find("tickTack")!=stmiss)
178
tBgTester(conFD).Run(cmd);
183
// not effective, why? signal(SIGPIPE, SIG_IGN);
187
//std::cout << "vgl: " << authLine << " und " << acfg::adminauth << "\n";
188
// admin actions are passed with GET parameters, appended after ?
189
tStrPos qpos=cmd.find('?');
193
if( ! acfg::adminauth.empty() && acfg::adminauth!=szAuthLine )
194
pWorker = new tAuthRequest(conFD);
195
else if(cmd.find("doExpire=")!=stmiss ||
196
cmd.find("justShow=")!=stmiss ||
197
cmd.find("justRemove=")!=stmiss)
198
pWorker = new expiration(conFD);
199
else if(cmd.find("doImport=")!=stmiss)
200
pWorker=new pkgimport(conFD);
201
else if(cmd.find("doMirror=")!=stmiss)
202
if(acfg::adminauth.empty())
203
pWorker=new authbounce(conFD);
205
pWorker=new pkgmirror(conFD);
206
else if(cmd.find("doDelete=")!=stmiss ||cmd.find("doDeleteYes=")!=stmiss)
207
if(acfg::adminauth.empty())
208
pWorker=new authbounce(conFD);
210
pWorker=new tDeleter(conFD);
211
else if(cmd.find("doCount=")!=stmiss)
212
pWorker = new tStaticFileSend(conFD, "report.html", "text/html", "200");
213
else // ok... just show the default page
215
cmd=cmd.substr(0,qpos);
220
else if (cmd==acfg::reportpage)
221
pWorker = new tStaticFileSend(conFD, "report.html", "text/html", "200");
222
else if (cmd == "/style.css")
223
pWorker = new tStaticFileSend(conFD, "style.css", "text/css", "200");
225
pWorker = new tStaticFileSend(conFD, "userinfo.html", "text/html", "404");