Location: PHPKode > scripts > eNetman > enetman-20050830/enetman/html/servers.php
<?
echo "<center><b><h2>".ucfirst($view)."s</b></center><br>";

if($searchfor) {
	$where = "WHERE $searchby";
	if($startswith) {
		$where = $where . " LIKE \"$searchfor%\"";
	} else {
		$where = $where . " LIKE \"%$searchfor%\"";
	}
}


if($orderby) {
	$order = "ORDER BY $orderby $dir";
} else {
	$order = "ORDER BY servers.Name ASC";
}

if(!$limit) { 
	$limit = 10;
}

if(!$start) {
	$start = 0;
}

$next = $start + $limit;
$previous = $start - $limit;

if($limit != 1000) {
	$limitby = "LIMIT $start,$limit";
}

$query = "SELECT servers.ID, servers.Name, device.Type AS 'Device', location.Name AS 'Location', manufacturer.Name AS 'Manufacturer', ";
$query = $query . "vendor.Name AS 'Vendor', os.Type AS 'Operating System', cpu.Type AS 'CPU' FROM servers LEFT JOIN types AS ";
$query = $query . "device ON servers.deviceType = device.ID LEFT JOIN types AS os ON servers.osType = os.ID LEFT JOIN types ";
$query = $query . "AS cpu ON servers.cpuType = cpu.ID LEFT JOIN maindata AS location ON servers.locationID = location.ID LEFT ";
$query = $query . "JOIN maindata AS manufacturer ON servers.manufacturerID = manufacturer.ID LEFT JOIN maindata AS vendor ON ";
$query = $query . "servers.vendorID = vendor.ID $where $order";

$result = mysql_query($query);
$num = mysql_num_rows($result);

echo "<form name='filter' method='post' action='index.php?page=servers.php&view=$view'>";
echo "<table bgcolor='000000' cellpadding=0 border=0 cellspacing=0 align='center' width='80%'>\n";
echo "\t<tr>\n";
echo "\t\t<td>\n";
echo "\t\t\t<table cellpadding=0 border=0 cellspacing=1 width='100%'>\n";
echo "\t\t\t\t<tr>\n";

echo "\t\t\t\t\t<td colspan=2 bgcolor='#FFFFFF'>&nbsp;&nbsp;Search by:<input type='radio' name='searchby' value='servers.Name' ";
if(($searchby == "servers.Name")  || ($searchby == "")){ echo "checked"; }
echo ">".ucfirst($view)." Name<input type='radio' name='searchby' value='os.Type' ";
if($searchby == "os.Type") { echo "checked"; }
echo ">OS<input type='radio' name='searchby' value='cpu.Type' ";
if($searchby == "cpu.Type") { echo "checked"; }
echo ">CPU<input type='radio' name='searchby' value='device.Type' ";
if($searchby == "device.Type") { echo "checked"; }
echo ">Device Type<input type='radio' name='searchby' value='location.Name' ";
if($searchby == "location.Name") { echo "checked"; }
echo ">Location";

#echo "&nbsp;&nbsp;&nbsp;&nbsp;Starts with : <input type='checkbox' name='startswith' value='true' ";

echo "&nbsp;&nbsp;&nbsp;&nbsp;Starts with : <input type='checkbox' name='startswith' value='true' ";
if($startswith) { echo "checked"; }
echo "> <input type='text' name='searchfor' class='frmStyle' value='$searchfor'>&nbsp;&nbsp;<input type='button' value='Search' class='frmStyle' onClick='filter.submit();'>&nbsp;&nbsp;<input type='button' value='Reset' class='frmStyle' onClick=\"location.href='index.php?page=servers.php&view=$view'\"></td>";
echo "\t\t\t\t</tr>";
echo "\t\t\t\t<tr>\n";
echo "\t\t\t\t\t<td bgcolor='#FFFFFF'>&nbsp;&nbsp;Order by: <select class='frmStyle' name='orderby' onChange='filter.submit();'";
echo "<option value='servers.Name' ";
if($orderby == "servers.Name") { echo "selected"; }
echo ">".ucfirst($view)." Name</option>";
echo "<option value='servers.deviceType' ";
if($orderby == "servers.deviceType") { echo "selected"; } 
echo ">Device Type</option>";
echo "<option value='servers.osType' ";
if($orderby == "servers.osType") { echo "selected"; }
echo ">Operating System</option>";
echo "<option value='servers.locationID' ";
if($orderby == "servers.locationID") { echo "selected"; } 
echo ">Location</option>";
echo "<option value='servers.manufacturerID' ";
if($orderby == "servers.manufacturerID") { echo "selected"; } 
echo ">Manufacturer</option>";
echo "<option value='servers.vendorID' ";
if($orderby == "servers.vendorID") { echo "selected"; } 
echo ">Vendor</option>";
echo "<option value='servers.cpuType' ";
if($orderby == "servers.cpuType") { echo "selected"; } 
echo ">CPU Type</option>";
echo "<option value='servers.cpuSpeed' ";
if($orderby == "servers.cpuSpeed") { echo "selected"; } 
echo ">CPU Speed</option>";
echo "</select> &nbsp;&nbsp;&nbsp;<select class='frmStyle' name='dir' onChange='filter.submit();'";
echo "<option value='ASC' ";
if($dir == "ASC") { echo "selected"; }   
echo ">Ascending</option>";
echo "<option value='DESC' ";                 
if($dir == "DESC") { echo "selected"; }                        
echo ">Descending</option>";  
echo "</select>";

