Browse Source

Check for hostname

You can enter the Djatoka URL as a relative path or full hostname. I did hostname and didn't get any errors. But this function assumes it is a path and sticks http(s)://<SERVER NAME> in front which causes you to get a blank Jpeg when downloading the clip.
pull/466/head
Jared Whiklo 11 years ago
parent
commit
024cf013fd
  1. 5
      islandora.module

5
islandora.module

@ -1540,9 +1540,12 @@ function islandora_entity_property_info() {
*/ */
function islandora_download_clip(AbstractObject $object) { function islandora_download_clip(AbstractObject $object) {
if (isset($_GET['clip'])) { if (isset($_GET['clip'])) {
$url = $_GET['clip'];
if (!preg_match('/^https?:\/\//',$url)) {
$is_https = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on'; $is_https = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on';
$http_protocol = $is_https ? 'https' : 'http'; $http_protocol = $is_https ? 'https' : 'http';
$url = $http_protocol . '://' . $_SERVER['HTTP_HOST'] . $_GET['clip']; $url = $http_protocol . '://' . $_SERVER['HTTP_HOST'] . $url;
}
$filename = $object->label; $filename = $object->label;
header("Content-Disposition: attachment; filename=\"{$filename}.jpg\""); header("Content-Disposition: attachment; filename=\"{$filename}.jpg\"");
header("Content-type: image/jpeg"); header("Content-type: image/jpeg");

Loading…
Cancel
Save