set_file("trial","block_hosting_trial.html");
$t->set_var("hosting_trial_href", $hosting_trial_page);
if ($operation != "" && $operation != "add") {
header("Location: /");
exit;
}
$errors = false;
if ($operation == "") {
$t->set_var("layout1_checked","checked");
$t->parse("add_account_form",false);
}
if ($operation == "add") {
$errors = false;
$connection_errors = false;
$account_exists = false;
$err_text = "";
if (get_param("username") == "") {
$errors = true;
$err_text .= str_replace("", LOGIN_FIELD, REQUIRED_MESSAGE) . "
";
}
if (get_param("email") == "") {
$errors = true;
$err_text .= str_replace("", EMAIL_FIELD, REQUIRED_MESSAGE) . "
";
} else if (!preg_match(EMAIL_REGEXP, get_param("email"))) {
$errors = true;
$err_text .= str_replace("", EMAIL_FIELD, INCORRECT_EMAIL_MESSAGE) . "
";
}
if (!$validation_number) {
$errors = true;
$err_text .= str_replace("", VALIDATION_CODE_FIELD, REQUIRED_MESSAGE) . "
";
} else {
$validated_number = check_image_validation($validation_number);
if (!$validated_number) {
$errors = true;
$validation_class = "error";
$err_text .= str_replace("", VALIDATION_CODE_FIELD, VALIDATION_MESSAGE) . "
";
} else if ($errors) {
// saved validated number for following submits
set_session("session_validation_number", $validated_number);
}
}
if (!$errors) {
// Database Initialize
$dbh = new VA_SQL();
$dbh->DBType = "mysql";
$dbh->DBDatabase = "ftpdb";
$dbh->DBHost = "trial.viart.com";
$dbh->DBPort = "3333";
$dbh->DBUser = "freehosting";
$dbh->DBPassword = "xthdb17";
$dbh->DBPersistent= false;
$dbh->HaltOnError = "no";
// check db connection and email to be unique
if ($dbh->db_connect()) {
$sql = " SELECT COUNT(*) FROM http_users_data WHERE contact_email=". $dbh->tosql($email, TEXT);
$dbh->query($sql);
$dbh->next_record($sql);
$email_count = $dbh->f(0);
if ($email_count > 0) {
$errors = true;
$err_text .= "Unfortunately, your email address is already in our database, as a contact email for another account.
";
$err_text .= "Please, remove your old account(s) if you wish to open a new one.
";
}
} else {
$errors = true;
$t->parse("errors_connect_to_hosting",false);
/*
if (strlen($dbh->Error)) {
$err_text = $dbh->Error . "
";
} else {
$err_text = DB_CONNECT_ERROR . "
";
}//*/
}
}
if (!$errors) {
// if there are no errors we can start creating account
//$dbh->HaltOnError = "yes";
$sql = "SELECT hostname,db_name,mysql_password FROM http_users_data WHERE commercial='T' AND status='C' LIMIT 1 ";
$dbh->query($sql);
if (!$dbh->next_record($sql)) {
$errors = true;
$t->parse("errors_connect_to_hosting",false);
} else {
$hostname = $dbh->f("hostname");
$shopurl = "http://trial.viart.com/~" . $dbh->f("hostname") . "/";
$ftphost = "trial.viart.com";
$ftpuser = $dbh->f("hostname");
$ftppass = $dbh->f("mysql_password");
$admurl = "http://trial.viart.com/~" . $dbh->f("hostname") . "/admin/";
$admlogin = $dbh->f("hostname");
$admpass = $dbh->f("mysql_password");
if (!($connection_user = @mysql_connect("trial.viart.com:3333", $ftpuser, $ftppass))) {
$errors = true;
$t->parse("errors_connect_to_hosting",false);
} else {
if (!(mysql_select_db("va_trial_" . $ftpuser))) {
$errors = true;
$t->parse("errors_connect_to_hosting",false);
} else {
$sql = "UPDATE va_global_settings SET setting_value=".(get_param("layout"))." WHERE setting_type='global' AND setting_name='layout_id'";
if (!(mysql_query($sql,$connection_user))) {
$errors = true;
$t->parse("errors_connect_to_hosting",false);
} else {
$sql = "UPDATE http_users_data SET webmaster_email=".$dbh->tosql($email, TEXT).", ";
$sql .= "contact_email=".$dbh->tosql($email, TEXT).", firstname=".$dbh->tosql($username, TEXT).", ";
$sql .= "status='W', added=NOW(), expires=NOW() + INTERVAL 30 DAY WHERE hostname=" . $dbh->tosql($hostname, TEXT);
if (!$dbh->query($sql)) {
$errors = true;
$t->parse("errors_connect_to_hosting",false);
} else {
$sql = "INSERT INTO licenses_needed VALUES ('$ftpuser',NOW()+INTERVAL 30 DAY, 'T', 'E')";
if (!$dbh->query($sql)) {
$errors = true;
$t->parse("errors_connect_to_hosting",false);
} else {
$subject = "Trial ViArt-Hosting Activation Letter";
$headers = "From: support@viart.com\nContent-Type: text/html";
$t->set_file("trial_email","email_hosting.html");
$t->set_var("shopurl",$shopurl);
$t->set_var("admurl", $admurl);
$t->set_var("admlogin", $admlogin);
$t->set_var("admpass", $admpass);
$t->parse("trial_email", false);
$body = $t->get_var("trial_email");
mail(get_param("email"),$subject,$body,$headers);
$t->set_var("website","http://trial.viart.com/~$ftpuser/");
$t->set_var("admins","http://trial.viart.com/~$ftpuser/admin/");
$t->parse("activation_success",false);
}
}
}
}
}
}
} // new account creation end
}
if ($errors) {
$t->set_var("errors_text",$err_text);
$t->parse("form_errors",false);
$t->set_var("username",htmlspecialchars($username));
$t->set_var("email",htmlspecialchars($email));
$t->set_var("validation_number",htmlspecialchars($validated_number));
$t->set_var("layout".(get_param("layout"))."_checked","checked");
$t->parse("add_account_form",false);
}
$t->parse("trial");
$block_body = $t->get_var("trial");
?>