Hi everyone. I'm new to PHP and trying to wrap my arms around it. I have been coding with ASP for a while and the best way for my personal learning style is to take and example I'm familiar with and see a conversion so I can get a good understanding of what the code is doing.
I have this ASP code that checks the referring URL. If its from a specific URL, I generate certain HTML. If not, I generate different HTML. Can someone help me translate this to PHP?
Code:
<%
const ValidReferers = "somedomain.com, somedomain"
Function CheckReferer()
dim arURLs, tmpCount, boolValidURL
dim strURL, nIndex
arURLs = Split(ValidReferers, ", ")
boolValidURL = False
strURL = Request.ServerVariables("HTTP_REFERER")
Response.Write strURL & "<br>"
If LCase(Left(strURL,11)) = "http://www." Then strURL = Mid(strURL,12)
If LCase(Left(strURL,12)) = "https://www." Then strURL = Mid(strURL,13)
nIndex = InStr( strURL, "/")
If nIndex > 0 Then strURL = Left(strURL,nIndex-1)
For tmpCount = 0 To UBound(arURLs)
If strURL = arURLs(tmpCount) Then boolValidURL = True
Next
CheckReferer = boolValidURL
End Function
If CheckReferer Then
'the URL is ok - do rest of processing
Response.Write strURL & " is good <br>"
%>
Do HTML Stuff here
<%
Else
'referring url is bad. Spit out an error message
Response.Write strURL & " is bad"
%>
Do HTML stuff here
<%
End If
%>
Thanks in advance!