Mercurial > hg > webaudioevaluationtool
diff php/get_filtered_count.php @ 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 | 760719986df3 |
children | d26623bd65e0 |
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)) {