Skip to content

Commit

Permalink
Merge pull request #60 from eruzavin/master
Browse files Browse the repository at this point in the history
FEATURE SVM-3260 Add PHP 8.1 support
  • Loading branch information
eruzavin authored Nov 18, 2022
2 parents fc1755a + bb0f53e commit e793453
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 31 deletions.
2 changes: 1 addition & 1 deletion modules/servers/solusvmpro/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.2.0
4.2.1
16 changes: 8 additions & 8 deletions modules/servers/solusvmpro/custom-example.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
# ### server is ordered, if no hostname is specified.
# ###########################################################################
# ################################## CODE ###################################
# $serviceid = $params["serviceid"];
# $clientsdetails = $params["clientsdetails"];
# if(!empty($params[domain])) {
# $currentHost = $params[domain] {
# strlen($params[domain]) - 1}
# $serviceid = $params['serviceid'];
# $clientsdetails = $params['clientsdetails'];
# if(!empty($params['domain'])) {
# $currentHost = $params['domain'] {
# strlen($params['domain']) - 1}
# ;
# if(!strcmp($currentHost, ".")) {
# $newHost = substr($params[domain], 0, -1);
# $newHost = substr($params['domain'], 0, -1);
# mysql_real_escape_string($newHost);
# mysql_query("UPDATE tblhosting SET `domain` = '$newHost' WHERE `id` = '$serviceid'");
# } else {
# $newHost = $params[domain];
# $newHost = $params['domain'];
# }
# } else {
# $newHost = "vps" . $serviceid . $clientsdetails['id'] . ".EXAMPLEDOMAIN.COM";
Expand Down Expand Up @@ -56,7 +56,7 @@
# ### from the server list in whmcs
# ###########################################################################
# ################################## CODE ###################################
# $code = '<form action="https://' . $params["serverip"] . ':5656/admincp/login.php" method="post" target="_blank">
# $code = '<form action="https://' . $params['serverip'] . ':5656/admincp/login.php" method="post" target="_blank">
# <input type="hidden" name="username" value="ADMINUSERNAME" />
# <input type="hidden" name="password" value="ADMINPASSOWRD" />
# <input type="submit" name="Submit" value="Login" />
Expand Down
2 changes: 1 addition & 1 deletion modules/servers/solusvmpro/lib/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function call()
*/
public function close()
{
if (is_resource($this->curl)) {
if (is_resource($this->curl) || is_object($this->curl)) {
curl_close($this->curl);
}
$this->options = null;
Expand Down
34 changes: 17 additions & 17 deletions modules/servers/solusvmpro/lib/SolusVM.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function sortReturn( $data ) {
foreach ( $matches[1] as $k => $v ) {
$result[ $v ] = $matches[2][ $k ];
}
$this->debugLog( 'solusvmpro', 'process', $data, $result, $result, '' );
$this->debugLog( 'solusvmpro', 'process', $data, $result, $result, [] );

return $result;
}
Expand Down Expand Up @@ -231,10 +231,10 @@ public function serverExtra( $mServer = array() ) {

public function passwordGen( $length = 10, $chars = 'abcdefghijklmnopqrstuvwxyzABCEFGHIJKLMNOPQRSTUVWXYZ1234567890' ) {
$chars_length = ( strlen( $chars ) - 1 );
$string = $chars{rand( 0, $chars_length )};
$string = $chars[rand( 0, $chars_length )];
for ( $i = 1; $i < $length; $i = strlen( $string ) ) {
$r = $chars{rand( 0, $chars_length )};
if ( $r != $string{$i - 1} ) {
$r = $chars[rand( 0, $chars_length )];
if ( $r != $string[$i - 1]) {
$string .= $r;
}
}
Expand Down Expand Up @@ -660,10 +660,10 @@ public function clientAreaCalculations( $result ) {
if ($result["state"] == "online" || $result["state"] == "offline") {
//Bandwidth graph
$bandwidthData = explode(",", $result["bandwidth"]);
$usedBwPercentage = $bandwidthData[3];
$bandwidthData[1] = $bandwidthData[1] / 1024;
$bandwidthData[2] = $bandwidthData[2] / 1024;
$bandwidthData[0] = $bandwidthData[0] / 1024;
$usedBwPercentage = (int)$bandwidthData[3];
$bandwidthData[1] = (int)$bandwidthData[1] / 1024;
$bandwidthData[2] = (int)$bandwidthData[2] / 1024;
$bandwidthData[0] = (int)$bandwidthData[0] / 1024;
$bwUsed = $this->bwFormat($bandwidthData[1]);
$bwFree = $this->bwFormat($bandwidthData[2]);
$bwTotal = $this->bwFormat($bandwidthData[0]);
Expand Down Expand Up @@ -691,10 +691,10 @@ public function clientAreaCalculations( $result ) {
if ($result["type"] == "openvz") {
if ($this->getExtData("memusage") != "disable") {
$memData = explode(",", $result["memory"]);
$usedMemPercentage = $memData[3];
$memData[1] = $memData[1] / 1024;
$memData[2] = $memData[2] / 1024;
$memData[0] = $memData[0] / 1024;
$usedMemPercentage = (int)$memData[3];
$memData[1] = (int)$memData[1] / 1024;
$memData[2] = (int)$memData[2] / 1024;
$memData[0] = (int)$memData[0] / 1024;
$memUsed = $this->bwFormat($memData[1]);
$memFree = $this->bwFormat($memData[2]);
$memTotal = $this->bwFormat($memData[0]);
Expand All @@ -721,10 +721,10 @@ public function clientAreaCalculations( $result ) {
if ($result["type"] == "openvz" || $result["type"] == "xen") {
if ($this->getExtData("diskusage") != "disable") {
$hddData = explode(",", $result["hdd"]);
$usedHddPercentage = $hddData[3];
$hddData[1] = $hddData[1] / 1024;
$hddData[2] = $hddData[2] / 1024;
$hddData[0] = $hddData[0] / 1024;
$usedHddPercentage = (int)$hddData[3];
$hddData[1] = (int)$hddData[1] / 1024;
$hddData[2] = (int)$hddData[2] / 1024;
$hddData[0] = (int)$hddData[0] / 1024;
$hddUsed = $this->bwFormat($hddData[1]);
$hddFree = $this->bwFormat($hddData[2]);
$hddTotal = $this->bwFormat($hddData[0]);
Expand Down Expand Up @@ -1100,7 +1100,7 @@ public function isSuccessResponse( $result ) {
*
* @return array
*/
public function collectionToArray($object) {
public static function collectionToArray($object) {
if (is_array($object)) {
return $object;
}
Expand Down
9 changes: 5 additions & 4 deletions modules/servers/solusvmpro/solusvmpro.php
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ function solusvmpro_ChangePackage( $params ) {

}

$lines_arr = [];
if ( $cextraip > 0 ){
//first() function doesn't work
$ipaddresses = SolusVM::collectionToArray(Capsule::table('tblhosting')->select('assignedips')->where( 'id', $params['serviceid'] )->get());
Expand Down Expand Up @@ -1199,12 +1200,12 @@ function solusvmpro_UsageUpdate($params)
$r = json_decode($res);

$bandwidthData = explode(',', $r->bandwidth);
$bwusage = round($bandwidthData[1] / 1024 ** 2, 0, PHP_ROUND_HALF_UP);
$bwlimit = round($bandwidthData[0] / 1024 ** 2, 0, PHP_ROUND_HALF_UP);
$bwusage = round((int)$bandwidthData[1] / 1024 ** 2, 0, PHP_ROUND_HALF_UP);
$bwlimit = round((int)$bandwidthData[0] / 1024 ** 2, 0, PHP_ROUND_HALF_UP);

$hddData = explode(',', $r->hdd);
$diskusage = round($hddData[1] / 1024 ** 2, 0, PHP_ROUND_HALF_UP);
$disklimit = round($hddData[0] / 1024 ** 2, 0, PHP_ROUND_HALF_UP);
$diskusage = round((int)$hddData[1] / 1024 ** 2, 0, PHP_ROUND_HALF_UP);
$disklimit = round((int)$hddData[0] / 1024 ** 2, 0, PHP_ROUND_HALF_UP);

Capsule::table('tblhosting')
->where('id', $ownerRow->id)
Expand Down

0 comments on commit e793453

Please sign in to comment.