Location: PHPKode > projects > SHOUTcast Management Interface > smi-0.3.4/mrtg/include/serverlist.php
<?
////////////////////////////////////////////////////////////////////////
/*SMI - SHOUTcast Management Interface
A web based shoutcast server management program
Founding Author: Scott D. Harvanek <hide@address.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.*/
////////////////////////////////////////////////////////////////////////

$config = settings();
?>

<table border="0" width="100%">
  <tr>
    <td align="left">
      <b>Server List</b><br>
    </td>
    </tr>
</table>

<table border="0" width="600px" cellspacing="0">
  <tr bgcolor="#828282">
    <td></td>
    <td align="left">
      <b>Created By</b>
    </td>
    <td align="left">
      <b>Server Name</b>
    </td>
    <td align="left">
      <b>Port</b>
    </td>
    <td align="left">
      <b>Status</b>
    </td>
    <td align="left">
      <span title="Current Users / Peak Users / Max Users"> <b>Listeners</b></span>
    </td>
    <td align="center">
      <span title="Stats">
    </td>
    <td align="right">
      <b>Action</b>
    </td>
  </tr>
<?
$i = "0";
if(useraccess($_SESSION['username']) < "4") {
  $owner = getuid($_SESSION['username']);
  $cond = array('owner' => $owner);
  //$query = mysql_query('SELECT created,MaxUser,PortBase,servername,enabled,id from servers  where owner='.$owner.' ORDER BY PortBase DESC');
} else {
  $cond = "";
  // $query = mysql_query('SELECT created,MaxUser,PortBase,servername,enabled,id from servers ORDER BY PortBase DESC');
}
$db = dbConnect();
$servers = $db->getRows('servers', $cond, 'created,MaxUser,PortBase,servername,enabled,id', 'PortBase', 'DESC');
if (!isset($servers)) {
  echo "<tr><td colspan=\"7\"><i>No servers are created</i></td></tr>\n";
} else {
  foreach ($servers as $row) {
    $bgcolor = ($i++ & 1) ? '#FFFFFF' : '#bcbcbc';
    echo "<tr bgcolor='$bgcolor'>\n";
?>
		<td align="left">
		<?if(useraccess($_SESSION['username']) < "4"){
			echo "<span title=\"Your priviledge level does not permit this action.\"><img src=\"imgs/cross.png\" border=\"0\"></span>";
		}else{?>
		<a href="delete.php?id=<?echo $row[5];?>&port=<?echo $row[2];?>&srvname=<?echo $row[3];?>" onclick="javascript:return confirm('Are you sure you want to delete this server?')"><img src="imgs/cross.png" border="0"></a>
		<?}?>
		</td>
		<td align="left">
                <?echo $row[0];?> 
                </td>
		<td align="left">
                <?
		$srvname = $row[3];
		$srvname = preg_replace('/_/', ' ', $srvname);
		echo "<span title=\"ID: $row[5]\">$srvname</span>";
		?>
                </td>
		<td align="left">
                  <a href="http://<? echo $config['host_addr'].":".$row[2] ?>" target=<? echo "smi_".$row[2].">".$row[2];?></a>
                </td>
		<td align="left">
                <?
		$port = $row[2];
		include('status/status.php');
		?>
               	</td>
		<td align="left">
		<?
		checklistener($port,$row[5]);
		?>
		</td>
                <td align="center">
		  <?
		    if ($config['mrtg'] == "on" && file_exists($config['smi_path']."/mrtg/".$row[2].$row[5].".html")) {
		    echo '<a href="serverdetail.php?port='.$row[2].'&id='.$row[5].'">';
		    echo '<img src="imgs/mrtg.png" alt="Show MRTG stats" border="0"></a>';
		    } else {
                  ?>
		    <img src="imgs/mrtgbw.png" alt="MRTG is disabled" border="0">
		  <?
		    }
		  ?>
		</td>
		<td align="right">
		<?if(useraccess($_SESSION['username']) < "4"){
		echo "<span title=\"Your priviledge level does not permit this action.\"><img src=\"imgs/edit.png\" border=\"0\"></span>";
		}else{
		if($row[4] == "0"){
		$status = "0";
		}else{
		$status = "1";
		}
		?>
		<a href="edit.php?portbase=<?echo "$row[2]&id=".$row[5]."&status=$status";?>"><img src="imgs/edit.png" border="0"></a>
		<?}?>
                <?
		if($row[4] == "0"){
			if(useraccess($_SESSION['username']) < "1"){
				echo "<span title=\"Your priviledge level does not permit this action.\"><img src=\"imgs/play.png\" border=\"0\"></span>";
			}else{
				?>
		<a href="control.php?control=<? echo $row[2];?>&id=<? echo $row[5];?>&action=start&srvname=<? echo $row[3];?>"><img src="imgs/play.png" border="0"></a>
		<div class="popup">
			Start server.
		</div>
			<?
			}
		}else{
			if(useraccess($_SESSION['username']) < "1"){
				echo "<span title=\"Your priviledge level does not permit this action.\"><img src=\"imgs/stop.png\" border=\"0\"></span>";
			}else{
				echo "<a href=\"control.php?control=".$row[2]."&id=".$row[5]."&action=stop&srvname=".$row[3]."\"><img src=\"imgs/stop.png\" border=\"0\"></a>";
			}
		}
		?>
                </td>	
	</tr>
<?
  }
}
?>
</table>
<br>
<b>Global statistics</b><br>
<?
if ($config['mrtg'] == "off") {
  echo "<i>MRTG graphical statistics are disabled</i>";
} else {
  if(file_exists($config['smi_path'].'/mrtg/aggregate-day.png')) {
    echo "<a href=\"serverdetail.php?port=aggregate\"><img src=\"mrtg/aggregate-day.png\" alt=\"Aggregate Utilization\" border=\"0\"></a>";
  } else {
    echo "Please wait about ".$config['mrtg_interval']." minutes for the first graph to show.";
  }
}                
?>
Return current item: SHOUTcast Management Interface