Jump to content

Network Status: Only Show Server Where Client is Hosted On


JLHC

Recommended Posts

Hello guys,

 

I am looking for a way to modify the Network Status page (serverstatus.tpl), specifically the Server Status section.

 

I would like to only show the status of servers where the clients are hosted on.

 

As such, if a client has an account in Server A, it will only the server status for Server A.

 

If a client has an account in Server A and Server B, it will show the server status for Server A and Server B only.

 

This is to prevent confusion especially when you have a lot of servers as the client may not even know which server they are hosted on.

 

I have been using a custom code in version 4.x of WHMCS but it doesn't seem to work on version 5.x:-

<table width="100%" border="0" align="center" cellpadding="10" cellspacing="0" class="data">
<tr>
<th>{$LANG.servername}</th>
<th>Hosting Account</th>
<th>HTTP</th>
<th>cPanel</th>
<th>FTP</th>
<th>POP3</th>
<th>SMTP</th>
</tr>
<tr>
{php}
$query1 = "SELECT * FROM tblservers ORDER BY name";
$result1 = mysql_query($query1);
while ($row1 = mysql_fetch_array($result1)) {

$serverid = $row1['id'];
$servername = $row1['name'];
$host = $row1['ipaddress'];

$hosteddomains="";

$query2 = "SELECT * FROM tblhosting WHERE userid='".$_SESSION["uid"]."' AND domainstatus='Active' AND server='".$serverid."'";

$result2 = mysql_query($query2);
while ($row2 = mysql_fetch_array($result2)) {

$hosteddomain = $row2['domain'];
$hosteddomains.=$hosteddomain."<br>";
}
if ($hosteddomains) {
$hosteddomains=substr($hosteddomains,0,-4);

if ($host) {
//HTTP
$port = 80;

$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
{
echo "<tr class=\"clientareatableactive\">";
echo "<td><b>".$servername."</b> </td>";
echo "<td>" .$hosteddomains."</td>";
echo "<td><img src=\"images/statusfailed.gif\"></td>";
}

else{
echo "<tr class=\"clientareatableactive\">";
echo "<td>".$servername." </td>";
echo "<td>" .$hosteddomains."</td>";
echo "<td><img src=\"images/statusok.gif\"></td>";
fclose($fp);
}

//cPanel
$port = 2082;

$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
{
echo "<td><img src=\"images/statusfailed.gif\"></td>";


}else{
echo "<td><img src=\"images/statusok.gif\"></td>";

fclose($fp);
}

//FTP
$port = 21;

$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
{
echo "<td><img src=\"images/statusfailed.gif\"></td>";


}else{
echo "<td><img src=\"images/statusok.gif\"></td>";

fclose($fp);
}

//POP3
$port = 110;

$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
{
echo "<td><img src=\"images/statusfailed.gif\"></td>";


}else{
echo "<td><img src=\"images/statusok.gif\"></td>";

fclose($fp);
}

//SMTP
$port = 25;

$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
{
echo "<td><img src=\"images/statusfailed.gif\"></td>";


}else{
echo "<td><img src=\"images/statusok.gif\"></td>";

fclose($fp);
}
$this->assign('serverid',$serverid);
$this->assign('servername',$servername);

{/php}

{php}
echo "</td></tr>";
} else {
echo "<tr class=\"clientareatableactive\">";
echo "<td>".$servername."</td>";
echo "<td>" .$hosteddomains."</td>";
echo "<td colspan=\"5\"><strong><font color=\"#AAAAAA\">Not Monitored Here</font></strong></td>";
}}}
{/php}
</table>

 

Any input from you guys will be greatly appreciated. :)

 

Thank you.

Link to comment
Share on other sites

This the code im useing hope it works for u mate let me know

Copy all the code and pase it in serverstatus.tpl

