/** * Building a list of all domains, matching set filter * * - OrderNr * - (Sub-)Domain * - PHP-Version * - Target */ public function buildList() { $orders = $this->getApi()->getOrderReadEntry()->get(true, 'ordnr'); $result = $this->getApi()->getMysqlReadEntry()->get(); if (!is_array($result)) { log::warning('There are no mysql-dbs you could export?!', __METHOD__); } else { foreach ($result as $row) { // Get Mysql-Version switch ($row['hostip']) { case '127.0.0.1': $version = 'MySQL 3 (DEPRECATED)'; break; case '127.0.0.2': $version = 'MySQL 4 (DEPRECATED)'; break; case '127.0.0.3': $version = 'MySQL 5'; break; } $customer = isset($orders[$row['ordnr']]) ? $this->getCustomerNameFormatted($orders[$row['ordnr']]) : ''; $pk = isset($orders[$row['ordnr']]) ? $customer : '000_' . $row['pk']; $this->csvFields[$pk] = ['Customer' => $customer, 'Order' => $row['ordnr'], 'IP (local)' => $row['hostip'], 'IP (external)' => $row['extip'], 'Version' => $version, 'Name' => $row['name'], 'Description' => $row['notice'], 'Password' => $row['password']]; } } ksort($this->csvFields); return $this; }
/** * Building a list of all domains, matching set filter * * - OrderNr * - (Sub-)Domain * - PHP-Version * - Target */ public function buildDomainList() { /** @var bbDomain_readEntry $domains */ $domains = $this->getApi()->getDomainReadEntry(); $result = $domains->addSettings()->addSubdomain()->get(); if (!is_array($result)) { log::warning('There are no domains you could export?!', __METHOD__); } else { foreach ($result as $domain) { $phpVersion =& $domain['settings']['php_version']; if (isset($domain['subdomain']) && is_array($domain['subdomain'])) { foreach ($domain['subdomain'] as $subdomain) { $this->domainList[$subdomain['name']] = ['name' => $subdomain['name'], 'orderNr' => $subdomain['ordnr'], 'phpVersion' => $phpVersion, 'target' => $subdomain['target']]; } } } } return $this; }
/** * Authorizes the given user at the api * * @param $rp2InstanceUrl * @param $rp2ApiUser * @param $rp2ApiPwd * @return bool */ public function auth($rp2InstanceUrl, $rp2ApiUser, $rp2ApiPwd) { $duration = microtime(1); log::debug('Setting RPC-URL', "bbRpc::setUrl({$rp2InstanceUrl})"); bbRpc::setUrl($rp2InstanceUrl); $userId = bbRpc::auth($rp2ApiUser, $rp2ApiPwd); $duration = round(microtime(1) - $duration, 3); if (!$userId) { log::warning("Login failed from " . $_SERVER['REMOTE_ADDR'] . " within {$duration} sec.", "bbRpc::auth({$rp2ApiUser}, *****)", $_SERVER); $this->fetchRpcLog(); return false; } else { // https://doku.premium-admin.eu/doku.php/api/methoden/bbrpc/setutf8native log::info("Login successful from " . $_SERVER['REMOTE_ADDR'] . " within {$duration} sec.", "bbRpc::auth({$rp2ApiUser}, *****)"); $this->fetchRpcLog(); log::debug('Set UTF-8', 'bbRpc::setUTF8Native(true)'); bbRpc::setUTF8Native(true); $this->fetchRpcLog(); return true; } }
/** * @todo fix me, seems like I'm broken */ protected function fetchRpcLog() { // I realy don't like the way of fetching RPC-Error-Messages... //$hLoglvl = array("error"=>0, "warn"=>1, "notice"=>2, "ok"=>3, "debug"=>4); global $_BBRPC_Msgs; if (is_array($_BBRPC_Msgs)) { foreach ($_BBRPC_Msgs as $key => &$hMsg) { switch ($hMsg["typ"]) { case 0: module\log::error("RPC-Msg.: {$hMsg}", __METHOD__); break; case 1: module\log::warning("RPC-Msg.: {$hMsg}", __METHOD__); break; case 2: module\log::info("RPC-Msg.: {$hMsg}", __METHOD__); break; case 3: module\log::debug("RPC-Msg.: OK! {$hMsg}", __METHOD__); break; case 4: module\log::debug("RPC-Msg.: {$hMsg}", __METHOD__); break; } unset($_BBRPC_Msgs[$key]); } } }