-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
1,244 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
RewriteEngine on | ||
|
||
# Rewrite /foo/bar to /foo/bar.php | ||
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L] | ||
|
||
# Return 404 if original request is /foo/bar.php | ||
RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$" [NC] | ||
RewriteRule .* - [L,R=404] | ||
|
||
# NOTE! FOR APACHE ON WINDOWS: Add [NC] to RewriteCond like this: | ||
# RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$" [NC] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
require "../connect.php"; | ||
|
||
session_start(); | ||
|
||
$login = new LoginUser($db); | ||
$login->email = $_POST["email"]; | ||
$login->password = $_POST["password"]; | ||
$r = $login->login(); | ||
|
||
var_dump($r); | ||
|
||
if ($r != null) | ||
{ | ||
$_SESSION["id"] = $r["id"]; | ||
$_SESSION["role"] = "user"; | ||
header("Location: ../homepage"); | ||
exit; | ||
} | ||
else | ||
{ | ||
header("Location: ../login?err=1"); | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
require "../connect.php"; | ||
|
||
session_start(); | ||
|
||
$login = new LoginAdmin($db); | ||
$login->username = $_POST["username"]; | ||
$login->password = $_POST["password"]; | ||
$r = $login->login(); | ||
|
||
var_dump($r); | ||
|
||
if ($r != null) | ||
{ | ||
$_SESSION["id"] = $r["id"]; | ||
$_SESSION["role"] = "admin"; | ||
header("Location: ../homepage"); | ||
exit; | ||
} | ||
else | ||
{ | ||
header("Location: ../loginadmin?err=1"); | ||
} | ||
|
||
?> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
require "../connect.php"; | ||
|
||
session_start(); | ||
|
||
if ($_POST["password"] != $_POST["confirmpassword"]) | ||
{ | ||
header("Location: ../registrasi?err=1"); | ||
} | ||
|
||
$reg = new RegisterUser($db); | ||
$reg->nama = $_POST["nama"]; | ||
$reg->email = $_POST["email"]; | ||
$reg->username = $_POST["username"]; | ||
$reg->no_ktp = $_POST["no_ktp"]; | ||
$reg->no_telp = $_POST["no_telp"]; | ||
$reg->password = $_POST["password"]; | ||
|
||
$user = $reg->register(); | ||
|
||
header("Location: ../login"); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,247 @@ | ||
<?php | ||
|
||
class DB { | ||
public $conn; | ||
|
||
function __construct($servername,$username,$password,$dbname) | ||
{ | ||
$this->conn = new mysqli($servername,$username,$password,$dbname); | ||
if ($this->conn->connect_error) { | ||
die("Connection failed: " . $this->conn->connect_error); | ||
} | ||
} | ||
|
||
function getConn() | ||
{ | ||
return $this->conn; | ||
} | ||
|
||
function query($query,$type,...$params) | ||
{ | ||
$stmt = $this->conn->prepare($query); | ||
$stmt->bind_param($type, ...$params); | ||
return $stmt; | ||
} | ||
} | ||
|
||
class RegisterUser | ||
{ | ||
public $nama,$username,$password,$no_ktp,$no_telp,$email,$db; | ||
|
||
function __construct(DB $db) | ||
{ | ||
$this->db = $db; | ||
} | ||
|
||
function register() | ||
{ | ||
|
||
$check = $this->db->query( | ||
"SELECT * FROM user WHERE email = ?", | ||
"s", | ||
$this->email | ||
); | ||
$check->execute(); | ||
$res = $check->get_result(); | ||
if ($res->num_rows > 0) | ||
{ | ||
header("location:../registrasi?err=2"); | ||
exit; | ||
} | ||
|
||
$stmt = $this->db->query( | ||
"INSERT INTO user (nama,email,username,no_ktp,no_telp,password) values (?,?,?,?,?,?)", | ||
"ssssss", | ||
$this->nama, | ||
$this->email, | ||
$this->username, | ||
$this->no_ktp, | ||
$this->no_telp, | ||
$this->password | ||
); | ||
|
||
$stmt->execute(); | ||
|
||
$stmt = $this->db->query( | ||
"SELECT * FROM user WHERE username = ?", | ||
"s", | ||
$this->username | ||
); | ||
|
||
$stmt->execute(); | ||
$res = $stmt->get_result(); | ||
$data = $res->fetch_assoc(); | ||
return $data; | ||
} | ||
} | ||
|
||
class User | ||
{ | ||
public $db,$nama,$username,$email,$no_ktp,$no_telp,$password; | ||
|
||
function __construct(DB $db,$id) | ||
{ | ||
$this->db = $db; | ||
$stmt = $this->db->query( | ||
"SELECT * FROM user WHERE id = ?;", | ||
"i", | ||
intval($id) | ||
); | ||
|
||
$stmt->execute(); | ||
$res = $stmt->get_result(); | ||
$data = $res->fetch_assoc(); | ||
$this->nama = $data["nama"]; | ||
$this->username = $data["username"]; | ||
$this->email = $data["email"]; | ||
$this->no_ktp = $data["no_ktp"]; | ||
$this->no_telp = $data["no_telp"]; | ||
$this->password = $data["password"]; | ||
} | ||
} | ||
|
||
class Admin | ||
{ | ||
public $db,$username,$password; | ||
|
||
function __construct(DB $db,$id) | ||
{ | ||
$this->db = $db; | ||
$stmt = $this->db->query( | ||
"SELECT * FROM admin WHERE id = ?;", | ||
"i", | ||
intval($id) | ||
); | ||
|
||
$stmt->execute(); | ||
$res = $stmt->get_result(); | ||
$data = $res->fetch_assoc(); | ||
$this->username = $data["username"]; | ||
$this->password = $data["password"]; | ||
} | ||
} | ||
|
||
class LoginUser | ||
{ | ||
public $db,$email,$password; | ||
|
||
function __construct(DB $db) | ||
{ | ||
$this->db = $db; | ||
} | ||
|
||
function login() | ||
{ | ||
$stmt = $this->db->query( | ||
"SELECT * FROM user WHERE email = ? AND password = ?;", | ||
"ss", | ||
$this->email, | ||
$this->password | ||
); | ||
$stmt->execute(); | ||
$res = $stmt->get_result(); | ||
$data = $res->fetch_assoc(); | ||
return $data; | ||
} | ||
} | ||
|
||
class LoginAdmin | ||
{ | ||
public $db,$username,$password; | ||
|
||
function __construct(DB $db) | ||
{ | ||
$this->db = $db; | ||
} | ||
|
||
function login() | ||
{ | ||
$stmt = $this->db->query( | ||
"SELECT * FROM admin WHERE username = ? AND password = ?;", | ||
"ss", | ||
$this->username, | ||
$this->password | ||
); | ||
$stmt->execute(); | ||
$res = $stmt->get_result(); | ||
$data = $res->fetch_assoc(); | ||
return $data; | ||
} | ||
} | ||
|
||
// Tambah Kategori | ||
class Kategori | ||
{ | ||
public static $kategori = ["fiksi","filsafat","religi","sains","komputer","antropologi","sejarah","musik","bisnis","biografi"]; | ||
public $db,$username,$password; | ||
|
||
function __construct(DB $db) | ||
{ | ||
$this->db = $db; | ||
} | ||
|
||
public function getBukuByKategori($kat) | ||
{ | ||
$res = $this->db->conn->query( | ||
"SELECT * FROM ktgr_$kat" | ||
); | ||
|
||
return $res; | ||
} | ||
|
||
} | ||
|
||
class Buku | ||
{ | ||
public $db,$judul,$pengarang,$foto,$preview; | ||
|
||
function __construct(DB $db) | ||
{ | ||
$this->db = $db; | ||
} | ||
|
||
function getBukuById($id) | ||
{ | ||
$stmt = $this->db->query( | ||
"SELECT * FROM buku WHERE id = ?", | ||
"i", | ||
$id | ||
); | ||
$stmt->execute(); | ||
$res = $stmt->get_result(); | ||
return $res->fetch_assoc(); | ||
} | ||
|
||
function uploadFoto($foto) | ||
{ | ||
$foto_name = strval(rand(1,999999)).$foto["name"]; | ||
move_uploaded_file($foto["tmp_name"],"../foto_buku/".$foto_name); | ||
$this->foto = $foto_name; | ||
} | ||
|
||
function tambah($kat) | ||
{ | ||
$stmt = $this->db->query( | ||
"INSERT INTO buku (judul,pengarang,foto,preview) VALUES (?,?,?,?)", | ||
"ssss", | ||
$this->judul,$this->pengarang,$this->foto,$this->preview | ||
); | ||
$stmt->execute(); | ||
$insertid = $stmt->insert_id; | ||
|
||
foreach (Kategori::$kategori as $k) | ||
{ | ||
if (isset($_POST["ktgr_".$k])) | ||
{ | ||
$stmt = $this->db->query( | ||
"INSERT INTO ktgr_$k (id_buku) VALUES (?) ", | ||
"i", | ||
$insertid | ||
); | ||
$stmt->execute(); | ||
} | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
require "classes.php"; | ||
|
||
$db = new DB("localhost","root","","library.id"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.bookbg { | ||
background: url("../img/undraw_Books_l33t.svg") no-repeat center center; | ||
-webkit-background-size: cover; | ||
-moz-background-size: cover; | ||
-o-background-size: cover; | ||
background-size: cover; | ||
} | ||
|
||
.text-outline { | ||
text-shadow: 0px 0px 10px black; | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+129 KB
Library.id/foto_buku/61741467885762_373415333537545_6946300485276008448_n.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
require "connect.php"; | ||
|
||
session_start(); | ||
|
||
if ($_SESSION["role"] == "user") | ||
{ | ||
$user = new User($db, $_SESSION["id"]); | ||
require "view/homepage-user.php"; | ||
} | ||
else | ||
{ | ||
$admin = new Admin($db, $_SESSION["id"]); | ||
require "view/tambahbuku.php"; | ||
} | ||
|
||
?> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.