Skip to content

Commit 60ebfe3

Browse files
committed
license manager
1 parent 45fd7dc commit 60ebfe3

File tree

13 files changed

+534
-47
lines changed

13 files changed

+534
-47
lines changed

bin/v-activate-vesta-license

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
# info: activate vesta license
3+
# options: MODULE LICENSE
4+
#
5+
# The function activates and register vesta license
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
module=$(echo $1 | tr '[:lower:]' '[:upper:]')
14+
license=$2
15+
16+
# Importing system enviroment
17+
source /etc/profile
18+
19+
# Includes
20+
source $VESTA/func/main.sh
21+
source $VESTA/conf/vesta.conf
22+
23+
24+
#----------------------------------------------------------#
25+
# Verifications #
26+
#----------------------------------------------------------#
27+
28+
# Checking arg number
29+
check_args '2' "$#" 'MODULE LICENSE'
30+
31+
32+
#----------------------------------------------------------#
33+
# Action #
34+
#----------------------------------------------------------#
35+
36+
# Activating license
37+
v_host='https://vestacp.com/checkout'
38+
answer=$(curl -s $v_host/activate.php?licence_key=$license&module=$module)
39+
check_result $? "cant' connect to vestacp.com " $E_CONNECT
40+
41+
# Checking server answer
42+
if [[ "$answer" != '0' ]]; then
43+
echo "Error: $module license $license is invalid"
44+
exit $E_INVALID
45+
fi
46+
47+
48+
#----------------------------------------------------------#
49+
# Vesta #
50+
#----------------------------------------------------------#
51+
52+
# Updating vesta.conf
53+
if [ -z "$(grep "${module}_KEY" $VESTA/conf/vesta.conf)" ]; then
54+
echo "${module}_KEY='$license'" >> $VESTA/conf/vesta.conf
55+
else
56+
sed -i "s/${module}_KEY=.*/${module}_KEY='$license'/g" $VESTA/conf/vesta.conf
57+
fi
58+
59+
# Logging
60+
log_event "$OK" "$EVENT"
61+
62+
exit