echo "</td><td bgcolor='#FFFFFF' align='right' width='50%'>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;Show <select name='limit' onChange='filter.submit();' class=frmStyle>";
echo "<option value=10 ";
if($limit == 10) { echo "selected"; }
echo ">10</option>";
echo "<option value=20 ";
if($limit == 20) { echo "selected"; }
echo ">20</option>";
echo "<option value=50 ";
if($limit == 50) { echo "selected"; }
echo ">50</option>";
echo "<option value=1000 ";
if($limit == 1000) { echo "selected"; }
echo ">All</option>";

echo "</select> per page</td>";

echo "\t\t\t\t</tr>";
echo "\t\t\t</table>\n";
echo "\t\t</td>\n";
echo "\t</tr>\n";

echo "<tr><td><table bgcolor='#ffffff' cellpadding=0 border=0 cellspacing=1 width='100%'>";
echo "<tr><td ";

if($start) {
        echo "bgcolor='#cccccc' width='10%' align=center style='cursor : pointer;' 
onClick=\"location.href='index.php?page=$page&view=$view&start=$previous'\">previous";
} else {
        echo ">&nbsp";
}

echo "</td><td>&nbsp;</td><td ";

if($start +1 < $tnum) {
        echo "bgcolor='#cccccc' width='10%' align=center style='cursor : pointer;' 
onClick=\"location.href='index.php?page=$page&view=$view&start=$next'\">next";
} else {
        echo ">&nbsp;";
}

echo "</td></tr></table></td></tr>";

echo "\t<tr>\n";
echo "<td align='right' bgcolor='#ffffff'><input type='button' class='frmStyle' name='add' value='Add ".ucfirst($view)."' onClick=\"NewWindow('index.php?page=add-server.php&view=$view&nonav=1','popped','550','595','yes');return false\"></td>";
echo "\t</tr>\n";
echo "</table>\n";
echo "</form>";

if(mysql_num_rows($result)) {
	echo "<table bgcolor='000000' cellpadding=0 border=0 cellspacing=0 align='center' width='80%'>\n";
	echo "\t<tr>\n";
	echo "\t\t<td>\n";
	echo "\t\t\t<table cellpadding=0 border=0 cellspacing=1 width='100%'>\n";

	$num = mysql_num_fields($result);

	echo "\t\t\t\t<tr>\n";
	while($rnum != $num) {
		$col_value = mysql_field_name($result, $rnum);
		if(($col_value != "ID") && ($col_value != "dataType") && ($col_value != "Main")) {
			echo "\t\t\t\t\t<td bgcolor='D3DCE3' align='center'><b>$col_value</b></td>\n";
		}
		$rnum++;
	}
	echo "\t\t\t\t</tr>\n";

	echo "\t\t\t\t<tr>\n";
	echo "\t\t\t\t\t<td colspan=$num bgcolor='cccccc' height='1'><img src='' height=1 width=1></td>\n";
	echo "\t\t\t\t</tr>\n";

	$color = 'FFFFFF';
	$num = 0;
	while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
	   $key = array_search('Inactive', $line);
	   $strike = "";
	   $strikelink = "";
	   if($key) {
		$strike = "class='inactive'";
		$strikelink = "class='ilink'";
	   }
	   echo "\t\t\t\t<tr bgcolor='#$color' $strike style=\"cursor: pointer;\" onMouseover=\"this.bgColor='#FFADAE';\" onMouseout=\"this.bgColor='#$color';\">\n";
	   foreach ($line as $col_value) {
	       $findhttp = array_search($col_value, $line);
	       $findID = array_search($col_value, $line);
	       if(($findID != "ID") && ($findID != "dataType") && ($findID != "Main")) {
		       if($findhttp != "Website") {
			       echo "\t\t\t\t\t<td align='center'onClick=\"location.href='index.php?page=edit-server.php&view=$view&ID=$line[ID]';\">$col_value</td>\n";
		       } else {
		               echo "\t\t\t\t\t<td align='center' bgcolor='#$color'><a href='$col_value' target='blank' $strikelink>$col_value</a></td>\n";
		       }
		}
	   }
	   echo "\t\t\t\t</tr>\n";
	   if($color == 'FFFFFF') {
		$color = 'CCCCCC';
	   } else {
		$color = 'FFFFFF';
   	   }
	}
	echo "\t\t\t</table>\n";
	echo "\t\t</td>\n";
	echo "\t</tr>\n";
	echo "</table>\n";
} else {
	echo "<center><font size=2 color='red'>No ".ucfirst($view)."s found</font>";
}

mysql_free_result($result);

mysql_close($link);

?>	
Return current item: eNetman