Location: PHPKode > projects > WebDebEx > webdebex/html/dom_add.php
<?php
require_once("functions.php");
DBOpen();
LoginAdmin();
MyHeader();

if(!isset($_POST[dom_name])) {
	$_POST[dom_max_accounts] = $_REQUEST[default_dom_max_accounts];
	$_POST[dom_max_space] = $_REQUEST[default_dom_max_space];
	$_POST[space_size] = 1;
	$_POST[dom_max_files] = $_REQUEST[default_dom_max_files];
	$_POST[dom_php_safemode] = $_REQUEST[default_dom_php_safemode];
	$_POST[dom_php_openbasedir] = $_REQUEST[default_dom_php_openbasedir];
}


if(isset($_POST[dom_name])) {
	$_POST[dom_name]=CheckString($_POST[dom_name],128);
	$_POST[dom_max_accounts]=CheckInt($_POST[dom_max_accounts]);
	$_POST[dom_max_space]=CheckInt($_POST[dom_max_space]);
	$_POST[space_size]=CheckInt($_POST[space_size]);
	$_POST[dom_max_files]=CheckInt($_POST[dom_max_files]);
	$_POST[dom_php_safemode]=CheckInt($_POST[dom_php_safemode]);
	$_POST[dom_php_openbasedir]=CheckInt($_POST[dom_php_openbasedir]);

	$status = true;
	echo "<BR>";

	if(!strlen($_POST[dom_name])>0) {
		echo "<B><FONT COLOR=RED>Empty Domainame!</FONT></B><BR>";
		$status = false;
	}

	$res = DBQuery("SELECT count(*) as dom_count FROM domains WHERE dom_name = '$_POST[dom_name]'");
	$row = mysql_fetch_assoc($res);
	if($row[dom_count]>0) {
		echo "<B><FONT COLOR=RED>Domain already in use!</FONT></B><BR>";
		$status = false;
	}
	
	if($_POST[dom_max_accounts]<1) {
		echo "<B><FONT COLOR=RED>Min 1 Account is requried</FONT></B><BR>";
		$status = false;
	}

	if($_POST[dom_max_space]<1) {
		echo "<B><FONT COLOR=RED>Min 1 MB Space should be allowed.</FONT></B><BR>";
		$status = false;
	}

	if($_POST[dom_max_files]<1) {
		echo "<B><FONT COLOR=RED>Min 1 File must be posible</FONT></B><BR>";
		$status = false;
	}

	if($status===true) {
		$res = DBQuery("SELECT max(dom_id) as dom_count FROM domains");
		$row = mysql_fetch_assoc($res);

		if($row[dom_count]>=$_REQUEST[default_gid]) $dom_id = $row[dom_count] + 1;
		else $dom_id = $_REQUEST[default_gid];

		if($_POST[space_size]==2) $_POST[dom_max_space2]=$_POST[dom_max_space]*1024*1024*1024;
		else $_POST[dom_max_space2]=$_POST[dom_max_space]*1024*1024;
		if($_POST[dom_php_safemode]) $_POST[dom_php_safemode] = "on";
		else $_POST[dom_php_safemode] = "off";
		if($_POST[dom_php_openbasedir]) $_POST[dom_php_openbasedir] = "on";
		else $_POST[dom_php_openbasedir] = "off";

		DBQuery("INSERT INTO domains (dom_id,dom_name,dom_type,dom_max_accounts,dom_max_space,dom_max_files,dom_php_safemode,dom_php_openbasedir,dom_sys_createdate,dom_sys_modifydate) VALUES ($dom_id,'$_POST[dom_name]','local',$_POST[dom_max_accounts],$_POST[dom_max_space2],$_POST[dom_max_files],'$_POST[dom_php_safemode]','$_POST[dom_php_openbasedir]',NOW(),NOW())");

		// Create Admin Account
		$user_mail_quota = $_POST[dom_max_space2];
		if($user_mail_quota > $_REQUEST[default_dom_max_space] * 1024 * 1024) $user_mail_quota = $_REQUEST[default_dom_max_space] * 1024 * 1024;
		$user_files = $_POST[dom_max_files];
		if($user_files > $_REQUEST[default_dom_max_files]) $user_files = $_REQUEST[default_dom_max_files];
		user_create($_REQUEST[conf_adminuser],$dom_id,"xxx","Default Admin User",1,$user_mail_quota/2,1,$user_mail_quota/2,$user_files,1);


		echo "<B><FONT COLOR=GREEN>Domain '$_POST[dom_name]' created!</FONT></B><BR>";
		
		// Set Defaults
		$_POST[dom_name] = NULL;
		$_POST[dom_max_accounts] = $_REQUEST[default_dom_max_accounts];
		$_POST[dom_max_space] = $_REQUEST[default_dom_max_space];
		$_POST[space_size] = 1;
		$_POST[dom_max_files] = $_REQUEST[default_dom_max_files];
		$_POST[dom_php_safemode] = $_REQUEST[default_dom_php_safemode];
		$_POST[dom_php_openbasedir] = $_REQUEST[default_dom_php_openbasedir];
		}
}



echo "<BR>";
echo "<FORM METHOD=POST STYLE='display:inline;'>";
echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=3>";
	echo "<TR>";
		echo "<TD>Domain Name</TD>";
		echo "<TD><INPUT TYPE=text NAME=dom_name VALUE='$_POST[dom_name]'></TD><TD><INPUT TYPE=image SRC='icons/add.gif' STYLE='border:0px;background-color:transparent;' ALIGN=middle ALT='Create new Domain'></TD>";
	echo "</TR>";

	echo "<TR>";
		echo "<TD>Max Accounts</TD>";
		echo "<TD><INPUT TYPE=text NAME=dom_max_accounts VALUE=$_POST[dom_max_accounts]></TD>";
	echo "</TR>";

	echo "<TR>";
		echo "<TD>Max Space</TD>";
		echo "<TD><INPUT TYPE=text NAME=dom_max_space VALUE=$_POST[dom_max_space] STYLE='width:80px;'> ";
		if($_POST[space_size]==2) echo "<SELECT NAME=space_size><OPTION VALUE=1>MB</OPTION><OPTION VALUE=2 SELECTED>GB</OPTION></SELECT></TD>";
		else echo "<SELECT NAME=space_size><OPTION VALUE=1 SELECTED>MB</OPTION><OPTION VALUE=2>GB</OPTION></SELECT></TD>";
	echo "</TR>";

	echo "<TR>";
		echo "<TD>Max Files</TD>";
		echo "<TD><INPUT TYPE=text NAME=dom_max_files VALUE=$_POST[dom_max_files]></TD>";
	echo "</TR>";

	echo "<TR>";
		echo "<TD>PHP Safe Mode</TD>";
		if($_POST[dom_php_safemode]) echo "<TD><INPUT TYPE=checkbox NAME=dom_php_safemode VALUE=1 CHECKED></TD>";
		else echo "<TD><INPUT TYPE=checkbox NAME=dom_php_safemode VALUE=1></TD>";
	echo "</TR>";

	echo "<TR>";
		echo "<TD>PHP Open Base Dir</TD>";
		if($_POST[dom_php_openbasedir]) echo "<TD><INPUT TYPE=checkbox NAME=dom_php_openbasedir VALUE=1 CHECKED></TD>";
		else echo "<TD><INPUT TYPE=checkbox NAME=dom_php_openbasedir VALUE=1></TD>";
	echo "</TR>";
echo "</TABLE>";
echo "</FORM>";


DBClose();
MyFooter();
MyEnd();
?>
Return current item: WebDebEx