Skip to content

Commit e793453

Browse files
authored
Merge pull request #60 from eruzavin/master
FEATURE SVM-3260 Add PHP 8.1 support
2 parents fc1755a + bb0f53e commit e793453

5 files changed

Lines changed: 32 additions & 31 deletions

File tree

‎modules/servers/solusvmpro/VERSION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.2.0
1+
4.2.1

‎modules/servers/solusvmpro/custom-example.php‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@
1616
# ### server is ordered, if no hostname is specified.
1717
# ###########################################################################
1818
# ################################## CODE ###################################
19-
# $serviceid = $params["serviceid"];
20-
# $clientsdetails = $params["clientsdetails"];
21-
# if(!empty($params[domain])) {
22-
# $currentHost = $params[domain] {
23-
# strlen($params[domain]) - 1}
19+
# $serviceid = $params['serviceid'];
20+
# $clientsdetails = $params['clientsdetails'];
21+
# if(!empty($params['domain'])) {
22+
# $currentHost = $params['domain'] {
23+
# strlen($params['domain']) - 1}
2424
# ;
2525
# if(!strcmp($currentHost, ".")) {
26-
# $newHost = substr($params[domain], 0, -1);
26+
# $newHost = substr($params['domain'], 0, -1);
2727
# mysql_real_escape_string($newHost);
2828
# mysql_query("UPDATE tblhosting SET `domain` = '$newHost' WHERE `id` = '$serviceid'");
2929
# } else {
30-
# $newHost = $params[domain];
30+
# $newHost = $params['domain'];
3131
# }
3232
# } else {
3333
# $newHost = "vps" . $serviceid . $clientsdetails['id'] . ".EXAMPLEDOMAIN.COM";
@@ -56,7 +56,7 @@
5656
# ### from the server list in whmcs
5757
# ###########################################################################
5858
# ################################## CODE ###################################
59-
# $code = '<form action="https://' . $params["serverip"] . ':5656/admincp/login.php" method="post" target="_blank">
59+
# $code = '<form action="https://' . $params['serverip'] . ':5656/admincp/login.php" method="post" target="_blank">
6060
# <input type="hidden" name="username" value="ADMINUSERNAME" />
6161
# <input type="hidden" name="password" value="ADMINPASSOWRD" />
6262
# <input type="submit" name="Submit" value="Login" />

‎modules/servers/solusvmpro/lib/Curl.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public function call()
199199
*/
200200
public function close()
201201
{
202-
if (is_resource($this->curl)) {
202+
if (is_resource($this->curl) || is_object($this->curl)) {
203203
curl_close($this->curl);
204204
}
205205
$this->options = null;

‎modules/servers/solusvmpro/lib/SolusVM.php‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public function sortReturn( $data ) {
201201
foreach ( $matches[1] as $k => $v ) {
202202
$result[ $v ] = $matches[2][ $k ];
203203
}
204-
$this->debugLog( 'solusvmpro', 'process', $data, $result, $result, '' );
204+
$this->debugLog( 'solusvmpro', 'process', $data, $result, $result, [] );
205205

206206
return $result;
207207
}
@@ -231,10 +231,10 @@ public function serverExtra( $mServer = array() ) {
231231

232232
public function passwordGen( $length = 10, $chars = 'abcdefghijklmnopqrstuvwxyzABCEFGHIJKLMNOPQRSTUVWXYZ1234567890' ) {
233233
$chars_length = ( strlen( $chars ) - 1 );
234-
$string = $chars{rand( 0, $chars_length )};
234+
$string = $chars[rand( 0, $chars_length )];
235235
for ( $i = 1; $i < $length; $i = strlen( $string ) ) {
236-
$r = $chars{rand( 0, $chars_length )};
237-
if ( $r != $string{$i - 1} ) {
236+
$r = $chars[rand( 0, $chars_length )];
237+
if ( $r != $string[$i - 1]) {
238238
$string .= $r;
239239
}
240240
}
@@ -660,10 +660,10 @@ public function clientAreaCalculations( $result ) {
660660
if ($result["state"] == "online" || $result["state"] == "offline") {
661661
//Bandwidth graph
662662
$bandwidthData = explode(",", $result["bandwidth"]);
663-
$usedBwPercentage = $bandwidthData[3];
664-
$bandwidthData[1] = $bandwidthData[1] / 1024;
665-
$bandwidthData[2] = $bandwidthData[2] / 1024;
666-
$bandwidthData[0] = $bandwidthData[0] / 1024;
663+
$usedBwPercentage = (int)$bandwidthData[3];
664+
$bandwidthData[1] = (int)$bandwidthData[1] / 1024;
665+
$bandwidthData[2] = (int)$bandwidthData[2] / 1024;
666+
$bandwidthData[0] = (int)$bandwidthData[0] / 1024;
667667
$bwUsed = $this->bwFormat($bandwidthData[1]);
668668
$bwFree = $this->bwFormat($bandwidthData[2]);
669669
$bwTotal = $this->bwFormat($bandwidthData[0]);
@@ -691,10 +691,10 @@ public function clientAreaCalculations( $result ) {
691691
if ($result["type"] == "openvz") {
692692
if ($this->getExtData("memusage") != "disable") {
693693
$memData = explode(",", $result["memory"]);
694-
$usedMemPercentage = $memData[3];
695-
$memData[1] = $memData[1] / 1024;
696-
$memData[2] = $memData[2] / 1024;
697-
$memData[0] = $memData[0] / 1024;
694+
$usedMemPercentage = (int)$memData[3];
695+
$memData[1] = (int)$memData[1] / 1024;
696+
$memData[2] = (int)$memData[2] / 1024;
697+
$memData[0] = (int)$memData[0] / 1024;
698698
$memUsed = $this->bwFormat($memData[1]);
699699
$memFree = $this->bwFormat($memData[2]);
700700
$memTotal = $this->bwFormat($memData[0]);
@@ -721,10 +721,10 @@ public function clientAreaCalculations( $result ) {
721721
if ($result["type"] == "openvz" || $result["type"] == "xen") {
722722
if ($this->getExtData("diskusage") != "disable") {
723723
$hddData = explode(",", $result["hdd"]);
724-
$usedHddPercentage = $hddData[3];
725-
$hddData[1] = $hddData[1] / 1024;
726-
$hddData[2] = $hddData[2] / 1024;
727-
$hddData[0] = $hddData[0] / 1024;
724+
$usedHddPercentage = (int)$hddData[3];
725+
$hddData[1] = (int)$hddData[1] / 1024;
726+
$hddData[2] = (int)$hddData[2] / 1024;
727+
$hddData[0] = (int)$hddData[0] / 1024;
728728
$hddUsed = $this->bwFormat($hddData[1]);
729729
$hddFree = $this->bwFormat($hddData[2]);
730730
$hddTotal = $this->bwFormat($hddData[0]);
@@ -1100,7 +1100,7 @@ public function isSuccessResponse( $result ) {
11001100
*
11011101
* @return array
11021102
*/
1103-
public function collectionToArray($object) {
1103+
public static function collectionToArray($object) {
11041104
if (is_array($object)) {
11051105
return $object;
11061106
}

‎modules/servers/solusvmpro/solusvmpro.php‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@ function solusvmpro_ChangePackage( $params ) {
732732

733733
}
734734

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

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

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

12091210
Capsule::table('tblhosting')
12101211
->where('id', $ownerRow->id)

0 commit comments

Comments
 (0)