| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace MGModule\DNSManager2\mgLibs\custom\dns;
- use MGModule\DNSManager2 as main;
- class Core
- {
- /**
- *
- * @return Strategy
- * @throws exceptions\DNSException
- */
- public static function getModule($module) {
- if(!class_exists($module)) {
- $path = __DIR__ . DIRECTORY_SEPARATOR . 'submodules' . DIRECTORY_SEPARATOR . $module . '.php';
- if(file_exists($path) )
- require_once $path;
- else
- throw new exceptions\DNSException("Module file ($path) not found");
- }
- $module = __NAMESPACE__ . '\\submodules\\' . $module;
- return new Strategy(new $module());
- }
- public static function getAvailableSubmodules() {
- if(!file_exists(__DIR__ . DS . 'submodules')) return array();
- $di = new \DirectoryIterator(__DIR__ . DS . 'submodules');
- $out = array();
- foreach (new \IteratorIterator($di) as $file) {
- if($file->isFile() && $file->getExtension() == 'php')
- $out[] = $file->getBasename('.php');
- }
- sort($out);
- return $out;
- }
- public static function getAvailableRecordTypes()
- {
- if(!file_exists(__DIR__.DS.'record'.DS.'type'))
- {
- return array();
- }
- $dir = new \DirectoryIterator(__DIR__.DS.'record'.DS.'type');
- $out = array();
- foreach(new \IteratorIterator($dir) as $file)
- {
- if($file->isFile() && $file->getExtension() == 'php')
- {
- $out[] = $file->getBasename('.php');
- }
- }
- $out = array_diff($out, array('OldDNS', 'RecordTypeAbstract', 'Def'));
- sort($out);
- return $out;
- }
- /*
- * return record types list only for active servers
- * @return array
- */
- public static function getAvailableRecordTypesByActiveServers()
- {
- $avalibleRecordTypes = array();
- $rep = main\models\custom\server\Repository::factory()->onlyActive();
- $activeServers = $rep->get();
- foreach($activeServers as $server)
- {
- $submodule = $server->getModule();
- $tmpTypes = $submodule->availableTypes;
- $avalibleRecordTypes = array_unique(array_merge($avalibleRecordTypes, $tmpTypes));
- }
- return $avalibleRecordTypes;
- }
- }
|