From 3e477ced5640bf732421444089a4627accbd465d Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Thu, 20 Sep 2012 16:57:12 +0300 Subject: [PATCH] refactoring ip section: new html formating --- bin/v_list_sys_users | 65 +++++++ web/add/ip/index.php | 3 +- web/edit/ip/index.php | 3 +- web/list/ip/index.php | 3 - web/templates/admin/add_ip.html | 209 +++++++++++++-------- web/templates/admin/edit_ip.html | 190 ++++++++++++------- web/templates/admin/list_ip.html | 254 ++++++++++++++++---------- web/templates/admin/menu_add_ip.html | 15 -- web/templates/admin/menu_edit_ip.html | 15 -- web/templates/admin/menu_ip.html | 39 ---- 10 files changed, 490 insertions(+), 306 deletions(-) create mode 100755 bin/v_list_sys_users delete mode 100644 web/templates/admin/menu_add_ip.html delete mode 100644 web/templates/admin/menu_edit_ip.html delete mode 100644 web/templates/admin/menu_ip.html diff --git a/bin/v_list_sys_users b/bin/v_list_sys_users new file mode 100755 index 000000000..f210ee72c --- /dev/null +++ b/bin/v_list_sys_users @@ -0,0 +1,65 @@ +#!/bin/bash +# info: list system users +# options: [format] +# +# The function for obtaining the list of system users without +# detailed information. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_users() { + users=$(grep @ /etc/passwd|cut -f 1 -d :) + int_counter=$(echo "$users" | wc -l) + i=1 + echo '[' + for user in $users; do + if [ "$i" -lt "$int_counter" ]; then + echo -e "\t\"$user\"," + else + echo -e "\t\"$user\"" + fi + (( ++i)) + done + echo "]" +} + +# Shell function +shell_list_users() { + if [ -z "$nohead" ]; then + echo "USERS" + echo "----------" + fi + for user in $(grep @ /etc/passwd|cut -f 1 -d :); do + echo "$user" + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing domains +case $format in + json) json_list_users ;; + plain) nohead=1; shell_list_users ;; + shell) shell_list_users ;; + *) check_args '1' '0' '[format]' ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/web/add/ip/index.php b/web/add/ip/index.php index 0f4207a2a..f1938886a 100644 --- a/web/add/ip/index.php +++ b/web/add/ip/index.php @@ -74,11 +74,10 @@ if ($_SESSION['user'] == 'admin') { $interfaces = json_decode(implode('', $output), true); unset($output); - exec (VESTA_CMD."v_list_users 'json'", $output, $return_var); + exec (VESTA_CMD."v_list_sys_users 'json'", $output, $return_var); $users = json_decode(implode('', $output), true); unset($output); - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_add_ip.html'); include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_ip.html'); unset($_SESSION['error_msg']); unset($_SESSION['ok_msg']); diff --git a/web/edit/ip/index.php b/web/edit/ip/index.php index 0f2e52fb1..feb9d981f 100644 --- a/web/edit/ip/index.php +++ b/web/edit/ip/index.php @@ -48,7 +48,7 @@ if ($_SESSION['user'] == 'admin') { $v_status = 'active'; } - exec (VESTA_CMD."v_list_users 'json'", $output, $return_var); + exec (VESTA_CMD."v_list_sys_users 'json'", $output, $return_var); $users = json_decode(implode('', $output), true); unset($output); @@ -110,7 +110,6 @@ if ($_SESSION['user'] == 'admin') { } } - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_ip.html'); include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_ip.html'); unset($_SESSION['error_msg']); unset($_SESSION['ok_msg']); diff --git a/web/list/ip/index.php b/web/list/ip/index.php index 576424971..11332b316 100644 --- a/web/list/ip/index.php +++ b/web/list/ip/index.php @@ -15,14 +15,11 @@ top_panel($user,$TAB); // Data if ($_SESSION['user'] == 'admin') { - exec (VESTA_CMD."v_list_sys_ips json", $output, $return_var); check_error($return_var); $data = json_decode(implode('', $output), true); $data = array_reverse($data); unset($output); - - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_ip.html'); include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/list_ip.html'); } diff --git a/web/templates/admin/add_ip.html b/web/templates/admin/add_ip.html index 287ab8956..4248c6706 100644 --- a/web/templates/admin/add_ip.html +++ b/web/templates/admin/add_ip.html @@ -1,74 +1,139 @@ - - - - - + +
- - -
-
- - -
- - - - - - - - - - - + + +
IP
Netmask
Interface
Shared
onclick="javascript:elementHideShow('usrtable');">
- - -
Assigned User
Associated Domain (optional)
+
Adding IP Address + → ".$_SESSION['error_msg'].""; + } else { + if (!empty($_SESSION['ok_msg'])) { + echo " → ".$_SESSION['ok_msg'].""; + } + } + ?> +
+
- - - - - - - - +
+ + + + + + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ IP +
+ + Netmask +
+ + Interface +
+ +
+ Shared +
+ onclick="javascript:elementHideShow('usrtable');"> +
+ + + + + + + +
+ Assigned User +
+ +
+
+ Associated Domain (optional) +
+ + + +
+
+ diff --git a/web/templates/admin/edit_ip.html b/web/templates/admin/edit_ip.html index dba815de9..bea6c4ba3 100644 --- a/web/templates/admin/edit_ip.html +++ b/web/templates/admin/edit_ip.html @@ -1,66 +1,128 @@ - - - - - + +
- - - - -
-
- - -
- - - - - - - - - - - + + +
IP
Netmask
Interface
Shared
Assigned User
Associated Domain (optional)
+
Editing IP Address + → ".$_SESSION['error_msg'].""; + } else { + if (!empty($_SESSION['ok_msg'])) { + echo " → ".$_SESSION['ok_msg'].""; + } + } + ?> +
+
- -
- - - - - - +
+ + + + + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ IP +
+ + Netmask +
+ + Interface +
+ + Shared +
+ +
+ Assigned User +
+ +
+ Associated Domain (optional) +
+ + + +
+
+
diff --git a/web/templates/admin/list_ip.html b/web/templates/admin/list_ip.html index ce575db71..c04788f32 100644 --- a/web/templates/admin/list_ip.html +++ b/web/templates/admin/list_ip.html @@ -1,99 +1,165 @@ - - $value) { - ++$i; -?> - - - - - - - - -
- - - - -
">
active
-
- - - - -
"> edit - - delete -
-

Are you sure you want to delete ip?

-
-
- - - - - +
- - - +
+ + + + +
-
- - - -
Web Domains:
Status:
-
- - -
Sys Users:
-
- - +
+ + $value) { + ++$i; + ?> - -
-"; ?> - - - - -
→ - -
-
-"; ?> -"; ?> -"; ?> + + + + + + + + +
">
active
+ + + + + + + + +
"> edit + + delete +
+

Are you sure you want to delete ip?

+
+
+ + + + + + + + + + +
+ +
+ + + + + + + +
+ +
+ +
+
+ + + + + + + + + +
+ Web Domains: + + +
+ Status: + + +
+
+ + + + +
+ Sys Users: +
+
+ + + + + + + + "; ?> + + + + + + +
+ +
+ + + "; ?> + "; ?> + "; ?> diff --git a/web/templates/admin/menu_add_ip.html b/web/templates/admin/menu_add_ip.html deleted file mode 100644 index 95d83d1e3..000000000 --- a/web/templates/admin/menu_add_ip.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/web/templates/admin/menu_edit_ip.html b/web/templates/admin/menu_edit_ip.html deleted file mode 100644 index f9ecbcd86..000000000 --- a/web/templates/admin/menu_edit_ip.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/web/templates/admin/menu_ip.html b/web/templates/admin/menu_ip.html deleted file mode 100644 index 07a2cc952..000000000 --- a/web/templates/admin/menu_ip.html +++ /dev/null @@ -1,39 +0,0 @@ - - -
-

.

-
- - - - - - - - - -