Jump to content

Issues with Some Code in the Latest WHMCS FreeRadius Module


ezyweb

Recommended Posts

G'day everyone .. I'm hoping someone can help me, please.

We're using the WHMCS FreeRadius module to provision and manage DSL and NBN tails for our customer, but we need a couple of extra elements added to it. Matt Pugh was really helpful with the previous version, but now that cPanel has partnered with WHMCS, they no longer offer the kind of fairly simple assistance he did.

So, here goes ...

This is the original code that still works if we use the old module

$query = "UPDATE radip SET allocated=('$username') WHERE allocated='' LIMIT 1";
$result = mysql_query($query,$nbnconnectsql);
if (!$result) {
	$nbnconnectsqlerror = mysql_error();
	nbnconnect_WHMCSReconnect();
	return "FreeRadius Database Query Error: ".$nbnconnectsqlerror;

 

And here's the code I'm trying to add into the new version of the module

$nbnconnectsql
	->from('radip')
	->where('allocated', '=', '')
	->update(array(
	'allocated' => $username,
))
->limit(1);

 

But the latter keeps throwing the following error, and for the life of me, I can't work out why

Module Command Error
FreeRadius Database Query Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'username' in 'where clause' (SQL: update `radip` set `allocated` = LOC000012345678@domain.net.au where `username` = LOC000012345678@domain.net.au)

 

Where the heck is it getting the "username" column from??

 

Once the action above is working, we then need it to do the following (old code first that works, followed by the new that I'm stuck on) ...

OLD and working

$query = "UPDATE radreply SET value=(SELECT ip FROM radip WHERE allocated='$username') WHERE value='' AND username='$username'";
$result = mysql_query($query,$nbnconnectsql);
if (!$result) {
	$nbnconnectsqlerror = mysql_error();
	nbnconnect_WHMCSReconnect();
	return "FreeRadius Database Query Error: ".$nbnconnectsqlerror;
}

NEW and likely wrong

$query = $nbnconnectsql
	->from('radip')
	->select('ip')
	->where('allocated', '=', $username);

$nbnconnectsql
	->from('radreply')
	->update('value', '=', '$dedicatedip')
	->where('value', '=', '')
	->where('username', '=', $username);

 

We then need it to update the WHMCS tblhosting table ...

OLD and working

$query = "SELECT ip FROM radip WHERE allocated='$username'";
$result = mysql_query($query,$nbnconnectsql);
$data = mysql_fetch_array($result);
$ipaddr = $data[0];
nbnconnect_WHMCSReconnect();
update_query("tblhosting",array("dedicatedip"=>$ipaddr),array("id"=>$params['serviceid']));
return "success";

NEW ... I have no idea how to do this with Laravel, so any help will be greatly appreciated.

Thanks in advance for your input.

Link to comment
Share on other sites

56 minutes ago, twhiting9275 said:

We've all known this change was coming for quite some time.

That might be true if you're a developer working with code all the time, but that's not me.

The reason this needs updating is because, for legitimate reasons, we've been forced to keep one of our WHMCS installations at v5.x.x, so the old code was more than suitable until now.

However, we're finally in a position to update WHMCS, so there's an obvious need to move to the new version of their FreeRadius module.

While I appreciate you taking the time to respond and for the links, these are things I've already found using our old friend Google, but to be honest, they're not much help because, as mentioned before, I'm not really a code guy.

What I'm hopeful of is some specific assistance and/or code suggestions in fixing the updated code I've attempted to use as inserted above, so that it actually works as expected.

I realise that you make your living doing development work, so my request may be out of line in asking for free assistance, but this is where the WHMCS support guys pointed me, so here I am asking.

Link to comment
Share on other sites

Yes, bear, but we have some specific modifications to their original module which need to be carried over to the new module's code. It that I need help with, as mentioned in the OP ...

On 14/02/2018 at 2:40 PM, ezyweb said:

We're using the WHMCS FreeRadius module to provision and manage DSL and NBN tails for our customer, but we need a couple of extra elements added to it. Matt Pugh was really helpful with the previous version, but now that cPanel has partnered with WHMCS, they no longer offer the kind of fairly simple assistance he did.

 

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