tazbug rev 63
Add online users in dashboard and misc changes
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Tue Jan 07 22:22:25 2014 +0100 (2014-01-07) |
parents | 10f3f4d09e09 |
children | 41de444b2aa3 |
files | web/bugs.cgi web/plugins/dashboard/dashboard.cgi |
line diff
1.1 --- a/web/bugs.cgi Tue Jan 07 20:53:30 2014 +0100 1.2 +++ b/web/bugs.cgi Tue Jan 07 22:22:25 2014 +0100 1.3 @@ -221,8 +221,6 @@ 1.4 # Display user public profile. 1.5 public_people() { 1.6 cat << EOT 1.7 -<pre> 1.8 -$(eval_gettext 'Real name : $NAME') 1.9 </pre> 1.10 EOT 1.11 } 1.12 @@ -230,10 +228,8 @@ 1.13 # Display authentified user profile. TODO: change password 1.14 auth_people() { 1.15 cat << EOT 1.16 -<pre> 1.17 -$(eval_gettext 'Real name : $NAME') 1.18 -$(eval_gettext 'Email : $MAIL') 1.19 -$(eval_gettext 'Secure key : $KEY') 1.20 +Email : $MAIL 1.21 +Secure key : $KEY 1.22 </pre> 1.23 EOT 1.24 } 1.25 @@ -556,6 +552,8 @@ 1.26 fi 1.27 md5session=$(echo -n "$$:$user:$pass:$$" | md5sum | awk '{print $1}') 1.28 mkdir -p $sessions 1.29 + # Log last login 1.30 + date '+%Y-%m-%d' > ${PEOPLE}/${user}/last 1.31 echo "$md5session" > $sessions/$user 1.32 js_set_cookie 'auth' "$user:$md5session" 1.33 js_log "Login authentification has been executed & accepted :)" 1.34 @@ -638,14 +636,23 @@ 1.35 fi ;; 1.36 *\ user\ *) 1.37 # User profile 1.38 + last="$(cat $PEOPLE/"$(GET user)"/last)" 1.39 header 1.40 html_header 1.41 user_box 1.42 . $PEOPLE/"$(GET user)"/account.conf 1.43 - echo "<h2>$(get_gravatar $MAIL) $(GET user)</h2>" 1.44 + cat << EOT 1.45 +<h2>$(get_gravatar $MAIL) $NAME</h2> 1.46 + 1.47 +<pre> 1.48 +$(gettext "User name :") $USER 1.49 +$(gettext "Last login :") $last 1.50 +EOT 1.51 if check_auth && [ "$(GET user)" == "$user" ]; then 1.52 auth_people 1.53 else 1.54 + # check_auth will set VARS to current logged user: re-source 1.55 + . $PEOPLE/"$(GET user)"/account.conf 1.56 public_people 1.57 fi 1.58 html_footer ;;
2.1 --- a/web/plugins/dashboard/dashboard.cgi Tue Jan 07 20:53:30 2014 +0100 2.2 +++ b/web/plugins/dashboard/dashboard.cgi Tue Jan 07 22:22:25 2014 +0100 2.3 @@ -10,7 +10,7 @@ 2.4 header 2.5 html_header 2.6 user_box 2.7 - if ! admin_user; then 2.8 + if check_auth && ! admin_user; then 2.9 gettext "You must be admin to manage users." 2.10 exit 0 2.11 fi 2.12 @@ -33,6 +33,26 @@ 2.13 unset NAME USER 2.14 done 2.15 echo "</pre>" && exit 0 ;; 2.16 + 2.17 + *\ online\ *) 2.18 + # Show online users based on sessions files. 2.19 + d="Online users" 2.20 + header 2.21 + html_header 2.22 + user_box 2.23 + cat << EOT 2.24 +<h2>Online users</h2> 2.25 +<pre> 2.26 +EOT 2.27 + for u in $(ls $sessions) 2.28 + do 2.29 + . "${PEOPLE}/${u}/account.conf" 2.30 + cat << EOT 2.31 +$(get_gravatar $MAIL 24) <a href="?user=$USER">$USER</a> | $NAME 2.32 +EOT 2.33 + done 2.34 + echo "</pre>" 2.35 + html_footer && exit 0 ;; 2.36 2.37 *\ dashboard\ *) 2.38 d="Dashboard" 2.39 @@ -46,8 +66,9 @@ 2.40 gettext "You must be logged in to view the dashboard." 2.41 exit 0 2.42 fi 2.43 - if admin_user; then 2.44 - admintools="<a href='?users'>Users</a>" 2.45 + if check_auth && admin_user; then 2.46 + # Online users should not be public ? 2.47 + admintools="<a href='?users'>List users</a>" 2.48 fi 2.49 cat << EOT 2.50 <h2>Dashboard</h2> 2.51 @@ -57,6 +78,7 @@ 2.52 Bugsize : $bugsize 2.53 </pre> 2.54 <div id="tools"> 2.55 + <a href='?online'>Online users</a> 2.56 $admintools 2.57 </div> 2.58 <h3>Admin users</h3>