slitaz-dev-tools rev 121

tazwikiss/wkp_Admin: add pages section
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Jun 19 16:09:09 2011 +0200 (2011-06-19)
parents 3d9bc6051576
children eafccab82109
files tazwikiss/rootfs/var/www/wiki/pages/Aide.txt tazwikiss/rootfs/var/www/wiki/pages/Welcome.txt tazwikiss/rootfs/var/www/wiki/plugins/wkp_Admin.sh
line diff
     1.1 --- a/tazwikiss/rootfs/var/www/wiki/plugins/wkp_Admin.sh	Sun Jun 19 14:03:36 2011 +0200
     1.2 +++ b/tazwikiss/rootfs/var/www/wiki/plugins/wkp_Admin.sh	Sun Jun 19 16:09:09 2011 +0200
     1.3 @@ -5,9 +5,9 @@
     1.4  admin_enable()
     1.5  {
     1.6  	[ -n "$(POST $1)" ] || return
     1.7 -	chmod 0 $4$2*
     1.8 +	chmod 444 $4/$2*
     1.9  	for i in $(POST); do
    1.10 -		case "$i" in $3*) chmod 755 $4${i/$3/$2}* ;; esac
    1.11 +		case "$i" in $3*) chmod 755 $4/${i/$3/$2}.* ;; esac
    1.12  	done
    1.13  }
    1.14  
    1.15 @@ -43,72 +43,85 @@
    1.16  	editable=false
    1.17  	lang="${HTTP_ACCEPT_LANGUAGE%%,*}"
    1.18  	PAGE_TITLE="Administration"
    1.19 -	curpassword="$(POST curpassword)"
    1.20 +	curpass="$(POST curpass)"
    1.21  	secret="admin.secret"
    1.22 -	if [ -n "$(POST setpassword)" ]; then
    1.23 -		if [ -z "$curpassword" ]; then	# unauthorized
    1.24 +	if [ -n "$(POST setpass)" ]; then
    1.25 +		if [ -z "$curpass" ]; then	# unauthorized
    1.26  			if [ ! -s $secret -o "$(cat $secret)" == \
    1.27  				  "$(echo $(POST password) | md5sum)" ]; then
    1.28 -				curpassword="$(POST password)"
    1.29 +				curpass="$(POST password)"
    1.30  			fi
    1.31  		fi
    1.32 -		[ -n "$curpassword" ] && echo $curpassword | md5sum > $secret
    1.33 +		[ -n "$curpass" ] && echo $curpass | md5sum > $secret
    1.34  	fi
    1.35  	if [ -n "$(POST save)" ]; then
    1.36  		admin_download $(POST file)
    1.37  		exit 0
    1.38  	fi
    1.39  	[ -n "$(POST restore)" ] && mv -f $(FILE data tmpname) $(POST file)
    1.40 -	admin_enable locales config- config_ ./
    1.41 -	admin_enable plugins wkp_ wkp_ plugins/
    1.42 +	admin_enable Locales config- config_ .
    1.43 +	admin_enable Plugins wkp_ wkp_ plugins
    1.44 +	admin_enable Pages '' page pages
    1.45  	disabled="disabled=disabled"
    1.46 -	[ -n "$curpassword" ] && disabled="" && 
    1.47 -	curpassword="<input type=\"hidden\" name=\"curpassword\" value=\"$curpassword\" />
    1.48 +	[ -n "$curpass" ] && disabled="" && 
    1.49 +	curpass="<input type=\"hidden\" name=\"curpass\" value=\"$curpass\" />
    1.50  "
    1.51 -	hr="$curpassword<tr><td colspan=2><hr /></td><tr />"
    1.52 +	hr="$curpass<tr><td colspan=2><hr /></td><tr />"
    1.53  	CONTENT="
    1.54  <table width=\"100%\">
    1.55  <form method=\"post\" action=\"?action=admin\">
    1.56  <tr><td><h2>$MDP</h2></td>
    1.57 -<td><input type=\"text\" name=\"password\" />$curpassword
    1.58 -<input type=\"submit\" value=\"$DONE_BUTTON\" name=\"setpassword\" /></td></tr>
    1.59 +<td><input type=\"text\" name=\"password\" />$curpass
    1.60 +<input type=\"submit\" value=\"$DONE_BUTTON\" name=\"setpass\" /></td></tr>
    1.61  </form>
    1.62 -<form method=\"post\" enctype=\"multipart/form-data\" action=\"?action=admin\">
    1.63 +"
    1.64 +	mform="form method=\"post\" enctype=\"multipart/form-data\" action=\"?action"
    1.65 +	while read section files test; do
    1.66 +		CONTENT="$CONTENT
    1.67 +<$mform=admin\">
    1.68  $hr
    1.69 -<tr><td><h2>Plugins</h2></td>
    1.70 -<td><input type=\"submit\" $disabled value=\"$DONE_BUTTON\" name=\"plugins\" /></td></tr>
    1.71 +<tr><td><h2>$section</h2></td>
    1.72 +<td><input type=\"submit\" $disabled value=\"$DONE_BUTTON\" name=\"$section\" /></td></tr>
    1.73  "
    1.74 -	for i in $plugins_dir/*.sh ; do
    1.75 -		plugin=
    1.76 -		eval $(grep ^plugin= $i)
    1.77 -		[ -n "$plugin" ] || continue
    1.78 -		eval $(grep ^description= $i)
    1.79 -		alt="$(grep ^description_$lang= $i)"
    1.80 -		[ -n "$alt" ] && eval $(echo "$alt" | sed 's/_..=/=/')
    1.81 -		CONTENT="$CONTENT
    1.82 +		for i in $files ; do
    1.83 +			case "$section" in
    1.84 +			Plugins)
    1.85 +				plugin=
    1.86 +				eval $(grep ^plugin= $i)
    1.87 +				[ -n "$plugin" ] || continue
    1.88 +				eval $(grep ^description= $i)
    1.89 +				alt="$(grep ^description_$lang= $i)"
    1.90 +				[ -n "$alt" ] && eval $(echo "$alt" | sed 's/_..=/=/')
    1.91 +				name="$(basename $i .sh)"
    1.92 +				;;
    1.93 +			Locales)
    1.94 +				j=${i#config-}
    1.95 +				j=${j%.sh}
    1.96 +				[ -n "$j" ] || continue
    1.97 +				name="config_$j"
    1.98 +				plugin="$j"
    1.99 +				description="$(. ./$i ; echo $WIKI_TITLE)"
   1.100 +				;;
   1.101 +			Pages)
   1.102 +				j="$(basename $i .txt)"
   1.103 +				plugin="<a href=\"?page=$j\">$j</a>"
   1.104 +				name="page$j"
   1.105 +				description="$([ -w $i ] || echo -n $PROTECTED_BUTTON)"
   1.106 +				;;
   1.107 +			esac
   1.108 +			CONTENT="$CONTENT
   1.109  <tr><td><b>
   1.110 -<input type=checkbox $disabled $([ -x $i ] && echo 'checked=checked ') name=\"$(basename $i .sh)\" />
   1.111 +<input type=checkbox $disabled $([ $test $i ] && echo 'checked=checked ') name=\"$name\" />
   1.112  $plugin</b></td><td><i>$description</i></td></tr>"
   1.113 -	done
   1.114 +		done
   1.115 +		CONTENT="$CONTENT\n</form>\n"
   1.116 +	done <<EOT
   1.117 +Plugins	$plugins_dir/*.sh	-x
   1.118 +Locales	config-*.sh		-x
   1.119 +Pages	pages/*.txt		-w
   1.120 +EOT
   1.121  	CONTENT="$CONTENT
   1.122 -</form>
   1.123 -<form method=\"post\" enctype=\"multipart/form-data\" action=\"?action=admin\">
   1.124 -$hr
   1.125 -<tr><td><h2>Locales</h2></td>
   1.126 -<td><input type=\"submit\" $disabled value=\"$DONE_BUTTON\" name=\"locales\" /></td></tr>
   1.127 -"
   1.128 -	for i in config-*.sh ; do
   1.129 -		j=${i#config-}
   1.130 -		j=${j%.sh}
   1.131 -		[ -n "$j" ] && CONTENT="$CONTENT
   1.132 -<tr><td><b>
   1.133 -<input type=checkbox $disabled $([ -x $i ] && echo 'checked=checked ') name=\"config_$j\" />
   1.134 -$j</b></td><td><i>$(. ./$i ; echo $WIKI_TITLE)</i></td></tr>
   1.135 -"
   1.136 -	done
   1.137 -	CONTENT="$CONTENT
   1.138 -</form>
   1.139 -<form method=\"post\" enctype=\"multipart/form-data\" action=\"?action=admin\">
   1.140 +<$mform=admin\">
   1.141  $hr
   1.142  <tr><td><h2>Configuration</h2></td>
   1.143  <td><select name="file" $disabled>
   1.144 @@ -119,7 +132,7 @@
   1.145  <input type=\"file\" $disabled name=\"data\" />
   1.146  <input type=\"submit\" $disabled value=\"$RESTORE\" name=\"restore\" /></td></tr>
   1.147  </form>
   1.148 -<form method=\"post\" enctype=\"multipart/form-data\" action=\"?action=backup\">
   1.149 +<$mform=backup\">
   1.150  $hr
   1.151  <tr><td><h2>Data</h2></td>
   1.152  <td><input type=\"submit\" $disabled name=\"save\" value=\"$DONE_BUTTON\" />