├── README.md ├── com └── imasters │ └── php │ ├── cpanel │ ├── cPanelModule.php │ ├── operation │ │ ├── dns │ │ │ ├── ListZonesOperation.php │ │ │ ├── KillDNSOperation.php │ │ │ ├── DumpZoneOperation.php │ │ │ ├── GetZoneRecordOperation.php │ │ │ ├── AddDNSZoneOperation.php │ │ │ ├── DNSModule.php │ │ │ ├── AddZoneRecordOperation.php │ │ │ └── EditZoneRecordOperation.php │ │ └── account │ │ │ ├── ListSuspendedAccountsOperation.php │ │ │ ├── ViewPrivilegesOperation.php │ │ │ ├── DomainUserDataOperation.php │ │ │ ├── UnsuspendAccountOperation.php │ │ │ ├── ChangePackageOperation.php │ │ │ ├── LimitBandwidthOperation.php │ │ │ ├── ListAccountsOperation.php │ │ │ ├── AccountSummaryOperation.php │ │ │ ├── EditQuotaOperation.php │ │ │ ├── TerminateAccountOperation.php │ │ │ ├── SuspendAccountOperation.php │ │ │ ├── PasswdOperation.php │ │ │ ├── SetSiteIPOperation.php │ │ │ ├── AccountModule.php │ │ │ ├── ModifyAccountOperation.php │ │ │ └── CreateAccountOperation.php │ ├── cPanelOperation.php │ ├── cPanelHashAuthentication.php │ ├── cPanelBasicAuthentication.php │ └── cPanel.php │ └── http │ ├── HTTPRequestMethod.php │ ├── HTTPAuthenticator.php │ ├── CookieManager.php │ ├── HTTPRequest.php │ ├── Cookie.php │ ├── HTTPResponse.php │ ├── HTTPCookieManager.php │ ├── CURL.php │ └── HTTPConnection.php └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /com/imasters/php/cpanel/cPanelModule.php: -------------------------------------------------------------------------------- 1 | 11 | */ 12 | abstract class cPanelModule { 13 | /** 14 | * @var cPanel 15 | */ 16 | protected $cpanel; 17 | 18 | final public function __construct( cPanel $cpanel ) { 19 | $this->cpanel = $cpanel; 20 | } 21 | } -------------------------------------------------------------------------------- /com/imasters/php/http/HTTPRequestMethod.php: -------------------------------------------------------------------------------- 1 | 10 | * @brief Constantes para identificar o método de requisição HTTP 11 | */ 12 | interface HTTPRequestMethod { 13 | const DELETE = 'DELETE'; 14 | const GET = 'GET'; 15 | const HEAD = 'HEAD'; 16 | const OPTIONS = 'OPTIONS'; 17 | const POST = 'POST'; 18 | const PUT = 'PUT'; 19 | const TRACE = 'TRACE'; 20 | } -------------------------------------------------------------------------------- /com/imasters/php/http/HTTPAuthenticator.php: -------------------------------------------------------------------------------- 1 | 12 | * @brief Interface para definição de um autenticador HTTP. 13 | */ 14 | interface HTTPAuthenticator { 15 | /** 16 | * @brief Autentica uma requisição HTTP. 17 | * @param HTTPRequest $httpRequest 18 | */ 19 | public function authenticate( HTTPRequest $httpRequest ); 20 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/dns/ListZonesOperation.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | class ListZonesOperation extends cPanelOperation { 15 | /** 16 | * @see cPanelOperation::getOperationName() 17 | * @return string 18 | */ 19 | public function getOperationName() { 20 | return 'listzones'; 21 | } 22 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/account/ListSuspendedAccountsOperation.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | class ListSuspendedAccountsOperation extends cPanelOperation { 17 | /** 18 | * 19 | * @see cPanelOperation::getOperationName() 20 | */ 21 | public function getOperationName() { 22 | return 'listsuspended'; 23 | } 24 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/account/ViewPrivilegesOperation.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class ViewPrivilegesOperation extends cPanelOperation { 18 | /** 19 | * @see cPanelOperation::getOperationName() 20 | * @return string 21 | */ 22 | public function getOperationName() { 23 | return 'myprivs'; 24 | } 25 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/dns/KillDNSOperation.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | class KillDNSOperation extends cPanelOperation { 15 | /** 16 | * @var string 17 | */ 18 | private $domain; 19 | 20 | /** 21 | * Recupera o valor de $domain 22 | * @return string 23 | */ 24 | public function getDomain() { 25 | return $this->domain; 26 | } 27 | 28 | /** 29 | * @see cPanelOperation::getOperationName() 30 | * @return string 31 | */ 32 | public function getOperationName() { 33 | return 'killdns'; 34 | } 35 | 36 | /** 37 | * @param string $domain 38 | */ 39 | public function setDomain( $domain ) { 40 | $this->domain = $domain; 41 | } 42 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/dns/DumpZoneOperation.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | class DumpZoneOperation extends cPanelOperation { 16 | /** 17 | * @var string 18 | */ 19 | private $domain; 20 | 21 | /** 22 | * Recupera o valor de $domain 23 | * @return string 24 | */ 25 | public function getDomain() { 26 | return $this->domain; 27 | } 28 | 29 | /** 30 | * @see cPanelOperation::getOperationName() 31 | * @return string 32 | */ 33 | public function getOperationName() { 34 | return 'dumpzone'; 35 | } 36 | 37 | /** 38 | * @param string $domain 39 | */ 40 | public function setDomain( $domain ) { 41 | $this->domain = $domain; 42 | } 43 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/account/DomainUserDataOperation.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | class DomainUserDataOperation extends cPanelOperation { 17 | /** 18 | * @var string 19 | */ 20 | private $domain; 21 | 22 | /** 23 | * Recupera o valor de $domain 24 | * @return string 25 | */ 26 | public function getDomain() { 27 | return $this->domain; 28 | } 29 | 30 | /** 31 | * @see cPanelOperation::getOperationName() 32 | * @return string 33 | */ 34 | public function getOperationName() { 35 | return 'domainuserdata'; 36 | } 37 | 38 | /** 39 | * @param string $domain 40 | */ 41 | public function setDomain( $domain ) { 42 | $this->domain = $domain; 43 | } 44 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/account/UnsuspendAccountOperation.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | class UnsuspendAccountOperation extends cPanelOperation { 17 | /** 18 | * @var string 19 | */ 20 | private $user; 21 | 22 | /** 23 | * @see cPanelOperation::getOperationName() 24 | * @return string 25 | */ 26 | public function getOperationName() { 27 | return 'unsuspendacct'; 28 | } 29 | 30 | /** 31 | * Recupera o valor de $user 32 | * @return string 33 | */ 34 | public function getUser() { 35 | return $this->user; 36 | } 37 | 38 | /** 39 | * @param string $user 40 | */ 41 | public function setUser( $user ) { 42 | $this->user = $user; 43 | $this->httpConnection->setParam( 'user' , $user ); 44 | } 45 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/account/ChangePackageOperation.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | class ChangePackageOperation extends cPanelOperation { 17 | /** 18 | * @var string 19 | */ 20 | private $pkg; 21 | 22 | /** 23 | * @var string 24 | */ 25 | private $user; 26 | 27 | /** 28 | * @see cPanelOperation::getOperationName() 29 | * @return string 30 | */ 31 | public function getOperationName() { 32 | return 'changepackage'; 33 | } 34 | 35 | /** 36 | * Recupera o valor de $pkg 37 | * @return string 38 | */ 39 | public function getPkg() { 40 | return $this->pkg; 41 | } 42 | 43 | /** 44 | * Recupera o valor de $user 45 | * @return string 46 | */ 47 | public function getUser() { 48 | return $this->user; 49 | } 50 | 51 | /** 52 | * @param string $pkg 53 | */ 54 | public function setPkg( $pkg ) { 55 | $this->pkg = $pkg; 56 | } 57 | 58 | /** 59 | * @param string $user 60 | */ 61 | public function setUser( $user ) { 62 | $this->user = $user; 63 | } 64 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/cPanelOperation.php: -------------------------------------------------------------------------------- 1 | 11 | */ 12 | abstract class cPanelOperation { 13 | /** 14 | * @var cPanel 15 | */ 16 | protected $cpanel; 17 | 18 | /** 19 | * @var HTTPConnection 20 | */ 21 | protected $httpConnection; 22 | 23 | /** 24 | * @var HTTPResponse 25 | */ 26 | private $httpResponse; 27 | 28 | /** 29 | * @brief Constroi o objeto que representa uma operação 30 | * @param cPanel $cpanel 31 | */ 32 | public final function __construct( cPanel $cpanel ) { 33 | $this->cpanel = $cpanel; 34 | $this->httpConnection = $cpanel->getHTTPConnection(); 35 | } 36 | 37 | /** 38 | * @return HTTPResponse 39 | */ 40 | public function __getLastResponse() { 41 | return $this->httpResponse; 42 | } 43 | 44 | /** 45 | * @brief Efetua a chamada à operação da API 46 | * @return stdClass 47 | */ 48 | public function call() { 49 | $this->httpResponse = $this->httpConnection->execute( '/json-api/' . $this->getOperationName() ); 50 | 51 | return json_decode( $this->httpResponse->getContent() ); 52 | } 53 | 54 | /** 55 | * @brief Recupera o nome da operação 56 | * @return string 57 | */ 58 | public abstract function getOperationName(); 59 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/account/LimitBandwidthOperation.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | class LimitBandwidthOperation extends cPanelOperation { 15 | /** 16 | * @var string 17 | */ 18 | private $bwlimit; 19 | 20 | /** 21 | * @var string 22 | */ 23 | private $user; 24 | 25 | /** 26 | * Recupera o valor de $bwlimit 27 | * @return string 28 | */ 29 | public function getBwlimit() { 30 | return $this->bwlimit; 31 | } 32 | 33 | /** 34 | * @see cPanelOperation::getOperationName() 35 | */ 36 | public function getOperationName() { 37 | return 'limitbw'; 38 | } 39 | 40 | /** 41 | * Recupera o valor de $user 42 | * @return string 43 | */ 44 | public function getUser() { 45 | return $this->user; 46 | } 47 | 48 | /** 49 | * @param string $bwlimit 50 | */ 51 | public function setBwlimit( $bwlimit ) { 52 | $this->bwlimit = $bwlimit; 53 | $this->httpConnection->setParam( 'bwlimit' , $bwlimit ); 54 | } 55 | 56 | /** 57 | * @param string $user 58 | */ 59 | public function setUser( $user ) { 60 | $this->user = $user; 61 | $this->httpConnection->setParam( 'user' , $user ); 62 | } 63 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/dns/GetZoneRecordOperation.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | class GetZoneRecordOperation extends cPanelOperation { 15 | /** 16 | * @var string 17 | */ 18 | private $domain; 19 | 20 | /** 21 | * @var string 22 | */ 23 | private $Line; 24 | 25 | /** 26 | * Recupera o valor de $domain 27 | * @return string 28 | */ 29 | public function getDomain() { 30 | return $this->domain; 31 | } 32 | 33 | /** 34 | * Recupera o valor de $Line 35 | * @return string 36 | */ 37 | public function getLine() { 38 | return $this->Line; 39 | } 40 | 41 | /** 42 | * @see cPanelOperation::getOperationName() 43 | * @return string 44 | */ 45 | public function getOperationName() { 46 | return 'getzonerecord'; 47 | } 48 | 49 | /** 50 | * @param string $domain 51 | */ 52 | public function setDomain( $domain ) { 53 | $this->domain = $domain; 54 | $this->httpConnection->setParam( 'domain' , $domain ); 55 | } 56 | 57 | /** 58 | * @param string $Line 59 | */ 60 | public function setLine( $Line ) { 61 | $this->Line = $Line; 62 | $this->httpConnection->setParam( 'Line' , $Line ); 63 | } 64 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/account/ListAccountsOperation.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | class ListAccountsOperation extends cPanelOperation { 15 | /** 16 | * @var string 17 | */ 18 | private $searchtype; 19 | 20 | /** 21 | * @var string 22 | */ 23 | private $search; 24 | 25 | /** 26 | * @see cPanelOperation::getOperationName() 27 | */ 28 | public function getOperationName() { 29 | return 'listaccts'; 30 | } 31 | 32 | /** 33 | * Recupera o valor de $searchtype 34 | * @return string 35 | */ 36 | public function getSearchtype() { 37 | return $this->searchtype; 38 | } 39 | 40 | /** 41 | * Recupera o valor de $search 42 | * @return string 43 | */ 44 | public function getSearch() { 45 | return $this->search; 46 | } 47 | 48 | /** 49 | * @param string $searchtype 50 | */ 51 | public function setSearchtype( $searchtype ) { 52 | $this->searchtype = $searchtype; 53 | $this->httpConnection->setParam( 'searchtype' , $searchtype ); 54 | } 55 | 56 | /** 57 | * @param string $search 58 | */ 59 | public function setSearch( $search ) { 60 | $this->search = $search; 61 | $this->httpConnection->setParam( 'search' , $search ); 62 | } 63 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/account/AccountSummaryOperation.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | class AccountSummaryOperation extends cPanelOperation{ 15 | /** 16 | * @var string 17 | */ 18 | private $domain; 19 | 20 | /** 21 | * @var string 22 | */ 23 | private $user; 24 | 25 | /** 26 | * @brief Recupera o domínio 27 | * @return string 28 | */ 29 | public function getDomain() { 30 | return $this->domain; 31 | } 32 | 33 | /** 34 | * @brief Recupera o usuário 35 | * @return string 36 | */ 37 | public function getUser() { 38 | return $this->user; 39 | } 40 | 41 | /** 42 | * @see cPanelOperation::getOperationName() 43 | */ 44 | public function getOperationName() { 45 | return 'accountsummary'; 46 | } 47 | 48 | /** 49 | * @brief Define o domínio 50 | * @param string $domain 51 | */ 52 | public function setDomain( $domain ) { 53 | $this->domain = $domain; 54 | $this->httpConnection->setParam( 'domain' , $domain ); 55 | } 56 | 57 | /** 58 | * @brief Define o usuário 59 | * @param string $user 60 | */ 61 | public function setUser( $user ) { 62 | $this->user = $user; 63 | $this->httpConnection->setParam( 'user' , $user ); 64 | } 65 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/account/EditQuotaOperation.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | class EditQuotaOperation extends cPanelOperation { 17 | /** 18 | * @var integer 19 | */ 20 | private $quota; 21 | 22 | /** 23 | * @var string 24 | */ 25 | private $user; 26 | 27 | /** 28 | * @see cPanelOperation::getOperationName() 29 | * @return string 30 | */ 31 | public function getOperationName() { 32 | return 'editquota'; 33 | } 34 | 35 | /** 36 | * Recupera o valor de $quota 37 | * @return integer 38 | */ 39 | public function getQuota() { 40 | return $this->quota; 41 | } 42 | 43 | /** 44 | * Recupera o valor de $user 45 | * @return string 46 | */ 47 | public function getUser() { 48 | return $this->user; 49 | } 50 | 51 | /** 52 | * @param integer $quota 53 | */ 54 | public function setQuota( $quota ) { 55 | $this->quota = $quota; 56 | $this->httpConnection->setParam( 'quota' , $quota ); 57 | } 58 | 59 | /** 60 | * @param string $user 61 | */ 62 | public function setUser( $user ) { 63 | $this->user = $user; 64 | $this->httpConnection->setParam( 'user' , $user ); 65 | } 66 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/account/TerminateAccountOperation.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | class TerminateAccountOperation extends cPanelOperation { 17 | /** 18 | * @var boolean 19 | */ 20 | private $keepdns; 21 | 22 | /** 23 | * @var integer 24 | */ 25 | private $user; 26 | 27 | /** 28 | * Recupera o valor de $keepdns 29 | * @return boolean 30 | */ 31 | public function getKeepdns() { 32 | return $this->keepdns; 33 | } 34 | 35 | /** 36 | * @see cPanelOperation::getOperationName() 37 | * @return string 38 | */ 39 | public function getOperationName() { 40 | return 'removeacct'; 41 | } 42 | 43 | /** 44 | * Recupera o valor de $user 45 | * @return integer 46 | */ 47 | public function getUser() { 48 | return $this->user; 49 | } 50 | 51 | /** 52 | * @param boolean $keepdns 53 | */ 54 | public function setKeepdns( $keepdns ) { 55 | $this->keepdns = $keepdns; 56 | $this->httpConnection->setParam( 'keepdns' , $keepdns ); 57 | } 58 | 59 | /** 60 | * @param integer $user 61 | */ 62 | public function setUser( $user ) { 63 | $this->user = $user; 64 | $this->httpConnection->setParam( 'user' , $user ); 65 | } 66 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/account/SuspendAccountOperation.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | class SuspendAccountOperation extends cPanelOperation { 17 | /** 18 | * @var string 19 | */ 20 | private $reason; 21 | 22 | /** 23 | * @var string 24 | */ 25 | private $user; 26 | 27 | /** 28 | * @see cPanelOperation::getOperationName() 29 | * @return string 30 | */ 31 | public function getOperationName() { 32 | return 'suspendacct'; 33 | } 34 | 35 | /** 36 | * Recupera o valor de $reason 37 | * @return string 38 | */ 39 | public function getReason() { 40 | return $this->reason; 41 | } 42 | 43 | /** 44 | * Recupera o valor de $user 45 | * @return string 46 | */ 47 | public function getUser() { 48 | return $this->user; 49 | } 50 | 51 | /** 52 | * @param string $reason 53 | */ 54 | public function setReason( $reason ) { 55 | $this->reason = $reason; 56 | $this->httpConnection->setParam( 'reason' , $reason ); 57 | } 58 | 59 | /** 60 | * @param string $user 61 | */ 62 | public function setUser( $user ) { 63 | $this->user = $user; 64 | $this->httpConnection->setParam( 'user' , $user ); 65 | } 66 | } -------------------------------------------------------------------------------- /com/imasters/php/http/CookieManager.php: -------------------------------------------------------------------------------- 1 | 12 | * @brief Interface para definição de um gerenciador de cookies. 13 | */ 14 | interface CookieManager extends Serializable { 15 | /** 16 | * @brief Adiciona um cookie para ser armazenado pelo gerenciador. 17 | * @param Cookie $cookie 18 | */ 19 | public function addCookie( Cookie $cookie ); 20 | 21 | /** 22 | * @brief Recupera os cookies armazenados para um determinado 23 | * domínio. 24 | * @param string $domain Domínio dos cookies. 25 | * @param boolean $secure Indica ambiente seguro (https). 26 | * @param string $path Caminho dos cookies. 27 | * @return string O valor retornado segue o padrão especificado 28 | * pela RFC 2965 para ser utilizado diretamente no campo de 29 | * cabeçalho Cookie. 30 | */ 31 | public function getCookie( $domain , $secure , $path ); 32 | 33 | /** 34 | * @brief Recupera uma lista com os cookies gerenciados. 35 | * @param string $domain Domínio dos cookies. 36 | * @param boolean $secure Indica ambiente seguro. 37 | * @param string $path Caminho dos cookies. 38 | * @return Iterator 39 | */ 40 | public function getCookieIterator( $domain , $secure , $path ); 41 | 42 | /** 43 | * @brief Define o conteúdo do campo de cabeçalho Set-Cookie 44 | * retornado pelo servidor. 45 | * @param string $setCookie 46 | * @param string $domain 47 | */ 48 | public function setCookie( $setCookie , $domain = null ); 49 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/account/PasswdOperation.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | class PasswdOperation extends cPanelOperation { 15 | /** 16 | * @var boolean 17 | */ 18 | private $db_pass_update; 19 | 20 | /** 21 | * @var string 22 | */ 23 | private $pass; 24 | 25 | /** 26 | * @var string 27 | */ 28 | private $user; 29 | 30 | /** 31 | * Recupera o valor de $db_pass_update 32 | * @return boolean 33 | */ 34 | public function getDbPassUpdate() { 35 | return $this->db_pass_update; 36 | } 37 | 38 | /** 39 | * @see cPanelOperation::getOperationName() 40 | */ 41 | public function getOperationName() { 42 | return 'passwd'; 43 | } 44 | 45 | /** 46 | * Recupera o valor de $pass 47 | * @return string 48 | */ 49 | public function getPass() { 50 | return $this->pass; 51 | } 52 | 53 | /** 54 | * Recupera o valor de $user 55 | * @return string 56 | */ 57 | public function getUser() { 58 | return $this->user; 59 | } 60 | 61 | /** 62 | * @param boolean $db_pass_update 63 | */ 64 | public function setDbPassUpdate( $db_pass_update ) { 65 | $this->db_pass_update = $db_pass_update; 66 | $this->httpConnection->setParam( 'db_pass_update' , $db_pass_update ); 67 | } 68 | 69 | /** 70 | * @param string $pass 71 | */ 72 | public function setPass( $pass ) { 73 | $this->pass = $pass; 74 | $this->httpConnection->setParam( 'pass' , $pass ); 75 | } 76 | 77 | /** 78 | * @param string $user 79 | */ 80 | public function setUser( $user ) { 81 | $this->user = $user; 82 | $this->httpConnection->setParam( 'user' , $user ); 83 | } 84 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/cPanelHashAuthentication.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | class cPanelHashAuthentication implements HTTPAuthenticator { 15 | /** 16 | * @var string 17 | */ 18 | private $hash; 19 | 20 | /** 21 | * @var string 22 | */ 23 | private $username; 24 | 25 | /** 26 | * @brief Constroi o objeto de autenticação 27 | * @param string $username Nome do usuário do cPanel 28 | * @param string $hash O hash 29 | */ 30 | public function __construct( $username , $hash ) { 31 | $this->setUsername( $username ); 32 | $this->setHash( $hash ); 33 | } 34 | 35 | /** 36 | * @param HTTPRequest $httpRequest 37 | * @see HTTPAuthenticator::authenticate() 38 | */ 39 | public function authenticate( HTTPRequest $httpRequest ) { 40 | $httpRequest->addRequestHeader( 'Authorization' , sprintf( 41 | 'WHM %s:%s' , $this->username , preg_replace( "/(\r|\n)/" , null, 42 | $this->hash 43 | ) ) 44 | ); 45 | } 46 | 47 | /** 48 | * @brief Recupera o hash 49 | * @return string 50 | */ 51 | public function getHash() { 52 | return $this->password; 53 | } 54 | 55 | /** 56 | * @brief Recupera o nome do usuário 57 | * @return string 58 | */ 59 | public function getUsername() { 60 | return $this->username; 61 | } 62 | 63 | /** 64 | * @brief Define o hash 65 | * @param string $hash O hash que será definido 66 | */ 67 | public function setHash( $hash ) { 68 | $this->hash = $hash; 69 | } 70 | 71 | /** 72 | * @brief Define o nome do usuário 73 | * @param string $username O nome que será definido 74 | */ 75 | public function setUsername( $username ) { 76 | $this->username = $username; 77 | } 78 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/account/SetSiteIPOperation.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | class SetSiteIPOperation extends cPanelOperation { 17 | /** 18 | * @var string 19 | */ 20 | private $domain; 21 | 22 | /** 23 | * @var string 24 | */ 25 | private $ip; 26 | 27 | /** 28 | * @var string 29 | */ 30 | private $user; 31 | 32 | /** 33 | * Recupera o valor de $domain 34 | * @return string 35 | */ 36 | public function getDomain() { 37 | return $this->domain; 38 | } 39 | 40 | /** 41 | * Recupera o valor de $ip 42 | * @return string 43 | */ 44 | public function getIp() { 45 | return $this->ip; 46 | } 47 | 48 | /** 49 | * @see cPanelOperation::getOperationName() 50 | * @return string 51 | */ 52 | public function getOperationName() { 53 | return 'setsiteip'; 54 | } 55 | 56 | /** 57 | * Recupera o valor de $user 58 | * @return string 59 | */ 60 | public function getUser() { 61 | return $this->user; 62 | } 63 | 64 | /** 65 | * @param string $domain 66 | */ 67 | public function setDomain( $domain ) { 68 | $this->domain = $domain; 69 | $this->httpConnection->setParam( 'domain' , $domain ); 70 | } 71 | 72 | /** 73 | * @param string $ip 74 | */ 75 | public function setIp( $ip ) { 76 | $this->ip = $ip; 77 | $this->httpConnection->setParam( 'ip' , $ip ); 78 | } 79 | 80 | /** 81 | * @param string $user 82 | */ 83 | public function setUser( $user ) { 84 | $this->user = $user; 85 | $this->httpConnection->setParam( 'user' , $user ); 86 | } 87 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/cPanelBasicAuthentication.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | class cPanelBasicAuthentication implements HTTPAuthenticator { 15 | /** 16 | * @var string 17 | */ 18 | private $password; 19 | 20 | /** 21 | * @var string 22 | */ 23 | private $username; 24 | 25 | /** 26 | * @brief Constroi o objeto de autenticação 27 | * @param string $username Nome do usuário do cPanel 28 | * @param string $password Senha do usuário do cPanel 29 | */ 30 | public function __construct( $username , $password ) { 31 | $this->setUsername( $username ); 32 | $this->setPassword( $password ); 33 | } 34 | 35 | /** 36 | * @param HTTPRequest $httpRequest 37 | * @see HTTPAuthenticator::authenticate() 38 | */ 39 | public function authenticate( HTTPRequest $httpRequest ) { 40 | $httpRequest->addRequestHeader( 'Authorization' , sprintf( 41 | 'Basic %s' , base64_encode( 42 | sprintf( '%s:%s' , $this->username , $this->password ) 43 | ) ) 44 | ); 45 | } 46 | 47 | /** 48 | * @brief Recupera a senha do usuário 49 | * @return string 50 | */ 51 | public function getPassword() { 52 | return $this->password; 53 | } 54 | 55 | /** 56 | * @brief Recupera o nome do usuário 57 | * @return string 58 | */ 59 | public function getUsername() { 60 | return $this->username; 61 | } 62 | 63 | /** 64 | * @brief Define a senha do usuário 65 | * @param string $password A senha que será definida 66 | */ 67 | public function setPassword( $password ) { 68 | $this->password = $password; 69 | } 70 | 71 | /** 72 | * @brief Define o nome do usuário 73 | * @param string $username O nome que será definido 74 | */ 75 | public function setUsername( $username ) { 76 | $this->username = $username; 77 | } 78 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/dns/AddDNSZoneOperation.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | class AddDNSZoneOperation extends cPanelOperation { 15 | /** 16 | * @var string 17 | */ 18 | private $domain; 19 | 20 | /** 21 | * @var string 22 | */ 23 | private $ip; 24 | 25 | /** 26 | * @var string 27 | */ 28 | private $template; 29 | 30 | /** 31 | * @var string 32 | */ 33 | private $trueowner; 34 | 35 | /** 36 | * Recupera o valor de $domain 37 | * @return string 38 | */ 39 | public function getDomain() { 40 | return $this->domain; 41 | } 42 | 43 | /** 44 | * Recupera o valor de $ip 45 | * @return string 46 | */ 47 | public function getIp() { 48 | return $this->ip; 49 | } 50 | 51 | /** 52 | * @see cPanelOperation::getOperationName() 53 | * @return string 54 | */ 55 | public function getOperationName() { 56 | return 'adddns'; 57 | } 58 | 59 | /** 60 | * Recupera o valor de $template 61 | * @return string 62 | */ 63 | public function getTemplate() { 64 | return $this->template; 65 | } 66 | 67 | /** 68 | * Recupera o valor de $trueowner 69 | * @return string 70 | */ 71 | public function getTrueowner() { 72 | return $this->trueowner; 73 | } 74 | 75 | /** 76 | * @param string $domain 77 | */ 78 | public function setDomain( $domain ) { 79 | $this->domain = $domain; 80 | $this->httpConnection->setParam( 'domain' , $domain ); 81 | } 82 | 83 | /** 84 | * @param string $ip 85 | */ 86 | public function setIp( $ip ) { 87 | $this->ip = $ip; 88 | $this->httpConnection->setParam( 'ip' , $ip ); 89 | } 90 | 91 | /** 92 | * @param string $template 93 | */ 94 | public function setTemplate( $template ) { 95 | $this->template = $template; 96 | $this->httpConnection->setParam( 'template' , $template ); 97 | } 98 | 99 | /** 100 | * @param string $trueowner 101 | */ 102 | public function setTrueowner( $trueowner ) { 103 | $this->trueowner = $trueowner; 104 | $this->httpConnection->setParam( 'trueowner' , $trueowner ); 105 | } 106 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/cPanel.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | class cPanel { 17 | const UNSECURED_PORT = 2086; 18 | const SECURED_PORT = 2087; 19 | 20 | /** 21 | * @var string 22 | */ 23 | private $host; 24 | 25 | /** 26 | * @var HTTPAuthenticator 27 | */ 28 | private $httpAuthenticator; 29 | 30 | /** 31 | * @var integer 32 | */ 33 | private $port = cPanel::SECURED_PORT; 34 | 35 | /** 36 | * @var boolean 37 | */ 38 | private $secure = true; 39 | 40 | /** 41 | * @brief Constroi o objeto para integração com a API do cPanel 42 | * @param string $host 43 | * @param HTTPAuthenticator $httpAuthenticator 44 | */ 45 | public function __construct( $host , HTTPAuthenticator $httpAuthenticator ) { 46 | $this->host = $host; 47 | $this->httpAuthenticator = $httpAuthenticator; 48 | $this->useSecureConnection(); 49 | } 50 | 51 | /** 52 | * @brief Módulo para gerenciamento de contas. 53 | * @return AccountModule 54 | */ 55 | public function account() { 56 | return new AccountModule( $this ); 57 | } 58 | 59 | /** 60 | * @brief Módulo para gerenciamento de DNS 61 | * @return DNSModule 62 | */ 63 | public function dns() { 64 | return new DNSModule( $this ); 65 | } 66 | 67 | /** 68 | * @brief Conexão HTTP 69 | * @details Recupera um objeto de conexão HTTP para ser utilizado 70 | * nas chamadas às operações da API. 71 | * @return HTTPConnection 72 | */ 73 | public function getHTTPConnection() { 74 | $httpConnection = new HTTPConnection(); 75 | $httpConnection->setAuthenticator( $this->httpAuthenticator ); 76 | $httpConnection->setCookieManager( new HTTPCookieManager() ); 77 | $httpConnection->initialize( $this->host , $this->secure , $this->port ); 78 | 79 | return $httpConnection; 80 | } 81 | 82 | /** 83 | * @brief Define a porta HTTP utilizada na conexão. 84 | * @param integer $port 85 | */ 86 | public function setHTTPPort( $port ) { 87 | $this->port = (int) $port; 88 | } 89 | 90 | /** 91 | * @brief Define se será utilizado conexão segura (https). 92 | * @param boolean $secure 93 | */ 94 | public function useSecureConnection( $secure = true ) { 95 | $this->secure = !!$secure; 96 | $this->port = $this->secure ? cPanel::SECURED_PORT : cPanel::UNSECURED_PORT; 97 | } 98 | } -------------------------------------------------------------------------------- /com/imasters/php/http/HTTPRequest.php: -------------------------------------------------------------------------------- 1 | 14 | * @brief Requisição HTTP 15 | * @details Interface para definição de um objeto que fará uma 16 | * requisição HTTP. 17 | */ 18 | interface HTTPRequest { 19 | /** 20 | * @brief Adiciona um campo de cabeçalho para ser enviado com a 21 | * requisição. 22 | * @param string $name Nome do campo de cabeçalho. 23 | * @param string $value Valor do campo de cabeçalho. 24 | * @param boolean $override Indica se o campo deverá 25 | * ser sobrescrito caso já tenha sido definido. 26 | * @throws InvalidArgumentException Se o nome ou o valor 27 | * do campo não forem valores scalar. 28 | */ 29 | public function addRequestHeader( $name , $value , $override = true ); 30 | 31 | /** 32 | * @brief Autentica uma requisição HTTP. 33 | * @param HTTPAuthenticator $authenticator 34 | */ 35 | public function authenticate( HTTPAuthenticator $authenticator ); 36 | 37 | /** 38 | * @brief Fecha a requisição. 39 | */ 40 | public function close(); 41 | 42 | /** 43 | * @brief Executa a requisição HTTP 44 | * @details Executa a requisição HTTP em um caminho utilizando um 45 | * método específico. 46 | * @param string $method Método da requisição. 47 | * @param string $path Alvo da requisição. 48 | * @return string Resposta HTTP. 49 | * @throws BadMethodCallException Se não houver uma conexão 50 | * inicializada. 51 | */ 52 | public function execute( $path = '/' , $method = HTTPRequestMethod::GET ); 53 | 54 | /** 55 | * @brief Recupera a resposta da requisição. 56 | * @return HTTPResponse 57 | */ 58 | public function getResponse(); 59 | 60 | /** 61 | * @brief Abre a requisição. 62 | * @param HTTPConnection $httpConnection Conexão HTTP 63 | * relacionada com essa requisição 64 | */ 65 | public function open( HTTPConnection $httpConnection ); 66 | 67 | /** 68 | * @brief Define um parâmetro 69 | * @details Define um parâmetro que será enviado com a requisição, 70 | * um parâmetro é um par nome-valor que será enviado como uma 71 | * query string (ex: ?name=value). 72 | * @param string $name Nome do parâmetro. 73 | * @param string $value Valor do parâmetro. 74 | * @throws InvalidArgumentException Se o nome ou o valor 75 | * do campo não forem valores scalar. 76 | */ 77 | public function setParameter( $name , $value ); 78 | 79 | /** 80 | * @brief Corpo da requisição HTTP. 81 | * @param string $contentBody 82 | */ 83 | public function setRequestBody( $requestBody ); 84 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/dns/DNSModule.php: -------------------------------------------------------------------------------- 1 | 20 | */ 21 | class DNSModule extends cPanelModule { 22 | /** 23 | * @param string $domain 24 | * @param string $ip 25 | * @return AddDNSOperation 26 | */ 27 | public function addDNSZone( $domain , $ip ) { 28 | $addDNSZoneOperation = new AddDNSZoneOperation( $this->cpanel ); 29 | $addDNSZoneOperation->setDomain( $domain ); 30 | $addDNSZoneOperation->setIp( $ip ); 31 | 32 | return $addDNSZoneOperation; 33 | } 34 | 35 | /** 36 | * @param string $zone 37 | * @return AddZoneRecordOperation 38 | */ 39 | public function addZoneRecord( $zone ) { 40 | $addZoneRecordOperation = new AddZoneRecordOperation( $this->cpanel ); 41 | $addZoneRecordOperation->setZone( $zone ); 42 | 43 | return $addZoneRecordOperation; 44 | } 45 | 46 | /** 47 | * @param string $domain 48 | * @return DumpZoneOperation 49 | */ 50 | public function dumpZone( $domain ) { 51 | $dumpZoneOperation = new DumpZoneOperation( $this->cpanel ); 52 | $dumpZoneOperation->setDomain( $domain ); 53 | 54 | return $dumpZoneOperation; 55 | } 56 | 57 | /** 58 | * @param string $domain 59 | * @param string $Line 60 | * @return EditZoneRecordOperation 61 | */ 62 | public function editZoneRecord( $domain , $Line ) { 63 | $editZoneRecordOperation = new EditZoneRecordOperation( $this->cpanel ); 64 | $editZoneRecordOperation->setDomain( $domain ); 65 | $editZoneRecordOperation->setLine( $Line ); 66 | 67 | return $editZoneRecordOperation; 68 | } 69 | 70 | /** 71 | * @param string $domain 72 | * @param string $Line 73 | * @return GetZoneRecordOperation 74 | */ 75 | public function getZoneRecord( $domain , $Line ) { 76 | $getZoneRecordOperation = new GetZoneRecordOperation( $this->cpanel ); 77 | $getZoneRecordOperation->setDomain( $domain ); 78 | $getZoneRecordOperation->setLine( $Line ); 79 | 80 | return $getZoneRecordOperation; 81 | } 82 | 83 | /** 84 | * @param string $domain 85 | * @return KillDNSOperation 86 | */ 87 | public function killDNS( $domain ) { 88 | $killDNSOperation = new KillDNSOperation( $this->cpanel ); 89 | $killDNSOperation->setDomain( $domain ); 90 | 91 | return $killDNSOperation; 92 | } 93 | 94 | /** 95 | * @return ListZonesOperation 96 | */ 97 | public function listZones() { 98 | return new ListZonesOperation( $this->cpanel ); 99 | } 100 | } -------------------------------------------------------------------------------- /com/imasters/php/http/Cookie.php: -------------------------------------------------------------------------------- 1 | 10 | * @brief Cookie HTTP 11 | * @details Implementação de um cookie HTTP segundo a especificação 12 | * RFC 2109. 13 | */ 14 | class Cookie { 15 | /** 16 | * @brief Comentário opcional do cookie 17 | * @var string 18 | */ 19 | protected $comment; 20 | 21 | /** 22 | * @brief Domínio do cookie 23 | * @var string 24 | */ 25 | protected $domain; 26 | 27 | /** 28 | * @brief Expiração do cookie (unix timestamp) 29 | * @var integer 30 | */ 31 | protected $expires; 32 | 33 | /** 34 | * @brief Nome do cookie 35 | * @var string 36 | */ 37 | protected $name; 38 | 39 | /** 40 | * @brief Caminho do cookie 41 | * @var string 42 | */ 43 | protected $path; 44 | 45 | /** 46 | * @brief Ambiente seguro (HTTPS) 47 | * @details Indica se o User-Agent deve utilizar o cookie 48 | * apenas em ambiente seguro (HTTPS) 49 | * @var boolean 50 | */ 51 | protected $secure; 52 | 53 | /** 54 | * @brief Valor do cookie 55 | * @var string 56 | */ 57 | protected $value; 58 | 59 | /** 60 | * @brief Constroi um cookie 61 | * @param string $name Nome do cookie 62 | * @param string $value Valor do cookie 63 | * @param string $domain Domínio do cookie 64 | * @param integer $expires Timestamp da expiração do cookie 65 | * @param string $path Caminho do cookie 66 | * @param boolean $secure Se o cookie é usado apenas em ambiente 67 | * seguro. 68 | * @param string $comment Comentário do cookie 69 | * @throws InvalidArgumentException Se $expires não for um número 70 | */ 71 | public function __construct( $name , $value , $domain , $expires , $path = '/' , $secure = false , $comment = null ) { 72 | $this->name = (string) $name; 73 | $this->value = (string) $value; 74 | $this->domain = (string) $domain; 75 | 76 | if ( is_numeric( $expires ) ) { 77 | $this->expires = (int) $expires; 78 | } else { 79 | throw new InvalidArgumentException( '$expires deve ser um número representando o timestamp da expiração do cookie, "' . $expires . '" foi dado.' ); 80 | } 81 | 82 | $this->path = (string) $path; 83 | $this->secure = $secure === true; 84 | $this->comment = $comment; 85 | } 86 | 87 | /** 88 | * @brief Retorna a representação do Cookie como uma string 89 | * @return string 90 | */ 91 | public function __toString() { 92 | return sprintf( '%s=%s' , $this->name , $this->value ); 93 | } 94 | 95 | /** 96 | * @brief Recupera o comentário do cookie 97 | * @return string 98 | */ 99 | public function getComment() { 100 | return $this->comment; 101 | } 102 | 103 | /** 104 | * @brief Recupera o domínio do cookie 105 | * @return string 106 | */ 107 | public function getDomain() { 108 | return $this->domain; 109 | } 110 | 111 | /** 112 | * @brief Recupera o timestamp da expiração do cookie 113 | * @return integer 114 | */ 115 | public function getExpires() { 116 | return $this->expires; 117 | } 118 | 119 | /** 120 | * @brief Recupera o nome do cookie 121 | * @return string 122 | */ 123 | public function getName() { 124 | return $this->name; 125 | } 126 | 127 | /** 128 | * @brief Recupera o caminho do cookie 129 | * @return string 130 | */ 131 | public function getPath() { 132 | return $this->path; 133 | } 134 | 135 | /** 136 | * @brief Recupera o valor do cookie 137 | * @return string 138 | */ 139 | public function getValue() { 140 | return $this->value; 141 | } 142 | 143 | /** 144 | * @brief Verifica ambiente seguro. 145 | * @details Verifica se o User-Agent deve utilizar o 146 | * cookie apenas em ambiente seguro. 147 | * @return boolean 148 | */ 149 | public function isSecure() { 150 | return $this->secure; 151 | } 152 | } -------------------------------------------------------------------------------- /com/imasters/php/http/HTTPResponse.php: -------------------------------------------------------------------------------- 1 | 12 | * @brief Resposta HTTP 13 | * @details Implementação de um objeto representa uma resposta HTTP. 14 | */ 15 | class HTTPResponse { 16 | /** 17 | * @var array 18 | */ 19 | private $responseHeader = array(); 20 | 21 | /** 22 | * @var string 23 | */ 24 | private $responseBody; 25 | 26 | /** 27 | * @var integer 28 | */ 29 | private $statusCode; 30 | 31 | /** 32 | * @var string 33 | */ 34 | private $statusMessage; 35 | 36 | /** 37 | * @brief Recupera o corpo da resposta HTTP. 38 | * @return string 39 | */ 40 | public function getContent() { 41 | return $this->responseBody; 42 | } 43 | 44 | /** 45 | * @brief Recupera o tamanho do corpo da resposta. 46 | * @return integer 47 | */ 48 | public function getContentLength() { 49 | return $this->getHeaderInt( 'Content-Length' ); 50 | } 51 | 52 | /** 53 | * @brief Recupera o tipo de conteúdo da resposta. 54 | * @return string 55 | */ 56 | public function getContentType() { 57 | return $this->getHeader( 'Content-Type' ); 58 | } 59 | 60 | /** 61 | * @brief Recupera o código de status da resposta do servidor. 62 | * @return integer 63 | */ 64 | public function getStatusCode() { 65 | return $this->statusCode; 66 | } 67 | 68 | /** 69 | * @brief Recupera a mensagem de status da resposta do servidor. 70 | * @return string 71 | */ 72 | public function getStatusMessage() { 73 | return $this->statusMessage; 74 | } 75 | 76 | /** 77 | * @brief Verifica se existe um cabeçalho de resposta HTTP. 78 | * @param string $name Nome do cabeçalho 79 | * @return boolean 80 | */ 81 | public function hasResponseHeader( $name ) { 82 | return isset( $this->responseHeader[ strtolower( $name ) ] ); 83 | } 84 | 85 | /** 86 | * @brief Recupera o valor um campo de cabeçalho da resposta HTTP. 87 | * @param string $name Nome do campo de cabeçalho. 88 | * @return string O valor do campo ou NULL se não estiver 89 | * existir. 90 | */ 91 | public function getHeader( $name ) { 92 | $key = strtolower( $name ); 93 | 94 | if ( isset( $this->responseHeader[ $key ] ) ) { 95 | if ( !isset( $this->responseHeader[ $key ][ 'name' ] ) && is_array( $this->responseHeader[ $key ] ) ) { 96 | $values = array(); 97 | 98 | foreach ( $this->responseHeader[ $key ] as $header ) { 99 | $values[] = $header[ 'value' ]; 100 | } 101 | 102 | return $values; 103 | } else { 104 | return $this->responseHeader[ $key ][ 'value' ]; 105 | } 106 | } 107 | 108 | return null; 109 | } 110 | 111 | /** 112 | * @brief Recupera um valor como inteiro de um campo de cabeçalho da 113 | * resposta HTTP. 114 | * @param string $name Nome do campo de cabeçalho. 115 | * @return integer 116 | */ 117 | public function getHeaderInt( $name ) { 118 | return (int) $this->getHeader( $name ); 119 | } 120 | 121 | /** 122 | * @brief Recupera um valor como unix timestamp de um campo de cabeçalho 123 | * da resposta HTTO. 124 | * @param string $name Nome do campo de cabeçalho. 125 | * @return integer UNIX Timestamp ou NULL se não estiver definido. 126 | */ 127 | public function getHeaderDate( $name ) { 128 | $date = $this->getHeader( $name ); 129 | 130 | if ( !is_null( $date ) && !empty( $date ) ) { 131 | return strtotime( $date ); 132 | } 133 | } 134 | 135 | /** 136 | * @brief Define a resposta da requisição HTTP. 137 | * @param string $response Toda a resposta da requisição 138 | */ 139 | public function setRawResponse( $response , CookieManager $cookieManager = null ) { 140 | $parts = explode( "\r\n\r\n" , $response ); 141 | 142 | if ( count( $parts ) == 2 ) { 143 | $matches = array(); 144 | $this->responseBody = $parts[ 1 ]; 145 | 146 | if ( preg_match_all( "/(HTTP\\/[1-9]\\.[0-9]\\s+(?\\d+)\\s+(?.*)|(?[^:]+)\\s*:\\s*(?.*))\r\n/m" , $parts[ 0 ] , $matches ) ) { 147 | foreach ( $matches[ 'statusCode' ] as $offset => $match ) { 148 | if ( !empty( $match ) ) { 149 | $this->statusCode = (int) $match; 150 | $this->statusMessage = $matches[ 'statusMessage' ][ $offset ]; 151 | break; 152 | } 153 | } 154 | 155 | foreach ( $matches[ 'headerName' ] as $offset => $name ) { 156 | if ( !empty( $name ) ) { 157 | $key = strtolower( $name ); 158 | $header = array( 159 | 'name' => $name, 160 | 'value' => $matches[ 'headerValue' ][ $offset ] 161 | ); 162 | 163 | if ( isset( $this->responseHeader[ $key ] ) ) { 164 | if ( isset( $this->responseHeader[ $key ][ 'name' ] ) ) { 165 | $this->responseHeader[ $key ] = array( $this->responseHeader[ $key ] ); 166 | } 167 | 168 | $this->responseHeader[ $key ][] = $header; 169 | 170 | } else { 171 | $this->responseHeader[ $key ] = $header; 172 | } 173 | } 174 | } 175 | } 176 | } else { 177 | $this->responseBody = $response; 178 | } 179 | } 180 | } -------------------------------------------------------------------------------- /com/imasters/php/http/HTTPCookieManager.php: -------------------------------------------------------------------------------- 1 | 12 | * @brief Gerenciador de Cookies HTTP 13 | * @details Implementação da interface CookieManager para 14 | * criação de um gerenciador de cookies que armazena os 15 | * cookies em um arquivo em disco. 16 | */ 17 | class HTTPCookieManager implements CookieManager { 18 | /** 19 | * @var string 20 | */ 21 | private $cookieFile; 22 | 23 | /** 24 | * @var array 25 | */ 26 | private $cookies = array(); 27 | 28 | /** 29 | * @brief Constroi o gerenciador de cookies que grava as informações 30 | * em um arquivo. 31 | * @param string $dirname Diretório onde os cookies serão 32 | * gravados, caso não informado o diretório temporário do 33 | * sistema será utilizado. 34 | */ 35 | public function __construct( $dirname = null ) { 36 | if ( $dirname == null ) { 37 | $dirname = sys_get_temp_dir(); 38 | } 39 | 40 | if ( is_readable( $dirname ) && is_writable( $dirname ) ) { 41 | $cookieFile = realpath( $dirname ) . '/cookie.jar'; 42 | 43 | if ( !is_file( $cookieFile ) ) { 44 | touch( $cookieFile ); 45 | } else { 46 | $cookieManager = unserialize( file_get_contents( $cookieFile ) ); 47 | 48 | if ( $cookieManager instanceof HTTPCookieManager ) { 49 | $this->cookies = $cookieManager->cookies; 50 | } 51 | } 52 | 53 | $this->cookieFile = $cookieFile; 54 | } else { 55 | throw new RuntimeException( 'O diretório ' . $dirname . ' precisa ter permissões de leitura e gravação.' ); 56 | } 57 | } 58 | 59 | /** 60 | * @brief Destroi o objeto e salva os cookies armazenados 61 | */ 62 | public function __destruct() { 63 | if ( $this->cookieFile != null ) { 64 | file_put_contents( $this->cookieFile , serialize( $this ) ); 65 | } 66 | } 67 | 68 | /** 69 | * @see CookieManager::addCookie() 70 | */ 71 | public function addCookie( Cookie $cookie ) { 72 | $cookieDomain = $cookie->getDomain(); 73 | 74 | if ( !isset( $this->cookies[ $cookieDomain ] ) ) { 75 | $this->cookies[ $cookieDomain ] = array(); 76 | } 77 | 78 | $this->cookies[ $cookieDomain ][] = $cookie; 79 | } 80 | 81 | /** 82 | * @see CookieManager::getCookie() 83 | */ 84 | public function getCookie( $domain , $secure , $path ) { 85 | return implode( '; ' , $this->getCookieArray( $domain , $secure , $path ) ); 86 | } 87 | 88 | private function getCookieArray( $domain , $secure , $path ) { 89 | $cookies = array(); 90 | $secure = $secure === true; 91 | 92 | if ( isset( $this->cookies[ $domain ] ) ) { 93 | foreach ( $this->cookies[ $domain ] as $cookie ) { 94 | if ( $cookie->isSecure() == $secure && $cookie->getPath() == $path ) { 95 | $cookies[] = $cookie; 96 | } 97 | } 98 | } 99 | 100 | return $cookies; 101 | } 102 | 103 | /** 104 | * @see CookieManager::getCookieIterator() 105 | */ 106 | public function getCookieIterator( $domain , $secure , $path ) { 107 | return new ArrayIterator( $this->getCookieArray( $domain , $secure , $path ) ); 108 | } 109 | 110 | /** 111 | * @see CookieManager::setCookie() 112 | */ 113 | public function setCookie( $setCookie , $domain = null ) { 114 | if ( is_array( $setCookie ) ) { 115 | foreach ( $setCookie as $setCookieItem ) { 116 | $this->setCookie( $setCookieItem ); 117 | } 118 | } else { 119 | $matches = array(); 120 | 121 | if ( preg_match( '/(?[^\=]+)\=(?[^;]+)(; expires=(?[^;]+))?(; path=(?[^;]+))?(; domain=(?[^;]+))?(; (?secure))?(; (?httponly))?/' , $setCookie , $matches ) ){ 122 | $cookieName = null; 123 | $cookieValue = null; 124 | $cookieExpires = INF; 125 | $cookiePath = '/'; 126 | $cookieDomain = $domain; 127 | $cookieSecure = false; 128 | 129 | foreach ( $matches as $key => $value ) { 130 | if ( !empty( $value ) ) { 131 | switch ( $key ) { 132 | case 'name' : 133 | $cookieName = $value; 134 | break; 135 | case 'value' : 136 | $cookieValue = $value; 137 | break; 138 | case 'expires' : 139 | $cookieExpires = strtotime( $value ); 140 | break; 141 | case 'path' : 142 | $cookiePath = $value; 143 | break; 144 | case 'domain' : 145 | $cookieDomain = $value; 146 | break; 147 | case 'secure' : 148 | $cookieSecure = true; 149 | break; 150 | } 151 | } 152 | } 153 | 154 | if ( !isset( $this->cookies[ $cookieDomain ] ) ) { 155 | $this->cookies[ $cookieDomain ] = array(); 156 | } 157 | 158 | $this->cookies[ $cookieDomain ][] = new Cookie( $cookieName , $cookieValue , $cookieDomain , $cookieExpires , $cookiePath , $cookieSecure ); 159 | } 160 | } 161 | } 162 | 163 | /** 164 | * @see Serializable::serialize() 165 | */ 166 | public function serialize() { 167 | return serialize( $this->cookies ); 168 | } 169 | 170 | /** 171 | * @see Serializable::unserialize() 172 | */ 173 | public function unserialize( $serialized ) { 174 | $cookies = unserialize( $serialized ); 175 | 176 | if ( is_array( $cookies ) ) { 177 | $now = time(); 178 | 179 | foreach ( $cookies as $domain => $domainCookies ) { 180 | foreach ( $domainCookies as $cookie ) { 181 | if ( $cookie instanceof Cookie ) { 182 | if ( $cookie->getExpires() > $now ) { 183 | if ( !isset( $this->cookies[ $domain ] ) ) { 184 | $this->cookies[ $domain ] = array(); 185 | } 186 | 187 | $this->cookies[ $domain ][] = $cookie; 188 | } 189 | } 190 | } 191 | } 192 | } 193 | } 194 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/dns/AddZoneRecordOperation.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | class AddZoneRecordOperation extends cPanelOperation { 15 | /** 16 | * @var string 17 | */ 18 | private $address; 19 | 20 | /** 21 | * @var string 22 | */ 23 | private $class; 24 | 25 | /** 26 | * @var string 27 | */ 28 | private $cname; 29 | 30 | /** 31 | * @var string 32 | */ 33 | private $exchange; 34 | 35 | /** 36 | * @var string 37 | */ 38 | private $name; 39 | 40 | /** 41 | * @var string 42 | */ 43 | private $nsname; 44 | 45 | /** 46 | * @var integer 47 | */ 48 | private $port; 49 | 50 | /** 51 | * @var integer 52 | */ 53 | private $preference; 54 | 55 | /** 56 | * @var string 57 | */ 58 | private $ptdrname; 59 | 60 | /** 61 | * @var string 62 | */ 63 | private $target; 64 | 65 | /** 66 | * @var integer 67 | */ 68 | private $ttl; 69 | 70 | /** 71 | * @var string 72 | */ 73 | private $type; 74 | 75 | /** 76 | * @var integer 77 | */ 78 | private $weight; 79 | 80 | /** 81 | * @var string 82 | */ 83 | private $zone; 84 | 85 | /** 86 | * Recupera o valor de $address 87 | * @return string 88 | */ 89 | public function getAddress() { 90 | return $this->address; 91 | } 92 | 93 | /** 94 | * Recupera o valor de $class 95 | * @return string 96 | */ 97 | public function getClass() { 98 | return $this->class; 99 | } 100 | 101 | /** 102 | * Recupera o valor de $cname 103 | * @return string 104 | */ 105 | public function getCname() { 106 | return $this->cname; 107 | } 108 | 109 | /** 110 | * Recupera o valor de $exchange 111 | * @return string 112 | */ 113 | public function getExchange() { 114 | return $this->exchange; 115 | } 116 | 117 | /** 118 | * Recupera o valor de $name 119 | * @return string 120 | */ 121 | public function getName() { 122 | return $this->name; 123 | } 124 | 125 | /** 126 | * Recupera o valor de $nsname 127 | * @return string 128 | */ 129 | public function getNsname() { 130 | return $this->nsname; 131 | } 132 | 133 | /** 134 | * @see cPanelOperation::getOperationName() 135 | * @return string 136 | */ 137 | public function getOperationName() { 138 | return 'addzonerecord'; 139 | } 140 | 141 | /** 142 | * Recupera o valor de $port 143 | * @return integer 144 | */ 145 | public function getPort() { 146 | return $this->port; 147 | } 148 | 149 | /** 150 | * Recupera o valor de $preference 151 | * @return integer 152 | */ 153 | public function getPreference() { 154 | return $this->preference; 155 | } 156 | 157 | /** 158 | * Recupera o valor de $ptdrname 159 | * @return string 160 | */ 161 | public function getPtdrname() { 162 | return $this->ptdrname; 163 | } 164 | 165 | /** 166 | * Recupera o valor de $target 167 | * @return string 168 | */ 169 | public function getTarget() { 170 | return $this->target; 171 | } 172 | 173 | /** 174 | * Recupera o valor de $ttl 175 | * @return integer 176 | */ 177 | public function getTtl() { 178 | return $this->ttl; 179 | } 180 | 181 | /** 182 | * Recupera o valor de $type 183 | * @return string 184 | */ 185 | public function getType() { 186 | return $this->type; 187 | } 188 | 189 | /** 190 | * Recupera o valor de $weight 191 | * @return integer 192 | */ 193 | public function getWeight() { 194 | return $this->weight; 195 | } 196 | 197 | /** 198 | * Recupera o valor de $zone 199 | * @return string 200 | */ 201 | public function getZone() { 202 | return $this->zone; 203 | } 204 | 205 | /** 206 | * @param string $address 207 | */ 208 | public function setAddress( $address ) { 209 | $this->address = $address; 210 | $this->httpConnection->setParam( 'address' , $address ); 211 | } 212 | 213 | /** 214 | * @param string $class 215 | */ 216 | public function setClass( $class ) { 217 | $this->class = $class; 218 | $this->httpConnection->setParam( 'class' , $class ); 219 | } 220 | 221 | /** 222 | * @param string $cname 223 | */ 224 | public function setCname( $cname ) { 225 | $this->cname = $cname; 226 | $this->httpConnection->setParam( 'cname' , $cname ); 227 | } 228 | 229 | /** 230 | * @param string $exchange 231 | */ 232 | public function setExchange( $exchange ) { 233 | $this->exchange = $exchange; 234 | $this->httpConnection->setParam( 'exchange' , $exchange ); 235 | } 236 | 237 | /** 238 | * @param string $name 239 | */ 240 | public function setName( $name ) { 241 | $this->name = $name; 242 | $this->httpConnection->setParam( 'name' , $name ); 243 | } 244 | 245 | /** 246 | * @param string $nsname 247 | */ 248 | public function setNsname( $nsname ) { 249 | $this->nsname = $nsname; 250 | $this->httpConnection->setParam( 'nsname' , $nsname ); 251 | } 252 | 253 | /** 254 | * @param integer $port 255 | */ 256 | public function setPort( $port ) { 257 | $this->port = $port; 258 | $this->httpConnection->setParam( 'port' , $port ); 259 | } 260 | 261 | /** 262 | * @param integer $preference 263 | */ 264 | public function setPreference( $preference ) { 265 | $this->preference = $preference; 266 | $this->httpConnection->setParam( 'preference' , $preference ); 267 | } 268 | 269 | /** 270 | * @param string $ptdrname 271 | */ 272 | public function setPtdrname( $ptdrname ) { 273 | $this->ptdrname = $ptdrname; 274 | $this->httpConnection->setParam( 'ptdrname' , $ptdrname ); 275 | } 276 | 277 | /** 278 | * @param string $target 279 | */ 280 | public function setTarget( $target ) { 281 | $this->target = $target; 282 | $this->httpConnection->setParam( 'target' , $target ); 283 | } 284 | 285 | /** 286 | * @param integer $ttl 287 | */ 288 | public function setTtl( $ttl ) { 289 | $this->ttl = $ttl; 290 | $this->httpConnection->setParam( 'ttl' , $ttl ); 291 | } 292 | 293 | /** 294 | * @param string $type 295 | */ 296 | public function setType( $type ) { 297 | $this->type = $type; 298 | $this->httpConnection->setParam( 'type' , $type ); 299 | } 300 | 301 | /** 302 | * @param integer $weight 303 | */ 304 | public function setWeight( $weight ) { 305 | $this->weight = $weight; 306 | $this->httpConnection->setParam( 'weight' , $weight ); 307 | } 308 | 309 | /** 310 | * @param string $zone 311 | */ 312 | public function setZone( $zone ) { 313 | $this->zone = $zone; 314 | $this->httpConnection->setParam( 'zone' , $zone ); 315 | } 316 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/account/AccountModule.php: -------------------------------------------------------------------------------- 1 | 28 | */ 29 | class AccountModule extends cPanelModule { 30 | /** 31 | * @param string $user 32 | * @return AccountSummaryOperation 33 | */ 34 | public function accountSummary( $user = null ) { 35 | $accountSummaryOperation = new AccountSummaryOperation( $this->cpanel ); 36 | 37 | if ( !is_null( $user ) ) { 38 | $accountSummaryOperation->setUser( $user ); 39 | } 40 | 41 | return $accountSummaryOperation; 42 | } 43 | 44 | /** 45 | * @param string $user 46 | * @param string $pkg 47 | * @return ChangePackageOperation 48 | */ 49 | public function changePackage( $user , $pkg ) { 50 | $changePackageOperation = new ChangePackageOperation( $this->cpanel ); 51 | $changePackageOperation->setUser( $user ); 52 | $changePackageOperation->setPkg( $pkg ); 53 | 54 | return $changePackageOperation; 55 | } 56 | 57 | /** 58 | * @param string $username 59 | * @param string $domain 60 | * @return CreateAccountOperation 61 | */ 62 | public function createAccount( $username , $domain ) { 63 | $createAccountOperation = new CreateAccountOperation( $this->cpanel ); 64 | $createAccountOperation->setUsername( $username ); 65 | $createAccountOperation->setDomain( $domain ); 66 | 67 | return $createAccountOperation; 68 | } 69 | 70 | /** 71 | * @param string $domain 72 | * @return DomainUserDataOperation 73 | */ 74 | public function domainUserData( $domain ) { 75 | $domainUserDataOperation = new DomainUserDataOperation( $this->cpanel ); 76 | $domainUserDataOperation->setDomain( $domain ); 77 | 78 | return $domainUserDataOperation; 79 | } 80 | 81 | /** 82 | * @param string $user 83 | * @param integer $quota 84 | * @return EditQuotaOperation 85 | */ 86 | public function editQuota( $user , $quota ) { 87 | $editQuotaOperation = new EditQuotaOperation( $this->cpanel ); 88 | $editQuotaOperation->setUser( $user ); 89 | $editQuotaOperation->setQuota( $quota ); 90 | 91 | return $editQuotaOperation; 92 | } 93 | 94 | /** 95 | * @param string $user 96 | * @param string $bwlimit 97 | * @return LimitBandwidthOperation 98 | */ 99 | public function limitBandwidth( $user , $bwlimit ) { 100 | $limitBWOperation = new LimitBandwidthOperation( $this->cpanel ); 101 | $limitBWOperation->setUser( $user ); 102 | $limitBWOperation->setBwlimit( $bwlimit ); 103 | 104 | return $limitBWOperation; 105 | } 106 | 107 | /** 108 | * @param string $search 109 | * @param string $searchtype 110 | * @return ListAccountsOperation 111 | */ 112 | public function listAccounts( $search = null , $searchtype = null ) { 113 | $listAccountsOperation = new ListAccountsOperation( $this->cpanel ); 114 | 115 | if ( !is_null( $search ) ) { 116 | $listAccountsOperation->setSearch( $search ); 117 | } 118 | 119 | if ( !is_null( $searchtype ) ) { 120 | $listAccountsOperation->setSearchtype( $searchtype ); 121 | } 122 | 123 | return $listAccountsOperation; 124 | } 125 | 126 | /** 127 | * @return ListSuspendedAccountsOperation 128 | */ 129 | public function listSuspendedAccounts() { 130 | return new ListSuspendedAccountsOperation( $this->cpanel ); 131 | } 132 | 133 | /** 134 | * @param string $user 135 | * @return ModifyAccountOperation 136 | */ 137 | public function modifyAccount( $user ) { 138 | $modifyAccountOperation = new ModifyAccountOperation( $this->cpanel ); 139 | $modifyAccountOperation->setUser( $user ); 140 | 141 | return $modifyAccountOperation; 142 | } 143 | 144 | /** 145 | * @param string $user 146 | * @param string $pass 147 | * @param boolean $db_pass_update 148 | * @return PasswdOperation 149 | */ 150 | public function passwd( $user , $pass , $db_pass_update = 1 ) { 151 | $passwdOperation = new PasswdOperation( $this->cpanel ); 152 | $passwdOperation->setUser( $user ); 153 | $passwdOperation->setPass( $pass ); 154 | $passwdOperation->setDbPassUpdate( $db_pass_update ); 155 | 156 | return $passwdOperation; 157 | } 158 | 159 | /** 160 | * @param string $ip 161 | * @return SetSiteIPOperation 162 | */ 163 | public function setSiteIP( $ip ) { 164 | $setSiteIPOperation = new SetSiteIPOperation( $this->cpanel ); 165 | $setSiteIPOperation->setIp( $ip ); 166 | 167 | return $setSiteIPOperation; 168 | } 169 | 170 | /** 171 | * @param string $user 172 | * @param string $reason 173 | * @return SuspendAccountOperation 174 | */ 175 | public function suspendAccount( $user , $reason = null ) { 176 | $suspendAccountOperation = new SuspendAccountOperation( $this->cpanel ); 177 | $suspendAccountOperation->setUser( $user ); 178 | 179 | if ( !is_null( $reason ) ) { 180 | $suspendAccountOperation->setReason( $reason ); 181 | } 182 | 183 | return $suspendAccountOperation; 184 | } 185 | 186 | /** 187 | * @param string $user 188 | * @param boolean $keepdns 189 | * @return TerminateAccountOperation 190 | */ 191 | public function terminateAccount( $user , $keepdns = false ) { 192 | $terminateAccountOperation = new TerminateAccountOperation( $this->cpanel ); 193 | $terminateAccountOperation->setUser( $user ); 194 | $terminateAccountOperation->setKeepdns( $keepdns ); 195 | 196 | return $terminateAccountOperation; 197 | } 198 | 199 | /** 200 | * @param string $user 201 | * @return UnsuspendAccountOperation 202 | */ 203 | public function unsuspendAccount( $user ) { 204 | $unsuspendAccountOperation = new UnsuspendAccountOperation( $this->cpanel ); 205 | $unsuspendAccountOperation->setUser( $user ); 206 | 207 | return $unsuspendAccountOperation; 208 | } 209 | 210 | /** 211 | * @return ViewPrivilegesOperation 212 | */ 213 | public function viewPrivileges() { 214 | return new ViewPrivilegesOperation( $this->cpanel ); 215 | } 216 | } -------------------------------------------------------------------------------- /com/imasters/php/http/CURL.php: -------------------------------------------------------------------------------- 1 | 13 | * @brief Requisição HTTP cURL 14 | * @details Implementação da interface HTTPRequest para uma 15 | * requisição HTTP que utiliza cURL. 16 | */ 17 | class CURL implements HTTPRequest { 18 | /** 19 | * @var resource 20 | */ 21 | private $curlResource; 22 | 23 | /** 24 | * @var HTTPConnection 25 | */ 26 | private $httpConnection; 27 | 28 | /** 29 | * @var HTTPResponse 30 | */ 31 | private $httpResponse; 32 | 33 | /** 34 | * @var boolean 35 | */ 36 | private $openned = false; 37 | 38 | /** 39 | * @var string 40 | */ 41 | private $requestBody; 42 | 43 | /** 44 | * @var array 45 | */ 46 | private $requestHeader = array(); 47 | 48 | /** 49 | * @var array 50 | */ 51 | private $requestParameter = array(); 52 | 53 | /** 54 | * @brief Destroi o objeto 55 | * @details Destroi o objeto e fecha a requisição se estiver 56 | * aberta. 57 | */ 58 | public function __destruct() { 59 | $this->close(); 60 | } 61 | 62 | /** 63 | * @see HTTPRequest::addRequestHeader() 64 | */ 65 | public function addRequestHeader( $name , $value , $override = true ) { 66 | if ( is_scalar( $name ) && is_scalar( $value ) ) { 67 | $key = strtolower( $name ); 68 | 69 | if ( $override === true || !isset( $this->requestHeader[ $key ] ) ) { 70 | $this->requestHeader[ $key ] = array( 'name' => $name , 'value' => $value ); 71 | 72 | return true; 73 | } 74 | 75 | return false; 76 | } else { 77 | throw new InvalidArgumentException( '$name e $value precisam ser strings.' ); 78 | } 79 | } 80 | 81 | /** 82 | * @brief Autentica uma requisição HTTP. 83 | * @param HTTPAuthenticator $authenticator 84 | * @see HTTPRequest::authenticate() 85 | */ 86 | public function authenticate( HTTPAuthenticator $authenticator ) { 87 | $authenticator->authenticate( $this ); 88 | } 89 | 90 | /** 91 | * @see HTTPRequest::close() 92 | */ 93 | public function close() { 94 | if ( $this->openned ) { 95 | curl_close( $this->curlResource ); 96 | $this->openned = false; 97 | } 98 | } 99 | 100 | /** 101 | * @see HTTPRequest::execute() 102 | */ 103 | public function execute( $path = '/' , $method = HTTPRequestMethod::GET ) { 104 | $targetURL = $this->httpConnection->getURI() . $path; 105 | $hasParameters = count( $this->requestParameter ) > 0; 106 | $query = $hasParameters ? http_build_query( $this->requestParameter ) : null; 107 | 108 | switch ( $method ) { 109 | case HTTPRequestMethod::PUT : 110 | case HTTPRequestMethod::POST : 111 | if ( $method != HTTPRequestMethod::POST ) { 112 | curl_setopt( $this->curlResource , CURLOPT_CUSTOMREQUEST , $method ); 113 | } else { 114 | curl_setopt( $this->curlResource , CURLOPT_POST , 1 ); 115 | } 116 | 117 | if ( empty( $this->requestBody ) ) { 118 | curl_setopt( $this->curlResource , CURLOPT_POSTFIELDS , $query ); 119 | } else { 120 | if ( $hasParameters ) { 121 | $targetURL .= '?' . $query; 122 | } 123 | 124 | curl_setopt( $this->curlResource , CURLOPT_POSTFIELDS , $this->requestBody ); 125 | } 126 | 127 | curl_setopt( $this->curlResource , CURLOPT_URL , $targetURL ); 128 | 129 | break; 130 | case HTTPRequestMethod::DELETE : 131 | case HTTPRequestMethod::HEAD : 132 | case HTTPRequestMethod::OPTIONS: 133 | case HTTPRequestMethod::TRACE: 134 | curl_setopt( $this->curlResource , CURLOPT_CUSTOMREQUEST , $method ); 135 | case HTTPRequestMethod::GET: 136 | if ( $hasParameters ) { 137 | $targetURL .= '?' . $query; 138 | } 139 | 140 | curl_setopt( $this->curlResource , CURLOPT_URL , $targetURL ); 141 | 142 | break; 143 | default : 144 | throw new UnexpectedValueException( 'Método desconhecido' ); 145 | } 146 | 147 | $resp = curl_exec( $this->curlResource ); 148 | $errno = curl_errno( $this->curlResource ); 149 | $error = curl_error( $this->curlResource ); 150 | 151 | if ( $errno != 0 ) { 152 | throw new RuntimeException( $error , $errno ); 153 | } 154 | 155 | $this->httpResponse = new HTTPResponse(); 156 | $this->httpResponse->setRawResponse( $resp ); 157 | 158 | if ( $this->httpResponse->hasResponseHeader( 'Set-Cookie' ) ) { 159 | $cookieManager = $this->httpConnection->getCookieManager(); 160 | 161 | if ( $cookieManager != null ) { 162 | $cookieManager->setCookie( $this->httpResponse->getHeader( 'Set-Cookie' ) , $this->httpConnection->getHostName() ); 163 | } 164 | } 165 | 166 | $statusCode = $this->httpResponse->getStatusCode(); 167 | 168 | return $statusCode < 400; 169 | } 170 | 171 | /** 172 | * @see HTTPRequest::getResponse() 173 | */ 174 | public function getResponse() { 175 | return $this->httpResponse; 176 | } 177 | 178 | /** 179 | * @see HTTPRequest::open() 180 | */ 181 | public function open( HTTPConnection $httpConnection ) { 182 | if ( function_exists( 'curl_init' ) ) { 183 | /** 184 | * Fechamos uma conexão existente antes de abrir uma nova 185 | */ 186 | $this->close(); 187 | 188 | $curl = curl_init(); 189 | 190 | /** 191 | * Verificamos se o recurso CURL foi criado com êxito 192 | */ 193 | if ( is_resource( $curl ) ) { 194 | curl_setopt( $curl , CURLOPT_SSL_VERIFYPEER , 0 ); 195 | curl_setopt( $curl , CURLOPT_HEADER , 1 ); 196 | curl_setopt( $curl , CURLOPT_RETURNTRANSFER , 1 ); 197 | curl_setopt( $curl , CURLINFO_HEADER_OUT , 1 ); 198 | 199 | if ( ( $timeout = $httpConnection->getTimeout() ) != null ) { 200 | curl_setopt( $curl , CURLOPT_TIMEOUT , $timeout ); 201 | } 202 | 203 | if ( ( $connectionTimeout = $httpConnection->getConnectionTimeout() ) != null ) { 204 | curl_setopt( $curl , CURLOPT_CONNECTTIMEOUT , $connectionTimeout ); 205 | } 206 | 207 | $headers = array(); 208 | 209 | foreach ( $this->requestHeader as $header ) { 210 | $headers[] = sprintf( '%s: %s' , $header[ 'name' ] , $header[ 'value' ] ); 211 | } 212 | 213 | curl_setopt( $curl , CURLOPT_HTTPHEADER , $headers ); 214 | 215 | $this->curlResource = $curl; 216 | $this->httpConnection = $httpConnection; 217 | $this->openned = true; 218 | } else { 219 | throw new RuntimeException( 'Não foi possível iniciar cURL' ); 220 | } 221 | } else { 222 | throw new RuntimeException( 'Extensão cURL não está instalada.' ); 223 | } 224 | } 225 | 226 | /** 227 | * @brief Define um parâmetro 228 | * @details Define um parâmetro que será enviado com a requisição, 229 | * um parâmetro é um par nome-valor que será enviado como uma 230 | * query string (ex: ?name=value). 231 | * @param string $name Nome do parâmetro. 232 | * @param string $value Valor do parâmetro. 233 | * @throws InvalidArgumentException Se o nome ou o valor 234 | * do campo não forem valores scalar. 235 | * @see HTTPRequest::setParameter() 236 | */ 237 | public function setParameter( $name , $value ) { 238 | $this->requestParameter[ $name ] = $value; 239 | } 240 | 241 | /** 242 | * @see HTTPRequest::setRequestBody() 243 | */ 244 | public function setRequestBody( $requestBody ) { 245 | $this->requestBody = $requestBody; 246 | } 247 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/account/ModifyAccountOperation.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | class ModifyAccountOperation extends cPanelOperation { 17 | /** 18 | * @var string 19 | */ 20 | private $CPTHEME; 21 | 22 | /** 23 | * @var string 24 | */ 25 | private $domain; 26 | 27 | /** 28 | * @var string 29 | */ 30 | private $HASCGI; 31 | 32 | /** 33 | * @var string 34 | */ 35 | private $LANG; 36 | 37 | /** 38 | * @var string 39 | */ 40 | private $LOCALE; 41 | 42 | /** 43 | * @var string 44 | */ 45 | private $MAXADDON; 46 | 47 | /** 48 | * @var string 49 | */ 50 | private $MAXFTP; 51 | 52 | /** 53 | * @var string 54 | */ 55 | private $MAXLST; 56 | 57 | /** 58 | * @var string 59 | */ 60 | private $MAXPARK; 61 | 62 | /** 63 | * @var string 64 | */ 65 | private $MAXPOP; 66 | 67 | /** 68 | * @var string 69 | */ 70 | private $MAXSQL; 71 | 72 | /** 73 | * @var string 74 | */ 75 | private $MAXSUB; 76 | 77 | /** 78 | * @var string 79 | */ 80 | private $newuser; 81 | 82 | /** 83 | * @var string 84 | */ 85 | private $owner; 86 | 87 | /** 88 | * @var string 89 | */ 90 | private $shell; 91 | 92 | /** 93 | * @var string 94 | */ 95 | private $user; 96 | 97 | /** 98 | * Recupera o valor de $CPTHEME 99 | * @return string 100 | */ 101 | public function getCPTHEME() { 102 | return $this->CPTHEME; 103 | } 104 | 105 | /** 106 | * Recupera o valor de $domain 107 | * @return string 108 | */ 109 | public function getDomain() { 110 | return $this->domain; 111 | } 112 | 113 | /** 114 | * Recupera o valor de $HASCGI 115 | * @return string 116 | */ 117 | public function getHASCGI() { 118 | return $this->HASCGI; 119 | } 120 | 121 | /** 122 | * Recupera o valor de $LANG 123 | * @return string 124 | */ 125 | public function getLANG() { 126 | return $this->LANG; 127 | } 128 | 129 | /** 130 | * Recupera o valor de $LOCALE 131 | * @return string 132 | */ 133 | public function getLOCALE() { 134 | return $this->LOCALE; 135 | } 136 | 137 | /** 138 | * Recupera o valor de $MAXADDON 139 | * @return string 140 | */ 141 | public function getMAXADDON() { 142 | return $this->MAXADDON; 143 | } 144 | 145 | /** 146 | * Recupera o valor de $MAXFTP 147 | * @return string 148 | */ 149 | public function getMAXFTP() { 150 | return $this->MAXFTP; 151 | } 152 | 153 | /** 154 | * Recupera o valor de $MAXLST 155 | * @return string 156 | */ 157 | public function getMAXLST() { 158 | return $this->MAXLST; 159 | } 160 | 161 | /** 162 | * Recupera o valor de $MAXPARK 163 | * @return string 164 | */ 165 | public function getMAXPARK() { 166 | return $this->MAXPARK; 167 | } 168 | 169 | /** 170 | * Recupera o valor de $MAXPOP 171 | * @return string 172 | */ 173 | public function getMAXPOP() { 174 | return $this->MAXPOP; 175 | } 176 | 177 | /** 178 | * Recupera o valor de $MAXSQL 179 | * @return string 180 | */ 181 | public function getMAXSQL() { 182 | return $this->MAXSQL; 183 | } 184 | 185 | /** 186 | * Recupera o valor de $MAXSUB 187 | * @return string 188 | */ 189 | public function getMAXSUB() { 190 | return $this->MAXSUB; 191 | } 192 | 193 | /** 194 | * Recupera o valor de $newuser 195 | * @return string 196 | */ 197 | public function getNewuser() { 198 | return $this->newuser; 199 | } 200 | 201 | /** 202 | * @see cPanelOperation::getOperationName() 203 | * @return string 204 | */ 205 | public function getOperationName() { 206 | return 'modifyacct'; 207 | } 208 | 209 | /** 210 | * Recupera o valor de $owner 211 | * @return string 212 | */ 213 | public function getOwner() { 214 | return $this->owner; 215 | } 216 | 217 | /** 218 | * Recupera o valor de $shell 219 | * @return string 220 | */ 221 | public function getShell() { 222 | return $this->shell; 223 | } 224 | 225 | /** 226 | * Recupera o valor de $user 227 | * @return string 228 | */ 229 | public function getUser() { 230 | return $this->user; 231 | } 232 | 233 | /** 234 | * @param string $CPTHEME 235 | */ 236 | public function setCPTHEME( $CPTHEME ) { 237 | $this->CPTHEME = $CPTHEME; 238 | $this->httpConnection->setParam( 'CPTHEME' , $CPTHEME ); 239 | } 240 | 241 | /** 242 | * @param string $domain 243 | */ 244 | public function setDomain( $domain ) { 245 | $this->domain = $domain; 246 | $this->httpConnection->setParam( 'domain' , $domain ); 247 | } 248 | 249 | /** 250 | * @param string $HASCGI 251 | */ 252 | public function setHASCGI( $HASCGI ) { 253 | $this->HASCGI = $HASCGI; 254 | $this->httpConnection->setParam( 'HASCGI' , $HASCGI ); 255 | } 256 | 257 | /** 258 | * @param string $LANG 259 | */ 260 | public function setLANG( $LANG ) { 261 | $this->LANG = $LANG; 262 | $this->httpConnection->setParam( 'LANG' , $LANG ); 263 | } 264 | 265 | /** 266 | * @param string $LOCALE 267 | */ 268 | public function setLOCALE( $LOCALE ) { 269 | $this->LOCALE = $LOCALE; 270 | $this->httpConnection->setParam( 'LOCALE' , $LOCALE ); 271 | } 272 | 273 | /** 274 | * @param string $MAXADDON 275 | */ 276 | public function setMAXADDON( $MAXADDON ) { 277 | $this->MAXADDON = $MAXADDON; 278 | $this->httpConnection->setParam( 'MAXADDON' , $MAXADDON ); 279 | } 280 | 281 | /** 282 | * @param string $MAXFTP 283 | */ 284 | public function setMAXFTP( $MAXFTP ) { 285 | $this->MAXFTP = $MAXFTP; 286 | $this->httpConnection->setParam( 'MAXFTP' , $MAXFTP ); 287 | } 288 | 289 | /** 290 | * @param string $MAXLST 291 | */ 292 | public function setMAXLST( $MAXLST ) { 293 | $this->MAXLST = $MAXLST; 294 | $this->httpConnection->setParam( 'MAXLST' , $MAXLST ); 295 | } 296 | 297 | /** 298 | * @param string $MAXPARK 299 | */ 300 | public function setMAXPARK( $MAXPARK ) { 301 | $this->MAXPARK = $MAXPARK; 302 | $this->httpConnection->setParam( 'MAXPARK' , $MAXPARK ); 303 | } 304 | 305 | /** 306 | * @param string $MAXPOP 307 | */ 308 | public function setMAXPOP( $MAXPOP ) { 309 | $this->MAXPOP = $MAXPOP; 310 | $this->httpConnection->setParam( 'MAXPOP' , $MAXPOP ); 311 | } 312 | 313 | /** 314 | * @param string $MAXSQL 315 | */ 316 | public function setMAXSQL( $MAXSQL ) { 317 | $this->MAXSQL = $MAXSQL; 318 | $this->httpConnection->setParam( 'MAXSQL' , $MAXSQL ); 319 | } 320 | 321 | /** 322 | * @param string $MAXSUB 323 | */ 324 | public function setMAXSUB( $MAXSUB ) { 325 | $this->MAXSUB = $MAXSUB; 326 | $this->httpConnection->setParam( 'MAXSUB' , $MAXSUB ); 327 | } 328 | 329 | /** 330 | * @param string $newuser 331 | */ 332 | public function setNewuser( $newuser ) { 333 | $this->newuser = $newuser; 334 | $this->httpConnection->setParam( 'newuser' , $newuser ); 335 | } 336 | 337 | /** 338 | * @param string $owner 339 | */ 340 | public function setOwner( $owner ) { 341 | $this->owner = $owner; 342 | $this->httpConnection->setParam( 'owner' , $owner ); 343 | } 344 | 345 | /** 346 | * @param string $shell 347 | */ 348 | public function setShell( $shell ) { 349 | $this->shell = $shell; 350 | $this->httpConnection->setParam( 'shell' , $shell ); 351 | } 352 | 353 | /** 354 | * @param string $user 355 | */ 356 | public function setUser( $user ) { 357 | $this->user = $user; 358 | $this->httpConnection->setParam( 'user' , $user ); 359 | } 360 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/dns/EditZoneRecordOperation.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | class EditZoneRecordOperation extends cPanelOperation { 15 | /** 16 | * @var string 17 | */ 18 | private $address; 19 | 20 | /** 21 | * @var string 22 | */ 23 | private $class; 24 | 25 | /** 26 | * @var string 27 | */ 28 | private $cname; 29 | 30 | /** 31 | * @var string 32 | */ 33 | private $domain; 34 | 35 | /** 36 | * @var string 37 | */ 38 | private $exchange; 39 | 40 | /** 41 | * @var string 42 | */ 43 | private $expire; 44 | 45 | /** 46 | * @var string 47 | */ 48 | private $Line; 49 | 50 | /** 51 | * @var integer 52 | */ 53 | private $minimum; 54 | 55 | /** 56 | * @var integer 57 | */ 58 | private $mname; 59 | 60 | /** 61 | * @var string 62 | */ 63 | private $name; 64 | 65 | /** 66 | * @var string 67 | */ 68 | private $nsdname; 69 | 70 | /** 71 | * @var integer 72 | */ 73 | private $preference; 74 | 75 | /** 76 | * @var string 77 | */ 78 | private $raw; 79 | 80 | /** 81 | * @var integer 82 | */ 83 | private $refresh; 84 | 85 | /** 86 | * @var integer 87 | */ 88 | private $retry; 89 | 90 | /** 91 | * @var string 92 | */ 93 | private $rname; 94 | 95 | /** 96 | * @var integer 97 | */ 98 | private $serial; 99 | 100 | /** 101 | * @var string 102 | */ 103 | private $ttl; 104 | 105 | /** 106 | * @var string 107 | */ 108 | private $txtdata; 109 | 110 | /** 111 | * @var string 112 | */ 113 | private $type; 114 | 115 | /** 116 | * Recupera o valor de $address 117 | * @return string 118 | */ 119 | public function getAddress() { 120 | return $this->address; 121 | } 122 | 123 | /** 124 | * Recupera o valor de $class 125 | * @return string 126 | */ 127 | public function getClass() { 128 | return $this->class; 129 | } 130 | 131 | /** 132 | * Recupera o valor de $cname 133 | * @return string 134 | */ 135 | public function getCname() { 136 | return $this->cname; 137 | } 138 | 139 | /** 140 | * Recupera o valor de $domain 141 | * @return string 142 | */ 143 | public function getDomain() { 144 | return $this->domain; 145 | } 146 | 147 | /** 148 | * Recupera o valor de $exchange 149 | * @return string 150 | */ 151 | public function getExchange() { 152 | return $this->exchange; 153 | } 154 | 155 | /** 156 | * Recupera o valor de $expire 157 | * @return string 158 | */ 159 | public function getExpire() { 160 | return $this->expire; 161 | } 162 | 163 | /** 164 | * Recupera o valor de $Line 165 | * @return string 166 | */ 167 | public function getLine() { 168 | return $this->Line; 169 | } 170 | 171 | /** 172 | * Recupera o valor de $minimum 173 | * @return integer 174 | */ 175 | public function getMinimum() { 176 | return $this->minimum; 177 | } 178 | 179 | /** 180 | * Recupera o valor de $mname 181 | * @return integer 182 | */ 183 | public function getMname() { 184 | return $this->mname; 185 | } 186 | 187 | /** 188 | * Recupera o valor de $name 189 | * @return string 190 | */ 191 | public function getName() { 192 | return $this->name; 193 | } 194 | 195 | /** 196 | * Recupera o valor de $nsdname 197 | * @return string 198 | */ 199 | public function getNsdname() { 200 | return $this->nsdname; 201 | } 202 | 203 | /** 204 | * @see cPanelOperation::getOperationName() 205 | * @return string 206 | */ 207 | public function getOperationName() { 208 | return 'editzonerecord'; 209 | } 210 | 211 | /** 212 | * Recupera o valor de $preference 213 | * @return integer 214 | */ 215 | public function getPreference() { 216 | return $this->preference; 217 | } 218 | 219 | /** 220 | * Recupera o valor de $raw 221 | * @return string 222 | */ 223 | public function getRaw() { 224 | return $this->raw; 225 | } 226 | 227 | /** 228 | * Recupera o valor de $refresh 229 | * @return integer 230 | */ 231 | public function getRefresh() { 232 | return $this->refresh; 233 | } 234 | 235 | /** 236 | * Recupera o valor de $retry 237 | * @return integer 238 | */ 239 | public function getRetry() { 240 | return $this->retry; 241 | } 242 | 243 | /** 244 | * Recupera o valor de $rname 245 | * @return string 246 | */ 247 | public function getRname() { 248 | return $this->rname; 249 | } 250 | 251 | /** 252 | * Recupera o valor de $serial 253 | * @return integer 254 | */ 255 | public function getSerial() { 256 | return $this->serial; 257 | } 258 | 259 | /** 260 | * Recupera o valor de $ttl 261 | * @return string 262 | */ 263 | public function getTtl() { 264 | return $this->ttl; 265 | } 266 | 267 | /** 268 | * Recupera o valor de $txtdata 269 | * @return string 270 | */ 271 | public function getTxtdata() { 272 | return $this->txtdata; 273 | } 274 | 275 | /** 276 | * Recupera o valor de $type 277 | * @return string 278 | */ 279 | public function getType() { 280 | return $this->type; 281 | } 282 | 283 | /** 284 | * @param string $address 285 | */ 286 | public function setAddress( $address ) { 287 | $this->address = $address; 288 | $this->httpConnection->setParam( 'address' , $address ); 289 | } 290 | 291 | /** 292 | * @param string $class 293 | */ 294 | public function setClass( $class ) { 295 | $this->class = $class; 296 | $this->httpConnection->setParam( 'class' , $class ); 297 | } 298 | 299 | /** 300 | * @param string $cname 301 | */ 302 | public function setCname( $cname ) { 303 | $this->cname = $cname; 304 | $this->httpConnection->setParam( 'cname' , $cname ); 305 | } 306 | 307 | /** 308 | * @param string $domain 309 | */ 310 | public function setDomain( $domain ) { 311 | $this->domain = $domain; 312 | $this->httpConnection->setParam( 'domain' , $domain ); 313 | } 314 | 315 | /** 316 | * @param string $exchange 317 | */ 318 | public function setExchange( $exchange ) { 319 | $this->exchange = $exchange; 320 | $this->httpConnection->setParam( 'exchange' , $exchange ); 321 | } 322 | 323 | /** 324 | * @param string $expire 325 | */ 326 | public function setExpire( $expire ) { 327 | $this->expire = $expire; 328 | $this->httpConnection->setParam( 'expire' , $expire ); 329 | } 330 | 331 | /** 332 | * @param string $Line 333 | */ 334 | public function setLine( $Line ) { 335 | $this->Line = $Line; 336 | $this->httpConnection->setParam( 'Line' , $Line ); 337 | } 338 | 339 | /** 340 | * @param integer $minimum 341 | */ 342 | public function setMinimum( $minimum ) { 343 | $this->minimum = $minimum; 344 | $this->httpConnection->setParam( 'minimum' , $minimum ); 345 | } 346 | 347 | /** 348 | * @param integer $mname 349 | */ 350 | public function setMname( $mname ) { 351 | $this->mname = $mname; 352 | $this->httpConnection->setParam( 'mname' , $mname ); 353 | } 354 | 355 | /** 356 | * @param string $name 357 | */ 358 | public function setName( $name ) { 359 | $this->name = $name; 360 | $this->httpConnection->setParam( 'name' , $name ); 361 | } 362 | 363 | /** 364 | * @param string $nsdname 365 | */ 366 | public function setNsdname( $nsdname ) { 367 | $this->nsdname = $nsdname; 368 | $this->httpConnection->setParam( 'nsdname' , $nsdname ); 369 | } 370 | 371 | /** 372 | * @param integer $preference 373 | */ 374 | public function setPreference( $preference ) { 375 | $this->preference = $preference; 376 | $this->httpConnection->setParam( 'preference' , $preference ); 377 | } 378 | 379 | /** 380 | * @param string $raw 381 | */ 382 | public function setRaw( $raw ) { 383 | $this->raw = $raw; 384 | $this->httpConnection->setParam( 'raw' , $raw ); 385 | } 386 | 387 | /** 388 | * @param integer $refresh 389 | */ 390 | public function setRefresh( $refresh ) { 391 | $this->refresh = $refresh; 392 | $this->httpConnection->setParam( 'refresh' , $refresh ); 393 | } 394 | 395 | /** 396 | * @param integer $retry 397 | */ 398 | public function setRetry( $retry ) { 399 | $this->retry = $retry; 400 | $this->httpConnection->setParam( 'retry' , $retry ); 401 | } 402 | 403 | /** 404 | * @param string $rname 405 | */ 406 | public function setRname( $rname ) { 407 | $this->rname = $rname; 408 | $this->httpConnection->setParam( 'rname' , $rname ); 409 | } 410 | 411 | /** 412 | * @param integer $serial 413 | */ 414 | public function setSerial( $serial ) { 415 | $this->serial = $serial; 416 | $this->httpConnection->setParam( 'serial' , $serial ); 417 | } 418 | 419 | /** 420 | * @param string $ttl 421 | */ 422 | public function setTtl( $ttl ) { 423 | $this->ttl = $ttl; 424 | $this->httpConnection->setParam( 'ttl' , $ttl ); 425 | } 426 | 427 | /** 428 | * @param string $txtdata 429 | */ 430 | public function setTxtdata( $txtdata ) { 431 | $this->txtdata = $txtdata; 432 | $this->httpConnection->setParam( 'txtdata' , $txtdata ); 433 | } 434 | 435 | /** 436 | * @param string $type 437 | */ 438 | public function setType( $type ) { 439 | $this->type = $type; 440 | $this->httpConnection->setParam( 'type' , $type ); 441 | } 442 | } -------------------------------------------------------------------------------- /com/imasters/php/http/HTTPConnection.php: -------------------------------------------------------------------------------- 1 | 14 | * @brief Implementação de um conector HTTP. 15 | */ 16 | class HTTPConnection { 17 | /** 18 | * @brief Porta padrão de uma conexão HTTP não segura. 19 | */ 20 | const HTTP_PORT = 80; 21 | 22 | /** 23 | * @brief Porta padrão de uma conexão HTTP segura. 24 | */ 25 | const HTTPS_PORT = 443; 26 | 27 | /** 28 | * @var HTTPAuthenticator 29 | */ 30 | protected $httpAuthenticator; 31 | 32 | /** 33 | * @var CookieManager 34 | */ 35 | protected $cookieManager; 36 | 37 | /** 38 | * @var integer 39 | */ 40 | protected $connectionTimeout; 41 | 42 | /** 43 | * @var string 44 | */ 45 | protected $hostname; 46 | 47 | /** 48 | * @var boolean 49 | */ 50 | protected $initialized = false; 51 | 52 | /** 53 | * @var integer 54 | */ 55 | protected $port; 56 | 57 | /** 58 | * @var string 59 | */ 60 | protected $requestBody; 61 | 62 | /** 63 | * @var array 64 | */ 65 | protected $requestHeader; 66 | 67 | /** 68 | * @var array 69 | */ 70 | protected $requestParameter; 71 | 72 | /** 73 | * @var boolean 74 | */ 75 | protected $secure; 76 | 77 | /** 78 | * @var integer 79 | */ 80 | protected $timeout; 81 | 82 | /** 83 | * @var string 84 | */ 85 | protected static $userAgent; 86 | 87 | /** 88 | * @brief Constroi o objeto de conexão HTTP. 89 | */ 90 | public function __construct() { 91 | if ( self::$userAgent == null ) { 92 | $locale = setlocale( LC_ALL , null ); 93 | 94 | if ( function_exists( 'posix_uname' ) ) { 95 | $uname = posix_uname(); 96 | 97 | self::$userAgent = sprintf( 'Mozilla/4.0 (compatible; %s; PHP/%s; %s %s; %s)' , PHP_SAPI , PHP_VERSION , $uname[ 'sysname' ] , $uname[ 'machine' ] , $locale ); 98 | } else { 99 | self::$userAgent = sprintf( 'Mozilla/4.0 (compatible; %s; PHP/%s; %s; %s)' , PHP_SAPI , PHP_VERSION , PHP_OS , $locale ); 100 | } 101 | } 102 | 103 | $this->requestHeader = array(); 104 | $this->requestParameter = array(); 105 | } 106 | 107 | /** 108 | * @brief Adiciona um campo de cabeçalho para ser enviado com a 109 | * requisição. 110 | * @param string $name Nome do campo de cabeçalho. 111 | * @param string $value Valor do campo de cabeçalho. 112 | * @param boolean $override Indica se o campo deverá 113 | * ser sobrescrito caso já tenha sido definido. 114 | * @throws InvalidArgumentException Se o nome ou o valor 115 | * do campo não forem valores scalar. 116 | */ 117 | public function addHeader( $name , $value , $override = true ) { 118 | if ( is_scalar( $name ) && is_scalar( $value ) ) { 119 | $key = strtolower( $name ); 120 | 121 | if ( $override === true || !isset( $this->requestHeader[ $key ] ) ) { 122 | $this->requestHeader[ $key ] = array( 'name' => $name , 'value' => $value ); 123 | 124 | return true; 125 | } 126 | 127 | return false; 128 | } else { 129 | throw new InvalidArgumentException( '$name e $value precisam ser strings.' ); 130 | } 131 | } 132 | 133 | /** 134 | * @brief Fecha a conexão. 135 | * @throws BadMethodCallException Se não houver uma conexão 136 | * inicializada. 137 | */ 138 | public function close() { 139 | $this->initialized = false; 140 | } 141 | 142 | /** 143 | * @brief Executa a requisição 144 | * @details Executa a requisição HTTP em um caminho utilizando um 145 | * método específico. 146 | * @param string $path Caminho da requisição. 147 | * @param string $method Método da requisição. 148 | * @return HTTPResponse Resposta HTTP. 149 | * @throws BadMethodCallException Se não houver uma conexão 150 | * inicializada ou se o objeto de requisição não for válido. 151 | */ 152 | public function execute( $path = '/' , $method = HTTPRequestMethod::GET ) { 153 | $request = $this->newRequest(); 154 | 155 | if ( $request instanceof HTTPRequest ) { 156 | $host = $this->getHost(); 157 | $accept = '*/*'; 158 | $userAgent = self::$userAgent; 159 | 160 | if ( isset( $this->requestHeader[ 'Host' ] ) ) { 161 | $host = $this->requestHeader[ 'host' ][ 'value' ]; 162 | 163 | unset( $this->requestHeader[ 'host' ] ); 164 | } 165 | 166 | if ( isset( $this->requestHeader[ 'accept' ] ) ) { 167 | $accept = $this->requestHeader[ 'accept' ][ 'value' ]; 168 | 169 | unset( $this->requestHeader[ 'accept' ] ); 170 | } 171 | 172 | if ( isset( $this->requestHeader[ 'user-agent' ] ) ) { 173 | $userAgent = $this->requestHeader[ 'user-agent' ][ 'value' ]; 174 | 175 | unset( $this->requestHeader[ 'user-agent' ] ); 176 | } 177 | 178 | $request->addRequestHeader( 'Host' , $host ); 179 | $request->addRequestHeader( 'Accept' , $accept ); 180 | $request->addRequestHeader( 'User-Agent' , $userAgent ); 181 | 182 | if ( $this->httpAuthenticator != null ) { 183 | $request->authenticate( $this->httpAuthenticator ); 184 | } 185 | 186 | foreach ( $this->requestHeader as $header ) { 187 | $request->addRequestHeader( $header[ 'name' ] , $header[ 'value' ] ); 188 | } 189 | 190 | $cookieManager = $this->getCookieManager(); 191 | 192 | if ( $cookieManager != null ) { 193 | $cookies = $cookieManager->getCookie( $this->getHostName() , $this->isSecure() , $path ); 194 | 195 | if ( isset( $this->requestHeader[ 'cookie' ] ) ) { 196 | $buffer = $this->requestHeader[ 'cookie' ][ 'value' ] . '; ' . $cookies; 197 | } else { 198 | $buffer = $cookies; 199 | } 200 | 201 | $request->addRequestHeader( 'Cookie' , $buffer ); 202 | } 203 | 204 | foreach ( $this->requestParameter as $name => $value ) { 205 | $request->setParameter( $name , $value ); 206 | } 207 | 208 | $request->setRequestBody( $this->requestBody ); 209 | 210 | if ( $path == null || !is_string( $path ) || empty( $path ) ) { 211 | $path = '/'; 212 | } else if ( substr( $path , 0 , 1 ) != '/' ) { 213 | $path = '/' . $path; 214 | } 215 | 216 | if ( $this->timeout != null ) { 217 | $request->setTimeout( $this->timeout ); 218 | } 219 | 220 | if ( $this->connectionTimeout != null ) { 221 | $request->setConnectionTimeout( $this->connectionTimeout ); 222 | } 223 | 224 | $request->open( $this ); 225 | $request->execute( $path , $method ); 226 | 227 | return $request->getResponse(); 228 | } else { 229 | throw new BadMethodCallException( 'Objeto de requisição inválido.' ); 230 | } 231 | } 232 | 233 | /** 234 | * @brief Recupera o timeout de conexão. 235 | * @return integer 236 | */ 237 | public function getConnectionTimeout() { 238 | return $this->connectionTimeout; 239 | } 240 | 241 | /** 242 | * @brief Recupera o gerenciador de Cookies. 243 | * @return CookieManager 244 | */ 245 | public function getCookieManager() { 246 | return $this->cookieManager; 247 | } 248 | 249 | /** 250 | * @brief Recupera o host da conexão. 251 | * @return string 252 | * @throws BadMethodCallException Se a conexão não tiver 253 | * sido inicializada. 254 | */ 255 | public function getHost() { 256 | if ( $this->initialized ) { 257 | $hostname = $this->getHostName(); 258 | 259 | if ( ( $this->secure && $this->port != HTTPConnection::HTTPS_PORT ) || ( !$this->secure && $this->port != HTTPConnection::HTTP_PORT ) ) { 260 | return $hostname . ':' . $this->port; 261 | } else { 262 | return $hostname; 263 | } 264 | } else { 265 | throw new BadMethodCallException( 'Conexão não inicializada' ); 266 | } 267 | } 268 | 269 | /** 270 | * @brief Recupera o nome do host. 271 | * @return string 272 | * @throws BadMethodCallException Se não houver uma conexão 273 | * inicializada. 274 | */ 275 | public function getHostName() { 276 | if ( $this->initialized ) { 277 | return $this->hostname; 278 | } else { 279 | throw new BadMethodCallException( 'Conexão não inicializada' ); 280 | } 281 | } 282 | 283 | /** 284 | * @brief Recupera a porta que será utilizada na conexão. 285 | * @return integer 286 | * @throws BadMethodCallException Se não houver uma conexão 287 | * inicializada. 288 | */ 289 | public function getPort() { 290 | if ( $this->initialized ) { 291 | return $this->port; 292 | } else { 293 | throw new BadMethodCallException( 'Conexão não inicializada' ); 294 | } 295 | } 296 | 297 | /** 298 | * @brief Recupera o timeout. 299 | * @return integer 300 | */ 301 | public function getTimeout() { 302 | return $this->timeout; 303 | } 304 | 305 | /** 306 | * @brief Recupera a URI que será utilizada na conexão. 307 | * @return string 308 | * @throws BadMethodCallException Se não houver uma conexão 309 | * inicializada. 310 | */ 311 | public function getURI() { 312 | if ( $this->initialized ) { 313 | return sprintf( '%s://%s' , $this->isSecure() ? 'https' : 'http' , $this->getHost() ); 314 | } else { 315 | throw new BadMethodCallException( 'Conexão não inicializada' ); 316 | } 317 | } 318 | 319 | /** 320 | * @brief Inicializa a conexão HTTP. 321 | * @param string $hostname Servidor que receberá a requisição. 322 | * @param boolean $secure Indica se a conexão será segura (https). 323 | * @param integer $port Porta da requisição. 324 | * @param integer $connectionTimeout Timeout de conexão em segundos. 325 | * @param integer $timeout Timeout de espera em segundos. 326 | */ 327 | public function initialize( $hostname , $secure = false , $port = HTTPConnection::HTTP_PORT , $connectionTimeout = 0 , $timeout = 0 ) { 328 | if ( $this->initialized ) { 329 | $this->close(); 330 | } 331 | 332 | $this->initialized = true; 333 | $this->hostname = $hostname; 334 | $this->secure = $secure === true; 335 | 336 | if ( func_num_args() == 2 ) { 337 | $this->port = $this->secure ? HTTPConnection::HTTPS_PORT : HTTPConnection::HTTP_PORT; 338 | } else { 339 | $this->port = (int) $port; 340 | } 341 | 342 | $this->connectionTimeout = (int) $connectionTimeout; 343 | $this->timeout = (int) $timeout; 344 | } 345 | 346 | /** 347 | * @brief Verifica se é uma conexão segura. 348 | * @return boolean 349 | */ 350 | public function isSecure() { 351 | return $this->secure === true; 352 | } 353 | 354 | /** 355 | * @brief Cria uma instância de um objeto de requisição HTTP. 356 | * @return HTTPRequest 357 | */ 358 | public function newRequest() { 359 | return new CURL(); 360 | } 361 | 362 | /** 363 | * @brief Define um autenticador HTTP. 364 | * @param HTTPAuthenticator $httpAuthenticator 365 | */ 366 | public function setAuthenticator( HTTPAuthenticator $httpAuthenticator ) { 367 | $this->httpAuthenticator = $httpAuthenticator; 368 | } 369 | 370 | /** 371 | * @brief Define o timeout de conexão. 372 | * @param integer $connectionTimeout 373 | * @throws InvalidArgumentException Se $connectionTimeout não for um inteiro. 374 | */ 375 | public function setConnectionTimeout( $connectionTimeout ) { 376 | if ( is_integer( $connectionTimeout ) ) { 377 | $this->connectionTimeout = $connectionTimeout; 378 | } else { 379 | throw new InvalidArgumentException( '$connectionTimeout precisa ser o tempo em segundos.' ); 380 | } 381 | } 382 | 383 | /** 384 | * @brief Define um gerenciador de cookies para essa conexão. 385 | * @param CookieManager $cookieManager 386 | */ 387 | public function setCookieManager( CookieManager $cookieManager ) { 388 | $this->cookieManager = $cookieManager; 389 | } 390 | 391 | /** 392 | * @brief Define um parâmetro 393 | * @details Define um parâmetro que será enviado com a requisição, 394 | * um parâmetro é um par nome-valor que será enviado como uma 395 | * query string (ex: ?name=value). 396 | * @param string $name Nome do parâmetro. 397 | * @param string $value Valor do parâmetro. 398 | * @throws InvalidArgumentException Se o nome ou o valor 399 | * do campo não forem valores scalar. 400 | */ 401 | public function setParam( $name , $value = null ) { 402 | if ( is_scalar( $name ) && ( is_scalar( $value ) || is_null( $value ) ) ) { 403 | $this->requestParameter[ $name ] = $value; 404 | } else { 405 | throw new InvalidArgumentException( '$name e $value precisam ser strings.' ); 406 | } 407 | } 408 | 409 | /** 410 | * @brief Define o corpo da requisição. 411 | * @param string $requestBody 412 | */ 413 | public function setRequestBody( $requestBody ) { 414 | $this->requestBody = $requestBody; 415 | } 416 | 417 | /** 418 | * @brief Define o timeout. 419 | * @param integer $timeout 420 | * @throws InvalidArgumentException Se $timeout não for um inteiro. 421 | */ 422 | public function setTimeout( $timeout ) { 423 | if ( is_integer( $timeout ) ) { 424 | $this->timeout = $timeout; 425 | } else { 426 | throw new InvalidArgumentException( '$timeout precisa ser o tempo em segundos.' ); 427 | } 428 | } 429 | } -------------------------------------------------------------------------------- /com/imasters/php/cpanel/operation/account/CreateAccountOperation.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | class CreateAccountOperation extends cPanelOperation { 17 | /** 18 | * @var integer 19 | */ 20 | private $bwlimit; 21 | 22 | /** 23 | * @var boolean 24 | */ 25 | private $cgi; 26 | 27 | /** 28 | * @var string 29 | */ 30 | private $contactemail; 31 | 32 | /** 33 | * @var string 34 | */ 35 | private $cpmod; 36 | 37 | /** 38 | * @var string 39 | */ 40 | private $customip; 41 | 42 | /** 43 | * @var string 44 | */ 45 | private $domain; 46 | 47 | /** 48 | * @var string 49 | */ 50 | private $featurelist; 51 | 52 | /** 53 | * @var boolean 54 | */ 55 | private $forcedns; 56 | 57 | /** 58 | * @var boolean 59 | */ 60 | private $frontpage; 61 | 62 | /** 63 | * @var boolean 64 | */ 65 | private $hasshell; 66 | 67 | /** 68 | * @var boolean 69 | */ 70 | private $hasuseregns; 71 | 72 | /** 73 | * @var string 74 | */ 75 | private $ip; 76 | 77 | /** 78 | * @var string 79 | */ 80 | private $language; 81 | 82 | /** 83 | * @var integer 84 | */ 85 | private $maxaddon; 86 | 87 | /** 88 | * @var integer 89 | */ 90 | private $maxftp; 91 | 92 | /** 93 | * @var integer 94 | */ 95 | private $maxlst; 96 | 97 | /** 98 | * @var integer 99 | */ 100 | private $maxpark; 101 | 102 | /** 103 | * @var integer 104 | */ 105 | private $maxpop; 106 | 107 | /** 108 | * @var integer 109 | */ 110 | private $maxsql; 111 | 112 | /** 113 | * @var integer 114 | */ 115 | private $maxsub; 116 | 117 | /** 118 | * @var string 119 | */ 120 | private $mxcheck; 121 | 122 | /** 123 | * @var string 124 | */ 125 | private $password; 126 | 127 | /** 128 | * @var string 129 | */ 130 | private $pkgname; 131 | 132 | /** 133 | * @var string 134 | */ 135 | private $plan; 136 | 137 | /** 138 | * @var integer 139 | */ 140 | private $quota; 141 | 142 | /** 143 | * @var boolean 144 | */ 145 | private $reseller; 146 | 147 | /** 148 | * @var boolean 149 | */ 150 | private $savepkg; 151 | 152 | /** 153 | * @var boolean 154 | */ 155 | private $useregns; 156 | 157 | /** 158 | * @var string 159 | */ 160 | private $username; 161 | 162 | /** 163 | * Recupera o valor de $bwlimit 164 | * @return integer 165 | */ 166 | public function getBwlimit() { 167 | return $this->bwlimit; 168 | } 169 | 170 | /** 171 | * Recupera o valor de $cgi 172 | * @return boolean 173 | */ 174 | public function getCgi() { 175 | return $this->cgi; 176 | } 177 | 178 | /** 179 | * Recupera o valor de $contactemail 180 | * @return string 181 | */ 182 | public function getContactemail() { 183 | return $this->contactemail; 184 | } 185 | 186 | /** 187 | * Recupera o valor de $cpmod 188 | * @return string 189 | */ 190 | public function getCpmod() { 191 | return $this->cpmod; 192 | } 193 | 194 | /** 195 | * Recupera o valor de $customip 196 | * @return string 197 | */ 198 | public function getCustomip() { 199 | return $this->customip; 200 | } 201 | 202 | /** 203 | * Recupera o valor de $domain 204 | * @return string 205 | */ 206 | public function getDomain() { 207 | return $this->domain; 208 | } 209 | 210 | /** 211 | * Recupera o valor de $featurelist 212 | * @return string 213 | */ 214 | public function getFeaturelist() { 215 | return $this->featurelist; 216 | } 217 | 218 | /** 219 | * Recupera o valor de $forcedns 220 | * @return boolean 221 | */ 222 | public function getForcedns() { 223 | return $this->forcedns; 224 | } 225 | 226 | /** 227 | * Recupera o valor de $frontpage 228 | * @return boolean 229 | */ 230 | public function getFrontpage() { 231 | return $this->frontpage; 232 | } 233 | 234 | /** 235 | * Recupera o valor de $hasshell 236 | * @return boolean 237 | */ 238 | public function getHasshell() { 239 | return $this->hasshell; 240 | } 241 | 242 | /** 243 | * Recupera o valor de $hasuseregns 244 | * @return boolean 245 | */ 246 | public function getHasuseregns() { 247 | return $this->hasuseregns; 248 | } 249 | 250 | /** 251 | * Recupera o valor de $ip 252 | * @return string 253 | */ 254 | public function getIp() { 255 | return $this->ip; 256 | } 257 | 258 | /** 259 | * Recupera o valor de $language 260 | * @return string 261 | */ 262 | public function getLanguage() { 263 | return $this->language; 264 | } 265 | 266 | /** 267 | * Recupera o valor de $maxaddon 268 | * @return integer 269 | */ 270 | public function getMaxaddon() { 271 | return $this->maxaddon; 272 | } 273 | 274 | /** 275 | * Recupera o valor de $maxftp 276 | * @return integer 277 | */ 278 | public function getMaxftp() { 279 | return $this->maxftp; 280 | } 281 | 282 | /** 283 | * Recupera o valor de $maxlst 284 | * @return integer 285 | */ 286 | public function getMaxlst() { 287 | return $this->maxlst; 288 | } 289 | 290 | /** 291 | * Recupera o valor de $maxpark 292 | * @return integer 293 | */ 294 | public function getMaxpark() { 295 | return $this->maxpark; 296 | } 297 | 298 | /** 299 | * Recupera o valor de $maxpop 300 | * @return integer 301 | */ 302 | public function getMaxpop() { 303 | return $this->maxpop; 304 | } 305 | 306 | /** 307 | * Recupera o valor de $maxsql 308 | * @return integer 309 | */ 310 | public function getMaxsql() { 311 | return $this->maxsql; 312 | } 313 | 314 | /** 315 | * Recupera o valor de $maxsub 316 | * @return integer 317 | */ 318 | public function getMaxsub() { 319 | return $this->maxsub; 320 | } 321 | 322 | /** 323 | * Recupera o valor de $mxcheck 324 | * @return string 325 | */ 326 | public function getMxcheck() { 327 | return $this->mxcheck; 328 | } 329 | 330 | /** 331 | * @see cPanelOperation::getOperationPath() 332 | * @return string 333 | */ 334 | public function getOperationName() { 335 | return 'createacct'; 336 | } 337 | 338 | /** 339 | * Recupera o valor de $password 340 | * @return string 341 | */ 342 | public function getPassword() { 343 | return $this->password; 344 | } 345 | 346 | /** 347 | * Recupera o valor de $pkgname 348 | * @return string 349 | */ 350 | public function getPkgname() { 351 | return $this->pkgname; 352 | } 353 | 354 | /** 355 | * Recupera o valor de $plan 356 | * @return string 357 | */ 358 | public function getPlan() { 359 | return $this->plan; 360 | } 361 | 362 | /** 363 | * Recupera o valor de $quota 364 | * @return integer 365 | */ 366 | public function getQuota() { 367 | return $this->quota; 368 | } 369 | 370 | /** 371 | * Recupera o valor de $reseller 372 | * @return boolean 373 | */ 374 | public function getReseller() { 375 | return $this->reseller; 376 | } 377 | 378 | /** 379 | * Recupera o valor de $savepkg 380 | * @return boolean 381 | */ 382 | public function getSavepkg() { 383 | return $this->savepkg; 384 | } 385 | 386 | /** 387 | * Recupera o valor de $useregns 388 | * @return boolean 389 | */ 390 | public function getUseregns() { 391 | return $this->useregns; 392 | } 393 | 394 | /** 395 | * Recupera o valor de $username 396 | * @return string 397 | */ 398 | public function getUsername() { 399 | return $this->username; 400 | } 401 | 402 | /** 403 | * @param integer $bwlimit 404 | */ 405 | public function setBwlimit( $bwlimit ) { 406 | $this->bwlimit = $bwlimit; 407 | $this->httpConnection->setParam( 'bwlimit' , $bwlimit ); 408 | } 409 | 410 | /** 411 | * @param boolean $cgi 412 | */ 413 | public function setCgi( $cgi ) { 414 | $this->cgi = $cgi; 415 | $this->httpConnection->setParam( 'cgi' , $cgi ); 416 | } 417 | 418 | /** 419 | * @param string $contactemail 420 | */ 421 | public function setContactemail( $contactemail ) { 422 | $this->contactemail = $contactemail; 423 | $this->httpConnection->setParam( 'contactemail' , $contactemail ); 424 | } 425 | 426 | /** 427 | * @param string $cpmod 428 | */ 429 | public function setCpmod( $cpmod ) { 430 | $this->cpmod = $cpmod; 431 | $this->httpConnection->setParam( 'cpmod' , $cpmod ); 432 | } 433 | 434 | /** 435 | * @param string $customip 436 | */ 437 | public function setCustomip( $customip ) { 438 | $this->customip = $customip; 439 | $this->httpConnection->setParam( 'customip' , $customip ); 440 | } 441 | 442 | /** 443 | * @param string $domain 444 | */ 445 | public function setDomain( $domain ) { 446 | $this->domain = $domain; 447 | $this->httpConnection->setParam( 'domain' , $domain ); 448 | } 449 | 450 | /** 451 | * @param string $featurelist 452 | */ 453 | public function setFeaturelist( $featurelist ) { 454 | $this->featurelist = $featurelist; 455 | $this->httpConnection->setParam( 'featurelist' , $featurelist ); 456 | } 457 | 458 | /** 459 | * @param boolean $forcedns 460 | */ 461 | public function setForcedns( $forcedns ) { 462 | $this->forcedns = $forcedns; 463 | $this->httpConnection->setParam( 'forcedns' , $forcedns ); 464 | } 465 | 466 | /** 467 | * @param boolean $frontpage 468 | */ 469 | public function setFrontpage( $frontpage ) { 470 | $this->frontpage = $frontpage; 471 | $this->httpConnection->setParam( 'frontpage' , $frontpage ); 472 | } 473 | 474 | /** 475 | * @param boolean $hasshell 476 | */ 477 | public function setHasshell( $hasshell ) { 478 | $this->hasshell = $hasshell; 479 | $this->httpConnection->setParam( 'hasshell' , $hasshell ); 480 | } 481 | 482 | /** 483 | * @param boolean $hasuseregns 484 | */ 485 | public function setHasuseregns( $hasuseregns ) { 486 | $this->hasuseregns = $hasuseregns; 487 | $this->httpConnection->setParam( 'hasuseregns' , $hasuseregns ); 488 | } 489 | 490 | /** 491 | * @param string $ip 492 | */ 493 | public function setIp( $ip ) { 494 | $this->ip = $ip; 495 | $this->httpConnection->setParam( 'ip' , $ip ); 496 | } 497 | 498 | /** 499 | * @param string $language 500 | */ 501 | public function setLanguage( $language ) { 502 | $this->language = $language; 503 | $this->httpConnection->setParam( 'language' , $language ); 504 | } 505 | 506 | /** 507 | * @param integer $maxaddon 508 | */ 509 | public function setMaxaddon( $maxaddon ) { 510 | $this->maxaddon = $maxaddon; 511 | $this->httpConnection->setParam( 'maxaddon' , $maxaddon ); 512 | } 513 | 514 | /** 515 | * @param integer $maxftp 516 | */ 517 | public function setMaxftp( $maxftp ) { 518 | $this->maxftp = $maxftp; 519 | $this->httpConnection->setParam( 'maxftp' , $maxftp ); 520 | } 521 | 522 | /** 523 | * @param integer $maxlst 524 | */ 525 | public function setMaxlst( $maxlst ) { 526 | $this->maxlst = $maxlst; 527 | $this->httpConnection->setParam( 'maxlst' , $maxlst ); 528 | } 529 | 530 | /** 531 | * @param integer $maxpark 532 | */ 533 | public function setMaxpark( $maxpark ) { 534 | $this->maxpark = $maxpark; 535 | $this->httpConnection->setParam( 'maxpark' , $maxpark ); 536 | } 537 | 538 | /** 539 | * @param integer $maxpop 540 | */ 541 | public function setMaxpop( $maxpop ) { 542 | $this->maxpop = $maxpop; 543 | $this->httpConnection->setParam( 'maxpop' , $maxpop ); 544 | } 545 | 546 | /** 547 | * @param integer $maxsql 548 | */ 549 | public function setMaxsql( $maxsql ) { 550 | $this->maxsql = $maxsql; 551 | $this->httpConnection->setParam( 'maxsql' , $maxsql ); 552 | } 553 | 554 | /** 555 | * @param integer $maxsub 556 | */ 557 | public function setMaxsub( $maxsub ) { 558 | $this->maxsub = $maxsub; 559 | $this->httpConnection->setParam( 'maxsub' , $maxsub ); 560 | } 561 | 562 | /** 563 | * @param string $mxcheck 564 | */ 565 | public function setMxcheck( $mxcheck ) { 566 | $this->mxcheck = $mxcheck; 567 | $this->httpConnection->setParam( 'mxcheck' , $mxcheck ); 568 | } 569 | 570 | /** 571 | * @param string $password 572 | */ 573 | public function setPassword( $password ) { 574 | $this->password = $password; 575 | $this->httpConnection->setParam( 'password' , $password ); 576 | } 577 | 578 | /** 579 | * @param string $pkgname 580 | */ 581 | public function setPkgname( $pkgname ) { 582 | $this->pkgname = $pkgname; 583 | $this->httpConnection->setParam( 'pkgname' , $pkgname ); 584 | } 585 | 586 | /** 587 | * @param string $plan 588 | */ 589 | public function setPlan( $plan ) { 590 | $this->plan = $plan; 591 | $this->httpConnection->setParam( 'plan' , $plan ); 592 | } 593 | 594 | /** 595 | * @param integer $quota 596 | */ 597 | public function setQuota( $quota ) { 598 | $this->quota = $quota; 599 | $this->httpConnection->setParam( 'quota' , $quota ); 600 | } 601 | 602 | /** 603 | * @param boolean $reseller 604 | */ 605 | public function setReseller( $reseller ) { 606 | $this->reseller = $reseller; 607 | $this->httpConnection->setParam( 'reseller' , $reseller ); 608 | } 609 | 610 | /** 611 | * @param boolean $savepkg 612 | */ 613 | public function setSavepkg( $savepkg ) { 614 | $this->savepkg = $savepkg; 615 | $this->httpConnection->setParam( 'savepkg' , $savepkg ); 616 | } 617 | 618 | /** 619 | * @param boolean $useregns 620 | */ 621 | public function setUseregns( $useregns ) { 622 | $this->useregns = $useregns; 623 | $this->httpConnection->setParam( 'useregns' , $useregns ); 624 | } 625 | 626 | /** 627 | * @param string $username 628 | */ 629 | public function setUsername( $username ) { 630 | $this->username = $username; 631 | $this->httpConnection->setParam( 'username' , $username ); 632 | } 633 | 634 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU Lesser General Public License 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 5 | 6 | [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] 7 | 8 | Preamble 9 | The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. 10 | 11 | This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. 12 | 13 | When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. 14 | 15 | To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. 16 | 17 | For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. 18 | 19 | We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. 20 | 21 | To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. 22 | 23 | Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. 24 | 25 | Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. 26 | 27 | When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. 28 | 29 | We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. 30 | 31 | For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. 32 | 33 | In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. 34 | 35 | Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. 36 | 37 | The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. 38 | 39 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 40 | 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". 41 | 42 | A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. 43 | 44 | The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) 45 | 46 | "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. 47 | 48 | Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 49 | 50 | 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. 51 | 52 | You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 53 | 54 | 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: 55 | 56 | a) The modified work must itself be a software library. 57 | 58 | b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. 59 | 60 | c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. 61 | 62 | d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. 63 | 64 | (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) 65 | 66 | These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. 67 | 68 | Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. 69 | 70 | In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 71 | 72 | 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. 73 | 74 | Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. 75 | 76 | This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 77 | 78 | 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. 79 | 80 | If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 81 | 82 | 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. 83 | 84 | However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. 85 | 86 | When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. 87 | 88 | If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) 89 | 90 | Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 91 | 92 | 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. 93 | 94 | You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: 95 | 96 | a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) 97 | 98 | b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. 99 | 100 | c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. 101 | 102 | d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. 103 | 104 | e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. 105 | 106 | For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. 107 | 108 | It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 109 | 110 | 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: 111 | 112 | a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. 113 | 114 | b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 115 | 116 | 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 117 | 118 | 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 119 | 120 | 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 121 | 122 | 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. 123 | 124 | If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. 125 | 126 | It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. 127 | 128 | This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 129 | 130 | 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 131 | 132 | 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. 133 | 134 | Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 135 | 136 | 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. 137 | 138 | NO WARRANTY 139 | 140 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 141 | 142 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. --------------------------------------------------------------------------------