aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/juick/http/www/SignUp.java
diff options
context:
space:
mode:
authorGravatar Ugnich Anton2014-03-08 16:26:50 +0700
committerGravatar Ugnich Anton2014-03-08 16:26:50 +0700
commit88f3693c53e70ad064ccc1466ddf27cae98db49a (patch)
treefbc0aa93af928137ae822017c6998519767b8cfa /src/java/com/juick/http/www/SignUp.java
parenta573191fa752c0d9155f1c9f0d8a89f044c7af7a (diff)
iPod contest
Diffstat (limited to 'src/java/com/juick/http/www/SignUp.java')
-rw-r--r--src/java/com/juick/http/www/SignUp.java30
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;