# HG changeset patch # User Nicholas Jillings # Date 1531928827 -3600 # Node ID 53d701288da5d90b5baf695e74721c22a9500834 # Parent aa4503f8c630f5657fafdbb217575a8686cf7e8f Create new php config to allow saves to be stored outside of web scope diff -r aa4503f8c630 -r 53d701288da5 php/comment_parser.php --- a/php/comment_parser.php Wed Jul 18 16:32:44 2018 +0100 +++ b/php/comment_parser.php Wed Jul 18 16:47:07 2018 +0100 @@ -1,4 +1,5 @@ \ No newline at end of file diff -r aa4503f8c630 -r 53d701288da5 php/get_filtered_count.php --- a/php/get_filtered_count.php Wed Jul 18 16:32:44 2018 +0100 +++ b/php/get_filtered_count.php Wed Jul 18 16:47:07 2018 +0100 @@ -33,7 +33,8 @@ } $files = array(); -$saves = glob("../saves/*.xml"); +$saveLocation = getSaveLocation(); +$saves = glob($saveLocation."*.xml"); if (is_array($saves)) { foreach($saves as $filename) { diff -r aa4503f8c630 -r 53d701288da5 php/get_tests.php --- a/php/get_tests.php Wed Jul 18 16:32:44 2018 +0100 +++ b/php/get_tests.php Wed Jul 18 16:47:07 2018 +0100 @@ -12,7 +12,8 @@ // XML Saves location - assumes it will be saves/ $data = array(); -$saves = glob("../saves/*.xml"); +$saveLocation = getSaveLocation(); +$saves = glob($saveLocation."*.xml"); if (is_array($saves)) { foreach($saves as $filename) { diff -r aa4503f8c630 -r 53d701288da5 php/pool.php --- a/php/pool.php Wed Jul 18 16:32:44 2018 +0100 +++ b/php/pool.php Wed Jul 18 16:47:07 2018 +0100 @@ -37,7 +37,8 @@ $waet_url = rel2abs("pool.php","http://".$_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']); -$saves = glob("../saves/*.xml"); +$saveLocation = getSaveLocation(); +$saves = glob($saveLocation."*.xml"); if (is_array($saves)) { foreach($saves as $filename) { diff -r aa4503f8c630 -r 53d701288da5 php/pseudo.php --- a/php/pseudo.php Wed Jul 18 16:32:44 2018 +0100 +++ b/php/pseudo.php Wed Jul 18 16:47:07 2018 +0100 @@ -16,15 +16,16 @@ } else { $dir = $_GET["dir"]; } - -$files = glob('../saves/' . $prefix . '*.xml'); +$saveLocation = getSaveLocation(); +$files = glob($saveLocation . $prefix . '*.xml'); $numsaves = 0; if ( $files !== false ) { $numsaves = count( $files ); } -$files = glob('../tests/' . $dir . '*.xml'); +$testLocation = getTestLocation(); +$files = glob($testLocation . $dir . '*.xml'); $numtests = 0; if ( $numtests !== false ) diff -r aa4503f8c630 -r 53d701288da5 php/requestKey.php --- a/php/requestKey.php Wed Jul 18 16:32:44 2018 +0100 +++ b/php/requestKey.php Wed Jul 18 16:47:07 2018 +0100 @@ -57,8 +57,8 @@ $key = $tempKey; } } - -$filename = "../saves/".$saveFilenamePrefix.$key.".xml"; +$saveLocation = getSaveLocation(); +$filename = $saveLocation.$saveFilenamePrefix.$key.".xml"; $fileHandle = fopen($filename, 'w'); if ($fileHandle == FALSE) { die("ERROR".$key."Could not open file for writing"); diff -r aa4503f8c630 -r 53d701288da5 php/save.php --- a/php/save.php Wed Jul 18 16:32:44 2018 +0100 +++ b/php/save.php Wed Jul 18 16:47:07 2018 +0100 @@ -39,10 +39,12 @@ $update = $_GET["update"] == "update"; } +$saveLocation = getSaveLocation(); + if ($update) { - $filename = '../saves/update-'.$saveFilenamePrefix.$file_key.".xml"; + $filename = $saveLocation.'update-'.$saveFilenamePrefix.$file_key.".xml"; } else { - $filename = '../saves/'.$saveFilenamePrefix.$file_key.".xml"; + $filename = $saveLocation.$saveFilenamePrefix.$file_key.".xml"; } if (!file_exists($filename)) { @@ -144,6 +146,6 @@ echo $xml; if (!$update) { - unlink('../saves/update-'.$saveFilenamePrefix.$file_key.".xml"); + unlink($saveLocation.'update-'.$saveFilenamePrefix.$file_key.".xml"); } ?> diff -r aa4503f8c630 -r 53d701288da5 php/score_parser.php --- a/php/score_parser.php Wed Jul 18 16:32:44 2018 +0100 +++ b/php/score_parser.php Wed Jul 18 16:47:07 2018 +0100 @@ -51,7 +51,8 @@ $root = new nestedObject("root"); // XML Saves location - assumes it will be saves/ -$saves = glob("../saves/*.xml"); +$saveLocation = getSaveLocation(); +$saves = glob($saveLocation."*.xml"); if (is_array($saves)) { foreach($saves as $filename) { diff -r aa4503f8c630 -r 53d701288da5 php/test_write.php --- a/php/test_write.php Wed Jul 18 16:32:44 2018 +0100 +++ b/php/test_write.php Wed Jul 18 16:47:07 2018 +0100 @@ -1,5 +1,6 @@ "); if ($state == FALSE) { echo "Could not open file";