tinycm rev 94

Clean-up keygen plugin
author Christophe Lincoln <pankso@slitaz.org>
date Fri Feb 17 13:39:44 2017 +0100 (2017-02-17)
parents 97dca04ea0fa
children c133447f0d65
files plugins/cloud/cloud.cgi plugins/community/community.cgi plugins/keygen/keygen.cgi
line diff
     1.1 --- a/plugins/cloud/cloud.cgi	Fri Feb 17 13:06:47 2017 +0100
     1.2 +++ b/plugins/cloud/cloud.cgi	Fri Feb 17 13:39:44 2017 +0100
     1.3 @@ -65,7 +65,7 @@
     1.4  EOT
     1.5  		if admin_user; then
     1.6  			cat << EOT
     1.7 -<a href="$script?cloudlog&amp;clean">$(gettext "Clean logfile")</a>"
     1.8 +<a href="$script?cloudlog&amp;clean">$(gettext "Clean logfile")</a>
     1.9  EOT
    1.10  		fi
    1.11  		echo "</div>"
     2.1 --- a/plugins/community/community.cgi	Fri Feb 17 13:06:47 2017 +0100
     2.2 +++ b/plugins/community/community.cgi	Fri Feb 17 13:39:44 2017 +0100
     2.3 @@ -87,28 +87,6 @@
     2.4  		fi
     2.5  		html_footer && exit 0 ;;
     2.6  	
     2.7 -	*\ communityconfig\ *)
     2.8 -		d="Community plugin config"
     2.9 -		header
    2.10 -		html_header
    2.11 -		user_box
    2.12 -		if ! admin_user; then
    2.13 -			header "Location: $script"
    2.14 -		fi
    2.15 -		cat << EOT
    2.16 -<div id="tools">
    2.17 -	<a href="$script?dashboard">Dashboard</a>
    2.18 -	<a href="$script?community">Community Tools</a>
    2.19 -</div>
    2.20 -
    2.21 -<h2>$d</h2>
    2.22 -<pre>
    2.23 -Wall mode        : $WALL_MODE
    2.24 -Messages length  : $WALL_MESSAGES_LENGTH
    2.25 -</pre>
    2.26 -EOT
    2.27 -		html_footer && exit 0 ;;
    2.28 -	
    2.29  	*\ community\ *)
    2.30  		d="Community Tools"
    2.31  		header
    2.32 @@ -118,15 +96,20 @@
    2.33  		if check_auth; then
    2.34  			echo "<a href='$script?dashboard'>Dashboard</a>"
    2.35  		fi
    2.36 -		if admin_user; then
    2.37 -			echo "<a href='$script?communityconfig'>Plugin Config</a>"
    2.38 -		fi
    2.39  		cat << EOT
    2.40  <a href="$script?wall">Community Wall</a>
    2.41  </div>
    2.42  <h2>$d</h2>
    2.43  <p>$SHORT_DESC</p>
    2.44  EOT
    2.45 -		
    2.46 +		if admin_user; then
    2.47 +			cat << EOT
    2.48 +<h3>Plugin config</h3>
    2.49 +<pre>
    2.50 +Wall mode        : $WALL_MODE
    2.51 +Messages length  : $WALL_MESSAGES_LENGTH
    2.52 +</pre>
    2.53 +EOT
    2.54 +		fi
    2.55  		html_footer && exit 0 ;;
    2.56  esac
     3.1 --- a/plugins/keygen/keygen.cgi	Fri Feb 17 13:06:47 2017 +0100
     3.2 +++ b/plugins/keygen/keygen.cgi	Fri Feb 17 13:39:44 2017 +0100
     3.3 @@ -12,13 +12,14 @@
     3.4  		html_header
     3.5  		user_box
     3.6  		cat << EOT
     3.7 -<h2>$(gettext "Key generator")</h2>
     3.8 +<h2>$(gettext "Password &amp; key generator")</h2>
     3.9  
    3.10  <div style="text-align: center; padding: 20px 0;">
    3.11  	<form method="get" action="$script">
    3.12  		<input type="text" name="keygen" 
    3.13  			placeholder="$(gettext "Random or personal string")" />
    3.14  		<div>
    3.15 +			<input type="submit" name="encryption" value="password" />
    3.16  			<input type="submit" name="encryption" value="base64" />
    3.17  			<input type="submit" name="encryption" value="md5sum" />
    3.18  			<input type="submit" name="encryption" value="sha256sum" />
    3.19 @@ -38,31 +39,10 @@
    3.20  			*\ md5sum\ *) echo "$keygen" | md5sum | awk '{print $1}' ;;
    3.21  			*\ sha256sum\ *) echo "$keygen" | sha256sum | awk '{print $1}' ;;
    3.22  			*\ sha512sum\ *) echo "$keygen" | sha512sum | awk '{print $1}' ;;
    3.23 +			*\ password\ *) 
    3.24 +				< /dev/urandom tr -dc '/()?!@#$%+-_A-Z-a-z-0-9' | head -c 10; echo "" ;;
    3.25  			*) echo "--" ;;
    3.26  		esac
    3.27 -		# Random password
    3.28 -		cat << EOT
    3.29 -</pre>
    3.30 -
    3.31 -<h3>$(gettext "Random password")</h3>
    3.32 -
    3.33 -<div>
    3.34 -	<form method="get" action="$script">
    3.35 -		<div>
    3.36 -			<input type="hidden" name="keygen" value="passwd" />
    3.37 -			<input type="submit" name="random" value="$(gettext "generate")" />
    3.38 -		</div>
    3.39 -	</form>
    3.40 -</div>
    3.41 -<pre>
    3.42 -EOT
    3.43 -		
    3.44 -		if [ "$(GET keygen)" == "passwd" ]; then
    3.45 -			< /dev/urandom tr -dc '/()?!@#$%+-_A-Z-a-z-0-9' | head -c 10; echo ""
    3.46 -			#date +%s | sha256sum | base64 | head -c 10 ; echo ""
    3.47 -		else
    3.48 -			echo "--"
    3.49 -		fi
    3.50  		echo "</pre>"
    3.51  		html_footer && exit 0 ;;
    3.52  esac