Completed
Pull Request — master (#2022)
by Christian
12:03
created
html/user/openid.php 4 patches
Doc Comments   +11 added lines, -1 removed lines patch added patch discarded remove patch
@@ -315,6 +315,11 @@  discard block
 block discarded – undo
315 315
     /**
316 316
      * Helper function used to scan for <meta>/<link> tags and extract information
317 317
      * from them
318
+     * @param string $tag
319
+     * @param string $attrName
320
+     * @param string $attrValue
321
+     * @param string $valueName
322
+     * @return string
318 323
      */
319 324
     protected function htmlTag($content, $tag, $attrName, $attrValue, $valueName)
320 325
     {
@@ -531,6 +536,9 @@  discard block
 block discarded – undo
531 536
         return $params;
532 537
     }
533 538
 
539
+    /**
540
+     * @param boolean $immediate
541
+     */
534 542
     protected function authUrl_v1($immediate)
535 543
     {
536 544
 	$returnUrl = $this->returnUrl;
@@ -552,6 +560,9 @@  discard block
 block discarded – undo
552 560
                                , array('query' => http_build_query($params, '', '&')));
553 561
     }
554 562
 
563
+    /**
564
+     * @param boolean $immediate
565
+     */
555 566
     protected function authUrl_v2($immediate)
556 567
     {
557 568
         $params = array(
@@ -587,7 +598,6 @@  discard block
 block discarded – undo
587 598
     /**
588 599
      * Returns authentication url. Usually, you want to redirect your user to it.
589 600
      * @return String The authentication url.
590
-     * @param String $select_identifier Whether to request OP to select identity for an user in OpenID 2. Does not affect OpenID 1.
591 601
      * @throws ErrorException
592 602
      */
593 603
     function authUrl($immediate = false)
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
 class LightOpenID
48 48
 {
49 49
     public $returnUrl
50
-         , $required = array()
51
-         , $optional = array()
52
-         , $verify_peer = null
53
-         , $capath = null
54
-         , $cainfo = null;
50
+            , $required = array()
51
+            , $optional = array()
52
+            , $verify_peer = null
53
+            , $capath = null
54
+            , $cainfo = null;
55 55
     private $identity, $claimed_id;
56 56
     protected $server, $version, $trustRoot, $aliases, $identifier_select = false
57 57
             , $ax = false, $sreg = false, $data, $setup_url = null;
@@ -261,8 +261,8 @@  discard block
 block discarded – undo
261 261
                         $parsed_url = parse_url($this->claimed_id);
262 262
                         $this->identity =
263 263
                         $this->claimed_id = $parsed_url['scheme'] . '://'
264
-                                          . $parsed_url['host']
265
-                                          . $headers[$name];
264
+                                            . $parsed_url['host']
265
+                                            . $headers[$name];
266 266
                     }
267 267
                 }
268 268
             }
@@ -301,14 +301,14 @@  discard block
 block discarded – undo
301 301
 
302 302
         $url = $parts + $url;
303 303
         $url = $url['scheme'] . '://'
304
-             . (empty($url['username'])?''
304
+                . (empty($url['username'])?''
305 305
                  :(empty($url['password'])? "{$url['username']}@"
306 306
                  :"{$url['username']}:{$url['password']}@"))
307
-             . $url['host']
308
-             . (empty($url['port'])?'':":{$url['port']}")
309
-             . (empty($url['path'])?'':$url['path'])
310
-             . (empty($url['query'])?'':"?{$url['query']}")
311
-             . (empty($url['fragment'])?'':"#{$url['fragment']}");
307
+                . $url['host']
308
+                . (empty($url['port'])?'':":{$url['port']}")
309
+                . (empty($url['path'])?'':$url['path'])
310
+                . (empty($url['query'])?'':"?{$url['query']}")
311
+                . (empty($url['fragment'])?'':"#{$url['fragment']}");
312 312
         return $url;
313 313
     }
314 314
 
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 
534 534
     protected function authUrl_v1($immediate)
535 535
     {
536
-	$returnUrl = $this->returnUrl;
536
+    $returnUrl = $this->returnUrl;
537 537
         # If we have an openid.delegate that is different from our claimed id,
538 538
         # we need to somehow preserve the claimed id between requests.
539 539
         # The simplest way is to just send it along with the return_to url.
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
             ) + $this->sregParams();
550 550
 
551 551
         return $this->build_url(parse_url($this->server)
552
-                               , array('query' => http_build_query($params, '', '&')));
552
+                                , array('query' => http_build_query($params, '', '&')));
553 553
     }
554 554
 
555 555
     protected function authUrl_v2($immediate)
@@ -574,14 +574,14 @@  discard block
 block discarded – undo
574 574
 
575 575
         if ($this->identifier_select) {
576 576
             $params['openid.identity'] = $params['openid.claimed_id']
577
-                 = 'http://specs.openid.net/auth/2.0/identifier_select';
577
+                    = 'http://specs.openid.net/auth/2.0/identifier_select';
578 578
         } else {
579 579
             $params['openid.identity'] = $this->identity;
580 580
             $params['openid.claimed_id'] = $this->claimed_id;
581 581
         }
582 582
 
583 583
         return $this->build_url(parse_url($this->server)
584
-                               , array('query' => http_build_query($params, '', '&')));
584
+                                , array('query' => http_build_query($params, '', '&')));
585 585
     }
586 586
 
587 587
     /**
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
             # If it's an OpenID 1 provider, and we've got claimed_id,
639 639
             # we have to append it to the returnUrl, like authUrl_v1 does.
640 640
             $this->returnUrl .= (strpos($this->returnUrl, '?') ? '&' : '?')
641
-                             .  'openid.claimed_id=' . $this->claimed_id;
641
+                                .  'openid.claimed_id=' . $this->claimed_id;
642 642
         }
643 643
 
644 644
         if ($this->data['openid_return_to'] != $this->returnUrl) {
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
                 continue;
708 708
             }
709 709
             $key = substr($this->data['openid_' . $alias . '_type_' . $key],
710
-                          strlen('http://axschema.org/'));
710
+                            strlen('http://axschema.org/'));
711 711
             $attributes[$key] = $value;
712 712
         }
713 713
         return $attributes;
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
 
70 70
     function __construct()
71 71
     {
72
-        $this->trustRoot = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'];
72
+        $this->trustRoot = (!empty($_SERVER['HTTPS']) ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'];
73 73
         $uri = rtrim(preg_replace('#((?<=\?)|&)openid\.[^&]+#', '', $_SERVER['REQUEST_URI']), '?');
74
-        $this->returnUrl = $this->trustRoot . $uri;
74
+        $this->returnUrl = $this->trustRoot.$uri;
75 75
 
76 76
         $this->data = $_POST + $_GET; # OPs may send data as POST or GET.
77 77
 
78
-        if(!function_exists('curl_init') && !in_array('https', stream_get_wrappers())) {
78
+        if (!function_exists('curl_init') && !in_array('https', stream_get_wrappers())) {
79 79
             throw new ErrorException('You must have either https wrappers or curl enabled.');
80 80
         }
81 81
     }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     {
85 85
         switch ($name) {
86 86
         case 'identity':
87
-            if (strlen($value = trim((String) $value))) {
87
+            if (strlen($value = trim((String)$value))) {
88 88
                 if (preg_match('#^xri:/*#i', $value, $m)) {
89 89
                     $value = substr($value, strlen($m[0]));
90 90
                 } elseif (!preg_match('/^(?:[=@+\$!\(]|https?:)/i', $value)) {
@@ -139,23 +139,23 @@  discard block
 block discarded – undo
139 139
         return !!gethostbynamel($server);
140 140
     }
141 141
 
142
-    protected function request_curl($url, $method='GET', $params=array())
142
+    protected function request_curl($url, $method = 'GET', $params = array())
143 143
     {
144 144
         $params = http_build_query($params, '', '&');
145
-        $curl = curl_init($url . ($method == 'GET' && $params ? '?' . $params : ''));
145
+        $curl = curl_init($url.($method == 'GET' && $params ? '?'.$params : ''));
146 146
         curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
147 147
         curl_setopt($curl, CURLOPT_HEADER, false);
148 148
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
149 149
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
150 150
         curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/xrds+xml, */*'));
