reset Timelimits on Daychange

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@904 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
allo 19 years ago
parent 54a97a7355
commit f1ff33177d

@ -51,6 +51,8 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Date;
import java.util.Calendar;
import de.anomic.kelondro.kelondroDyn; import de.anomic.kelondro.kelondroDyn;
import de.anomic.kelondro.kelondroException; import de.anomic.kelondro.kelondroException;
@ -160,6 +162,7 @@ public final class userDB {
// this is a simple record structure that hold all properties of a user // this is a simple record structure that hold all properties of a user
private Map mem; private Map mem;
private String userName; private String userName;
private Calendar oldDate, newDate;
public Entry(String userName, Map mem) { public Entry(String userName, Map mem) {
if ((userName == null) || (userName.length() == 0)) if ((userName == null) || (userName.length() == 0))
@ -173,6 +176,8 @@ public final class userDB {
else this.mem = mem; else this.mem = mem;
if (!mem.containsKey(AUTHENTICATION_METHOD))this.mem.put(AUTHENTICATION_METHOD,"yacy"); if (!mem.containsKey(AUTHENTICATION_METHOD))this.mem.put(AUTHENTICATION_METHOD,"yacy");
this.oldDate=Calendar.getInstance();
this.newDate=Calendar.getInstance();
} }
public String getUserName() { public String getUserName() {
@ -259,6 +264,24 @@ public final class userDB {
if (incrementTimeUsed) { if (incrementTimeUsed) {
if ((lastAccess == null)||((lastAccess != null)&&(timeStamp-lastAccess.longValue()>=1000*60))) { if ((lastAccess == null)||((lastAccess != null)&&(timeStamp-lastAccess.longValue()>=1000*60))) {
this.mem.put(TIME_USED,Long.toString(newTimeUsed = ++oldTimeUsed)); this.mem.put(TIME_USED,Long.toString(newTimeUsed = ++oldTimeUsed));
if(lastAccess != null){
this.oldDate.setTime(new Date(lastAccess.longValue()));
this.newDate.setTime(new Date(System.currentTimeMillis()));
if(
this.oldDate.get(Calendar.DAY_OF_MONTH) != this.newDate.get(Calendar.DAY_OF_MONTH) ||
this.oldDate.get(Calendar.MONTH) != this.newDate.get(Calendar.MONTH) ||
this.oldDate.get(Calendar.YEAR) != this.newDate.get(Calendar.YEAR)
){ //new Day, reset time
newTimeUsed=0;
System.out.println("foo");
}else{
System.out.println("baz");
}
}else{ //no access so far
newTimeUsed=0;
System.out.println("bar");
}
this.mem.put(TIME_USED,Long.toString(newTimeUsed));
this.mem.put(LAST_ACCESS,Long.toString(timeStamp)); //update Timestamp this.mem.put(LAST_ACCESS,Long.toString(timeStamp)); //update Timestamp
} }
}else{ }else{

@ -322,7 +322,6 @@ public final class httpd implements serverHandler {
if(tmp.length == 2){ if(tmp.length == 2){
userDB.Entry entry=switchboard.userDB.getEntry(tmp[0]); userDB.Entry entry=switchboard.userDB.getEntry(tmp[0]);
if( entry != null && entry.getMD5EncodedUserPwd().equals(serverCodings.encodeMD5Hex(auth)) ){ if( entry != null && entry.getMD5EncodedUserPwd().equals(serverCodings.encodeMD5Hex(auth)) ){
//TODO: Check Timelimits
if(entry.canSurf()){ if(entry.canSurf()){
return true; return true;
} else { } else {

Loading…
Cancel
Save