Jump to content

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

Link to comment
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
Link to comment
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');

 

Link to comment
Share on other sites

  • 1 month later...
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

Link to comment
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' ?

Link to comment
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.

Link to comment
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 ?

Link to comment
Share on other sites

  • 4 weeks later...

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',
        ));
    }
});

 

Link to comment
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:

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