Jump to content

WHMCS and WHMSONIC module


DraGoNeTi

Recommended Posts

Hello,

i am trying to figure how to add a product and the server in whmcs.

i added the server as i know and working great, but i have an issue with the products. how can i configure them to work properly for internal accounts?

what should i set to the module/product so that it can work properly ? it makes the radio account but with no name... (i 've added the custom field)

and i don't want to use external radio accounts

Link to comment
Share on other sites

Ah don't mind this topic... ! I even don't understand what i have asked, lol !

Well let's get things straight....

As i searched in this community and on the internet, i found that the WHMCS module for whmsonic is outdated. So i found from whmsonic a module for v1.9 and tested it on php5.6 and working great. the thing is that i want to switch with php-fpm to php7.0 and the module crashes because it was encoded for php5.6 . can someone help me or point me somewhere that i can fix this ? 

whmcs_whmsonicv1.9.zip

Link to comment
Share on other sites

11 hours ago, DraGoNeTi said:

Yes I tried it. It's the file I attached. The point is that I want to use php7.0 and the file is for php5.6

I couldn't tell - I can't download your attachment.

I assume the full v7.5 release will have an encoded version for PHP7+ because there is one in the RC1 beta.

Link to comment
Share on other sites

well, the file i attached is the one i found in the whmsonic site, v1.9 but "it is encoded for php5.6".... i want the module v1.9 to use with php7.0. i already have started a ticket with whmsonic and still waiting an answer. i assume there is someone who checks the tickets and will respond .. ! until then, as you say, the bet version whmcs 7.5, does it have the module i want or the v2.2 ?

Link to comment
Share on other sites

15 hours ago, DraGoNeTi said:

This is the file that WHMSonic suport gave me for my needs... !

I don't seem able to download that attachment...

Quote

Sorry, there is a problem

The page you are trying to access is not available for your account.

Error code: 2C171/1

 

Link to comment
Share on other sites

<?php

function whmsonic_ConfigOptions($params) {

// Since params are not assigned to ConfigOptions from WHMCS this is a temporary solution until params are assigned.
$sqlsonic = "SELECT * FROM tblservers WHERE type='whmsonic'";
$resultsonic = mysql_query($sqlsonic);
while($row=mysql_fetch_array($resultsonic)){
	$server_ip = $row[ipaddress];
	$server_p = $row[password];
	$serveruser = $row[username];
	}
    $server_p = decrypt($server_p);
    $auth = "$serveruser:$server_p";
// Since params are not assigned to ConfigOptions from WHMCS this is a temporary solution until params are assigned.

$url = "https://$server_ip:2087/whmsonic/modules/api2.php?";
$data = "cmd=packs&owner=$serveruser";
$ch = curl_init();
curl_setopt($ch, CURLAUTH_BASIC, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, $auth);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 59);
curl_setopt($ch, CURLOPT_URL, $url);
$retval = curl_exec($ch);
curl_close($ch);

	if (strpos($retval,"Login Attempt Failed!") == true) {$result = "Unable to connect to the server. Check your root password in WHMCS server settings.";
	} else {
	$result = "$retval";
	}

$configarraysonic = array(
 "Client Type" => array( "Type" => "dropdown", "Options" => "External,internal","Description" => "If Internal, create a custom field with 'cpanel username' field name without ' '"),
 "" => array( "Type" => ""), // To make the options appear better.
  "Radio Account Packages" => array( "Type" => "dropdown", "Options" => "$result","Description" => "Create packages in WHMSonic root to use here."),
);
return $configarraysonic;
}



