示例#1
0
<?php

require_once 'autoload.php';
$session = new \website\utils\Session();
?>
<!DOCTYPE html>
<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">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="favicon.ico">

    <title>What's up</title>

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="css/ie10-viewport-bug-workaround.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="//oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="//oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
示例#2
0
<?php

require_once 'autoload.php';
//TODO Move login into class
$session = new \website\utils\Session();
isset($_GET['q']) and $session->isLogged() or die;
$q = \website\db\Escape::escapeSQLLike($_GET['q']);
strlen($q) >= 2 or die;
$q = $q . '%';
$input_parameters = ['q' => $q];
$where = '(first_name LIKE :q OR last_name LIKE :q)';
if (isset($_GET['role']) && \website\model\User::isValidRole($_GET['role'])) {
    $where .= ' AND role = :role';
    $input_parameters['role'] = $_GET['role'];
}
$result = \website\model\User::findWhere($where, $input_parameters, 10, ['id', 'first_name', 'last_name']);
$arrayResult = array_map(function ($e) {
    return $e->toArray();
}, $result);
header('Cache-Control: no-cache, must-revalidate');
header('Content-type: application/json');
echo json_encode(['items' => $arrayResult]);
示例#3
0
<?php

require_once 'autoload.php';
$session = new \website\utils\Session();
if ($session->isLogged()) {
    header('Location: .');
    exit;
}
$method = $_SERVER['REQUEST_METHOD'];
$loginStatus = null;
if ($method == 'POST' && isset($_POST['login']) && isset($_POST['password'])) {
    $login = $_POST['login'];
    $password = $_POST['password'];
    $loginStatus = $session->login($login, $password);
    if ($loginStatus === true) {
        header('Location: .');
        exit;
    }
}
$session->flushAndClose();
?>
<!DOCTYPE html>
<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">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="favicon.ico">