Mercurial > hg > webaudioevaluationtool
changeset 2283:169f08dc9634
Fix for #25, PHP uses the array() function rather than the [] initialiser (only supported if PHP >= 5.4)
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Fri, 22 Apr 2016 09:34:34 +0100 |
parents | 185232d01324 |
children | 29e754aca00f |
files | php/get_filtered_count.php php/get_tests.php php/pool.php |
diffstat | 3 files changed, 11 insertions(+), 66 deletions(-) [+] |
line wrap: on
line diff
--- a/php/get_filtered_count.php Wed Apr 20 21:41:49 2016 +0200 +++ b/php/get_filtered_count.php Fri Apr 22 09:34:34 2016 +0100 @@ -1,33 +1,6 @@ <?php //http://stackoverflow.com/questions/4444475/transfrom-relative-path-into-absolute-url-using-php -function rel2abs($rel, $base) -{ - /* return if already absolute URL */ - if (parse_url($rel, PHP_URL_SCHEME) != '' || substr($rel, 0, 2) == '//') return $rel; - - /* queries and anchors */ - if ($rel[0]=='#' || $rel[0]=='?') return $base.$rel; - - /* parse base URL and convert to local variables: - $scheme, $host, $path */ - extract(parse_url($base)); - - /* remove non-directory element from path */ - $path = preg_replace('#/[^/]*$#', '', $path); - - /* destroy path if relative url points to root */ - if ($rel[0] == '/') $path = ''; - - /* dirty absolute URL */ - $abs = "$host$path/$rel"; - - /* replace '//' or '/./' or '/foo/../' with '/' */ - $re = array('#(/\.?/)#', '#/(?!\.\.)[^/]+/\.\./#'); - for($n=1; $n>0; $abs=preg_replace($re, '/', $abs, -1, $n)) {} - - /* absolute URL is ready! */ - return $scheme.'://'.$abs; -} +include "rel2abs.php"; /* This looks for files that pass the filtering response @@ -38,25 +11,25 @@ max - Maximum Inclusive exclude-# - exclude, followed by a number to uniquely add, (will create a triple [], ignore the third as random) */ -$keys = []; +$keys = array(); $waet_url = null; foreach ($_GET as $key => $value) { $key = explode("-",$key); if ($key[0] == "url") { $waet_url = $value; } else { - $v_pair = [$key[1],$value]; + $v_pair = array($key[1],$value); if(array_key_exists($key[0],$keys)) { // We have some data array_push($keys[$key[0]],$v_pair); } else { // Create new key data - $keys[$key[0]] = [$v_pair]; + $keys[$key[0]] = array($v_pair); } } } -$files = []; +$files = array(); $saves = glob("../saves/*.xml"); if (is_array($saves)) {
--- a/php/get_tests.php Wed Apr 20 21:41:49 2016 +0200 +++ b/php/get_tests.php Fri Apr 22 09:34:34 2016 +0100 @@ -5,38 +5,10 @@ This script returns the XML test names available, plus the number of tests */ -//http://stackoverflow.com/questions/4444475/transfrom-relative-path-into-absolute-url-using-php -function rel2abs($rel, $base) -{ - /* return if already absolute URL */ - if (parse_url($rel, PHP_URL_SCHEME) != '' || substr($rel, 0, 2) == '//') return $rel; - - /* queries and anchors */ - if ($rel[0]=='#' || $rel[0]=='?') return $base.$rel; - - /* parse base URL and convert to local variables: - $scheme, $host, $path */ - extract(parse_url($base)); - - /* remove non-directory element from path */ - $path = preg_replace('#/[^/]*$#', '', $path); - - /* destroy path if relative url points to root */ - if ($rel[0] == '/') $path = ''; - - /* dirty absolute URL */ - $abs = "$host$path/$rel"; - - /* replace '//' or '/./' or '/foo/../' with '/' */ - $re = array('#(/\.?/)#', '#/(?!\.\.)[^/]+/\.\./#'); - for($n=1; $n>0; $abs=preg_replace($re, '/', $abs, -1, $n)) {} - - /* absolute URL is ready! */ - return $scheme.'://'.$abs; -} +include "rel2abs.php"; // XML Saves location - assumes it will be saves/ -$data = []; +$data = array(); $saves = glob("../saves/*.xml"); if (is_array($saves)) { @@ -52,7 +24,7 @@ array_push($data[$testName],$filename); } else { // Key does not exist - $data[$testName] = [$filename]; + $data[$testName] = array($filename); } } }
--- a/php/pool.php Wed Apr 20 21:41:49 2016 +0200 +++ b/php/pool.php Fri Apr 22 09:34:34 2016 +0100 @@ -17,7 +17,7 @@ // Note this is relative to the PHP location // First set up the store with all the test page key nodes -$pages = []; +$pages = array(); $master_xml = simplexml_load_string(file_get_contents($master_file, FILE_TEXT)); if ($master_xml) { if (!isset($master_xml->setup["poolSize"])) @@ -72,12 +72,12 @@ $root->appendChild($dom_setup); // We must now extract the number which have been performed the least -$rot_pages = []; +$rot_pages = array(); foreach($pages as $key => $var) if(array_key_exists($var,$rot_pages)) { array_push($rot_pages[$var],$key); } else { - $rot_pages[$var] = [$key]; + $rot_pages[$var] = array($key); } ksort($rot_pages); $Keys = array_keys($rot_pages);