<?php

$SQL = "SELECT * from FREEHOSTING";
$result = mysql_query( $SQL );
while( $row = mysql_fetch_array( $result ) ) {
include 'admin/query.php'; }

$unc = substr("$un", 0, 1);
$www = substr("$domain", 0, 4);
$http = substr("$domain", 0, 5);
$test = substr("$un", 0,4);

$mystring = "$domain";
$findme  = '.';
$pos = strpos($mystring, $findme);
####################################################################################################
//----- (!)
if ($syn == YES) {}else{
$poss = strpos($domain, $findme);
if (empty($poss)){
$error = "Error : Your domain name requires an extension (.com .net .org etc)";
include 'adjust.php';
include 'order.php';
die();
}}
//----- (!)
if ($syn == NO) {}else{
$posss = strpos($mystring, $findme);
if (empty($posss)){}else {
$error = "Error : Do not include .com .net .biz .org (etc) or .$sub in subdomain name";
include 'adjust.php';
include 'order.php';
die(); }}
//----- (!)


if ($test == 'test') {
$error = 'Error : Sorry, *test is a reserved username';
include 'adjust.php';
include 'order.php';
die(); }
//----- (!)
if ($www == 'www.') {
$error = 'Error : Domain name is incorrect, omit "www." & "http://"';
include 'adjust.php';
include 'order.php';
die(); }
//----- (!)
if ($http == 'http:') {
$error = 'Error : Domain name is incorrect, omit "www." & "http://"';
include 'adjust.php';
include 'order.php';
die(); }
//----- (!)
if ($pw == $confirmpassword) {} else {
$error = 'Error : Password does not match, or password contains illegal characters.';
include 'adjust.php';
include 'order.php';
die(); }
//----- (!)
if ($email == $confirmemail) {} else {
$error = 'Error : Email address does not match.';
include 'adjust.php';
include 'order.php';
die(); }
//----- (!)
if (is_numeric($unc)) {
$error = 'Error : Username cannot start with a number';
include 'adjust.php';
include 'order.php';
die(); }
//----- (!)
if (empty($package)) {
$error = 'Error : No package selected';
include 'adjust.php';
include 'order.php';
die(); }
//----- (!)
if (empty($domain)) {
$error = 'Error : Please enter a domain name';
include 'adjust.php';
include 'order.php';
die(); }
//----- (!)
if (empty($un)) {
$error = 'Error : Please enter a username';
include 'adjust.php';
include 'order.php';
die(); }
//----- (!)
if (empty($pw)) {
$error = 'Error : Please enter a password';
include 'adjust.php';
include 'order.php';
die(); }
//----- (!)
if (empty($confirmpassword)) {
$error = 'Error : Password confirmation not entered';
include 'adjust.php';
include 'order.php';
die(); }
//----- (!)
if (empty($email)) {
$error = 'Error : Email not entered';
include 'adjust.php';
include 'order.php';
die(); }
//----- (!)
if (empty($confirmemail)) {
$error = 'Error : Email confirmation not entered';
include 'adjust.php';
include 'order.php';
die(); }
//----- (!)

// []\/,.>
//<if (eregi ('[! @ # \$ % ^ & * ( ) _ + = | { } ; \' " :] ?', $domain)) {
//if (preg_match('[abc]', $domain)){}else{

if (preg_match('/[^a-z0-9\-.]/i', $domain)) {
$error = 'Error : Only characters a-z, A-Z, 0-9, and dash(-) are allowed in domain name. No spaces';
include 'adjust.php';
include 'order.php';
die(); }else{}
//----- (!)
if (preg_match('/[^a-z0-9]/i', $un)) {
$error = 'Error : Only characters a-z, A-Z & 0-9 are allowed in username. No spaces.';
include 'adjust.php';
include 'order.php';
die(); }else{}
//----- (!)
if (preg_match('/[^a-z0-9]/i', $pw)) {
$error = 'Error : Only characters a-z, A-Z & 0-9 are allowed in password. No spaces.';
include 'adjust.php';
include 'order.php';
die(); }else{}
//----- (!)

if ($domain == '-') {
$error = 'Error : Domain name must contain atleast 2 characters excluding dash(-)';
include 'adjust.php';
include 'order.php';
die(); }
//----- (!)
####################################################################################################
require '/usr/local/cpanel/Cpanel/Accounting.php.inc';

$SQL = "SELECT * from SETTINGS";
$result = mysql_query( $SQL ); while( $row = mysql_fetch_array( $result ) ) {
$host = $row["HOST"];
$rak = $row["RAK"];
$user = $row["USER"];
$erroremail = $row["RECEIVER_EMAIL"];}

$accesshash = "$rak";
####################################################################################################

$viewaccounts = listaccts( $host , $user , $accesshash , 0);
$keys = array_keys( $viewaccounts );
$account_found = "NULL";
for( $i = 0; $i < count( $keys ); $i++ ) {
if( in_array( $domain, $viewaccounts[$keys[$i]] ) ) {

$error = 'Error : That domain name is already taken, please choose another.';
include 'adjust.php';
include 'order.php';
die();
break;}}

if ($syn == YES) {

$withsub = "$domain.$sub";

$viewaccounts = listaccts( $host , $user , $accesshash , 0);
$keys = array_keys( $viewaccounts );
$account_found = "NULL";
for( $i = 0; $i < count( $keys ); $i++ ) {
if( in_array( $withsub, $viewaccounts[$keys[$i]] ) ) {

$error = 'Error : That subdomain is already taken, please choose another.';
include 'adjust.php';
include 'order.php';
die();
break;}}
}else{}
//----- (!)

$newUser="$un";

if( array_key_exists($newUser, $viewaccounts) )
{
$error = 'Error : That username is already taken, please choose another.';
include 'adjust.php';
include 'order.php';
die();
}

?>
