/** * Send application/csv-header and starts downloading the csv * * @param string $filename * @return $this * @throws \Exception */ public function sendDownloadCsv($filename = NULL) { $filename = $filename !== NULL ? $filename : 'DomainExport_' . date('ymd') . '_1SRV.csv'; log::info("Download started: {$filename}", __METHOD__); header('Content-Type: text/html; charset=iso-8859-15'); header('Content-Type: application/csv'); header("Content-Disposition: attachment; filename=\"{$filename}\";"); echo utf8_decode($this->getCsv()); 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]); } } }