Jump to content

Adding Hostname to Server Status


HostOrca

Recommended Posts

Hi

 

I have searched the docs and forum for an answer to this but can not find an answer.

 

I am trying to edit the serverstatus page to add a link using the hostname for the server (as set in the server setup page (admin). But I can not seem to work out the variable to use.

 

Any help would be apreciated.

Link to comment
Share on other sites

Be default there isn't a variable available for this. A solution is the code below. Just add it at the top of your serverstatus.tpl.

 

{php}
foreach ($this->_tpl_vars['servers'] as $key => $value) 
{
$result = select_query("tblservers","hostname",array("name" => $value['name']));
$data = mysql_fetch_array($result);

$this->_tpl_vars['servers'][$key]['hostname'] = $data['hostname'];
}
{/php}

 

You can request it inside the foreach with {$server.hostname}.

Link to comment
Share on other sites

Be default there isn't a variable available for this. A solution is the code below. Just add it at the top of your serverstatus.tpl.

 

{php}
foreach ($this->_tpl_vars['servers'] as $key => $value) 
{
   $result = select_query("tblservers","hostname",array("name" => $value['name']));
   $data = mysql_fetch_array($result);

   $this->_tpl_vars['servers'][$key]['hostname'] = $data['hostname'];
}
{/php}

 

You can request it inside the foreach with {$server.hostname}.

Just tried and it works with just one problem.

 

This is the code in full:

{php}
foreach ($this->_tpl_vars['servers'] as $key => $value) 
{
   $result = select_query("tblservers","hostname",array("name" => $value['name']));
   $data = mysql_fetch_array($result);
   $this->_tpl_vars['servers'][$key]['hostname'] = $data['hostname'];
}
{/php}
<p>{$LANG.serverstatusheadingtext}</p> 
<table width="100%" border="0" align="center" cellpadding="10" cellspacing="0" class="data"> 
 <tr align="center"> 
   <th>{$LANG.servername}</th> 
   <th>cPanel</th> 
   <th>HTTP</th> 
   <th>MySQL</th> 
   <th>FTP</th> 
   <th>POP3</th>   
   <th>{$LANG.speedtest}</th> 
   <th>{$LANG.serverstatusserverload}</th> 
   <th>{$LANG.serverstatusuptime}</th> 
 </tr> 
 {foreach key=num item=server from=$servers} 
 <tr align="center"> 
   <td>{$server.name}</td> 
   <td>{get_port_status num="$num" port="2082"}</td> 
   <td>{get_port_status num="$num" port="80"}</td> 
   <td>{get_port_status num="$num" port="3306"}</td> 
   <td>{get_port_status num="$num" port="21"}</td> 
   <td>{get_port_status num="$num" port="110"}</td>  
   <td><a href="{$server.hostname}/speedtest.html" target="_blank">{$LANG.speedtest}</a></td> 
   <td>{$server.serverload}</td> 
   <td>{$server.uptime}</td> 
 </tr> 
 {foreachelse} 
 <tr> 
   <td colspan="7">{$LANG.serverstatusnoservers}</td> 
 </tr> 
 {/foreach} 
</table>  

 

The problem is the link generated by this

><a href="{$server.hostname}/speedtest.html" target="_blank">{$LANG.speedtest}</a>

makes the link http://whmcsdomain.co.uk/hostname/speedtest.html

 

Any ideas

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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