Example #1
0
 /**
  * login process
  */
 public static function login()
 {
     // form validation
     if (!filter_input(INPUT_POST, "form_token") || Form::isFormTokenValid(filter_input(INPUT_POST, "form_token"))) {
         View::setMessageFlash("danger", "Form tidak valid");
         return FALSE;
     }
     if (!filter_input(INPUT_POST, "username") || !filter_input(INPUT_POST, "password")) {
         View::setMessageFlash("danger", "Masukkan Username dan Password");
         return FALSE;
     }
     $username = filter_input(INPUT_POST, "username", FILTER_SANITIZE_STRING);
     $password = md5(filter_input(INPUT_POST, "password", FILTER_SANITIZE_STRING));
     $mysqli = App::getConnection(true);
     $sql = "SELECT user_id FROM users WHERE username='******' AND password='******'";
     if (!($query = $mysqli->query($sql))) {
         View::setMessageFlash("danger", $mysqli->error);
         return FALSE;
     }
     if ($query->num_rows == 0) {
         View::setMessageFlash("danger", "Username dan Password Salah");
         return FALSE;
     }
     $row = $query->fetch_row();
     $_SESSION['user_id'] = $row[0];
     return TRUE;
 }
Example #2
0
 public function __construct($session_array = '', $car_id = '')
 {
     // Header
     echo parent::getHeader('Car Details');
     // Get the proper car from the session array
     $car = $session_array[$car_id['id']];
     $heading = Heading::newHeading('h5', 'Car Details');
     $content = parent::htmlAlertDiv('warning', $heading);
     echo parent::htmlDiv($content, 8);
     // Display information about the car
     foreach ($car as $attribute => $value) {
         $clean = HTML::cleanAttribute($attribute);
         if ($clean == 'Image') {
             $image = Heading::newHeading('h2', 'Image');
             if (!empty($value)) {
                 $image .= '<img src="' . $value . '" alt="image" class="img-thumbnail">';
             } else {
                 $image .= Heading::newHeading('h4', 'Not Available');
             }
         } else {
             if ($clean == 'Guid') {
                 continue;
             } else {
                 $ctn .= '<b>' . $clean . '</b>: ' . $value . '<br />';
             }
         }
     }
     $ctn .= Link::newLink('<br />Go Back', 'index.php', '_self');
     $well = parent::htmlWell('lg', $ctn);
     echo parent::htmlDiv($image, 6);
     echo parent::htmlDiv($well, 6);
     // Footer
     echo parent::getFooter();
 }
 private function saveProcess()
 {
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         View::setMessageFlash("danger", "Form tidak valid");
         return FALSE;
     }
     // form validation
     if (!filter_input(INPUT_POST, "form_token") || Form::isFormTokenValid(filter_input(INPUT_POST, "form_token"))) {
         View::setMessageFlash("danger", "Form tidak valid");
         return FALSE;
     }
     // required fields
     $filter = array("name" => FILTER_SANITIZE_STRING, "phone" => FILTER_SANITIZE_STRING, "address" => FILTER_SANITIZE_STRING);
     $input = filter_input_array(INPUT_POST, $filter);
     if (in_array('', $input) || in_array(NULL, $input)) {
         View::setMessageFlash("danger", "Kolom tidak boleh kosong");
         return FALSE;
     }
     // set member object
     $staff = Authentication::getUser();
     $staff->setData('name', $input['name']);
     $staff->setData('phone', $input['phone']);
     $staff->setData('address', $input['address']);
     if (!($update = $staff->update())) {
         View::setMessageFlash("danger", "Penyimpanan Gagal");
         return;
     }
     View::setMessageFlash("success", "Penyimpanan Berhasil");
 }
Example #4
0
 public function __construct()
 {
     echo parent::htmlHeader('Home');
     $heading = parent::htmlAlertDiv('info', Heading::newHeading('h4', 'Sign up below'));
     echo parent::htmlDiv($heading, 8);
     $hp_uniq = InputField::hiddenInputField('text', 'form');
     $hp = InputField::hpInputField();
     $firstname = InputField::newInputField('text', 'fname', 'First name');
     $lastname = InputField::newInputField('text', 'lname', 'Last name');
     $email = InputField::newInputField('text', 'email', 'Email');
     $password = InputField::newInputField('password', 'pass', 'Password');
     $password2 = InputField::newInputField('password', 'pass2', 'Re-enter password');
     $captcha = InputField::captchaInputField();
     $submit = Button::newButton('submit', 'btn-primary', 'Register');
     $form = new Form('index.php?page=signup', 'POST');
     $form->addNewInput($hp_uniq);
     $form->addNewInput($hp);
     $form->addNewInput($firstname);
     $form->addNewInput($lastname);
     $form->addNewInput($email);
     $form->addNewInput($password);
     $form->addNewInput($password2);
     $form->addNewInput($captcha);
     $form->addNewInput($submit);
     $content = $form->getForm();
     $content .= Link::newLink('Go Back', 'index.php', '_self');
     echo parent::htmlDiv($content, 4);
     echo parent::htmlFooter();
 }
