Skip to content

Pull Request #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions assets/css/screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ a:hover {
z-index: 2;
}
.nav.fixed {
position: fixed;
/*position: fixed;*/
}
#logo {
float: left;
Expand Down Expand Up @@ -228,12 +228,12 @@ div.cover > img {
height: 900px;
/* Background image is defined in the post */
background-position: top center;
background-attachment: fixed;
/*background-attachment: scroll;*/
overflow: hidden;
}
/* Contains the time, title and subtitle for an article */
.art-header-inner {
position: fixed;
position: absolute;
top: 300px;
left: 50%;
margin-left: -490px;
Expand All @@ -243,6 +243,7 @@ div.cover > img {
.art-subtitle {
text-align: center;
text-transform: uppercase;
position: absolute;
}
.art-time {
font-size: 14px;
Expand Down Expand Up @@ -275,6 +276,7 @@ div.cover > img {
.art-body {
position: relative;
width: 100%;
margin-top: 100px;
background: #fff;
z-index: 100;
-webkit-box-shadow: 0 -3px 3px rgba(0,0,0,.2);
Expand Down
71 changes: 71 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="IF3110-02-Simple-Blog-Java" default="default" basedir=".">
<description>Builds, tests, and runs the project IF3110-02-Simple-Blog-Java.</description>
<import file="nbproject/build-impl.xml"/>
<!--

There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:

-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-dist: called before archive building
-post-dist: called after archive building
-post-clean: called after cleaning build products
-pre-run-deploy: called before deploying
-post-run-deploy: called after deploying

Example of pluging an obfuscator after the compilation could look like

<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>

For list of available properties check the imported
nbproject/build-impl.xml file.


Other way how to customize the build is by overriding existing main targets.
The target of interest are:

init-macrodef-javac: defines macro for javac compilation
init-macrodef-junit: defines macro for junit execution
init-macrodef-debug: defines macro for class debugging
do-dist: archive building
run: execution of project
javadoc-build: javadoc generation

Example of overriding the target for project execution could look like

<target name="run" depends="<PROJNAME>-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>

Notice that overridden target depends on jar target and not only on
compile target as regular run target does. Again, for list of available
properties which you can use check the target you are overriding in
nbproject/build-impl.xml file.

-->
</project>
27 changes: 27 additions & 0 deletions build/web/AddForm.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<%--
Document : add
Created on : Nov 25, 2014, 6:30:47 PM
Author : Teofebano
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h2>User Details</h2>
<form action="add.jsp" method="post">
<br/>Username :<input type="text" name="username" value="username">
<br/>Password :<input type="text" name="password" value="password">
<br/>Role :<input type="text" name="role" value="role">
<br/>Email :<input type="text" name="email" value="email">
<br/><br><input type="submit" value="Submit">
</form>
<br/>
<br/>
<a href="ManagementUser.jsp">Back to main page</a>
</body>
</html>
99 changes: 99 additions & 0 deletions build/web/LoginCheck.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<%--
Document : LoginCheck
Created on : Nov 24, 2014, 2:10:26 PM
Author : Teofebano
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page language="java" import="java.sql.Connection"%>
<%@ page language="java" import="java.sql.PreparedStatement"%>
<%@ page language="java" import="java.sql.ResultSet"%>
<%@ page language="java" import="java.sql.SQLException"%>
<%@ page language="java" import="java.sql.DriverManager"%>
<%@ page language="java" import="java.util.*"%>
<%@ page language="java" import="java.lang.String"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login Check</title>
</head>
<body>
<%
String username=request.getParameter("username");
String password=request.getParameter("password");
String passwordS = ""; // dari SQL
String rol = "";
int user_id = 0;

Connection con = null;
// Connect to DB
try {
//Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/simpleblog_withjava";
String user = "root";
String passwordSQL = "";

DriverManager.registerDriver(new com.mysql.jdbc.Driver());

con = DriverManager.getConnection(url, user, passwordSQL);
}
catch(SQLException ex){
System.out.println(ex);
}

// Retrieve password and role
try
{
String sql=("SELECT user_id, password, role FROM user WHERE nama='"+username+"'");
PreparedStatement ps = con.prepareStatement(sql);
ResultSet rs = ps.executeQuery(sql);

String[] pass = null;
int rl = 0;
int user = 0;
while (rs.next()){
String em = rs.getString("password");
rl = rs.getInt("role");
user = rs.getInt("user_id");
pass = em.split("\n");
for (int i =0; i < pass.length; i++){
System.out.println(pass[i]);
}
}
if (pass != null){
passwordS = pass[0];

switch (rl){
case 1: rol = "Owner"; break;
case 2: rol = "Editor"; break;
case 3: rol = "Admin"; break;
default : rol = "Guest"; break;
}

user_id = user;
}

}
catch (SQLException ex)
{
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}

if( password.equals(passwordS))
{
session.setAttribute("username",username);
session.setAttribute("password",password);
session.setAttribute("role",rol);
session.setAttribute("user_id",user_id);
response.sendRedirect("cookies.jsp");
}
else
response.sendRedirect("index.jsp");

%>
</body>
</html>

2 changes: 2 additions & 0 deletions build/web/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Manifest-Version: 1.0

2 changes: 2 additions & 0 deletions build/web/META-INF/context.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/IF3110-02-Simple-Blog-Java 2"/>
107 changes: 107 additions & 0 deletions build/web/ManagementUser.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<%--
Document : ManagementUser
Created on : Nov 24, 2014, 5:24:10 PM
Author : Teofebano
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page language="java" import="java.sql.Connection"%>
<%@ page language="java" import="java.sql.PreparedStatement"%>
<%@ page language="java" import="java.sql.ResultSet"%>
<%@ page language="java" import="java.sql.SQLException"%>
<%@ page language="java" import="java.sql.DriverManager"%>
<%@ page language="java" import="java.util.*"%>
<%@ page language="java" import="java.lang.String"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Management User</title>
</head>
<body>

<table border="2">
<tr>
<td>Name</td>
<td>Password</td>
<td>Role</td>
<td>Email</td>
<td>Update</td>
<td>Delete</td>
</tr>
<%

Connection con = null;
// Connect to DB
try {
//Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/simpleblog_withjava";
String user = "root";
String passwordSQL = "";

DriverManager.registerDriver(new com.mysql.jdbc.Driver());

con = DriverManager.getConnection(url, user, passwordSQL);
}
catch(SQLException ex){
System.out.println(ex);
}

// Retrieve password and role
try
{
String sql=("SELECT user_id, nama, password, role, email FROM user");
PreparedStatement ps = con.prepareStatement(sql);
ResultSet rs = ps.executeQuery(sql);

while (rs.next()){
String x = rs.getString("nama");
String y = rs.getString("password");
String email = rs.getString("email");
int z = rs.getInt("role");
int user_id = rs.getInt("user_id");
%>

<tr>
<td><% out.println(x); %></td>
<td><% out.println(y); %></td>
<td><% out.println(z); %></td>
<td><% out.println(email); %></td>

<td> <form type ="button" action = "UpdateForm.jsp?user_id=<%=user_id%>" method ="post"> <button type="submit" value="Submit"> Update </button></form></td>
<td> <form type ="button" action = "delete.jsp?user_id=<%=user_id%>" method ="post"> <button type="submit" value="Submit"> Delete </button></form></td>
</tr>

<%

}

rs.close();
con.close();
%>
</table>

<%
}
catch (SQLException ex)
{
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
%>
<br>
<form type ="button" action = "AddForm.jsp" method ="post"> <button type="submit" value="Submit"> Add User </button></form>
<br>
<br>
<a href="home-admin.jsp">Back to main page</a>
<script>
function delete(){
<%

%>
}
</script>
</body>
</html>
Loading