function VdsManager4_Create($Settings, $VPSOrder, $IP, $VPSScheme) { /****************************************************************************/ $__args_types = array('array', 'array', 'string', 'array'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $authinfo = SPrintF('%s:%s', $Settings['Login'], $Settings['Password']); #----------------------------------------------------------------------------- $HTTP = array('Address' => $Settings['Params']['IP'], 'Port' => $Settings['Port'], 'Host' => $Settings['Address'], 'Protocol' => $Settings['Protocol'], 'Hidden' => $authinfo, 'IsLogging' => $Settings['Params']['IsLogging']); #----------------------------------------------------------------------------- $IsReselling = FALSE; #----------------------------------------------------------------------------- $IDNA = new Net_IDNA_php5(); $Domain = $IDNA->encode($VPSOrder['Domain']); #----------------------------------------------------------------------------- $Request = array('authinfo' => $authinfo, 'out' => 'xml', 'func' => $IsReselling ? 'user.edit' : 'vds.edit', 'sok' => 'yes', 'id' => 'auto', 'name' => $IsReselling ? $VPSOrder['Login'] : $VPSOrder['Domain'], 'passwd' => $VPSOrder['Password'], 'confirm' => $VPSOrder['Password'], 'ip' => 'auto', 'vdspreset' => $VPSScheme['PackageID'], 'disk' => $VPSScheme['disklimit'], 'ncpu' => $VPSScheme['ncpu'], 'cpu' => ceil($VPSScheme['cpu']), 'mem' => ceil($VPSScheme['mem']), 'bmem' => ceil($VPSScheme['bmem']), $IsReselling ? 'maxswap' : 'swap' => ceil($VPSScheme['maxswap']), 'traf' => $VPSScheme['traf'], 'chrate' => SPrintF('%u', $VPSScheme['chrate'] * 1024), 'desc' => $VPSScheme['maxdesc'], 'proc' => $VPSScheme['proc'], 'ipcount' => $VPSScheme['ipalias'], 'disktempl' => $VPSOrder['DiskTemplate'], 'extns' => $VPSScheme['extns'], 'limitpvtdns' => $VPSScheme['limitpvtdns'], 'limitpubdns' => $VPSScheme['limitpubdns'], 'backup' => $VPSScheme['backup']); if (!$IsReselling) { $Request['owner'] = $Settings['Login']; # Владелец } else { $Request['userlimit'] = $VPSScheme['QuotaUsers']; # Пользователи } $Response = HTTP_Send('/manager/vdsmgr', $HTTP, array(), $Request); if (Is_Error($Response)) { return ERROR | @Trigger_Error('[VdsManager4_Create]: не удалось соедениться с сервером'); } $Response = Trim($Response['Body']); $XML = String_XML_Parse($Response); if (Is_Exception($XML)) { return new gException('WRONG_SERVER_ANSWER', $Response, $XML); } #----------------------------------------------------------------------------- $XML = $XML->ToArray(); #----------------------------------------------------------------------------- $Doc = $XML['doc']; #----------------------------------------------------------------------------- if (isset($Doc['error'])) { return new gException('ACCOUNT_CREATE_ERROR', 'Не удалось создать заказ виртуального сервера'); } #----------------------------------------------------------------------------- Debug(SPrintF('[system/libs/VdsManager4]: VPS order created with IP = %s', $Doc['ip'])); #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- return array('ID' => $VPSOrder['ID'], 'IP' => $Doc['ip']); #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- }
function DirectAdmin_Create($Settings, $Login, $Password, $Domain, $IP, $HostingScheme, $Email, $PersonID = 'Default', $Person = array()) { /****************************************************************************/ $__args_types = array('array', 'string', 'string', 'string', 'string', 'array', 'string', 'string', 'array'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $HTTP = array('Address' => $Settings['IP'], 'Port' => $Settings['Port'], 'Host' => $Settings['Address'], 'Protocol' => $Settings['Protocol'], 'Basic' => SPrintF('%s:%s', $Settings['Login'], $Settings['Password']), 'IsLogging' => $Settings['Params']['IsLogging']); #----------------------------------------------------------------------------- $IsReselling = $HostingScheme['IsReselling']; #----------------------------------------------------------------------------- $IDNA = new Net_IDNA_php5(); $Domain = $IDNA->encode($Domain); #----------------------------------------------------------------------------- $Request = array('action' => 'create', 'add' => 'Submit', 'username' => $Login, 'passwd' => $Password, 'passwd2' => $Password, 'domain' => $Domain, 'ip' => $IP, 'notify' => 'NO', 'email' => $Email); #----------------------------------------------------------------------------- $PackageID = $HostingScheme['PackageID']; #----------------------------------------------------------------------------- if ($PackageID) { $Request['package'] = $PackageID; } else { #--------------------------------------------------------------------------- $Adding = array('bandwidth' => $HostingScheme['QuotaTraffic'], 'ubandwidth' => $HostingScheme['QuotaTraffic'] != -1 ? 'OFF' : 'ON', 'quota' => $HostingScheme['QuotaDisk'], 'uquota' => $HostingScheme['QuotaDisk'] != -1 ? 'OFF' : 'ON', 'vdomains' => $HostingScheme['QuotaDomains'], 'uvdomains' => $HostingScheme['QuotaDomains'] != -1 ? 'OFF' : 'ON', 'nsubdomains' => $HostingScheme['QuotaSubDomains'], 'unsubdomains' => $HostingScheme['QuotaSubDomains'] != -1 ? 'OFF' : 'ON', 'nemails' => $HostingScheme['QuotaEmail'], 'unemails' => $HostingScheme['QuotaEmail'] != -1 ? 'OFF' : 'ON', 'nemailf' => $HostingScheme['QuotaEmailForwards'], 'unemailf' => $HostingScheme['QuotaEmailForwards'] != -1 ? 'OFF' : 'ON', 'nemailml' => $HostingScheme['QuotaEmailLists'], 'unemailml' => $HostingScheme['QuotaEmailLists'] != -1 ? 'OFF' : 'ON', 'nemailr' => $HostingScheme['QuotaEmailAutoResp'], 'unemailr' => $HostingScheme['QuotaEmailAutoResp'] != -1 ? 'OFF' : 'ON', 'mysql' => $HostingScheme['QuotaDBs'], 'umysql' => $HostingScheme['QuotaDBs'] != -1 ? 'OFF' : 'ON', 'domainptr' => $HostingScheme['QuotaParkDomains'], 'udomainptr' => $HostingScheme['QuotaParkDomains'] != -1 ? 'OFF' : 'ON', 'ftp' => $HostingScheme['QuotaFTP'], 'uftp' => $HostingScheme['QuotaFTP'] != -1 ? 'OFF' : 'ON', 'aftp' => $HostingScheme['IsAnonimousFTP'] ? 'ON' : 'OFF', 'ssh' => $HostingScheme['IsShellAccess'] ? 'ON' : 'OFF', 'ssl' => $HostingScheme['IsSSLAccess'] ? 'ON' : 'OFF', 'cgi' => $HostingScheme['IsCGIAccess'] ? 'ON' : 'OFF', 'php' => $HostingScheme['IsPHPAccess'] ? 'ON' : 'OFF', 'spamd' => $HostingScheme['IsSpamAssasing'] ? 'ON' : 'OFF', 'catchall' => $HostingScheme['IsCatchAll'] ? 'ON' : 'OFF', 'sysinfo' => $HostingScheme['IsSystemInfo'] ? 'ON' : 'OFF', 'dnscontrol' => $HostingScheme['IsDnsControll'] ? 'ON' : 'OFF'); #--------------------------------------------------------------------------- Array_Union($Request, $Adding); } #----------------------------------------------------------------------------- $Response = HTTP_Send($IsReselling ? '/CMD_API_ACCOUNT_RESELLER' : '/CMD_API_ACCOUNT_USER', $HTTP, $Request); if (Is_Error($Response)) { return ERROR | @Trigger_Error('[DirectAdmin_Create]: не удалось осуществить запрос'); } #----------------------------------------------------------------------------- $Result = Trim($Response['Body']); #----------------------------------------------------------------------------- if (Preg_Match('/User\\screated\\ssuccessfully/', $Result)) { return TRUE; } #----------------------------------------------------------------------------- return new gException('WRONG_ANSWER', $Result); }
function Cpanel_Create($Settings, $Login, $Password, $Domain, $IP, $HostingScheme, $Email, $PersonID = 'Default', $Person = array()) { /****************************************************************************/ $__args_types = array('array', 'string', 'string', 'string', 'string', 'array', 'string', 'string', 'array'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $HTTP = array('Address' => $Settings['Params']['IP'], 'Port' => $Settings['Port'], 'Host' => $Settings['Address'], 'Protocol' => $Settings['Protocol'], 'Basic' => SPrintF('%s:%s', $Settings['Login'], $Settings['Password']), 'IsLogging' => $Settings['Params']['IsLogging']); #----------------------------------------------------------------------------- $IDNA = new Net_IDNA_php5(); $Domain = $IDNA->encode($Domain); #----------------------------------------------------------------------------- $Request = array('nohtml' => 'y', 'contactemail' => $Email, 'username' => $Login, 'domain' => $Domain, 'password' => $Password, 'plan' => $HostingScheme['PackageID'], 'quota' => $HostingScheme['QuotaDisk'], 'maxsub' => $HostingScheme['QuotaSubDomains'], 'maxpark' => $HostingScheme['QuotaParkDomains'], 'maxaddon' => $HostingScheme['QuotaAddonDomains'], 'maxpop' => $HostingScheme['QuotaEmail'], 'maxsql' => $HostingScheme['QuotaDBs'], 'maxlst' => $HostingScheme['QuotaEmailLists'], 'maxftp' => $HostingScheme['QuotaFTP'], 'bwlimit' => $HostingScheme['QuotaTraffic'], 'cpmod' => $Settings['Theme'], 'customip' => $IP); #----------------------------------------------------------------------------- if ($HostingScheme['IsShellAccess']) { $Request['hasshell'] = 'yes'; } #----------------------------------------------------------------------------- if ($HostingScheme['IsCGIAccess']) { $Request['cgi'] = 'yes'; } #----------------------------------------------------------------------------- $Response = HTTP_Send('/scripts/wwwacct', $HTTP, $Request); if (Is_Error($Response)) { return ERROR | @Trigger_Error('[Cpanel_Create]: не удалось осуществить запрос'); } #----------------------------------------------------------------------------- $Response = Strip_Tags(Trim($Response['Body'])); #----------------------------------------------------------------------------- if (Preg_Match('/Creation\\sComplete/', $Response)) { return TRUE; } #----------------------------------------------------------------------------- return new gException('WRONG_ANSWER', $Response); }
function Plesk_Create($Settings, $Login, $Password, $Domain, $IP, $HostingScheme, $Email, $PersonID = 'Default', $Person = array()) { /****************************************************************************/ $__args_types = array('array', 'string', 'string', 'string', 'string', 'array', 'string', 'string', 'array'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $gen_info = new Tag('gen_info'); #----------------------------------------------------------------------------- switch ($PersonID) { case 'Default': #------------------------------------------------------------------------- $gen_info->AddChild(new Tag('cname', 'не указано')); $gen_info->AddChild(new Tag('pname', SPrintF('не указано (%s)', $Login))); $gen_info->AddChild(new Tag('country', 'RU')); $gen_info->AddChild(new Tag('state', 'не указано')); $gen_info->AddChild(new Tag('city', 'не указано')); $gen_info->AddChild(new Tag('address', 'не указано')); $gen_info->AddChild(new Tag('phone')); $gen_info->AddChild(new Tag('fax')); $gen_info->AddChild(new Tag('email')); break; case 'Natural': #------------------------------------------------------------------------- $gen_info->AddChild(new Tag('cname', 'не указано')); $gen_info->AddChild(new Tag('pname', SPrintF('%s %s (%s)', $Person['Sourname'], $Person['Name'], $Login))); $gen_info->AddChild(new Tag('country', $Person['pCountry'])); $gen_info->AddChild(new Tag('state', $Person['pState'])); $gen_info->AddChild(new Tag('city', $Person['pCity'])); $gen_info->AddChild(new Tag('address', $Person['pCity'])); $gen_info->AddChild(new Tag('phone', $Person['Phone'])); $gen_info->AddChild(new Tag('fax', $Person['Phone'])); $gen_info->AddChild(new Tag('email', $Person['Email'])); break; case 'Juridical': #------------------------------------------------------------------------- $gen_info->AddChild(new Tag('cname', SPrintF('%s "%s" (%s)', $Person['CompanyFormFull'], $Person['CompanyName'], $Login))); $gen_info->AddChild($Person['dSourname'] && $Person['dSourname'] && $Person['dLastname'] ? new Tag('pname', SPrintF('%s %s %s', $Person['dSourname'], $Person['dName'], $Person['dLastname'])) : new Tag('pname', SPrintF('не указано (%s)', $Login))); $gen_info->AddChild(new Tag('country', $Person['jCountry'])); $gen_info->AddChild(new Tag('state', $Person['jState'])); $gen_info->AddChild(new Tag('city', $Person['jCity'])); $gen_info->AddChild(new Tag('address', $Person['jCity'])); $gen_info->AddChild(new Tag('phone', $Person['Phone'])); $gen_info->AddChild(new Tag('fax', $Person['Phone'])); $gen_info->AddChild(new Tag('email', $Person['Email'])); break; case 'Individual': #------------------------------------------------------------------------- $gen_info->AddChild(new Tag('cname', SPrintF('ИП "%s" (%s)', $Person['CompanyName'], $Login))); $gen_info->AddChild($Person['dSourname'] && $Person['dSourname'] && $Person['dLastname'] ? new Tag('pname', SPrintF('%s %s %s', $Person['dSourname'], $Person['dName'], $Person['dLastname'])) : new Tag('pname', 'не указано')); $gen_info->AddChild(new Tag('country', $Person['jCountry'])); $gen_info->AddChild(new Tag('state', $Person['jState'])); $gen_info->AddChild(new Tag('city', $Person['jCity'])); $gen_info->AddChild(new Tag('address', $Person['jCity'])); $gen_info->AddChild(new Tag('phone', $Person['Phone'])); $gen_info->AddChild(new Tag('fax', $Person['Phone'])); $gen_info->AddChild(new Tag('email', $Person['Email'])); break; default: return ERROR | @Trigger_Error('[Plesk_Create]: тип персоны не определён'); } #----------------------------------------------------------------------------- $gen_info->AddChild(new Tag('login', $Login)); $gen_info->AddChild(new Tag('passwd', $Password)); $gen_info->AddChild(new Tag('status', 0)); $gen_info->AddChild(new Tag('pcode')); #----------------------------------------------------------------------------- $add = new Tag('add', $gen_info); #----------------------------------------------------------------------------- $limits = new Tag('limits'); #----------------------------------------------------------------------------- $QuotaDisk = $HostingScheme['QuotaDisk'] * 1048576; #----------------------------------------------------------------------------- $limits->AddChild(new Tag('limit', new Tag('name', 'disk_space'), new Tag('value', $QuotaDisk > 0 ? $QuotaDisk : -1))); $limits->AddChild(new Tag('limit', new Tag('name', 'max_dom'), new Tag('value', $HostingScheme['QuotaDomains']))); $limits->AddChild(new Tag('limit', new Tag('name', 'max_subdom'), new Tag('value', $HostingScheme['QuotaSubDomains']))); $limits->AddChild(new Tag('limit', new Tag('name', 'max_dom_aliases'), new Tag('value', $HostingScheme['QuotaParkDomains']))); $limits->AddChild(new Tag('limit', new Tag('name', 'max_db'), new Tag('value', $HostingScheme['QuotaDBs']))); $limits->AddChild(new Tag('limit', new Tag('name', 'max_wu'), new Tag('value', $HostingScheme['QuotaWebUsers']))); $limits->AddChild(new Tag('limit', new Tag('name', 'max_mg'), new Tag('value', $HostingScheme['QuotaEmailGroups']))); $limits->AddChild(new Tag('limit', new Tag('name', 'max_maillists'), new Tag('value', $HostingScheme['QuotaEmailLists']))); $limits->AddChild(new Tag('limit', new Tag('name', 'max_resp'), new Tag('value', $HostingScheme['QuotaEmailAutoResp']))); #----------------------------------------------------------------------------- $QuotaEmailBox = $HostingScheme['QuotaEmailBox'] * 1048576; #----------------------------------------------------------------------------- $limits->AddChild(new Tag('limit', new Tag('name', 'mbox_quota'), new Tag('value', $QuotaEmailBox > 0 ? $QuotaEmailBox : -1))); $limits->AddChild(new Tag('limit', new Tag('name', 'max_webapps'), new Tag('value', $HostingScheme['QuotaWebApp']))); $limits->AddChild(new Tag('limit', new Tag('name', 'max_box'), new Tag('value', $HostingScheme['QuotaEmail']))); $limits->AddChild(new Tag('limit', new Tag('name', 'max_redir'), new Tag('value', $HostingScheme['QuotaEmailForwards']))); #----------------------------------------------------------------------------- $QuotaTraffic = $HostingScheme['QuotaTraffic'] * 1048576; #----------------------------------------------------------------------------- $limits->AddChild(new Tag('limit', new Tag('name', 'max_traffic'), new Tag('value', $QuotaTraffic > 0 ? $QuotaTraffic : -1))); #----------------------------------------------------------------------------- $add->AddChild($limits); #----------------------------------------------------------------------------- $permissions = new Tag('permissions'); #----------------------------------------------------------------------------- $permissions->AddChild(new Tag('permission', new Tag('name', 'create_domains'), new Tag('value', $HostingScheme['IsCreateDomains'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'manage_phosting'), new Tag('value', $HostingScheme['IsManageHosting'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'manage_quota'), new Tag('value', $HostingScheme['IsManageQuota'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'manage_subdomains'), new Tag('value', $HostingScheme['IsManageSubdomains'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'change_limits'), new Tag('value', $HostingScheme['IsChangeLimits'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'manage_log'), new Tag('value', $HostingScheme['IsManageLog'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'manage_crontab'), new Tag('value', $HostingScheme['IsManageCrontab'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'manage_anonftp'), new Tag('value', $HostingScheme['IsManageAnonFtp'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'manage_webapps'), new Tag('value', $HostingScheme['IsManageWebapps'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'manage_maillists'), new Tag('value', $HostingScheme['IsManageMaillists'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'manage_drweb'), new Tag('value', $HostingScheme['IsManageDrWeb'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'make_dumps'), new Tag('value', $HostingScheme['IsMakeDumps'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'site_builder'), new Tag('value', $HostingScheme['IsSiteBuilder'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'remote_access_interface'), new Tag('value', $HostingScheme['IsRemoteInterface'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'manage_performance'), new Tag('value', $HostingScheme['IsManagePerformance'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'cp_access'), new Tag('value', $HostingScheme['IsCpAccess'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'manage_domain_aliases'), new Tag('value', $HostingScheme['IsManageDomainAliases'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'manage_iis_app_pool'), new Tag('value', $HostingScheme['IsManageIISAppPool'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'dashboard'), new Tag('value', $HostingScheme['IsDashBoard'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'stdgui'), new Tag('value', $HostingScheme['IsStdGIU'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'manage_dashboard'), new Tag('value', $HostingScheme['IsManageDashboard'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'manage_subftp'), new Tag('value', $HostingScheme['IsManageSubFtp'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'manage_spamfilter'), new Tag('value', $HostingScheme['ISManageSpamFilter'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'allow_local_backups'), new Tag('value', $HostingScheme['IsLocalBackups'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'allow_ftp_backups'), new Tag('value', $HostingScheme['IsFtpBackups'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'manage_dns'), new Tag('value', $HostingScheme['IsDnsControll'] ? 'true' : 'false'))); $permissions->AddChild(new Tag('permission', new Tag('name', 'manage_sh_access'), new Tag('value', $HostingScheme['IsShellAccess'] ? 'true' : 'false'))); #----------------------------------------------------------------------------- $add->AddChild($permissions); #----------------------------------------------------------------------------- $packet = new Tag('packet', array('version' => '1.5.0.0'), new Tag('client', $add)); #----------------------------------------------------------------------------- $Request = SPrintF("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n%s", $packet->ToXMLString()); #----------------------------------------------------------------------------- $Headers = array('Content-Type: text/xml', SPrintF('HTTP_AUTH_LOGIN: %s', $Settings['Login']), SPrintF('HTTP_AUTH_PASSWD: %s', $Settings['Password'])); #----------------------------------------------------------------------------- $HTTP = array('Address' => $Settings['IP'], 'Port' => $Settings['Port'], 'Host' => $Settings['Address'], 'Protocol' => $Settings['Protocol'], 'Hidden' => $Settings['Password'], 'IsLogging' => $Settings['Params']['IsLogging']); #----------------------------------------------------------------------------- $Response = HTTP_Send('/enterprise/control/agent.php', $HTTP, array(), $Request, $Headers); if (Is_Error($Response)) { return ERROR | @Trigger_Error('[Plesk_Create]: не удалось соедениться с сервером'); } #----------------------------------------------------------------------------- $Response = Trim($Response['Body']); #----------------------------------------------------------------------------- $XML = String_XML_Parse($Response); if (Is_Exception($XML)) { return new gException('WRONG_SERVER_ANSWER', $Response, $XML); } #----------------------------------------------------------------------------- $XML = $XML->ToArray(); #----------------------------------------------------------------------------- $Result = $XML['packet']['client']['add']['result']; #----------------------------------------------------------------------------- switch ($Result['status']) { case 'ok': #-------------------------------------------------------------------------- $ClientID = $Result['id']; #-------------------------------------------------------------------------- $ippool_add_ip = new Tag('ippool_add_ip', new Tag('client_id', $ClientID), new Tag('ip_address', $Settings['IP'])); #-------------------------------------------------------------------------- $packet = new Tag('packet', array('version' => '1.4.2.0'), new Tag('client', $ippool_add_ip)); #-------------------------------------------------------------------------- $Request = SPrintF("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n%s", $packet->ToXMLString()); #-------------------------------------------------------------------------- $Response = HTTP_Send('/enterprise/control/agent.php', $HTTP, array(), $Request, $Headers); if (Is_Error($Response)) { return ERROR | @Trigger_Error('[Plesk_Create]: не удалось соедениться с сервером'); } #-------------------------------------------------------------------------- $Response = Trim($Response['Body']); #-------------------------------------------------------------------------- $XML = String_XML_Parse($Response); if (Is_Exception($XML)) { return new gException('WRONG_SERVER_ANSWER', $Response, $XML); } #-------------------------------------------------------------------------- $XML = $XML->ToArray(); #-------------------------------------------------------------------------- $Result = $XML['packet']['client']['ippool_add_ip']['result']; #-------------------------------------------------------------------------- switch ($Result['status']) { case 'ok': #---------------------------------------------------------------------- $IDNA = new Net_IDNA_php5(); $Domain = $IDNA->encode($Domain); #---------------------------------------------------------------------- $gen_setup = new Tag('gen_setup'); $gen_setup->AddChild(new Tag('client_id', $ClientID)); $gen_setup->AddChild(new Tag('name', $Domain)); $gen_setup->AddChild(new Tag('ip_address', $IP)); $gen_setup->AddChild(new Tag('status', 0)); #---------------------------------------------------------------------- $add = new Tag('add', $gen_setup); #---------------------------------------------------------------------- $vrt_hst = new Tag('vrt_hst'); $vrt_hst->AddChild(new Tag('ftp_login', $Login)); $vrt_hst->AddChild(new Tag('ftp_password', $Password)); $vrt_hst->AddChild(new Tag('php', 'true')); $vrt_hst->AddChild(new Tag('ssi', 'true')); $vrt_hst->AddChild(new Tag('cgi', 'true')); $vrt_hst->AddChild(new Tag('php_safe_mode', 'true')); $vrt_hst->AddChild(new Tag('ip_address', $Settings['IP'])); #---------------------------------------------------------------------- $add->AddChild(new Tag('hosting', $vrt_hst)); #---------------------------------------------------------------------- $packet = new Tag('packet', array('version' => '1.4.2.0'), new Tag('domain', $add)); #---------------------------------------------------------------------- $Request = SPrintF("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n%s", $packet->ToXMLString()); #---------------------------------------------------------------------- $Response = HTTP_Send('/enterprise/control/agent.php', $HTTP, array(), $Request, $Headers); if (Is_Error($Response)) { return ERROR | @Trigger_Error('[Plesk_Create]: не удалось соедениться с сервером'); } #---------------------------------------------------------------------- $Response = Trim($Response['Body']); #---------------------------------------------------------------------- $XML = String_XML_Parse($Response); if (Is_Exception($XML)) { return new gException('WRONG_SERVER_ANSWER', $Response, $XML); } #---------------------------------------------------------------------- $XML = $XML->ToArray(); #---------------------------------------------------------------------- $Result = $XML['packet']['domain']['add']['result']; #---------------------------------------------------------------------- switch ($Result['status']) { case 'ok': return TRUE; case 'error': #------------------------------------------------------------------- Debug(SPrintF('[%u]=(%s)', $Result['errcode'], $Result['errtext'])); #------------------------------------------------------------------- return new gException('SERVER_ERROR', Trim($Result['errtext'])); default: return new gException('WRONG_ANSWER', 'Неизвестный ответ'); } case 'error': #----------------------------------------------------------------------- Debug(SPrintF('[%u]=(%s)', $Result['errcode'], $Result['errtext'])); #----------------------------------------------------------------------- return new gException('SERVER_ERROR', Trim($Result['errtext'])); break; default: return new gException('WRONG_ANSWER', 'Неизвестный ответ'); } case 'error': #-------------------------------------------------------------------------- Debug(SPrintF('[%u]=(%s)', $Result['errcode'], $Result['errtext'])); #-------------------------------------------------------------------------- return new gException('SERVER_ERROR', Trim($Result['errtext'])); default: return new gException('WRONG_ANSWER', 'Неизвестный ответ'); } }
/** * Constructor * * @param array $options * @access public * @see setParams() */ public function __construct($options = null) { $this->_slast = $this->_sbase + $this->_lcount * $this->_vcount * $this->_tcount; if (is_array($options)) { $this->setParams($options); } // populate mbstring overloading cache if not set if (self::$_mb_string_overload === null) { self::$_mb_string_overload = extension_loaded('mbstring') && (ini_get('mbstring.func_overload') & 0x2) === 0x2; } }
function IspManager4_Create($Settings, $Login, $Password, $Domain, $IP, $HostingScheme, $Email, $PersonID = 'Default', $Person = array()) { /****************************************************************************/ $__args_types = array('array', 'string', 'string', 'string', 'string', 'array', 'string', 'string', 'array'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $authinfo = SPrintF('%s:%s', $Settings['Login'], $Settings['Password']); #----------------------------------------------------------------------------- $HTTP = IspManager4_Build_HTTP($Settings); #----------------------------------------------------------------------------- $IsReselling = $HostingScheme['IsReselling']; #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # JBS-543, проверяем наличие такого юзера $Request = array('authinfo' => $authinfo, 'func' => $IsReselling ? 'reseller.edit' : 'user.edit', 'out' => 'xml', 'elid' => $Login); #----------------------------------------------------------------------------- $Response = HTTP_Send('/manager/ispmgr', $HTTP, array(), $Request); if (Is_Error($Response)) { return new gException('NOT_CONNECTED_TO_SERVER', 'Не удалось соедениться с сервером'); } #----------------------------------------------------------------------------- $Response = Trim($Response['Body']); $XML = String_XML_Parse($Response); if (Is_Exception($XML)) { return new gException('WRONG_SERVER_ANSWER', $Response, $XML); } #----------------------------------------------------------------------------- $XML = $XML->ToArray(); #----------------------------------------------------------------------------- $Doc = $XML['doc']; #----------------------------------------------------------------------------- if (!isset($Doc['error'])) { return TRUE; } #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- $IDNA = new Net_IDNA_php5(); $Domain = $IDNA->encode($Domain); #----------------------------------------------------------------------------- $Request = array('authinfo' => $authinfo, 'out' => 'xml', 'func' => $IsReselling ? 'reseller.edit' : 'user.edit', 'sok' => 'yes', 'name' => $Login, 'passwd' => $Password, 'confirm' => $Password, 'ip' => $IsReselling ? 'noassign' : $IP, 'preset' => $HostingScheme['PackageID'], 'email' => $Email, 'disklimit' => $HostingScheme['QuotaDisk'], 'ftplimit' => $HostingScheme['QuotaFTP'], 'maillimit' => $HostingScheme['QuotaEmail'], 'domainlimit' => $HostingScheme['QuotaDomains'], 'webdomainlimit' => $HostingScheme['QuotaWWWDomains'], 'maildomainlimit' => $HostingScheme['QuotaEmailDomains'], 'baselimit' => $HostingScheme['QuotaDBs'], 'baseuserlimit' => $HostingScheme['QuotaUsersDBs'], 'bandwidthlimit' => $HostingScheme['QuotaTraffic'], 'shell' => $HostingScheme['IsShellAccess'] ? 'on' : 'off', 'ssl' => $HostingScheme['IsSSLAccess'] ? 'on' : 'off', 'cgi' => $HostingScheme['IsCGIAccess'] ? 'on' : 'off', 'ssi' => $HostingScheme['IsSSIAccess'] ? 'on' : 'off', 'phpmod' => $HostingScheme['IsPHPModAccess'] ? 'on' : 'off', 'phpcgi' => $HostingScheme['IsPHPCGIAccess'] ? 'on' : 'off', 'phpfcgi' => $HostingScheme['IsPHPFastCGIAccess'] ? 'on' : 'off', 'safemode' => $HostingScheme['IsPHPSafeMode'] ? 'on' : 'off', 'cpulimit' => $HostingScheme['MaxExecutionTime'], 'memlimit' => Ceil($HostingScheme['QuotaMEM']), 'proclimit' => $HostingScheme['QuotaPROC'], 'maxclientsvhost' => $HostingScheme['QuotaMPMworkers'], 'mysqlquerieslimit' => $HostingScheme['mysqlquerieslimit'], 'mysqlupdateslimit' => $HostingScheme['mysqlupdateslimit'], 'mysqlconnectlimit' => $HostingScheme['mysqlconnectlimit'], 'mysqluserconnectlimit' => $HostingScheme['mysqluserconnectlimit'], 'mailrate' => $HostingScheme['mailrate']); #------------------------------------------------------------------------------- if ($HostingScheme['QuotaWWWDomains']) { $Request['domain'] = $Domain; } # Домен #------------------------------------------------------------------------------- if (!$IsReselling) { $Request['owner'] = $Settings['Login']; # Владелец } else { $Request['userlimit'] = $HostingScheme['QuotaUsers']; # Пользователи } $Response = HTTP_Send('/manager/ispmgr', $HTTP, array(), $Request); if (Is_Error($Response)) { return ERROR | @Trigger_Error('[IspManager4_Create]: не удалось соедениться с сервером'); } $Response = Trim($Response['Body']); $XML = String_XML_Parse($Response); if (Is_Exception($XML)) { return new gException('WRONG_SERVER_ANSWER', $Response, $XML); } #----------------------------------------------------------------------------- $XML = $XML->ToArray(); #----------------------------------------------------------------------------- $Doc = $XML['doc']; #----------------------------------------------------------------------------- if (isset($Doc['error'])) { return new gException('ACCOUNT_CREATE_ERROR', 'Не удалось создать заказ хостинга'); } #----------------------------------------------------------------------------- if (!$Settings['Params']['NoRestartCreate']) { $Request = array('authinfo' => SPrintF('%s:%s', $Settings['Login'], $Settings['Password']), 'out' => 'xml', 'func' => 'restart'); #----------------------------------------------------------------------------- $Response = HTTP_Send('/manager/ispmgr', $HTTP, array(), $Request); if (Is_Error($Response)) { return ERROR | @Trigger_Error('[IspManager4_Create]: не удалось соедениться с сервером'); } } #----------------------------------------------------------------------------- return TRUE; }
function VmManager5_KVM_Create($Settings, $VPSOrder, $IP, $VPSScheme) { /******************************************************************************/ $__args_types = array('array', 'array', 'string', 'array'); #------------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /******************************************************************************/ $IDNA = new Net_IDNA_php5(); $Domain = $IDNA->encode($VPSOrder['Domain']); #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $authinfo = SPrintF('%s:%s', $Settings['Login'], $Settings['Password']); #------------------------------------------------------------------------------- $HTTP = VmManager5_KVM_Build_HTTP($Settings); #------------------------------------------------------------------------------- # создаём юзера $Request = array('authinfo' => $authinfo, 'out' => 'xml', 'func' => 'user.edit', 'sok' => 'ok', 'allowcreatevm' => 'off', 'snapshot_limit' => $VPSScheme['snapshot_limit'], 'isolimitsize' => $VPSScheme['isolimitsize'], 'isolimitnum' => $VPSScheme['isolimitnum'], 'name' => $VPSOrder['Login'], 'passwd' => $VPSOrder['Password'], 'confirm' => $VPSOrder['Password']); #------------------------------------------------------------------------------- $Response = HTTP_Send('/vmmgr', $HTTP, array(), $Request); if (Is_Error($Response)) { return ERROR | @Trigger_Error('[VmManager5_KVM_Create]: не удалось соедениться с сервером'); } #------------------------------------------------------------------------------- $Response = Trim($Response['Body']); #------------------------------------------------------------------------------- $XML = String_XML_Parse($Response); if (Is_Exception($XML)) { return new gException('WRONG_SERVER_ANSWER', $Response, $XML); } #------------------------------------------------------------------------------- $XML = $XML->ToArray(); #------------------------------------------------------------------------------- $Doc = $XML['doc']; #------------------------------------------------------------------------------- if (isset($Doc['error'])) { return new gException('USER_ACCOUNT_CREATE_ERROR', 'Не удалось создать пользователя для виртуального сервера'); } #------------------------------------------------------------------------------- if (!isset($Doc['id'])) { return new gException('USER_ID_MISSING', 'Отсутствует идентификатор созданного пользователя'); } #------------------------------------------------------------------------------- $VmUserID = $Doc['id']; #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- # создаём виртуалку $Request = array('authinfo' => $authinfo, 'out' => 'xml', 'func' => 'vm.edit', 'sok' => 'ok', 'hostnode' => 'auto', 'blkiotune' => Ceil($VPSScheme['blkiotune']), 'password' => $VPSOrder['Password'], 'confirm' => $VPSOrder['Password'], 'cputune' => Ceil($VPSScheme['cpu']), 'domain' => $VPSOrder['Domain'], 'family' => 'ipv4', 'inbound' => SPrintF('%u', $VPSScheme['chrate'] * 1024), 'outbound' => SPrintF('%u', $VPSScheme['chrate'] * 1024), 'iptype' => 'public', 'mem' => Ceil($VPSScheme['mem']), 'name' => $VPSOrder['Login'], 'user' => $VmUserID, 'vcpu' => $VPSScheme['ncpu'], 'vmi' => SPrintF('ISPsystem__%s', Trim($VPSOrder['DiskTemplate'])), 'vsize' => $VPSScheme['disklimit']); #------------------------------------------------------------------------------- $Response = HTTP_Send('/vmmgr', $HTTP, array(), $Request); if (Is_Error($Response)) { return ERROR | @Trigger_Error('[VmManager5_KVM_Create]: не удалось соедениться с сервером'); } #------------------------------------------------------------------------------- $Response = Trim($Response['Body']); #------------------------------------------------------------------------------- $XML = String_XML_Parse($Response); if (Is_Exception($XML)) { return new gException('WRONG_SERVER_ANSWER', $Response, $XML); } #------------------------------------------------------------------------------- $XML = $XML->ToArray(); #------------------------------------------------------------------------------- $Doc = $XML['doc']; #------------------------------------------------------------------------------- if (isset($Doc['error'])) { return new gException('ACCOUNT_CREATE_ERROR', 'Не удалось создать виртуальный сервер'); } #------------------------------------------------------------------------------- if (!isset($Doc['id'])) { return new gException('VM_ID_MISSING', 'Отсутствует идентификатор созданной виртуальной машины'); } #------------------------------------------------------------------------------- $VmID = $Doc['id']; #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $Request = array('authinfo' => $authinfo, 'out' => 'xml', 'func' => 'vm.edit', 'elid' => $VmID); #------------------------------------------------------------------------------- $Response = HTTP_Send('/vmmgr', $HTTP, array(), $Request); if (Is_Error($Response)) { return ERROR | @Trigger_Error('[VmManager5_KVM_Create]: не удалось соедениться с сервером'); } #------------------------------------------------------------------------------- $Response = Trim($Response['Body']); #------------------------------------------------------------------------------- $XML = String_XML_Parse($Response); if (Is_Exception($XML)) { return new gException('WRONG_SERVER_ANSWER', $Response, $XML); } #------------------------------------------------------------------------------- $XML = $XML->ToArray(); #------------------------------------------------------------------------------- $Doc = $XML['doc']; #------------------------------------------------------------------------------- if (isset($Doc['error'])) { return new gException('GET_VM_INFO_ERROR', 'Не удалось получить информацию о виртуальном сервере'); } #------------------------------------------------------------------------------- if (!isset($Doc['ip'])) { return new gException('VM_IP_MISSING', 'Отсутствует IP созданной виртуальной машины'); } #------------------------------------------------------------------------------- Debug(SPrintF('[system/libs/VmManager5_KVM]: VPS order created with IP = %s', $Doc['ip'])); #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- return array('ID' => $VPSOrder['ID'], 'IP' => $Doc['ip']); #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- }
function IspManager5_Create($Settings, $Login, $Password, $Domain, $IP, $HostingScheme, $Email, $PersonID = 'Default', $Person = array()) { /******************************************************************************/ $__args_types = array('array', 'string', 'string', 'string', 'string', 'array', 'string', 'string', 'array'); #------------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /******************************************************************************/ $authinfo = SPrintF('%s:%s', $Settings['Login'], $Settings['Password']); #------------------------------------------------------------------------------- $HTTP = IspManager5_Build_HTTP($Settings); #------------------------------------------------------------------------------- $Version = IspManager5_Check_Version($Settings); #------------------------------------------------------------------------------- $IsReselling = $HostingScheme['IsReselling']; #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- # JBS-543, проверяем наличие такого юзера $Request = array('authinfo' => $authinfo, 'func' => $IsReselling ? 'reseller.edit' : 'user.edit', 'out' => 'xml', 'elid' => $Login); #------------------------------------------------------------------------------- $Response = HTTP_Send('/ispmgr', $HTTP, array(), $Request); if (Is_Error($Response)) { return new gException('NOT_CONNECTED_TO_SERVER', 'Не удалось соедениться с сервером'); } #------------------------------------------------------------------------------- $Response = Trim($Response['Body']); #------------------------------------------------------------------------------- $XML = String_XML_Parse($Response); #------------------------------------------------------------------------------- if (Is_Exception($XML)) { return new gException('WRONG_SERVER_ANSWER', $Response, $XML); } #------------------------------------------------------------------------------- $XML = $XML->ToArray(); #------------------------------------------------------------------------------- $Doc = $XML['doc']; #------------------------------------------------------------------------------- if (!isset($Doc['error'])) { if (!isset($Doc['tparams']['func'])) { return TRUE; } } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $IDNA = new Net_IDNA_php5(); #------------------------------------------------------------------------------- $Domain = $IDNA->encode($Domain); #------------------------------------------------------------------------------- $Request = array('authinfo' => $authinfo, 'out' => 'xml', 'func' => $IsReselling ? 'reseller.edit' : 'user.add.finish', 'sok' => 'ok', 'name' => $Login, 'fullname' => $Email, 'passwd' => $Password, 'confirm' => $Password, 'ip' => $IP, 'email' => $Email, 'limit_quota' => $HostingScheme['QuotaDisk'] ? $HostingScheme['QuotaDisk'] : '1', 'limit_cgi' => $HostingScheme['IsCGIAccess'] ? 'on' : 'off', 'limit_db' => $HostingScheme['QuotaDBs'], 'limit_db_users' => $HostingScheme['QuotaUsersDBs'], 'limit_domains' => $HostingScheme['QuotaDomains'], 'limit_emaildomains' => $HostingScheme['QuotaEmailDomains'], 'limit_emaildomains_enabled' => $HostingScheme['QuotaEmailDomains'] ? 'on' : 'off', 'limit_emails' => $HostingScheme['QuotaEmail'], 'limit_ftp_users' => $HostingScheme['QuotaFTP'], 'limit_php_mode' => $HostingScheme['IsPHPModAccess'] ? 'php_mode_mod' : 'php_mode_none', 'limit_php_mode_cgi' => $HostingScheme['IsPHPCGIAccess'] ? 'on' : 'off', 'limit_php_mode_mod' => $HostingScheme['IsPHPModAccess'] ? 'on' : 'off', 'limit_shell' => $HostingScheme['IsShellAccess'] ? 'on' : 'off', 'limit_ssl' => $HostingScheme['IsSSLAccess'] ? 'on' : 'off', 'limit_webdomains' => $HostingScheme['QuotaWWWDomains'], 'limit_webdomains_enabled' => $HostingScheme['QuotaWWWDomains'] ? 'on' : 'off', 'php_enable' => $HostingScheme['IsPHPModAccess'] || $HostingScheme['IsPHPCGIAccess'] || $HostingScheme['IsPHPFastCGIAccess'] ? 'on' : 'off', 'preset' => '#custom', 'mailrate' => $HostingScheme['mailrate'], 'ftp_user' => 'off', 'emaildomain_name' => $Domain, 'webdomain_name' => $Domain, 'domain' => $Domain, 'limit_dirindex' => '', 'limit_cpu' => $HostingScheme['MaxExecutionTime'], 'limit_memory' => Ceil($HostingScheme['QuotaMEM']), 'limit_process' => $HostingScheme['QuotaPROC'], 'limit_maxclientsvhost' => $HostingScheme['QuotaMPMworkers'], 'limit_mysql_query' => $HostingScheme['mysqlquerieslimit'] ? $HostingScheme['mysqlquerieslimit'] : '', 'limit_mysql_update' => $HostingScheme['mysqlupdateslimit'] ? $HostingScheme['mysqlupdateslimit'] : '', 'limit_mysql_maxconn' => $HostingScheme['mysqlconnectlimit'] ? $HostingScheme['mysqlconnectlimit'] : '', 'limit_mysql_maxuserconn' => $HostingScheme['mysqluserconnectlimit'] ? $HostingScheme['mysqluserconnectlimit'] : ''); #------------------------------------------------------------------------------- if ($HostingScheme['QuotaWWWDomains']) { $Request['domain'] = $Domain; } # Домен #------------------------------------------------------------------------------- if ($IsReselling) { #------------------------------------------------------------------------------- $Request['limit_users'] = $HostingScheme['QuotaUsers']; # Пользователи # TODO сделать нормальное лимитирование через интерфейс. наверное, не раньше перевода тарифов на xml $Request['limit_ipv4addrs'] = 0; # адреса, v4 $Request['limit_ipv6addrs'] = 0; # адреса, v6 #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- $Response = HTTP_Send('/ispmgr', $HTTP, array(), $Request); if (Is_Error($Response)) { return ERROR | @Trigger_Error('[IspManager5_Create]: не удалось соедениться с сервером'); } #------------------------------------------------------------------------------- $Response = Trim($Response['Body']); #------------------------------------------------------------------------------- $XML = String_XML_Parse($Response); #------------------------------------------------------------------------------- if (Is_Exception($XML)) { return new gException('WRONG_SERVER_ANSWER', $Response, $XML); } #------------------------------------------------------------------------------- $XML = $XML->ToArray(); #------------------------------------------------------------------------------- $Doc = $XML['doc']; #------------------------------------------------------------------------------- if (isset($Doc['error']) || !isset($Doc['ok'])) { return new gException('ACCOUNT_CREATE_ERROR', 'Не удалось создать заказ хостинга'); } #------------------------------------------------------------------------------- # TODO надо и для Business как-то рестартавать веб-сервер ноды if (!$Settings['Params']['NoRestartCreate'] && $Version == 'Lite') { IspManager5_Service_Restart($Settings, 'httpd'); } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- return TRUE; #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- }