slitaz-dev-tools 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 317ec0b8302e
children 8b4a54db076c
files tazwikiss/rootfs/var/www/wiki/plugins/wkp_ListPlugins.sh
line diff
     1.1 --- a/tazwikiss/rootfs/var/www/wiki/plugins/wkp_ListPlugins.sh	Sat Apr 02 13:52:03 2011 +0000
     1.2 +++ b/tazwikiss/rootfs/var/www/wiki/plugins/wkp_ListPlugins.sh	Sun Apr 03 00:29:02 2011 +0200
     1.3 @@ -4,7 +4,27 @@
     1.4        
     1.5  action()
     1.6  {
     1.7 -	[ "$1" == "list" -o "$1" == "config" ] || return 1
     1.8 +	case "$1" in
     1.9 +	list|config);;
    1.10 +	backup)	if [ -n "$(POST save)" ]; then
    1.11 +			file=$(mktemp -p /tmp)
    1.12 +			find */ | cpio -o -H newc | gzip -9 > $file
    1.13 +			cat <<EOT
    1.14 +Content-Type: application/octet-stream
    1.15 +Content-Length: $(stat -c %s $file)
    1.16 +Content-Disposition: attachment; filename=wiki-$(date '+%Y%m%d%H%M').cpio.gz
    1.17 +
    1.18 +EOT
    1.19 +			cat $file
    1.20 +		elif [ -n "$(POST restore)" ]; then
    1.21 +			file=$(FILE file tmpname)
    1.22 +			zcat $file | cpio -idmu
    1.23 +		fi
    1.24 +		rm -f $file
    1.25 +		exit 0
    1.26 +		;;
    1.27 +	*) return 1
    1.28 +	esac
    1.29  	CONTENT='
    1.30  <table width="100%">
    1.31  <tr><td span=2><h2>Plugins</h2></td></tr>
    1.32 @@ -40,10 +60,12 @@
    1.33  	done
    1.34  	CONTENT="$CONTENT
    1.35  <tr><td><br /><h2>Data</h2></td>
    1.36 -<td><form method=\"get\" action=\"?action=saveconf\">
    1.37 -<input disabled type=\"submit\" name=\"save\" value=\"save\" />
    1.38 -<input disabled type=\"file\" name=\"file\" value=\"file\" />
    1.39 -<input disabled type=\"submit\" name=\"restore\" value=\"restore\" />
    1.40 +<td><form method=\"post\" action=\"?action=backup\">
    1.41 +<input type=\"submit\" name=\"save\" value=\"save\" />"
    1.42 +	[ "$ALLOW_UPLOAD" == "yes" ] && CONTENT="$CONTENT
    1.43 +<input type=\"file\" name=\"file\" value=\"file\" />
    1.44 +<input type=\"submit\" name=\"restore\" value=\"restore\" />"
    1.45 +	CONTENT="$CONTENT
    1.46  </form></td></tr>
    1.47  $(du -hs */ | awk '{ printf "<tr><td><b>%s</b></td><td><i>%s</i></td></tr>\n",$1,$2 }')
    1.48  </table>