Portions created by the Initial Developer are Copyright (C) 2016-2018 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ //includes require_once "root.php"; require_once "resources/require.php"; //add multi-lingual support $language = new text; $text = $language->get(); //get attachment uuid $contact_attachment_uuid = $_GET['id']; $action = $_GET['action']; //get media if (is_uuid($contact_attachment_uuid)) { $sql = "select attachment_filename, attachment_content from v_contact_attachments "; $sql .= "where contact_attachment_uuid = :contact_attachment_uuid "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; $parameters['contact_attachment_uuid'] = $contact_attachment_uuid; $parameters['domain_uuid'] = $domain_uuid; $database = new database; $attachment = $database->select($sql, $parameters, 'row'); unset($sql, $parameters); $attachment_type = strtolower(pathinfo($attachment['attachment_filename'], PATHINFO_EXTENSION)); //determine mime type $content_type = 'application/octet-stream'; //set default $allowed_attachment_types = json_decode($_SESSION['contacts']['allowed_attachment_types']['text'], true); if (is_array($allowed_attachment_types) && sizeof($allowed_attachment_types) != 0) { if ($allowed_attachment_types[$attachment_type] != '') { $content_type = $allowed_attachment_types[$attachment_type]; } } switch ($action) { case 'download': header("Content-type: ".$content_type."; charset=utf-8"); header("Content-Disposition: attachment; filename=\"".$attachment['attachment_filename']."\""); header("Content-Length: ".strlen(base64_decode($attachment['attachment_content']))); echo base64_decode($attachment['attachment_content']); break; case 'display': echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " \n"; echo "
\n"; break; } } ?>