@@ -315,6 +315,11 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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) |
@@ -47,11 +47,11 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -44,8 +44,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -69,13 +69,13 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -88,17 +88,26 @@ discard block |
||
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 |
||
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 |
||
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); |
@@ -171,7 +171,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -251,7 +251,7 @@ |
||
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; |
@@ -25,6 +25,9 @@ |
||
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"; |
@@ -92,7 +92,7 @@ |
||
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); |
@@ -37,6 +37,9 @@ discard block |
||
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 |
||
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 |
||
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: |
@@ -323,7 +323,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 · $result->name </a></td> |
440 | 440 | <td>".state_string($result)."</td> |
@@ -369,7 +369,7 @@ |
||
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 | } |
@@ -308,7 +308,7 @@ discard block |
||
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 |
||
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> · |
@@ -57,6 +57,9 @@ |
||
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 " |
@@ -30,6 +30,9 @@ |
||
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; |
@@ -31,7 +31,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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); |
@@ -92,10 +92,10 @@ discard block |
||
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 |
||
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 |
||
175 | 175 | # 'anonymous' => 'Visitor', |
176 | 176 | # ); |
177 | 177 | $conf = array( |
178 | - 'maintenance_theme' => 'einstein', |
|
178 | + 'maintenance_theme' => 'einstein', |
|
179 | 179 | ); |
@@ -92,7 +92,7 @@ discard block |
||
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 |
||
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', '&'); |
|
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', '&'); |
|
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'); |
@@ -9,9 +9,9 @@ discard block |
||
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 |
||
20 | 20 | 'uses fields' => TRUE, |
21 | 21 | 'uses options' => TRUE, |
22 | 22 | 'type' => 'normal', |
23 | - ), |
|
23 | + ), |
|
24 | 24 | ), |
25 | - ); |
|
25 | + ); |
|
26 | 26 | } |
@@ -16,9 +16,9 @@ |
||
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 | ), |
@@ -9,20 +9,20 @@ discard block |
||
9 | 9 | * Implementation of hook_views_default_views(). |
10 | 10 | */ |
11 | 11 | function jump_views_default_views() { |
12 | - $view = new view; |
|
13 | - $view->name = 'recent_nodes_jump_menu'; |
|
14 | - $view->description = 'Recent nodes in a jump menu.'; |
|
15 | - $view->tag = ''; |
|
16 | - $view->view_php = ''; |
|
17 | - $view->base_table = 'node'; |
|
18 | - $view->is_cacheable = FALSE; |
|
19 | - $view->api_version = 2; |
|
20 | - $view->disabled = TRUE; |
|
21 | - $handler = $view->new_display('default', 'Defaults', 'default'); |
|
22 | - $handler->override_option('fields', array( |
|
12 | + $view = new view; |
|
13 | + $view->name = 'recent_nodes_jump_menu'; |
|
14 | + $view->description = 'Recent nodes in a jump menu.'; |
|
15 | + $view->tag = ''; |
|
16 | + $view->view_php = ''; |
|
17 | + $view->base_table = 'node'; |
|
18 | + $view->is_cacheable = FALSE; |
|
19 | + $view->api_version = 2; |
|
20 | + $view->disabled = TRUE; |
|
21 | + $handler = $view->new_display('default', 'Defaults', 'default'); |
|
22 | + $handler->override_option('fields', array( |
|
23 | 23 | 'nid' => array( |
24 | - 'label' => 'Nid', |
|
25 | - 'alter' => array( |
|
24 | + 'label' => 'Nid', |
|
25 | + 'alter' => array( |
|
26 | 26 | 'alter_text' => 1, |
27 | 27 | 'text' => 'node/[nid]', |
28 | 28 | 'make_link' => 0, |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | 'ellipsis' => 1, |
39 | 39 | 'strip_tags' => 0, |
40 | 40 | 'html' => 0, |
41 | - ), |
|
42 | - 'link_to_node' => 0, |
|
43 | - 'exclude' => 1, |
|
44 | - 'id' => 'nid', |
|
45 | - 'table' => 'node', |
|
46 | - 'field' => 'nid', |
|
47 | - 'relationship' => 'none', |
|
41 | + ), |
|
42 | + 'link_to_node' => 0, |
|
43 | + 'exclude' => 1, |
|
44 | + 'id' => 'nid', |
|
45 | + 'table' => 'node', |
|
46 | + 'field' => 'nid', |
|
47 | + 'relationship' => 'none', |
|
48 | 48 | ), |
49 | 49 | 'title' => array( |
50 | - 'label' => '', |
|
51 | - 'alter' => array( |
|
50 | + 'label' => '', |
|
51 | + 'alter' => array( |
|
52 | 52 | 'alter_text' => 0, |
53 | 53 | 'text' => '', |
54 | 54 | 'make_link' => 0, |
@@ -64,60 +64,60 @@ discard block |
||
64 | 64 | 'ellipsis' => 1, |
65 | 65 | 'strip_tags' => 0, |
66 | 66 | 'html' => 0, |
67 | - ), |
|
68 | - 'link_to_node' => 0, |
|
69 | - 'exclude' => 0, |
|
70 | - 'id' => 'title', |
|
71 | - 'table' => 'node', |
|
72 | - 'field' => 'title', |
|
73 | - 'relationship' => 'none', |
|
67 | + ), |
|
68 | + 'link_to_node' => 0, |
|
69 | + 'exclude' => 0, |
|
70 | + 'id' => 'title', |
|
71 | + 'table' => 'node', |
|
72 | + 'field' => 'title', |
|
73 | + 'relationship' => 'none', |
|
74 | 74 | ), |
75 | - )); |
|
76 | - $handler->override_option('sorts', array( |
|
75 | + )); |
|
76 | + $handler->override_option('sorts', array( |
|
77 | 77 | 'changed' => array( |
78 | - 'order' => 'DESC', |
|
79 | - 'granularity' => 'second', |
|
80 | - 'id' => 'changed', |
|
81 | - 'table' => 'node', |
|
82 | - 'field' => 'changed', |
|
83 | - 'relationship' => 'none', |
|
78 | + 'order' => 'DESC', |
|
79 | + 'granularity' => 'second', |
|
80 | + 'id' => 'changed', |
|
81 | + 'table' => 'node', |
|
82 | + 'field' => 'changed', |
|
83 | + 'relationship' => 'none', |
|
84 | 84 | ), |
85 | - )); |
|
86 | - $handler->override_option('filters', array( |
|
85 | + )); |
|
86 | + $handler->override_option('filters', array( |
|
87 | 87 | 'status_extra' => array( |
88 | - 'operator' => '=', |
|
89 | - 'value' => '', |
|
90 | - 'group' => '0', |
|
91 | - 'exposed' => FALSE, |
|
92 | - 'expose' => array( |
|
88 | + 'operator' => '=', |
|
89 | + 'value' => '', |
|
90 | + 'group' => '0', |
|
91 | + 'exposed' => FALSE, |
|
92 | + 'expose' => array( |
|
93 | 93 | 'operator' => FALSE, |
94 | 94 | 'label' => '', |
95 | - ), |
|
96 | - 'id' => 'status_extra', |
|
97 | - 'table' => 'node', |
|
98 | - 'field' => 'status_extra', |
|
99 | - 'relationship' => 'none', |
|
95 | + ), |
|
96 | + 'id' => 'status_extra', |
|
97 | + 'table' => 'node', |
|
98 | + 'field' => 'status_extra', |
|
99 | + 'relationship' => 'none', |
|
100 | 100 | ), |
101 | - )); |
|
102 | - $handler->override_option('access', array( |
|
101 | + )); |
|
102 | + $handler->override_option('access', array( |
|
103 | 103 | 'type' => 'none', |
104 | - )); |
|
105 | - $handler->override_option('cache', array( |
|
104 | + )); |
|
105 | + $handler->override_option('cache', array( |
|
106 | 106 | 'type' => 'none', |
107 | - )); |
|
108 | - $handler->override_option('style_plugin', 'jump_views'); |
|
109 | - $handler->override_option('style_options', array( |
|
107 | + )); |
|
108 | + $handler->override_option('style_plugin', 'jump_views'); |
|
109 | + $handler->override_option('style_options', array( |
|
110 | 110 | 'grouping' => '', |
111 | 111 | 'keys' => array( |
112 | - 'nid' => 'nid', |
|
113 | - 'title' => 0, |
|
112 | + 'nid' => 'nid', |
|
113 | + 'title' => 0, |
|
114 | 114 | ), |
115 | 115 | 'first_item' => 'Recent nodes', |
116 | - )); |
|
117 | - $handler = $view->new_display('block', 'Block', 'block_1'); |
|
118 | - $handler->override_option('block_description', ''); |
|
119 | - $handler->override_option('block_caching', -1); |
|
116 | + )); |
|
117 | + $handler = $view->new_display('block', 'Block', 'block_1'); |
|
118 | + $handler->override_option('block_description', ''); |
|
119 | + $handler->override_option('block_caching', -1); |
|
120 | 120 | |
121 | - $views[$view->name] = $view; |
|
122 | - return $views; |
|
121 | + $views[$view->name] = $view; |
|
122 | + return $views; |
|
123 | 123 | } |
@@ -15,9 +15,9 @@ discard block |
||
15 | 15 | $view->tag = ''; |
16 | 16 | $view->view_php = ''; |
17 | 17 | $view->base_table = 'node'; |
18 | - $view->is_cacheable = FALSE; |
|
18 | + $view->is_cacheable = false; |
|
19 | 19 | $view->api_version = 2; |
20 | - $view->disabled = TRUE; |
|
20 | + $view->disabled = true; |
|
21 | 21 | $handler = $view->new_display('default', 'Defaults', 'default'); |
22 | 22 | $handler->override_option('fields', array( |
23 | 23 | 'nid' => array( |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | 'operator' => '=', |
89 | 89 | 'value' => '', |
90 | 90 | 'group' => '0', |
91 | - 'exposed' => FALSE, |
|
91 | + 'exposed' => false, |
|
92 | 92 | 'expose' => array( |
93 | - 'operator' => FALSE, |
|
93 | + 'operator' => false, |
|
94 | 94 | 'label' => '', |
95 | 95 | ), |
96 | 96 | 'id' => 'status_extra', |