-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_Add_Community1.jsp
221 lines (168 loc) · 6.86 KB
/
admin_Add_Community1.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Add Categories</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="css/coin-slider.css" />
<script type="text/javascript" src="js/cufon-yui.js"></script>
<script type="text/javascript" src="js/droid_sans_400-droid_sans_700.font.js"></script>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript" src="js/coin-slider.min.js"></script>
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
.style3 {font-size: 16px}
-->
</style>
</head>
<body>
<div class="main">
<div class="header">
<div class="header_resize">
<div class="menu_nav">
<ul>
<li><a href="index.html"><span>Home </span></a></li>
<li class="active"><a href="admin_Login.jsp"><span>Admin</span></a></li>
<li><a href="user_Login.jsp"><span>User</span></a></li>
<li></li>
</ul>
</div>
<div class="logo">
<h2><span class="style1">Clustering Based Collaborative Filtering Using an Incentivized Penalized User Model<small></small></span></h2>
</div>
<div class="clr"></div>
<div class="slider">
<div id="coin-slider"> <a href="#"><img src="images/slide1.jpg" width="960" height="294" alt="" /> </a> <a href="#"><img src="images/slide2.jpg" width="960" height="294" alt="" /> </a> <a href="#"><img src="images/slide3.jpg" width="960" height="294" alt="" /> </a> </div>
<div class="clr"></div>
</div>
<div class="clr"></div>
</div>
</div>
<div class="content">
<div class="content_resize">
<div class="mainbar">
<div class="article">
<h2><span>Add User Domain .</span></h2>
<div class="clr"></div>
<p> </p>
<p>
<%@ include file="connect.jsp" %>
<%@ page import = "java.io.*"%>
<%@ page import = "java.util.*" %>
<%@ page import = "java.util.Date" %>
<%@ page import ="java.math.BigInteger" %>
<%@ page import = "javax.crypto.Cipher" %>
<%@ page import = "com.oreilly.servlet.*" %>
<%@ page import = "java.text.SimpleDateFormat" %>
<%@ page import = "javax.crypto.spec.SecretKeySpec,java.security.DigestInputStream" %>
<%@ page import = "org.bouncycastle.util.encoders.Base64,java.security.MessageDigest" %>
<%@ page import = "java.security.KeyPairGenerator,java.security.KeyPair,java.security.Key" %>
<%
ArrayList list = new ArrayList();
ServletContext context = getServletContext();
String dirName =context.getRealPath("Gallery/");
String title=null,Community=null,location1=null,sk=null,bin = "", paramname=null;
FileInputStream fs=null;
File file1 = null;
try {
MultipartRequest multi = new MultipartRequest(request, dirName, 10 * 1024 * 1024);
Enumeration params = multi.getParameterNames();
while (params.hasMoreElements())
{
paramname = (String) params.nextElement();
if(paramname.equalsIgnoreCase("Community"))
{
Community=multi.getParameter(paramname);
}
}
FileInputStream fs1 = null;
String query1="select * from Communitys where Community='"+Community+"' ";
Statement st1=connection.createStatement();
ResultSet rs1=st1.executeQuery(query1);
if ( rs1.next() )
{
out.print("Community Already Exist");
%>
<p><a href="admin_Add_Community.jsp" class="style8">Back</a></p>
<%
}
else
{
SimpleDateFormat sdfDate = new SimpleDateFormat("dd/MM/yyyy");
SimpleDateFormat sdfTime = new SimpleDateFormat("HH:mm:ss");
Date now = new Date();
String strDate = sdfDate.format(now);
String strTime = sdfTime.format(now);
String dt = strDate + " " + strTime;
String keys = "ef50a0ef2c3e3a5f";
String h1="";
String filename="filename.txt";
KeyPairGenerator kg = KeyPairGenerator.getInstance("RSA");
Cipher encoder = Cipher.getInstance("RSA");
KeyPair kp = kg.generateKeyPair();
Key pubKey = kp.getPublic();
byte[] pub = pubKey.getEncoded();
PrintStream p = new PrintStream(new FileOutputStream(filename));
p.print(new String(Community));
MessageDigest md = MessageDigest.getInstance("SHA1");
FileInputStream fis11 = new FileInputStream(filename);
DigestInputStream dis1 = new DigestInputStream(fis11, md);
BufferedInputStream bis1 = new BufferedInputStream(dis1);
//Read the bis so SHA1 is auto calculated at dis
while (true) {
int b1 = bis1.read();
if (b1 == -1)
break;
}
BigInteger bi1 = new BigInteger(md.digest());
String spl1 = bi1.toString();
h1 = bi1.toString(16);
String strQuery2 = "insert into Communitys(Community,hash_sign) values('"+Community+"','"+h1+"')";
connection.createStatement().executeUpdate(strQuery2);
out.print("Community Added Successfully");
%>
<p><a href="admin_Add_Community.jsp" class="style8">Back</a></p>
<%
}
}
catch (Exception e)
{
out.println(e.getMessage());
}
%>
</p>
<p> </p>
<div class="clr"></div>
</div>
<div class="article">
<div class="clr"></div>
<div class="clr"></div>
</div>
</div>
<div class="sidebar">
<div class="searchform">
</div>
<div class="clr"></div>
<div class="gadget">
<h2 class="star"><span>Admin</span> Menu</h2>
<div class="clr"></div>
<ul class="sb_menu">
<li><a href="admin_Main.jsp"><span>Admin Main </span></a></li>
<li><a href="admin_Login.jsp"><span>Log Out</span></a></li>
</ul>
</div>
</div>
<div class="clr"></div>
</div>
</div>
<div class="fbg"></div>
<div class="footer">
<div class="footer_resize">
<div style="clear:both;"></div>
</div>
</div>
</div>
</body>
</html>