151 151
 
152
-        if($this->verify_peer !== null) {
152
+        if ($this->verify_peer !== null) {
153 153
             curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verify_peer);
154
-            if($this->capath) {
154
+            if ($this->capath) {
155 155
                 curl_setopt($curl, CURLOPT_CAPATH, $this->capath);
156 156
             }
157 157
 
158
-            if($this->cainfo) {
158
+            if ($this->cainfo) {
159 159
                 curl_setopt($curl, CURLOPT_CAINFO, $this->cainfo);
160 160
             }
161 161
         }
@@ -171,17 +171,17 @@  discard block
 block discarded – undo
171 171
         }
172 172
         $response = curl_exec($curl);
173 173
 
174
-        if($method == 'HEAD') {
174
+        if ($method == 'HEAD') {
175 175
             $headers = array();
176
-            foreach(explode("\n", $response) as $header) {
177
-                $pos = strpos($header,':');
176
+            foreach (explode("\n", $response) as $header) {
177
+                $pos = strpos($header, ':');
178 178
                 $name = strtolower(trim(substr($header, 0, $pos)));
179
-                $headers[$name] = trim(substr($header, $pos+1));
179
+                $headers[$name] = trim(substr($header, $pos + 1));
180 180
             }
181 181
 
182 182
             # Updating claimed_id in case of redirections.
183 183
             $effective_url = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
184
-            if($effective_url != $url) {
184
+            if ($effective_url != $url) {
185 185
                 $this->identity = $this->claimed_id = $effective_url;
186 186
             }
187 187
 
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
         return $response;
196 196
     }
197 197
 
198
-    protected function request_streams($url, $method='GET', $params=array())
198
+    protected function request_streams($url, $method = 'GET', $params = array())
199 199
     {
200
-        if(!$this->hostExists($url)) {
200
+        if (!$this->hostExists($url)) {
201 201
             throw new ErrorException('Invalid request.');
202 202
         }
203 203
 
204 204
         $params = http_build_query($params, '', '&');
205
-        switch($method) {
205
+        switch ($method) {
206 206
         case 'GET':
207 207
             $opts = array(
208 208
                 'http' => array(
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
                     'ignore_errors' => true,
212 212
                 )
213 213
             );
214
-            $url = $url . ($params ? '?' . $params : '');
214
+            $url = $url.($params ? '?'.$params : '');
215 215
             break;
216 216
         case 'POST':
217 217
             $opts = array(
@@ -236,31 +236,31 @@  discard block
 block discarded – undo
236 236
                 ))
237 237
             );
238 238
 
239
-            $url = $url . ($params ? '?' . $params : '');
240
-            $headers_tmp = get_headers ($url);
241
-            if(!$headers_tmp) {
239
+            $url = $url.($params ? '?'.$params : '');
240
+            $headers_tmp = get_headers($url);
241
+            if (!$headers_tmp) {
242 242
                 return array();
243 243
             }
244 244
 
245 245
             # Parsing headers.
246 246
             $headers = array();
247
-            foreach($headers_tmp as $header) {
248
-                $pos = strpos($header,':');
247
+            foreach ($headers_tmp as $header) {
248
+                $pos = strpos($header, ':');
249 249
                 $name = strtolower(trim(substr($header, 0, $pos)));
250
-                $headers[$name] = trim(substr($header, $pos+1));
250
+                $headers[$name] = trim(substr($header, $pos + 1));
251 251
 
252 252
                 # Following possible redirections. The point is just to have
253 253
                 # claimed_id change with them, because get_headers() will
254 254
                 # follow redirections automatically.
255 255
                 # We ignore redirections with relative paths.
256 256
                 # If any known provider uses them, file a bug report.
257
-                if($name == 'location') {
258
-                    if(strpos($headers[$name], 'http') === 0) {
257
+                if ($name == 'location') {
258
+                    if (strpos($headers[$name], 'http') === 0) {
259 259
                         $this->identity = $this->claimed_id = $headers[$name];
260
-                    } elseif($headers[$name][0] == '/') {
260
+                    } elseif ($headers[$name][0] == '/') {
261 261
                         $parsed_url = parse_url($this->claimed_id);
262 262
                         $this->identity =
263
-                        $this->claimed_id = $parsed_url['scheme'] . '://'
263
+                        $this->claimed_id = $parsed_url['scheme'].'://'
264 264
                                           . $parsed_url['host']
265 265
                                           . $headers[$name];
266 266
                     }
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
             return $headers;
273 273
         }
274 274
 
275
-        if($this->verify_peer) {
275
+        if ($this->verify_peer) {
276 276
             $opts += array('ssl' => array(
277 277
                 'verify_peer' => true,
278 278
                 'capath'      => $this->capath,
@@ -280,14 +280,14 @@  discard block
 block discarded – undo
280 280
             ));
281 281
         }
282 282
 
283
-        $context = stream_context_create ($opts);
283
+        $context = stream_context_create($opts);
284 284
 
285 285
         return file_get_contents($url, false, $context);
286 286
     }
287 287
 
288
-    protected function request($url, $method='GET', $params=array())
288
+    protected function request($url, $method = 'GET', $params = array())
289 289
     {
290
-        if(function_exists('curl_init') && !ini_get('safe_mode') && !ini_get('open_basedir')) {
290
+        if (function_exists('curl_init') && !ini_get('safe_mode') && !ini_get('open_basedir')) {
291 291
             return $this->request_curl($url, $method, $params);
292 292
         }
293 293
         return $this->request_streams($url, $method, $params);
@@ -296,19 +296,19 @@  discard block
 block discarded – undo
296 296
     protected function build_url($url, $parts)
297 297
     {
298 298
         if (isset($url['query'], $parts['query'])) {
299
-            $parts['query'] = $url['query'] . '&' . $parts['query'];
299
+            $parts['query'] = $url['query'].'&'.$parts['query'];
300 300
         }
301 301
 
302 302
         $url = $parts + $url;
303
-        $url = $url['scheme'] . '://'
304
-             . (empty($url['username'])?''
305
-                 :(empty($url['password'])? "{$url['username']}@"
303
+        $url = $url['scheme'].'://'
304
+             . (empty($url['username']) ? ''
305
+                 :(empty($url['password']) ? "{$url['username']}@"
306 306
                  :"{$url['username']}:{$url['password']}@"))
307 307
              . $url['host']
308
-             . (empty($url['port'])?'':":{$url['port']}")
309
-             . (empty($url['path'])?'':$url['path'])
310
-             . (empty($url['query'])?'':"?{$url['query']}")
311
-             . (empty($url['fragment'])?'':"#{$url['fragment']}");
308
+             . (empty($url['port']) ? '' : ":{$url['port']}")
309
+             . (empty($url['path']) ? '' : $url['path'])
310
+             . (empty($url['query']) ? '' : "?{$url['query']}")
311
+             . (empty($url['fragment']) ? '' : "#{$url['fragment']}");
312 312
         return $url;
313 313
     }
314 314
 
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
         preg_match_all("#<{$tag}[^>]*$valueName=['\"](.+?)['\"][^>]*$attrName=['\"].*?$attrValue.*?['\"][^>]*/?>#i", $content, $matches2);
323 323
 
324 324
         $result = array_merge($matches1[1], $matches2[1]);
325
-        return empty($result)?false:$result[0];
325
+        return empty($result) ? false : $result[0];
326 326
     }
327 327
 
328 328
     /**
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
         $yadis = true;
349 349
 
350 350
         # We'll jump a maximum of 5 times, to avoid endless redirections.
351
-        for ($i = 0; $i < 5; $i ++) {
351
+        for ($i = 0; $i < 5; $i++) {
352 352
             if ($yadis) {
353 353
                 $headers = $this->request($url, 'HEAD');
354 354
 
@@ -370,12 +370,12 @@  discard block
 block discarded – undo
370 370
                     $content = $this->request($url, 'GET');
371 371
 
372 372
                     preg_match_all('#<Service.*?>(.*?)</Service>#s', $content, $m);
373
-                    foreach($m[1] as $content) {
374
-                        $content = ' ' . $content; # The space is added, so that strpos doesn't return 0.
373
+                    foreach ($m[1] as $content) {
374
+                        $content = ' '.$content; # The space is added, so that strpos doesn't return 0.
375 375
 
376 376
                         # OpenID 2
377 377
                         $ns = preg_quote('http://specs.openid.net/auth/2.0/');
378
-                        if(preg_match('#<Type>\s*'.$ns.'(server|signon)\s*</Type>#s', $content, $type)) {
378
+                        if (preg_match('#<Type>\s*'.$ns.'(server|signon)\s*</Type>#s', $content, $type)) {
379 379
                             if ($type[1] == 'server') $this->identifier_select = true;
380 380
 
381 381
                             preg_match('#<URI.*?>(.*)</URI>#', $content, $server);
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
                                 return false;
385 385
                             }
386 386
                             # Does the server advertise support for either AX or SREG?
387
-                            $this->ax   = (bool) strpos($content, '<Type>http://openid.net/srv/ax/1.0</Type>');
387
+                            $this->ax   = (bool)strpos($content, '<Type>http://openid.net/srv/ax/1.0</Type>');
388 388
                             $this->sreg = strpos($content, '<Type>http://openid.net/sreg/1.0</Type>')
389 389
                                        || strpos($content, '<Type>http://openid.net/extensions/sreg/1.1</Type>');
390 390
 
@@ -498,33 +498,33 @@  discard block
 block discarded – undo
498 498
         if ($this->required || $this->optional) {
499 499
             $params['openid.ns.ax'] = 'http://openid.net/srv/ax/1.0';
500 500
             $params['openid.ax.mode'] = 'fetch_request';
501
-            $this->aliases  = array();
501
+            $this->aliases = array();
502 502
             $counts   = array();
503 503
             $required = array();
504 504
             $optional = array();
505
-            foreach (array('required','optional') as $type) {
505
+            foreach (array('required', 'optional') as $type) {
506 506
                 foreach ($this->$type as $alias => $field) {
507 507
                     if (is_int($alias)) $alias = strtr($field, '/', '_');
508
-                    $this->aliases[$alias] = 'http://axschema.org/' . $field;
508
+                    $this->aliases[$alias] = 'http://axschema.org/'.$field;
509 509
                     if (empty($counts[$alias])) $counts[$alias] = 0;
510 510
                     $counts[$alias] += 1;
511 511
                     ${$type}[] = $alias;
512 512
                 }
513 513
             }
514 514
             foreach ($this->aliases as $alias => $ns) {
515
-                $params['openid.ax.type.' . $alias] = $ns;
515
+                $params['openid.ax.type.'.$alias] = $ns;
516 516
             }
517 517
             foreach ($counts as $alias => $count) {
518 518
                 if ($count == 1) continue;
519
-                $params['openid.ax.count.' . $alias] = $count;
519
+                $params['openid.ax.count.'.$alias] = $count;
520 520
             }
521 521
 
522 522
             # Don't send empty ax.requied and ax.if_available.
523 523
             # Google and possibly other providers refuse to support ax when one of these is empty.
524
-            if($required) {
524
+            if ($required) {
525 525
                 $params['openid.ax.required'] = implode(',', $required);
526 526
             }
527
-            if($optional) {
527
+            if ($optional) {
528 528
                 $params['openid.ax.if_available'] = implode(',', $optional);
529 529
             }
530 530
         }
@@ -537,8 +537,8 @@  discard block
 block discarded – undo
537 537
         # If we have an openid.delegate that is different from our claimed id,
538 538
         # we need to somehow preserve the claimed id between requests.
539 539
         # The simplest way is to just send it along with the return_to url.
540
-        if($this->identity != $this->claimed_id) {
541
-            $returnUrl .= (strpos($returnUrl, '?') ? '&' : '?') . 'openid.claimed_id=' . $this->claimed_id;
540
+        if ($this->identity != $this->claimed_id) {
541
+            $returnUrl .= (strpos($returnUrl, '?') ? '&' : '?').'openid.claimed_id='.$this->claimed_id;
542 542
         }
543 543
 
544 544
         $params = array(
@@ -612,15 +612,15 @@  discard block
 block discarded – undo
612 612
         # by presenting user_setup_url (for 1.1) or reporting
613 613
         # mode 'setup_needed' (for 2.0). Also catching all modes other than
614 614
         # id_res, in order to avoid throwing errors.
615
-        if(isset($this->data['openid_user_setup_url'])) {
615
+        if (isset($this->data['openid_user_setup_url'])) {
616 616
             $this->setup_url = $this->data['openid_user_setup_url'];
617 617
             return false;
618 618
         }
619
-        if($this->mode != 'id_res') {
619
+        if ($this->mode != 'id_res') {
620 620
             return false;
621 621
         }
622 622
 
623
-        $this->claimed_id = isset($this->data['openid_claimed_id'])?$this->data['openid_claimed_id']:$this->data['openid_identity'];
623
+        $this->claimed_id = isset($this->data['openid_claimed_id']) ? $this->data['openid_claimed_id'] : $this->data['openid_identity'];
624 624
         $params = array(
625 625
             'openid.assoc_handle' => $this->data['openid_assoc_handle'],
626 626
             'openid.signed'       => $this->data['openid_signed'],
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
             # If it's an OpenID 1 provider, and we've got claimed_id,
639 639
             # we have to append it to the returnUrl, like authUrl_v1 does.
640 640
             $this->returnUrl .= (strpos($this->returnUrl, '?') ? '&' : '?')
641
-                             .  'openid.claimed_id=' . $this->claimed_id;
641
+                             .  'openid.claimed_id='.$this->claimed_id;
642 642
         }
643 643
 
644 644
         if ($this->data['openid_return_to'] != $this->returnUrl) {
@@ -656,8 +656,8 @@  discard block
 block discarded – undo
656 656
             # In such case, validation would fail, since we'd send different data than OP
657 657
             # wants to verify. stripslashes() should solve that problem, but we can't
658 658
             # use it when magic_quotes is off.
659
-            $value = $this->data['openid_' . str_replace('.','_',$item)];
660
-            $params['openid.' . $item] = get_magic_quotes_gpc() ? stripslashes($value) : $value;
659
+            $value = $this->data['openid_'.str_replace('.', '_', $item)];
660
+            $params['openid.'.$item] = get_magic_quotes_gpc() ? stripslashes($value) : $value;
661 661
 
662 662
         }
663 663
 
@@ -695,18 +695,18 @@  discard block
 block discarded – undo
695 695
 
696 696
         $attributes = array();
697 697
         foreach ($this->data as $key => $value) {
698
-            $keyMatch = 'openid_' . $alias . '_value_';
698
+            $keyMatch = 'openid_'.$alias.'_value_';
699 699
             if (substr($key, 0, strlen($keyMatch)) != $keyMatch) {
700 700
                 continue;
701 701
             }
702 702
             $key = substr($key, strlen($keyMatch));
703
-            if (!isset($this->data['openid_' . $alias . '_type_' . $key])) {
703
+            if (!isset($this->data['openid_'.$alias.'_type_'.$key])) {
704 704
                 # OP is breaking the spec by returning a field without
705 705
                 # associated ns. This shouldn't happen, but it's better
706 706
                 # to check, than cause an E_NOTICE.
707 707
                 continue;
708 708
             }
709
-            $key = substr($this->data['openid_' . $alias . '_type_' . $key],
709
+            $key = substr($this->data['openid_'.$alias.'_type_'.$key],
710 710
                           strlen('http://axschema.org/'));
711 711
             $attributes[$key] = $value;
712 712
         }
Please login to merge, or discard this patch.
Braces   +24 added lines, -42 removed lines patch added patch discarded remove patch
@@ -44,8 +44,7 @@  discard block
 block discarded – undo
44 44
  * @copyright Copyright (c) 2010, Mewp
45 45
  * @license http://www.opensource.org/licenses/mit-license.php MIT
46 46
  */
47
-class LightOpenID
48
-{
47
+class LightOpenID {
49 48
     public $returnUrl
50 49
          , $required = array()
51 50
          , $optional = array()
@@ -67,8 +66,7 @@  discard block
 block discarded – undo
67 66
         'pref/timezone'           => 'timezone',
68 67
         );
69 68
 
70
-    function __construct()
71
-    {
69
+    function __construct() {
72 70
         $this->trustRoot = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'];
73 71
         $uri = rtrim(preg_replace('#((?<=\?)|&)openid\.[^&]+#', '', $_SERVER['REQUEST_URI']), '?');
74 72
         $this->returnUrl = $this->trustRoot . $uri;
@@ -80,8 +78,7 @@  discard block
 block discarded – undo
80 78
         }
81 79
     }
82 80
 
83
-    function __set($name, $value)
84
-    {
81
+    function __set($name, $value) {
85 82
         switch ($name) {
86 83
         case 'identity':
87 84
             if (strlen($value = trim((String) $value))) {
@@ -102,8 +99,7 @@  discard block
 block discarded – undo
102 99
         }
103 100
     }
104 101
 
105
-    function __get($name)
106
-    {
102
+    function __get($name) {
107 103
         switch ($name) {
108 104
         case 'identity':
109 105
             # We return claimed_id instead of identity,
@@ -124,8 +120,7 @@  discard block
 block discarded – undo
124 120
      * @param $url url to check
125 121
      * @return true, if the server exists; false otherwise
126 122
      */
127
-    function hostExists($url)
128
-    {
123
+    function hostExists($url) {
129 124
         if (strpos($url, '/') === false) {
130 125
             $server = $url;
131 126
         } else {
@@ -139,8 +134,7 @@  discard block
 block discarded – undo
139 134
         return !!gethostbynamel($server);
140 135
     }
141 136
 
142
-    protected function request_curl($url, $method='GET', $params=array())
143
-    {
137
+    protected function request_curl($url, $method='GET', $params=array()) {
144 138
         $params = http_build_query($params, '', '&');
145 139
         $curl = curl_init($url . ($method == 'GET' && $params ? '?' . $params : ''));
146 140
         curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
@@ -195,8 +189,7 @@  discard block
 block discarded – undo
195 189
         return $response;
196 190
     }
197 191
 
198
-    protected function request_streams($url, $method='GET', $params=array())
199
-    {
192
+    protected function request_streams($url, $method='GET', $params=array()) {
200 193
         if(!$this->hostExists($url)) {
201 194
             throw new ErrorException('Invalid request.');
202 195
         }
@@ -285,16 +278,14 @@  discard block
 block discarded – undo
285 278
         return file_get_contents($url, false, $context);
286 279
     }
287 280
 
288
-    protected function request($url, $method='GET', $params=array())
289
-    {
281
+    protected function request($url, $method='GET', $params=array()) {
290 282
         if(function_exists('curl_init') && !ini_get('safe_mode') && !ini_get('open_basedir')) {
291 283
             return $this->request_curl($url, $method, $params);
292 284
         }
293 285
         return $this->request_streams($url, $method, $params);
294 286
     }
295 287
 
296
-    protected function build_url($url, $parts)
297
-    {
288
+    protected function build_url($url, $parts) {
298 289
         if (isset($url['query'], $parts['query'])) {
299 290
             $parts['query'] = $url['query'] . '&' . $parts['query'];
300 291
         }
@@ -316,8 +307,7 @@  discard block
 block discarded – undo
316 307
      * Helper function used to scan for <meta>/<link> tags and extract information
317 308
      * from them
318 309
      */
319
-    protected function htmlTag($content, $tag, $attrName, $attrValue, $valueName)
320
-    {
310
+    protected function htmlTag($content, $tag, $attrName, $attrValue, $valueName) {
321 311
         preg_match_all("#<{$tag}[^>]*$attrName=['\"].*?$attrValue.*?['\"][^>]*$valueName=['\"](.+?)['\"][^>]*/?>#i", $content, $matches1);
322 312
         preg_match_all("#<{$tag}[^>]*$valueName=['\"](.+?)['\"][^>]*$attrName=['\"].*?$attrValue.*?['\"][^>]*/?>#i", $content, $matches2);
323 313
 
@@ -331,8 +321,7 @@  discard block
 block discarded – undo
331 321
      * @return String OP Endpoint (i.e. OpenID provider address).
332 322
      * @throws ErrorException
333 323
      */
334
-    function discover($url)
335
-    {
324
+    function discover($url) {
336 325
         if (!$url) throw new ErrorException('No identity supplied.');
337 326
         # Use xri.net proxy to resolve i-name identities
338 327
         if (!preg_match('#^https?:#', $url)) {
@@ -465,8 +454,7 @@  discard block
 block discarded – undo
465 454
         throw new ErrorException('Endless redirection!');
466 455
     }
467 456
 
468
-    protected function sregParams()
469
-    {
457
+    protected function sregParams() {
470 458
         $params = array();
471 459
         # We always use SREG 1.1, even if the server is advertising only support for 1.0.
472 460
         # That's because it's fully backwards compatibile with 1.0, and some providers
@@ -492,8 +480,7 @@  discard block
 block discarded – undo
492 480
         return $params;
493 481
     }
494 482
 
495
-    protected function axParams()
496
-    {
483
+    protected function axParams() {
497 484
         $params = array();
498 485
         if ($this->required || $this->optional) {
499 486
             $params['openid.ns.ax'] = 'http://openid.net/srv/ax/1.0';
@@ -531,8 +518,7 @@  discard block
 block discarded – undo
531 518
         return $params;
532 519
     }
533 520
 
534
-    protected function authUrl_v1($immediate)
535
-    {
521
+    protected function authUrl_v1($immediate) {
536 522
 	$returnUrl = $this->returnUrl;
537 523
         # If we have an openid.delegate that is different from our claimed id,
538 524
         # we need to somehow preserve the claimed id between requests.
@@ -552,8 +538,7 @@  discard block
 block discarded – undo
552 538
                                , array('query' => http_build_query($params, '', '&')));
553 539
     }
554 540
 
555
-    protected function authUrl_v2($immediate)
556
-    {
541
+    protected function authUrl_v2($immediate) {
557 542
         $params = array(
558 543
             'openid.ns'          => 'http://specs.openid.net/auth/2.0',
559 544
             'openid.mode'        => $immediate ? 'checkid_immediate' : 'checkid_setup',
@@ -590,8 +575,7 @@  discard block
 block discarded – undo
590 575
      * @param String $select_identifier Whether to request OP to select identity for an user in OpenID 2. Does not affect OpenID 1.
591 576
      * @throws ErrorException
592 577
      */
593
-    function authUrl($immediate = false)
594
-    {
578
+    function authUrl($immediate = false) {
595 579
         if ($this->setup_url && !$immediate) return $this->setup_url;
596 580
         if (!$this->server) $this->discover($this->identity);
597 581
 
@@ -606,8 +590,7 @@  discard block
 block discarded – undo
606 590
      * @return Bool Whether the verification was successful.
607 591
      * @throws ErrorException
608 592
      */
609
-    function validate()
610
-    {
593
+    function validate() {
611 594
         # If the request was using immediate mode, a failure may be reported
612 595
         # by presenting user_setup_url (for 1.1) or reporting
613 596
         # mode 'setup_needed' (for 2.0). Also catching all modes other than
@@ -668,12 +651,12 @@  discard block
 block discarded – undo
668 651
         return preg_match('/is_valid\s*:\s*true/i', $response);
669 652
     }
670 653
 
671
-    protected function getAxAttributes()
672
-    {
654
+    protected function getAxAttributes() {
673 655
         $alias = null;
674 656
         if (isset($this->data['openid_ns_ax'])
675 657
             && $this->data['openid_ns_ax'] != 'http://openid.net/srv/ax/1.0'
676
-        ) { # It's the most likely case, so we'll check it before
658
+        ) {
659
+# It's the most likely case, so we'll check it before
677 660
             $alias = 'ax';
678 661
         } else {
679 662
             # 'ax' prefix is either undefined, or points to another extension,
@@ -713,8 +696,7 @@  discard block
 block discarded – undo
713 696
         return $attributes;
714 697
     }
715 698
 
716
-    protected function getSregAttributes()
717
-    {
699
+    protected function getSregAttributes() {
718 700
         $attributes = array();
719 701
         $sreg_to_ax = array_flip(self::$ax_to_sreg);
720 702
         foreach ($this->data as $key => $value) {
@@ -741,11 +723,11 @@  discard block
 block discarded – undo
741 723
      *     * @return Array Array of attributes with keys being the AX schema names, e.g. 'contact/email'
742 724
      * @see http://www.axschema.org/types/
743 725
      */
744
-    function getAttributes()
745
-    {
726
+    function getAttributes() {
746 727
         if (isset($this->data['openid_ns'])
747 728
             && $this->data['openid_ns'] == 'http://specs.openid.net/auth/2.0'
748
-        ) { # OpenID 2.0
729
+        ) {
730
+# OpenID 2.0
749 731
             # We search for both AX and SREG attributes, with AX taking precedence.
750 732
             return $this->getAxAttributes() + $this->getSregAttributes();
751 733
         }
Please login to merge, or discard this patch.
html/user/server_status.php 3 patches
Doc Comments   +17 added lines patch added patch discarded remove patch
@@ -88,17 +88,26 @@  discard block
 block discarded – undo
88 88
 ";
89 89
 }
90 90
 
91
+/**
92
+ * @param string $name
93
+ */
91 94
 function item_xml($name, $val) {
92 95
     if (!$val) $val = 0;
93 96
     echo "   <$name>$val</$name>\n";
94 97
 }
95 98
 
99
+/**
100
+ * @param string $name
101
+ */
96 102
 function item_html($name, $val) {
97 103
     $name = tra($name);
98 104
     echo "<tr><td>$name</td><td>$val</td></tr>\n";
99 105
     //echo "<tr><td align=right>$name</td><td align=right>$val</td></tr>\n";
100 106
 }
101 107
 
108
+/**
109
+ * @param stdClass $x
110
+ */
102 111
 function show_status_html($x) {
103 112
     page_head(tra("Project status"));
104 113
     $j = $x->jobs;
@@ -190,6 +199,9 @@  discard block
 block discarded – undo
190 199
     page_tail();
191 200
 }
192 201
 
202
+/**
203
+ * @param stdClass $x
204
+ */
193 205
 function show_status_xml($x) {
194 206
     xml_header();
195 207
     echo "<server_status>\n<daemon_status>\n";
@@ -239,6 +251,11 @@  discard block
 block discarded – undo
239 251
 ";
240 252
 }
241 253
 
254
+/**
255
+ * @param string $cmd
256
+ * @param string $pidname
257
+ * @param string $host
258
+ */
242 259
 function local_daemon_running($cmd, $pidname, $host) {
243 260
     if (!$pidname) {
244 261
         $cmd = trim($cmd);
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
         $avg = round($app->info->avg, 2);
172 172
         $min = round($app->info->min, 2);
173 173
         $max = round($app->info->max, 2);
174
-        $x = $max?"$avg ($min - $max)":"---";
174
+        $x = $max ? "$avg ($min - $max)" : "---";
175 175
         $u = $app->info->users;
176 176
         echo "<tr>
177 177
             <td>$app->user_friendly_name</td>
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         $cmd = trim($cmd);
245 245
         $x = explode(" ", $cmd);
246 246
         $prog = $x[0];
247
-        $pidname = $prog . '.pid';
247
+        $pidname = $prog.'.pid';
248 248
     }
249 249
     $path = "../../pid_$host/$pidname";
250 250
     if (is_file($path)) {
@@ -285,12 +285,12 @@  discard block
 block discarded – undo
285 285
     }
286 286
     $master_host = $u["host"];
287 287
     if ($config->www_host) {
288
-        $web_host = trim((string) $config->www_host);
288
+        $web_host = trim((string)$config->www_host);
289 289
     } else {
290 290
         $web_host = $main_host;
291 291
     }
292 292
     if ($config->sched_host) {
293
-        $sched_host = trim((string) $config->sched_host);
293
+        $sched_host = trim((string)$config->sched_host);
294 294
     } else {
295 295
         $sched_host = $main_host;
296 296
     }
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 
301 301
     // the upload and download servers are sort of daemons too
302 302
     //
303
-    $url = trim((string) $config->download_url);
303
+    $url = trim((string)$config->download_url);
304 304
     $u = parse_url($url);
305 305
     $h = $u["host"];
306 306
     if ($h == $master_host) {
@@ -312,14 +312,14 @@  discard block
 block discarded – undo
312 312
     } else {
313 313
         $have_remote = true;
314 314
     }
315
-    $url = trim((string) $config->upload_url);
315
+    $url = trim((string)$config->upload_url);
316 316
     $u = parse_url($url);
317 317
     $h = $u["host"];
318 318
     if ($h == $master_host) {
319 319
         $y = new StdClass;
320 320
         $y->cmd = "Upload server";
321 321
         $y->host = $h;
322
-        $y->status = !file_exists("../../stop_upload");;
322
+        $y->status = !file_exists("../../stop_upload"); ;
323 323
         $local_daemons[] = $y;
324 324
     } else {
325 325
         $have_remote = true;
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
         $y = new StdClass;
332 332
         $y->cmd = "Scheduler";
333 333
         $y->host = $sched_host;
334
-        $y->status = !file_exists("../../stop_sched");;
334
+        $y->status = !file_exists("../../stop_sched"); ;
335 335
         $local_daemons[] = $y;
336 336
     } else {
337 337
         $have_remote = true;
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
             $disabled_daemons[] = $x;
348 348
             continue;
349 349
         }
350
-        $host = $d->host?(string)$d->host:$main_host;
350
+        $host = $d->host ? (string)$d->host : $main_host;
351 351
         if ($host != $web_host) {
352 352
             $have_remote = true;
353 353
             continue;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -251,7 +251,7 @@
 block discarded – undo
251 251
         $pid = file_get_contents($path);
252 252
         if ($pid) {
253 253
             $pid = trim($pid);
254
-            $out = Array();
254
+            $out = array();
255 255
             exec("ps -ww $pid", $out);
256 256
             foreach ($out as $y) {
257 257
                 if (strstr($y, (string)$pid)) return 1;
Please login to merge, or discard this patch.
html/user/show_coproc.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -25,6 +25,9 @@
 block discarded – undo
25 25
 
26 26
 check_get_args(array("mode"));
27 27
 
28
+/**
29
+ * @param string $mode
30
+ */
28 31
 function filename($mode) {
29 32
     switch ($mode) {
30 33
     case 'host': return "cuda_hosts.dat";
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@
 block discarded – undo
92 92
         echo $x;
93 93
         break;
94 94
     }
95
-    echo "</td><td align=right>".format_credit_large($y->credit),"</td><td align=right>$y->nresults</td></tr>\n";
95
+    echo "</td><td align=right>".format_credit_large($y->credit), "</td><td align=right>$y->nresults</td></tr>\n";
96 96
 }
97 97
 
98 98
 $mode = get_str('mode', true);
Please login to merge, or discard this patch.
html/user/submit.php 4 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -37,6 +37,9 @@  discard block
 block discarded – undo
37 37
     return $n;
38 38
 }
39 39
 
40
+/**
41
+ * @param integer $state
42
+ */
40 43
 function show_all_link($batches, $state, $limit, $user, $app) {
41 44
     $n = state_count($batches, $state);
42 45
     if ($n > $limit) {
@@ -269,6 +272,9 @@  discard block
 block discarded – undo
269 272
     page_tail();
270 273
 }
271 274
 
275
+/**
276
+ * @param null|integer $app_id
277
+ */
272 278
 function check_admin_access($user, $app_id) {
273 279
     $user_submit = BoincUserSubmit::lookup_userid($user->id);
274 280
     if (!$user_submit) error_page("no access");
@@ -523,6 +529,9 @@  discard block
 block discarded – undo
523 529
     page_tail();
524 530
 }
525 531
 
532
+/**
533
+ * @param null|integer $state
534
+ */
526 535
 function show_batches_in_state($batches, $state) {
527 536
     switch ($state) {
528 537
     case BATCH_STATE_IN_PROGRESS:
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
     }
324 324
     row2("GFLOP/hours, estimated", number_format(credit_to_gflop_hours($batch->credit_estimate), 2));
325 325
     row2("GFLOP/hours, actual", number_format(credit_to_gflop_hours($batch->credit_canonical), 2));
326
-    row2("Output File Size (MB)", number_format(batch_output_file_size($batch->id)/1e6,2));
326
+    row2("Output File Size (MB)", number_format(batch_output_file_size($batch->id)/1e6, 2));
327 327
     end_table();
328 328
     if (batch_output_file_size($batch->id) <= 1e8) {
329 329
         $url = boinc_get_output_files_url($user, $batch_id);
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
         "Canonical instance<br><p class=\"text-muted\">click to see result page on BOINC server</p>",
358 358
         "Download Results"
359 359
     );
360
-    foreach($wus as $wu) {
360
+    foreach ($wus as $wu) {
361 361
         $resultid = $wu->canonical_resultid;
362
-        $durl = boinc_get_wu_output_files_url($user,$wu->id);
362
+        $durl = boinc_get_wu_output_files_url($user, $wu->id);
363 363
         if ($resultid) {
364 364
             $x = "<a href=result.php?resultid=$resultid>$resultid</a>";
365 365
             $y = '<font color="green">completed</font>';
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
             $text = "---";
370 370
             if ($batch->state == BATCH_STATE_COMPLETE) {
371 371
                 $y = '<font color="red">failed</font>';
372
-            }   else {
372
+            } else {
373 373
                 $y = "in progress";
374 374
             }
375 375
         }
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
     $results = BoincResult::enum("workunitid=$wuid");
435 435
     $upload_dir = parse_config(get_config(), "<upload_dir>");
436 436
     $fanout = parse_config(get_config(), "<uldl_dir_fanout>");
437
-    foreach($results as $result) {
437
+    foreach ($results as $result) {
438 438
         echo "<tr>
439 439
             <td><a href=result.php?resultid=$result->id>$result->id &middot; $result->name </a></td>
440 440
             <td>".state_string($result)."</td>
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -369,7 +369,7 @@
 block discarded – undo
369 369
             $text = "---";
370 370
             if ($batch->state == BATCH_STATE_COMPLETE) {
371 371
                 $y = '<font color="red">failed</font>';
372
-            }   else {
372
+            } else {
373 373
                 $y = "in progress";
374 374
             }
375 375
         }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
     $wus = BoincWorkunit::enum("batch = $batch->id");
309 309
     $batch = get_batch_params($batch, $wus);
310 310
 
311
-    page_head("Batch $batch_id");
311
+    page_head("batch $batch_id");
312 312
     start_table();
313 313
     row2("name", $batch->name);
314 314
     row2("application", $app->name);
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
     $wu = BoincWorkunit::lookup_id($wuid);
394 394
     if (!$wu) error_page("no such job");
395 395
 
396
-    page_head("Job $wuid");
396
+    page_head("job $wuid");
397 397
 
398 398
     echo "
399 399
         <a href=workunit.php?wuid=$wuid>Workunit details</a> &middot;
Please login to merge, or discard this patch.
html/user/submit_rpc_handler.php 4 patches
Doc Comments   +25 added lines patch added patch discarded remove patch
@@ -30,6 +30,9 @@  discard block
 block discarded – undo
30 30
 ini_set('display_errors', true);
31 31
 ini_set('display_startup_errors', true);
32 32
 
33
+/**
34
+ * @param string $name
35
+ */
33 36
 function get_wu($name) {
34 37
     $name = BoincDb::escape_string($name);
35 38
     $wu = BoincWorkunit::lookup("name='$name'");
@@ -37,6 +40,9 @@  discard block
 block discarded – undo
37 40
     return $wu;
38 41
 }
39 42
 
43
+/**
44
+ * @param string $name
45
+ */
40 46
 function get_submit_app($name) {
41 47
     $name = BoincDb::escape_string($name);
42 48
     $app = BoincApp::lookup("name='$name'");
@@ -76,6 +82,9 @@  discard block
 block discarded – undo
76 82
     return $y;
77 83
 }
78 84
 
85
+/**
86
+ * @param SimpleXMLElement|null $template
87
+ */
79 88
 function est_elapsed_time($r, $template) {
80 89
     // crude estimate: batch FLOPs / project FLOPS
81 90
     //
@@ -122,6 +131,9 @@  discard block
 block discarded – undo
122 131
     ";
123 132
 }
124 133
 
134
+/**
135
+ * @param SimpleXMLElement $template
136
+ */
125 137
 function validate_batch($jobs, $template) {
126 138
     $i = 0;
127 139
     $n = count($template->file_info);
@@ -191,6 +203,10 @@  discard block
 block discarded – undo
191 203
 
192 204
 // submit a list of jobs with a single create_work command.
193 205
 //
206
+/**
207
+ * @param SimpleXMLElement|null $template
208
+ * @param double $priority
209
+ */
194 210
 function submit_jobs(
195 211
     $jobs, $template, $app, $batch_id, $priority,
196 212
     $result_template_file,      // batch-level; can also specify per job
@@ -267,6 +283,9 @@  discard block
 block discarded – undo
267 283
 // Check whether the template is already in our map.
268 284
 // If not, write it to a temp file.
269 285
 //
286
+/**
287
+ * @param stdClass $job
288
+ */
270 289
 function make_wu_template($job) {
271 290
     global $wu_templates;
272 291
     if (!array_key_exists($job->wu_template, $wu_templates)) {
@@ -283,6 +302,9 @@  discard block
 block discarded – undo
283 302
 // A little different because these have to exist for life of job.
284 303
 // Store them in templates/tmp/, with content-based filenames
285 304
 //
305
+/**
306
+ * @param stdClass $job
307
+ */
286 308
 function make_result_template($job) {
287 309
     global $result_templates;
288 310
     if (!array_key_exists($job->result_template, $result_templates)) {
@@ -468,6 +490,9 @@  discard block
 block discarded – undo
468 490
     ";
469 491
 }
470 492
 
493
+/**
494
+ * @param integer $get_cpu_time
495
+ */
471 496
 function print_batch_params($batch, $get_cpu_time) {
472 497
     $app = BoincApp::lookup_id($batch->app_id);
473 498
     if (!$app) $app->name = "none";
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     if ($template) {
55 55
         $t = (double)$template->workunit->rsc_fpops_est;
56 56
     }
57
-    foreach($r->batch->job as $job) {
57
+    foreach ($r->batch->job as $job) {
58 58
         $y = (double)$job->rsc_fpops_est;
59 59
         if ($y) {
60 60
             $x += $y;
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
 function est_elapsed_time($r, $template) {
80 80
     // crude estimate: batch FLOPs / project FLOPS
81 81
     //
82
-    return batch_flop_count($r, $template) / project_flops();
82
+    return batch_flop_count($r, $template)/project_flops();
83 83
 }
84 84
 
85 85
 function read_input_template($app, $r) {
86 86
     if ((isset($r->batch)) && (isset($r->batch->workunit_template_file)) && ($r->batch->workunit_template_file)) {
87
-        $path = project_dir() . "/templates/".$r->batch->workunit_template_file;
87
+        $path = project_dir()."/templates/".$r->batch->workunit_template_file;
88 88
     } else {
89
-        $path = project_dir() . "/templates/$app->name"."_in";
89
+        $path = project_dir()."/templates/$app->name"."_in";
90 90
     }
91 91
     if (file_exists($path)) {
92 92
         $x = simplexml_load_file($path);
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 function validate_batch($jobs, $template) {
126 126
     $i = 0;
127 127
     $n = count($template->file_info);
128
-    foreach($jobs as $job) {
128
+    foreach ($jobs as $job) {
129 129
         $m = count($job->input_files);
130 130
         if ($n != $m) {
131 131
             xml_error(-1, "BOINC server: wrong # of input files for job $i: need $n, got $m");
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 // stage all the files
181 181
 //
182 182
 function stage_files(&$jobs) {
183
-    foreach($jobs as $job) {
183
+    foreach ($jobs as $job) {
184 184
         foreach ($job->input_files as $file) {
185 185
             if ($file->mode != "remote") {
186 186
                 $file->name = stage_file($file);
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 //
194 194
 function submit_jobs(
195 195
     $jobs, $template, $app, $batch_id, $priority,
196
-    $result_template_file,      // batch-level; can also specify per job
196
+    $result_template_file, // batch-level; can also specify per job
197 197
     $workunit_template_file
198 198
 ) {
199 199
     global $wu_templates, $result_templates;
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
     // one line per job
203 203
     //
204 204
     $x = "";
205
-    foreach($jobs as $job) {
205
+    foreach ($jobs as $job) {
206 206
         if ($job->name) {
207 207
             $x .= " --wu_name $job->name";
208 208
         }
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
         $x .= "\n";
235 235
     }
236 236
 
237
-    $errfile = "/tmp/create_work_" . getmypid() . ".err";
238
-    $cmd = "cd " . project_dir() . "; ./bin/create_work --appname $app->name --batch $batch_id --priority $priority";
237
+    $errfile = "/tmp/create_work_".getmypid().".err";
238
+    $cmd = "cd ".project_dir()."; ./bin/create_work --appname $app->name --batch $batch_id --priority $priority";
239 239
     if ($result_template_file) {
240 240
         $cmd .= " --result_template templates/$result_template_file";
241 241
     }
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 //
314 314
 function xml_get_jobs($r) {
315 315
     $jobs = array();
316
-    foreach($r->batch->job as $j) {
316
+    foreach ($r->batch->job as $j) {
317 317
         $job = new StdClass;
318 318
         $job->input_files = array();
319 319
         $job->command_line = (string)$j->command_line;
@@ -384,11 +384,11 @@  discard block
 block discarded – undo
384 384
     // - use that for batch logical end time and job priority
385 385
     //
386 386
     $total_flops = 0;
387
-    foreach($jobs as $job) {
387
+    foreach ($jobs as $job) {
388 388
         if ($job->rsc_fpops_est) {
389 389
             $total_flops += $job->rsc_fpops_est;
390 390
         } else {
391
-            $x = (double) $template->workunit->rsc_fpops_est;
391
+            $x = (double)$template->workunit->rsc_fpops_est;
392 392
             if ($x) {
393 393
                 $total_flops += $x;
394 394
             } else {
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
             }
397 397
         }
398 398
     }
399
-    $cmd = "cd " . project_dir() . "/bin; ./adjust_user_priority --user $user->id --flops $total_flops --app $app->name";
399
+    $cmd = "cd ".project_dir()."/bin; ./adjust_user_priority --user $user->id --flops $total_flops --app $app->name";
400 400
     $x = exec($cmd);
401 401
     if (!is_numeric($x) || (double)$x == 0) {
402 402
         xml_error(-1, "BOINC server: $cmd returned $x");
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 }
511 511
 
512 512
 function n_outfiles($wu) {
513
-    $path = project_dir() . "/$wu->result_template_file";
513
+    $path = project_dir()."/$wu->result_template_file";
514 514
     $r = simplexml_load_file($path);
515 515
     return count($r->file_info);
516 516
 }
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 ";
694 694
         if ($result->server_state == 5) {   // over?
695 695
             $paths = get_outfile_paths($result);
696
-            foreach($paths as $path) {
696
+            foreach ($paths as $path) {
697 697
                 if (is_file($path)) {
698 698
                     $size = filesize($path);
699 699
                     echo "        <outfile>
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
     } else {
734 734
         $results = BoincResult::enum("workunitid=$job_id");
735 735
         foreach ($results as $r) {
736
-            switch($r->outcome) {
736
+            switch ($r->outcome) {
737 737
             case 1:
738 738
             case 3:
739 739
             case 6:
@@ -841,8 +841,8 @@  discard block
 block discarded – undo
841 841
     }
842 842
 
843 843
     list($user, $user_submit) = authenticate_user($r, $app);
844
-    $in = file_get_contents(project_dir() . "/templates/".$app->name."_in");
845
-    $out = file_get_contents(project_dir() . "/templates/".$app->name."_out");
844
+    $in = file_get_contents(project_dir()."/templates/".$app->name."_in");
845
+    $out = file_get_contents(project_dir()."/templates/".$app->name."_out");
846 846
     if ($in === false || $out === false) {
847 847
         xml_error(-1, "template file missing");
848 848
     }
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
 
854 854
 function ping($r) {
855 855
     xml_start_tag("ping");
856
-    BoincDb::get();     // errors out if DB down or web disabled
856
+    BoincDb::get(); // errors out if DB down or web disabled
857 857
     echo "<success>1</success>
858 858
         </ping>
859 859
     ";
@@ -907,10 +907,10 @@  discard block
 block discarded – undo
907 907
 if ($request_log) {
908 908
     $request_log_dir = parse_config(get_config(), "<log_dir>");
909 909
     if ($request_log_dir) {
910
-        $request_log = $request_log_dir . "/" . $request_log;
910
+        $request_log = $request_log_dir."/".$request_log;
911 911
     }
912 912
     if ($file = fopen($request_log, "a+")) {
913
-        fwrite($file, "\n<submit_rpc_handler date=\"" . date(DATE_ATOM) . "\">\n" . $_POST['request'] . "\n</submit_rpc_handler>\n");
913
+        fwrite($file, "\n<submit_rpc_handler date=\"".date(DATE_ATOM)."\">\n".$_POST['request']."\n</submit_rpc_handler>\n");
914 914
         fclose($file);
915 915
     }
916 916
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -691,7 +691,8 @@
 block discarded – undo
691 691
         <id>$result->id</id>
692 692
         <state>".state_string($result)."</state>
693 693
 ";
694
-        if ($result->server_state == 5) {   // over?
694
+        if ($result->server_state == 5) {
695
+// over?
695 696
             $paths = get_outfile_paths($result);
696 697
             foreach($paths as $path) {
697 698
                 if (is_file($path)) {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -784,7 +784,7 @@
 block discarded – undo
784 784
             xml_error(-1, "No job $job_name");
785 785
         }
786 786
         if (!$wu->batch) {
787
-            xml_error(-1, "Job $job_name is not part of a batch");
787
+            xml_error(-1, "job $job_name is not part of a batch");
788 788
         }
789 789
         if (!$batch || $wu->batch != $batch->id) {
790 790
             $batch = BoincBatch::lookup_id($wu->batch);
Please login to merge, or discard this patch.
html/user/team_forum.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -57,6 +57,9 @@
 block discarded – undo
57 57
     edit_form($user, $team, $forum, true);
58 58
 }
59 59
 
60
+/**
61
+ * @param boolean $first
62
+ */
60 63
 function edit_form($user, $team, $forum, $first) {
61 64
     page_head(tra("Team Message Board"));
62 65
     echo "
Please login to merge, or discard this patch.
html/user/team_search.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -30,6 +30,9 @@
 block discarded – undo
30 30
 // list entries are of the form id => team,
31 31
 // where team includes a field "refcnt".
32 32
 // 
33
+/**
34
+ * @param integer $weight
35
+ */
33 36
 function merge_lists($list1, &$list2, $weight) {
34 37
     foreach($list1 as $team) {
35 38
         $id = $team->id;
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 // where team includes a field "refcnt".
32 32
 // 
33 33
 function merge_lists($list1, &$list2, $weight) {
34
-    foreach($list1 as $team) {
34
+    foreach ($list1 as $team) {
35 35
         $id = $team->id;
36 36
         if (array_key_exists($id, $list2)) {
37 37
             $list2[$id]->refcnt += $weight;
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         if (defined("SHOW_NONVALIDATED_TEAMS")) {
98 98
             $user = BoincUser::lookup_id($team->userid);
99 99
             echo "<td>";
100
-            echo $user->email_validated?"Yes":"No";
100
+            echo $user->email_validated ? "Yes" : "No";
101 101
             echo "</td>\n";
102 102
         }
103 103
         echo "
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     xml_header();
138 138
     echo "<teams>\n";
139 139
     sort_list($list);
140
-    foreach($list as $team) {
140
+    foreach ($list as $team) {
141 141
         show_team_xml($team);
142 142
     }
143 143
     echo "</teams>\n";
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
         merge_lists($list2, $list, 3);
165 165
         $tried = true;
166 166
     }
167
-    if (strlen($params->country) && $params->country!='None') {
167
+    if (strlen($params->country) && $params->country != 'None') {
168 168
         $country = BoincDb::escape_string($params->country);
169 169
         $list2 = get_teams("country = '$country'", $params->active);
170 170
         //echo "<br>country matches: ",sizeof($list2);
171 171
         merge_lists($list2, $list, 1);
172 172
         $tried = true;
173 173
     }
174
-    if ($params->type and $params->type>1) {
174
+    if ($params->type and $params->type > 1) {
175 175
         $list2 = get_teams("type=$params->type", $params->active);
176 176
         //echo "<br>type matches: ",sizeof($list2);
177 177
         merge_lists($list2, $list, 2);
Please login to merge, or discard this patch.
drupal/sites/default/settings.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
  */
93 93
 require_once('dbconfig.php');
94 94
 if (!isset($dbserver) || empty($dbserver))
95
-  $dbserver='localhost';
95
+    $dbserver='localhost';
96 96
 $db_url = array(
97
-  'default' => "{$dbtype}://{$dbuser}:".urlencode($dbpass)."@{$dbserver}/{$dbname}",
98
-  'boinc' => "{$boinc_dbtype}://{$boinc_dbuser}:".urlencode($boinc_dbpass)."@{$boinc_dbserver}/{$boinc_dbname}"
97
+    'default' => "{$dbtype}://{$dbuser}:".urlencode($dbpass)."@{$dbserver}/{$dbname}",
98
+    'boinc' => "{$boinc_dbtype}://{$boinc_dbuser}:".urlencode($boinc_dbpass)."@{$boinc_dbserver}/{$boinc_dbname}"
99 99
 );
100 100
 $db_prefix = '';
101 101
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
  */
121 121
 # $base_url = 'http://www.example.com';  // NO trailing slash!
122 122
 if (stream_resolve_include_path('baseurl.php')) {
123
-  include_once('baseurl.php');
123
+    include_once('baseurl.php');
124 124
 }
125 125
 
126 126
 /**
@@ -175,5 +175,5 @@  discard block
 block discarded – undo
175 175
 #   'anonymous' => 'Visitor',
176 176
 # );
177 177
 $conf = array(
178
-  'maintenance_theme' => 'einstein',
178
+    'maintenance_theme' => 'einstein',
179 179
 );
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
  */
93 93
 require_once('dbconfig.php');
94 94
 if (!isset($dbserver) || empty($dbserver))
95
-  $dbserver='localhost';
95
+  $dbserver = 'localhost';
96 96
 $db_url = array(
97 97
   'default' => "{$dbtype}://{$dbuser}:".urlencode($dbpass)."@{$dbserver}/{$dbname}",
98 98
   'boinc' => "{$boinc_dbtype}://{$boinc_dbuser}:".urlencode($boinc_dbpass)."@{$boinc_dbserver}/{$boinc_dbname}"
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
  * settings are used there. Settings defined here should not be
134 134
  * duplicated there so as to avoid conflict issues.
135 135
  */
136
-ini_set('arg_separator.output',     '&amp;');
137
-ini_set('magic_quotes_runtime',     0);
138
-ini_set('magic_quotes_sybase',      0);
139
-ini_set('session.cache_expire',     200000);
140
-ini_set('session.cache_limiter',    'none');
141
-ini_set('session.cookie_lifetime',  2000000);
142
-ini_set('session.gc_maxlifetime',   200000);
143
-ini_set('session.save_handler',     'user');
136
+ini_set('arg_separator.output', '&amp;');
137
+ini_set('magic_quotes_runtime', 0);
138
+ini_set('magic_quotes_sybase', 0);
139
+ini_set('session.cache_expire', 200000);
140
+ini_set('session.cache_limiter', 'none');
141
+ini_set('session.cookie_lifetime', 2000000);
142
+ini_set('session.gc_maxlifetime', 200000);
143
+ini_set('session.save_handler', 'user');
144 144
 ini_set('session.use_only_cookies', 1);
145
-ini_set('session.use_trans_sid',    0);
146
-ini_set('url_rewriter.tags',        '');
145
+ini_set('session.use_trans_sid', 0);
146
+ini_set('url_rewriter.tags', '');
147 147
 ini_set('memory_limit', '128M');
148 148
 ini_set('post_max_size', '8MB');
149 149
 ini_set('upload_max_filesize', '8MB');
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/contrib/jump/jump.views.inc 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@  discard block
 block discarded – undo
9 9
  * Implementation of hook_views_plugins().
10 10
  */
11 11
 function jump_views_plugins() {
12
-  return array(
12
+    return array(
13 13
     'style' => array(
14
-      'jump_views' => array(
14
+        'jump_views' => array(
15 15
         'title' => t('Jump menu'),
16 16
         'theme' => 'jump_views_plugin_style',
17 17
         'help' => t('Displays items as a select list jump menu.'),
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
         'uses fields' => TRUE,
21 21
         'uses options' => TRUE,
22 22
         'type' => 'normal',
23
-      ),
23
+        ),
24 24
     ),
25
-  );
25
+    );
26 26
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@
 block discarded – undo
16 16
         'theme' => 'jump_views_plugin_style',
17 17
         'help' => t('Displays items as a select list jump menu.'),
18 18
         'handler' => 'jump_views_plugin_style',
19
-        'uses row plugin' => TRUE,
20
-        'uses fields' => TRUE,
21
-        'uses options' => TRUE,
19
+        'uses row plugin' => true,
20
+        'uses fields' => true,
21
+        'uses options' => true,
22 22
         'type' => 'normal',
23 23
       ),
24 24
     ),
Please login to merge, or discard this patch.