@@ -94,6 +94,7 @@ func ServeLegacy(w http.ResponseWriter, r *http.Request) {
9494 // If it's a PHP file, let CGI handle instead
9595 for _ , ext := range serverSettings .ExtScriptTypes {
9696 if filepath .Ext (filePath ) == "." + ext {
97+ fmt .Printf ("[Legacy] Executing script file: %s\n " , filepath .ToSlash (filePath ))
9798 zipfs .Cgi (w , r , serverSettings .PhpCgiPath , filePath )
9899 return
99100 }
@@ -121,6 +122,10 @@ func ServeLegacy(w http.ResponseWriter, r *http.Request) {
121122 if serverSettings .UseInfinityServer {
122123 serverUrl := strings .TrimRight (serverSettings .InfinityServerURL , "/" )
123124 for _ , filePath := range append (exactFilePaths , indexFilePaths ... ) {
125+ // Do not attempt to run server side scripts
126+ if isScriptFile (filePath ) {
127+ continue
128+ }
124129 // Create a new request to the online server
125130 relPath , err := filepath .Rel (serverSettings .LegacyHTDOCSPath , filePath )
126131 if err != nil {
@@ -148,15 +153,18 @@ func ServeLegacy(w http.ResponseWriter, r *http.Request) {
148153
149154 // 3. Special Behaviour (MAD4FP)
150155 if serverSettings .UseMad4FP {
151- // Clone the entire request, to keep headers intact for better scraping
152- liveReq := r .Clone (r .Context ())
153- liveReq .Header .Set ("User-Agent" , "Flashpoint Game Server MAD4FP" )
154- // Perform request
155- resp , err := DoWebRequest (liveReq , client , 0 )
156- // If 200, serve and save
157- if err == nil {
158- serveLiveResponse (w , resp , exactContentPath , successCloser , "MAD4FP" )
159- return
156+ // Do not attempt to run server side scripts
157+ if ! isScriptUrl (r .URL ) {
158+ // Clone the entire request, to keep headers intact for better scraping
159+ liveReq := r .Clone (r .Context ())
160+ liveReq .Header .Set ("User-Agent" , "Flashpoint Game Server MAD4FP" )
161+ // Perform request
162+ resp , err := DoWebRequest (liveReq , client , 0 )
163+ // If 200, serve and save
164+ if err == nil {
165+ serveLiveResponse (w , resp , exactContentPath , successCloser , "MAD4FP" )
166+ return
167+ }
160168 }
161169 }
162170
@@ -239,3 +247,21 @@ func DoWebRequest(r *http.Request, client *http.Client, depth int) (*http.Respon
239247 }
240248 return resp , fmt .Errorf (resp .Status )
241249}
250+
251+ func isScriptFile (filePath string ) bool {
252+ for _ , ext := range serverSettings .ExtScriptTypes {
253+ if filepath .Ext (filePath ) == "." + ext {
254+ return true
255+ }
256+ }
257+ return false
258+ }
259+
260+ func isScriptUrl (u * url.URL ) bool {
261+ for _ , ext := range serverSettings .ExtScriptTypes {
262+ if filepath .Ext (u .Path ) == "." + ext {
263+ return true
264+ }
265+ }
266+ return false
267+ }
0 commit comments