Exemplo n.º 1
0
function theme_navbar($show_profile = false, $roll = 0)
{
    ?>
      <!-- Sidebar -->
      <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="index.php"><i class="fa fa-keyboard-o fa-lg"> <?php 
    echo site_name;
    ?>
</i></a>
        </div>

        <!-- Page Links -->
        <div class="collapse navbar-collapse navbar-ex1-collapse">
          <ul class="nav navbar-nav side-nav">
            <?
            foreach(db_select('pages', 'name, path, icon') as $page) {
                echo '<li';
                if(basename($_SERVER['PHP_SELF']) == $page['path'])
                    echo ' class="active"';
                echo '><a href="' . $page['path'] . '"><i class="fa ' . $page['icon']. ' fa-lg"> ' . $page['name'] . '</i></a></li>' . PHP_EOL;
            }
            ?>
          </ul>
          
          <!-- Profile -->
          <?
          if($show_profile) {
          $name = db_select_where('students', 'name', 'roll='.$roll);
          $name = $name[0];
          ?>
          <ul class="nav navbar-nav navbar-right navbar-user">
            <li class="dropdown user-dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user"></i> <? echo $name['name'] ?> <b class="caret"></b></a>
              <ul class="dropdown-menu">
                <li><a href="details.php?roll=<? echo $roll; ?>"><i class="fa fa-user"></i> View My Profile</a></li>
                <li><a href="edit.php"><i class="fa fa-edit"></i> Edit My Profile</a></li>
                <li><a href="change.php"><i class="fa fa-unlock"></i> Change Password</a></li>
                <li class="divider"></li>
                <li><a href="logout.php"><i class="fa fa-power-off"></i> Log Out</a></li>
              </ul>
            </li>
          </ul>
          <?
          }
          ?>
        </div><!-- /.navbar-collapse -->
      </nav>
      <div id="page-wrapper">
<?php 
}
Exemplo n.º 2
0
<?php

include 'include.php';
$login_success = false;
if ($_POST) {
    $roll = $_POST['roll'];
    $password = $_POST['password'];
    $result = db_select_where('students', 'roll,name', 'roll=' . $roll . ' and md5("' . $password . '")=password');
    if ($result) {
        $token = uniqid();
        setcookie("roll", $roll);
        setcookie("token", $token);
        $login_query = 'update students set token="' . $token . '" where roll=' . $roll;
        if (db_exec_only($login_query)) {
            $login_success = true;
        }
    }
}
theme_header('Login');
theme_navbar($login_success, $roll);
?>
        <div class="col-lg-5">
        <h2><i class="fa fa-sign-in fa-fw"></i> Login <small>Get access student database</small></h2>
        <?
        if($login_success)
            login_success();
        else {
            if($_POST) {
                login_error();
            }
            theme_login_form();
Exemplo n.º 3
0
<?php

include 'include.php';
$user_exists = false;
$field_incomplete = false;
$register_success = false;
if ($_POST) {
    $roll = $_POST['roll'];
    $name = $_POST['name'];
    $password = $_POST['password'];
    if (empty($roll) or empty($name)) {
        $field_incomplete = true;
    } else {
        $result = db_select_where('students', 'roll', 'roll=' . $roll);
        if ($result) {
            $user_exists = true;
        } else {
            $register_query = sprintf('insert into students (roll,name,password) values (%d, "%s", md5("%s"))', $roll, $name, $password);
            if (db_exec_only($register_query)) {
                $register_success = true;
            }
        }
    }
}
theme_header('Register');
theme_navbar($verified_user, $roll);
?>
        <div class="col-lg-5">
        <h2><i class="fa fa-plus fa-fw"></i> Register <small>Add a new student to database</small></h2>
        <?
        if($user_exists) {
Exemplo n.º 4
0
$success = false;

if($_POST)
{
    $querystr = "update students set ";
    $params = array();
    foreach($_POST as $key => $value)
    {
        if($key != 'roll')
            $params[] = $key . '="' . mysql_escape_string($value) . '"';
    }
    $querystr = $querystr . join(', ', $params) . ' where roll = ' . $roll;
    $success = db_exec_only($querystr);
}

$student = db_select_where('students', 'roll,name,birthdate,email,cell_number,emergency_number,hall_name,room_no,address', 'roll='.$roll);
$student = $student[0];
$fields = array_keys($student);

foreach(db_select('icons', 'field,icon') as $icon)
    $icons[$icon['field']] = $icon['icon'];

theme_header('Edit Profile | ' . $student['name']);
theme_navbar($verified_user, $roll);

if($verified_user) {
?>
        <div class="col-lg-9">
        <h2><i class="fa fa-user fa-fw"></i><? echo $student['name']; ?><small> Edit details</small></h2>
        </div>
        <div class="col-lg-5">
Exemplo n.º 5
0
<?php

$verified_user = false;
$roll = $_COOKIE['roll'];
$token = $_COOKIE['token'];
if (empty($roll)) {
    $roll = 0;
}
if ($roll and $token) {
    $result = db_select_where('students', 'roll', 'roll=' . $roll . ' and token="' . $token . '"');
}
if ($result) {
    $verified_user = true;
} else {
    $verified_user = false;
}