Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sclaeys committed Feb 20, 2022
1 parent 924b0fd commit f6c6ee6
Show file tree
Hide file tree
Showing 276 changed files with 33,023 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
2 changes: 2 additions & 0 deletions README.md.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# RadWebHosting-Blesta
Rad Web Hosting Domains Reseller module for Blesta
22 changes: 22 additions & 0 deletions modules/radwebhosting/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "ModulesGarden\\DomainsReseller\\Registrar\\radwebhosting",
"description": "",
"version": "1.0.0",
"type": "project",
"license": "EULA",
"homepage": "http://www.modulesgarden.com",
"support":
{
"email": "[email protected]",
"issues": "http://www.modulesgarden.com/customers/support",
"forum": "http://www.forum.modulesgarden.com/"
},
"authors": [],
"require":
{
"php": ">=5.5.9",
"guzzlehttp/guzzle": "5.3.1"
},
"autoload": {
}
}
188 changes: 188 additions & 0 deletions modules/radwebhosting/config/radwebhosting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
<?php
// Transfer fields
Configure::set('radwebhosting.transfer_fields',
[
'domain' =>
[
'label' => Language::_('radwebhosting.transfer.domain', true),
'type' => 'text'
],
'EPPCode' =>
[
'label' => Language::_('radwebhosting.transfer.EPPCode', true),
'type' => 'text'
]
]);

// Domain fields
Configure::set('radwebhosting.domain_fields',
[
'domain' =>
[
'label' => Language::_('radwebhosting.domain.domain', true),
'type' => 'text'
],
]);

// Nameserver fields
Configure::set('radwebhosting.nameserver_fields',
[
'ns1' =>
[
'label' => Language::_('radwebhosting.nameserver.ns1', true),
'type' => 'text'
],
'ns2' =>
[
'label' => Language::_('radwebhosting.nameserver.ns2', true),
'type' => 'text'
],
'ns3' =>
[
'label' => Language::_('radwebhosting.nameserver.ns3', true),
'type' => 'text'
],
'ns4' =>
[
'label' => Language::_('radwebhosting.nameserver.ns4', true),
'type' => 'text'
],
'ns5' =>
[
'label' => Language::_('radwebhosting.nameserver.ns5', true),
'type' => 'text'
]
]);

// Whois fields
Configure::set('radwebhosting.whois_fields',
[
"registrant" =>
[
'firstname' =>
[
'label' => Language::_('radwebhosting.whois.RegistrantFirstName', true),
'type' => 'text'
],
'lastname' =>
[
'label' => Language::_('radwebhosting.whois.RegistrantLastName', true),
'type' => 'text'
],
'fullname' =>
[
'label' => Language::_('radwebhosting.whois.RegistrantFullname', true),
'type' => 'text'
],
'companyname' =>
[
'label' => Language::_('radwebhosting.whois.RegistrantCompanyName', true),
'type' => 'text'
],
'email' =>
[
'label' => Language::_('radwebhosting.whois.RegistrantEmail', true),
'type' => 'text'
],
'address1' =>
[
'label' => Language::_('radwebhosting.whois.RegistrantAddress1', true),
'type' => 'text'
],
'address2' =>
[
'label' => Language::_('radwebhosting.whois.RegistrantAddress2', true),
'type' => 'text'
],
'city' =>
[
'label' => Language::_('radwebhosting.whois.RegistrantCity', true),
'type' => 'text'
],
'state' =>
[
'label' => Language::_('radwebhosting.whois.RegistrantState', true),
'type' => 'text'
],
'zipcode' =>
[
'label' => Language::_('radwebhosting.whois.RegistrantZipCode', true),
'type' => 'text'
],
'country' =>
[
'label' => Language::_('radwebhosting.whois.RegistrantCountry', true),
'type' => 'text'
],
'phone' =>
[
'label' => Language::_('radwebhosting.whois.RegistrantPhone', true),
'type' => 'text'
],
],

"tech" =>
[
'firstname' =>
[
'label' => Language::_('radwebhosting.whois.TechFirstName', true),
'type' => 'text'
],
'lastname' =>
[
'label' => Language::_('radwebhosting.whois.TechLastName', true),
'type' => 'text'
],
'fullname' =>
[
'label' => Language::_('radwebhosting.whois.TechFullname', true),
'type' => 'text'
],
'companyname' =>
[
'label' => Language::_('radwebhosting.whois.TechCompanyName', true),
'type' => 'text'
],
'email' =>
[
'label' => Language::_('radwebhosting.whois.TechEmail', true),
'type' => 'text'
],
'address1' =>
[
'label' => Language::_('radwebhosting.whois.TechAddress1', true),
'type' => 'text'
],
'address2' =>
[
'label' => Language::_('radwebhosting.whois.TechAddress2', true),
'type' => 'text'
],
'city' =>
[
'label' => Language::_('radwebhosting.whois.TechCity', true),
'type' => 'text'
],
'state' =>
[
'label' => Language::_('radwebhosting.whois.TechState', true),
'type' => 'text'
],
'zipcode' =>
[
'label' => Language::_('radwebhosting.whois.TechZipCode', true),
'type' => 'text'
],
'country' =>
[
'label' => Language::_('radwebhosting.whois.TechCountry', true),
'type' => 'text'
],
'phone' =>
[
'label' => Language::_('radwebhosting.whois.TechPhone', true),
'type' => 'text'
],
]
]
);
140 changes: 140 additions & 0 deletions modules/radwebhosting/core/Call.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<?php

