Portions created by the Initial Developer are Copyright (C) 2008-2020 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ //includes require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; //check permissions if (permission_exists('contact_attachment_view')) { //access granted } else { echo "access denied"; exit; } //get the contact attachment list $sql = "select *, length(decode(attachment_content,'base64')) as attachment_size from v_contact_attachments "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and contact_uuid = :contact_uuid "; $sql .= "order by attachment_primary desc, attachment_filename asc "; $parameters['domain_uuid'] = $domain_uuid; $parameters['contact_uuid'] = $contact_uuid; $database = new database; $contact_attachments = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); //show if exists if (is_array($contact_attachments) && @sizeof($contact_attachments) != 0) { //styles and attachment layer echo "\n"; echo "\n"; //display script echo "\n"; //show the content echo "
\n"; $x = 0; foreach ($contact_attachments as $row) { $attachment_type = strtolower(pathinfo($row['attachment_filename'], PATHINFO_EXTENSION)); $attachment_type_label = $attachment_type == 'jpg' || $attachment_type == 'jpeg' || $attachment_type == 'gif' || $attachment_type == 'png' ? $text['label-image'] : $text['label-file']; echo "
".$attachment_type_label."
\n"; // ($row['attachment_primary'] ? " " : null)."\n"; echo "
"; if ($attachment_type == 'jpg' || $attachment_type == 'jpeg' || $attachment_type == 'gif' || $attachment_type == 'png') { echo button::create(['type'=>'button','class'=>'link','label'=>escape($row['attachment_filename']),'onclick'=>"display_attachment('".escape($row['contact_attachment_uuid'])."');"]); } else { echo button::create(['type'=>'button','class'=>'link','label'=>escape($row['attachment_filename']),'onclick'=>"window.location='contact_attachment.php?id=".urlencode($row['contact_attachment_uuid'])."&action=download';"]); } echo "
\n"; echo "
".strtoupper(byte_convert($row['attachment_size']))."
\n"; $x++; } echo "
\n"; unset($contact_attachments); } ?>