aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/juick/http/www/SignUp.java
diff options
context:
space:
mode:
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;