{if $loggedin}
<td height="29"> <div align="center"><font color="red"><strong>Live Uptime Status as of Today:</font> 
{$todaysdate}{$time} </strong>
</div></td>
<hr />
<br />
<table  width="100%" class="clientareatable" align="center" cellspacing="1">
<tr class="clientareatableheading">
<td>{$LANG.servername}</td>
<td>Hosting</td>
<td>HTTP</td>
<td>WHM</td>
<td>CPanel</td>
<td>FTP</td>
<td>POP3</td>
<td>SMTP</td>
</tr>
<tr>
{php}
$query1 = "SELECT * FROM tblservers ORDER BY name";
$result1 = mysql_query($query1);
while ($row1 = mysql_fetch_array($result1)) {

$serverid = $row1['id'];
$servername = $row1['name'];
$host = $row1['ipaddress'];

$hosteddomains="";

$query2 = "SELECT * FROM tblhosting WHERE userid='".$_SESSION["uid"]."' AND domainstatus='Active' AND server='".$serverid."'";

$result2 = mysql_query($query2);
while ($row2 = mysql_fetch_array($result2)) {

$hosteddomain = $row2['domain'];
$hosteddomains.=$hosteddomain."<br>";
}
if ($hosteddomains) {
$hosteddomains=substr($hosteddomains,0,-4);

if ($host) {
//HTTP
$port = 80;

$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
{
echo "<tr class=\"clientareatableactive\">";
echo "<td><b>".$servername."</b> </td>";
echo "<td>" .$hosteddomains."</td>";
echo "<td rowspan=\"2\"><img src=\"images/statusfailed.gif\"></td>";
}

else{
echo "<tr class=\"clientareatableactive\">";
echo "<td>".$servername." </td>";
echo "<td>" .$hosteddomains."</td>";
echo "<td><img src=\"images/statusok.gif\"></td>";
fclose($fp);
}

//CPanel
$port = 2082;

$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
{
echo "<td rowspan=\"2\"><img src=\"images/statusfailed.gif\"></td>";


}else{
echo "<td><img src=\"images/statusok.gif\"></td>";

fclose($fp);
}

//WHM
$port = 2086;

$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
{
echo "<td rowspan=\"2\"><img src=\"images/statusfailed.gif\"></td>";


}else{
echo "<td><img src=\"images/statusok.gif\"></td>";

fclose($fp);
}

//FTP
$port = 21;

$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
{
echo "<td rowspan=\"2\"><img src=\"images/statusfailed.gif\"></td>";


}else{
echo "<td><img src=\"images/statusok.gif\"></td>";

fclose($fp);
}

//POP3
$port = 110;

$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
{
echo "<td rowspan=\"2\"><img src=\"images/statusfailed.gif\"></td>";


}else{
echo "<td><img src=\"images/statusok.gif\"></td>";

fclose($fp);
}

//SMTP
$port = 25;

$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
{
echo "<td rowspan=\"2\"><img src=\"imagesfailed.gif\"></td>";


}else{
echo "<td><img src=\"images/statusok.gif\"></td>";

fclose($fp);
}
$this->assign('serverid',$serverid);
$this->assign('servername',$servername);

{/php}

{php}
echo "</td></tr>";
} else {
echo "<tr class=\"clientareatableactive\">";
echo "<td>".$servername."</td>";
echo "<td>" .$hosteddomains."</td>";

echo "<td colspan=\"5\"><strong><font color=\"#AAAAAA\">Not Monitored Here</font></strong></td>";
}}}
{/php}
</table>
{else}
<p>{$LANG.loginintrotext}</p>

<form action="dologin.php?goto=serverstatus" method="post">

<table align="center">
<tr><td align="right">{$LANG.loginemail}:</td><td><input type="text" name="username" size="40" value="{$username}"></td></tr>
<tr><td align="right">{$LANG.loginpassword}:</td><td><input type="password" name="password" size="25" value="{$password}"></td></tr>
</table>

<p align="center"><input type="submit" value="{$LANG.loginbutton}"><br><input type="checkbox" name="rememberme"{$rememberme}> {$LANG.loginrememberme}</p>
</form>
<p><b>{$LANG.loginforgotten}</B> <a href="passwordreminder.php">{$LANG.loginforgotteninstructions}</a>.</p>
{/if}

Link to comment
Share on other sites

This the code im useing hope it works for u mate let me know

Copy all the code and pase it in serverstatus.tpl

Redacted

 

Your codes seem similar to mine.

 

Anyway I made some changes to the code and it seem to work now.

 

Thanks! :)

Link to comment
Share on other sites

  • 1 year later...

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