Skip to content

Commit f685d8d

Browse files
committed
added admin search
1 parent ac2aa3c commit f685d8d

Some content is hidden

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

76 files changed

+871
-114
lines changed

bin/v_search_object

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
#!/bin/bash
2+
# info: search objects
3+
# options: object [format]
4+
#
5+
# The function that allows to find system objects.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
object=$1
14+
format=${2-shell}
15+
16+
# Includes
17+
source $VESTA/conf/vesta.conf
18+
source $VESTA/func/main.sh
19+
20+
#----------------------------------------------------------#
21+
# Verifications #
22+
#----------------------------------------------------------#
23+
24+
check_args '1' "$#" 'object [format]'
25+
validate_format 'object'
26+
27+
28+
#----------------------------------------------------------#
29+
# Action #
30+
#----------------------------------------------------------#
31+
32+
conf=$(mktemp)
33+
i=0
34+
OLD_IFS=$IFS
35+
IFS=$'\n'
36+
37+
# User loop
38+
for user in $(ls $VESTA/data/users/); do
39+
# Search query
40+
search=$(grep "$object" \
41+
$VESTA/data/users/$user/web.conf \
42+
$VESTA/data/users/$user/dns.conf \
43+
$VESTA/data/users/$user/mail.conf \
44+
$VESTA/data/users/$user/db.conf)
45+
46+
for row in $search; do
47+
# Initialise variable
48+
key=''
49+
result=''
50+
dom_alias=''
51+
suspended=''
52+
object_time=''
53+
object_date=''
54+
55+
# Parsing result
56+
type=$(echo $row |cut -f 1 -d : |cut -f 8 -d / |cut -f 1 -d \.)
57+
data=$(echo $row |cut -f 2,3,4,5 -d :)
58+
eval "$data"
59+
60+
# Check WEB domain
61+
dom_alias=''
62+
if [ "$type" = 'web' ]; then
63+
if [ -n "$(echo $DOMAIN |grep $object)" ]; then
64+
# Check domain alias
65+
check_dom_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)"
66+
if [ ! -z "$check_dom_alias" ];then
67+
dom_alias=$(echo $check_dom_alias | tr ' ' ',')
68+
fi
69+
key="DOMAIN"
70+
result="$DOMAIN"
71+
suspended=$SUSPENDED
72+
object_time=$TIME
73+
object_date=$DATE
74+
((i ++))
75+
fi
76+
fi
77+
78+
# DNS
79+
if [ "$type" = 'dns' ]; then
80+
if [ -n "$(echo $DOMAIN |grep $object)" ]; then
81+
key="DOMAIN"
82+
result="$DOMAIN"
83+
suspended=$SUSPENDED
84+
object_time=$TIME
85+
object_date=$DATE
86+
((i ++))
87+
fi
88+
fi
89+
90+
# MAIL
91+
if [ "$type" = 'mail' ]; then
92+
if [ -n "$(echo $DOMAIN |grep $object)" ]; then
93+
key="DOMAIN"
94+
result="$DOMAIN"
95+
suspended=$SUSPENDED
96+
object_time=$TIME
97+
object_date=$DATE
98+
((i ++))
99+
fi
100+
fi
101+
102+
# DB
103+
if [ "$type" = 'db' ]; then
104+
if [ -n "$(echo $DB |grep $object)" ]; then
105+
key="DATABASE"
106+
result="$DB"
107+
suspended=$SUSPENDED
108+
object_time=$TIME
109+
object_date=$DATE
110+
((i ++))
111+
fi
112+
fi
113+
114+
if [ ! -z "$result" ]; then
115+
str="ID='$i' USER='$user' TYPE='$type' KEY='$key'"
116+
str="$str RESULT='$result' ALIAS='$dom_alias'"
117+
str="$str SUSPENDED='$suspended' TIME='$object_time'"
118+
str="$str DATE='$object_date'"
119+
echo $str >> $conf
120+
fi
121+
done
122+
done
123+
IFS=$OLD_IFS
124+
125+
# Defining fileds to select
126+
fields='$ID $USER $TYPE $KEY $RESULT $ALIAS $SUSPENDED $TIME $DATE'
127+
128+
# Listing domains
129+
case $format in
130+
json) json_list ;;
131+
plain) nohead=1; shell_list ;;
132+
shell) fields='$USER $TYPE $KEY $RESULT $ALIAS'; shell_list |column -t;;
133+
*) check_args '2' '0' 'object [format]'
134+
esac
135+
136+
rm $conf
137+
138+
#----------------------------------------------------------#
139+
# Vesta #
140+
#----------------------------------------------------------#
141+
142+
# Logging
143+
#log_event "$OK" "$EVENT"
144+
145+
exit

web/delete/backup/index.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
session_start();
66
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
77

