CHANGE_CLAIM_DRIVE_VIEW_URL_CONVERT_TO_DOWNLOAD_URL

This commit is contained in:
VENKATESHWARAN 2026-01-27 11:39:28 +05:30
parent e0eeb42779
commit a219dce42e
3 changed files with 38 additions and 6 deletions

View File

@ -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,

View File

@ -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();
// }
}

View File

@ -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;
}
}