<?php

/**
 * Created by PhpStorm.
 * User: JayDz
 * Date: 15/07/15
 * Time: 2:54 PM
 */
require_once './controller/UserCtrl.php';
require_once './model/User.php';
echo '<br><br><br><br>';
foreach ($_POST as $key => $value) {
    //    echo $key.': '.$value.'<br>';
    if ($key == 'uid') {
        if (UserCtrl::has($value)) {
            echo ':::Username already exists!:::';
        } else {
            $pwd = 'qwerty';
            if (strlen($_POST['pwd']) > 0) {
                $pwd = $_POST['pwd'];
            }
            $u = new User($value, $pwd);
            $u->setType($_POST['type']);
            UserCtrl::add($u);
            echo 'okkkk';
        }
    }
}
Exemple #2
0
<?php

session_start();
require_once './controller/UserCtrl.php';
$b = isset($_COOKIE['uid']) && $_COOKIE['uid'] != '';
$admin = isset($_SESSION['admin']) && $_SESSION['admin'] != '' ? $_SESSION['admin'] : 'abort';
if (!$b) {
    echo '<script>window.location.href = "login.php";</script>';
} else {
    if (UserCtrl::getType($_COOKIE['uid']) != 1903 || $admin != '^f8fg3j5&(:c3') {
        echo '<script>window.location.href = "admin-login.php";</script>';
    } else {
        $valid = ['admin', '0', '1', '2', '3', '4', '5', '10', '11', '12', '13', '14', '15', '16', '17', '18', '20'];
        $page = isset($_GET['p']) ? $_GET['p'] : (isset($_POST['p']) ? $_POST['p'] : null);
        if (is_null($page)) {
            $content = 'view/dashboard.php';
        } else {
            if (in_array($page, $valid)) {
                switch ($page) {
                    case '0':
                        $url = 'a_pretest';
                        break;
                    case '1':
                        $url = 'a_posttest';
                        break;
                    case '2':
                        $url = 'a_survey';
                        break;
                    case '3':
                        $url = 'a_users';
                        break;
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>
<div class="container hidden-xs" style="margin-top: 50px;"></div>
<div class="container">
    <div class="row">
        <li class="user-dd dropdown hidden-xs">
            <div class="user dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                <?php 
echo $_COOKIE['uid'];
?>
<span style="margin-left: 10px" class="glyphicon glyphicon-chevron-down"></span>
            </div>
            <ul class="dropdown-menu">
                <?php 
if (UserCtrl::isAdmin($_COOKIE['uid'])) {
    ?>
                    <li><a href="admin.php">Admin CP</a></li>
                    <li role="separator" class="divider"></li>
                <?php 
}
?>
<!--                <li><a href="change-password.php">Change Password</a></li>-->
                <li><a href="login.php?a=logout">Logout</a></li>
            </ul>
        </li>
    </div>
    <div class="row">
        <div class="row step text-center">
            <div id="index.php?p=1&c=1" class="st col-xs-offset-1 col-xs-2 nav-step <?php 
echo $p1;
Exemple #4
0
        $ctrl = new LocationCtrl();
        break;
    case 'service':
        require 'Controllers/ServiceCtrl.php';
        $ctrl = new ServiceCtrl();
        break;
    case 'Inventory':
        require 'Controllers/Inventory.php';
        $ctrl = new InventoryCtrl();
        break;
    case 'brand':
        require 'Controllers/BrandCtrl.php';
        $ctrl = new BrandCtrl();
        break;
    case 'model':
        require 'Controllers/ModelCtrl.php';
        $ctrl = new ModelCtrl();
        break;
    case 'Reporte':
        require 'Controllers/ReporteCtrl.php';
        $ctrl = new ReporteCtrl();
        break;
    case 'vehicle':
        require 'Controllers/VehicleCtrl.php';
        $ctrl = new VehicleCtrl();
        break;
    default:
        require 'Controllers/UserCtrl.php';
        $ctrl = new UserCtrl();
}
$ctrl->run();
<?php

/**
 * Created by PhpStorm.
 * User: JayDz
 * Date: 15/07/15
 * Time: 2:54 PM
 */
require_once './controller/UserCtrl.php';
echo '<br><br><br><br>';
foreach ($_GET as $key => $value) {
    echo $key . ': ' . $value . '<br>';
    if ($key == 'id') {
        UserCtrl::remove($value);
        echo 'okkkk';
    }
}
?>

<script>
    window.location.href = 'admin.php?p=3';
</script>
Exemple #6
0
                 header('Location: index.php?p=1&c=2');
             } else {
                 $url = 'post_done';
             }
         }
     }
     break;
 case '15':
     $title = 'ATS - Survey';
     if (!UserCtrl::isDone(1)) {
         header('Location: index.php?p=1');
     } else {
         if (!UserCtrl::isDone(2)) {
             header('Location: index.php?p=2');
         } else {
             if (!UserCtrl::isDone(3)) {
                 header('Location: index.php?p=1&c=2');
             } else {
                 $url = 'survey_done';
             }
         }
     }
     break;
 case '21':
     $title = 'ATS - View Test';
     $url = 'view_test';
     break;
 default:
     $title = 'ATS - Homepage';
     header('Location: index.php');
     break;
<?php

/**
 * Created by PhpStorm.
 * User: JayDz
 * Date: 10/07/15
 * Time: 12:02 AM
 */
require_once './controller/QuestionCtrl.php';
require_once './controller/UserCtrl.php';
if (!UserCtrl::isDone(2)) {
    $uid = $_COOKIE['uid'];
    QuestionCtrl::submitTest(new Answers($uid, 3));
}
?>

<div class="clear-top hidden-xs"></div>
<div class="container">
<div class="jumbotron">
    <h2>Congrats!</h2>
    <p>Let's do some questions to see how better you are now xD.</p>
    <p><a class="btn btn-primary btn-lg" href="index.php?p=1&c=2" role="button">
            <span class="glyphicon glyphicon-chevron-right"></span>&nbsp;&nbsp; Do post-test</a></p>
</div>
</div>
 /**
  * @return string
  * @param User $user
  */
 public static function add($user)
 {
     if (UserCtrl::has($user->getUsername())) {
         return 'Duplicate User!';
     } else {
         $db = DB::getConn();
         $stm = $db->prepare('insert into Users (username, password, type) values (:uid, :pwd, :type)');
         $stm->bindParam(':uid', $user->getUsername());
         $stm->bindParam(':pwd', $user->getPassword());
         $stm->bindParam(':type', $user->getType());
         return $stm->execute();
     }
 }
require_once './controller/SurveyCtrl.php';
require_once './controller/UserCtrl.php';
$uid = $_COOKIE['uid'];
foreach ($_POST as $key => $value) {
    $param_name = 'r::';
    if (substr($key, 0, strlen($param_name)) == $param_name) {
        $sid = explode('::', $key)[1];
        if (isset($_POST['c::' . $sid]) && $_POST['c::' . $sid] != '') {
            $comment = $_POST['c::' . $sid];
        } else {
            $comment = '';
        }
        $vote = new Vote($sid, $uid, $value, $comment);
        SurveyCtrl::vote($vote);
    }
}
if (!UserCtrl::isDone(4)) {
    QuestionCtrl::submitTest(new Answers($uid, 4));
}
?>

<div class="clear-top hidden-xs"></div>
<div class="container">
<div class="jumbotron">
    <h2>Thanks a lot xD</h2>
    <p>You can finally check your results now.</p>
    <p><a class="btn btn-primary btn-lg" href="index.php?p=5" role="button">
            <span class="glyphicon glyphicon-chevron-right"></span>&nbsp;&nbsp; View Results</a>
    </p>
</div>
</div>
<?php

session_start();
require_once './controller/UserCtrl.php';
$uid = isset($_POST['username']) ? $_POST['username'] : '';
$pwd = isset($_POST['password']) ? $_POST['password'] : '';
if (UserCtrl::getType($_COOKIE['uid']) != 1903) {
    echo '<script>window.location.href="index.php";</script>';
}
if ($uid != '' && $pwd != '') {
    if (UserCtrl::login(new User($uid, $pwd)) && UserCtrl::getType($uid) == 1903) {
        $_SESSION['admin'] = '^f8fg3j5&(:c3';
        echo '<script>window.location.href="admin.php";</script>';
    } else {
        if (UserCtrl::login(new User($uid, $pwd)) && UserCtrl::getType($uid) != 1903) {
            setcookie('uid', $uid);
            echo '<script>alert("You dont have admin access. Redirect to homepage");</script>';
            echo '<script>window.location.href="index.php";</script>';
        } else {
            echo '<script>alert("Incorrect username/password.");</script>';
        }
    }
}
?>


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
<?php

/**
 * Created by PhpStorm.
 * User: JayDz
 * Date: 15/07/15
 * Time: 2:54 PM
 */
require_once './controller/UserCtrl.php';
require_once './model/User.php';
echo '<br><br><br><br>';
foreach ($_GET as $key => $value) {
    //    echo $key.': '.$value.'<br>';
    if ($key == 'id') {
        UserCtrl::resetPassword($value);
        echo 'okkkk';
    }
}
?>

<script>
    window.location.href = 'admin.php?p=3';
</script>
Exemple #12
0
<?php

require_once './controller/UserCtrl.php';
$arr = UserCtrl::getUserList();
?>

<ol class="breadcrumb">
    <li><a href="admin.php">Admin CP</a></li>
    <li class="active">User List</li>
</ol>

<h1 class="page-header">Students
    <div class="pull-right">
        <!-- Button trigger modal -->
        <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#new-user">
            <span class="glyphicon glyphicon-plus"></span> New Student</a>
        </button>


        <!-- Modal -->
        <form id="new-user-form" action="admin.php" method="post">
            <input type="hidden" name="p" value="16">
            <input type="hidden" name="type" value="1">
            <div class="modal fade" id="new-user" tabindex="-1" role="dialog">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-body">
                            <input id="uid-u" name="uid" type="text" class="form-control" placeholder="username">
                            <input id="pwd-u" name="pwd" type="password" class="form-control"
                                   placeholder="password, leave it blank to set default 'qwerty'">
                        </div>
Exemple #13
0
        unset($_COOKIE['uid']);
        unset($_SESSION['admin']);
        setcookie("uid", "", time() - 3600);
        echo '<script>window.location.href = "login.php";</script>';
        $b = false;
    }
}
if (isset($_COOKIE['uid']) && $_COOKIE['uid'] != '') {
    echo '<script>window.location.href = "index.php";</script>';
    $b = false;
}
if (isset($_POST['u']) && isset($_POST['p'])) {
    $b = false;
    $u = $_POST['u'];
    $p = $_POST['p'];
    if (UserCtrl::login(new User($u, $p))) {
        echo 'okkkk';
    } else {
        echo 'naaah';
    }
}
?>

<?php 
if ($b) {
    ?>
<!DOCTYPE html>
<html class="login">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">