Skip to content
Snippets Groups Projects
Commit 49f636bd authored by Iqbal's avatar Iqbal
Browse files

Merge branch 'project_structure' of...

Merge branch 'project_structure' of http://gitlab.informatika.org/DagoDev/TugasBesar1_2017 into login-and-register
parents 56bcd03a 72a3eeb3
Branches
No related merge requests found
.container{
width: 100%;
max-width: 1200px;
margin:auto;
}
.row:before,
.row:after {
content:"";
display: table ;
clear:both;
}
[class*='col-'] {
float: left;
min-height: 1px;
width: 16.66%;
}
.col-1{ width: 16.66%; }
.col-2{ width: 33.33%; }
.col-3{ width: 50%; }
.col-4{ width: 66.66%; }
.col-5{ width: 83.33%; }
.col-6{ width: 100%; }
.tab {
outline: 1px solid #004D40;
padding-top:10px;
padding-bottom:10px;
font-weight: 900;
}
.tab.active {
background-color: #00695C;
color : #FAFAFA;
}
.text-right {
text-align: right;
}
.text-center {
text-align: center;
}
.img-circle {
max-width: 170px;
max-height: 170px;
border-radius: 50%;
}
\ No newline at end of file
<?php
// ----------------------- Setting Up Global Connection -----------------------------------
class DB {
private $_db;
static $_instance;
private function __construct() {
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'superadmin';
$dbname = 'db_dagojek';
$this->_db = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass);
$this->_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
private function __clone(){}
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance->_db;
}
}
// ------------------------------ Helper Function ----------------------------------------
function simpleCrypt( $string, $action = 'e' ) {
$secret_key = 'dagojek_key';
$secret_iv = 'dagojek_iv';
$output = false;
$encrypt_method = "AES-256-CBC";
$key = hash( 'sha256', $secret_key );
$iv = substr( hash( 'sha256', $secret_iv ), 0, 16 );
if( $action == 'e' ) {
$output = base64_encode( openssl_encrypt( $string, $encrypt_method, $key, 0, $iv ) );
}
else if( $action == 'd' ){
$output = openssl_decrypt( base64_decode( $string ), $encrypt_method, $key, 0, $iv );
}
return $output;
}
\ No newline at end of file
<?php
class ProfilController {
public static function ProfilHandler() {
// Getting user id from url
if (!isset($_GET['u']) || $_GET['u'] == "") {
echo "Invalid parameter!";
return;
}
// Decrypt user id
$uid = simpleCrypt($_GET['u'], 'd');
try {
// Get connection to database
$dbconn = DB::getInstance();
// Prepare and execute sql query
$stmt = $dbconn->prepare("SELECT * FROM user WHERE id=$uid");
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
$user = $stmt->fetchObject();
if (!$user) {
echo "User not found!";
return;
}
$user->is_driver = 1;
if ($user->is_driver) {
$driver_rating = 4.7;
$driver_order = 1728;
}
require __DIR__.'/../view/profil.php';
} catch (PDOException $e) {
echo "Error: ".$e->getMessage();
}
}
public static function EditHandler() {
echo "TBD";
}
}
\ No newline at end of file
......@@ -7,8 +7,8 @@ $AppInstance = Dagojek::Instance();
$AppInstance->addRoute("/", 'MainController::LoginHandler');
$AppInstance->addRoute("/login", 'MainController::LoginHandler');
$AppInstance->addRoute("/register", 'MainController::DefaultHandler');
$AppInstance->addRoute("/main/profil", 'MainController::DefaultHandler');
$AppInstance->addRoute("/main/profil/edit", 'MainController::DefaultHandler');
$AppInstance->addRoute("/main/profil", 'ProfilController::ProfilHandler');
$AppInstance->addRoute("/main/profil/edit", 'ProfilController::EditHandler');
$AppInstance->addRoute("/main/history", 'MainController::DefaultHandler');
$AppInstance->addRoute("/main/order/", 'MainController::DefaultHandler');
$AppInstance->addRoute("/main/order/select", 'MainController::DefaultHandler');
......
<html>
<head>
<title>DAGO-JEK | Profil</title>
<link rel="stylesheet" type="text/css" href="/style.css">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-3">Logo</div>
<div class="col-3 text-right">
<p>
Hi, <?=$user->username?><br>
Logout
</p>
</div>
</div>
<div class="row">
<div class="col-2 tab text-center">ORDER</div>
<div class="col-2 tab text-center">HISTORY</div>
<div class="col-2 tab text-center active">MY PROFILE</div>
</div>
<div class="row">
<div class="col-5"><h1>MY PROFILE</h1></div>
<div class="col-1 text-right">edit</div>
</div>
<div class="text-center">
<img class="img-circle" src="<?=$user->photo?>"/><br>
<h2>@<?=$user->username?></h2>
<p><?=$user->name?></p>
<?php if ($user->is_driver) : ?>
<p>Driver | <?=$driver_rating?> (<?=$driver_order?> vote<?=($driver_order>1)?'s':''?>)</p>
<?php else : ?>
<p>Non Driver</p>
<?php endif; ?>
<p><?=$user->email?></p>
<p><?=$user->phone?></p>
</div>
<div class="row">
<div class="col-5"><h2>PREFERED LOCATIONS</h2></div>
<div class="col-1 text-right">edit</div>
</div>
<div class="row">
<ul>
<li>Lokasi 1</li>
<li>Lokasi 2</li>
<li>Lokasi 3</li>
<li>Lokasi 4</li>
</ul>
</div>
</div>
</body>
</html>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment