From 34da94d887ae7be134d17c4bc9e101a8c198b300 Mon Sep 17 00:00:00 2001 From: Ugnich Anton Date: Mon, 20 Feb 2012 21:38:29 +0700 Subject: Bugfixes --- src/java/com/juick/http/www/Blogs.java | 36 ++++++++++++++++++------ src/java/com/juick/http/www/Login.java | 4 +-- src/java/com/juick/http/www/Main.java | 2 +- src/java/com/juick/http/www/NewMessage.java | 12 ++++++-- src/java/com/juick/http/www/PageTemplates.java | 13 ++++++--- src/java/com/juick/http/www/UserThread.java | 38 ++++++++++++++++++++------ 6 files changed, 79 insertions(+), 26 deletions(-) (limited to 'src/java/com/juick') diff --git a/src/java/com/juick/http/www/Blogs.java b/src/java/com/juick/http/www/Blogs.java index 1e212b7a..a1cfdeb0 100644 --- a/src/java/com/juick/http/www/Blogs.java +++ b/src/java/com/juick/http/www/Blogs.java @@ -83,17 +83,37 @@ public class Blogs { mids = MessagesQueries.getAll(sql, paramBefore); } } else if (paramShow.equals("my")) { - title = rb.getString("My feed"); - mids = MessagesQueries.getMyFeed(sql, visitor.UID, paramBefore); + if (visitor != null) { + title = rb.getString("My feed"); + mids = MessagesQueries.getMyFeed(sql, visitor.UID, paramBefore); + } else { + response.sendError(404); + return; + } } else if (paramShow.equals("private")) { - title = rb.getString("Private"); - mids = MessagesQueries.getPrivate(sql, visitor.UID, paramBefore); + if (visitor != null) { + title = rb.getString("Private"); + mids = MessagesQueries.getPrivate(sql, visitor.UID, paramBefore); + } else { + response.sendError(404); + return; + } } else if (paramShow.equals("incoming")) { - title = rb.getString("Incoming"); - mids = MessagesQueries.getIncoming(sql, visitor.UID, paramBefore); + if (visitor != null) { + title = rb.getString("Incoming"); + mids = MessagesQueries.getIncoming(sql, visitor.UID, paramBefore); + } else { + response.sendError(404); + return; + } } else if (paramShow.equals("recommended")) { - title = rb.getString("Recommended"); - mids = MessagesQueries.getRecommended(sql, visitor.UID, paramBefore); + if (visitor != null) { + title = rb.getString("Recommended"); + mids = MessagesQueries.getRecommended(sql, visitor.UID, paramBefore); + } else { + response.sendError(404); + return; + } } else if (paramShow.equals("top")) { title = rb.getString("Popular"); mids = MessagesQueries.getPopular(sql, paramBefore); diff --git a/src/java/com/juick/http/www/Login.java b/src/java/com/juick/http/www/Login.java index 1baf6e43..0006f9d0 100644 --- a/src/java/com/juick/http/www/Login.java +++ b/src/java/com/juick/http/www/Login.java @@ -73,7 +73,7 @@ public class Login { if (com.juick.server.UserQueries.getUIDbyHash(sql, hash) > 0) { Cookie c = new Cookie("hash", hash); c.setDomain(".juick.com"); - c.setMaxAge(0); + c.setMaxAge(365 * 24 * 60 * 60); response.addCookie(c); response.sendRedirect("/"); @@ -95,7 +95,7 @@ public class Login { String hash = com.juick.server.UserQueries.getHashByUID(sql, uid); Cookie c = new Cookie("hash", hash); c.setDomain(".juick.com"); - c.setMaxAge(0); + c.setMaxAge(365 * 24 * 60 * 60); response.addCookie(c); String referer = request.getHeader("Referer"); diff --git a/src/java/com/juick/http/www/Main.java b/src/java/com/juick/http/www/Main.java index b7f95a4a..910a554f 100644 --- a/src/java/com/juick/http/www/Main.java +++ b/src/java/com/juick/http/www/Main.java @@ -149,7 +149,7 @@ public class Main extends HttpServlet implements XmppListener { //TODO settings } else if (uri.matches("^/\\d+$")) { rootRedirects.doGetPostID(sql, request, response); - } else if (uri.matches("^/[^/]$")) { + } else if (uri.matches("^/[^/]+$")) { rootRedirects.doGetUsername(sql, request, response); } else if (uri.matches("^/.+/.*")) { String uriparts[] = uri.split("/"); diff --git a/src/java/com/juick/http/www/NewMessage.java b/src/java/com/juick/http/www/NewMessage.java index 1beacf62..d35af8f3 100644 --- a/src/java/com/juick/http/www/NewMessage.java +++ b/src/java/com/juick/http/www/NewMessage.java @@ -54,10 +54,18 @@ public class NewMessage { out.println("