array ( 'friendlyName' => 'Validator Test', 'validators' => array( 'required' => 'required', ) ), 'testConnection' =>array ( 'friendlyName' => 'Test Connection', 'type' => 'select', 'options' => array( '0' => 'Error', '1' => 'Random', '2' => 'Success' ) ), 'zoneExist' =>array ( 'friendlyName' => 'Zone Exist', 'type' => 'select', 'options' => array( '0' => 'Error', '1' => 'Random', '2' => 'Success' ) ), 'activateZone' =>array ( 'friendlyName' => 'Create Zone', 'type' => 'select', 'options' => array( '0' => 'Error', '1' => 'Random', '2' => 'Success' ) ), 'terminateZone' =>array ( 'friendlyName' => 'Remove Zone', 'type' => 'select', 'options' => array( '0' => 'Error', '1' => 'Random', '2' => 'Success' ) ), 'addRecord' =>array ( 'friendlyName' => 'Add Record', 'type' => 'select', 'options' => array( '0' => 'Error', '1' => 'Random', '2' => 'Success' ) ), 'editRecord' =>array ( 'friendlyName' => 'Edit Record', 'type' => 'select', 'options' => array( '0' => 'Error', '1' => 'Random', '2' => 'Success' ) ), 'deleteRecord' =>array ( 'friendlyName' => 'Remove Record', 'type' => 'select', 'options' => array( '0' => 'Error', '1' => 'Random', '2' => 'Success' ) ), 'updateRDNS' =>array ( 'friendlyName' => 'Update rDNS Record', 'type' => 'select', 'options' => array( '0' => 'Error', '1' => 'Random', '2' => 'Success' ) ), 'removeRDNS' =>array ( 'friendlyName' => 'Remove rDNS Record', 'type' => 'select', 'options' => array( '0' => 'Error', '1' => 'Random', '2' => 'Success' ) ), 'getZones' =>array ( 'friendlyName' => 'Import/Migrate Zones', 'type' => 'select', 'options' => array( '0' => 'Error', '1' => 'Random', '2' => 'Success' ) ), 'default_ip' =>array ( 'friendlyName' => 'Default IP', ), ); public $availableTypes = array('A', 'AAAA', 'ASFDB', 'CNAME', 'DNAME', 'DS', 'Def', 'HINFO', 'ISDN', 'LOC', 'MB', 'MD', 'MF', 'MG', 'MINFO', 'MR', 'MX', 'NAPTR', 'NS', 'PTR', 'RP', 'SOA', 'SRV', 'TXT', 'WKS', 'X25'); private function ret($function) { if(!isset($this->config[$function]) || $this->config[$function] == '2') { return true; } if($this->config[$function] == '1' && (rand() % 2) == 0) { return true; } $code = $this->configFields['exception']?:dns\SubmoduleExceptionCodes::COMMAND_ERROR; throw new exceptions\DNSSubmoduleException('ERROR', $code); } public function testConnection() { $this->ret(__FUNCTION__); } public function getRecords($recordType = false) { //TODO: moznaby zapisac do sesji $this->ret(__FUNCTION__); $out = array(); if(count($_SESSION['DNS_TestModuleRecords']) > 30) { unset($_SESSION['DNS_TestModuleRecords']); } if(!isset($_SESSION['DNS_TestModuleRecords'])) { $record = new dns\record\Record(); $record->line = 1; $record->name = 'test'; $record->ttl = '14400'; $record->type = 'TXT'; $record->createRDATAObject('TXT'); $record->rdata->setFirstProperty('test'); $out[1] = $record->toArray(FALSE); $_SESSION['DNS_TestModuleRecords'] = $out; } else { $out = $_SESSION['DNS_TestModuleRecords']; } foreach($out as &$record) { $record = dns\record\Record::tryToCreateFromArray($record); } return $out; } public function addRecord(dns\record\Record $record) { $this->ret(__FUNCTION__); $record->line = uniqid(); $_SESSION['DNS_TestModuleRecords'][$record->line] = $record->toArray(FALSE); } public function editRecord(dns\record\Record $record) { $this->ret(__FUNCTION__); $_SESSION['DNS_TestModuleRecords'][$record->line] = $record->toArray(FALSE); } public function deleteRecord(dns\record\Record $record) { $this->ret(__FUNCTION__); unset($_SESSION['DNS_TestModuleRecords'][$record->line]); } public function zoneExists() { try { $this->ret(__FUNCTION__); } catch (Exception $e) { return false; } return true; } public function activateZone() { $this->ret(__FUNCTION__); } public function terminateZone() { $this->ret(__FUNCTION__); } public function getZones() { $this->ret(__FUNCTION__); return array( 'example.com' => '123.123.123.123', 'test.eu' => '', ); } public function updateRDNS($ip, $ttl = false, $value = false) { $this->ret(__FUNCTION__); } public function removeRDNS($ip) { $this->ret(__FUNCTION__); } }