Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

Bug - config.php does not load on windows #15

Open
tanaaKa opened this issue Mar 2, 2018 · 14 comments
Open

Bug - config.php does not load on windows #15

tanaaKa opened this issue Mar 2, 2018 · 14 comments

Comments

@tanaaKa
Copy link

tanaaKa commented Mar 2, 2018

Issue:
We've been using R3 for a year now and recently switched from a linux to a windows server. After installing new R3 files and new db's to the new server, the web interface is no longer working.

Versions:
Apache 2.4 from https://httpd.apache.org/
PHP7

Files:
Httpd.conf attached
PHP.ini attached
config.php attached

@tanaaKa
Copy link
Author

tanaaKa commented Mar 2, 2018

files.zip

@alexcroox
Copy link
Owner

Apologies the code in master isn't particularly resilient to Windows web servers and I've not had a chance to test and update.

In this file and line: https://github.com/alexcroox/R3-Web/blob/master/dist/inc/bootstrap.php#L7

Try changing to $path = substr($dir, 0, strrpos($dir, "\\"));

@tanaaKa
Copy link
Author

tanaaKa commented Mar 2, 2018

Dev server in question: http://149.56.106.43/aar/

Okay, so it seems we just get a white screen with
$path = substr($dir, 0, strrpos($dir, "\\"));
and the UI doesn't appear.

However, with
$path = substr($dir, 0, strrpos($dir, "/"));
the bootstrap doesn't initialize.

@tanaaKa tanaaKa changed the title Bug - config.php does not load Bug - config.php does not load on windows Mar 2, 2018
@alexcroox
Copy link
Owner

That link 500's, what do your web server error logs say?

@tanaaKa
Copy link
Author

tanaaKa commented Mar 2, 2018

PHP Fatal error: Maximum execution time of 30 seconds exceeded in C:\\Apache24\\htdocs\\aar\\inc\\classes\\Replays.php on line 252

Im changing max execution time now to see if it changes anything.

@alexcroox
Copy link
Owner

It's terrible advice and a horrible fix but you could temporarily add

ini_set('max_execution_time', 300);
ini_set('memory_limit','1600M');

to the top of that class. Sounds like it has a lot of events and missions to initially cache at once and is timing out. Adding that should give it the time to work it out all then cache the result (future reloads should be faster).

@tanaaKa
Copy link
Author

tanaaKa commented Mar 2, 2018

That seems to have fixed it. Extremely weird. This is why I choose to stay away from php 🤐. Thanks a bunch alex and keep on with R3. It is invaluable.

@alexcroox
Copy link
Owner

The issue here isn’t with php but my poorly thought out initial version of R3 :)

That’s why in the rewrite branch I started with an established framework and a more scalable approach to data fetching.

@tanaaKa
Copy link
Author

tanaaKa commented Mar 2, 2018

One more issue, as I believe it's in relation to this:

All playbacks return a 404. Example:
http://149.56.106.43/aar/62/cmf44-co66-krampuseve

Specifically, it's pointing to a dir that doesn't exist for some raisin. Not sure why this would be.

@alexcroox
Copy link
Owner

I don't know much about IIS but someone in Discord converted htaccess to webconfig(?)

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="^(.*)/$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Redirect" url="/{R:1}" redirectType="Permanent" />
                </rule>
                <rule name="Imported Rule 2" stopProcessing="true">
                    <match url="^share/([0-9]+)$" ignoreCase="false" />
                    <action type="Rewrite" url="share.php?shareId={R:1}" appendQueryString="true" />
                </rule>
                <rule name="Imported Rule 3" stopProcessing="true">
                    <match url="^([0-9]+)/?([^/]*)$" ignoreCase="false" />
                    <action type="Rewrite" url="playback.php?replayId={R:1}" appendQueryString="true" />
                </rule>
                <rule name="Imported Rule 4" stopProcessing="true">
                    <match url="^([^.]+)$" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{SCRIPT_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="{R:1}.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

@tanaaKa
Copy link
Author

tanaaKa commented Mar 2, 2018

Perfect. Now the replays just aren't playing due to timeout it seems. Waited about ~10minutes for this link to load to no avail:
http://149.56.106.43/aar/61/cmf44-co60-risingfury1-1v3

The only issue seems to be PHP Warning: file_get_contents(https://r3icons.titanmods.xyz/markers.json): failed to open stream: No such file or directory in C:\\Apache24\\htdocs\\aar\\inc\\classes\\Replays.php on line 282, referer: http://149.56.106.43/aar/

@alexcroox
Copy link
Owner

In your php config do you have allow_url_fopen = On?

@tanaaKa
Copy link
Author

tanaaKa commented Mar 3, 2018

Yes it does.

@lubomirblazekcz
Copy link

lubomirblazekcz commented Mar 30, 2018

We had problems with allow_url_fopen that was set false with our hosting provider, I resolved this by loading the json files via javascript on frontend

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
    function loadJSON(url){
      return JSON.stringify(Promise.resolve($.getJSON(url)));
    }

    var objectiveMarkersConfig = loadJSON("https://r3icons.titanmods.xyz/markers.json");
    var icons = loadJSON("https://r3icons.titanmods.xyz/config.json");
    var replayDetails = <?php echo json_encode($replayDetails); ?>;
    var sharedPresets = <?php echo strip_tags(json_encode($sharedPresets)); ?>;
    var playerList = <?php echo strip_tags(json_encode($playerList)); ?>;
    var cacheAvailable = <?php echo json_encode($cacheAvailable); ?>;
    var mappingConfig = loadJSON("https://r3tiles-a.titanmods.xyz/config.json");
</script>

We also had problems with filenames in inc/classes/, they were lowercased via ftp upload. But we got it all working now, and it works great!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants