slitaz-dev-tools view tazwikiss/rootfs/var/www/wiki/plugins/wkp_ListPlugins.sh @ rev 56

tazwikiss: save/restore data
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Apr 03 00:29:02 2011 +0200 (2011-04-03)
parents add86f2168cd
children 8b4a54db076c
line source
1 plugin="<a href=\"?action=list\">ListPlugins</a>"
2 description_fr="Affiche la liste des plugins chargés"
3 description="List plugins"
5 action()
6 {
7 case "$1" in
8 list|config);;
9 backup) if [ -n "$(POST save)" ]; then
10 file=$(mktemp -p /tmp)
11 find */ | cpio -o -H newc | gzip -9 > $file
12 cat <<EOT
13 Content-Type: application/octet-stream
14 Content-Length: $(stat -c %s $file)
15 Content-Disposition: attachment; filename=wiki-$(date '+%Y%m%d%H%M').cpio.gz
17 EOT
18 cat $file
19 elif [ -n "$(POST restore)" ]; then
20 file=$(FILE file tmpname)
21 zcat $file | cpio -idmu
22 fi
23 rm -f $file
24 exit 0
25 ;;
26 *) return 1
27 esac
28 CONTENT='
29 <table width="100%">
30 <tr><td span=2><h2>Plugins</h2></td></tr>
31 '
32 PAGE_TITLE_link=false
33 editable=false
34 lang="${HTTP_ACCEPT_LANGUAGE%%,*}"
35 PAGE_TITLE="Configuration"
36 for i in $plugins_dir/*.sh ; do
37 plugin=
38 eval $(grep ^plugin= $i)
39 [ -n "$plugin" ] || continue
40 eval $(grep ^description= $i)
41 alt="$(grep ^description_$lang= $i)"
42 [ -n "$alt" ] && eval $(echo "$alt" | sed 's/_..=/=/')
43 CONTENT="$CONTENT
44 <tr><td><b>
45 <input type=checkbox disabled=disabled $([ -x $i ] && echo 'checked=checked ')/>
46 $plugin</b></td><td><i>$description</i></td></tr>"
47 done
48 CONTENT="$CONTENT
49 <tr><td span=2><br /><h2>Locales</h2></td></tr>
50 "
51 for i in config-*.sh ; do
52 i=${i#config-}
53 i=${i%.sh}
54 [ -n "$i" ] || continue
55 CONTENT="$CONTENT
56 <tr><td><b>
57 <input type=checkbox disabled=disabled $([ "$i" == "$lang" ] && echo 'checked=checked ')/>
58 $i</b></td></tr>
59 "
60 done
61 CONTENT="$CONTENT
62 <tr><td><br /><h2>Data</h2></td>
63 <td><form method=\"post\" action=\"?action=backup\">
64 <input type=\"submit\" name=\"save\" value=\"save\" />"
65 [ "$ALLOW_UPLOAD" == "yes" ] && CONTENT="$CONTENT
66 <input type=\"file\" name=\"file\" value=\"file\" />
67 <input type=\"submit\" name=\"restore\" value=\"restore\" />"
68 CONTENT="$CONTENT
69 </form></td></tr>
70 $(du -hs */ | awk '{ printf "<tr><td><b>%s</b></td><td><i>%s</i></td></tr>\n",$1,$2 }')
71 </table>
72 "
73 }