Location: PHPKode > scripts > PHP Hosting Directory > phphost_directoryv2/include/host.php
<?

############################# CREATING PAGES ##############################
$order = "";
$direction = "";
$cpage = 1;

if ($request[2] == '') { $order = 'monthly_price'; } else { $order = $request[2]; }
if ($request[3] != '' && intval($request[3]) == 0) { $direction = $request[3]; }
if (intval($request[3]) != 0) { $cpage = $request[3]; }
if (intval($request[4]) != 0) { $cpage = $request[4]; }

$t->assign($order, 1);
if ($direction != '') { $t->assign($direction, 1); }
$t->assign('order', $order);
$t->assign('direction', $direction);

$sql_pages = "SELECT COUNT(*) FROM `hsl_plan` p LEFT JOIN `hsl_host` h ON p.`hid`=h.`hid` WHERE h.`name`='".$request[1]."' AND p.`status`=1";
$res_pages = mysql_query($sql_pages);
$pages = mysql_result($res_pages, 0, 0);

if ((($pages/5) - intval($pages/5)) > 0) { $pages = intval($pages/5)+1; }
else { $pages = intval($pages/5); }

$pages_hash = array();
if ($pages > 1)
{
	for ($i = 1; $i <= $pages; $i++)
	{
		$page = array();
		$page['value'] = $i;
		if ($cpage == $i)
		{
			$page['current'] = 1;
		}
		array_push($pages_hash, $page);
	}
	if ($cpage == 1)
	{
		$t->assign('first_page', 1);
	}
	elseif ($cpage == $pages)
	{
		$t->assign('last_page', 1);
	}
	$t->assign('prev_page', $cpage-1);
	$t->assign('next_page', $cpage+1);
	$t->assign('pages', $pages_hash);
}

#################### SETTING NAME FOR HOST TITLE #####################
$sql_host = "SELECT * FROM `hsl_host` WHERE `name`='".$request[1]."'";
$sql_special = "SELECT s.`text` FROM `hsl_special` s LEFT JOIN `hsl_host` h ON h.`hid`=s.`hid` WHERE s.`expire` > NOW() AND h.`name`='".$request[1]."'";
$sql_rating = "SELECT SUM((r.speed+r.reliability+r.support+r.price)/40)/COUNT(*) AS rating FROM `hsl_host` h LEFT JOIN `hsl_review` r ON h.`name`=r.`company` WHERE h.`name`='".$request[1]."' AND r.`status`=1 GROUP BY h.`name`";

$res_host = mysql_query($sql_host);
$host = mysql_fetch_array($res_host);

$res_special = mysql_query($sql_special);
if (mysql_num_rows($res_special) > 0)
{
	$special = mysql_fetch_assoc($res_special);
	$host['special'] = $special['text'];
}

$res_rating = mysql_query($sql_rating);
if (mysql_num_rows($res_rating) > 0)
{
	$rating = mysql_fetch_assoc($res_rating);
	$host['rating'] = round($rating['rating'] * 10);
}

############################## FETCHING ITEMS ##############################
$sql_plans = "SELECT p.*, h.name AS company, h.company_url FROM `hsl_plan` p LEFT JOIN `hsl_host` h ON p.hid=h.hid WHERE h.`name`='".$request[1]."' AND p.`status`=1 ORDER BY `".$order."` ".$direction." LIMIT ".($cpage*5-5).",5";

$res_plans = mysql_query($sql_plans);
$plans = array();
while ($plan = mysql_fetch_array($res_plans))
{
	### creating LOGO
	if (!file_exists("logos/".$plan['hid']."_logo.gif")) { $plan['image'] = "default"; }
	else { $plan['image'] = $plan['hid']."_logo"; }

	### Data Transfer
	if ($plan['datatransfer'] != 999999999) { $plan['datatransfer'] = $plan['datatransfer'] / 1000; }

	array_push($plans, $plan);
}

################################## OUTPUT ###################################
$t->assign('host', $host);
$t->assign('plans', $plans);

$t->assign('main_html', $request[0].'.html');

?>
Return current item: PHP Hosting Directory