From 881bc336c1cef93d08cd1f14e37f3a3feeb07e58 Mon Sep 17 00:00:00 2001 From: Ugnich Anton Date: Thu, 3 Jan 2013 17:24:54 +0700 Subject: many bugfixes message number js autoselection privacy fix --- src/java/com/juick/http/www/Blogs.java | 11 +-- src/java/com/juick/http/www/Help.java | 2 +- src/java/com/juick/http/www/Login.java | 4 +- src/java/com/juick/http/www/NewMessage.java | 2 +- src/java/com/juick/http/www/PageTemplates.java | 110 +++++++++++-------------- src/java/com/juick/http/www/User.java | 10 +-- src/java/com/juick/http/www/UserThread.java | 6 +- 7 files changed, 65 insertions(+), 80 deletions(-) (limited to 'src') diff --git a/src/java/com/juick/http/www/Blogs.java b/src/java/com/juick/http/www/Blogs.java index 44c734d2..4af75cd3 100644 --- a/src/java/com/juick/http/www/Blogs.java +++ b/src/java/com/juick/http/www/Blogs.java @@ -92,11 +92,12 @@ public class Blogs { } com.juick.Place place = null; + int visitor_uid = visitor != null ? visitor.UID : 0; if (paramShow == null) { if (paramTag > 0) { title = "*" + Utils.encodeHTML(paramTagStr); - mids = MessagesQueries.getTag(sql, paramTag, paramBefore); + mids = MessagesQueries.getTag(sql, paramTag, visitor_uid, paramBefore); } else if (paramSearch != null) { title = rb.getString("Search") + ": " + Utils.encodeHTML(paramSearch); mids = MessagesQueries.getSearch(sql, sqlSearch, Utils.encodeSphinx(paramSearch), paramBefore); @@ -109,14 +110,14 @@ public class Blogs { place = com.juick.server.PlacesQueries.getPlace(sql, place_id); if (place != null) { title = place.name; - mids = MessagesQueries.getPlace(sql, place_id, paramBefore); + mids = MessagesQueries.getPlace(sql, place_id, visitor_uid, paramBefore); } else { response.sendError(404); return; } } else { title = rb.getString("Last messages"); - mids = MessagesQueries.getAll(sql, paramBefore); + mids = MessagesQueries.getAll(sql, visitor_uid, paramBefore); } } else if (paramShow.equals("my")) { if (visitor != null) { @@ -155,7 +156,7 @@ public class Blogs { mids = MessagesQueries.getPopular(sql, paramBefore); } else if (paramShow.equals("photos")) { title = rb.getString("With photos"); - mids = MessagesQueries.getPhotos(sql, paramBefore); + mids = MessagesQueries.getPhotos(sql, visitor_uid, paramBefore); } else { response.sendError(404); return; @@ -222,7 +223,7 @@ public class Blogs { out.println(""); // topwrapper PageTemplates.pageDialogTemplate(out, locale); - PageTemplates.pageFooter(request, out, locale, visitor); + PageTemplates.pageFooter(request, out, locale, visitor, true); } finally { out.close(); } diff --git a/src/java/com/juick/http/www/Help.java b/src/java/com/juick/http/www/Help.java index e780e196..3dfe1f80 100644 --- a/src/java/com/juick/http/www/Help.java +++ b/src/java/com/juick/http/www/Help.java @@ -92,7 +92,7 @@ public class Help { out.println(""); - PageTemplates.pageFooter(request, out, locale, visitor); + PageTemplates.pageFooter(request, out, locale, visitor, false); } finally { out.close(); } diff --git a/src/java/com/juick/http/www/Login.java b/src/java/com/juick/http/www/Login.java index 326206da..e2585909 100644 --- a/src/java/com/juick/http/www/Login.java +++ b/src/java/com/juick/http/www/Login.java @@ -46,6 +46,7 @@ public class Login { PageTemplates.pageHead(out, rb.getString("Login"), ""); PageTemplates.pageNavigation(out, locale, visitor, null); + out.println("
"); out.println("
"); out.println("
"); out.println("
"); @@ -55,8 +56,9 @@ public class Login { out.println("
"); out.println("
"); out.println("
"); + out.println("
"); // topwrapper - PageTemplates.pageFooter(request, out, locale, visitor); + PageTemplates.pageFooter(request, out, locale, visitor, false); } finally { out.close(); } diff --git a/src/java/com/juick/http/www/NewMessage.java b/src/java/com/juick/http/www/NewMessage.java index b66b87d1..369e9de3 100644 --- a/src/java/com/juick/http/www/NewMessage.java +++ b/src/java/com/juick/http/www/NewMessage.java @@ -76,7 +76,7 @@ public class NewMessage { out.println(""); out.println(""); - PageTemplates.pageFooter(request, out, locale, visitor); + PageTemplates.pageFooter(request, out, locale, visitor, false); } finally { out.close(); } diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java index 67f036fc..080752d1 100644 --- a/src/java/com/juick/http/www/PageTemplates.java +++ b/src/java/com/juick/http/www/PageTemplates.java @@ -23,9 +23,6 @@ import java.io.PrintWriter; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -55,11 +52,11 @@ public class PageTemplates { out.println(""); out.println(""); out.println(" " + title + ""); - out.println(" "); + out.println(" "); out.println(" "); out.println(" "); out.println(" "); - out.println(" "); + out.println(" "); if (headers != null) { out.println(headers); } @@ -85,69 +82,54 @@ public class PageTemplates { out.println("
  • \""
  • "); out.println("
  • "); } else { - out.println("
  • " + rb.getString("Login") + "
  • "); + out.println("
  • " + rb.getString("Login") + "
  • "); } out.println(""); out.println(""); } /* - public static void pageFilters(PrintWriter out, Locale loc, com.juick.User user) { - ResourceBundle rb = ResourceBundle.getBundle("Global", loc); + public static void pageUserTitle(PrintWriter out, Connection sql, Locale loc, com.juick.User user, com.juick.User visitor) { + ResourceBundle rb = ResourceBundle.getBundle("User", loc); - out.println("
    "); - out.println(""); + // Full name and description + String fullname = null; + String description = null; + PreparedStatement stmt = null; + ResultSet rs = null; + try { + stmt = sql.prepareStatement("SELECT fullname,descr FROM usersinfo WHERE user_id=?"); + stmt.setInt(1, user.UID); + rs = stmt.executeQuery(); + if (rs.first()) { + fullname = rs.getString(1) + " (" + user.UName + ")"; + description = rs.getString(2); + } + } catch (SQLException e) { + System.err.println(e); + } finally { + Utils.finishSQL(rs, stmt); + } + if (fullname == null) { + fullname = user.UName; + } + if (description == null) { + description = ""; + } + + out.println("
    "); + out.println("
    \""
    "); + out.println("
    "); + out.println("

    " + fullname + "

    " + description + "

    "); out.println("
    "); + out.println(); } */ - public static void pageUserTitle(PrintWriter out, Connection sql, Locale loc, com.juick.User user, com.juick.User visitor) { - ResourceBundle rb = ResourceBundle.getBundle("User", loc); - - // Full name and description - String fullname = null; - String description = null; - PreparedStatement stmt = null; - ResultSet rs = null; - try { - stmt = sql.prepareStatement("SELECT fullname,descr FROM usersinfo WHERE user_id=?"); - stmt.setInt(1, user.UID); - rs = stmt.executeQuery(); - if (rs.first()) { - fullname = rs.getString(1) + " (" + user.UName + ")"; - description = rs.getString(2); - } - } catch (SQLException e) { - System.err.println(e); - } finally { - Utils.finishSQL(rs, stmt); - } - if (fullname == null) { - fullname = user.UName; - } - if (description == null) { - description = ""; - } - - out.println("
    "); - out.println("
    \""
    "); - out.println("
    "); - out.println("

    " + fullname + "

    " + description + "

    "); - out.println("
    "); - out.println(); - } - public static void pageYandexAd(PrintWriter out, int stat_id) { out.println("
    "); out.println("