diff --git a/htroot/User.html b/htroot/User.html index 8b73f6030..f3b5f6c2d 100644 --- a/htroot/User.html +++ b/htroot/User.html @@ -17,7 +17,9 @@ You are currently logged in as #[username]#.
#(limit)#:: -You have used #[timeused]# minutes of your onlinetime limit of #[timelimit]# minutes per day.
+#{percent}##{/percent}##{percent2}##{/percent2}# +
+You have used #[timeused]# minutes of your onlinetime limit of #[timelimit]# minutes per day.
#(/limit)#
@@ -38,6 +40,11 @@ You have used #[timeused]# minutes of your onlinetime limit of #[timel

+:: +You are currently logged in as admin.
+
+ + #(/logged-in)# #(status)# :: diff --git a/htroot/User.java b/htroot/User.java index b48046c1f..555d0d317 100644 --- a/htroot/User.java +++ b/htroot/User.java @@ -79,11 +79,20 @@ public class User{ if(entry != null){ prop.put("logged-in", 1); prop.put("logged-in_username", entry.getUserName()); - if(entry.getTimeLimit().intValue() > 0){ + if(entry.getTimeLimit() > 0){ prop.put("logged-in_limit", 1); - prop.put("logged-in_limit_timelimit", entry.getTimeLimit()); - prop.put("logged-in_limit_timeused", entry.getTimeUsed()); + long limit=entry.getTimeLimit(); + long used=entry.getTimeUsed(); + prop.put("logged-in_limit_timelimit", limit); + prop.put("logged-in_limit_timeused", used); + int percent=0; + if(limit!=0 && used != 0) + percent=(int)((float)used/(float)limit*100); + prop.put("logged-in_limit_percent", percent/3); + prop.put("logged-in_limit_percent2", (100-percent)/3); } + }else if(sb.verifyAuthentication(header, true)){ + prop.put("logged-in", 2); } if(post!= null && entry != null){ if(post.containsKey("logout")){ @@ -108,6 +117,11 @@ public class User{ prop.put("status_password", 1); //old pw wrong } } + }else if(post!=null && post.containsKey("logout")){ + prop.put("logged-in",0); + if(sb.verifyAuthentication(header, true)){ + prop.put("AUTHENTICATE","admin log-in"); + } } // return rewrite properties return prop; diff --git a/htroot/env/grafics/green-bar.png b/htroot/env/grafics/green-bar.png new file mode 100644 index 000000000..a5d796166 Binary files /dev/null and b/htroot/env/grafics/green-bar.png differ diff --git a/htroot/env/grafics/red-bar.png b/htroot/env/grafics/red-bar.png new file mode 100644 index 000000000..d97e616b9 Binary files /dev/null and b/htroot/env/grafics/red-bar.png differ diff --git a/source/de/anomic/data/userDB.java b/source/de/anomic/data/userDB.java index 35187db10..f885bd9bc 100644 --- a/source/de/anomic/data/userDB.java +++ b/source/de/anomic/data/userDB.java @@ -316,18 +316,22 @@ public final class userDB { } try { this.setProperty(TIME_USED,"0"); - } catch (IOException e) { - e.printStackTrace(); - } + } catch (IOException e) {} return 0; } - public Long getTimeLimit() { - try{ - return (this.mem.containsKey(TIME_LIMIT)?Long.valueOf((String)this.mem.get(TIME_LIMIT)):null); - }catch(NumberFormatException e){ - return new Long(0); + public long getTimeLimit() { + if (this.mem.containsKey(TIME_LIMIT)) { + try{ + return Long.valueOf((String)this.mem.get(TIME_LIMIT)).longValue(); + }catch(NumberFormatException e){ + return 0; + } } + try { + this.setProperty(TIME_LIMIT,"0"); + } catch (IOException e) {} + return 0; } public long getTrafficSize() { @@ -370,9 +374,9 @@ public final class userDB { if(this.hasProxyRight() == false) return false; - return ( this.getTimeLimit() == null || - this.getTimeLimit().longValue() <= 0 || - ( timeUsed < this.getTimeLimit().longValue()) + return ( this.getTimeLimit() == 0 || + this.getTimeLimit() <= 0 || + ( timeUsed < this.getTimeLimit() ) ); //no timelimit or timelimit not reached }