Jump to content

Using php if statement in serverstatus.tpl (version 5.1.3)


wiseprt

Recommended Posts

Hello there,

 

I just registered to the community cause i need help! My problem is that i have an ftp (home) server and i want to included this in server status page of WHMCS but i want only to show FTP PORT for this specific server.

 

I think that something like this is possible with php if statements like "If this server, then only show ftp status."

 

So i tried this one

 

{if $server.name == 'server_name_here'}

<tr>

<td>{$server.name}</td>

<td></td>

<td>{get_port_status num="$num" port="21"}</td>

<td></td>

<td></td>

<td></td>

<td></td>

</tr>

{/if}

 

but is not working... :(

 

I am sure that i am doing something wrong. Maybe i am not good with php in .tpl files!

Please help guys.

Thanks!

Link to comment
Share on other sites

I didn't understand the whole thing but if you need php if statement do the following:

// Start PHP if()
{php} if($whatever=="bobby") { {/php}

// Show something
{if $server.name == 'server_name_here'}
<tr>
<td>{$server.name}</td>
<td></td>
<td>{get_port_status num="$num" port="21"}</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
{/if}

// End PHP if()
{php} } {/php}

Link to comment
Share on other sites

Hello Kian, thank you for your response. To be more specific i need here

 

issue.jpg

 

To show only FTP port for the Backup Server. I tried your code but something doing wrong... i'am very new to php coding, so you can understand! Any help will be appreciated.

 

Thanks again.

Link to comment
Share on other sites

Hello again,

 

Tried to give you a screenshot for better undertanding but the admin still not approved it! So i say you again that i want to edit the serverstatus.tpl in order to display ONLY FTP PORT but for a specific server only!

 

Trying your code but is not working...

Link to comment
Share on other sites

  • 4 weeks later...

try this, this should show only FTP status for all..

 


<table width="100%" border="0" align="center" cellpadding="10" cellspacing="0" class="data">
 <tr>
   <th>{$LANG.servername}</th>
   <!-- <th>HTTP</th> -->
   <th>FTP</th>
  <!--  <th>POP3</th> -->
   <th>{$LANG.serverstatusphpinfo}</th>
   <th>{$LANG.serverstatusserverload}</th>
   <th>{$LANG.serverstatusuptime}</th>
 </tr>
 {foreach key=num item=server from=$servers}
 <tr>
   <td>{$server.name}</td>
   <!-- <td id="port80_{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" /></td> -->
   <td id="port21_{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" /></td>
  <!--  <td id="port110_{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" /></td> -->
   <td><a href="{$server.phpinfourl}" target="_blank">{$LANG.serverstatusphpinfo}</a></td>
   <td id="load{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" /></td>

   <td id="uptime{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" />	
<script> 
/* checkPort({$num},80); */
checkPort({$num},21); 
/* checkPort({$num},110); */
getStats({$num}); 
</script>	
</td>

 </tr>
 {foreachelse}
 <tr>
   <td colspan="7">{$LANG.serverstatusnoservers}</td>
 </tr>
 {/foreach}
</table>


Link to comment
Share on other sites

Hello Kian,

 

You want this if i understanding well what you said.

=4 => Array (9)

name => FTP Backup Server

ipaddress => 212.251.46.58

statusaddr => ftp://212.251.46.58/status/index.php

phpinfourl => ftp://212.251.46.58/status/index.php?...

serverload => empty

uptime => empty

phpver => empty

mysqlver => empty

zendver => empty

 

Am i right? Thanks so much for helping...

Link to comment
Share on other sites

Hello durangod,

I want this but only for the FTP Server in the list. As Kian said this must be a simple "if" statement.

 

try this, this should show only FTP status for all..

 


<table width="100%" border="0" align="center" cellpadding="10" cellspacing="0" class="data">
 <tr>
   <th>{$LANG.servername}</th>
   <!-- <th>HTTP</th> -->
   <th>FTP</th>
  <!--  <th>POP3</th> -->
   <th>{$LANG.serverstatusphpinfo}</th>
   <th>{$LANG.serverstatusserverload}</th>
   <th>{$LANG.serverstatusuptime}</th>
 </tr>
 {foreach key=num item=server from=$servers}
 <tr>
   <td>{$server.name}</td>
   <!-- <td id="port80_{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" /></td> -->
   <td id="port21_{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" /></td>
  <!--  <td id="port110_{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" /></td> -->
   <td><a href="{$server.phpinfourl}" target="_blank">{$LANG.serverstatusphpinfo}</a></td>
   <td id="load{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" /></td>

   <td id="uptime{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" />	
<script> 
/* checkPort({$num},80); */
checkPort({$num},21); 
/* checkPort({$num},110); */
getStats({$num}); 
</script>	
</td>

 </tr>
 {foreachelse}
 <tr>
   <td colspan="7">{$LANG.serverstatusnoservers}</td>
 </tr>
 {/foreach}
</table>


Link to comment
Share on other sites

Ok you can get this...

 

serverstatusarray.jpg

 

With this:

 

{foreach from=$servers key=num item=server}
{if $server.ipaddress eq 'YOUR_BACKUP_SERVER_IP'}
	<tr>
           <td>{$server.name}</td>
           <td class="textcenter" id="port21_{$num}" colspan="3"><img src="images/loadingsml.gif" alt="{$LANG.loading}"/></td>
           <td class="textcenter"><a href="{$server.phpinfourl}" target="_blank">{$LANG.serverstatusphpinfo}</a></td>
           <td class="textcenter" id="load{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" /></td>
           <td class="textcenter" id="uptime{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" /><script> checkPort({$num},80); checkPort({$num},21); checkPort({$num},110); getStats({$num}); </script></td>
       </tr>
{else}    
	<tr>
           <td>{$server.name}</td>
           <td class="textcenter" id="port80_{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" /></td>
           <td class="textcenter" id="port21_{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" /></td>
           <td class="textcenter" id="port110_{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" /></td>
           <td class="textcenter"><a href="{$server.phpinfourl}" target="_blank">{$LANG.serverstatusphpinfo}</a></td>
           <td class="textcenter" id="load{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" /></td>
           <td class="textcenter" id="uptime{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" /><script> checkPort({$num},80); checkPort({$num},21); checkPort({$num},110); getStats({$num}); </script></td>
       </tr>
{/if}      
{foreachelse}
       <tr>
           <td colspan="7">{$LANG.serverstatusnoservers}</td>
       </tr>
{/foreach}

 

You can exclude your backup server by IP in this statement {if $server.ipaddress eq 'YOUR_BACKUP_SERVER_IP'}. That's it.

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