8-
//if ($_SESSION['user'] == 'admin') {
8+
// Delete as someone else?
9+
if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) {
10+
$user=$_GET['user'];
11+
}
12+
913
if (!empty($_GET['backup'])) {
1014
$v_username = escapeshellarg($user);
1115
$v_backup = escapeshellarg($_GET['backup']);
@@ -20,4 +24,10 @@
2024

2125
//}
2226

27+
$back=getenv("HTTP_REFERER");
28+
if (!empty($back)) {
29+
header("Location: ".$back);
30+
exit;
31+
}
2332
header("Location: /list/backup/");
33+
exit;

web/delete/cron/index.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
session_start();
66
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
77

8-
//if ($_SESSION['user'] == 'admin') {
8+
// Delete as someone else?
9+
if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) {
10+
$user=$_GET['user'];
11+
}
12+
913
if (!empty($_GET['job'])) {
1014
$v_username = escapeshellarg($user);
1115
$v_job = escapeshellarg($_GET['job']);
@@ -20,4 +24,10 @@
2024

2125
//}
2226

27+
$back=getenv("HTTP_REFERER");
28+
if (!empty($back)) {
29+
header("Location: ".$back);
30+
exit;
31+
}
2332
header("Location: /list/cron/");
33+
exit;

web/delete/db/index.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
session_start();
66
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
77

8-
//if ($_SESSION['user'] == 'admin') {
8+
// Delete as someone else?
9+
if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) {
10+
$user=$_GET['user'];
11+
}
12+
913
if (!empty($_GET['database'])) {
1014
$v_username = escapeshellarg($user);
1115
$v_database = escapeshellarg($_GET['database']);
@@ -20,4 +24,10 @@
2024

2125
//}
2226

27+
$back=getenv("HTTP_REFERER");
28+
if (!empty($back)) {
29+
header("Location: ".$back);
30+
exit;
31+
}
2332
header("Location: /list/db/");
33+
exit;

web/delete/dns/index.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
session_start();
66
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
77

8-
//if ($_SESSION['user'] == 'admin') {
8+
// Delete as someone else?
9+
if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) {
10+
$user=$_GET['user'];
11+
}
12+
913
// DNS domain
1014
if ((!empty($_GET['domain'])) && (empty($_GET['record_id']))) {
1115
$v_username = escapeshellarg($user);
@@ -17,6 +21,11 @@
1721
$_SESSION['error_msg'] = $error;
1822
}
1923
unset($output);
24+
$back=getenv("HTTP_REFERER");
25+
if (!empty($back)) {
26+
header("Location: ".$back);
27+
exit;
28+
}
2029
header("Location: /list/dns/");
2130
exit;
2231
}
@@ -33,11 +42,20 @@
3342
$_SESSION['error_msg'] = $error;
3443
}
3544
unset($output);
36-
37-
unset($output);
45+
$back=getenv("HTTP_REFERER");
46+
if (!empty($back)) {
47+
header("Location: ".$back);
48+
exit;
49+
}
3850
header("Location: /list/dns/?domain=".$_GET['domain']);
3951
exit;
4052
}
4153
//}
4254

55+
$back=getenv("HTTP_REFERER");
56+
if (!empty($back)) {
57+
header("Location: ".$back);
58+
exit;
59+
}
4360
header("Location: /list/dns/");
61+
exit;

web/delete/ip/index.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@
1919

2020
}
2121

22+
$back=getenv("HTTP_REFERER");
23+
if (!empty($back)) {
24+
header("Location: ".$back);
25+
exit;
26+
}
2227
header("Location: /list/ip/");
28+
exit;

web/delete/mail/index.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
session_start();
66
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
77

8-
//if ($_SESSION['user'] == 'admin') {
8+
// Delete as someone else?
9+
if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) {
10+
$user=$_GET['user'];
11+
}
12+
913
// Mail domain
1014
if ((!empty($_GET['domain'])) && (empty($_GET['account']))) {
1115
$v_username = escapeshellarg($user);
@@ -17,6 +21,11 @@
1721
$_SESSION['error_msg'] = $error;
1822
}
1923
unset($output);
24+
$back=getenv("HTTP_REFERER");
25+
if (!empty($back)) {
26+
header("Location: ".$back);
27+
exit;
28+
}
2029
header("Location: /list/mail/");
2130
exit;
2231
}
@@ -33,9 +42,20 @@
3342
$_SESSION['error_msg'] = $error;
3443
}
3544
unset($output);
45+
$back=getenv("HTTP_REFERER");
46+
if (!empty($back)) {
47+
header("Location: ".$back);
48+
exit;
49+
}
3650
header("Location: /list/mail/?domain=".$_GET['domain']);
3751
exit;
3852
}
3953
//}
4054

55+
$back=getenv("HTTP_REFERER");
56+
if (!empty($back)) {
57+
header("Location: ".$back);
58+
exit;
59+
}
4160
header("Location: /list/mail/");
61+
exit;

web/delete/package/index.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,10 @@
1818
unset($output);
1919
}
2020

21+
$back=getenv("HTTP_REFERER");
22+
if (!empty($back)) {
23+
header("Location: ".$back);
24+
exit;
25+
}
2126
header("Location: /list/package/");
27+
exit;

web/delete/user/index.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,10 @@
1818
unset($output);
1919
}
2020

21+
$back=getenv("HTTP_REFERER");
22+
if (!empty($back)) {
23+
header("Location: ".$back);
24+
exit;
25+
}
2126
header("Location: /list/user/");
27+
exit;

web/delete/web/index.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
session_start();
66
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
77

8+
// Delete as someone else?
9+
if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) {
10+
$user=$_GET['user'];
11+
}
12+
813
if (!empty($_GET['domain'])) {
914
$v_username = escapeshellarg($user);
1015
$v_domain = escapeshellarg($_GET['domain']);
@@ -45,4 +50,10 @@
4550
}
4651
}
4752

53+
$back=getenv("HTTP_REFERER");
54+
if (!empty($back)) {
55+
header("Location: ".$back);
56+
exit;
57+
}
4858
header("Location: /list/web/");
59+
exit;

0 commit comments

Comments
 (0)