Location: PHPKode > projects > web-cp - Web Hosting Control Panel > webcp/web/domain/subpointer.phps
<? 
// If data is set (i.e the submit button has been hit) and $action != 'newaccount' (setup exception)
// create, update domain pointers & subdomains
if (isset($data)) {
	if (is_array($data)) {
		// check action
		if ($action != 'create') 
			$action = 'update';
		
		// remove spaces and slashes.
		while (list($key, $val) = each($data)) {
			if ($key != 'serverside')
				$data[$key] = trim(stripslashes($val));
		}
		
		// HARDCODED $data['owner'], $data['email'], $data['ip_addr'], $data['type'];
		if ($data['type'] != 'subdomain')
			$data['type'] = 'pointer';
		if ($data['type'] == 'subdomain')
			$data['domain'] = $domaindata['domain'];
		if ($action == 'create')
			$data['id'] = $domaindata['id'];
		$data['email'] = $domaindata['email'];
		$data['ip_addr'] = $domaindata['ip'];
		
		$error = domain($action,$data,$null);
		if ($error)
			echo "<br>&nbsp;&nbsp;• ".implode("<br>\n&nbsp;&nbsp;• ",$error)."<br>\n";
		else
			echo "<br><div align='center'>".$T['domain '.$action]."<a href='$current_url&domid=$domid'><b>".$data['hostname'].".".$data['domain']."</b></a></div><br>\n";
		unset($action);
	}
}


// If action is set (i.e the apply button or a link with &action=)
// suspend, unduspend, remove domain pointers & subdomains
if ($action AND $confirm == "true") {
	// Initialize
	unset($data);
	unset($error);
	
	// check if its a GET or POST (i.e is $domid a string or an array?)
	if (!is_array($domid)) { // single action from GET
		// hardcode data
		$data['owner'] = $domaindata['id'];
		$data['id'] = $domid;
		
		$error = domain($action,$data,$return);
		$tmp = fetchdata("host,domain","domain",$domid);
		$tmp = $tmp['host'].'.'.$tmp['domain'];
	}
	elseif (is_array($domid)) { // multiple user action.
		// hardcode data
		$data['owner'] = $domaindata['id'];

		do {
			$data['id'] = trim(current($domid));
			$tmperr = domain($action,$data,$return);
			
			// Trap errors and 'add' them up.
			if ($tmperr) {
				if ($error) $error = array_merge($error,$tmperr);
				else $error = $tmperr;
			}
		} while(next($domid));
		reset($domid);

		unset($tmpid);
		while (list($key, $val) = each($domid)) {
			$tmp = fetchdata("host,domain","domain",$val);
			$tmpid[$key] = $tmp['host'].'.'.$tmp['domain'];
		}
		$tmp = implode(", ",$tmpid);
	}
	else $error[1] = $T['Invalid Input'];

	if ($error)
		echo "<br>&nbsp;&nbsp;&bull; ".implode("<br>\n&nbsp;&nbsp;&bull; ",$error)."<br>\n";
	else 
		echo $T['domain '.$action]."<b>".$tmp."</b><br>\n";
}
// if its an update, do nothing.
if ($action == 'update');

// ask confirmation for suspend - unsuspend - remove
elseif ($action AND $domid AND $confirm != "true") {
	if (is_array($domid)) {
		reset($domid);
		unset($tmpid);
		while (list($key, $val) = each($domid)) {
			$tmp = fetchdata("host,domain","domain",$val);
			$tmpid[$key] = $tmp['host'].'.'.$tmp['domain'];
		}
		$tmp = implode(", ",$tmpid);
	}
	else {
		$tmp = fetchdata("host,domain","domain",$domid);
		$tmp = $tmp['host'].'.'.$tmp['domain'];
	}
?>
<blockquote>
<form action="<?=$current_url;?>" method="post"  name="webcp1" onSubmit="submitonce(this);">
&nbsp;&nbsp;&bull; <?=$T['really '.$action];?><b><?=$tmp;?></b><br>
&nbsp;&nbsp;&nbsp;<input type="submit" value="<?=$T['yes'];?>">
<? if (is_array($domid)) {
	reset($domid);
	while (list($key, $val) = each($domid))
		echo "<input type='hidden' name='domid[$key]' value='$val'>\n";
}
else echo '<input type="hidden" name="domid" value="'.$domid.'">';
?>
<input type="hidden" name="action" value="<?=$action;?>">
<input type="hidden" name="confirm" value="true">
</form>
</blockquote>
<? }