bin/v-check-vesta-license

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
# info: check vesta license
3+
# options: [MODULE]
4+
#
5+
# The function activates and register vesta license
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
module=$(echo $1 | tr '[:lower:]' '[:upper:]')
14+
15+
# Importing system enviroment
16+
source /etc/profile
17+
18+
# Includes
19+
source $VESTA/func/main.sh
20+
source $VESTA/conf/vesta.conf
21+
22+
23+
#----------------------------------------------------------#
24+
# Verifications #
25+
#----------------------------------------------------------#
26+
27+
28+
#----------------------------------------------------------#
29+
# Action #
30+
#----------------------------------------------------------#
31+
32+
# Checking module
33+
if [ -z "$module" ]; then
34+
modules=$(grep _KEY= $VESTA/conf/vesta.conf)
35+
else
36+
modules=$(grep "${module}_KEY" $VESTA/conf/vesta.conf)
37+
fi
38+
39+
IFS=$'\n'
40+
for str in $modules; do
41+
module=$(echo "$str" |cut -f 1 -d _)
42+
license=$(echo "$str" |cut -f 2 -d \')
43+
if [ ! -z "$license" ]; then
44+
v_host='https://vestacp.com/checkout'
45+
answer=$(curl -s $v_host/check.php?licence_key=$license)
46+
check_result $? "cant' connect to vestacp.com " 0
47+
if [[ "$answer" != '0' ]]; then
48+
sed -i "s/${module}_KEY=.*/${module}_KEY=''/g" $VESTA/conf/vesta.conf
49+
echo "deactivating $module"
50+
fi
51+
fi
52+
done
53+
54+
55+
#----------------------------------------------------------#
56+
# Vesta #
57+
#----------------------------------------------------------#
58+
59+
exit

bin/v-deactivate-vesta-license

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/bash
2+
# info: deactivate vesta license
3+
# options: MODULE LICENSE
4+
#
5+
# The function activates and register vesta license
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
module=$(echo $1 | tr '[:lower:]' '[:upper:]')
14+
license=$2
15+
16+
# Importing system enviroment
17+
source /etc/profile
18+
19+
# Includes
20+
source $VESTA/func/main.sh
21+
source $VESTA/conf/vesta.conf
22+
23+
24+
#----------------------------------------------------------#
25+
# Verifications #
26+
#----------------------------------------------------------#
27+
28+
# Checking arg number
29+
check_args '2' "$#" 'MODULE LICENSE'
30+
31+
32+
#----------------------------------------------------------#
33+
# Action #
34+
#----------------------------------------------------------#
35+
36+
# Activating license
37+
v_host='https://vestacp.com/checkout'
38+
answer=$(curl -s $v_host/cancel.php?licence_key=$license)
39+
check_result $? "cant' connect to vestacp.com " $E_CONNECT
40+
echo $answer
41+
42+
# Checking server answer
43+
if [[ "$answer" != '0' ]]; then
44+
echo "Error: $module license $license is invalid"
45+
exit $E_INVALID
46+
fi
47+
48+
49+
#----------------------------------------------------------#
50+
# Vesta #
51+
#----------------------------------------------------------#
52+
53+
# Updating vesta.conf
54+
if [ ! -z "$(grep "${module}_KEY" $VESTA/conf/vesta.conf)" ]; then
55+
sed -i "s/${module}_KEY=.*/${module}_KEY=''/g" $VESTA/conf/vesta.conf
56+
fi
57+
58+
# Logging
59+
log_event "$OK" "$EVENT"
60+
61+
exit

web/css/styles.min.css

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -799,11 +799,6 @@ input[type="checkbox"] {
799799
background-color: #c4da5e;
800800
}
801801
.l-profile__notifications.updates {
802-
background-position: -165px -135px;
803-
}
804-
805-
.l-profile__notifications.updates2 {
806-
/* background-position: -202px -135px; */
807802
background-position: -202px -157px;
808803
}
809804

@@ -820,32 +815,40 @@ input[type="checkbox"] {
820815
z-index: 21;
821816
font-size: 12px;
822817
padding: 0;
823-
color: #9E9E9E;
818+
color: #7f7f7f;
819+
}
820+
.notification-container .unseen {
821+
color: #ABABAB;
824822
}
823+
824+
825825
.notification-container li {
826826
border-bottom: 1px solid #555;
827827
padding: 10px 15px 24px;
828828
}
829829
.notification-container .mark-seen {
830-
background: rgba(0, 0, 0, 0) url("/images/sprite.png") repeat scroll -427px -486px;
831-
border: 5px solid #454545;
832-
border-radius: 12px;
830+
background-color: #abc04b;
831+
border: 2px solid #454545;
832+
border-radius: 10px;
833833
cursor: pointer;
834-
display: inline-block;
834+
display: none;
835835
float: right;
836-
height: 9px;
837-
margin-right: -8px;
838-
margin-top: -3px;
839-
width: 9px;
836+
height: 7px;
837+
margin-right: -5px;
838+
margin-top: 0;
839+
width: 7px;
840840
}
841841
.notification-container .mark-seen:hover {
842842
background-color: #333;
843-
border-color: #333;
843+
border-color: #abc04b;
844844
}
845845
.notification-container .mark-seen:active {
846846
background-color: #777;
847847
border-color: #777;
848848
}
849+
.notification-container .unseen .mark-seen{
850+
display: inline-block;
851+
}
849852
.notification-container .title {
850853
color: #9e9e9e;
851854
font-weight: bold;
@@ -870,7 +873,6 @@ input[type="checkbox"] {
870873
color: #dacf2e;
871874
}
872875

873-
874876
.notification-container a {
875877
color: #5ABDB5;/* #eee;*/
876878
}
@@ -881,6 +883,21 @@ input[type="checkbox"] {
881883
color: #00C0C0;
882884
}
883885

886+
.notification-container .icon {
887+
display: inline-block;
888+
width: 0;
889+
}
890+
.notification-container .icon.filemanager {
891+
display: inline-block;
892+
width: 22px;
893+
background: url("/images/flat_icons.png") repeat scroll -31px -100px;
894+
}
895+
.notification-container .icon.starred {
896+
display: inline-block;
897+
width: 21px;
898+
background: url("/images/sprite.png") repeat scroll -184px 556px;
899+
}
900+
884901

885902

886903
.l-stat {
@@ -3001,6 +3018,10 @@ form#vstobjects.suspended {
30013018
background-color: #5f9491;
30023019
}
30033020

3021+
.description.cancel-success {
3022+
color: #8fac0a;
3023+
font-weight: bold;
3024+
}
30043025

30053026
.description .licence {
30063027
padding: 20px 0;

web/delete/notification/index.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
// Init
3+
error_reporting(NULL);
4+
session_start();
5+
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
6+
7+
8+
// Check token
9+
if ((!isset($_GET['token'])) || ($_SESSION['token'] != $_GET['token'])) {
10+
header('location: /login/');
11+
exit();
12+
}
13+
14+
15+
if($_GET['delete'] == 1){
16+
$v_username = escapeshellarg($user);
17+
$v_id = escapeshellarg((int)$_GET['notification_id']);
18+
exec (VESTA_CMD."v-delete-user-notification ".$v_username." ".$v_id, $output, $return_var);
19+
check_return_code($return_var,$output);
20+
unset($output);
21+
} else {
22+
$v_username = escapeshellarg($user);
23+
$v_id = escapeshellarg((int)$_GET['notification_id']);
24+
echo VESTA_CMD."v-acknowledge-user-notification ".$v_username." ".$v_id;
25+
exec (VESTA_CMD."v-acknowledge-user-notification ".$v_username." ".$v_id, $output, $return_var);
26+
check_return_code($return_var,$output);
27+
unset($output);
28+
}
29+
30+
exit;

web/edit/server/index.php

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
// Init
3-
error_reporting(NULL);
4-
ob_start();
3+
//error_reporting(NULL);
4+
//ob_start();
55
session_start();
66
$TAB = 'SERVER';
77

@@ -333,6 +333,67 @@
333333
if (empty($_SESSION['error_msg'])) {
334334
$_SESSION['ok_msg'] = __('Changes has been saved.');
335335
}
336+
337+
// activating sftp licence
338+
if (empty($_SESSION['error_msg'])) {
339+
if($_SESSION['SFTP_KEY'] != $_POST['v_sftp_licence'] && $_POST['v_sftp'] == 'yes'){
340+
$module = 'sftpjail';
341+
$licence_key = escapeshellarg($_POST['v_sftp_licence']);
342+
exec (VESTA_CMD."v-activate-vesta-license ".$module." ".$licence_key, $output, $return_var);
343+
check_return_code($return_var,$output);
344+
unset($output);
345+
if (empty($_SESSION['error_msg'])) {
346+
$_SESSION['ok_msg'] = __('Licence Activated');
347+
$_SESSION['SFTP_KEY'] = $_POST['v_sftp_licence'];
348+
}
349+
}
350+
}
351+
352+
// cancel sftp licence
353+
if (empty($_SESSION['error_msg'])) {
354+
if($_POST['v_sftp'] == 'cancel' && $_SESSION['SFTP_KEY']){
355+
$module = 'sftpjail';
356+
$licence_key = escapeshellarg($_SESSION['SFTP_KEY']);
357+
exec (VESTA_CMD."v-deactivate-vesta-license ".$module." ".$licence_key, $output, $return_var);
358+
check_return_code($return_var,$output);
359+
unset($output);
360+
if (empty($_SESSION['error_msg'])) {
361+
$_SESSION['ok_msg'] = __('Licence Deactivated');
362+
unset($_SESSION['SFTP_KEY']);
363+
}
364+
}
365+
}
366+
367+
368+
// activating filemanager licence
369+
if (empty($_SESSION['error_msg'])) {
370+
if($_SESSION['FILEMANAGER_KEY'] != $_POST['v_filemanager_licence'] && $_POST['v_filemanager'] == 'yes'){
371+
$module = 'filemanager';
372+
$licence_key = escapeshellarg($_POST['v_filemanager_licence']);
373+
exec (VESTA_CMD."v-activate-vesta-license ".$module." ".$licence_key, $output, $return_var);
374+
check_return_code($return_var,$output);
375+
unset($output);
376+
if (empty($_SESSION['error_msg'])) {
377+
$_SESSION['ok_msg'] = __('Licence Activated');
378+
$_SESSION['FILEMANAGER_KEY'] = $_POST['v_filemanager_licence'];
379+
}
380+
}
381+
}
382+
383+
// cancel filemanager licence
384+
if (empty($_SESSION['error_msg'])) {
385+
if($_POST['v_filemanager'] == 'cancel' && $_SESSION['FILEMANAGER_KEY']){
386+
$module = 'filemanager';
387+
$licence_key = escapeshellarg($_SESSION['FILEMANAGER_KEY']);
388+
exec (VESTA_CMD."v-deactivate-vesta-license ".$module." ".$licence_key, $output, $return_var);
389+
check_return_code($return_var,$output);
390+
unset($output);
391+
if (empty($_SESSION['error_msg'])) {
392+
$_SESSION['ok_msg'] = __('Licence Deactivated');
393+
unset($_SESSION['FILEMANAGER_KEY']);
394+
}
395+
}
396+
}
336397
}
337398

338399
// Check system configuration

0 commit comments

Comments
 (0)