GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( f05b96...91bb41 )
by gyeong-won
06:57
created
modules/widget/widget.view.php 2 patches
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,7 +21,9 @@  discard block
 block discarded – undo
21 21
 	function dispWidgetInfo()
22 22
 	{
23 23
 		// If people have skin widget widget output as a function of the skin More Details
24
-		if(Context::get('skin')) return $this->dispWidgetSkinInfo();
24
+		if(Context::get('skin')) {
25
+			return $this->dispWidgetSkinInfo();
26
+		}
25 27
 		// Wanted widget is selected information
26 28
 		$oWidgetModel = getModel('widget');
27 29
 		$widget_info = $oWidgetModel->getWidgetInfo(Context::get('selected_widget'));
@@ -62,7 +64,9 @@  discard block
 block discarded – undo
62 64
 
63 65
 		$widget_list = $oWidgetModel->getDownloadedWidgetList();
64 66
 		$selected_widget = Context::get('selected_widget');
65
-		if(!$selected_widget) $selected_widget = $widget_list[0]->widget;
67
+		if(!$selected_widget) {
68
+			$selected_widget = $widget_list[0]->widget;
69
+		}
66 70
 
67 71
 		$widget_info = $oWidgetModel->getWidgetInfo($selected_widget);
68 72
 		Context::set('widget_info', $widget_info);
@@ -89,8 +93,7 @@  discard block
 block discarded – undo
89 93
 			foreach($mid_list as $module_srl => $module) {
90 94
 				$module_categories[$module->module_category_srl]->list[$module_srl] = $module;
91 95
 			}
92
-		}
93
-		else
96
+		} else
94 97
 		{
95 98
 			$module_categories[0] = new stdClass();
96 99
 			$module_categories[0]->list = $mid_list;
@@ -118,7 +121,9 @@  discard block
 block discarded – undo
118 121
 		$widget_list = $oWidgetModel->getDownloadedWidgetList();
119 122
 		Context::set('widget_list',$widget_list);
120 123
 		// When there is no widget is selected in the first widget
121
-		if(!Context::get('selected_widget')) Context::set('selected_widget',$widget_list[0]->widget);
124
+		if(!Context::get('selected_widget')) {
125
+			Context::set('selected_widget',$widget_list[0]->widget);
126
+		}
122 127
 
123 128
 		$this->dispWidgetGenerateCode();
124 129
 		$this->setLayoutFile('default_layout');
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	function dispWidgetInfo()
22 22
 	{
23 23
 		// If people have skin widget widget output as a function of the skin More Details
24
-		if(Context::get('skin')) return $this->dispWidgetSkinInfo();
24
+		if (Context::get('skin')) return $this->dispWidgetSkinInfo();
25 25
 		// Wanted widget is selected information
26 26
 		$oWidgetModel = getModel('widget');
27 27
 		$widget_info = $oWidgetModel->getWidgetInfo(Context::get('selected_widget'));
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		$oModuleModel = getModel('module');
46 46
 		$skin_info = $oModuleModel->loadSkinInfo($path, $skin);
47 47
 
48
-		Context::set('skin_info',$skin_info);
48
+		Context::set('skin_info', $skin_info);
49 49
 		// Specifies the widget to pop up
50 50
 		$this->setLayoutFile('popup_layout');
51 51
 		// Set a template file
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 
63 63
 		$widget_list = $oWidgetModel->getDownloadedWidgetList();
64 64
 		$selected_widget = Context::get('selected_widget');
65
-		if(!$selected_widget) $selected_widget = $widget_list[0]->widget;
65
+		if (!$selected_widget) $selected_widget = $widget_list[0]->widget;
66 66
 
67 67
 		$widget_info = $oWidgetModel->getWidgetInfo($selected_widget);
68 68
 		Context::set('widget_info', $widget_info);
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 		$group_list = $oMemberModel->getGroups($site_module_info->site_srl);
85 85
 		Context::set('group_list', $group_list);
86 86
 		// module_category and module combination
87
-		if($module_categories)
87
+		if ($module_categories)
88 88
 		{
89
-			foreach($mid_list as $module_srl => $module) {
89
+			foreach ($mid_list as $module_srl => $module) {
90 90
 				$module_categories[$module->module_category_srl]->list[$module_srl] = $module;
91 91
 			}
92 92
 		}
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
 			$module_categories[0]->list = $mid_list;
97 97
 		}
98 98
 
99
-		Context::set('mid_list',$module_categories);
99
+		Context::set('mid_list', $module_categories);
100 100
 		// Menu Get a list
101 101
 		$output = executeQueryArray('menu.getMenus');
102
-		Context::set('menu_list',$output->data);
102
+		Context::set('menu_list', $output->data);
103 103
 		// Wanted information on skin
104 104
 		$skin_list = $oModuleModel->getSkins($widget_info->path);
105 105
 		Context::set('skin_list', $skin_list);
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 	{
117 117
 		$oWidgetModel = getModel('widget');
118 118
 		$widget_list = $oWidgetModel->getDownloadedWidgetList();
119
-		Context::set('widget_list',$widget_list);
119
+		Context::set('widget_list', $widget_list);
120 120
 		// When there is no widget is selected in the first widget
121
-		if(!Context::get('selected_widget')) Context::set('selected_widget',$widget_list[0]->widget);
121
+		if (!Context::get('selected_widget')) Context::set('selected_widget', $widget_list[0]->widget);
122 122
 
123 123
 		$this->dispWidgetGenerateCode();
124 124
 		$this->setLayoutFile('default_layout');
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
 		// Widget-style list
134 134
 		$oWidgetModel = getModel('widget');
135 135
 		$widgetStyle_list = $oWidgetModel->getDownloadedWidgetStyleList();
136
-		Context::set('widgetStyle_list',$widgetStyle_list);
136
+		Context::set('widgetStyle_list', $widgetStyle_list);
137 137
 		// Selected list of widget styles
138 138
 		$widgetstyle = Context::get('widgetstyle');
139 139
 		$widgetstyle_info = $oWidgetModel->getWidgetStyleInfo($widgetstyle);
140
-		if($widgetstyle && $widgetstyle_info)
140
+		if ($widgetstyle && $widgetstyle_info)
141 141
 		{
142
-			Context::set('widgetstyle_info',$widgetstyle_info);
142
+			Context::set('widgetstyle_info', $widgetstyle_info);
143 143
 		}
144 144
 
145 145
 		$this->dispWidgetGenerateCode();
Please login to merge, or discard this patch.
tools/dbxml_validator/connect_wrapper.php 3 patches
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 /**
13 13
   @brief
14 14
   @developer
15
-  */
15
+ */
16 16
 class DBMysqlConnectWrapper extends DBMysql
17 17
 {
18 18
 	public $queries = '';
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 		@developer
23 23
 		@return
24 24
 		@access
25
-		*/
25
+	 */
26 26
 	public function __construct()
27 27
 	{
28 28
 		$this->db_type = 'mysql';
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 		@developer
35 35
 		@return
36 36
 		@access
37
-		*/
37
+	 */
38 38
 	public function create()
39 39
 	{
40 40
 		return new DBMysqlConnectWrapper();
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		@developer
46 46
 		@return
47 47
 		@access
48
-		*/
48
+	 */
49 49
 	public function actDBClassStart()
50 50
 	{
51 51
 	}
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		@return
57 57
 		@access
58 58
 		@param $query
59
-		*/
59
+	 */
60 60
 	public function actStart($query)
61 61
 	{
62 62
 	}
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		@developer
67 67
 		@return
68 68
 		@access
69
-		*/
69
+	 */
70 70
 	public function actFinish()
71 71
 	{
72 72
 	}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		@developer
77 77
 		@return
78 78
 		@access
79
-		*/
79
+	 */
80 80
 	public function actDBClassFinish()
81 81
 	{
82 82
 	}
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		@developer
87 87
 		@return
88 88
 		@access
89
-		*/
89
+	 */
90 90
 	public function isSupported()
91 91
 	{
92 92
 		// No need to actually check for 'mysql_connect' function
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		@return
100 100
 		@access
101 101
 		@param $connection
102
-		*/
102
+	 */
103 103
 	public function __connect($connection)
104 104
 	{
105 105
 		return TRUE;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		@return
112 112
 		@access
113 113
 		@param $connection
114
-		*/
114
+	 */
115 115
 	public function _afterConnect($connection)
116 116
 	{
117 117
 	}
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 		@return
123 123
 		@access
124 124
 		@param $connection
125
-		*/
125
+	 */
126 126
 	public function _close($connection)
127 127
 	{
128 128
 	}
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		@access
135 135
 		@param $type
136 136
 		@param $indx
137
-		*/
137
+	 */
138 138
 	public function close($type = 'master', $indx = NULL)
139 139
 	{
140 140
 	}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		@developer
145 145
 		@return
146 146
 		@access
147
-		*/
147
+	 */
148 148
 	public function _begin()
149 149
 	{
150 150
 		return TRUE;
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 		@developer
156 156
 		@return
157 157
 		@access
158
-		*/
158
+	 */
159 159
 	public function _rollback()
160 160
 	{
161 161
 		return TRUE;
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 		@developer
167 167
 		@return
168 168
 		@access
169
-		*/
169
+	 */
170 170
 	public function _commit()
171 171
 	{
172 172
 		return TRUE;
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 		@access
180 180
 		@param $query
181 181
 		@param $connection
182
-		*/
182
+	 */
183 183
 	public function __query($query, $connection)
184 184
 	{
185 185
 		$this->queries .= "\n" . $query;
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 		@access
195 195
 		@param $result
196 196
 		@param $arrayIndexEndValue
197
-		*/
197
+	 */
198 198
 	public function _fetch($result, $arrayIndexEndValue = NULL)
199 199
 	{
200 200
 		return new Any_prop_obj_base();
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 		@return
207 207
 		@access
208 208
 		@param $target_name
209
-		*/
209
+	 */
210 210
 	public function isTableExists($target_name)
211 211
 	{
212 212
 		parent::isTableExists($target_name);
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 		@developer
220 220
 		@return
221 221
 		@access
222
-		*/
222
+	 */
223 223
 	public function db_insert_id()
224 224
 	{
225 225
 		return NULL;
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 		@return
232 232
 		@access
233 233
 		@param $result
234
-		*/
234
+	 */
235 235
 	public function db_fetch_object(&$result)
236 236
 	{
237 237
 		return new Any_prop_obj_base();
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 /**
242 242
   @brief
243 243
   @developer
244
-  */
244
+ */
245 245
 class DBMysqliConnectWrapper extends DBMysqli
246 246
 {
247 247
 	public $queries = '';
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 		@developer
252 252
 		@return
253 253
 		@access
254
-		*/
254
+	 */
255 255
 	public function __construct()
256 256
 	{
257 257
 		$this->db_type = 'mysqli';
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 		@developer
264 264
 		@return
265 265
 		@access
266
-		*/
266
+	 */
267 267
 	public function create()
268 268
 	{
269 269
 		return new DBMysqlConnectWrapper();
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 		@developer
275 275
 		@return
276 276
 		@access
277
-		*/
277
+	 */
278 278
 	public function actDBClassStart()
279 279
 	{
280 280
 	}
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 		@return
286 286
 		@access
287 287
 		@param $query
288
-		*/
288
+	 */
289 289
 	public function actStart($query)
290 290
 	{
291 291
 	}
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 		@developer
296 296
 		@return
297 297
 		@access
298
-		*/
298
+	 */
299 299
 	public function actFinish()
300 300
 	{
301 301
 	}
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 		@developer
306 306
 		@return
307 307
 		@access
308
-		*/
308
+	 */
309 309
 	public function actDBClassFinish()
310 310
 	{
311 311
 	}
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 		@developer
316 316
 		@return
317 317
 		@access
318
-		*/
318
+	 */
319 319
 	public function isSupported()
320 320
 	{
321 321
 		// No need to actually check for 'mysql_connect' function
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 		@return
329 329
 		@access
330 330
 		@param $target_name
331
-		*/
331
+	 */
332 332
 	public function isTableExists($target_name)
333 333
 	{
334 334
 		parent::isTableExists($target_name);
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 		@return
345 345
 		@access
346 346
 		@param $string
347
-		*/
347
+	 */
348 348
 	public function addQuotes($string)
349 349
 	{
350 350
 		if(version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc())
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 		@return
367 367
 		@access
368 368
 		@param $connection
369
-		*/
369
+	 */
370 370
 	public function __connect($connection)
371 371
 	{
372 372
 		return TRUE;
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 		@return
379 379
 		@access
380 380
 		@param $connection
381
-		*/
381
+	 */
382 382
 	public function _afterConnect($connection)
383 383
 	{
384 384
 	}
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 		@return
390 390
 		@access
391 391
 		@param $connection
392
-		*/
392
+	 */
393 393
 	public function _close($connection)
394 394
 	{
395 395
 	}
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 		@access
402 402
 		@param $type
403 403
 		@param $indx
404
-		*/
404
+	 */
405 405
 	public function close($type = 'master', $indx = NULL)
406 406
 	{
407 407
 	}
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 		@developer
412 412
 		@return
413 413
 		@access
414
-		*/
414
+	 */
415 415
 	public function _begin()
416 416
 	{
417 417
 		return TRUE;
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 		@developer
423 423
 		@return
424 424
 		@access
425
-		*/
425
+	 */
426 426
 	public function _rollback()
427 427
 	{
428 428
 		return TRUE;
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 		@developer
434 434
 		@return
435 435
 		@access
436
-		*/
436
+	 */
437 437
 	public function _commit()
438 438
 	{
439 439
 		return TRUE;
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 		@access
447 447
 		@param $query
448 448
 		@param $connection
449
-		*/
449
+	 */
450 450
 	public function __query($query, $connection)
451 451
 	{
452 452
 		$this->queries .= "\n" . $query;
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 		@access
462 462
 		@param $result
463 463
 		@param $arrayIndexEndValue
464
-		*/
464
+	 */
465 465
 	public function _fetch($result, $arrayIndexEndValue = NULL)
466 466
 	{
467 467
 		return new Any_prop_obj_base();
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 		@developer
473 473
 		@return
474 474
 		@access
475
-		*/
475
+	 */
476 476
 	public function db_insert_id()
477 477
 	{
478 478
 		return NULL;
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 		@return
485 485
 		@access
486 486
 		@param $result
487
-		*/
487
+	 */
488 488
 	public function db_fetch_object(&$result)
489 489
 	{
490 490
 		return new Any_prop_obj_base();
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 /**
495 495
   @brief
496 496
   @developer
497
-  */
497
+ */
498 498
 class DBCubridConnectWrapper extends DBCubrid
499 499
 {
500 500
 	public $queries = '';
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 		@developer
505 505
 		@return
506 506
 		@access
507
-		*/
507
+	 */
508 508
 	public function __construct()
509 509
 	{
510 510
 		$this->db_type = 'cubrid';
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 		@developer
517 517
 		@return
518 518
 		@access
519
-		*/
519
+	 */
520 520
 	public function create()
521 521
 	{
522 522
 		return new DBMysqlConnectWrapper();
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 		@developer
528 528
 		@return
529 529
 		@access
530
-		*/
530
+	 */
531 531
 	public function actDBClassStart()
532 532
 	{
533 533
 	}
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 		@return
539 539
 		@access
540 540
 		@param $query
541
-		*/
541
+	 */
542 542
 	public function actStart($query)
543 543
 	{
544 544
 	}
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 		@developer
549 549
 		@return
550 550
 		@access
551
-		*/
551
+	 */
552 552
 	public function _makeSequence()
553 553
 	{
554 554
 		return TRUE;
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 		@developer
560 560
 		@return
561 561
 		@access
562
-		*/
562
+	 */
563 563
 	public function actFinish()
564 564
 	{
565 565
 	}
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 		@developer
570 570
 		@return
571 571
 		@access
572
-		*/
572
+	 */
573 573
 	public function actDBClassFinish()
574 574
 	{
575 575
 	}
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 		@developer
580 580
 		@return
581 581
 		@access
582
-		*/
582
+	 */
583 583
 	public function isSupported()
584 584
 	{
585 585
 		// No need to actually check for 'cubrid_connect' function
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 		@return
593 593
 		@access
594 594
 		@param $target_name
595
-		*/
595
+	 */
596 596
 	public function isTableExists($target_name)
597 597
 	{
598 598
 		try
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 		@return
613 613
 		@access
614 614
 		@param $connection
615
-		*/
615
+	 */
616 616
 	public function __connect($connection)
617 617
 	{
618 618
 		return TRUE;
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 		@return
625 625
 		@access
626 626
 		@param $connection
627
-		*/
627
+	 */
628 628
 	public function _afterConnect($connection)
629 629
 	{
630 630
 	}
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 		@return
636 636
 		@access
637 637
 		@param $connection
638
-		*/
638
+	 */
639 639
 	public function _close($connection)
640 640
 	{
641 641
 	}
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 		@access
648 648
 		@param $type
649 649
 		@param $indx
650
-		*/
650
+	 */
651 651
 	public function close($type = 'master', $indx = NULL)
652 652
 	{
653 653
 	}
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 		@developer
658 658
 		@return
659 659
 		@access
660
-		*/
660
+	 */
661 661
 	public function _begin()
662 662
 	{
663 663
 		return TRUE;
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 		@developer
669 669
 		@return
670 670
 		@access
671
-		*/
671
+	 */
672 672
 	public function _rollback()
673 673
 	{
674 674
 		return TRUE;
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
 		@developer
680 680
 		@return
681 681
 		@access
682
-		*/
682
+	 */
683 683
 	public function _commit()
684 684
 	{
685 685
 		return TRUE;
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 		@access
693 693
 		@param $query
694 694
 		@param $connection
695
-		*/
695
+	 */
696 696
 	public function __query($query, $connection)
697 697
 	{
698 698
 		$this->queries .= "\n" . $query;
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 		@access
708 708
 		@param $result
709 709
 		@param $arrayIndexEndValue
710
-		*/
710
+	 */
711 711
 	public function _fetch($result, $arrayIndexEndValue = NULL)
712 712
 	{
713 713
 		return new Any_prop_obj_base();
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 		@developer
719 719
 		@return
720 720
 		@access
721
-		*/
721
+	 */
722 722
 	public function db_insert_id()
723 723
 	{
724 724
 		return NULL;
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
 		@developer
730 730
 		@return
731 731
 		@access
732
-		*/
732
+	 */
733 733
 	public function &db_fetch_object()
734 734
 	{
735 735
 		return new Any_prop_obj_base();
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
 /**
740 740
   @brief
741 741
   @developer
742
-  */
742
+ */
743 743
 class DBMssqlConnectWrapper extends DBMssql
744 744
 {
745 745
 	public $queries = '';
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 		@developer
750 750
 		@return
751 751
 		@access
752
-		*/
752
+	 */
753 753
 	public function __construct()
754 754
 	{
755 755
 		$this->db_type = 'mssql';
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 		@developer
762 762
 		@return
763 763
 		@access
764
-		*/
764
+	 */
765 765
 	public function create()
766 766
 	{
767 767
 		return new DBMssqlConnectWrapper();
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 		@developer
773 773
 		@return
774 774
 		@access
775
-		*/
775
+	 */
776 776
 	public function actDBClassStart()
777 777
 	{
778 778
 	}
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 		@return
784 784
 		@access
785 785
 		@param $query
786
-		*/
786
+	 */
787 787
 	public function actStart($query)
788 788
 	{
789 789
 	}
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
 		@developer
794 794
 		@return
795 795
 		@access
796
-		*/
796
+	 */
797 797
 	public function actFinish()
798 798
 	{
799 799
 	}
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 		@developer
804 804
 		@return
805 805
 		@access
806
-		*/
806
+	 */
807 807
 	public function actDBClassFinish()
808 808
 	{
809 809
 	}
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 		@developer
814 814
 		@return
815 815
 		@access
816
-		*/
816
+	 */
817 817
 	public function isSupported()
818 818
 	{
819 819
 		// No need to actually check for 'mssql_connect' function
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
 		@return
827 827
 		@access
828 828
 		@param $target_name
829
-		*/
829
+	 */
830 830
 	public function isTableExists($target_name)
831 831
 	{
832 832
 		parent::isTableExists($target_name);
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
 		@return
841 841
 		@access
842 842
 		@param $connection
843
-		*/
843
+	 */
844 844
 	public function __connect($connection)
845 845
 	{
846 846
 		return TRUE;
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
 		@return
853 853
 		@access
854 854
 		@param $connection
855
-		*/
855
+	 */
856 856
 	public function _afterConnect($connection)
857 857
 	{
858 858
 	}
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 		@return
864 864
 		@access
865 865
 		@param $connection
866
-		*/
866
+	 */
867 867
 	public function _close($connection)
868 868
 	{
869 869
 	}
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
 		@access
876 876
 		@param $type
877 877
 		@param $indx
878
-		*/
878
+	 */
879 879
 	public function close($type = 'master', $indx = NULL)
880 880
 	{
881 881
 	}
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
 		@developer
886 886
 		@return
887 887
 		@access
888
-		*/
888
+	 */
889 889
 	public function _begin()
890 890
 	{
891 891
 		return TRUE;
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 		@developer
897 897
 		@return
898 898
 		@access
899
-		*/
899
+	 */
900 900
 	public function _rollback()
901 901
 	{
902 902
 		return TRUE;
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
 		@developer
908 908
 		@return
909 909
 		@access
910
-		*/
910
+	 */
911 911
 	public function _commit()
912 912
 	{
913 913
 		return TRUE;
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
 		@access
921 921
 		@param $query
922 922
 		@param $connection
923
-		*/
923
+	 */
924 924
 	public function __query($query, $connection)
925 925
 	{
926 926
 		if($this->queries)
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
 		@access
941 941
 		@param $result
942 942
 		@param $arrayIndexEndValue
943
-		*/
943
+	 */
944 944
 	public function _fetch($result, $arrayIndexEndValue = NULL)
945 945
 	{
946 946
 		return new Any_prop_obj_base();
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
 		@developer
952 952
 		@return
953 953
 		@access
954
-		*/
954
+	 */
955 955
 	public function db_insert_id()
956 956
 	{
957 957
 		return NULL;
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
 		@developer
963 963
 		@return
964 964
 		@access
965
-		*/
965
+	 */
966 966
 	public function &db_fetch_object()
967 967
 	{
968 968
 		return new Any_prop_obj_base();
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -598,8 +598,7 @@
 block discarded – undo
598 598
 		try
599 599
 		{
600 600
 			parent::isTableExists($target_name);
601
-		}
602
-		catch (Exception $ex)
601
+		} catch (Exception $ex)
603 602
 		{
604 603
 		}
605 604
 
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	public function __construct()
27 27
 	{
28 28
 		$this->db_type = 'mysql';
29
-		$this->_setDBInfo();	// Context::get() should indicate a mysql db
29
+		$this->_setDBInfo(); // Context::get() should indicate a mysql db
30 30
 	}
31 31
 
32 32
 	/**
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 		*/
183 183
 	public function __query($query, $connection)
184 184
 	{
185
-		$this->queries .= "\n" . $query;
185
+		$this->queries .= "\n".$query;
186 186
 
187 187
 		return TRUE;
188 188
 	}
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 	public function __construct()
256 256
 	{
257 257
 		$this->db_type = 'mysqli';
258
-		$this->_setDBInfo();	// Context::get() should indicate a mysqli db
258
+		$this->_setDBInfo(); // Context::get() should indicate a mysqli db
259 259
 	}
260 260
 
261 261
 	/**
@@ -347,12 +347,12 @@  discard block
 block discarded – undo
347 347
 		*/
348 348
 	public function addQuotes($string)
349 349
 	{
350
-		if(version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc())
350
+		if (version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc())
351 351
 		{
352 352
 			$string = stripslashes(str_replace("\\", "\\\\", $string));
353 353
 		}
354 354
 
355
-		if(!is_numeric($string))
355
+		if (!is_numeric($string))
356 356
 		{
357 357
 			$string = @mysql_real_escape_string($string);
358 358
 		}
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 		*/
450 450
 	public function __query($query, $connection)
451 451
 	{
452
-		$this->queries .= "\n" . $query;
452
+		$this->queries .= "\n".$query;
453 453
 
454 454
 		return TRUE;
455 455
 	}
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 	public function __construct()
509 509
 	{
510 510
 		$this->db_type = 'cubrid';
511
-		$this->_setDBInfo();	// Context::get() should indicate a CUBRID db
511
+		$this->_setDBInfo(); // Context::get() should indicate a CUBRID db
512 512
 	}
513 513
 
514 514
 	/**
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 		*/
696 696
 	public function __query($query, $connection)
697 697
 	{
698
-		$this->queries .= "\n" . $query;
698
+		$this->queries .= "\n".$query;
699 699
 
700 700
 		return TRUE;
701 701
 	}
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 	public function __construct()
754 754
 	{
755 755
 		$this->db_type = 'mssql';
756
-		$this->_setDBInfo();	// Context::get() should indicate a MS Sql db
756
+		$this->_setDBInfo(); // Context::get() should indicate a MS Sql db
757 757
 	}
758 758
 
759 759
 	/**
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
 		*/
924 924
 	public function __query($query, $connection)
925 925
 	{
926
-		if($this->queries)
926
+		if ($this->queries)
927 927
 		{
928 928
 			$this->queries .= ";\n";
929 929
 		}
Please login to merge, or discard this patch.
widgets/counter_status/counter_status.class.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,13 +19,13 @@
 block discarded – undo
19 19
 		$oCounterModel = getModel('counter');
20 20
 
21 21
 		$site_module_info = Context::get('site_module_info');
22
-		$output = $oCounterModel->getStatus(array('00000000', date('Ymd', $_SERVER['REQUEST_TIME']-60*60*24), date('Ymd')), $site_module_info->site_srl);
23
-		if(count($output))
22
+		$output = $oCounterModel->getStatus(array('00000000', date('Ymd', $_SERVER['REQUEST_TIME'] - 60 * 60 * 24), date('Ymd')), $site_module_info->site_srl);
23
+		if (count($output))
24 24
 		{
25
-			foreach($output as $key => $val) 
25
+			foreach ($output as $key => $val) 
26 26
 			{
27
-				if(!$key) Context::set('total_counter', $val);
28
-				elseif($key == date("Ymd")) Context::set('today_counter', $val);
27
+				if (!$key) Context::set('total_counter', $val);
28
+				elseif ($key == date("Ymd")) Context::set('today_counter', $val);
29 29
 				else Context::set('yesterday_counter', $val);
30 30
 			}
31 31
 		}
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,9 +24,13 @@
 block discarded – undo
24 24
 		{
25 25
 			foreach($output as $key => $val) 
26 26
 			{
27
-				if(!$key) Context::set('total_counter', $val);
28
-				elseif($key == date("Ymd")) Context::set('today_counter', $val);
29
-				else Context::set('yesterday_counter', $val);
27
+				if(!$key) {
28
+					Context::set('total_counter', $val);
29
+				} elseif($key == date("Ymd")) {
30
+					Context::set('today_counter', $val);
31
+				} else {
32
+					Context::set('yesterday_counter', $val);
33
+				}
30 34
 			}
31 35
 		}
32 36
 		// Set a path of the template skin (values of skin, colorset settings)
Please login to merge, or discard this patch.
widgets/login_info/login_info.class.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 		$tpl_path = sprintf('%sskins/%s', $this->widget_path, $args->skin);
22 22
 		Context::set('colorset', $args->colorset);
23 23
 		// Specify a template file
24
-		if(Context::get('is_logged')) $tpl_file = 'login_info';
24
+		if (Context::get('is_logged')) $tpl_file = 'login_info';
25 25
 		else $tpl_file = 'login_form';
26 26
 		// Get the member configuration
27 27
 		$oModuleModel = getModel('module');
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 		// Set a flag to check if the https connection is made when using SSL and create https url 
32 32
 		$ssl_mode = false;
33 33
 		$useSsl = Context::getSslStatus();
34
-		if($useSsl != 'none')
34
+		if ($useSsl != 'none')
35 35
 		{
36
-			if(strncasecmp('https://', Context::getRequestUri(), 8) === 0) $ssl_mode = true;
36
+			if (strncasecmp('https://', Context::getRequestUri(), 8) === 0) $ssl_mode = true;
37 37
 		}
38
-		Context::set('ssl_mode',$ssl_mode);
38
+		Context::set('ssl_mode', $ssl_mode);
39 39
 
40 40
 		// Compile a template
41 41
 		$oTemplate = &TemplateHandler::getInstance();
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,8 +21,11 @@  discard block
 block discarded – undo
21 21
 		$tpl_path = sprintf('%sskins/%s', $this->widget_path, $args->skin);
22 22
 		Context::set('colorset', $args->colorset);
23 23
 		// Specify a template file
24
-		if(Context::get('is_logged')) $tpl_file = 'login_info';
25
-		else $tpl_file = 'login_form';
24
+		if(Context::get('is_logged')) {
25
+			$tpl_file = 'login_info';
26
+		} else {
27
+			$tpl_file = 'login_form';
28
+		}
26 29
 		// Get the member configuration
27 30
 		$oModuleModel = getModel('module');
28 31
 		$this->member_config = $oModuleModel->getModuleConfig('member');
@@ -33,7 +36,9 @@  discard block
 block discarded – undo
33 36
 		$useSsl = Context::getSslStatus();
34 37
 		if($useSsl != 'none')
35 38
 		{
36
-			if(strncasecmp('https://', Context::getRequestUri(), 8) === 0) $ssl_mode = true;
39
+			if(strncasecmp('https://', Context::getRequestUri(), 8) === 0) {
40
+				$ssl_mode = true;
41
+			}
37 42
 		}
38 43
 		Context::set('ssl_mode',$ssl_mode);
39 44
 
Please login to merge, or discard this patch.
libs/PEAR.1.9/HTTP/Request2/Adapter/Mock.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     * A queue of responses to be returned by sendRequest()
75 75
     * @var  array
76 76
     */
77
-    protected $responses = array();
77
+	protected $responses = array();
78 78
 
79 79
    /**
80 80
     * Returns the next response from the queue built by addResponse()
@@ -86,23 +86,23 @@  discard block
 block discarded – undo
86 86
     * @return   HTTP_Request2_Response
87 87
     * @throws   Exception
88 88
     */
89
-    public function sendRequest(HTTP_Request2 $request)
90
-    {
91
-        if (count($this->responses) > 0) {
92
-            $response = array_shift($this->responses);
93
-            if ($response instanceof HTTP_Request2_Response) {
94
-                return $response;
95
-            } else {
96
-                // rethrow the exception
97
-                $class   = get_class($response);
98
-                $message = $response->getMessage();
99
-                $code    = $response->getCode();
100
-                throw new $class($message, $code);
101
-            }
102
-        } else {
103
-            return self::createResponseFromString("HTTP/1.1 400 Bad Request\r\n\r\n");
104
-        }
105
-    }
89
+	public function sendRequest(HTTP_Request2 $request)
90
+	{
91
+		if (count($this->responses) > 0) {
92
+			$response = array_shift($this->responses);
93
+			if ($response instanceof HTTP_Request2_Response) {
94
+				return $response;
95
+			} else {
96
+				// rethrow the exception
97
+				$class   = get_class($response);
98
+				$message = $response->getMessage();
99
+				$code    = $response->getCode();
100
+				throw new $class($message, $code);
101
+			}
102
+		} else {
103
+			return self::createResponseFromString("HTTP/1.1 400 Bad Request\r\n\r\n");
104
+		}
105
+	}
106 106
 
107 107
    /**
108 108
     * Adds response to the queue
@@ -111,19 +111,19 @@  discard block
 block discarded – undo
111 111
     *                   an instance of HTTP_Request2_Response or Exception
112 112
     * @throws   HTTP_Request2_Exception
113 113
     */
114
-    public function addResponse($response)
115
-    {
116
-        if (is_string($response)) {
117
-            $response = self::createResponseFromString($response);
118
-        } elseif (is_resource($response)) {
119
-            $response = self::createResponseFromFile($response);
120
-        } elseif (!$response instanceof HTTP_Request2_Response &&
121
-                  !$response instanceof Exception
122
-        ) {
123
-            throw new HTTP_Request2_Exception('Parameter is not a valid response');
124
-        }
125
-        $this->responses[] = $response;
126
-    }
114
+	public function addResponse($response)
115
+	{
116
+		if (is_string($response)) {
117
+			$response = self::createResponseFromString($response);
118
+		} elseif (is_resource($response)) {
119
+			$response = self::createResponseFromFile($response);
120
+		} elseif (!$response instanceof HTTP_Request2_Response &&
121
+				  !$response instanceof Exception
122
+		) {
123
+			throw new HTTP_Request2_Exception('Parameter is not a valid response');
124
+		}
125
+		$this->responses[] = $response;
126
+	}
127 127
 
128 128
    /**
129 129
     * Creates a new HTTP_Request2_Response object from a string
@@ -132,20 +132,20 @@  discard block
 block discarded – undo
132 132
     * @return   HTTP_Request2_Response
133 133
     * @throws   HTTP_Request2_Exception
134 134
     */
135
-    public static function createResponseFromString($str)
136
-    {
137
-        $parts       = preg_split('!(\r?\n){2}!m', $str, 2);
138
-        $headerLines = explode("\n", $parts[0]);
139
-        $response    = new HTTP_Request2_Response(array_shift($headerLines));
140
-        foreach ($headerLines as $headerLine) {
141
-            $response->parseHeaderLine($headerLine);
142
-        }
143
-        $response->parseHeaderLine('');
144
-        if (isset($parts[1])) {
145
-            $response->appendBody($parts[1]);
146
-        }
147
-        return $response;
148
-    }
135
+	public static function createResponseFromString($str)
136
+	{
137
+		$parts       = preg_split('!(\r?\n){2}!m', $str, 2);
138
+		$headerLines = explode("\n", $parts[0]);
139
+		$response    = new HTTP_Request2_Response(array_shift($headerLines));
140
+		foreach ($headerLines as $headerLine) {
141
+			$response->parseHeaderLine($headerLine);
142
+		}
143
+		$response->parseHeaderLine('');
144
+		if (isset($parts[1])) {
145
+			$response->appendBody($parts[1]);
146
+		}
147
+		return $response;
148
+	}
149 149
 
150 150
    /**
151 151
     * Creates a new HTTP_Request2_Response object from a file
@@ -154,18 +154,18 @@  discard block
 block discarded – undo
154 154
     * @return   HTTP_Request2_Response
155 155
     * @throws   HTTP_Request2_Exception
156 156
     */
157
-    public static function createResponseFromFile($fp)
158
-    {
159
-        $response = new HTTP_Request2_Response(fgets($fp));
160
-        do {
161
-            $headerLine = fgets($fp);
162
-            $response->parseHeaderLine($headerLine);
163
-        } while ('' != trim($headerLine));
157
+	public static function createResponseFromFile($fp)
158
+	{
159
+		$response = new HTTP_Request2_Response(fgets($fp));
160
+		do {
161
+			$headerLine = fgets($fp);
162
+			$response->parseHeaderLine($headerLine);
163
+		} while ('' != trim($headerLine));
164 164
 
165
-        while (!feof($fp)) {
166
-            $response->appendBody(fread($fp, 8192));
167
-        }
168
-        return $response;
169
-    }
165
+		while (!feof($fp)) {
166
+			$response->appendBody(fread($fp, 8192));
167
+		}
168
+		return $response;
169
+	}
170 170
 }
171 171
 ?>
172 172
\ No newline at end of file
Please login to merge, or discard this patch.
libs/phpmailer/language/phpmailer.lang-en.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@
 block discarded – undo
7 7
 $PHPMAILER_LANG = array();
8 8
 
9 9
 $PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' .
10
-                                     'recipient email address.';
10
+									 'recipient email address.';
11 11
 $PHPMAILER_LANG["mailer_not_supported"] = ' mailer is not supported.';
12 12
 $PHPMAILER_LANG["execute"] = 'Could not execute: ';
13 13
 $PHPMAILER_LANG["instantiate"] = 'Could not instantiate mail function.';
14 14
 $PHPMAILER_LANG["authenticate"] = 'SMTP Error: Could not authenticate.';
15 15
 $PHPMAILER_LANG["from_failed"] = 'The following From address failed: ';
16 16
 $PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following ' .
17
-                                       'recipients failed: ';
17
+									   'recipients failed: ';
18 18
 $PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data not accepted.';
19 19
 $PHPMAILER_LANG["connect_host"] = 'SMTP Error: Could not connect to SMTP host.';
20 20
 $PHPMAILER_LANG["file_access"] = 'Could not access file: ';
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,14 +6,14 @@
 block discarded – undo
6 6
 
7 7
 $PHPMAILER_LANG = array();
8 8
 
9
-$PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' .
9
+$PHPMAILER_LANG["provide_address"] = 'You must provide at least one '.
10 10
                                      'recipient email address.';
11 11
 $PHPMAILER_LANG["mailer_not_supported"] = ' mailer is not supported.';
12 12
 $PHPMAILER_LANG["execute"] = 'Could not execute: ';
13 13
 $PHPMAILER_LANG["instantiate"] = 'Could not instantiate mail function.';
14 14
 $PHPMAILER_LANG["authenticate"] = 'SMTP Error: Could not authenticate.';
15 15
 $PHPMAILER_LANG["from_failed"] = 'The following From address failed: ';
16
-$PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following ' .
16
+$PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following '.
17 17
                                        'recipients failed: ';
18 18
 $PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data not accepted.';
19 19
 $PHPMAILER_LANG["connect_host"] = 'SMTP Error: Could not connect to SMTP host.';
Please login to merge, or discard this patch.
libs/PEAR.1.9.5/HTTP/Request2/Exception.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -36,58 +36,58 @@
 block discarded – undo
36 36
  */
37 37
 class HTTP_Request2_Exception extends PEAR_Exception
38 38
 {
39
-    /** An invalid argument was passed to a method */
40
-    const INVALID_ARGUMENT   = 1;
41
-    /** Some required value was not available */
42
-    const MISSING_VALUE      = 2;
43
-    /** Request cannot be processed due to errors in PHP configuration */
44
-    const MISCONFIGURATION   = 3;
45
-    /** Error reading the local file */
46
-    const READ_ERROR         = 4;
39
+	/** An invalid argument was passed to a method */
40
+	const INVALID_ARGUMENT   = 1;
41
+	/** Some required value was not available */
42
+	const MISSING_VALUE      = 2;
43
+	/** Request cannot be processed due to errors in PHP configuration */
44
+	const MISCONFIGURATION   = 3;
45
+	/** Error reading the local file */
46
+	const READ_ERROR         = 4;
47 47
 
48
-    /** Server returned a response that does not conform to HTTP protocol */
49
-    const MALFORMED_RESPONSE = 10;
50
-    /** Failure decoding Content-Encoding or Transfer-Encoding of response */
51
-    const DECODE_ERROR       = 20;
52
-    /** Operation timed out */
53
-    const TIMEOUT            = 30;
54
-    /** Number of redirects exceeded 'max_redirects' configuration parameter */
55
-    const TOO_MANY_REDIRECTS = 40;
56
-    /** Redirect to a protocol other than http(s):// */
57
-    const NON_HTTP_REDIRECT  = 50;
48
+	/** Server returned a response that does not conform to HTTP protocol */
49
+	const MALFORMED_RESPONSE = 10;
50
+	/** Failure decoding Content-Encoding or Transfer-Encoding of response */
51
+	const DECODE_ERROR       = 20;
52
+	/** Operation timed out */
53
+	const TIMEOUT            = 30;
54
+	/** Number of redirects exceeded 'max_redirects' configuration parameter */
55
+	const TOO_MANY_REDIRECTS = 40;
56
+	/** Redirect to a protocol other than http(s):// */
57
+	const NON_HTTP_REDIRECT  = 50;
58 58
 
59
-    /**
60
-     * Native error code
61
-     * @var int
62
-     */
63
-    private $_nativeCode;
59
+	/**
60
+	 * Native error code
61
+	 * @var int
62
+	 */
63
+	private $_nativeCode;
64 64
 
65
-    /**
66
-     * Constructor, can set package error code and native error code
67
-     *
68
-     * @param string $message    exception message
69
-     * @param int    $code       package error code, one of class constants
70
-     * @param int    $nativeCode error code from underlying PHP extension
71
-     */
72
-    public function __construct($message = null, $code = null, $nativeCode = null)
73
-    {
74
-        parent::__construct($message, $code);
75
-        $this->_nativeCode = $nativeCode;
76
-    }
65
+	/**
66
+	 * Constructor, can set package error code and native error code
67
+	 *
68
+	 * @param string $message    exception message
69
+	 * @param int    $code       package error code, one of class constants
70
+	 * @param int    $nativeCode error code from underlying PHP extension
71
+	 */
72
+	public function __construct($message = null, $code = null, $nativeCode = null)
73
+	{
74
+		parent::__construct($message, $code);
75
+		$this->_nativeCode = $nativeCode;
76
+	}
77 77
 
78
-    /**
79
-     * Returns error code produced by underlying PHP extension
80
-     *
81
-     * For Socket Adapter this may contain error number returned by
82
-     * stream_socket_client(), for Curl Adapter this will contain error number
83
-     * returned by curl_errno()
84
-     *
85
-     * @return integer
86
-     */
87
-    public function getNativeCode()
88
-    {
89
-        return $this->_nativeCode;
90
-    }
78
+	/**
79
+	 * Returns error code produced by underlying PHP extension
80
+	 *
81
+	 * For Socket Adapter this may contain error number returned by
82
+	 * stream_socket_client(), for Curl Adapter this will contain error number
83
+	 * returned by curl_errno()
84
+	 *
85
+	 * @return integer
86
+	 */
87
+	public function getNativeCode()
88
+	{
89
+		return $this->_nativeCode;
90
+	}
91 91
 }
92 92
 
93 93
 /**
Please login to merge, or discard this patch.
libs/PEAR/HTTP/Request/Listener.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -60,17 +60,17 @@  discard block
 block discarded – undo
60 60
     * A listener's identifier
61 61
     * @var string
62 62
     */
63
-    var $_id;
63
+	var $_id;
64 64
 
65 65
    /**
66 66
     * Constructor, sets the object's identifier
67 67
     *
68 68
     * @access public
69 69
     */
70
-    function HTTP_Request_Listener()
71
-    {
72
-        $this->_id = md5(uniqid('http_request_', 1));
73
-    }
70
+	function HTTP_Request_Listener()
71
+	{
72
+		$this->_id = md5(uniqid('http_request_', 1));
73
+	}
74 74
 
75 75
 
76 76
    /**
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
     * @access public
80 80
     * @return string
81 81
     */
82
-    function getId()
83
-    {
84
-        return $this->_id;
85
-    }
82
+	function getId()
83
+	{
84
+		return $this->_id;
85
+	}
86 86
 
87 87
 
88 88
    /**
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
     * @param    mixed   Additional data
95 95
     * @abstract
96 96
     */
97
-    function update(&$subject, $event, $data = null)
98
-    {
99
-        echo "Notified of event: '$event'\n";
100
-        if (null !== $data) {
101
-            echo "Additional data: ";
102
-            var_dump($data);
103
-        }
104
-    }
97
+	function update(&$subject, $event, $data = null)
98
+	{
99
+		echo "Notified of event: '$event'\n";
100
+		if (null !== $data) {
101
+			echo "Additional data: ";
102
+			var_dump($data);
103
+		}
104
+	}
105 105
 }
106 106
 ?>
Please login to merge, or discard this patch.
libs/PEAR.1.9/HTTP/Request2/Adapter/Socket.php 2 patches
Indentation   +719 added lines, -719 removed lines patch added patch discarded remove patch
@@ -62,19 +62,19 @@  discard block
 block discarded – undo
62 62
    /**
63 63
     * Regular expression for 'token' rule from RFC 2616
64 64
     */
65
-    const REGEXP_TOKEN = '[^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+';
65
+	const REGEXP_TOKEN = '[^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+';
66 66
 
67 67
    /**
68 68
     * Regular expression for 'quoted-string' rule from RFC 2616
69 69
     */
70
-    const REGEXP_QUOTED_STRING = '"(?:\\\\.|[^\\\\"])*"';
70
+	const REGEXP_QUOTED_STRING = '"(?:\\\\.|[^\\\\"])*"';
71 71
 
72 72
    /**
73 73
     * Connected sockets, needed for Keep-Alive support
74 74
     * @var  array
75 75
     * @see  connect()
76 76
     */
77
-    protected static $sockets = array();
77
+	protected static $sockets = array();
78 78
 
79 79
    /**
80 80
     * Data for digest authentication scheme
@@ -88,39 +88,39 @@  discard block
 block discarded – undo
88 88
     *
89 89
     * @var  array
90 90
     */
91
-    protected static $challenges = array();
91
+	protected static $challenges = array();
92 92
 
93 93
    /**
94 94
     * Connected socket
95 95
     * @var  resource
96 96
     * @see  connect()
97 97
     */
98
-    protected $socket;
98
+	protected $socket;
99 99
 
100 100
    /**
101 101
     * Challenge used for server digest authentication
102 102
     * @var  array
103 103
     */
104
-    protected $serverChallenge;
104
+	protected $serverChallenge;
105 105
 
106 106
    /**
107 107
     * Challenge used for proxy digest authentication
108 108
     * @var  array
109 109
     */
110
-    protected $proxyChallenge;
110
+	protected $proxyChallenge;
111 111
 
112 112
    /**
113 113
     * Sum of start time and global timeout, exception will be thrown if request continues past this time
114 114
     * @var  integer
115 115
     */
116
-    protected $deadline = null;
116
+	protected $deadline = null;
117 117
 
118 118
    /**
119 119
     * Remaining length of the current chunk, when reading chunked response
120 120
     * @var  integer
121 121
     * @see  readChunked()
122 122
     */
123
-    protected $chunkLength = 0;
123
+	protected $chunkLength = 0;
124 124
 
125 125
    /**
126 126
     * Remaining amount of redirections to follow
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     *
131 131
     * @var  integer
132 132
     */
133
-    protected $redirectCountdown = null;
133
+	protected $redirectCountdown = null;
134 134
 
135 135
    /**
136 136
     * Sends request to the remote server and returns its response
@@ -139,69 +139,69 @@  discard block
 block discarded – undo
139 139
     * @return   HTTP_Request2_Response
140 140
     * @throws   HTTP_Request2_Exception
141 141
     */
142
-    public function sendRequest(HTTP_Request2 $request)
143
-    {
144
-        $this->request = $request;
145
-
146
-        // Use global request timeout if given, see feature requests #5735, #8964
147
-        if ($timeout = $request->getConfig('timeout')) {
148
-            $this->deadline = time() + $timeout;
149
-        } else {
150
-            $this->deadline = null;
151
-        }
152
-
153
-        try {
154
-            $keepAlive = $this->connect();
155
-            $headers   = $this->prepareHeaders();
156
-            if (false === @fwrite($this->socket, $headers, strlen($headers))) {
157
-                throw new HTTP_Request2_Exception('Error writing request');
158
-            }
159
-            // provide request headers to the observer, see request #7633
160
-            $this->request->setLastEvent('sentHeaders', $headers);
161
-            $this->writeBody();
162
-
163
-            if ($this->deadline && time() > $this->deadline) {
164
-                throw new HTTP_Request2_Exception(
165
-                    'Request timed out after ' .
166
-                    $request->getConfig('timeout') . ' second(s)'
167
-                );
168
-            }
169
-
170
-            $response = $this->readResponse();
171
-
172
-            if (!$this->canKeepAlive($keepAlive, $response)) {
173
-                $this->disconnect();
174
-            }
175
-
176
-            if ($this->shouldUseProxyDigestAuth($response)) {
177
-                return $this->sendRequest($request);
178
-            }
179
-            if ($this->shouldUseServerDigestAuth($response)) {
180
-                return $this->sendRequest($request);
181
-            }
182
-            if ($authInfo = $response->getHeader('authentication-info')) {
183
-                $this->updateChallenge($this->serverChallenge, $authInfo);
184
-            }
185
-            if ($proxyInfo = $response->getHeader('proxy-authentication-info')) {
186
-                $this->updateChallenge($this->proxyChallenge, $proxyInfo);
187
-            }
188
-
189
-        } catch (Exception $e) {
190
-            $this->disconnect();
191
-        }
192
-
193
-        unset($this->request, $this->requestBody);
194
-
195
-        if (!empty($e)) {
196
-            throw $e;
197
-        }
198
-
199
-        if (!$request->getConfig('follow_redirects') || !$response->isRedirect()) {
200
-            return $response;
201
-        } else {
202
-            return $this->handleRedirect($request, $response);
203
-        }
204
-    }
142
+	public function sendRequest(HTTP_Request2 $request)
143
+	{
144
+		$this->request = $request;
145
+
146
+		// Use global request timeout if given, see feature requests #5735, #8964
147
+		if ($timeout = $request->getConfig('timeout')) {
148
+			$this->deadline = time() + $timeout;
149
+		} else {
150
+			$this->deadline = null;
151
+		}
152
+
153
+		try {
154
+			$keepAlive = $this->connect();
155
+			$headers   = $this->prepareHeaders();
156
+			if (false === @fwrite($this->socket, $headers, strlen($headers))) {
157
+				throw new HTTP_Request2_Exception('Error writing request');
158
+			}
159
+			// provide request headers to the observer, see request #7633
160
+			$this->request->setLastEvent('sentHeaders', $headers);
161
+			$this->writeBody();
162
+
163
+			if ($this->deadline && time() > $this->deadline) {
164
+				throw new HTTP_Request2_Exception(
165
+					'Request timed out after ' .
166
+					$request->getConfig('timeout') . ' second(s)'
167
+				);
168
+			}
169
+
170
+			$response = $this->readResponse();
171
+
172
+			if (!$this->canKeepAlive($keepAlive, $response)) {
173
+				$this->disconnect();
174
+			}
175
+
176
+			if ($this->shouldUseProxyDigestAuth($response)) {
177
+				return $this->sendRequest($request);
178
+			}
179
+			if ($this->shouldUseServerDigestAuth($response)) {
180
+				return $this->sendRequest($request);
181
+			}
182
+			if ($authInfo = $response->getHeader('authentication-info')) {
183
+				$this->updateChallenge($this->serverChallenge, $authInfo);
184
+			}
185
+			if ($proxyInfo = $response->getHeader('proxy-authentication-info')) {
186
+				$this->updateChallenge($this->proxyChallenge, $proxyInfo);
187
+			}
188
+
189
+		} catch (Exception $e) {
190
+			$this->disconnect();
191
+		}
192
+
193
+		unset($this->request, $this->requestBody);
194
+
195
+		if (!empty($e)) {
196
+			throw $e;
197
+		}
198
+
199
+		if (!$request->getConfig('follow_redirects') || !$response->isRedirect()) {
200
+			return $response;
201
+		} else {
202
+			return $this->handleRedirect($request, $response);
203
+		}
204
+	}
205 205
 
206 206
    /**
207 207
     * Connects to the remote server
@@ -209,114 +209,114 @@  discard block
 block discarded – undo
209 209
     * @return   bool    whether the connection can be persistent
210 210
     * @throws   HTTP_Request2_Exception
211 211
     */
212
-    protected function connect()
213
-    {
214
-        $secure  = 0 == strcasecmp($this->request->getUrl()->getScheme(), 'https');
215
-        $tunnel  = HTTP_Request2::METHOD_CONNECT == $this->request->getMethod();
216
-        $headers = $this->request->getHeaders();
217
-        $reqHost = $this->request->getUrl()->getHost();
218
-        if (!($reqPort = $this->request->getUrl()->getPort())) {
219
-            $reqPort = $secure? 443: 80;
220
-        }
221
-
222
-        if ($host = $this->request->getConfig('proxy_host')) {
223
-            if (!($port = $this->request->getConfig('proxy_port'))) {
224
-                throw new HTTP_Request2_Exception('Proxy port not provided');
225
-            }
226
-            $proxy = true;
227
-        } else {
228
-            $host  = $reqHost;
229
-            $port  = $reqPort;
230
-            $proxy = false;
231
-        }
232
-
233
-        if ($tunnel && !$proxy) {
234
-            throw new HTTP_Request2_Exception(
235
-                "Trying to perform CONNECT request without proxy"
236
-            );
237
-        }
238
-        if ($secure && !in_array('ssl', stream_get_transports())) {
239
-            throw new HTTP_Request2_Exception(
240
-                'Need OpenSSL support for https:// requests'
241
-            );
242
-        }
243
-
244
-        // RFC 2068, section 19.7.1: A client MUST NOT send the Keep-Alive
245
-        // connection token to a proxy server...
246
-        if ($proxy && !$secure &&
247
-            !empty($headers['connection']) && 'Keep-Alive' == $headers['connection']
248
-        ) {
249
-            $this->request->setHeader('connection');
250
-        }
251
-
252
-        $keepAlive = ('1.1' == $this->request->getConfig('protocol_version') &&
253
-                      empty($headers['connection'])) ||
254
-                     (!empty($headers['connection']) &&
255
-                      'Keep-Alive' == $headers['connection']);
256
-        $host = ((!$secure || $proxy)? 'tcp://': 'ssl://') . $host;
257
-
258
-        $options = array();
259
-        if ($secure || $tunnel) {
260
-            foreach ($this->request->getConfig() as $name => $value) {
261
-                if ('ssl_' == substr($name, 0, 4) && null !== $value) {
262
-                    if ('ssl_verify_host' == $name) {
263
-                        if ($value) {
264
-                            $options['CN_match'] = $reqHost;
265
-                        }
266
-                    } else {
267
-                        $options[substr($name, 4)] = $value;
268
-                    }
269
-                }
270
-            }
271
-            ksort($options);
272
-        }
273
-
274
-        // Changing SSL context options after connection is established does *not*
275
-        // work, we need a new connection if options change
276
-        $remote    = $host . ':' . $port;
277
-        $socketKey = $remote . (($secure && $proxy)? "->{$reqHost}:{$reqPort}": '') .
278
-                     (empty($options)? '': ':' . serialize($options));
279
-        unset($this->socket);
280
-
281
-        // We use persistent connections and have a connected socket?
282
-        // Ensure that the socket is still connected, see bug #16149
283
-        if ($keepAlive && !empty(self::$sockets[$socketKey]) &&
284
-            !feof(self::$sockets[$socketKey])
285
-        ) {
286
-            $this->socket =& self::$sockets[$socketKey];
287
-
288
-        } elseif ($secure && $proxy && !$tunnel) {
289
-            $this->establishTunnel();
290
-            $this->request->setLastEvent(
291
-                'connect', "ssl://{$reqHost}:{$reqPort} via {$host}:{$port}"
292
-            );
293
-            self::$sockets[$socketKey] =& $this->socket;
294
-
295
-        } else {
296
-            // Set SSL context options if doing HTTPS request or creating a tunnel
297
-            $context = stream_context_create();
298
-            foreach ($options as $name => $value) {
299
-                if (!stream_context_set_option($context, 'ssl', $name, $value)) {
300
-                    throw new HTTP_Request2_Exception(
301
-                        "Error setting SSL context option '{$name}'"
302
-                    );
303
-                }
304
-            }
305
-            $this->socket = @stream_socket_client(
306
-                $remote, $errno, $errstr,
307
-                $this->request->getConfig('connect_timeout'),
308
-                STREAM_CLIENT_CONNECT, $context
309
-            );
310
-            if (!$this->socket) {
311
-                throw new HTTP_Request2_Exception(
312
-                    "Unable to connect to {$remote}. Error #{$errno}: {$errstr}"
313
-                );
314
-            }
315
-            $this->request->setLastEvent('connect', $remote);
316
-            self::$sockets[$socketKey] =& $this->socket;
317
-        }
318
-        return $keepAlive;
319
-    }
212
+	protected function connect()
213
+	{
214
+		$secure  = 0 == strcasecmp($this->request->getUrl()->getScheme(), 'https');
215
+		$tunnel  = HTTP_Request2::METHOD_CONNECT == $this->request->getMethod();
216
+		$headers = $this->request->getHeaders();
217
+		$reqHost = $this->request->getUrl()->getHost();
218
+		if (!($reqPort = $this->request->getUrl()->getPort())) {
219
+			$reqPort = $secure? 443: 80;
220
+		}
221
+
222
+		if ($host = $this->request->getConfig('proxy_host')) {
223
+			if (!($port = $this->request->getConfig('proxy_port'))) {
224
+				throw new HTTP_Request2_Exception('Proxy port not provided');
225
+			}
226
+			$proxy = true;
227
+		} else {
228
+			$host  = $reqHost;
229
+			$port  = $reqPort;
230
+			$proxy = false;
231
+		}
232
+
233
+		if ($tunnel && !$proxy) {
234
+			throw new HTTP_Request2_Exception(
235
+				"Trying to perform CONNECT request without proxy"
236
+			);
237
+		}
238
+		if ($secure && !in_array('ssl', stream_get_transports())) {
239
+			throw new HTTP_Request2_Exception(
240
+				'Need OpenSSL support for https:// requests'
241
+			);
242
+		}
243
+
244
+		// RFC 2068, section 19.7.1: A client MUST NOT send the Keep-Alive
245
+		// connection token to a proxy server...
246
+		if ($proxy && !$secure &&
247
+			!empty($headers['connection']) && 'Keep-Alive' == $headers['connection']
248
+		) {
249
+			$this->request->setHeader('connection');
250
+		}
251
+
252
+		$keepAlive = ('1.1' == $this->request->getConfig('protocol_version') &&
253
+					  empty($headers['connection'])) ||
254
+					 (!empty($headers['connection']) &&
255
+					  'Keep-Alive' == $headers['connection']);
256
+		$host = ((!$secure || $proxy)? 'tcp://': 'ssl://') . $host;
257
+
258
+		$options = array();
259
+		if ($secure || $tunnel) {
260
+			foreach ($this->request->getConfig() as $name => $value) {
261
+				if ('ssl_' == substr($name, 0, 4) && null !== $value) {
262
+					if ('ssl_verify_host' == $name) {
263
+						if ($value) {
264
+							$options['CN_match'] = $reqHost;
265
+						}
266
+					} else {
267
+						$options[substr($name, 4)] = $value;
268
+					}
269
+				}
270
+			}
271
+			ksort($options);
272
+		}
273
+
274
+		// Changing SSL context options after connection is established does *not*
275
+		// work, we need a new connection if options change
276
+		$remote    = $host . ':' . $port;
277
+		$socketKey = $remote . (($secure && $proxy)? "->{$reqHost}:{$reqPort}": '') .
278
+					 (empty($options)? '': ':' . serialize($options));
279
+		unset($this->socket);
280
+
281
+		// We use persistent connections and have a connected socket?
282
+		// Ensure that the socket is still connected, see bug #16149
283
+		if ($keepAlive && !empty(self::$sockets[$socketKey]) &&
284
+			!feof(self::$sockets[$socketKey])
285
+		) {
286
+			$this->socket =& self::$sockets[$socketKey];
287
+
288
+		} elseif ($secure && $proxy && !$tunnel) {
289
+			$this->establishTunnel();
290
+			$this->request->setLastEvent(
291
+				'connect', "ssl://{$reqHost}:{$reqPort} via {$host}:{$port}"
292
+			);
293
+			self::$sockets[$socketKey] =& $this->socket;
294
+
295
+		} else {
296
+			// Set SSL context options if doing HTTPS request or creating a tunnel
297
+			$context = stream_context_create();
298
+			foreach ($options as $name => $value) {
299
+				if (!stream_context_set_option($context, 'ssl', $name, $value)) {
300
+					throw new HTTP_Request2_Exception(
301
+						"Error setting SSL context option '{$name}'"
302
+					);
303
+				}
304
+			}
305
+			$this->socket = @stream_socket_client(
306
+				$remote, $errno, $errstr,
307
+				$this->request->getConfig('connect_timeout'),
308
+				STREAM_CLIENT_CONNECT, $context
309
+			);
310
+			if (!$this->socket) {
311
+				throw new HTTP_Request2_Exception(
312
+					"Unable to connect to {$remote}. Error #{$errno}: {$errstr}"
313
+				);
314
+			}
315
+			$this->request->setLastEvent('connect', $remote);
316
+			self::$sockets[$socketKey] =& $this->socket;
317
+		}
318
+		return $keepAlive;
319
+	}
320 320
 
321 321
    /**
322 322
     * Establishes a tunnel to a secure remote server via HTTP CONNECT request
@@ -328,40 +328,40 @@  discard block
 block discarded – undo
328 328
     * @link     http://tools.ietf.org/html/rfc2817#section-5.2
329 329
     * @throws   HTTP_Request2_Exception
330 330
     */
331
-    protected function establishTunnel()
332
-    {
333
-        $donor   = new self;
334
-        $connect = new HTTP_Request2(
335
-            $this->request->getUrl(), HTTP_Request2::METHOD_CONNECT,
336
-            array_merge($this->request->getConfig(),
337
-                        array('adapter' => $donor))
338
-        );
339
-        $response = $connect->send();
340
-        // Need any successful (2XX) response
341
-        if (200 > $response->getStatus() || 300 <= $response->getStatus()) {
342
-            throw new HTTP_Request2_Exception(
343
-                'Failed to connect via HTTPS proxy. Proxy response: ' .
344
-                $response->getStatus() . ' ' . $response->getReasonPhrase()
345
-            );
346
-        }
347
-        $this->socket = $donor->socket;
348
-
349
-        $modes = array(
350
-            STREAM_CRYPTO_METHOD_TLS_CLIENT,
351
-            STREAM_CRYPTO_METHOD_SSLv3_CLIENT,
352
-            STREAM_CRYPTO_METHOD_SSLv23_CLIENT,
353
-            STREAM_CRYPTO_METHOD_SSLv2_CLIENT
354
-        );
355
-
356
-        foreach ($modes as $mode) {
357
-            if (stream_socket_enable_crypto($this->socket, true, $mode)) {
358
-                return;
359
-            }
360
-        }
361
-        throw new HTTP_Request2_Exception(
362
-            'Failed to enable secure connection when connecting through proxy'
363
-        );
364
-    }
331
+	protected function establishTunnel()
332
+	{
333
+		$donor   = new self;
334
+		$connect = new HTTP_Request2(
335
+			$this->request->getUrl(), HTTP_Request2::METHOD_CONNECT,
336
+			array_merge($this->request->getConfig(),
337
+						array('adapter' => $donor))
338
+		);
339
+		$response = $connect->send();
340
+		// Need any successful (2XX) response
341
+		if (200 > $response->getStatus() || 300 <= $response->getStatus()) {
342
+			throw new HTTP_Request2_Exception(
343
+				'Failed to connect via HTTPS proxy. Proxy response: ' .
344
+				$response->getStatus() . ' ' . $response->getReasonPhrase()
345
+			);
346
+		}
347
+		$this->socket = $donor->socket;
348
+
349
+		$modes = array(
350
+			STREAM_CRYPTO_METHOD_TLS_CLIENT,
351
+			STREAM_CRYPTO_METHOD_SSLv3_CLIENT,
352
+			STREAM_CRYPTO_METHOD_SSLv23_CLIENT,
353
+			STREAM_CRYPTO_METHOD_SSLv2_CLIENT
354
+		);
355
+
356
+		foreach ($modes as $mode) {
357
+			if (stream_socket_enable_crypto($this->socket, true, $mode)) {
358
+				return;
359
+			}
360
+		}
361
+		throw new HTTP_Request2_Exception(
362
+			'Failed to enable secure connection when connecting through proxy'
363
+		);
364
+	}
365 365
 
366 366
    /**
367 367
     * Checks whether current connection may be reused or should be closed
@@ -371,34 +371,34 @@  discard block
 block discarded – undo
371 371
     * @param    HTTP_Request2_Response  response object to check
372 372
     * @return   boolean
373 373
     */
374
-    protected function canKeepAlive($requestKeepAlive, HTTP_Request2_Response $response)
375
-    {
376
-        // Do not close socket on successful CONNECT request
377
-        if (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() &&
378
-            200 <= $response->getStatus() && 300 > $response->getStatus()
379
-        ) {
380
-            return true;
381
-        }
382
-
383
-        $lengthKnown = 'chunked' == strtolower($response->getHeader('transfer-encoding')) ||
384
-                       null !== $response->getHeader('content-length');
385
-        $persistent  = 'keep-alive' == strtolower($response->getHeader('connection')) ||
386
-                       (null === $response->getHeader('connection') &&
387
-                        '1.1' == $response->getVersion());
388
-        return $requestKeepAlive && $lengthKnown && $persistent;
389
-    }
374
+	protected function canKeepAlive($requestKeepAlive, HTTP_Request2_Response $response)
375
+	{
376
+		// Do not close socket on successful CONNECT request
377
+		if (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() &&
378
+			200 <= $response->getStatus() && 300 > $response->getStatus()
379
+		) {
380
+			return true;
381
+		}
382
+
383
+		$lengthKnown = 'chunked' == strtolower($response->getHeader('transfer-encoding')) ||
384
+					   null !== $response->getHeader('content-length');
385
+		$persistent  = 'keep-alive' == strtolower($response->getHeader('connection')) ||
386
+					   (null === $response->getHeader('connection') &&
387
+						'1.1' == $response->getVersion());
388
+		return $requestKeepAlive && $lengthKnown && $persistent;
389
+	}
390 390
 
391 391
    /**
392 392
     * Disconnects from the remote server
393 393
     */
394
-    protected function disconnect()
395
-    {
396
-        if (is_resource($this->socket)) {
397
-            fclose($this->socket);
398
-            $this->socket = null;
399
-            $this->request->setLastEvent('disconnect');
400
-        }
401
-    }
394
+	protected function disconnect()
395
+	{
396
+		if (is_resource($this->socket)) {
397
+			fclose($this->socket);
398
+			$this->socket = null;
399
+			$this->request->setLastEvent('disconnect');
400
+		}
401
+	}
402 402
 
403 403
    /**
404 404
     * Handles HTTP redirection
@@ -412,49 +412,49 @@  discard block
 block discarded – undo
412 412
     * @return   HTTP_Request2_Response      Response from a new location
413 413
     * @throws   HTTP_Request2_Exception
414 414
     */
415
-    protected function handleRedirect(HTTP_Request2 $request,
416
-                                      HTTP_Request2_Response $response)
417
-    {
418
-        if (is_null($this->redirectCountdown)) {
419
-            $this->redirectCountdown = $request->getConfig('max_redirects');
420
-        }
421
-        if (0 == $this->redirectCountdown) {
422
-            // Copying cURL behaviour
423
-            throw new HTTP_Request2_Exception(
424
-                'Maximum (' . $request->getConfig('max_redirects') . ') redirects followed'
425
-            );
426
-        }
427
-        $redirectUrl = new Net_URL2(
428
-            $response->getHeader('location'),
429
-            array(Net_URL2::OPTION_USE_BRACKETS => $request->getConfig('use_brackets'))
430
-        );
431
-        // refuse non-HTTP redirect
432
-        if ($redirectUrl->isAbsolute()
433
-            && !in_array($redirectUrl->getScheme(), array('http', 'https'))
434
-        ) {
435
-            throw new HTTP_Request2_Exception(
436
-                'Refusing to redirect to a non-HTTP URL ' . $redirectUrl->__toString()
437
-            );
438
-        }
439
-        // Theoretically URL should be absolute (see http://tools.ietf.org/html/rfc2616#section-14.30),
440
-        // but in practice it is often not
441
-        if (!$redirectUrl->isAbsolute()) {
442
-            $redirectUrl = $request->getUrl()->resolve($redirectUrl);
443
-        }
444
-        $redirect = clone $request;
445
-        $redirect->setUrl($redirectUrl);
446
-        if (303 == $response->getStatus() || (!$request->getConfig('strict_redirects')
447
-             && in_array($response->getStatus(), array(301, 302)))
448
-        ) {
449
-            $redirect->setMethod(HTTP_Request2::METHOD_GET);
450
-            $redirect->setBody('');
451
-        }
452
-
453
-        if (0 < $this->redirectCountdown) {
454
-            $this->redirectCountdown--;
455
-        }
456
-        return $this->sendRequest($redirect);
457
-    }
415
+	protected function handleRedirect(HTTP_Request2 $request,
416
+									  HTTP_Request2_Response $response)
417
+	{
418
+		if (is_null($this->redirectCountdown)) {
419
+			$this->redirectCountdown = $request->getConfig('max_redirects');
420
+		}
421
+		if (0 == $this->redirectCountdown) {
422
+			// Copying cURL behaviour
423
+			throw new HTTP_Request2_Exception(
424
+				'Maximum (' . $request->getConfig('max_redirects') . ') redirects followed'
425
+			);
426
+		}
427
+		$redirectUrl = new Net_URL2(
428
+			$response->getHeader('location'),
429
+			array(Net_URL2::OPTION_USE_BRACKETS => $request->getConfig('use_brackets'))
430
+		);
431
+		// refuse non-HTTP redirect
432
+		if ($redirectUrl->isAbsolute()
433
+			&& !in_array($redirectUrl->getScheme(), array('http', 'https'))
434
+		) {
435
+			throw new HTTP_Request2_Exception(
436
+				'Refusing to redirect to a non-HTTP URL ' . $redirectUrl->__toString()
437
+			);
438
+		}
439
+		// Theoretically URL should be absolute (see http://tools.ietf.org/html/rfc2616#section-14.30),
440
+		// but in practice it is often not
441
+		if (!$redirectUrl->isAbsolute()) {
442
+			$redirectUrl = $request->getUrl()->resolve($redirectUrl);
443
+		}
444
+		$redirect = clone $request;
445
+		$redirect->setUrl($redirectUrl);
446
+		if (303 == $response->getStatus() || (!$request->getConfig('strict_redirects')
447
+			 && in_array($response->getStatus(), array(301, 302)))
448
+		) {
449
+			$redirect->setMethod(HTTP_Request2::METHOD_GET);
450
+			$redirect->setBody('');
451
+		}
452
+
453
+		if (0 < $this->redirectCountdown) {
454
+			$this->redirectCountdown--;
455
+		}
456
+		return $this->sendRequest($redirect);
457
+	}
458 458
 
459 459
    /**
460 460
     * Checks whether another request should be performed with server digest auth
@@ -473,52 +473,52 @@  discard block
 block discarded – undo
473 473
     * @return   boolean whether another request should be performed
474 474
     * @throws   HTTP_Request2_Exception in case of unsupported challenge parameters
475 475
     */
476
-    protected function shouldUseServerDigestAuth(HTTP_Request2_Response $response)
477
-    {
478
-        // no sense repeating a request if we don't have credentials
479
-        if (401 != $response->getStatus() || !$this->request->getAuth()) {
480
-            return false;
481
-        }
482
-        if (!$challenge = $this->parseDigestChallenge($response->getHeader('www-authenticate'))) {
483
-            return false;
484
-        }
485
-
486
-        $url    = $this->request->getUrl();
487
-        $scheme = $url->getScheme();
488
-        $host   = $scheme . '://' . $url->getHost();
489
-        if ($port = $url->getPort()) {
490
-            if ((0 == strcasecmp($scheme, 'http') && 80 != $port) ||
491
-                (0 == strcasecmp($scheme, 'https') && 443 != $port)
492
-            ) {
493
-                $host .= ':' . $port;
494
-            }
495
-        }
496
-
497
-        if (!empty($challenge['domain'])) {
498
-            $prefixes = array();
499
-            foreach (preg_split('/\\s+/', $challenge['domain']) as $prefix) {
500
-                // don't bother with different servers
501
-                if ('/' == substr($prefix, 0, 1)) {
502
-                    $prefixes[] = $host . $prefix;
503
-                }
504
-            }
505
-        }
506
-        if (empty($prefixes)) {
507
-            $prefixes = array($host . '/');
508
-        }
509
-
510
-        $ret = true;
511
-        foreach ($prefixes as $prefix) {
512
-            if (!empty(self::$challenges[$prefix]) &&
513
-                (empty($challenge['stale']) || strcasecmp('true', $challenge['stale']))
514
-            ) {
515
-                // probably credentials are invalid
516
-                $ret = false;
517
-            }
518
-            self::$challenges[$prefix] =& $challenge;
519
-        }
520
-        return $ret;
521
-    }
476
+	protected function shouldUseServerDigestAuth(HTTP_Request2_Response $response)
477
+	{
478
+		// no sense repeating a request if we don't have credentials
479
+		if (401 != $response->getStatus() || !$this->request->getAuth()) {
480
+			return false;
481
+		}
482
+		if (!$challenge = $this->parseDigestChallenge($response->getHeader('www-authenticate'))) {
483
+			return false;
484
+		}
485
+
486
+		$url    = $this->request->getUrl();
487
+		$scheme = $url->getScheme();
488
+		$host   = $scheme . '://' . $url->getHost();
489
+		if ($port = $url->getPort()) {
490
+			if ((0 == strcasecmp($scheme, 'http') && 80 != $port) ||
491
+				(0 == strcasecmp($scheme, 'https') && 443 != $port)
492
+			) {
493
+				$host .= ':' . $port;
494
+			}
495
+		}
496
+
497
+		if (!empty($challenge['domain'])) {
498
+			$prefixes = array();
499
+			foreach (preg_split('/\\s+/', $challenge['domain']) as $prefix) {
500
+				// don't bother with different servers
501
+				if ('/' == substr($prefix, 0, 1)) {
502
+					$prefixes[] = $host . $prefix;
503
+				}
504
+			}
505
+		}
506
+		if (empty($prefixes)) {
507
+			$prefixes = array($host . '/');
508
+		}
509
+
510
+		$ret = true;
511
+		foreach ($prefixes as $prefix) {
512
+			if (!empty(self::$challenges[$prefix]) &&
513
+				(empty($challenge['stale']) || strcasecmp('true', $challenge['stale']))
514
+			) {
515
+				// probably credentials are invalid
516
+				$ret = false;
517
+			}
518
+			self::$challenges[$prefix] =& $challenge;
519
+		}
520
+		return $ret;
521
+	}
522 522
 
523 523
    /**
524 524
     * Checks whether another request should be performed with proxy digest auth
@@ -537,28 +537,28 @@  discard block
 block discarded – undo
537 537
     * @return   boolean whether another request should be performed
538 538
     * @throws   HTTP_Request2_Exception in case of unsupported challenge parameters
539 539
     */
540
-    protected function shouldUseProxyDigestAuth(HTTP_Request2_Response $response)
541
-    {
542
-        if (407 != $response->getStatus() || !$this->request->getConfig('proxy_user')) {
543
-            return false;
544
-        }
545
-        if (!($challenge = $this->parseDigestChallenge($response->getHeader('proxy-authenticate')))) {
546
-            return false;
547
-        }
548
-
549
-        $key = 'proxy://' . $this->request->getConfig('proxy_host') .
550
-               ':' . $this->request->getConfig('proxy_port');
551
-
552
-        if (!empty(self::$challenges[$key]) &&
553
-            (empty($challenge['stale']) || strcasecmp('true', $challenge['stale']))
554
-        ) {
555
-            $ret = false;
556
-        } else {
557
-            $ret = true;
558
-        }
559
-        self::$challenges[$key] = $challenge;
560
-        return $ret;
561
-    }
540
+	protected function shouldUseProxyDigestAuth(HTTP_Request2_Response $response)
541
+	{
542
+		if (407 != $response->getStatus() || !$this->request->getConfig('proxy_user')) {
543
+			return false;
544
+		}
545
+		if (!($challenge = $this->parseDigestChallenge($response->getHeader('proxy-authenticate')))) {
546
+			return false;
547
+		}
548
+
549
+		$key = 'proxy://' . $this->request->getConfig('proxy_host') .
550
+			   ':' . $this->request->getConfig('proxy_port');
551
+
552
+		if (!empty(self::$challenges[$key]) &&
553
+			(empty($challenge['stale']) || strcasecmp('true', $challenge['stale']))
554
+		) {
555
+			$ret = false;
556
+		} else {
557
+			$ret = true;
558
+		}
559
+		self::$challenges[$key] = $challenge;
560
+		return $ret;
561
+	}
562 562
 
563 563
    /**
564 564
     * Extracts digest method challenge from (WWW|Proxy)-Authenticate header value
@@ -588,48 +588,48 @@  discard block
 block discarded – undo
588 588
     *                   no challenge is present in header value
589 589
     * @throws   HTTP_Request2_Exception in case of unsupported challenge parameters
590 590
     */
591
-    protected function parseDigestChallenge($headerValue)
592
-    {
593
-        $authParam   = '(' . self::REGEXP_TOKEN . ')\\s*=\\s*(' .
594
-                       self::REGEXP_TOKEN . '|' . self::REGEXP_QUOTED_STRING . ')';
595
-        $challenge   = "!(?<=^|\\s|,)Digest ({$authParam}\\s*(,\\s*|$))+!";
596
-        if (!preg_match($challenge, $headerValue, $matches)) {
597
-            return false;
598
-        }
599
-
600
-        preg_match_all('!' . $authParam . '!', $matches[0], $params);
601
-        $paramsAry   = array();
602
-        $knownParams = array('realm', 'domain', 'nonce', 'opaque', 'stale',
603
-                             'algorithm', 'qop');
604
-        for ($i = 0; $i < count($params[0]); $i++) {
605
-            // section 3.2.1: Any unrecognized directive MUST be ignored.
606
-            if (in_array($params[1][$i], $knownParams)) {
607
-                if ('"' == substr($params[2][$i], 0, 1)) {
608
-                    $paramsAry[$params[1][$i]] = substr($params[2][$i], 1, -1);
609
-                } else {
610
-                    $paramsAry[$params[1][$i]] = $params[2][$i];
611
-                }
612
-            }
613
-        }
614
-        // we only support qop=auth
615
-        if (!empty($paramsAry['qop']) &&
616
-            !in_array('auth', array_map('trim', explode(',', $paramsAry['qop'])))
617
-        ) {
618
-            throw new HTTP_Request2_Exception(
619
-                "Only 'auth' qop is currently supported in digest authentication, " .
620
-                "server requested '{$paramsAry['qop']}'"
621
-            );
622
-        }
623
-        // we only support algorithm=MD5
624
-        if (!empty($paramsAry['algorithm']) && 'MD5' != $paramsAry['algorithm']) {
625
-            throw new HTTP_Request2_Exception(
626
-                "Only 'MD5' algorithm is currently supported in digest authentication, " .
627
-                "server requested '{$paramsAry['algorithm']}'"
628
-            );
629
-        }
630
-
631
-        return $paramsAry;
632
-    }
591
+	protected function parseDigestChallenge($headerValue)
592
+	{
593
+		$authParam   = '(' . self::REGEXP_TOKEN . ')\\s*=\\s*(' .
594
+					   self::REGEXP_TOKEN . '|' . self::REGEXP_QUOTED_STRING . ')';
595
+		$challenge   = "!(?<=^|\\s|,)Digest ({$authParam}\\s*(,\\s*|$))+!";
596
+		if (!preg_match($challenge, $headerValue, $matches)) {
597
+			return false;
598
+		}
599
+
600
+		preg_match_all('!' . $authParam . '!', $matches[0], $params);
601
+		$paramsAry   = array();
602
+		$knownParams = array('realm', 'domain', 'nonce', 'opaque', 'stale',
603
+							 'algorithm', 'qop');
604
+		for ($i = 0; $i < count($params[0]); $i++) {
605
+			// section 3.2.1: Any unrecognized directive MUST be ignored.
606
+			if (in_array($params[1][$i], $knownParams)) {
607
+				if ('"' == substr($params[2][$i], 0, 1)) {
608
+					$paramsAry[$params[1][$i]] = substr($params[2][$i], 1, -1);
609
+				} else {
610
+					$paramsAry[$params[1][$i]] = $params[2][$i];
611
+				}
612
+			}
613
+		}
614
+		// we only support qop=auth
615
+		if (!empty($paramsAry['qop']) &&
616
+			!in_array('auth', array_map('trim', explode(',', $paramsAry['qop'])))
617
+		) {
618
+			throw new HTTP_Request2_Exception(
619
+				"Only 'auth' qop is currently supported in digest authentication, " .
620
+				"server requested '{$paramsAry['qop']}'"
621
+			);
622
+		}
623
+		// we only support algorithm=MD5
624
+		if (!empty($paramsAry['algorithm']) && 'MD5' != $paramsAry['algorithm']) {
625
+			throw new HTTP_Request2_Exception(
626
+				"Only 'MD5' algorithm is currently supported in digest authentication, " .
627
+				"server requested '{$paramsAry['algorithm']}'"
628
+			);
629
+		}
630
+
631
+		return $paramsAry;
632
+	}
633 633
 
634 634
    /**
635 635
     * Parses [Proxy-]Authentication-Info header value and updates challenge
@@ -638,26 +638,26 @@  discard block
 block discarded – undo
638 638
     * @param    string  value of [Proxy-]Authentication-Info header
639 639
     * @todo     validate server rspauth response
640 640
     */
641
-    protected function updateChallenge(&$challenge, $headerValue)
642
-    {
643
-        $authParam   = '!(' . self::REGEXP_TOKEN . ')\\s*=\\s*(' .
644
-                       self::REGEXP_TOKEN . '|' . self::REGEXP_QUOTED_STRING . ')!';
645
-        $paramsAry   = array();
646
-
647
-        preg_match_all($authParam, $headerValue, $params);
648
-        for ($i = 0; $i < count($params[0]); $i++) {
649
-            if ('"' == substr($params[2][$i], 0, 1)) {
650
-                $paramsAry[$params[1][$i]] = substr($params[2][$i], 1, -1);
651
-            } else {
652
-                $paramsAry[$params[1][$i]] = $params[2][$i];
653
-            }
654
-        }
655
-        // for now, just update the nonce value
656
-        if (!empty($paramsAry['nextnonce'])) {
657
-            $challenge['nonce'] = $paramsAry['nextnonce'];
658
-            $challenge['nc']    = 1;
659
-        }
660
-    }
641
+	protected function updateChallenge(&$challenge, $headerValue)
642
+	{
643
+		$authParam   = '!(' . self::REGEXP_TOKEN . ')\\s*=\\s*(' .
644
+					   self::REGEXP_TOKEN . '|' . self::REGEXP_QUOTED_STRING . ')!';
645
+		$paramsAry   = array();
646
+
647
+		preg_match_all($authParam, $headerValue, $params);
648
+		for ($i = 0; $i < count($params[0]); $i++) {
649
+			if ('"' == substr($params[2][$i], 0, 1)) {
650
+				$paramsAry[$params[1][$i]] = substr($params[2][$i], 1, -1);
651
+			} else {
652
+				$paramsAry[$params[1][$i]] = $params[2][$i];
653
+			}
654
+		}
655
+		// for now, just update the nonce value
656
+		if (!empty($paramsAry['nextnonce'])) {
657
+			$challenge['nonce'] = $paramsAry['nextnonce'];
658
+			$challenge['nc']    = 1;
659
+		}
660
+	}
661 661
 
662 662
    /**
663 663
     * Creates a value for [Proxy-]Authorization header when using digest authentication
@@ -669,40 +669,40 @@  discard block
 block discarded – undo
669 669
     * @return   string  value of [Proxy-]Authorization request header
670 670
     * @link     http://tools.ietf.org/html/rfc2617#section-3.2.2
671 671
     */
672
-    protected function createDigestResponse($user, $password, $url, &$challenge)
673
-    {
674
-        if (false !== ($q = strpos($url, '?')) &&
675
-            $this->request->getConfig('digest_compat_ie')
676
-        ) {
677
-            $url = substr($url, 0, $q);
678
-        }
679
-
680
-        $a1 = md5($user . ':' . $challenge['realm'] . ':' . $password);
681
-        $a2 = md5($this->request->getMethod() . ':' . $url);
682
-
683
-        if (empty($challenge['qop'])) {
684
-            $digest = md5($a1 . ':' . $challenge['nonce'] . ':' . $a2);
685
-        } else {
686
-            $challenge['cnonce'] = 'Req2.' . rand();
687
-            if (empty($challenge['nc'])) {
688
-                $challenge['nc'] = 1;
689
-            }
690
-            $nc     = sprintf('%08x', $challenge['nc']++);
691
-            $digest = md5($a1 . ':' . $challenge['nonce'] . ':' . $nc . ':' .
692
-                          $challenge['cnonce'] . ':auth:' . $a2);
693
-        }
694
-        return 'Digest username="' . str_replace(array('\\', '"'), array('\\\\', '\\"'), $user) . '", ' .
695
-               'realm="' . $challenge['realm'] . '", ' .
696
-               'nonce="' . $challenge['nonce'] . '", ' .
697
-               'uri="' . $url . '", ' .
698
-               'response="' . $digest . '"' .
699
-               (!empty($challenge['opaque'])?
700
-                ', opaque="' . $challenge['opaque'] . '"':
701
-                '') .
702
-               (!empty($challenge['qop'])?
703
-                ', qop="auth", nc=' . $nc . ', cnonce="' . $challenge['cnonce'] . '"':
704
-                '');
705
-    }
672
+	protected function createDigestResponse($user, $password, $url, &$challenge)
673
+	{
674
+		if (false !== ($q = strpos($url, '?')) &&
675
+			$this->request->getConfig('digest_compat_ie')
676
+		) {
677
+			$url = substr($url, 0, $q);
678
+		}
679
+
680
+		$a1 = md5($user . ':' . $challenge['realm'] . ':' . $password);
681
+		$a2 = md5($this->request->getMethod() . ':' . $url);
682
+
683
+		if (empty($challenge['qop'])) {
684
+			$digest = md5($a1 . ':' . $challenge['nonce'] . ':' . $a2);
685
+		} else {
686
+			$challenge['cnonce'] = 'Req2.' . rand();
687
+			if (empty($challenge['nc'])) {
688
+				$challenge['nc'] = 1;
689
+			}
690
+			$nc     = sprintf('%08x', $challenge['nc']++);
691
+			$digest = md5($a1 . ':' . $challenge['nonce'] . ':' . $nc . ':' .
692
+						  $challenge['cnonce'] . ':auth:' . $a2);
693
+		}
694
+		return 'Digest username="' . str_replace(array('\\', '"'), array('\\\\', '\\"'), $user) . '", ' .
695
+			   'realm="' . $challenge['realm'] . '", ' .
696
+			   'nonce="' . $challenge['nonce'] . '", ' .
697
+			   'uri="' . $url . '", ' .
698
+			   'response="' . $digest . '"' .
699
+			   (!empty($challenge['opaque'])?
700
+				', opaque="' . $challenge['opaque'] . '"':
701
+				'') .
702
+			   (!empty($challenge['qop'])?
703
+				', qop="auth", nc=' . $nc . ', cnonce="' . $challenge['cnonce'] . '"':
704
+				'');
705
+	}
706 706
 
707 707
    /**
708 708
     * Adds 'Authorization' header (if needed) to request headers array
@@ -712,41 +712,41 @@  discard block
 block discarded – undo
712 712
     * @param    string  request URL (needed for digest authentication)
713 713
     * @throws   HTTP_Request2_Exception
714 714
     */
715
-    protected function addAuthorizationHeader(&$headers, $requestHost, $requestUrl)
716
-    {
717
-        if (!($auth = $this->request->getAuth())) {
718
-            return;
719
-        }
720
-        switch ($auth['scheme']) {
721
-            case HTTP_Request2::AUTH_BASIC:
722
-                $headers['authorization'] =
723
-                    'Basic ' . base64_encode($auth['user'] . ':' . $auth['password']);
724
-                break;
725
-
726
-            case HTTP_Request2::AUTH_DIGEST:
727
-                unset($this->serverChallenge);
728
-                $fullUrl = ('/' == $requestUrl[0])?
729
-                           $this->request->getUrl()->getScheme() . '://' .
730
-                            $requestHost . $requestUrl:
731
-                           $requestUrl;
732
-                foreach (array_keys(self::$challenges) as $key) {
733
-                    if ($key == substr($fullUrl, 0, strlen($key))) {
734
-                        $headers['authorization'] = $this->createDigestResponse(
735
-                            $auth['user'], $auth['password'],
736
-                            $requestUrl, self::$challenges[$key]
737
-                        );
738
-                        $this->serverChallenge =& self::$challenges[$key];
739
-                        break;
740
-                    }
741
-                }
742
-                break;
743
-
744
-            default:
745
-                throw new HTTP_Request2_Exception(
746
-                    "Unknown HTTP authentication scheme '{$auth['scheme']}'"
747
-                );
748
-        }
749
-    }
715
+	protected function addAuthorizationHeader(&$headers, $requestHost, $requestUrl)
716
+	{
717
+		if (!($auth = $this->request->getAuth())) {
718
+			return;
719
+		}
720
+		switch ($auth['scheme']) {
721
+			case HTTP_Request2::AUTH_BASIC:
722
+				$headers['authorization'] =
723
+					'Basic ' . base64_encode($auth['user'] . ':' . $auth['password']);
724
+				break;
725
+
726
+			case HTTP_Request2::AUTH_DIGEST:
727
+				unset($this->serverChallenge);
728
+				$fullUrl = ('/' == $requestUrl[0])?
729
+						   $this->request->getUrl()->getScheme() . '://' .
730
+							$requestHost . $requestUrl:
731
+						   $requestUrl;
732
+				foreach (array_keys(self::$challenges) as $key) {
733
+					if ($key == substr($fullUrl, 0, strlen($key))) {
734
+						$headers['authorization'] = $this->createDigestResponse(
735
+							$auth['user'], $auth['password'],
736
+							$requestUrl, self::$challenges[$key]
737
+						);
738
+						$this->serverChallenge =& self::$challenges[$key];
739
+						break;
740
+					}
741
+				}
742
+				break;
743
+
744
+			default:
745
+				throw new HTTP_Request2_Exception(
746
+					"Unknown HTTP authentication scheme '{$auth['scheme']}'"
747
+				);
748
+		}
749
+	}
750 750
 
751 751
    /**
752 752
     * Adds 'Proxy-Authorization' header (if needed) to request headers array
@@ -755,43 +755,43 @@  discard block
 block discarded – undo
755 755
     * @param    string  request URL (needed for digest authentication)
756 756
     * @throws   HTTP_Request2_Exception
757 757
     */
758
-    protected function addProxyAuthorizationHeader(&$headers, $requestUrl)
759
-    {
760
-        if (!$this->request->getConfig('proxy_host') ||
761
-            !($user = $this->request->getConfig('proxy_user')) ||
762
-            (0 == strcasecmp('https', $this->request->getUrl()->getScheme()) &&
763
-             HTTP_Request2::METHOD_CONNECT != $this->request->getMethod())
764
-        ) {
765
-            return;
766
-        }
767
-
768
-        $password = $this->request->getConfig('proxy_password');
769
-        switch ($this->request->getConfig('proxy_auth_scheme')) {
770
-            case HTTP_Request2::AUTH_BASIC:
771
-                $headers['proxy-authorization'] =
772
-                    'Basic ' . base64_encode($user . ':' . $password);
773
-                break;
774
-
775
-            case HTTP_Request2::AUTH_DIGEST:
776
-                unset($this->proxyChallenge);
777
-                $proxyUrl = 'proxy://' . $this->request->getConfig('proxy_host') .
778
-                            ':' . $this->request->getConfig('proxy_port');
779
-                if (!empty(self::$challenges[$proxyUrl])) {
780
-                    $headers['proxy-authorization'] = $this->createDigestResponse(
781
-                        $user, $password,
782
-                        $requestUrl, self::$challenges[$proxyUrl]
783
-                    );
784
-                    $this->proxyChallenge =& self::$challenges[$proxyUrl];
785
-                }
786
-                break;
787
-
788
-            default:
789
-                throw new HTTP_Request2_Exception(
790
-                    "Unknown HTTP authentication scheme '" .
791
-                    $this->request->getConfig('proxy_auth_scheme') . "'"
792
-                );
793
-        }
794
-    }
758
+	protected function addProxyAuthorizationHeader(&$headers, $requestUrl)
759
+	{
760
+		if (!$this->request->getConfig('proxy_host') ||
761
+			!($user = $this->request->getConfig('proxy_user')) ||
762
+			(0 == strcasecmp('https', $this->request->getUrl()->getScheme()) &&
763
+			 HTTP_Request2::METHOD_CONNECT != $this->request->getMethod())
764
+		) {
765
+			return;
766
+		}
767
+
768
+		$password = $this->request->getConfig('proxy_password');
769
+		switch ($this->request->getConfig('proxy_auth_scheme')) {
770
+			case HTTP_Request2::AUTH_BASIC:
771
+				$headers['proxy-authorization'] =
772
+					'Basic ' . base64_encode($user . ':' . $password);
773
+				break;
774
+
775
+			case HTTP_Request2::AUTH_DIGEST:
776
+				unset($this->proxyChallenge);
777
+				$proxyUrl = 'proxy://' . $this->request->getConfig('proxy_host') .
778
+							':' . $this->request->getConfig('proxy_port');
779
+				if (!empty(self::$challenges[$proxyUrl])) {
780
+					$headers['proxy-authorization'] = $this->createDigestResponse(
781
+						$user, $password,
782
+						$requestUrl, self::$challenges[$proxyUrl]
783
+					);
784
+					$this->proxyChallenge =& self::$challenges[$proxyUrl];
785
+				}
786
+				break;
787
+
788
+			default:
789
+				throw new HTTP_Request2_Exception(
790
+					"Unknown HTTP authentication scheme '" .
791
+					$this->request->getConfig('proxy_auth_scheme') . "'"
792
+				);
793
+		}
794
+	}
795 795
 
796 796
 
797 797
    /**
@@ -800,88 +800,88 @@  discard block
 block discarded – undo
800 800
     * @return   string
801 801
     * @throws   HTTP_Request2_Exception
802 802
     */
803
-    protected function prepareHeaders()
804
-    {
805
-        $headers = $this->request->getHeaders();
806
-        $url     = $this->request->getUrl();
807
-        $connect = HTTP_Request2::METHOD_CONNECT == $this->request->getMethod();
808
-        $host    = $url->getHost();
809
-
810
-        $defaultPort = 0 == strcasecmp($url->getScheme(), 'https')? 443: 80;
811
-        if (($port = $url->getPort()) && $port != $defaultPort || $connect) {
812
-            $host .= ':' . (empty($port)? $defaultPort: $port);
813
-        }
814
-        // Do not overwrite explicitly set 'Host' header, see bug #16146
815
-        if (!isset($headers['host'])) {
816
-            $headers['host'] = $host;
817
-        }
818
-
819
-        if ($connect) {
820
-            $requestUrl = $host;
821
-
822
-        } else {
823
-            if (!$this->request->getConfig('proxy_host') ||
824
-                0 == strcasecmp($url->getScheme(), 'https')
825
-            ) {
826
-                $requestUrl = '';
827
-            } else {
828
-                $requestUrl = $url->getScheme() . '://' . $host;
829
-            }
830
-            $path        = $url->getPath();
831
-            $query       = $url->getQuery();
832
-            $requestUrl .= (empty($path)? '/': $path) . (empty($query)? '': '?' . $query);
833
-        }
834
-
835
-        if ('1.1' == $this->request->getConfig('protocol_version') &&
836
-            extension_loaded('zlib') && !isset($headers['accept-encoding'])
837
-        ) {
838
-            $headers['accept-encoding'] = 'gzip, deflate';
839
-        }
840
-
841
-        $this->addAuthorizationHeader($headers, $host, $requestUrl);
842
-        $this->addProxyAuthorizationHeader($headers, $requestUrl);
843
-        $this->calculateRequestLength($headers);
844
-
845
-        $headersStr = $this->request->getMethod() . ' ' . $requestUrl . ' HTTP/' .
846
-                      $this->request->getConfig('protocol_version') . "\r\n";
847
-        foreach ($headers as $name => $value) {
848
-            $canonicalName = implode('-', array_map('ucfirst', explode('-', $name)));
849
-            $headersStr   .= $canonicalName . ': ' . $value . "\r\n";
850
-        }
851
-        return $headersStr . "\r\n";
852
-    }
803
+	protected function prepareHeaders()
804
+	{
805
+		$headers = $this->request->getHeaders();
806
+		$url     = $this->request->getUrl();
807
+		$connect = HTTP_Request2::METHOD_CONNECT == $this->request->getMethod();
808
+		$host    = $url->getHost();
809
+
810
+		$defaultPort = 0 == strcasecmp($url->getScheme(), 'https')? 443: 80;
811
+		if (($port = $url->getPort()) && $port != $defaultPort || $connect) {
812
+			$host .= ':' . (empty($port)? $defaultPort: $port);
813
+		}
814
+		// Do not overwrite explicitly set 'Host' header, see bug #16146
815
+		if (!isset($headers['host'])) {
816
+			$headers['host'] = $host;
817
+		}
818
+
819
+		if ($connect) {
820
+			$requestUrl = $host;
821
+
822
+		} else {
823
+			if (!$this->request->getConfig('proxy_host') ||
824
+				0 == strcasecmp($url->getScheme(), 'https')
825
+			) {
826
+				$requestUrl = '';
827
+			} else {
828
+				$requestUrl = $url->getScheme() . '://' . $host;
829
+			}
830
+			$path        = $url->getPath();
831
+			$query       = $url->getQuery();
832
+			$requestUrl .= (empty($path)? '/': $path) . (empty($query)? '': '?' . $query);
833
+		}
834
+
835
+		if ('1.1' == $this->request->getConfig('protocol_version') &&
836
+			extension_loaded('zlib') && !isset($headers['accept-encoding'])
837
+		) {
838
+			$headers['accept-encoding'] = 'gzip, deflate';
839
+		}
840
+
841
+		$this->addAuthorizationHeader($headers, $host, $requestUrl);
842
+		$this->addProxyAuthorizationHeader($headers, $requestUrl);
843
+		$this->calculateRequestLength($headers);
844
+
845
+		$headersStr = $this->request->getMethod() . ' ' . $requestUrl . ' HTTP/' .
846
+					  $this->request->getConfig('protocol_version') . "\r\n";
847
+		foreach ($headers as $name => $value) {
848
+			$canonicalName = implode('-', array_map('ucfirst', explode('-', $name)));
849
+			$headersStr   .= $canonicalName . ': ' . $value . "\r\n";
850
+		}
851
+		return $headersStr . "\r\n";
852
+	}
853 853
 
854 854
    /**
855 855
     * Sends the request body
856 856
     *
857 857
     * @throws   HTTP_Request2_Exception
858 858
     */
859
-    protected function writeBody()
860
-    {
861
-        if (in_array($this->request->getMethod(), self::$bodyDisallowed) ||
862
-            0 == $this->contentLength
863
-        ) {
864
-            return;
865
-        }
866
-
867
-        $position   = 0;
868
-        $bufferSize = $this->request->getConfig('buffer_size');
869
-        while ($position < $this->contentLength) {
870
-            if (is_string($this->requestBody)) {
871
-                $str = substr($this->requestBody, $position, $bufferSize);
872
-            } elseif (is_resource($this->requestBody)) {
873
-                $str = fread($this->requestBody, $bufferSize);
874
-            } else {
875
-                $str = $this->requestBody->read($bufferSize);
876
-            }
877
-            if (false === @fwrite($this->socket, $str, strlen($str))) {
878
-                throw new HTTP_Request2_Exception('Error writing request');
879
-            }
880
-            // Provide the length of written string to the observer, request #7630
881
-            $this->request->setLastEvent('sentBodyPart', strlen($str));
882
-            $position += strlen($str);
883
-        }
884
-    }
859
+	protected function writeBody()
860
+	{
861
+		if (in_array($this->request->getMethod(), self::$bodyDisallowed) ||
862
+			0 == $this->contentLength
863
+		) {
864
+			return;
865
+		}
866
+
867
+		$position   = 0;
868
+		$bufferSize = $this->request->getConfig('buffer_size');
869
+		while ($position < $this->contentLength) {
870
+			if (is_string($this->requestBody)) {
871
+				$str = substr($this->requestBody, $position, $bufferSize);
872
+			} elseif (is_resource($this->requestBody)) {
873
+				$str = fread($this->requestBody, $bufferSize);
874
+			} else {
875
+				$str = $this->requestBody->read($bufferSize);
876
+			}
877
+			if (false === @fwrite($this->socket, $str, strlen($str))) {
878
+				throw new HTTP_Request2_Exception('Error writing request');
879
+			}
880
+			// Provide the length of written string to the observer, request #7630
881
+			$this->request->setLastEvent('sentBodyPart', strlen($str));
882
+			$position += strlen($str);
883
+		}
884
+	}
885 885
 
886 886
    /**
887 887
     * Reads the remote server's response
@@ -889,70 +889,70 @@  discard block
 block discarded – undo
889 889
     * @return   HTTP_Request2_Response
890 890
     * @throws   HTTP_Request2_Exception
891 891
     */
892
-    protected function readResponse()
893
-    {
894
-        $bufferSize = $this->request->getConfig('buffer_size');
895
-
896
-        do {
897
-            $response = new HTTP_Request2_Response($this->readLine($bufferSize), true);
898
-            do {
899
-                $headerLine = $this->readLine($bufferSize);
900
-                $response->parseHeaderLine($headerLine);
901
-            } while ('' != $headerLine);
902
-        } while (in_array($response->getStatus(), array(100, 101)));
903
-
904
-        $this->request->setLastEvent('receivedHeaders', $response);
905
-
906
-        // No body possible in such responses
907
-        if (HTTP_Request2::METHOD_HEAD == $this->request->getMethod() ||
908
-            (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() &&
909
-             200 <= $response->getStatus() && 300 > $response->getStatus()) ||
910
-            in_array($response->getStatus(), array(204, 304))
911
-        ) {
912
-            return $response;
913
-        }
914
-
915
-        $chunked = 'chunked' == $response->getHeader('transfer-encoding');
916
-        $length  = $response->getHeader('content-length');
917
-        $hasBody = false;
918
-        if ($chunked || null === $length || 0 < intval($length)) {
919
-            // RFC 2616, section 4.4:
920
-            // 3. ... If a message is received with both a
921
-            // Transfer-Encoding header field and a Content-Length header field,
922
-            // the latter MUST be ignored.
923
-            $toRead = ($chunked || null === $length)? null: $length;
924
-            $this->chunkLength = 0;
925
-
926
-            while (!feof($this->socket) && (is_null($toRead) || 0 < $toRead)) {
927
-                if ($chunked) {
928
-                    $data = $this->readChunked($bufferSize);
929
-                } elseif (is_null($toRead)) {
930
-                    $data = $this->fread($bufferSize);
931
-                } else {
932
-                    $data    = $this->fread(min($toRead, $bufferSize));
933
-                    $toRead -= strlen($data);
934
-                }
935
-                if ('' == $data && (!$this->chunkLength || feof($this->socket))) {
936
-                    break;
937
-                }
938
-
939
-                $hasBody = true;
940
-                if ($this->request->getConfig('store_body')) {
941
-                    $response->appendBody($data);
942
-                }
943
-                if (!in_array($response->getHeader('content-encoding'), array('identity', null))) {
944
-                    $this->request->setLastEvent('receivedEncodedBodyPart', $data);
945
-                } else {
946
-                    $this->request->setLastEvent('receivedBodyPart', $data);
947
-                }
948
-            }
949
-        }
950
-
951
-        if ($hasBody) {
952
-            $this->request->setLastEvent('receivedBody', $response);
953
-        }
954
-        return $response;
955
-    }
892
+	protected function readResponse()
893
+	{
894
+		$bufferSize = $this->request->getConfig('buffer_size');
895
+
896
+		do {
897
+			$response = new HTTP_Request2_Response($this->readLine($bufferSize), true);
898
+			do {
899
+				$headerLine = $this->readLine($bufferSize);
900
+				$response->parseHeaderLine($headerLine);
901
+			} while ('' != $headerLine);
902
+		} while (in_array($response->getStatus(), array(100, 101)));
903
+
904
+		$this->request->setLastEvent('receivedHeaders', $response);
905
+
906
+		// No body possible in such responses
907
+		if (HTTP_Request2::METHOD_HEAD == $this->request->getMethod() ||
908
+			(HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() &&
909
+			 200 <= $response->getStatus() && 300 > $response->getStatus()) ||
910
+			in_array($response->getStatus(), array(204, 304))
911
+		) {
912
+			return $response;
913
+		}
914
+
915
+		$chunked = 'chunked' == $response->getHeader('transfer-encoding');
916
+		$length  = $response->getHeader('content-length');
917
+		$hasBody = false;
918
+		if ($chunked || null === $length || 0 < intval($length)) {
919
+			// RFC 2616, section 4.4:
920
+			// 3. ... If a message is received with both a
921
+			// Transfer-Encoding header field and a Content-Length header field,
922
+			// the latter MUST be ignored.
923
+			$toRead = ($chunked || null === $length)? null: $length;
924
+			$this->chunkLength = 0;
925
+
926
+			while (!feof($this->socket) && (is_null($toRead) || 0 < $toRead)) {
927
+				if ($chunked) {
928
+					$data = $this->readChunked($bufferSize);
929
+				} elseif (is_null($toRead)) {
930
+					$data = $this->fread($bufferSize);
931
+				} else {
932
+					$data    = $this->fread(min($toRead, $bufferSize));
933
+					$toRead -= strlen($data);
934
+				}
935
+				if ('' == $data && (!$this->chunkLength || feof($this->socket))) {
936
+					break;
937
+				}
938
+
939
+				$hasBody = true;
940
+				if ($this->request->getConfig('store_body')) {
941
+					$response->appendBody($data);
942
+				}
943
+				if (!in_array($response->getHeader('content-encoding'), array('identity', null))) {
944
+					$this->request->setLastEvent('receivedEncodedBodyPart', $data);
945
+				} else {
946
+					$this->request->setLastEvent('receivedBodyPart', $data);
947
+				}
948
+			}
949
+		}
950
+
951
+		if ($hasBody) {
952
+			$this->request->setLastEvent('receivedBody', $response);
953
+		}
954
+		return $response;
955
+	}
956 956
 
957 957
    /**
958 958
     * Reads until either the end of the socket or a newline, whichever comes first
@@ -964,27 +964,27 @@  discard block
 block discarded – undo
964 964
     * @return   Available data up to the newline (not including newline)
965 965
     * @throws   HTTP_Request2_Exception     In case of timeout
966 966
     */
967
-    protected function readLine($bufferSize)
968
-    {
969
-        $line = '';
970
-        while (!feof($this->socket)) {
971
-            if ($this->deadline) {
972
-                stream_set_timeout($this->socket, max($this->deadline - time(), 1));
973
-            }
974
-            $line .= @fgets($this->socket, $bufferSize);
975
-            $info  = stream_get_meta_data($this->socket);
976
-            if ($info['timed_out'] || $this->deadline && time() > $this->deadline) {
977
-                $reason = $this->deadline
978
-                          ? 'after ' . $this->request->getConfig('timeout') . ' second(s)'
979
-                          : 'due to default_socket_timeout php.ini setting';
980
-                throw new HTTP_Request2_Exception("Request timed out {$reason}");
981
-            }
982
-            if (substr($line, -1) == "\n") {
983
-                return rtrim($line, "\r\n");
984
-            }
985
-        }
986
-        return $line;
987
-    }
967
+	protected function readLine($bufferSize)
968
+	{
969
+		$line = '';
970
+		while (!feof($this->socket)) {
971
+			if ($this->deadline) {
972
+				stream_set_timeout($this->socket, max($this->deadline - time(), 1));
973
+			}
974
+			$line .= @fgets($this->socket, $bufferSize);
975
+			$info  = stream_get_meta_data($this->socket);
976
+			if ($info['timed_out'] || $this->deadline && time() > $this->deadline) {
977
+				$reason = $this->deadline
978
+						  ? 'after ' . $this->request->getConfig('timeout') . ' second(s)'
979
+						  : 'due to default_socket_timeout php.ini setting';
980
+				throw new HTTP_Request2_Exception("Request timed out {$reason}");
981
+			}
982
+			if (substr($line, -1) == "\n") {
983
+				return rtrim($line, "\r\n");
984
+			}
985
+		}
986
+		return $line;
987
+	}
988 988
 
989 989
    /**
990 990
     * Wrapper around fread(), handles global request timeout
@@ -993,21 +993,21 @@  discard block
 block discarded – undo
993 993
     * @return   Data read from socket
994 994
     * @throws   HTTP_Request2_Exception     In case of timeout
995 995
     */
996
-    protected function fread($length)
997
-    {
998
-        if ($this->deadline) {
999
-            stream_set_timeout($this->socket, max($this->deadline - time(), 1));
1000
-        }
1001
-        $data = fread($this->socket, $length);
1002
-        $info = stream_get_meta_data($this->socket);
1003
-        if ($info['timed_out'] || $this->deadline && time() > $this->deadline) {
1004
-            $reason = $this->deadline
1005
-                      ? 'after ' . $this->request->getConfig('timeout') . ' second(s)'
1006
-                      : 'due to default_socket_timeout php.ini setting';
1007
-            throw new HTTP_Request2_Exception("Request timed out {$reason}");
1008
-        }
1009
-        return $data;
1010
-    }
996
+	protected function fread($length)
997
+	{
998
+		if ($this->deadline) {
999
+			stream_set_timeout($this->socket, max($this->deadline - time(), 1));
1000
+		}
1001
+		$data = fread($this->socket, $length);
1002
+		$info = stream_get_meta_data($this->socket);
1003
+		if ($info['timed_out'] || $this->deadline && time() > $this->deadline) {
1004
+			$reason = $this->deadline
1005
+					  ? 'after ' . $this->request->getConfig('timeout') . ' second(s)'
1006
+					  : 'due to default_socket_timeout php.ini setting';
1007
+			throw new HTTP_Request2_Exception("Request timed out {$reason}");
1008
+		}
1009
+		return $data;
1010
+	}
1011 1011
 
1012 1012
    /**
1013 1013
     * Reads a part of response body encoded with chunked Transfer-Encoding
@@ -1016,31 +1016,31 @@  discard block
 block discarded – undo
1016 1016
     * @return   string
1017 1017
     * @throws   HTTP_Request2_Exception
1018 1018
     */
1019
-    protected function readChunked($bufferSize)
1020
-    {
1021
-        // at start of the next chunk?
1022
-        if (0 == $this->chunkLength) {
1023
-            $line = $this->readLine($bufferSize);
1024
-            if (!preg_match('/^([0-9a-f]+)/i', $line, $matches)) {
1025
-                throw new HTTP_Request2_Exception(
1026
-                    "Cannot decode chunked response, invalid chunk length '{$line}'"
1027
-                );
1028
-            } else {
1029
-                $this->chunkLength = hexdec($matches[1]);
1030
-                // Chunk with zero length indicates the end
1031
-                if (0 == $this->chunkLength) {
1032
-                    $this->readLine($bufferSize);
1033
-                    return '';
1034
-                }
1035
-            }
1036
-        }
1037
-        $data = $this->fread(min($this->chunkLength, $bufferSize));
1038
-        $this->chunkLength -= strlen($data);
1039
-        if (0 == $this->chunkLength) {
1040
-            $this->readLine($bufferSize); // Trailing CRLF
1041
-        }
1042
-        return $data;
1043
-    }
1019
+	protected function readChunked($bufferSize)
1020
+	{
1021
+		// at start of the next chunk?
1022
+		if (0 == $this->chunkLength) {
1023
+			$line = $this->readLine($bufferSize);
1024
+			if (!preg_match('/^([0-9a-f]+)/i', $line, $matches)) {
1025
+				throw new HTTP_Request2_Exception(
1026
+					"Cannot decode chunked response, invalid chunk length '{$line}'"
1027
+				);
1028
+			} else {
1029
+				$this->chunkLength = hexdec($matches[1]);
1030
+				// Chunk with zero length indicates the end
1031
+				if (0 == $this->chunkLength) {
1032
+					$this->readLine($bufferSize);
1033
+					return '';
1034
+				}
1035
+			}
1036
+		}
1037
+		$data = $this->fread(min($this->chunkLength, $bufferSize));
1038
+		$this->chunkLength -= strlen($data);
1039
+		if (0 == $this->chunkLength) {
1040
+			$this->readLine($bufferSize); // Trailing CRLF
1041
+		}
1042
+		return $data;
1043
+	}
1044 1044
 }
1045 1045
 
1046 1046
 ?>
1047 1047
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +65 added lines, -68 removed lines patch added patch discarded remove patch
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
 
163 163
             if ($this->deadline && time() > $this->deadline) {
164 164
                 throw new HTTP_Request2_Exception(
165
-                    'Request timed out after ' .
166
-                    $request->getConfig('timeout') . ' second(s)'
165
+                    'Request timed out after '.
166
+                    $request->getConfig('timeout').' second(s)'
167 167
                 );
168 168
             }
169 169
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
         $headers = $this->request->getHeaders();
217 217
         $reqHost = $this->request->getUrl()->getHost();
218 218
         if (!($reqPort = $this->request->getUrl()->getPort())) {
219
-            $reqPort = $secure? 443: 80;
219
+            $reqPort = $secure ? 443 : 80;
220 220
         }
221 221
 
222 222
         if ($host = $this->request->getConfig('proxy_host')) {
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
                       empty($headers['connection'])) ||
254 254
                      (!empty($headers['connection']) &&
255 255
                       'Keep-Alive' == $headers['connection']);
256
-        $host = ((!$secure || $proxy)? 'tcp://': 'ssl://') . $host;
256
+        $host = ((!$secure || $proxy) ? 'tcp://' : 'ssl://').$host;
257 257
 
258 258
         $options = array();
259 259
         if ($secure || $tunnel) {
@@ -273,9 +273,9 @@  discard block
 block discarded – undo
273 273
 
274 274
         // Changing SSL context options after connection is established does *not*
275 275
         // work, we need a new connection if options change
276
-        $remote    = $host . ':' . $port;
277
-        $socketKey = $remote . (($secure && $proxy)? "->{$reqHost}:{$reqPort}": '') .
278
-                     (empty($options)? '': ':' . serialize($options));
276
+        $remote    = $host.':'.$port;
277
+        $socketKey = $remote.(($secure && $proxy) ? "->{$reqHost}:{$reqPort}" : '').
278
+                     (empty($options) ? '' : ':'.serialize($options));
279 279
         unset($this->socket);
280 280
 
281 281
         // We use persistent connections and have a connected socket?
@@ -283,14 +283,14 @@  discard block
 block discarded – undo
283 283
         if ($keepAlive && !empty(self::$sockets[$socketKey]) &&
284 284
             !feof(self::$sockets[$socketKey])
285 285
         ) {
286
-            $this->socket =& self::$sockets[$socketKey];
286
+            $this->socket = & self::$sockets[$socketKey];
287 287
 
288 288
         } elseif ($secure && $proxy && !$tunnel) {
289 289
             $this->establishTunnel();
290 290
             $this->request->setLastEvent(
291 291
                 'connect', "ssl://{$reqHost}:{$reqPort} via {$host}:{$port}"
292 292
             );
293
-            self::$sockets[$socketKey] =& $this->socket;
293
+            self::$sockets[$socketKey] = & $this->socket;
294 294
 
295 295
         } else {
296 296
             // Set SSL context options if doing HTTPS request or creating a tunnel
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
                 );
314 314
             }
315 315
             $this->request->setLastEvent('connect', $remote);
316
-            self::$sockets[$socketKey] =& $this->socket;
316
+            self::$sockets[$socketKey] = & $this->socket;
317 317
         }
318 318
         return $keepAlive;
319 319
     }
@@ -340,8 +340,8 @@  discard block
 block discarded – undo
340 340
         // Need any successful (2XX) response
341 341
         if (200 > $response->getStatus() || 300 <= $response->getStatus()) {
342 342
             throw new HTTP_Request2_Exception(
343
-                'Failed to connect via HTTPS proxy. Proxy response: ' .
344
-                $response->getStatus() . ' ' . $response->getReasonPhrase()
343
+                'Failed to connect via HTTPS proxy. Proxy response: '.
344
+                $response->getStatus().' '.$response->getReasonPhrase()
345 345
             );
346 346
         }
347 347
         $this->socket = $donor->socket;
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
         if (0 == $this->redirectCountdown) {
422 422
             // Copying cURL behaviour
423 423
             throw new HTTP_Request2_Exception(
424
-                'Maximum (' . $request->getConfig('max_redirects') . ') redirects followed'
424
+                'Maximum ('.$request->getConfig('max_redirects').') redirects followed'
425 425
             );
426 426
         }
427 427
         $redirectUrl = new Net_URL2(
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
             && !in_array($redirectUrl->getScheme(), array('http', 'https'))
434 434
         ) {
435 435
             throw new HTTP_Request2_Exception(
436
-                'Refusing to redirect to a non-HTTP URL ' . $redirectUrl->__toString()
436
+                'Refusing to redirect to a non-HTTP URL '.$redirectUrl->__toString()
437 437
             );
438 438
         }
439 439
         // Theoretically URL should be absolute (see http://tools.ietf.org/html/rfc2616#section-14.30),
@@ -485,12 +485,12 @@  discard block
 block discarded – undo
485 485
 
486 486
         $url    = $this->request->getUrl();
487 487
         $scheme = $url->getScheme();
488
-        $host   = $scheme . '://' . $url->getHost();
488
+        $host   = $scheme.'://'.$url->getHost();
489 489
         if ($port = $url->getPort()) {
490 490
             if ((0 == strcasecmp($scheme, 'http') && 80 != $port) ||
491 491
                 (0 == strcasecmp($scheme, 'https') && 443 != $port)
492 492
             ) {
493
-                $host .= ':' . $port;
493
+                $host .= ':'.$port;
494 494
             }
495 495
         }
496 496
 
@@ -499,12 +499,12 @@  discard block
 block discarded – undo
499 499
             foreach (preg_split('/\\s+/', $challenge['domain']) as $prefix) {
500 500
                 // don't bother with different servers
501 501
                 if ('/' == substr($prefix, 0, 1)) {
502
-                    $prefixes[] = $host . $prefix;
502
+                    $prefixes[] = $host.$prefix;
503 503
                 }
504 504
             }
505 505
         }
506 506
         if (empty($prefixes)) {
507
-            $prefixes = array($host . '/');
507
+            $prefixes = array($host.'/');
508 508
         }
509 509
 
510 510
         $ret = true;
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
                 // probably credentials are invalid
516 516
                 $ret = false;
517 517
             }
518
-            self::$challenges[$prefix] =& $challenge;
518
+            self::$challenges[$prefix] = & $challenge;
519 519
         }
520 520
         return $ret;
521 521
     }
@@ -546,8 +546,8 @@  discard block
 block discarded – undo
546 546
             return false;
547 547
         }
548 548
 
549
-        $key = 'proxy://' . $this->request->getConfig('proxy_host') .
550
-               ':' . $this->request->getConfig('proxy_port');
549
+        $key = 'proxy://'.$this->request->getConfig('proxy_host').
550
+               ':'.$this->request->getConfig('proxy_port');
551 551
 
552 552
         if (!empty(self::$challenges[$key]) &&
553 553
             (empty($challenge['stale']) || strcasecmp('true', $challenge['stale']))
@@ -590,14 +590,14 @@  discard block
 block discarded – undo
590 590
     */
591 591
     protected function parseDigestChallenge($headerValue)
592 592
     {
593
-        $authParam   = '(' . self::REGEXP_TOKEN . ')\\s*=\\s*(' .
594
-                       self::REGEXP_TOKEN . '|' . self::REGEXP_QUOTED_STRING . ')';
593
+        $authParam   = '('.self::REGEXP_TOKEN.')\\s*=\\s*('.
594
+                       self::REGEXP_TOKEN.'|'.self::REGEXP_QUOTED_STRING.')';
595 595
         $challenge   = "!(?<=^|\\s|,)Digest ({$authParam}\\s*(,\\s*|$))+!";
596 596
         if (!preg_match($challenge, $headerValue, $matches)) {
597 597
             return false;
598 598
         }
599 599
 
600
-        preg_match_all('!' . $authParam . '!', $matches[0], $params);
600
+        preg_match_all('!'.$authParam.'!', $matches[0], $params);
601 601
         $paramsAry   = array();
602 602
         $knownParams = array('realm', 'domain', 'nonce', 'opaque', 'stale',
603 603
                              'algorithm', 'qop');
@@ -616,14 +616,14 @@  discard block
 block discarded – undo
616 616
             !in_array('auth', array_map('trim', explode(',', $paramsAry['qop'])))
617 617
         ) {
618 618
             throw new HTTP_Request2_Exception(
619
-                "Only 'auth' qop is currently supported in digest authentication, " .
619
+                "Only 'auth' qop is currently supported in digest authentication, ".
620 620
                 "server requested '{$paramsAry['qop']}'"
621 621
             );
622 622
         }
623 623
         // we only support algorithm=MD5
624 624
         if (!empty($paramsAry['algorithm']) && 'MD5' != $paramsAry['algorithm']) {
625 625
             throw new HTTP_Request2_Exception(
626
-                "Only 'MD5' algorithm is currently supported in digest authentication, " .
626
+                "Only 'MD5' algorithm is currently supported in digest authentication, ".
627 627
                 "server requested '{$paramsAry['algorithm']}'"
628 628
             );
629 629
         }
@@ -640,8 +640,8 @@  discard block
 block discarded – undo
640 640
     */
641 641
     protected function updateChallenge(&$challenge, $headerValue)
642 642
     {
643
-        $authParam   = '!(' . self::REGEXP_TOKEN . ')\\s*=\\s*(' .
644
-                       self::REGEXP_TOKEN . '|' . self::REGEXP_QUOTED_STRING . ')!';
643
+        $authParam   = '!('.self::REGEXP_TOKEN.')\\s*=\\s*('.
644
+                       self::REGEXP_TOKEN.'|'.self::REGEXP_QUOTED_STRING.')!';
645 645
         $paramsAry   = array();
646 646
 
647 647
         preg_match_all($authParam, $headerValue, $params);
@@ -677,31 +677,29 @@  discard block
 block discarded – undo
677 677
             $url = substr($url, 0, $q);
678 678
         }
679 679
 
680
-        $a1 = md5($user . ':' . $challenge['realm'] . ':' . $password);
681
-        $a2 = md5($this->request->getMethod() . ':' . $url);
680
+        $a1 = md5($user.':'.$challenge['realm'].':'.$password);
681
+        $a2 = md5($this->request->getMethod().':'.$url);
682 682
 
683 683
         if (empty($challenge['qop'])) {
684
-            $digest = md5($a1 . ':' . $challenge['nonce'] . ':' . $a2);
684
+            $digest = md5($a1.':'.$challenge['nonce'].':'.$a2);
685 685
         } else {
686
-            $challenge['cnonce'] = 'Req2.' . rand();
686
+            $challenge['cnonce'] = 'Req2.'.rand();
687 687
             if (empty($challenge['nc'])) {
688 688
                 $challenge['nc'] = 1;
689 689
             }
690 690
             $nc     = sprintf('%08x', $challenge['nc']++);
691
-            $digest = md5($a1 . ':' . $challenge['nonce'] . ':' . $nc . ':' .
692
-                          $challenge['cnonce'] . ':auth:' . $a2);
691
+            $digest = md5($a1.':'.$challenge['nonce'].':'.$nc.':'.
692
+                          $challenge['cnonce'].':auth:'.$a2);
693 693
         }
694
-        return 'Digest username="' . str_replace(array('\\', '"'), array('\\\\', '\\"'), $user) . '", ' .
695
-               'realm="' . $challenge['realm'] . '", ' .
696
-               'nonce="' . $challenge['nonce'] . '", ' .
697
-               'uri="' . $url . '", ' .
698
-               'response="' . $digest . '"' .
699
-               (!empty($challenge['opaque'])?
700
-                ', opaque="' . $challenge['opaque'] . '"':
701
-                '') .
702
-               (!empty($challenge['qop'])?
703
-                ', qop="auth", nc=' . $nc . ', cnonce="' . $challenge['cnonce'] . '"':
704
-                '');
694
+        return 'Digest username="'.str_replace(array('\\', '"'), array('\\\\', '\\"'), $user).'", '.
695
+               'realm="'.$challenge['realm'].'", '.
696
+               'nonce="'.$challenge['nonce'].'", '.
697
+               'uri="'.$url.'", '.
698
+               'response="'.$digest.'"'.
699
+               (!empty($challenge['opaque']) ?
700
+                ', opaque="'.$challenge['opaque'].'"' : '').
701
+               (!empty($challenge['qop']) ?
702
+                ', qop="auth", nc='.$nc.', cnonce="'.$challenge['cnonce'].'"' : '');
705 703
     }
706 704
 
707 705
    /**
@@ -720,22 +718,21 @@  discard block
 block discarded – undo
720 718
         switch ($auth['scheme']) {
721 719
             case HTTP_Request2::AUTH_BASIC:
722 720
                 $headers['authorization'] =
723
-                    'Basic ' . base64_encode($auth['user'] . ':' . $auth['password']);
721
+                    'Basic '.base64_encode($auth['user'].':'.$auth['password']);
724 722
                 break;
725 723
 
726 724
             case HTTP_Request2::AUTH_DIGEST:
727 725
                 unset($this->serverChallenge);
728
-                $fullUrl = ('/' == $requestUrl[0])?
729
-                           $this->request->getUrl()->getScheme() . '://' .
730
-                            $requestHost . $requestUrl:
731
-                           $requestUrl;
726
+                $fullUrl = ('/' == $requestUrl[0]) ?
727
+                           $this->request->getUrl()->getScheme().'://'.
728
+                            $requestHost.$requestUrl : $requestUrl;
732 729
                 foreach (array_keys(self::$challenges) as $key) {
733 730
                     if ($key == substr($fullUrl, 0, strlen($key))) {
734 731
                         $headers['authorization'] = $this->createDigestResponse(
735 732
                             $auth['user'], $auth['password'],
736 733
                             $requestUrl, self::$challenges[$key]
737 734
                         );
738
-                        $this->serverChallenge =& self::$challenges[$key];
735
+                        $this->serverChallenge = & self::$challenges[$key];
739 736
                         break;
740 737
                     }
741 738
                 }
@@ -769,26 +766,26 @@  discard block
 block discarded – undo
769 766
         switch ($this->request->getConfig('proxy_auth_scheme')) {
770 767
             case HTTP_Request2::AUTH_BASIC:
771 768
                 $headers['proxy-authorization'] =
772
-                    'Basic ' . base64_encode($user . ':' . $password);
769
+                    'Basic '.base64_encode($user.':'.$password);
773 770
                 break;
774 771
 
775 772
             case HTTP_Request2::AUTH_DIGEST:
776 773
                 unset($this->proxyChallenge);
777
-                $proxyUrl = 'proxy://' . $this->request->getConfig('proxy_host') .
778
-                            ':' . $this->request->getConfig('proxy_port');
774
+                $proxyUrl = 'proxy://'.$this->request->getConfig('proxy_host').
775
+                            ':'.$this->request->getConfig('proxy_port');
779 776
                 if (!empty(self::$challenges[$proxyUrl])) {
780 777
                     $headers['proxy-authorization'] = $this->createDigestResponse(
781 778
                         $user, $password,
782 779
                         $requestUrl, self::$challenges[$proxyUrl]
783 780
                     );
784
-                    $this->proxyChallenge =& self::$challenges[$proxyUrl];
781
+                    $this->proxyChallenge = & self::$challenges[$proxyUrl];
785 782
                 }
786 783
                 break;
787 784
 
788 785
             default:
789 786
                 throw new HTTP_Request2_Exception(
790
-                    "Unknown HTTP authentication scheme '" .
791
-                    $this->request->getConfig('proxy_auth_scheme') . "'"
787
+                    "Unknown HTTP authentication scheme '".
788
+                    $this->request->getConfig('proxy_auth_scheme')."'"
792 789
                 );
793 790
         }
794 791
     }
@@ -807,9 +804,9 @@  discard block
 block discarded – undo
807 804
         $connect = HTTP_Request2::METHOD_CONNECT == $this->request->getMethod();
808 805
         $host    = $url->getHost();
809 806
 
810
-        $defaultPort = 0 == strcasecmp($url->getScheme(), 'https')? 443: 80;
807
+        $defaultPort = 0 == strcasecmp($url->getScheme(), 'https') ? 443 : 80;
811 808
         if (($port = $url->getPort()) && $port != $defaultPort || $connect) {
812
-            $host .= ':' . (empty($port)? $defaultPort: $port);
809
+            $host .= ':'.(empty($port) ? $defaultPort : $port);
813 810
         }
814 811
         // Do not overwrite explicitly set 'Host' header, see bug #16146
815 812
         if (!isset($headers['host'])) {
@@ -825,11 +822,11 @@  discard block
 block discarded – undo
825 822
             ) {
826 823
                 $requestUrl = '';
827 824
             } else {
828
-                $requestUrl = $url->getScheme() . '://' . $host;
825
+                $requestUrl = $url->getScheme().'://'.$host;
829 826
             }
830 827
             $path        = $url->getPath();
831 828
             $query       = $url->getQuery();
832
-            $requestUrl .= (empty($path)? '/': $path) . (empty($query)? '': '?' . $query);
829
+            $requestUrl .= (empty($path) ? '/' : $path).(empty($query) ? '' : '?'.$query);
833 830
         }
834 831
 
835 832
         if ('1.1' == $this->request->getConfig('protocol_version') &&
@@ -842,13 +839,13 @@  discard block
 block discarded – undo
842 839
         $this->addProxyAuthorizationHeader($headers, $requestUrl);
843 840
         $this->calculateRequestLength($headers);
844 841
 
845
-        $headersStr = $this->request->getMethod() . ' ' . $requestUrl . ' HTTP/' .
846
-                      $this->request->getConfig('protocol_version') . "\r\n";
842
+        $headersStr = $this->request->getMethod().' '.$requestUrl.' HTTP/'.
843
+                      $this->request->getConfig('protocol_version')."\r\n";
847 844
         foreach ($headers as $name => $value) {
848 845
             $canonicalName = implode('-', array_map('ucfirst', explode('-', $name)));
849
-            $headersStr   .= $canonicalName . ': ' . $value . "\r\n";
846
+            $headersStr   .= $canonicalName.': '.$value."\r\n";
850 847
         }
851
-        return $headersStr . "\r\n";
848
+        return $headersStr."\r\n";
852 849
     }
853 850
 
854 851
    /**
@@ -920,7 +917,7 @@  discard block
 block discarded – undo
920 917
             // 3. ... If a message is received with both a
921 918
             // Transfer-Encoding header field and a Content-Length header field,
922 919
             // the latter MUST be ignored.
923
-            $toRead = ($chunked || null === $length)? null: $length;
920
+            $toRead = ($chunked || null === $length) ? null: $length;
924 921
             $this->chunkLength = 0;
925 922
 
926 923
             while (!feof($this->socket) && (is_null($toRead) || 0 < $toRead)) {
@@ -975,7 +972,7 @@  discard block
 block discarded – undo
975 972
             $info  = stream_get_meta_data($this->socket);
976 973
             if ($info['timed_out'] || $this->deadline && time() > $this->deadline) {
977 974
                 $reason = $this->deadline
978
-                          ? 'after ' . $this->request->getConfig('timeout') . ' second(s)'
975
+                          ? 'after '.$this->request->getConfig('timeout').' second(s)'
979 976
                           : 'due to default_socket_timeout php.ini setting';
980 977
                 throw new HTTP_Request2_Exception("Request timed out {$reason}");
981 978
             }
@@ -1002,7 +999,7 @@  discard block
 block discarded – undo
1002 999
         $info = stream_get_meta_data($this->socket);
1003 1000
         if ($info['timed_out'] || $this->deadline && time() > $this->deadline) {
1004 1001
             $reason = $this->deadline
1005
-                      ? 'after ' . $this->request->getConfig('timeout') . ' second(s)'
1002
+                      ? 'after '.$this->request->getConfig('timeout').' second(s)'
1006 1003
                       : 'due to default_socket_timeout php.ini setting';
1007 1004
             throw new HTTP_Request2_Exception("Request timed out {$reason}");
1008 1005
         }
Please login to merge, or discard this patch.