preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($data);
return $dom->saveXML();
} // public function beautifyXML($data){
public function GetStatusTaskContent($actionID){
$n = 0; // done=0 && outdated=0
$xml = new SimpleXMLElement('');
$config = new Config();
$conn = new Connection();
$table = $config->sql_tablename();
$pdo = $conn->prepareQuery();
$sql = "SELECT status FROM $table WHERE `done`=:done AND `outdated`=:outdated AND `hash`=:hash";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':done', $n, PDO::PARAM_INT);
$stmt->bindParam(':outdated', $n, PDO::PARAM_INT);
$stmt->bindParam(':hash', $actionID, PDO::PARAM_STR);
$stmt->execute();
$obj = $stmt->fetchObject();
$xml->addChild('datetime', date('Y-m-d H:i:s'));
$xml->addChild('status', $obj->status);
return $this->beautifyXML($xml->asXML());
} // public function GetStatusTaskContent($actionID){
public function GetNewTaskContent(){
$n = 0; // done=0 && outdated=0
$xml = new SimpleXMLElement('');
$config = new Config();
$conn = new Connection();
$table = $config->sql_tablename();
$pdo = $conn->prepareQuery();
//$sql = "SELECT traintext FROM $table WHERE `done`=:done AND `outdated`=:outdated AND `status`=:status AND `hash`=:hash";
$sql = "SELECT * FROM $table WHERE `done`=:done AND `outdated`=:outdated AND `status`=:status ORDER BY `created` DESC LIMIT 1";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':done', $n, PDO::PARAM_INT);
$stmt->bindParam(':outdated', $n, PDO::PARAM_INT);
$stmt->bindParam(':status', $n, PDO::PARAM_INT);
/*
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':done', $n, PDO::PARAM_INT);
$stmt->bindParam(':outdated', $n, PDO::PARAM_INT);
$stmt->bindParam(':hash', $actionID, PDO::PARAM_STR);
$stmt->bindParam(':status', $n, PDO::PARAM_INT);
*/
$stmt->execute();
$obj = $stmt->fetchObject();
$xml->addChild('datetime', date('Y-m-d H:i:s'));
$xml->addChild('timestamp', time());
$xml->addChild('aid', $obj->hash);
$xml->addChild('language', $obj->lang);
$xml->addChild('worktime', $obj->worktime);
$xml->addChild('traintext', htmlentities($obj->traintext));
// no : beautifyXML($data) here !!
return $xml->asXML();
} // public function GetNewTaskContent($actionID){
/*
public function GetNewTaskXML(){
$n = 0; // done=0 && outdated=0
$config = new Config();
$conn = new Connection();
$xml = new SimpleXMLElement('');
$table = $config->sql_tablename();
$pdo = $conn->prepareQuery();
//$stmt = $pdo->prepare("SELECT * FROM $table WHERE id>0 AND done=0 AND outdated=0 ORDER BY created DESC LIMIT 1;");
$sql = "SELECT * FROM $table WHERE `done`=:done AND `outdated`=:outdated AND `status`=:status ORDER BY `created` DESC LIMIT 1";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':done', $n, PDO::PARAM_INT);
$stmt->bindParam(':outdated', $n, PDO::PARAM_INT);
$stmt->bindParam(':status', $n, PDO::PARAM_INT);
$stmt->execute();
$obj = $stmt->fetchObject();
$xml->addChild('datetime', date('Y-m-d H:i:s'));
$xml->addChild('timestamp', time());
$xml->addChild('language', $obj);
$xml->addChild('worktime', $obj->worktime);
$xml->addChild('aid', $obj->hash);
$count = 1;
while($rows = $stmt->fetch(PDO::FETCH_ASSOC)) {
$lang = $rows["lang"];
$worktime = $rows["worktime"];
$hash = $rows["hash"];
//$org_text = $rows["hash"];
//$train_text = $rows["traintext"];
// create XML
$p->addChild('timestamp'.$count, time());
$p->addChild('language'.$count, $lang);
$p->addChild('worktime'.$count, $worktime);
$p->addChild('aid'.$count, $hash);
//$p->addChild('traintext'.$count, htmlentities($train_text));
$count++;
} // while($rows = $stmt->fetch(PDO::FETCH_ASSOC)) {
return $this->beautifyXML($xml->asXML());
} // public function GetNewTaskXML(){
*/
public function GetIndexPageXML($data, $flag){
// http://php.net/manual/de/simplexmlelement.addchild.php
$co = new Config();
$xml = new SimpleXMLElement('');
$wwwroot_storepath = $co->wwwroot_storepath();
$xml->addChild('datetime', date('Y-m-d H:i:s'));
if ($flag == "IndexPage"){
$data = $co->ForceClientManagerUpdate();
$count = 1;
$p = $xml->addChild('ForceClientManagerUpdate');
while (list($key, $value) = each ($data)) {
$url_path = parse_url($key, PHP_URL_PATH);
$file = $wwwroot_storepath.$url_path;
$file_md5 = md5_file($file);
$p->addChild('fetchurl'.$count, $key);
$p->addChild('storepath'.$count, $value);
$p->addChild('md5filehash'.$count, $file_md5);
$count++;
} // while (list($key, $value) = each ($data)) {
$data = $co->ForceInternalDockerImageAPTUpdate();
$count = 1;
$p = $xml->addChild('ForceInternalDockerImageAPTUpdate');
while (list($key, $value) = each ($data)) {
$key = htmlentities($key);
$p->addChild('exec_command'.$count, $key);
$count++;
} // while (list($key, $value) = each ($data)) {
$data = $co->ForceDeepLearningTrainingSoftwareUpdate();
$count = 1;
$p = $xml->addChild('ForceDeepLearningTrainingSoftwareUpdate');
while (list($key, $value) = each ($data)) {
$url_path = parse_url($key, PHP_URL_PATH);
$file = $wwwroot_storepath.$url_path;
$file_md5 = md5_file($file);
$p->addChild('fetchurl'.$count, $key);
$p->addChild('storepath'.$count, $value);
$p->addChild('md5filehash'.$count, $file_md5);
$count++;
} // while (list($key, $value) = each ($data)) {
} // if ($flag == "IndexPage"){
if ($flag == "ForceClientManagerUpdate"){
$count = 1;
$p = $xml->addChild('ForceClientManagerUpdate');
while (list($key, $value) = each ($data)) {
$url_path = parse_url($key, PHP_URL_PATH);
$file = $wwwroot_storepath.$url_path;
$file_md5 = md5_file($file);
$p->addChild('fetchurl'.$count, $key);
$p->addChild('storepath'.$count, $value);
$p->addChild('md5filehash'.$count, $file_md5);
$count++;
} // while (list($key, $value) = each ($data)) {
} // if ($flag == "ForceClientManagerUpdate"){
if ($flag == "ForceInternalDockerImageAPTUpdate"){
$count = 1;
$p = $xml->addChild('ForceInternalDockerImageAPTUpdate');
while (list($key, $value) = each ($data)) {
$key = htmlentities($key);
$p->addChild('exec_command'.$count, $key);
$count++;
} // while (list($key, $value) = each ($data)) {
} // if ($flag == "ForceInternalDockerImageAPTUpdate"){
if ($flag == "ForceDeepLearningTrainingSoftwareUpdate"){
$count = 1;
$p = $xml->addChild('ForceDeepLearningTrainingSoftwareUpdate');
while (list($key, $value) = each ($data)) {
$url_path = parse_url($key, PHP_URL_PATH);
$file = $wwwroot_storepath.$url_path;
$file_md5 = md5_file($file);
$p->addChild('fetchurl'.$count, $key);
$p->addChild('storepath'.$count, $value);
$p->addChild('md5filehash'.$count, $file_md5);
$count++;
} // while (list($key, $value) = each ($data)) {
} // if ($flag == "ForceDeepLearningTrainingSoftwareUpdate"){
return $this->beautifyXML($xml->asXML());
} // public function GetIndexPageXML($data, $flag){
}
?>