Skip to content
This repository was archived by the owner on Apr 20, 2020. It is now read-only.

Commit 3600fef

Browse files
author
MrCrankHank
committed
version 0.5.2
1 parent d711434 commit 3600fef

File tree

167 files changed

+999
-614
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+999
-614
lines changed

LICENSE

100755100644
File mode changed.

README.md

100755100644
Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,9 @@ https://github.com/MrCrankHank/phpietadmin/wiki/Screens-v05
2424
## Features
2525
Take a look at the github releases for detailed information about the features.
2626

27-
## Since v0.5 has a few design issues, the bugs will all be fixed with version v0.6
28-
## Bugs in the beta of v0.5:
29-
## So far:
30-
- [x] Jquery/javascript is sometimes not executed, when loaded via ajax
31-
- [ ] Target acl cannot be deleted if no initiator acl exists (Page isn't displayed, only error)
32-
- [x] Discovery users are always already added, even if not
33-
- [ ] Adding of multiple discovery users to the daemon might fail
34-
- [x] Config menu update might not work
35-
- [ ] A few unnecessary page reloads
36-
- [ ] Installer isn't working <- should be fixed, to be tested
37-
- [x] Filter table jquery plugin displays hidden rows when searching
38-
- [ ] Login not possible under yet unknown conditions
39-
- [x] Password of discovery user max 12 chars
40-
- [ ] Enable a few special chars in Targets/Add
41-
- [ ] Fix dependencies between models
42-
* Ietaddtarget->ietvolumes->parse_proc_volumes()
43-
* IetVolumes->Ietaddtarget->get_proc_volume_content()
27+
## Bugs in 0.5.1:
28+
- [ ] Target model add acl: Duplication check doesn't work, Target acl is added to the initiator file
29+
- [ ] Dashboard read version from github (not from local file)
4430

4531
## Planned features and todo
4632
In version 0.6:
@@ -54,46 +40,43 @@ In version 0.6:
5440
- [ ] Support for live resizing of targets (with workaround, since iet doesn't support)
5541

5642
* Frontend
57-
- [ ] Config -> MISC -> Idle, no zeros
58-
- [ ] Pie Chart for volume groups
43+
- [ ] Disable the auto logout by using a 0 in the config menu
5944
- [x] Put hostname in title
60-
- [ ] Bar for volume group usage
45+
- [x] Bar for PV/VG usage
6146
- [ ] Bootstrap-table Table Select Checkbox
6247
- [ ] Display input validation with bootstrap css Validation states
6348
- [x] Nested tables for iet volumes and iet sessions (https://github.com/wenzhixin/bootstrap-table-examples/blob/master/options/sub-table.html)
6449
- [ ] Drag & Drop with HTML5
6550
- [ ] Menu to import orphaned objects into database
6651
- [x] Override option, if user is already logged in
67-
- [ ] Use more html5 elements (like autofocus)
68-
- [ ] Use json for tables
6952
- [ ] Create logging gui
53+
- [x] Improved ajax menu with error handling
7054

7155
* Backend
7256
- [ ] Prevent comments from being deleted, when editing a config file
7357
- [x] Create a target model with all functions which are necessary to add/delete/change a target
7458
- [x] Create a lvm model
7559
- [ ] Write phpietadmin-cli
7660
- [ ] Install/Update
77-
- [ ] Import orphaned objects into database
7861
- [x] Basic error logging
7962
- [x] Login/Logout logging
8063
- [x] Debug logging
8164
- [ ] Log also successful messages
8265
- [ ] Rework controller/models
8366
- [ ] Database model
8467
- [x] Dashboard
85-
- [ ] Overview
68+
- [x] Overview
8669
- [ ] Targets
8770
- [x] Lun
8871
- [ ] ACL
8972
- [x] Users
9073
- [x] Sessions
9174
- [ ] Settings
9275
- [ ] Delete
93-
- [ ] Users
94-
- [ ] Objects
76+
- [x] Users
77+
- [x] Objects
9578
- [ ] LVM
96-
- [ ] Services
79+
- [x] Services
9780
- [ ] Config
9881
- [ ] Login/Logout/Reboot/Shutdown
9982
- [x] Use namespaces with basic autoloader
@@ -113,6 +96,7 @@ In version 0.6:
11396
- [ ] Support for apcupsd
11497
- [ ] Manual selection of block devices (input menu already implemented, but logic is missing)
11598
- [ ] HDD temp
99+
- [ ] Pie Chart for volume groups
116100
- [ ] Smart data
117101
- [ ] Config option for production and development
118102
* Production:
@@ -125,6 +109,8 @@ In version 0.6:
125109
- [ ] Create "consistency", which displays if the daemon config and the config file are identically
126110
- [ ] Use composer
127111
- [ ] Use unity testing
112+
- [ ] Use more html5 elements (like autofocus)
113+
- [ ] Use json for tables
128114

129115
Items are completely random ;-)
130116

app/.htaccess

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Options -Indexes

app/config.db

100755100644
0 Bytes
Binary file not shown.

app/controllers/auth.php

100755100644
File mode changed.

app/controllers/config.php

100755100644
File mode changed.

app/controllers/connection.php

100755100644
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ class connection extends Controller {
99
*/
1010
public function status() {
1111
if (isset($_POST['servicename'])) {
12-
$return = $this->std->get_service_status($_POST['servicename']);
13-
echo htmlspecialchars($return[1]);
14-
} else {
15-
echo 'Undefined service name';
12+
$service = $this->model('Service', $_POST['servicename']);
13+
$service->action('status');
14+
$return = $service->get_action_result();
15+
echo htmlspecialchars($return['code']);
1616
}
1717
}
1818

@@ -37,6 +37,6 @@ public function check_session_expired() {
3737
*
3838
*/
3939
public function check_server_online() {
40-
echo 'alive';
40+
echo true;
4141
}
4242
}

app/controllers/dashboard.php

100755100644
File mode changed.

app/controllers/ietusers.php

100755100644
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ public function add_to_db() {
2323
if (isset($_POST['username'], $_POST['password']) && !$this->std->mempty($_POST['username'], $_POST['password'])) {
2424
$_POST['username'] = str_replace(' ', '', $_POST['username']);
2525
$_POST['password'] = str_replace(' ', '', $_POST['password']);
26-
$user = $this->ietuser_model($_POST['username']);
26+
$user = $this->model('Ietuser', $_POST['username']);
2727
$user->add_user_to_db($_POST['password']);
2828
echo json_encode($user->get_action_result());
2929
}
3030
}
3131

3232
public function delete_from_db() {
3333
if (isset($_POST['username']) && !empty($_POST['username'])) {
34-
$user = $this->ietuser_model($_POST['username']);
34+
$user = $this->model('Ietuser', $_POST['username']);
3535
$user->delete_user_from_db();
3636
echo json_encode($user->get_action_result());
3737
}

app/controllers/log.php

100755100644
Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public function config() {
66

77
public function show($param) {
88
if ($param == 'action') {
9-
$data = $this->std->tail('/var/log/phpietadmin/phpietadmin_action.log');
9+
$data = $this->std->tail($this->database->get_config('log_base')['value'] . '/' . $this->database->get_config('action_log')['value']);
1010
if ($data !== false) {
1111
$view = array(
1212
'title' => 'Action',
@@ -20,55 +20,36 @@ public function show($param) {
2020
'type',
2121
'method'
2222
),
23-
'body' => $data
23+
'body' => array_reverse($data)
2424
);
2525

2626
$this->view('table', $view);
2727
} else {
2828
$this->view('message', array('message' => 'The action log file is empty!', 'type' => 'danger'));
2929
}
3030
} else if ($param == 'access') {
31-
$data = $this->std->tail('/var/log/phpietadmin/phpietadmin_access.log');
31+
$data = $this->std->tail($this->database->get_config('log_base')['value'] . '/' . $this->database->get_config('access_log')['value']);
3232
if ($data !== false) {
3333
$view = array(
3434
'title' => 'Access',
3535
'heading' => array(
3636
'timestamp',
37+
'user',
3738
'ip',
3839
'browser agent',
3940
'session id',
40-
'command',
4141
'message',
42+
'status',
43+
'type',
4244
'method'
4345
),
44-
'body' => $data
46+
'body' => array_reverse($data)
4547
);
4648

4749
$this->view('table', $view);
4850
} else {
4951
$this->view('message', array('message' => 'The access log file is empty!', 'type' => 'danger'));
5052
}
51-
} else if ($param == 'debug') {
52-
$data = $this->std->tail('/var/log/phpietadmin/phpietadmin_debug.log');
53-
if ($data !== false) {
54-
$view = array(
55-
'title' => 'Debug',
56-
'heading' => array(
57-
'timestamp',
58-
'ip',
59-
'browser agent',
60-
'session id',
61-
'command',
62-
'message'
63-
),
64-
'body' => $data
65-
);
66-
$this->view('table', $view);
67-
} else {
68-
$this->view('message', array('message' => 'The debug log file is empty!', 'type' => 'danger'));
69-
}
70-
} else if ($param == 'syslog') {
71-
// ToDo
7253
} else if ($param == 'php') {
7354
// ToDo
7455
} else {

app/controllers/lvm.php

100755100644
File mode changed.

app/controllers/objects.php

100755100644
Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,45 @@
22
class objects extends Controller {
33
public function index() {
44
$data['type'] = $this->database->get_object_types();
5-
$data['objects'] = $this->database->get_all_objects();
6-
5+
$data['objects'] = array_reverse($this->database->get_all_objects());
76
$this->view('objecttable', $data);
87
}
98

109
public function add() {
11-
if (isset($_POST['type'], $_POST['name'], $_POST['value'])) {
12-
$this->database->add_object($_POST['type'], $_POST['name'], $_POST['value']);
13-
}
14-
}
10+
if (isset($_POST['type'], $_POST['name'], $_POST['value']) && !$this->std->mempty($_POST['type'], $_POST['name'], $_POST['value'])) {
11+
// delete whitespaces from the user input
12+
$_POST['type'] = str_replace(' ', '', $_POST['type']);
13+
$_POST['name'] = str_replace(' ', '', $_POST['name']);
14+
$_POST['value'] = str_replace(' ', '', $_POST['value']);
1515

16-
public function delete() {
17-
if (isset($_POST['id']) && !empty($_POST['id'])) {
18-
$id = intval($_POST['id']);
19-
$return = $this->database->delete_object($id);
20-
if ($return !== 0) {
21-
echo "Failed";
22-
} else {
23-
echo "Success";
16+
$data = $this->database->get_all_objects();
17+
try {
18+
if (is_array($data)) {
19+
if ($this->std->recursive_array_search($_POST['value'], $data) !== false) {
20+
throw new exception('value');
21+
} else if($this->std->recursive_array_search($_POST['name'], $data) !== false) {
22+
throw new exception('name');
23+
}
24+
}
25+
if ($this->database->add_object($_POST['type'], $_POST['name'], $_POST['value']) != 0) {
26+
echo json_encode(array('code' => 6, 'message' => 'DB error'));
27+
} else {
28+
echo json_encode(array('code' => 0, 'message' => 'Success'));
29+
}
30+
} catch(Exception $e) {
31+
// send the error with the field where the error should be displayed to the client
32+
echo json_encode(array('code' => 4, 'field' => $e->getMessage()));
2433
}
25-
} else {
26-
echo "Can't do anything!";
2734
}
2835
}
2936

30-
public function checkvalueexists() {
31-
if (isset($_POST['check'], $_POST['value']) && $_POST['check'] == 'duplicated') {
32-
$data = $this->database->get_all_object_values();
33-
34-
if (is_array($data)) {
35-
$result = array_search($_POST['value'], $data);
36-
if ($result === false) {
37-
echo "false";
38-
} else {
39-
echo "true";
40-
}
37+
public function delete() {
38+
if (!empty($_POST['id'])) {
39+
$return = $this->database->delete_object(intval($_POST['id']));
40+
if ($return !== 0) {
41+
echo json_encode(array('code' => $return, 'message' => 'Database error!'));
4142
} else {
42-
echo "false";
43+
echo json_encode(array('code' => 0));
4344
}
4445
}
4546
}

app/controllers/overview.php

100755100644
Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?php
22
class Overview extends Controller {
33
public function disks() {
4-
$disk = $this->generic_model('Disks');
5-
4+
$disk = $this->model('Disks');
65
$data = $disk->get_disks();
76

87
if (!empty($data) && $data !== false) {
@@ -13,7 +12,7 @@ public function disks() {
1312
}
1413

1514
public function iet($param) {
16-
$targets = $this->target_model();
15+
$targets = $this->model('target\Target', '');
1716
$data = $targets->return_target_data();
1817

1918
$view['data'] = $data;
@@ -36,18 +35,55 @@ public function iet($param) {
3635

3736
public function lvm($param) {
3837
if ($param == 'pv') {
39-
$model = $this->pv_model();
38+
$model = $this->model('lvm\pv\Pv', false);
4039
$data = $model->get_pv();
40+
41+
foreach ($data as $volumes) {
42+
$size = intval($volumes['PSize']);
43+
$width = intval(($size - intval($volumes['PFree'])) * 100 / $size);
44+
if ($width <= 60) {
45+
$bar = 'success';
46+
} else if ($width >= 81) {
47+
$bar = 'danger';
48+
} else if ($width >= 61) {
49+
$bar = 'warning';
50+
} else {
51+
$bar = 'info';
52+
}
53+
$meta[] = array(
54+
'width' => $width,
55+
'type' => $bar
56+
);
57+
}
58+
4159
$title = 'Physical volumes';
4260
$heading = array_keys($data[0]);
4361
} else if ($param == 'vg') {
44-
$model = $this->vg_model();
62+
$model = $this->model('lvm\vg\Vg', false);
4563
$data = $model->get_vg();
64+
65+
foreach ($data as $volumes) {
66+
$size = intval($volumes['VSize']);
67+
$width = intval(($size - intval($volumes['VFree'])) * 100 / $size);
68+
if ($width <= 60) {
69+
$bar = 'success';
70+
} else if ($width >= 81) {
71+
$bar = 'danger';
72+
} else if ($width >= 61) {
73+
$bar = 'warning';
74+
} else {
75+
$bar = 'info';
76+
}
77+
$meta[] = array(
78+
'width' => $width,
79+
'type' => $bar
80+
);
81+
}
82+
4683
$title = 'Volume groups';
4784
$heading = array_keys($data[0]);
48-
array_push($heading, 'Used');
4985
} else if ($param == 'lv') {
50-
$model = $this->lv_model(false, false);
86+
$model = $this->model('lvm\lv\Lv', false, false);
5187
$data = $model->get_lv();
5288
$title = 'Logical volumes';
5389
$heading = array_keys($data[0]);
@@ -57,7 +93,14 @@ public function lvm($param) {
5793

5894
if (!empty($data)) {
5995
if ($data !== false) {
60-
$this->view('table', array('title' => $title, 'heading' => $heading, 'body' => $data));
96+
if (isset($meta)) {
97+
array_push($heading, 'Used');
98+
$view = array('title' => $title, 'heading' => $heading, 'body' => $data, 'meta' => $meta);
99+
} else {
100+
$view = array('title' => $title, 'heading' => $heading, 'body' => $data);
101+
}
102+
103+
$this->view('lvm_table', $view);
61104
} else {
62105
$data = $model->get_action_result();
63106
$this->view('message', array('message' => $data['message'], 'type' => 'danger'));

app/controllers/permission.php

100755100644
File mode changed.

0 commit comments

Comments
 (0)