diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..a9ad921 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,115 @@ +TRANSIP API V5.9 + +NEW + - Added a function to request the authcode of a domain at the dnsBE or EURid registries + +TRANSIP API V5.8 + +NEW + - Added Pooled Traffic for VPS + +TRANSIP API V5.7 + +NEW + - Added AvailabilityZones + +TRANSIP API V5.6 + +NEW + - Added custom target ports for HA-IP + Use different source and destination ports for a HA-IP configuration. + - Added option to configure SSL between HA-IP and VPS + For each configuration specify whether the connection between HA-IP and the VPS is secured. + - Added HA-IP Pro support + Attach multiple VPSes to a HA-IP, and modify load balancing settings. + +TRANSIP API V5.5 + +NEW + - Added HA-IP Certificates + HTTPS Offloading on our proxy's + - Add LetsEncrypt certificate to HA-IP + Let transip handle your Lets Encrypt certificate and renewals automatically + - Change proxy modes: HTTP, HTTPS, TCP, PROXY + Use HTTPS modus for SSL offloading. HTTP/HTTPS mode will also set the X-Forwarded-For Header. + +TRANSIP API V5.4 + +NEW + - Added HaipService + With which you can list your Haips and change the coupled Vps to your Haip + +TRANSIP API V5.3 + +NEW + - Added VpsService::installOperatingSystemUnattended + Start a installation with a custom preseed/kickstart provided via the api (base64_encoded) + +TRANSIP API V5.2 + +NEW + - Added VpsService::cloneVps + The ability to clone a VPS to a new VPS + + - Added VpsService::revertSnapshotToOtherVps + Revert a snapshot from any vps to any vps + + - Added VpsService::revertVpsBackup + Revert a automated VPS backup + + +TRANSIP API V5.1 + +NEW + - Added VpsService::getTrafficInformationForVps + This method provides more information about your traffic usage + + - Added VpsService::handoverVps + With this method you will be able to start the push handover process to another TransIP Account + + - Added VpsService::setCustomerLock + Enable or disable the customerlock via the Api + +DEPRECATED: + - VpsService::getAmountOfTrafficUsed (still works for now) + + +TRANSIP API V5.0 + +NEW + - Added Support for VPS + + +TRANSIP API V4.2.1 + +NEW + - The RSA part of the private key is no longer required for newly generated keys + + +TRANSIP API V4.1 + +NEW + - Single distribution for all TransIP countries: added Transip_ApiSettings::$endpoint to determine which endpoint to target when making API requests + + +TRANSIP API V4.0 + +NEW: + - Improved security by using SSL based signatures for API requests. + + +TRANSIP API V3.0 + +NEW: + - check up to 20 domains within one call: Transip_DomainService::batchCheckAvailability() + - get information (price, renewal period, possible actions) about all TLDs offered with Transip_DomainService::getAllTldInfos() and Transip_DomainService::getTldInfo() + - get the current running action a domain is doing and/or retry/cancel with getCurrentDomainAction(), retryCurrentDomainActionWithNewData(), retryTransferWithDifferentAuthCode(), cancelDomainAction() + - The domain object now holds information registrationDate, renewalDate, authCode and isLocked status + - Get all Colocation items with ColocationService::getColoNames() + - Manage IP/Network info with getIpRanges(), createIpAddress(), and more + - Manage, order and modify Forwards with the ForwardService + - Manage, order and modify Webhosting with the WebhostingService + +DEPRECATED: + - Transip_DomainService::getAuthCode(). Returned in Transip_DomainService::getInfo() now. + - Transip_DomainService::getIsLocked(). Returned in Transip_DomainService::getInfo() now. diff --git a/Transip/ApiSettings.php b/Transip/ApiSettings.php new file mode 100644 index 0000000..9a98a06 --- /dev/null +++ b/Transip/ApiSettings.php @@ -0,0 +1,43 @@ + diff --git a/Transip/ColocationService.php b/Transip/ColocationService.php new file mode 100644 index 0000000..3801ffc --- /dev/null +++ b/Transip/ColocationService.php @@ -0,0 +1,305 @@ +' . implode("
\n", $errors) . '
'); + + $classMap = array( + 'DataCenterVisitor' => 'Transip_DataCenterVisitor', + ); + + $options = array( + 'classmap' => $classMap, + 'encoding' => 'utf-8', // lets support unicode + 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // see http://bugs.php.net/bug.php?id=43338 + 'trace' => false, // can be used for debugging + ); + + $wsdlUri = "https://{$endpoint}/wsdl/?service=" . self::SERVICE; + try + { + self::$_soapClient = new SoapClient($wsdlUri, $options); + } + catch(SoapFault $sf) + { + throw new Exception("Unable to connect to endpoint '{$endpoint}'"); + } + self::$_soapClient->__setCookie('login', Transip_ApiSettings::$login); + self::$_soapClient->__setCookie('mode', Transip_ApiSettings::$mode); + } + + $timestamp = time(); + $nonce = uniqid('', true); + + self::$_soapClient->__setCookie('timestamp', $timestamp); + self::$_soapClient->__setCookie('nonce', $nonce); + self::$_soapClient->__setCookie('clientVersion', self::API_VERSION); + self::$_soapClient->__setCookie('signature', self::_urlencode(self::_sign(array_merge($parameters, array( + '__service' => self::SERVICE, + '__hostname' => $endpoint, + '__timestamp' => $timestamp, + '__nonce' => $nonce + ))))); + + return self::$_soapClient; + } + + /** + * Calculates the hash to sign our request with based on the given parameters. + * + * @param mixed $parameters The parameters to sign. + * @return string Base64 encoded signing hash. + */ + protected static function _sign($parameters) + { + // Fixup our private key, copy-pasting the key might lead to whitespace faults + if(!preg_match('/-----BEGIN (RSA )?PRIVATE KEY-----(.*)-----END (RSA )?PRIVATE KEY-----/si', Transip_ApiSettings::$privateKey, $matches)) + die('Could not find your private key, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.
'); + + $key = $matches[2]; + $key = preg_replace('/\s*/s', '', $key); + $key = chunk_split($key, 64, "\n"); + + $key = "-----BEGIN PRIVATE KEY-----\n" . $key . "-----END PRIVATE KEY-----"; + + $digest = self::_sha512Asn1(self::_encodeParameters($parameters)); + if(!@openssl_private_encrypt($digest, $signature, $key)) + die('Could not sign your request, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.
'); + + return base64_encode($signature); + } + + /** + * Creates a digest of the given data, with an asn1 header. + * + * @param string $data The data to create a digest of. + * @return string The digest of the data, with asn1 header. + */ + protected static function _sha512Asn1($data) + { + $digest = hash('sha512', $data, true); + + // this ASN1 header is sha512 specific + $asn1 = chr(0x30).chr(0x51); + $asn1 .= chr(0x30).chr(0x0d); + $asn1 .= chr(0x06).chr(0x09); + $asn1 .= chr(0x60).chr(0x86).chr(0x48).chr(0x01).chr(0x65); + $asn1 .= chr(0x03).chr(0x04); + $asn1 .= chr(0x02).chr(0x03); + $asn1 .= chr(0x05).chr(0x00); + $asn1 .= chr(0x04).chr(0x40); + $asn1 .= $digest; + + return $asn1; + } + + /** + * Encodes the given paramaters into a url encoded string based upon RFC 3986. + * + * @param mixed $parameters The parameters to encode. + * @param string $keyPrefix Key prefix. + * @return string The given parameters encoded according to RFC 3986. + */ + protected static function _encodeParameters($parameters, $keyPrefix = null) + { + if(!is_array($parameters) && !is_object($parameters)) + return self::_urlencode($parameters); + + $encodedData = array(); + + foreach($parameters as $key => $value) + { + $encodedKey = is_null($keyPrefix) + ? self::_urlencode($key) + : $keyPrefix . '[' . self::_urlencode($key) . ']'; + + if(is_array($value) || is_object($value)) + { + $encodedData[] = self::_encodeParameters($value, $encodedKey); + } + else + { + $encodedData[] = $encodedKey . '=' . self::_urlencode($value); + } + } + + return implode('&', $encodedData); + } + + /** + * Our own function to encode a string according to RFC 3986 since. + * PHP < 5.3.0 encodes the ~ character which is not allowed. + * + * @param string $string The string to encode. + * @return string The encoded string according to RFC 3986. + */ + protected static function _urlencode($string) + { + $string = trim($string); + $string = rawurlencode($string); + return str_replace('%7E', '~', $string); + } + + const TRACK_ENDPOINT_NAME = 'Colocation'; + + /** + * Requests access to the data-center + * + * @param string $when the datetime of the wanted datacenter access, in YYYY-MM-DD hh:mm:ss format + * @param int $duration the expected duration of the visit, in minutes + * @param string[] $visitors the names of the visitors for this data-center visit, must be at least 1 and at most 20 + * @param string $phoneNumber if an SMS with access codes needs to be sent, set the phonenumber of the receiving phone here; + * @return Transip_DataCenterVisitor[] An array of Visitor objects holding information (such as reservation and access number) about + * @throws ApiException + */ + public static function requestAccess($when, $duration, $visitors, $phoneNumber) + { + return self::_getSoapClient(array_merge(array($when, $duration, $visitors, $phoneNumber), array('__method' => 'requestAccess')))->requestAccess($when, $duration, $visitors, $phoneNumber); + } + + /** + * Request remote hands to the data-center + * + * @param string $coloName The name of the colocation + * @param string $contactName The contact name + * @param string $phoneNumber Phone number to contact + * @param int $expectedDuration Expected duration of the job in minutes + * @param string $instructions What to do + * @throws ApiException + */ + public static function requestRemoteHands($coloName, $contactName, $phoneNumber, $expectedDuration, $instructions) + { + return self::_getSoapClient(array_merge(array($coloName, $contactName, $phoneNumber, $expectedDuration, $instructions), array('__method' => 'requestRemoteHands')))->requestRemoteHands($coloName, $contactName, $phoneNumber, $expectedDuration, $instructions); + } + + /** + * Get coloNames for customer + * + * @return string[] Array with colo names + */ + public static function getColoNames() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getColoNames')))->getColoNames(); + } + + /** + * Get IpAddresses that are active and assigned to a Colo. + * Both ipv4 and ipv6 addresses are returned: ipv4 adresses in dot notation, + * ipv6 addresses in ipv6 presentation. + * + * @param string $coloName The name of the colo to get the ipaddresses for for + * @return string[] Array with assigned IPv4 and IPv6 addresses for the colo + */ + public static function getIpAddresses($coloName) + { + return self::_getSoapClient(array_merge(array($coloName), array('__method' => 'getIpAddresses')))->getIpAddresses($coloName); + } + + /** + * Get ipranges that are assigned to a Colo. Both ipv4 and ipv6 ranges are + * returned, in CIDR notation. + * + * @param string $coloName The name of the colo to get the ranges for + * @see http://en.wikipedia.org/wiki/CIDR_notation + * @return string[] Array of ipranges in CIDR format assigned to this colo. + */ + public static function getIpRanges($coloName) + { + return self::_getSoapClient(array_merge(array($coloName), array('__method' => 'getIpRanges')))->getIpRanges($coloName); + } + + /** + * Adds a new IpAddress, either an ipv6 or an ipv4 address. + * The service will validate the address, ensure the user is entitled + * to the address and will add the address to the correct Colo and range. + * + * @param string $ipAddress The IpAddress to create, can be either ipv4 or ipv6. + * @param string $reverseDns The RDNS name for this IpAddress + * @throws ApiException + */ + public static function createIpAddress($ipAddress, $reverseDns) + { + return self::_getSoapClient(array_merge(array($ipAddress, $reverseDns), array('__method' => 'createIpAddress')))->createIpAddress($ipAddress, $reverseDns); + } + + /** + * Deletes an IpAddress currently in use this account. + * IpAddress can be either ipv4 or ipv6. The service will validate + * if the user has rights to remove the address and will remove it completely, + * together with any RDNS or monitoring assigned to the address. + * + * @param string $ipAddress the IpAddress to delete, can be either ipv4 or ipv6. + */ + public static function deleteIpAddress($ipAddress) + { + return self::_getSoapClient(array_merge(array($ipAddress), array('__method' => 'deleteIpAddress')))->deleteIpAddress($ipAddress); + } + + /** + * Get the Reverse DNS for an IpAddress assigned to the user + * Throws an Exception when the Address does not exist or is not + * owned by the user. + * + * @param string $ipAddress the IpAddress, either ipv4 or ipv6 + * @return string rdns + */ + public static function getReverseDns($ipAddress) + { + return self::_getSoapClient(array_merge(array($ipAddress), array('__method' => 'getReverseDns')))->getReverseDns($ipAddress); + } + + /** + * Set the RDNS name for an ipAddress. + * Throws an Exception when the Address does not exist or is not + * owned by the user. + * + * @param string $ipAddress The IpAddress to set the reverse dns for, can be either ipv4 or ipv6. + * @param string $reverseDns The new reverse DNS, must be a valid RDNS value. + */ + public static function setReverseDns($ipAddress, $reverseDns) + { + return self::_getSoapClient(array_merge(array($ipAddress, $reverseDns), array('__method' => 'setReverseDns')))->setReverseDns($ipAddress, $reverseDns); + } +} + +?> diff --git a/Transip/Cronjob.php b/Transip/Cronjob.php new file mode 100644 index 0000000..a93c0a1 --- /dev/null +++ b/Transip/Cronjob.php @@ -0,0 +1,102 @@ +name = $name; + $this->url = $url; + $this->email = $email; + $this->minuteTrigger = $minuteTrigger; + $this->hourTrigger = $hourTrigger; + $this->dayTrigger = $dayTrigger; + $this->monthTrigger = $monthTrigger; + $this->weekdayTrigger = $weekdayTrigger; + } +} + +?> diff --git a/Transip/DataCenterVisitor.php b/Transip/DataCenterVisitor.php new file mode 100644 index 0000000..38ddae0 --- /dev/null +++ b/Transip/DataCenterVisitor.php @@ -0,0 +1,42 @@ + diff --git a/Transip/Db.php b/Transip/Db.php new file mode 100644 index 0000000..6b9a8ce --- /dev/null +++ b/Transip/Db.php @@ -0,0 +1,49 @@ +name = $name; + $this->username = $username; + $this->maxDiskUsage = $maxDiskUsage; + } +} + +?> diff --git a/Transip/DnsEntry.php b/Transip/DnsEntry.php new file mode 100644 index 0000000..89dd520 --- /dev/null +++ b/Transip/DnsEntry.php @@ -0,0 +1,70 @@ +name = $name; + $this->expire = $expire; + $this->type = $type; + $this->content = $content; + } +} + +?> diff --git a/Transip/DnsSecEntry.php b/Transip/DnsSecEntry.php new file mode 100644 index 0000000..e9c0ef7 --- /dev/null +++ b/Transip/DnsSecEntry.php @@ -0,0 +1,86 @@ + 3, + 1 => 5, + 2 => 6, + 3 => 7, + 4 => 8, + 5 => 10, + 6 => 12, + 7 => 13, + 8 => 14, + 9 => 15, + 10 => 16, +); + const ALL_FLAGS = array ( + 0 => 0, + 1 => 256, + 2 => 257, +); + + /** + * + * + * @var int $keyTag + */ + public $keyTag; + + /** + * For all supported flags see Transip_DnsSecEntry::ALL_FLAGS + * + * @var int $flags + */ + public $flags; + + /** + * For all supported algorithms see Transip_DnsSecEntry::ALL_ALGORITHMS + * + * @var int $algorithm + */ + public $algorithm; + + /** + * + * + * @var string $publicKey + */ + public $publicKey; + + /** + * DnsSecEntry constructor. + * + */ + public function __construct($keyTag, $flags, $algorithm, $publicKey) + { + $this->keyTag = $keyTag; + $this->flags = $flags; + $this->algorithm = $algorithm; + $this->publicKey = $publicKey; + } +} + +?> diff --git a/Transip/DnsService.php b/Transip/DnsService.php new file mode 100644 index 0000000..8e7a50a --- /dev/null +++ b/Transip/DnsService.php @@ -0,0 +1,247 @@ +' . implode("\n", $errors) . '
'); + + $classMap = array( + 'DnsEntry' => 'Transip_DnsEntry', + 'DnsSecEntry' => 'Transip_DnsSecEntry', + ); + + $options = array( + 'classmap' => $classMap, + 'encoding' => 'utf-8', // lets support unicode + 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // see http://bugs.php.net/bug.php?id=43338 + 'trace' => false, // can be used for debugging + ); + + $wsdlUri = "https://{$endpoint}/wsdl/?service=" . self::SERVICE; + try + { + self::$_soapClient = new SoapClient($wsdlUri, $options); + } + catch(SoapFault $sf) + { + throw new Exception("Unable to connect to endpoint '{$endpoint}'"); + } + self::$_soapClient->__setCookie('login', Transip_ApiSettings::$login); + self::$_soapClient->__setCookie('mode', Transip_ApiSettings::$mode); + } + + $timestamp = time(); + $nonce = uniqid('', true); + + self::$_soapClient->__setCookie('timestamp', $timestamp); + self::$_soapClient->__setCookie('nonce', $nonce); + self::$_soapClient->__setCookie('clientVersion', self::API_VERSION); + self::$_soapClient->__setCookie('signature', self::_urlencode(self::_sign(array_merge($parameters, array( + '__service' => self::SERVICE, + '__hostname' => $endpoint, + '__timestamp' => $timestamp, + '__nonce' => $nonce + ))))); + + return self::$_soapClient; + } + + /** + * Calculates the hash to sign our request with based on the given parameters. + * + * @param mixed $parameters The parameters to sign. + * @return string Base64 encoded signing hash. + */ + protected static function _sign($parameters) + { + // Fixup our private key, copy-pasting the key might lead to whitespace faults + if(!preg_match('/-----BEGIN (RSA )?PRIVATE KEY-----(.*)-----END (RSA )?PRIVATE KEY-----/si', Transip_ApiSettings::$privateKey, $matches)) + die('Could not find your private key, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.
'); + + $key = $matches[2]; + $key = preg_replace('/\s*/s', '', $key); + $key = chunk_split($key, 64, "\n"); + + $key = "-----BEGIN PRIVATE KEY-----\n" . $key . "-----END PRIVATE KEY-----"; + + $digest = self::_sha512Asn1(self::_encodeParameters($parameters)); + if(!@openssl_private_encrypt($digest, $signature, $key)) + die('Could not sign your request, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.
'); + + return base64_encode($signature); + } + + /** + * Creates a digest of the given data, with an asn1 header. + * + * @param string $data The data to create a digest of. + * @return string The digest of the data, with asn1 header. + */ + protected static function _sha512Asn1($data) + { + $digest = hash('sha512', $data, true); + + // this ASN1 header is sha512 specific + $asn1 = chr(0x30).chr(0x51); + $asn1 .= chr(0x30).chr(0x0d); + $asn1 .= chr(0x06).chr(0x09); + $asn1 .= chr(0x60).chr(0x86).chr(0x48).chr(0x01).chr(0x65); + $asn1 .= chr(0x03).chr(0x04); + $asn1 .= chr(0x02).chr(0x03); + $asn1 .= chr(0x05).chr(0x00); + $asn1 .= chr(0x04).chr(0x40); + $asn1 .= $digest; + + return $asn1; + } + + /** + * Encodes the given paramaters into a url encoded string based upon RFC 3986. + * + * @param mixed $parameters The parameters to encode. + * @param string $keyPrefix Key prefix. + * @return string The given parameters encoded according to RFC 3986. + */ + protected static function _encodeParameters($parameters, $keyPrefix = null) + { + if(!is_array($parameters) && !is_object($parameters)) + return self::_urlencode($parameters); + + $encodedData = array(); + + foreach($parameters as $key => $value) + { + $encodedKey = is_null($keyPrefix) + ? self::_urlencode($key) + : $keyPrefix . '[' . self::_urlencode($key) . ']'; + + if(is_array($value) || is_object($value)) + { + $encodedData[] = self::_encodeParameters($value, $encodedKey); + } + else + { + $encodedData[] = $encodedKey . '=' . self::_urlencode($value); + } + } + + return implode('&', $encodedData); + } + + /** + * Our own function to encode a string according to RFC 3986 since. + * PHP < 5.3.0 encodes the ~ character which is not allowed. + * + * @param string $string The string to encode. + * @return string The encoded string according to RFC 3986. + */ + protected static function _urlencode($string) + { + $string = trim($string); + $string = rawurlencode($string); + return str_replace('%7E', '~', $string); + } + + const TRACK_ENDPOINT_NAME = 'Dns'; + + /** + * Sets the DnEntries for this Domain, will replace all existing dns entries with the new entries + * + * @param string $domainName the domainName to change the dns entries for", $errors) . '
'); + + $classMap = array( + 'DomainCheckResult' => 'Transip_DomainCheckResult', + 'Domain' => 'Transip_Domain', + 'Nameserver' => 'Transip_Nameserver', + 'WhoisContact' => 'Transip_WhoisContact', + 'DnsEntry' => 'Transip_DnsEntry', + 'DomainBranding' => 'Transip_DomainBranding', + 'Tld' => 'Transip_Tld', + 'DomainAction' => 'Transip_DomainAction', + ); + + $options = array( + 'classmap' => $classMap, + 'encoding' => 'utf-8', // lets support unicode + 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // see http://bugs.php.net/bug.php?id=43338 + 'trace' => false, // can be used for debugging + ); + + $wsdlUri = "https://{$endpoint}/wsdl/?service=" . self::SERVICE; + try + { + self::$_soapClient = new SoapClient($wsdlUri, $options); + } + catch(SoapFault $sf) + { + throw new Exception("Unable to connect to endpoint '{$endpoint}'"); + } + self::$_soapClient->__setCookie('login', Transip_ApiSettings::$login); + self::$_soapClient->__setCookie('mode', Transip_ApiSettings::$mode); + } + + $timestamp = time(); + $nonce = uniqid('', true); + + self::$_soapClient->__setCookie('timestamp', $timestamp); + self::$_soapClient->__setCookie('nonce', $nonce); + self::$_soapClient->__setCookie('clientVersion', self::API_VERSION); + self::$_soapClient->__setCookie('signature', self::_urlencode(self::_sign(array_merge($parameters, array( + '__service' => self::SERVICE, + '__hostname' => $endpoint, + '__timestamp' => $timestamp, + '__nonce' => $nonce + ))))); + + return self::$_soapClient; + } + + /** + * Calculates the hash to sign our request with based on the given parameters. + * + * @param mixed $parameters The parameters to sign. + * @return string Base64 encoded signing hash. + */ + protected static function _sign($parameters) + { + // Fixup our private key, copy-pasting the key might lead to whitespace faults + if(!preg_match('/-----BEGIN (RSA )?PRIVATE KEY-----(.*)-----END (RSA )?PRIVATE KEY-----/si', Transip_ApiSettings::$privateKey, $matches)) + die('Could not find your private key, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.
'); + + $key = $matches[2]; + $key = preg_replace('/\s*/s', '', $key); + $key = chunk_split($key, 64, "\n"); + + $key = "-----BEGIN PRIVATE KEY-----\n" . $key . "-----END PRIVATE KEY-----"; + + $digest = self::_sha512Asn1(self::_encodeParameters($parameters)); + if(!@openssl_private_encrypt($digest, $signature, $key)) + die('Could not sign your request, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.
'); + + return base64_encode($signature); + } + + /** + * Creates a digest of the given data, with an asn1 header. + * + * @param string $data The data to create a digest of. + * @return string The digest of the data, with asn1 header. + */ + protected static function _sha512Asn1($data) + { + $digest = hash('sha512', $data, true); + + // this ASN1 header is sha512 specific + $asn1 = chr(0x30).chr(0x51); + $asn1 .= chr(0x30).chr(0x0d); + $asn1 .= chr(0x06).chr(0x09); + $asn1 .= chr(0x60).chr(0x86).chr(0x48).chr(0x01).chr(0x65); + $asn1 .= chr(0x03).chr(0x04); + $asn1 .= chr(0x02).chr(0x03); + $asn1 .= chr(0x05).chr(0x00); + $asn1 .= chr(0x04).chr(0x40); + $asn1 .= $digest; + + return $asn1; + } + + /** + * Encodes the given paramaters into a url encoded string based upon RFC 3986. + * + * @param mixed $parameters The parameters to encode. + * @param string $keyPrefix Key prefix. + * @return string The given parameters encoded according to RFC 3986. + */ + protected static function _encodeParameters($parameters, $keyPrefix = null) + { + if(!is_array($parameters) && !is_object($parameters)) + return self::_urlencode($parameters); + + $encodedData = array(); + + foreach($parameters as $key => $value) + { + $encodedKey = is_null($keyPrefix) + ? self::_urlencode($key) + : $keyPrefix . '[' . self::_urlencode($key) . ']'; + + if(is_array($value) || is_object($value)) + { + $encodedData[] = self::_encodeParameters($value, $encodedKey); + } + else + { + $encodedData[] = $encodedKey . '=' . self::_urlencode($value); + } + } + + return implode('&', $encodedData); + } + + /** + * Our own function to encode a string according to RFC 3986 since. + * PHP < 5.3.0 encodes the ~ character which is not allowed. + * + * @param string $string The string to encode. + * @return string The encoded string according to RFC 3986. + */ + protected static function _urlencode($string) + { + $string = trim($string); + $string = rawurlencode($string); + return str_replace('%7E', '~', $string); + } + + const AVAILABILITY_INYOURACCOUNT = 'inyouraccount'; + const AVAILABILITY_UNAVAILABLE = 'unavailable'; + const AVAILABILITY_NOTFREE = 'notfree'; + const AVAILABILITY_FREE = 'free'; + const AVAILABILITY_INTERNALPULL = 'internalpull'; + const CANCELLATIONTIME_END = 'end'; + const CANCELLATIONTIME_IMMEDIATELY = 'immediately'; + const ACTION_REGISTER = 'register'; + const ACTION_TRANSFER = 'transfer'; + const ACTION_INTERNALPULL = 'internalpull'; + const TRACK_ENDPOINT_NAME = 'Domain'; + + /** + * Checks the availability of multiple domains. + * + * @param string[] $domainNames The domain names to check for availability.", $errors) . '
'); + + $classMap = array( + 'Forward' => 'Transip_Forward', + ); + + $options = array( + 'classmap' => $classMap, + 'encoding' => 'utf-8', // lets support unicode + 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // see http://bugs.php.net/bug.php?id=43338 + 'trace' => false, // can be used for debugging + ); + + $wsdlUri = "https://{$endpoint}/wsdl/?service=" . self::SERVICE; + try + { + self::$_soapClient = new SoapClient($wsdlUri, $options); + } + catch(SoapFault $sf) + { + throw new Exception("Unable to connect to endpoint '{$endpoint}'"); + } + self::$_soapClient->__setCookie('login', Transip_ApiSettings::$login); + self::$_soapClient->__setCookie('mode', Transip_ApiSettings::$mode); + } + + $timestamp = time(); + $nonce = uniqid('', true); + + self::$_soapClient->__setCookie('timestamp', $timestamp); + self::$_soapClient->__setCookie('nonce', $nonce); + self::$_soapClient->__setCookie('clientVersion', self::API_VERSION); + self::$_soapClient->__setCookie('signature', self::_urlencode(self::_sign(array_merge($parameters, array( + '__service' => self::SERVICE, + '__hostname' => $endpoint, + '__timestamp' => $timestamp, + '__nonce' => $nonce + ))))); + + return self::$_soapClient; + } + + /** + * Calculates the hash to sign our request with based on the given parameters. + * + * @param mixed $parameters The parameters to sign. + * @return string Base64 encoded signing hash. + */ + protected static function _sign($parameters) + { + // Fixup our private key, copy-pasting the key might lead to whitespace faults + if(!preg_match('/-----BEGIN (RSA )?PRIVATE KEY-----(.*)-----END (RSA )?PRIVATE KEY-----/si', Transip_ApiSettings::$privateKey, $matches)) + die('Could not find your private key, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.
'); + + $key = $matches[2]; + $key = preg_replace('/\s*/s', '', $key); + $key = chunk_split($key, 64, "\n"); + + $key = "-----BEGIN PRIVATE KEY-----\n" . $key . "-----END PRIVATE KEY-----"; + + $digest = self::_sha512Asn1(self::_encodeParameters($parameters)); + if(!@openssl_private_encrypt($digest, $signature, $key)) + die('Could not sign your request, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.
'); + + return base64_encode($signature); + } + + /** + * Creates a digest of the given data, with an asn1 header. + * + * @param string $data The data to create a digest of. + * @return string The digest of the data, with asn1 header. + */ + protected static function _sha512Asn1($data) + { + $digest = hash('sha512', $data, true); + + // this ASN1 header is sha512 specific + $asn1 = chr(0x30).chr(0x51); + $asn1 .= chr(0x30).chr(0x0d); + $asn1 .= chr(0x06).chr(0x09); + $asn1 .= chr(0x60).chr(0x86).chr(0x48).chr(0x01).chr(0x65); + $asn1 .= chr(0x03).chr(0x04); + $asn1 .= chr(0x02).chr(0x03); + $asn1 .= chr(0x05).chr(0x00); + $asn1 .= chr(0x04).chr(0x40); + $asn1 .= $digest; + + return $asn1; + } + + /** + * Encodes the given paramaters into a url encoded string based upon RFC 3986. + * + * @param mixed $parameters The parameters to encode. + * @param string $keyPrefix Key prefix. + * @return string The given parameters encoded according to RFC 3986. + */ + protected static function _encodeParameters($parameters, $keyPrefix = null) + { + if(!is_array($parameters) && !is_object($parameters)) + return self::_urlencode($parameters); + + $encodedData = array(); + + foreach($parameters as $key => $value) + { + $encodedKey = is_null($keyPrefix) + ? self::_urlencode($key) + : $keyPrefix . '[' . self::_urlencode($key) . ']'; + + if(is_array($value) || is_object($value)) + { + $encodedData[] = self::_encodeParameters($value, $encodedKey); + } + else + { + $encodedData[] = $encodedKey . '=' . self::_urlencode($value); + } + } + + return implode('&', $encodedData); + } + + /** + * Our own function to encode a string according to RFC 3986 since. + * PHP < 5.3.0 encodes the ~ character which is not allowed. + * + * @param string $string The string to encode. + * @return string The encoded string according to RFC 3986. + */ + protected static function _urlencode($string) + { + $string = trim($string); + $string = rawurlencode($string); + return str_replace('%7E', '~', $string); + } + + const CANCELLATIONTIME_END = 'end'; + const CANCELLATIONTIME_IMMEDIATELY = 'immediately'; + const TRACK_ENDPOINT_NAME = 'Forward'; + + /** + * Gets a list of all domains which have the Forward option enabled. + * + * @return string[] A list of all forwards enabled domains for the user + */ + public static function getForwardDomainNames() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getForwardDomainNames')))->getForwardDomainNames(); + } + + /** + * Gets information about a forwarded domain + * + * @param string $forwardDomainName The domain to get the info for + * @return Transip_Forward Forward object with all info if found, an exception otherwise + */ + public static function getInfo($forwardDomainName) + { + return self::_getSoapClient(array_merge(array($forwardDomainName), array('__method' => 'getInfo')))->getInfo($forwardDomainName); + } + + /** + * Order webhosting for a domain name + * + * @param Transip_Forward $forward info about the forward to order. Mandatory fields are $domainName. Other fields are optional. + */ + public static function order($forward) + { + return self::_getSoapClient(array_merge(array($forward), array('__method' => 'order')))->order($forward); + } + + /** + * Cancel webhosting for a domain + * + * @param string $forwardDomainName The domain name of the forward to cancel the forwarding service for + * @param string $endTime the time to cancel the domain (ForwardService::CANCELLATIONTIME_END (end of contract) or ForwardService::CANCELLATIONTIME_IMMEDIATELY (as soon as possible)) + */ + public static function cancel($forwardDomainName, $endTime) + { + return self::_getSoapClient(array_merge(array($forwardDomainName, $endTime), array('__method' => 'cancel')))->cancel($forwardDomainName, $endTime); + } + + /** + * Modify the options of a Forward. All fields set in the Forward object will be changed. + * + * @param Transip_Forward $forward The forward to modify + */ + public static function modify($forward) + { + return self::_getSoapClient(array_merge(array($forward), array('__method' => 'modify')))->modify($forward); + } +} + +?> diff --git a/Transip/Haip.php b/Transip/Haip.php new file mode 100644 index 0000000..9a593ef --- /dev/null +++ b/Transip/Haip.php @@ -0,0 +1,140 @@ + diff --git a/Transip/HaipService.php b/Transip/HaipService.php new file mode 100644 index 0000000..eee8324 --- /dev/null +++ b/Transip/HaipService.php @@ -0,0 +1,539 @@ +' . implode("\n", $errors) . '
'); + + $classMap = array( + 'Haip' => 'Transip_Haip', + 'Vps' => 'Transip_Vps', + ); + + $options = array( + 'classmap' => $classMap, + 'encoding' => 'utf-8', // lets support unicode + 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // see http://bugs.php.net/bug.php?id=43338 + 'trace' => false, // can be used for debugging + ); + + $wsdlUri = "https://{$endpoint}/wsdl/?service=" . self::SERVICE; + try + { + self::$_soapClient = new SoapClient($wsdlUri, $options); + } + catch(SoapFault $sf) + { + throw new Exception("Unable to connect to endpoint '{$endpoint}'"); + } + self::$_soapClient->__setCookie('login', Transip_ApiSettings::$login); + self::$_soapClient->__setCookie('mode', Transip_ApiSettings::$mode); + } + + $timestamp = time(); + $nonce = uniqid('', true); + + self::$_soapClient->__setCookie('timestamp', $timestamp); + self::$_soapClient->__setCookie('nonce', $nonce); + self::$_soapClient->__setCookie('clientVersion', self::API_VERSION); + self::$_soapClient->__setCookie('signature', self::_urlencode(self::_sign(array_merge($parameters, array( + '__service' => self::SERVICE, + '__hostname' => $endpoint, + '__timestamp' => $timestamp, + '__nonce' => $nonce + ))))); + + return self::$_soapClient; + } + + /** + * Calculates the hash to sign our request with based on the given parameters. + * + * @param mixed $parameters The parameters to sign. + * @return string Base64 encoded signing hash. + */ + protected static function _sign($parameters) + { + // Fixup our private key, copy-pasting the key might lead to whitespace faults + if(!preg_match('/-----BEGIN (RSA )?PRIVATE KEY-----(.*)-----END (RSA )?PRIVATE KEY-----/si', Transip_ApiSettings::$privateKey, $matches)) + die('Could not find your private key, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.
'); + + $key = $matches[2]; + $key = preg_replace('/\s*/s', '', $key); + $key = chunk_split($key, 64, "\n"); + + $key = "-----BEGIN PRIVATE KEY-----\n" . $key . "-----END PRIVATE KEY-----"; + + $digest = self::_sha512Asn1(self::_encodeParameters($parameters)); + if(!@openssl_private_encrypt($digest, $signature, $key)) + die('Could not sign your request, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.
'); + + return base64_encode($signature); + } + + /** + * Creates a digest of the given data, with an asn1 header. + * + * @param string $data The data to create a digest of. + * @return string The digest of the data, with asn1 header. + */ + protected static function _sha512Asn1($data) + { + $digest = hash('sha512', $data, true); + + // this ASN1 header is sha512 specific + $asn1 = chr(0x30).chr(0x51); + $asn1 .= chr(0x30).chr(0x0d); + $asn1 .= chr(0x06).chr(0x09); + $asn1 .= chr(0x60).chr(0x86).chr(0x48).chr(0x01).chr(0x65); + $asn1 .= chr(0x03).chr(0x04); + $asn1 .= chr(0x02).chr(0x03); + $asn1 .= chr(0x05).chr(0x00); + $asn1 .= chr(0x04).chr(0x40); + $asn1 .= $digest; + + return $asn1; + } + + /** + * Encodes the given paramaters into a url encoded string based upon RFC 3986. + * + * @param mixed $parameters The parameters to encode. + * @param string $keyPrefix Key prefix. + * @return string The given parameters encoded according to RFC 3986. + */ + protected static function _encodeParameters($parameters, $keyPrefix = null) + { + if(!is_array($parameters) && !is_object($parameters)) + return self::_urlencode($parameters); + + $encodedData = array(); + + foreach($parameters as $key => $value) + { + $encodedKey = is_null($keyPrefix) + ? self::_urlencode($key) + : $keyPrefix . '[' . self::_urlencode($key) . ']'; + + if(is_array($value) || is_object($value)) + { + $encodedData[] = self::_encodeParameters($value, $encodedKey); + } + else + { + $encodedData[] = $encodedKey . '=' . self::_urlencode($value); + } + } + + return implode('&', $encodedData); + } + + /** + * Our own function to encode a string according to RFC 3986 since. + * PHP < 5.3.0 encodes the ~ character which is not allowed. + * + * @param string $string The string to encode. + * @return string The encoded string according to RFC 3986. + */ + protected static function _urlencode($string) + { + $string = trim($string); + $string = rawurlencode($string); + return str_replace('%7E', '~', $string); + } + + const TRACK_ENDPOINT_NAME = 'HA-IP'; + const CANCELLATIONTIME_END = 'end'; + const CANCELLATIONTIME_IMMEDIATELY = 'immediately'; + + /** + * Get a HA-IP by name + * + * @param string $haipName The HA-IP name + * @throws ApiException + * @return Transip_Haip The vps objects + */ + public static function getHaip($haipName) + { + return self::_getSoapClient(array_merge(array($haipName), array('__method' => 'getHaip')))->getHaip($haipName); + } + + /** + * Get all HA-IPs + * + * @return Transip_Haip[] Array of HA-IP objects + */ + public static function getHaips() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getHaips')))->getHaips(); + } + + /** + * Changes the VPS connected to the HA-IP. + * + * @param string $haipName The HA-IP name + * @param string $vpsName The Vps name + * @throws ApiException + */ + public static function changeHaipVps($haipName, $vpsName) + { + return self::_getSoapClient(array_merge(array($haipName, $vpsName), array('__method' => 'changeHaipVps')))->changeHaipVps($haipName, $vpsName); + } + + /** + * Replaces currently attached VPSes to the HA-IP with the provided list of VPSes. + * + * @param string $haipName The HA-IP name + * @param string[] $vpsNames The Vps names + * @throws ApiException + */ + public static function setHaipVpses($haipName, $vpsNames) + { + return self::_getSoapClient(array_merge(array($haipName, $vpsNames), array('__method' => 'setHaipVpses')))->setHaipVpses($haipName, $vpsNames); + } + + /** + * Sets the provided IP setup for the HA-IP. + * + * @param string $haipName The HA-IP name + * @param string $ipSetup The IP setup ('both','noipv6','ipv6to4') + * @throws ApiException + */ + public static function setIpSetup($haipName, $ipSetup) + { + return self::_getSoapClient(array_merge(array($haipName, $ipSetup), array('__method' => 'setIpSetup')))->setIpSetup($haipName, $ipSetup); + } + + /** + * Sets the provided balancing mode for the HA-IP. The cookieName argument may be an empty string unless the + * balancing mode is set to 'cookie'. + * + * This is a HA-IP Pro feature. + * + * @param string $haipName The HA-IP name + * @param string $balancingMode The balancing mode ('roundrobin','cookie','source') + * @param string $cookieName The cookie name that pins the session if the balancing mode is 'cookie' + * @throws ApiException + */ + public static function setBalancingMode($haipName, $balancingMode, $cookieName) + { + return self::_getSoapClient(array_merge(array($haipName, $balancingMode, $cookieName), array('__method' => 'setBalancingMode')))->setBalancingMode($haipName, $balancingMode, $cookieName); + } + + /** + * Configures a HTTP health check for the HA-IP. To disable a HTTP health check use setTcpHealthCheck(). + * + * This is a HA-IP Pro feature. + * + * @param string $haipName The HA-IP name + * @param string $path The path that will be accessed when performing health checks + * @param int $port The port that will be used when performing health checks + * @throws ApiException + */ + public static function setHttpHealthCheck($haipName, $path, $port) + { + return self::_getSoapClient(array_merge(array($haipName, $path, $port), array('__method' => 'setHttpHealthCheck')))->setHttpHealthCheck($haipName, $path, $port); + } + + /** + * Configures a TCP health check for the HA-IP (this is the default health check). + * + * This is a HA-IP Pro feature. + * + * @param string $haipName The HA-IP name + * @throws ApiException + */ + public static function setTcpHealthCheck($haipName) + { + return self::_getSoapClient(array_merge(array($haipName), array('__method' => 'setTcpHealthCheck')))->setTcpHealthCheck($haipName); + } + + /** + * Get a status report for the HA-IP. + * + * This is a HA-IP Pro feature. + * + * @param string $haipName The HA-IP name + * @throws ApiException + * @return array + */ + public static function getStatusReport($haipName) + { + return self::_getSoapClient(array_merge(array($haipName), array('__method' => 'getStatusReport')))->getStatusReport($haipName); + } + + /** + * Get all Certificates by Haip + * + * @param string $haipName + * @throws ApiException + * @return array + */ + public static function getCertificatesByHaip($haipName) + { + return self::_getSoapClient(array_merge(array($haipName), array('__method' => 'getCertificatesByHaip')))->getCertificatesByHaip($haipName); + } + + /** + * Get all available certificates ready to attach to your HAIP + * + * @param string $haipName + * @throws ApiException + * @return array + */ + public static function getAvailableCertificatesByHaip($haipName) + { + return self::_getSoapClient(array_merge(array($haipName), array('__method' => 'getAvailableCertificatesByHaip')))->getAvailableCertificatesByHaip($haipName); + } + + /** + * Add a HaipCertificate to this object + * + * @param string $haipName + * @param int $certificateId + * @throws ApiException + */ + public static function addCertificateToHaip($haipName, $certificateId) + { + return self::_getSoapClient(array_merge(array($haipName, $certificateId), array('__method' => 'addCertificateToHaip')))->addCertificateToHaip($haipName, $certificateId); + } + + /** + * Removes a Certificate from this HA-IP + * + * @param string $haipName + * @param int $certificateId + * @throws ApiException + */ + public static function deleteCertificateFromHaip($haipName, $certificateId) + { + return self::_getSoapClient(array_merge(array($haipName, $certificateId), array('__method' => 'deleteCertificateFromHaip')))->deleteCertificateFromHaip($haipName, $certificateId); + } + + /** + * Add EncryptCertificate to HA-IP + * + * @param string $haipName + * @param string $commonName + * @throws ApiException + */ + public static function startHaipLetsEncryptCertificateIssue($haipName, $commonName) + { + return self::_getSoapClient(array_merge(array($haipName, $commonName), array('__method' => 'startHaipLetsEncryptCertificateIssue')))->startHaipLetsEncryptCertificateIssue($haipName, $commonName); + } + + /** + * Returns the current ptr for the given HA-IP + * + * @param string $haipName + * @throws ApiException + * @return string + */ + public static function getPtrForHaip($haipName) + { + return self::_getSoapClient(array_merge(array($haipName), array('__method' => 'getPtrForHaip')))->getPtrForHaip($haipName); + } + + /** + * Update the ptr records for the given HA-IP + * + * @param string $haipName + * @param string $ptr + * @throws ApiException + */ + public static function setPtrForHaip($haipName, $ptr) + { + return self::_getSoapClient(array_merge(array($haipName, $ptr), array('__method' => 'setPtrForHaip')))->setPtrForHaip($haipName, $ptr); + } + + /** + * Update the description for HA-IP + * + * @param string $haipName + * @param string $description + * @throws ApiException + */ + public static function setHaipDescription($haipName, $description) + { + return self::_getSoapClient(array_merge(array($haipName, $description), array('__method' => 'setHaipDescription')))->setHaipDescription($haipName, $description); + } + + /** + * Get all port configurations for given HA-IP + * + * @param string $haipName The HA-IP name + * @deprecated Please use HaipService::getPortConfigurations() + * @throws ApiException + * @return array + */ + public static function getHaipPortConfigurations($haipName) + { + return self::_getSoapClient(array_merge(array($haipName), array('__method' => 'getHaipPortConfigurations')))->getHaipPortConfigurations($haipName); + } + + /** + * Get all port configurations for given HA-IP + * + * @param string $haipName The HA-IP name + * @throws ApiException + * @return array + */ + public static function getPortConfigurations($haipName) + { + return self::_getSoapClient(array_merge(array($haipName), array('__method' => 'getPortConfigurations')))->getPortConfigurations($haipName); + } + + /** + * Set default port configurations for given HA-IP + * + * @param string $haipName The HA-IP name + * @throws ApiException + */ + public static function setDefaultPortConfiguration($haipName) + { + return self::_getSoapClient(array_merge(array($haipName), array('__method' => 'setDefaultPortConfiguration')))->setDefaultPortConfiguration($haipName); + } + + /** + * Add port configuration to HA-IP + * + * @param string $haipName The HA-IP name + * @param string $name The name describing the port configuration + * @param int $portNumber The port that is addressed on the HA-IP IP + * @param string $mode The port mode ('tcp','http','https','proxy') + * @deprecated Please use HaipService::addPortConfiguration() + * @throws ApiException + */ + public static function addHaipPortConfiguration($haipName, $name, $portNumber, $mode) + { + return self::_getSoapClient(array_merge(array($haipName, $name, $portNumber, $mode), array('__method' => 'addHaipPortConfiguration')))->addHaipPortConfiguration($haipName, $name, $portNumber, $mode); + } + + /** + * Add port configuration to HA-IP + * + * @param string $haipName The HA-IP name + * @param string $name The name describing the port configuration + * @param int $sourcePort The port that is addressed on the HA-IP IP + * @param int $targetPort The port that is addressed on the VPS + * @param string $mode The port mode ('tcp','http','https','proxy') + * @param string $endpointSslMode The SSL mode for the endpoint ('off','on','strict') + * @throws ApiException + */ + public static function addPortConfiguration($haipName, $name, $sourcePort, $targetPort, $mode, $endpointSslMode) + { + return self::_getSoapClient(array_merge(array($haipName, $name, $sourcePort, $targetPort, $mode, $endpointSslMode), array('__method' => 'addPortConfiguration')))->addPortConfiguration($haipName, $name, $sourcePort, $targetPort, $mode, $endpointSslMode); + } + + /** + * Update port configuration to HA-IP + * + * @param string $haipName The HA-IP name + * @param int $configurationId The identifier for the configuration + * @param string $name The name describing the port configuration + * @param int $portNumber The port that is addressed on the HA-IP IP + * @param string $mode The port mode ('tcp','http','https','proxy') + * @deprecated Please use HaipService::updatePortConfiguration() + * @throws ApiException + */ + public static function updateHaipPortConfiguration($haipName, $configurationId, $name, $portNumber, $mode) + { + return self::_getSoapClient(array_merge(array($haipName, $configurationId, $name, $portNumber, $mode), array('__method' => 'updateHaipPortConfiguration')))->updateHaipPortConfiguration($haipName, $configurationId, $name, $portNumber, $mode); + } + + /** + * Update port configuration to HA-IP + * + * @param string $haipName The HA-IP name + * @param int $configurationId The identifier for the configuration + * @param string $name The name describing the port configuration + * @param int $sourcePort The port that is addressed on the HA-IP IP + * @param int $targetPort The port that is addressed on the VPS + * @param string $mode The port mode ('tcp','http','https','proxy') + * @param string $endpointSslMode The SSL mode for the endpoint ('off','on','strict') + * @throws ApiException + */ + public static function updatePortConfiguration($haipName, $configurationId, $name, $sourcePort, $targetPort, $mode, $endpointSslMode) + { + return self::_getSoapClient(array_merge(array($haipName, $configurationId, $name, $sourcePort, $targetPort, $mode, $endpointSslMode), array('__method' => 'updatePortConfiguration')))->updatePortConfiguration($haipName, $configurationId, $name, $sourcePort, $targetPort, $mode, $endpointSslMode); + } + + /** + * Delete configuration with the provided id from the HA-IP. + * + * @param string $haipName The HA-IP name + * @param int $configurationId The identifier for the configuration + * @deprecated Please use HaipService::deletePortConfiguration() + * @throws ApiException + */ + public static function deleteHaipPortConfiguration($haipName, $configurationId) + { + return self::_getSoapClient(array_merge(array($haipName, $configurationId), array('__method' => 'deleteHaipPortConfiguration')))->deleteHaipPortConfiguration($haipName, $configurationId); + } + + /** + * + * + * @param string $haipName + * @param int $configurationId + * @throws ApiException + */ + public static function deletePortConfiguration($haipName, $configurationId) + { + return self::_getSoapClient(array_merge(array($haipName, $configurationId), array('__method' => 'deletePortConfiguration')))->deletePortConfiguration($haipName, $configurationId); + } + + /** + * Cancel a Haip + * + * @param string $haipName The vps to cancel + * @param string $endTime The time to cancel the haip (HaipService::CANCELLATIONTIME_END (end of contract) + * @throws ApiException on error + */ + public static function cancelHaip($haipName, $endTime) + { + return self::_getSoapClient(array_merge(array($haipName, $endTime), array('__method' => 'cancelHaip')))->cancelHaip($haipName, $endTime); + } +} + +?> diff --git a/Transip/MailBox.php b/Transip/MailBox.php new file mode 100644 index 0000000..db34c85 --- /dev/null +++ b/Transip/MailBox.php @@ -0,0 +1,80 @@ +address = $address; + $this->spamCheckerStrength = $spamCheckerStrength; + $this->maxDiskUsage = $maxDiskUsage; + $this->hasVacationReply = $hasVacationReply; + $this->vacationReplySubject = $vacationReplySubject; + $this->vacationReplyMessage = $vacationReplyMessage; + } +} + +?> diff --git a/Transip/MailForward.php b/Transip/MailForward.php new file mode 100644 index 0000000..b8f7342 --- /dev/null +++ b/Transip/MailForward.php @@ -0,0 +1,39 @@ +name = $name; + $this->targetAddress = $targetAddress; + } +} + +?> diff --git a/Transip/Nameserver.php b/Transip/Nameserver.php new file mode 100644 index 0000000..e492a9d --- /dev/null +++ b/Transip/Nameserver.php @@ -0,0 +1,50 @@ +hostname = $hostname; + $this->ipv4 = $ipv4; + $this->ipv6 = $ipv6; + } +} + +?> diff --git a/Transip/OperatingSystem.php b/Transip/OperatingSystem.php new file mode 100644 index 0000000..b7b1cb7 --- /dev/null +++ b/Transip/OperatingSystem.php @@ -0,0 +1,41 @@ + diff --git a/Transip/PrivateNetwork.php b/Transip/PrivateNetwork.php new file mode 100644 index 0000000..5c7a0f7 --- /dev/null +++ b/Transip/PrivateNetwork.php @@ -0,0 +1,20 @@ + diff --git a/Transip/Product.php b/Transip/Product.php new file mode 100644 index 0000000..9f84c26 --- /dev/null +++ b/Transip/Product.php @@ -0,0 +1,41 @@ + diff --git a/Transip/PropositionService.php b/Transip/PropositionService.php new file mode 100644 index 0000000..801a505 --- /dev/null +++ b/Transip/PropositionService.php @@ -0,0 +1,194 @@ +' . implode("\n", $errors) . '
'); + + $classMap = array( + ); + + $options = array( + 'classmap' => $classMap, + 'encoding' => 'utf-8', // lets support unicode + 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // see http://bugs.php.net/bug.php?id=43338 + 'trace' => false, // can be used for debugging + ); + + $wsdlUri = "https://{$endpoint}/wsdl/?service=" . self::SERVICE; + try + { + self::$_soapClient = new SoapClient($wsdlUri, $options); + } + catch(SoapFault $sf) + { + throw new Exception("Unable to connect to endpoint '{$endpoint}'"); + } + self::$_soapClient->__setCookie('login', Transip_ApiSettings::$login); + self::$_soapClient->__setCookie('mode', Transip_ApiSettings::$mode); + } + + $timestamp = time(); + $nonce = uniqid('', true); + + self::$_soapClient->__setCookie('timestamp', $timestamp); + self::$_soapClient->__setCookie('nonce', $nonce); + self::$_soapClient->__setCookie('clientVersion', self::API_VERSION); + self::$_soapClient->__setCookie('signature', self::_urlencode(self::_sign(array_merge($parameters, array( + '__service' => self::SERVICE, + '__hostname' => $endpoint, + '__timestamp' => $timestamp, + '__nonce' => $nonce + ))))); + + return self::$_soapClient; + } + + /** + * Calculates the hash to sign our request with based on the given parameters. + * + * @param mixed $parameters The parameters to sign. + * @return string Base64 encoded signing hash. + */ + protected static function _sign($parameters) + { + // Fixup our private key, copy-pasting the key might lead to whitespace faults + if(!preg_match('/-----BEGIN (RSA )?PRIVATE KEY-----(.*)-----END (RSA )?PRIVATE KEY-----/si', Transip_ApiSettings::$privateKey, $matches)) + die('Could not find your private key, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.
'); + + $key = $matches[2]; + $key = preg_replace('/\s*/s', '', $key); + $key = chunk_split($key, 64, "\n"); + + $key = "-----BEGIN PRIVATE KEY-----\n" . $key . "-----END PRIVATE KEY-----"; + + $digest = self::_sha512Asn1(self::_encodeParameters($parameters)); + if(!@openssl_private_encrypt($digest, $signature, $key)) + die('Could not sign your request, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.
'); + + return base64_encode($signature); + } + + /** + * Creates a digest of the given data, with an asn1 header. + * + * @param string $data The data to create a digest of. + * @return string The digest of the data, with asn1 header. + */ + protected static function _sha512Asn1($data) + { + $digest = hash('sha512', $data, true); + + // this ASN1 header is sha512 specific + $asn1 = chr(0x30).chr(0x51); + $asn1 .= chr(0x30).chr(0x0d); + $asn1 .= chr(0x06).chr(0x09); + $asn1 .= chr(0x60).chr(0x86).chr(0x48).chr(0x01).chr(0x65); + $asn1 .= chr(0x03).chr(0x04); + $asn1 .= chr(0x02).chr(0x03); + $asn1 .= chr(0x05).chr(0x00); + $asn1 .= chr(0x04).chr(0x40); + $asn1 .= $digest; + + return $asn1; + } + + /** + * Encodes the given paramaters into a url encoded string based upon RFC 3986. + * + * @param mixed $parameters The parameters to encode. + * @param string $keyPrefix Key prefix. + * @return string The given parameters encoded according to RFC 3986. + */ + protected static function _encodeParameters($parameters, $keyPrefix = null) + { + if(!is_array($parameters) && !is_object($parameters)) + return self::_urlencode($parameters); + + $encodedData = array(); + + foreach($parameters as $key => $value) + { + $encodedKey = is_null($keyPrefix) + ? self::_urlencode($key) + : $keyPrefix . '[' . self::_urlencode($key) . ']'; + + if(is_array($value) || is_object($value)) + { + $encodedData[] = self::_encodeParameters($value, $encodedKey); + } + else + { + $encodedData[] = $encodedKey . '=' . self::_urlencode($value); + } + } + + return implode('&', $encodedData); + } + + /** + * Our own function to encode a string according to RFC 3986 since. + * PHP < 5.3.0 encodes the ~ character which is not allowed. + * + * @param string $string The string to encode. + * @return string The encoded string according to RFC 3986. + */ + protected static function _urlencode($string) + { + $string = trim($string); + $string = rawurlencode($string); + return str_replace('%7E', '~', $string); + } + + /** + * Returns the status for a proposition number ('pending', 'finished' or 'invalid') + * + * @param string $propositionNumber + * @return string + * @throws ApiException + */ + public static function getPropositionStatus($propositionNumber) + { + return self::_getSoapClient(array_merge(array($propositionNumber), array('__method' => 'getPropositionStatus')))->getPropositionStatus($propositionNumber); + } +} + +?> diff --git a/Transip/Snapshot.php b/Transip/Snapshot.php new file mode 100644 index 0000000..f0d4310 --- /dev/null +++ b/Transip/Snapshot.php @@ -0,0 +1,41 @@ + diff --git a/Transip/SubDomain.php b/Transip/SubDomain.php new file mode 100644 index 0000000..dabc9ab --- /dev/null +++ b/Transip/SubDomain.php @@ -0,0 +1,30 @@ +name = $name; + } +} + +?> diff --git a/Transip/Tld.php b/Transip/Tld.php new file mode 100644 index 0000000..7cb301e --- /dev/null +++ b/Transip/Tld.php @@ -0,0 +1,70 @@ + diff --git a/Transip/Vps.php b/Transip/Vps.php new file mode 100644 index 0000000..5c6df40 --- /dev/null +++ b/Transip/Vps.php @@ -0,0 +1,125 @@ + diff --git a/Transip/VpsBackup.php b/Transip/VpsBackup.php new file mode 100644 index 0000000..6673bc3 --- /dev/null +++ b/Transip/VpsBackup.php @@ -0,0 +1,48 @@ + diff --git a/Transip/VpsService.php b/Transip/VpsService.php new file mode 100644 index 0000000..2d1f32e --- /dev/null +++ b/Transip/VpsService.php @@ -0,0 +1,702 @@ +' . implode("\n", $errors) . '
'); + + $classMap = array( + 'Product' => 'Transip_Product', + 'PrivateNetwork' => 'Transip_PrivateNetwork', + 'Vps' => 'Transip_Vps', + 'Snapshot' => 'Transip_Snapshot', + 'VpsBackup' => 'Transip_VpsBackup', + 'OperatingSystem' => 'Transip_OperatingSystem', + 'AvailabilityZone' => 'Transip_AvailabilityZone', + ); + + $options = array( + 'classmap' => $classMap, + 'encoding' => 'utf-8', // lets support unicode + 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // see http://bugs.php.net/bug.php?id=43338 + 'trace' => false, // can be used for debugging + ); + + $wsdlUri = "https://{$endpoint}/wsdl/?service=" . self::SERVICE; + try + { + self::$_soapClient = new SoapClient($wsdlUri, $options); + } + catch(SoapFault $sf) + { + throw new Exception("Unable to connect to endpoint '{$endpoint}'"); + } + self::$_soapClient->__setCookie('login', Transip_ApiSettings::$login); + self::$_soapClient->__setCookie('mode', Transip_ApiSettings::$mode); + } + + $timestamp = time(); + $nonce = uniqid('', true); + + self::$_soapClient->__setCookie('timestamp', $timestamp); + self::$_soapClient->__setCookie('nonce', $nonce); + self::$_soapClient->__setCookie('clientVersion', self::API_VERSION); + self::$_soapClient->__setCookie('signature', self::_urlencode(self::_sign(array_merge($parameters, array( + '__service' => self::SERVICE, + '__hostname' => $endpoint, + '__timestamp' => $timestamp, + '__nonce' => $nonce + ))))); + + return self::$_soapClient; + } + + /** + * Calculates the hash to sign our request with based on the given parameters. + * + * @param mixed $parameters The parameters to sign. + * @return string Base64 encoded signing hash. + */ + protected static function _sign($parameters) + { + // Fixup our private key, copy-pasting the key might lead to whitespace faults + if(!preg_match('/-----BEGIN (RSA )?PRIVATE KEY-----(.*)-----END (RSA )?PRIVATE KEY-----/si', Transip_ApiSettings::$privateKey, $matches)) + die('Could not find your private key, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.
'); + + $key = $matches[2]; + $key = preg_replace('/\s*/s', '', $key); + $key = chunk_split($key, 64, "\n"); + + $key = "-----BEGIN PRIVATE KEY-----\n" . $key . "-----END PRIVATE KEY-----"; + + $digest = self::_sha512Asn1(self::_encodeParameters($parameters)); + if(!@openssl_private_encrypt($digest, $signature, $key)) + die('Could not sign your request, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.
'); + + return base64_encode($signature); + } + + /** + * Creates a digest of the given data, with an asn1 header. + * + * @param string $data The data to create a digest of. + * @return string The digest of the data, with asn1 header. + */ + protected static function _sha512Asn1($data) + { + $digest = hash('sha512', $data, true); + + // this ASN1 header is sha512 specific + $asn1 = chr(0x30).chr(0x51); + $asn1 .= chr(0x30).chr(0x0d); + $asn1 .= chr(0x06).chr(0x09); + $asn1 .= chr(0x60).chr(0x86).chr(0x48).chr(0x01).chr(0x65); + $asn1 .= chr(0x03).chr(0x04); + $asn1 .= chr(0x02).chr(0x03); + $asn1 .= chr(0x05).chr(0x00); + $asn1 .= chr(0x04).chr(0x40); + $asn1 .= $digest; + + return $asn1; + } + + /** + * Encodes the given paramaters into a url encoded string based upon RFC 3986. + * + * @param mixed $parameters The parameters to encode. + * @param string $keyPrefix Key prefix. + * @return string The given parameters encoded according to RFC 3986. + */ + protected static function _encodeParameters($parameters, $keyPrefix = null) + { + if(!is_array($parameters) && !is_object($parameters)) + return self::_urlencode($parameters); + + $encodedData = array(); + + foreach($parameters as $key => $value) + { + $encodedKey = is_null($keyPrefix) + ? self::_urlencode($key) + : $keyPrefix . '[' . self::_urlencode($key) . ']'; + + if(is_array($value) || is_object($value)) + { + $encodedData[] = self::_encodeParameters($value, $encodedKey); + } + else + { + $encodedData[] = $encodedKey . '=' . self::_urlencode($value); + } + } + + return implode('&', $encodedData); + } + + /** + * Our own function to encode a string according to RFC 3986 since. + * PHP < 5.3.0 encodes the ~ character which is not allowed. + * + * @param string $string The string to encode. + * @return string The encoded string according to RFC 3986. + */ + protected static function _urlencode($string) + { + $string = trim($string); + $string = rawurlencode($string); + return str_replace('%7E', '~', $string); + } + + const CANCELLATIONTIME_END = 'end'; + const CANCELLATIONTIME_IMMEDIATELY = 'immediately'; + const TRACK_ENDPOINT_NAME = 'VPS'; + + /** + * Get available VPS products + * + * @return Transip_Product[] List of available VPS Products + */ + public static function getAvailableProducts() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getAvailableProducts')))->getAvailableProducts(); + } + + /** + * Get available VPS addons + * + * @return Transip_Product[] List of available VPS Products + */ + public static function getAvailableAddons() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getAvailableAddons')))->getAvailableAddons(); + } + + /** + * Get all the Active Addons for Vps + * + * @param string $vpsName The name of the VPS + * @return Transip_Product[] List of available VPS Products + */ + public static function getActiveAddonsForVps($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'getActiveAddonsForVps')))->getActiveAddonsForVps($vpsName); + } + + /** + * Get available VPS upgrades for a specific Vps + * + * @param string $vpsName The name of the VPS + * @return Transip_Product[] List of available VPS Products + */ + public static function getAvailableUpgrades($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'getAvailableUpgrades')))->getAvailableUpgrades($vpsName); + } + + /** + * Get available Addons for Vps + * + * @param string $vpsName The name of the VPS + * @return Transip_Product[] List of available VPS Products + */ + public static function getAvailableAddonsForVps($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'getAvailableAddonsForVps')))->getAvailableAddonsForVps($vpsName); + } + + /** + * Get cancellable addons for specific Vps + * + * @param string $vpsName The name of the Vps + * @return Transip_Product[] List of cancellable addons for this Vps + */ + public static function getCancellableAddonsForVps($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'getCancellableAddonsForVps')))->getCancellableAddonsForVps($vpsName); + } + + /** + * Order a VPS with optional Addons + * + * @param string $productName Name of the product + * @param string[] $addons array with additional addons + * @param string $operatingSystemName The name of the operatingSystem to install + * @param string $hostname The name for the host + * @throws Exception + */ + public static function orderVps($productName, $addons, $operatingSystemName, $hostname) + { + return self::_getSoapClient(array_merge(array($productName, $addons, $operatingSystemName, $hostname), array('__method' => 'orderVps')))->orderVps($productName, $addons, $operatingSystemName, $hostname); + } + + /** + * Order a VPS with optional Addons + * + * @param string $productName Name of the product + * @param string[] $addons array with additional addons + * @param string $operatingSystemName The name of the operatingSystem to install + * @param string $hostname The name for the host + * @param string $availabilityZone The availability zone the vps should be created in + * @throws Exception + */ + public static function orderVpsInAvailabilityZone($productName, $addons, $operatingSystemName, $hostname, $availabilityZone) + { + return self::_getSoapClient(array_merge(array($productName, $addons, $operatingSystemName, $hostname, $availabilityZone), array('__method' => 'orderVpsInAvailabilityZone')))->orderVpsInAvailabilityZone($productName, $addons, $operatingSystemName, $hostname, $availabilityZone); + } + + /** + * Clone a VPS + * + * @param string $vpsName The vps name + * @throws Exception + */ + public static function cloneVps($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'cloneVps')))->cloneVps($vpsName); + } + + /** + * Clone a VPS + * + * @param string $vpsName The vps name + * @param string $availabilityZone The availability zone the clone should be created in. + * @throws Exception + */ + public static function cloneVpsToAvailabilityZone($vpsName, $availabilityZone) + { + return self::_getSoapClient(array_merge(array($vpsName, $availabilityZone), array('__method' => 'cloneVpsToAvailabilityZone')))->cloneVpsToAvailabilityZone($vpsName, $availabilityZone); + } + + /** + * Order addons to a VPS + * + * @param string $vpsName The name of the VPS + * @param string[] $addons Array with Addons + * @throws ApiException on error + */ + public static function orderAddon($vpsName, $addons) + { + return self::_getSoapClient(array_merge(array($vpsName, $addons), array('__method' => 'orderAddon')))->orderAddon($vpsName, $addons); + } + + /** + * Order a private Network + * + * @throws ApiException on error + */ + public static function orderPrivateNetwork() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'orderPrivateNetwork')))->orderPrivateNetwork(); + } + + /** + * upgrade a Vps + * + * @param string $vpsName The name of the VPS + * @param string $upgradeToProductName The name of the product to upgrade to + * @throws ApiException on error + */ + public static function upgradeVps($vpsName, $upgradeToProductName) + { + return self::_getSoapClient(array_merge(array($vpsName, $upgradeToProductName), array('__method' => 'upgradeVps')))->upgradeVps($vpsName, $upgradeToProductName); + } + + /** + * Cancel a Vps + * + * @param string $vpsName The vps to cancel + * @param string $endTime The time to cancel the vps (VpsService::CANCELLATIONTIME_END (end of contract) + * @throws ApiException on error + */ + public static function cancelVps($vpsName, $endTime) + { + return self::_getSoapClient(array_merge(array($vpsName, $endTime), array('__method' => 'cancelVps')))->cancelVps($vpsName, $endTime); + } + + /** + * Cancel a Vps Addon + * + * @param string $vpsName The vps to cancel + * @param string $addonName name of the addon + * @throws ApiException on error + */ + public static function cancelAddon($vpsName, $addonName) + { + return self::_getSoapClient(array_merge(array($vpsName, $addonName), array('__method' => 'cancelAddon')))->cancelAddon($vpsName, $addonName); + } + + /** + * Cancel a PrivateNetwork + * + * @param string $privateNetworkName the name of the private network to cancel + * @param string $endTime The time to cancel the vps (VpsService::CANCELLATIONTIME_END (end of contract) + * @throws ApiException on error + */ + public static function cancelPrivateNetwork($privateNetworkName, $endTime) + { + return self::_getSoapClient(array_merge(array($privateNetworkName, $endTime), array('__method' => 'cancelPrivateNetwork')))->cancelPrivateNetwork($privateNetworkName, $endTime); + } + + /** + * Get Private networks for a specific vps + * + * @param string $vpsName The name of the VPS + * @return Transip_PrivateNetwork[] $privateNetworks Array of PrivateNetwork objects + */ + public static function getPrivateNetworksByVps($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'getPrivateNetworksByVps')))->getPrivateNetworksByVps($vpsName); + } + + /** + * Get all Private networks in your account + * + * @return Transip_PrivateNetwork[] $privateNetworks Array of PrivateNetwork objects + */ + public static function getAllPrivateNetworks() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getAllPrivateNetworks')))->getAllPrivateNetworks(); + } + + /** + * Add VPS to a private Network + * + * @param string $vpsName The name of the VPS + * @param string $privateNetworkName The name of the privateNetwork to add to + */ + public static function addVpsToPrivateNetwork($vpsName, $privateNetworkName) + { + return self::_getSoapClient(array_merge(array($vpsName, $privateNetworkName), array('__method' => 'addVpsToPrivateNetwork')))->addVpsToPrivateNetwork($vpsName, $privateNetworkName); + } + + /** + * Remove VPS from a private Network + * + * @param string $vpsName The name of the VPS + * @param string $privateNetworkName The name of the private Network + */ + public static function removeVpsFromPrivateNetwork($vpsName, $privateNetworkName) + { + return self::_getSoapClient(array_merge(array($vpsName, $privateNetworkName), array('__method' => 'removeVpsFromPrivateNetwork')))->removeVpsFromPrivateNetwork($vpsName, $privateNetworkName); + } + + /** + * Get Traffic information by vpsName for this contractPeriod + * + * @param string $vpsName The name of the VPS + * @throws ApiException on error + * @return array The traffic information for this VPS + */ + public static function getTrafficInformationForVps($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'getTrafficInformationForVps')))->getTrafficInformationForVps($vpsName); + } + + /** + * Get PooledTraffic information for the account + * + * @return array + */ + public static function getPooledTrafficInformation() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getPooledTrafficInformation')))->getPooledTrafficInformation(); + } + + /** + * Start a Vps + * + * @param string $vpsName The vps name + * @throws ApiException on error + */ + public static function start($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'start')))->start($vpsName); + } + + /** + * Stop a Vps + * + * @param string $vpsName The vps name + * @throws ApiException on error + */ + public static function stop($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'stop')))->stop($vpsName); + } + + /** + * Reset a Vps + * + * @param string $vpsName The vps name + * @throws ApiException on error + */ + public static function reset($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'reset')))->reset($vpsName); + } + + /** + * Create a snapshot + * + * @param string $vpsName The vps name + * @param string $description The snapshot description + * @throws ApiException on error + */ + public static function createSnapshot($vpsName, $description) + { + return self::_getSoapClient(array_merge(array($vpsName, $description), array('__method' => 'createSnapshot')))->createSnapshot($vpsName, $description); + } + + /** + * Revert a snapshot + * + * @param string $vpsName The vps name + * @param string $snapshotName The snapshot name + * @throws ApiException on error + */ + public static function revertSnapshot($vpsName, $snapshotName) + { + return self::_getSoapClient(array_merge(array($vpsName, $snapshotName), array('__method' => 'revertSnapshot')))->revertSnapshot($vpsName, $snapshotName); + } + + /** + * Revert a snapshot to another VPS + * + * @param string $sourceVpsName The name of the VPS where the snapshot is made + * @param string $snapshotName The snapshot name + * @param string $destinationVpsName The name of the VPS where the snapshot should be reverted to + * @throws ApiException on error + */ + public static function revertSnapshotToOtherVps($sourceVpsName, $snapshotName, $destinationVpsName) + { + return self::_getSoapClient(array_merge(array($sourceVpsName, $snapshotName, $destinationVpsName), array('__method' => 'revertSnapshotToOtherVps')))->revertSnapshotToOtherVps($sourceVpsName, $snapshotName, $destinationVpsName); + } + + /** + * Remove a snapshot + * + * @param string $vpsName The vps name + * @param string $snapshotName The snapshot name + * @throws ApiException on error + */ + public static function removeSnapshot($vpsName, $snapshotName) + { + return self::_getSoapClient(array_merge(array($vpsName, $snapshotName), array('__method' => 'removeSnapshot')))->removeSnapshot($vpsName, $snapshotName); + } + + /** + * Revert a vps backup + * + * @param string $vpsName The vps name + * @param int $vpsBackupId The backup id + * @throws ApiException on error + */ + public static function revertVpsBackup($vpsName, $vpsBackupId) + { + return self::_getSoapClient(array_merge(array($vpsName, $vpsBackupId), array('__method' => 'revertVpsBackup')))->revertVpsBackup($vpsName, $vpsBackupId); + } + + /** + * Get a Vps by name + * + * @param string $vpsName The vps name + * @return Transip_Vps $vps The vps objects + */ + public static function getVps($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'getVps')))->getVps($vpsName); + } + + /** + * Get all Vpses + * + * @return Transip_Vps[] Array of Vps objects + */ + public static function getVpses() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getVpses')))->getVpses(); + } + + /** + * Get all Snapshots for a vps + * + * @param string $vpsName The name of the VPS + * @return Transip_Snapshot[] $snapshotArray Array of snapshot objects + */ + public static function getSnapshotsByVps($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'getSnapshotsByVps')))->getSnapshotsByVps($vpsName); + } + + /** + * Get all VpsBackups for a vps + * + * @param string $vpsName The name of the VPS + * @return Transip_VpsBackup[] $vpsBackupArray Array of snapshot objects + */ + public static function getVpsBackupsByVps($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'getVpsBackupsByVps')))->getVpsBackupsByVps($vpsName); + } + + /** + * Get all operating systems + * + * @return Transip_OperatingSystem[] Array of OperatingSystem objects + */ + public static function getOperatingSystems() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getOperatingSystems')))->getOperatingSystems(); + } + + /** + * Install an operating system on a vps + * + * @param string $vpsName The name of the VPS + * @param string $operatingSystemName The name of the operating to install + * @param string $hostname preinstallable Only + */ + public static function installOperatingSystem($vpsName, $operatingSystemName, $hostname) + { + return self::_getSoapClient(array_merge(array($vpsName, $operatingSystemName, $hostname), array('__method' => 'installOperatingSystem')))->installOperatingSystem($vpsName, $operatingSystemName, $hostname); + } + + /** + * Install an operating system on a vps with a unattended installfile + * + * @param string $vpsName The name of the VPS + * @param string $operatingSystemName The name of the operating to install + * @param string $base64InstallText base64_encoded preseed/kickstart text + * @throws ApiException + */ + public static function installOperatingSystemUnattended($vpsName, $operatingSystemName, $base64InstallText) + { + return self::_getSoapClient(array_merge(array($vpsName, $operatingSystemName, $base64InstallText), array('__method' => 'installOperatingSystemUnattended')))->installOperatingSystemUnattended($vpsName, $operatingSystemName, $base64InstallText); + } + + /** + * Get Ips for a specific Vps + * + * @param string $vpsName The name of the Vps + * @return string[] $ipAddresses Array of ipAddresses + */ + public static function getIpsForVps($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'getIpsForVps')))->getIpsForVps($vpsName); + } + + /** + * Get All ips + * + * @return string[] $ipAddresses Array of ipAddresses + */ + public static function getAllIps() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getAllIps')))->getAllIps(); + } + + /** + * Add Ipv6 Address to Vps + * + * @param string $vpsName The name of the VPS + * @param string $ipv6Address The Ipv6 Address from your range + * @throws ApiException on error + */ + public static function addIpv6ToVps($vpsName, $ipv6Address) + { + return self::_getSoapClient(array_merge(array($vpsName, $ipv6Address), array('__method' => 'addIpv6ToVps')))->addIpv6ToVps($vpsName, $ipv6Address); + } + + /** + * Update PTR record (reverse DNS) for an ipAddress + * + * @param string $ipAddress The IP Address to update (ipv4 or ipv6) + * @param string $ptrRecord The PTR Record to update to + * @throws ApiException on error + */ + public static function updatePtrRecord($ipAddress, $ptrRecord) + { + return self::_getSoapClient(array_merge(array($ipAddress, $ptrRecord), array('__method' => 'updatePtrRecord')))->updatePtrRecord($ipAddress, $ptrRecord); + } + + /** + * Enable or Disable a Customer Lock for a Vps + * + * @param string $vpsName The name of the Vps + * @param boolean $enabled Enable (true) or Disable (false) the lock + * @throws ApiException on error + */ + public static function setCustomerLock($vpsName, $enabled) + { + return self::_getSoapClient(array_merge(array($vpsName, $enabled), array('__method' => 'setCustomerLock')))->setCustomerLock($vpsName, $enabled); + } + + /** + * Handover a VPS to another TransIP User + * + * @param string $vpsName The name of the Vps + * @param string $targetAccountname the target account name + * @throws ApiException on error + */ + public static function handoverVps($vpsName, $targetAccountname) + { + return self::_getSoapClient(array_merge(array($vpsName, $targetAccountname), array('__method' => 'handoverVps')))->handoverVps($vpsName, $targetAccountname); + } + + /** + * Returns an array of available AvailabilityZones + * + * @return Transip_AvailabilityZone[] an array of AvailabilityZones + */ + public static function getAvailableAvailabilityZones() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getAvailableAvailabilityZones')))->getAvailableAvailabilityZones(); + } +} + +?> diff --git a/Transip/WebHost.php b/Transip/WebHost.php new file mode 100644 index 0000000..c630a0b --- /dev/null +++ b/Transip/WebHost.php @@ -0,0 +1,60 @@ + diff --git a/Transip/WebhostingPackage.php b/Transip/WebhostingPackage.php new file mode 100644 index 0000000..34b2412 --- /dev/null +++ b/Transip/WebhostingPackage.php @@ -0,0 +1,41 @@ + diff --git a/Transip/WebhostingService.php b/Transip/WebhostingService.php new file mode 100644 index 0000000..7f4062b --- /dev/null +++ b/Transip/WebhostingService.php @@ -0,0 +1,474 @@ +' . implode("\n", $errors) . '
'); + + $classMap = array( + 'WebhostingPackage' => 'Transip_WebhostingPackage', + 'WebHost' => 'Transip_WebHost', + 'Cronjob' => 'Transip_Cronjob', + 'MailBox' => 'Transip_MailBox', + 'Db' => 'Transip_Db', + 'MailForward' => 'Transip_MailForward', + 'SubDomain' => 'Transip_SubDomain', + ); + + $options = array( + 'classmap' => $classMap, + 'encoding' => 'utf-8', // lets support unicode + 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // see http://bugs.php.net/bug.php?id=43338 + 'trace' => false, // can be used for debugging + ); + + $wsdlUri = "https://{$endpoint}/wsdl/?service=" . self::SERVICE; + try + { + self::$_soapClient = new SoapClient($wsdlUri, $options); + } + catch(SoapFault $sf) + { + throw new Exception("Unable to connect to endpoint '{$endpoint}'"); + } + self::$_soapClient->__setCookie('login', Transip_ApiSettings::$login); + self::$_soapClient->__setCookie('mode', Transip_ApiSettings::$mode); + } + + $timestamp = time(); + $nonce = uniqid('', true); + + self::$_soapClient->__setCookie('timestamp', $timestamp); + self::$_soapClient->__setCookie('nonce', $nonce); + self::$_soapClient->__setCookie('clientVersion', self::API_VERSION); + self::$_soapClient->__setCookie('signature', self::_urlencode(self::_sign(array_merge($parameters, array( + '__service' => self::SERVICE, + '__hostname' => $endpoint, + '__timestamp' => $timestamp, + '__nonce' => $nonce + ))))); + + return self::$_soapClient; + } + + /** + * Calculates the hash to sign our request with based on the given parameters. + * + * @param mixed $parameters The parameters to sign. + * @return string Base64 encoded signing hash. + */ + protected static function _sign($parameters) + { + // Fixup our private key, copy-pasting the key might lead to whitespace faults + if(!preg_match('/-----BEGIN (RSA )?PRIVATE KEY-----(.*)-----END (RSA )?PRIVATE KEY-----/si', Transip_ApiSettings::$privateKey, $matches)) + die('Could not find your private key, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.
'); + + $key = $matches[2]; + $key = preg_replace('/\s*/s', '', $key); + $key = chunk_split($key, 64, "\n"); + + $key = "-----BEGIN PRIVATE KEY-----\n" . $key . "-----END PRIVATE KEY-----"; + + $digest = self::_sha512Asn1(self::_encodeParameters($parameters)); + if(!@openssl_private_encrypt($digest, $signature, $key)) + die('Could not sign your request, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.
'); + + return base64_encode($signature); + } + + /** + * Creates a digest of the given data, with an asn1 header. + * + * @param string $data The data to create a digest of. + * @return string The digest of the data, with asn1 header. + */ + protected static function _sha512Asn1($data) + { + $digest = hash('sha512', $data, true); + + // this ASN1 header is sha512 specific + $asn1 = chr(0x30).chr(0x51); + $asn1 .= chr(0x30).chr(0x0d); + $asn1 .= chr(0x06).chr(0x09); + $asn1 .= chr(0x60).chr(0x86).chr(0x48).chr(0x01).chr(0x65); + $asn1 .= chr(0x03).chr(0x04); + $asn1 .= chr(0x02).chr(0x03); + $asn1 .= chr(0x05).chr(0x00); + $asn1 .= chr(0x04).chr(0x40); + $asn1 .= $digest; + + return $asn1; + } + + /** + * Encodes the given paramaters into a url encoded string based upon RFC 3986. + * + * @param mixed $parameters The parameters to encode. + * @param string $keyPrefix Key prefix. + * @return string The given parameters encoded according to RFC 3986. + */ + protected static function _encodeParameters($parameters, $keyPrefix = null) + { + if(!is_array($parameters) && !is_object($parameters)) + return self::_urlencode($parameters); + + $encodedData = array(); + + foreach($parameters as $key => $value) + { + $encodedKey = is_null($keyPrefix) + ? self::_urlencode($key) + : $keyPrefix . '[' . self::_urlencode($key) . ']'; + + if(is_array($value) || is_object($value)) + { + $encodedData[] = self::_encodeParameters($value, $encodedKey); + } + else + { + $encodedData[] = $encodedKey . '=' . self::_urlencode($value); + } + } + + return implode('&', $encodedData); + } + + /** + * Our own function to encode a string according to RFC 3986 since. + * PHP < 5.3.0 encodes the ~ character which is not allowed. + * + * @param string $string The string to encode. + * @return string The encoded string according to RFC 3986. + */ + protected static function _urlencode($string) + { + $string = trim($string); + $string = rawurlencode($string); + return str_replace('%7E', '~', $string); + } + + const CANCELLATIONTIME_END = 'end'; + const CANCELLATIONTIME_IMMEDIATELY = 'immediately'; + const TRACK_ENDPOINT_NAME = 'Webhosting'; + + /** + * Get all domain names that have a webhosting package attached to them. + * + * @return string[] List of domain names that have a webhosting package + */ + public static function getWebhostingDomainNames() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getWebhostingDomainNames')))->getWebhostingDomainNames(); + } + + /** + * Get available webhosting packages + * + * @return Transip_WebhostingPackage[] List of available webhosting packages + */ + public static function getAvailablePackages() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getAvailablePackages')))->getAvailablePackages(); + } + + /** + * Get information about existing webhosting on a domain. + * + * Please be aware that the information returned is outdated when + * a modifying function in Transip_WebhostingService is called (e.g. createCronjob()). + * + * Call this function again to refresh the info. + * + * @param string $domainName The domain name of the webhosting package to get the info for. Must be owned by this user + * @return Transip_WebHost WebHost object with all info about the requested webhosting package + */ + public static function getInfo($domainName) + { + return self::_getSoapClient(array_merge(array($domainName), array('__method' => 'getInfo')))->getInfo($domainName); + } + + /** + * Order webhosting for a domain name + * + * @param string $domainName The domain name to order the webhosting for. Must be owned by this user + * @param Transip_WebhostingPackage $webhostingPackage The webhosting Package to order, one of the packages returned by Transip_WebhostingService::getAvailablePackages() + * @throws ApiException on error + */ + public static function order($domainName, $webhostingPackage) + { + return self::_getSoapClient(array_merge(array($domainName, $webhostingPackage), array('__method' => 'order')))->order($domainName, $webhostingPackage); + } + + /** + * Get available upgrades packages for a domain name with webhosting. Only those packages will be returned to which + * the given domain name can be upgraded to. + * + * @param string $domainName Domain to get upgrades for. Must be owned by the current user. + * @return Transip_WebhostingPackage[] Available packages to which the domain name can be upgraded to. + * @throws ApiException Throwns an Exception ig the domain is not found in the requester account + */ + public static function getAvailableUpgrades($domainName) + { + return self::_getSoapClient(array_merge(array($domainName), array('__method' => 'getAvailableUpgrades')))->getAvailableUpgrades($domainName); + } + + /** + * Upgrade the webhosting of a domain name to a new webhosting package to a given new package. + * + * @param string $domainName The domain to upgrade webhosting for. Must be owned by the current user. + * @param string $newWebhostingPackage The new webhosting package, must be one of the packages returned getAvailableUpgrades() for the given domain name + * @throws ApiException Throws an exception when the domain name does not belong to the requester (or is not found) or the package can't be upgraded + */ + public static function upgrade($domainName, $newWebhostingPackage) + { + return self::_getSoapClient(array_merge(array($domainName, $newWebhostingPackage), array('__method' => 'upgrade')))->upgrade($domainName, $newWebhostingPackage); + } + + /** + * Cancel webhosting for a domain + * + * @param string $domainName The domain to cancel the webhosting for + * @param string $endTime the time to cancel the domain (WebhostingService::CANCELLATIONTIME_END (end of contract) or WebhostingService::CANCELLATIONTIME_IMMEDIATELY (as soon as possible)) + * @throws ApiException Throws an exception when the domain name does not belong to the requester (or is not found). + */ + public static function cancel($domainName, $endTime) + { + return self::_getSoapClient(array_merge(array($domainName, $endTime), array('__method' => 'cancel')))->cancel($domainName, $endTime); + } + + /** + * Set a new FTP password for a webhosting package + * + * @param string $domainName Domain to set webhosting FTP password for + * @param string $newPassword The new FTP password for the webhosting package + * @throws ApiException When the new password is empty + */ + public static function setFtpPassword($domainName, $newPassword) + { + return self::_getSoapClient(array_merge(array($domainName, $newPassword), array('__method' => 'setFtpPassword')))->setFtpPassword($domainName, $newPassword); + } + + /** + * Create a cronjob + * + * @param string $domainName the domain name of the webhosting package to create cronjob for + * @param Transip_Cronjob $cronjob the cronjob to create. All fields must be valid. + * @throws ApiException When the new URL is either invalid or the URL is not a URL linking to the domain the CronJob is for. + */ + public static function createCronjob($domainName, $cronjob) + { + return self::_getSoapClient(array_merge(array($domainName, $cronjob), array('__method' => 'createCronjob')))->createCronjob($domainName, $cronjob); + } + + /** + * Delete a cronjob from a webhosting package. + * Note, all completely matching cronjobs will be removed + * + * @param string $domainName the domain name of the webhosting package to delete a cronjob + * @param Transip_Cronjob $cronjob Cronjob the cronjob to delete. Be aware that all matching cronjobs will be removed. + * @throws ApiException When the CronJob that needs to be deleted is not found. + */ + public static function deleteCronjob($domainName, $cronjob) + { + return self::_getSoapClient(array_merge(array($domainName, $cronjob), array('__method' => 'deleteCronjob')))->deleteCronjob($domainName, $cronjob); + } + + /** + * Creates a MailBox for a webhosting package. + * The address field of the MailBox object must be unique. + * + * @param string $domainName the domain name of the webhosting package to create the mailbox for + * @param Transip_MailBox $mailBox MailBox object to create + */ + public static function createMailBox($domainName, $mailBox) + { + return self::_getSoapClient(array_merge(array($domainName, $mailBox), array('__method' => 'createMailBox')))->createMailBox($domainName, $mailBox); + } + + /** + * Modifies MailBox settings + * + * @param string $domainName the domain name of the webhosting package to modify the mailbox for + * @param Transip_MailBox $mailBox the MailBox to modify + * @throws ApiException When the MailBox that needs to be modified is not found. + */ + public static function modifyMailBox($domainName, $mailBox) + { + return self::_getSoapClient(array_merge(array($domainName, $mailBox), array('__method' => 'modifyMailBox')))->modifyMailBox($domainName, $mailBox); + } + + /** + * Sets a new password for a MailBox + * + * @param string $domainName the domain name of the webhosting package to set the mailbox password for + * @param Transip_MailBox $mailBox the MailBox to set the password for + * @param string $newPassword the new password for the MailBox, cannot be empty. + * @throws ApiException When the MailBox that needs to be modified is not found. + */ + public static function setMailBoxPassword($domainName, $mailBox, $newPassword) + { + return self::_getSoapClient(array_merge(array($domainName, $mailBox, $newPassword), array('__method' => 'setMailBoxPassword')))->setMailBoxPassword($domainName, $mailBox, $newPassword); + } + + /** + * Deletes a MailBox from a webhosting package + * + * @param string $domainName the domain name of the webhosting package to remove the MailBox from + * @param Transip_MailBox $mailBox the mailbox object to remove + * @throws ApiException When the MailBox that needs to be deleted is not found. + */ + public static function deleteMailBox($domainName, $mailBox) + { + return self::_getSoapClient(array_merge(array($domainName, $mailBox), array('__method' => 'deleteMailBox')))->deleteMailBox($domainName, $mailBox); + } + + /** + * Creates a MailForward for a webhosting package + * + * @param string $domainName the domain name of the webhosting package to add the MailForward to + * @param Transip_MailForward $mailForward The MailForward object to create + */ + public static function createMailForward($domainName, $mailForward) + { + return self::_getSoapClient(array_merge(array($domainName, $mailForward), array('__method' => 'createMailForward')))->createMailForward($domainName, $mailForward); + } + + /** + * Changes an active MailForward object + * + * @param string $domainName the domain name of the webhosting package to modify the MailForward from + * @param Transip_MailForward $mailForward the MailForward to modify + * @throws ApiException When the MailForward that needs to be modified is not found. + */ + public static function modifyMailForward($domainName, $mailForward) + { + return self::_getSoapClient(array_merge(array($domainName, $mailForward), array('__method' => 'modifyMailForward')))->modifyMailForward($domainName, $mailForward); + } + + /** + * Deletes an active MailForward object + * + * @param string $domainName the domain name of the webhosting package to delete the MailForward from + * @param Transip_MailForward $mailForward the MailForward to delete + */ + public static function deleteMailForward($domainName, $mailForward) + { + return self::_getSoapClient(array_merge(array($domainName, $mailForward), array('__method' => 'deleteMailForward')))->deleteMailForward($domainName, $mailForward); + } + + /** + * Creates a new database + * + * @param string $domainName the domain name of the webhosting package to create the Db for + * @param Transip_Db $db Db object to create + */ + public static function createDatabase($domainName, $db) + { + return self::_getSoapClient(array_merge(array($domainName, $db), array('__method' => 'createDatabase')))->createDatabase($domainName, $db); + } + + /** + * Changes a Db object + * + * @param string $domainName the domain name of the webhosting package to change the Db for + * @param Transip_Db $db The db object to modify + */ + public static function modifyDatabase($domainName, $db) + { + return self::_getSoapClient(array_merge(array($domainName, $db), array('__method' => 'modifyDatabase')))->modifyDatabase($domainName, $db); + } + + /** + * Sets A database password for a Db + * + * @param string $domainName the domain name of the webhosting package of the Db to change the password for + * @param Transip_Db $db Modified database object to save + * @param string $newPassword New password for the database + */ + public static function setDatabasePassword($domainName, $db, $newPassword) + { + return self::_getSoapClient(array_merge(array($domainName, $db, $newPassword), array('__method' => 'setDatabasePassword')))->setDatabasePassword($domainName, $db, $newPassword); + } + + /** + * Deletes a Db object + * + * @param string $domainName the domain name of the webhosting package to delete the Db for + * @param Transip_Db $db Db object to remove + * @throws ApiException When the Database that needs to be deleted is not found. + */ + public static function deleteDatabase($domainName, $db) + { + return self::_getSoapClient(array_merge(array($domainName, $db), array('__method' => 'deleteDatabase')))->deleteDatabase($domainName, $db); + } + + /** + * Creates a SubDomain + * + * @param string $domainName the domain name of the webhosting package to create the SubDomain for + * @param Transip_SubDomain $subDomain SubDomain object to create + */ + public static function createSubdomain($domainName, $subDomain) + { + return self::_getSoapClient(array_merge(array($domainName, $subDomain), array('__method' => 'createSubdomain')))->createSubdomain($domainName, $subDomain); + } + + /** + * Deletes a SubDomain + * + * @param string $domainName the domain name of the webhosting package to delete the SubDomain for + * @param Transip_SubDomain $subDomain SubDomain object to delete + * @throws ApiException When the Subdomain that needs to be deleted is not found. + */ + public static function deleteSubdomain($domainName, $subDomain) + { + return self::_getSoapClient(array_merge(array($domainName, $subDomain), array('__method' => 'deleteSubdomain')))->deleteSubdomain($domainName, $subDomain); + } +} + +?> diff --git a/Transip/WhoisContact.php b/Transip/WhoisContact.php new file mode 100644 index 0000000..79307e0 --- /dev/null +++ b/Transip/WhoisContact.php @@ -0,0 +1,403 @@ + 'BV - Besloten Vennootschap', + 'BVI/O' => 'BV i.o. - BV in oprichting', + 'COOP' => 'Cooperatie', + 'CV' => 'CV - Commanditaire Vennootschap', + 'EENMANSZAAK' => 'Eenmanszaak', + 'KERK' => 'Kerkgenootschap', + 'NV' => 'NV - Naamloze Vennootschap', + 'OWM' => 'Onderlinge Waarborg Maatschappij', + 'REDR' => 'Rederij', + 'STICHTING' => 'Stichting', + 'VERENIGING' => 'Vereniging', + 'VOF' => 'VoF - Vennootschap onder firma', + 'BEG' => 'Buitenlandse EG vennootschap', + 'BRO' => 'Buitenlandse rechtsvorm/onderneming', + 'EESV' => 'Europees Economisch Samenwerkingsverband', + 'ANDERS' => 'Anders', + '' => 'Geen', + ); + + /** + * The possible country codes with their respective english names + * + * @var array + * @nosoap + */ + public static $possibleCountryCodes = array ( + 'af' => 'Afghanistan', + 'al' => 'Albania', + 'dz' => 'Algeria', + 'as' => 'American Samoa', + 'ad' => 'Andorra', + 'ao' => 'Angola', + 'ai' => 'Anguilla', + 'aq' => 'Antarctica', + 'ag' => 'Antigua and Barbuda', + 'ar' => 'Argentina', + 'am' => 'Armenia', + 'aw' => 'Aruba', + 'au' => 'Australia', + 'at' => 'Austria', + 'az' => 'Azerbaijan', + 'bs' => 'Bahamas', + 'bh' => 'Bahrain', + 'bd' => 'Bangladesh', + 'bb' => 'Barbados', + 'by' => 'Belarus', + 'be' => 'Belgium', + 'bz' => 'Belize', + 'bj' => 'Benin', + 'bm' => 'Bermuda', + 'bt' => 'Bhutan', + 'bo' => 'Bolivia', + 'ba' => 'Bosnia and Herzegovina', + 'bw' => 'Botswana', + 'bv' => 'Bouvet Island', + 'br' => 'Brazil', + 'io' => 'British Indian Ocean Territory', + 'bn' => 'Brunei Darussalem', + 'bg' => 'Bulgaria', + 'bf' => 'Burkina Faso', + 'bi' => 'Burundi', + 'kh' => 'Cambodia', + 'cm' => 'Cameroon', + 'ca' => 'Canada', + 'cv' => 'Cape Verde', + 'ky' => 'Cayman Islands', + 'cf' => 'Central African Republic', + 'td' => 'Chad', + 'cl' => 'Chile', + 'cn' => 'China', + 'cx' => 'Christmas Island', + 'cc' => 'Cocos (Keeling) Islands', + 'co' => 'Colombia', + 'km' => 'Comoros', + 'cg' => 'Congo', + 'cd' => 'Congo, the Democratic Republic of the', + 'ck' => 'Cook Islands', + 'cr' => 'Costa Rica', + 'hr' => 'Croatia', + 'cu' => 'Cuba', + 'cy' => 'Cyprus', + 'cz' => 'Czech Republic', + 'ci' => 'Côte d\'Ivoire', + 'dk' => 'Denmark', + 'dj' => 'Djibouti', + 'dm' => 'Dominica', + 'do' => 'Dominican Republic', + 'ec' => 'Ecuador', + 'eg' => 'Egypt', + 'sv' => 'El Salvador', + 'gq' => 'Equatorial Guinea', + 'er' => 'Eritrea', + 'ee' => 'Estonia', + 'et' => 'Ethiopia', + 'fk' => 'Falkland Islands (Malvinas)', + 'fo' => 'Faroe Islands', + 'fj' => 'Fiji', + 'fi' => 'Finland', + 'fr' => 'France', + 'gf' => 'French Guiana', + 'pf' => 'French Polynesia', + 'tf' => 'French Southern Territories', + 'ga' => 'Gabon', + 'gm' => 'Gambia', + 'ge' => 'Georgia', + 'de' => 'Germany', + 'gh' => 'Ghana', + 'gi' => 'Gibraltar', + 'gr' => 'Greece', + 'gl' => 'Greenland', + 'gd' => 'Grenada', + 'gp' => 'Guadeloupe', + 'gu' => 'Guam', + 'gt' => 'Guatemala', + 'gg' => 'Guernsey', + 'gn' => 'Guinea', + 'gw' => 'Guinea-Bissau', + 'gy' => 'Guyana', + 'ht' => 'Haiti', + 'hm' => 'Heard Island and McDonald Islands', + 'va' => 'Holy See (Vatican City State)', + 'hn' => 'Honduras', + 'hk' => 'Hong Kong', + 'hu' => 'Hungary', + 'is' => 'Iceland', + 'in' => 'India', + 'id' => 'Indonesia', + 'ir' => 'Iran, Islamic Republic of', + 'iq' => 'Iraq', + 'ie' => 'Ireland', + 'im' => 'Isle of Man', + 'il' => 'Israel', + 'it' => 'Italy', + 'jm' => 'Jamaica', + 'jp' => 'Japan', + 'je' => 'Jersey', + 'jo' => 'Jordan', + 'kz' => 'Kazakhstan', + 'ke' => 'Kenya', + 'ki' => 'Kiribati', + 'kp' => 'Korea, Democratic People\'s Republic of', + 'kr' => 'Korea, Republic of', + 'kw' => 'Kuwait', + 'kg' => 'Kyrgyzstan', + 'la' => 'Lao People\'s Democratic Republic', + 'lv' => 'Latvia', + 'lb' => 'Lebanon', + 'ls' => 'Lesotho', + 'lr' => 'Liberia', + 'ly' => 'Libyan Arab Jamahiriya', + 'li' => 'Liechtenstein', + 'lt' => 'Lithuania', + 'lu' => 'Luxembourg', + 'mo' => 'Macao', + 'mk' => 'Macedonia, the former Yugoslav Republic of', + 'mg' => 'Madagascar', + 'mw' => 'Malawi', + 'my' => 'Malaysia', + 'mv' => 'Maldives', + 'ml' => 'Mali', + 'mt' => 'Malta', + 'mh' => 'Marshall Islands', + 'mq' => 'Martinique', + 'mr' => 'Mauritania', + 'mu' => 'Mauritius', + 'yt' => 'Mayotte', + 'mx' => 'Mexico', + 'fm' => 'Micronesia, Federated States of', + 'md' => 'Moldova', + 'mc' => 'Monaco', + 'mn' => 'Mongolia', + 'me' => 'Montenegro', + 'ms' => 'Montserrat', + 'ma' => 'Morocco', + 'mz' => 'Mozambique', + 'mm' => 'Myanmar', + 'na' => 'Namibia', + 'nr' => 'Nauru', + 'np' => 'Nepal', + 'nl' => 'Netherlands', + 'an' => 'Netherlands Antilles', + 'nc' => 'New Caledonia', + 'nz' => 'New Zealand', + 'ni' => 'Nicaragua', + 'ne' => 'Niger', + 'ng' => 'Nigeria', + 'nu' => 'Niue', + 'nf' => 'Norfolk Island', + 'mp' => 'Northern Mariana Islands', + 'no' => 'Norway', + 'om' => 'Oman', + 'pk' => 'Pakistan', + 'pw' => 'Palau', + 'ps' => 'Palestinian Territory, Occupied', + 'pa' => 'Panama', + 'pg' => 'Papua New Guinea', + 'py' => 'Paraguay', + 'pe' => 'Peru', + 'ph' => 'Philippines', + 'pn' => 'Pitcairn', + 'pl' => 'Poland', + 'pt' => 'Portugal', + 'pr' => 'Puerto Rico', + 'qa' => 'Qatar', + 'ro' => 'Romania', + 'ru' => 'Russian Federation', + 'rw' => 'Rwanda', + 're' => 'Réunion', + 'bl' => 'Saint Barthélemy', + 'sh' => 'Saint Helena', + 'kn' => 'Saint Kitts and Nevis', + 'lc' => 'Saint Lucia', + 'mf' => 'Saint Martin (French part)', + 'pm' => 'Saint Pierre and Miquelon', + 'vc' => 'Saint Vincent and the Grenadines', + 'ws' => 'Samoa', + 'sm' => 'San Marino', + 'st' => 'Sao Tome and Principe', + 'sa' => 'Saudi Arabia', + 'sn' => 'Senegal', + 'rs' => 'Serbia', + 'sc' => 'Seychelles', + 'sl' => 'Sierra Leone', + 'sg' => 'Singapore', + 'sk' => 'Slovakia', + 'si' => 'Slovenia', + 'sb' => 'Solomon Islands', + 'so' => 'Somalia', + 'za' => 'South Africa', + 'gs' => 'South Georgia and the South Sandwich Islands', + 'es' => 'Spain', + 'lk' => 'Sri Lanka', + 'sd' => 'Sudan', + 'sr' => 'Suriname', + 'sj' => 'Svalbard and Jan Mayen', + 'sz' => 'Swaziland', + 'se' => 'Sweden', + 'ch' => 'Switzerland', + 'sy' => 'Syrian Arab Republic', + 'tw' => 'Taiwan, Province of China', + 'tj' => 'Tajikistan', + 'tz' => 'Tanzania, United Republic of', + 'th' => 'Thailand', + 'tl' => 'Timor-Leste', + 'tg' => 'Togo', + 'tk' => 'Tokelau', + 'to' => 'Tonga', + 'tt' => 'Trinidad and Tobago', + 'tn' => 'Tunisia', + 'tr' => 'Turkey', + 'tm' => 'Turkmenistan', + 'tc' => 'Turks and Caicos Islands', + 'tv' => 'Tuvalu', + 'ug' => 'Uganda', + 'ua' => 'Ukraine', + 'ae' => 'United Arab Emirates', + 'gb' => 'United Kingdom', + 'us' => 'United States', + 'um' => 'United States Minor Outlying Islands', + 'uy' => 'Uruguay', + 'uz' => 'Uzbekistan', + 'vu' => 'Vanuatu', + 've' => 'Venezuela', + 'vn' => 'Viet Nam', + 'vg' => 'Virgin Islands, British', + 'vi' => 'Virgin Islands, U.S.', + 'wf' => 'Wallis and Futuna', + 'eh' => 'Western Sahara', + 'ye' => 'Yemen', + 'zm' => 'Zambia', + 'zw' => 'Zimbabwe', + 'ax' => 'Åland Islands', + ); + + /** + * The type of this Contact, owner, administrative or technical + * + * @var string + */ + public $type; + + /** + * The firstName of this Contact + * + * @var string + */ + public $firstName; + + /** + * The middleName of this Contact + * + * @var string + */ + public $middleName; + + /** + * The lastName of this Contact + * + * @var string + */ + public $lastName; + + /** + * The companyName of this Contact, in case of a company + * + * @var string + */ + public $companyName; + + /** + * The kvk number of this Contact, in case of a company + * + * @var string + */ + public $companyKvk; + + /** + * The type number of this Contact, in case of a company + * + * @var string + */ + public $companyType; + + /** + * The street of the address of this Contact + * + * @var string + */ + public $street; + + /** + * The number part of the address of this Contact + * + * @var string + */ + public $number; + + /** + * The postalCode part of the address of this Contact + * + * @var string + */ + public $postalCode; + + /** + * The city part of the address of this Contact + * + * @var string + */ + public $city; + + /** + * The phoneNumber of this Contact + * + * @var string + */ + public $phoneNumber; + + /** + * The faxNumber of this Contact + * + * @var string + */ + public $faxNumber; + + /** + * The email of this Contact + * + * @var string + */ + public $email; + + /** + * The country of this Contact, one of the ISO country abbrevs, must be lowercase. + * + * @var string + */ + public $country; +} + +?> diff --git a/examples/ColocationService-createIpAddress.php b/examples/ColocationService-createIpAddress.php new file mode 100644 index 0000000..8bd2a3a --- /dev/null +++ b/examples/ColocationService-createIpAddress.php @@ -0,0 +1,23 @@ + + */ + + +require_once('Transip/ColocationService.php'); + +try +{ + // Creates an IpAddress and will assign it to the current user. + // Please note that 127.0.0.1 is an example address. + Transip_ColocationService::createIpAddress('127.0.0.1', 'reverse.example.com'); +} +catch(Exception $e) +{ + print "error: {$e->getMessage()}\n"; +} +?> diff --git a/examples/ColocationService-deleteIpAddress.php b/examples/ColocationService-deleteIpAddress.php new file mode 100644 index 0000000..dd42b0c --- /dev/null +++ b/examples/ColocationService-deleteIpAddress.php @@ -0,0 +1,22 @@ + + */ + + +require_once('Transip/ColocationService.php'); + +try +{ + // Please note that 127.0.0.1 is an example address + Transip_ColocationService::deleteIpAddress('127.0.0.1'); +} +catch(Exception $e) +{ + print "error: {$e->getMessage()}\n"; +} +?> diff --git a/examples/ColocationService-getColoOverview.php b/examples/ColocationService-getColoOverview.php new file mode 100644 index 0000000..7098bd7 --- /dev/null +++ b/examples/ColocationService-getColoOverview.php @@ -0,0 +1,54 @@ + + */ + +require_once('Transip/ColocationService.php'); + +try +{ + // retrieve all colocation items and loop + $coloNames = Transip_ColocationService::getColoNames(); + foreach($coloNames as $coloName) + { + echo $coloName . ':' . PHP_EOL; + + // for each colo, get the IPRanges used by this colo + $ipRanges = Transip_ColocationService::getIpRanges($coloName); + foreach($ipRanges as $ipRange) + { + echo '- IP range: ' . $ipRange . PHP_EOL; + } + + // get all IPAddresses attached to this colo and iterate over + // the addresses to get the reverse dns and print information. + $ipAddresses = Transip_ColocationService::getIpAddresses($coloName); + foreach($ipAddresses as $ipAddress) + { + $reverseDns = Transip_ColocationService::getReverseDns($ipAddress); + echo '- IP address: ' . $ipAddress . ' (rDNS "' . $reverseDns . '")' . PHP_EOL; + } + + echo PHP_EOL; + } +} +catch(Exception $exception) +{ + // When something goes wrong, an Exception will be thrown with relevant information. + echo "An Exception occured. Code: {$exception->getCode()}, message: {$exception->getMessage()}\n"; +} + +?> \ No newline at end of file diff --git a/examples/ColocationService-requestAccess.php b/examples/ColocationService-requestAccess.php new file mode 100644 index 0000000..eb11b87 --- /dev/null +++ b/examples/ColocationService-requestAccess.php @@ -0,0 +1,114 @@ + + */ + + +require_once('Transip/ColocationService.php'); + +if(isset($_POST['request']) && count($_POST['request']) > 0) +{ + extract($_POST['request']); + try + { + // filter out empty input fields + $visitor = array_filter($visitor, 'strlen'); + + $dataCenterVisitors = Transip_ColocationService::requestAccess( + $when, $duration, $visitor, $phoneNumber); + + $result = ''; + foreach($dataCenterVisitors as $dataCenterVisitor) + { + if($dataCenterVisitor->hasBeenRegisteredBefore) + { + $result .= "{$dataCenterVisitor->name} (no code needed)\n"; + } + else + { + $result .= "{$dataCenterVisitor->name}"; + $result .= " (reservation number: {$dataCenterVisitor->reservationNumber};"; + $result .= " access code: {$dataCenterVisitor->accessCode})\n"; + } + } + } + catch(SoapFault $e) + { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + $result = 'An error occurred: ' . htmlspecialchars($e->getMessage()); + } +} + +?> + + + + + +".$result."":"")?> + Fill out the form to create an access request + + + + + + \ No newline at end of file diff --git a/examples/ColocationService-requestRemoteHands.php b/examples/ColocationService-requestRemoteHands.php new file mode 100644 index 0000000..c4ae189 --- /dev/null +++ b/examples/ColocationService-requestRemoteHands.php @@ -0,0 +1,96 @@ + + */ + + +require_once('Transip/ColocationService.php'); + +if(isset($_POST['request']) && count($_POST['request']) > 0) +{ + extract($_POST['request']); + try + { + $dataCenterHandsRequest = Transip_ColocationService::requestRemoteHands( + $coloName, $contactName, $phoneNumber, $expectedDuration, $instructions); + $result = 'The request has been sent.'; + } + catch(SoapFault $e) + { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + $result = 'An error occurred: ' . htmlspecialchars($e->getMessage()); + } +} + +?> + + +
'.$result.'':'')?> + Fill out the form to create a remote hands request + + + + + diff --git a/examples/ColocationService-setReverseDns.php b/examples/ColocationService-setReverseDns.php new file mode 100644 index 0000000..c2697ef --- /dev/null +++ b/examples/ColocationService-setReverseDns.php @@ -0,0 +1,22 @@ + + */ + +require_once('Transip/ColocationService.php'); + +try +{ + // Change the reverse dns of an already active IPAddress assigned to the current user + // Please note that 127.0.0.1 is a example addresss + Transip_ColocationService::setReverseDns('127.0.0.1', 'reverse.example.com'); +} +catch(Exception $e) +{ + print "error: {$e->getMessage()}\n"; +} +?> diff --git a/examples/DnsService-getDnsSecEntries.php b/examples/DnsService-getDnsSecEntries.php new file mode 100644 index 0000000..57e5080 --- /dev/null +++ b/examples/DnsService-getDnsSecEntries.php @@ -0,0 +1,23 @@ + + */ + +// Include dnsservice +require_once('Transip/DnsService.php'); + +$domainName = 'example.com'; + +try { + // Get the dnssec entries from the transip system + $entries = Transip_DnsService::getDnsSecEntries($domainName); + var_dump($entries); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/DnsService-setDnsEntries.php b/examples/DnsService-setDnsEntries.php new file mode 100644 index 0000000..08097e2 --- /dev/null +++ b/examples/DnsService-setDnsEntries.php @@ -0,0 +1,30 @@ + + */ + +// Include dnsservice +require_once('Transip/DnsService.php'); + +$domainName = 'example.com'; + +// Create the dns entries we want +$dnsEntries = []; +$dnsEntries[] = new Transip_DnsEntry('@', 86400, Transip_DnsEntry::TYPE_A, '127.0.0.1'); +$dnsEntries[] = new Transip_DnsEntry('www', 86400, Transip_DnsEntry::TYPE_CNAME, '@'); +$dnsEntries[] = new Transip_DnsEntry('mail', 86400, Transip_DnsEntry::TYPE_CNAME, '@'); +$dnsEntries[] = new Transip_DnsEntry('@', 86400, Transip_DnsEntry::TYPE_MX, '10 mail.'); + +try { + // Save the dns entries in the transip system + Transip_DnsService::setDnsEntries($domainName, $dnsEntries); + echo 'The DNS Entries have been saved.'; +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/DnsService-setDnsSecEntries.php b/examples/DnsService-setDnsSecEntries.php new file mode 100644 index 0000000..17c5833 --- /dev/null +++ b/examples/DnsService-setDnsSecEntries.php @@ -0,0 +1,49 @@ + + */ + +// Include domainservice +require_once('Transip/DnsService.php'); + +$domainName = 'example.com'; + +$keyTag = ''; +/** + * @var $flag + * @see Transip_DnsSecEntry::ALL_FLAGS + */ +$flag = ''; +/** + * @var $algorithm + * @see Transip_DnsSecEntry::ALL_ALGORITHMS + */ +$algorithm = ''; +$publicKey = ''; + +if (!Transip_DnsService::canEditDnsSec($domainName)) { + die("Unable to update DNSSEC data."); +} + +// Create the dnssec entries we want +$dnsSecEntries = []; +$dnsSecEntries[] = new Transip_DnsSecEntry( + $keyTag, + $flag, + $algorithm, + $publicKey +); + +try { + // Save the dnssec entries in the transip system + Transip_DnsService::setDnsSecEntries($domainName, $dnsSecEntries); + echo 'The DNSSEC Entries have been saved.'; +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/DomainService-batchCheckAvailability.php b/examples/DomainService-batchCheckAvailability.php new file mode 100644 index 0000000..e8ae608 --- /dev/null +++ b/examples/DomainService-batchCheckAvailability.php @@ -0,0 +1,82 @@ + + */ + +require_once('../Transip/DomainService.php'); + +if(isset($_GET['domains']) && strlen($_GET['domains']) > 0) +{ + // seperate each line into a domain and trim off any whitespace + $domains = explode("\n", $_GET['domains']); + $domains = array_map('trim', $domains); + $result = ''; + + try + { + // Request the availability of multiple domains by using the Transip_DomainService API; + // we can get the following different statusses back with different meanings, wrapped in a Transip_DomainCheckResult. + $domainCheckResults = Transip_DomainService::batchCheckAvailability($domains); + foreach($domainCheckResults as $domainCheckResult) + { + switch($domainCheckResult->status) + { + case Transip_DomainService::AVAILABILITY_INYOURACCOUNT: + $result .= htmlspecialchars($domainCheckResult->domainName) + . ' is not available.
" . htmlspecialchars($key) . " | "; + echo "" . htmlspecialchars($value) . " | "; + + echo "
name | +expire | +type | +content | +
---|---|---|---|
" . htmlspecialchars($dnsEntry->name) . " | "; + echo "" . htmlspecialchars($dnsEntry->expire) . " | "; + echo "" . htmlspecialchars($dnsEntry->type) . " | "; + echo "" . htmlspecialchars($dnsEntry->content) . " | "; + + echo "
" . htmlspecialchars($key) . " | "; + echo "" . htmlspecialchars($value) . " | "; + + echo "
name | +expire | +type | +content | +
---|---|---|---|
" . htmlspecialchars($dnsEntry->name) . " | "; + echo "" . htmlspecialchars($dnsEntry->expire) . " | "; + echo "" . htmlspecialchars($dnsEntry->type) . " | "; + echo "" . htmlspecialchars($dnsEntry->content) . " | "; + + echo "
mailbox | +spamCheckerStrength | +maxDiskUsage | +VacationReply | +
---|---|---|---|
" . htmlspecialchars($mailBox->address) . " | "; + echo "" . $mailBox->spamCheckerStrength . " | "; + echo "" . $mailBox->maxDiskUsage . " MB | "; + echo "";
+ if($mailBox->hasVacationReply)
+ {
+ echo "Subject: " . htmlspecialchars($mailBox->vacationReplySubject) . " "; + echo "Message: " . htmlspecialchars($mailBox->vacationReplyMessage) . " "; + } + else + { + echo " "; + } + echo " | ";
+ echo "
mailForward | +targetAddress | +
---|---|
" . htmlspecialchars($mailForward->name) . " | "; + echo "" . htmlspecialchars($mailForward->targetAddress) . " | "; + echo "
Database | +
---|
" . htmlspecialchars($database->name) . " | "; + echo "
name | +url | +TimeSpecification | +|
---|---|---|---|
" . htmlspecialchars($cronjob->name) . " | "; + echo "" . htmlspecialchars($cronjob->url) . " | "; + echo "" . htmlspecialchars($cronjob->email) . " | "; + echo "";
+ echo "minute: {$cronjob->minuteTrigger} "; + echo "hour: {$cronjob->hourTrigger} "; + echo "day: {$cronjob->dayTrigger} "; + echo "month: {$cronjob->monthTrigger} "; + echo "weekday: {$cronjob->weekdayTrigger} "; + echo " | ";
+ echo "
subdomain | +
---|
" . htmlspecialchars($subDomain->name) . " | "; + echo "