slitaz-dev-tools view tazwikiss/rootfs/var/www/wiki/index.sh @ rev 184

tazwikiss: fix httphelper path
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Jul 07 18:30:41 2012 +0200 (2012-07-07)
parents 767b3878de00
children 82786012f589
line source
1 #!/bin/sh
2 #
3 # TazWikiss - A tiny Wiki for busybox/httpd
4 # Licence GNU/GPLv2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
5 # Copyright (C) Pascal Bellard
6 # Based on WiKiss - http://wikiss.tuxfamily.org/
8 . /usr/lib/slitaz/httphelper.sh
10 cd $(dirname $0)
11 CONFIG=config-${HTTP_ACCEPT_LANGUAGE%%,*}.sh
12 [ -x "$CONFIG" ] || CONFIG=config.sh
13 . ./$CONFIG
15 WIKI_VERSION="Based on WiKiss 0.3"
17 # Initialisations
18 toc='' # Table Of Content
19 CONTENT='' # contenu de la page
20 HISTORY='' # lien vers l'historique
21 plugins_dir="plugins/" # repertoire ou stocker les plugins
22 template="template.html" # Fichier template
23 PAGE_TITLE_link=true # y-a-t-il un lien sur le titre de la page ?
24 editable=true # la page est editable
25 urlbase="$SCRIPT_NAME"
26 #urlbase="./"
28 die()
29 {
30 echo $@
31 exit
32 }
34 redirect()
35 {
36 awk '{ printf "%s\r\n",$0 }' <<EOT
37 HTTP/1.0 302 Found
38 location: $1
40 EOT
41 exit
42 }
44 cache_auth()
45 {
46 local tmp
47 tmp="$(echo $1$(date +%d) | md5sum | cut -c1-8)"
48 [ "$(POST sc)" == "$1" ] && AUTH=$tmp || [ "$AUTH" == "$tmp" ]
49 }
51 authentified()
52 {
53 [ -n "$PASSWORDS" ] && for i in $PASSWORDS ; do
54 cache_auth "$i" && return
55 done
56 cache_auth "$PASSWORD"
57 }
59 plugin_call_method()
60 {
61 local status
62 local name
63 name=$1
64 shift
65 [ -d "$plugins_dir" ] || return
66 status=false
67 for i in $plugins_dir/*.sh ; do
68 [ -x $i ] || continue
69 grep -q "^$name()" $i || continue
70 . $i
71 eval $name "$@"
72 [ $? == 0 ] && status=true
73 done
74 $status
75 }
77 curdate()
78 {
79 date '+%Y-%m-%d %H:%M'
80 }
82 filedate()
83 {
84 stat -c %y $1 | sed -e 's|-|/|g' -e 's/\(:..\):.*/\1/'
85 }
87 AUTH=$(GET auth)
88 [ -n "$AUTH" ] || AUTH=$(POST auth)
89 PAGE_TITLE="$(GET page)"
90 [ -n "$PAGE_TITLE" ] || PAGE_TITLE="$(POST page)"
91 if [ -z "$PAGE_TITLE" ]; then
92 PAGE_TITLE="$START_PAGE"
93 case "$(GET action)" in
94 recent) PAGE_TITLE="$RECENT_CHANGES" ;;
95 search) PAGE_TITLE="$LIST"
96 [ -n "$(GET query)" ] && PAGE_TITLE="$SEARCH_RESULTS $(GET query)"
97 esac
98 fi
99 case "$PAGE_TITLE" in
100 */*|*\&*) PAGE_TITLE="$START_PAGE" ;;
101 esac
102 gtime=$(GET time)
103 case "$gtime" in
104 */*|*\&*) gtime="" ;;
105 esac
106 action=$(GET action)
107 datew="$(curdate)"
108 content="$(POST content)"
110 # Ecrire les modifications, s'il y a lieu
111 PAGE_txt="$PAGES_DIR$PAGE_TITLE.txt"
112 plugin_call_method "init" $PAGE_txt
113 if [ -n "$content" ]; then # content => page
114 if authentified; then
115 CR="$(echo -en '\r')"
116 sed 's/</\&lt;/g;s/'$CR' /'$CR'\n/g' > $PAGE_txt <<EOT
117 $content
118 EOT
119 if [ -n "$BACKUP_DIR" ]; then
120 complete_dir_s="$BACKUP_DIR$PAGE_TITLE/"
121 if [ ! -d "$complete_dir_s" ]; then
122 mkdir -p $complete_dir_s
123 chmod 777 $complete_dir_s
124 fi
125 cat >> "$complete_dir_s$(curdate).bak" <<EOT
127 // $datew / $REMOTE_ADDR
128 $(cat $PAGE_txt)
129 EOT
130 fi
131 plugin_call_method "writedPage" $PAGE_txt
132 PAGE_TITLE="$PAGE_TITLE&auth=$AUTH"
133 else
134 PAGE_TITLE="$PAGE_TITLE&action=edit&error=1"
135 fi
136 redirect "$urlbase?page=$PAGE_TITLE"
137 fi
139 if [ -r "$PAGE_txt" -o -n "$action" ]; then
140 CONTENT=""
141 if [ -e "$PAGE_txt" ]; then
142 TIME=$(filedate $PAGE_txt)
143 CONTENT="$(cat $PAGE_txt)"
144 fi
145 # Restaurer une page
146 [ -n "$(GET page)" -a -n "$gtime" -a "$(GET restore)" == 1 ] &&
147 [ -r "$BACKUP_DIR$PAGE_TITLE/$gtime" ] &&
148 CONTENT="$(cat $BACKUP_DIR$PAGE_TITLE/$gtime)"
149 CONTENT="$(sed -e 's/\$/\&#036;/g' -e 's/\\/\&#092;/g' <<EOT
150 $CONTENT
151 EOT
152 )"
153 else
154 CONTENT="$(sed -e "s#%page%#$PAGE_TITLE#" <<EOT
155 $DEFAULT_CONTENT
156 EOT
157 )"
158 fi
160 htmldiff()
161 {
162 local files
163 local old
164 local new
165 old="$BACKUP_DIR$(GET page)/$1"
166 new="$BACKUP_DIR$(GET page)/$2"
167 [ -s "$old" ] || old=/dev/null
168 [ -n "$2" -a "$2" != "none" ] || new=$PAGES_DIR$(GET page).txt
169 files="$old $new"
170 [ "$old" -nt "$new" -a "$old" != "/dev/null" ] && files="$new $old"
171 diff -aU 99999 $files | sed -e '1,3d' -e '/^\\/d' -e 's|$|<br/>|' \
172 -e 's|^-\(.*\)$|<font color=red>\1</font>|' \
173 -e 's|^+\(.*\)$|<font color=green>\1</font>|'
174 }
176 # Actions speciales du Wiki
177 case "$action" in
178 edit)
179 editable=false
180 HISTORY="<a href=\"$urlbase?page=$(urlencode $PAGE_TITLE)\&amp;action=history\" accesskey=\"6\" rel=\"nofollow\">$HISTORY_BUTTON</a><br />"
181 CONTENT="<form method=\"post\" action=\"$urlbase\">
182 <textarea name=\"content\" cols=\"83\" rows=\"30\" style=\"width: 100%;\">
183 $CONTENT
184 </textarea>
185 <input type=\"hidden\" name=\"page\" value=\"$PAGE_TITLE\" /><br />
186 <p align=\"right\">"
187 if authentified; then
188 CONTENT="$CONTENT<input type=\"hidden\" value=\"$(POST password)\""
189 else
190 CONTENT="$CONTENT$MDP : <input type=\"password\""
191 fi
192 CONTENT="$CONTENT name=\"sc\" /> <input type=\"submit\" value=\"$DONE_BUTTON\" accesskey=\"s\" /></p></form>"
193 ;;
194 history)
195 complete_dir="$BACKUP_DIR$PAGE_TITLE/"
196 if [ -n "$gtime" ]; then
197 HISTORY="<a href=\"$urlbase?page=$PAGE_TITLE\&amp;action=history\" rel=\"nofollow\">$HISTORY_BUTTON</a>"
198 if [ -r "$complete_dir$gtime" ]; then
199 HISTORY="$HISTORY <a href=\"$urlbase?page=$PAGE_TITLE\&amp;action=edit\&amp;time=$gtime&amp;restore=1\" rel=\"nofollow\">$RESTORE</a>"
200 CONTENT="$(cat $complete_dir$gtime | sed -e s/$(echo -ne '\r')//g -e 's|$|<br/>|g')"
201 else
202 HISTORY="$HISTORY -"
203 fi
204 else
205 HISTORY="$HISTORY_BUTTON"
206 CONTENT="$NO_HISTORY"
207 if [ -d $complete_dir ]; then
208 CONTENT="<form method=\"GET\" action=\"$urlbase\">\n<input type=hidden name=action value=diff><input type=hidden name=page value=\"$PAGE_TITLE\">"
209 for file in $(ls $complete_dir | sort -r); do
210 CONTENT="$CONTENT
211 <input type=radio name=f1 value=$file><input type=radio name=f2 value=$file />
212 <a href=\"$urlbase?page=$PAGE_TITLE&amp;action=history&amp;time=$file\">$file</a><br />
213 "
214 done
215 CONTENT="$CONTENT<input type=submit value=diff></form>"
216 fi
217 fi ;;
218 diff)
219 if [ -n "$(GET f1)" ]; then
220 HISTORY="<a href=\"$urlbase?page=$(urlencode "$PAGE_TITLE")\&amp;action=history\">$HISTORY_BUTTON</a>"
221 CONTENT="$(htmldiff "$(GET f1)" "$(GET f2)" )"
222 else
223 # diff auto entre les 2 dernières versions
224 ls "$BACKUP_DIR$PAGE_TITLE/" | ( sort -r ; echo none ; echo ) | head -n 2 | while read f1 f2; do
225 redirect "$urlbase?page=$(urlencode "$PAGE_TITLE")&action=$action&f1=$f1&f2=$f2"
226 done
227 fi ;;
228 search)
229 PAGE_TITLE_link=false
230 editable=false
231 query="$(GET query)"
232 n=0
233 for file in $(ls $PAGES_DIR/*.txt 2> /dev/null | sort) ; do
234 [ -e $file ] || continue
235 echo $file | grep -qs "$query" $file /dev/stdin || continue
236 file=$(basename $file ".txt")
237 CONTENT="$CONTENT<a href=\"$urlbase?page=$file\">$file</a><br />
238 "
239 n=$(($n + 1))
240 done
241 PAGE_TITLE="$PAGE_TITLE ($n)" ;;
242 recent)
243 PAGE_TITLE_link=false
244 editable=false
245 n=0
246 for file in $(ls -l $PAGES_DIR/*.txt 2> /dev/null | awk '{ print $9 }' | tail -n 10) ; do
247 filename=$(basename $file ".txt")
248 timestamp=$(filedate $file)
249 CONTENT="$CONTENT<a href=\"$urlbase?page=$filename\">$filename</a> ($timestamp - <a href=\"$urlbase?page=$filename&amp;action=diff\">diff</a>)<br />
250 "
251 done ;;
252 '') ;;
253 *)
254 plugin_call_method "action" $action || action="" ;;
255 esac
256 if [ -z "$action" ]; then
257 if echo "$CONTENT" | grep -q '%html%\s'; then
258 CONTENT="$(sed 's/%html%\s//' <<EOT
259 $CONTENT
260 EOT
261 )"
262 else
263 tmpdir=/tmp/tazwiki$$
264 mkdir $tmpdir
265 unesc="$(echo "$CONTENT" | sed 's/\^\(.\)/\n^\1\n/g' | grep '\^' |\
266 sort | uniq | grep -v "['[!]" | hexdump -e '"" 3/1 "%d " "\n"' |\
267 awk '{ printf "-e '\''s/\\^%c/\\&#%d;/g'\'' ",$2,$2}') \
268 -e 's/\\^'\\''/\\&#39;/g' -e 's/\^\!/\&#33;/g' \
269 -e 's/\^\[/\&#91;/g'"
270 CONTENT="$(eval sed $unesc <<EOT | \
271 sed -e 's/&/\&amp;/g' -e s/$(echo -ne '\r')//g \
272 -e 's/&amp;lt;/\&lt;/g' -e 's/&amp;#\([0-9]\)/\&#\1/g' | \
273 awk -v tmpdir=$tmpdir 'BEGIN { n=1; state=0 } {
274 s=$0
275 while (1) {
276 if (state == 0) {
277 if (match(s,/\{\{/)) {
278 printf "%s<pre><code>{{CODE%s}}</code></pre>",substr(s,1,RSTART-1),n
279 s=substr(s,RSTART+RLENGTH)
280 state=1
281 }
282 else {
283 print s
284 break
285 }
286 }
287 if (state == 1) {
288 if (match(s,/\}\}/)) {
289 printf "%s",substr(s,1,RSTART-1) >> tmpdir "/CODE" n
290 s=substr(s,RSTART+RLENGTH)
291 n++
292 state=0
293 }
294 else {
295 print s >> tmpdir "/CODE" n
296 break
297 }
298 }
299 }
300 }'
301 $CONTENT
302 EOT
303 )"
304 plugin_call_method formatBegin
305 CONTENT="$(sed -e 's/&lt;-->/\&harr;/g' -e 's/&lt;==>/\&hArr;/g'\
306 -e 's/-->/\&rarr;/g' -e 's/&lt;--/\&larr;/g' \
307 -e 's/==>/\&rArr;/g' -e 's/&lt;==/\&lArr;/g' \
308 -e 's/([eE])/\&euro;/g' -e 's/([pP])/\&pound;/g' \
309 -e 's/([yY])/\&yen;/g' -e 's/([tT][mM])/\&trade;/g' \
310 -e 's/([cC])/\&copy;/g' -e 's/([rR])/\&reg;/g' \
311 -e 's/([dD])/\&deg;/g' -e 's/(1\/2)/\&frac12;/g' \
312 -e 's/(1\/4)/\&frac14;/g' -e 's/(3\/4)/\&frac34;/g' \
313 -e 's/(&lt;=)/\&le;/g' -e 's/(>=)/\&ge;/g' \
314 -e 's/(!=)/\&ne;/g' -e 's/(+-)/\&plusmn;/g' <<EOT
315 $CONTENT
316 EOT
317 )"
318 rg_url="[0-9a-zA-Z\.\#/~\_%=\?\&,\+\:@;!\(\)\*\$'\-]*" # TODO: verif & / &amp;
319 rg_link_local="$rg_url"
320 rg_link_http="https\?://$rg_url"
321 rg_img_local="$rg_url\.jpe\?g\|$rg_url\.gif\|$rg_url\.png"
322 rg_img_http="$rg_link_http\.jpe\?g\|$rg_link_http\.gif\|$rg_link_http\.png"
324 # image, image link, link, wikipedia, email ...
325 CONTENT="$(sed \
326 -e "s#\[\($rg_img_http\)\]#<img src=\"\1\" alt=\"\1\" style=\"float:\"/>#g" \
327 -e "s#\[\($rg_img_local\)\]#<img src=\"\1\" alt=\"\1\" style=\"float:\"/>#g" \
328 -e "s#\[\($rg_img_http\)|*\([a-z]*\)*\]#<img src=\"\1\" alt=\"\1\" style=\"float:\2;\"/>#g" \
329 -e "s#\[\($rg_img_local\)|*\([a-z]*\)*\]#<img src=\"\1\" alt=\"\1\" style=\"float:\2;\"/>#g" \
330 -e "s#\[\($rg_img_http\)|\($rg_link_http\)|*\([a-z]*\)*\]#<a href=\"\2\" class=\"url\"><img src=\"\1\" alt=\"\1\" title=\"\1\"style=\"float:\3;\"/></a>#g" \
331 -e "s#\[\($rg_img_http\)|\($rg_link_local\)|*\([a-z]*\)*\]#<a href=\"\2\" class=\"url\"><img src=\"\1\" alt=\"\1\" title=\"\1\"style=\"float:\3;\"/></a>#g" \
332 -e "s#\[\($rg_img_local\)|\($rg_link_http\)|*\([a-z]*\)*\]#<a href=\"\2\" class=\"url\"><img src=\"\1\" alt=\"\1\" title=\"\1\"style=\"float:\3;\"/></a>#g" \
333 -e "s#\[\($rg_img_local\)|\($rg_link_local\)|*\([a-z]*\)*\]#<a href=\"\2\" class=\"url\"><img src=\"\1\" alt=\"\1\" title=\"\1\"style=\"float:\3;\"/></a>#g" \
334 -e "s#\[\([^]]*\)|\($rg_link_http\)\]#<a href=\"\2\" class=\"url\">\1</a>#g" \
335 -e "s#\[\([^]]*\)|\($rg_link_local\)\]#<a href=\"\2\" class=\"url\">\1</a>#g" \
336 -e "s#\[\($rg_link_http\)\]#<a href=\"\1\" class=\"url\">\1</a>#g" \
337 -e "s#\([^>\"]\)\($rg_link_http\)#\1<a href=\"\2\" class=\"url\">\2</a>#g" \
338 -e "s#\[?\([^]]*\)\]#<a href=\"http://$LANG.wikipedia.org/wiki/\1\" class=\"url\" title=\"Wikipedia\">\1</a>#g" \
339 -e "s#\[\([^]]*\)\]#<a href=\"$urlbase?page=\1\">\1</a>#g" \
340 -e 's#\([0-9a-zA-Z\./~\-\_][0-9a-zA-Z\./~\-\_]*@[0-9a-zA-Z\./~\-\_][0-9a-zA-Z\./~\-\_]*\)#<a href=\"mailto:\1\">\1</a>#g' \
341 -e 's#^\*\*\*\(.*\)#<ul><ul><ul><li>\1</li></ul></ul></ul>#g' \
342 -e 's#^\*\*\(.*\)#<ul><ul><li>\1</li></ul></ul>#g' \
343 -e 's#^\*\(.*\)#<ul><li>\1</li></ul>#g' \
344 -e 's,^\#\#\#\(.*\),<ol><ol><ol><li>\1</li></ol></ol></ol>,g' \
345 -e 's,^\#\#\(.*\),<ol><ol><li>\1</li></ol></ol>,g' \
346 -e 's,^\#\(.*\),<ol><li>\1</li></ol>,g' \
347 -e "s/$(printf '\r')//" <<EOT | sed \
348 -e ':x;/<\/ol>$/{N;s/\n//;$P;$D;bx;}' | sed \
349 -e ':x;/<\/ul>$/{N;s/\n//;$P;$D;bx;}' | sed \
350 -e ':x;s/<\/ul><ul>//g;tx' -e ':x;s/<\/ol><ol>//g;tx' \
351 -e 's|----*$|<hr />|' -e 's|$|<br />|' \
352 -e 's#</li>#&\n#g' -e 's#\(</h[123456]>\)<br />#\1#g' \
353 -e "s#'--\([^']*\)--'#<del>\1</del>#g" \
354 -e "s#'__\([^']*\)__'#<u>\1</u>#g" \
355 -e "s#'''''\([^']*\)'''''#<strong><em>\1</em></strong>#g" \
356 -e "s#'''\([^']*\)'''#<strong>\1</strong>#g" \
357 -e "s#''\([^']*\)''#<em>\1</em>#g"
358 $CONTENT
359 EOT
360 )"
361 while read link; do
362 [ -s $PAGES_DIR$link.txt ] && continue
363 CONTENT="$(sed "s|\\?page=$link\"|& class=\"pending\"|" <<EOT
364 $CONTENT
365 EOT
366 )"
367 done <<EOT
368 $(grep "$urlbase?page=" <<EOM | sed -e 's/^.*\?page=\([^"]*\).*$/\1/' -e 's/&.*//'
369 $CONTENT
370 EOM
371 )
372 EOT
373 while echo "$CONTENT" | grep -q '^ ' ; do
374 CONTENT="$(sed 's/^\( *\) \([^ ]\)/\1\&nbsp;\&nbsp;\&nbsp;\&nbsp;\2/' <<EOT
375 $CONTENT
376 EOT
377 )"
378 done
379 read hastoc <<EOT
380 $CONTENT
381 EOT
382 CONTENT="$(sed -e 's/^ /\&nbsp;\&nbsp;\&nbsp;\&nbsp;/' -e '1s/^TOC//' <<EOT
383 $CONTENT
384 EOT
385 )"
386 toc='<div id="toc">'
387 i=1
388 for pat in '^![^!]' '^!![^!]' '^!!![^!]' '^!!!![^!]' '^!!!!!' ; do
389 while read line; do
390 [ -n "$line" ] || continue
391 label="$(echo $line | sed 's/[^\dA-Za-z]/_/g')"
392 toc="$(cat <<EOT
393 $toc
394 <h$i><a href="#$label">$line</a></h$i>
395 EOT
396 )"
397 CONTENT="$(sed "s#^!!* *$line\$#<h$i><a name=\"$label\">$line</a></h$i>#" <<EOT
398 $CONTENT
399 EOT
400 )"
401 done <<EOT
402 $(grep "$pat" <<EOM | sed -e 's/^!!*//' -e 's/#/\#/g' -e 's/&/\\\&/g'
403 $CONTENT
404 EOM
405 )
406 EOT
407 i=$(( $i + 1 ))
408 done
409 toc="$(cat <<EOT
410 $toc
411 </div>
412 EOT
413 )"
414 case "$hastoc" in
415 TOC*) ;;
416 *) toc='';;
417 esac
418 CONTENT="$(awk -v tmpdir=$tmpdir '{
419 s=$0
420 while (1) {
421 if (match(s,/\{\{CODE[0-9]+\}\}/)) {
422 printf "%s" substr(s,1,RSTART-1)
423 system("cat " tmpdir "/" substr(s,RSTART+2,RLENGTH-4))
424 s=substr(s,RSTART+RLENGTH)
425 }
426 else {
427 print s
428 break
429 }
430 }
431 }' <<EOT
432 $CONTENT
433 EOT
434 )"
435 rm -rf $tmpdir
436 plugin_call_method formatEnd
437 fi
438 fi
440 # Remplacement dans le template
441 RECENT="<a href=\"$urlbase?action=recent\" accesskey=\"3\">$RECENT_CHANGES</a>"
442 [ "$action" == "recent" ] && RECENT=$RECENT_CHANGES
443 HOME="<a href=\"$urlbase?page=$START_PAGE\" accesskey=\"1\">$HOME_BUTTON</a>"
444 [ "$PAGE_TITLE" == "$START_PAGE" -a "$action" != "search" ] && HOME=$HOME_BUTTON
445 HELP="\1<a href=\"$urlbase?page=$HELP_BUTTON\" accesskey=\"2\" rel=\"nofollow\">$HELP_BUTTON</a>\2"
446 [ "$action" != "edit" ] && HELP=""
448 [ -r "$template" ] || die "'$template' is missing!"
449 html="$(sed -e "s#{\([^}]*\)RECENT_CHANGES\([^}]*\)}#\1$RECENT\2#" \
450 -e "s#{\([^}]*\)HOME\([^}]*\)}#\1$HOME\2#" \
451 -e "s#{\([^}]*\)HELP\([^}]*\)}#$HELP#" \
452 -e "s#{SEARCH}#<form method=\"get\" action=\"$urlbase?page=$(urlencode "$PAGE_TITLE" | sed 's/#/\\#/g')\"><div><input type=\"hidden\" name=\"action\" value=\"search\" /><input type=\"text\" name=\"query\" value=\"$(htmlentities $(GET query) )\" tabindex=\"1\" /> <input type=\"submit\" value=\"$SEARCH_BUTTON\" accesskey=\"q\" /></div></form>#" \
453 < $template )"
454 [ "$action" != "" -a "$action" != "edit" -o ! -e "$PAGE_txt" ] && TIME="-"
455 plugin_call_method template
456 [ -n "$(GET error)" ] || ERROR=""
457 [ -n "$HISTORY" ] && HISTORY="\1$HISTORY\2"
458 PAGE_TITLE_str="$(htmlentities "$PAGE_TITLE")"
459 $PAGE_TITLE_link &&
460 PAGE_TITLE_str="<a href=\"$urlbase?page=$(urlencode "$PAGE_TITLE")\">$PAGE_TITLE_str</a>"
461 EDIT="$EDIT_BUTTON"
462 if $editable ; then
463 EDIT="$PROTECTED_BUTTON"
464 [ -w "$PAGE_txt" -o ! -e "$PAGE_txt" ] &&
465 EDIT="<a href=\"$urlbase?page=$(urlencode "$PAGE_TITLE")\&amp;action=edit\" accesskey=\"5\" rel=\"nofollow\">$EDIT_BUTTON</a>"
466 fi
467 [ -n "$toc" ] && toc="\1$toc\2"
468 AUTH_GET=""
469 AUTH_POST=""
470 if authentified; then
471 AUTH_GET="auth=$AUTH\&"
472 AUTH_POST="\n<input type=\"hidden\" name=\"auth\" value=\"$AUTH\" />"
473 fi
475 header "Content-type: text/html"
476 sed -e "s#{ERROR}#$ERROR#" -e "s#{WIKI_TITLE}#$WIKI_TITLE#" \
477 -e "s#{\([^}]*\)HISTORY\([^}]*\)}#$HISTORY#" \
478 -e "s#{PAGE_TITLE}#$PAGE_TITLE_str#" \
479 -e "s#{\([^}]*\)EDIT\([^}]*\)}#\1$EDIT\2#" \
480 -e "s|{\([^}]*\)TOC\([^}]*\)}|$(awk '{ printf "%s\\n" $0 }' <<EOT | \
481 sed -e 's/&/\\\&/g' -e 's/|/\\|/g'
482 $toc
483 EOT
484 )|" \
485 -e "s#{PAGE_TITLE_BRUT}#$(htmlentities "$PAGE_TITLE")#" \
486 -e "s#{LAST_CHANGE}#$LAST_CHANGES :#" \
487 -e "s#{CONTENT}#$(awk '{ printf "%s\\n" $0 }' <<EOT | \
488 sed -e 's/&/\\\&/g' -e 's/#/\\#/g'
489 $CONTENT
490 EOT
491 )#" \
492 -e "s#{LANG}#$LANG#" -e "s#href=\"?#href=\"$urlbase?#g" \
493 -e "s#$urlbase?#&$AUTH_GET#g" -e "s#action=\"$urlbase\">#&$AUTH_POST#g" \
494 -e "s#{WIKI_VERSION}#$WIKI_VERSION#" \
495 -e "s#{TIME}#$TIME#" -e "s#{DATE}#$datew#" \
496 -e "s#{IP}#$REMOTE_ADDR#" -e "s#{COOKIE}##" <<EOT
497 $html
498 EOT