static function ExecuteAddDomain($uid, $domain, $destination, $autohome) { global $zdbh; $retval = FALSE; runtime_hook::Execute('OnBeforeAddDomain'); $currentuser = ctrl_users::GetUserDetail($uid); $domain = strtolower(str_replace(' ', '', $domain)); if (!fs_director::CheckForEmptyValue(self::CheckCreateForErrors($domain))) { //** New Home Directory **// if ($autohome == 1) { $destination = "/" . str_replace(".", "_", $domain); $vhost_path = ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . "/public_html/" . $destination . "/"; fs_director::CreateDirectory($vhost_path); fs_director::SetFileSystemPermissions($vhost_path, 0777); //** Existing Home Directory **// } else { $destination = "/" . $destination; $vhost_path = ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . "/public_html/" . $destination . "/"; } // Error documents:- Error pages are added automatically if they are found in the _errorpages directory // and if they are a valid error code, and saved in the proper format, i.e. <error_number>.html fs_director::CreateDirectory($vhost_path . "/_errorpages/"); $errorpages = ctrl_options::GetSystemOption('static_dir') . "/errorpages/"; if (is_dir($errorpages)) { if ($handle = @opendir($errorpages)) { while (($file = @readdir($handle)) !== false) { if ($file != "." && $file != "..") { $page = explode(".", $file); if (!fs_director::CheckForEmptyValue(self::CheckErrorDocument($page[0]))) { fs_filehandler::CopyFile($errorpages . $file, $vhost_path . '/_errorpages/' . $file); } } } closedir($handle); } } // Lets copy the default welcome page across... if (!file_exists($vhost_path . "/index.html") && !file_exists($vhost_path . "/index.php") && !file_exists($vhost_path . "/index.htm")) { fs_filehandler::CopyFileSafe(ctrl_options::GetSystemOption('static_dir') . "pages/welcome.html", $vhost_path . "/index.html"); } // If all has gone well we need to now create the domain in the database... $sql = $zdbh->prepare("INSERT INTO x_vhosts (vh_acc_fk,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t vh_name_vc,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t vh_directory_vc,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t vh_type_in,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t vh_created_ts) VALUES (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t :userid,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t :domain,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t :destination,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t 1,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t :time)"); //CLEANER FUNCTION ON $domain and $homedirectory_to_use (Think I got it?) $time = time(); $sql->bindParam(':time', $time); $sql->bindParam(':userid', $currentuser['userid']); $sql->bindParam(':domain', $domain); $sql->bindParam(':destination', $destination); $sql->execute(); // Only run if the Server platform is Windows. if (sys_versions::ShowOSPlatformVersion() == 'Windows') { if (ctrl_options::GetSystemOption('disable_hostsen') == 'false') { // Lets add the hostname to the HOSTS file so that the server can view the domain immediately... @exec("C:/Sentora/bin/zpss/setroute.exe " . $domain . ""); @exec("C:/Sentora/bin/zpss/setroute.exe www." . $domain . ""); } } self::SetWriteApacheConfigTrue(); $retval = TRUE; runtime_hook::Execute('OnAfterAddDomain'); return $retval; } }