%@ include file="htmlglobal.jsp" %> <%@ page import="java.security.*" %> <%@ page import="sun.misc.BASE64Encoder" %> <% if(!checkLogin(response, session, SID_LOGIN, URL_SIGNUP_LOGIN+"?next="+URL_MY_PROFILE)) return; MSSQLStoredProc sp = null; ResultSet rs = null; String flag = request.getParameter("lwp"); String lwpurl = ""; if("1".equals(flag)) { lwpurl = "?&lwp=1"; } String currentUser = (String)session.getAttribute(SID_LOGIN); int currentUserLevel = -100; SknMemberSimple member = skn_getmemberinfo(currentUser); if (member != null) { currentUserLevel = member.userlevel; } else { response.sendRedirect(URL_INDEX); return; } String fromHost = request.getParameter("fhost"); if(fromHost != null && fromHost.length() > 0) { session.setAttribute(SID_FROM_HOST, fromHost); } String pass1 = ""; String pass2 = ""; String email = ""; String gender = ""; String birthdate = ""; String country = ""; String registertime = ""; String logintime = ""; String alias = ""; String motto = ""; String aboutme = ""; String relation = ""; String occupation = ""; String companies = ""; String schools = ""; String mobileopr = ""; String phonemodel = ""; String zipcode = ""; String hometown = ""; String avatarurl = ""; String ilike = ""; String ihate = ""; String music = ""; String movies = ""; String books = ""; String tvshows = ""; String celebrity = ""; String lastaccess = ""; String profileaccess = ""; String byear = ""; String bmonth = ""; String bday = ""; String content = "0"; int status = -1; int statuscode=-1; if(request.getParameter("profile_submit") != null && (currentUserLevel & 0x4000) == 0) { email = request.getParameter("email"); pass1 = request.getParameter("password1"); pass2 = request.getParameter("password2"); gender = request.getParameter("gender"); country = request.getParameter("country"); bmonth = request.getParameter("birthday_mon"); bday = request.getParameter("birthday_day"); byear = request.getParameter("birthday_year"); alias = request.getParameter("alias"); motto = request.getParameter("motto"); aboutme = request.getParameter("aboutme"); relation = request.getParameter("relation"); occupation = request.getParameter("occupation"); companies = request.getParameter("companies"); schools = request.getParameter("schools"); mobileopr = request.getParameter("mobileopr"); phonemodel = request.getParameter("phonemodel"); zipcode = request.getParameter("zipcode"); hometown = request.getParameter("hometown"); avatarurl = ""; ilike = request.getParameter("ilike"); ihate = request.getParameter("ihate"); music = request.getParameter("music"); movies = request.getParameter("movies"); books = request.getParameter("books"); tvshows = request.getParameter("tvshows"); celebrity = request.getParameter("celebrity"); profileaccess = "0"; if(bmonth.length() < 2) bmonth = "0" + bmonth; if(bday.length() < 2) bday = "0" + bday; birthdate = byear + bmonth + bday; content = request.getParameter("content"); if(!pass1.equals(pass2)) { status = 8301; } else if(!gender.equals("m") && !gender.equals("f")) { status = 8302; } else if(birthdate.length() != 8) { status = 8303; } else if(pass1.length() > 0 && (pass1.length() < 4 || pass1.length() > 20)) { status = 8304; } else { try { sp = new MSSQLStoredProc(MSSQLStoredProc.DB_MASTER, "skn_updatefullprofile", 26); sp.setInput((String)session.getAttribute(SID_LOGIN)); sp.setInput(pass1.length() > 4 ? encryptPassword(pass1, SECRET_KEY) : ""); sp.setInput(email); sp.setInput(gender); sp.setInput(birthdate); sp.setInput(country); sp.setInput(alias); sp.setInput(motto); sp.setInput(aboutme); sp.setInput(Integer.parseInt(relation)); sp.setInput(occupation); sp.setInput(companies); sp.setInput(schools); sp.setInput(mobileopr); sp.setInput(phonemodel); sp.setInput(zipcode); sp.setInput(hometown); sp.setInput(avatarurl); sp.setInput(ilike); sp.setInput(ihate); sp.setInput(music); sp.setInput(movies); sp.setInput(books); sp.setInput(tvshows); sp.setInput(celebrity); sp.setInput(Integer.parseInt(profileaccess)); status = sp.execute(); } catch(Exception e) { println("updateprofile(ERROR) EXCEPTION: " + e.toString()); } finally { try { sp.close(); } catch(Exception e) {} } /* add/update content setting --- START ---- */ try { sp = new MSSQLStoredProc(MSSQLStoredProc.DB_MASTER, "skn_addcontent_setting", 2); sp.setInput(USERNAME); sp.setInput(Integer.parseInt(content)); statuscode = sp.execute(); println("add/update content setting=" + statuscode); } catch(Exception e) { e.printStackTrace(); } finally { try { sp.close(); } catch(Exception e) {} } /* add/update content setting --- END ---- */ if(status == 0 && statuscode == 0 && pass1.length() > 4) { Cookie usernameCookie = new Cookie(CKE_LOGIN, null); usernameCookie.setMaxAge(0); usernameCookie.setDomain(CKE_DOMAIN); response.addCookie(usernameCookie); Cookie keyCookie = new Cookie(CKE_KEY, null); keyCookie.setMaxAge(0); keyCookie.setDomain(CKE_DOMAIN); response.addCookie(keyCookie); Cookie wapusernameCookie = new Cookie(WG_COOKIE_LOGIN, null); wapusernameCookie.setMaxAge(0); wapusernameCookie.setDomain(CKE_DOMAIN); response.addCookie(wapusernameCookie); } // phpbb insertion /*try { sp = new MSSQLStoredProc(MSSQLStoredProc.DB_FORUM2, "phpbb_updateuser", 4); sp.setInput((String)session.getAttribute(SID_LOGIN)); //-------------- fix starts here ------------------- String pswd = (pass1.length() > 4 ? encryptPassword(pass1, SECRET_KEY) : ""); StringBuffer hexString = new StringBuffer(); if (!pswd.equals("")) { String plainText = pswd; MessageDigest mdAlgorithm = MessageDigest.getInstance("MD5"); mdAlgorithm.update(plainText.getBytes()); byte[] digest = mdAlgorithm.digest(); for (int i = 0; i < digest.length; i++) { plainText = Integer.toHexString(0xFF & digest[i]); if (plainText.length() < 2) { plainText = "0" + plainText; } hexString.append(plainText); } } sp.setInput((hexString.toString()!=null && hexString.toString().length() > 0) ? hexString.toString() : ""); //--------------------------------------------------- sp.setInput(email); sp.setInput(avatarurl); status = sp.execute(); } catch(Exception e) { println("updateprofile_phpbb(ERROR) EXCEPTION: " + e.toString()); } finally { try { sp.close(); } catch(Exception e) {} }*/ } } else if(request.getParameter("avatar_submit") != null && (currentUserLevel & 0x4000) == 0) { // copy avarta from session to user avatar directory and store into db String avatarOwner = (String)session.getAttribute(SID_LOGIN); String srcAvatarImage = (String)session.getAttribute(SID_CROPIMAGE_PATH + "." + ID_AVATAR); if(srcAvatarImage != null && new File(srcAvatarImage).exists()) { String dstAvatarPath = application.getRealPath("img/avatar"); String dstAvatarBigImage = ""; String dstAvatarTbnImage = ""; String subpath = ""; Random r = new Random(System.currentTimeMillis()); do { subpath = "" + r.nextInt(10) + File.separator + r.nextInt(10) + File.separator + r.nextInt(10) + File.separator + Common.getRandomString(16) + ".jpg"; dstAvatarBigImage = dstAvatarPath + File.separator + "big" + File.separator + subpath; dstAvatarTbnImage = dstAvatarPath + File.separator + "tbn" + File.separator + subpath; } while(new File(dstAvatarBigImage).exists() || new File(dstAvatarTbnImage).exists()); new File(dstAvatarBigImage).getParentFile().mkdirs(); new File(dstAvatarTbnImage).getParentFile().mkdirs(); ImageUtil.resizeAndSave(srcAvatarImage, dstAvatarBigImage, 85, 85); ImageUtil.resizeAndSave(srcAvatarImage, dstAvatarTbnImage, 30, 30); // store subpath into db, sp will return current subpath and we delete that try { subpath = subpath.replace('\\', '/'); sp = new MSSQLStoredProc(MSSQLStoredProc.DB_MASTER, "skn_updateavatar", 3); sp.setInput((String)session.getAttribute(SID_LOGIN)); sp.setInput(subpath); sp.setOutput(""); sp.execute(); // phpbb insertion /*MSSQLStoredProc sp1 = null; try { String usravtr = getAvatarURL("http://cuser.ownskin.com/img/avatar", gender, subpath, false); sp1 = new MSSQLStoredProc(MSSQLStoredProc.DB_FORUM2, "phpbb_updateavatar", 2); sp1.setInput((String)session.getAttribute(SID_LOGIN)); sp1.setInput(usravtr); sp1.execute(); } catch(Exception e) { } finally { try { sp1.close(); } catch(Exception e) {} }*/ subpath = sp.getString(3); if(subpath != null && subpath.length() > 0) { new File(dstAvatarPath + File.separator + "big" + File.separator + subpath).delete(); new File(dstAvatarPath + File.separator + "tbn" + File.separator + subpath).delete(); } sp.setOutput(""); sp.execute(); subpath = sp.getString(3); if(subpath != null && subpath.length() > 0) { new File(dstAvatarPath + File.separator + "big" + File.separator + subpath).delete(); new File(dstAvatarPath + File.separator + "tbn" + File.separator + subpath).delete(); } } catch(Exception e) { } finally { try { sp.close(); } catch(Exception e) {} } } response.sendRedirect(URL_MY_PROFILE+ lwpurl); return; } else if(request.getParameter("hpdesign_submit") != null && (currentUserLevel & 0x4000) == 0) { String hpReset = request.getParameter("hpReset"); String hpBgColor = request.getParameter("hpBgColor"); String hpBgURL = request.getParameter("hpBgURL"); String hpBgRepeat = request.getParameter("hpBgRepeat"); String hpTransparency = request.getParameter("hpTransparency"); String hpLinkColor = request.getParameter("hpLinkColor"); String hpBorderColor = request.getParameter("hpBorderColor"); String hpBoxBgColor = request.getParameter("hpBoxBgColor"); String hpBoxTextColor = request.getParameter("hpBoxTextColor"); String hpHighBgColor = request.getParameter("hpHighBgColor"); String hpHighTextColor = request.getParameter("hpHighTextColor"); String hpPhoneColor = request.getParameter("hpPhoneColor"); String hpPhoneClass = "1";//request.getParameter("hpPhoneClass"); String hpFont = request.getParameter("hpFont"); try { boolean updateNow = true; int iTransparency = Integer.parseInt(hpTransparency); int iWidgetClass = Integer.parseInt(hpPhoneClass); if(iTransparency < 50 || iTransparency > 100) updateNow = false; if(iWidgetClass < 1 || iWidgetClass > 16) updateNow = false; if(hpBgColor.length() != 7 || !validColor(hpBgColor.substring(1))) { updateNow = false; } else { hpBgColor = hpBgColor.substring(1); } if(hpLinkColor.length() != 7 || !validColor(hpLinkColor.substring(1))) { updateNow = false; } else { hpLinkColor = hpLinkColor.substring(1); } if(hpBorderColor.length() != 7 || !validColor(hpBorderColor.substring(1))) { updateNow = false; } else { hpBorderColor = hpBorderColor.substring(1); } if(hpBoxBgColor.length() != 7 || !validColor(hpBoxBgColor.substring(1))) { updateNow = false; } else { hpBoxBgColor = hpBoxBgColor.substring(1); } if(hpBoxTextColor.length() != 7 || !validColor(hpBoxTextColor.substring(1))) { updateNow = false; } else { hpBoxTextColor = hpBoxTextColor.substring(1); } if(hpHighBgColor.length() != 7 || !validColor(hpHighBgColor.substring(1))) { updateNow = false; } else { hpHighBgColor = hpHighBgColor.substring(1); } if(hpHighTextColor.length() != 7 || !validColor(hpHighTextColor.substring(1))) { updateNow = false; } else { hpHighTextColor = hpHighTextColor.substring(1); } if(hpPhoneColor.length() != 7 || !validColor(hpPhoneColor.substring(1))) { updateNow = false; } else { hpPhoneColor = hpPhoneColor.substring(1); } if(!hpBgURL.toLowerCase().startsWith("http://")) { hpBgURL = "http://" + hpBgURL; } if(hpBgURL.toLowerCase().trim().equals("http://")) { hpBgURL = ""; } if(!hpBgRepeat.equals("Y") && !hpBgRepeat.equals("N")) { updateNow = false; } if(!hpFont.equals("Verdana") && !hpFont.equals("Arial") && !hpFont.equals("Times New Roman") && !hpFont.equals("Georgia")) { updateNow = false; } if(hpReset.equals("1")) { sp = new MSSQLStoredProc(MSSQLStoredProc.DB_MASTER, "skn_deletehomepage", 1); sp.setInput(USERNAME); sp.execute(); response.sendRedirect(URL_HOME+"?u="+USERNAME); return; } else if(updateNow) { sp = new MSSQLStoredProc(MSSQLStoredProc.DB_MASTER, "skn_updatehomepage", 16); sp.setInput(USERNAME); sp.setInput(hpBgColor); sp.setInput(hpLinkColor); sp.setInput(hpBorderColor); sp.setInput(hpBoxBgColor); sp.setInput(hpBoxTextColor); sp.setInput(hpHighBgColor); sp.setInput(hpHighTextColor); sp.setInput(hpPhoneColor); sp.setInput(iWidgetClass); sp.setInput(hpBgURL); sp.setInput(hpBgRepeat); sp.setInput(iTransparency); sp.setInput(hpFont); sp.setInput("A"); sp.setInput("A"); sp.execute(); response.sendRedirect(URL_HOME+"?u="+USERNAME); return; } } catch(Exception e) { e.printStackTrace(); } finally { try { sp.close(); } catch(Exception e) {} } } tabselected = TAB_HOME; try { sp = new MSSQLStoredProc(MSSQLStoredProc.DB_MASTER, "skn_getmemberfullinfo", 1); sp.setInput((String)session.getAttribute(SID_LOGIN)); rs = sp.executeQuery(); if(rs.next()) { email = rs.getString("email"); gender = rs.getString("gender"); birthdate = rs.getString("birthdate"); country = rs.getString("country"); registertime = rs.getString("registertime"); logintime = rs.getString("logintime"); alias = rs.getString("alias"); motto = rs.getString("motto"); aboutme = rs.getString("aboutme"); relation = rs.getString("relation"); occupation = rs.getString("occupation"); companies = rs.getString("companies"); schools = rs.getString("schools"); mobileopr = rs.getString("mobileopr"); phonemodel = rs.getString("phonemodel"); zipcode = rs.getString("zipcode"); hometown = rs.getString("hometown"); avatarurl = rs.getString("avatarurl"); ilike = rs.getString("ilike"); ihate = rs.getString("ihate"); music = rs.getString("music"); movies = rs.getString("movies"); books = rs.getString("books"); tvshows = rs.getString("tvshows"); celebrity = rs.getString("celebrity"); lastaccess = rs.getString("lastaccess"); profileaccess = rs.getString("profileaccess"); // reset null if(alias == null) alias = ""; if(motto == null) motto = ""; if(aboutme == null) aboutme = ""; if(relation == null) relation = "0"; if(occupation == null) occupation = ""; if(companies == null) companies = ""; if(schools == null) schools = ""; if(mobileopr == null) mobileopr = ""; if(phonemodel == null) phonemodel = ""; if(zipcode == null) zipcode = ""; if(hometown == null) hometown = ""; avatarurl = getAvatarURL(AVATAR_URL_ROOT, gender, avatarurl, false); if(ilike == null) ilike = ""; if(ihate == null) ihate = ""; if(music == null) music = ""; if(movies == null) movies = ""; if(books == null) books = ""; if(tvshows == null) tvshows = ""; if(celebrity == null) celebrity = ""; if(profileaccess == null) profileaccess = "0"; // format birthdate byear = birthdate.substring(0, 4); bmonth = birthdate.substring(5, 7); bday = birthdate.substring(8, 10); } } catch(Exception e) { } finally { try { rs.close(); } catch(Exception e) {} try { sp.close(); } catch(Exception e) {} } /* get content setting --- START ---- */ try { sp = new MSSQLStoredProc(MSSQLStoredProc.DB_MASTER, "skn_getcontent_setting", 1); sp.setInput(USERNAME); rs = sp.executeQuery(); if(rs.next()){ content = rs.getString("content"); } } catch(Exception e) { e.printStackTrace(); } finally { try { rs.close(); } catch(Exception e) {} try { sp.close(); } catch(Exception e) {} } /* get content setting --- END ---- */ String[] month = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", }; %> <% if("1".equals(flag)){ %> <%@ include file="htmllwpheader.jsp" %> <% } else { %> <%@ include file="htmlheader.jsp" %> <% } %>