tinycm annotate 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
rev   line source
pankso@75 1 #!/bin/sh
pankso@75 2 #
pankso@75 3 # TinyCM/TazBug Plugin - Users profile and admin
pankso@75 4 #
pankso@75 5
pankso@75 6 case " $(GET) " in
pankso@75 7 *\ users\ *)
pankso@75 8 d="Users"
pankso@75 9 header
pankso@75 10 html_header
pankso@75 11 user_box
pankso@75 12 if check_auth && ! admin_user; then
pankso@75 13 gettext "You must be admin to manage users"
pankso@75 14 exit 0
pankso@75 15 fi
pankso@75 16 users=$(ls -1 $PEOPLE | wc -l)
pankso@75 17 cat << EOT
pankso@75 18 <h2>Users: $users</h2>
pankso@75 19 <div id="tools">
pankso@75 20 <a href="$script?dashboard">Dashboard</a>
pankso@75 21 <a href='?logged'>Logged users</a>
pankso@75 22 </div>
pankso@75 23 <pre>
pankso@75 24 EOT
pankso@75 25 for u in $(ls $PEOPLE)
pankso@75 26 do
pankso@75 27 # Skip corrupted accounts
pankso@75 28 if ! [ -f "${PEOPLE}/${u}/account.conf" ]; then
pankso@75 29 echo "${u} : Missing account.conf"
pankso@75 30 continue
pankso@75 31 fi
pankso@75 32 . "${PEOPLE}/${u}/account.conf"
pankso@75 33 cat << EOT
pankso@75 34 $(get_gravatar $MAIL 24) <a href="?user=$USER">$USER</a> | $NAME | $MAIL
pankso@75 35 EOT
pankso@75 36 # deluser link
pankso@75 37 #: <a href="?users&amp;deluser=$USER">$(gettext "delete")</a>
pankso@75 38 unset NAME USER
pankso@75 39 done
pankso@75 40 echo "</pre>"
pankso@75 41 html_footer && exit 0 ;;
pankso@75 42
pankso@75 43 *\ logged\ *)
pankso@75 44 # Show online users based on sessions files.
pankso@75 45 d="Logged users"
pankso@75 46 header
pankso@75 47 html_header
pankso@75 48 user_box
pankso@75 49 if ! check_auth; then
pankso@75 50 gettext "You must be logged in to view online users"
pankso@75 51 exit 0
pankso@75 52 fi
pankso@75 53 cat << EOT
pankso@75 54 <h2>Logged users</h2>
pankso@75 55 <div id="tools">
pankso@75 56 <a href="$script?dashboard">Dashboard</a>
pankso@75 57 </div>
pankso@75 58 <pre>
pankso@75 59 EOT
pankso@75 60 for u in $(ls $sessions)
pankso@75 61 do
pankso@75 62 . "${PEOPLE}/${u}/account.conf"
pankso@75 63 cat << EOT
pankso@75 64 $(get_gravatar $MAIL 24) <a href="?user=$USER">$USER</a> | $NAME
pankso@75 65 EOT
pankso@75 66 done
pankso@75 67 echo "</pre>"
pankso@75 68 html_footer && exit 0 ;;
pankso@75 69 esac