01: package forum;
02:
03: import java.io.*;
04: import javax.servlet.*;
05: import javax.servlet.http.*;
06: import java.util.*;
07: import java.sql.*;
08: import java.sql.Connection;
09: import java.sql.Statement;
10: import java.sql.ResultSet;
11:
12: public class ChangeProfile extends HttpServlet {
13:
14: DBConnectie db = new DBConnectie(Variable.getDb(), Variable
15: .getDbLogin(), Variable.getDbPassword());
16:
17: public void doPost(HttpServletRequest request,
18: HttpServletResponse response) throws ServletException,
19: IOException {
20: PrintWriter out = response.getWriter();
21: try {
22:
23: HttpSession session = request.getSession(true);
24: String sessionUsername = (String) session
25: .getAttribute("username");
26: String sessionType = (String) session.getAttribute("type");
27:
28: String avatar_list = request.getParameter("avatar_list");
29: String link_avatar = request.getParameter("link_avatar");
30: String member_title = request.getParameter("member_title");
31: String signature = request.getParameter("signature");
32:
33: member_title = Filter.filterAll(member_title);
34: signature = Filter.filterAll(signature);
35:
36: String avatar = null;
37: if (link_avatar.equals("http://")) {
38: avatar = avatar_list;
39: } else {
40: avatar = link_avatar;
41: }
42:
43: db.connect();
44:
45: db.query("INSERT INTO forum_users(user_name) VALUES(\""
46: + sessionUsername + "\"");
47: db
48: .query("UPDATE forum_users SET type = \""
49: + sessionType + "\" WHERE user_name =\""
50: + sessionUsername + "\"");
51: db
52: .query("UPDATE forum_users SET avatar = \""
53: + avatar + "\" WHERE user_name =\""
54: + sessionUsername + "\"");
55: db.query("UPDATE forum_users SET member_title = \""
56: + member_title + "\" WHERE user_name =\""
57: + sessionUsername + "\"");
58: db.query("UPDATE forum_users SET signature = \""
59: + signature + "\" WHERE user_name =\""
60: + sessionUsername + "\"");
61:
62: response.sendRedirect(Variable.getForumPath()
63: + "index.jsp?page=profile");
64: db.close();
65:
66: } catch (Exception e) {
67: out.println(e);
68: }
69:
70: }
71:
72: public void doGet(HttpServletRequest request,
73: HttpServletResponse response) throws ServletException,
74: IOException {
75: doPost(request, response);
76: }
77:
78: }
|