-
Notifications
You must be signed in to change notification settings - Fork 1
/
api_key_list.php
44 lines (39 loc) · 1.57 KB
/
api_key_list.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
require_once('runtime.php');
require_once(ROOT_DIR.'/lib/core/ApiKeyList.class.php');
require_once(ROOT_DIR.'/lib/core/Router.class.php');
require_once(ROOT_DIR.'/lib/core/User.class.php');
$smarty->assign('message', Message::getMessage());
if(isset($_GET['object_type']) AND isset($_GET['object_id'])) {
if($_GET['object_type'] == "router") {
$router = new Router((int)$_GET['object_id']);
$router->fetch();
//Root and owning user can see api keys
if(permission::checkIfUserIsOwnerOrPermitted(PERM_ROOT, $router->getUserId())) {
$api_key_list = new ApiKeyList((int)$_GET['object_id'], 'router');
$smarty->assign('api_key_list', $api_key_list->getList());
$smarty->display("header.tpl.html");
$smarty->display("api_key_list.tpl.html");
$smarty->display("footer.tpl.html");
} else {
Permission::denyAccess(PERM_ROOT, (int)$router->getUserId());
}
} elseif($_GET['object_type'] == "user") {
$user = new User((int)$_GET['object_id']);
$user->fetch();
//Root and owning user can see api keys
if(permission::checkIfUserIsOwnerOrPermitted(PERM_ROOT, $user->getUserId())) {
$api_key_list = new ApiKeyList((int)$_GET['object_id'], 'user');
$smarty->assign('api_key_list', $api_key_list->getList());
$smarty->display("header.tpl.html");
$smarty->display("api_key_list.tpl.html");
$smarty->display("footer.tpl.html");
} else {
Permission::denyAccess(PERM_ROOT, (int)$user->getUserId());
}
}
} elseif(Permission::checkPermission(PERM_ROOT)) {
} else {
//no permission to access this site
}
?>