function whmsonic_CreateAccount($params) {

    // Get The Package Information
    $stype = $params["configoption1"];
    $radioip = $params["serverip"];
    $package = $params["configoption3"];


    // Get The General Information
    $serverp = $params["serverpassword"]; // Target Server root password
    $serveruser = $params["serverusername"];
    $auth = "$serveruser:$serverp";
    $orderid = $params["serviceid"];

    // Get The Client Information
    $client_email = $params["clientsdetails"]["email"];
    $client_name = $params["clientsdetails"]["firstname"];
    if ($params["configoption1"]=="internal") {
	$radiousername = $params["customfields"]["cpanel username"];
	} else {
	// External user, create a custom WHMSonic username & password.
	$chars = "abcdefghijkmnpqrstuvwxyz123456789";
    srand((double)microtime()*1000000);
    $i = 0;
    $exu = '' ;
    while ($i <= 4) {
    $num = rand() % 33;
    $tmp = substr($chars, $num, 1);
    $exu = $exu . $tmp;
    $i++;}
    $radiousername = "sc_$exu";}
    $chars2 = "ABCDEFGHJKMNPQRSTUVWXYZ23456789";
    srand((double)microtime()*1000000);
    $i = 0;
    $pass = '' ;
    while ($i <= 20) {
    $num = rand() % 45;
    $tmp = substr($chars2, $num, 1);
    $pass = $pass . $tmp;
    $i++;
}

$url = "https://$radioip:2087/whmsonic/modules/api2.php?";
$data = "cmd=setup&stype=$stype&ip=$radioip&cemail=$client_email&rad_username=$radiousername&c_pass=$pass&owner=$serveruser&package=$package&esend=yes";
$ch = curl_init();
curl_setopt($ch, CURLAUTH_BASIC, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, $auth);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 59);
curl_setopt($ch, CURLOPT_URL, $url);
$retval = curl_exec($ch);
if (curl_errno($ch)) {
    $retval = "CURL Error: ".curl_errno($ch)." - ".curl_error($ch)." - Unable to connect, check serverIP in WHMCS servers setting of WHMSonic.";
}
curl_close($ch);

	if ($retval=="Complete") {
	// Update WHMCS db for the username, required for other actions.
    $hostpass = encrypt($pass);
    mysql_query("UPDATE tblhosting SET username='$radiousername', password='$hostpass' WHERE id='".$params["accountid"]."'");
    // Update WHMCS db for the username, required for other actions.
	$result = "success";
	} else {
	if (strpos($retval,"Login Attempt Failed!") == true) {$result = "WHMSonic server($radioip) WHM login failed! The username or password is incorrect. Please check your WHMSonic server/connection settings in WHMCS servers settings of WHMSonic.";
	} else {
	$result = "$retval";
	}}
	return $result;
}


function whmsonic_TerminateAccount($params) {

    // Details
    $radioip = $params["serverip"];
    $rad_username= $params["username"];
    $serverp = $params["serverpassword"];
    $serveruser = $params["serverusername"];
    $auth = "$serveruser:$serverp";

$url = "https://$radioip:2087/whmsonic/modules/api2.php?";
$data = "cmd=terminate&rad_username=$rad_username";
$ch = curl_init();
curl_setopt($ch, CURLAUTH_BASIC, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, $auth);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 59);
curl_setopt($ch, CURLOPT_URL, $url);
$retval = curl_exec($ch);
if (curl_errno($ch)) {
    $retval = "CURL Error: ".curl_errno($ch)." - ".curl_error($ch);
}
curl_close($ch);

	if ($retval=="Complete") {
		$result = "success";
	} else {
		$result = "<br>$retval";
	}
	return $result;
}

function whmsonic_SuspendAccount($params) {

    // Details
    $radioip = $params["serverip"];
    $rad_username= $params["username"];
    $serverp = $params["serverpassword"];
    $serveruser = $params["serverusername"];
    $auth = "$serveruser:$serverp";

$url = "https://$radioip:2087/whmsonic/modules/api2.php?";
$data = "cmd=suspend&rad_username=$rad_username";
$ch = curl_init();
curl_setopt($ch, CURLAUTH_BASIC, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, $auth);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 59);
curl_setopt($ch, CURLOPT_URL, $url);
$retval = curl_exec($ch);
if (curl_errno($ch)) {
    $retval = "CURL Error: ".curl_errno($ch)." - ".curl_error($ch);
}
curl_close($ch);

	if ($retval=="Complete") {
		$result = "success";
	} else {
		$result = "<br>$retval";
	}
	return $result;

}

function whmsonic_UnsuspendAccount($params) {

    // Details
    $radioip = $params["serverip"];
    $rad_username= $params["username"];
    $serverp = $params["serverpassword"]; // Target Server root password
    $serveruser = $params["serverusername"];
    $auth = "$serveruser:$serverp";

$url = "https://$radioip:2087/whmsonic/modules/api2.php?";
$data = "cmd=unsuspend&rad_username=$rad_username";
$ch = curl_init();
curl_setopt($ch, CURLAUTH_BASIC, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, $auth);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 59);
curl_setopt($ch, CURLOPT_URL, $url);
$retval = curl_exec($ch);
if (curl_errno($ch)) {
    $retval = "CURL Error: ".curl_errno($ch)." - ".curl_error($ch);
}
curl_close($ch);

	if ($retval=="Complete") {
		$result = "success";
	} else {
		$result = "<br>$retval";
	}
	return $result;

}

function whmsonic_ClientArea($params) {
	$connection = $params["serverip"];
	$code = "<form action=http://$connection/cpanel/ method=post target=_blank><input type=hidden name=ip value=$licenseip><input type=submit value=\"WHMSonic Login\"></form>";
	return $code;
}
function whmsonic_AdminLink($params) {
    $connection = $params["serverip"];
	$code = "<form action=https://$connection:2087/whmsonic/main.php method=post target=_blank><input type=hidden name=username value=\"".$params["serverusername"]."\"><input type=hidden name=password value=\"".$params["serverpassword"]."\"><input type=submit value=\"WHMSonic Root\"></form>";
	return $code;
}
?>

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated