/** * Returns values from recUploadedFiles for given file ID * * used in saveURLasFile and getSearchResults * * @todo to use in renderRecordData * * @param mixed $fileID * @param mixed $needConnect */ function get_uploaded_file_info($fileID, $needConnect) { $res = get_uploaded_file_info_internal($fileID, $needConnect); if ($res) { unset($res["parameters"]); //unset($res["remoteURL"]); unset($res["fullpath"]); unset($res["prefsource"]); $res = array("file" => $res); } return $res; }
return; } // nothing returned if no ulf_ID parameter if (@$_REQUEST['ulf_ID']) { $filedata = get_uploaded_file_info_internal($_REQUEST['ulf_ID'], false); if ($filedata == null) { return; } // nothing returned if parameter does not match one and only one row $url = $filedata['URL']; $url = str_replace("\\", "\\\\", $url); $recID = get_uploaded_file_recordid($filedata['id'], false); } else { $recID = $_REQUEST['rec_ID']; $ulf_id = get_uploaded_fileid_by_recid($recID); $filedata = get_uploaded_file_info_internal($ulf_id, false); if ($filedata == null) { return; } // nothing returned if parameter does not match one and only one row $url = $filedata['URL']; } if (array_key_exists('width', $_REQUEST)) { $width = $_REQUEST['width']; } else { $width = '100%'; } if (array_key_exists('height', $_REQUEST)) { $height = $_REQUEST['height']; } else { $height = '100%';
require_once dirname(__FILE__) . "/uploadFile.php"; require_once dirname(__FILE__) . "/fileUtils.php"; if (@$_REQUEST['mobcfg']) { downloadFile("text/xml", HEURIST_FILESTORE_DIR . "settings/mobile-config.xml"); return; } mysql_connection_select(DATABASE); // May be best to avoid the possibility of somebody harvesting ulf_ID=1, 2, 3, ... // so the files are indexed by the SHA-1 hash of the concatenation of the ulf_ID and a random integer. if (!@$_REQUEST['ulf_ID']) { return; } // nothing returned if no ulf_ID parameter $recID = null; //need for image annotations $filedata = get_uploaded_file_info_internal($_REQUEST['ulf_ID'], false); if ($filedata == null) { return; } // nothing returned if parameter does not match one and only one row $type_source = $filedata['remoteSource']; $type_media = $filedata['mediaType']; $isplayer = array_key_exists('player', $_REQUEST) && $_REQUEST['player'] == 'yes'; $isannotation_editor = defined('DT_ANNOTATION_RANGE') && defined('DT_ANNOTATION_RESOURCE') && @$_REQUEST['annedit'] == 'yes'; if ($isplayer) { $size = ''; if (array_key_exists('width', $_REQUEST)) { $width = $_REQUEST['width']; $size = 'width="' . $width . '" '; } else { $width = '100%';
function outputDetail($dt, $value, $rt, $recInfos, $depth = 0, $outputStub, $parentID) { global $DTN, $DTT, $TL, $RQS, $INV, $GEO_TYPES, $MAX_DEPTH, $INCLUDE_FILE_CONTENT, $SUPRESS_LOOPBACKS, $relTypDT; $attrs = array('id' => $dt, 'conceptID' => getDetailTypeConceptID($dt)); if (array_key_exists($dt, $DTN)) { $attrs['type'] = $DTN[$dt]; } if (array_key_exists($rt, $RQS) && array_key_exists($dt, $RQS[$rt])) { $attrs['name'] = $RQS[$rt][$dt]; } if ($dt === $relTypDT && array_key_exists($value, $INV) && $INV[$value] && array_key_exists($INV[$value], $TL)) { //saw Enum change $attrs['inverse'] = $TL[$INV[$value]]['trm_Label']; $attrs['invTermConceptID'] = getTermConceptID($INV[$value]); } if (is_array($value)) { if (array_key_exists('id', $value)) { // record pointer $attrs['isRecordPointer'] = "true"; if ($MAX_DEPTH == 0 && $outputStub) { openTag('detail', $attrs); $recinfo = loadRecord_NoCache($value['id'], true); outputRecordStub($recinfo); //$recInfos[$value['id']]['record']); closeTag('detail'); } else { makeTag('detail', $attrs, $value['id']); } } else { if (array_key_exists('file', $value)) { $file = $value['file']; if (@$_REQUEST['includeresources'] == '1' && @$_REQUEST['mode'] == '1') { $file = get_uploaded_file_info_internal($file['id'], false); unset($file['thumbURL']); if ($file['fullpath'] && file_exists($file['fullpath'])) { //if path is relative then we copy file if (@$file['ulf_FilePath'] == null || $file['ulf_FilePath'] == '' || substr($file['ulf_FilePath'], 1) != '/') { //$path_parts = pathinfo($file['fullpath']); //$dirname = $path_parts['dirname'].'/'; //copy file and create required folders chdir(HEURIST_FILESTORE_DIR); // relatively db root $fpath = realpath($file['fullpath']); $fpath = str_replace('\\', '/', $fpath); recurse_copy(HEURIST_FILESTORE_DIR, HEURIST_FILESTORE_DIR . 'backup/' . HEURIST_DBNAME . '/', null, $fpath); $file['URL'] = @$file['ulf_FilePath'] . @$file['ulf_FileName']; //relative path to db root } else { //otherwise skip copy and use downloadURL //$file['URL'] - it is already has downloadFile or remote URL } /* this code is not use anymore - we copy the entire file_uploads folder // backup file into backup/user folder $folder = HEURIST_FILESTORE_DIR . "backup/" . get_user_username() . "/resources/"; if(!file_exists($folder) && !mkdir($folder, 0777, true)){ print "<p class='error'>'Failed to create folder for file resources: ".$folder.'</p>'; break; } $path_parts = pathinfo($file['fullpath']); $file['URL'] = $path_parts['basename']; $filename_bk = $folder . $file['URL']; copy($file['fullpath'], $filename_bk); $file['URL'] = 'resources/'.$file['URL']; */ } } openTag('detail', $attrs); openTag('file'); makeTag('id', null, $file['id']); makeTag('nonce', null, $file['nonce']); makeTag('origName', null, $file['origName']); if (@$file['mimeType']) { makeTag('mimeType', null, $file['mimeType']); } if (@$file['fileSize']) { makeTag('fileSize', array('units' => 'kB'), $file['fileSize']); } if (@$file['date']) { makeTag('date', null, $file['date']); } if (@$file['description']) { makeTag('description', null, $file['description']); } if (@$file['URL']) { makeTag('url', null, $file['URL']); } if (@$file['thumbURL']) { makeTag('thumbURL', null, $file['thumbURL']); } if ($INCLUDE_FILE_CONTENT !== false && $INCLUDE_FILE_CONTENT >= $depth) { makeFileContentNode($file); } closeTag('file'); closeTag('detail'); } else { if (array_key_exists('geo', $value)) { openTag('detail', $attrs); openTag('geo'); makeTag('type', null, $GEO_TYPES[$value['geo']['type']]); makeTag('wkt', null, $value['geo']['wkt']); closeTag('geo'); closeTag('detail'); } } } } else { if ($DTT[$dt] === 'date') { openTag('detail', $attrs); if (strpos($value, "|") === false) { outputDateDetail($attrs, $value); } else { outputTemporalDetail($attrs, $value); } closeTag('detail'); } else { if ($DTT[$dt] === 'resource') { $attrs['isRecordPointer'] = "true"; if ($MAX_DEPTH == 0 && $outputStub) { openTag('detail', $attrs); $recinfo = loadRecord_NoCache($value['id'], true); outputRecordStub($recinfo); //$recInfos[$value['id']]['record']); closeTag('detail'); } else { makeTag('detail', $attrs, $value['id']); } } else { if (($DTT[$dt] === 'enum' || $DTT[$dt] === 'relationtype') && array_key_exists($value, $TL)) { $attrs['termID'] = $value; $attrs['termConceptID'] = getTermConceptID($value); if (@$TL[$value]['trm_ParentTermID']) { $attrs['ParentTerm'] = $TL[$TL[$value]['trm_ParentTermID']]['trm_Label']; } makeTag('detail', $attrs, $TL[$value]['trm_Label']); } else { makeTag('detail', $attrs, replaceIllegalChars($value)); } } } } }
/** * description * @global type description of global variable usage in a function * @staticvar type [$varname] description of static variable usage in function * @param type [$varname] description * @return type description * @link URL * @see name of another element (function or object) used in this function * @throws list of exceptions thrown in this code * @uses code_element_name description of use */ function outputDetail($dt, $value, $rt, $recInfos, $depth = 0, $outputStub, $parentID) { global $DTN, $DTT, $TL, $RQS, $INV, $GEO_TYPES, $MAX_DEPTH, $INCLUDE_FILE_CONTENT, $SUPRESS_LOOPBACKS, $relTypDT; $attrs = array('id' => $dt, 'conceptID' => getDetailTypeConceptID($dt)); if (array_key_exists($dt, $DTN)) { $attrs['type'] = $DTN[$dt]; } if (array_key_exists($rt, $RQS) && array_key_exists($dt, $RQS[$rt])) { $attrs['name'] = $RQS[$rt][$dt]; } if ($dt === $relTypDT && array_key_exists($value, $INV) && $INV[$value] && array_key_exists($INV[$value], $TL)) { //saw Enum change $attrs['inverse'] = $TL[$INV[$value]]['trm_Label']; $attrs['invTermConceptID'] = getTermConceptID($INV[$value]); } if (is_array($value)) { if (array_key_exists('id', $value)) { // record pointer $attrs['isRecordPointer'] = "true"; if ($MAX_DEPTH == 0 && $outputStub) { openTag('detail', $attrs); outputRecordStub($recInfos[$value['id']]['record']); closeTag('detail'); } else { makeTag('detail', $attrs, $value['id']); } } else { if (array_key_exists('file', $value)) { $file = $value['file']; if (@$_REQUEST['includeresources'] == '1' && @$_REQUEST['mode'] == '1') { $file = get_uploaded_file_info_internal($file['id'], false); if ($file['fullpath'] && file_exists($file['fullpath'])) { //backup file inot backup/user folder $folder = HEURIST_UPLOAD_DIR . "backup/" . get_user_username() . "/"; $path_parts = pathinfo($file['fullpath']); $file['URL'] = $path_parts['basename']; $filename_bk = $folder . $file['URL']; copy($file['fullpath'], $filename_bk); unset($file['thumbURL']); } } openTag('detail', $attrs); openTag('file'); makeTag('id', null, $file['id']); makeTag('nonce', null, $file['nonce']); makeTag('origName', null, $file['origName']); if (@$file['mimeType']) { makeTag('mimeType', null, $file['mimeType']); } if (@$file['fileSize']) { makeTag('fileSize', array('units' => 'kB'), $file['fileSize']); } if (@$file['date']) { makeTag('date', null, $file['date']); } if (@$file['description']) { makeTag('description', null, $file['description']); } if (@$file['URL']) { makeTag('url', null, $file['URL']); } if (@$file['thumbURL']) { makeTag('thumbURL', null, $file['thumbURL']); } if ($INCLUDE_FILE_CONTENT !== false && $INCLUDE_FILE_CONTENT >= $depth) { makeFileContentNode($file); } closeTag('file'); closeTag('detail'); } else { if (array_key_exists('geo', $value)) { openTag('detail', $attrs); openTag('geo'); makeTag('type', null, $GEO_TYPES[$value['geo']['type']]); makeTag('wkt', null, $value['geo']['wkt']); closeTag('geo'); closeTag('detail'); } } } } else { if ($DTT[$dt] === 'date') { openTag('detail', $attrs); if (strpos($value, "|") === false) { outputDateDetail($attrs, $value); } else { outputTemporalDetail($attrs, $value); } closeTag('detail'); } else { if ($DTT[$dt] === 'resource') { $attrs['isRecordPointer'] = "true"; if ($MAX_DEPTH == 0 && $outputStub) { openTag('detail', $attrs); outputRecordStub($recInfos[$value['id']]['record']); closeTag('detail'); } else { makeTag('detail', $attrs, $value['id']); } } else { if (($DTT[$dt] === 'enum' || $DTT[$dt] === 'relationtype') && array_key_exists($value, $TL)) { $attrs['termID'] = $value; $attrs['termConceptID'] = getTermConceptID($value); if (@$TL[$value]['trm_ParentTermID']) { $attrs['ParentTerm'] = $TL[$TL[$value]['trm_ParentTermID']]['trm_Label']; } makeTag('detail', $attrs, $TL[$value]['trm_Label']); } else { makeTag('detail', $attrs, replaceIllegalChars($value)); } } } } }