@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | function init_conn($user, $passwd, $host, $name, $readonly) { |
| 30 | 30 | if (MYSQLI) { |
| 31 | 31 | $x = explode(":", $host); |
| 32 | - if (sizeof($x)>1) { |
|
| 32 | + if (sizeof($x) > 1) { |
|
| 33 | 33 | $host = $x[0]; |
| 34 | 34 | $port = $x[1]; |
| 35 | 35 | } else { |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | $where_clause = "where $where_clause"; |
| 144 | 144 | } |
| 145 | 145 | $query = "select $fields from DBNAME.$table $where_clause $order_clause"; |
| 146 | - return $this->enum_general($classname,$query); |
|
| 146 | + return $this->enum_general($classname, $query); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - function enum($table, $classname, $where_clause=null, $order_clause=null) { |
|
| 149 | + function enum($table, $classname, $where_clause = null, $order_clause = null) { |
|
| 150 | 150 | return self::enum_fields( |
| 151 | 151 | $table, $classname, '*', $where_clause, $order_clause |
| 152 | 152 | ); |
@@ -205,15 +205,15 @@ discard block |
||
| 205 | 205 | if ($x) return (double)$x->$field; |
| 206 | 206 | return false; |
| 207 | 207 | } |
| 208 | - function count($table, $clause="TRUE") { |
|
| 208 | + function count($table, $clause = "TRUE") { |
|
| 209 | 209 | $query = "select count(*) as total from DBNAME.$table where $clause"; |
| 210 | 210 | return $this->get_int($query, 'total'); |
| 211 | 211 | } |
| 212 | - function sum($table, $field, $clause="") { |
|
| 212 | + function sum($table, $field, $clause = "") { |
|
| 213 | 213 | $query = "select sum($field) as total from DBNAME.$table $clause"; |
| 214 | 214 | return $this->get_double($query, 'total'); |
| 215 | 215 | } |
| 216 | - function max($table, $field, $clause="") { |
|
| 216 | + function max($table, $field, $clause = "") { |
|
| 217 | 217 | $query = "select max($field) as total from DBNAME.$table $clause"; |
| 218 | 218 | return $this->get_double($query, 'total'); |
| 219 | 219 | } |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | mkdir("../cache", 0770); |
| 33 | 33 | chmod("../cache", 0770); |
| 34 | 34 | } |
| 35 | - for ($i=0;$i<256;$i++) { |
|
| 36 | - $j=sprintf("%02x",$i); |
|
| 35 | + for ($i = 0; $i < 256; $i++) { |
|
| 36 | + $j = sprintf("%02x", $i); |
|
| 37 | 37 | if (!@filemtime("../cache/$j")) { |
| 38 | 38 | mkdir("../cache/$j", 0770); |
| 39 | 39 | chmod("../cache/$j", 0770); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | -function get_path($params, $phpfile=null) { |
|
| 44 | +function get_path($params, $phpfile = null) { |
|
| 45 | 45 | if (!@filemtime("../cache/00")) make_cache_dirs(); |
| 46 | 46 | if ($phpfile) { |
| 47 | 47 | $z = $phpfile; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | // add a layer of subdirectories for reducing file lookup time |
| 54 | - $sz = substr(md5($z."_".urlencode($params)),1,2); |
|
| 54 | + $sz = substr(md5($z."_".urlencode($params)), 1, 2); |
|
| 55 | 55 | $path = "../cache/".$sz."/".$z; |
| 56 | 56 | if ($params) { |
| 57 | 57 | $path = $path."_".urlencode($params); |
@@ -60,14 +60,14 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | function disk_usage($dir) { |
| 63 | - $usage=0; |
|
| 64 | - if ($handle=@opendir($dir)) { |
|
| 65 | - while ($file=readdir($handle)) { |
|
| 63 | + $usage = 0; |
|
| 64 | + if ($handle = @opendir($dir)) { |
|
| 65 | + while ($file = readdir($handle)) { |
|
| 66 | 66 | if (($file != ".") && ($file != "..")) { |
| 67 | 67 | if (@is_dir($dir."/".$file)) { |
| 68 | - $usage+=disk_usage($dir."/".$file); |
|
| 68 | + $usage += disk_usage($dir."/".$file); |
|
| 69 | 69 | } else { |
| 70 | - $usage+=@filesize($dir."/".$file); |
|
| 70 | + $usage += @filesize($dir."/".$file); |
|
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | if (!chdir($dir)) { |
| 82 | 82 | return; |
| 83 | 83 | } |
| 84 | - if ($handle=@opendir(".")) { |
|
| 85 | - while ($file=readdir($handle)) { |
|
| 84 | + if ($handle = @opendir(".")) { |
|
| 85 | + while ($file = readdir($handle)) { |
|
| 86 | 86 | if ($file == ".") continue; |
| 87 | 87 | if ($file == "..") continue; |
| 88 | 88 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | if (@is_dir($file)) { |
| 94 | 94 | clean_cache($max_age, $file); |
| 95 | 95 | } else { |
| 96 | - if ((time()-@filemtime($file))>$max_age) { |
|
| 96 | + if ((time() - @filemtime($file)) > $max_age) { |
|
| 97 | 97 | //echo "unlinking ".getcwd()."/$file\n"; |
| 98 | 98 | @unlink($file); |
| 99 | 99 | } |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | // check cache size every once in a while, purge if too big |
| 109 | 109 | // |
| 110 | -function cache_check_diskspace(){ |
|
| 111 | - if ((rand() % CACHE_SIZE_CHECK_FREQ)) return; |
|
| 110 | +function cache_check_diskspace() { |
|
| 111 | + if ((rand()%CACHE_SIZE_CHECK_FREQ)) return; |
|
| 112 | 112 | if (disk_usage("../cache") < MAX_CACHE_USAGE) return; |
| 113 | 113 | $x = max(TEAM_PAGE_TTL, USER_PAGE_TTL, USER_HOST_TTL, |
| 114 | 114 | USER_PROFILE_TTL, TOP_PAGES_TTL, INDEX_PAGE_TTL |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | clean_cache($x, "../cache"); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | -function cache_need_to_regenerate($path, $max_age){ |
|
| 119 | +function cache_need_to_regenerate($path, $max_age) { |
|
| 120 | 120 | $regenerate = false; |
| 121 | 121 | $request = apache_request_headers(); |
| 122 | 122 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | // and touch the cached copy so other processes |
| 129 | 129 | // don't regenerate at the same time |
| 130 | 130 | // |
| 131 | - if ($lastmodified<time()-$max_age) { |
|
| 131 | + if ($lastmodified < time() - $max_age) { |
|
| 132 | 132 | $regenerate = true; |
| 133 | 133 | @touch($path); |
| 134 | 134 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | // Returns cached data or false if nothing was found |
| 142 | -function get_cached_data($max_age, $params=""){ |
|
| 142 | +function get_cached_data($max_age, $params = "") { |
|
| 143 | 143 | global $no_cache; |
| 144 | 144 | |
| 145 | 145 | if ($no_cache) return; |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | } |
| 156 | 156 | } else { |
| 157 | 157 | cache_check_diskspace(); |
| 158 | - $regenerate=cache_need_to_regenerate($path, $max_age); |
|
| 158 | + $regenerate = cache_need_to_regenerate($path, $max_age); |
|
| 159 | 159 | if (!$regenerate) { |
| 160 | 160 | return file_get_contents($path); |
| 161 | 161 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | // DEPRECATED |
| 168 | -function start_cache($max_age, $params=""){ |
|
| 168 | +function start_cache($max_age, $params = "") { |
|
| 169 | 169 | global $no_cache, $caching, $memcache; |
| 170 | 170 | |
| 171 | 171 | if ($no_cache) return; |
@@ -188,15 +188,15 @@ discard block |
||
| 188 | 188 | $regenerate = cache_need_to_regenerate($path, $max_age); |
| 189 | 189 | } |
| 190 | 190 | //Is the stored version too old, do we need to regenerate it? |
| 191 | - if ($regenerate){ |
|
| 191 | + if ($regenerate) { |
|
| 192 | 192 | // If cached version is too old (or non-existent) |
| 193 | 193 | // generate the page and write to cache |
| 194 | 194 | // |
| 195 | 195 | ob_start(); |
| 196 | 196 | ob_implicit_flush(0); |
| 197 | - Header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
| 198 | - Header("Expires: " . gmdate("D, d M Y H:i:s",time()+$max_age) . " GMT"); |
|
| 199 | - Header("Cache-Control: public, max-age=" . $max_age); |
|
| 197 | + Header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
| 198 | + Header("Expires: ".gmdate("D, d M Y H:i:s", time() + $max_age)." GMT"); |
|
| 199 | + Header("Cache-Control: public, max-age=".$max_age); |
|
| 200 | 200 | |
| 201 | 201 | // allow the calling page to see cache period |
| 202 | 202 | // |
@@ -208,9 +208,9 @@ discard block |
||
| 208 | 208 | if (strstr($params, "format=xml")) { |
| 209 | 209 | header('Content-type: text/xml'); |
| 210 | 210 | } |
| 211 | - Header("Last-Modified: " . gmdate("D, d M Y H:i:s",$lastmodified) . " GMT"); |
|
| 212 | - Header("Expires: " . gmdate("D, d M Y H:i:s",$lastmodified+$max_age) . " GMT"); |
|
| 213 | - Header("Cache-Control: public, max-age=" . $max_age ); |
|
| 211 | + Header("Last-Modified: ".gmdate("D, d M Y H:i:s", $lastmodified)." GMT"); |
|
| 212 | + Header("Expires: ".gmdate("D, d M Y H:i:s", $lastmodified + $max_age)." GMT"); |
|
| 213 | + Header("Cache-Control: public, max-age=".$max_age); |
|
| 214 | 214 | if ($cache && $cache->content) { |
| 215 | 215 | echo $cache->content; |
| 216 | 216 | exit; |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | // write output buffer both to client and to cache |
| 230 | 230 | // DEPRECATED |
| 231 | -function end_cache($max_age,$params=""){ |
|
| 231 | +function end_cache($max_age, $params = "") { |
|
| 232 | 232 | global $no_cache; |
| 233 | 233 | if ($no_cache) return; |
| 234 | 234 | |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | -function set_cached_data($max_age, $data, $params=""){ |
|
| 256 | +function set_cached_data($max_age, $data, $params = "") { |
|
| 257 | 257 | // for the benefit of hackers |
| 258 | 258 | if (strstr($params, "..")) { |
| 259 | 259 | return "bad params"; |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | self::$instance->setOption(Memcached::OPT_PREFIX_KEY, MEMCACHE_PREFIX); |
| 295 | 295 | } |
| 296 | 296 | $servers = explode('|', MEMCACHE_SERVERS); |
| 297 | - foreach($servers as &$server) { |
|
| 297 | + foreach ($servers as &$server) { |
|
| 298 | 298 | list($ip, $port) = explode(':', $server); |
| 299 | 299 | if (!$port) { $port = 11211; } |
| 300 | 300 | $server = array($ip, $port); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | if ($fp_total) { |
| 76 | - $batch->fraction_done = $fp_done / $fp_total; |
|
| 76 | + $batch->fraction_done = $fp_done/$fp_total; |
|
| 77 | 77 | } |
| 78 | 78 | if ($completed && $batch->state == BATCH_STATE_IN_PROGRESS) { |
| 79 | 79 | $batch->state = BATCH_STATE_COMPLETE; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | // get the total size of output files of a batch |
| 160 | 160 | // |
| 161 | 161 | function batch_output_file_size($batchid) { |
| 162 | - $batch_td_size=0; |
|
| 162 | + $batch_td_size = 0; |
|
| 163 | 163 | $wus = BoincWorkunit::enum("batch=$batchid"); |
| 164 | 164 | $fanout = parse_config(get_config(), "<uldl_dir_fanout>"); |
| 165 | 165 | $upload_dir = parse_config(get_config(), "<upload_dir>"); |
@@ -170,9 +170,9 @@ discard block |
||
| 170 | 170 | foreach ($names as $name) { |
| 171 | 171 | $path = dir_hier_path($name, $upload_dir, $fanout); |
| 172 | 172 | if (is_file($path)) { |
| 173 | - $s=stat($path); |
|
| 174 | - $size=$s['size']; |
|
| 175 | - $batch_td_size+=$size; |
|
| 173 | + $s = stat($path); |
|
| 174 | + $size = $s['size']; |
|
| 175 | + $batch_td_size += $size; |
|
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | function boinc_get_wu_output_files_url($user, $wu_id) { |
| 194 | - $auth_str = md5($user->authenticator.$wu_id); |
|
| 194 | + $auth_str = md5($user->authenticator.$wu_id); |
|
| 195 | 195 | return "get_output.php?cmd=workunit_files&wu_id=$wu_id&auth_str=$auth_str"; |
| 196 | 196 | } |
| 197 | 197 | |
@@ -27,11 +27,11 @@ discard block |
||
| 27 | 27 | function birth_year_select($user) { |
| 28 | 28 | $this_year = date("Y"); |
| 29 | 29 | $x = "<select name=birth_year>\n"; |
| 30 | - for ($i=$this_year-100; $i<$this_year; $i++) { |
|
| 31 | - $s = ($i == $user->bolt->birth_year)?"selected":""; |
|
| 30 | + for ($i = $this_year - 100; $i < $this_year; $i++) { |
|
| 31 | + $s = ($i == $user->bolt->birth_year) ? "selected" : ""; |
|
| 32 | 32 | $x .= "<option value=$i $s>$i</option>\n"; |
| 33 | 33 | } |
| 34 | - $s = (!$user->bolt->birth_year)?"selected":""; |
|
| 34 | + $s = (!$user->bolt->birth_year) ? "selected" : ""; |
|
| 35 | 35 | $x .= "<option value=$0 $s>Unspecified</option>\n"; |
| 36 | 36 | $x .= "</select>\n"; |
| 37 | 37 | return $x; |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | function sex_select($user) { |
| 41 | 41 | $x = "<select name=sex>\n"; |
| 42 | - $s = ($user->bolt->sex == 0)?"selected":""; |
|
| 42 | + $s = ($user->bolt->sex == 0) ? "selected" : ""; |
|
| 43 | 43 | $x .= "<option value=0 $s>Unspecified</option>\n"; |
| 44 | - $s = ($user->bolt->sex == 1)?"selected":""; |
|
| 44 | + $s = ($user->bolt->sex == 1) ? "selected" : ""; |
|
| 45 | 45 | $x .= "<option value=1 $s>Male</option>\n"; |
| 46 | - $s = ($user->bolt->sex == 2)?"selected":""; |
|
| 46 | + $s = ($user->bolt->sex == 2) ? "selected" : ""; |
|
| 47 | 47 | $x .= "<option value=2 $s>Female</option>\n"; |
| 48 | 48 | $x .= "</select>\n"; |
| 49 | 49 | return $x; |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | // Return path of sandbox directory for the given user. |
| 26 | 26 | // Create dir if not present. |
| 27 | 27 | // |
| 28 | -if (!function_exists("sandbox_dir")){ |
|
| 28 | +if (!function_exists("sandbox_dir")) { |
|
| 29 | 29 | function sandbox_dir($user) { |
| 30 | 30 | $dir = parse_config(get_config(), "<sandbox_dir>"); |
| 31 | 31 | if (!$dir) { $dir = "../../sandbox/"; } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | foreach ($files as $file) { |
| 55 | 55 | $path = $dir."/".$file; |
| 56 | 56 | list($err, $file_size, $file_md5) = sandbox_parse_link_file($path); |
| 57 | - if (!$err){ |
|
| 57 | + if (!$err) { |
|
| 58 | 58 | if (strcmp($md5, $file_md5) == 0) { |
| 59 | 59 | //echo "this file with $md5 already exisits with another name $file"; |
| 60 | 60 | $exist = 1; |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | $files = sandbox_file_names($user); |
| 127 | 127 | foreach ($files as $f) { |
| 128 | - if(preg_match("/$regexp/",$f)){ |
|
| 128 | + if (preg_match("/$regexp/", $f)) { |
|
| 129 | 129 | $x .= "<option value=\"$f\">$f</option>\n"; |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | //check if a file is still being used by a unfinished batch |
| 138 | 138 | // |
| 139 | -function sandbox_file_in_use($user, $file){ |
|
| 139 | +function sandbox_file_in_use($user, $file) { |
|
| 140 | 140 | $ufiles = array(); |
| 141 | 141 | |
| 142 | 142 | // batch status: 2(completed), 3(aborted) |
@@ -144,17 +144,17 @@ discard block |
||
| 144 | 144 | $pbatches = BoincBatch::enum("user_id = $user->id and state != 2 and state != 3"); |
| 145 | 145 | if (!$pbatches) return false; |
| 146 | 146 | |
| 147 | - foreach ($pbatches as $batch){ |
|
| 148 | - $wus = BoincWorkUnit::enum("batch = $batch->id limit 1" ); |
|
| 149 | - if ($wus == null){ |
|
| 147 | + foreach ($pbatches as $batch) { |
|
| 148 | + $wus = BoincWorkUnit::enum("batch = $batch->id limit 1"); |
|
| 149 | + if ($wus == null) { |
|
| 150 | 150 | //echo " no workunit for this batch<br/>"; |
| 151 | 151 | continue; |
| 152 | 152 | } |
| 153 | - foreach($wus as $wu){ |
|
| 153 | + foreach ($wus as $wu) { |
|
| 154 | 154 | $x = "<in>".$wu->xml_doc."</in>"; |
| 155 | 155 | $x = simplexml_load_string($x); |
| 156 | 156 | global $fanout; |
| 157 | - foreach($x->workunit->file_ref as $fr){ |
|
| 157 | + foreach ($x->workunit->file_ref as $fr) { |
|
| 158 | 158 | $pname = (string)$fr->file_name; |
| 159 | 159 | $ufiles[] = $pname; |
| 160 | 160 | } |
@@ -165,10 +165,10 @@ discard block |
||
| 165 | 165 | $dir = sandbox_dir($user); |
| 166 | 166 | $path = $dir."/".$file; |
| 167 | 167 | list($err, $size, $md5) = sandbox_parse_link_file($path); |
| 168 | - if (!$err){ |
|
| 168 | + if (!$err) { |
|
| 169 | 169 | $f = sandbox_file_name($user, $md5); |
| 170 | - foreach($ufiles as $uf) { |
|
| 171 | - if (strcmp($f,$uf) == 0){ |
|
| 170 | + foreach ($ufiles as $uf) { |
|
| 171 | + if (strcmp($f, $uf) == 0) { |
|
| 172 | 172 | return true; |
| 173 | 173 | } |
| 174 | 174 | |
@@ -88,18 +88,18 @@ |
||
| 88 | 88 | $errno = 0; |
| 89 | 89 | $errstr = ''; |
| 90 | 90 | |
| 91 | - if (false === $this->socket->fsockopen('ssl://' . self::RECAPTCHA_HOST, 443, $errno, $errstr, 30)) { |
|
| 91 | + if (false === $this->socket->fsockopen('ssl://'.self::RECAPTCHA_HOST, 443, $errno, $errstr, 30)) { |
|
| 92 | 92 | return self::BAD_REQUEST; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $content = $params->toQueryString(); |
| 96 | 96 | |
| 97 | - $request = "POST " . self::SITE_VERIFY_PATH . " HTTP/1.1\r\n"; |
|
| 98 | - $request .= "Host: " . self::RECAPTCHA_HOST . "\r\n"; |
|
| 97 | + $request = "POST ".self::SITE_VERIFY_PATH." HTTP/1.1\r\n"; |
|
| 98 | + $request .= "Host: ".self::RECAPTCHA_HOST."\r\n"; |
|
| 99 | 99 | $request .= "Content-Type: application/x-www-form-urlencoded\r\n"; |
| 100 | - $request .= "Content-length: " . strlen($content) . "\r\n"; |
|
| 100 | + $request .= "Content-length: ".strlen($content)."\r\n"; |
|
| 101 | 101 | $request .= "Connection: close\r\n\r\n"; |
| 102 | - $request .= $content . "\r\n\r\n"; |
|
| 102 | + $request .= $content."\r\n\r\n"; |
|
| 103 | 103 | |
| 104 | 104 | $this->socket->fwrite($request); |
| 105 | 105 | $response = ''; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | function send_friend_request_email($src_user, $dest_user, $msg) { |
| 53 | - $message = " |
|
| 53 | + $message = " |
|
| 54 | 54 | $src_user->name has added you as a friend at ".PROJECT.". |
| 55 | 55 | "; |
| 56 | 56 | if (strlen($msg)) { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | function send_friend_accept_email($dest_user, $src_user, $msg) { |
| 75 | - $message = " |
|
| 75 | + $message = " |
|
| 76 | 76 | $dest_user->name has confirmed you as a friend at ".PROJECT.". |
| 77 | 77 | "; |
| 78 | 78 | if (strlen($msg)) { |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | // Some of this should be merged with translation.inc |
| 21 | 21 | |
| 22 | 22 | function get_lang_list() { |
| 23 | - if (isset($_COOKIE['lang'])){ |
|
| 23 | + if (isset($_COOKIE['lang'])) { |
|
| 24 | 24 | $language_string = $_COOKIE['lang'].","; |
| 25 | 25 | } else { |
| 26 | 26 | $language_string = ''; |
@@ -28,28 +28,28 @@ discard block |
||
| 28 | 28 | if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) { |
| 29 | 29 | $language_string .= strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"]); |
| 30 | 30 | } |
| 31 | - $client_languages = explode(",",$language_string); |
|
| 31 | + $client_languages = explode(",", $language_string); |
|
| 32 | 32 | |
| 33 | 33 | $lang_list = array(); |
| 34 | - for ($i=0; $i<sizeof($client_languages); $i++) { |
|
| 35 | - if ((strlen($client_languages[$i])>2) |
|
| 36 | - && (substr($client_languages[$i],2,1)=="_" || substr($client_languages[$i],2,1)=="-")) |
|
| 34 | + for ($i = 0; $i < sizeof($client_languages); $i++) { |
|
| 35 | + if ((strlen($client_languages[$i]) > 2) |
|
| 36 | + && (substr($client_languages[$i], 2, 1) == "_" || substr($client_languages[$i], 2, 1) == "-")) |
|
| 37 | 37 | { |
| 38 | 38 | // If this is defined as primary-secondary, represent it as xx_YY |
| 39 | 39 | // |
| 40 | 40 | $language = substr( |
| 41 | - $client_languages[$i],0,2)."_".strtoupper(substr($client_languages[$i],3,2) |
|
| 41 | + $client_languages[$i], 0, 2)."_".strtoupper(substr($client_languages[$i], 3, 2) |
|
| 42 | 42 | ); |
| 43 | 43 | $lang_list[] = $language; |
| 44 | 44 | |
| 45 | 45 | // And also check for the primary language |
| 46 | 46 | // |
| 47 | - $language = substr($client_languages[$i],0,2); |
|
| 47 | + $language = substr($client_languages[$i], 0, 2); |
|
| 48 | 48 | $lang_list[] = $language; |
| 49 | 49 | } else { |
| 50 | 50 | // else just use xx |
| 51 | 51 | // |
| 52 | - $language = substr($client_languages[$i],0,2); |
|
| 52 | + $language = substr($client_languages[$i], 0, 2); |
|
| 53 | 53 | $lang_list[] = $language; |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | $n++; |
| 90 | 90 | $delta = $x - $m; |
| 91 | 91 | $m += $delta/$n; |
| 92 | - $m2 += $delta*($x-$m); |
|
| 92 | + $m2 += $delta*($x - $m); |
|
| 93 | 93 | } |
| 94 | 94 | $mean = $m; |
| 95 | - $stdev = sqrt($m2/($n-1)); |
|
| 95 | + $stdev = sqrt($m2/($n - 1)); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | // approximate the 90% confidence interval for the mean of an array |
@@ -103,13 +103,13 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | // I'm too lazy to compute the t distribution |
| 105 | 105 | $t_90 = 1.7; |
| 106 | - $d = $t_90 * $stdev / sqrt($n); |
|
| 106 | + $d = $t_90*$stdev/sqrt($n); |
|
| 107 | 107 | $lo = $mean - $d; |
| 108 | 108 | $hi = $mean + $d; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | function test_stats() { |
| 112 | - $a = array(1,1,1,1,0,1,1,1,3, 1, 1, 1, 1); |
|
| 112 | + $a = array(1, 1, 1, 1, 0, 1, 1, 1, 3, 1, 1, 1, 1); |
|
| 113 | 113 | mean_stdev($a, $mean, $stdev); |
| 114 | 114 | echo "mean: $mean stdev: $stdev\n"; |
| 115 | 115 | conf_int_90($a, $lo, $hi); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | function compare_bar($title, $n, $width, $lo, $hi) { |
| 122 | 122 | $x1 = $width*$lo; |
| 123 | - $x2 = $width*($hi-$lo); |
|
| 123 | + $x2 = $width*($hi - $lo); |
|
| 124 | 124 | $a1 = number_format($lo*100); |
| 125 | 125 | $a2 = number_format($hi*100); |
| 126 | 126 | return " |
@@ -151,12 +151,12 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | function outcome_graph($x, $width) { |
| 154 | - $n = $x[0]+$x[1]+$x[2]; |
|
| 154 | + $n = $x[0] + $x[1] + $x[2]; |
|
| 155 | 155 | if (!$n) return empty_cell(); |
| 156 | 156 | $x0 = $width*$x[1]/$n; |
| 157 | 157 | $x1 = $width*$x[0]/$n; |
| 158 | 158 | $x2 = $width*$x[2]/$n; |
| 159 | - if ($x[1]/$n>0.05) { |
|
| 159 | + if ($x[1]/$n > 0.05) { |
|
| 160 | 160 | $t0 = number_format(100*$x[1]/$n)."%"; |
| 161 | 161 | } else { |
| 162 | 162 | $t0 = ""; |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | function time_graph($t, $w) { |
| 186 | 186 | if ($t == 0) return "<td>---</td>"; |
| 187 | - $x = (log10($t)+2)*$w/4; |
|
| 187 | + $x = (log10($t) + 2)*$w/4; |
|
| 188 | 188 | $t = number_format($t, 1); |
| 189 | 189 | return "<td> |
| 190 | 190 | <table class=bolt_bar><tr> |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | function score_graph($t, $w) { |
| 197 | 197 | if ($t == 0) return "<td>---</td>"; |
| 198 | 198 | $x = $t*$w; |
| 199 | - $y = (1-$t)*$w; |
|
| 199 | + $y = (1 - $t)*$w; |
|
| 200 | 200 | $t = number_format($t*100); |
| 201 | 201 | $s = "<td> |
| 202 | 202 | <table class=bolt_bar><tr> |