Example #5
0
 public function __construct()
 {
     // Header
     echo parent::getHeader('New Car');
     $heading = Heading::newHeading('h5', 'Add a New Car');
     $content = parent::htmlAlertDiv('warning', $heading);
     echo parent::htmlDiv($content, 8);
     // newInputField($type, $name, $value, $readonly, $placeholder)
     // I need: type, name, placeholder
     // newButton($type, $name, $class, $text)
     // I need: type, class, text
     $make = InputField::newInputField('text', 'make', '', '', 'Make');
     $model = InputField::newInputField('text', 'model', '', '', 'Model');
     $year = InputField::newInputField('text', 'year', '', '', 'Year');
     $carPic = InputField::newInputField('file', 'file', '', '', 'File Input');
     $submit = Button::newButton('submit', '', 'primary', 'Submit');
     $form = new Form('index.php?page=addcar', 'POST');
     $form->addNewInput($make);
     $form->addNewInput($model);
     $form->addNewInput($year);
     $form->addNewInput($carPic);
     $form->addNewInput($submit);
     $content = $form->getForm();
     $content .= Link::newLink('Go Back', 'index.php', '_self');
     echo parent::htmlDiv($content, 4);
     // Get footer
     echo parent::getFooter();
 }
Example #6
0
 public function __construct()
 {
     echo parent::htmlHeader('Login');
     $heading = Heading::newHeading('h4', '<b>Welcome!</b> Sing in or sing up below.');
     $content = parent::htmlAlertDiv('info', $heading);
     echo parent::htmlDiv($content, 8);
     // Form
     $hp_uniq = InputField::hiddenInputField('text', 'form');
     $hp = InputField::hpInputField();
     $username = InputField::newInputField('text', 'email', 'Email');
     $password = InputField::newInputField('password', 'password', 'Password');
     $captcha = InputField::captchaInputField();
     $submit = Button::newButton('submit', 'btn-primary', 'Sing in');
     $form = new Form('index.php?page=login', 'POST');
     $form->addNewInput($hp_uniq);
     $form->addNewInput($hp);
     $form->addNewInput($username);
     $form->addNewInput($password);
     $form->addNewInput($captcha);
     $form->addNewInput($submit);
     $content = $form->getForm();
     $content .= Paragraph::newParagraph('Not a member yet? Please sing up below!');
     $content .= Link::newLink('Sing up', 'index.php?page=signup', '_self');
     echo parent::htmlDiv($content, 4);
     echo parent::htmlFooter();
 }
Example #7
0
 protected function actionEdit()
 {
     if (isset($_POST['title']) && isset($_POST['text'])) {
         $id = $_GET['id'];
         $article = new News();
         $article->title = $_POST['title'];
         $article->text = $_POST['text'];
         $article->update($id);
     }
     $editart = new View('../view/article_admin.php');
     $editart->article = News::findByPk($_GET['id']);
     $editart->display();
     /*$article = new News();
       $article->title = $_POST['title'];
       $article->text = $_POST['text'];
       $article->update();*/
 }
Example #8
0
 public function __construct($notifications = '', $type = '')
 {
     echo parent::htmlHeader('Notifications');
     $heading = parent::htmlAlertDiv($type, Heading::newHeading('h4', '<b>Results</b>'));
     echo parent::htmlDiv($heading, 8);
     $well = parent::htmlWell($notifications);
     echo parent::htmlDiv($well, 6);
     echo parent::htmlFooter();
 }
