-
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
1 parent
b73591c
commit cb403f2
Showing
38 changed files
with
1,366 additions
and
0 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 @@ | ||
vendor/ |
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,19 @@ | ||
<?php | ||
|
||
namespace Controller; | ||
session_start(); | ||
|
||
class AdminBook{ | ||
|
||
public function get(){ | ||
if($_SESSION["admin"]==null){ | ||
header("Location: /illegal"); | ||
}else{ | ||
$books = \Models\Admin::get_books(); | ||
$books["users"] = str_replace(";",",",$books["users"]); | ||
echo \View\Loader::make()->render("templates/adminbook.twig", array( | ||
books => $books | ||
)); | ||
} | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace Controller; | ||
session_start(); | ||
|
||
class AdminHome{ | ||
public function get(){ | ||
if($_SESSION["admin"]==null){ | ||
header("Location: /illegal"); | ||
}else{ | ||
echo \View\Loader::make()->render("templates/adminhome.twig",array( | ||
name => $_SESSION["admin"], | ||
)); | ||
} | ||
} | ||
|
||
} |
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,30 @@ | ||
<?php | ||
|
||
namespace Controller; | ||
session_start(); | ||
$_SESSION["user"] = null; | ||
$_SESSION["admin"] = null ; | ||
|
||
|
||
class AdminLog{ | ||
public function get(){ | ||
echo \View\Loader::make()->render("templates/adminsignin.twig", array( | ||
error => false | ||
)); | ||
} | ||
public function post(){ | ||
$usr = $_POST["usr"]; | ||
$pass = $_POST["pass"]; | ||
$passhash = hash("sha256",$pass); | ||
|
||
if(\Models\Admin::login($usr,$passhash)){ | ||
$_SESSION["admin"] = $usr; | ||
header("Location: /adminhome"); | ||
} | ||
else{ | ||
echo \View\Loader::make()->render("templates/adminsignin.twig", array( | ||
error => true | ||
)); | ||
} | ||
} | ||
} |
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 | ||
|
||
namespace Controller; | ||
session_start(); | ||
|
||
class AdminReq{ | ||
public function get(){ | ||
if($_SESSION["admin"]==null){ | ||
header("Location: /illegal"); | ||
}else{ | ||
echo \View\Loader::make()->render("templates/adminreq.twig",array( | ||
requests => \Models\Admin::get_req() | ||
)); | ||
} | ||
} | ||
public function post(){ | ||
$data = json_decode(file_get_contents('php://input'), true); | ||
$reqid = $data["reqid"]; | ||
$action = $data["action"]; | ||
if(\Models\Admin::admin_req($reqid,$action)){ | ||
echo "{\"status\":\"Request processed successful\"}"; | ||
}else{ | ||
echo "{\"status\":\"Request has failed\"}"; | ||
} | ||
} | ||
} |
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 | ||
|
||
namespace Controller; | ||
session_start(); | ||
|
||
class BookDel{ | ||
public function get(){ | ||
if($_SESSION["admin"]==null){ | ||
header("Location: /illegal"); | ||
}else{ | ||
echo \View\Loader::make()->render("templates/bookdel.twig"); | ||
} | ||
} | ||
public function post(){ | ||
$bid = $_POST['bid']; | ||
if(\Models\Admin::book_del($bid)){ | ||
echo \View\Loader::make()->render("templates/bookdel.twig",array( | ||
stat => 1 | ||
)); | ||
}else{ | ||
echo \View\Loader::make()->render("templates/bookdel.twig",array( | ||
stat => 2 | ||
)); | ||
} | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
|
||
namespace Controller; | ||
session_start(); | ||
|
||
class BookReg{ | ||
public function get(){ | ||
if($_SESSION["admin"]==null){ | ||
header("Location: /illegal"); | ||
}else{ | ||
echo \View\Loader::make()->render("templates/bookreg.twig"); | ||
} | ||
} | ||
public function post(){ | ||
$name = $_POST['name']; | ||
$author = $_POST['author']; | ||
$publisher = $_POST['publisher']; | ||
$maxqty = $_POST['qty']; | ||
if(\Models\Admin::book_reg($name,$author,$publisher,$maxqty)){ | ||
echo \View\Loader::make()->render("templates/bookreg.twig",array( | ||
stat => 2 | ||
)); | ||
}else{ | ||
echo \View\Loader::make()->render("templates/bookreg.twig",array( | ||
stat => 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,13 @@ | ||
<?php | ||
|
||
namespace Controller; | ||
session_start(); | ||
|
||
$_SESSION["user"] = null; | ||
$_SESSION["admin"] = null; | ||
|
||
class Home{ | ||
public function get(){ | ||
echo \View\Loader::make()->render("templates/welcome.twig"); | ||
} | ||
} |
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,9 @@ | ||
<?php | ||
|
||
namespace Controller; | ||
|
||
class IllegalAccess{ | ||
public function get(){ | ||
echo \View\Loader::make()->render("templates/illaccess.twig"); | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
namespace Controller; | ||
session_start(); | ||
|
||
class UserBook{ | ||
public function get(){ | ||
if($_SESSION["user"]==null){ | ||
header("Location: /illegal"); | ||
}else{ | ||
echo \View\Loader::make()->render("templates/userbook.twig",array( | ||
books => \Models\User::get_books() | ||
)); | ||
} | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
|
||
namespace Controller; | ||
session_start(); | ||
|
||
class UserDets{ | ||
public function get(){ | ||
if($_SESSION["admin"]==null){ | ||
header("Location: /illegal"); | ||
}else{ | ||
echo \View\Loader::make()->render("templates/userdets.twig"); | ||
} | ||
} | ||
public function post(){ | ||
$usr = $_POST["usr"]; | ||
$row = \Models\Admin::user_dets($usr); | ||
if($row==false){ | ||
echo \View\Loader::make()->render("templates/userdets.twig",array( | ||
stat => 2, | ||
)); | ||
}else{ | ||
echo \View\Loader::make()->render("templates/userdets.twig",array( | ||
stat => 1, | ||
dat => $row | ||
)); | ||
} | ||
} | ||
|
||
} |
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,19 @@ | ||
<?php | ||
|
||
namespace Controller; | ||
session_start(); | ||
|
||
class UserHome{ | ||
public function get(){ | ||
if($_SESSION["user"]==null){ | ||
header("Location: /illegal"); | ||
}else{ | ||
echo \View\Loader::make()->render("templates/userhome.twig",array( | ||
name => $_SESSION["user"], | ||
checkout => \Models\User::get_checkout($_SESSION["user"]), | ||
pendreqs => \Models\User::get_pendreq($_SESSION["user"]), | ||
)); | ||
} | ||
} | ||
|
||
} |
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,21 @@ | ||
<?php | ||
|
||
namespace Controller; | ||
session_start(); | ||
|
||
class UserRequest{ | ||
public function post(){ | ||
$data = json_decode(file_get_contents('php://input'), true); | ||
$bid = $data['bid']; | ||
$type = $data['type']; | ||
$usr = $_SESSION['user']; | ||
$dt = date("Y-m-d h:i:sa"); | ||
$res = \Models\User::set_req($usr,$bid,$type,$dt); | ||
if(res){ | ||
echo "{\"status\":\"Request successful\"}"; | ||
} | ||
else{ | ||
echo "{\"status\":\"Request unsuccessful\"}"; | ||
} | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
namespace Controller; | ||
session_start(); | ||
$_SESSION["user"] = null; | ||
$_SESSION["admin"] = null ; | ||
|
||
|
||
class UserLog{ | ||
public function get(){ | ||
echo \View\Loader::make()->render("templates/usersignin.twig", array( | ||
error => false | ||
)); | ||
} | ||
|
||
public function post(){ | ||
$usr = $_POST["usr"]; | ||
$pass = $_POST["pass"]; | ||
$passhash = hash("sha256",$pass); | ||
|
||
if(\Models\User::login($usr,$passhash)){ | ||
$_SESSION["user"] = $usr; | ||
header("Location: /userhome"); | ||
} | ||
else{ | ||
echo \View\Loader::make()->render("templates/usersignin.twig", array( | ||
error => true | ||
)); | ||
} | ||
} | ||
} |
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,36 @@ | ||
<?php | ||
|
||
namespace Controller; | ||
|
||
class UserSignUp{ | ||
public function get(){ | ||
echo \View\Loader::make()->render("templates/usersignup.twig", array( | ||
error => false | ||
)); | ||
} | ||
|
||
public function post(){ | ||
$name = $_POST["name"]; | ||
$email = $_POST["email"]; | ||
$phone = $_POST["phone"]; | ||
$usr = $_POST["usr"]; | ||
$pass = $_POST["pass"]; | ||
$repass = $_POST["repass"]; | ||
if($pass==$repass && preg_match("/^[a-zA-Z0-9 ]+$/",$name) && preg_match("/^[a-zA-Z0-9]+$/",$usr) && preg_match("/^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+$/",$email) && preg_match("/^[0-9]+$/",$phone)){ | ||
$pass = hash("sha256",$pass); | ||
if(\Models\User::user_reg($usr,$name,$email,$phone,$pass)){ | ||
echo \View\Loader::make()->render("templates/usersignup.twig", array( | ||
error => 1 | ||
)); | ||
}else{ | ||
echo \View\Loader::make()->render("templates/usersignup.twig", array( | ||
error => 2 | ||
)); | ||
} | ||
}else{ | ||
echo \View\Loader::make()->render("templates/usersignup.twig", array( | ||
error => 2 | ||
)); | ||
} | ||
} | ||
} |
Oops, something went wrong.