getAntUrlActionList(); DBG::nicePrint($taskList, 'ant-url_action'); $featureID = V::get('featureID', '', $_GET); $typeName = V::get('typeName', '', $_GET); // TODO: validate missing ... UI::startTag('ul'); foreach ($taskList as $path => $label) { $link = "index.php?_route=UrlAction_Ant&_task=ant&path={$path}&typeName={$typeName}&featureID={$featureID}"; echo UI::h('li', [], [ UI::h('a', ['href'=>$link], "Uruchom '{$label}'") ]); } UI::endTag('ul'); } catch (Exception $e) { UI::alert('danger', $e->getMessage()); DBG::log($e); } UI::dol(); } public function outputAction() {// index.php?_route=UrlAction_Ant&_task=output & path={$path} & file={$file}"; $path = V::get('path', '', $_GET); if (!$path) throw new Exception("Missing Ant path!"); $file = V::get('file', '', $_GET); if (!$file) throw new Exception("Missing Ant file!"); // TODO: allow auth by token? throw new Exception("TODO: return output file '$file' from ant task '{$path}'"); } public function antAction() { UI::gora(); try { echo UI::h('h1', [], "Ant action"); $path = V::get('path', '', $_GET); if (!$path) throw new Exception("Missing Ant path!"); $primaryKey = V::get('primaryKey', '', $_GET); $xpath = V::get('xpath', '', $_GET); $typeName = V::get('typeName', '', $_GET); list($nsPrefix, $objectName) = explode(':', $typeName);// TODO: get wfs prefix from typeName // TODO: validate missing ... DBG::log([ 'msg'=>'$path', '$path'=>$path]); DBG::log([ 'msg'=>'$primaryKey', '$primaryKey'=>$primaryKey]); DBG::log([ 'msg'=>'$typeName', '$typeName'=>$typeName]); $taskList = $this->getAntUrlActionList(); if (!array_key_exists($path, $taskList)) throw new Exception("Ant path not exists! '{$path}'"); echo UI::h('hr'); $webRootUrl = Request::getPathUri() . "schema/ant-url_action/{$path}";// TODO: security - only for test $outputFunctionUrl = Request::getPathUri() . "index.php?_route=UrlAction_Ant&_task=output&path={$path}&file="; DBG::log([ 'msg'=>'$webRootUrl', '$webRootUrl'=>$webRootUrl]); DBG::log([ 'msg'=>'$outputFunctionUrl', '$outputFunctionUrl'=>$outputFunctionUrl]); $testUrl = Request::getPathUri() . "wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=".$typeName."&SRSNAME=EPSG:3003&featureID={$objectName}.{$primaryKey}"; $cryptedPass = base64_encode(User::getLogin() . ":" . Crypt::decrypt($_SESSION['ADM_PASS_HASH'])); // $cmd = "cd {$this->pathUrlActions}{$path} && {$this->antBin} -DoutputFunctionUrl='{$outputFunctionUrl}' -DwebRootUrl='{$webRootUrl}' -Durl='{$testUrl}' -DpasswordBase64Basic=\"{$cryptedPass}\" -Duuid=\"".session_id()."\" -Dxpath=".$xpath." -Dxpath_value=".$primaryKey." -DtypeName=\"".$typeName."\" 2>&1"; $cmd = "{$this->pathUrlActions}{$path}/do_build.sh -DoutputFunctionUrl='{$outputFunctionUrl}' -DwebRootUrl='{$webRootUrl}' -Durl='{$testUrl}' -DpasswordBase64Basic=\"{$cryptedPass}\" -Duuid=\"".session_id()."\" -Dxpath=".$xpath." -Dxpath_value=".$primaryKey." -DtypeName=\"".$typeName."\" "; DBG::log([ 'msg'=>"cmd", 'cmd'=>str_replace(APP_PATH_ROOT, 'SE', $cmd) ]); //V::exec($cmd, $out, $ret); to nie dziala prawidlowo $out=shell_exec($cmd); DBG::log([ 'msg'=>"cmd and returns({$ret})", 'output'=>$out ]); $html = []; $startRead = false; echo "
".$out."
"; //do poprawy, chce ruszyc, bo lokalnie mi dziala /* foreach ($out as $line) { if (!$startRead) { if ('OUTPUT__START' == $line) { $startRead = true; continue; } } else { if ('"container", 'style'=>"padding:12px; border:1px solid #ddd"], $html); */ } catch (Exception $e) { UI::alert('danger', $e->getMessage()); DBG::log($e); } UI::dol(); } }