function request($post_data) { //$log = new Log("REP"); $this->buf = ""; $post = "POST " . $this->path . " HTTP/1.1\r\n" . "Host: " . $this->host . ":" . $this->port . "\r\n" . "Accept: text/html, text/xml, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n" . "Cache-Control: no-cache\r\n" . "Connection: Close\r\n" . "Content-Length: {$this->dataLength} \r\n" . "Pragma: no-cache\r\n" . "SOAPAction: \"\"\r\n" . "User-Agent: myAgent\r\n" . "Content-Type: text/xml; charset=\"utf-8\"\r\n" . "\r\n" . $post_data; if ($this->save_files) { writeTmpFiles($post, $this->idfile . "-HTTP_Client_POSTED-" . $this->idfile); } fwrite($this->socket, $post); while (!feof($this->socket)) { #$this->buf .= fgets($this->socket, 2048); $this->buf .= fgets($this->socket); } $this->close(); return $this->buf; }
if (preg_match('([^\\t\\n\\r\\f\\v";][:]*+ENVELOPE)', strtoupper($registry_response))) { writeTimeFile($idfile . "--Repository: Ho trovato SOAPENV:ENVELOPE"); preg_match('(<([^\\t\\n\\r\\f\\v";<]+:)?(ENVELOPE))', strtoupper($registry_response), $matches_reg); $presoap_reg = $matches_reg[1]; writeTimeFile($idfile . "--Repository: Ho trovato {$presoap}"); $body = substr($registry_response, strpos(strtoupper($registry_response), "<" . $presoap_reg . "ENVELOPE")); //risposta DEL REGISTRY writeTmpFiles($body, $idfile . "-body_response_reg-" . $idfile); // Devo sostituire urn:ihe:iti:2007:RegisterDocumentSet-bResponse con urn:ihe:iti:2007:ProvideAndRegisterDocumentSet-bResponse $search = "urn:ihe:iti:2007:RegisterDocumentSet-bResponse"; $replace = "urn:ihe:iti:2007:ProvideAndRegisterDocumentSet-bResponse"; $body_response = str_replace($search, $replace, $body); $body_response = "<?xml version='1.0' encoding='UTF-8'?>\r\n" . $body_response; } //Risposta modificata!!!!! writeTmpFiles($body_response, $idfile . "-body_response.xml"); header("HTTP/1.1 200 OK"); //header("Content-Type: application/soap+xml;charset=UTF-8"); header("Content-Type: application/soap+xml; action=\"urn:ihe:iti:2007:RegisterDocumentSet-bResponse\";charset=UTF-8"); //header("Content-Length: ".(string)filesize($tmp_path.$idfile."-body_response-".$idfile)); ##### PULISCO IL BUFFER DI USCITA ob_get_clean(); //OKKIO FONDAMENTALE!!!!! //print($body_response); $file = fopen($tmp_path . $idfile . "-body_response.xml", 'rb'); if ($file) { while (!feof($file) && connection_status() == 0) { print fread($file, 1024 * 8); // flush();//NOTA BENE!!!!!!!!! } //END OF while((!feof($file)) && (connection_status()==0))
function writeTmpFiles($log_text, $file_name, $mandatory = false) { ### PATH COMPLETO AL FILE if (!isset($_SESSION['tmp_path'])) { $pathToFile = "./tmp/" . $file_name; } else { $pathToFile = $_SESSION['tmp_path'] . $file_name; } $writef = false; $nfile = 0; //Se il file è obbligatorio devo accertarmi che venga salvato if ($mandatory) { while (!$writef && $nfile < 10) { ### APERTURA DEL FILE IN FORMA TAIL ED IN SOLA SCRITTURA $handler_log = fopen($pathToFile, "wb+"); if ($handler_log) { ## CASO DI DATO TIPO ARRAY if (is_array($log_text)) { $txt = ""; ### IMPOSTA L'ARRAY NELLA FORMA [etichetta] = valore foreach ($log_text as $element => $value) { $txt = $txt . "{$element} = {$value}\n"; } //END OF foreach $log_text = $txt; } //END OF if(is_array($log_text)) if (fwrite($handler_log, $log_text) === FALSE) { sleep(1); $nfile++; } else { // Caso OK Riesce a aprire e scrivere il file correttamente $writef = true; } } else { sleep(1); $nfile++; } } //Fine while #### CHIUDO L'HANDLER fclose($handler_log); if (!$writef) { $errorcode[] = "XDSRepositoryError"; $error_message[] = "Repository can't create tmp file. "; $tmp_response = makeSoapedFailureResponse($error_message, $errorcode); writeTimeFile($_SESSION['idfile'] . "--Repository: Tmp File error"); $file_input = $idfile . "-tmp_failure_response-" . $idfile; writeTmpFiles($tmp_response, $file_input); SendResponse($tmp_response); exit; } } else { $handler_log = fopen($pathToFile, "wb+"); ## CASO DI DATO TIPO ARRAY if (is_array($log_text)) { $txt = ""; ### IMPOSTA L'ARRAY NELLA FORMA [etichetta] = valore foreach ($log_text as $element => $value) { $txt = $txt . "{$element} = {$value}\n"; } //END OF foreach $log_text = $txt; } //END OF if(is_array($log_text)) fwrite($handler_log, $log_text); fclose($handler_log); } #### RITORNO IL PATH AL FILE SCRITTO return $pathToFile; }
function verificaExtrinsicObject($dom_ebXML) { $ExtrinsicObject_array = $dom_ebXML->get_elements_by_tagname("ExtrinsicObject"); $conta_EO = count($ExtrinsicObject_array); if ($conta_EO > 0) { //RESTITUISCE IL MESSAGGIO DI ERRORE $errorcode[] = "XDSMissingDocument"; $error_message[] = "XDSDocumentEntry exists in metadata with no corresponding attached document"; $failure_response = makeSoapedFailureResponse($error_message, $errorcode); $file_input = $_SESSION['idfile'] . "-Document_missing-" . $_SESSION['idfile']; writeTmpFiles($failure_response, $file_input); SendResponse($failure_response); exit; //PULISCO IL BUFFER DI USCITA ob_get_clean(); //OKKIO FONDAMENTALE!!!!! } else { return true; } }
function giveboundary($headers) { if (stripos($headers["Content-Type"], "boundary")) { writeTimeFile($_SESSION['idfile'] . "--Repository: Il boundary e' presente"); if (preg_match('(boundary="[^\\t\\n\\r\\f\\v";]+")', $headers["Content-Type"])) { writeTimeFile($_SESSION['idfile'] . "--Repository: Ho trovato il boundary di tipo boundary=\"bvdwetrct637crtv\""); $content_type = stristr($headers["Content-Type"], 'boundary'); $pre_boundary = substr($content_type, strpos($content_type, '"') + 1); $fine_boundary = strpos($pre_boundary, '"') + 1; //BOUNDARY ESATTO $boundary = ''; $boundary = substr($pre_boundary, 0, $fine_boundary - 1); writeTimeFile($idfile . "--Repository: Il boundary " . $boundary); } else { if (preg_match('(boundary=[^\\t\\n\\r\\f\\v";]+[;])', $headers["Content-Type"])) { writeTimeFile($_SESSION['idfile'] . "--Repository: Ho trovato il boundary di tipo boundary=bvdwetrct637crtv;"); $content_type = stristr($headers["Content-Type"], 'boundary'); $pre_boundary = substr($content_type, strpos($content_type, '=') + 1); $fine_boundary = strpos($pre_boundary, ';'); //BOUNDARY ESATTO $boundary = ''; $boundary = substr($pre_boundary, 0, $fine_boundary); writeTimeFile($_SESSION['idfile'] . "--Repository: Il boundary " . $boundary); } else { $errorcode[] = "XDSRepositoryError"; $error_message[] = "Repository can't recognize boundary. "; $folder_response = makeSoapedFailureResponse($error_message, $errorcode); writeTimeFile($_SESSION['idfile'] . "--Repository: Il boundary non e' del tipo boundary=\"bvdwetrct637crtv\" o boundary=bvdwetrct637crtv;"); $file_input = $idfile . "-boundary_failure_response-" . $idfile; writeTmpFiles($folder_response, $file_input); SendResponse($folder_response); exit; } } $MTOM = false; } else { writeTimeFile($_SESSION['idfile'] . "--Repository: non e' dichiarato il boundary"); $MTOM = true; //$boundary = "--boundary_per_MTOM"; } $ret = array($boundary, $MTOM); return $ret; }
} if ($ATNA_active == 'A') { require_once './lib/syslog.php'; $syslog = new Syslog(); // ATNA IMPORT per Register Document Set $eventOutcomeIndicator = "0"; //EventOutcomeIndicator 0 OK 12 ERROR $registry_endpoint = $http_protocol . $ip_server . ":" . $port_server . $www_REG_path . "registry.php"; $ip_repository = $_SERVER['REMOTE_ADDR']; $today = date("Y-m-d"); $cur_hour = date("H:i:s"); $datetime = $today . "T" . $cur_hour; $message_import = "<AuditMessage>\n\t<EventIdentification EventDateTime=\"{$datetime}\" EventActionCode=\"R\" EventOutcomeIndicator=\"0\">\n\t\t<EventID code=\"110106\" codeSystemName=\"DCM\" displayName=\"Import\"/>\n\t\t<EventTypeCode code=\"ITI-14\" codeSystemName=\"IHE Transactions\" displayName=\"Register Document Set\"/>\n\t</EventIdentification>\n\t<AuditSourceIdentification AuditSourceID=\"MARIS Registry\">\n\t\t<AuditSourceTypeCode code=\"4\" />\n\t</AuditSourceIdentification>\n\t<ActiveParticipant UserID=\"{$ip_repository}\" UserIsRequestor=\"true\">\n\t\t<RoleIDCode code=\"110153\" codeSystemName=\"DCM\" displayName=\"Source\"/>\n\t</ActiveParticipant>\n\t<ActiveParticipant UserID=\"{$registry_endpoint}\" UserIsRequestor=\"false\">\n\t\t<RoleIDCode code=\"110152\" codeSystemName=\"DCM\" displayName=\"Destination\"/>\n\t</ActiveParticipant>\n\t<ParticipantObjectIdentification ParticipantObjectID=\"" . htmlentities($XDSSubmissionSetPatientId) . "\" ParticipantObjectTypeCode=\"1\" ParticipantObjectTypeCodeRole=\"1\">\n\t\t<ParticipantObjectIDTypeCode code=\"2\"/>\n \t</ParticipantObjectIdentification>\n\t<ParticipantObjectIdentification ParticipantObjectID=\"" . $SubmissionSetUniqueId_valid_array[3] . "\" ParticipantObjectTypeCode=\"2\" ParticipantObjectTypeCodeRole=\"20\">\n\t\t<ParticipantObjectIDTypeCode code=\"urn:uuid:a54d6aa5-d40d-43f9-88c5-b4633d873bdd\"/>\n\t</ParticipantObjectIdentification>\n\t</AuditMessage>"; $logSyslog = $syslog->Send($ATNA_host, $ATNA_port, $message_import); if ($clean_cache != "O") { writeTmpFiles($message_import, $idfile . "-atna_import.xml"); } writeTimeFile($idfile . "--Registry: Ho spedito i messaggi di ATNA"); } //Statistiche if ($statActive == "A") { //Parte per calcolare i tempi di esecuzione $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = number_format($endtime - $starttime, 15); $STAT_SUBMISSION = "INSERT INTO STATS (REPOSITORY,DATA,EXECUTION_TIME,OPERATION) VALUES ('" . $_SERVER['REMOTE_ADDR'] . "',CURRENT_TIMESTAMP,'{$totaltime}','SUBMISSION-A')"; $ris = query_exec2($STAT_SUBMISSION, $connessione); writeSQLQuery($ris . ": " . $STAT_SUBMISSION); }
} else { exec('rm -f ' . $document_URI2); } $deleteDocument = "DELETE FROM DOCUMENTS WHERE KEY_PROG = {$next_token}"; $res_delete = query_execute2($deleteDocument, $connessione); } #### XML RICEVUTO IN RISPOSTA DAL REGISTRY if (preg_match('([^\\t\\n\\r\\f\\v";][:]*+ENVELOPE)', strtoupper($registry_response))) { writeTimeFile($idfile . "--Repository: Ho trovato SOAPENV:ENVELOPE"); preg_match('(<([^\\t\\n\\r\\f\\v";<]+:)?(ENVELOPE))', strtoupper($registry_response), $matches_reg); $presoap_reg = $matches_reg[1]; writeTimeFile($idfile . "--Repository: Ho trovato {$presoap}"); $body = substr($registry_response, strpos(strtoupper($registry_response), "<" . $presoap_reg . "ENVELOPE")); } //File da scrivere!!!!! writeTmpFiles($body, $idfile . "-body_response-" . $idfile); header("HTTP/1.1 200 OK"); header("Content-Type: text/xml;charset=UTF-8"); header("Content-Length: " . (string) filesize($tmp_path . $idfile . "-body_response-" . $idfile)); ##### PULISCO IL BUFFER DI USCITA ob_get_clean(); //OKKIO FONDAMENTALE!!!!! //print($body); //flush(); $file = fopen($tmp_path . $idfile . "-body_response-" . $idfile, 'rb'); if ($file) { while (!feof($file) && connection_status() == 0) { print fread($file, 1024 * 8); flush(); //NOTA BENE!!!!!!!!! }
# Copyright (C) 2007 - 2010 MARiS Project # Dpt. Medical and Diagnostic Sciences, University of Padova - csaccavini@rad.unipd.it # This program is distributed under the terms and conditions of the GPL # Contributor(s): # A-thon srl <*****@*****.**> # Alberto Castellini # See the LICENSE files for details # ------------------------------------------------------------------------------------ require_once "./config/REP_configuration.php"; if ($repository_status == "O") { $errorcode[] = "XDSRepositoryNotAvailable"; $error_message[] = "Repository is down for maintenance"; $status_response = makeSoapedFailureResponse($error_message, $errorcode); writeTimeFile($_SESSION['idfile'] . "--Repository: Repository is down"); $file_input = $idfile . "-down_failure_response.xml"; writeTmpFiles($status_response, $file_input, true); //SendResponseFile($tmp_path.$file_input); SendResponse($status_response); exit; } ob_start(); //Non stampa niente a monitor ma mette tutto su un buffer $connessione = connectDB(); //ob_get_clean();//OKKIO FONDAMENTALE!!!!! Pulisco il buffer //ob_end_flush();// Spedisco il contenuto del buffer $token = $_GET["token"]; $get_token = "SELECT URI,MIMETYPE,CRYPT FROM DOCUMENTS WHERE KEY_PROG={$token}"; $res_token = query_select2($get_token, $connessione); // Da verificare se si possono usare funzioni php al posto di java if ($ATNA_active == 'A') { $eventOutcomeIndicator = "0";
function fill_Association_tables($dom, $RegistryPackage_id_array, $ExtrinsicObject_id_array, $simbolic_RegistryPackage_FOL_id_array, $connessione) { writeTimeFile("Registry: sono entrato in fill_Association_tables"); ##### RADICE DEL DOCUMENTO ebXML $root_ebXML = $dom->document_element(); ##### ARRAY DEI NODI LeafRegistryObjectList $dom_ebXML_LeafRegistryObjectList_node_array = $root_ebXML->get_elements_by_tagname("LeafRegistryObjectList"); ##### NODO LeafRegistryObjectList $dom_ebXML_LeafRegistryObjectList_node = $dom_ebXML_LeafRegistryObjectList_node_array[0]; ##### TUTTI I NODI FIGLI DI LeafRegistryObjectList $dom_ebXML_LeafRegistryObjectList_child_nodes = $dom_ebXML_LeafRegistryObjectList_node->child_nodes(); for ($i = 0; $i < count($dom_ebXML_LeafRegistryObjectList_child_nodes); $i++) { #### SINGOLO NODO $dom_ebXML_LeafRegistryObjectList_child_node = $dom_ebXML_LeafRegistryObjectList_child_nodes[$i]; ##### tagname $dom_ebXML_LeafRegistryObjectList_child_node_tagname = $dom_ebXML_LeafRegistryObjectList_child_node->node_name(); #### SOLO I NODI ASSOCIATION if ($dom_ebXML_LeafRegistryObjectList_child_node_tagname == 'Association') { $association_node = $dom_ebXML_LeafRegistryObjectList_child_node; $DB_array_association_attributes = array(); $value_id = $association_node->get_attribute('id'); if ($value_id == '' || isSimbolic($value_id)) { $value_id = "urn:uuid:" . idrandom(); } #### PARENT $value_parent = $value_id; $value_accessControlPolicy = $association_node->get_attribute('accessControlPolicy'); if ($value_accessControlPolicy == '') { $value_accessControlPolicy = "NULL"; } $value_objectType = $association_node->get_attribute('objectType'); if ($value_objectType == '') { $value_objectType = "Association"; } $value_associationType = $association_node->get_attribute('associationType'); if ($value_associationType == '') { $value_associationType = "NOT DECLARED"; } $value_sourceObject = $association_node->get_attribute('sourceObject'); //writeSQLQuery('Valore fuori dall if '.$value_sourceObject); if ($value_sourceObject == "") { $errorcode[] = "XDSRegistryError"; $error_message[] = "The sourceObject in Association is empty. "; $folder_response = makeSoapedFailureResponse($error_message, $errorcode); writeTimeFile($_SESSION['idfile'] . "--Registry: targetObject error"); $file_input = $idfile . "-sourceObject_failure_response.xml"; writeTmpFiles($folder_response, $file_input, true); SendResponseFile($_SESSION['tmp_path'] . $file_input); //SendResponse($folder_response,"application/soap+xml",filesize($tmp_path.$idfile."-folder_failure_response.xml")); exit; } if (isSimbolic($value_sourceObject)) { $value_sourceObject_1 = $ExtrinsicObject_id_array[$value_sourceObject]; $value_sourceObject_2 = $RegistryPackage_id_array[$value_sourceObject]; if ($value_sourceObject_1 != "") { $value_sourceObject = $value_sourceObject_1; } else { $value_sourceObject = $value_sourceObject_2; } } //END OF if(isSimbolic($value_sourceObject)) $value_targetObject = $association_node->get_attribute('targetObject'); if ($value_targetObject == "") { $errorcode[] = "XDSRegistryError"; $error_message[] = "The targetObject in Association is empty. "; $folder_response = makeSoapedFailureResponse($error_message, $errorcode); writeTimeFile($_SESSION['idfile'] . "--Registry: targetObject error"); $file_input = $idfile . "-targetObject_failure_response.xml"; writeTmpFiles($folder_response, $file_input, true); SendResponseFile($_SESSION['tmp_path'] . $file_input); //SendResponse($folder_response,"application/soap+xml",filesize($tmp_path.$idfile."-folder_failure_response.xml")); exit; } $simbolic_value_targetObject = $association_node->get_attribute('targetObject'); if (isSimbolic($value_targetObject)) { $value_targetObject_1 = $ExtrinsicObject_id_array[$value_targetObject]; $value_targetObject_2 = $RegistryPackage_id_array[$value_targetObject]; if ($value_targetObject_1 != "") { $value_targetObject = $value_targetObject_1; } else { $value_targetObject = $value_targetObject_2; } } //END OF if(isSimbolic($simbolic_value_targetObject)) $value_isConfirmedBySourceOwner = $association_node->get_attribute('isConfirmedBySourceOwner'); if ($value_isConfirmedBySourceOwner == '') { $value_isConfirmedBySourceOwner = "0"; } $value_isConfirmedByTargetOwner = $association_node->get_attribute('isConfirmedByTargetOwner'); if ($value_isConfirmedByTargetOwner == '') { $value_isConfirmedByTargetOwner = "0"; } $DB_array_association_attributes['id'] = $value_id; $DB_array_association_attributes['accessControlPolicy'] = $value_accessControlPolicy; $DB_array_association_attributes['objectType'] = $value_objectType; $DB_array_association_attributes['associationType'] = $value_associationType; $DB_array_association_attributes['sourceObject'] = $value_sourceObject; $DB_array_association_attributes['targetObject'] = $value_targetObject; $DB_array_association_attributes['isConfirmedBySourceOwner'] = $value_isConfirmedBySourceOwner; $DB_array_association_attributes['isConfirmedByTargetOwner'] = $value_isConfirmedByTargetOwner; $Association_folder = in_array($simbolic_value_targetObject, $simbolic_RegistryPackage_FOL_id_array); if (!$Association_folder) { ####### QUI ORA POSSO RIEMPIRE IL DB $INSERT_INTO_Association = "INSERT INTO Association (id,accessControlPolicy,objectType,associationType,sourceObject,targetObject,isConfirmedBySourceOwner,isConfirmedByTargetOwner) VALUES ('" . $DB_array_association_attributes['id'] . "','" . $DB_array_association_attributes['accessControlPolicy'] . "','" . $DB_array_association_attributes['objectType'] . "','" . $DB_array_association_attributes['associationType'] . "','" . $DB_array_association_attributes['sourceObject'] . "','" . $DB_array_association_attributes['targetObject'] . "','" . $DB_array_association_attributes['isConfirmedBySourceOwner'] . "','" . $DB_array_association_attributes['isConfirmedByTargetOwner'] . "')"; $ris = query_exec2($INSERT_INTO_Association, $connessione); writeSQLQuery($ris . ": " . $INSERT_INTO_Association); #### NODI FIGLI DI ASSOCIATION $association_child_nodes = $association_node->child_nodes(); if (!empty($association_child_nodes)) { for ($j = 0; $j < count($association_child_nodes); $j++) { #### SINGOLO NODO $association_child_node = $association_child_nodes[$j]; ##### tagname $association_child_node_tagname = $association_child_node->node_name(); #### SOLO I NODI SLOT if ($association_child_node_tagname == 'Slot') { $slot_node = $association_child_node; $DB_array_slot_attributes = array(); $value_name = $slot_node->get_attribute('name'); if ($value_name == '') { $value_name = "NOT DECLARED"; } $value_slotType = $slot_node->get_attribute('slotType'); if ($value_slotType == '') { $value_slotType = "NULL"; } $DB_array_slot_attributes['name'] = $value_name; $DB_array_slot_attributes['slotType'] = $value_slotType; $DB_array_slot_attributes['value'] = ''; $DB_array_slot_attributes['parent'] = $value_parent; #### NODI FIGLI DI SLOT $slot_child_nodes = $slot_node->child_nodes(); for ($q = 0; $q < count($slot_child_nodes); $q++) { $slot_child_node = $slot_child_nodes[$q]; $slot_child_node_tagname = $slot_child_node->node_name(); if ($slot_child_node_tagname == 'ValueList') { $valuelist_node = $slot_child_node; $valuelist_child_nodes = $valuelist_node->child_nodes(); ## UN SOLO VALUE for ($r = 0; $r < count($valuelist_child_nodes); $r++) { $value_node = $valuelist_child_nodes[$r]; $value_node_tagname = $value_node->node_name(); if ($value_node_tagname == 'Value') { $value_value = $value_node->get_content(); $DB_array_slot_attributes['value'] = $value_value; ##### SONO PRONTO A SCRIVERE NEL DB $INSERT_INTO_Slot = "INSERT INTO Slot (name,slotType,value,parent) VALUES ('" . trim($DB_array_slot_attributes['name']) . "','" . trim($DB_array_slot_attributes['slotType']) . "','" . trim(adjustString($DB_array_slot_attributes['value'])) . "','" . trim($DB_array_slot_attributes['parent']) . "')"; $ris = query_exec2($INSERT_INTO_Slot, $connessione); writeSQLQuery($ris . ": " . $INSERT_INTO_Slot); } } } } } //END OF if($association_child_node_tagname=='Slot') } } //END OF if(!empty($association_child_nodes)) } else { } ########### CASI DI REPLACEMENT + ADDENDUM + TRANSFORMATION ##### CASO RPLC Accept Document Replace if ($value_associationType == "RPLC") { // devo verificare se il documento da sostituire è dentro ad un folder, se è dentro ad un folder devo creare una association Folder Document. $query_SELECT_RegistryPackage = "SELECT id from RegistryPackage where id IN (SELECT sourceObject from Association where targetObject = '{$value_targetObject}') and objectType = 'urn:uuid:d9d542f3-6cc4-48b6-8870-ea235fbc94c2'"; $Association_folder_array = query_select2($query_SELECT_RegistryPackage, $connessione); writeSQLQuery($Association_folder_array . ": " . $query_SELECT_RegistryPackage); //Se trovo qualche RegistryPackage di tipo folder $conta_Folder = count($Association_folder_array); for ($i_Folder = 0; $i_Folder < $conta_Folder; $i_Folder++) { $insert_Association_folderDoc = "INSERT INTO Association (id,objectType,associationType,sourceObject,targetObject) VALUES ('urn:uuid:" . idrandom() . "','Association','HasMember','" . $Association_folder_array[$i_Folder][0] . "','" . $value_sourceObject . "')"; $res_insert_Association = query_exec2($insert_Association_folderDoc, $connessione); writeSQLQuery($res_insert_Association . ": " . $insert_Association_folderDoc); } // devo cambiare lo stato del documento a Deprecated $query_UPDATE_targetObject = "UPDATE ExtrinsicObject SET status = 'Deprecated' WHERE ExtrinsicObject.id = '{$value_targetObject}'"; $ex = query_exec2($query_UPDATE_targetObject, $connessione); writeSQLQuery($ex . ": " . $query_UPDATE_targetObject); } //END OF if($value_associationType=="RPLC") ##### CASO XFRM_RPLC Accept Document Replace with Transformation if ($value_associationType == "XFRM_RPLC") { $query_UPDATE_targetObject = "UPDATE ExtrinsicObject SET status = 'Deprecated' WHERE ExtrinsicObject.id = '{$value_targetObject}'"; $ex = query_exec2($query_UPDATE_targetObject, $connessione); writeSQLQuery($ex . ": " . $query_UPDATE_targetObject); } //END OF if($value_associationType=="XFRM_RPLC") ##### CASO XFRM Accept Document Transformation if ($value_associationType == "XFRM") { $query_UPDATE_targetObject = "UPDATE ExtrinsicObject SET status = 'Approved' WHERE ExtrinsicObject.id = '{$value_targetObject}'"; $ex = query_exec2($query_UPDATE_targetObject, $connessione); writeSQLQuery($ex . ": " . $query_UPDATE_targetObject); } //END OF if($value_associationType=="XFRM") ##### CASO APND Accept Document Addendum if ($value_associationType == "APND") { $query_UPDATE_targetObject = "UPDATE ExtrinsicObject SET status = 'Approved' WHERE ExtrinsicObject.id = '{$value_targetObject}'"; $ex = query_exec2($query_UPDATE_targetObject, $connessione); writeTimeFile("Registry: update status" . $query_UPDATE_targetObject); } //END OF if($value_associationType=="APND") ########### CASI DI GESTIONE FOLDER + SUBMISSIONSET if ($value_associationType == "HasMember") { ##### FIGLI DI ASSOCIATION $association_node_childs = $association_node->child_nodes(); #### AGGIUNTA DI UN DOCUMENTO A FOLDER GIA' ESISTENTE if (!isSimbolic($value_sourceObject) && empty($association_node_childs)) { #### APPURIAMO DI ESSERE NEL CASO FOLDER $query_folder = "SELECT * FROM Slot WHERE Slot.name = 'lastUpdateTime' AND Slot.parent = '{$value_sourceObject}'"; $ris_folder = query_select2($query_folder, $connessione); writeSQLQuery($ris_folder . ": " . $query_folder); if (!empty($ris_folder[0])) { #### ricavo data-ora correnti $today = date("Ymd"); $cur_hour = date("His"); $datetime = $today . $cur_hour; //$datetime = "CURRENT_TIMESTAMP"; ####UPDATE DI lastUpdateTime $update_lastUpdateTime = "UPDATE Slot SET Slot.value = '{$datetime}' WHERE Slot.name = 'lastUpdateTime' AND Slot.parent = '{$value_sourceObject}'"; $ex = query_exec2($update_lastUpdateTime, $connessione); writeSQLQuery($ex . ": " . $update_lastUpdateTime); } //END OF if(!empty($ris_folder)) } else { if (!isSimbolic($value_sourceObject) && !empty($association_node_childs)) { for ($y = 0; $y < count($association_node_childs); $y++) { ##### NODO SLOT $slot_node = $association_node_childs[$y]; ##### RECUPERO TAGNAME $slot_node_tagname = $slot_node->node_name(); if ($slot_node_tagname == "Slot") { #### NAME ATTRIBUTE FOR SLOT $slot_node_name = $slot_node->get_attribute('name'); #### NODI FIGLI DI SLOT $slot_node_childs = $slot_node->child_nodes(); for ($x = 0; $x < count($slot_node_childs); $x++) { $slot_node_child = $slot_node_childs[$x]; $slot_node_child_tagname = $slot_node_child->node_name(); if ($slot_node_child_tagname == "ValueList") { $slot_node_childs_2 = $slot_node_child->child_nodes(); for ($z = 0; $z < count($slot_node_childs_2); $z++) { $slot_node_child_2 = $slot_node_childs_2[$z]; $slot_node_child_2_tagname = $slot_node_child_2->node_name(); if ($slot_node_child_2_tagname == "Value") { $update_value = $slot_node_child_2->get_content(); } //END OF if($slot_node_child_2_tagname=="Value") } } //END OF if($slot_node_child_tagname=="ValueList") } ####UPDATE DI SubmissionSetStatus Non va fatta ????? Deve rimanere Approved $update_RegistryPackageStatus = "UPDATE RegistryPackage SET RegistryPackage.status = '{$update_value}' WHERE RegistryPackage.id = '{$value_sourceObject}'"; //writeSQLQuery($ris.": ".$update_RegistryPackageStatus); $selectIdAssociation = "SELECT id FROM Association WHERE Association.sourceObject = '{$value_sourceObject}'"; $ris_selectIdAssociation = query_select2($selectIdAssociation, $connessione); writeSQLQuery($ris_selectIdAssociation . ": " . $selectIdAssociation); $countID = count($ris_selectIdAssociation); for ($risId = 0; $risId < $countID; $risId++) { //$update_SubmissionSetStatus="UPDATE Slot SET Slot.value = '$update_value' WHERE name ='$slot_node_name' AND Slot.parent IN (SELECT id FROM Association WHERE Association.sourceObject = '$value_sourceObject')"; $update_SubmissionSetStatus = "UPDATE Slot SET Slot.value = '{$update_value}' WHERE name ='{$slot_node_name}' AND Slot.parent ='" . $ris_selectIdAssociation[$risId][0] . "'"; //writeTimeFile("Registry: update Slot ".$update_SubmissionSetStatus); $ex = query_exec2($update_SubmissionSetStatus, $connessione); writeSQLQuery($ex . ": " . $update_SubmissionSetStatus); } } //END OF if($slot_node_tagname=="Slot") } //END OF for($y=0;$y<count($association_node_childs);$y++) } } //END OF else if(!isSimbolic($value_sourceObject)) } //END OF if($value_associationType=="HasMember") } else { continue; } } //END OF for($i=0;$i<count($dom_ebXML_LeafRegistryObjectList_child_nodes);$i++) writeTimeFile("Registry: esco da fill_Association_tables"); }
$storage_directory = "./Submitted_Documents"; } else { $storage_directory = "./Submitted_Documents/disk-" . $Storage_number; } $spaziolibero = disk_free_space($storage_directory); writeTimeFile($_SESSION['idfile'] . "--Repository: Spazio disponibile: {$spaziolibero}"); if ($spaziolibero < $Storage_size && $Storage_number != 0) { $Storage_number++; $storage_directory = "./Submitted_Documents/disk-" . $Storage_number; if (!is_dir($storage_directory) && strpos($_SERVER['PHP_SELF'], "repository.php")) { $errorcode[] = "XDSRepositoryError"; $error_message[] = "Repository disk is FULL "; $File_response = makeSoapedFailureResponse($error_message, $errorcode); writeTimeFile($_SESSION['idfile'] . "--Repository: Disk error"); $file_input = $idfile . "-disk_failure_response-" . $idfile; writeTmpFiles($File_response, $file_input); SendResponse($File_response); exit; } $updateconfig = "UPDATE CONFIG SET STORAGE = {$Storage_number}"; $updateconfig_res = query_execute2($updateconfig, $connessione); } if ($Storage_number == '0') { $relative_docs_path = "./Submitted_Documents/" . date("Y") . "/" . date("m") . "/" . date("d") . "/"; // come sopra $relative_docs_path_2 = "Submitted_Documents/" . date("Y") . "/" . date("m") . "/" . date("d") . "/"; //PER COMPORRE L'URI } else { $relative_docs_path = "./Submitted_Documents/disk-" . $Storage_number . "/" . date("Y") . "/" . date("m") . "/" . date("d") . "/"; // come sopra $relative_docs_path_2 = "Submitted_Documents/disk-" . $Storage_number . "/" . date("Y") . "/" . date("m") . "/" . date("d") . "/";
function connectDB() { include './config/registry_oracle_db.php'; //putenv("ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0"); # open connection to db $conn = oci_connect($user_db, $password_db, $db); if (!$conn) { $errorcode = array(); $error_message = array(); $errorcode[] = "XDSRegistryError"; $err = ocierror(); $error_message[] = $err['message']; $database_error_response = makeSoapedFailureResponse($error_message, $errorcode); writeTimeFile($_SESSION['idfile'] . "--Registry: database_error_response"); $file_input = $_SESSION['idfile'] . "-database_error_response.xml"; writeTmpFiles($database_error_response, $file_input, true); SendResponseFile($_SESSION['tmp_path'] . $file_input); //SendResponse($database_error_response); exit; } return $conn; }
function isValid($ebxml_STRING_VALIDATION, $schema) { ####### VALIDAZIONE DELL'ebXML SECONDO LO SCHEMA libxml_use_internal_errors(true); $domEbxml = DOMDocument::loadXML($ebxml_STRING_VALIDATION); // Valido il messaggio da uno schema if (!$domEbxml->schemaValidate($schema)) { $errors = libxml_get_errors(); foreach ($errors as $error) { $errorcode[] = "XDSRegistryMetadataError"; $error_message[] = $error->message; } ### RESTITUISCE IL MESSAGGIO DI FAIL IN SOAP $failure_response = makeSoapedFailureResponse($error_message, $errorcode); ### SCRIVO LA RISPOSTA IN UN FILE // File da scrivere $file_input = $_SESSION['idfile'] . "-SOAPED_failure_VALIDATION_response.xml"; writeTmpFiles($failure_response, $file_input, true); SendResponseFile($_SESSION['tmp_path'] . $file_input); //SendResponse($failure_response); exit; } else { return true; } }
function connectDB() { # IMPORT MYSQL PARAMETERS (NOTE: IT WORKS WITH ABSOLUTE PATH ONLY !!) include './config/registry_mysql_db.php'; //ob_start();//OKKIO FONADAMENTALE!!!!!!!!!! # open connection to db $connessione = mysql_connect($ip_q, $user_db_q, $password_db_q); // or die("Connessione non riuscita: " . mysql_error()); if (!$connessione) { $errorcode = array(); $error_message = array(); $errorcode[] = "XDSRegistryError"; $error_message[] = mysql_error(); $database_error_response = makeSoapedFailureResponse($error_message, $errorcode); writeTimeFile($_SESSION['idfile'] . "--Registry: database_error_response"); $file_input = $_SESSION['idfile'] . "-database_error_response.xml"; writeTmpFiles($database_error_response, $file_input, true); SendResponseFile($_SESSION['tmp_path'] . $file_input); //SendResponse($database_error_response,"text/xml"); exit; } # open db //mysql_select_db($db_name_q); return $connessione; }
$MessageID = $MessageID_node->item(0)->nodeValue; writeTimeFile($idfile . "--Repository Retrieve: MessageID: " . $MessageID); if ($Action == "") { $failure_response = array("You must set the Action of the Request"); $error_code = array("XDSRepositoryActionError"); $SOAPED_failure_response = makeSoapedFailureResponse($failure_response, $error_code, $Action, $MessageID); $file_input = $idfile . "-SOAPED_Action_failure.xml"; writeTmpQueryFiles($SOAPED_failure_response, $file_input, true); SendResponseFile($_SESSION['tmpQueryService_path'] . $file_input); exit; } elseif ($Action != "urn:ihe:iti:2007:RetrieveDocumentSet") { $failure_response = array("This is a Retrieve Document Set transaction and you don't use the Action urn:ihe:iti:2007:RetrieveDocumentSet"); $error_code = array("XDSRepositoryActionError"); $SOAPED_failure_response = makeSoapedFailureResponse($failure_response, $error_code, $Action, $MessageID); $file_input = $idfile . "-SOAPED_Action_failure.xml"; writeTmpFiles($SOAPED_failure_response, $file_input, true); SendResponseFile($_SESSION['tmp_path'] . $file_input); exit; } $DocumentRequests = $dom->getElementsByTagName('DocumentRequest'); $DocumentRequests_array = array(); $file = array(); $documento_encoded64 = array(); foreach ($DocumentRequests as $DocumentRequest) { $RepositoryUniqueIds = $DocumentRequest->getElementsByTagName('RepositoryUniqueId'); $RepositoryUniqueId = $RepositoryUniqueIds->item(0)->nodeValue; writeTimeFile($idfile . "--Repository Retrieve: RepositoryUniqueId: " . $RepositoryUniqueId); $DocumentUniqueIds = $DocumentRequest->getElementsByTagName('DocumentUniqueId'); $DocumentUniqueId = $DocumentUniqueIds->item(0)->nodeValue; writeTimeFile($idfile . "--Repository Retrieve: DocumentUniqueId: " . $DocumentUniqueId); $DocumentRequests_array[] = array($RepositoryUniqueId, $DocumentUniqueId);
writeTimeFile($idfile . "--Ho creato il folder tmp correttamente"); $createtmpdir = true; } else { sleep(1); $ntmpdir++; } } //Fine while // Se dopo 10 volte non sono riuscito a creare il folder riporto un errore if (!$createtmpdir) { $errorcode[] = "XDSRegistryError"; $error_message[] = "Registry can't create tmp folder. "; $folder_response = makeSoapedFailureResponse($error_message, $errorcode); writeTimeFile($_SESSION['idfile'] . "--Registry: Folder error"); $file_input = $idfile . "-folder_failure_response.xml"; writeTmpFiles($folder_response, $file_input, true); SendResponseFile($_SESSION['tmpQueryService_path'] . $file_input); //SendResponse($folder_response); exit; } } //PULISCO LA CACHE TEMPORANEA //exec('rm -f '.$tmpQueryService_path."*"); //RECUPERO GLI HEADERS RICEVUTI DA APACHE $headers = apache_request_headers(); //COPIO IN LOCALE TUTTI GLI HEADERS RICEVUTI if ($clean_cache != "O") { writeTmpQueryFiles($headers, $idfile . "-headers_received-" . $idfile); } //AdhocQueryRequest IMBUSTATO $ebxml_imbustato_soap_STRING = $HTTP_RAW_POST_DATA;
function connectDB() { # IMPORT MYSQL PARAMETERS (NOTE: IT WORKS WITH ABSOLUTE PATH ONLY !!) include './config/repository_mysql_db.php'; # open connection to db $connessione = mysql_connect($ip, $user_db, $password_db); if (!$connessione) { $errorcode = array(); $error_message = array(); $errorcode[] = "XDSRepositoryError"; $error_message[] = mysql_error(); $database_error_response = makeSoapedFailureResponse($error_message, $errorcode); writeTimeFile($_SESSION['idfile'] . "--Repository: database_error_response"); $file_input = $_SESSION['idfile'] . "-database_error_response-" . $_SESSION['idfile']; writeTmpFiles($database_error_response, $file_input); SendResponse($database_error_response); exit; } # open db mysql_select_db($db_name); return $connessione; }