/** * Finds the url that belongs to the file with the given fileID in the given system * * @param mixed $system System reference * @param mixed $fileID FileID * @return mixed Image URL */ function getFileURL($system, $fileID) { return HEURIST_BASE_URL . "redirects/file_download.php?db=" . HEURIST_DBNAME . "&id=" . $fileID; $paths = fileGetPath_URL_Type($system, $fileID); //print_r($paths); if (isset($paths[0][0])) { // Heurist URL return HEURIST_FILES_URL . $paths[0][0]; } else { if (isset($paths[0][1])) { // External URL return $paths[0][1]; } } return "null"; }
/** * Delete files * * @param mixed $system * @param mixed $file_ids - list of files to be deleted */ function fileDelete($system, $file_ids, $ugrID = null) { //verify that current user can delete $ugrID = $system->is_admin2($ugrID); if (!$ugrID) { $system->addError(HEURIST_REQUEST_DENIED); return false; } else { if (is_string($file_ids)) { $file_ids = explode(",", $file_ids); } //$kwd_ids = array_map('intval', array_keys($_REQUEST['delete_kwds'])); if (is_array($file_ids) && count($file_ids) > 0) { $mysqli = $system->get_mysqli(); $res = $mysqli->query('delete recUploadedFiles, recDetails from recUploadedFiles left join recDetails on dtl_UploadedFileID = ulf_ID where ulf_ID in (' . implode(', ', $file_ids) . ') and ulf_UploaderUGrpID=' . $ugrID); if ($res) { $listpaths = fileGetPath_URL_Type($system, $file_ids); //@todo $ugrID if (is_array($listpaths)) { foreach ($listpaths as $fileinfo) { if (file_exists($fileinfo[0])) { unlink($fileinfo[0]); } } } $cnt = $mysqli->affected_rows; return $cnt; } else { $system->addError(HEURIST_DB_ERROR, "Cannot delete file", $mysqli->error); return false; } } else { $system->addError(HEURIST_INVALID_REQUEST); return false; } } }
$system->initPathConstants($db); $thumbfile = HEURIST_THUMB_DIR . 'ulf_' . $fileid . '.png'; if (file_exists($thumbfile)) { downloadFile('image/png', $thumbfile); } else { //@todo - change to the same script in h4 $thumb_url = HEURIST_BASE_URL . "common/php/resizeImage.php?db=" . $db . "&ulf_ID=" . $fileid; header("Location: " . $thumb_url); exit; } } else { if (@$_REQUEST['id']) { $system->init($db); $fileid = @$_REQUEST['id']; //find $listpaths = fileGetPath_URL_Type($system, $fileid); if (is_array($listpaths) && count($listpaths) > 0) { $fileinfo = $listpaths[0]; $filepath = $fileinfo[0]; $url = $fileinfo[1]; $mimeType = $fileinfo[2]; $params = $fileinfo[3]; $originalFileName = $fileinfo[4]; $is_video = strpos($mimeType, "video/") === 0 || strpos($params, "video") !== false; $is_audio = strpos($mimeType, "audio/") === 0 || strpos($params, "audio") !== false; if (@$_REQUEST['player'] && ($is_video || $is_audio)) { if ($url) { $filepath = $url; } else { $filepath = HEURIST_BASE_URL . "redirects/file_download.php?db=" . HEURIST_DBNAME . "&id=" . $fileid; }