Skip to content

Commit

Permalink
Added host:update
Browse files Browse the repository at this point in the history
  • Loading branch information
getpinga authored Feb 20, 2023
1 parent bd15345 commit 0d56767
Showing 1 changed file with 78 additions and 9 deletions.
87 changes: 78 additions & 9 deletions src/Registries/FredEpp.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,18 +446,12 @@ public function hostCreate($params = array())
$from = $to = array();
$from[] = '/{{ name }}/';
$to[] = htmlspecialchars($params['hostname']);
$from[] = '/{{ v }}/';
$to[] = htmlspecialchars($params['v']);
$from[] = '/{{ ip }}/';
$to[] = htmlspecialchars($params['ip']);
if (!empty($params['contact'])) {
$from[] = '/{{ contact }}/';
$to[] = htmlspecialchars($params['contact']);
}
$from[] = '/{{ ip }}/';
$to[] = htmlspecialchars($params['ipaddress']);
$from[] = '/{{ name2 }}/';
$to[] = htmlspecialchars($params['hostname2']);
$from[] = '/{{ ip2 }}/';
$to[] = htmlspecialchars($params['ip2']);
$to[] = htmlspecialchars($params['ipaddress2']);
$from[] = '/{{ nsid }}/';
$to[] = htmlspecialchars($params['nsid']);
$from[] = '/{{ nstech }}/';
Expand Down Expand Up @@ -510,6 +504,81 @@ public function hostCreate($params = array())

return $return;
}

/**
* hostUpdate
*/
public function hostUpdate($params = array())
{
if (!$this->isLoggedIn) {
return array(
'code' => 2002,
'msg' => 'Command use error'
);
}

$return = array();
try {
$from = $to = array();
$from[] = '/{{ newname }}/';
$to[] = htmlspecialchars($params['newhostname']);
$from[] = '/{{ oldname }}/';
$to[] = htmlspecialchars($params['oldhostname']);
$from[] = '/{{ ip2 }}/';
$to[] = htmlspecialchars($params['newipaddress']);
$from[] = '/{{ nsid }}/';
$to[] = htmlspecialchars($params['nsid']);
$from[] = '/{{ nstech_new }}/';
$to[] = htmlspecialchars($params['nstech_new']);
$from[] = '/{{ nstech_old }}/';
$to[] = htmlspecialchars($params['nstech_old']);
$from[] = '/{{ clTRID }}/';
$clTRID = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->prefix . '-host-update-' . $clTRID);
$xml = preg_replace($from, $to, '<?xml version="1.0" encoding="utf-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<update>
<nsset:update xmlns:nsset="http://www.nic.cz/xml/epp/nsset-1.2"
xsi:schemaLocation="http://www.nic.cz/xml/epp/nsset-1.2 nsset-1.2.2.xsd">
<nsset:id>{{ nsid }}</nsset:id>
<nsset:add>
<nsset:ns>
<nsset:name>{{ newname }}</nsset:name>
<nsset:addr>{{ ip2 }}</nsset:addr>
</nsset:ns>
<nsset:tech>{{ nstech_new }}</nsset:tech>
</nsset:add>
<nsset:rem>
<nsset:name>{{ oldname }}</nsset:name>
<nsset:tech>{{ nstech_old }}</nsset:tech>
</nsset:rem>
<nsset:chg>
<nsset:reportlevel>4</nsset:reportlevel>
</nsset:chg>
</nsset:update>
</update>
<clTRID>{{ clTRID }}</clTRID>
</command>
</epp>');
$r = $this->writeRequest($xml);
$code = (int)$r->response->result->attributes()->code;
$msg = (string)$r->response->result->msg;

$return = array(
'code' => $code,
'msg' => $msg
);
} catch (\Exception $e) {
$return = array(
'error' => $e->getMessage()
);
}

return $return;
}

/**
* hostDelete
Expand Down

0 comments on commit 0d56767

Please sign in to comment.