Jump to content
DraGoNeTi

Hosting Information Hook

Recommended Posts

Hello,

i am really sorry if this is the wrong category to post.

i came across this information on a hosting company... and i was wondering if i can add it to my site... i know i have seen it as a hook somewhere in here, but now i can't.. ! 

can someone help me ?

 

whmcs v7

hosting info.png

Share this post


Link to post
Share on other sites

Here you go... This will return the left sidebar of service information when the service page is displayed

<?php
use WHMCS\View\Menu\Item as MenuItem;
use Illuminate\Database\Capsule\Manager as Capsule;

/* Add credentials to the end of all secondary sidebars. 
 */
add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar)
{
	/* Get the credentials. */
	$service = Menu::context('service');
	$username = "{$service->username}";
	$serverid = "{$service->server}";
	$domain = "{$service->domain}";
	$password = "{$service->password}";
	$server = Capsule::table('tblservers')->where('id', '=', $serverid)->pluck('hostname');
	$ipaddress = Capsule::table('tblservers')->where('id', '=', $serverid)->pluck('ipaddress');
	$name1 = Capsule::table('tblservers')->where('id', '=', $serverid)->pluck('nameserver1');
	$name2 = Capsule::table('tblservers')->where('id', '=', $serverid)->pluck('nameserver2');

	$password = decrypt($password);
	/* If the username isn't empty let's show them! */
	if ($username != '') {
		/*
		Add a panel to the end of the secondary sidebar for credentials.
		Declare it with the name "credentials" so we can easily retrieve it
		later.
		*/
		$secondarySidebar->addChild('credentials', array(
		'label' => 'Service Information',
		'uri' => '#',
		'icon' => 'fa-desktop',
		));
		/* Retrieve the panel we just created. */
		$credentialPanel = $secondarySidebar->getChild('credentials');
		$credentialPanel->moveToBack();
		/* Show the username. */
		$credentialPanel->addChild('username', array(
		'label' => $username,
		'order' => 1,
		'icon' => 'fa-user',
		));

		/* Show the password. */
		$credentialPanel->addChild('password', array(
		'label' => $password,
		'order' => 2,
		'icon' => 'fa-lock',
		));
		/* Show the password. */
		$credentialPanel->addChild('domain', array(
		'label' => $domain,
		'order' => 3,
		'icon' => 'fa-globe',
		));
		/*show the server IP*/
		$credentialPanel->addChild('ip', array(
		'label' => $ipaddress,
		'order' => 4,
		'icon' => 'fa-info',
		));
		/*show the server name*/
		$credentialPanel->addChild('server', array(
		'label' => $server,
		'order' => 5,
		'icon' => 'fa-server',
		));

		/*NS1*/
		$credentialPanel->addChild('name1', array(
		'label' => $name1,
		'order' => 6,
		'icon' => 'fa-info-circle',
		));
		/*NS2*/
		$credentialPanel->addChild('name2', array(
		'label' => $name2,
		'order' => 7,
		'icon' => 'fa-info-circle',
		));
	}
});

At some point, long, long ago, this was in there, but taken out. This will return it.

Edited by twhiting9275
  • Thanks 1

Share this post


Link to post
Share on other sites
23 hours ago, DraGoNeTi said:

i came across this information on a hosting company... and i was wondering if i can add it to my site... i know i have seen it as a hook somewhere in here, but now i can't.. ! 

can someone help me ?

it should be added automatically if the product requires a domain (and has a domain value within it).

and if you wanted to use the sidebar hook to duplicate the information for v7.4, the credentials code should be changed to...

	/* Get the credentials. */
	$service = Menu::context('service');
	$username = $service->username;
	$serverid = $service->server;
	$domain = $service->domain;
	$password = $service->password;
	$server = Capsule::table('tblservers')->where('id', $serverid)->value('hostname');
	$ipaddress = Capsule::table('tblservers')->where('id', $serverid)->value('ipaddress');
	$name1 = Capsule::table('tblservers')->where('id', $serverid)->value('nameserver1');
	$name2 = Capsule::table('tblservers')->where('id', $serverid)->value('nameserver2');

 

  • Thanks 1

Share this post


Link to post
Share on other sites
On 15/02/2018 at 9:30 PM, twhiting9275 said:

Here you go... This will return the left sidebar of service information when the service page is displayed


<?php
use WHMCS\View\Menu\Item as MenuItem;
use Illuminate\Database\Capsule\Manager as Capsule;

/* Add credentials to the end of all secondary sidebars. 
 */
