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

if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
	if ($request[2] == '')
	{
		$sql = "INSERT INTO `hsl_service` (`sid`, `name`) VALUES ('".$vars['sid']."', '".$vars['name']."')";
		$sql_add = "ALTER TABLE `hsl_plan` ADD `service_".$vars['sid']."` INT( 1 ) UNSIGNED NOT NULL";
		mysql_query($sql);
		mysql_query($sql_add);
		$t->assign('info_message', "Added new service with uin '".$vars['sid']."'");
	}
	else
	{
		$sql = "UPDATE `hsl_service` SET `name`='".$vars['name']."' WHERE `sid`='".$request[2]."'";
		mysql_query($sql);
		$t->assign('info_message', "Updated name of service with sid '".$request[2]."'");
	}
}

if ($request[2] == 'edit')
{
	$sql_e = "SELECT * FROM `hsl_service` WHERE `sid`='".$request[3]."'";
	$res_e = mysql_query($sql_e);
	$edit = mysql_fetch_array($res_e);
	$t->assign('edit', $edit);
}

if ($request[2] == 'delete')
{
	mysql_query("DELETE FROM `hsl_service` WHERE `sid`='".$request[3]."'");
	mysql_query("ALTER TABLE `hsl_plan` DROP `service_".$request[3]."`");

	$t->assign('info_message', "Deleted service with sid '".$request[3]."'");
}

$sql = "SELECT * FROM `hsl_service`";
$res = mysql_query($sql);
$services = array();
while ($service = mysql_fetch_array($res))
{
	array_push($services, $service);
}
$t->assign('services', $services);

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

?>
Return current item: PHP Hosting Directory