"You don't have access to share that."])); } $has_otp = false; $item_label = ''; if ($type === 'Credential') { $credential = credentialRow($related_id); if (!$credential) { exit(json_encode(['error' => 'That credential no longer exists.'])); } $client_id = intval($credential['credential_client_id']); $item_label = $credential['credential_name']; $has_otp = credentialOtpSeed($credential['credential_otp_secret']) !== '' && credentialOtpSeed($credential['credential_otp_secret']) !== false; } elseif ($type === 'Document') { $document = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT document_name, document_client_id FROM documents WHERE document_id = $related_id LIMIT 1")); if (!$document) { exit(json_encode(['error' => 'That document no longer exists.'])); } $client_id = intval($document['document_client_id']); $item_label = $document['document_name']; } elseif ($type === 'File') { $file = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT file_name, file_client_id FROM files WHERE file_id = $related_id LIMIT 1")); if (!$file) { exit(json_encode(['error' => 'That file no longer exists.'])); } $client_id = intval($file['file_client_id']); $item_label = $file['file_name']; } else { $related_id = 0; $client_id = intval($_GET['client_id'] ?? 0); } if (!$client_id || !getFieldById('clients', $client_id, 'client_name')) { exit(json_encode(['error' => 'That client no longer exists.'])); } enforceClientAccess(); $uid = 'shareAdd' . preg_replace('/[^A-Za-z0-9]/', '', randomString(8)); $defaults = shareDefaults($type); $mail_ready = shareMailReady(); $must_protect = shareNeedsProtection($type); // IT documentation needs a passphrase or code by policy only once its passwords go in it $protect_with_secrets = $type === 'Export' && shareNeedsProtection($type, true); $export_secrets = $type === 'Export' && isset(clientExportAllowedSections()['credentials']); $suggested_passphrase = generateReadablePassword(); // Who it might go to - the client's people with an email, or anyone typed in $recipients = []; $sql = mysqli_query($mysqli, "SELECT contact_id, contact_name, contact_email, contact_title, contact_photo, contact_client_id FROM contacts WHERE contact_client_id = $client_id AND contact_email <> '' AND contact_archived_at IS NULL ORDER BY contact_primary DESC, contact_name ASC"); while ($row = mysqli_fetch_assoc($sql)) { $recipients[] = $row; } $titles = [ 'Credential' => ['fa-key', 'Share ' . escapeHtml($item_label) . ''], 'Document' => ['fa-file-alt', 'Share ' . escapeHtml($item_label) . ''], 'File' => ['fa-paperclip', 'Share ' . escapeHtml($item_label) . ''], 'Export' => ['fa-book', 'Share the IT documentation'], 'Note' => ['fa-user-secret', 'Send a secure note'], 'Request' => ['fa-inbox', 'Ask for a login'], ]; [$title_icon, $title_html] = $titles[$type]; $intros = [ 'Credential' => 'They get a link to the username and password' . ($has_otp ? ', and the 2FA code if you include it' : '') . '. What they see is fixed now - changing the credential later does not change the link.', 'Document' => 'They get a link to read the document as it is when they open it, and print it.', 'File' => 'They get a link to download the file.', 'Export' => 'They get a link to download the documentation PDF - a cover, contents, an overview with the key contacts, then a chapter for each part you pick. It is made now, so changes after this are not in it, and kept encrypted until the link stops working.', 'Note' => 'Type a password, a recovery key or anything else private. It is encrypted, and only the link opens it - it is not saved anywhere else.', 'Request' => 'They get a form for the website, username, password and 2FA secret. What they send is encrypted, and you save it to the client\'s credentials from Shared Links.', ]; ob_start(); ?>