mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
Updated Share Model to have an Expire selection instead of selecting a date and time, also share link will now email a chosen contact that has a valid email with the secure link, along with notifications when link is clicked. The Link now adds the https:// in the beginning for easy copy paste
This commit is contained in:
27
ajax.php
27
ajax.php
@@ -230,6 +230,7 @@ if (isset($_GET['share_generate_link'])) {
|
||||
$client_id = intval($_GET['client_id']);
|
||||
$item_type = sanitizeInput($_GET['type']);
|
||||
$item_id = intval($_GET['id']);
|
||||
$item_email = sanitizeInput($_GET['contact_email']);
|
||||
$item_note = sanitizeInput($_GET['note']);
|
||||
$item_view_limit = intval($_GET['views']);
|
||||
$item_expires = sanitizeInput($_GET['expires']);
|
||||
@@ -266,18 +267,38 @@ if (isset($_GET['share_generate_link'])) {
|
||||
}
|
||||
|
||||
// Insert entry into DB
|
||||
$sql = mysqli_query($mysqli, "INSERT INTO shared_items SET item_active = 1, item_key = '$item_key', item_type = '$item_type', item_related_id = $item_id, item_encrypted_username = '$item_encrypted_username', item_encrypted_credential = '$item_encrypted_credential', item_note = '$item_note', item_views = 0, item_view_limit = $item_view_limit, item_expire_at = '$item_expires', item_client_id = $client_id");
|
||||
$sql = mysqli_query($mysqli, "INSERT INTO shared_items SET item_active = 1, item_key = '$item_key', item_type = '$item_type', item_related_id = $item_id, item_encrypted_username = '$item_encrypted_username', item_encrypted_credential = '$item_encrypted_credential', item_note = '$item_note', item_views = 0, item_view_limit = $item_view_limit, item_expire_at = NOW() + INTERVAL + $item_expires, item_client_id = $client_id");
|
||||
$share_id = $mysqli->insert_id;
|
||||
|
||||
// Return URL
|
||||
if ($item_type == "Login") {
|
||||
$url = "$config_base_url/guest_view_item.php?id=$share_id&key=$item_key&ek=$login_encryption_key";
|
||||
$url = "https://$config_base_url/guest_view_item.php?id=$share_id&key=$item_key&ek=$login_encryption_key";
|
||||
}
|
||||
else {
|
||||
$url = "$config_base_url/guest_view_item.php?id=$share_id&key=$item_key";
|
||||
$url = "https://$config_base_url/guest_view_item.php?id=$share_id&key=$item_key";
|
||||
}
|
||||
|
||||
// Send user e-mail, if specified
|
||||
if(!empty($config_smtp_host) && filter_var($item_email, FILTER_VALIDATE_EMAIL)){
|
||||
|
||||
$subject = "Time sensitive encrypted link enclosed";
|
||||
$body = "Hello,<br><br>$session_name from $session_company_name sent you a time sensitive encrypted link which will expire in <strong>$item_expires</strong> and may only be viewed <strong>$item_view_limit</strong> times, before the link is destroyed. The sender will recieved a notification when the link is viewed. Please click the link below to view your shared secret<br><br><strong><a href='$url'>Click Here</a></strong><br><br>~<br>$session_company_name<br>Support Department<br>$config_ticket_from_email";
|
||||
|
||||
$mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port,
|
||||
$config_ticket_from_email, $config_ticket_from_name,
|
||||
$item_email, $item_email,
|
||||
$subject, $body);
|
||||
|
||||
if ($mail !== true) {
|
||||
mysqli_query($mysqli,"INSERT INTO notifications SET notification_type = 'Mail', notification = 'Failed to send email to $item_email'");
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Mail', log_action = 'Error', log_description = 'Failed to send email to $item_email regarding $subject. $item_mail', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo json_encode($url);
|
||||
|
||||
|
||||
// Logging
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Sharing', log_action = 'Create', log_description = '$session_name created shared link for $item_type - $item_name', log_client_id = $client_id, log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user