-
Notifications
You must be signed in to change notification settings - Fork 0
/
html.H
299 lines (278 loc) · 13.5 KB
/
html.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
/*
* Copyright (c) 2006-2011, Guillaume Gimenez <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of G.Gimenez nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL G.Gimenez SA BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors:
* * Guillaume Gimenez <[email protected]>
*
*/
class textfield {
String title;
String desc;
String name;
String value;
public:
textfield() : title(""), desc(""), name(""), value("") {}
void setTitle(const String& str) { title=str; }
void setDesc(const String& str) { desc=str; }
void setName(const String& str) { name=str; }
void setValue(const String& str) { value=str; }
void doStart(HttpServletRequest& request, HttpServletResponse& response) {
response << "<div class=\"row\">\n"
<< " <div class=\"label\"><a title=\""<<title<<"\" href=\"#\">"<<desc<<"</a></div>\n"
<< " <div class=\"control\"><input type=\"text\" size=\"30\" name=\""<<name<<"\" value=\""<<value<<"\" /></div>\n"
<< "</div>\n";
}
};
class password {
String title;
String desc;
String name;
String value;
public:
password() : title(""), desc(""), name(""), value("") {}
void setTitle(const String& str) { title=str; }
void setDesc(const String& str) { desc=str; }
void setName(const String& str) { name=str; }
void setValue(const String& str) { value=str; }
void doStart(HttpServletRequest& request, HttpServletResponse& response) {
response << "<div class=\"row\">\n"
<< " <div class=\"label\"><a title=\""<<title<<"\" href=\"#\">"<<desc<<"</a></div>\n"
<< " <div class=\"control\"><input type=\"password\" size=\"30\" name=\""<<name<<"\" value=\""<<value<<"\" /></div>\n"
<< "</div>\n";
}
};
class checkbox {
String title;
String desc;
String name;
bool checked;
public:
checkbox() : title(""), desc(""), name(""), checked(false) {}
void setTitle(const String& str) { title=str; }
void setDesc(const String& str) { desc=str; }
void setName(const String& str) { name=str; }
void setChecked(bool v) { checked=v; }
void doStart(HttpServletRequest& request, HttpServletResponse& response) {
response << "<div class=\"row\">\n"
<< " <div class=\"label\"><a title=\""<<title<<"\" href=\"#\">"<<desc<<"</a></div>\n"
<< " <div class=\"control\"><input type=\"checkbox\" size=\"30\" name=\""<<name<<"\" "
<< (checked?"checked=\"checked\"":"") <<" /></div>\n"
<< "</div>\n";
}
};
class textarea {
String title;
String desc;
String name;
String value;
public:
textarea() : title(""), desc(""), name(""), value("") {}
void setTitle(const String& str) { title=str; }
void setDesc(const String& str) { desc=str; }
void setName(const String& str) { name=str; }
void setValue(const String& str) { value=str; }
void doStart(HttpServletRequest& request, HttpServletResponse& response) {
response << "<div class=\"row\">\n"
<< " <div class=\"label\"><a title=\""<<title<<"\" href=\"#\">"<<desc<<"</a></div>\n"
<< " <div class=\"control\"><textarea name=\""<<name<<"\" cols=\"40\" rows=\"10\">"<<value<<"</textarea></div>\n"
<< "</div>\n";
}
};
class submit {
String name;
String value;
public:
submit() : name(""), value("") {}
void setName(const String& str) { name=str; }
void setValue(const String& str) { value=str; }
void doStart(HttpServletRequest& request, HttpServletResponse& response) {
response << "<div class=\"row\">\n"
<< " <div class=\"label\"></div>\n"
<< " <div class=\"control\"><input type=\"submit\" name=\""<<name<<"\" value=\""<<value<<"\" /></div>\n"
<< "</div>\n";
}
};
class head {
String title;
public:
void setTitle(const String& str) { title=str; }
head() : title("Galerie photo") {}
void doStart(HttpServletRequest& request, HttpServletResponse& response) {
response
<<" <head>\n"
<<"<!-- This makes IE6 suck less (a bit) -->\n"
<<"<!--[if lt IE 7]>\n"
<<"<script src=\""<< request.getContextPath() << "/inc/styles/ie7/ie7-standard.js\" type=\"text/javascript\">\n"
<<"</script>\n"
<<"<![endif]-->\n"
<<" <title>"<<title<<"</title>\n"
<<" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n"
<<" <link rel=\"icon\" href=\""<<request.getContextPath()<<"/stock_camera-16.png\" type=\"image/png\" />\n"
<<" <link rel=\"shortcut icon\" href=\""<<request.getContextPath()<<"/favicon.ico\" type=\"image/x-icon\" />\n"
<<" <link type=\"text/css\" rel=\"stylesheet\" href=\""<<request.getContextPath()<<"/inc/styles/dark/dark.css\" title=\"dark\" media=\"screen\" />\n"
<<" <link type=\"text/css\" rel=\"prefertch alternate stylesheet\" href=\""<<request.getContextPath()<<"/inc/styles/classic/classic.css\" title=\"classic\" media=\"screen\" />\n"
<<" <link type=\"text/css\" rel=\"prefertch alternate stylesheet\" href=\""<< request.getContextPath()<<"/inc/styles/gorilla/gorilla.css\" title=\"gorilla\" media=\"screen\" />\n"
<<" <script src=\""<< request.getContextPath()<<"/inc/global.js\" type=\"text/javascript\"></script>\n"
<<" </head>\n";
response.setCharacterEncoding("UTF-8");
}
};
class dropdown {
String title;
String desc;
String name;
Map<String,String> options;
String defaultTo;
public:
dropdown() : title(""), desc(""), name(""), options(), defaultTo("") {}
void setTitle(const String& str) { title=str; }
void setDesc(const String& str) { desc=str; }
void setName(const String& str) { name=str; }
void setOptions(const Map<String,String>& opts) { options=opts; }
void setDefaultTo(const String& str) { defaultTo=str; }
void doStart(HttpServletRequest& request, HttpServletResponse& response) {
response << "<div class=\"row\">\n"
<< " <div class=\"label\"><a title=\""<<title<<"\" href=\"#\">"<<desc<<"</a></div>\n"
<< " <div class=\"control\"><select name=\""<< name <<"\">\n";
for ( Map<String,String>::const_iterator it=options.begin();
it != options.end();
it++ ) {
response << " <option value=\""<<it->first<<"\" "<< ( (!defaultTo.empty() && it->first==defaultTo)? "selected=\"selected\"" : "" ) <<">"<<it->second<<"</option>\n";
}
response << "</select></div>\n"
<<"</div>\n";
}
};
class dirpermdropdown {
public:
String title;
String desc;
String name;
dirpermdropdown() : title(""), desc(""), name("") {};
void setTitle(const String& str) { title=str; }
void setDesc(const String& str) { desc=str; }
void setName(const String& str) { name=str; }
void doStart(HttpServletRequest& request, HttpServletResponse& response) {
ImageDesc ddesc(path_encode(url_decode(request.getPathInfo())));
bool isPublic=ddesc.isPublic&&!ddesc.isHidden;
bool isPrivate=!ddesc.isPublic&&!ddesc.isHidden;
bool isHidden=ddesc.isHidden;
response << "<div class=\"row\">\n"
<< " <div class=\"label\"><a title=\""<<title<<"\" href=\"#\">"<<desc<<"</a></div>\n"
<< " <div class=\"control\"><select name=\""<<name<<"\">"
<< " <option value=\"hidden\" "<<(isHidden?"selected=\"selected\"":"")<<">caché</option>"
<< " <option value=\"true\" "<<(isPrivate?"selected=\"selected\"":"")<<">privé</option>"
<< " <option value=\"false\" "<<(isPublic?"selected=\"selected\"":"")<<">public</option>"
<< " </select></div>\n"
<< "</div>\n";
}
};
class dirdatedropdown {
String title;
String desc;
String name;
String root;
public:
void setTitle(const String& str) { title=str; }
void setDesc(const String& str) { desc=str; }
void setName(const String& str) { name=str; }
void setRoot(const String& str) { root=str; }
dirdatedropdown() : title(""), desc(""), name(""), root("") {}
void doStart(raii::HttpServletRequest& request, raii::HttpServletResponse& response) {
const char *mname[]= { NULL, "janvier","février","mars","avril","mai","juin",
"juillet","août","septembre","octobre","novembre","décembre",NULL};
String pathPart=getVDirPathPart(url_decode(request.getPathInfo()));
String dirPart=getVDirDirPart(url_decode(request.getPathInfo()));
int timestamp=0;
if ( isVDir(url_decode(request.getPathInfo())) ) {
Connection conn;
String req=String("SELECT date FROM gallery_vdir WHERE path='")+path_encode(pathPart)+"' AND name='"+path_encode(dirPart)+"'";
ResultSet rs=conn.query(req);
if ( rs.next() ) {
timestamp=atoi(rs["date"].c_str());
}
}
Dir ddesc(root,pathPart,dirPart,timestamp);
time_t now=time(NULL);
struct tm bdtime;
if ( !localtime_r(&now,&bdtime) )
throw IOException("localtime");
response << "<div class=\"row\">\n"
<< " <div class=\"label\"><a title=\""<<title<<"\" href=\"#\">"<<desc<<"</a></div>\n"
" <div class=\"control\"><select name=\""<<name<<"_day\">\n";
for ( int i=1 ; i <= 31 ; ++i ) {
response << " <option value=\""<<i<<"\"" << ( i == ddesc.day ? " selected=\"selected\"" : "" ) << ">"
<< i << "</option>\n";
}
response << " </select><select name=\""<<name<<"_month\">\n";
for ( int i=1 ; i <= 12 ; ++i ) {
response << " <option value=\""<<i<<"\"" << ( i == ddesc.month ? " selected=\"selected\"" : "" ) << ">"
<< String(mname[i]) << "</option>\n";
}
response << " </select>""<select name=\""<<name<<"_year\">\n";
for ( int i=bdtime.tm_year+1900; i > 1900 ; --i ) {
response << " <option value=\""<<i<<"\"" << ( i == ddesc.year ? " selected=\"selected\"" : "" ) << ">"
<< i << "</option>\n";
}
response << " </select></div>\n"
"</div>";
}
};
class footer {
int sessionCount;
public:
footer() : sessionCount(0) {}
void setSessionCount(int s) { sessionCount=s; }
void doStart(HttpServletRequest& request, HttpServletResponse& response) {
response << "<div class=\"footer\">"
"Propulsé par <a href=\"http://blackmilk.fr/www/cms/dev/libapache2_mod_raii\">libapache2-mod-raii</a>, "
"<a href=\"http://www.cybercom.net/~dcoffin/dcraw/\">dcraw</a> et "
"<a href=\"http://www.imagemagick.org/\">ImageMagick</a>.<br />"
"Généré par "
"<em><a href=\"http://blackmilk.fr/www/cms/dev/not_so_original\">NotSoOriginal</a> ver. 1.0/rc5</em>.<br />\n"
" Voyeurs connectés : "<< sessionCount << "\n"
"</div>\n";
}
};
class includeSense {
String filename;
public:
void setFilename(const String& str) { filename=str; }
includeSense() : filename("") {}
void doStart(raii::HttpServletRequest& request, raii::HttpServletResponse& response) {
if ( ! filename.empty() ) {
FILE *f=fopen(filename.c_str(),"r");
try {
response << f;
if (f) fclose(f);
}
catch ( ... ) {
if (f) fclose(f);
throw;
}
}
}
};