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

Commit 9671bcd

Browse files
author
mrcrankhank
committed
2 parents f652773 + 29ee768 commit 9671bcd

File tree

11 files changed

+161
-342
lines changed

11 files changed

+161
-342
lines changed

README.md

Lines changed: 25 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
11
# phpietadmin
22
Phpietadmin is an easy to use webinterface to control the iscsi enterprise target (iet) daemon (http://sourceforge.net/projects/iscsitarget/) written in php and javascript.
33

4+
## Features
5+
### Dashboard
6+
The dashboard provides a quick overview about your system and phpietadmin.
7+
8+
### iSCSI
9+
phpietadmin enables you to configure all features of the iscsi enterprise target daemon via web, e.g.:
10+
11+
* Adding/Removing luns
12+
* Initiator/Target allow
13+
* User management
14+
* Sessions
15+
* Settings
16+
* Target removal
17+
18+
### LVM
19+
phpietadmin currently only supports lvm as iscsi luns!
20+
21+
* Adding volumes
22+
* Extending volumes (+ notify iscsi initiator about the change)
23+
* Shrinking volumes
24+
* Renaming volumes
25+
* Deleting volumes
26+
27+
..and more.
28+
429
## Intention
530
The main reason for developing this was, to create a way to configure the daemon while it’s in use. The iet daemon reads
631
the config file only at start/restart. Changes after the daemon was started are only possible via the ietadm command line
@@ -26,68 +51,4 @@ Official support for CentOS is planned.
2651
### Beta
2752
* https://github.com/HankIT/phpietadmin-doc/wiki/v0.6.2-%5Bbeta%5D
2853

29-
## Features
30-
Take a look at the github releases for detailed information about the features.
31-
32-
## Roadmap
33-
In version 0.7:
34-
* LVM
35-
- [ ] Volume group menu (select which volume groups phpietadmin should use)
36-
- [ ] Optional lv prefix (append LV_ or some other user chosen string)
37-
- [ ] Add snapshot merge feature to gui
38-
- [ ] Add enable/disable logical volume feature to gui
39-
40-
* Frontend
41-
- [ ] Use jwindow to dynamically display the status of running commands
42-
- [ ] Drag & Drop with HTML5
43-
- [ ] Menu to import orphaned objects into database
44-
- [ ] Display input validation with bootstrap css Validation states (http://formvalidation.io/validators/integer/)
45-
- [ ] Bootstrap-table Table Select Checkbox
46-
- [ ] Awesome checkboxes (https://github.com/designmodo/Flat-UI)
47-
- [ ] Improve nested table row handling
48-
- [ ] Add target and lvm name to url
49-
- [ ] Overview/Logical volumes VG selector
50-
- [ ] Add "Edit file directly" option
51-
- [ ] Searchable table for overview menu
52-
- [ ] Release "compressed" javascript files
53-
54-
* Backend
55-
- [ ] Write process class to execute commands in the background (+ jwindow)
56-
- [ ] Create complete documentation on https://readthedocs.org/
57-
- [ ] Use unity testing
58-
- [ ] Replace all error codes with exceptions
59-
- [ ] Support "All" permission in ietd config files
60-
- [ ] Write phpietadmin-cli
61-
- [ ] Database error log
62-
63-
* In version 0.8:
64-
- [ ] Support for DRBD (show status)
65-
- [ ] Support for HA Clusters (Corosync & Pacemaker, only for iet)
66-
67-
* In version 0.9:
68-
- [ ] Support for nfs
69-
70-
## More
71-
- [ ] Software raid status
72-
- [ ] Support for samba shares
73-
- [ ] Show and configure network settings
74-
- [ ] Enable/Disable features
75-
- [ ] Support for apcupsd
76-
- [ ] Manual selection of block devices
77-
- [ ] HDD temp
78-
- [ ] Pie Chart for volume groups
79-
- [ ] Smart data
80-
- [ ] Backup config files (http://code.stephenmorley.org/php/diff-implementation/)
81-
- [ ] Menu to restore config files
82-
- [ ] function naming convention in models (prepend class name to function name)
83-
- [ ] Create "consistency", which displays if the daemon config and the config file are identically
84-
- [ ] Use composer
85-
- [ ] Use json for tables
86-
- [ ] Change duplication check (Try to select the specific value from the database)
87-
- [ ] Use own exception class for error handling
88-
- [ ] Sign archives
89-
- [ ] Separate database models
90-
- [ ] SSH login via web gui (https://github.com/liftoff/GateOne)
91-
- [ ] Add bar to snapshot delete gui
92-
9354
If you have any problems, please open an issue!

ROADMAP.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
## Roadmap
2+
This is just a approximately of the features, i want to implement in the future.
3+
In version 0.7:
4+
* LVM
5+
- [ ] Volume group menu (select which volume groups phpietadmin should use)
6+
- [ ] Optional lv prefix (append LV_ or some other user chosen string)
7+
- [ ] Add snapshot merge feature to gui
8+
- [ ] Add enable/disable logical volume feature to gui
9+
10+
* Frontend
11+
- [ ] Use jwindow to dynamically display the status of running commands
12+
- [ ] Drag & Drop with HTML5
13+
- [ ] Menu to import orphaned objects into database
14+
- [ ] Display input validation with bootstrap css Validation states (http://formvalidation.io/validators/integer/)
15+
- [ ] Bootstrap-table Table Select Checkbox
16+
- [ ] Awesome checkboxes (https://github.com/designmodo/Flat-UI)
17+
- [ ] Improve nested table row handling
18+
- [ ] Add target and lvm name to url
19+
- [ ] Overview/Logical volumes VG selector
20+
- [ ] Add "Edit file directly" option
21+
- [ ] Searchable table for overview menu
22+
- [ ] Release "compressed" javascript files
23+
24+
* Backend
25+
- [ ] Write process class to execute commands in the background (+ jwindow)
26+
- [ ] Create complete documentation on https://readthedocs.org/
27+
- [ ] Use unity testing
28+
- [ ] Replace all error codes with exceptions
29+
- [ ] Support "All" permission in ietd config files
30+
- [ ] Write phpietadmin-cli
31+
- [ ] Database error log
32+
33+
* In version 0.8:
34+
- [ ] Support for DRBD (show status)
35+
- [ ] Support for HA Clusters (Corosync & Pacemaker, only for iet)
36+
37+
* In version 0.9:
38+
- [ ] Support for nfs
39+
40+
## More
41+
- [ ] Software raid status
42+
- [ ] Support for samba shares
43+
- [ ] Show and configure network settings
44+
- [ ] Enable/Disable features
45+
- [ ] Support for apcupsd
46+
- [ ] Manual selection of block devices
47+
- [ ] HDD temp
48+
- [ ] Pie Chart for volume groups
49+
- [ ] Smart data
50+
- [ ] Backup config files (http://code.stephenmorley.org/php/diff-implementation/)
51+
- [ ] Menu to restore config files
52+
- [ ] function naming convention in models (prepend class name to function name)
53+
- [ ] Create "consistency", which displays if the daemon config and the config file are identically
54+
- [ ] Use composer
55+
- [ ] Use json for tables
56+
- [ ] Change duplication check (Try to select the specific value from the database)
57+
- [ ] Use own exception class for error handling
58+
- [ ] Sign archives
59+
- [ ] Separate database models
60+
- [ ] SSH login via web gui (https://github.com/liftoff/GateOne)
61+
- [ ] Add bar to snapshot delete gui

app/controllers/Targets.php

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -16,52 +16,6 @@ public function addtarget() {
1616
}
1717
}
1818

19-
public function adddisuser() {
20-
if (isset($_POST['id'], $_POST['type'])) {
21-
$type = filter_input(INPUT_POST, 'type', FILTER_SANITIZE_STRING);
22-
$id = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT);
23-
24-
if ($type === 'Incoming') {
25-
$type = 'IncomingUser';
26-
} else if ($type === 'Outgoing') {
27-
$type = 'OutgoingUser';
28-
} else {
29-
echo "The type value is invalid!";
30-
die();
31-
}
32-
$target = $this->model('target\Target');
33-
$target->add_user($id, true, $type);
34-
echo json_encode($target->logging->get_action_result());
35-
} else {
36-
$data = $this->baseModel->database->get_all_usernames(true);
37-
38-
if ($data != 0) {
39-
$this->view('targets/add_dis_user', $data);
40-
} else {
41-
$this->view('message', array('message' => 'Error - No user available!', 'type' => 'warning', 'container' => true));
42-
}
43-
}
44-
}
45-
46-
public function deletedisuser() {
47-
if (isset($_POST['type'], $_POST['id'])) {
48-
$type = filter_input(INPUT_POST, 'type', FILTER_SANITIZE_STRING);
49-
$id = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT);
50-
51-
$target = $this->model('target\Target');
52-
$target->delete_user($id, true, $type);
53-
echo json_encode($target->logging->get_action_result());
54-
} else {
55-
$target = $this->model('target\Target');
56-
$data = $target->get_user(true);
57-
if ($data !== false) {
58-
$this->view('targets/delete_dis_user', $data);
59-
} else {
60-
$this->view('message', array('message' => 'Error - No user available!', 'type' => 'warning', 'container' => true));
61-
}
62-
}
63-
}
64-
6519
public function configure($iqn = false, $function = false) {
6620
if ($iqn !== false) {
6721
$iqn = filter_var($iqn, FILTER_SANITIZE_STRING);

app/core/App.php

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,25 @@
55
app\models\logging,
66
app\models;
77

8+
/**
9+
* Entry point for this application. All requests are handled here.
10+
* @package app\core
11+
* @throws \Exception if the version file is invalid
12+
*/
813
class App {
14+
/** @var object $controllerObject Contains the object of the called controller */
915
protected $controllerObject;
16+
17+
/** @var string $controllerName Contains the name of the called controller, it's initialized with a default value */
1018
protected $controllerName = 'app\\controllers\\dashboard';
19+
20+
/** @var string $method Contains the name of the called method, it's initialized with a default value */
1121
protected $method = 'index';
22+
23+
/** @var array $params Contains an array with all parameters */
1224
protected $params = [];
25+
26+
/** @var array $url Contains the url using the parseUrl() function */
1327
protected $url;
1428

1529
public function __construct() {
@@ -18,6 +32,11 @@ public function __construct() {
1832
$this->url = $this->parseUrl();
1933
}
2034

35+
/**
36+
* Create the database. Check if it's already there, otherwise you will delete all data ;-)
37+
*
38+
* @return void
39+
*/
2140
private function installDb() {
2241
exec('sqlite3 ' . DB_FILE . ' < ' . INSTALL_DIR . '/database.new.sql', $output, $code);
2342

@@ -26,6 +45,14 @@ private function installDb() {
2645
}
2746
}
2847

48+
/**
49+
* Check if the database has the same version as the application. If not update it using the
50+
* database.update.sql file.
51+
* Nothing will be done, if the application is in development mode.
52+
*
53+
* @throws \Exception if the version file is invalid
54+
* @return void
55+
*/
2956
private function updateDb() {
3057
// check if db update is necessary
3158
$version = $this->controllerObject->baseModel->database->get_config('version');
@@ -49,6 +76,13 @@ private function updateDb() {
4976
}
5077
}
5178

79+
/**
80+
* This method start the application. It creates necessary objects, handles authentication
81+
* and outputs the application header + menu if the request isn't an ajax
82+
*
83+
* @throws \Exception if the called controller or method is not found
84+
* @return void
85+
*/
5286
public function app() {
5387
if (file_exists(CONTROLLER_DIR . '/' . ucfirst($this->url[0]) . '.php')) {
5488
$this->controllerName = 'app\\controllers\\' . $this->url[0];
@@ -107,26 +141,49 @@ public function app() {
107141
call_user_func_array([$this->controllerObject, $this->method], $this->params);
108142
}
109143

144+
/**
145+
* Split the url for application routing
146+
* @return array
147+
*/
110148
private function parseUrl() {
111149
if (isset($_GET['url'])) {
112150
return $url = explode('/', filter_var(rtrim($_GET['url'], '/'), FILTER_SANITIZE_URL));
113151
}
114152
}
115153

154+
/**
155+
* Fill the registry with all necessary models and
156+
* instantiated a baseModel, to access the models through the
157+
* controllerObject
158+
*
159+
* @throws \Exception
160+
* @return void
161+
*/
116162
private function setupRegistry() {
117163
$registry = Registry::getInstance();
118164
$registry->set('database', new models\Database());
119165
$registry->set('logging', new logging\Logging());
120166
$this->controllerObject->baseModel = new BaseModel();
121167
}
122168

123-
// Sanitize user input
124-
// Unlikely that this does something useful
125-
// but it's a welcome addition
169+
/**
170+
* Sanitize user input
171+
* Unlikely that this does something useful
172+
* but it's a welcome addition
173+
*
174+
* @param $value array
175+
* @return void
176+
*/
126177
private function sanitize(&$value) {
127178
$value = addslashes(strip_tags(trim($value)));
128179
}
129180

181+
/**
182+
* Output application header and menu, if the user is authenticated and
183+
* the request is not ajax
184+
*
185+
* @return void
186+
*/
130187
private function showHeader() {
131188
// If request is no ajax, display header, menu and footer
132189
if (!models\Misc::isXHttpRequest() && $this->controllerName !== 'app\controllers\auth') {
@@ -135,6 +192,11 @@ private function showHeader() {
135192
}
136193
}
137194

195+
/**
196+
* Validate if the user is correctly authenticated
197+
*
198+
* @return void
199+
*/
138200
private function checkAuth() {
139201
// auth controller is accessible without authentication
140202
if ($this->controllerName !== 'app\controllers\auth') {

app/core/BaseModel.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@
44
use app\models,
55
app\models\logging;
66

7+
/**
8+
* This classed provides basic functions, which are used in almost every model.
9+
*
10+
* @package app\core
11+
* @throws \Exception if the selected registry element is not found
12+
*/
713
class BaseModel {
14+
/** @var object $database Object for database access */
815
public $database;
16+
17+
/** @var object $logging Object for logging (read and write) */
918
public $logging;
1019

1120
public function __construct() {

app/models/target/Exec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ protected function get_configured_iet_users($discovery = false) {
105105
if ($discovery === true) {
106106
$return = models\Misc::logExec($this->ietadm . ' --op show --user');
107107
} else {
108-
$return = models\Misc::logExecn($this->ietadm . ' --op show --tid=' . $this->tid . ' --user');
108+
$return = models\Misc::logExec($this->ietadm . ' --op show --tid=' . $this->tid . ' --user');
109109
}
110110

111111
if (!empty($return['status'])) {

app/views/menu.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929
<ul class = "dropdown-menu">
3030
<li><a class="workspaceTab" href="<?php echo WEB_PATH ?>/targets/addtarget"><span class="glyphicon glyphicon-plus"></span> Add</a></li>
3131
<li><a class="workspaceTab" href="<?php echo WEB_PATH ?>/targets/configure"><span class="glyphicon glyphicon-wrench"></span> Configure</a></li>
32-
<li class="divider"></li>
33-
<li><a class="workspaceTab" href="<?php echo WEB_PATH ?>/targets/adddisuser"><span class="glyphicon glyphicon-plus"></span> Add discovery user</a></li>
34-
<li><a class="workspaceTab" href="<?php echo WEB_PATH ?>/targets/deletedisuser"><span class="glyphicon glyphicon-trash"></span> Delete discovery user</a></li>
3532
</ul>
3633
</li>
3734
<li><a class="workspaceTab" href="<?php echo WEB_PATH ?>/ietusers"><span class="glyphicon glyphicon-user"></span> <span>iSCSI users</span></a></li>

0 commit comments

Comments
 (0)