diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 7dee25b6..7a0d1ae9 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -2789,7 +2789,7 @@ class TicketController extends BaseController $insertData = [ 'doc_name' => $data['docs_name'][$key] ?? '', - 'url' => $data['url'][$key] ?? '', + 'url' => convertGoogleDriveToDownloadLink($data['url'][$key] ?? ''), 'ticket_id' => $data['ticket_id_url'] ?? '', 'created_by' => get_session_userid(), 'is_active' => 1, diff --git a/app/Filters/AuthMVC.php b/app/Filters/AuthMVC.php index ef2da046..298a72b9 100755 --- a/app/Filters/AuthMVC.php +++ b/app/Filters/AuthMVC.php @@ -23,11 +23,11 @@ class AuthMVC implements FilterInterface // } // Fingerprint validation - $fp = generateFingerprint(); - // log_message('error',$fp); - if (session()->get('fingerprint') !== $fp) { - return AuthLogout::logout(); - } + // $fp = generateFingerprint(); + // // log_message('error',$fp); + // if (session()->get('fingerprint') !== $fp) { + // return AuthLogout::logout(); + // } } diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php index 9e7f4791..dc7ba8b2 100755 --- a/app/Helpers/utility_helper.php +++ b/app/Helpers/utility_helper.php @@ -1067,3 +1067,35 @@ function generateFingerprint() // return hash('sha256', $ua . '|' . $ipSubnet . '|' . $secret); return hash('sha256', $ua . '|' . $ipSubnet ); } + +if (!function_exists('convertGoogleDriveToDownloadLink')) { + function convertGoogleDriveToDownloadLink(?string $url): ?string + { + if (empty($url)) { + return null; + } + + // Trim spaces + $url = trim($url); + + // Pattern to extract Google Drive file ID + $patterns = [ + '#https?://drive\.google\.com/file/d/([^/]+)/?#', + '#https?://drive\.google\.com/open\?id=([^&]+)#', + '#https?://drive\.google\.com/uc\?id=([^&]+)#' + ]; + + foreach ($patterns as $pattern) { + if (preg_match($pattern, $url, $matches)) { + $fileId = $matches[1]; + + // Return direct download link + return 'https://drive.google.com/uc?export=download&id=' . $fileId; + } + } + + // Not a Google Drive link → return original + return $url; + } +} +