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
|
while(1){
int cnt = 0;
while( db_step(&q1)==SQLITE_ROW ){
int id = db_column_int(&q1, 0);
const char *zDate = db_column_text(&q1, 1);
const char *zFrom = db_column_text(&q1, 2);
const char *zRawMsg = db_column_text(&q1, 3);
char *zMsg;
int nByte;
cnt++;
blob_append(&json, zSep, -1);
zSep = ",\n";
blob_appendf(&json, "{\"msgid\":%d,\"mtime\":\"%j\",", id, zDate);
blob_appendf(&json, "\"xfrom\":\"%j\",", zFrom);
blob_appendf(&json, "\"uclr\":\"%j\",", hash_color(zFrom));
/* TBD: Convert the raw message into HTML, perhaps by running it
** through a text formatter, or putting markup on @name phrases,
** etc. */
zMsg = mprintf("%h", zRawMsg);
blob_appendf(&json, "\"xmsg\":\"%j\",", zMsg);
fossil_free(zMsg);
nByte = db_column_bytes(&q1, 4);
if( nByte==0 ){
blob_appendf(&json, "\"fsize\":0}");
}else{
const char *zFName = db_column_text(&q1, 5);
const char *zFMime = db_column_text(&q1, 6);
blob_appendf(&json, "\"fsize\":%d,\"fname\":\"%j\",\"fmime\":\"%j\"}",
nByte, zFName, zFMime);
}
}
if( cnt ){
blob_append(&json, "\n]}", 3);
cgi_set_content(&json);
|
>
>
>
<
<
<
<
|
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
|
while(1){
int cnt = 0;
while( db_step(&q1)==SQLITE_ROW ){
int id = db_column_int(&q1, 0);
const char *zDate = db_column_text(&q1, 1);
const char *zFrom = db_column_text(&q1, 2);
const char *zRawMsg = db_column_text(&q1, 3);
int nByte = db_column_bytes(&q1, 4);
const char *zFName = db_column_text(&q1, 5);
const char *zFMime = db_column_text(&q1, 6);
char *zMsg;
cnt++;
blob_append(&json, zSep, -1);
zSep = ",\n";
blob_appendf(&json, "{\"msgid\":%d,\"mtime\":\"%j\",", id, zDate);
blob_appendf(&json, "\"xfrom\":\"%j\",", zFrom);
blob_appendf(&json, "\"uclr\":\"%j\",", hash_color(zFrom));
/* TBD: Convert the raw message into HTML, perhaps by running it
** through a text formatter, or putting markup on @name phrases,
** etc. */
zMsg = mprintf("%h", zRawMsg);
blob_appendf(&json, "\"xmsg\":\"%j\",", zMsg);
fossil_free(zMsg);
if( nByte==0 ){
blob_appendf(&json, "\"fsize\":0}");
}else{
blob_appendf(&json, "\"fsize\":%d,\"fname\":\"%j\",\"fmime\":\"%j\"}",
nByte, zFName, zFMime);
}
}
if( cnt ){
blob_append(&json, "\n]}", 3);
cgi_set_content(&json);
|
287
288
289
290
291
292
293
294
295
296
297
|
** WEBPAGE: chat-download
**
** Download the CHAT.FILE attachment associated with a single chat
** entry. The "name" query parameter begins with an integer that
** identifies the particular chat message.
*/
void chat_download_webpage(void){
login_check_credentials();
if( !g.perm.Chat ) return;
chat_create_tables();
}
|
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
** WEBPAGE: chat-download
**
** Download the CHAT.FILE attachment associated with a single chat
** entry. The "name" query parameter begins with an integer that
** identifies the particular chat message.
*/
void chat_download_webpage(void){
int msgid;
Blob r;
const char *zMime;
login_check_credentials();
if( !g.perm.Chat ){
style_header("Chat Not Authorized");
@ <h1>Not Authorized</h1>
@ <p>You do not have permission to use the chatroom on this
@ repository.</p>
style_finish_page();
return;
}
chat_create_tables();
msgid = atoi(PD("name","0"));
blob_zero(&r);
zMime = db_text(0, "SELECT fmime FROM chat wHERE msgid=%d", msgid);
if( zMime==0 ) return;
db_blob(&r, "SELECT file FROM chat WHERE msgid=%d", msgid);
cgi_set_content_type(zMime);
cgi_set_content(&r);
}
|