本文整理汇总了PHP中CommonFunctions::detectIPType方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonFunctions::detectIPType方法的具体用法?PHP CommonFunctions::detectIPType怎么用?PHP CommonFunctions::detectIPType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommonFunctions
的用法示例。
在下文中一共展示了CommonFunctions::detectIPType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRequestDataForUpdate
private function getRequestDataForUpdate(Host $host)
{
$data = array('add' => array(), 'rem' => array());
$json = STRegistry::Hosts()->query($host->getName());
$currentHost = Host::fromJSON($json);
foreach (array_merge($host->getIPv4(), $host->getIPv6()) as $id => $ip) {
if (!in_array($ip, array_merge($currentHost->getIPv4(), $currentHost->getIPv6()))) {
if (!isset($data['add']['addr'])) {
$data['add']['addr'] = array();
}
$data['add']['addr'][] = array($id => array('version' => CommonFunctions::detectIPType($ip), 'address' => $ip));
}
}
foreach (array_merge($currentHost->getIPv4(), $currentHost->getIPv6()) as $id => $ip) {
if (!in_array($ip, array_merge($host->getIPv4(), $host->getIPv6()))) {
if (!isset($data['rem']['addr'])) {
$data['rem']['addr'] = array();
}
$data['rem']['addr'][] = array($id => array('version' => CommonFunctions::detectIPType($ip), 'address' => $ip));
}
}
foreach ($host->getStatuses() as $status) {
if (!in_array($status, $currentHost->getStatuses())) {
if (!isset($data['add']['status'])) {
$data['add']['status'] = array();
}
$data['add']['status'][] = $status;
}
}
foreach ($currentHost->getStatuses() as $status) {
if (!in_array($status, $host->getStatuses())) {
if (!isset($data['rem']['status'])) {
$data['rem']['status'] = array();
}
$data['rem']['status'][] = $status;
}
}
return $data;
}
示例2: stregistry_ModifyNameserver
/**
* make request to update host ip addresses
*
* @param array $params whmcs data
*
* @return mixed array containig error message will return if error was ocurred, 'success' string in other case
*/
function stregistry_ModifyNameserver($params)
{
// init connection
if (($status = __initConnectionAndAuthorize($params)) !== true) {
return __errorArray($status);
}
$json = STRegistry::Hosts()->query($params['nameserver']);
if (!ResponseHelper::isSuccess($json)) {
return __errorArray(ResponseHelper::fromJSON($json)->message);
}
$host = Host::fromJSON($json);
if (!empty($params['currentipaddress'])) {
$host->removeIP($params['currentipaddress'], CommonFunctions::detectIPType($params['currentipaddress']));
}
if (!empty($params['newipaddress'])) {
$host->addIP($params['newipaddress'], CommonFunctions::detectIPType($params['newipaddress']));
}
$json = STRegistry::Hosts()->update($host);
if (!ResponseHelper::isSuccess($json)) {
return __errorArray(ResponseHelper::fromJSON($json)->message);
}
return 'success';
}
示例3: getRequestDataForUpdate
/**
*
*/
public function getRequestDataForUpdate(Domain $domain)
{
$data = array();
$json = STRegistry::Domains()->query($domain->getName());
$currentDomain = Domain::fromJSON($json);
if ($currentDomain->getAuthCode() != $domain->getAuthCode()) {
if (!isset($data['chg'])) {
$data['chg'] = array();
}
$data['chg']['authInfo'] = array('pw' => $domain->getAuthCode());
}
foreach ($currentDomain->getContacts() as $type => $contact) {
$newContacts = $domain->getContacts();
if ($newContacts[$type] !== false && $newContacts[$type] != $contact) {
if (!isset($data['rem']['contact'])) {
$data['rem']['contact'] = array();
}
if (!isset($data['add']['contact'])) {
$data['add']['contact'] = array();
}
$data['rem']['contact'][] = array($type => $contact);
if (!empty($newContacts[$type])) {
$data['add']['contact'][] = array($type => $newContacts[$type]);
}
}
}
foreach ($domain->getNameServers() as $nameserver => $ips) {
if (!in_array($nameserver, array_keys($currentDomain->getNameServers()))) {
if (!isset($data['add']['ns'])) {
$data['add']['ns'] = array();
}
$upd = array('name' => $nameserver);
if (count($ips)) {
$upd['addr'] = array();
foreach ($ips as $ip) {
$upd['addr'][] = array(CommonFunctions::detectIPType($ip) => $ip);
}
}
$data['add']['ns'][] = $upd;
}
}
foreach ($currentDomain->getNameServers() as $nameserver => $ips) {
if (!in_array($nameserver, array_keys($domain->getNameServers()))) {
if (!isset($data['rem']['ns'])) {
$data['rem']['ns'] = array();
}
$data['rem']['ns'][] = $nameserver;
}
}
foreach ($domain->getStatuses() as $status) {
if (!in_array($status, array(Domain::STATUS_HOLD, Domain::STATUS_DELETE_PROHIBITED, Domain::STATUS_RENEW_PROHIBITED, Domain::STATUS_TRANSFER_PROHIBITED, Domain::STATUS_UPDATE_PROHIBITED))) {
continue;
}
if (!in_array($status, $currentDomain->getStatuses())) {
if (!isset($data['add']['status'])) {
$data['add']['status'] = array();
}
$data['add']['status'][] = $status;
}
}
foreach ($currentDomain->getStatuses() as $status) {
if (!in_array($status, array(Domain::STATUS_HOLD, Domain::STATUS_DELETE_PROHIBITED, Domain::STATUS_RENEW_PROHIBITED, Domain::STATUS_TRANSFER_PROHIBITED, Domain::STATUS_UPDATE_PROHIBITED))) {
continue;
}
if (!in_array($status, $domain->getStatuses())) {
if (!isset($data['rem']['status'])) {
$data['rem']['status'] = array();
}
$data['rem']['status'][] = $status;
}
}
return $data;
}