diff options
author | Ugnich Anton | 2014-03-08 16:26:50 +0700 |
---|---|---|
committer | Ugnich Anton | 2014-03-08 16:26:50 +0700 |
commit | 88f3693c53e70ad064ccc1466ddf27cae98db49a (patch) | |
tree | fbc0aa93af928137ae822017c6998519767b8cfa /src/java/com/juick/http/www/SignUp.java | |
parent | a573191fa752c0d9155f1c9f0d8a89f044c7af7a (diff) |
iPod contest
Diffstat (limited to 'src/java/com/juick/http/www/SignUp.java')
-rw-r--r-- | src/java/com/juick/http/www/SignUp.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/java/com/juick/http/www/SignUp.java b/src/java/com/juick/http/www/SignUp.java index 2fbe2e2d..cf6679ce 100644 --- a/src/java/com/juick/http/www/SignUp.java +++ b/src/java/com/juick/http/www/SignUp.java @@ -172,6 +172,19 @@ public class SignUp { return; } + int ref = 0; + String sRef = Utils.getCookie(request, "ref"); + if (sRef != null) { + try { + ref = Integer.parseInt(sRef); + } catch (Exception e) { + } + } + + if (ref > 0) { + setUserRef(sql, uid, ref); + } + visitor = null; } @@ -185,6 +198,23 @@ public class SignUp { response.sendRedirect("/"); } + private boolean setUserRef(Connection sql, int uid, int ref) { + boolean ret = false; + PreparedStatement stmt = null; + try { + stmt = sql.prepareStatement("INSERT INTO users_refs(user_id,ref) VALUES (?,?)"); + stmt.setInt(1, uid); + stmt.setInt(2, ref); + stmt.executeUpdate(); + ret = true; + } catch (SQLException e) { + System.err.println(e); + } finally { + Utils.finishSQL(null, stmt); + } + return ret; + } + private String getFacebookNameByHash(Connection sql, String hash) { String ret = null; |