// get domain & reseller serverside for checks
$resellerdata = fetchdata('serverside','reseller',$domaindata['id']);
			
			
	//////////////////////////////////
	// List subdomains and create
	if ($domaindata['subdomains']) {
?>

<div align="center">
<form action="<?=$current_url;?>" method="post"  name="webcp2" onSubmit="submitonce(this);">
<table border="0" cellpadding="0" cellspacing="0"><tr><td>
<table border="0" cellspacing="1" width="560">
	<tr>
		<td class="tbltop" colspan="3">&nbsp;<?=$T['Subdomains'];?>&nbsp;</td>
	</tr>
<?
$i = 0;
// Get subdomains list
$dbp = mysql_query("SELECT * FROM domains WHERE owner=".$domaindata['id']." AND type='subdomain' AND action != 'remove' ORDER BY priority,domain");
while ($domlist = mysql_fetch_array($dbp)) {
	// select cell bg color
	($i++ % 2) ? ($cell = "row1") : ($cell = "row2");
	
	// if the current user is suspended, put no bg color
	if ($domlist['suspended'] == "true" OR $domlist['action'] == "suspend")
		$cell = "suspend";
	?>
	<tr>
		<td class="<?=$cell;?>" width="10"><input type="checkbox" name="domid[]" value="<?=$domlist['id'];?>"></td>
		<td class="<?=$cell;?>" width="500"><? if ($domid != $domlist['id']) { ?>
		<b><a href="<?=$current_url;?>&domid=<?=$domlist['id'];?>"><?=$domlist['host'].'.'.$domlist['domain'];?></a></b>
		&nbsp;
		(<?=$domlist['ip'];?>)&nbsp;
		<? } else {
			$j = $i;
			($j++ % 2) ? ($cell1 = "row1") : ($cell1 = "row2");
		?>
		<table border="0" summary="">
			<tr><td class='<?=$cell1;?>'><input type="text" name="data[hostname]" size="20" maxlength="255" value="<?=$domlist['host'];?>"></td>
			<td class='<?=$cell;?>'><b>. <?=$domlist['domain'];?></b></td>
			</tr>
			<?
			if (strstr($cfg['sslang'],",")) $sslang = explode(",",$cfg['sslang']);
			else $sslang[0] = $cfg['sslang'];
			
			$j = 0;
			while ($sslang[$j]) {
				$tmp = trim($sslang[$j]);
				
				$tmpdata = fetchdata('serverside','domain',$domlist['id']);
				
				unset($check);
				$check[$tmpdata['serverside'][$tmp]] = ' checked';
				
				echo "<tr><td class='$cell1'><div class='small'>&nbsp;".$T['ss'][$tmp]."&nbsp;</div></td><td class='small'>\n";
				
				if (($tmpdata['serverside'][$tmp] == "na" AND $userdata['level'] > 2) OR $resellerdata['serverside'][$tmp] != "on")
					echo '&nbsp;<input type="radio" name="data[serverside]['.$tmp.']" value="na" CHECKED>'.$T['na'];
				else {
					echo '&nbsp;<input type="radio" name="data[serverside]['.$tmp.']" value="na"'.$check['na'].'>'.$T['na'];
					echo '&nbsp;<input type="radio" name="data[serverside]['.$tmp.']" value="on"'.$check['on'].'>'.$T['on'];
					echo '&nbsp;<input type="radio" name="data[serverside]['.$tmp.']" value="off"'.$check['off'].'>'.$T['off'];
				}
				echo "\n</td></tr>\n";
				++$j;
			}
		?></table>
		<input type="hidden" name="data[type]" value="subdomain">
		<input type="hidden" name="data[id]" value="<?=$domlist['id'];?>">
		<input type="hidden" name="domid" value="<?=$domlist['id'];?>">
		<div align="center"><input type="submit" value="<?=$T['Apply'];?>"></div>
		<? } ?></td>
		<td class="<?=$cell;?>" width="50"><nobr>&nbsp;
		<? // select suspend or unsuspend icon/link
		if ($domlist['suspended'] == "true" OR $domlist['action'] == "suspend") { ?>
		<a href="<?=$current_url;?>&action=unsuspend&confirm=true&domid=<?=$domlist['id'];?>"><img src="icon/unsuspend.gif" border="0" width="16" height="16" alt="Unsuspend"></a><? } else { ?>
		<a href="<?=$current_url;?>&action=suspend&domid=<?=$domlist['id'];?>"><img src="icon/suspend.gif" border="0" width="16" height="16" alt="Suspend"></a><? } ?>
		<a href="<?=$current_url;?>&action=remove&domid=<?=$domlist['id'];?>"><img src="icon/remove.gif" border="0" width="15" height="15" alt="Remove"></a></nobr></td>
	</tr>
	<? } ?>
</table>
<? if (mysql_num_rows($dbp)) { ?>
<br>
<div align="right">
<select name="action">
	<option value=""> <?=$T['Select Action'];?></option>
	<option value="suspend"> <?=$T['Suspend Subdomains'];?></option>
	<option value="unsuspend"> <?=$T['Reactivate Subdomains'];?></option>
	<option value="remove"> <?=$T['Remove Subdomains'];?></option>
</select>
&nbsp;
<input type="submit" value="<?=$T['Apply'];?>"></div> <? } ?>
</td></tr></table>
</form>
<br>
<form action="<?=$current_url;?>" method="post" name="webcp3" onSubmit="submitonce(this);">
<table border="0" cellpadding="0" cellspacing="0"><tr><td>
<table border="0" cellpadding="0" cellspacing="0" class="tblbg"><tr><td>
<table border="0" cellspacing="1">
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Hostname'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[hostname]" size="25" maxlength="255" value="<? if(!$data['hostname'] OR $domid) echo "subdomain"; else echo $data['hostname'];?>">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Domain Name'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<?=$domaindata['domain'];?>&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Server Side Options'];?>&nbsp;</b></td>
		<td class="row2"><table border="0" cellpadding="0" cellspacing="0">
		<?
		if (strstr($cfg['sslang'],",")) $sslang = explode(",",$cfg['sslang']);
		else $sslang[0] = $cfg['sslang'];

		$j = 0;
		while ($sslang[$j]) {
			echo "<tr><td class='row2' width='50'>&nbsp;".$T['ss'][trim($sslang[$j])]."&nbsp;</td><td class='small'>\n";
			if ($domaindata['serverside'][trim($sslang[$j])] == "na")
				echo '&nbsp;<input type="radio" name="data[serverside]['.trim($sslang[$j]).']" value="na" CHECKED>'.$T['na'];
			else {
				echo '&nbsp;<input type="radio" name="data[serverside]['.trim($sslang[$j]).']" value="na">'.$T['na'];
				echo '&nbsp;<input type="radio" name="data[serverside]['.trim($sslang[$j]).']" value="on">'.$T['on'];
				echo '&nbsp;<input type="radio" name="data[serverside]['.trim($sslang[$j]).']" value="off" CHECKED>'.$T['off'];
			}
			echo "\n</td></tr>\n";
			++$j;
		}
	?>
	
	</table></tr>
</table>
</td></tr></table><br>
<input type="hidden" name="data[type]" value="subdomain">
<input type="hidden" name="action" value="create">
<div align="center"><input type="submit" value="<?=$T['Apply'];?>"></div>
</td></tr></table>
</form>
</div>
<br><br>


<? }
	//////////////////////////////////
	// List domain pointers and create
	if ($domaindata['pointers']) {
?>
<div align="center">
<form action="<?=$current_url;?>" method="post" name="webcp4" onSubmit="submitonce(this);">
<table border="0" cellpadding="0" cellspacing="0"><tr><td>
<table border="0" cellspacing="1" width="560">
	<tr>
		<td class="tbltop" colspan="3">&nbsp;<?=$T['Dom Pointers'];?>&nbsp;</td>
	</tr>
<?
$i = 0;
// Get domain pointers list
$dbp = mysql_query("SELECT * FROM domains WHERE owner=".$domaindata['id']." AND type='pointer' AND action != 'remove' ORDER BY priority,domain");
while ($domlist = mysql_fetch_array($dbp)) {
	// select cell bg color
	($i++ % 2) ? ($cell = "row1") : ($cell = "row2");
	
	// if the current user is suspended, put no bg color
	if ($domlist['suspended'] == "true" OR $domlist['action'] == "suspend")
		$cell = "suspend";
	?>
	<tr>
		<td class="<?=$cell;?>" width="10"><input type="checkbox" name="domid[]" value="<?=$domlist['id'];?>"></td>
		<td class="<?=$cell;?>" width="500"><? if ($domid != $domlist['id']) { ?>
		<b><a href="<?=$current_url;?>&domid=<?=$domlist['id'];?>"><?=$domlist['host'].'.'.$domlist['domain'];?></a></b>
		&nbsp;
		(<?=$domlist['ip'];?>)
		<? } else { ?>
		<input type="text" name="data[hostname]" size="4" maxlength="255" value="<?=$domlist['host'];?>">
		.
		<input type="text" name="data[domain]" size="20" maxlength="255" value="<?=$domlist['domain'];?>"><br>
		<?=$T['DocumentRoot'];?> 
		<? // get dir listing to get possible user roots
			$i = 0;
			unset($dir_info);
			// get default values
			$tmp = str_replace($cfg['webdir']."/".$domaindata['id'],"",$domlist['path']);
			$tmp = ereg_replace("/+","/",$tmp);
			
			$dir_info[$i++] = $tmp;
			$dir_info[$i++] = "";
			
			// get dir data
			$tmp_array = dirlist($domaindata['path'],"dir");
			
			//make it all look nice
			do {
				$tmp = str_replace($cfg['webdir']."/".$domaindata['id'],"",current($tmp_array));
				$tmp = ereg_replace("/+","/",$tmp);
				if ($tmp AND $tmp != "/") $dir_info[$i++] = $tmp;
			} while (next($tmp_array));
			
			echo '<select name="data[path]">';
			$i = 0;
			while (isset($dir_info[$i])) {
				echo '<option value="'.$dir_info[$i].'"> ';
				$tmp = $dir_info[$i];
				if (strlen($tmp) > 35)
					$tmp = substr($tmp, 0, 5)."[..]".substr($tmp, strlen($tmp)-26, 26);
				else
					$tmp =  $dir_info[$i];
				echo "$tmp</option>\n";
				++$i;
			}
			echo '</select>';
		?>
		<br>
		<table border="0" cellpadding="0" summary="">
			<?
			if (strstr($cfg['sslang'],",")) $sslang = explode(",",$cfg['sslang']);
			else $sslang[0] = $cfg['sslang'];
			
			// get domain & reseller serverside for check
			$tmpdata = fetchdata('serverside','domain',$domlist['id']);
			$j = 0;
			while ($sslang[$j]) {
				$tmp = trim($sslang[$j]);
				
				unset($check);
				$check[$tmpdata['serverside'][$tmp]] = ' checked';
				
				echo "<tr><td class='row2'><div class='small'>&nbsp;".$T['ss'][$tmp]."&nbsp;</div></td><td class='small'>\n";
				
				if (($tmpdata['serverside'][$tmp] == "na" AND $userdata['level'] > 2) OR $resellerdata['serverside'][$tmp] != "on")
					echo '&nbsp;<input type="radio" name="data[serverside]['.$tmp.']" value="na" CHECKED>'.$T['na'];
				else {
					echo '&nbsp;<input type="radio" name="data[serverside]['.$tmp.']" value="na"'.$check['na'].'>'.$T['na'];
					echo '&nbsp;<input type="radio" name="data[serverside]['.$tmp.']" value="on"'.$check['on'].'>'.$T['on'];
					echo '&nbsp;<input type="radio" name="data[serverside]['.$tmp.']" value="off"'.$check['off'].'>'.$T['off'];
				}
				echo "\n</td></tr>\n";
				++$j;
			}
		?></table>
		<input type="hidden" name="data[type]" value="pointer">
		<input type="hidden" name="data[id]" value="<?=$domlist['id'];?>">
		<input type="hidden" name="domid" value="<?=$domlist['id'];?>">
		<input type="submit" value="<?=$T['Apply'];?>">
		<? } ?>&nbsp;</td>
		<td class="<?=$cell;?>" width="50"><nobr>&nbsp;
		<? // select suspend or unsuspend icon/link
		if ($domlist['suspended'] == "true" OR $domlist['action'] == "suspend") { ?>
		<a href="<?=$current_url;?>&action=unsuspend&confirm=true&domid=<?=$domlist['id'];?>"><img src="icon/unsuspend.gif" border="0" width="16" height="16" alt="Unsuspend"></a><? } else { ?>
		<a href="<?=$current_url;?>&action=suspend&domid=<?=$domlist['id'];?>"><img src="icon/suspend.gif" border="0" width="16" height="16" alt="Suspend"></a><? } ?>
		<a href="<?=$current_url;?>&action=remove&domid=<?=$domlist['id'];?>"><img src="icon/remove.gif" border="0" width="15" height="15" alt="Remove"></a></nobr></td>
	</tr>
	<? } ?>
</table>
<? if (mysql_num_rows($dbp)) { ?>
<br>
<div align="right">
<select name="action">
	<option value=""> <?=$T['Select Action'];?></option>
	<option value="suspend"> <?=$T['Suspend Pointers'];?></option>
	<option value="unsuspend"> <?=$T['Reactivate Pointers'];?></option>
	<option value="remove"> <?=$T['Remove Pointers'];?></option>
</select>
&nbsp;
<input type="submit" value="<?=$T['Apply'];?>"></div><? } ?>
</td></tr></table>
</form>
<br>
<form action="<?=$current_url;?>" method="post" name="webcp5" onSubmit="submitonce(this);">
<table border="0" cellpadding="0" cellspacing="0"><tr><td>
<table border="0" cellpadding="0" cellspacing="0" class="tblbg"><tr><td>
<table border="0" cellspacing="1">
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Hostname'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[hostname]" size="25" maxlength="255" value="<? if(!$data['hostname'] OR $domid) echo "www"; else echo $data['hostname'];?>">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Domain Name'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[domain]" size="25" maxlength="255" value="<?if(!$domid) echo $data['domain'];?>">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['DocumentRoot'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<? // get dir listing to get possible user roots
			$i = 0;
			unset($dir_info);
			// get dir data
			$tmp_array = dirlist($domaindata['path'],"dir");
			
			//make it all look nice
			do {
				$tmp = str_replace($cfg['webdir']."/".$domaindata['id'],"",current($tmp_array));
				$tmp = ereg_replace("/+","/",$tmp);
				if ($tmp AND $tmp != "/") $dir_info[$i++] = $tmp;
			} while (next($tmp_array));
			
			echo '<select name="data[path]">';
			$i = 0;
			while (isset($dir_info[$i])) {
				echo '<option value="'.$dir_info[$i].'"> ';
					$tmp = $dir_info[$i];
					if (strlen($tmp) > 25)
						$tmp = substr($tmp, 0, 5)."[..]".substr($tmp, strlen($tmp)-16, 16);
					else
						$tmp =  $dir_info[$i];
					echo "$tmp</option>\n";
				++$i;
			}
			echo '</select>';
		?>&nbsp;</td></tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Domain Alias'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="checkbox" name="data[nohost]" value="true" CHECKED>&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Catch all Aliases'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="checkbox" name="data[catchall]" value="true">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Redirect'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="checkbox" name="data[redirect]" value="true" CHECKED>&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Server Side Options'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<table border="0" cellpadding="0" cellspacing="0">
		<?
		if (strstr($cfg['sslang'],",")) $sslang = explode(",",$cfg['sslang']);
		else $sslang[0] = $cfg['sslang'];

		$j = 0;
		while ($sslang[$j]) {
			echo "<tr><td class='row2'>&nbsp;".$T['ss'][trim($sslang[$j])]."&nbsp;</td><td class='small'>\n";
			if ($domaindata['serverside'][trim($sslang[$j])] == "na")
				echo '&nbsp;<input type="radio" name="data[serverside]['.trim($sslang[$j]).']" value="na" CHECKED>'.$T['na'];
			else {
				echo '&nbsp;<input type="radio" name="data[serverside]['.trim($sslang[$j]).']" value="na">'.$T['na'];
				echo '&nbsp;<input type="radio" name="data[serverside]['.trim($sslang[$j]).']" value="on">'.$T['on'];
				echo '&nbsp;<input type="radio" name="data[serverside]['.trim($sslang[$j]).']" value="off" CHECKED>'.$T['off'];
			}
			echo "\n</td></tr>\n";
			++$j;
		}
		?></table>&nbsp;</td>
	</tr>
</table>
</td></tr></table><br>
<input type="hidden" name="data[type]" value="pointer">
<input type="hidden" name="action" value="create">
<div align="right"><input type="submit" value="<?=$T['submit'];?>"></div>
</td></tr></table>
</form>
</div>
<? } ?>
Return current item: web-cp - Web Hosting Control Panel