<?php

//////////////////////////////////////////////////////////////
//===========================================================
// editiprange_theme.php
//===========================================================
// SOFTACULOUS VIRTUALIZOR
// Version : 1.0
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Alons
// Date:       8th Mar 2010
// Time:       23:00 hrs
// Site:       https://www.virtualizor.com/ (SOFTACULOUS VIRTUALIZOR)
// ----------------------------------------------------------
// Please Read the Terms of use at https://www.virtualizor.com
// ----------------------------------------------------------
//===========================================================
// (c)Softaculous Ltd.
//===========================================================
//////////////////////////////////////////////////////////////

if(!defined('VIRTUALIZOR')){

	die('Hacking Attempt');

}

function editiprange_theme(){
	

global $theme, $l, $globals, $cluster, $servers, $user, $error, $ippools, $ip, $iprid, $done, $allowed_netmasks;

softheader($l['<title>']);
					
echo page_header(__('Edit IP Range'), 'icon icon-ippool', '', 0, 0, '');

$breadcrumbs = ['dashboard', 'lm_ipranges', 'lms_editiprange'];


echo get_breadcrumb($breadcrumbs);

error_handle($error);

if(!empty($done)){
	show_alert(__('The subnet have been saved. Return to <a href="index.php?act=ippool">IP Pool Overview</a>'));
}

echo '
<div class="card p-2 mx-3">
	<form accept-charset="'.$globals['charset'].'" name="editiprange" method="post" action="" class="form-horizontal">
		<div class="row mx-auto w-100 my-3">
			<div class="col-sm-4">
				<label class="control-label">'.__('Enter IP').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('If the IP Address is assigned, it cannot be edited.').'"><i class="fas text-primary fa-info-circle"></i></a></label>
			</div>
			<div class="col-sm-4">
				<input type="text" class="form-control" name="ip"  size="50" '.(empty($ip['vpsid']) ? ' value="'.POSTval('ip' , $ip['ip']).'"' : 'value="'.$ip['ip'].'" disabled="disabled" ').'/>
			</div>
		</div>
		<div class="row mx-auto w-100 my-3">
			<div class="col-sm-4">
				<label class="control-label">'.__('Netmask (Routing Prefix)').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('A valid routing prefix').'"><i class="fas text-primary fa-info-circle"></i></a></label>
			</div>
			<div class="col-sm-4 d-flex align-items-center">';
				$default_netmask = (int) empty($_REQUEST['netmask']) ? $ip['ipr_netmask'] : $_REQUEST['netmask'];
				echo '<label class="float-left pr-2">/</label><select id="netmask" class="custom-select" name="netmask">';
					foreach($allowed_netmasks as $k => $v){
						echo '<option value="'.$k.'" '.($default_netmask == $k ? 'selected="selected"' : '').'>'.$k.'</option>';
					}			
				echo '</select>
			</div>
		</div>
		<div class="row mx-auto w-100 my-3">
			<div class="col-4">
				<label class="control-label">'.__('Lock').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('Lock this IP range i.e. it cannot be assigned to any VPS').'"><i class="fas text-primary fa-info-circle"></i></a></label>
			</div>
			<div class="col-4">
				'.get_checkbox('locked', '', '', array('chk_it' => 1, 'val' => $ip['locked'])).'
			</div>
		</div>
		<div class="row mx-auto w-100 my-3">
			<div class="col-sm-4">
				<label class="control-label">'.__('IP Pool').'</label>
			</div>
			<div class="col-sm-4">
				'.(empty($ippools[$ip['ippid']]['ippool_name']) ? '<i>'.__('None').'</i>' : $ippools[$ip['ippid']]['ippool_name']).'
			</div>
		</div>
		<br />
		<center>
			<input type="submit" name="editip" class="go_btn mt-5" value="'.__('Submit').'"/>
		</center>
	</form>
</div>
';

softfooter();

}