add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar)
{
	/* Get the credentials. */
	$service = Menu::context('service');
	$username = "{$service->username}";
	$serverid = "{$service->server}";
	$domain = "{$service->domain}";
	$password = "{$service->password}";
	$server = Capsule::table('tblservers')->where('id', '=', $serverid)->pluck('hostname');
	$ipaddress = Capsule::table('tblservers')->where('id', '=', $serverid)->pluck('ipaddress');
	$name1 = Capsule::table('tblservers')->where('id', '=', $serverid)->pluck('nameserver1');
	$name2 = Capsule::table('tblservers')->where('id', '=', $serverid)->pluck('nameserver2');

	$password = decrypt($password);
	/* If the username isn't empty let's show them! */
	if ($username != '') {
		/*
		Add a panel to the end of the secondary sidebar for credentials.
		Declare it with the name "credentials" so we can easily retrieve it
		later.
		*/
		$secondarySidebar->addChild('credentials', array(
		'label' => 'Service Information',
		'uri' => '#',
		'icon' => 'fa-desktop',
		));
		/* Retrieve the panel we just created. */
		$credentialPanel = $secondarySidebar->getChild('credentials');
		$credentialPanel->moveToBack();
		/* Show the username. */
		$credentialPanel->addChild('username', array(
		'label' => $username,
		'order' => 1,
		'icon' => 'fa-user',
		));

		/* Show the password. */
		$credentialPanel->addChild('password', array(
		'label' => $password,
		'order' => 2,
		'icon' => 'fa-lock',
		));
		/* Show the password. */
		$credentialPanel->addChild('domain', array(
		'label' => $domain,
		'order' => 3,
		'icon' => 'fa-globe',
		));
		/*show the server IP*/
		$credentialPanel->addChild('ip', array(
		'label' => $ipaddress,
		'order' => 4,
		'icon' => 'fa-info',
		));
		/*show the server name*/
		$credentialPanel->addChild('server', array(
		'label' => $server,
		'order' => 5,
		'icon' => 'fa-server',
		));

		/*NS1*/
		$credentialPanel->addChild('name1', array(
		'label' => $name1,
		'order' => 6,
		'icon' => 'fa-info-circle',
		));
		/*NS2*/
		$credentialPanel->addChild('name2', array(
		'label' => $name2,
		'order' => 7,
		'icon' => 'fa-info-circle',
		));
	}
});

At some point, long, long ago, this was in there, but taken out. This will return it.

- Hello, I added this hook in my whmcs however when I tried to access the part of the services the use of the cpu of the account that this installed the whmcs goes in 100% could I help to solve this question? Version used of whmcs is 7.4.2x

Share this post


Link to post
Share on other sites
17 hours ago, Walas Lima said:

Hello, I added this hook in my whmcs however when I tried to access the part of the services the use of the cpu of the account that this installed the whmcs goes in 100% could I help to solve this question? Version used of whmcs is 7.4.2x

if you're using v7.4.2, did you change references of 'pluck' to 'value' ?

Share this post


Link to post
Share on other sites
On 17/2/2018 at 8:47 AM, DraGoNeTi said:

and what if i wanted to add titles and not icons ?

guys.... !!!

Share this post


Link to post
Share on other sites

in the sidebar? just remove the icon lines from the hook.

Share this post


Link to post
Share on other sites
7 minutes ago, brian! said:

in the sidebar? just remove the icon lines from the hook.

yes, but i want it to say: (icon) Password: blablabla

Share this post


Link to post
Share on other sites
9 minutes ago, DraGoNeTi said:

yes, but i want it to say: (icon) Password: blablabla

if this is v7.4.2, then the icons are on the right... that will be defined in sidebar.tpl, so your options would be to either edit the template to move them to the left... or in the hook, remove the icons as I said above, but add them manually to the label value as you would with any fontawesome icon.

Share this post


Link to post
Share on other sites

