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

tazwikiss: restore data trees only
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Apr 03 17:01:11 2011 +0200 (2011-04-03)
parents a8cceb6943e9
children d06be7877600
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 else
20 file=$(FILE file tmpname)
21 zcat $file | cpio -idmu $(echo */ | sed 's|/||g')
22 return 1
23 fi
24 rm -f $file
25 exit 0
26 ;;
27 *) return 1
28 esac
29 CONTENT='
30 <table width="100%">
31 <tr><td span=2><h2>Plugins</h2></td></tr>
32 '
33 PAGE_TITLE_link=false
34 editable=false
35 lang="${HTTP_ACCEPT_LANGUAGE%%,*}"
36 PAGE_TITLE="Configuration"
37 for i in $plugins_dir/*.sh ; do
38 plugin=
39 eval $(grep ^plugin= $i)
40 [ -n "$plugin" ] || continue
41 eval $(grep ^description= $i)
42 alt="$(grep ^description_$lang= $i)"
43 [ -n "$alt" ] && eval $(echo "$alt" | sed 's/_..=/=/')
44 CONTENT="$CONTENT
45 <tr><td><b>
46 <input type=checkbox disabled=disabled $([ -x $i ] && echo 'checked=checked ')/>
47 $plugin</b></td><td><i>$description</i></td></tr>"
48 done
49 CONTENT="$CONTENT
50 <tr><td span=2><br /><h2>Locales</h2></td></tr>
51 "
52 for i in config-*.sh ; do
53 i=${i#config-}
54 i=${i%.sh}
55 [ -n "$i" ] || continue
56 CONTENT="$CONTENT
57 <tr><td><b>
58 <input type=checkbox disabled=disabled $([ "$i" == "$lang" ] && echo 'checked=checked ')/>
59 $i</b></td></tr>
60 "
61 done
62 CONTENT="$CONTENT
63 <tr><td><br /><h2>Data</h2></td>
64 <td><form method=\"post\" enctype=\"multipart/form-data\" action=\"?action=backup\">
65 <input type=\"submit\" name=\"save\" value=\"$DONE_BUTTON\" />"
66 [ "$ALLOW_UPLOAD" == "yes" ] && CONTENT="$CONTENT
67 <input type=\"file\" name=\"file\" value=\"file\" />
68 <input type=\"submit\" name=\"restore\" value=\"$RESTORE\" />"
69 CONTENT="$CONTENT
70 </form></td></tr>
71 $(du -hs */ | awk '{ printf "<tr><td><b>%s</b></td><td><i>%s</i></td></tr>\n",$1,$2 }')
72 </table>
73 "
74 }