Hello friends,
Best regards,
Otto
/* DOS2Web( input )
The `DOS2Web` function converts a local file system path to a web URL.
It constructs the base URL from the server's HTTPS status and host name.
It adjusts the local path by removing any trailing slashes and replacing backslashes with forward slashes.
Then, it substitutes the local server path (from `DOCUMENT_ROOT`) with the base URL to create the web-accessible URL.
The resulting URL is returned, representing the web path equivalent of the input DOS path.
This function is typically used in a web server environment like mod_harbour to reference local resources in a web-accessible format. */
function DOSPath2Web( input )
local result := ""
local cbase_url := ""
local chtdocspath := LOWER( ALLTRIM( AP_GetEnv( "DOCUMENT_ROOT" ) ))
if AP_GetEnv( "HTTPS" ) = "on"
cbase_url := "https://"
endif
cbase_url += AP_HeadersIn()["Host"]
if RIGHT( chtdocspath, 1) = '/'
chtdocspath := left( chtdocspath , ( len(chtdocspath) - 1) )
endif
input := STRTRAN( input, '', '/' )
result := STRTRAN( (input), (chtdocspath), cbase_url )
return ( result )
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 53 guests