Example #9
0
 public function __construct()
 {
     // Header
     echo parent::getHeader('Import CSV File');
     // Check if a csv file exists in the uploads folder
     // If so, display a table and a button to delete the file if necessary
     $dir = 'uploads/*.csv';
     foreach (glob($dir) as $file) {
         // If a csv file exists on the server, process it
         if ($file != NULL) {
             $heading = Heading::newHeading('h5', 'File Being Processed');
             $content = parent::htmlAlertDiv('warning', $heading);
             echo parent::htmlDiv($content, 8);
             $content = '<p><strong>' . basename($file) . '</strong>&ensp;&ensp;';
             $content .= '<span><a href="index.php?page=importcsv&deleteFile=' . $file . '"
       class="btn btn-danger btn-xs" role="button">Remove</a></span></p>';
             echo parent::htmlDiv($content, 6);
             // Open up the file and save its content into an array
             $arrayCSV = array();
             $pathToFile = 'uploads/' . basename($file);
             $handle = fopen($pathToFile, 'r');
             if ($handle) {
                 while (($data = fgetcsv($handle, 1000, ',')) != false) {
                     $arrayCSV[] = $data;
                 }
                 fclose($handle);
             }
             $table = '<br /><br />';
             $table .= Heading::newHeading('h3', 'This table only shows 13 columns and 200 rows');
             $table .= '<br />';
             $table .= CSVTable::generateCSVTable($arrayCSV);
             echo parent::htmlDiv($table, 12);
         }
     }
     // If no csv files in the uploads directory, display the form
     if (glob($dir) == NULL) {
         $heading = Heading::newHeading('h5', 'Upload a CSV file to see its content below
     in a table.');
         $content .= parent::htmlAlertDiv('info', $heading);
         echo parent::htmlDiv($content, 8);
         // Form to upload CSV file
         $csvFile = InputField::newInputField('file', 'file', '', '', 'File Input');
         $submit = Button::newButton('submit', '', 'primary btn-xs', 'Upload');
         $form = new Form('index.php?page=importcsv', 'POST');
         $form->addNewInput($csvFile);
         $form->addNewInput($submit);
         $content = $form->getForm();
         echo parent::htmlDiv($content, 4);
     }
     // Footer
     echo parent::getFooter();
 }
Example #10
0
 public function __construct($session_array = '', $car_id = '')
 {
     // Get header
     echo parent::getHeader('Edit Car');
     // Get the proper car in the array
     $car = $session_array[$car_id['id']];
     $content = parent::htmlAlertDiv('warning', Heading::newHeading('h5', 'Edit or delete the car below'));
     echo parent::htmlDiv($content, 8);
     // newInputField($type, $name, $value, $readonly, $placeholder)
     // newButton($type, $name, $class, $text)
     $form = new Form('index.php?page=editcar', 'POST');
     foreach ($car as $attribute => $value) {
         $clean = HTML::cleanAttribute($attribute, 'false');
         if ($clean == 'guid') {
             // Disable the GUID input field so it cannot be edited
             ${$clean} = InputField::newInputField('text', $clean, $value, 'readonly', 'ID');
             $form->addNewInput(${$clean});
         } else {
             if ($clean == 'image') {
                 $img = Heading::newHeading('h2', 'Image');
                 if (!empty($value)) {
                     $img = '<div class="thumbnail">';
                     $img .= '<img src="' . $value . '" alt="image">';
                     $img .= '</div>';
                     ${$clean} = InputField::newInputField('text', $clean, $value, 'readonly', 'Image Path');
                     $form->addNewInput(${$clean});
                 } else {
                     $img .= Heading::newHeading('h4', 'Not available');
                 }
             } else {
                 // If not a GUID input field, allow for editing
                 ${$clean} = InputField::newInputField('text', $clean, $value);
                 $form->addNewInput(${$clean});
             }
         }
     }
     $carPic = InputField::newInputField('file', 'file', '', '', 'New Picture');
     $save = Button::newButton('submit', 'save', 'success', 'Save');
     $delete = Button::newButton('submit', 'delete', 'danger', 'Delete');
     $form->addNewInput($carPic);
     $form->addNewInput($save);
     $form->addNewInput($delete);
     $content = $form->getForm();
     $content .= Link::newLink('Go Back<br /><br />', 'index.php', '_self') . '</li></ul>';
     echo parent::htmlDiv($img, 6);
     echo parent::htmlDiv($content, 4);
     // Get footer
     echo parent::getFooter();
 }
Example #11
0
 public function __construct($session_array = '')
 {
     // Header
     echo parent::getHeader('Home');
     // Content
     if (!empty($session_array)) {
         $heading = Heading::newHeading('h5', 'Cars Stored in Session');
         $content = parent::htmlAlertDiv('warning', $heading);
         echo parent::htmlDiv($content, 8);
         $content = Table::generateTable($session_array);
         echo parent::htmlDiv($content, 6);
     } else {
         $heading = Heading::newHeading('h5', 'No cars stored in session to be displayed.');
         $content = parent::htmlAlertDiv('danger', $heading);
         $heading = Heading::newHEading('h5', 'Add a new car by clicking the <strong>"Add
     New Car"</strong> link above.');
         $content .= parent::htmlAlertDiv('info', $heading);
         echo parent::htmlDiv($content, 8);
     }
     // Footer
     echo parent::getFooter();
 }
Example #12
0
 public function __construct($basicInfo, $detailedInfo, $salesman = false)
 {
     echo parent::htmlHeader('Car Details');
     $heading = Heading::newHeading('h4', 'Car details');
     $content = parent::htmlAlertDiv('info', $heading);
     echo parent::htmlDiv($content, 8);
     $detailsList = Heading::newHeading('h4', 'Basic information:');
     $detailsList .= ListHTML::carDetailsList($basicInfo);
     echo parent::htmlDiv($detailsList, 6);
     $detailedList = Heading::newHeading('h4', 'Detailed information:');
     $detailedList .= ListHTML::carDetailedList($detailedInfo);
     echo parent::htmlDiv($detailedList, 6);
     // Display the form to edit a car if the user is logged in and the car belongs to the user
     if ($_SESSION['user_session'] && $salesman) {
         $cInfo = $basicInfo[0];
         $hp = InputField::hiddenInputField('text', 'form');
         $img_url = InputField::hiddenImageField($cInfo['Image']);
         $vin_number = InputField::newInputFieldEdit('text', 'vin', 'Vin Number', $cInfo['Vin'], true);
         $price = InputField::newInputFieldEdit('text', 'price', 'Price', $cInfo['Price'], false);
         $condition = InputField::newInputFieldEdit('text', 'condition', 'Condition', $cInfo['Condition'], false);
         $picture = InputField::newInputFieldEdit('file', 'file', 'File Input', 'Value', false);
         $edit = Button::newButtonEdit('submit', 'edit', 'btn-success', 'Edit');
         $delete = Button::newButtonEdit('submit', 'delete', 'btn-danger', 'Delete');
         $form = new Form('index.php?page=editcar', 'POST', false);
         $form->addNewInput($hp);
         $form->addNewInput($img_url);
         $form->addNewInput($vin_number);
         $form->addNewInput($price);
         $form->addNewInput($condition);
         $form->addNewInput($picture);
         $form->addNewInput($edit);
         $form->addNewInput($delete);
         $content = $form->getForm();
         $collapsible = parent::collapsibleDiv('Edit or Delete', $content);
         $collapsible .= '<br /><br /><br /><br /><br /><br /><br /><br />';
         echo parent::htmlDiv($collapsible, 6);
     }
     echo parent::htmlFooter();
 }
Example #13
0
 public function __construct($cars = '', $amountOfPages = '', $page_no = '')
 {
     echo parent::htmlHeader('Home');
     if (!empty($cars)) {
         $heading = Heading::newHeading('h4', 'Cars for sale');
         $content = parent::htmlAlertDiv('info', $heading);
         echo parent::htmlDiv($content, 8);
         $carsTable = Table::displayCarsTable($cars);
         echo parent::htmlDiv($carsTable, 10);
         if ($amountOfPages > 1) {
             $paging = Paging::getPagingLinks($amountOfPages);
             if (isset($page_no) && !empty($page_no)) {
                 $paging .= '<br /><b>Page:</b> ' . $page_no;
             }
             echo parent::htmlDiv($paging, 2);
         }
     } else {
         $heading = Heading::newHeading('h4', 'There are currently no cars for sale');
         $content = parent::htmlAlertDiv('danger', $heading);
         echo parent::htmlDiv($content, 8);
     }
     echo parent::htmlFooter();
 }
Example #14
0
 public function __construct()
 {
     echo parent::htmlHeader('Add New Car');
     $heading = Heading::newHeading('h4', 'Add a new car below');
     $content = parent::htmlAlertDiv('info', $heading);
     echo parent::htmlDiv($content, 8);
     // Form
     $hp = InputField::hiddenInputField('text', 'form');
     $vin_number = InputField::newInputField('text', 'vin', 'Vin Number');
     $price = InputField::newInputField('text', 'price', 'Price');
     $condition = InputField::newInputField('text', 'condition', 'Condition');
     $picture = InputField::newInputField('file', 'file', 'File Input');
     $submit = Button::newButton('submit', 'btn-primary', 'Submit');
     $form = new Form('index.php?page=addcar', 'POST', false);
     $form->addNewInput($hp);
     $form->addNewInput($vin_number);
     $form->addNewInput($price);
     $form->addNewInput($condition);
     $form->addNewInput($picture);
     $form->addNewInput($submit);
     $content = $form->getForm();
     echo parent::htmlDiv($content, 4);
     echo parent::htmlFooter();
 }
Example #15
0
 public function __construct($loginAttempts = '', $userInformation = '', $usersCars = '')
 {
     echo parent::htmlHeader('Profile Information');
     $heading = Heading::newHeading('h4', 'Profile information');
     $content = parent::htmlAlertDiv('info', $heading);
     echo parent::htmlDiv($content, 8);
     // Display users cars if he/she has added any
     if (!empty($usersCars)) {
         $content = Heading::newHeading('h4', 'Cars added by this user:'******'h4', 'Basic user information:');
     $content .= ListHTML::databaseList($userInformation);
     $well = parent::htmlWell($content);
     echo parent::htmlDiv($well, 6);
     // Display the login attemps if user is logged in
     if (isset($_SESSION['user_session']) && !empty($_SESSION['user_session']) && !empty($loginAttempts)) {
         $content = Heading::newHeading('h4', 'Login attempts:');
         $content .= Table::userLoginHistory($loginAttempts);
         echo parent::htmlDiv($content, 6);
     }
     echo parent::htmlFooter();
 }
Example #16
0
 public function render()
 {
     $this->data['user'] = Authentication::getUser()->getData();
     $this->data['content'] = $this->content;
     View::renderPage($this->view, $this->setup, $this->data);
 }
Example #17
0
<?php

use App\App;
use App\View\View;
use App\Authentication\Authentication;
use App\Authentication\LoginController;
include './config.php';
include './autoload.php';
App::begin();
Authentication::authLogin();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (LoginController::login()) {
        View::redirect('./');
    } else {
        View::redirect('./login.php', FALSE);
    }
} else {
    LoginController::loginPage();
}
App::end();
Example #18
0
 private static function redirectLogin($hasMessage = FALSE)
 {
     View::redirect('./logout.php', !$hasMessage);
 }
Example #19
0
 public function index()
 {
     return View::make('CustomersList');
 }
Example #20
0
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <title><?php 
echo View::get('title');
?>
</title>

        <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700,800' rel='stylesheet' type='text/css'>

        <!--main css-->
<?php 
echo View::getCSS();
?>

        <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
    <body>

        <div id="sidebar_overlay"></div>

        <!--BEGIN HEADER-->
Example #21
0
 public static function registerInfoPage()
 {
     $pageSetup = array("title" => "Register Info");
     View::renderPage("auth/register-info.php", $pageSetup);
 }
Example #22
0
<?php

use App\View\View;
use App\View\Form;
use App\View\FormField;
?>
<div class="main-header">
    <h1><i class="fa fa-edit"></i> Edit Profil</h1>
</div>

<?php 
echo View::renderFlashMessages();
?>

<div class="row">
    <div class="col-lg-9">
        <div class="panel panel-default panel-section">
            <div class="panel-heading">
                <div class="panel-title"><i class="fa fa-pencil panel-icon"></i> Edit Profile</div>
            </div>
            <div class="panel-body">
                <?php 
$field_nama = new FormField('Nama Lengkap', 'text', 'name', $data['user']['name'], 'Nama Lengkap');
$field_nama->isRequired(TRUE);
$field_telp = new FormField('Telp./HP', 'text', 'phone', $data['user']['phone'], 'No Telp / HP');
$field_telp->isRequired(TRUE);
$field_address = new FormField('Alamat', 'textarea', 'address', $data['user']['address'], 'Alamat Lengkap');
$field_address->isRequired(TRUE);
$form = new Form('profile-form', 'POST', './?p=staff-profile-save', 'form-horizontal');
$form->addField($field_nama);
$form->addField($field_telp);
Example #23
0
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
    <body style="padding-top: 20px;">
        
        <div class="container">
            <img src="assets/img/logo.png" style="margin-bottom: 20px;">
            <div class="well" style="font-size: 16px;">
                <h3 style="margin-top: 10px;">Selamat Bergabung !</h3>
                <p>
                    Untuk mengaktifkan akun Anda, silahkan lakukan konfirmasi melalui email yang kami kirimkan ke alamat email Anda.
                </p>
                <p>
                    Tidak menerima email konfirmasi? <a href="#">Kirim Ulang</a>
                </p>
                
            </div>
        </div>


        <?php 
echo View::getJS();
?>
    </body>
</html>