Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Developers' Forum

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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
 

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ownership of website backups lucani Developers' Forum 0 17th November 2010 17:10
chroot_ssh_sftp_debian_etch jon HOWTO-Related Questions 0 24th August 2008 00:40
Can't Create a User Account for a new Website city Installation/Configuration 6 22nd October 2005 15:17


All times are GMT +2. The time now is 10:26.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.