namespace ModulesGarden\DomainsReseller\Registrar\radwebhosting\core;

use GuzzleHttp\Client;

/**
* Description of Call
*
* @author Paweł Złamaniec <[email protected]>
*/
abstract class Call
{
const TYPE_GET = "GET";

const TYPE_POST = "POST";

const TYPE_PUT = "PUT";

const TYPE_DELETE = "DELETE";

/**
* Action path
*
* @var string
*/
public $action;

/**
* Request type
*
* @var string
*/
public $type;

/**
* Configuration
*
* @var Configuration
*/
public $config;

/**
* params to send trough API
*
* @var mixed
*/
public $params;

/**
* AbstractCall constructor
*
* @param Configuration $config
* @param $params
*/
public function __construct(Configuration $config, $params = [])
{
$this->config = $config;
$this->params = $params;
}

/**
* Make request to API
*
* @return array|bool|mixed|\stdClass|string
*/
public function process()
{
try
{
$this->setVariablesInActionString();
$url = "{$this->config->ApiEndpoint}/{$this->action}";

$client = new Client();
$request = $client->createRequest($this->type, $url, ["headers" => $this->config->getAuthHeaders(), $this->getParamKeyName() => $this->params]);

$output = $client->send($request)->getBody()->getContents();
}
catch (\GuzzleHttp\Exception\ClientException $ex)
{
$response = $ex->getResponse();
$output = $response->getBody()->getContents();
}
catch (\GuzzleHttp\Exception\ServerException $ex)
{
$response = $ex->getResponse();
$output = $response->getBody()->getContents();
}

$result = json_decode($output, true);
if($result === null && is_string($output))
{
$result = ["error" => $result];
}

return $result;
}

/**
* Put variables from params to action string if possible
*/
protected function setVariablesInActionString()
{
//Check if params needs to be filled
if(strpos($this->action, ":") !== false)
{
//Get params names
$pos = 0;
$names = [];
while(($pos = strpos($this->action, ":", $pos)) !== false)
{
$pos++;

$slash = strpos($this->action, "/", $pos);
$names[] = substr($this->action, $pos, $slash - $pos);
}

foreach($names as $name)
{
$this->action = str_replace(":{$name}", $this->params[$name], $this->action);
}
}
}

/**
* Get correct param name depending on the request type
*
* @return string
*/
protected function getParamKeyName()
{
$result = "query";
if($this->type == self::TYPE_POST)
{
$result = "body";
}

return $result;
}
}
Loading

0 comments on commit f6c6ee6

Please sign in to comment.