Location: PHPKode > projects > web-cp - Web Hosting Control Panel > webcp/web/server/newaccount.phps
<?
// If data is set (i.e the submit button has been hit)
if (isset($data) && $userdata['type'] != "demo") {
	if (is_array($data)) {
		// remove spaces and slashes.
		while (list($key, $val) = each($data)) {
			if ($key != 'serverside')
				$data[$key] = trim(stripslashes($val));
		}
		$error = reseller("create",$data,$return);
		if ($error)
			echo "<br>&nbsp;&nbsp;• ".implode("<br>\n&nbsp;&nbsp;• ",$error)."<br>\n";
		else {
			echo "<br><div align='center'>".$T['reseller created']."<a href='./?cp=reseller&number=$return' target='_top'><b>".$data['name']."</b></a>.</div>\n";
			
			// if domain is set, attempt to create domain
			if ($data['domain']) {
				if (ereg("[:space:]",$data['ip'])) {
					$ip = split("([[:space:]]+,?|[[:space:]]*,)",$data['ip']);
					$data['ip'] = $ip[0];
				}
				$data['ip_addr'] = $data['ip'];
				unset($tmp);
				foreach($data['serverside'] AS $key=>$val) {
					if ($val == 'on')
						$tmp[$key] = 'off';
					else
						$tmp[$key] = 'na';
				}
				$data['serverside'] = $tmp;
				$data['users'] = $data['domusers'];
				$data['hd'] = $data['domhd'];
				$data['transfer'] = $data['domtransfer'];
				$data['subdomains'] = $data['domsubdomains'];
				$data['pointers'] = $data['dompointers'];
				$data['databases'] = $data['domdatabases'];
				$data['bandwidth'] = $data['dombandwidth'];
				$data['defaultroot'] = "/".$data['hostname']."/".$cfg['webname']."/%USER%";
				$data['type'] = 'domain';
				$data['id'] = $return;

				$error = domain("create",$data,$return);
				if ($error)
					echo "<br>&nbsp;&nbsp;• ".implode("<br>\n&nbsp;&nbsp;• ",$error)."<br>\n";
				else {
					echo "<br><div align='center'>".$T['domain created']."<a href='./?cp=domain&number=$return' target='_top'><b>".$data['hostname'].".".$data['domain']."</b></a>.</div>\n";
					
					// if username is set, attempt to create user
					if ($data['username']) {
						// sleep 2 seconds to let the domain be created
						sleep(2);
						
						$data['aliases'] = $data['usraliases'];
						$data['type'] = 'standard';
						$data['level'] = 2;
						$data['id'] = $return;
						unset($data['root']);
						
						$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&number=$return&user=".$data['username']."' target='_top'><b>".$data['username']."</b></a>.</div>\n";
					}
				}
			}
		}
	}
} elseif (isset($data) && $userdata['type'] == "demo") {
	echo "<center>".$T['err']['demo user']."</center>";
}
?>
<br>
<!-- RESELLER CREATION -->
<form action="<?=$current_url;?>" method="post" name="webcp" onSubmit="submitonce(this);">
<div align="center">
<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['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['Email'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[email]" size="25" maxlength="255" value="<?=$data['email'];?>">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['IP Address'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<textarea name="data[ip]" cols="19" rows="3" wrap="virtual"><?if ($data['ip']) echo $data['ip']; else echo $SERVER_ADDR;?></textarea>&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Num Domains'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[domains]" size="5" maxlength="255" value="<? if($data['domains']) echo intval($data['domains']); else echo 25;?>">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Num Subdomains'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[subdomains]" size="5" maxlength="255" value="<? if($data['subdomains']) echo intval($data['subdomains']); else echo 150;?>">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Num Pointers'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[pointers]" size="5" maxlength="255" value="<? if($data['pointers']) echo intval($data['pointers']); else echo 50;?>">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['HD Quota'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[hd]" size="5" maxlength="255" value="<? if(isset($data['hd'])) echo intval($data['hd']); else echo 2500;?>"> <?=$T['mb'];?>&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Num Users'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[users]" size="5" maxlength="255" value="<? if(isset($data['users'])) echo intval($data['users']); else echo 500;?>">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Num Databases'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[databases]" size="5" maxlength="255" value="<? if(isset($data['databases'])) echo intval($data['databases']); else echo 50;?>">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Transfer'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[transfer]" size="5" maxlength="255" value="<? if(isset($data['transfer'])) echo intval($data['transfer']); else echo 10;?>"> <?=$T['gb'];?>&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Shell Access'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="radio" name="data[shell]" value="on"> <?=$T['on'];?>&nbsp;&nbsp;<input type="radio" name="data[shell]" value="off" checked> <?=$T['off'];?>&nbsp;</td>
	</tr>
	<? if ($cfg['bandwidth']) { ?>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Bandwidth'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[bandwidth]" size="5" maxlength="255" value="<? if($data['bandwidth']) echo intval($data['bandwidth']); else echo '0';?>"> <?=$T['kbps'];?>&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]) {
			unset($check);
			if ($data['serverside'][trim($sslang[$j])] == 'on')
				$check['on'] = ' checked';
			else
				$check['off'] = ' checked';
				
			echo "<tr><td class='small'>&nbsp;<b>".$T['ss'][trim($sslang[$j])]."</b>&nbsp;</td><td class='small'>\n";
			echo '&nbsp;<input type="radio" name="data[serverside]['.trim($sslang[$j]).']" value="on"'.$check['on'].'>'.$T['on'];
			echo '&nbsp;<input type="radio" name="data[serverside]['.trim($sslang[$j]).']" value="off"'.$check['off'].'>'.$T['off'];
			echo "\n</td></tr>\n";
			++$j;
		}
		?></table></tr>
</table>
</td></tr></table><br>
<div align="right"><input type="submit" value="<?=$T['submit'];?>"></div>
</td></tr></table>
</div>
<br><br>
<!-- DOMAIN CREATION -->
<div align="center">
<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['reseller']['newdomain'];?>&nbsp;</td>
	</tr>
	<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']) 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="<?=$data['domain'];?>">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Num Users'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[domusers]" size="5" maxlength="255" value="<? if($data['users']) echo intval($data['users']); else echo 10;?>">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['HD Quota'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[domhd]" size="5" maxlength="255" value="<? if($data['hd']) echo intval($data['hd']); else echo 50;?>"> <?=$T['mb'];?>&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Transfer Quota'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[domtransfer]" size="5" maxlength="255" value="<? if($data['domtransfer']) echo intval($data['domtransfer']); else echo 2;?>"> <?=$T['gb'];?>&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Num Subdomains'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[domsubdomains]" size="5" maxlength="255" value="<? if(isset($data['domsubdomains'])) echo intval($data['domsubdomains']); else echo 2;?>">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Num Pointers'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[dompointers]" size="5" maxlength="255" value="<? if(isset($data['dompointers'])) echo intval($data['dompointers']); else echo 1;?>">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Num Databases'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[domdatabases]" size="5" maxlength="255" value="<? if(isset($data['domdatabases'])) echo intval($data['domdatabases']); else echo 5;?>">&nbsp;</td>
	</tr>
	<? if ($cfg['bandwidth']) { ?>
	<tr>
		<td class="row1"><b>&nbsp;<?=$T['Bandwidth'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[dombandwidth]" size="5" maxlength="255" value="<? if($data['dombandwidth']) echo intval($data['dombandwidth']); else echo '0';?>"> <?=$T['kbps'];?>&nbsp;</td>
	</tr>
	<? } ?>
</table>
</td></tr></table><br>
<div align="right"><input type="submit" value="Submit"></div>
</td></tr></table>
</div>
<br><br>
<!-- USER CREATION -->
<div align="center">
<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['domain']['newuser'];?>&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['E-Mail Aliases'];?>&nbsp;</b></td>
		<td class="row2">&nbsp;<textarea name="data[usraliases]" cols="20" rows="3" wrap="virtual"><?if ($data['usraliases']) echo trim($data['usraliases']); else echo 'webmaster, admin';?></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) == $userdata['lang']) echo " SELECTED";
			echo '> '.$T[current($language)].'</option>';
			echo "\n";
		} while(next($language)); ?>
           	</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