Location: PHPKode > projects > web-cp - Web Hosting Control Panel > webcp/web/domain/newuser.phps
<?
// If data is set (i.e the submit button has been hit) and $action != 'newdomain' (setup exception)
if (isset($data) AND $action != 'newdomain') {
	if (is_array($data)) {
		// remove spaces and slashes.
		while (list($key, $val) = each($data))
			$data[$key] = trim(stripslashes($val));
		
		// HARDCODED $data['id']
		$data['id'] = $domaindata['id'];
		
		$error = user("create",$data);
		if ($error)
			echo "<br>&nbsp;&nbsp;• ".implode("<br>\n&nbsp;&nbsp;• ",$error)."<br>\n";
		else
			echo "<br><div align='center'>".$T['user created']."<a href='./?cp=personal&url=userset&number=$number&user=".$data['username']."' target='_top'><b>".$data['username']."</b></a></div><br>\n";
	}
}
?>

<div align="center">
<form action="<?=$current_url;?>" method="post" name="webcp" 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 colspan="2" class="tbltop">&nbsp;<?=$T[$cp][$url];?>&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Full Name'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[name]" size="25" maxlength="255" value="<?=$data['name'];?>">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Username'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[username]" size="25" maxlength="255" value="<?=$data['username'];?>">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Password'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[password]" size="25" maxlength="255" value="<?=$data['password'];?>">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['User Type'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<? // select good option.
		unset($D);
		if ($data['type'] == "regular") $D['reg'] = " SELECTED";
		if ($data['type'] == "demo") $D['dmo'] = " SELECTED";
		if ($data['type'] == "virtual") $D['vir'] = " SELECTED";
		if ($data['type'] == "email") $D['eml'] = " SELECTED";
		if ($data['type'] == "ftp") $D['ftp'] = " SELECTED";
		?><select name="data[type]">
    			<option value="standard"<?=$D['reg'];?>> <?=$T['usertype']['standard'];?></option>
			<option value="demo"<?=$D['dmo'];?>> <?=$T['usertype']['demo'];?></option>
    		</select>&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Access Level'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<select name="data[level]">
		<?
		if (!isset($data['level']))
			$data['level'] = 4;
		for ($i=4; $i>$userdata['level'];$i--) {
			echo '<option value="'.$i.'"';
			if ($i == $data['level']) echo " SELECTED";
			echo '> '.$T['userlvl'][$i].'</option>';
			echo "\n";
		} ?>
		</select>&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['User Root Directory'];?>&nbsp;</b></td>
		


		<? // get dir listing
		$i = 0;
		unset($dir_info);
		// get default values
		$tmp = trim(str_replace($cfg['webdir']."/".$domaindata['id'],"",$domaindata['defaultroot']));
		if (trim(str_replace("/","",$tmp))) {
			if ($tmp)
				$dir_info[$i++] = $tmp;
			$dir_info[$i++] = "";
		}
		
		
		// get dir data
		$tmp_array = dirlist($domaindata['path'],"dir");
		//make it all look nice
		while (list($key, $val) = each($tmp_array)) {
			$tmp = str_replace($cfg['webdir']."/".$domaindata['id'],"",$val);
			$tmp = ereg_replace("/+","/",$tmp);
			if ($tmp)
				$dir_info[$i++] = $tmp;
			else
				$dir_info[$i++] = '/';
		}
		?>
	

		<td class="row2">
		&nbsp;<? 
		echo '<select name="data[root]">';
//		$i = 0;
//		while (isset($dir_info[$i])) {
//			echo '<option value="'.$dir_info[$i].'"';

// if this is the first user then rootdir=/ else rootdir=/%user

$sql_query = "SELECT * FROM users WHERE id=".$domaindata['id']." AND action != 'remove' ORDER BY level,username";
$dbp = mysql_query($sql_query);

// check for users
$numrows = mysql_num_rows($dbp);

if (!$numrows AND $search != 'true')
	echo '<option value="/" SELECTED>/ ';
else
        echo '<option value="/%USER%" SELECTED>/%USER% </option>\n';


echo '</option>\n';


//			if ($dir_info[$i] == $data['root'])
//				echo ' SELECTED';
//			echo '> ';
//			$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['Hard Disk Space'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[hd]" size="10" maxlength="10" value="<?
			if($data['hd']) echo $data['hd']; else echo $domaindata['hd'];
			?>">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['E-Mail Aliases'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<textarea name="data[aliases]" cols="20" rows="3" wrap="virtual"><?=trim($data['aliases']);?></textarea>&nbsp;</td>
	</tr>
	<tr>
		<? // get available languages
		if (strstr($cfg['lang'],",")) {
			$language = explode(",",$cfg['lang']);
		}
		else $language[1] = $cfg['lang'];
		?>
		<td class="row1"><b>&nbsp;<?=$T['Language'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<select name="data[lang]">
		<? do {
			echo '<option value="'.trim(current($language)).'"';
			if (current($language) == $cfg['defaultlang']) echo " SELECTED";
			echo '> '.$T[current($language)].'</option>';
			echo "\n";
		} while(next($language)); ?>
           	</select>&nbsp;</td>
	</tr>
	<tr>
		<? 				
			unset($skin_info);
			unset($tmp_info);
			
			// fetch reseller data to check any limitation on skin usage
			$rdata = fetchdata("skin","reseller",$domaindata['id']);

			// Check if a skin list exists, if so parse it.  Else use default skin.
			if (file_exists("skin/list")) {
				$i = 0;
				$j = 0;
				$tmp = file("skin/list");
				while ($tmp[$i]) {
					
					$tmp_info = split("[[:space:]]+",$tmp[$i]);
					if (count($tmp_info) >= 2) {
						if ($rdata['skin'] == "any" OR $rdata['skin'] == $tmp_info[0]) {
							
							$skin_info[$j]['dir'] = array_shift($tmp_info);
							if (count($tmp_info) > 1)
								$skin_info[$j]['name'] = implode(" ",$tmp_info);
							else
								$skin_info[$j]['name'] = $tmp_info[0];
							++$j;
						}
					}
					++$i;
				}

				// Check if we actually got anything.
				if (count($skin_info) < 1) {
					unset($skin_info);
					$skin_info[0]['dir'] = $cfg['defaultskin'];
					$skin_info[0]['name'] = $cfg['defaultskin'];
				}
			}
			else {
				$skin_info[0]['dir'] = $cfg['defaultskin'];
				$skin_info[0]['name'] = $cfg['defaultskin'];
			}
		?>
		<td class="row1"><b>&nbsp;<?=$T['Interface Look'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<select name="data[skin]">
		<? // print skin choice(s)
			$i = 0;
			while ($skin_info[$i]) {
				echo '<option value="'.$skin_info[$i]['dir'].'"';
				if ($userdatadata['skin'] == $skin_info[$i]['dir']) echo " SELECTED";
				echo '> '.$skin_info[$i]['name'].'</option>';
				echo "\n";
				++$i;
			}
		?>
           	</select>&nbsp;</td>
	</tr>
</table>
</td></tr></table><br>
<div align="right"><input type="submit" value="Submit"></div>
</td></tr></table>
</form>
</div>
Return current item: web-cp - Web Hosting Control Panel