Ejemplo n.º 1
0
 function p_new()
 {
     # get the common server class and set login details
     include_once PATH_MODULES . 'host_server/host_server.inc.php';
     $host = new host_server();
     if (empty($this->service['host_username'])) {
         # set the limits
         $pass_len = 8;
         $user_len = 8;
         # Generate a new username/login:
         $domain = $this->service['domain_name'] . $this->service['domain_tld'];
         # set the username
         $username = trim($domain);
         $username = eregi_replace("[-_\\.]", "", $username);
         if (strlen($username) < $user_len) {
             $rand = md5(md5($username) . time());
             $diff = $user_len - strlen($username);
             $username = $username . substr($rand, 0, $diff);
         } else {
             $rand = md5(microtime() . md5($username) . microtime());
             $username = substr($username, 0, $user_len - 5);
             $username = $username . substr($rand, 0, 5);
         }
         # Set the password
         $password = substr(md5(md5(time()) . $domain . $username), 0, $pass_len);
         # Set the user/pass
         $this->login['username'] = strtolower($username);
         $this->login['password'] = $password;
     } else {
         # Validate
         $this->login['username'] = strtolower($this->service['host_username']);
         $this->login['password'] = $this->service['host_password'];
     }
     $result = createacct($this->server_cfg['host'], $this->server_cfg['account'], $this->server_cfg['accesshash'], $this->usessl, $this->service['domain_name'] . "." . $this->service['domain_tld'], $this->login['username'], $this->login['password'], $this->plugin_data['plan']);
     if ($this->server['debug']) {
         echo "<pre> {$result} </pre>";
     }
     if (!eregi("Account Creation Complete", @$result)) {
         return false;
     } else {
         $db =& DB();
         $id = $this->service_id;
         $sql = "SELECT * FROM " . AGILE_DB_PREFIX . "service WHERE id = {$id}";
         $rs = $db->Execute($sql);
         $plugin_data = unserialize($rs->fields['host_provision_plugin_data']);
         $insert = array('host_provision_plugin_data' => serialize($plugin_data), 'host_username' => $this->login['username'], 'host_password' => $this->login['password']);
         $sql = $db->GetUpdateSQL($rs, $insert);
         $result = $db->Execute($sql);
         if ($result === false) {
             global $C_debug;
             $C_debug->error('WHM.php', 'p_new()', $db->ErrorMsg() . "\r\n\r\n" . $sql);
         }
         # send the user the details
         include_once PATH_MODULES . 'email_template/email_template.inc.php';
         $email = new email_template();
         $email->send('host_new_user', $this->account['id'], $this->service_id, '', '');
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * Create an Account
  */
 public function createAccount(ServerDBO $serverDBO, HostingServiceDBO $serviceDBO, $domainName, $username, $password)
 {
     $CPServerDBO = $this->getCPanelServerDBO($serverDBO);
     $result = createacct($serverDBO->getHostName(), $CPServerDBO->getUsername(), $CPServerDBO->getAccessHash(), false, $domainName, $username, $password, $serviceDBO->getTitle());
     if (null == stristr($result, "wwwacct creation finished")) {
         throw new SWUserException("[CPANEL_FAILED_TO_CREATE_ACCOUNT]: " . $result);
     }
 }