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
...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
lib.str.cmp(art(0).mime, 'application/sql') == 0
-- and so on (we need a mimelib at some point) --
then
var view = data.view.media_text(viewerprops)
var text, mime = co.srv:artifact_load(id) mime:free()
var san = lib.html.sanitize(&co.srv.pool,pstr{[rawstring](text.ptr),text.ct}, false)
text:free()
view.text = lib.str.acc{}:compose('<pre>',san,'</pre>'):finalize()
san:free()
var pg = view:tostr()
view.text:free()
co:stdpage([lib.srv.convo.page] {
title = lib.str.plit'media :: text';
class = lib.str.plit'media viewer text';
cache = false, body = pg;
})
pg:free()
else co:complain(500,'bad file type','this file type is not supported') end
elseif path.ct == 4 then
var act = path(3)
var curl = lib.str.acc{}:compose(pfx, '/media/a/', path(2)):finalize()
defer curl:free()
if act:cmp(lib.str.lit'avi') and lib.str.ncmp(art(0).mime, 'image/', 6) == 0 then
co:confirm('set avatar', 'are you sure you want this image to be your new avatar?',curl)
elseif act:cmp(lib.str.lit'del') then
co:confirm('delete', 'are you sure you want to permanently delete this artifact?',curl)
else goto e404 end
end
else
................................................................................
folders = pstr{'',0};
directory = pstr{'',0};
images = pstr{'',0};
pfx = pfx;
}
if folders.ct > 0 then
var fa: lib.str.acc fa:pool(&co.srv.pool,128)
var fldr = co:pgetv('folder')
for i=0,folders.ct do
var ule = lib.html.urlenc(&co.srv.pool,folders(i), true) -- defer ule:free()
var san = lib.html.sanitize(&co.srv.pool,folders(i), true) -- defer san:free()
fa:lpush('<a href="'):ppush(pfx):lpush('/media?folder='):ppush(ule)
:lpush('">'):ppush(san):lpush('</a>')
lib.dbg('checking folder ',{fldr.ptr,fldr.ct},' against ',{folders(i).ptr,folders(i).ct})
|
|
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
...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
lib.str.cmp(art(0).mime, 'application/sql') == 0
-- and so on (we need a mimelib at some point) --
then
var view = data.view.media_text(viewerprops)
var text, mime = co.srv:artifact_load(id) mime:free()
var san = lib.html.sanitize(&co.srv.pool,pstr{[rawstring](text.ptr),text.ct}, false)
text:free()
view.text = co:qstr('<pre>',san,'</pre>')
--san:free()
var pg = view:poolstr(&co.srv.pool)
--view.text:free()
co:stdpage([lib.srv.convo.page] {
title = lib.str.plit'media :: text';
class = lib.str.plit'media viewer text';
cache = false, body = pg;
})
--pg:free()
else co:complain(500,'bad file type','this file type is not supported') end
elseif path.ct == 4 then
var act = path(3)
var curl = co:qstr('/media/a/', path(2))
-- defer curl:free()
if act:cmp(lib.str.lit'avi') and lib.str.ncmp(art(0).mime, 'image/', 6) == 0 then
co:confirm('set avatar', 'are you sure you want this image to be your new avatar?',curl)
elseif act:cmp(lib.str.lit'del') then
co:confirm('delete', 'are you sure you want to permanently delete this artifact?',curl)
else goto e404 end
end
else
................................................................................
folders = pstr{'',0};
directory = pstr{'',0};
images = pstr{'',0};
pfx = pfx;
}
if folders.ct > 0 then
var fa = co:stra(128)
var fldr = co:pgetv('folder')
for i=0,folders.ct do
var ule = lib.html.urlenc(&co.srv.pool,folders(i), true) -- defer ule:free()
var san = lib.html.sanitize(&co.srv.pool,folders(i), true) -- defer san:free()
fa:lpush('<a href="'):ppush(pfx):lpush('/media?folder='):ppush(ule)
:lpush('">'):ppush(san):lpush('</a>')
lib.dbg('checking folder ',{fldr.ptr,fldr.ct},' against ',{folders(i).ptr,folders(i).ct})
|