diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..c697bc3 --- /dev/null +++ b/.classpath @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 62c8935..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.idea/ \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 0000000..cc010a9 --- /dev/null +++ b/.project @@ -0,0 +1,31 @@ + + + oaps + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.jdt.core.javanature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/.settings/.jsdtscope b/.settings/.jsdtscope new file mode 100644 index 0000000..92e666d --- /dev/null +++ b/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..0c68a61 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..d0ec994 --- /dev/null +++ b/.settings/org.eclipse.wst.common.component @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..ddc9712 --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.container b/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000..3bd5d0a --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.name b/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 0000000..05bd71b --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/111.zip b/111.zip new file mode 100644 index 0000000..c637241 Binary files /dev/null and b/111.zip differ diff --git a/The things I have done.txt b/The things I have done.txt deleted file mode 100644 index a919318..0000000 --- a/The things I have done.txt +++ /dev/null @@ -1,7 +0,0 @@ -The things I have done (What I still remember): -0、Organize the messy resources, design and modify the database to make the project run; -1、The function of hiding or displaying the article is added; -2、The administrator can edit and add subject; -3、The problem of Chinese garbled code is solved; -4、The type and size of uploaded files are limited; -5、Fixed some bugs in the original project; \ No newline at end of file diff --git a/WZF_OAPS.zip b/WZF_OAPS.zip new file mode 100644 index 0000000..38f359d Binary files /dev/null and b/WZF_OAPS.zip differ diff --git a/WZF_OAPS/.idea/.gitignore b/WZF_OAPS/.idea/.gitignore new file mode 100644 index 0000000..676678a --- /dev/null +++ b/WZF_OAPS/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/../../../../../../:\Users\lkm\Desktop\WZF_OAPS\.idea/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/WZF_OAPS/.idea/WZF_OAPS.iml b/WZF_OAPS/.idea/WZF_OAPS.iml new file mode 100644 index 0000000..78b2cc5 --- /dev/null +++ b/WZF_OAPS/.idea/WZF_OAPS.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/artifacts/WZF_OAPS_war.xml b/WZF_OAPS/.idea/artifacts/WZF_OAPS_war.xml new file mode 100644 index 0000000..5c0faaa --- /dev/null +++ b/WZF_OAPS/.idea/artifacts/WZF_OAPS_war.xml @@ -0,0 +1,14 @@ + + + $PROJECT_DIR$/target + + + WZF_OAPS + war + + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/artifacts/WZF_OAPS_war_exploded.xml b/WZF_OAPS/.idea/artifacts/WZF_OAPS_war_exploded.xml new file mode 100644 index 0000000..5e72e2d --- /dev/null +++ b/WZF_OAPS/.idea/artifacts/WZF_OAPS_war_exploded.xml @@ -0,0 +1,35 @@ + + + $PROJECT_DIR$/target/WZF_OAPS + + + true + WZF_OAPS + war + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/compiler.xml b/WZF_OAPS/.idea/compiler.xml new file mode 100644 index 0000000..347e842 --- /dev/null +++ b/WZF_OAPS/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/encodings.xml b/WZF_OAPS/.idea/encodings.xml new file mode 100644 index 0000000..fade66b --- /dev/null +++ b/WZF_OAPS/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/jarRepositories.xml b/WZF_OAPS/.idea/jarRepositories.xml new file mode 100644 index 0000000..d46a6c7 --- /dev/null +++ b/WZF_OAPS/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/libraries/Java_EE_6_Java_EE_6.xml b/WZF_OAPS/.idea/libraries/Java_EE_6_Java_EE_6.xml new file mode 100644 index 0000000..fcb1ba9 --- /dev/null +++ b/WZF_OAPS/.idea/libraries/Java_EE_6_Java_EE_6.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/libraries/Java_EE_6_Java_EE_6__2_.xml b/WZF_OAPS/.idea/libraries/Java_EE_6_Java_EE_6__2_.xml new file mode 100644 index 0000000..1155a32 --- /dev/null +++ b/WZF_OAPS/.idea/libraries/Java_EE_6_Java_EE_6__2_.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/libraries/Maven__commons_fileupload_commons_fileupload_1_3.xml b/WZF_OAPS/.idea/libraries/Maven__commons_fileupload_commons_fileupload_1_3.xml new file mode 100644 index 0000000..e7b8a8b --- /dev/null +++ b/WZF_OAPS/.idea/libraries/Maven__commons_fileupload_commons_fileupload_1_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/libraries/Maven__commons_io_commons_io_2_4.xml b/WZF_OAPS/.idea/libraries/Maven__commons_io_commons_io_2_4.xml new file mode 100644 index 0000000..c39070b --- /dev/null +++ b/WZF_OAPS/.idea/libraries/Maven__commons_io_commons_io_2_4.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/libraries/Maven__javax_servlet_javax_servlet_api_3_1_0.xml b/WZF_OAPS/.idea/libraries/Maven__javax_servlet_javax_servlet_api_3_1_0.xml new file mode 100644 index 0000000..40ed55e --- /dev/null +++ b/WZF_OAPS/.idea/libraries/Maven__javax_servlet_javax_servlet_api_3_1_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/libraries/Maven__jstl_jstl_1_2.xml b/WZF_OAPS/.idea/libraries/Maven__jstl_jstl_1_2.xml new file mode 100644 index 0000000..a2123ed --- /dev/null +++ b/WZF_OAPS/.idea/libraries/Maven__jstl_jstl_1_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_aop_5_0_5_RELEASE.xml b/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_aop_5_0_5_RELEASE.xml new file mode 100644 index 0000000..874b0eb --- /dev/null +++ b/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_aop_5_0_5_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_beans_5_0_5_RELEASE.xml b/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_beans_5_0_5_RELEASE.xml new file mode 100644 index 0000000..e858768 --- /dev/null +++ b/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_beans_5_0_5_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_context_5_0_5_RELEASE.xml b/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_context_5_0_5_RELEASE.xml new file mode 100644 index 0000000..ce69e45 --- /dev/null +++ b/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_context_5_0_5_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_core_5_0_5_RELEASE.xml b/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_core_5_0_5_RELEASE.xml new file mode 100644 index 0000000..4bfbc1d --- /dev/null +++ b/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_core_5_0_5_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_expression_5_0_5_RELEASE.xml b/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_expression_5_0_5_RELEASE.xml new file mode 100644 index 0000000..b78cecc --- /dev/null +++ b/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_expression_5_0_5_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_jcl_5_0_5_RELEASE.xml b/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_jcl_5_0_5_RELEASE.xml new file mode 100644 index 0000000..0a06c72 --- /dev/null +++ b/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_jcl_5_0_5_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_web_5_0_5_RELEASE.xml b/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_web_5_0_5_RELEASE.xml new file mode 100644 index 0000000..1d4a3e6 --- /dev/null +++ b/WZF_OAPS/.idea/libraries/Maven__org_springframework_spring_web_5_0_5_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/misc.xml b/WZF_OAPS/.idea/misc.xml new file mode 100644 index 0000000..919019a --- /dev/null +++ b/WZF_OAPS/.idea/misc.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/uiDesigner.xml b/WZF_OAPS/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/WZF_OAPS/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/vcs.xml b/WZF_OAPS/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/WZF_OAPS/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/web/WEB-INF/web.xml b/WZF_OAPS/.idea/web/WEB-INF/web.xml new file mode 100644 index 0000000..d80081d --- /dev/null +++ b/WZF_OAPS/.idea/web/WEB-INF/web.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/WZF_OAPS/.idea/webContexts.xml b/WZF_OAPS/.idea/webContexts.xml new file mode 100644 index 0000000..f4124c7 --- /dev/null +++ b/WZF_OAPS/.idea/webContexts.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/WZF_OAPS.iml b/WZF_OAPS/WZF_OAPS.iml similarity index 100% rename from WZF_OAPS.iml rename to WZF_OAPS/WZF_OAPS.iml diff --git a/WZF_OAPS/lib/javax.annotation.jar b/WZF_OAPS/lib/javax.annotation.jar new file mode 100644 index 0000000..52dca7f Binary files /dev/null and b/WZF_OAPS/lib/javax.annotation.jar differ diff --git a/WZF_OAPS/lib/javax.ejb.jar b/WZF_OAPS/lib/javax.ejb.jar new file mode 100644 index 0000000..4ebf5ec Binary files /dev/null and b/WZF_OAPS/lib/javax.ejb.jar differ diff --git a/WZF_OAPS/lib/javax.jms.jar b/WZF_OAPS/lib/javax.jms.jar new file mode 100644 index 0000000..d31451a Binary files /dev/null and b/WZF_OAPS/lib/javax.jms.jar differ diff --git a/WZF_OAPS/lib/javax.persistence.jar b/WZF_OAPS/lib/javax.persistence.jar new file mode 100644 index 0000000..21d80e0 Binary files /dev/null and b/WZF_OAPS/lib/javax.persistence.jar differ diff --git a/WZF_OAPS/lib/javax.resource.jar b/WZF_OAPS/lib/javax.resource.jar new file mode 100644 index 0000000..696a234 Binary files /dev/null and b/WZF_OAPS/lib/javax.resource.jar differ diff --git a/WZF_OAPS/lib/javax.servlet.jar b/WZF_OAPS/lib/javax.servlet.jar new file mode 100644 index 0000000..0519e4a Binary files /dev/null and b/WZF_OAPS/lib/javax.servlet.jar differ diff --git a/WZF_OAPS/lib/javax.servlet.jsp.jar b/WZF_OAPS/lib/javax.servlet.jsp.jar new file mode 100644 index 0000000..9c0631c Binary files /dev/null and b/WZF_OAPS/lib/javax.servlet.jsp.jar differ diff --git a/WZF_OAPS/lib/javax.servlet.jsp.jstl.jar b/WZF_OAPS/lib/javax.servlet.jsp.jstl.jar new file mode 100644 index 0000000..7be17cc Binary files /dev/null and b/WZF_OAPS/lib/javax.servlet.jsp.jstl.jar differ diff --git a/WZF_OAPS/lib/javax.transaction.jar b/WZF_OAPS/lib/javax.transaction.jar new file mode 100644 index 0000000..729c695 Binary files /dev/null and b/WZF_OAPS/lib/javax.transaction.jar differ diff --git a/pom.xml b/WZF_OAPS/pom.xml similarity index 92% rename from pom.xml rename to WZF_OAPS/pom.xml index 2bca6e9..e707170 100644 --- a/pom.xml +++ b/WZF_OAPS/pom.xml @@ -20,6 +20,11 @@ + + mysql + mysql-connector-java + 5.1.32 + commons-fileupload commons-fileupload @@ -39,28 +44,26 @@ jstl jstl 1.2 + provided - - mysql - mysql-connector-java - 5.1.32 - + commons-io commons-io 2.4 - - junit - junit - 4.11 - test - + + + + + + javax.servlet javax.servlet-api 3.1.0 + provided diff --git a/WZF_OAPS/src/main/java/com/database/DB.java b/WZF_OAPS/src/main/java/com/database/DB.java new file mode 100644 index 0000000..ddb0187 --- /dev/null +++ b/WZF_OAPS/src/main/java/com/database/DB.java @@ -0,0 +1,501 @@ +package com.database; + +import com.javaBean.Administrator; +import com.javaBean.Article; +import com.javaBean.Author; +import com.javaBean.Subject; + +import java.sql.*; + +public class DB { + + public String root = "wzf"; + public String url = "jdbc:mysql://47.115.56.157:3306/oo?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8"; + public String password = "wzf"; + public String Driver = "com.mysql.jdbc.Driver"; + public Connection con; + + public void connect() throws SQLException + { + try + { + Class.forName(Driver); + + con = DriverManager.getConnection(url, root, password); + + } + + catch(ClassNotFoundException e) + { + e.printStackTrace(); + } + + } + + public void close() throws SQLException + { + con.close(); + } + + public void updateArticle(Article a) throws SQLException + { + connect(); + + String sql = "update article set title=?, highlight=?, abstracts=?, time=? where title=?"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, a.getTitle()); + ps.setString(2, a.getHighlights()); + ps.setString(3, a.getAbstracts()); + ps.setTimestamp(4, a.getTime()); + ps.setString(5, a.getOldtitle()); + ps.executeUpdate(); + + close(); + } + public void updateSubject(Subject s) throws SQLException + { + connect(); + + String sql = "update subject set subject=?, sdate=? where subject=?"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, s.getSubject()); + ps.setTimestamp(2,s.sdate); + ps.setString(3, s.getOldsubject()); + + ps.executeUpdate(); + + close(); + } + public void showArticle(String title) throws SQLException + { + connect(); + String sql="update article set hide=? where title=?"; + PreparedStatement ps = con.prepareStatement(sql); + ps.setString(1,"No"); + ps.setString(2,title); + ps.executeUpdate(); + close(); + + + + } + public void hideArticle(String title) throws SQLException + { + connect(); + String sql="update article set hide=? where title=?"; + PreparedStatement ps = con.prepareStatement(sql); + ps.setString(1,"Yes"); + ps.setString(2,title); + ps.executeUpdate(); + close(); + + + + } + + public void deleteArticle(String title) throws SQLException + { + connect(); + + String sql = "delete from article where title=?"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, title); + ps.executeUpdate(); + + close(); + + } + public void deleteSubject(int sid) throws SQLException + { + connect(); + + String sql = "delete from subject where sid=? or parentsid=?"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setInt(1, sid); + ps.setInt(2, sid); + ps.executeUpdate(); + + close(); + + } + + + public void deleteComment(String comment) throws SQLException + { + connect(); + + String sql = "delete from comments where comment=?"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, comment); + ps.executeUpdate(); + + close(); + + } + + public void addAuthor(Author a) throws SQLException + { + connect(); + + String sql = "insert into author(email,password) values(?,?)"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, a.getEmail()); + ps.setString(2, a.getPassword()); + ps.executeUpdate(); + + close(); + + } + public void addSubject(Subject a) throws SQLException + { + connect(); + + String sql = "insert into subject(sid,subject,sdate,parentsid) values(?,?,?,?)"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setInt(1,0); + ps.setString(2, a.getSubject()); + ps.setTimestamp(3, a.getSdate()); + int parentsid=0; + if (a.parentsid!=0) + { + parentsid=a.getParentsid(); + + + } + ps.setInt(4,parentsid); + ps.executeUpdate(); + + close(); + + } + + public boolean checkAuthor(Author a) throws SQLException + { + connect(); + + boolean result = false; + int i = 0; + + String sql = "select * from author where email=? and password=?"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, a.getEmail()); + ps.setString(2, a.getPassword()); + + ResultSet rs = ps.executeQuery(); + + while(rs.next()) + { + i = 1; + result= true; + } + + close(); + + return result; + } + public boolean checkAdministrator(Administrator a) throws SQLException + { + connect(); + + boolean result = false; + int i = 0; + + String sql = "select * from administrator where email=? and password=?"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, a.getEmail()); + ps.setString(2, a.getPassword()); + + ResultSet rs = ps.executeQuery(); + + if(rs.next()) + { + + result= true; + } + + close(); + + return result; + } + + public boolean checkblockauthor(String email) throws SQLException + { + connect(); + + boolean result = false; + int i = 0; + + + String sql = "select * from block_author where email=?"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, email); + + + ResultSet rs = ps.executeQuery(); + + while(rs.next()) + { + i = 1; + result= true; + } + + close(); + + return result; + } +public void addVisit(String id,String ip) throws SQLException + { + int aid=-1; + if (id!=null&&!id.equals("")) + { + aid=Integer.parseInt(id); + + } + connect(); + String sql0="select * from visit where ip=? and aid=?"; + PreparedStatement ps0 = con.prepareStatement(sql0); + ps0.setString(1,ip); + ps0.setInt(2,aid); + ResultSet resultSet = ps0.executeQuery(); + if (!resultSet.next()) + { + Timestamp time = new Timestamp(System.currentTimeMillis()); + + String sql = "insert into visit(vid,aid,ip,vdate) values (?,?,?,?)"; + + PreparedStatement ps = con.prepareStatement(sql); + ps.setInt(1,0); + ps.setInt(2,aid); + ps.setString(3,ip); + ps.setTimestamp(4,time); + ps.executeUpdate(); + + } + + close(); + + + } + + public void blockAuthor(String author) throws SQLException + { + connect(); + + String sql = "insert into block_author(email) values(?)"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, author); + ps.executeUpdate(); + + close(); + + } + + public void releaseAuthor(String author) throws SQLException + { + connect(); + + String sql = "delete from block_author where email=?"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, author); + ps.executeUpdate(); + + close(); + + } + + + public boolean checktitle(String title) throws SQLException + { + connect(); + + boolean result = false; + int i = 0; + + String sql = "select * from article a , subject s where a.sid=s.sid and title=?"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, title); + + + ResultSet rs = ps.executeQuery(); + + while(rs.next()) + { + i = 1; + result= true; + break; + } + + close(); + + return result; + } + public boolean checksubject(String subject) throws SQLException + { + connect(); + + boolean result = false; +// int i = 0; + + String sql = "select * from subject where subject=?"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, subject); + + + ResultSet rs = ps.executeQuery(); + + while(rs.next()) + { +// i = 1; + result= true; + break; + } + + close(); + + return result; + } + + + + // public boolean check_popular(String ip, String title, int a) throws SQLException +// { + public void check_popular(String ip, String title, int a) throws SQLException + { + connect(); + +// boolean result = false; + int i = 0; + + + + String sql = "insert into love_article(ip, title, prefer) values(?, ?, ?)"; + String sql2 = "select * from love_article where ip=? and title=?"; + String sql3 = "update love_article set prefer=? where ip=? and title=?"; + + PreparedStatement ps2 = con.prepareStatement(sql2); + ps2.setString(1, ip); + ps2.setString(2, title); + + ResultSet rs = ps2.executeQuery(); + + while(rs.next()) + { + i = 1; + } + + if(i==1) + { + PreparedStatement ps3 = con.prepareStatement(sql3); + ps3.setInt(1, a); + ps3.setString(2, ip); + ps3.setString(3, title); + ps3.executeUpdate(); +// result = false; + } + + else if(i==0) + { + PreparedStatement ps = con.prepareStatement(sql); + ps.setString(1, ip); + ps.setString(2, title); + ps.setInt(3, a); + ps.executeUpdate(); +// result = true; + } + + + close(); + +// return result; + } + + /* + + This function checks whether the user with the specific 'ip', has liked/disliked the comment + with the specific 'id'. + 'a' is a flag to determine whether the required operation is like or dislike, where a = 0, if + the required operation is dislike, and a = 1 if it's like. + + */ +// public boolean check_comments_popular(String ip, int id, int a) throws SQLException +// { + public void check_comments_popular(String ip, int id, int a) throws SQLException + { + connect(); + +// boolean result = false; + int i = 0; + + + + String sql = "insert into love_comment(ip, cid, prefer) values(?, ?, ?)"; + String sql2 = "select * from love_comment where ip=? and cid=?"; + String sql3 = "update love_comment set prefer=? where ip=? and cid=?"; + + PreparedStatement ps2 = con.prepareStatement(sql2); + ps2.setString(1, ip); + ps2.setInt(2, id); + + ResultSet rs = ps2.executeQuery(); + + if(rs.next()) + { + i = 1; + } + + if(i==1) + { + PreparedStatement ps3 = con.prepareStatement(sql3); + ps3.setInt(1, a); + ps3.setString(2, ip); + ps3.setInt(3, id); + ps3.executeUpdate(); +// result = false; + } + + else if(i==0) + { + PreparedStatement ps = con.prepareStatement(sql); + ps.setString(1, ip); + ps.setInt(2, id); + ps.setInt(3, a); + ps.executeUpdate(); +// result = true; + } + + + close(); + +// return result; + } + + +} diff --git a/WZF_OAPS/src/main/java/com/filter/Filter_AdminLogin.java b/WZF_OAPS/src/main/java/com/filter/Filter_AdminLogin.java new file mode 100644 index 0000000..758642d --- /dev/null +++ b/WZF_OAPS/src/main/java/com/filter/Filter_AdminLogin.java @@ -0,0 +1,38 @@ +package com.filter; + +import com.database.DB; +import com.javaBean.Author; + +import javax.servlet.*; +import javax.servlet.annotation.WebFilter; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import java.io.IOException; +import java.sql.SQLException; + +@WebFilter(value={"/AdministratorHome.jsp","/AdministratorEdit.jsp","/AddSubject.jsp"},dispatcherTypes= {DispatcherType.REQUEST,DispatcherType.FORWARD}) +public class Filter_AdminLogin implements Filter { + @Override + public void init(FilterConfig filterConfig) throws ServletException { + + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { + HttpSession session=((HttpServletRequest) request).getSession(); + if(session.getAttribute("admin_login")!=null) + { + chain.doFilter(request, response); + } + else + { + request.setAttribute("advice","If you are an administrator,login in first "); + request.getRequestDispatcher("Administrator.jsp").forward(request,response); + } + } + + @Override + public void destroy() { + + } +} diff --git a/WZF_OAPS/src/main/java/com/javaBean/Administrator.java b/WZF_OAPS/src/main/java/com/javaBean/Administrator.java new file mode 100644 index 0000000..f1e5a32 --- /dev/null +++ b/WZF_OAPS/src/main/java/com/javaBean/Administrator.java @@ -0,0 +1,22 @@ +package com.javaBean; + +public class Administrator { + public String email, password; + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + +} diff --git a/WZF_OAPS/src/main/java/com/javaBean/Article.java b/WZF_OAPS/src/main/java/com/javaBean/Article.java new file mode 100644 index 0000000..1e2710d --- /dev/null +++ b/WZF_OAPS/src/main/java/com/javaBean/Article.java @@ -0,0 +1,69 @@ +package com.javaBean; + +import java.sql.Timestamp; + +public class Article { + + public String subject, title, author, highlights, abstracts, oldtitle; + public String comment, user; + public Timestamp time; + + + public String getSubject() { + return subject; + } + public void setSubject(String subject) { + this.subject = subject; + } + public String getTitle() { + return title; + } + public void setTitle(String title) { + this.title = title; + } + public String getAuthor() { + return author; + } + public void setAuthor(String author) { + this.author = author; + } + public String getHighlights() { + return highlights; + } + public void setHighlights(String highlights) { + this.highlights = highlights; + } + public String getAbstracts() { + return abstracts; + } + public void setAbstracts(String abstracts) { + this.abstracts = abstracts; + } + public Timestamp getTime() { + return time; + } + public void setTime(Timestamp time) { + this.time = time; + } + public String getComment() { + return comment; + } + public void setComment(String comment) { + this.comment = comment; + } + public String getUser() { + return user; + } + public void setUser(String user) { + this.user = user; + } + public String getOldtitle() { + return oldtitle; + } + public void setOldtitle(String oldtitle) { + this.oldtitle = oldtitle; + } + + + +} diff --git a/WZF_OAPS/src/main/java/com/javaBean/Author.java b/WZF_OAPS/src/main/java/com/javaBean/Author.java new file mode 100644 index 0000000..ed1028b --- /dev/null +++ b/WZF_OAPS/src/main/java/com/javaBean/Author.java @@ -0,0 +1,23 @@ +package com.javaBean; +public class Author { + + public String email, password; + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + +} diff --git a/WZF_OAPS/src/main/java/com/javaBean/Subject.java b/WZF_OAPS/src/main/java/com/javaBean/Subject.java new file mode 100644 index 0000000..e8ca4cf --- /dev/null +++ b/WZF_OAPS/src/main/java/com/javaBean/Subject.java @@ -0,0 +1,51 @@ +package com.javaBean; + +import java.sql.Timestamp; + +public class Subject { + public int sid; + public String subject; + public Timestamp sdate; + public String oldsubject; + public int parentsid; + + public int getParentsid() { + return parentsid; + } + + public void setParentsid(int parentsid) { + this.parentsid = parentsid; + } + + public String getOldsubject() { + return oldsubject; + } + + public void setOldsubject(String oldsubject) { + this.oldsubject = oldsubject; + } + + public int getSid() { + return sid; + } + + public void setSid(int sid) { + this.sid = sid; + } + + public String getSubject() { + return subject; + } + + public void setSubject(String subject) { + this.subject = subject; + } + + public Timestamp getSdate() { + return sdate; + } + + public void setSdate(Timestamp sdate) { + this.sdate = sdate; + } +} diff --git a/WZF_OAPS/src/main/java/com/javaBeans/AdministorController.java b/WZF_OAPS/src/main/java/com/javaBeans/AdministorController.java new file mode 100644 index 0000000..1f32ba4 --- /dev/null +++ b/WZF_OAPS/src/main/java/com/javaBeans/AdministorController.java @@ -0,0 +1,172 @@ +package com.javaBeans; + + +import com.database.DB; +import com.javaBean.Administrator; +import com.javaBean.Subject; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.io.IOException; +import java.sql.SQLException; +import java.sql.Timestamp; + +@WebServlet(name = "AdministorController") +public class AdministorController extends HttpServlet { + HttpSession session; + protected void doGet (HttpServletRequest request, HttpServletResponse response) throws + ServletException, IOException { + doPost(request, response); + } + + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + String page = request.getParameter("page"); + + if (page.equals("administrator")) { + String email = request.getParameter("email"); + String password = request.getParameter("password"); + Administrator a = new Administrator(); + a.setEmail(email); + a.setPassword(password); + + DB db = new DB(); + boolean status = false; + + try { + status = db.checkAdministrator(a); + } catch (SQLException e) { + e.printStackTrace(); + } + + if (status) { + HttpSession session = request.getSession(); + session.setAttribute("admin_login","yes"); + + request.getRequestDispatcher("AdministratorHome.jsp").forward(request, response); + } else { + request.setAttribute("msg", "invalid"); + request.getRequestDispatcher("Administrator.jsp").forward(request, response); + } + } + if (page.equals("logout")) { + HttpSession session = request.getSession(); + session.setAttribute("admin_login",null); + request.getRequestDispatcher("Administrator.jsp").forward(request, response); + } + if (page.equals("add")) { + String parentsid = request.getParameter("parentsid"); + request.setAttribute("parentsid",parentsid); + request.getRequestDispatcher("AddSubject.jsp").forward(request, response); + } + if (page.equals("addSubject")) { + int parentsid=0; + String parent = request.getParameter("parentsid"); + if (!parent.equals("")) + { + parentsid=Integer.parseInt(parent); + + } + + String subject = request.getParameter("subject"); + Subject sub = new Subject(); + Timestamp time = new Timestamp(System.currentTimeMillis()); + sub.setSdate(time); + sub.setSubject(subject); + sub.setParentsid(parentsid); + DB db = new DB(); + try { + db.addSubject(sub); + } catch (SQLException e) { + e.printStackTrace(); + } + request.getRequestDispatcher("AdministratorHome.jsp").forward(request,response); + + + } + if (page.equals("edit")) { + String subject = request.getParameter("subject"); + + + request.setAttribute("subject", subject); + + request.getRequestDispatcher("AdministratorEdit.jsp").forward(request, response); + } + if(page.equals("delete")) + { + String i = request.getParameter("sid"); + + DB db = new DB(); + + try + { + db.deleteSubject(Integer.parseInt(i)); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + request.getRequestDispatcher("AdministratorHome.jsp").forward(request, response); + } + if (page.equals("edit-form")) { + String oldsubject = request.getParameter("oldsubject"); + + String newsubject = request.getParameter("newsubject"); + System.out.println("oldsubject"+oldsubject); + System.out.println("newsubject"+newsubject); + + Timestamp time = new Timestamp(System.currentTimeMillis()); + + + DB db = new DB(); + boolean checkstatus = false; + + try { + checkstatus = db.checksubject(newsubject); + } catch (SQLException e) { + e.printStackTrace(); + } + + if (checkstatus) { + //JOptionPane.showMessageDialog(null, "com.javaBean.Article Title is already exist please try anotherone ", "Info", JOptionPane.INFORMATION_MESSAGE); + + request.setAttribute("subject", oldsubject); + + request.getRequestDispatcher("AdministratorEdit.jsp").forward(request, response); + } else { + + + if (newsubject.length() > 30) { + //JOptionPane.showMessageDialog(null, "you have typed more than 100 letters in Highlights", "Info", JOptionPane.INFORMATION_MESSAGE); + request.getSession().setAttribute("info", "subject name长度不能超过30个字符"); + request.setAttribute("subject", oldsubject); + request.getRequestDispatcher("AuthorEdit.jsp").forward(request, response); + } else { + Subject s = new Subject(); + s.setOldsubject(oldsubject); + s.setSubject(newsubject); + s.setSdate(time); + + + try { + db.updateSubject(s); + } catch (SQLException e) { + e.printStackTrace(); + } + + request.getRequestDispatcher("AdministratorHome.jsp").forward(request, response); + } +// } else + + } + + } + + } + +} diff --git a/WZF_OAPS/src/main/java/com/javaBeans/AuthorController.java b/WZF_OAPS/src/main/java/com/javaBeans/AuthorController.java new file mode 100644 index 0000000..4849d95 --- /dev/null +++ b/WZF_OAPS/src/main/java/com/javaBeans/AuthorController.java @@ -0,0 +1,391 @@ +package com.javaBeans; + +import java.io.IOException; +import java.sql.SQLException; +import java.sql.Timestamp; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import javax.swing.JOptionPane; +import com.database.DB; +import com.javaBean.Administrator; +import com.javaBean.Article; +import com.javaBean.Author; + +/** + * Servlet implementation class com.javaBeans.AuthorController + */ +@WebServlet("/com.javaBeans.AuthorController") +public class AuthorController extends HttpServlet { + HttpSession session; + private static final long serialVersionUID = 1L; + + /** + * @see HttpServlet#HttpServlet() + */ + public AuthorController() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + String page = request.getParameter("page"); + + if(page == null) + { + request.getRequestDispatcher("AuthorHome.jsp").forward(request, response); + } + + else + { + doPost(request, response); + } + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + String page = request.getParameter("page"); + HttpSession session=request.getSession(); + + if(page.equals("admin")) + { + String email = request.getParameter("email"); + String password = request.getParameter("password"); + session.setAttribute("email",email); + Administrator a = new Administrator(); + a.setEmail(email); + a.setPassword(password); + + DB db = new DB(); + boolean status = false; + + try + { + status = db.checkAdministrator(a); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + if(status) + { + + +// request.setAttribute("email",email); + request.getRequestDispatcher("AuthorHome.jsp").forward(request, response); + } + + else + { + request.setAttribute("msg", "invalid"); + request.getRequestDispatcher("Author.jsp").forward(request, response); + } + } + + if(page.equals("register")) + { + request.getRequestDispatcher("AuthorRegister.jsp").forward(request, response); + } + + if(page.equals("register-form")) + { + String email = request.getParameter("email"); + String password = request.getParameter("password"); + String conpassword = request.getParameter("conpassword"); + + if(password.equals(conpassword)) + { + Author a = new Author(); + a.setEmail(email); + a.setPassword(password); + + DB db = new DB(); + + try + { + db.addAuthor(a); + session.setAttribute("email",email); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + request.getRequestDispatcher("Author.jsp").forward(request, response); + } + + else + { + request.getRequestDispatcher("AuthorRegister.jsp").forward(request, response); + } + } + + if(page.equals("home")) + { + String email = request.getParameter("email"); + request.setAttribute("email",email); + request.getRequestDispatcher("AuthorHome.jsp").forward(request, response); + } + + if(page.equals("logout")) + { + session.setAttribute("email",null); + request.getRequestDispatcher("Author.jsp").forward(request, response); + } + + if(page.equals("edit")) + { + String title = request.getParameter("title"); + String email = request.getParameter("email"); + + request.setAttribute("title", title); + request.setAttribute("email", email); + request.getRequestDispatcher("AuthorEdit.jsp").forward(request, response); + } + if (page.equals("hide")) + { + String title = request.getParameter("title"); + DB db = new DB(); + try { + db.hideArticle(title); + } catch (SQLException e) { + e.printStackTrace(); + } + request.getRequestDispatcher("AuthorHome.jsp").forward(request, response); + } + if (page.equals("show")) + { + String title = request.getParameter("title"); + DB db = new DB(); + try { + db.showArticle(title); + } catch (SQLException e) { + e.printStackTrace(); + } + request.getRequestDispatcher("AuthorHome.jsp").forward(request, response); + } + + if(page.equals("edit-form")) + { + String oldtitle = request.getParameter("old-title"); + + String title = request.getParameter("title"); + String highlights = request.getParameter("highlights"); + String abstracts = request.getParameter("abstracts"); + Timestamp time = new Timestamp(System.currentTimeMillis()); + + + DB db = new DB(); +/* boolean checkstatus = false; + + try + { + checkstatus = db.checktitle(title); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + if(checkstatus) + { + //JOptionPane.showMessageDialog(null, "com.javaBean.Article Title is already exist please try anotherone ", "Info", JOptionPane.INFORMATION_MESSAGE); + + request.setAttribute("title", title); + request.setAttribute("highlights", highlights); + request.setAttribute("abstracts", abstracts); + request.getRequestDispatcher("AuthorEdit.jsp").forward(request, response); + } + + else + { +*/ + + if(highlights.length() > 250) + { + //JOptionPane.showMessageDialog(null, "you have typed more than 250 letters in Highlights", "Info", JOptionPane.INFORMATION_MESSAGE); + request.getSession().setAttribute("info","highlight长度不能超过250个字符"); + request.setAttribute("title", oldtitle); + request.getRequestDispatcher("AuthorEdit.jsp").forward(request, response); + } + + else if(abstracts.length() > 999) + { + //JOptionPane.showMessageDialog(null, "you have typed more than 1000 letters in abstract", "Info", JOptionPane.INFORMATION_MESSAGE); + request.getSession().setAttribute("info","abstract长度不能超过999个字符"); + request.setAttribute("title", oldtitle); + request.getRequestDispatcher("AuthorEdit.jsp").forward(request, response); + } + + else + { + + Article a = new Article(); + a.setTitle(title); + a.setHighlights(highlights); + a.setAbstracts(abstracts); + a.setTime(time); + a.setOldtitle(oldtitle); + +// DB db = new DB(); + + try + { + db.updateArticle(a); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + request.getRequestDispatcher("AuthorHome.jsp").forward(request, response); + } +// } else + + } + + if(page.equals("delete")) + { + String title = request.getParameter("title"); + + DB db = new DB(); + + try + { + db.deleteArticle(title); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + request.getRequestDispatcher("AuthorHome.jsp").forward(request, response); + } + + +//---------------------------------------------------------------------------------------------- +// master function + + if(page.equals("master-home")) + { + request.getRequestDispatcher("Master.jsp").forward(request, response); + } + + if(page.equals("master-articles")) + { + request.getRequestDispatcher("MasterArticles.jsp").forward(request, response); + } + + if(page.equals("master-comments")) + { + request.getRequestDispatcher("Comments.jsp").forward(request, response); + } + + if(page.equals("master-authors")) + { + request.getRequestDispatcher("MasterAuthors.jsp").forward(request, response); + } + + if(page.equals("master-delete")) + { + String title = request.getParameter("title"); + + DB db = new DB(); + + try + { + db.deleteArticle(title); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + request.getRequestDispatcher("MasterArticles.jsp").forward(request, response); + } + + if(page.equals("master-view-article")) + { + String title = request.getParameter("title"); + + request.setAttribute("title", title); + request.getRequestDispatcher("MasterViewArticle.jsp").forward(request, response); + } + + if(page.equals("master-delete-comments")) + { + String comment = request.getParameter("comment"); + + DB db = new DB(); + + try + { + db.deleteComment(comment); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + request.getRequestDispatcher("Comments.jsp").forward(request, response); + } + + if(page.equals("master-block-author")) + { + String author = request.getParameter("author"); + + DB db = new DB(); + + try + { + db.blockAuthor(author); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + request.getRequestDispatcher("blocklist.jsp").forward(request, response); + } + + if(page.equals("master-release-author")) + { + String author = request.getParameter("author"); + + DB db = new DB(); + + try + { + db.releaseAuthor(author); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + request.getRequestDispatcher("MasterAuthors.jsp").forward(request, response); + } + + } + +} diff --git a/WZF_OAPS/src/main/java/com/javaBeans/Controller.java b/WZF_OAPS/src/main/java/com/javaBeans/Controller.java new file mode 100644 index 0000000..b4b304c --- /dev/null +++ b/WZF_OAPS/src/main/java/com/javaBeans/Controller.java @@ -0,0 +1,434 @@ +package com.javaBeans; +import com.database.DB; +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Timestamp; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * Servlet implementation class com.javaBeans.Controller + */ +@WebServlet("/com.javaBeans.Controller") +public class Controller extends HttpServlet { + private static final long serialVersionUID = 1L; + + /** + * @see HttpServlet#HttpServlet() + */ + public Controller() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + String page = request.getParameter("page"); + + if(page == null || page.equals("home")) + { + request.getRequestDispatcher("index.jsp").forward(request, response); + } + + else + { + doPost(request, response); + } + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + String page = request.getParameter("page"); + + + if(page.equals("like")||page.equals("dislike")) + { + String ip = request.getRemoteAddr(); + String title = request.getParameter("title"); + + int a = -1; + if(page.equals("like")) + { + a=1; + } + else if(page.equals("dislike")) + { + a=0; + } + DB db = new DB(); + boolean status = false; + + try + { +// status = db.check_popular(ip, title, a); + db.check_popular(ip, title, a); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + +// if(status) +// { + request.setAttribute("title", title); + request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); +// } +// +// else +// { +// JOptionPane.showMessageDialog(null, "You have already liked the article.", "Info", JOptionPane.INFORMATION_MESSAGE); +// +// request.setAttribute("title", title); +// request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); +// } + } + +// if(page.equals("dislike")) +// { +// String ip = request.getRemoteAddr(); +// String title = request.getParameter("title"); +// +// int a = 0; +// +// DB db = new DB(); +// boolean status = false; +// +// try +// { +//// status = db.check_popular(ip, title, a); +// db.check_popular(ip, title, a); +// } +// +// catch(SQLException e) +// { +// e.printStackTrace(); +// } +// +//// if(status) +//// { +// request.setAttribute("title", title); +// request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); +//// } +//// +//// else +//// { +//// JOptionPane.showMessageDialog(null, +//// "You have already disliked the article", "Info", JOptionPane.INFORMATION_MESSAGE); +//// +//// request.setAttribute("title", title); +//// request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); +//// } +// } +// + + if(page.equals("comments_like")||page.equals("comments_dislike")) + { + int a=-1; + String title = request.getParameter("title"); + String ip = request.getRemoteAddr(); + int id = Integer.parseInt(request.getParameter("id")); + if(page.equals("comments_like")) + { + a = 1; + } + else if(page.equals("comments_dislike")) + { + a=0; + } + + + DB db = new DB(); + boolean status = false; + + try + { +// status = db.check_comments_popular(ip, id, a); + db.check_comments_popular(ip, id, a); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + +// if(status) +// { + request.setAttribute("title", title); + request.setAttribute("id", id); + request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); +// } +// +// else +// { +// JOptionPane.showMessageDialog(null, "You have already liked the comment.", "Info", JOptionPane.INFORMATION_MESSAGE); + +// request.setAttribute("title", title); +// request.setAttribute("id", id); +// request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); +// } + } + +// if(page.equals("comments_dislike")) +// { +// String title = request.getParameter("title"); +// String ip = request.getRemoteAddr(); +// int id = Integer.parseInt(request.getParameter("id")); +// +// int a = 0; +// +// DB db = new DB(); +// boolean status = false; +// +// try +// { +//// status = db.check_comments_popular(ip, id, a); +// db.check_comments_popular(ip, id, a); +// } +// +// catch(SQLException e) +// { +// e.printStackTrace(); +// } +// +//// if(status) +//// { +// request.setAttribute("title", title); +// request.setAttribute("id", id); +// request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); +//// } +//// +//// else +//// { +//// JOptionPane.showMessageDialog(null, "You have already disliked the comment", "Info", JOptionPane.INFORMATION_MESSAGE); +//// +//// request.setAttribute("title", title); +//// request.setAttribute("id", id); +//// request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); +//// } +// +// } + + if(page.equals("administrator")) + { + if (request.getSession().getAttribute("admin_login")!=null) + { + request.getRequestDispatcher("AdministratorHome.jsp").forward(request, response); + + } + else { + request.getRequestDispatcher("Administrator.jsp").forward(request, response); + } + } + if(page.equals("home")) + { + request.getRequestDispatcher("index.jsp").forward(request, response); + } + + if(page.equals("aboutus")) + { + request.getRequestDispatcher("Aboutus.jsp").forward(request, response); + } + + if(page.equals("contact")) + { + request.getRequestDispatcher("Contact.jsp").forward(request, response); + } + + if(page.equals("admin")) + { + + if (request.getSession().getAttribute("admin_login")!=null) + { + request.getRequestDispatcher("AuthorHome.jsp").forward(request, response); + + } + else + { + request.getRequestDispatcher("Author.jsp").forward(request, response); + } + + } + + if(page.equals("select")) + { + String option = request.getParameter("option"); + + if(option.equals("Articles")) + { + request.getRequestDispatcher("Articles.jsp").forward(request, response); + } + + if(option.equals("Comments")) + { + request.getRequestDispatcher("Comments.jsp").forward(request, response); + } + } + + if(page.equals("search")) + { + String search2 = request.getParameter("search2"); + + request.setAttribute("search2", search2); + request.getRequestDispatcher("Search.jsp").forward(request, response); + } + + if(page.equals("subject")) + { + String subject = request.getParameter("id"); + + request.setAttribute("subject", subject); + + request.getRequestDispatcher("NewFile.jsp").forward(request, response); +// response.sendRedirect("NewFile.jsp"); + } + + if(page.equals("post-article")) + { + String subject = request.getParameter("subject"); + String email = request.getParameter("email"); + String authorName = request.getParameter("authorName"); + + + boolean status = false; + DB db = new DB(); + + try + { + status = db.checkblockauthor(email); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + if(status) + { + //JOptionPane.showMessageDialog(null, "Sorry you have been blcoked, please contact Author", "Info", JOptionPane.INFORMATION_MESSAGE); + + request.setAttribute("subject", subject); + request.getRequestDispatcher("NewFile.jsp").forward(request, response); + } + + else + { + request.setAttribute("subject", subject); + request.setAttribute("email", email); + request.setAttribute("authorName", authorName); + request.getRequestDispatcher("PostArticle.jsp").forward(request, response); + } + + } + + if(page.equals("view-article")) + { + String title = request.getParameter("title"); + String aid = request.getParameter("id"); + String ip = request.getRemoteAddr(); + DB db = new DB(); + try { + db.addVisit(aid,ip); + } catch (SQLException e) { + e.printStackTrace(); + } + request.setAttribute("title", title); + request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); + } + + if(page.equals("admin-view-article")) + { + String title = request.getParameter("title"); + + request.setAttribute("title", title); + request.getRequestDispatcher("AuthorViewArticle.jsp").forward(request, response); + } + + if(page.equals("comment-post")) + { + + String email = request.getParameter("email"); + String comment = request.getParameter("comment"); + String title = request.getParameter("title"); + Timestamp time = new Timestamp(System.currentTimeMillis()); + + String comment2 = comment.toLowerCase(); + if(comment.length()>10000) + { + request.setAttribute("title", title); + request.setAttribute("msg","The length of comment can not exceed 10000 characters!"); + } + else if (comment2.contains("fuck") || comment2.contains("motherfucker") || comment2.contains("nigga") || comment2.contains("bitch") + || comment2.contains("idiot") || comment2.contains("stupid") || comment2.contains("dick") || comment2.contains("boobs") || comment2.contains("pussy") || comment2.contains("suck")) { +// System.out.println("illegal"); + + request.setAttribute("title", title); + request.setAttribute("msg", "using improper words, please use proper words"); + + } else { + + + try { + String root = "wzf"; + String password = "wzf"; + String url = "jdbc:mysql://47.115.56.157:3306/oo?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8"; + String driver = "com.mysql.jdbc.Driver"; + Connection con; + + Class.forName(driver); + + String sql = "insert into comments (title, user, comment, time) values (?,?,?,?)"; + + con = DriverManager.getConnection(url, root, password); + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, title); + ps.setString(2, email); + ps.setString(3, comment); + ps.setTimestamp(4, time); + + ps.executeUpdate(); + + } catch (ClassNotFoundException e1) { + e1.printStackTrace(); + } catch (SQLException e) { + e.printStackTrace(); + } + +// System.out.println(email); +// System.out.println(comment); +// System.out.println(title); +// System.out.println(time); + + request.setAttribute("title", title); + + + } + request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); + + } + + if(page.equals("authorarticle")) + { + String author = request.getParameter("author"); + + request.setAttribute("author", author); + request.getRequestDispatcher("AuthorArticle.jsp").forward(request, response); + } + + } + +} diff --git a/WZF_OAPS/src/main/java/com/javaBeans/DownloadServlet.java b/WZF_OAPS/src/main/java/com/javaBeans/DownloadServlet.java new file mode 100644 index 0000000..6c03c63 --- /dev/null +++ b/WZF_OAPS/src/main/java/com/javaBeans/DownloadServlet.java @@ -0,0 +1,156 @@ +package com.javaBeans; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintWriter; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + + +/** + * Servlet implementation class com.javaBeans.DownloadServlet + */ +@WebServlet("/com.javaBeans.DownloadServlet") +public class DownloadServlet extends HttpServlet { + + public static int BUFFER_SIZE = 1024*100; + public static final String UPLOAD_DIR = "resources"; + public static String fn = null; + + private static final long serialVersionUID = 1L; + + + public DownloadServlet() + { + super(); + + } + + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + +// fn = request.getParameter("fileName"); + +// response.setContentType("text/plain;charset=UTF-8"); + + PrintWriter out = response.getWriter(); + String filename = request.getParameter("fileName"); + String filepath = request.getServletContext().getRealPath("")+ UPLOAD_DIR+ File.separator; + response.setContentType("APPLICATION/OCTET-STREAM"); + response.setHeader("Content-Disposition","attachment; filename=\"" + filename + "\""); + + System.out.println(filename); + System.out.println(filepath); + + //use inline if you want to view the content in browser, helpful for pdf file + //response.setHeader("Content-Disposition","inline; filename=\"" + filename + "\""); + FileInputStream fileInputStream = new FileInputStream(filepath + filename); + + int i; + while ((i=fileInputStream.read()) != -1) { + out.write(i); + } + fileInputStream.close(); + out.close(); + } + + +/* if(fn.equals("") || fn == null) + { + response.setContentType("text/html"); + response.getWriter().println("File : " +fn+" is not exist "); + } + + else + { + String serverpath = request.getServletContext().getRealPath(""); + String downloadPath = serverpath + UPLOAD_DIR; + String filepath = downloadPath + File.separator + fn; + + System.out.println(fn); + System.out.println(filepath); + System.out.println("filename:" +fn); + System.out.println("filepath:" +filepath); + + File file = new File(filepath); + + OutputStream os = null; + FileInputStream is = null; + + if(file.exists()) + { + String mimetype ="APPLICATION/OCTET-STREAM"; + response.setContentType(mimetype); + + String headerKey = "Content-Disposition"; + String headervalue = String.format("attachment; filename=\""+fn+"\""); + response.setHeader(headerKey, headervalue); + + try + { + os = response.getOutputStream(); + is = new FileInputStream(file); + + int i; + + while ((i=is.read()) != -1) + { + out.write(i); + } + + is.close(); + out.close(); + + byte[] buffer = new byte[BUFFER_SIZE]; + int bytesread = -1; + + while((bytesread = is.read(buffer)) != -1) + { + os.write(buffer, 0, bytesread); + } + } + + catch(IOException e) + { + System.out.println("exception while performe: " +e.getMessage()); + } + + finally + { + if(is != null) + { + is.close(); + } + + os.flush(); + + if(os != null) + { + os.close(); + } + } + } + + else + { + response.setContentType("text/html"); + + response.getWriter().println("file: "+fn+" not exist"); + } + } + + } +*/ + + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + + } + +} diff --git a/WZF_OAPS/src/main/java/com/javaBeans/UploadServlet.java b/WZF_OAPS/src/main/java/com/javaBeans/UploadServlet.java new file mode 100644 index 0000000..2103edd --- /dev/null +++ b/WZF_OAPS/src/main/java/com/javaBeans/UploadServlet.java @@ -0,0 +1,220 @@ +package com.javaBeans; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.sql.*; +import javax.servlet.ServletException; +import javax.servlet.annotation.MultipartConfig; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import javax.servlet.http.Part; + + +import com.database.DB; +/** + * Servlet implementation class com.javaBeans.UploadServlet + */ +@WebServlet("/com.javaBeans.UploadServlet") +@MultipartConfig(fileSizeThreshold = 1024 * 1024 * 10, + maxFileSize = 1024 * 1024 * 1000, + maxRequestSize = 1024 * 1024 * 1000) +public class UploadServlet extends HttpServlet { + + PrintWriter out = null; + Connection con = null; + PreparedStatement ps = null; + HttpSession session = null; + + private static final long serialVersionUID = 1L; + + /** + * @see HttpServlet#HttpServlet() + */ + public UploadServlet() { + super(); + // TODO Auto-generated constructor stub + } + + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + } + + + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + Part filePart = request.getPart("file"); + response.setContentType("text/plain;charset=UTF-8"); + String author = request.getParameter("author"); + String subject = request.getParameter("subject"); + String title = request.getParameter("title"); + String highlights = request.getParameter("highlights"); + String abstracts = request.getParameter("abstracts"); + String authorName = request.getParameter("authorName"); + String ip = request.getRemoteAddr(); + request.setAttribute("email", author); + request.setAttribute("subject", subject); + request.setAttribute("title", title); + request.setAttribute("highlights", highlights); + request.setAttribute("abstracts", abstracts); + request.setAttribute("authorName", authorName); + DB db = new DB(); + boolean checkstatus = false; + + try { + checkstatus = db.checktitle(title); + } catch (SQLException e) { + e.printStackTrace(); + } +// response.setContentType("text/plain;charset=UTF-8"); + if (checkstatus) { + request.getSession().setAttribute("suggestion", "已经存在的article title,不能重复发布哦"); + //JOptionPane.showMessageDialog(null, "The article title already exists.\nPlease use another one. ", "Info", JOptionPane.INFORMATION_MESSAGE); + +// request.setAttribute("email", author); +// request.setAttribute("subject", subject); +// request.setAttribute("title", title); +// request.setAttribute("highlights", highlights); +// request.setAttribute("abstracts", abstracts); + request.getRequestDispatcher("PostArticle.jsp").forward(request, response); + } else { + +// --------------------------------------------------------------------------------------------------------------- + + + try { + out = response.getWriter(); + session = request.getSession(false); + + String folderName = "resources"; + String uploadPath = request.getServletContext().getRealPath("") + folderName; + + File dir = new File(uploadPath); + + if (!dir.exists()) { + dir.mkdir(); + } + + Timestamp time = new Timestamp(System.currentTimeMillis()); + +// response.setContentType("application/octet-stream"); +// Part filePart = request.getPart("file"); + String fileType = filePart.getContentType();// get the uploaded file type +// String fileName = filePart.getSubmittedFileName(); + String cd = filePart.getHeader("Content-Disposition"); + String fileName = cd.substring(cd.lastIndexOf("=") + 2, cd.length() - 1); + String path = folderName + File.separator + fileName; + + + + // if the uploaded file type is PDF, then upload the file to the server + if (fileType.equals("application/pdf")) { +// + File file = new File(uploadPath+File.separator + fileName); + System.out.println(file.length()/(1024.0*1024)); + if (file.length()/(1024.0*1024)>20) + { + request.setAttribute("suggestion","The size of file can not exceed 20MB"); + request.getRequestDispatcher("PostArticle.jsp").forward(request, response); + } + else { + + + InputStream is = filePart.getInputStream(); + Files.copy(is, Paths.get(uploadPath + File.separator + fileName), StandardCopyOption.REPLACE_EXISTING); + + try { + Class.forName("com.mysql.jdbc.Driver"); + + String u = "wzf"; + String password = "wzf"; + String ul = "jdbc:mysql://47.115.56.157:3306/oo?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8"; + + con = DriverManager.getConnection(ul, u, password); + String sql0="select sid from subject where subject=?"; + ps = con.prepareStatement(sql0); + ps.setString(1,subject); + ResultSet resultSet = ps.executeQuery(); + int sid=0; + if (resultSet.next()) + { + sid = resultSet.getInt("sid"); + } + + String sql = "insert into article(sid, title, highlight, abstracts, author, time, filename, path,hide,authorName,ip) values (?,?,?,?,?,?,?,?,?,?,?)"; + + ps = con.prepareStatement(sql); + + ps.setInt(1, sid); + ps.setString(2, title); + ps.setString(3, highlights); + ps.setString(4, abstracts); + ps.setString(5, author); + ps.setTimestamp(6, time); + ps.setString(7, fileName); + ps.setString(8, path); + ps.setString(9,"No"); + ps.setString(10,authorName); + ps.setString(11,ip); + + int status = ps.executeUpdate(); + + + if (status > 0) { + session.setAttribute("fileName", fileName); + String msg = "" + fileName + " upload successfully"; + request.setAttribute("msg", msg); + + + request.setAttribute("subject", subject); + request.getRequestDispatcher("NewFile.jsp").forward(request, response); + + } + + } catch (SQLException | ClassNotFoundException e) { + System.out.println(e); + } finally { + try { + if (ps != null) { + ps.close(); + } + + if (con != null) { + con.close(); + } + } catch (SQLException e) { + out.println(e); + } + } + } + + } else { + // if the uploaded file type is not PDF, show an alert message + +// JOptionPane.showMessageDialog(null, "Unsupported file format!.\nOnly PDF files are supported. ", "Info", JOptionPane.INFORMATION_MESSAGE); + +// request.setAttribute("email", author); +// request.setAttribute("subject", subject); +// request.setAttribute("title", title); +// request.setAttribute("highlights", highlights); +// request.setAttribute("abstracts", abstracts); + request.setAttribute("suggestion","Unsupported file format!.\nOnly PDF files are supported."); + request.getRequestDispatcher("PostArticle.jsp").forward(request, response); + + } + + + } catch (IOException | ServletException e) { + out.println(e); + } + } + + } + +} diff --git a/WZF_OAPS/src/main/webapp/Aboutus.jsp b/WZF_OAPS/src/main/webapp/Aboutus.jsp new file mode 100644 index 0000000..cba87f3 --- /dev/null +++ b/WZF_OAPS/src/main/webapp/Aboutus.jsp @@ -0,0 +1,133 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +About us + + + + + + +
+ +
+
团队成员:吴钟富,唐震,卓晨曦,庄梓淇
+ + + + diff --git a/WZF_OAPS/src/main/webapp/AddSubject.jsp b/WZF_OAPS/src/main/webapp/AddSubject.jsp new file mode 100644 index 0000000..8a6b501 --- /dev/null +++ b/WZF_OAPS/src/main/webapp/AddSubject.jsp @@ -0,0 +1,99 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %> + + + + + Insert title here + + + + + + + +
+

Welcome Administrator

+ +
+ + +

${info}

+
+ + + + + + + + + + + + + +
+ +
+ +<%----%> + + + + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/Administrator.jsp b/WZF_OAPS/src/main/webapp/Administrator.jsp new file mode 100644 index 0000000..95b33be --- /dev/null +++ b/WZF_OAPS/src/main/webapp/Administrator.jsp @@ -0,0 +1,166 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + + + + Admin + + + + + + +
+ +
+ + +
+ + + + + + + + +

Admin Login

Apply for administrator account
+
+

${advice}

+ + + + + + diff --git a/WZF_OAPS/src/main/webapp/AdministratorEdit.jsp b/WZF_OAPS/src/main/webapp/AdministratorEdit.jsp new file mode 100644 index 0000000..da0ba40 --- /dev/null +++ b/WZF_OAPS/src/main/webapp/AdministratorEdit.jsp @@ -0,0 +1,122 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %> + + + + + Insert title here + + + + + + + +
+

Welcome Administrator

+ +
+ + + +<%----%> +<%----%> + <%--select * from subject where subject='<%= request.getAttribute("subject")%>'--%> +<%----%> + +<%----%> + +

${info}

+
+ + "> + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current Subject Name
" readonly style="background:lightgray">
New Subject Name
+ +
+ +<%--
--%> + +
+ 2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/AdministratorHome.jsp b/WZF_OAPS/src/main/webapp/AdministratorHome.jsp new file mode 100644 index 0000000..841d1b2 --- /dev/null +++ b/WZF_OAPS/src/main/webapp/AdministratorHome.jsp @@ -0,0 +1,131 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> + + + + + + Author Home + + + + + + + + + select * from subject order by parentsid + + +
+

Admin Subject

+ +
+ + + +
+ + + + + + + + + + + + + + + + + + + +
SubjectIdNameParentIdLastModificationTime
edit || + delete + + || + AddChildSubject + + +
+
+ +
+ 2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/Articles.jsp b/WZF_OAPS/src/main/webapp/Articles.jsp new file mode 100644 index 0000000..9f52d54 --- /dev/null +++ b/WZF_OAPS/src/main/webapp/Articles.jsp @@ -0,0 +1,177 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> + + + + +Articles + + + + + + +
+ +
+ + + + +select * from article a , subject s where a.sid=s.sid and hide="No" + + +
+ + + + + + + + + + + + + + select * from visit where aid="${ row.aid}"; + + + + + + + + + + +
TitleAuthorTimePopularity
+
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/Author.jsp b/WZF_OAPS/src/main/webapp/Author.jsp new file mode 100644 index 0000000..8b2c032 --- /dev/null +++ b/WZF_OAPS/src/main/webapp/Author.jsp @@ -0,0 +1,165 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + + + +Admin + + + + + + +
+ +
+ + +
+ + + + + + + + +

Admin Login

register
+
+

${advice}

+ + +
+2020 copyright©Wu Zhongfu +
+ + + diff --git a/WZF_OAPS/src/main/webapp/AuthorArticle.jsp b/WZF_OAPS/src/main/webapp/AuthorArticle.jsp new file mode 100644 index 0000000..fe2adbb --- /dev/null +++ b/WZF_OAPS/src/main/webapp/AuthorArticle.jsp @@ -0,0 +1,181 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> + + + + + +Author Article + + + + + + +
+ +
+ + + + +select * from article a , subject s where a.sid=s.sid and author = '${ author}' and hide!="Yes" + + +
+ + + + + + + + + + + + + + + + + + select * from visit where aid="${ row.aid}"; + + + + + + + + + +
AuthorSubjectTitleTimePopularityDownLoad
Download
+
+ + +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/AuthorEdit.jsp b/WZF_OAPS/src/main/webapp/AuthorEdit.jsp new file mode 100644 index 0000000..6bb92c6 --- /dev/null +++ b/WZF_OAPS/src/main/webapp/AuthorEdit.jsp @@ -0,0 +1,134 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %> + + + + + Insert title here + + + + + + + +
+

Welcome Author

+ +
+ + + + + + select * from article a , subject s where a.sid=s.sid and title='<%= request.getAttribute("title")%>' + + + + +

${info}

+
+ + "> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current Subject
" readonly style="background:lightgray">
Title
" placeholder="Enter title" required>
Highlights
" placeholder="Enter highlights" required>
Abstract
" placeholder="Enter abstract" required>
+
+ +
+ +
+ 2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/AuthorHome.jsp b/WZF_OAPS/src/main/webapp/AuthorHome.jsp new file mode 100644 index 0000000..fcdcd08 --- /dev/null +++ b/WZF_OAPS/src/main/webapp/AuthorHome.jsp @@ -0,0 +1,130 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> + + + + +Author Home + + + + + + + + + select * from article a , subject s where a.sid=s.sid + +
+

Admin Article

+ +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
SubjectTitleHighlightHideOption
edit || + delete|| + show|| + hide +
+
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/AuthorRegister.jsp b/WZF_OAPS/src/main/webapp/AuthorRegister.jsp new file mode 100644 index 0000000..e6e57f6 --- /dev/null +++ b/WZF_OAPS/src/main/webapp/AuthorRegister.jsp @@ -0,0 +1,171 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + + +Author Register + + + + + + +
+ +
+ + +
+ + + + + + + + + + + +

Registration

email
password
confirm password
+
+ + +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/Comments.jsp b/WZF_OAPS/src/main/webapp/Comments.jsp new file mode 100644 index 0000000..857f39e --- /dev/null +++ b/WZF_OAPS/src/main/webapp/Comments.jsp @@ -0,0 +1,170 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> + + + + + +Comments + + + + + + +
+ +
+ + + + +select * from comments + + +
+ + + + + + + + + + + + + + + +
TitleUserCommentTime
+
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/Contact.jsp b/WZF_OAPS/src/main/webapp/Contact.jsp new file mode 100644 index 0000000..7a16727 --- /dev/null +++ b/WZF_OAPS/src/main/webapp/Contact.jsp @@ -0,0 +1,113 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +Contact + + + + + + +
+ +
+ + +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/Master.jsp b/WZF_OAPS/src/main/webapp/Master.jsp new file mode 100644 index 0000000..8a9393a --- /dev/null +++ b/WZF_OAPS/src/main/webapp/Master.jsp @@ -0,0 +1,64 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +Master Author + + + + + + + +
+

Welcome Author

+ +
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/MasterArticles.jsp b/WZF_OAPS/src/main/webapp/MasterArticles.jsp new file mode 100644 index 0000000..f4cb794 --- /dev/null +++ b/WZF_OAPS/src/main/webapp/MasterArticles.jsp @@ -0,0 +1,125 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> + + + + + +Master Articles + + + + + + + +
+

Welcome Author

+ +
+ + + + +select * from article a,subject s where a.sid=c.sid + + +
+ + + + + + + + + + + + + + + +
TitleAuthorTimeOption
delete
+
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/MasterAuthors.jsp b/WZF_OAPS/src/main/webapp/MasterAuthors.jsp new file mode 100644 index 0000000..96b142e --- /dev/null +++ b/WZF_OAPS/src/main/webapp/MasterAuthors.jsp @@ -0,0 +1,123 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> + + + + + +Master Author + + + + + + + +
+

Welcome Author

+ +
+ + + + +select author from article where author not in (select email from block_author) + + +
+ + + + + + + + + + + + +
AuthorOption
block
+
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/MasterComments.jsp b/WZF_OAPS/src/main/webapp/MasterComments.jsp new file mode 100644 index 0000000..6351b7a --- /dev/null +++ b/WZF_OAPS/src/main/webapp/MasterComments.jsp @@ -0,0 +1,64 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +Master Comments + + + + + + + +
+

Welcome Author

+ +
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/MasterViewArticle.jsp b/WZF_OAPS/src/main/webapp/MasterViewArticle.jsp new file mode 100644 index 0000000..ee9ce27 --- /dev/null +++ b/WZF_OAPS/src/main/webapp/MasterViewArticle.jsp @@ -0,0 +1,130 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> + + + + + + +Master View Article + + + + + + + +
+

Welcome Author

+ +
+ + + + +select * from article a , subject s where a.sid=s.sid and title="${ title}"; + + +
+ + + + + + + + + + + + + + + + + +

Abstract
Highlight
Publication Date
+
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/NewFile.jsp b/WZF_OAPS/src/main/webapp/NewFile.jsp new file mode 100644 index 0000000..9aa7278 --- /dev/null +++ b/WZF_OAPS/src/main/webapp/NewFile.jsp @@ -0,0 +1,225 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> + + + + +NewFile + + + + + + +
+ +
+ +
+ + + + + + + +

You are in

+
+ + + + +select * from article a , subject s where a.sid=s.sid and subject='<%=request.getAttribute("subject") %>' and hide="No" + + +
+ + + + + + + + + + + + + + + select * from visit where aid="${ row.aid}"; + + + + + + + + + + + +
TitleAuthorTimePopularity
+
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/PostArticle.jsp b/WZF_OAPS/src/main/webapp/PostArticle.jsp new file mode 100644 index 0000000..0939da6 --- /dev/null +++ b/WZF_OAPS/src/main/webapp/PostArticle.jsp @@ -0,0 +1,193 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + + + + +Post Articles + + + + + + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

${suggestion}

Current Subject
" readonly style="background:lightgray">
Author's email
" readonly style="background:lightgray">
Author's Name
" readonly style="background:lightgray">
Title
Highlights
Abstract
+
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/Search.jsp b/WZF_OAPS/src/main/webapp/Search.jsp new file mode 100644 index 0000000..f3d7293 --- /dev/null +++ b/WZF_OAPS/src/main/webapp/Search.jsp @@ -0,0 +1,262 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> + + + + + +Search + + + + + + +
+ +
+ + + + +select * from article a , subject s where a.sid=s.sid and hide="No" and (title like '%<%=request.getAttribute("search2") %>%' or title like '%<%=request.getAttribute("search2").toString().trim() %>%' or abstracts like '%<%=request.getAttribute("search2") %>%' or abstracts like '%<%=request.getAttribute("search2").toString().trim() %>%' or highlight like '%<%=request.getAttribute("search2") %>%' or highlight like '%<%=request.getAttribute("search2").toString().trim() %>%') order by time desc + + + + select * from article a , subject s where a.sid=s.sid and hide="No" order by time desc + + +<% if (request.getAttribute("search2")!=null){%> +
+ + + + + + + + + + + + + + + + + select * from visit where aid="${ row.aid}"; + + + + + + + + + + +
SubjectTitleAuthor EmailTimePopularity
+
+ +

+<%}else{%> +
+ + + + + + + + + + + + + + + + + select * from visit where aid="${ row3.aid}"; + + + + + + + + + + +
SubjectTitleAuthor EmailTimePopularity
+
+<%}%> + + +select * from comments where comment like '%<%=request.getAttribute("search2") %>%' or comment like '%<%=request.getAttribute("search2").toString().trim()%>%' order by time desc + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
TitleCommentTimeAuthor
+
+ + +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/ViewArticle.jsp b/WZF_OAPS/src/main/webapp/ViewArticle.jsp new file mode 100644 index 0000000..d035aaa --- /dev/null +++ b/WZF_OAPS/src/main/webapp/ViewArticle.jsp @@ -0,0 +1,416 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> + + + + + +${title} + + + + + + + +
+ +
+ + + + +select * from article a , subject s where a.sid=s.sid and title="${ title}"; + + +<%---------------------------------------------------------------------- --%> + + +select * from love_article where prefer=1 and title="${ title}"; + + + + + + + + +<%---------------------------------------------------------------------- --%> + + +select * from love_article where prefer=0 and title="${ title}"; + + + + + + + +

+
+ + + + + + + + + + + + + + + + + + + + + + + + +

Author
Abstract
Highlight
Publication Date
Author Email
+
+ + + + +
+
+ + + + +
+Download +
+
+ +
+ +
+ + + + + + + +
+
+ +
+ + +select * from comments where title="${ title}" + + +<%---------------------------------------------------------------------- --%> +<%-- This block is the comment box, where the comment, user, and time are + going to be displayed. + --%> + + +
+ + + + + + + +

+ + + + + +select * from love_comment where prefer=1 and cid="${ row.id}"; + + + + + + + + +
+ + + + + +
+ + + + + +select * from love_comment where prefer=0 and cid="${ row.id}"; + + + + + + + + + +
+ + + + + +
+ + + +
+
+ +

+ +
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/WEB-INF/web.xml b/WZF_OAPS/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..1418e5b --- /dev/null +++ b/WZF_OAPS/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,66 @@ + + + + OOAD + + index.jsp + + + Controller + com.javaBeans.Controller + + + Controller + /Controller + + + AuthorController + com.javaBeans.AuthorController + + + AuthorController + /AuthorController + + + AdministratorController + com.javaBeans.AdministorController + + + AdministratorController + /AdministratorController + + + UploadServlet + com.javaBeans.UploadServlet + + + UploadServlet + /UploadServlet + + + DownloadServlet + com.javaBeans.DownloadServlet + + + DownloadServlet + /DownloadServlet + + + + CharacterEncodingFilter + org.springframework.web.filter.CharacterEncodingFilter + + encoding + UTF-8 + + + + CharacterEncodingFilter + /* + + + diff --git a/WZF_OAPS/src/main/webapp/blocklist.jsp b/WZF_OAPS/src/main/webapp/blocklist.jsp new file mode 100644 index 0000000..19fafd8 --- /dev/null +++ b/WZF_OAPS/src/main/webapp/blocklist.jsp @@ -0,0 +1,123 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> + + + + + +Master Author + + + + + + + +
+

Block List

+ +
+ + + + +select email from block_author; + + +
+ + + + + + + + + + + + +
AuthorOption
release
+
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/index.jsp b/WZF_OAPS/src/main/webapp/index.jsp new file mode 100644 index 0000000..e2c4faa --- /dev/null +++ b/WZF_OAPS/src/main/webapp/index.jsp @@ -0,0 +1,200 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> + + + + + +Home + + + + + + +
+ +
+ + + + + select * from subject where parentsid=0 + + +
+
+
+
+ + <%----%> + <%--select * from article a , subject s where a.sid=s.sid and subject="${s_row.subject}" and hide="No";--%> + <%-- --%> + + select * from subject where parentsid=${s_row.sid}; + + + + +
+ +
+ + select * from article a , subject s where a.sid=s.sid and subject="${row.subject}" and hide="No"; + + +
+
+
+
+<%--Computer Science--%> +<%----%> +<%--
--%> +<%--
--%> + +<%--Medical Science--%> +<%----%> +<%--
--%> +<%--
--%> + + +<%--Social Science--%> +<%----%> +<%--
--%> +<%--
--%> + +<%--Biological Science--%> +<%----%> +<%--
--%> +<%--
--%> + +<%--Mathematics--%> +<%----%> +<%--
--%> +<%--
--%> + +
+
+
+
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/src/main/webapp/style.css b/WZF_OAPS/src/main/webapp/style.css new file mode 100644 index 0000000..25dedef --- /dev/null +++ b/WZF_OAPS/src/main/webapp/style.css @@ -0,0 +1,69 @@ +@charset "UTF-8"; + +body +{ + margin:0px; +} + +header +{ + background-color:blue; + text-align:center; + height:70px; + margin-bottom:50px; +} + +header nav +{ + padding-top:20px; +} + +header a +{ + font-size:25px; + margin-left:25px; + text-decoration:none; + color:white; + cursor:default; +} + +header a:hover +{ + color:gold; +} + +header form +{ + display:inline-block; +} + +header select +{ + margin-left:25px; + font-size:25px; + border-radius:3px 3px 3px 3px; +} + +header button +{ + font-size:20px; + border-radius:5px 5px 5px 5px; +} + +header input +{ + margin-left:25px; + font-size:20px; + border-radius:3px 3px 3px 3px; +} + +footer +{ + background:dodgerblue; + height:40px; + color:white; + text-align:center; + padding:5px; + font-size:20px; + margin-top:50px; +} diff --git a/WZF_OAPS/src/main/webapp/success.jsp b/WZF_OAPS/src/main/webapp/success.jsp new file mode 100644 index 0000000..8cd981d --- /dev/null +++ b/WZF_OAPS/src/main/webapp/success.jsp @@ -0,0 +1,24 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + +Insert title here + + + + + + + + + + + +">download +<%--">list--%> + + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/Aboutus.jsp b/WZF_OAPS/target/WZF_OAPS/Aboutus.jsp new file mode 100644 index 0000000..cba87f3 --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/Aboutus.jsp @@ -0,0 +1,133 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +About us + + + + + + +
+ +
+
团队成员:吴钟富,唐震,卓晨曦,庄梓淇
+
+ 2020 copyright©Wu Zhongfu +
+ + + diff --git a/WZF_OAPS/target/WZF_OAPS/AddSubject.jsp b/WZF_OAPS/target/WZF_OAPS/AddSubject.jsp new file mode 100644 index 0000000..8a6b501 --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/AddSubject.jsp @@ -0,0 +1,99 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %> + + + + + Insert title here + + + + + + + +
+

Welcome Administrator

+ +
+ + +

${info}

+
+ + + + + + + + + + + + + +
+ +
+ +<%----%> + +
+ 2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/Administrator.jsp b/WZF_OAPS/target/WZF_OAPS/Administrator.jsp new file mode 100644 index 0000000..95b33be --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/Administrator.jsp @@ -0,0 +1,166 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + + + + Admin + + + + + + +
+ +
+ + +
+ + + + + + + + +

Admin Login

Apply for administrator account
+
+

${advice}

+ + +
+ 2020 copyright©Wu Zhongfu +
+ + + diff --git a/WZF_OAPS/target/WZF_OAPS/AdministratorEdit.jsp b/WZF_OAPS/target/WZF_OAPS/AdministratorEdit.jsp new file mode 100644 index 0000000..da0ba40 --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/AdministratorEdit.jsp @@ -0,0 +1,122 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %> + + + + + Insert title here + + + + + + + +
+

Welcome Administrator

+ +
+ + + +<%----%> +<%----%> + <%--select * from subject where subject='<%= request.getAttribute("subject")%>'--%> +<%----%> + +<%----%> + +

${info}

+
+ + "> + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current Subject Name
" readonly style="background:lightgray">
New Subject Name
+ +
+ +<%--
--%> + +
+ 2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/AdministratorHome.jsp b/WZF_OAPS/target/WZF_OAPS/AdministratorHome.jsp new file mode 100644 index 0000000..841d1b2 --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/AdministratorHome.jsp @@ -0,0 +1,131 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> + + + + + + Author Home + + + + + + + + + select * from subject order by parentsid + + +
+

Admin Subject

+ +
+ + + +
+ + + + + + + + + + + + + + + + + + + +
SubjectIdNameParentIdLastModificationTime
edit || + delete + + || + AddChildSubject + + +
+
+ +
+ 2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/Articles.jsp b/WZF_OAPS/target/WZF_OAPS/Articles.jsp new file mode 100644 index 0000000..9f52d54 --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/Articles.jsp @@ -0,0 +1,177 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> + + + + +Articles + + + + + + +
+ +
+ + + + +select * from article a , subject s where a.sid=s.sid and hide="No" + + +
+ + + + + + + + + + + + + + select * from visit where aid="${ row.aid}"; + + + + + + + + + + +
TitleAuthorTimePopularity
+
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/Author.jsp b/WZF_OAPS/target/WZF_OAPS/Author.jsp new file mode 100644 index 0000000..8b2c032 --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/Author.jsp @@ -0,0 +1,165 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + + + +Admin + + + + + + +
+ +
+ + +
+ + + + + + + + +

Admin Login

register
+
+

${advice}

+ + +
+2020 copyright©Wu Zhongfu +
+ + + diff --git a/WZF_OAPS/target/WZF_OAPS/AuthorArticle.jsp b/WZF_OAPS/target/WZF_OAPS/AuthorArticle.jsp new file mode 100644 index 0000000..fe2adbb --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/AuthorArticle.jsp @@ -0,0 +1,181 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> + + + + + +Author Article + + + + + + +
+ +
+ + + + +select * from article a , subject s where a.sid=s.sid and author = '${ author}' and hide!="Yes" + + +
+ + + + + + + + + + + + + + + + + + select * from visit where aid="${ row.aid}"; + + + + + + + + + +
AuthorSubjectTitleTimePopularityDownLoad
Download
+
+ + +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/AuthorEdit.jsp b/WZF_OAPS/target/WZF_OAPS/AuthorEdit.jsp new file mode 100644 index 0000000..6bb92c6 --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/AuthorEdit.jsp @@ -0,0 +1,134 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %> + + + + + Insert title here + + + + + + + +
+

Welcome Author

+ +
+ + + + + + select * from article a , subject s where a.sid=s.sid and title='<%= request.getAttribute("title")%>' + + + + +

${info}

+
+ + "> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current Subject
" readonly style="background:lightgray">
Title
" placeholder="Enter title" required>
Highlights
" placeholder="Enter highlights" required>
Abstract
" placeholder="Enter abstract" required>
+
+ +
+ +
+ 2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/AuthorHome.jsp b/WZF_OAPS/target/WZF_OAPS/AuthorHome.jsp new file mode 100644 index 0000000..fcdcd08 --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/AuthorHome.jsp @@ -0,0 +1,130 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> + + + + +Author Home + + + + + + + + + select * from article a , subject s where a.sid=s.sid + +
+

Admin Article

+ +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
SubjectTitleHighlightHideOption
edit || + delete|| + show|| + hide +
+
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/AuthorRegister.jsp b/WZF_OAPS/target/WZF_OAPS/AuthorRegister.jsp new file mode 100644 index 0000000..e6e57f6 --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/AuthorRegister.jsp @@ -0,0 +1,171 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + + +Author Register + + + + + + +
+ +
+ + +
+ + + + + + + + + + + +

Registration

email
password
confirm password
+
+ + +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/Comments.jsp b/WZF_OAPS/target/WZF_OAPS/Comments.jsp new file mode 100644 index 0000000..857f39e --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/Comments.jsp @@ -0,0 +1,170 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> + + + + + +Comments + + + + + + +
+ +
+ + + + +select * from comments + + +
+ + + + + + + + + + + + + + + +
TitleUserCommentTime
+
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/Contact.jsp b/WZF_OAPS/target/WZF_OAPS/Contact.jsp new file mode 100644 index 0000000..7a16727 --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/Contact.jsp @@ -0,0 +1,113 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +Contact + + + + + + +
+ +
+ + +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/META-INF/MANIFEST.MF b/WZF_OAPS/target/WZF_OAPS/META-INF/MANIFEST.MF new file mode 100644 index 0000000..6298c05 --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/META-INF/MANIFEST.MF @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +Created-By: IntelliJ IDEA +Built-By: lkm +Build-Jdk: 1.8.0_241 + diff --git a/WZF_OAPS/target/WZF_OAPS/Master.jsp b/WZF_OAPS/target/WZF_OAPS/Master.jsp new file mode 100644 index 0000000..8a9393a --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/Master.jsp @@ -0,0 +1,64 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +Master Author + + + + + + + +
+

Welcome Author

+ +
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/MasterArticles.jsp b/WZF_OAPS/target/WZF_OAPS/MasterArticles.jsp new file mode 100644 index 0000000..f4cb794 --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/MasterArticles.jsp @@ -0,0 +1,125 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> + + + + + +Master Articles + + + + + + + +
+

Welcome Author

+ +
+ + + + +select * from article a,subject s where a.sid=c.sid + + +
+ + + + + + + + + + + + + + + +
TitleAuthorTimeOption
delete
+
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/MasterAuthors.jsp b/WZF_OAPS/target/WZF_OAPS/MasterAuthors.jsp new file mode 100644 index 0000000..96b142e --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/MasterAuthors.jsp @@ -0,0 +1,123 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> + + + + + +Master Author + + + + + + + +
+

Welcome Author

+ +
+ + + + +select author from article where author not in (select email from block_author) + + +
+ + + + + + + + + + + + +
AuthorOption
block
+
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/MasterComments.jsp b/WZF_OAPS/target/WZF_OAPS/MasterComments.jsp new file mode 100644 index 0000000..6351b7a --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/MasterComments.jsp @@ -0,0 +1,64 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +Master Comments + + + + + + + +
+

Welcome Author

+ +
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/MasterViewArticle.jsp b/WZF_OAPS/target/WZF_OAPS/MasterViewArticle.jsp new file mode 100644 index 0000000..ee9ce27 --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/MasterViewArticle.jsp @@ -0,0 +1,130 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> + + + + + + +Master View Article + + + + + + + +
+

Welcome Author

+ +
+ + + + +select * from article a , subject s where a.sid=s.sid and title="${ title}"; + + +
+ + + + + + + + + + + + + + + + + +

Abstract
Highlight
Publication Date
+
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/NewFile.jsp b/WZF_OAPS/target/WZF_OAPS/NewFile.jsp new file mode 100644 index 0000000..9aa7278 --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/NewFile.jsp @@ -0,0 +1,225 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> + + + + +NewFile + + + + + + +
+ +
+ +
+ + + + + + + +

You are in

+
+ + + + +select * from article a , subject s where a.sid=s.sid and subject='<%=request.getAttribute("subject") %>' and hide="No" + + +
+ + + + + + + + + + + + + + + select * from visit where aid="${ row.aid}"; + + + + + + + + + + + +
TitleAuthorTimePopularity
+
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/PostArticle.jsp b/WZF_OAPS/target/WZF_OAPS/PostArticle.jsp new file mode 100644 index 0000000..0939da6 --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/PostArticle.jsp @@ -0,0 +1,193 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + + + + +Post Articles + + + + + + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

${suggestion}

Current Subject
" readonly style="background:lightgray">
Author's email
" readonly style="background:lightgray">
Author's Name
" readonly style="background:lightgray">
Title
Highlights
Abstract
+
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/Search.jsp b/WZF_OAPS/target/WZF_OAPS/Search.jsp new file mode 100644 index 0000000..f3d7293 --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/Search.jsp @@ -0,0 +1,262 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> + + + + + +Search + + + + + + +
+ +
+ + + + +select * from article a , subject s where a.sid=s.sid and hide="No" and (title like '%<%=request.getAttribute("search2") %>%' or title like '%<%=request.getAttribute("search2").toString().trim() %>%' or abstracts like '%<%=request.getAttribute("search2") %>%' or abstracts like '%<%=request.getAttribute("search2").toString().trim() %>%' or highlight like '%<%=request.getAttribute("search2") %>%' or highlight like '%<%=request.getAttribute("search2").toString().trim() %>%') order by time desc + + + + select * from article a , subject s where a.sid=s.sid and hide="No" order by time desc + + +<% if (request.getAttribute("search2")!=null){%> +
+ + + + + + + + + + + + + + + + + select * from visit where aid="${ row.aid}"; + + + + + + + + + + +
SubjectTitleAuthor EmailTimePopularity
+
+ +

+<%}else{%> +
+ + + + + + + + + + + + + + + + + select * from visit where aid="${ row3.aid}"; + + + + + + + + + + +
SubjectTitleAuthor EmailTimePopularity
+
+<%}%> + + +select * from comments where comment like '%<%=request.getAttribute("search2") %>%' or comment like '%<%=request.getAttribute("search2").toString().trim()%>%' order by time desc + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
TitleCommentTimeAuthor
+
+ + +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/ViewArticle.jsp b/WZF_OAPS/target/WZF_OAPS/ViewArticle.jsp new file mode 100644 index 0000000..d035aaa --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/ViewArticle.jsp @@ -0,0 +1,416 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> + + + + + +${title} + + + + + + + +
+ +
+ + + + +select * from article a , subject s where a.sid=s.sid and title="${ title}"; + + +<%---------------------------------------------------------------------- --%> + + +select * from love_article where prefer=1 and title="${ title}"; + + + + + + + + +<%---------------------------------------------------------------------- --%> + + +select * from love_article where prefer=0 and title="${ title}"; + + + + + + + +

+
+ + + + + + + + + + + + + + + + + + + + + + + + +

Author
Abstract
Highlight
Publication Date
Author Email
+
+ + + + +
+
+ + + + +
+Download +
+
+ +
+ +
+ + + + + + + +
+
+ +
+ + +select * from comments where title="${ title}" + + +<%---------------------------------------------------------------------- --%> +<%-- This block is the comment box, where the comment, user, and time are + going to be displayed. + --%> + + +
+ + + + + + + +

+ + + + + +select * from love_comment where prefer=1 and cid="${ row.id}"; + + + + + + + + +
+ + + + + +
+ + + + + +select * from love_comment where prefer=0 and cid="${ row.id}"; + + + + + + + + + +
+ + + + + +
+ + + +
+
+ +

+ +
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/database/DB.class b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/database/DB.class new file mode 100644 index 0000000..fcd194e Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/database/DB.class differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/filter/Filter_AdminLogin.class b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/filter/Filter_AdminLogin.class new file mode 100644 index 0000000..7896c5d Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/filter/Filter_AdminLogin.class differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBean/Administrator.class b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBean/Administrator.class new file mode 100644 index 0000000..60b84cf Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBean/Administrator.class differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBean/Article.class b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBean/Article.class new file mode 100644 index 0000000..4d61b9b Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBean/Article.class differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBean/Author.class b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBean/Author.class new file mode 100644 index 0000000..4613e37 Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBean/Author.class differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBean/Subject.class b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBean/Subject.class new file mode 100644 index 0000000..6ffed53 Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBean/Subject.class differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBeans/AdministorController.class b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBeans/AdministorController.class new file mode 100644 index 0000000..b52da27 Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBeans/AdministorController.class differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBeans/AuthorController.class b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBeans/AuthorController.class new file mode 100644 index 0000000..9e49679 Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBeans/AuthorController.class differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBeans/Controller.class b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBeans/Controller.class new file mode 100644 index 0000000..2ed0759 Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBeans/Controller.class differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBeans/DownloadServlet.class b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBeans/DownloadServlet.class new file mode 100644 index 0000000..fa6d4a4 Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBeans/DownloadServlet.class differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBeans/UploadServlet.class b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBeans/UploadServlet.class new file mode 100644 index 0000000..03fcae6 Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/classes/com/javaBeans/UploadServlet.class differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/commons-fileupload-1.3.jar b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/commons-fileupload-1.3.jar new file mode 100644 index 0000000..32f2360 Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/commons-fileupload-1.3.jar differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/commons-io-2.4.jar b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/commons-io-2.4.jar new file mode 100644 index 0000000..90035a4 Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/commons-io-2.4.jar differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/jstl-1.2.jar b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/jstl-1.2.jar new file mode 100644 index 0000000..0fd275e Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/jstl-1.2.jar differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/mysql-connector-java-5.1.32.jar b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/mysql-connector-java-5.1.32.jar new file mode 100644 index 0000000..f82dd98 Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/mysql-connector-java-5.1.32.jar differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-aop-5.0.5.RELEASE.jar b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-aop-5.0.5.RELEASE.jar new file mode 100644 index 0000000..74f8d71 Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-aop-5.0.5.RELEASE.jar differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-beans-5.0.5.RELEASE.jar b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-beans-5.0.5.RELEASE.jar new file mode 100644 index 0000000..7720693 Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-beans-5.0.5.RELEASE.jar differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-context-5.0.5.RELEASE.jar b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-context-5.0.5.RELEASE.jar new file mode 100644 index 0000000..9e846d4 Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-context-5.0.5.RELEASE.jar differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-core-5.0.5.RELEASE.jar b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-core-5.0.5.RELEASE.jar new file mode 100644 index 0000000..016a47b Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-core-5.0.5.RELEASE.jar differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-expression-5.0.5.RELEASE.jar b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-expression-5.0.5.RELEASE.jar new file mode 100644 index 0000000..80a30f6 Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-expression-5.0.5.RELEASE.jar differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-jcl-5.0.5.RELEASE.jar b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-jcl-5.0.5.RELEASE.jar new file mode 100644 index 0000000..c04f8ff Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-jcl-5.0.5.RELEASE.jar differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-web-5.0.5.RELEASE.jar b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-web-5.0.5.RELEASE.jar new file mode 100644 index 0000000..8233049 Binary files /dev/null and b/WZF_OAPS/target/WZF_OAPS/WEB-INF/lib/spring-web-5.0.5.RELEASE.jar differ diff --git a/WZF_OAPS/target/WZF_OAPS/WEB-INF/web.xml b/WZF_OAPS/target/WZF_OAPS/WEB-INF/web.xml new file mode 100644 index 0000000..1418e5b --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/WEB-INF/web.xml @@ -0,0 +1,66 @@ + + + + OOAD + + index.jsp + + + Controller + com.javaBeans.Controller + + + Controller + /Controller + + + AuthorController + com.javaBeans.AuthorController + + + AuthorController + /AuthorController + + + AdministratorController + com.javaBeans.AdministorController + + + AdministratorController + /AdministratorController + + + UploadServlet + com.javaBeans.UploadServlet + + + UploadServlet + /UploadServlet + + + DownloadServlet + com.javaBeans.DownloadServlet + + + DownloadServlet + /DownloadServlet + + + + CharacterEncodingFilter + org.springframework.web.filter.CharacterEncodingFilter + + encoding + UTF-8 + + + + CharacterEncodingFilter + /* + + + diff --git a/WZF_OAPS/target/WZF_OAPS/blocklist.jsp b/WZF_OAPS/target/WZF_OAPS/blocklist.jsp new file mode 100644 index 0000000..19fafd8 --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/blocklist.jsp @@ -0,0 +1,123 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> + + + + + +Master Author + + + + + + + +
+

Block List

+ +
+ + + + +select email from block_author; + + +
+ + + + + + + + + + + + +
AuthorOption
release
+
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/index.jsp b/WZF_OAPS/target/WZF_OAPS/index.jsp new file mode 100644 index 0000000..e2c4faa --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/index.jsp @@ -0,0 +1,200 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> + + + + + +Home + + + + + + +
+ +
+ + + + + select * from subject where parentsid=0 + + +
+
+
+
+ + <%----%> + <%--select * from article a , subject s where a.sid=s.sid and subject="${s_row.subject}" and hide="No";--%> + <%-- --%> + + select * from subject where parentsid=${s_row.sid}; + + + + +
+ +
+ + select * from article a , subject s where a.sid=s.sid and subject="${row.subject}" and hide="No"; + + +
+
+
+
+<%--Computer Science--%> +<%----%> +<%--
--%> +<%--
--%> + +<%--Medical Science--%> +<%----%> +<%--
--%> +<%--
--%> + + +<%--Social Science--%> +<%----%> +<%--
--%> +<%--
--%> + +<%--Biological Science--%> +<%----%> +<%--
--%> +<%--
--%> + +<%--Mathematics--%> +<%----%> +<%--
--%> +<%--
--%> + +
+
+
+
+ +
+2020 copyright©Wu Zhongfu +
+ + + \ No newline at end of file diff --git a/WZF_OAPS/target/WZF_OAPS/style.css b/WZF_OAPS/target/WZF_OAPS/style.css new file mode 100644 index 0000000..25dedef --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/style.css @@ -0,0 +1,69 @@ +@charset "UTF-8"; + +body +{ + margin:0px; +} + +header +{ + background-color:blue; + text-align:center; + height:70px; + margin-bottom:50px; +} + +header nav +{ + padding-top:20px; +} + +header a +{ + font-size:25px; + margin-left:25px; + text-decoration:none; + color:white; + cursor:default; +} + +header a:hover +{ + color:gold; +} + +header form +{ + display:inline-block; +} + +header select +{ + margin-left:25px; + font-size:25px; + border-radius:3px 3px 3px 3px; +} + +header button +{ + font-size:20px; + border-radius:5px 5px 5px 5px; +} + +header input +{ + margin-left:25px; + font-size:20px; + border-radius:3px 3px 3px 3px; +} + +footer +{ + background:dodgerblue; + height:40px; + color:white; + text-align:center; + padding:5px; + font-size:20px; + margin-top:50px; +} diff --git a/WZF_OAPS/target/WZF_OAPS/success.jsp b/WZF_OAPS/target/WZF_OAPS/success.jsp new file mode 100644 index 0000000..8cd981d --- /dev/null +++ b/WZF_OAPS/target/WZF_OAPS/success.jsp @@ -0,0 +1,24 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + +Insert title here + + + + + + + + + + + +">download +<%--">list--%> + + + \ No newline at end of file diff --git a/WZF_OAPS/target/classes/com/database/DB.class b/WZF_OAPS/target/classes/com/database/DB.class new file mode 100644 index 0000000..fcd194e Binary files /dev/null and b/WZF_OAPS/target/classes/com/database/DB.class differ diff --git a/WZF_OAPS/target/classes/com/filter/Filter_AdminLogin.class b/WZF_OAPS/target/classes/com/filter/Filter_AdminLogin.class new file mode 100644 index 0000000..7896c5d Binary files /dev/null and b/WZF_OAPS/target/classes/com/filter/Filter_AdminLogin.class differ diff --git a/WZF_OAPS/target/classes/com/javaBean/Administrator.class b/WZF_OAPS/target/classes/com/javaBean/Administrator.class new file mode 100644 index 0000000..60b84cf Binary files /dev/null and b/WZF_OAPS/target/classes/com/javaBean/Administrator.class differ diff --git a/WZF_OAPS/target/classes/com/javaBean/Article.class b/WZF_OAPS/target/classes/com/javaBean/Article.class new file mode 100644 index 0000000..4d61b9b Binary files /dev/null and b/WZF_OAPS/target/classes/com/javaBean/Article.class differ diff --git a/WZF_OAPS/target/classes/com/javaBean/Author.class b/WZF_OAPS/target/classes/com/javaBean/Author.class new file mode 100644 index 0000000..4613e37 Binary files /dev/null and b/WZF_OAPS/target/classes/com/javaBean/Author.class differ diff --git a/WZF_OAPS/target/classes/com/javaBean/Subject.class b/WZF_OAPS/target/classes/com/javaBean/Subject.class new file mode 100644 index 0000000..6ffed53 Binary files /dev/null and b/WZF_OAPS/target/classes/com/javaBean/Subject.class differ diff --git a/WZF_OAPS/target/classes/com/javaBeans/AdministorController.class b/WZF_OAPS/target/classes/com/javaBeans/AdministorController.class new file mode 100644 index 0000000..b52da27 Binary files /dev/null and b/WZF_OAPS/target/classes/com/javaBeans/AdministorController.class differ diff --git a/WZF_OAPS/target/classes/com/javaBeans/AuthorController.class b/WZF_OAPS/target/classes/com/javaBeans/AuthorController.class new file mode 100644 index 0000000..9e49679 Binary files /dev/null and b/WZF_OAPS/target/classes/com/javaBeans/AuthorController.class differ diff --git a/WZF_OAPS/target/classes/com/javaBeans/Controller.class b/WZF_OAPS/target/classes/com/javaBeans/Controller.class new file mode 100644 index 0000000..2ed0759 Binary files /dev/null and b/WZF_OAPS/target/classes/com/javaBeans/Controller.class differ diff --git a/WZF_OAPS/target/classes/com/javaBeans/DownloadServlet.class b/WZF_OAPS/target/classes/com/javaBeans/DownloadServlet.class new file mode 100644 index 0000000..fa6d4a4 Binary files /dev/null and b/WZF_OAPS/target/classes/com/javaBeans/DownloadServlet.class differ diff --git a/WZF_OAPS/target/classes/com/javaBeans/UploadServlet.class b/WZF_OAPS/target/classes/com/javaBeans/UploadServlet.class new file mode 100644 index 0000000..03fcae6 Binary files /dev/null and b/WZF_OAPS/target/classes/com/javaBeans/UploadServlet.class differ diff --git a/WebContent/Aboutus.jsp b/WebContent/Aboutus.jsp new file mode 100644 index 0000000..29ba1bd --- /dev/null +++ b/WebContent/Aboutus.jsp @@ -0,0 +1,113 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +About us + + + + + + +
+ +
+ +
+2019 copyright©mjh.mohamed +
+ + + diff --git a/WebContent/Admin.jsp b/WebContent/Admin.jsp new file mode 100644 index 0000000..8d4a5ff --- /dev/null +++ b/WebContent/Admin.jsp @@ -0,0 +1,169 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + + +Admin + + + + + + +
+ +
+ + +
+ + + + + + + + +

Admin Login

register
+
+ + +
+2019 copyright©mjh.mohamed +
+ + + diff --git a/WebContent/AdminEdit.jsp b/WebContent/AdminEdit.jsp new file mode 100644 index 0000000..095dbe9 --- /dev/null +++ b/WebContent/AdminEdit.jsp @@ -0,0 +1,135 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %> + + + + +Insert title here + + + + + + + +
+

Welcome Admin

+ +
+ + + + + + + select * from article where title='<%= request.getAttribute("title")%>' + + + + + +
+ +"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current Subject
" readonly style="background:lightgray">
Title
" placeholder="Enter title" required>
Highlights
" placeholder="Enter highlights" required>
Abstract
" placeholder="Enter abstract" required>
+
+ +
+ +
+2019 copyright©mjh.mohamed +
+ + + \ No newline at end of file diff --git a/WebContent/AdminHome.jsp b/WebContent/AdminHome.jsp new file mode 100644 index 0000000..58ee905 --- /dev/null +++ b/WebContent/AdminHome.jsp @@ -0,0 +1,117 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> + + + + + +Admin Home + + + + + + +
+

Welcome Admin

+ +
+ + + + +select * from article where author="${ email}" + + +
+ + + + + + + + + + + + + + + +
SubjectTitleHighlightOption
edit || + delete
+
+ +
+2019 copyright©mjh.mohamed +
+ + + \ No newline at end of file diff --git a/WebContent/AdminRegister.jsp b/WebContent/AdminRegister.jsp new file mode 100644 index 0000000..fdc3cb3 --- /dev/null +++ b/WebContent/AdminRegister.jsp @@ -0,0 +1,173 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + + +Author Register + + + + + + +
+ +
+ + +
+ + + + + + + + + + + +

Author Registration

email
password
confirm password
+
+ + +
+2019 copyright©mjh.mohamed +
+ + + \ No newline at end of file diff --git a/WebContent/Articles.jsp b/WebContent/Articles.jsp new file mode 100644 index 0000000..d3a1c1f --- /dev/null +++ b/WebContent/Articles.jsp @@ -0,0 +1,172 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> + + + + +Articles + + + + + + +
+ +
+ + + + +select * from article + +
+ + + + + + + + + + + + + + + +
TitleAuthorTimePopularity
+
+ +
+2019 copyright©mjh.mohamed +
+ + + \ No newline at end of file diff --git a/WebContent/AuthorArticle.jsp b/WebContent/AuthorArticle.jsp new file mode 100644 index 0000000..a4aac39 --- /dev/null +++ b/WebContent/AuthorArticle.jsp @@ -0,0 +1,179 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> + + + + + +Author Article + + + + + + +
+ +
+ + + + + +select * from article where author = '${ author}' + + +
+ + + + + + + + + + + + + + + + + + +
AuthorSubjectTitleTimePopularity
Download
+
+ + +
+2019 copyright©mjh.mohamed +
+ + + \ No newline at end of file diff --git a/WebContent/Comments.jsp b/WebContent/Comments.jsp new file mode 100644 index 0000000..c2f09dc --- /dev/null +++ b/WebContent/Comments.jsp @@ -0,0 +1,177 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> + + + + + +Comments + + + + + + +
+ +
+ + + + + +select * from comments + + +
+ + + + + + + + + + + + + + + +
TitleUserCommentTime
+
+ +
+2019 copyright©mjh.mohamed +
+ + + \ No newline at end of file diff --git a/WebContent/Contact.jsp b/WebContent/Contact.jsp new file mode 100644 index 0000000..73b1aa2 --- /dev/null +++ b/WebContent/Contact.jsp @@ -0,0 +1,113 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +Contact + + + + + + +
+ +
+ +
+2019 copyright©mjh.mohamed +
+ + + \ No newline at end of file diff --git a/WebContent/META-INF/MANIFEST.MF b/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 0000000..254272e --- /dev/null +++ b/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/WebContent/Master.jsp b/WebContent/Master.jsp new file mode 100644 index 0000000..4a67506 --- /dev/null +++ b/WebContent/Master.jsp @@ -0,0 +1,64 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +Master Admin + + + + + + + +
+

Welcome Admin

+ +
+ +
+2019 copyright©mjh.mohamed +
+ + + \ No newline at end of file diff --git a/WebContent/MasterArticles.jsp b/WebContent/MasterArticles.jsp new file mode 100644 index 0000000..bcf5451 --- /dev/null +++ b/WebContent/MasterArticles.jsp @@ -0,0 +1,126 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> + + + + + +Master Articles + + + + + + + +
+

Welcome Admin

+ +
+ + + + + +select * from article + + +
+ + + + + + + + + + + + + + + +
TitleAuthorTimeOption
delete
+
+ +
+2019 copyright©mjh.mohamed +
+ + + \ No newline at end of file diff --git a/WebContent/MasterAuthors.jsp b/WebContent/MasterAuthors.jsp new file mode 100644 index 0000000..d4b477d --- /dev/null +++ b/WebContent/MasterAuthors.jsp @@ -0,0 +1,124 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> + + + + + +Master Author + + + + + + + +
+

Welcome Admin

+ +
+ + + + + +select author from article where author not in (select email from block_author) + + +
+ + + + + + + + + + + + +
AuthorOption
block
+
+ +
+2019 copyright©mjh.mohamed +
+ + + \ No newline at end of file diff --git a/WebContent/MasterComments.jsp b/WebContent/MasterComments.jsp new file mode 100644 index 0000000..5b5ddd5 --- /dev/null +++ b/WebContent/MasterComments.jsp @@ -0,0 +1,64 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +Master Comments + + + + + + + +
+

Welcome Admin

+ +
+ +
+2019 copyright©mjh.mohamed +
+ + + \ No newline at end of file diff --git a/WebContent/MasterViewArticle.jsp b/WebContent/MasterViewArticle.jsp new file mode 100644 index 0000000..e427ac5 --- /dev/null +++ b/WebContent/MasterViewArticle.jsp @@ -0,0 +1,132 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> + + + + + + +Master View Article + + + + + + + +
+

Welcome Admin

+ +
+ + + + + + +select * from article where title="${ title}"; + + +
+ + + + + + + + + + + + + + + + + +

Abstract
Highlight
Publication Date
+
+ +
+2019 copyright©mjh.mohamed +
+ + + \ No newline at end of file diff --git a/WebContent/NewFile.jsp b/WebContent/NewFile.jsp new file mode 100644 index 0000000..1c2afea --- /dev/null +++ b/WebContent/NewFile.jsp @@ -0,0 +1,221 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> + + + + +NewFile + + + + + + +
+ +
+ +
+ + + + + + +

You are in

+
+ + + + + +select * from article where subject='<%=request.getAttribute("subject") %>' + + +
+ + + + + + + + + + + + + + + + +
TitleAuthorTimePopularity
+
+ +
+2019 copyright©mjh.mohamed +
+ + + \ No newline at end of file diff --git a/WebContent/NewFile1.jsp b/WebContent/NewFile1.jsp new file mode 100644 index 0000000..68bd61b --- /dev/null +++ b/WebContent/NewFile1.jsp @@ -0,0 +1,200 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> + + + + + +Home + + + + + + +
+ +
+ + + + + +select * from article where subject="Physical Science"; + + + +select * from article where subject="Computer Science"; + + + +select * from article where subject="Medical Science"; + + + +select * from article where subject="Social Science"; + + + +select * from article where subject="Biological Science"; + + + +select * from article where subject="Mathematics"; + + + +
+
+
+
+Physical Science + +
+
+ +Computer Science + +
+
+ +Medical Science + +
+
+ + +Social Science + +
+
+ +Biological Science + +
+
+ +Mathematics + +
+
+ +
+
+
+
+ +
+2019 copyright©mjh.mohamed +
+ + + \ No newline at end of file diff --git a/WebContent/PostArticle.jsp b/WebContent/PostArticle.jsp new file mode 100644 index 0000000..1ee65d4 --- /dev/null +++ b/WebContent/PostArticle.jsp @@ -0,0 +1,191 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + + + + +Post Articles + + + + + + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Author
" readonly style="background:lightgray">
Current Subject
" readonly style="background:lightgray">
Title
Highlights
Abstract
+
+ +
+2019 copyright©mjh.mohamed +
+ + + \ No newline at end of file diff --git a/WebContent/Search.jsp b/WebContent/Search.jsp new file mode 100644 index 0000000..17c6447 --- /dev/null +++ b/WebContent/Search.jsp @@ -0,0 +1,217 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> + + + + + +Search + + + + + + +
+ +
+ + + + + +select * from article where title like '%<%=request.getAttribute("search2") %>%' or abstracts like '%<%=request.getAttribute("search2") %>%' or highlight like '%<%=request.getAttribute("search2") %>%' order by time desc + + +
+ + + + + + + + + + + + + + + + + + +
SubjectTitleAuthorTimePopularity
+
+ +

+ + + +select * from comments where comment like '%<%=request.getAttribute("search2") %>%' order by time desc + + + +
+ + + + + + + + + + + + + + + + + + + +
Article TitleCommentTimeAuthor
+
+ + +
+Copyright (C) 2019, 2020 [MIJC Team] +
+ + + \ No newline at end of file diff --git a/WebContent/ViewArticle.jsp b/WebContent/ViewArticle.jsp new file mode 100644 index 0000000..3c755f2 --- /dev/null +++ b/WebContent/ViewArticle.jsp @@ -0,0 +1,420 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> + + + + + +View Article + + + + + + + +
+ +
+ + + + + +select * from article where title="${ title}"; + + +<%---------------------------------------------------------------------- --%> + + +select * from user_ip where prefer=1 and title="${ title}"; + + + + + + + + +<%---------------------------------------------------------------------- --%> + + +select * from user_ip where prefer=0 and title="${ title}"; + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + +

Abstract
Highlight
Publication Date
Author
+
+ + + + +
+
+ + + + +
+Download +
+
+ +
+ +
+ + + + + + + +
+
+ +
+ + +select * from comments where title="${ title}" + + +<%---------------------------------------------------------------------- --%> +<%-- This block is the comment box, where the comment, user, and time are + going to be displayed. + --%> + + +
+ + + + + + + +

+ + + + + +select * from comments_ip where prefer=1 and id="${ row.id}"; + + + + + + + + +
+ + + + + +
+ + + + + +select * from comments_ip where prefer=0 and id="${ row.id}"; + + + + + + + + + +
+ + + + + +
+ + + +
+
+ +

+ +
+ +
+2019 copyright©mjh.mohamed +
+ + + \ No newline at end of file diff --git a/WebContent/WEB-INF/lib/commons-fileupload-1.3.jar b/WebContent/WEB-INF/lib/commons-fileupload-1.3.jar new file mode 100644 index 0000000..32f2360 Binary files /dev/null and b/WebContent/WEB-INF/lib/commons-fileupload-1.3.jar differ diff --git a/WebContent/WEB-INF/lib/commons-io-2.4.jar b/WebContent/WEB-INF/lib/commons-io-2.4.jar new file mode 100644 index 0000000..90035a4 Binary files /dev/null and b/WebContent/WEB-INF/lib/commons-io-2.4.jar differ diff --git a/WebContent/WEB-INF/lib/jsp-api.jar b/WebContent/WEB-INF/lib/jsp-api.jar new file mode 100644 index 0000000..eef05db Binary files /dev/null and b/WebContent/WEB-INF/lib/jsp-api.jar differ diff --git a/WebContent/WEB-INF/lib/jstl-1.2.jar b/WebContent/WEB-INF/lib/jstl-1.2.jar new file mode 100644 index 0000000..0fd275e Binary files /dev/null and b/WebContent/WEB-INF/lib/jstl-1.2.jar differ diff --git a/WebContent/WEB-INF/lib/mysql-connector-java-8.0.19.jar b/WebContent/WEB-INF/lib/mysql-connector-java-8.0.19.jar new file mode 100644 index 0000000..7750517 Binary files /dev/null and b/WebContent/WEB-INF/lib/mysql-connector-java-8.0.19.jar differ diff --git a/WebContent/WEB-INF/lib/servlet-api.jar b/WebContent/WEB-INF/lib/servlet-api.jar new file mode 100644 index 0000000..1531d60 Binary files /dev/null and b/WebContent/WEB-INF/lib/servlet-api.jar differ diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml new file mode 100644 index 0000000..51b5ac2 --- /dev/null +++ b/WebContent/WEB-INF/web.xml @@ -0,0 +1,45 @@ + + + + OOAD + + indix.jsp + NewFile1.jsp + + + + + + user + com.javaBeans.Controller + + + user + /user + + + admin + com.javaBeans.AdminController + + + admin + /admin + + + up + com.javaBeans.UploadServlet + + + up + /up + + + down + com.javaBeans.DownloadServlet + + + down + /down + + + \ No newline at end of file diff --git a/WebContent/blocklist.jsp b/WebContent/blocklist.jsp new file mode 100644 index 0000000..801135f --- /dev/null +++ b/WebContent/blocklist.jsp @@ -0,0 +1,125 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> + + + + + +Master Author + + + + + + + +
+

Block List

+ +
+ + + + + + +select email from block_author; + + +
+ + + + + + + + + + + + +
AuthorOption
release
+
+ +
+2019 copyright©mjh.mohamed +
+ + + \ No newline at end of file diff --git a/WebContent/indix.jsp b/WebContent/indix.jsp new file mode 100644 index 0000000..bdb6d8d --- /dev/null +++ b/WebContent/indix.jsp @@ -0,0 +1,12 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +Insert title heres + + + + + \ No newline at end of file diff --git a/WebContent/style.css b/WebContent/style.css new file mode 100644 index 0000000..170e81b --- /dev/null +++ b/WebContent/style.css @@ -0,0 +1,69 @@ +@charset "ISO-8859-1"; + +body +{ + margin:0px; +} + +header +{ + background-color:blue; + text-align:center; + height:70px; + margin-bottom:50px; +} + +header nav +{ + padding-top:20px; +} + +header a +{ + font-size:25px; + margin-left:25px; + text-decoration:none; + color:white; + cursor: +} + +header a:hover +{ + color:gold; +} + +header form +{ + display:inline-block; +} + +header select +{ + margin-left:25px; + font-size:25px; + border-radius:3px 3px 3px 3px; +} + +header button +{ + font-size:20px; + border-radius:5px 5px 5px 5px; +} + +header input +{ + margin-left:25px; + font-size:20px; + border-radius:3px 3px 3px 3px; +} + +footer +{ + background:black; + height:40px; + color:white; + text-align:center; + padding:5px; + font-size:20px; + margin-top:50px; +} diff --git a/WebContent/success.jsp b/WebContent/success.jsp new file mode 100644 index 0000000..4ac633b --- /dev/null +++ b/WebContent/success.jsp @@ -0,0 +1,24 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + +Insert title here + + + + + + + + + + + +">download +">list + + + \ No newline at end of file diff --git a/build/classes/com/database/DB.class b/build/classes/com/database/DB.class new file mode 100644 index 0000000..624039f Binary files /dev/null and b/build/classes/com/database/DB.class differ diff --git a/build/classes/com/javaBean/Article.class b/build/classes/com/javaBean/Article.class new file mode 100644 index 0000000..0947f64 Binary files /dev/null and b/build/classes/com/javaBean/Article.class differ diff --git a/build/classes/com/javaBean/Author.class b/build/classes/com/javaBean/Author.class new file mode 100644 index 0000000..0853a55 Binary files /dev/null and b/build/classes/com/javaBean/Author.class differ diff --git a/build/classes/com/javaBeans/AdminController.class b/build/classes/com/javaBeans/AdminController.class new file mode 100644 index 0000000..a4b7875 Binary files /dev/null and b/build/classes/com/javaBeans/AdminController.class differ diff --git a/build/classes/com/javaBeans/Controller.class b/build/classes/com/javaBeans/Controller.class new file mode 100644 index 0000000..c5ee12a Binary files /dev/null and b/build/classes/com/javaBeans/Controller.class differ diff --git a/build/classes/com/javaBeans/DownloadServlet.class b/build/classes/com/javaBeans/DownloadServlet.class new file mode 100644 index 0000000..70e0ba5 Binary files /dev/null and b/build/classes/com/javaBeans/DownloadServlet.class differ diff --git a/build/classes/com/javaBeans/UploadServlet.class b/build/classes/com/javaBeans/UploadServlet.class new file mode 100644 index 0000000..389f591 Binary files /dev/null and b/build/classes/com/javaBeans/UploadServlet.class differ diff --git a/db.sql b/db.sql deleted file mode 100644 index 49dfac2..0000000 --- a/db.sql +++ /dev/null @@ -1,126 +0,0 @@ -/* - -. -Navicat MySQL Data Transfer - -Source Server : yun -Source Server Version : 50730 -Source Host : 47.115.56.157:3306 -Source Database : oo - -Target Server Type : MYSQL -Target Server Version : 50730 -File Encoding : 65001 - -Date: 2020-11-04 12:59:31 -*/ - -SET FOREIGN_KEY_CHECKS=0; - --- ---------------------------- --- Table structure for administrator --- ---------------------------- -DROP TABLE IF EXISTS `administrator`; -CREATE TABLE `administrator` ( - `email` varchar(20) DEFAULT NULL, - `password` varchar(20) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - --- ---------------------------- --- Table structure for article --- ---------------------------- -DROP TABLE IF EXISTS `article`; -CREATE TABLE `article` ( - `aid` int(11) NOT NULL AUTO_INCREMENT, - `sid` int(11) DEFAULT NULL, - `title` varchar(100) CHARACTER SET utf8 DEFAULT NULL, - `highlight` varchar(250) CHARACTER SET utf8 DEFAULT NULL, - `abstracts` varchar(999) CHARACTER SET utf8 DEFAULT NULL, - `author` varchar(20) CHARACTER SET utf8 DEFAULT NULL, - `time` timestamp NULL DEFAULT NULL, - `filename` varchar(80) CHARACTER SET utf8 DEFAULT NULL, - `path` varchar(100) CHARACTER SET utf8 DEFAULT NULL, - `hide` varchar(10) CHARACTER SET utf8 DEFAULT NULL, - `ip` varchar(30) CHARACTER SET utf8 DEFAULT NULL, - PRIMARY KEY (`aid`) -) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4; - --- ---------------------------- --- Table structure for author --- ---------------------------- -DROP TABLE IF EXISTS `author`; -CREATE TABLE `author` ( - `email` varchar(20) DEFAULT NULL, - `password` varchar(20) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - --- ---------------------------- --- Table structure for block_author --- ---------------------------- -DROP TABLE IF EXISTS `block_author`; -CREATE TABLE `block_author` ( - `id` int(11) NOT NULL, - `email` varchar(20) NOT NULL, - `ip` varchar(30) CHARACTER SET utf8 COLLATE utf8_german2_ci DEFAULT NULL, - `blockuntil` datetime DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - --- ---------------------------- --- Table structure for comments --- ---------------------------- -DROP TABLE IF EXISTS `comments`; -CREATE TABLE `comments` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `title` varchar(30) DEFAULT NULL, - `comment` varchar(50) DEFAULT NULL, - `time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, - `user` varchar(20) DEFAULT NULL, - `hide` varchar(10) CHARACTER SET utf8 DEFAULT NULL, - `ip` varchar(30) CHARACTER SET utf8 DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8mb4; - --- ---------------------------- --- Table structure for love_article --- ---------------------------- -DROP TABLE IF EXISTS `love_article`; -CREATE TABLE `love_article` ( - `ip` varchar(20) DEFAULT NULL, - `title` varchar(30) DEFAULT NULL, - `prefer` int(11) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - --- ---------------------------- --- Table structure for love_comment --- ---------------------------- -DROP TABLE IF EXISTS `love_comment`; -CREATE TABLE `love_comment` ( - `ip` varchar(20) DEFAULT NULL, - `cid` int(11) NOT NULL, - `prefer` int(11) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - --- ---------------------------- --- Table structure for subject --- ---------------------------- -DROP TABLE IF EXISTS `subject`; -CREATE TABLE `subject` ( - `sid` int(11) NOT NULL AUTO_INCREMENT, - `subject` varchar(30) CHARACTER SET utf8 DEFAULT NULL, - `sdate` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, - `parentsid` int(11) DEFAULT NULL, - PRIMARY KEY (`sid`) -) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4; - --- ---------------------------- --- Table structure for visit --- ---------------------------- -DROP TABLE IF EXISTS `visit`; -CREATE TABLE `visit` ( - `vid` int(11) NOT NULL AUTO_INCREMENT, - `aid` int(11) DEFAULT NULL, - `ip` varchar(30) DEFAULT NULL, - `date` datetime DEFAULT NULL, - PRIMARY KEY (`vid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/src/com/database/DB.java b/src/com/database/DB.java new file mode 100644 index 0000000..b1e2206 --- /dev/null +++ b/src/com/database/DB.java @@ -0,0 +1,328 @@ +package com.database; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import com.javaBean.Article; +import com.javaBean.Author; + +public class DB { + + public String root = "root"; + public String url = "jdbc:mysql://localhost:3306/oaps?autoReconnect=true&&useSSL=false&serverTimezone=CTT"; + public String password = "yujiahui@2014"; + public String Driver = "com.mysql.cj.jdbc.Driver"; + public Connection con; + + public void connect() throws SQLException + { + try + { + Class.forName(Driver); + + con = DriverManager.getConnection(url, root, password); + + } + + catch(ClassNotFoundException e) + { + e.printStackTrace(); + } + + } + + public void close() throws SQLException + { + con.close(); + } + + public void updateArticle(Article a) throws SQLException + { + connect(); + + String sql = "update article set title=?, highlight=?, abstracts=?, time=? where title=?"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, a.getTitle()); + ps.setString(2, a.getHighlights()); + ps.setString(3, a.getAbstracts()); + ps.setTimestamp(4, a.getTime()); + ps.setString(5, a.getOldtitle()); + ps.executeUpdate(); + + close(); + } + + public void deleteArticle(String title) throws SQLException + { + connect(); + + String sql = "delete from article where title=?"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, title); + ps.executeUpdate(); + + close(); + + } + + public void deleteComment(String comment) throws SQLException + { + connect(); + + String sql = "delete from comments where comment=?"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, comment); + ps.executeUpdate(); + + close(); + + } + + public void addAuthor(Author a) throws SQLException + { + connect(); + + String sql = "insert into author(email,password) values(?,?)"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, a.getEmail()); + ps.setString(2, a.getPassword()); + ps.executeUpdate(); + + close(); + + } + + public boolean checkAuthor(Author a) throws SQLException + { + connect(); + + boolean result = false; + int i = 0; + + String sql = "select * from author where email=? and password=?"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, a.getEmail()); + ps.setString(2, a.getPassword()); + + ResultSet rs = ps.executeQuery(); + + while(rs.next()) + { + i = 1; + result= true; + } + + close(); + + return result; + } + + public boolean checkblockauthor(String email) throws SQLException + { + connect(); + + boolean result = false; + int i = 0; + + String sql = "select * from block_author where email=?"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, email); + + + ResultSet rs = ps.executeQuery(); + + while(rs.next()) + { + i = 1; + result= true; + } + + close(); + + return result; + } + + public void blockAuthor(String author) throws SQLException + { + connect(); + + String sql = "insert into block_author(email) values(?)"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, author); + ps.executeUpdate(); + + close(); + + } + + public void releaseAuthor(String author) throws SQLException + { + connect(); + + String sql = "delete from block_author where email=?"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, author); + ps.executeUpdate(); + + close(); + + } + + + public boolean checktitle(String title) throws SQLException + { + connect(); + + boolean result = false; + int i = 0; + + String sql = "select * from article where title=?"; + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, title); + + + ResultSet rs = ps.executeQuery(); + + while(rs.next()) + { + i = 1; + result= true; + } + + close(); + + return result; + } + + + public boolean check_popular(String ip, String title, int a) throws SQLException + { + connect(); + + boolean result = false; + int i = 0; + + + + String sql = "insert into user_ip(ip, title, prefer) values(?, ?, ?)"; + String sql2 = "select * from user_ip where ip=? and title=?"; + String sql3 = "update user_ip set prefer=? where ip=? and title=?"; + + PreparedStatement ps2 = con.prepareStatement(sql2); + ps2.setString(1, ip); + ps2.setString(2, title); + + ResultSet rs = ps2.executeQuery(); + + while(rs.next()) + { + i = 1; + } + + if(i==1) + { + PreparedStatement ps3 = con.prepareStatement(sql3); + ps3.setInt(1, a); + ps3.setString(2, ip); + ps3.setString(3, title); + ps3.executeUpdate(); + result = true; + } + + else if(i==0) + { + PreparedStatement ps = con.prepareStatement(sql); + ps.setString(1, ip); + ps.setString(2, title); + ps.setInt(3, a); + ps.executeUpdate(); + result = true; + } + + + close(); + + return result; + } + + /* + + This function checks whether the user with the specific 'ip', has liked/disliked the comment + with the specific 'id'. + 'a' is a flag to determine whether the required operation is like or dislike, where a = 0, if + the required operation is dislike, and a = 1 if it's like. + + */ + public boolean check_comments_popular(String ip, int id, int a) throws SQLException + { + connect(); + + boolean result = false; + int i = 0; + + + + String sql = "insert into comments_ip(ip, id, prefer) values(?, ?, ?)"; + String sql2 = "select * from comments_ip where ip=? and id=?"; + String sql3 = "update comments_ip set prefer=? where ip=? and id=?"; + + PreparedStatement ps2 = con.prepareStatement(sql2); + ps2.setString(1, ip); + ps2.setInt(2, id); + + ResultSet rs = ps2.executeQuery(); + + while(rs.next()) + { + i = 1; + } + + if(i==1) + { + PreparedStatement ps3 = con.prepareStatement(sql3); + ps3.setInt(1, a); + ps3.setString(2, ip); + ps3.setInt(3, id); + ps3.executeUpdate(); + result = true; + } + + else if(i==0) + { + PreparedStatement ps = con.prepareStatement(sql); + ps.setString(1, ip); + ps.setInt(2, id); + ps.setInt(3, a); + ps.executeUpdate(); + result = true; + } + + + close(); + + return result; + } + + +} diff --git a/src/com/javaBean/Article.java b/src/com/javaBean/Article.java new file mode 100644 index 0000000..1e2710d --- /dev/null +++ b/src/com/javaBean/Article.java @@ -0,0 +1,69 @@ +package com.javaBean; + +import java.sql.Timestamp; + +public class Article { + + public String subject, title, author, highlights, abstracts, oldtitle; + public String comment, user; + public Timestamp time; + + + public String getSubject() { + return subject; + } + public void setSubject(String subject) { + this.subject = subject; + } + public String getTitle() { + return title; + } + public void setTitle(String title) { + this.title = title; + } + public String getAuthor() { + return author; + } + public void setAuthor(String author) { + this.author = author; + } + public String getHighlights() { + return highlights; + } + public void setHighlights(String highlights) { + this.highlights = highlights; + } + public String getAbstracts() { + return abstracts; + } + public void setAbstracts(String abstracts) { + this.abstracts = abstracts; + } + public Timestamp getTime() { + return time; + } + public void setTime(Timestamp time) { + this.time = time; + } + public String getComment() { + return comment; + } + public void setComment(String comment) { + this.comment = comment; + } + public String getUser() { + return user; + } + public void setUser(String user) { + this.user = user; + } + public String getOldtitle() { + return oldtitle; + } + public void setOldtitle(String oldtitle) { + this.oldtitle = oldtitle; + } + + + +} diff --git a/src/com/javaBean/Author.java b/src/com/javaBean/Author.java new file mode 100644 index 0000000..020b6d8 --- /dev/null +++ b/src/com/javaBean/Author.java @@ -0,0 +1,24 @@ +package com.javaBean; + +public class Author { + + public String email, password; + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + +} diff --git a/src/com/javaBeans/AdminController.java b/src/com/javaBeans/AdminController.java new file mode 100644 index 0000000..2405f4d --- /dev/null +++ b/src/com/javaBeans/AdminController.java @@ -0,0 +1,373 @@ +package com.javaBeans; + +import java.io.IOException; +import java.sql.SQLException; +import java.sql.Timestamp; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import javax.swing.JOptionPane; + +import com.database.DB; +import com.javaBean.Article; +import com.javaBean.Author; + +/** + * Servlet implementation class AdminController + */ +@WebServlet("/AdminController") +public class AdminController extends HttpServlet { + HttpSession session; + private static final long serialVersionUID = 1L; + + /** + * @see HttpServlet#HttpServlet() + */ + public AdminController() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + String page = request.getParameter("page"); + + if(page == null) + { + request.getRequestDispatcher("AdminHome.jsp").forward(request, response); + } + + else + { + doPost(request, response); + } + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + String page = request.getParameter("page"); + + if(page.equals("admin")) + { + String email = request.getParameter("email"); + String password = request.getParameter("password"); + + Author a = new Author(); + a.setEmail(email); + a.setPassword(password); + + DB db = new DB(); + boolean status = false; + + try + { + status = db.checkAuthor(a); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + if(status) + { + session = request.getSession(); + session.setAttribute("email", email); + request.getRequestDispatcher("AdminHome.jsp").forward(request, response); + } + + else + { + request.setAttribute("msg", "invalid"); + request.getRequestDispatcher("Admin.jsp").forward(request, response); + } + } + + if(page.equals("register")) + { + request.getRequestDispatcher("AdminRegister.jsp").forward(request, response); + } + + if(page.equals("register-form")) + { + String email = request.getParameter("email"); + String password = request.getParameter("password"); + String conpassword = request.getParameter("conpassword"); + + if(password.equals(conpassword)) + { + Author a = new Author(); + a.setEmail(email); + a.setPassword(password); + + DB db = new DB(); + + try + { + db.addAuthor(a); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + request.getRequestDispatcher("Admin.jsp").forward(request, response); + } + + else + { + request.getRequestDispatcher("AdminRegister.jsp").forward(request, response); + } + } + + if(page.equals("home")) + { + String email = request.getParameter("email"); + request.getRequestDispatcher("AdminHome.jsp").forward(request, response); + } + + if(page.equals("logout")) + { + request.getRequestDispatcher("Admin.jsp").forward(request, response); + } + + if(page.equals("edit")) + { + String title = request.getParameter("title"); + String email = request.getParameter("email"); + + request.setAttribute("title", title); + request.setAttribute("email", email); + request.getRequestDispatcher("AdminEdit.jsp").forward(request, response); + } + + if(page.equals("edit-form")) + { + String oldtitle = request.getParameter("old-title"); + + String title = request.getParameter("title"); + String highlights = request.getParameter("highlights"); + String abstracts = request.getParameter("abstracts"); + Timestamp time = new Timestamp(System.currentTimeMillis()); + + + DB db = new DB(); +/* boolean checkstatus = false; + + try + { + checkstatus = db.checktitle(title); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + if(checkstatus) + { + JOptionPane.showMessageDialog(null, "Article Title is already exist please try anotherone ", "Info", JOptionPane.INFORMATION_MESSAGE); + + request.setAttribute("title", title); + request.setAttribute("highlights", highlights); + request.setAttribute("abstracts", abstracts); + request.getRequestDispatcher("AdminEdit.jsp").forward(request, response); + } + + else + { +*/ + + if(title.length() > 100) + { + JOptionPane.showMessageDialog(null, "you have typed more than 100 letters in Highlights", "Info", JOptionPane.INFORMATION_MESSAGE); + + request.setAttribute("title", oldtitle); + request.getRequestDispatcher("AdminEdit.jsp").forward(request, response); + } + + else if(highlights.length() > 250) + { + JOptionPane.showMessageDialog(null, "you have typed more than 250 letters in Highlights", "Info", JOptionPane.INFORMATION_MESSAGE); + + request.setAttribute("title", oldtitle); + request.getRequestDispatcher("AdminEdit.jsp").forward(request, response); + } + + else if(abstracts.length() > 999) + { + JOptionPane.showMessageDialog(null, "you have typed more than 1000 letters in abstract", "Info", JOptionPane.INFORMATION_MESSAGE); + + request.setAttribute("title", oldtitle); + request.getRequestDispatcher("AdminEdit.jsp").forward(request, response); + } + + else + { + + Article a = new Article(); + a.setTitle(title); + a.setHighlights(highlights); + a.setAbstracts(abstracts); + a.setTime(time); + a.setOldtitle(oldtitle); + +// DB db = new DB(); + + try + { + db.updateArticle(a); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + request.getRequestDispatcher("AdminHome.jsp").forward(request, response); + } +// } else + + } + + if(page.equals("delete")) + { + String title = request.getParameter("title"); + + DB db = new DB(); + + try + { + db.deleteArticle(title); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + request.getRequestDispatcher("AdminHome.jsp").forward(request, response); + } + + +//---------------------------------------------------------------------------------------------- +// master function + + if(page.equals("master-home")) + { + request.getRequestDispatcher("Master.jsp").forward(request, response); + } + + if(page.equals("master-articles")) + { + request.getRequestDispatcher("MasterArticles.jsp").forward(request, response); + } + + if(page.equals("master-comments")) + { + request.getRequestDispatcher("Comments.jsp").forward(request, response); + } + + if(page.equals("master-authors")) + { + request.getRequestDispatcher("MasterAuthors.jsp").forward(request, response); + } + + if(page.equals("master-delete")) + { + String title = request.getParameter("title"); + + DB db = new DB(); + + try + { + db.deleteArticle(title); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + request.getRequestDispatcher("MasterArticles.jsp").forward(request, response); + } + + if(page.equals("master-view-article")) + { + String title = request.getParameter("title"); + + request.setAttribute("title", title); + request.getRequestDispatcher("MasterViewArticle.jsp").forward(request, response); + } + + if(page.equals("master-delete-comments")) + { + String comment = request.getParameter("comment"); + + DB db = new DB(); + + try + { + db.deleteComment(comment); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + request.getRequestDispatcher("Comments.jsp").forward(request, response); + } + + if(page.equals("master-block-author")) + { + String author = request.getParameter("author"); + + DB db = new DB(); + + try + { + db.blockAuthor(author); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + request.getRequestDispatcher("blocklist.jsp").forward(request, response); + } + + if(page.equals("master-release-author")) + { + String author = request.getParameter("author"); + + DB db = new DB(); + + try + { + db.releaseAuthor(author); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + request.getRequestDispatcher("MasterAuthors.jsp").forward(request, response); + } + + } + +} diff --git a/src/com/javaBeans/Controller.java b/src/com/javaBeans/Controller.java new file mode 100644 index 0000000..6a51c69 --- /dev/null +++ b/src/com/javaBeans/Controller.java @@ -0,0 +1,389 @@ +package com.javaBeans; + +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Timestamp; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.swing.JOptionPane; + +import com.database.DB; + +/** + * Servlet implementation class Controller + */ +@WebServlet("/Controller") +public class Controller extends HttpServlet { + private static final long serialVersionUID = 1L; + + /** + * @see HttpServlet#HttpServlet() + */ + public Controller() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + String page = request.getParameter("page"); + + if(page == null || page.equals("home")) + { + request.getRequestDispatcher("NewFile1.jsp").forward(request, response); + } + + else + { + doPost(request, response); + } + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + String page = request.getParameter("page"); + + + if(page.equals("like")) + { + String ip = request.getRemoteAddr(); + String title = request.getParameter("title"); + + int a = 1; + + DB db = new DB(); + boolean status = false; + + try + { + status = db.check_popular(ip, title, a); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + if(status) + { + request.setAttribute("title", title); + request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); + } + + else + { + JOptionPane.showMessageDialog(null, "You have already liked the article.", "Info", JOptionPane.INFORMATION_MESSAGE); + + request.setAttribute("title", title); + request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); + } + } + + if(page.equals("dislike")) + { + String ip = request.getRemoteAddr(); + String title = request.getParameter("title"); + + int a = 0; + + DB db = new DB(); + boolean status = false; + + try + { + status = db.check_popular(ip, title, a); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + if(status) + { + request.setAttribute("title", title); + request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); + } + + else + { + JOptionPane.showMessageDialog(null, "You have already disliked the article", "Info", JOptionPane.INFORMATION_MESSAGE); + + request.setAttribute("title", title); + request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); + } + } + + + if(page.equals("comments_like")) + { + String title = request.getParameter("title"); + String ip = request.getRemoteAddr(); + int id = Integer.parseInt(request.getParameter("id")); + + int a = 1; + + DB db = new DB(); + boolean status = false; + + try + { + status = db.check_comments_popular(ip, id, a); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + if(status) + { + request.setAttribute("title", title); + request.setAttribute("id", id); + request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); + } + + else + { + JOptionPane.showMessageDialog(null, "You have already liked the comment.", "Info", JOptionPane.INFORMATION_MESSAGE); + + request.setAttribute("title", title); + request.setAttribute("id", id); + request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); + } + } + + if(page.equals("comments_dislike")) + { + String title = request.getParameter("title"); + String ip = request.getRemoteAddr(); + int id = Integer.parseInt(request.getParameter("id")); + + int a = 0; + + DB db = new DB(); + boolean status = false; + + try + { + status = db.check_comments_popular(ip, id, a); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + if(status) + { + request.setAttribute("title", title); + request.setAttribute("id", id); + request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); + } + + else + { + JOptionPane.showMessageDialog(null, "You have already disliked the comment", "Info", JOptionPane.INFORMATION_MESSAGE); + + request.setAttribute("title", title); + request.setAttribute("id", id); + request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); + } + + } + + + if(page.equals("home")) + { + request.getRequestDispatcher("NewFile1.jsp").forward(request, response); + } + + if(page.equals("aboutus")) + { + request.getRequestDispatcher("Aboutus.jsp").forward(request, response); + } + + if(page.equals("contact")) + { + request.getRequestDispatcher("Contact.jsp").forward(request, response); + } + + if(page.equals("admin")) + { + request.getRequestDispatcher("Admin.jsp").forward(request, response); + } + + if(page.equals("select")) + { + String option = request.getParameter("option"); + + if(option.equals("Articles")) + { + request.getRequestDispatcher("Articles.jsp").forward(request, response); + } + + if(option.equals("Comments")) + { + request.getRequestDispatcher("Comments.jsp").forward(request, response); + } + } + + if(page.equals("search")) + { + String search2 = request.getParameter("search2"); + + request.setAttribute("search2", search2); + request.getRequestDispatcher("Search.jsp").forward(request, response); + } + + if(page.equals("subject")) + { + String subject = request.getParameter("id"); + + request.setAttribute("subject", subject); + request.getRequestDispatcher("NewFile.jsp").forward(request, response); + } + + if(page.equals("post-article")) + { + String subject = request.getParameter("subject"); + String email = request.getParameter("email"); + + boolean status = false; + DB db = new DB(); + + try + { + status = db.checkblockauthor(email); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + if(status) + { + JOptionPane.showMessageDialog(null, "Sorry you have been blcoked, please contact Admin", "Info", JOptionPane.INFORMATION_MESSAGE); + + request.setAttribute("subject", subject); + request.getRequestDispatcher("NewFile.jsp").forward(request, response); + } + + else + { + request.setAttribute("subject", subject); + request.setAttribute("email", email); + request.getRequestDispatcher("PostArticle.jsp").forward(request, response); + } + + } + + + if(page.equals("view-article")) + { + String title = request.getParameter("title"); + + request.setAttribute("title", title); + request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); + } + + if(page.equals("admin-view-article")) + { + String title = request.getParameter("title"); + + request.setAttribute("title", title); + request.getRequestDispatcher("AdminViewArticle.jsp").forward(request, response); + } + + if(page.equals("comment-post")) + { + String email = request.getParameter("email"); + String comment = request.getParameter("comment"); + String title = request.getParameter("title"); + Timestamp time = new Timestamp(System.currentTimeMillis()); + + String comment2 = comment.toLowerCase(); + if(comment2.contains("fuck") || comment2.contains("motherfucker") || comment2.contains("nigga") || comment2.contains("bitch") + || comment2.contains("idiot") || comment2.contains("stupid") || comment2.contains("dick") || comment2.contains("boobs") || comment2.contains("pussy") || comment2.contains("suck")) + { +// System.out.println("illegal"); + request.setAttribute("title", title); + request.setAttribute("msg", "using improper words, please use proper words"); + request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); + } + + else + { + + + try + { + String root ="root"; + String password = "Fathihachellam.1"; + String url = "jdbc:mysql://localhost:3306/ooad?autoReconnect=true&&useSSL=false"; + String driver = "com.mysql.jdbc.Driver"; + Connection con; + + Class.forName(driver); + + String sql = "insert into comments (title, user, comment, time) values (?,?,?,?)"; + + con = DriverManager.getConnection(url, root, password); + + PreparedStatement ps = con.prepareStatement(sql); + + ps.setString(1, title); + ps.setString(2, email); + ps.setString(3, comment); + ps.setTimestamp(4, time); + + ps.executeUpdate(); + + } + + catch (ClassNotFoundException e1) + { + e1.printStackTrace(); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + +// System.out.println(email); +// System.out.println(comment); +// System.out.println(title); +// System.out.println(time); + + request.setAttribute("title", title); + request.getRequestDispatcher("ViewArticle.jsp").forward(request, response); + + } + } + + if(page.equals("authorarticle")) + { + String author = request.getParameter("author"); + + request.setAttribute("author", author); + request.getRequestDispatcher("AuthorArticle.jsp").forward(request, response); + } + + } + +} diff --git a/src/com/javaBeans/DownloadServlet.java b/src/com/javaBeans/DownloadServlet.java new file mode 100644 index 0000000..ba63c77 --- /dev/null +++ b/src/com/javaBeans/DownloadServlet.java @@ -0,0 +1,157 @@ +package com.javaBeans; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + + +/** + * Servlet implementation class DownloadServlet + */ +@WebServlet("/DownloadServlet") +public class DownloadServlet extends HttpServlet { + + public static int BUFFER_SIZE = 1024*100; + public static final String UPLOAD_DIR = "resources"; + public static String fn = null; + + private static final long serialVersionUID = 1L; + + + public DownloadServlet() + { + super(); + + } + + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + +// fn = request.getParameter("fileName"); + + response.setContentType("text/html"); + + PrintWriter out = response.getWriter(); + String filename = request.getParameter("fileName"); + String filepath = request.getServletContext().getRealPath("")+ UPLOAD_DIR+ File.separator; + response.setContentType("APPLICATION/OCTET-STREAM"); + response.setHeader("Content-Disposition","attachment; filename=\"" + filename + "\""); + + System.out.println(filename); + System.out.println(filepath); + + //use inline if you want to view the content in browser, helpful for pdf file + //response.setHeader("Content-Disposition","inline; filename=\"" + filename + "\""); + FileInputStream fileInputStream = new FileInputStream(filepath + filename); + + int i; + while ((i=fileInputStream.read()) != -1) { + out.write(i); + } + fileInputStream.close(); + out.close(); + } + + +/* if(fn.equals("") || fn == null) + { + response.setContentType("text/html"); + response.getWriter().println("File : " +fn+" is not exist "); + } + + else + { + String serverpath = request.getServletContext().getRealPath(""); + String downloadPath = serverpath + UPLOAD_DIR; + String filepath = downloadPath + File.separator + fn; + + System.out.println(fn); + System.out.println(filepath); + System.out.println("filename:" +fn); + System.out.println("filepath:" +filepath); + + File file = new File(filepath); + + OutputStream os = null; + FileInputStream is = null; + + if(file.exists()) + { + String mimetype ="APPLICATION/OCTET-STREAM"; + response.setContentType(mimetype); + + String headerKey = "Content-Disposition"; + String headervalue = String.format("attachment; filename=\""+fn+"\""); + response.setHeader(headerKey, headervalue); + + try + { + os = response.getOutputStream(); + is = new FileInputStream(file); + + int i; + + while ((i=is.read()) != -1) + { + out.write(i); + } + + is.close(); + out.close(); + + byte[] buffer = new byte[BUFFER_SIZE]; + int bytesread = -1; + + while((bytesread = is.read(buffer)) != -1) + { + os.write(buffer, 0, bytesread); + } + } + + catch(IOException e) + { + System.out.println("exception while performe: " +e.getMessage()); + } + + finally + { + if(is != null) + { + is.close(); + } + + os.flush(); + + if(os != null) + { + os.close(); + } + } + } + + else + { + response.setContentType("text/html"); + + response.getWriter().println("file: "+fn+" not exist"); + } + } + + } +*/ + + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + + } + +} diff --git a/src/com/javaBeans/UploadServlet.java b/src/com/javaBeans/UploadServlet.java new file mode 100644 index 0000000..ded0ae6 --- /dev/null +++ b/src/com/javaBeans/UploadServlet.java @@ -0,0 +1,218 @@ +package com.javaBeans; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Timestamp; + +import javax.servlet.ServletException; +import javax.servlet.annotation.MultipartConfig; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import javax.servlet.http.Part; +import javax.swing.JOptionPane; + +import org.apache.catalina.core.ApplicationPart; + +import com.database.DB; + +/** + * Servlet implementation class UploadServlet + */ +@WebServlet("/UploadServlet") +@MultipartConfig(fileSizeThreshold = 1024 *1024 * 10, + maxFileSize = 1024 * 1024 * 1000, + maxRequestSize = 1024 * 1024 *1000) +public class UploadServlet extends HttpServlet { + + PrintWriter out = null; + Connection con = null; + PreparedStatement ps = null; + HttpSession session = null; + + private static final long serialVersionUID = 1L; + + /** + * @see HttpServlet#HttpServlet() + */ + public UploadServlet() { + super(); + // TODO Auto-generated constructor stub + } + + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + + } + + + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + String author = request.getParameter("author"); + String subject = request.getParameter("subject"); + String title = request.getParameter("title"); + String highlights = request.getParameter("highlights"); + String abstracts = request.getParameter("abstracts"); + + + DB db = new DB(); + boolean checkstatus = false; + + try + { + checkstatus = db.checktitle(title); + } + + catch(SQLException e) + { + e.printStackTrace(); + } + + if(checkstatus) + { + JOptionPane.showMessageDialog(null, "The article title already exists.\nPlease use another one. ", "Info", JOptionPane.INFORMATION_MESSAGE); + + request.setAttribute("author", author); + request.setAttribute("subject", subject); + request.setAttribute("title", title); + request.setAttribute("highlights", highlights); + request.setAttribute("abstracts", abstracts); + request.getRequestDispatcher("PostArticle.jsp").forward(request, response); + } + + else + { + +// --------------------------------------------------------------------------------------------------------------- + + response.setContentType("text/plain;charset=UTF=8"); + + try + { + out = response.getWriter(); + session = request.getSession(false); + + String folderName = "resources"; + String uploadPath = request.getServletContext().getRealPath("") + folderName; + + File dir = new File (uploadPath); + + if(!dir.exists()) + { + dir.mkdir(); + } + + Timestamp time = new Timestamp(System.currentTimeMillis()); + + + Part filePart = request.getPart("file"); + String fileName = filePart.getSubmittedFileName(); + String path = folderName + File.separator + fileName; + String fileType = filePart.getContentType();// get the uploaded file type + + // if the uploaded file type is PDF, then upload the file to the server + if(fileType == "application/pdf") { + + InputStream is = filePart.getInputStream(); + Files.copy(is, Paths.get(uploadPath + File.separator + fileName), StandardCopyOption.REPLACE_EXISTING); + + try + { + Class.forName("com.mysql.jdbc.Driver"); + + String u = "root"; + String password = "124536"; + String ul = "jdbc:mysql://localhost:3306/ooad?autoReconnect=true&&useSSL=false"; + + con = DriverManager.getConnection(ul, u, password); + + String sql = "insert into article(subject, title, highlight, abstracts, author, time, filename, path) values (?,?,?,?,?,?,?,?)"; + + ps = con.prepareStatement(sql); + + ps.setString(1, subject); + ps.setString(2, title); + ps.setString(3, highlights); + ps.setString(4, abstracts); + ps.setString(5, author); + ps.setTimestamp(6, time); + ps.setString(7, fileName); + ps.setString(8, path); + + int status = ps.executeUpdate(); + + if(status>0) + { + session.setAttribute("fileName", fileName); + String msg = "" +fileName+ " upload successfully"; + request.setAttribute("msg", msg); + request.setAttribute("subject", subject); + request.getRequestDispatcher("NewFile.jsp").forward(request, response); + + } + + } + + catch(SQLException | ClassNotFoundException e) + { + System.out.println(e); + } + + finally + { + try + { + if(ps != null) + { + ps.close(); + } + + if(con!=null) + { + con.close(); + } + } + + catch(SQLException e) + { + out.println(e); + } + } + + }else {// if the uploaded file type is not PDF, show an alert message + + JOptionPane.showMessageDialog(null, "Unsupported file format!.\nOnly PDF files are supported. ", "Info", JOptionPane.INFORMATION_MESSAGE); + + request.setAttribute("author", author); + request.setAttribute("subject", subject); + request.setAttribute("title", title); + request.setAttribute("highlights", highlights); + request.setAttribute("abstracts", abstracts); + request.getRequestDispatcher("PostArticle.jsp").forward(request, response); + + } + + + } + + catch(IOException | ServletException e) + { + out.println(e); + } + } + + } + +} diff --git a/the improvement i have done.txt b/the improvement i have done.txt new file mode 100644 index 0000000..2b505d2 --- /dev/null +++ b/the improvement i have done.txt @@ -0,0 +1,39 @@ +添加CountServlet类用于记录网页访问次数: +package count; + +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class CountServlet extends HttpServlet { + + /** + * + */ + private static final long serialVersionUID = 1L; + + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + + + int totalCount=1;//默认访问量为1 + //获取网站访问量 + + Object count = request.getServletContext().getAttribute("count"); + + //判断count是否为null,不为null表示曾经访问过,直接将count赋值给totalCount + if(count!=null) { + totalCount=(int)count; + } + //访问次数累加 + request.getServletContext().setAttribute("count",totalCount+1); + response.getWriter().println("网站访问量为:"+totalCount); //输出到界面 + + } + +} +之后在admin.jsp中添加调用: +点我查看网站访问量 \ No newline at end of file diff --git "a/\344\277\256\346\224\271\345\206\205\345\256\271.txt" "b/\344\277\256\346\224\271\345\206\205\345\256\271.txt" new file mode 100644 index 0000000..2adf5f4 --- /dev/null +++ "b/\344\277\256\346\224\271\345\206\205\345\256\271.txt" @@ -0,0 +1,6 @@ +删除了页面中Ariticle列表以及GO按钮 + +search搜索栏中新支持前后去除空格,不输入内容搜索即输出全部文章 + +修复了搜索文章Time的时间显示多出.0的问题 + diff --git "a/\351\241\271\347\233\256\345\267\262\347\273\217\344\270\212\344\274\240\345\210\260\350\277\231\344\270\252\347\275\221\345\235\200.txt" "b/\351\241\271\347\233\256\345\267\262\347\273\217\344\270\212\344\274\240\345\210\260\350\277\231\344\270\252\347\275\221\345\235\200.txt" deleted file mode 100644 index 2624c19..0000000 --- "a/\351\241\271\347\233\256\345\267\262\347\273\217\344\270\212\344\274\240\345\210\260\350\277\231\344\270\252\347\275\221\345\235\200.txt" +++ /dev/null @@ -1 +0,0 @@ -http://47.115.56.157:8080/wzf/ \ No newline at end of file