tinycm diff plugins/users/users.cgi @ rev 75

Small fix to cmdline tool and backport users plugins from tazbug
author Christophe Lincoln <pankso@slitaz.org>
date Fri Feb 10 20:32:34 2017 +0100 (2017-02-10)
parents
children e3cba575c564
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/plugins/users/users.cgi	Fri Feb 10 20:32:34 2017 +0100
     1.3 @@ -0,0 +1,69 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# TinyCM/TazBug Plugin - Users profile and admin
     1.7 +#
     1.8 +
     1.9 +case " $(GET) " in
    1.10 +	*\ users\ *)
    1.11 +		d="Users"
    1.12 +		header
    1.13 +		html_header
    1.14 +		user_box
    1.15 +		if check_auth && ! admin_user; then
    1.16 +			gettext "You must be admin to manage users"
    1.17 +			exit 0
    1.18 +		fi
    1.19 +		users=$(ls -1 $PEOPLE | wc -l)
    1.20 +		cat << EOT
    1.21 +<h2>Users: $users</h2>
    1.22 +<div id="tools">
    1.23 +	<a href="$script?dashboard">Dashboard</a>
    1.24 +	<a href='?logged'>Logged users</a>
    1.25 +</div>
    1.26 +<pre>
    1.27 +EOT
    1.28 +		for u in $(ls $PEOPLE)
    1.29 +		do
    1.30 +			# Skip corrupted accounts
    1.31 +			if ! [ -f "${PEOPLE}/${u}/account.conf" ]; then
    1.32 +				echo "${u} : Missing account.conf"
    1.33 +				continue
    1.34 +			fi
    1.35 +			. "${PEOPLE}/${u}/account.conf"
    1.36 +			cat << EOT
    1.37 +$(get_gravatar $MAIL 24) <a href="?user=$USER">$USER</a> | $NAME | $MAIL
    1.38 +EOT
    1.39 +# deluser link
    1.40 +#: <a href="?users&amp;deluser=$USER">$(gettext "delete")</a>
    1.41 +			unset NAME USER 
    1.42 +		done
    1.43 +		echo "</pre>" 
    1.44 +		html_footer && exit 0 ;;
    1.45 +	
    1.46 +	*\ logged\ *)
    1.47 +		# Show online users based on sessions files.
    1.48 +		d="Logged users"
    1.49 +		header
    1.50 +		html_header
    1.51 +		user_box
    1.52 +		if ! check_auth; then
    1.53 +			gettext "You must be logged in to view online users"
    1.54 +			exit 0
    1.55 +		fi
    1.56 +		cat << EOT
    1.57 +<h2>Logged users</h2>
    1.58 +<div id="tools">
    1.59 +	<a href="$script?dashboard">Dashboard</a>
    1.60 +</div>
    1.61 +<pre>
    1.62 +EOT
    1.63 +		for u in $(ls $sessions)
    1.64 +		do
    1.65 +			. "${PEOPLE}/${u}/account.conf"
    1.66 +			cat << EOT
    1.67 +$(get_gravatar $MAIL 24) <a href="?user=$USER">$USER</a> | $NAME
    1.68 +EOT
    1.69 +		done
    1.70 +		echo "</pre>"
    1.71 +		html_footer && exit 0 ;;
    1.72 +esac