Esempio n. 1
0
 /**
  * Get the setup configuration
  * 
  * 
  * @return ArrayObject
  */
 public static function getSetup($id)
 {
     $setup = "";
     $services = array();
     $panel = Isp::getPanel();
     $records = Doctrine_Query::create()->from('OrdersItems oi')->leftJoin('oi.Products p')->where('oi.detail_id = ?', $id)->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
     foreach ($records as $record) {
         if (!empty($record['Products']['setup'])) {
             $setup = $record['Products']['setup'];
             // Get the parameters set in the order details (service)
             $params = json_decode($record['parameters'], true);
             if (is_array($params)) {
                 // Get the list of all the domains
                 $domains = OrdersItemsDomains::get_domains($record['detail_id']);
                 // We have to get the first domain
                 if (!empty($domains[0]['domain'])) {
                     $params['domain'] = $domains[0]['domain'];
                     // Get all the var {string} in the xml setup
                     preg_match_all('/{([^}]+)}/Ui', $setup, $matches);
                     foreach ($matches[1] as $parameter) {
                         $setup = str_replace("{" . $parameter . "}", $params[$parameter], $setup);
                     }
                 }
             }
         }
     }
     $xml = simplexml_load_string($setup);
     $arrSetup = Shineisp_Commons_Utilities::simpleXMLToArray($xml);
     return $arrSetup;
 }
Esempio n. 2
0
 /**
  * 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)
 {
     $params = array();
     try {
         $server = self::getServer($task['orderitem_id'], 'web');
         // Get the server id
         if (!empty($server['server_id']) && is_numeric($server['server_id'])) {
             $clientId = self::get_client_id($task, $server['server_id']);
             // Connection to the SOAP system
             $client = $this->connect($server['server_id']);
             // Get the remote server ID set in the servers profile in ShineISP
             $customAttribute = CustomAttributes::getAttribute($server['server_id'], "remote_server_id");
             // Get the remote server id set in ShineISP
             if (is_numeric($customAttribute['value'])) {
                 $ServerId = $customAttribute['value'];
                 // Get the Json encoded parameters in the task
                 $parameters = json_decode($task['parameters'], true);
                 // Get the domain
                 $domains = OrdersItemsDomains::get_domains($task['orderitem_id']);
                 if (!empty($domains[0]['domain'])) {
                     $params = array('server_id' => $ServerId, 'ip_address' => '*', 'domain' => $domains[0]['domain'], 'type' => 'vhost', 'parent_domain_id' => 0, 'vhost_type' => 'name', 'hd_quota' => $parameters['webspace'], 'traffic_quota' => $parameters['trafficdata'], 'cgi' => 'n', 'ssi' => 'n', 'suexec' => 'y', 'errordocs' => 1, 'is_subdomainwww' => 1, 'subdomain' => 'www', 'php' => 'fast-cgi', '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', 'allow_override' => 'All', 'apache_directives' => '', 'php_open_basedir' => '/', 'custom_php_ini' => '', 'backup_interval' => '', 'backup_copies' => 1, 'active' => 'y', 'traffic_quota_lock' => 'n', 'pm_process_idle_timeout' => '10', 'pm_max_requests' => '0');
                     try {
                         $websiteId = $client->sites_web_domain_add($this->getSession(), $clientId, $params, $readonly = false);
                         if (!is_numeric($websiteId)) {
                             throw new Exception("There was a problem with website creation: sites_web_domain_add doesn't return the websiteID identifier", "3505");
                         }
                     } catch (SoapFault $e) {
                         throw new Exception("There was a problem with " . $domains[0]['domain'] . " website creation: " . $e->getMessage() . " - Parameters: " . json_encode($params), "3504");
                     }
                     // Add relation between order_item and server
                     OrdersItemsServers::addServer($task['orderitem_id'], $server['server_id']);
                     // Create the log message
                     Shineisp_Commons_Utilities::logs("ID: " . $task['action_id'] . " - " . __METHOD__ . " - Parameters: " . json_encode($params), "ispconfig.log");
                 } else {
                     throw new Exception("No domain set for the selected service in the ShineISP service order detail ID #: " . $task['orderitem_id'], "3503");
                 }
             } else {
                 throw new Exception("No remote web server id set in the ShineISP server profile.", "3502");
             }
         } else {
             throw new Exception("Web Server has not been found in IspConfig server settings.", "3501");
         }
         // Logout from the IspConfig Remote System
         $client->logout($this->getSession());
         return $websiteId;
     } catch (Exception $e) {
         Shineisp_Commons_Utilities::logs(__METHOD__ . ": " . $e->getMessage());
     }
 }