View Single Post
  #1  
Old 3rd December 2011, 09:33
vaio1 vaio1 is offline
Senior Member
 
Join Date: Jul 2007
Location: Italy
Posts: 664
Thanks: 77
Thanked 12 Times in 7 Posts
Default SOLVED: How-to create a website: sites_web_domain_add

Hi guys,

after a searching on the forum I have solved the creation of the website domain in this way:

At the moment I have created this function and this works!

IspConfig needs more documentation. The class declaration are not sufficient.

Code:
	/**
	 * Create a new website
	 * 
	 * Executes the creation of new website in the IspConfig control panel
	 * Note in order to not fail this command, it must meet the following requirements:
	 * 
	 * - The customer must be registered in the db.
	 * - The parameters must be saved in the service detail (orderitems table)
	 * 
	 * @param      array      $task     Must be a valid task 
	 * @return     mixed       True, or throw an Exception if failed.
	 * @access     public
	 */
	public function create_website(array $task) {
		// Connection to the SOAP system
		$client = $this->Connect ();
		
		// Get all the customer information
		$customer = Customers::getAllInfo ( $task ['customer_id'] );
		
		// Get the custom ISPConfig attribute set in the customer control panel 
		if (!empty($customer ['CustomersAttributesValues'] [0] ['CustomersAttributes'] ['var']) && $customer ['CustomersAttributesValues'] [0] ['CustomersAttributes'] ['var'] == "client_id" && ! empty ( $customer ['CustomersAttributesValues'] [0] ['value'] ) && is_numeric ( $customer ['CustomersAttributesValues'] [0] ['value'] )) {
			$clientId = $customer ['CustomersAttributesValues'] [0] ['value']; // External ISPConfig ClientID
			$record = $client->client_get ( $this->getSession (), $clientId );
			if ($record == false) {
				$clientId = self::create_client($task);
				$client = $this->Connect (); 	// Open again the Connection to the SOAP system previously closed
			}
			
			// Get the service details
			$service = OrdersItems::getAllInfo($task['orderitem_id']);
			
			if(!empty($service)){
				// Get the Json encoded parameters in the task
				$parameters = json_decode ( $task ['parameters'], true );
	
				// Get the domain
				if(!empty($service['Orders']['OrdersItemsDomains'][0]['Domains'])){
					$domain = $service['Orders']['OrdersItemsDomains'][0]['Domains']['domain'] . "." . $service['Orders']['OrdersItemsDomains'][0]['Domains']['tld'];
	
					$params = array(
							'server_id' => 1,
							'ip_address' => '',
							'domain' => $domain,
							'type' => 'vhost',
							'parent_domain_id' => 0,
							'vhost_type' => 'name',
							'hd_quota' => $parameters['webspace'],
							'traffic_quota' => $parameters['bandwidth'],
							'cgi' => 'y',
							'ssi' => 'y',
							'suexec' => 'y',
							'errordocs' => 1,
							'is_subdomainwww' => 1,
							'subdomain' => '',
							'php' => 'y',
							'ruby' => 'n',
							'redirect_type' => '',
							'redirect_path' => '',
							'ssl' => 'n',
							'ssl_state' => '',
							'ssl_locality' => '',
							'ssl_organisation' => '',
							'ssl_organisation_unit' => '',
							'ssl_country' => '',
							'ssl_domain' => '',
							'ssl_request' => '',
							'ssl_cert' => '',
							'ssl_bundle' => '',
							'ssl_action' => '',
							'stats_password' => '',
							'stats_type' => 'webalizer',
							'backup_interval' => '',
							'backup_copies' => 1,
							'active' => 'y',
							'traffic_quota_lock' => 'n',
	                        'system_user' =>'web1', 
	                        'allow_override' =>'All', 
	                        'custom_php_ini' =>'',  
	                        'apache_directives' => ''
						);
					
				}
				
				$websiteId = $client->sites_web_domain_add($this->getSession(), $clientId, $params, $readonly = false);
			}
		}
		// Logout from the IspConfig Remote System
		$client->logout($this->getSession ());
		
		return $websiteId;
		
	}

Last edited by vaio1; 3rd December 2011 at 12:43. Reason: solved
Reply With Quote
Sponsored Links