Skip to content
Permalink
Newer
Older
100644 20 lines (17 sloc) 535 Bytes
1
<?php
2
defined('APP_DIR') or define('APP_DIR', __DIR__ . '/../app/');
3
include_once(APP_DIR . 'model/User.php');
4
include_once(APP_DIR . 'include/http.php');
5
6
$data = User::authenticated();
7
if (!$data || $data->access != 'admin') {
8
Http::redirect('index.php');
9
}
10
11
/* TODO: Validate input */
12
$params = Http::post_params();
13
$user = new User;
14
$user->username = $params['username'];
15
$user->password = password_hash($params['password'], PASSWORD_DEFAULT);
16
$user->access = $params['access'];
17
$user->save();
18
19
Http::redirect('admin.php');
20
?>
You can’t perform that action at this time.