and how about if the service is a whmsonic/centova product, show the admin password as well as the radio port and some extra info ( let's say, the listeners limit, the kbps limit etc etc )

Share this post


Link to post
Share on other sites
4 minutes ago, DraGoNeTi said:

and how about if the service is a whmsonic/centova product, show the admin password as well as the radio port and some extra info ( let's say, the listeners limit, the kbps limit etc etc )

then it's a case of locating the information required, e.g can you get it via the class docs; is it available as Smarty variables or do you need to query the db ?

Share this post


Link to post
Share on other sites
Posted (edited)

i think we could query the db...

but ! as i can remember, the whmsonic is under root account so we couldn't query it

Edited by DraGoNeTi

Share this post


Link to post
Share on other sites
3 hours ago, brian! said:

if you're using v7.4.2, did you change references of 'pluck' to 'value' ?

Hello, Can not I do this?

Share this post


Link to post
Share on other sites
21 hours ago, Walas Lima said:

Hello, Can not I do this?

if you're using v7.4.2, you will need to edit the hook file to make it work.

Share this post


Link to post
Share on other sites
14 hours ago, DraGoNeTi said:

@brian! you forgot me.. ! :P When you can and you have time...

forgive me but I can't see which question I haven't answered! :?:

Share this post


Link to post
Share on other sites

This will work with either 6.x or 7.x . Sorry, it's been a while since I played around on the WHMCS forums, but here's an updated version.  No more editing necessary


 

<?php
use WHMCS\View\Menu\Item as MenuItem;
use Illuminate\Database\Capsule\Manager as Capsule;

/* Add credentials to the end of all secondary sidebars.
*/
add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar)
{
    /* Get the credentials. */
    $service = Menu::context('service');
    $username = "{$service->username}";
    $serverid = "{$service->server}";
    $domain = "{$service->domain}";
    $password = "{$service->password}";
    $server = Capsule::table('tblservers')->where('id', '=', $serverid)->pluck('hostname');
    $ipaddress = Capsule::table('tblservers')->where('id', '=', $serverid)->pluck('ipaddress');
    $name1 = Capsule::table('tblservers')->where('id', '=', $serverid)->pluck('nameserver1');
    $name2 = Capsule::table('tblservers')->where('id', '=', $serverid)->pluck('nameserver2');
    if (is_array($name2))
    {
        $name2 = $name2['0'];
    }

    if (is_array($name1))
    {
        $name1 = $name1['0'];
    }

    if (is_array($ipaddress))
    {
        $ipaddress = $ipaddress['0'];
    }

    if (is_array($server))
    {
        $server = $server['0'];
    }
    $password = decrypt($password);
    /* If the username isn't empty let's show them! */
    if ($username != '') {
        /*
        Add a panel to the end of the secondary sidebar for credentials.
        Declare it with the name "credentials" so we can easily retrieve it
        later.
        */
        $secondarySidebar->addChild('credentials', array(
        'label' => 'Service Information',
        'uri' => '#',
        'icon' => 'fa-desktop',
        ));
        /* Retrieve the panel we just created. */
        $credentialPanel = $secondarySidebar->getChild('credentials');
        $credentialPanel->moveToBack();
        /* Show the username. */
        $credentialPanel->addChild('username', array(
        'label' => $username,
        'order' => 1,
        'icon' => 'fa-user',
        ));

        /* Show the password. */
        $credentialPanel->addChild('password', array(
        'label' => $password,
        'order' => 2,
        'icon' => 'fa-lock',
        ));
        /* Show the password. */
        $credentialPanel->addChild('domain', array(
        'label' => $domain,
        'order' => 3,
        'icon' => 'fa-globe',
        ));
        /*show the server IP*/
        $credentialPanel->addChild('ip', array(
        'label' => $ipaddress,
        'order' => 4,
        'icon' => 'fa-info',
        ));
        /*show the server name*/
        $credentialPanel->addChild('server', array(
        'label' => $server,
        'order' => 5,
        'icon' => 'fa-server',
        ));

        /*NS1*/
        $credentialPanel->addChild('name1', array(
        'label' => $name1,
        'order' => 6,
        'icon' => 'fa-info-circle',
        ));
        /*NS2*/
        $credentialPanel->addChild('name2', array(
        'label' => $name2,
        'order' => 7,
        'icon' => 'fa-info-circle',
        ));
    }
});

 

Share this post


Link to post
Share on other sites

@twhiting9275 hey man, thanks for the update. What if the product is a whmsonic radio? i wanted it to say package name, ip, port, dj port(if autodj enabled), password, admin password, listeners... is it easy to do ?

Share this post


Link to post
Share on other sites

That's likely possible, but not something you'll likely find here for free . The idea with this was to provide a basic example of how to do this. For more one on one customization, you'll need to work with a dev on that :)

Share this post


Link to post
Share on other sites
13 hours ago, twhiting9275 said:

That's likely possible, but not something you'll likely find here for free.

a tempting invitation, but even I can't be bothered to do that on a sunny public holiday here in the UK! :411_tropical_drink:

21 hours ago, DraGoNeTi said:

What if the product is a whmsonic radio? i wanted it to say package name, ip, port, dj port(if autodj enabled), password, admin password, listeners... is it easy to do ?

it's just going to be a variation on the theme of the sample hook above... you'll be able to get all that info from a combination of the class docs and/or querying the database...

e.g name will probably be... $service->product->name

listeners... $service->product->moduleConfigOption2

bitrate... $service->product->moduleConfigOption3

autodj status... $service->product->moduleConfigOption4 and so on...

then if you need to query the db, it will be tblproducts for product details, tblservers for server details and tblhosting for any specifics about the specific service... the info is out there somewhere! :768_mag_right:

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

By using this site, you agree to our Terms of Use & Guidelines