Example #1
0
 //if(substr($web_folder, -1, 1) === '/') $web_folder = substr($web_folder, 0, -1);
 $params = array('server_id' => $server_id, 'ip_address' => '*', 'domain' => $entry['name'], 'web_folder' => $web_folder, 'type' => 'vhostsubdomain', 'parent_domain_id' => $domain_ids[$entry['parentDomainId']], 'vhost_type' => 'name', 'hd_quota' => byte_to_mbyte(get_limit($limits, $entry['dom_id'], 'disk_space', -1)), 'traffic_quota' => byte_to_mbyte(get_limit($limits, $entry['dom_id'], 'max_traffic', -1)), 'cgi' => yes_no(get_option($hosting, 'cgi', 'false') === 'true' ? 1 : 0), 'ssi' => yes_no(get_option($hosting, 'ssi', 'false') === 'true' ? 1 : 0), 'suexec' => yes_no(1), 'errordocs' => get_option($options, 'apacheErrorDocs', 'false') === 'true' ? 1 : 0, 'subdomain' => '', 'ssl' => yes_no(get_option($hosting, 'ssl', 'false') === 'true' ? 1 : 0), 'php' => $phpmode, 'fastcgi_php_version' => '', 'ruby' => yes_no(0), 'python' => yes_no(get_option($hosting, 'python', 'false') === 'true' ? 1 : 0), 'active' => yes_no($entry['status'] == 0 && get_option($hosting, 'maintenance_mode', 'false') !== 'true' ? 1 : 0), 'redirect_type' => $redir_type, 'redirect_path' => $redir_path, 'seo_redirect' => '', 'ssl_state' => $entry[''], 'ssl_locality' => $entry[''], 'ssl_organisation' => $entry[''], 'ssl_organisation_unit' => $entry[''], 'ssl_country' => $entry[''], 'ssl_domain' => $entry[''], 'ssl_request' => $entry[''], 'ssl_cert' => $entry[''], 'ssl_bundle' => $entry[''], 'ssl_action' => $entry[''], 'stats_password' => '', 'stats_type' => get_option($hosting, 'webstat', 'webalizer') === 'awstats' ? 'awstats' : 'webalizer', 'backup_interval' => 'none', 'backup_copies' => 1, 'allow_override' => 'All', 'pm_process_idle_timeout' => 10, 'pm_max_requests' => 0);
 $old_domain = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain = '" . $entry['name'] . "'");
 if (!$old_domain) {
     $old_domain = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE CONCAT(subdomain, '.', domain) = '" . $entry['name'] . "'");
 }
 if ($old_domain) {
     $new_id = $old_domain['domain_id'];
     $params = array_merge($old_domain, $params);
     $msg .= "Found domain " . $entry['name'] . " with id " . $new_id . ", updating it.<br />";
     $ok = $importer->sites_web_vhost_subdomain_update($session_id, $plesk_ispc_ids[$parent_domain['cl_id']], $new_id, $params);
     if ($ok === false) {
         $msg .= "&nbsp; Error: " . $importer->getFault() . "<br />";
     }
 } else {
     $new_id = $importer->sites_web_vhost_subdomain_add($session_id, $plesk_ispc_ids[$parent_domain['cl_id']], $params, true);
     // read only...
 }
 $subdomain_ids[$entry['id']] = $new_id;
 $subdomain_roots[$entry['id']] = $hosting['www_root'];
 $subdomain_owners[$entry['id']] = $entry['cl_id'];
 if ($new_id === false) {
     //something went wrong here...
     $msg .= "Subdomain " . $entry['id'] . " (" . $entry['name'] . ") with folder \"" . $web_folder . "\" could not be inserted.<br />";
     $msg .= "&nbsp; Error: " . $importer->getFault() . "<br />";
 } else {
     $msg .= "Subdomain " . $entry['id'] . " (" . $entry['name'] . ") inserted.<br />";
     $cmd_data = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = '" . $new_id . "'");
     $path = $cmd_data['document_root'];
     add_command('chattr -i ' . escapeshellarg($path));
     add_command('if [[ -f ' . $path . '/' . $web_folder . '/index.html ]] ; then rm ' . $path . '/' . $web_folder . '/index.html ; fi');