From 2e78f1e3c971f7371e69d6ca15a9cf4ce5a796b8 Mon Sep 17 00:00:00 2001 From: kotso Date: Wed, 25 Mar 2015 00:38:51 +0400 Subject: [PATCH 1/4] Fixed error when connecting to 8083 over HTTP Fixed error "400 The plain HTTP request was sent to HTTPS port" By putting custom error page on http error coder 497 that redirects http uri to https uri --- src/rpm/conf/nginx.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rpm/conf/nginx.conf b/src/rpm/conf/nginx.conf index 7a3d2fd0e..bf3618969 100644 --- a/src/rpm/conf/nginx.conf +++ b/src/rpm/conf/nginx.conf @@ -82,6 +82,9 @@ http { root /usr/local/vesta/web; charset utf-8; + // Fix error "The plain HTTP request was sent to HTTPS port" + error_page 497 https://$host:$server_port$request_uri; + ssl on; ssl_certificate /usr/local/vesta/ssl/certificate.crt; ssl_certificate_key /usr/local/vesta/ssl/certificate.key; From 63e37289993a4e43bb9b94213ae608706c6d7b51 Mon Sep 17 00:00:00 2001 From: kotso Date: Wed, 25 Mar 2015 01:23:28 +0400 Subject: [PATCH 2/4] Fixed Multiple bugs in WHMCS module Added module debug logging Fixed simple bugs in function result codes returns --- install/ubuntu/whmcs-module.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/install/ubuntu/whmcs-module.php b/install/ubuntu/whmcs-module.php index b3b1710ee..6775ac016 100644 --- a/install/ubuntu/whmcs-module.php +++ b/install/ubuntu/whmcs-module.php @@ -43,6 +43,8 @@ function vesta_CreateAccount($params) { curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); $answer = curl_exec($curl); + logModuleCall('vesta','CreateAccount_UserAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + // Enable ssh access if(($answer == 'OK') && ($params["configoption2"] == 'on')) { $postvars = array( @@ -62,6 +64,8 @@ function vesta_CreateAccount($params) { curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); $answer = curl_exec($curl); + + logModuleCall('vesta','CreateAccount_EnableSSH','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); } // Add domain @@ -84,6 +88,8 @@ function vesta_CreateAccount($params) { curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); $answer = curl_exec($curl); + + logModuleCall('vesta','CreateAccount_AddDomain','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); } } @@ -92,8 +98,8 @@ function vesta_CreateAccount($params) { } else { $result = $answer; } - return $result; + return $result; } function vesta_TerminateAccount($params) { @@ -122,6 +128,8 @@ function vesta_TerminateAccount($params) { $answer = curl_exec($curl); } + logModuleCall('vesta','TerminateAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + if($answer == 'OK') { $result = "success"; } else { @@ -129,7 +137,6 @@ function vesta_TerminateAccount($params) { } return $result; - } function vesta_SuspendAccount($params) { @@ -158,12 +165,15 @@ function vesta_SuspendAccount($params) { $answer = curl_exec($curl); } + logModuleCall('vesta','SuspendAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + if($answer == 'OK') { $result = "success"; } else { $result = $answer; } + return $result; } function vesta_UnsuspendAccount($params) { @@ -192,12 +202,15 @@ function vesta_UnsuspendAccount($params) { $answer = curl_exec($curl); } + logModuleCall('vesta','UnsuspendAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + if($answer == 'OK') { $result = "success"; } else { $result = $answer; } + return $result; } function vesta_ChangePassword($params) { @@ -227,13 +240,15 @@ function vesta_ChangePassword($params) { $answer = curl_exec($curl); } + logModuleCall('vesta','ChangePassword','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + if($answer == 'OK') { $result = "success"; } else { $result = $answer; } + return $result; - } function vesta_ChangePackage($params) { @@ -263,13 +278,15 @@ function vesta_ChangePackage($params) { $answer = curl_exec($curl); } + logModuleCall('vesta','ChangePackage','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + if($answer == 'OK') { $result = "success"; } else { $result = $answer; } - return $result; + return $result; } function vesta_ClientArea($params) { From e690ee5048f0d502e535d985c0b1369969af468e Mon Sep 17 00:00:00 2001 From: kotso Date: Wed, 25 Mar 2015 01:32:10 +0400 Subject: [PATCH 3/4] Updated changes in other distribution folders I think this file should be stored in some other folder. No need to keep same copy of file in 3 different folders. This file is not OS specific. --- install/debian/whmcs-module.php | 25 +++++++++++++++++++++---- install/rhel/whmcs-module.php | 25 +++++++++++++++++++++---- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/install/debian/whmcs-module.php b/install/debian/whmcs-module.php index b3b1710ee..6775ac016 100644 --- a/install/debian/whmcs-module.php +++ b/install/debian/whmcs-module.php @@ -43,6 +43,8 @@ function vesta_CreateAccount($params) { curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); $answer = curl_exec($curl); + logModuleCall('vesta','CreateAccount_UserAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + // Enable ssh access if(($answer == 'OK') && ($params["configoption2"] == 'on')) { $postvars = array( @@ -62,6 +64,8 @@ function vesta_CreateAccount($params) { curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); $answer = curl_exec($curl); + + logModuleCall('vesta','CreateAccount_EnableSSH','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); } // Add domain @@ -84,6 +88,8 @@ function vesta_CreateAccount($params) { curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); $answer = curl_exec($curl); + + logModuleCall('vesta','CreateAccount_AddDomain','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); } } @@ -92,8 +98,8 @@ function vesta_CreateAccount($params) { } else { $result = $answer; } - return $result; + return $result; } function vesta_TerminateAccount($params) { @@ -122,6 +128,8 @@ function vesta_TerminateAccount($params) { $answer = curl_exec($curl); } + logModuleCall('vesta','TerminateAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + if($answer == 'OK') { $result = "success"; } else { @@ -129,7 +137,6 @@ function vesta_TerminateAccount($params) { } return $result; - } function vesta_SuspendAccount($params) { @@ -158,12 +165,15 @@ function vesta_SuspendAccount($params) { $answer = curl_exec($curl); } + logModuleCall('vesta','SuspendAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + if($answer == 'OK') { $result = "success"; } else { $result = $answer; } + return $result; } function vesta_UnsuspendAccount($params) { @@ -192,12 +202,15 @@ function vesta_UnsuspendAccount($params) { $answer = curl_exec($curl); } + logModuleCall('vesta','UnsuspendAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + if($answer == 'OK') { $result = "success"; } else { $result = $answer; } + return $result; } function vesta_ChangePassword($params) { @@ -227,13 +240,15 @@ function vesta_ChangePassword($params) { $answer = curl_exec($curl); } + logModuleCall('vesta','ChangePassword','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + if($answer == 'OK') { $result = "success"; } else { $result = $answer; } + return $result; - } function vesta_ChangePackage($params) { @@ -263,13 +278,15 @@ function vesta_ChangePackage($params) { $answer = curl_exec($curl); } + logModuleCall('vesta','ChangePackage','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + if($answer == 'OK') { $result = "success"; } else { $result = $answer; } - return $result; + return $result; } function vesta_ClientArea($params) { diff --git a/install/rhel/whmcs-module.php b/install/rhel/whmcs-module.php index b3b1710ee..6775ac016 100644 --- a/install/rhel/whmcs-module.php +++ b/install/rhel/whmcs-module.php @@ -43,6 +43,8 @@ function vesta_CreateAccount($params) { curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); $answer = curl_exec($curl); + logModuleCall('vesta','CreateAccount_UserAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + // Enable ssh access if(($answer == 'OK') && ($params["configoption2"] == 'on')) { $postvars = array( @@ -62,6 +64,8 @@ function vesta_CreateAccount($params) { curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); $answer = curl_exec($curl); + + logModuleCall('vesta','CreateAccount_EnableSSH','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); } // Add domain @@ -84,6 +88,8 @@ function vesta_CreateAccount($params) { curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); $answer = curl_exec($curl); + + logModuleCall('vesta','CreateAccount_AddDomain','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); } } @@ -92,8 +98,8 @@ function vesta_CreateAccount($params) { } else { $result = $answer; } - return $result; + return $result; } function vesta_TerminateAccount($params) { @@ -122,6 +128,8 @@ function vesta_TerminateAccount($params) { $answer = curl_exec($curl); } + logModuleCall('vesta','TerminateAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + if($answer == 'OK') { $result = "success"; } else { @@ -129,7 +137,6 @@ function vesta_TerminateAccount($params) { } return $result; - } function vesta_SuspendAccount($params) { @@ -158,12 +165,15 @@ function vesta_SuspendAccount($params) { $answer = curl_exec($curl); } + logModuleCall('vesta','SuspendAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + if($answer == 'OK') { $result = "success"; } else { $result = $answer; } + return $result; } function vesta_UnsuspendAccount($params) { @@ -192,12 +202,15 @@ function vesta_UnsuspendAccount($params) { $answer = curl_exec($curl); } + logModuleCall('vesta','UnsuspendAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + if($answer == 'OK') { $result = "success"; } else { $result = $answer; } + return $result; } function vesta_ChangePassword($params) { @@ -227,13 +240,15 @@ function vesta_ChangePassword($params) { $answer = curl_exec($curl); } + logModuleCall('vesta','ChangePassword','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + if($answer == 'OK') { $result = "success"; } else { $result = $answer; } + return $result; - } function vesta_ChangePackage($params) { @@ -263,13 +278,15 @@ function vesta_ChangePackage($params) { $answer = curl_exec($curl); } + logModuleCall('vesta','ChangePackage','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + if($answer == 'OK') { $result = "success"; } else { $result = $answer; } - return $result; + return $result; } function vesta_ClientArea($params) { From 1d12eb46d429d8f4c17786cef82464a1e074fd62 Mon Sep 17 00:00:00 2001 From: kotso Date: Wed, 25 Mar 2015 14:45:44 +0400 Subject: [PATCH 4/4] PHP syntax errors fix --- install/debian/whmcs-module.php | 16 ++++++++-------- install/rhel/whmcs-module.php | 16 ++++++++-------- install/ubuntu/whmcs-module.php | 16 ++++++++-------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/install/debian/whmcs-module.php b/install/debian/whmcs-module.php index 6775ac016..1cb250611 100644 --- a/install/debian/whmcs-module.php +++ b/install/debian/whmcs-module.php @@ -43,7 +43,7 @@ function vesta_CreateAccount($params) { curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); $answer = curl_exec($curl); - logModuleCall('vesta','CreateAccount_UserAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','CreateAccount_UserAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); // Enable ssh access if(($answer == 'OK') && ($params["configoption2"] == 'on')) { @@ -65,7 +65,7 @@ function vesta_CreateAccount($params) { curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); $answer = curl_exec($curl); - logModuleCall('vesta','CreateAccount_EnableSSH','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','CreateAccount_EnableSSH','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); } // Add domain @@ -89,7 +89,7 @@ function vesta_CreateAccount($params) { curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); $answer = curl_exec($curl); - logModuleCall('vesta','CreateAccount_AddDomain','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','CreateAccount_AddDomain','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); } } @@ -128,7 +128,7 @@ function vesta_TerminateAccount($params) { $answer = curl_exec($curl); } - logModuleCall('vesta','TerminateAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','TerminateAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); if($answer == 'OK') { $result = "success"; @@ -165,7 +165,7 @@ function vesta_SuspendAccount($params) { $answer = curl_exec($curl); } - logModuleCall('vesta','SuspendAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','SuspendAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); if($answer == 'OK') { $result = "success"; @@ -202,7 +202,7 @@ function vesta_UnsuspendAccount($params) { $answer = curl_exec($curl); } - logModuleCall('vesta','UnsuspendAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','UnsuspendAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); if($answer == 'OK') { $result = "success"; @@ -240,7 +240,7 @@ function vesta_ChangePassword($params) { $answer = curl_exec($curl); } - logModuleCall('vesta','ChangePassword','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','ChangePassword','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); if($answer == 'OK') { $result = "success"; @@ -278,7 +278,7 @@ function vesta_ChangePackage($params) { $answer = curl_exec($curl); } - logModuleCall('vesta','ChangePackage','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','ChangePackage','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); if($answer == 'OK') { $result = "success"; diff --git a/install/rhel/whmcs-module.php b/install/rhel/whmcs-module.php index 6775ac016..1cb250611 100644 --- a/install/rhel/whmcs-module.php +++ b/install/rhel/whmcs-module.php @@ -43,7 +43,7 @@ function vesta_CreateAccount($params) { curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); $answer = curl_exec($curl); - logModuleCall('vesta','CreateAccount_UserAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','CreateAccount_UserAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); // Enable ssh access if(($answer == 'OK') && ($params["configoption2"] == 'on')) { @@ -65,7 +65,7 @@ function vesta_CreateAccount($params) { curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); $answer = curl_exec($curl); - logModuleCall('vesta','CreateAccount_EnableSSH','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','CreateAccount_EnableSSH','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); } // Add domain @@ -89,7 +89,7 @@ function vesta_CreateAccount($params) { curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); $answer = curl_exec($curl); - logModuleCall('vesta','CreateAccount_AddDomain','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','CreateAccount_AddDomain','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); } } @@ -128,7 +128,7 @@ function vesta_TerminateAccount($params) { $answer = curl_exec($curl); } - logModuleCall('vesta','TerminateAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','TerminateAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); if($answer == 'OK') { $result = "success"; @@ -165,7 +165,7 @@ function vesta_SuspendAccount($params) { $answer = curl_exec($curl); } - logModuleCall('vesta','SuspendAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','SuspendAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); if($answer == 'OK') { $result = "success"; @@ -202,7 +202,7 @@ function vesta_UnsuspendAccount($params) { $answer = curl_exec($curl); } - logModuleCall('vesta','UnsuspendAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','UnsuspendAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); if($answer == 'OK') { $result = "success"; @@ -240,7 +240,7 @@ function vesta_ChangePassword($params) { $answer = curl_exec($curl); } - logModuleCall('vesta','ChangePassword','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','ChangePassword','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); if($answer == 'OK') { $result = "success"; @@ -278,7 +278,7 @@ function vesta_ChangePackage($params) { $answer = curl_exec($curl); } - logModuleCall('vesta','ChangePackage','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','ChangePackage','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); if($answer == 'OK') { $result = "success"; diff --git a/install/ubuntu/whmcs-module.php b/install/ubuntu/whmcs-module.php index 6775ac016..1cb250611 100644 --- a/install/ubuntu/whmcs-module.php +++ b/install/ubuntu/whmcs-module.php @@ -43,7 +43,7 @@ function vesta_CreateAccount($params) { curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); $answer = curl_exec($curl); - logModuleCall('vesta','CreateAccount_UserAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','CreateAccount_UserAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); // Enable ssh access if(($answer == 'OK') && ($params["configoption2"] == 'on')) { @@ -65,7 +65,7 @@ function vesta_CreateAccount($params) { curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); $answer = curl_exec($curl); - logModuleCall('vesta','CreateAccount_EnableSSH','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','CreateAccount_EnableSSH','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); } // Add domain @@ -89,7 +89,7 @@ function vesta_CreateAccount($params) { curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); $answer = curl_exec($curl); - logModuleCall('vesta','CreateAccount_AddDomain','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','CreateAccount_AddDomain','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); } } @@ -128,7 +128,7 @@ function vesta_TerminateAccount($params) { $answer = curl_exec($curl); } - logModuleCall('vesta','TerminateAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','TerminateAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); if($answer == 'OK') { $result = "success"; @@ -165,7 +165,7 @@ function vesta_SuspendAccount($params) { $answer = curl_exec($curl); } - logModuleCall('vesta','SuspendAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','SuspendAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); if($answer == 'OK') { $result = "success"; @@ -202,7 +202,7 @@ function vesta_UnsuspendAccount($params) { $answer = curl_exec($curl); } - logModuleCall('vesta','UnsuspendAccount','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','UnsuspendAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); if($answer == 'OK') { $result = "success"; @@ -240,7 +240,7 @@ function vesta_ChangePassword($params) { $answer = curl_exec($curl); } - logModuleCall('vesta','ChangePassword','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','ChangePassword','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); if($answer == 'OK') { $result = "success"; @@ -278,7 +278,7 @@ function vesta_ChangePackage($params) { $answer = curl_exec($curl); } - logModuleCall('vesta','ChangePackage','https://'.$params["serverhostname"].':8083/api/'$postdata,$answer); + logModuleCall('vesta','ChangePackage','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer); if($answer == 'OK') { $result = "success";