Completed
Push — 1.10.x ( a26f23...c6c321 )
by Julito
59:04
created
main/inc/lib/magpierss/rss_utils.inc 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -22,35 +22,35 @@
 block discarded – undo
22 22
  *
23 23
  * NOTE: http://www.w3.org/TR/NOTE-datetime
24 24
  */
25
-function parse_w3cdtf ( $date_str ) {
25
+function parse_w3cdtf($date_str) {
26 26
     
27 27
     # regex to match wc3dtf
28 28
     $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/";
29 29
     
30
-    if ( preg_match( $pat, $date_str, $match ) ) {
31
-        list( $year, $month, $day, $hours, $minutes, $seconds) = 
32
-            array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6]);
30
+    if (preg_match($pat, $date_str, $match)) {
31
+        list($year, $month, $day, $hours, $minutes, $seconds) = 
32
+            array($match[1], $match[2], $match[3], $match[4], $match[5], $match[6]);
33 33
         
34 34
         # calc epoch for current date assuming GMT
35
-        $epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year);
35
+        $epoch = gmmktime($hours, $minutes, $seconds, $month, $day, $year);
36 36
         
37 37
         $offset = 0;
38
-        if ( $match[10] == 'Z' ) {
38
+        if ($match[10] == 'Z') {
39 39
             # zulu time, aka GMT
40 40
         }
41 41
         else {
42
-            list( $tz_mod, $tz_hour, $tz_min ) =
43
-                array( $match[8], $match[9], $match[10]);
42
+            list($tz_mod, $tz_hour, $tz_min) =
43
+                array($match[8], $match[9], $match[10]);
44 44
             
45 45
             # zero out the variables
46
-            if ( ! $tz_hour ) { $tz_hour = 0; }
47
-            if ( ! $tz_min ) { $tz_min = 0; }
46
+            if (!$tz_hour) { $tz_hour = 0; }
47
+            if (!$tz_min) { $tz_min = 0; }
48 48
         
49
-            $offset_secs = (($tz_hour*60)+$tz_min)*60;
49
+            $offset_secs = (($tz_hour * 60) + $tz_min) * 60;
50 50
             
51 51
             # is timezone ahead of GMT?  then subtract offset
52 52
             #
53
-            if ( $tz_mod == '+' ) {
53
+            if ($tz_mod == '+') {
54 54
                 $offset_secs = $offset_secs * -1;
55 55
             }
56 56
             
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@  discard block
 block discarded – undo
37 37
         $offset = 0;
38 38
         if ( $match[10] == 'Z' ) {
39 39
             # zulu time, aka GMT
40
-        }
41
-        else {
40
+        } else {
42 41
             list( $tz_mod, $tz_hour, $tz_min ) =
43 42
                 array( $match[8], $match[9], $match[10]);
44 43
             
@@ -58,8 +57,7 @@  discard block
 block discarded – undo
58 57
         }
59 58
         $epoch = $epoch + $offset;
60 59
         return $epoch;
61
-    }
62
-    else {
60
+    } else {
63 61
         return -1;
64 62
     }
65 63
 }
Please login to merge, or discard this patch.
main/inc/lib/magpierss/extlib/Snoopy.class.inc 4 patches
Indentation   +666 added lines, -666 removed lines patch added patch discarded remove patch
@@ -36,81 +36,81 @@  discard block
 block discarded – undo
36 36
 *************************************************/
37 37
 
38 38
 class Snoopy {
39
-	/**** Public variables ****/
39
+    /**** Public variables ****/
40 40
 	
41
-	/* user definable vars */
42
-
43
-	public $host			=	"www.php.net";		// host name we are connecting to
44
-	public $port			=	80;					// port we are connecting to
45
-	public $proxy_host		=	"";					// proxy host to use
46
-	public $proxy_port		=	"";					// proxy port to use
47
-	public $agent			=	"Snoopy v1.0";		// agent we masquerade as
48
-	public $referer		=	"";					// referer info to pass
49
-	public $cookies		=	array();			// array of cookies to pass
50
-												// $cookies["username"]="joe";
51
-	public	$rawheaders		=	array();			// array of raw headers to send
52
-												// $rawheaders["Content-type"]="text/html";
53
-
54
-	public $maxredirs		=	5;					// http redirection depth maximum. 0 = disallow
55
-	public $lastredirectaddr	=	"";				// contains address of last redirected address
56
-	public	$offsiteok		=	true;				// allows redirection off-site
57
-	public $maxframes		=	0;					// frame content depth maximum. 0 = disallow
58
-	public $expandlinks	=	true;				// expand links to fully qualified URLs.
59
-												// this only applies to fetchlinks()
60
-												// or submitlinks()
61
-	public $passcookies	=	true;				// pass set cookies back through redirects
62
-												// NOTE: this currently does not respect
63
-												// dates, domains or paths.
41
+    /* user definable vars */
42
+
43
+    public $host			=	"www.php.net";		// host name we are connecting to
44
+    public $port			=	80;					// port we are connecting to
45
+    public $proxy_host		=	"";					// proxy host to use
46
+    public $proxy_port		=	"";					// proxy port to use
47
+    public $agent			=	"Snoopy v1.0";		// agent we masquerade as
48
+    public $referer		=	"";					// referer info to pass
49
+    public $cookies		=	array();			// array of cookies to pass
50
+                                                // $cookies["username"]="joe";
51
+    public	$rawheaders		=	array();			// array of raw headers to send
52
+                                                // $rawheaders["Content-type"]="text/html";
53
+
54
+    public $maxredirs		=	5;					// http redirection depth maximum. 0 = disallow
55
+    public $lastredirectaddr	=	"";				// contains address of last redirected address
56
+    public	$offsiteok		=	true;				// allows redirection off-site
57
+    public $maxframes		=	0;					// frame content depth maximum. 0 = disallow
58
+    public $expandlinks	=	true;				// expand links to fully qualified URLs.
59
+                                                // this only applies to fetchlinks()
60
+                                                // or submitlinks()
61
+    public $passcookies	=	true;				// pass set cookies back through redirects
62
+                                                // NOTE: this currently does not respect
63
+                                                // dates, domains or paths.
64 64
 	
65
-	public	$user			=	"";					// user for http authentication
66
-	public	$pass			=	"";					// password for http authentication
65
+    public	$user			=	"";					// user for http authentication
66
+    public	$pass			=	"";					// password for http authentication
67 67
 	
68
-	// http accept types
69
-	public $accept			=	"image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
68
+    // http accept types
69
+    public $accept			=	"image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
70 70
 	
71
-	public $results		=	"";					// where the content is put
71
+    public $results		=	"";					// where the content is put
72 72
 		
73
-	public $error			=	"";					// error messages sent here
74
-	public	$response_code	=	"";					// response code returned from server
75
-	public	$headers		=	array();			// headers returned from server sent here
76
-	public	$maxlength		=	500000;				// max return data length (body)
77
-	public $read_timeout	=	0;					// timeout on read operations, in seconds
78
-												// supported only since PHP 4 Beta 4
79
-												// set to 0 to disallow timeouts
80
-	public $timed_out		=	false;				// if a read operation timed out
81
-	public	$status			=	0;					// http request status
73
+    public $error			=	"";					// error messages sent here
74
+    public	$response_code	=	"";					// response code returned from server
75
+    public	$headers		=	array();			// headers returned from server sent here
76
+    public	$maxlength		=	500000;				// max return data length (body)
77
+    public $read_timeout	=	0;					// timeout on read operations, in seconds
78
+                                                // supported only since PHP 4 Beta 4
79
+                                                // set to 0 to disallow timeouts
80
+    public $timed_out		=	false;				// if a read operation timed out
81
+    public	$status			=	0;					// http request status
82 82
 	
83
-	public	$curl_path		=	"/usr/bin/curl";
84
-												// Snoopy will use cURL for fetching
85
-												// SSL content if a full system path to
86
-												// the cURL binary is supplied here.
87
-												// set to false if you do not have
88
-												// cURL installed. See http://curl.haxx.se
89
-												// for details on installing cURL.
90
-												// Snoopy does *not* use the cURL
91
-												// library functions built into php,
92
-												// as these functions are not stable
93
-												// as of this Snoopy release.
83
+    public	$curl_path		=	"/usr/bin/curl";
84
+                                                // Snoopy will use cURL for fetching
85
+                                                // SSL content if a full system path to
86
+                                                // the cURL binary is supplied here.
87
+                                                // set to false if you do not have
88
+                                                // cURL installed. See http://curl.haxx.se
89
+                                                // for details on installing cURL.
90
+                                                // Snoopy does *not* use the cURL
91
+                                                // library functions built into php,
92
+                                                // as these functions are not stable
93
+                                                // as of this Snoopy release.
94 94
 	
95
-	// send Accept-encoding: gzip?
96
-	public $use_gzip		= true;	
95
+    // send Accept-encoding: gzip?
96
+    public $use_gzip		= true;	
97 97
 	
98
-	/**** Private variables ****/	
98
+    /**** Private variables ****/	
99 99
 	
100
-	private	$_maxlinelen	=	4096;				// max line length (headers)
100
+    private	$_maxlinelen	=	4096;				// max line length (headers)
101 101
 	
102
-	private $_httpmethod	=	"GET";				// default http request method
103
-	private $_httpversion	=	"HTTP/1.0";			// default http request version
104
-	private $_submit_method	=	"POST";				// default submit method
105
-	private $_submit_type	=	"application/x-www-form-urlencoded";	// default submit type
106
-	private $_mime_boundary	=   "";					// MIME boundary for multipart/form-data submit type
107
-	private $_redirectaddr	=	false;				// will be set if page fetched is a redirect
108
-	private $_redirectdepth	=	0;					// increments on an http redirect
109
-	private $_frameurls		= 	array();			// frame src urls
110
-	private $_framedepth	=	0;					// increments on frame depth
102
+    private $_httpmethod	=	"GET";				// default http request method
103
+    private $_httpversion	=	"HTTP/1.0";			// default http request version
104
+    private $_submit_method	=	"POST";				// default submit method
105
+    private $_submit_type	=	"application/x-www-form-urlencoded";	// default submit type
106
+    private $_mime_boundary	=   "";					// MIME boundary for multipart/form-data submit type
107
+    private $_redirectaddr	=	false;				// will be set if page fetched is a redirect
108
+    private $_redirectdepth	=	0;					// increments on an http redirect
109
+    private $_frameurls		= 	array();			// frame src urls
110
+    private $_framedepth	=	0;					// increments on frame depth
111 111
 	
112
-	private $_isproxy		=	false;				// set if using a proxy server
113
-	private $_fp_timeout	=	30;					// timeout for socket connection
112
+    private $_isproxy		=	false;				// set if using a proxy server
113
+    private $_fp_timeout	=	30;					// timeout for socket connection
114 114
 
115 115
 /*======================================================================*\
116 116
 	Function:	fetch
@@ -121,136 +121,136 @@  discard block
 block discarded – undo
121 121
 	Output:		$this->results	the output text from the fetch
122 122
 \*======================================================================*/
123 123
 
124
-	public function fetch($URI) {
125
-		//preg_match("|^([^:]+)://([^:/]+)(:[\d]+)*(.*)|",$URI,$URI_PARTS);
126
-		$URI_PARTS = parse_url($URI);
127
-		if (!empty($URI_PARTS["user"]))
128
-			$this->user = $URI_PARTS["user"];
129
-		if (!empty($URI_PARTS["pass"]))
130
-			$this->pass = $URI_PARTS["pass"];
131
-		if (!isset($fp)) { $fp = false; }
132
-		switch ($URI_PARTS["scheme"]) {
133
-			case "http":
134
-				$this->host = $URI_PARTS["host"];
135
-				if(!empty($URI_PARTS["port"]))
136
-					$this->port = $URI_PARTS["port"];
137
-				if($this->_connect($fp))
138
-				{
139
-					if($this->_isproxy)
140
-					{
141
-						// using proxy, send entire URI
142
-						$this->_httprequest($URI,$fp,$URI,$this->_httpmethod);
143
-					}
144
-					else
145
-					{
146
-						$path = $URI_PARTS["path"].(isset($URI_PARTS["query"]) ? "?".$URI_PARTS["query"] : "");
147
-						// no proxy, send only the path
148
-						$this->_httprequest($path, $fp, $URI, $this->_httpmethod);
149
-					}
124
+    public function fetch($URI) {
125
+        //preg_match("|^([^:]+)://([^:/]+)(:[\d]+)*(.*)|",$URI,$URI_PARTS);
126
+        $URI_PARTS = parse_url($URI);
127
+        if (!empty($URI_PARTS["user"]))
128
+            $this->user = $URI_PARTS["user"];
129
+        if (!empty($URI_PARTS["pass"]))
130
+            $this->pass = $URI_PARTS["pass"];
131
+        if (!isset($fp)) { $fp = false; }
132
+        switch ($URI_PARTS["scheme"]) {
133
+            case "http":
134
+                $this->host = $URI_PARTS["host"];
135
+                if(!empty($URI_PARTS["port"]))
136
+                    $this->port = $URI_PARTS["port"];
137
+                if($this->_connect($fp))
138
+                {
139
+                    if($this->_isproxy)
140
+                    {
141
+                        // using proxy, send entire URI
142
+                        $this->_httprequest($URI,$fp,$URI,$this->_httpmethod);
143
+                    }
144
+                    else
145
+                    {
146
+                        $path = $URI_PARTS["path"].(isset($URI_PARTS["query"]) ? "?".$URI_PARTS["query"] : "");
147
+                        // no proxy, send only the path
148
+                        $this->_httprequest($path, $fp, $URI, $this->_httpmethod);
149
+                    }
150 150
 					
151
-					$this->_disconnect($fp);
152
-
153
-					if($this->_redirectaddr)
154
-					{
155
-						/* url was redirected, check if we've hit the max depth */
156
-						if($this->maxredirs > $this->_redirectdepth)
157
-						{
158
-							// only follow redirect if it's on this site, or offsiteok is true
159
-							if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
160
-							{
161
-								/* follow the redirect */
162
-								$this->_redirectdepth++;
163
-								$this->lastredirectaddr=$this->_redirectaddr;
164
-								$this->fetch($this->_redirectaddr);
165
-							}
166
-						}
167
-					}
168
-
169
-					if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
170
-					{
171
-						$frameurls = $this->_frameurls;
172
-						$this->_frameurls = array();
151
+                    $this->_disconnect($fp);
152
+
153
+                    if($this->_redirectaddr)
154
+                    {
155
+                        /* url was redirected, check if we've hit the max depth */
156
+                        if($this->maxredirs > $this->_redirectdepth)
157
+                        {
158
+                            // only follow redirect if it's on this site, or offsiteok is true
159
+                            if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
160
+                            {
161
+                                /* follow the redirect */
162
+                                $this->_redirectdepth++;
163
+                                $this->lastredirectaddr=$this->_redirectaddr;
164
+                                $this->fetch($this->_redirectaddr);
165
+                            }
166
+                        }
167
+                    }
168
+
169
+                    if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
170
+                    {
171
+                        $frameurls = $this->_frameurls;
172
+                        $this->_frameurls = array();
173 173
 						
174
-						while(list(,$frameurl) = each($frameurls))
175
-						{
176
-							if($this->_framedepth < $this->maxframes)
177
-							{
178
-								$this->fetch($frameurl);
179
-								$this->_framedepth++;
180
-							}
181
-							else
182
-								break;
183
-						}
184
-					}					
185
-				}
186
-				else
187
-				{
188
-					return false;
189
-				}
190
-				return true;					
191
-				break;
192
-			case "https":
193
-				if(!$this->curl_path || (!is_executable($this->curl_path))) {
194
-					$this->error = "Bad curl ($this->curl_path), can't fetch HTTPS \n";
195
-					return false;
196
-				}
197
-				$this->host = $URI_PARTS["host"];
198
-				if(!empty($URI_PARTS["port"]))
199
-					$this->port = $URI_PARTS["port"];
200
-				if($this->_isproxy)
201
-				{
202
-					// using proxy, send entire URI
203
-					$this->_httpsrequest($URI,$URI,$this->_httpmethod);
204
-				}
205
-				else
206
-				{
207
-					$path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : "");
208
-					// no proxy, send only the path
209
-					$this->_httpsrequest($path, $URI, $this->_httpmethod);
210
-				}
211
-
212
-				if($this->_redirectaddr)
213
-				{
214
-					/* url was redirected, check if we've hit the max depth */
215
-					if($this->maxredirs > $this->_redirectdepth)
216
-					{
217
-						// only follow redirect if it's on this site, or offsiteok is true
218
-						if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
219
-						{
220
-							/* follow the redirect */
221
-							$this->_redirectdepth++;
222
-							$this->lastredirectaddr=$this->_redirectaddr;
223
-							$this->fetch($this->_redirectaddr);
224
-						}
225
-					}
226
-				}
227
-
228
-				if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
229
-				{
230
-					$frameurls = $this->_frameurls;
231
-					$this->_frameurls = array();
232
-
233
-					while(list(,$frameurl) = each($frameurls))
234
-					{
235
-						if($this->_framedepth < $this->maxframes)
236
-						{
237
-							$this->fetch($frameurl);
238
-							$this->_framedepth++;
239
-						}
240
-						else
241
-							break;
242
-					}
243
-				}					
244
-				return true;					
245
-				break;
246
-			default:
247
-				// not a valid protocol
248
-				$this->error	=	'Invalid protocol "'.$URI_PARTS["scheme"].'"\n';
249
-				return false;
250
-				break;
251
-		}		
252
-		return true;
253
-	}
174
+                        while(list(,$frameurl) = each($frameurls))
175
+                        {
176
+                            if($this->_framedepth < $this->maxframes)
177
+                            {
178
+                                $this->fetch($frameurl);
179
+                                $this->_framedepth++;
180
+                            }
181
+                            else
182
+                                break;
183
+                        }
184
+                    }					
185
+                }
186
+                else
187
+                {
188
+                    return false;
189
+                }
190
+                return true;					
191
+                break;
192
+            case "https":
193
+                if(!$this->curl_path || (!is_executable($this->curl_path))) {
194
+                    $this->error = "Bad curl ($this->curl_path), can't fetch HTTPS \n";
195
+                    return false;
196
+                }
197
+                $this->host = $URI_PARTS["host"];
198
+                if(!empty($URI_PARTS["port"]))
199
+                    $this->port = $URI_PARTS["port"];
200
+                if($this->_isproxy)
201
+                {
202
+                    // using proxy, send entire URI
203
+                    $this->_httpsrequest($URI,$URI,$this->_httpmethod);
204
+                }
205
+                else
206
+                {
207
+                    $path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : "");
208
+                    // no proxy, send only the path
209
+                    $this->_httpsrequest($path, $URI, $this->_httpmethod);
210
+                }
211
+
212
+                if($this->_redirectaddr)
213
+                {
214
+                    /* url was redirected, check if we've hit the max depth */
215
+                    if($this->maxredirs > $this->_redirectdepth)
216
+                    {
217
+                        // only follow redirect if it's on this site, or offsiteok is true
218
+                        if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
219
+                        {
220
+                            /* follow the redirect */
221
+                            $this->_redirectdepth++;
222
+                            $this->lastredirectaddr=$this->_redirectaddr;
223
+                            $this->fetch($this->_redirectaddr);
224
+                        }
225
+                    }
226
+                }
227
+
228
+                if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
229
+                {
230
+                    $frameurls = $this->_frameurls;
231
+                    $this->_frameurls = array();
232
+
233
+                    while(list(,$frameurl) = each($frameurls))
234
+                    {
235
+                        if($this->_framedepth < $this->maxframes)
236
+                        {
237
+                            $this->fetch($frameurl);
238
+                            $this->_framedepth++;
239
+                        }
240
+                        else
241
+                            break;
242
+                    }
243
+                }					
244
+                return true;					
245
+                break;
246
+            default:
247
+                // not a valid protocol
248
+                $this->error	=	'Invalid protocol "'.$URI_PARTS["scheme"].'"\n';
249
+                return false;
250
+                break;
251
+        }		
252
+        return true;
253
+    }
254 254
 
255 255
 
256 256
 
@@ -266,32 +266,32 @@  discard block
 block discarded – undo
266 266
 	Output:		$match		an array of the links
267 267
 \*======================================================================*/
268 268
 
269
-	private function _striplinks($document)
270
-	{	
271
-		preg_match_all("'<\s*a\s+.*href\s*=\s*			# find <a href=
269
+    private function _striplinks($document)
270
+    {	
271
+        preg_match_all("'<\s*a\s+.*href\s*=\s*			# find <a href=
272 272
 						([\"\'])?					# find single or double quote
273 273
 						(?(1) (.*?)\\1 | ([^\s\>]+))		# if quote found, match up to next matching
274 274
 													# quote, otherwise match up to next space
275 275
 						'isx",$document,$links);
276 276
 						
277 277
 
278
-		// catenate the non-empty matches from the conditional subpattern
278
+        // catenate the non-empty matches from the conditional subpattern
279 279
 
280
-		while(list($key,$val) = each($links[2]))
281
-		{
282
-			if(!empty($val))
283
-				$match[] = $val;
284
-		}				
280
+        while(list($key,$val) = each($links[2]))
281
+        {
282
+            if(!empty($val))
283
+                $match[] = $val;
284
+        }				
285 285
 		
286
-		while(list($key,$val) = each($links[3]))
287
-		{
288
-			if(!empty($val))
289
-				$match[] = $val;
290
-		}		
286
+        while(list($key,$val) = each($links[3]))
287
+        {
288
+            if(!empty($val))
289
+                $match[] = $val;
290
+        }		
291 291
 		
292
-		// return the links
293
-		return $match;
294
-	}
292
+        // return the links
293
+        return $match;
294
+    }
295 295
 
296 296
 /*======================================================================*\
297 297
 	Function:	_stripform
@@ -300,16 +300,16 @@  discard block
 block discarded – undo
300 300
 	Output:		$match		an array of the links
301 301
 \*======================================================================*/
302 302
 
303
-	private function _stripform($document)
304
-	{	
305
-		preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi",$document,$elements);
303
+    private function _stripform($document)
304
+    {	
305
+        preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi",$document,$elements);
306 306
 		
307
-		// catenate the matches
308
-		$match = implode("\r\n",$elements[0]);
307
+        // catenate the matches
308
+        $match = implode("\r\n",$elements[0]);
309 309
 				
310
-		// return the links
311
-		return $match;
312
-	}
310
+        // return the links
311
+        return $match;
312
+    }
313 313
 
314 314
 	
315 315
 	
@@ -320,43 +320,43 @@  discard block
 block discarded – undo
320 320
 	Output:		$text		the resulting text
321 321
 \*======================================================================*/
322 322
 
323
-	private function _striptext($document)
324
-	{
323
+    private function _striptext($document)
324
+    {
325 325
 		
326
-		// I didn't use preg eval (//e) since that is only available in PHP 4.0.
327
-		// so, list your entities one by one here. I included some of the
328
-		// more common ones.
326
+        // I didn't use preg eval (//e) since that is only available in PHP 4.0.
327
+        // so, list your entities one by one here. I included some of the
328
+        // more common ones.
329 329
 								
330
-		$search = array("'<script[^>]*?>.*?</script>'si",	// strip out javascript
331
-						"'<[\/\!]*?[^<>]*?>'si",			// strip out html tags
332
-						"'([\r\n])[\s]+'",					// strip out white space
333
-						"'&(quote|#34);'i",					// replace html entities
334
-						"'&(amp|#38);'i",
335
-						"'&(lt|#60);'i",
336
-						"'&(gt|#62);'i",
337
-						"'&(nbsp|#160);'i",
338
-						"'&(iexcl|#161);'i",
339
-						"'&(cent|#162);'i",
340
-						"'&(pound|#163);'i",
341
-						"'&(copy|#169);'i"
342
-						);				
343
-		$replace = array(	"",
344
-							"",
345
-							"\\1",
346
-							"\"",
347
-							"&",
348
-							"<",
349
-							">",
350
-							" ",
351
-							chr(161),
352
-							chr(162),
353
-							chr(163),
354
-							chr(169));
330
+        $search = array("'<script[^>]*?>.*?</script>'si",	// strip out javascript
331
+                        "'<[\/\!]*?[^<>]*?>'si",			// strip out html tags
332
+                        "'([\r\n])[\s]+'",					// strip out white space
333
+                        "'&(quote|#34);'i",					// replace html entities
334
+                        "'&(amp|#38);'i",
335
+                        "'&(lt|#60);'i",
336
+                        "'&(gt|#62);'i",
337
+                        "'&(nbsp|#160);'i",
338
+                        "'&(iexcl|#161);'i",
339
+                        "'&(cent|#162);'i",
340
+                        "'&(pound|#163);'i",
341
+                        "'&(copy|#169);'i"
342
+                        );				
343
+        $replace = array(	"",
344
+                            "",
345
+                            "\\1",
346
+                            "\"",
347
+                            "&",
348
+                            "<",
349
+                            ">",
350
+                            " ",
351
+                            chr(161),
352
+                            chr(162),
353
+                            chr(163),
354
+                            chr(169));
355 355
 					
356
-		$text = preg_replace($search,$replace,$document);
356
+        $text = preg_replace($search,$replace,$document);
357 357
 								
358
-		return $text;
359
-	}
358
+        return $text;
359
+    }
360 360
 
361 361
 /*======================================================================*\
362 362
 	Function:	_expandlinks
@@ -366,29 +366,29 @@  discard block
 block discarded – undo
366 366
 	Output:		$expandedLinks	the expanded links
367 367
 \*======================================================================*/
368 368
 
369
-	private function _expandlinks($links,$URI)
370
-	{
369
+    private function _expandlinks($links,$URI)
370
+    {
371 371
 		
372
-		preg_match("/^[^\?]+/",$URI,$match);
372
+        preg_match("/^[^\?]+/",$URI,$match);
373 373
 
374
-		$match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|","",$match[0]);
374
+        $match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|","",$match[0]);
375 375
 				
376
-		$search = array( 	"|^http://".preg_quote($this->host)."|i",
377
-							"|^(?!http://)(\/)?(?!mailto:)|i",
378
-							"|/\./|",
379
-							"|/[^\/]+/\.\./|"
380
-						);
376
+        $search = array( 	"|^http://".preg_quote($this->host)."|i",
377
+                            "|^(?!http://)(\/)?(?!mailto:)|i",
378
+                            "|/\./|",
379
+                            "|/[^\/]+/\.\./|"
380
+                        );
381 381
 						
382
-		$replace = array(	"",
383
-							$match."/",
384
-							"/",
385
-							"/"
386
-						);			
382
+        $replace = array(	"",
383
+                            $match."/",
384
+                            "/",
385
+                            "/"
386
+                        );			
387 387
 				
388
-		$expandedLinks = preg_replace($search,$replace,$links);
388
+        $expandedLinks = preg_replace($search,$replace,$links);
389 389
 
390
-		return $expandedLinks;
391
-	}
390
+        return $expandedLinks;
391
+    }
392 392
 
393 393
 /*======================================================================*\
394 394
 	Function:	_httprequest
@@ -400,179 +400,179 @@  discard block
 block discarded – undo
400 400
 	Output:		
401 401
 \*======================================================================*/
402 402
 	
403
-	private function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="")
404
-	{
405
-		if($this->passcookies && $this->_redirectaddr)
406
-			$this->setcookies();
403
+    private function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="")
404
+    {
405
+        if($this->passcookies && $this->_redirectaddr)
406
+            $this->setcookies();
407 407
 			
408
-		$URI_PARTS = parse_url($URI);
409
-		if(empty($url))
410
-			$url = "/";
411
-		$headers = $http_method." ".$url." ".$this->_httpversion."\r\n";		
412
-		if(!empty($this->agent))
413
-			$headers .= "User-Agent: ".$this->agent."\r\n";
414
-		if(!empty($this->host) && !isset($this->rawheaders['Host']))
415
-			$headers .= "Host: ".$this->host."\r\n";
416
-		if(!empty($this->accept))
417
-			$headers .= "Accept: ".$this->accept."\r\n";
408
+        $URI_PARTS = parse_url($URI);
409
+        if(empty($url))
410
+            $url = "/";
411
+        $headers = $http_method." ".$url." ".$this->_httpversion."\r\n";		
412
+        if(!empty($this->agent))
413
+            $headers .= "User-Agent: ".$this->agent."\r\n";
414
+        if(!empty($this->host) && !isset($this->rawheaders['Host']))
415
+            $headers .= "Host: ".$this->host."\r\n";
416
+        if(!empty($this->accept))
417
+            $headers .= "Accept: ".$this->accept."\r\n";
418 418
 		
419
-		if($this->use_gzip) {
420
-			// make sure PHP was built with --with-zlib
421
-			// and we can handle gzipp'ed data
422
-			if ( function_exists(gzinflate) ) {
423
-			   $headers .= "Accept-encoding: gzip\r\n";
424
-			}
425
-			else {
426
-			   trigger_error(
427
-			   	"use_gzip is on, but PHP was built without zlib support.".
428
-				"  Requesting file(s) without gzip encoding.", 
429
-				E_USER_NOTICE);
430
-			}
431
-		}
419
+        if($this->use_gzip) {
420
+            // make sure PHP was built with --with-zlib
421
+            // and we can handle gzipp'ed data
422
+            if ( function_exists(gzinflate) ) {
423
+                $headers .= "Accept-encoding: gzip\r\n";
424
+            }
425
+            else {
426
+                trigger_error(
427
+                    "use_gzip is on, but PHP was built without zlib support.".
428
+                "  Requesting file(s) without gzip encoding.", 
429
+                E_USER_NOTICE);
430
+            }
431
+        }
432 432
 		
433
-		if(!empty($this->referer))
434
-			$headers .= "Referer: ".$this->referer."\r\n";
435
-		if(!empty($this->cookies))
436
-		{			
437
-			if(!is_array($this->cookies))
438
-				$this->cookies = (array)$this->cookies;
433
+        if(!empty($this->referer))
434
+            $headers .= "Referer: ".$this->referer."\r\n";
435
+        if(!empty($this->cookies))
436
+        {			
437
+            if(!is_array($this->cookies))
438
+                $this->cookies = (array)$this->cookies;
439 439
 	
440
-			reset($this->cookies);
441
-			if ( count($this->cookies) > 0 ) {
442
-				$cookie_headers .= 'Cookie: ';
443
-				foreach ( $this->cookies as $cookieKey => $cookieVal ) {
444
-				$cookie_headers .= $cookieKey."=".urlencode($cookieVal)."; ";
445
-				}
446
-				$headers .= substr($cookie_headers,0,-2) . "\r\n";
447
-			} 
448
-		}
449
-		if(!empty($this->rawheaders))
450
-		{
451
-			if(!is_array($this->rawheaders))
452
-				$this->rawheaders = (array)$this->rawheaders;
453
-			while(list($headerKey,$headerVal) = each($this->rawheaders))
454
-				$headers .= $headerKey.": ".$headerVal."\r\n";
455
-		}
456
-		if(!empty($content_type)) {
457
-			$headers .= "Content-type: $content_type";
458
-			if ($content_type == "multipart/form-data")
459
-				$headers .= "; boundary=".$this->_mime_boundary;
460
-			$headers .= "\r\n";
461
-		}
462
-		if(!empty($body))	
463
-			$headers .= "Content-length: ".strlen($body)."\r\n";
464
-		if(!empty($this->user) || !empty($this->pass))	
465
-			$headers .= "Authorization: BASIC ".base64_encode($this->user.":".$this->pass)."\r\n";
466
-
467
-		$headers .= "\r\n";
440
+            reset($this->cookies);
441
+            if ( count($this->cookies) > 0 ) {
442
+                $cookie_headers .= 'Cookie: ';
443
+                foreach ( $this->cookies as $cookieKey => $cookieVal ) {
444
+                $cookie_headers .= $cookieKey."=".urlencode($cookieVal)."; ";
445
+                }
446
+                $headers .= substr($cookie_headers,0,-2) . "\r\n";
447
+            } 
448
+        }
449
+        if(!empty($this->rawheaders))
450
+        {
451
+            if(!is_array($this->rawheaders))
452
+                $this->rawheaders = (array)$this->rawheaders;
453
+            while(list($headerKey,$headerVal) = each($this->rawheaders))
454
+                $headers .= $headerKey.": ".$headerVal."\r\n";
455
+        }
456
+        if(!empty($content_type)) {
457
+            $headers .= "Content-type: $content_type";
458
+            if ($content_type == "multipart/form-data")
459
+                $headers .= "; boundary=".$this->_mime_boundary;
460
+            $headers .= "\r\n";
461
+        }
462
+        if(!empty($body))	
463
+            $headers .= "Content-length: ".strlen($body)."\r\n";
464
+        if(!empty($this->user) || !empty($this->pass))	
465
+            $headers .= "Authorization: BASIC ".base64_encode($this->user.":".$this->pass)."\r\n";
466
+
467
+        $headers .= "\r\n";
468 468
 		
469
-		// set the read timeout if needed
470
-		if ($this->read_timeout > 0)
471
-			socket_set_timeout($fp, $this->read_timeout);
472
-		$this->timed_out = false;
469
+        // set the read timeout if needed
470
+        if ($this->read_timeout > 0)
471
+            socket_set_timeout($fp, $this->read_timeout);
472
+        $this->timed_out = false;
473 473
 		
474
-		fwrite($fp,$headers.$body,strlen($headers.$body));
474
+        fwrite($fp,$headers.$body,strlen($headers.$body));
475 475
 		
476
-		$this->_redirectaddr = false;
477
-		unset($this->headers);
476
+        $this->_redirectaddr = false;
477
+        unset($this->headers);
478 478
 		
479
-		// content was returned gzip encoded?
480
-		$is_gzipped = false;
479
+        // content was returned gzip encoded?
480
+        $is_gzipped = false;
481 481
 						
482
-		while($currentHeader = fgets($fp,$this->_maxlinelen))
483
-		{
484
-			if ($this->read_timeout > 0 && $this->_check_timeout($fp))
485
-			{
486
-				$this->status=-100;
487
-				return false;
488
-			}
482
+        while($currentHeader = fgets($fp,$this->_maxlinelen))
483
+        {
484
+            if ($this->read_timeout > 0 && $this->_check_timeout($fp))
485
+            {
486
+                $this->status=-100;
487
+                return false;
488
+            }
489 489
 				
490
-		//	if($currentHeader == "\r\n")
491
-			if(preg_match("/^\r?\n$/", $currentHeader) )
492
-			      break;
490
+        //	if($currentHeader == "\r\n")
491
+            if(preg_match("/^\r?\n$/", $currentHeader) )
492
+                    break;
493 493
 						
494
-			// if a header begins with Location: or URI:, set the redirect
495
-			if(preg_match("/^(Location:|URI:)/i",$currentHeader))
496
-			{
497
-				// get URL portion of the redirect
498
-				preg_match("/^(Location:|URI:)\s+(.*)/",chop($currentHeader),$matches);
499
-				// look for :// in the Location header to see if hostname is included
500
-				if(!preg_match("|\:\/\/|",$matches[2]))
501
-				{
502
-					// no host in the path, so prepend
503
-					$this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
504
-					// eliminate double slash
505
-					if(!preg_match("|^/|",$matches[2]))
506
-							$this->_redirectaddr .= "/".$matches[2];
507
-					else
508
-							$this->_redirectaddr .= $matches[2];
509
-				}
510
-				else
511
-					$this->_redirectaddr = $matches[2];
512
-			}
494
+            // if a header begins with Location: or URI:, set the redirect
495
+            if(preg_match("/^(Location:|URI:)/i",$currentHeader))
496
+            {
497
+                // get URL portion of the redirect
498
+                preg_match("/^(Location:|URI:)\s+(.*)/",chop($currentHeader),$matches);
499
+                // look for :// in the Location header to see if hostname is included
500
+                if(!preg_match("|\:\/\/|",$matches[2]))
501
+                {
502
+                    // no host in the path, so prepend
503
+                    $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
504
+                    // eliminate double slash
505
+                    if(!preg_match("|^/|",$matches[2]))
506
+                            $this->_redirectaddr .= "/".$matches[2];
507
+                    else
508
+                            $this->_redirectaddr .= $matches[2];
509
+                }
510
+                else
511
+                    $this->_redirectaddr = $matches[2];
512
+            }
513 513
 		
514
-			if(preg_match("|^HTTP/|",$currentHeader))
515
-			{
514
+            if(preg_match("|^HTTP/|",$currentHeader))
515
+            {
516 516
                 if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$currentHeader, $status))
517
-				{
518
-					$this->status= $status[1];
517
+                {
518
+                    $this->status= $status[1];
519 519
                 }				
520
-				$this->response_code = $currentHeader;
521
-			}
520
+                $this->response_code = $currentHeader;
521
+            }
522 522
 			
523
-			if (preg_match("/Content-Encoding: gzip/", $currentHeader) ) {
524
-				$is_gzipped = true;
525
-			}
523
+            if (preg_match("/Content-Encoding: gzip/", $currentHeader) ) {
524
+                $is_gzipped = true;
525
+            }
526 526
 			
527
-			$this->headers[] = $currentHeader;
528
-		}
529
-
530
-		# $results = fread($fp, $this->maxlength);
531
-		$results = "";
532
-		while ( $data = fread($fp, $this->maxlength) ) {
533
-		    $results .= $data;
534
-		    if (
535
-		        strlen($results) > $this->maxlength ) {
536
-		        break;
537
-		    }
538
-		}
527
+            $this->headers[] = $currentHeader;
528
+        }
529
+
530
+        # $results = fread($fp, $this->maxlength);
531
+        $results = "";
532
+        while ( $data = fread($fp, $this->maxlength) ) {
533
+            $results .= $data;
534
+            if (
535
+                strlen($results) > $this->maxlength ) {
536
+                break;
537
+            }
538
+        }
539 539
 		
540
-		// gunzip
541
-		if ( $is_gzipped ) {
542
-			// per http://www.php.net/manual/en/function.gzencode.php
543
-			$results = substr($results, 10);
544
-			$results = gzinflate($results);
545
-		}
540
+        // gunzip
541
+        if ( $is_gzipped ) {
542
+            // per http://www.php.net/manual/en/function.gzencode.php
543
+            $results = substr($results, 10);
544
+            $results = gzinflate($results);
545
+        }
546 546
 		
547
-		if ($this->read_timeout > 0 && $this->_check_timeout($fp))
548
-		{
549
-			$this->status=-100;
550
-			return false;
551
-		}
547
+        if ($this->read_timeout > 0 && $this->_check_timeout($fp))
548
+        {
549
+            $this->status=-100;
550
+            return false;
551
+        }
552 552
 		
553
-		// check if there is a a redirect meta tag
553
+        // check if there is a a redirect meta tag
554 554
 		
555
-		if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
556
-		{
557
-			$this->_redirectaddr = $this->_expandlinks($match[1],$URI);	
558
-		}
559
-
560
-		// have we hit our frame depth and is there frame src to fetch?
561
-		if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
562
-		{
563
-			$this->results[] = $results;
564
-			for($x=0; $x<count($match[1]); $x++)
565
-				$this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
566
-		}
567
-		// have we already fetched framed content?
568
-		elseif(is_array($this->results))
569
-			$this->results[] = $results;
570
-		// no framed content
571
-		else
572
-			$this->results = $results;
555
+        if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
556
+        {
557
+            $this->_redirectaddr = $this->_expandlinks($match[1],$URI);	
558
+        }
559
+
560
+        // have we hit our frame depth and is there frame src to fetch?
561
+        if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
562
+        {
563
+            $this->results[] = $results;
564
+            for($x=0; $x<count($match[1]); $x++)
565
+                $this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
566
+        }
567
+        // have we already fetched framed content?
568
+        elseif(is_array($this->results))
569
+            $this->results[] = $results;
570
+        // no framed content
571
+        else
572
+            $this->results = $results;
573 573
 		
574
-		return true;
575
-	}
574
+        return true;
575
+    }
576 576
 
577 577
 /*======================================================================*\
578 578
 	Function:	_httpsrequest
@@ -583,163 +583,163 @@  discard block
 block discarded – undo
583 583
 	Output:		
584 584
 \*======================================================================*/
585 585
 	
586
-	private function _httpsrequest($url,$URI,$http_method,$content_type="",$body="")
587
-	{
588
-		if($this->passcookies && $this->_redirectaddr)
589
-			$this->setcookies();
586
+    private function _httpsrequest($url,$URI,$http_method,$content_type="",$body="")
587
+    {
588
+        if($this->passcookies && $this->_redirectaddr)
589
+            $this->setcookies();
590 590
 
591
-		$headers = array();		
591
+        $headers = array();		
592 592
 					
593
-		$URI_PARTS = parse_url($URI);
594
-		if(empty($url))
595
-			$url = "/";
596
-		// GET ... header not needed for curl
597
-		//$headers[] = $http_method." ".$url." ".$this->_httpversion;		
598
-		if(!empty($this->agent))
599
-			$headers[] = "User-Agent: ".$this->agent;
600
-		if(!empty($this->host))
601
-			$headers[] = "Host: ".$this->host;
602
-		if(!empty($this->accept))
603
-			$headers[] = "Accept: ".$this->accept;
604
-		if(!empty($this->referer))
605
-			$headers[] = "Referer: ".$this->referer;
606
-		if(!empty($this->cookies))
607
-		{			
608
-			if(!is_array($this->cookies))
609
-				$this->cookies = (array)$this->cookies;
593
+        $URI_PARTS = parse_url($URI);
594
+        if(empty($url))
595
+            $url = "/";
596
+        // GET ... header not needed for curl
597
+        //$headers[] = $http_method." ".$url." ".$this->_httpversion;		
598
+        if(!empty($this->agent))
599
+            $headers[] = "User-Agent: ".$this->agent;
600
+        if(!empty($this->host))
601
+            $headers[] = "Host: ".$this->host;
602
+        if(!empty($this->accept))
603
+            $headers[] = "Accept: ".$this->accept;
604
+        if(!empty($this->referer))
605
+            $headers[] = "Referer: ".$this->referer;
606
+        if(!empty($this->cookies))
607
+        {			
608
+            if(!is_array($this->cookies))
609
+                $this->cookies = (array)$this->cookies;
610 610
 	
611
-			reset($this->cookies);
612
-			if ( count($this->cookies) > 0 ) {
613
-				$cookie_str = 'Cookie: ';
614
-				foreach ( $this->cookies as $cookieKey => $cookieVal ) {
615
-				$cookie_str .= $cookieKey."=".urlencode($cookieVal)."; ";
616
-				}
617
-				$headers[] = substr($cookie_str,0,-2);
618
-			}
619
-		}
620
-		if(!empty($this->rawheaders))
621
-		{
622
-			if(!is_array($this->rawheaders))
623
-				$this->rawheaders = (array)$this->rawheaders;
624
-			while(list($headerKey,$headerVal) = each($this->rawheaders))
625
-				$headers[] = $headerKey.": ".$headerVal;
626
-		}
627
-		if(!empty($content_type)) {
628
-			if ($content_type == "multipart/form-data")
629
-				$headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary;
630
-			else
631
-				$headers[] = "Content-type: $content_type";
632
-		}
633
-		if(!empty($body))	
634
-			$headers[] = "Content-length: ".strlen($body);
635
-		if(!empty($this->user) || !empty($this->pass))	
636
-			$headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass);
611
+            reset($this->cookies);
612
+            if ( count($this->cookies) > 0 ) {
613
+                $cookie_str = 'Cookie: ';
614
+                foreach ( $this->cookies as $cookieKey => $cookieVal ) {
615
+                $cookie_str .= $cookieKey."=".urlencode($cookieVal)."; ";
616
+                }
617
+                $headers[] = substr($cookie_str,0,-2);
618
+            }
619
+        }
620
+        if(!empty($this->rawheaders))
621
+        {
622
+            if(!is_array($this->rawheaders))
623
+                $this->rawheaders = (array)$this->rawheaders;
624
+            while(list($headerKey,$headerVal) = each($this->rawheaders))
625
+                $headers[] = $headerKey.": ".$headerVal;
626
+        }
627
+        if(!empty($content_type)) {
628
+            if ($content_type == "multipart/form-data")
629
+                $headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary;
630
+            else
631
+                $headers[] = "Content-type: $content_type";
632
+        }
633
+        if(!empty($body))	
634
+            $headers[] = "Content-length: ".strlen($body);
635
+        if(!empty($this->user) || !empty($this->pass))	
636
+            $headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass);
637 637
 			
638
-		for($curr_header = 0; $curr_header < count($headers); $curr_header++) {
639
-			$cmdline_params .= " -H \"".$headers[$curr_header]."\"";
640
-		}
638
+        for($curr_header = 0; $curr_header < count($headers); $curr_header++) {
639
+            $cmdline_params .= " -H \"".$headers[$curr_header]."\"";
640
+        }
641 641
 			  	                         
642
-		if(!empty($body))
643
-			$cmdline_params .= " -d \"$body\"";
642
+        if(!empty($body))
643
+            $cmdline_params .= " -d \"$body\"";
644 644
 		
645
-		if($this->read_timeout > 0)
646
-			$cmdline_params .= " -m ".$this->read_timeout;
645
+        if($this->read_timeout > 0)
646
+            $cmdline_params .= " -m ".$this->read_timeout;
647 647
 		
648
-		$headerfile = uniqid(time());
648
+        $headerfile = uniqid(time());
649 649
 		
650
-		# accept self-signed certs
651
-		$cmdline_params .= " -k";
650
+        # accept self-signed certs
651
+        $cmdline_params .= " -k";
652 652
         $results = array();
653 653
         $return = 0;
654
-		exec($this->curl_path." -D \"/tmp/$headerfile\"".escapeshellcmd($cmdline_params)." ".escapeshellcmd($URI),$results,$return);
654
+        exec($this->curl_path." -D \"/tmp/$headerfile\"".escapeshellcmd($cmdline_params)." ".escapeshellcmd($URI),$results,$return);
655 655
 		
656
-		if($return)
657
-		{
658
-			$this->error = "Error: cURL could not retrieve the document, error $return.";
659
-			return false;
660
-		}
656
+        if($return)
657
+        {
658
+            $this->error = "Error: cURL could not retrieve the document, error $return.";
659
+            return false;
660
+        }
661 661
 			
662 662
 			
663
-		$results = implode("\r\n",$results);
663
+        $results = implode("\r\n",$results);
664 664
 		
665
-		$result_headers = file("/tmp/$headerfile");
665
+        $result_headers = file("/tmp/$headerfile");
666 666
 						
667
-		$this->_redirectaddr = false;
668
-		unset($this->headers);
667
+        $this->_redirectaddr = false;
668
+        unset($this->headers);
669 669
 						
670
-		for($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++)
671
-		{
670
+        for($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++)
671
+        {
672 672
 			
673
-			// if a header begins with Location: or URI:, set the redirect
674
-			if(preg_match("/^(Location: |URI: )/i",$result_headers[$currentHeader]))
675
-			{
676
-				// get URL portion of the redirect
677
-				preg_match("/^(Location: |URI:)(.*)/",chop($result_headers[$currentHeader]),$matches);
678
-				// look for :// in the Location header to see if hostname is included
679
-				if(!preg_match("|\:\/\/|",$matches[2]))
680
-				{
681
-					// no host in the path, so prepend
682
-					$this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
683
-					// eliminate double slash
684
-					if(!preg_match("|^/|",$matches[2]))
685
-							$this->_redirectaddr .= "/".$matches[2];
686
-					else
687
-							$this->_redirectaddr .= $matches[2];
688
-				}
689
-				else
690
-					$this->_redirectaddr = $matches[2];
691
-			}
673
+            // if a header begins with Location: or URI:, set the redirect
674
+            if(preg_match("/^(Location: |URI: )/i",$result_headers[$currentHeader]))
675
+            {
676
+                // get URL portion of the redirect
677
+                preg_match("/^(Location: |URI:)(.*)/",chop($result_headers[$currentHeader]),$matches);
678
+                // look for :// in the Location header to see if hostname is included
679
+                if(!preg_match("|\:\/\/|",$matches[2]))
680
+                {
681
+                    // no host in the path, so prepend
682
+                    $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
683
+                    // eliminate double slash
684
+                    if(!preg_match("|^/|",$matches[2]))
685
+                            $this->_redirectaddr .= "/".$matches[2];
686
+                    else
687
+                            $this->_redirectaddr .= $matches[2];
688
+                }
689
+                else
690
+                    $this->_redirectaddr = $matches[2];
691
+            }
692 692
 		
693
-			if(preg_match("|^HTTP/|",$result_headers[$currentHeader]))
694
-			{
695
-			    $this->response_code = $result_headers[$currentHeader];
696
-			    if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$this->response_code, $match))
697
-			    {
698
-				$this->status= $match[1];
699
-                	    }
700
-			}
701
-			$this->headers[] = $result_headers[$currentHeader];
702
-		}
703
-
704
-		// check if there is a a redirect meta tag
693
+            if(preg_match("|^HTTP/|",$result_headers[$currentHeader]))
694
+            {
695
+                $this->response_code = $result_headers[$currentHeader];
696
+                if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$this->response_code, $match))
697
+                {
698
+                $this->status= $match[1];
699
+                        }
700
+            }
701
+            $this->headers[] = $result_headers[$currentHeader];
702
+        }
703
+
704
+        // check if there is a a redirect meta tag
705 705
 		
706
-		if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
707
-		{
708
-			$this->_redirectaddr = $this->_expandlinks($match[1],$URI);	
709
-		}
710
-
711
-		// have we hit our frame depth and is there frame src to fetch?
712
-		if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
713
-		{
714
-			$this->results[] = $results;
715
-			for($x=0; $x<count($match[1]); $x++)
716
-				$this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
717
-		}
718
-		// have we already fetched framed content?
719
-		elseif(is_array($this->results))
720
-			$this->results[] = $results;
721
-		// no framed content
722
-		else
723
-			$this->results = $results;
724
-
725
-		unlink("/tmp/$headerfile");
706
+        if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
707
+        {
708
+            $this->_redirectaddr = $this->_expandlinks($match[1],$URI);	
709
+        }
710
+
711
+        // have we hit our frame depth and is there frame src to fetch?
712
+        if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
713
+        {
714
+            $this->results[] = $results;
715
+            for($x=0; $x<count($match[1]); $x++)
716
+                $this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
717
+        }
718
+        // have we already fetched framed content?
719
+        elseif(is_array($this->results))
720
+            $this->results[] = $results;
721
+        // no framed content
722
+        else
723
+            $this->results = $results;
724
+
725
+        unlink("/tmp/$headerfile");
726 726
 		
727
-		return true;
728
-	}
727
+        return true;
728
+    }
729 729
 
730 730
 /*======================================================================*\
731 731
 	Function:	setcookies()
732 732
 	Purpose:	set cookies for a redirection
733 733
 \*======================================================================*/
734 734
 	
735
-	public function setcookies()
736
-	{
737
-		for($x=0; $x<count($this->headers); $x++)
738
-		{
739
-		if(preg_match("/^set-cookie:[\s]+([^=]+)=([^;]+)/i", $this->headers[$x],$match))
740
-			$this->cookies[$match[1]] = $match[2];
741
-		}
742
-	}
735
+    public function setcookies()
736
+    {
737
+        for($x=0; $x<count($this->headers); $x++)
738
+        {
739
+        if(preg_match("/^set-cookie:[\s]+([^=]+)=([^;]+)/i", $this->headers[$x],$match))
740
+            $this->cookies[$match[1]] = $match[2];
741
+        }
742
+    }
743 743
 
744 744
 	
745 745
 /*======================================================================*\
@@ -748,17 +748,17 @@  discard block
 block discarded – undo
748 748
 	Input:		$fp	file pointer
749 749
 \*======================================================================*/
750 750
 
751
-	private function _check_timeout($fp)
752
-	{
753
-		if ($this->read_timeout > 0) {
754
-			$fp_status = socket_get_status($fp);
755
-			if ($fp_status["timed_out"]) {
756
-				$this->timed_out = true;
757
-				return true;
758
-			}
759
-		}
760
-		return false;
761
-	}
751
+    private function _check_timeout($fp)
752
+    {
753
+        if ($this->read_timeout > 0) {
754
+            $fp_status = socket_get_status($fp);
755
+            if ($fp_status["timed_out"]) {
756
+                $this->timed_out = true;
757
+                return true;
758
+            }
759
+        }
760
+        return false;
761
+    }
762 762
 
763 763
 /*======================================================================*\
764 764
 	Function:	_connect
@@ -766,62 +766,62 @@  discard block
 block discarded – undo
766 766
 	Input:		$fp	file pointer
767 767
 \*======================================================================*/
768 768
 	
769
-	private function _connect(&$fp)
770
-	{
771
-		if(!empty($this->proxy_host) && !empty($this->proxy_port))
772
-			{
773
-				$this->_isproxy = true;
774
-				$host = $this->proxy_host;
775
-				$port = $this->proxy_port;
776
-			}
777
-		else
778
-		{
779
-			$host = $this->host;
780
-			$port = $this->port;
781
-		}
769
+    private function _connect(&$fp)
770
+    {
771
+        if(!empty($this->proxy_host) && !empty($this->proxy_port))
772
+            {
773
+                $this->_isproxy = true;
774
+                $host = $this->proxy_host;
775
+                $port = $this->proxy_port;
776
+            }
777
+        else
778
+        {
779
+            $host = $this->host;
780
+            $port = $this->port;
781
+        }
782 782
 	
783
-		$this->status = 0;
783
+        $this->status = 0;
784 784
 		
785
-		if($fp = fsockopen(
786
-					$host,
787
-					$port,
788
-					$errno,
789
-					$errstr,
790
-					$this->_fp_timeout
791
-					))
792
-		{
793
-			// socket connection succeeded
794
-
795
-			return true;
796
-		}
797
-		else
798
-		{
799
-			// socket connection failed
800
-			$this->status = $errno;
801
-			switch($errno)
802
-			{
803
-				case -3:
804
-					$this->error="socket creation failed (-3)";
805
-				case -4:
806
-					$this->error="dns lookup failure (-4)";
807
-				case -5:
808
-					$this->error="connection refused or timed out (-5)";
809
-				default:
810
-					$this->error="connection failed (".$errno.")";
811
-			}
812
-			return false;
813
-		}
814
-	}
785
+        if($fp = fsockopen(
786
+                    $host,
787
+                    $port,
788
+                    $errno,
789
+                    $errstr,
790
+                    $this->_fp_timeout
791
+                    ))
792
+        {
793
+            // socket connection succeeded
794
+
795
+            return true;
796
+        }
797
+        else
798
+        {
799
+            // socket connection failed
800
+            $this->status = $errno;
801
+            switch($errno)
802
+            {
803
+                case -3:
804
+                    $this->error="socket creation failed (-3)";
805
+                case -4:
806
+                    $this->error="dns lookup failure (-4)";
807
+                case -5:
808
+                    $this->error="connection refused or timed out (-5)";
809
+                default:
810
+                    $this->error="connection failed (".$errno.")";
811
+            }
812
+            return false;
813
+        }
814
+    }
815 815
 /*======================================================================*\
816 816
 	Function:	_disconnect
817 817
 	Purpose:	disconnect a socket connection
818 818
 	Input:		$fp	file pointer
819 819
 \*======================================================================*/
820 820
 	
821
-	private function _disconnect($fp)
822
-	{
823
-		return(fclose($fp));
824
-	}
821
+    private function _disconnect($fp)
822
+    {
823
+        return(fclose($fp));
824
+    }
825 825
 
826 826
 	
827 827
 /*======================================================================*\
@@ -832,65 +832,65 @@  discard block
 block discarded – undo
832 832
 	Output:		post body
833 833
 \*======================================================================*/
834 834
 	
835
-	private function _prepare_post_body($formvars, $formfiles)
836
-	{
837
-		settype($formvars, "array");
838
-		settype($formfiles, "array");
835
+    private function _prepare_post_body($formvars, $formfiles)
836
+    {
837
+        settype($formvars, "array");
838
+        settype($formfiles, "array");
839 839
 
840
-		if (count($formvars) == 0 && count($formfiles) == 0)
841
-			return;
840
+        if (count($formvars) == 0 && count($formfiles) == 0)
841
+            return;
842 842
 		
843
-		switch ($this->_submit_type) {
844
-			case "application/x-www-form-urlencoded":
845
-				reset($formvars);
846
-				while(list($key,$val) = each($formvars)) {
847
-					if (is_array($val) || is_object($val)) {
848
-						while (list($cur_key, $cur_val) = each($val)) {
849
-							$postdata .= urlencode($key)."[]=".urlencode($cur_val)."&";
850
-						}
851
-					} else
852
-						$postdata .= urlencode($key)."=".urlencode($val)."&";
853
-				}
854
-				break;
855
-
856
-			case "multipart/form-data":
857
-				$this->_mime_boundary = "Snoopy".md5(uniqid(microtime()));
843
+        switch ($this->_submit_type) {
844
+            case "application/x-www-form-urlencoded":
845
+                reset($formvars);
846
+                while(list($key,$val) = each($formvars)) {
847
+                    if (is_array($val) || is_object($val)) {
848
+                        while (list($cur_key, $cur_val) = each($val)) {
849
+                            $postdata .= urlencode($key)."[]=".urlencode($cur_val)."&";
850
+                        }
851
+                    } else
852
+                        $postdata .= urlencode($key)."=".urlencode($val)."&";
853
+                }
854
+                break;
855
+
856
+            case "multipart/form-data":
857
+                $this->_mime_boundary = "Snoopy".md5(uniqid(microtime()));
858 858
 				
859
-				reset($formvars);
860
-				while(list($key,$val) = each($formvars)) {
861
-					if (is_array($val) || is_object($val)) {
862
-						while (list($cur_key, $cur_val) = each($val)) {
863
-							$postdata .= "--".$this->_mime_boundary."\r\n";
864
-							$postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n";
865
-							$postdata .= "$cur_val\r\n";
866
-						}
867
-					} else {
868
-						$postdata .= "--".$this->_mime_boundary."\r\n";
869
-						$postdata .= "Content-Disposition: form-data; name=\"$key\"\r\n\r\n";
870
-						$postdata .= "$val\r\n";
871
-					}
872
-				}
859
+                reset($formvars);
860
+                while(list($key,$val) = each($formvars)) {
861
+                    if (is_array($val) || is_object($val)) {
862
+                        while (list($cur_key, $cur_val) = each($val)) {
863
+                            $postdata .= "--".$this->_mime_boundary."\r\n";
864
+                            $postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n";
865
+                            $postdata .= "$cur_val\r\n";
866
+                        }
867
+                    } else {
868
+                        $postdata .= "--".$this->_mime_boundary."\r\n";
869
+                        $postdata .= "Content-Disposition: form-data; name=\"$key\"\r\n\r\n";
870
+                        $postdata .= "$val\r\n";
871
+                    }
872
+                }
873 873
 				
874
-				reset($formfiles);
875
-				while (list($field_name, $file_names) = each($formfiles)) {
876
-					settype($file_names, "array");
877
-					while (list(, $file_name) = each($file_names)) {
878
-						if (!is_readable($file_name)) continue;
879
-
880
-						$fp = fopen($file_name, "r");
881
-						$file_content = fread($fp, filesize($file_name));
882
-						fclose($fp);
883
-						$base_name = basename($file_name);
884
-
885
-						$postdata .= "--".$this->_mime_boundary."\r\n";
886
-						$postdata .= "Content-Disposition: form-data; name=\"$field_name\"; filename=\"$base_name\"\r\n\r\n";
887
-						$postdata .= "$file_content\r\n";
888
-					}
889
-				}
890
-				$postdata .= "--".$this->_mime_boundary."--\r\n";
891
-				break;
892
-		}
893
-
894
-		return $postdata;
895
-	}
874
+                reset($formfiles);
875
+                while (list($field_name, $file_names) = each($formfiles)) {
876
+                    settype($file_names, "array");
877
+                    while (list(, $file_name) = each($file_names)) {
878
+                        if (!is_readable($file_name)) continue;
879
+
880
+                        $fp = fopen($file_name, "r");
881
+                        $file_content = fread($fp, filesize($file_name));
882
+                        fclose($fp);
883
+                        $base_name = basename($file_name);
884
+
885
+                        $postdata .= "--".$this->_mime_boundary."\r\n";
886
+                        $postdata .= "Content-Disposition: form-data; name=\"$field_name\"; filename=\"$base_name\"\r\n\r\n";
887
+                        $postdata .= "$file_content\r\n";
888
+                    }
889
+                }
890
+                $postdata .= "--".$this->_mime_boundary."--\r\n";
891
+                break;
892
+        }
893
+
894
+        return $postdata;
895
+    }
896 896
 }
897 897
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -40,47 +40,47 @@  discard block
 block discarded – undo
40 40
 	
41 41
 	/* user definable vars */
42 42
 
43
-	public $host			=	"www.php.net";		// host name we are connecting to
44
-	public $port			=	80;					// port we are connecting to
45
-	public $proxy_host		=	"";					// proxy host to use
46
-	public $proxy_port		=	"";					// proxy port to use
47
-	public $agent			=	"Snoopy v1.0";		// agent we masquerade as
48
-	public $referer		=	"";					// referer info to pass
49
-	public $cookies		=	array();			// array of cookies to pass
43
+	public $host			= "www.php.net"; // host name we are connecting to
44
+	public $port			= 80; // port we are connecting to
45
+	public $proxy_host		= ""; // proxy host to use
46
+	public $proxy_port		= ""; // proxy port to use
47
+	public $agent = "Snoopy v1.0"; // agent we masquerade as
48
+	public $referer		= ""; // referer info to pass
49
+	public $cookies		= array(); // array of cookies to pass
50 50
 												// $cookies["username"]="joe";
51
-	public	$rawheaders		=	array();			// array of raw headers to send
51
+	public	$rawheaders = array(); // array of raw headers to send
52 52
 												// $rawheaders["Content-type"]="text/html";
53 53
 
54
-	public $maxredirs		=	5;					// http redirection depth maximum. 0 = disallow
55
-	public $lastredirectaddr	=	"";				// contains address of last redirected address
56
-	public	$offsiteok		=	true;				// allows redirection off-site
57
-	public $maxframes		=	0;					// frame content depth maximum. 0 = disallow
58
-	public $expandlinks	=	true;				// expand links to fully qualified URLs.
54
+	public $maxredirs		= 5; // http redirection depth maximum. 0 = disallow
55
+	public $lastredirectaddr = ""; // contains address of last redirected address
56
+	public	$offsiteok		= true; // allows redirection off-site
57
+	public $maxframes		= 0; // frame content depth maximum. 0 = disallow
58
+	public $expandlinks	= true; // expand links to fully qualified URLs.
59 59
 												// this only applies to fetchlinks()
60 60
 												// or submitlinks()
61
-	public $passcookies	=	true;				// pass set cookies back through redirects
61
+	public $passcookies	= true; // pass set cookies back through redirects
62 62
 												// NOTE: this currently does not respect
63 63
 												// dates, domains or paths.
64 64
 	
65
-	public	$user			=	"";					// user for http authentication
66
-	public	$pass			=	"";					// password for http authentication
65
+	public	$user			= ""; // user for http authentication
66
+	public	$pass			= ""; // password for http authentication
67 67
 	
68 68
 	// http accept types
69
-	public $accept			=	"image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
69
+	public $accept			= "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
70 70
 	
71
-	public $results		=	"";					// where the content is put
71
+	public $results		= ""; // where the content is put
72 72
 		
73
-	public $error			=	"";					// error messages sent here
74
-	public	$response_code	=	"";					// response code returned from server
75
-	public	$headers		=	array();			// headers returned from server sent here
76
-	public	$maxlength		=	500000;				// max return data length (body)
77
-	public $read_timeout	=	0;					// timeout on read operations, in seconds
73
+	public $error = ""; // error messages sent here
74
+	public	$response_code = ""; // response code returned from server
75
+	public	$headers = array(); // headers returned from server sent here
76
+	public	$maxlength = 500000; // max return data length (body)
77
+	public $read_timeout = 0; // timeout on read operations, in seconds
78 78
 												// supported only since PHP 4 Beta 4
79 79
 												// set to 0 to disallow timeouts
80
-	public $timed_out		=	false;				// if a read operation timed out
81
-	public	$status			=	0;					// http request status
80
+	public $timed_out		= false; // if a read operation timed out
81
+	public	$status = 0; // http request status
82 82
 	
83
-	public	$curl_path		=	"/usr/bin/curl";
83
+	public	$curl_path		= "/usr/bin/curl";
84 84
 												// Snoopy will use cURL for fetching
85 85
 												// SSL content if a full system path to
86 86
 												// the cURL binary is supplied here.
@@ -93,24 +93,24 @@  discard block
 block discarded – undo
93 93
 												// as of this Snoopy release.
94 94
 	
95 95
 	// send Accept-encoding: gzip?
96
-	public $use_gzip		= true;	
96
+	public $use_gzip = true;	
97 97
 	
98 98
 	/**** Private variables ****/	
99 99
 	
100
-	private	$_maxlinelen	=	4096;				// max line length (headers)
100
+	private	$_maxlinelen	= 4096; // max line length (headers)
101 101
 	
102
-	private $_httpmethod	=	"GET";				// default http request method
103
-	private $_httpversion	=	"HTTP/1.0";			// default http request version
104
-	private $_submit_method	=	"POST";				// default submit method
105
-	private $_submit_type	=	"application/x-www-form-urlencoded";	// default submit type
106
-	private $_mime_boundary	=   "";					// MIME boundary for multipart/form-data submit type
107
-	private $_redirectaddr	=	false;				// will be set if page fetched is a redirect
108
-	private $_redirectdepth	=	0;					// increments on an http redirect
109
-	private $_frameurls		= 	array();			// frame src urls
110
-	private $_framedepth	=	0;					// increments on frame depth
102
+	private $_httpmethod	= "GET"; // default http request method
103
+	private $_httpversion	= "HTTP/1.0"; // default http request version
104
+	private $_submit_method	= "POST"; // default submit method
105
+	private $_submit_type	= "application/x-www-form-urlencoded"; // default submit type
106
+	private $_mime_boundary	= ""; // MIME boundary for multipart/form-data submit type
107
+	private $_redirectaddr = false; // will be set if page fetched is a redirect
108
+	private $_redirectdepth	= 0; // increments on an http redirect
109
+	private $_frameurls		= array(); // frame src urls
110
+	private $_framedepth	= 0; // increments on frame depth
111 111
 	
112
-	private $_isproxy		=	false;				// set if using a proxy server
113
-	private $_fp_timeout	=	30;					// timeout for socket connection
112
+	private $_isproxy = false; // set if using a proxy server
113
+	private $_fp_timeout	= 30; // timeout for socket connection
114 114
 
115 115
 /*======================================================================*\
116 116
 	Function:	fetch
@@ -132,14 +132,14 @@  discard block
 block discarded – undo
132 132
 		switch ($URI_PARTS["scheme"]) {
133 133
 			case "http":
134 134
 				$this->host = $URI_PARTS["host"];
135
-				if(!empty($URI_PARTS["port"]))
135
+				if (!empty($URI_PARTS["port"]))
136 136
 					$this->port = $URI_PARTS["port"];
137
-				if($this->_connect($fp))
137
+				if ($this->_connect($fp))
138 138
 				{
139
-					if($this->_isproxy)
139
+					if ($this->_isproxy)
140 140
 					{
141 141
 						// using proxy, send entire URI
142
-						$this->_httprequest($URI,$fp,$URI,$this->_httpmethod);
142
+						$this->_httprequest($URI, $fp, $URI, $this->_httpmethod);
143 143
 					}
144 144
 					else
145 145
 					{
@@ -150,30 +150,30 @@  discard block
 block discarded – undo
150 150
 					
151 151
 					$this->_disconnect($fp);
152 152
 
153
-					if($this->_redirectaddr)
153
+					if ($this->_redirectaddr)
154 154
 					{
155 155
 						/* url was redirected, check if we've hit the max depth */
156
-						if($this->maxredirs > $this->_redirectdepth)
156
+						if ($this->maxredirs > $this->_redirectdepth)
157 157
 						{
158 158
 							// only follow redirect if it's on this site, or offsiteok is true
159
-							if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
159
+							if (preg_match("|^http://".preg_quote($this->host)."|i", $this->_redirectaddr) || $this->offsiteok)
160 160
 							{
161 161
 								/* follow the redirect */
162 162
 								$this->_redirectdepth++;
163
-								$this->lastredirectaddr=$this->_redirectaddr;
163
+								$this->lastredirectaddr = $this->_redirectaddr;
164 164
 								$this->fetch($this->_redirectaddr);
165 165
 							}
166 166
 						}
167 167
 					}
168 168
 
169
-					if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
169
+					if ($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
170 170
 					{
171 171
 						$frameurls = $this->_frameurls;
172 172
 						$this->_frameurls = array();
173 173
 						
174
-						while(list(,$frameurl) = each($frameurls))
174
+						while (list(,$frameurl) = each($frameurls))
175 175
 						{
176
-							if($this->_framedepth < $this->maxframes)
176
+							if ($this->_framedepth < $this->maxframes)
177 177
 							{
178 178
 								$this->fetch($frameurl);
179 179
 								$this->_framedepth++;
@@ -190,17 +190,17 @@  discard block
 block discarded – undo
190 190
 				return true;					
191 191
 				break;
192 192
 			case "https":
193
-				if(!$this->curl_path || (!is_executable($this->curl_path))) {
193
+				if (!$this->curl_path || (!is_executable($this->curl_path))) {
194 194
 					$this->error = "Bad curl ($this->curl_path), can't fetch HTTPS \n";
195 195
 					return false;
196 196
 				}
197 197
 				$this->host = $URI_PARTS["host"];
198
-				if(!empty($URI_PARTS["port"]))
198
+				if (!empty($URI_PARTS["port"]))
199 199
 					$this->port = $URI_PARTS["port"];
200
-				if($this->_isproxy)
200
+				if ($this->_isproxy)
201 201
 				{
202 202
 					// using proxy, send entire URI
203
-					$this->_httpsrequest($URI,$URI,$this->_httpmethod);
203
+					$this->_httpsrequest($URI, $URI, $this->_httpmethod);
204 204
 				}
205 205
 				else
206 206
 				{
@@ -209,30 +209,30 @@  discard block
 block discarded – undo
209 209
 					$this->_httpsrequest($path, $URI, $this->_httpmethod);
210 210
 				}
211 211
 
212
-				if($this->_redirectaddr)
212
+				if ($this->_redirectaddr)
213 213
 				{
214 214
 					/* url was redirected, check if we've hit the max depth */
215
-					if($this->maxredirs > $this->_redirectdepth)
215
+					if ($this->maxredirs > $this->_redirectdepth)
216 216
 					{
217 217
 						// only follow redirect if it's on this site, or offsiteok is true
218
-						if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
218
+						if (preg_match("|^http://".preg_quote($this->host)."|i", $this->_redirectaddr) || $this->offsiteok)
219 219
 						{
220 220
 							/* follow the redirect */
221 221
 							$this->_redirectdepth++;
222
-							$this->lastredirectaddr=$this->_redirectaddr;
222
+							$this->lastredirectaddr = $this->_redirectaddr;
223 223
 							$this->fetch($this->_redirectaddr);
224 224
 						}
225 225
 					}
226 226
 				}
227 227
 
228
-				if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
228
+				if ($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
229 229
 				{
230 230
 					$frameurls = $this->_frameurls;
231 231
 					$this->_frameurls = array();
232 232
 
233
-					while(list(,$frameurl) = each($frameurls))
233
+					while (list(,$frameurl) = each($frameurls))
234 234
 					{
235
-						if($this->_framedepth < $this->maxframes)
235
+						if ($this->_framedepth < $this->maxframes)
236 236
 						{
237 237
 							$this->fetch($frameurl);
238 238
 							$this->_framedepth++;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 				break;
246 246
 			default:
247 247
 				// not a valid protocol
248
-				$this->error	=	'Invalid protocol "'.$URI_PARTS["scheme"].'"\n';
248
+				$this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n';
249 249
 				return false;
250 250
 				break;
251 251
 		}		
@@ -272,20 +272,20 @@  discard block
 block discarded – undo
272 272
 						([\"\'])?					# find single or double quote
273 273
 						(?(1) (.*?)\\1 | ([^\s\>]+))		# if quote found, match up to next matching
274 274
 													# quote, otherwise match up to next space
275
-						'isx",$document,$links);
275
+						'isx",$document, $links);
276 276
 						
277 277
 
278 278
 		// catenate the non-empty matches from the conditional subpattern
279 279
 
280
-		while(list($key,$val) = each($links[2]))
280
+		while (list($key, $val) = each($links[2]))
281 281
 		{
282
-			if(!empty($val))
282
+			if (!empty($val))
283 283
 				$match[] = $val;
284 284
 		}				
285 285
 		
286
-		while(list($key,$val) = each($links[3]))
286
+		while (list($key, $val) = each($links[3]))
287 287
 		{
288
-			if(!empty($val))
288
+			if (!empty($val))
289 289
 				$match[] = $val;
290 290
 		}		
291 291
 		
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
 
303 303
 	private function _stripform($document)
304 304
 	{	
305
-		preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi",$document,$elements);
305
+		preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi", $document, $elements);
306 306
 		
307 307
 		// catenate the matches
308
-		$match = implode("\r\n",$elements[0]);
308
+		$match = implode("\r\n", $elements[0]);
309 309
 				
310 310
 		// return the links
311 311
 		return $match;
@@ -327,10 +327,10 @@  discard block
 block discarded – undo
327 327
 		// so, list your entities one by one here. I included some of the
328 328
 		// more common ones.
329 329
 								
330
-		$search = array("'<script[^>]*?>.*?</script>'si",	// strip out javascript
331
-						"'<[\/\!]*?[^<>]*?>'si",			// strip out html tags
332
-						"'([\r\n])[\s]+'",					// strip out white space
333
-						"'&(quote|#34);'i",					// replace html entities
330
+		$search = array("'<script[^>]*?>.*?</script>'si", // strip out javascript
331
+						"'<[\/\!]*?[^<>]*?>'si", // strip out html tags
332
+						"'([\r\n])[\s]+'", // strip out white space
333
+						"'&(quote|#34);'i", // replace html entities
334 334
 						"'&(amp|#38);'i",
335 335
 						"'&(lt|#60);'i",
336 336
 						"'&(gt|#62);'i",
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 						"'&(pound|#163);'i",
341 341
 						"'&(copy|#169);'i"
342 342
 						);				
343
-		$replace = array(	"",
343
+		$replace = array("",
344 344
 							"",
345 345
 							"\\1",
346 346
 							"\"",
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 							chr(163),
354 354
 							chr(169));
355 355
 					
356
-		$text = preg_replace($search,$replace,$document);
356
+		$text = preg_replace($search, $replace, $document);
357 357
 								
358 358
 		return $text;
359 359
 	}
@@ -366,26 +366,26 @@  discard block
 block discarded – undo
366 366
 	Output:		$expandedLinks	the expanded links
367 367
 \*======================================================================*/
368 368
 
369
-	private function _expandlinks($links,$URI)
369
+	private function _expandlinks($links, $URI)
370 370
 	{
371 371
 		
372
-		preg_match("/^[^\?]+/",$URI,$match);
372
+		preg_match("/^[^\?]+/", $URI, $match);
373 373
 
374
-		$match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|","",$match[0]);
374
+		$match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|", "", $match[0]);
375 375
 				
376
-		$search = array( 	"|^http://".preg_quote($this->host)."|i",
376
+		$search = array("|^http://".preg_quote($this->host)."|i",
377 377
 							"|^(?!http://)(\/)?(?!mailto:)|i",
378 378
 							"|/\./|",
379 379
 							"|/[^\/]+/\.\./|"
380 380
 						);
381 381
 						
382
-		$replace = array(	"",
382
+		$replace = array("",
383 383
 							$match."/",
384 384
 							"/",
385 385
 							"/"
386 386
 						);			
387 387
 				
388
-		$expandedLinks = preg_replace($search,$replace,$links);
388
+		$expandedLinks = preg_replace($search, $replace, $links);
389 389
 
390 390
 		return $expandedLinks;
391 391
 	}
@@ -400,26 +400,26 @@  discard block
 block discarded – undo
400 400
 	Output:		
401 401
 \*======================================================================*/
402 402
 	
403
-	private function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="")
403
+	private function _httprequest($url, $fp, $URI, $http_method, $content_type = "", $body = "")
404 404
 	{
405
-		if($this->passcookies && $this->_redirectaddr)
405
+		if ($this->passcookies && $this->_redirectaddr)
406 406
 			$this->setcookies();
407 407
 			
408 408
 		$URI_PARTS = parse_url($URI);
409
-		if(empty($url))
409
+		if (empty($url))
410 410
 			$url = "/";
411 411
 		$headers = $http_method." ".$url." ".$this->_httpversion."\r\n";		
412
-		if(!empty($this->agent))
412
+		if (!empty($this->agent))
413 413
 			$headers .= "User-Agent: ".$this->agent."\r\n";
414
-		if(!empty($this->host) && !isset($this->rawheaders['Host']))
414
+		if (!empty($this->host) && !isset($this->rawheaders['Host']))
415 415
 			$headers .= "Host: ".$this->host."\r\n";
416
-		if(!empty($this->accept))
416
+		if (!empty($this->accept))
417 417
 			$headers .= "Accept: ".$this->accept."\r\n";
418 418
 		
419
-		if($this->use_gzip) {
419
+		if ($this->use_gzip) {
420 420
 			// make sure PHP was built with --with-zlib
421 421
 			// and we can handle gzipp'ed data
422
-			if ( function_exists(gzinflate) ) {
422
+			if (function_exists(gzinflate)) {
423 423
 			   $headers .= "Accept-encoding: gzip\r\n";
424 424
 			}
425 425
 			else {
@@ -430,38 +430,38 @@  discard block
 block discarded – undo
430 430
 			}
431 431
 		}
432 432
 		
433
-		if(!empty($this->referer))
433
+		if (!empty($this->referer))
434 434
 			$headers .= "Referer: ".$this->referer."\r\n";
435
-		if(!empty($this->cookies))
435
+		if (!empty($this->cookies))
436 436
 		{			
437
-			if(!is_array($this->cookies))
438
-				$this->cookies = (array)$this->cookies;
437
+			if (!is_array($this->cookies))
438
+				$this->cookies = (array) $this->cookies;
439 439
 	
440 440
 			reset($this->cookies);
441
-			if ( count($this->cookies) > 0 ) {
441
+			if (count($this->cookies) > 0) {
442 442
 				$cookie_headers .= 'Cookie: ';
443
-				foreach ( $this->cookies as $cookieKey => $cookieVal ) {
443
+				foreach ($this->cookies as $cookieKey => $cookieVal) {
444 444
 				$cookie_headers .= $cookieKey."=".urlencode($cookieVal)."; ";
445 445
 				}
446
-				$headers .= substr($cookie_headers,0,-2) . "\r\n";
446
+				$headers .= substr($cookie_headers, 0, -2)."\r\n";
447 447
 			} 
448 448
 		}
449
-		if(!empty($this->rawheaders))
449
+		if (!empty($this->rawheaders))
450 450
 		{
451
-			if(!is_array($this->rawheaders))
452
-				$this->rawheaders = (array)$this->rawheaders;
453
-			while(list($headerKey,$headerVal) = each($this->rawheaders))
451
+			if (!is_array($this->rawheaders))
452
+				$this->rawheaders = (array) $this->rawheaders;
453
+			while (list($headerKey, $headerVal) = each($this->rawheaders))
454 454
 				$headers .= $headerKey.": ".$headerVal."\r\n";
455 455
 		}
456
-		if(!empty($content_type)) {
456
+		if (!empty($content_type)) {
457 457
 			$headers .= "Content-type: $content_type";
458 458
 			if ($content_type == "multipart/form-data")
459 459
 				$headers .= "; boundary=".$this->_mime_boundary;
460 460
 			$headers .= "\r\n";
461 461
 		}
462
-		if(!empty($body))	
462
+		if (!empty($body))	
463 463
 			$headers .= "Content-length: ".strlen($body)."\r\n";
464
-		if(!empty($this->user) || !empty($this->pass))	
464
+		if (!empty($this->user) || !empty($this->pass))	
465 465
 			$headers .= "Authorization: BASIC ".base64_encode($this->user.":".$this->pass)."\r\n";
466 466
 
467 467
 		$headers .= "\r\n";
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 			socket_set_timeout($fp, $this->read_timeout);
472 472
 		$this->timed_out = false;
473 473
 		
474
-		fwrite($fp,$headers.$body,strlen($headers.$body));
474
+		fwrite($fp, $headers.$body, strlen($headers.$body));
475 475
 		
476 476
 		$this->_redirectaddr = false;
477 477
 		unset($this->headers);
@@ -479,30 +479,30 @@  discard block
 block discarded – undo
479 479
 		// content was returned gzip encoded?
480 480
 		$is_gzipped = false;
481 481
 						
482
-		while($currentHeader = fgets($fp,$this->_maxlinelen))
482
+		while ($currentHeader = fgets($fp, $this->_maxlinelen))
483 483
 		{
484 484
 			if ($this->read_timeout > 0 && $this->_check_timeout($fp))
485 485
 			{
486
-				$this->status=-100;
486
+				$this->status = -100;
487 487
 				return false;
488 488
 			}
489 489
 				
490 490
 		//	if($currentHeader == "\r\n")
491
-			if(preg_match("/^\r?\n$/", $currentHeader) )
491
+			if (preg_match("/^\r?\n$/", $currentHeader))
492 492
 			      break;
493 493
 						
494 494
 			// if a header begins with Location: or URI:, set the redirect
495
-			if(preg_match("/^(Location:|URI:)/i",$currentHeader))
495
+			if (preg_match("/^(Location:|URI:)/i", $currentHeader))
496 496
 			{
497 497
 				// get URL portion of the redirect
498
-				preg_match("/^(Location:|URI:)\s+(.*)/",chop($currentHeader),$matches);
498
+				preg_match("/^(Location:|URI:)\s+(.*)/", chop($currentHeader), $matches);
499 499
 				// look for :// in the Location header to see if hostname is included
500
-				if(!preg_match("|\:\/\/|",$matches[2]))
500
+				if (!preg_match("|\:\/\/|", $matches[2]))
501 501
 				{
502 502
 					// no host in the path, so prepend
503 503
 					$this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
504 504
 					// eliminate double slash
505
-					if(!preg_match("|^/|",$matches[2]))
505
+					if (!preg_match("|^/|", $matches[2]))
506 506
 							$this->_redirectaddr .= "/".$matches[2];
507 507
 					else
508 508
 							$this->_redirectaddr .= $matches[2];
@@ -511,16 +511,16 @@  discard block
 block discarded – undo
511 511
 					$this->_redirectaddr = $matches[2];
512 512
 			}
513 513
 		
514
-			if(preg_match("|^HTTP/|",$currentHeader))
514
+			if (preg_match("|^HTTP/|", $currentHeader))
515 515
 			{
516
-                if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$currentHeader, $status))
516
+                if (preg_match("|^HTTP/[^\s]*\s(.*?)\s|", $currentHeader, $status))
517 517
 				{
518
-					$this->status= $status[1];
518
+					$this->status = $status[1];
519 519
                 }				
520 520
 				$this->response_code = $currentHeader;
521 521
 			}
522 522
 			
523
-			if (preg_match("/Content-Encoding: gzip/", $currentHeader) ) {
523
+			if (preg_match("/Content-Encoding: gzip/", $currentHeader)) {
524 524
 				$is_gzipped = true;
525 525
 			}
526 526
 			
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 
530 530
 		# $results = fread($fp, $this->maxlength);
531 531
 		$results = "";
532
-		while ( $data = fread($fp, $this->maxlength) ) {
532
+		while ($data = fread($fp, $this->maxlength)) {
533 533
 		    $results .= $data;
534 534
 		    if (
535 535
 		        strlen($results) > $this->maxlength ) {
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 		}
539 539
 		
540 540
 		// gunzip
541
-		if ( $is_gzipped ) {
541
+		if ($is_gzipped) {
542 542
 			// per http://www.php.net/manual/en/function.gzencode.php
543 543
 			$results = substr($results, 10);
544 544
 			$results = gzinflate($results);
@@ -546,26 +546,26 @@  discard block
 block discarded – undo
546 546
 		
547 547
 		if ($this->read_timeout > 0 && $this->_check_timeout($fp))
548 548
 		{
549
-			$this->status=-100;
549
+			$this->status = -100;
550 550
 			return false;
551 551
 		}
552 552
 		
553 553
 		// check if there is a a redirect meta tag
554 554
 		
555
-		if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
555
+		if (preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i", $results, $match))
556 556
 		{
557
-			$this->_redirectaddr = $this->_expandlinks($match[1],$URI);	
557
+			$this->_redirectaddr = $this->_expandlinks($match[1], $URI);	
558 558
 		}
559 559
 
560 560
 		// have we hit our frame depth and is there frame src to fetch?
561
-		if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
561
+		if (($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i", $results, $match))
562 562
 		{
563 563
 			$this->results[] = $results;
564
-			for($x=0; $x<count($match[1]); $x++)
565
-				$this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
564
+			for ($x = 0; $x < count($match[1]); $x++)
565
+				$this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"]."://".$this->host);
566 566
 		}
567 567
 		// have we already fetched framed content?
568
-		elseif(is_array($this->results))
568
+		elseif (is_array($this->results))
569 569
 			$this->results[] = $results;
570 570
 		// no framed content
571 571
 		else
@@ -583,66 +583,66 @@  discard block
 block discarded – undo
583 583
 	Output:		
584 584
 \*======================================================================*/
585 585
 	
586
-	private function _httpsrequest($url,$URI,$http_method,$content_type="",$body="")
586
+	private function _httpsrequest($url, $URI, $http_method, $content_type = "", $body = "")
587 587
 	{
588
-		if($this->passcookies && $this->_redirectaddr)
588
+		if ($this->passcookies && $this->_redirectaddr)
589 589
 			$this->setcookies();
590 590
 
591 591
 		$headers = array();		
592 592
 					
593 593
 		$URI_PARTS = parse_url($URI);
594
-		if(empty($url))
594
+		if (empty($url))
595 595
 			$url = "/";
596 596
 		// GET ... header not needed for curl
597 597
 		//$headers[] = $http_method." ".$url." ".$this->_httpversion;		
598
-		if(!empty($this->agent))
598
+		if (!empty($this->agent))
599 599
 			$headers[] = "User-Agent: ".$this->agent;
600
-		if(!empty($this->host))
600
+		if (!empty($this->host))
601 601
 			$headers[] = "Host: ".$this->host;
602
-		if(!empty($this->accept))
602
+		if (!empty($this->accept))
603 603
 			$headers[] = "Accept: ".$this->accept;
604
-		if(!empty($this->referer))
604
+		if (!empty($this->referer))
605 605
 			$headers[] = "Referer: ".$this->referer;
606
-		if(!empty($this->cookies))
606
+		if (!empty($this->cookies))
607 607
 		{			
608
-			if(!is_array($this->cookies))
609
-				$this->cookies = (array)$this->cookies;
608
+			if (!is_array($this->cookies))
609
+				$this->cookies = (array) $this->cookies;
610 610
 	
611 611
 			reset($this->cookies);
612
-			if ( count($this->cookies) > 0 ) {
612
+			if (count($this->cookies) > 0) {
613 613
 				$cookie_str = 'Cookie: ';
614
-				foreach ( $this->cookies as $cookieKey => $cookieVal ) {
614
+				foreach ($this->cookies as $cookieKey => $cookieVal) {
615 615
 				$cookie_str .= $cookieKey."=".urlencode($cookieVal)."; ";
616 616
 				}
617
-				$headers[] = substr($cookie_str,0,-2);
617
+				$headers[] = substr($cookie_str, 0, -2);
618 618
 			}
619 619
 		}
620
-		if(!empty($this->rawheaders))
620
+		if (!empty($this->rawheaders))
621 621
 		{
622
-			if(!is_array($this->rawheaders))
623
-				$this->rawheaders = (array)$this->rawheaders;
624
-			while(list($headerKey,$headerVal) = each($this->rawheaders))
622
+			if (!is_array($this->rawheaders))
623
+				$this->rawheaders = (array) $this->rawheaders;
624
+			while (list($headerKey, $headerVal) = each($this->rawheaders))
625 625
 				$headers[] = $headerKey.": ".$headerVal;
626 626
 		}
627
-		if(!empty($content_type)) {
627
+		if (!empty($content_type)) {
628 628
 			if ($content_type == "multipart/form-data")
629 629
 				$headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary;
630 630
 			else
631 631
 				$headers[] = "Content-type: $content_type";
632 632
 		}
633
-		if(!empty($body))	
633
+		if (!empty($body))	
634 634
 			$headers[] = "Content-length: ".strlen($body);
635
-		if(!empty($this->user) || !empty($this->pass))	
635
+		if (!empty($this->user) || !empty($this->pass))	
636 636
 			$headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass);
637 637
 			
638
-		for($curr_header = 0; $curr_header < count($headers); $curr_header++) {
638
+		for ($curr_header = 0; $curr_header < count($headers); $curr_header++) {
639 639
 			$cmdline_params .= " -H \"".$headers[$curr_header]."\"";
640 640
 		}
641 641
 			  	                         
642
-		if(!empty($body))
642
+		if (!empty($body))
643 643
 			$cmdline_params .= " -d \"$body\"";
644 644
 		
645
-		if($this->read_timeout > 0)
645
+		if ($this->read_timeout > 0)
646 646
 			$cmdline_params .= " -m ".$this->read_timeout;
647 647
 		
648 648
 		$headerfile = uniqid(time());
@@ -651,37 +651,37 @@  discard block
 block discarded – undo
651 651
 		$cmdline_params .= " -k";
652 652
         $results = array();
653 653
         $return = 0;
654
-		exec($this->curl_path." -D \"/tmp/$headerfile\"".escapeshellcmd($cmdline_params)." ".escapeshellcmd($URI),$results,$return);
654
+		exec($this->curl_path." -D \"/tmp/$headerfile\"".escapeshellcmd($cmdline_params)." ".escapeshellcmd($URI), $results, $return);
655 655
 		
656
-		if($return)
656
+		if ($return)
657 657
 		{
658 658
 			$this->error = "Error: cURL could not retrieve the document, error $return.";
659 659
 			return false;
660 660
 		}
661 661
 			
662 662
 			
663
-		$results = implode("\r\n",$results);
663
+		$results = implode("\r\n", $results);
664 664
 		
665 665
 		$result_headers = file("/tmp/$headerfile");
666 666
 						
667 667
 		$this->_redirectaddr = false;
668 668
 		unset($this->headers);
669 669
 						
670
-		for($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++)
670
+		for ($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++)
671 671
 		{
672 672
 			
673 673
 			// if a header begins with Location: or URI:, set the redirect
674
-			if(preg_match("/^(Location: |URI: )/i",$result_headers[$currentHeader]))
674
+			if (preg_match("/^(Location: |URI: )/i", $result_headers[$currentHeader]))
675 675
 			{
676 676
 				// get URL portion of the redirect
677
-				preg_match("/^(Location: |URI:)(.*)/",chop($result_headers[$currentHeader]),$matches);
677
+				preg_match("/^(Location: |URI:)(.*)/", chop($result_headers[$currentHeader]), $matches);
678 678
 				// look for :// in the Location header to see if hostname is included
679
-				if(!preg_match("|\:\/\/|",$matches[2]))
679
+				if (!preg_match("|\:\/\/|", $matches[2]))
680 680
 				{
681 681
 					// no host in the path, so prepend
682 682
 					$this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
683 683
 					// eliminate double slash
684
-					if(!preg_match("|^/|",$matches[2]))
684
+					if (!preg_match("|^/|", $matches[2]))
685 685
 							$this->_redirectaddr .= "/".$matches[2];
686 686
 					else
687 687
 							$this->_redirectaddr .= $matches[2];
@@ -690,12 +690,12 @@  discard block
 block discarded – undo
690 690
 					$this->_redirectaddr = $matches[2];
691 691
 			}
692 692
 		
693
-			if(preg_match("|^HTTP/|",$result_headers[$currentHeader]))
693
+			if (preg_match("|^HTTP/|", $result_headers[$currentHeader]))
694 694
 			{
695 695
 			    $this->response_code = $result_headers[$currentHeader];
696
-			    if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$this->response_code, $match))
696
+			    if (preg_match("|^HTTP/[^\s]*\s(.*?)\s|", $this->response_code, $match))
697 697
 			    {
698
-				$this->status= $match[1];
698
+				$this->status = $match[1];
699 699
                 	    }
700 700
 			}
701 701
 			$this->headers[] = $result_headers[$currentHeader];
@@ -703,20 +703,20 @@  discard block
 block discarded – undo
703 703
 
704 704
 		// check if there is a a redirect meta tag
705 705
 		
706
-		if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
706
+		if (preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i", $results, $match))
707 707
 		{
708
-			$this->_redirectaddr = $this->_expandlinks($match[1],$URI);	
708
+			$this->_redirectaddr = $this->_expandlinks($match[1], $URI);	
709 709
 		}
710 710
 
711 711
 		// have we hit our frame depth and is there frame src to fetch?
712
-		if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
712
+		if (($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i", $results, $match))
713 713
 		{
714 714
 			$this->results[] = $results;
715
-			for($x=0; $x<count($match[1]); $x++)
716
-				$this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
715
+			for ($x = 0; $x < count($match[1]); $x++)
716
+				$this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"]."://".$this->host);
717 717
 		}
718 718
 		// have we already fetched framed content?
719
-		elseif(is_array($this->results))
719
+		elseif (is_array($this->results))
720 720
 			$this->results[] = $results;
721 721
 		// no framed content
722 722
 		else
@@ -734,9 +734,9 @@  discard block
 block discarded – undo
734 734
 	
735 735
 	public function setcookies()
736 736
 	{
737
-		for($x=0; $x<count($this->headers); $x++)
737
+		for ($x = 0; $x < count($this->headers); $x++)
738 738
 		{
739
-		if(preg_match("/^set-cookie:[\s]+([^=]+)=([^;]+)/i", $this->headers[$x],$match))
739
+		if (preg_match("/^set-cookie:[\s]+([^=]+)=([^;]+)/i", $this->headers[$x], $match))
740 740
 			$this->cookies[$match[1]] = $match[2];
741 741
 		}
742 742
 	}
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
 	
769 769
 	private function _connect(&$fp)
770 770
 	{
771
-		if(!empty($this->proxy_host) && !empty($this->proxy_port))
771
+		if (!empty($this->proxy_host) && !empty($this->proxy_port))
772 772
 			{
773 773
 				$this->_isproxy = true;
774 774
 				$host = $this->proxy_host;
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
 	
783 783
 		$this->status = 0;
784 784
 		
785
-		if($fp = fsockopen(
785
+		if ($fp = fsockopen(
786 786
 					$host,
787 787
 					$port,
788 788
 					$errno,
@@ -798,16 +798,16 @@  discard block
 block discarded – undo
798 798
 		{
799 799
 			// socket connection failed
800 800
 			$this->status = $errno;
801
-			switch($errno)
801
+			switch ($errno)
802 802
 			{
803 803
 				case -3:
804
-					$this->error="socket creation failed (-3)";
804
+					$this->error = "socket creation failed (-3)";
805 805
 				case -4:
806
-					$this->error="dns lookup failure (-4)";
806
+					$this->error = "dns lookup failure (-4)";
807 807
 				case -5:
808
-					$this->error="connection refused or timed out (-5)";
808
+					$this->error = "connection refused or timed out (-5)";
809 809
 				default:
810
-					$this->error="connection failed (".$errno.")";
810
+					$this->error = "connection failed (".$errno.")";
811 811
 			}
812 812
 			return false;
813 813
 		}
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
 		switch ($this->_submit_type) {
844 844
 			case "application/x-www-form-urlencoded":
845 845
 				reset($formvars);
846
-				while(list($key,$val) = each($formvars)) {
846
+				while (list($key, $val) = each($formvars)) {
847 847
 					if (is_array($val) || is_object($val)) {
848 848
 						while (list($cur_key, $cur_val) = each($val)) {
849 849
 							$postdata .= urlencode($key)."[]=".urlencode($cur_val)."&";
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
 				$this->_mime_boundary = "Snoopy".md5(uniqid(microtime()));
858 858
 				
859 859
 				reset($formvars);
860
-				while(list($key,$val) = each($formvars)) {
860
+				while (list($key, $val) = each($formvars)) {
861 861
 					if (is_array($val) || is_object($val)) {
862 862
 						while (list($cur_key, $cur_val) = each($val)) {
863 863
 							$postdata .= "--".$this->_mime_boundary."\r\n";
Please login to merge, or discard this patch.
Braces   +159 added lines, -118 removed lines patch added patch discarded remove patch
@@ -124,24 +124,26 @@  discard block
 block discarded – undo
124 124
 	public function fetch($URI) {
125 125
 		//preg_match("|^([^:]+)://([^:/]+)(:[\d]+)*(.*)|",$URI,$URI_PARTS);
126 126
 		$URI_PARTS = parse_url($URI);
127
-		if (!empty($URI_PARTS["user"]))
128
-			$this->user = $URI_PARTS["user"];
129
-		if (!empty($URI_PARTS["pass"]))
130
-			$this->pass = $URI_PARTS["pass"];
127
+		if (!empty($URI_PARTS["user"])) {
128
+					$this->user = $URI_PARTS["user"];
129
+		}
130
+		if (!empty($URI_PARTS["pass"])) {
131
+					$this->pass = $URI_PARTS["pass"];
132
+		}
131 133
 		if (!isset($fp)) { $fp = false; }
132 134
 		switch ($URI_PARTS["scheme"]) {
133 135
 			case "http":
134 136
 				$this->host = $URI_PARTS["host"];
135
-				if(!empty($URI_PARTS["port"]))
136
-					$this->port = $URI_PARTS["port"];
137
+				if(!empty($URI_PARTS["port"])) {
138
+									$this->port = $URI_PARTS["port"];
139
+				}
137 140
 				if($this->_connect($fp))
138 141
 				{
139 142
 					if($this->_isproxy)
140 143
 					{
141 144
 						// using proxy, send entire URI
142 145
 						$this->_httprequest($URI,$fp,$URI,$this->_httpmethod);
143
-					}
144
-					else
146
+					} else
145 147
 					{
146 148
 						$path = $URI_PARTS["path"].(isset($URI_PARTS["query"]) ? "?".$URI_PARTS["query"] : "");
147 149
 						// no proxy, send only the path
@@ -177,13 +179,12 @@  discard block
 block discarded – undo
177 179
 							{
178 180
 								$this->fetch($frameurl);
179 181
 								$this->_framedepth++;
182
+							} else {
183
+															break;
180 184
 							}
181
-							else
182
-								break;
183 185
 						}
184 186
 					}					
185
-				}
186
-				else
187
+				} else
187 188
 				{
188 189
 					return false;
189 190
 				}
@@ -195,14 +196,14 @@  discard block
 block discarded – undo
195 196
 					return false;
196 197
 				}
197 198
 				$this->host = $URI_PARTS["host"];
198
-				if(!empty($URI_PARTS["port"]))
199
-					$this->port = $URI_PARTS["port"];
199
+				if(!empty($URI_PARTS["port"])) {
200
+									$this->port = $URI_PARTS["port"];
201
+				}
200 202
 				if($this->_isproxy)
201 203
 				{
202 204
 					// using proxy, send entire URI
203 205
 					$this->_httpsrequest($URI,$URI,$this->_httpmethod);
204
-				}
205
-				else
206
+				} else
206 207
 				{
207 208
 					$path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : "");
208 209
 					// no proxy, send only the path
@@ -236,9 +237,9 @@  discard block
 block discarded – undo
236 237
 						{
237 238
 							$this->fetch($frameurl);
238 239
 							$this->_framedepth++;
240
+						} else {
241
+													break;
239 242
 						}
240
-						else
241
-							break;
242 243
 					}
243 244
 				}					
244 245
 				return true;					
@@ -279,14 +280,16 @@  discard block
 block discarded – undo
279 280
 
280 281
 		while(list($key,$val) = each($links[2]))
281 282
 		{
282
-			if(!empty($val))
283
-				$match[] = $val;
283
+			if(!empty($val)) {
284
+							$match[] = $val;
285
+			}
284 286
 		}				
285 287
 		
286 288
 		while(list($key,$val) = each($links[3]))
287 289
 		{
288
-			if(!empty($val))
289
-				$match[] = $val;
290
+			if(!empty($val)) {
291
+							$match[] = $val;
292
+			}
290 293
 		}		
291 294
 		
292 295
 		// return the links
@@ -402,27 +405,31 @@  discard block
 block discarded – undo
402 405
 	
403 406
 	private function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="")
404 407
 	{
405
-		if($this->passcookies && $this->_redirectaddr)
406
-			$this->setcookies();
408
+		if($this->passcookies && $this->_redirectaddr) {
409
+					$this->setcookies();
410
+		}
407 411
 			
408 412
 		$URI_PARTS = parse_url($URI);
409
-		if(empty($url))
410
-			$url = "/";
413
+		if(empty($url)) {
414
+					$url = "/";
415
+		}
411 416
 		$headers = $http_method." ".$url." ".$this->_httpversion."\r\n";		
412
-		if(!empty($this->agent))
413
-			$headers .= "User-Agent: ".$this->agent."\r\n";
414
-		if(!empty($this->host) && !isset($this->rawheaders['Host']))
415
-			$headers .= "Host: ".$this->host."\r\n";
416
-		if(!empty($this->accept))
417
-			$headers .= "Accept: ".$this->accept."\r\n";
417
+		if(!empty($this->agent)) {
418
+					$headers .= "User-Agent: ".$this->agent."\r\n";
419
+		}
420
+		if(!empty($this->host) && !isset($this->rawheaders['Host'])) {
421
+					$headers .= "Host: ".$this->host."\r\n";
422
+		}
423
+		if(!empty($this->accept)) {
424
+					$headers .= "Accept: ".$this->accept."\r\n";
425
+		}
418 426
 		
419 427
 		if($this->use_gzip) {
420 428
 			// make sure PHP was built with --with-zlib
421 429
 			// and we can handle gzipp'ed data
422 430
 			if ( function_exists(gzinflate) ) {
423 431
 			   $headers .= "Accept-encoding: gzip\r\n";
424
-			}
425
-			else {
432
+			} else {
426 433
 			   trigger_error(
427 434
 			   	"use_gzip is on, but PHP was built without zlib support.".
428 435
 				"  Requesting file(s) without gzip encoding.", 
@@ -430,12 +437,14 @@  discard block
 block discarded – undo
430 437
 			}
431 438
 		}
432 439
 		
433
-		if(!empty($this->referer))
434
-			$headers .= "Referer: ".$this->referer."\r\n";
440
+		if(!empty($this->referer)) {
441
+					$headers .= "Referer: ".$this->referer."\r\n";
442
+		}
435 443
 		if(!empty($this->cookies))
436 444
 		{			
437
-			if(!is_array($this->cookies))
438
-				$this->cookies = (array)$this->cookies;
445
+			if(!is_array($this->cookies)) {
446
+							$this->cookies = (array)$this->cookies;
447
+			}
439 448
 	
440 449
 			reset($this->cookies);
441 450
 			if ( count($this->cookies) > 0 ) {
@@ -448,27 +457,33 @@  discard block
 block discarded – undo
448 457
 		}
449 458
 		if(!empty($this->rawheaders))
450 459
 		{
451
-			if(!is_array($this->rawheaders))
452
-				$this->rawheaders = (array)$this->rawheaders;
453
-			while(list($headerKey,$headerVal) = each($this->rawheaders))
454
-				$headers .= $headerKey.": ".$headerVal."\r\n";
460
+			if(!is_array($this->rawheaders)) {
461
+							$this->rawheaders = (array)$this->rawheaders;
462
+			}
463
+			while(list($headerKey,$headerVal) = each($this->rawheaders)) {
464
+							$headers .= $headerKey.": ".$headerVal."\r\n";
465
+			}
455 466
 		}
456 467
 		if(!empty($content_type)) {
457 468
 			$headers .= "Content-type: $content_type";
458
-			if ($content_type == "multipart/form-data")
459
-				$headers .= "; boundary=".$this->_mime_boundary;
469
+			if ($content_type == "multipart/form-data") {
470
+							$headers .= "; boundary=".$this->_mime_boundary;
471
+			}
460 472
 			$headers .= "\r\n";
461 473
 		}
462
-		if(!empty($body))	
463
-			$headers .= "Content-length: ".strlen($body)."\r\n";
464
-		if(!empty($this->user) || !empty($this->pass))	
465
-			$headers .= "Authorization: BASIC ".base64_encode($this->user.":".$this->pass)."\r\n";
474
+		if(!empty($body)) {
475
+					$headers .= "Content-length: ".strlen($body)."\r\n";
476
+		}
477
+		if(!empty($this->user) || !empty($this->pass)) {
478
+					$headers .= "Authorization: BASIC ".base64_encode($this->user.":".$this->pass)."\r\n";
479
+		}
466 480
 
467 481
 		$headers .= "\r\n";
468 482
 		
469 483
 		// set the read timeout if needed
470
-		if ($this->read_timeout > 0)
471
-			socket_set_timeout($fp, $this->read_timeout);
484
+		if ($this->read_timeout > 0) {
485
+					socket_set_timeout($fp, $this->read_timeout);
486
+		}
472 487
 		$this->timed_out = false;
473 488
 		
474 489
 		fwrite($fp,$headers.$body,strlen($headers.$body));
@@ -488,8 +503,9 @@  discard block
 block discarded – undo
488 503
 			}
489 504
 				
490 505
 		//	if($currentHeader == "\r\n")
491
-			if(preg_match("/^\r?\n$/", $currentHeader) )
492
-			      break;
506
+			if(preg_match("/^\r?\n$/", $currentHeader) ) {
507
+						      break;
508
+			}
493 509
 						
494 510
 			// if a header begins with Location: or URI:, set the redirect
495 511
 			if(preg_match("/^(Location:|URI:)/i",$currentHeader))
@@ -502,13 +518,14 @@  discard block
 block discarded – undo
502 518
 					// no host in the path, so prepend
503 519
 					$this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
504 520
 					// eliminate double slash
505
-					if(!preg_match("|^/|",$matches[2]))
506
-							$this->_redirectaddr .= "/".$matches[2];
507
-					else
508
-							$this->_redirectaddr .= $matches[2];
521
+					if(!preg_match("|^/|",$matches[2])) {
522
+												$this->_redirectaddr .= "/".$matches[2];
523
+					} else {
524
+												$this->_redirectaddr .= $matches[2];
525
+					}
526
+				} else {
527
+									$this->_redirectaddr = $matches[2];
509 528
 				}
510
-				else
511
-					$this->_redirectaddr = $matches[2];
512 529
 			}
513 530
 		
514 531
 			if(preg_match("|^HTTP/|",$currentHeader))
@@ -561,15 +578,18 @@  discard block
 block discarded – undo
561 578
 		if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
562 579
 		{
563 580
 			$this->results[] = $results;
564
-			for($x=0; $x<count($match[1]); $x++)
565
-				$this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
581
+			for($x=0; $x<count($match[1]); $x++) {
582
+							$this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
583
+			}
566 584
 		}
567 585
 		// have we already fetched framed content?
568
-		elseif(is_array($this->results))
569
-			$this->results[] = $results;
586
+		elseif(is_array($this->results)) {
587
+					$this->results[] = $results;
588
+		}
570 589
 		// no framed content
571
-		else
572
-			$this->results = $results;
590
+		else {
591
+					$this->results = $results;
592
+		}
573 593
 		
574 594
 		return true;
575 595
 	}
@@ -585,28 +605,35 @@  discard block
 block discarded – undo
585 605
 	
586 606
 	private function _httpsrequest($url,$URI,$http_method,$content_type="",$body="")
587 607
 	{
588
-		if($this->passcookies && $this->_redirectaddr)
589
-			$this->setcookies();
608
+		if($this->passcookies && $this->_redirectaddr) {
609
+					$this->setcookies();
610
+		}
590 611
 
591 612
 		$headers = array();		
592 613
 					
593 614
 		$URI_PARTS = parse_url($URI);
594
-		if(empty($url))
595
-			$url = "/";
615
+		if(empty($url)) {
616
+					$url = "/";
617
+		}
596 618
 		// GET ... header not needed for curl
597 619
 		//$headers[] = $http_method." ".$url." ".$this->_httpversion;		
598
-		if(!empty($this->agent))
599
-			$headers[] = "User-Agent: ".$this->agent;
600
-		if(!empty($this->host))
601
-			$headers[] = "Host: ".$this->host;
602
-		if(!empty($this->accept))
603
-			$headers[] = "Accept: ".$this->accept;
604
-		if(!empty($this->referer))
605
-			$headers[] = "Referer: ".$this->referer;
620
+		if(!empty($this->agent)) {
621
+					$headers[] = "User-Agent: ".$this->agent;
622
+		}
623
+		if(!empty($this->host)) {
624
+					$headers[] = "Host: ".$this->host;
625
+		}
626
+		if(!empty($this->accept)) {
627
+					$headers[] = "Accept: ".$this->accept;
628
+		}
629
+		if(!empty($this->referer)) {
630
+					$headers[] = "Referer: ".$this->referer;
631
+		}
606 632
 		if(!empty($this->cookies))
607 633
 		{			
608
-			if(!is_array($this->cookies))
609
-				$this->cookies = (array)$this->cookies;
634
+			if(!is_array($this->cookies)) {
635
+							$this->cookies = (array)$this->cookies;
636
+			}
610 637
 	
611 638
 			reset($this->cookies);
612 639
 			if ( count($this->cookies) > 0 ) {
@@ -619,31 +646,38 @@  discard block
 block discarded – undo
619 646
 		}
620 647
 		if(!empty($this->rawheaders))
621 648
 		{
622
-			if(!is_array($this->rawheaders))
623
-				$this->rawheaders = (array)$this->rawheaders;
624
-			while(list($headerKey,$headerVal) = each($this->rawheaders))
625
-				$headers[] = $headerKey.": ".$headerVal;
649
+			if(!is_array($this->rawheaders)) {
650
+							$this->rawheaders = (array)$this->rawheaders;
651
+			}
652
+			while(list($headerKey,$headerVal) = each($this->rawheaders)) {
653
+							$headers[] = $headerKey.": ".$headerVal;
654
+			}
626 655
 		}
627 656
 		if(!empty($content_type)) {
628
-			if ($content_type == "multipart/form-data")
629
-				$headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary;
630
-			else
631
-				$headers[] = "Content-type: $content_type";
632
-		}
633
-		if(!empty($body))	
634
-			$headers[] = "Content-length: ".strlen($body);
635
-		if(!empty($this->user) || !empty($this->pass))	
636
-			$headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass);
657
+			if ($content_type == "multipart/form-data") {
658
+							$headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary;
659
+			} else {
660
+							$headers[] = "Content-type: $content_type";
661
+			}
662
+		}
663
+		if(!empty($body)) {
664
+					$headers[] = "Content-length: ".strlen($body);
665
+		}
666
+		if(!empty($this->user) || !empty($this->pass)) {
667
+					$headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass);
668
+		}
637 669
 			
638 670
 		for($curr_header = 0; $curr_header < count($headers); $curr_header++) {
639 671
 			$cmdline_params .= " -H \"".$headers[$curr_header]."\"";
640 672
 		}
641 673
 			  	                         
642
-		if(!empty($body))
643
-			$cmdline_params .= " -d \"$body\"";
674
+		if(!empty($body)) {
675
+					$cmdline_params .= " -d \"$body\"";
676
+		}
644 677
 		
645
-		if($this->read_timeout > 0)
646
-			$cmdline_params .= " -m ".$this->read_timeout;
678
+		if($this->read_timeout > 0) {
679
+					$cmdline_params .= " -m ".$this->read_timeout;
680
+		}
647 681
 		
648 682
 		$headerfile = uniqid(time());
649 683
 		
@@ -681,13 +715,14 @@  discard block
 block discarded – undo
681 715
 					// no host in the path, so prepend
682 716
 					$this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
683 717
 					// eliminate double slash
684
-					if(!preg_match("|^/|",$matches[2]))
685
-							$this->_redirectaddr .= "/".$matches[2];
686
-					else
687
-							$this->_redirectaddr .= $matches[2];
718
+					if(!preg_match("|^/|",$matches[2])) {
719
+												$this->_redirectaddr .= "/".$matches[2];
720
+					} else {
721
+												$this->_redirectaddr .= $matches[2];
722
+					}
723
+				} else {
724
+									$this->_redirectaddr = $matches[2];
688 725
 				}
689
-				else
690
-					$this->_redirectaddr = $matches[2];
691 726
 			}
692 727
 		
693 728
 			if(preg_match("|^HTTP/|",$result_headers[$currentHeader]))
@@ -712,15 +747,18 @@  discard block
 block discarded – undo
712 747
 		if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
713 748
 		{
714 749
 			$this->results[] = $results;
715
-			for($x=0; $x<count($match[1]); $x++)
716
-				$this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
750
+			for($x=0; $x<count($match[1]); $x++) {
751
+							$this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
752
+			}
717 753
 		}
718 754
 		// have we already fetched framed content?
719
-		elseif(is_array($this->results))
720
-			$this->results[] = $results;
755
+		elseif(is_array($this->results)) {
756
+					$this->results[] = $results;
757
+		}
721 758
 		// no framed content
722
-		else
723
-			$this->results = $results;
759
+		else {
760
+					$this->results = $results;
761
+		}
724 762
 
725 763
 		unlink("/tmp/$headerfile");
726 764
 		
@@ -736,8 +774,9 @@  discard block
 block discarded – undo
736 774
 	{
737 775
 		for($x=0; $x<count($this->headers); $x++)
738 776
 		{
739
-		if(preg_match("/^set-cookie:[\s]+([^=]+)=([^;]+)/i", $this->headers[$x],$match))
740
-			$this->cookies[$match[1]] = $match[2];
777
+		if(preg_match("/^set-cookie:[\s]+([^=]+)=([^;]+)/i", $this->headers[$x],$match)) {
778
+					$this->cookies[$match[1]] = $match[2];
779
+		}
741 780
 		}
742 781
 	}
743 782
 
@@ -773,8 +812,7 @@  discard block
 block discarded – undo
773 812
 				$this->_isproxy = true;
774 813
 				$host = $this->proxy_host;
775 814
 				$port = $this->proxy_port;
776
-			}
777
-		else
815
+			} else
778 816
 		{
779 817
 			$host = $this->host;
780 818
 			$port = $this->port;
@@ -793,8 +831,7 @@  discard block
 block discarded – undo
793 831
 			// socket connection succeeded
794 832
 
795 833
 			return true;
796
-		}
797
-		else
834
+		} else
798 835
 		{
799 836
 			// socket connection failed
800 837
 			$this->status = $errno;
@@ -837,8 +874,9 @@  discard block
 block discarded – undo
837 874
 		settype($formvars, "array");
838 875
 		settype($formfiles, "array");
839 876
 
840
-		if (count($formvars) == 0 && count($formfiles) == 0)
841
-			return;
877
+		if (count($formvars) == 0 && count($formfiles) == 0) {
878
+					return;
879
+		}
842 880
 		
843 881
 		switch ($this->_submit_type) {
844 882
 			case "application/x-www-form-urlencoded":
@@ -848,8 +886,9 @@  discard block
 block discarded – undo
848 886
 						while (list($cur_key, $cur_val) = each($val)) {
849 887
 							$postdata .= urlencode($key)."[]=".urlencode($cur_val)."&";
850 888
 						}
851
-					} else
852
-						$postdata .= urlencode($key)."=".urlencode($val)."&";
889
+					} else {
890
+											$postdata .= urlencode($key)."=".urlencode($val)."&";
891
+					}
853 892
 				}
854 893
 				break;
855 894
 
@@ -875,7 +914,9 @@  discard block
 block discarded – undo
875 914
 				while (list($field_name, $file_names) = each($formfiles)) {
876 915
 					settype($file_names, "array");
877 916
 					while (list(, $file_name) = each($file_names)) {
878
-						if (!is_readable($file_name)) continue;
917
+						if (!is_readable($file_name)) {
918
+						    continue;
919
+						}
879 920
 
880 921
 						$fp = fopen($file_name, "r");
881 922
 						$file_content = fread($fp, filesize($file_name));
Please login to merge, or discard this patch.
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -366,6 +366,9 @@  discard block
 block discarded – undo
366 366
 	Output:		$expandedLinks	the expanded links
367 367
 \*======================================================================*/
368 368
 
369
+	/**
370
+	 * @param string $links
371
+	 */
369 372
 	private function _expandlinks($links,$URI)
370 373
 	{
371 374
 		
@@ -400,6 +403,9 @@  discard block
 block discarded – undo
400 403
 	Output:		
401 404
 \*======================================================================*/
402 405
 	
406
+	/**
407
+	 * @param string $http_method
408
+	 */
403 409
 	private function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="")
404 410
 	{
405 411
 		if($this->passcookies && $this->_redirectaddr)
@@ -583,6 +589,9 @@  discard block
 block discarded – undo
583 589
 	Output:		
584 590
 \*======================================================================*/
585 591
 	
592
+	/**
593
+	 * @param string $http_method
594
+	 */
586 595
 	private function _httpsrequest($url,$URI,$http_method,$content_type="",$body="")
587 596
 	{
588 597
 		if($this->passcookies && $this->_redirectaddr)
@@ -766,6 +775,9 @@  discard block
 block discarded – undo
766 775
 	Input:		$fp	file pointer
767 776
 \*======================================================================*/
768 777
 	
778
+	/**
779
+	 * @param boolean $fp
780
+	 */
769 781
 	private function _connect(&$fp)
770 782
 	{
771 783
 		if(!empty($this->proxy_host) && !empty($this->proxy_port))
Please login to merge, or discard this patch.
main/inc/lib/magpierss/rss_parse.inc 4 patches
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 define('RSS', 'RSS');
25 25
 define('ATOM', 'Atom');
26 26
 
27
-require_once (MAGPIE_DIR . 'rss_utils.inc');
27
+require_once (MAGPIE_DIR.'rss_utils.inc');
28 28
 
29 29
 /**
30 30
 * Hybrid parser, and object, takes RSS as a string and returns a simple object.
@@ -36,16 +36,16 @@  discard block
 block discarded – undo
36 36
 class MagpieRSS {
37 37
     public $parser;
38 38
     
39
-    public $current_item   = array();  // item currently being parsed
40
-    public $items          = array();  // collection of parsed items
41
-    public $channel        = array();  // hash of channel fields
39
+    public $current_item   = array(); // item currently being parsed
40
+    public $items          = array(); // collection of parsed items
41
+    public $channel        = array(); // hash of channel fields
42 42
     public $textinput      = array();
43 43
     public $image          = array();
44 44
     public $feed_type;
45 45
     public $feed_version;
46
-    public $encoding       = '';       // output encoding of parsed rss
46
+    public $encoding       = ''; // output encoding of parsed rss
47 47
     
48
-    private $_source_encoding = '';     // only set if we have to parse xml prolog
48
+    private $_source_encoding = ''; // only set if we have to parse xml prolog
49 49
     
50 50
     public $ERROR = "";
51 51
     public $WARNING = "";
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
      *                                  source encoding. (caveat emptor)
94 94
      *
95 95
      */
96
-    public function MagpieRSS ($source, $output_encoding='ISO-8859-1', 
97
-                        $input_encoding=null, $detect_encoding=true) 
96
+    public function MagpieRSS($source, $output_encoding = 'ISO-8859-1', 
97
+                        $input_encoding = null, $detect_encoding = true) 
98 98
     {   
99 99
         # if PHP xml isn't compiled in, die
100 100
         #
101 101
         if (!function_exists('xml_parser_create')) {
102
-            $this->error( "Failed to load PHP's XML Extension. " . 
102
+            $this->error("Failed to load PHP's XML Extension. ". 
103 103
                           "http://www.php.net/manual/en/ref.xml.php",
104
-                           E_USER_ERROR );
104
+                           E_USER_ERROR);
105 105
         }
106 106
         
107 107
         list($parser, $source) = $this->create_parser($source, 
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
         
110 110
         
111 111
         if (!is_resource($parser)) {
112
-            $this->error( "Failed to create an instance of PHP's XML parser. " .
112
+            $this->error("Failed to create an instance of PHP's XML parser. ".
113 113
                           "http://www.php.net/manual/en/ref.xml.php",
114
-                          E_USER_ERROR );
114
+                          E_USER_ERROR);
115 115
         }
116 116
 
117 117
         
@@ -120,27 +120,27 @@  discard block
 block discarded – undo
120 120
         # pass in parser, and a reference to this object
121 121
         # setup handlers
122 122
         #
123
-        xml_set_object( $this->parser, $this );
123
+        xml_set_object($this->parser, $this);
124 124
         xml_set_element_handler($this->parser, 
125
-                'feed_start_element', 'feed_end_element' );
125
+                'feed_start_element', 'feed_end_element');
126 126
                         
127
-        xml_set_character_data_handler( $this->parser, 'feed_cdata' ); 
127
+        xml_set_character_data_handler($this->parser, 'feed_cdata'); 
128 128
     
129
-        $status = xml_parse( $this->parser, $source );
129
+        $status = xml_parse($this->parser, $source);
130 130
         
131
-        if (! $status ) {
132
-            $errorcode = xml_get_error_code( $this->parser );
133
-            if ( $errorcode != XML_ERROR_NONE ) {
134
-                $xml_error = xml_error_string( $errorcode );
131
+        if (!$status) {
132
+            $errorcode = xml_get_error_code($this->parser);
133
+            if ($errorcode != XML_ERROR_NONE) {
134
+                $xml_error = xml_error_string($errorcode);
135 135
                 $error_line = xml_get_current_line_number($this->parser);
136 136
                 $error_col = xml_get_current_column_number($this->parser);
137 137
                 $errormsg = "$xml_error at line $error_line, column $error_col";
138 138
 
139
-                $this->error( $errormsg );
139
+                $this->error($errormsg);
140 140
             }
141 141
         }
142 142
         
143
-        xml_parser_free( $this->parser );
143
+        xml_parser_free($this->parser);
144 144
 
145 145
         $this->normalize();
146 146
     }
@@ -151,26 +151,26 @@  discard block
 block discarded – undo
151 151
         
152 152
         // check for a namespace, and split if found
153 153
         $ns = false;
154
-        if ( strpos( $element, ':' ) ) {
155
-            list($ns, $el) = split( ':', $element, 2); 
154
+        if (strpos($element, ':')) {
155
+            list($ns, $el) = split(':', $element, 2); 
156 156
         }
157
-        if ( $ns and $ns != 'rdf' ) {
157
+        if ($ns and $ns != 'rdf') {
158 158
             $this->current_namespace = $ns;
159 159
         }
160 160
             
161 161
         # if feed type isn't set, then this is first element of feed
162 162
         # identify feed from root element
163 163
         #
164
-        if (!isset($this->feed_type) ) {
165
-            if ( $el == 'rdf' ) {
164
+        if (!isset($this->feed_type)) {
165
+            if ($el == 'rdf') {
166 166
                 $this->feed_type = RSS;
167 167
                 $this->feed_version = '1.0';
168 168
             }
169
-            elseif ( $el == 'rss' ) {
169
+            elseif ($el == 'rss') {
170 170
                 $this->feed_type = RSS;
171 171
                 $this->feed_version = $attrs['version'];
172 172
             }
173
-            elseif ( $el == 'feed' ) {
173
+            elseif ($el == 'feed') {
174 174
                 $this->feed_type = ATOM;
175 175
                 $this->feed_version = $attrs['version'];
176 176
                 $this->inchannel = true;
@@ -178,14 +178,14 @@  discard block
 block discarded – undo
178 178
             return;
179 179
         }
180 180
     
181
-        if ( $el == 'channel' ) 
181
+        if ($el == 'channel') 
182 182
         {
183 183
             $this->inchannel = true;
184 184
         }
185
-        elseif ($el == 'item' or $el == 'entry' ) 
185
+        elseif ($el == 'item' or $el == 'entry') 
186 186
         {
187 187
             $this->initem = true;
188
-            if ( isset($attrs['rdf:about']) ) {
188
+            if (isset($attrs['rdf:about'])) {
189 189
                 $this->current_item['about'] = $attrs['rdf:about']; 
190 190
             }
191 191
         }
@@ -209,10 +209,10 @@  discard block
 block discarded – undo
209 209
         }
210 210
         
211 211
         # handle atom content constructs
212
-        elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
212
+        elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS))
213 213
         {
214 214
             // avoid clashing w/ RSS mod_content
215
-            if ($el == 'content' ) {
215
+            if ($el == 'content') {
216 216
                 $el = 'atom_content';
217 217
             }
218 218
             
@@ -222,31 +222,31 @@  discard block
 block discarded – undo
222 222
         }
223 223
         
224 224
         // if inside an Atom content construct (e.g. content or summary) field treat tags as text
225
-        elseif ($this->feed_type == ATOM and $this->incontent ) 
225
+        elseif ($this->feed_type == ATOM and $this->incontent) 
226 226
         {
227 227
             // if tags are inlined, then flatten
228 228
             $attrs_str = join(' ', 
229 229
                     array_map('map_attrs', 
230 230
                     array_keys($attrs), 
231
-                    array_values($attrs) ) );
231
+                    array_values($attrs)));
232 232
             
233
-            $this->append_content( "<$element $attrs_str>"  );
233
+            $this->append_content("<$element $attrs_str>");
234 234
                     
235
-            array_unshift( $this->stack, $el );
235
+            array_unshift($this->stack, $el);
236 236
         }
237 237
         
238 238
         // Atom support many links per containging element.
239 239
         // Magpie treats link elements of type rel='alternate'
240 240
         // as being equivalent to RSS's simple link element.
241 241
         //
242
-        elseif ($this->feed_type == ATOM and $el == 'link' ) 
242
+        elseif ($this->feed_type == ATOM and $el == 'link') 
243 243
         {
244
-            if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) 
244
+            if (isset($attrs['rel']) and $attrs['rel'] == 'alternate') 
245 245
             {
246 246
                 $link_el = 'link';
247 247
             }
248 248
             else {
249
-                $link_el = 'link_' . $attrs['rel'];
249
+                $link_el = 'link_'.$attrs['rel'];
250 250
             }
251 251
             
252 252
             $this->append($link_el, $attrs['href']);
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
     
260 260
 
261 261
     
262
-    public function feed_cdata ($p, $text) {
262
+    public function feed_cdata($p, $text) {
263 263
         if ($this->feed_type == ATOM and $this->incontent) 
264 264
         {
265
-            $this->append_content( $text );
265
+            $this->append_content($text);
266 266
         }
267 267
         else {
268 268
             $current_el = join('_', array_reverse($this->stack));
@@ -270,35 +270,35 @@  discard block
 block discarded – undo
270 270
         }
271 271
     }
272 272
     
273
-    public function feed_end_element ($p, $el) {
273
+    public function feed_end_element($p, $el) {
274 274
         $el = strtolower($el);
275 275
         
276
-        if ( $el == 'item' or $el == 'entry' ) 
276
+        if ($el == 'item' or $el == 'entry') 
277 277
         {
278 278
             $this->items[] = $this->current_item;
279 279
             $this->current_item = array();
280 280
             $this->initem = false;
281 281
         }
282
-        elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) 
282
+        elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput') 
283 283
         {
284 284
             $this->intextinput = false;
285 285
         }
286
-        elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) 
286
+        elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image') 
287 287
         {
288 288
             $this->inimage = false;
289 289
         }
290
-        elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
290
+        elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS))
291 291
         {   
292 292
             $this->incontent = false;
293 293
         }
294
-        elseif ($el == 'channel' or $el == 'feed' ) 
294
+        elseif ($el == 'channel' or $el == 'feed') 
295 295
         {
296 296
             $this->inchannel = false;
297 297
         }
298
-        elseif ($this->feed_type == ATOM and $this->incontent  ) {
298
+        elseif ($this->feed_type == ATOM and $this->incontent) {
299 299
             // balance tags properly
300 300
             // note:  i don't think this is actually neccessary
301
-            if ( $this->stack[0] == $el ) 
301
+            if ($this->stack[0] == $el) 
302 302
             {
303 303
                 $this->append_content("</$el>");
304 304
             }
@@ -306,18 +306,18 @@  discard block
 block discarded – undo
306 306
                 $this->append_content("<$el />");
307 307
             }
308 308
 
309
-            array_shift( $this->stack );
309
+            array_shift($this->stack);
310 310
         }
311 311
         else {
312
-            array_shift( $this->stack );
312
+            array_shift($this->stack);
313 313
         }
314 314
         
315 315
         $this->current_namespace = false;
316 316
     }
317 317
     
318
-    public function concat (&$str1, $str2="") {
319
-        if (!isset($str1) ) {
320
-            $str1="";
318
+    public function concat(&$str1, $str2 = "") {
319
+        if (!isset($str1)) {
320
+            $str1 = "";
321 321
         }
322 322
         $str1 .= $str2;
323 323
     }
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
     
326 326
     
327 327
     public function append_content($text) {
328
-        if ( $this->initem ) {
329
-            $this->concat( $this->current_item[ $this->incontent ], $text );
328
+        if ($this->initem) {
329
+            $this->concat($this->current_item[$this->incontent], $text);
330 330
         }
331
-        elseif ( $this->inchannel ) {
332
-            $this->concat( $this->channel[ $this->incontent ], $text );
331
+        elseif ($this->inchannel) {
332
+            $this->concat($this->channel[$this->incontent], $text);
333 333
         }
334 334
     }
335 335
     
@@ -338,59 +338,59 @@  discard block
 block discarded – undo
338 338
         if (!$el) {
339 339
             return;
340 340
         }
341
-        if ( $this->current_namespace ) 
341
+        if ($this->current_namespace) 
342 342
         {
343
-            if ( $this->initem ) {
343
+            if ($this->initem) {
344 344
                 $this->concat(
345
-                    $this->current_item[ $this->current_namespace ][ $el ], $text);
345
+                    $this->current_item[$this->current_namespace][$el], $text);
346 346
             }
347 347
             elseif ($this->inchannel) {
348 348
                 $this->concat(
349
-                    $this->channel[ $this->current_namespace][ $el ], $text );
349
+                    $this->channel[$this->current_namespace][$el], $text );
350 350
             }
351 351
             elseif ($this->intextinput) {
352 352
                 $this->concat(
353
-                    $this->textinput[ $this->current_namespace][ $el ], $text );
353
+                    $this->textinput[$this->current_namespace][$el], $text );
354 354
             }
355 355
             elseif ($this->inimage) {
356 356
                 $this->concat(
357
-                    $this->image[ $this->current_namespace ][ $el ], $text );
357
+                    $this->image[$this->current_namespace][$el], $text );
358 358
             }
359 359
         }
360 360
         else {
361
-            if ( $this->initem ) {
361
+            if ($this->initem) {
362 362
                 $this->concat(
363
-                    $this->current_item[ $el ], $text);
363
+                    $this->current_item[$el], $text);
364 364
             }
365 365
             elseif ($this->intextinput) {
366 366
                 $this->concat(
367
-                    $this->textinput[ $el ], $text );
367
+                    $this->textinput[$el], $text );
368 368
             }
369 369
             elseif ($this->inimage) {
370 370
                 $this->concat(
371
-                    $this->image[ $el ], $text );
371
+                    $this->image[$el], $text );
372 372
             }
373 373
             elseif ($this->inchannel) {
374 374
                 $this->concat(
375
-                    $this->channel[ $el ], $text );
375
+                    $this->channel[$el], $text );
376 376
             }
377 377
             
378 378
         }
379 379
     }
380 380
     
381
-    public function normalize () {
381
+    public function normalize() {
382 382
         // if atom populate rss fields
383
-        if ( $this->is_atom() ) {
383
+        if ($this->is_atom()) {
384 384
             $this->channel['description'] = $this->channel['tagline'];
385
-            for ( $i = 0; $i < count($this->items); $i++) {
385
+            for ($i = 0; $i < count($this->items); $i++) {
386 386
                 $item = $this->items[$i];
387
-                if ( isset($item['summary']) )
387
+                if (isset($item['summary']))
388 388
                     $item['description'] = $item['summary'];
389
-                if ( isset($item['atom_content']))
389
+                if (isset($item['atom_content']))
390 390
                     $item['content']['encoded'] = $item['atom_content'];
391 391
                 
392
-                $atom_date = (isset($item['issued']) ) ? $item['issued'] : $item['modified'];
393
-                if ( $atom_date ) {
392
+                $atom_date = (isset($item['issued'])) ? $item['issued'] : $item['modified'];
393
+                if ($atom_date) {
394 394
                     $epoch = @parse_w3cdtf($atom_date);
395 395
                     if ($epoch and $epoch > 0) {
396 396
                         $item['date_timestamp'] = $epoch;
@@ -400,22 +400,22 @@  discard block
 block discarded – undo
400 400
                 $this->items[$i] = $item;
401 401
             }       
402 402
         }
403
-        elseif ( $this->is_rss() ) {
403
+        elseif ($this->is_rss()) {
404 404
             $this->channel['tagline'] = $this->channel['description'];
405
-            for ( $i = 0; $i < count($this->items); $i++) {
405
+            for ($i = 0; $i < count($this->items); $i++) {
406 406
                 $item = $this->items[$i];
407
-                if ( isset($item['description']))
407
+                if (isset($item['description']))
408 408
                     $item['summary'] = $item['description'];
409
-                if ( isset($item['content']['encoded'] ) )
409
+                if (isset($item['content']['encoded']))
410 410
                     $item['atom_content'] = $item['content']['encoded'];
411 411
                 
412
-                if ( $this->is_rss() == '1.0' and isset($item['dc']['date']) ) {
412
+                if ($this->is_rss() == '1.0' and isset($item['dc']['date'])) {
413 413
                     $epoch = @parse_w3cdtf($item['dc']['date']);
414 414
                     if ($epoch and $epoch > 0) {
415 415
                         $item['date_timestamp'] = $epoch;
416 416
                     }
417 417
                 }
418
-                elseif ( isset($item['pubdate']) ) {
418
+                elseif (isset($item['pubdate'])) {
419 419
                     $epoch = @strtotime($item['pubdate']);
420 420
                     if ($epoch > 0) {
421 421
                         $item['date_timestamp'] = $epoch;
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 428
     }
429 429
     
430 430
     
431
-    public function is_rss () {
432
-        if ( $this->feed_type == RSS ) {
431
+    public function is_rss() {
432
+        if ($this->feed_type == RSS) {
433 433
             return $this->feed_version; 
434 434
         }
435 435
         else {
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
     }
439 439
     
440 440
     public function is_atom() {
441
-        if ( $this->feed_type == ATOM ) {
441
+        if ($this->feed_type == ATOM) {
442 442
             return $this->feed_version;
443 443
         }
444 444
         else {
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
     *
452 452
     */
453 453
     public function create_parser($source, $out_enc, $in_enc, $detect) {
454
-        if ( substr(phpversion(),0,1) == 5) {
454
+        if (substr(phpversion(), 0, 1) == 5) {
455 455
             $parser = $this->php5_create_parser($in_enc, $detect);
456 456
         }
457 457
         else {
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
     */
477 477
     public function php5_create_parser($in_enc, $detect) {
478 478
         // by default php5 does a fine job of detecting input encodings
479
-        if(!$detect && $in_enc) {
479
+        if (!$detect && $in_enc) {
480 480
             return xml_parser_create($in_enc);
481 481
         }
482 482
         else {
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
     *
501 501
     */
502 502
     public function php4_create_parser($source, $in_enc, $detect) {
503
-        if ( !$detect ) {
503
+        if (!$detect) {
504 504
             return array(xml_parser_create($in_enc), $source);
505 505
         }
506 506
         
@@ -524,8 +524,8 @@  discard block
 block discarded – undo
524 524
         // cast the XML to a known encoding
525 525
         // @see http://php.net/iconv
526 526
        
527
-        if (function_exists('iconv'))  {
528
-            $encoded_source = iconv($in_enc,'UTF-8', $source);
527
+        if (function_exists('iconv')) {
528
+            $encoded_source = iconv($in_enc, 'UTF-8', $source);
529 529
             if ($encoded_source) {
530 530
                 return array(xml_parser_create('UTF-8'), $encoded_source);
531 531
             }
@@ -533,15 +533,15 @@  discard block
 block discarded – undo
533 533
         
534 534
         // iconv didn't work, try mb_convert_encoding
535 535
         // @see http://php.net/mbstring
536
-        if(function_exists('mb_convert_encoding')) {
537
-            $encoded_source = mb_convert_encoding($source, 'UTF-8', $in_enc );
536
+        if (function_exists('mb_convert_encoding')) {
537
+            $encoded_source = mb_convert_encoding($source, 'UTF-8', $in_enc);
538 538
             if ($encoded_source) {
539 539
                 return array(xml_parser_create('UTF-8'), $encoded_source);
540 540
             }
541 541
         }
542 542
         
543 543
         // else 
544
-        $this->error("Feed is in an unsupported character encoding. ($in_enc) " .
544
+        $this->error("Feed is in an unsupported character encoding. ($in_enc) ".
545 545
                      "You may see strange artifacts, and mangled characters.",
546 546
                      E_USER_NOTICE);
547 547
             
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
     
551 551
     public function known_encoding($enc) {
552 552
         $enc = strtoupper($enc);
553
-        if ( in_array($enc, $this->_KNOWN_ENCODINGS) ) {
553
+        if (in_array($enc, $this->_KNOWN_ENCODINGS)) {
554 554
             return $enc;
555 555
         }
556 556
         else {
@@ -558,20 +558,20 @@  discard block
 block discarded – undo
558 558
         }
559 559
     }
560 560
 
561
-    public function error ($errormsg, $lvl=E_USER_WARNING) {
561
+    public function error($errormsg, $lvl = E_USER_WARNING) {
562 562
         // append PHP's error message if track_errors enabled
563
-        if ( isset($php_errormsg) ) { 
563
+        if (isset($php_errormsg)) { 
564 564
             $errormsg .= " ($php_errormsg)";
565 565
         }
566
-        if ( MAGPIE_DEBUG ) {
567
-            trigger_error( $errormsg, $lvl);        
566
+        if (MAGPIE_DEBUG) {
567
+            trigger_error($errormsg, $lvl);        
568 568
         }
569 569
         else {
570
-            error_log( $errormsg, 0);
570
+            error_log($errormsg, 0);
571 571
         }
572 572
         
573
-        $notices = E_USER_NOTICE|E_NOTICE;
574
-        if ( $lvl&$notices ) {
573
+        $notices = E_USER_NOTICE | E_NOTICE;
574
+        if ($lvl & $notices) {
575 575
             $this->WARNING = $errormsg;
576 576
         } else {
577 577
             $this->ERROR = $errormsg;
@@ -589,15 +589,15 @@  discard block
 block discarded – undo
589 589
 // courtesy, Ryan Currie, [email protected]
590 590
 
591 591
 if (!function_exists('array_change_key_case')) {
592
-	define("CASE_UPPER",1);
593
-	define("CASE_LOWER",0);
592
+	define("CASE_UPPER", 1);
593
+	define("CASE_LOWER", 0);
594 594
 
595 595
 
596
-	function array_change_key_case($array,$case=CASE_LOWER) {
597
-       if ($case=CASE_LOWER) $cmd=strtolower;
598
-       elseif ($case=CASE_UPPER) $cmd=strtoupper;
599
-       foreach($array as $key=>$value) {
600
-               $output[$cmd($key)]=$value;
596
+	function array_change_key_case($array, $case = CASE_LOWER) {
597
+       if ($case = CASE_LOWER) $cmd = strtolower;
598
+       elseif ($case = CASE_UPPER) $cmd = strtoupper;
599
+       foreach ($array as $key=>$value) {
600
+               $output[$cmd($key)] = $value;
601 601
        }
602 602
        return $output;
603 603
 	}
Please login to merge, or discard this patch.
Braces   +47 added lines, -71 removed lines patch added patch discarded remove patch
@@ -165,12 +165,10 @@  discard block
 block discarded – undo
165 165
             if ( $el == 'rdf' ) {
166 166
                 $this->feed_type = RSS;
167 167
                 $this->feed_version = '1.0';
168
-            }
169
-            elseif ( $el == 'rss' ) {
168
+            } elseif ( $el == 'rss' ) {
170 169
                 $this->feed_type = RSS;
171 170
                 $this->feed_version = $attrs['version'];
172
-            }
173
-            elseif ( $el == 'feed' ) {
171
+            } elseif ( $el == 'feed' ) {
174 172
                 $this->feed_type = ATOM;
175 173
                 $this->feed_version = $attrs['version'];
176 174
                 $this->inchannel = true;
@@ -181,8 +179,7 @@  discard block
 block discarded – undo
181 179
         if ( $el == 'channel' ) 
182 180
         {
183 181
             $this->inchannel = true;
184
-        }
185
-        elseif ($el == 'item' or $el == 'entry' ) 
182
+        } elseif ($el == 'item' or $el == 'entry' ) 
186 183
         {
187 184
             $this->initem = true;
188 185
             if ( isset($attrs['rdf:about']) ) {
@@ -198,9 +195,7 @@  discard block
 block discarded – undo
198 195
             $el == 'textinput' ) 
199 196
         {
200 197
             $this->intextinput = true;
201
-        }
202
-        
203
-        elseif (
198
+        } elseif (
204 199
             $this->feed_type == RSS and 
205 200
             $this->current_namespace == '' and 
206 201
             $el == 'image' ) 
@@ -244,8 +239,7 @@  discard block
 block discarded – undo
244 239
             if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) 
245 240
             {
246 241
                 $link_el = 'link';
247
-            }
248
-            else {
242
+            } else {
249 243
                 $link_el = 'link_' . $attrs['rel'];
250 244
             }
251 245
             
@@ -263,8 +257,7 @@  discard block
 block discarded – undo
263 257
         if ($this->feed_type == ATOM and $this->incontent) 
264 258
         {
265 259
             $this->append_content( $text );
266
-        }
267
-        else {
260
+        } else {
268 261
             $current_el = join('_', array_reverse($this->stack));
269 262
             $this->append($current_el, $text);
270 263
         }
@@ -278,37 +271,30 @@  discard block
 block discarded – undo
278 271
             $this->items[] = $this->current_item;
279 272
             $this->current_item = array();
280 273
             $this->initem = false;
281
-        }
282
-        elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) 
274
+        } elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) 
283 275
         {
284 276
             $this->intextinput = false;
285
-        }
286
-        elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) 
277
+        } elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) 
287 278
         {
288 279
             $this->inimage = false;
289
-        }
290
-        elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
280
+        } elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
291 281
         {   
292 282
             $this->incontent = false;
293
-        }
294
-        elseif ($el == 'channel' or $el == 'feed' ) 
283
+        } elseif ($el == 'channel' or $el == 'feed' ) 
295 284
         {
296 285
             $this->inchannel = false;
297
-        }
298
-        elseif ($this->feed_type == ATOM and $this->incontent  ) {
286
+        } elseif ($this->feed_type == ATOM and $this->incontent  ) {
299 287
             // balance tags properly
300 288
             // note:  i don't think this is actually neccessary
301 289
             if ( $this->stack[0] == $el ) 
302 290
             {
303 291
                 $this->append_content("</$el>");
304
-            }
305
-            else {
292
+            } else {
306 293
                 $this->append_content("<$el />");
307 294
             }
308 295
 
309 296
             array_shift( $this->stack );
310
-        }
311
-        else {
297
+        } else {
312 298
             array_shift( $this->stack );
313 299
         }
314 300
         
@@ -327,8 +313,7 @@  discard block
 block discarded – undo
327 313
     public function append_content($text) {
328 314
         if ( $this->initem ) {
329 315
             $this->concat( $this->current_item[ $this->incontent ], $text );
330
-        }
331
-        elseif ( $this->inchannel ) {
316
+        } elseif ( $this->inchannel ) {
332 317
             $this->concat( $this->channel[ $this->incontent ], $text );
333 318
         }
334 319
     }
@@ -343,34 +328,27 @@  discard block
 block discarded – undo
343 328
             if ( $this->initem ) {
344 329
                 $this->concat(
345 330
                     $this->current_item[ $this->current_namespace ][ $el ], $text);
346
-            }
347
-            elseif ($this->inchannel) {
331
+            } elseif ($this->inchannel) {
348 332
                 $this->concat(
349 333
                     $this->channel[ $this->current_namespace][ $el ], $text );
350
-            }
351
-            elseif ($this->intextinput) {
334
+            } elseif ($this->intextinput) {
352 335
                 $this->concat(
353 336
                     $this->textinput[ $this->current_namespace][ $el ], $text );
354
-            }
355
-            elseif ($this->inimage) {
337
+            } elseif ($this->inimage) {
356 338
                 $this->concat(
357 339
                     $this->image[ $this->current_namespace ][ $el ], $text );
358 340
             }
359
-        }
360
-        else {
341
+        } else {
361 342
             if ( $this->initem ) {
362 343
                 $this->concat(
363 344
                     $this->current_item[ $el ], $text);
364
-            }
365
-            elseif ($this->intextinput) {
345
+            } elseif ($this->intextinput) {
366 346
                 $this->concat(
367 347
                     $this->textinput[ $el ], $text );
368
-            }
369
-            elseif ($this->inimage) {
348
+            } elseif ($this->inimage) {
370 349
                 $this->concat(
371 350
                     $this->image[ $el ], $text );
372
-            }
373
-            elseif ($this->inchannel) {
351
+            } elseif ($this->inchannel) {
374 352
                 $this->concat(
375 353
                     $this->channel[ $el ], $text );
376 354
             }
@@ -384,10 +362,12 @@  discard block
 block discarded – undo
384 362
             $this->channel['description'] = $this->channel['tagline'];
385 363
             for ( $i = 0; $i < count($this->items); $i++) {
386 364
                 $item = $this->items[$i];
387
-                if ( isset($item['summary']) )
388
-                    $item['description'] = $item['summary'];
389
-                if ( isset($item['atom_content']))
390
-                    $item['content']['encoded'] = $item['atom_content'];
365
+                if ( isset($item['summary']) ) {
366
+                                    $item['description'] = $item['summary'];
367
+                }
368
+                if ( isset($item['atom_content'])) {
369
+                                    $item['content']['encoded'] = $item['atom_content'];
370
+                }
391 371
                 
392 372
                 $atom_date = (isset($item['issued']) ) ? $item['issued'] : $item['modified'];
393 373
                 if ( $atom_date ) {
@@ -399,23 +379,23 @@  discard block
 block discarded – undo
399 379
                 
400 380
                 $this->items[$i] = $item;
401 381
             }       
402
-        }
403
-        elseif ( $this->is_rss() ) {
382
+        } elseif ( $this->is_rss() ) {
404 383
             $this->channel['tagline'] = $this->channel['description'];
405 384
             for ( $i = 0; $i < count($this->items); $i++) {
406 385
                 $item = $this->items[$i];
407
-                if ( isset($item['description']))
408
-                    $item['summary'] = $item['description'];
409
-                if ( isset($item['content']['encoded'] ) )
410
-                    $item['atom_content'] = $item['content']['encoded'];
386
+                if ( isset($item['description'])) {
387
+                                    $item['summary'] = $item['description'];
388
+                }
389
+                if ( isset($item['content']['encoded'] ) ) {
390
+                                    $item['atom_content'] = $item['content']['encoded'];
391
+                }
411 392
                 
412 393
                 if ( $this->is_rss() == '1.0' and isset($item['dc']['date']) ) {
413 394
                     $epoch = @parse_w3cdtf($item['dc']['date']);
414 395
                     if ($epoch and $epoch > 0) {
415 396
                         $item['date_timestamp'] = $epoch;
416 397
                     }
417
-                }
418
-                elseif ( isset($item['pubdate']) ) {
398
+                } elseif ( isset($item['pubdate']) ) {
419 399
                     $epoch = @strtotime($item['pubdate']);
420 400
                     if ($epoch > 0) {
421 401
                         $item['date_timestamp'] = $epoch;
@@ -431,8 +411,7 @@  discard block
 block discarded – undo
431 411
     public function is_rss () {
432 412
         if ( $this->feed_type == RSS ) {
433 413
             return $this->feed_version; 
434
-        }
435
-        else {
414
+        } else {
436 415
             return false;
437 416
         }
438 417
     }
@@ -440,8 +419,7 @@  discard block
 block discarded – undo
440 419
     public function is_atom() {
441 420
         if ( $this->feed_type == ATOM ) {
442 421
             return $this->feed_version;
443
-        }
444
-        else {
422
+        } else {
445 423
             return false;
446 424
         }
447 425
     }
@@ -453,8 +431,7 @@  discard block
 block discarded – undo
453 431
     public function create_parser($source, $out_enc, $in_enc, $detect) {
454 432
         if ( substr(phpversion(),0,1) == 5) {
455 433
             $parser = $this->php5_create_parser($in_enc, $detect);
456
-        }
457
-        else {
434
+        } else {
458 435
             list($parser, $source) = $this->php4_create_parser($source, $in_enc, $detect);
459 436
         }
460 437
         if ($out_enc) {
@@ -478,8 +455,7 @@  discard block
 block discarded – undo
478 455
         // by default php5 does a fine job of detecting input encodings
479 456
         if(!$detect && $in_enc) {
480 457
             return xml_parser_create($in_enc);
481
-        }
482
-        else {
458
+        } else {
483 459
             return xml_parser_create('');
484 460
         }
485 461
     }
@@ -508,8 +484,7 @@  discard block
 block discarded – undo
508 484
             if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) {
509 485
                 $in_enc = strtoupper($m[1]);
510 486
                 $this->source_encoding = $in_enc;
511
-            }
512
-            else {
487
+            } else {
513 488
                 $in_enc = 'UTF-8';
514 489
             }
515 490
         }
@@ -552,8 +527,7 @@  discard block
 block discarded – undo
552 527
         $enc = strtoupper($enc);
553 528
         if ( in_array($enc, $this->_KNOWN_ENCODINGS) ) {
554 529
             return $enc;
555
-        }
556
-        else {
530
+        } else {
557 531
             return false;
558 532
         }
559 533
     }
@@ -565,8 +539,7 @@  discard block
 block discarded – undo
565 539
         }
566 540
         if ( MAGPIE_DEBUG ) {
567 541
             trigger_error( $errormsg, $lvl);        
568
-        }
569
-        else {
542
+        } else {
570 543
             error_log( $errormsg, 0);
571 544
         }
572 545
         
@@ -594,8 +567,11 @@  discard block
 block discarded – undo
594 567
 
595 568
 
596 569
 	function array_change_key_case($array,$case=CASE_LOWER) {
597
-       if ($case=CASE_LOWER) $cmd=strtolower;
598
-       elseif ($case=CASE_UPPER) $cmd=strtoupper;
570
+       if ($case=CASE_LOWER) {
571
+           $cmd=strtolower;
572
+       } elseif ($case=CASE_UPPER) {
573
+           $cmd=strtoupper;
574
+       }
599 575
        foreach($array as $key=>$value) {
600 576
                $output[$cmd($key)]=$value;
601 577
        }
Please login to merge, or discard this patch.
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
         #
101 101
         if (!function_exists('xml_parser_create')) {
102 102
             $this->error( "Failed to load PHP's XML Extension. " . 
103
-                          "http://www.php.net/manual/en/ref.xml.php",
104
-                           E_USER_ERROR );
103
+                            "http://www.php.net/manual/en/ref.xml.php",
104
+                            E_USER_ERROR );
105 105
         }
106 106
         
107 107
         list($parser, $source) = $this->create_parser($source, 
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
         
111 111
         if (!is_resource($parser)) {
112 112
             $this->error( "Failed to create an instance of PHP's XML parser. " .
113
-                          "http://www.php.net/manual/en/ref.xml.php",
114
-                          E_USER_ERROR );
113
+                            "http://www.php.net/manual/en/ref.xml.php",
114
+                            E_USER_ERROR );
115 115
         }
116 116
 
117 117
         
@@ -447,9 +447,9 @@  discard block
 block discarded – undo
447 447
     }
448 448
 
449 449
     /**
450
-    * return XML parser, and possibly re-encoded source
451
-    *
452
-    */
450
+     * return XML parser, and possibly re-encoded source
451
+     *
452
+     */
453 453
     public function create_parser($source, $out_enc, $in_enc, $detect) {
454 454
         if ( substr(phpversion(),0,1) == 5) {
455 455
             $parser = $this->php5_create_parser($in_enc, $detect);
@@ -466,14 +466,14 @@  discard block
 block discarded – undo
466 466
     }
467 467
     
468 468
     /**
469
-    * Instantiate an XML parser under PHP5
470
-    *
471
-    * PHP5 will do a fine job of detecting input encoding
472
-    * if passed an empty string as the encoding. 
473
-    *
474
-    * All hail libxml2!
475
-    *
476
-    */
469
+     * Instantiate an XML parser under PHP5
470
+     *
471
+     * PHP5 will do a fine job of detecting input encoding
472
+     * if passed an empty string as the encoding. 
473
+     *
474
+     * All hail libxml2!
475
+     *
476
+     */
477 477
     public function php5_create_parser($in_enc, $detect) {
478 478
         // by default php5 does a fine job of detecting input encodings
479 479
         if(!$detect && $in_enc) {
@@ -485,20 +485,20 @@  discard block
 block discarded – undo
485 485
     }
486 486
     
487 487
     /**
488
-    * Instaniate an XML parser under PHP4
489
-    *
490
-    * Unfortunately PHP4's support for character encodings
491
-    * and especially XML and character encodings sucks.  As
492
-    * long as the documents you parse only contain characters
493
-    * from the ISO-8859-1 character set (a superset of ASCII,
494
-    * and a subset of UTF-8) you're fine.  However once you
495
-    * step out of that comfy little world things get mad, bad,
496
-    * and dangerous to know.
497
-    *
498
-    * The following code is based on SJM's work with FoF
499
-    * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
500
-    *
501
-    */
488
+     * Instaniate an XML parser under PHP4
489
+     *
490
+     * Unfortunately PHP4's support for character encodings
491
+     * and especially XML and character encodings sucks.  As
492
+     * long as the documents you parse only contain characters
493
+     * from the ISO-8859-1 character set (a superset of ASCII,
494
+     * and a subset of UTF-8) you're fine.  However once you
495
+     * step out of that comfy little world things get mad, bad,
496
+     * and dangerous to know.
497
+     *
498
+     * The following code is based on SJM's work with FoF
499
+     * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
500
+     *
501
+     */
502 502
     public function php4_create_parser($source, $in_enc, $detect) {
503 503
         if ( !$detect ) {
504 504
             return array(xml_parser_create($in_enc), $source);
@@ -542,8 +542,8 @@  discard block
 block discarded – undo
542 542
         
543 543
         // else 
544 544
         $this->error("Feed is in an unsupported character encoding. ($in_enc) " .
545
-                     "You may see strange artifacts, and mangled characters.",
546
-                     E_USER_NOTICE);
545
+                        "You may see strange artifacts, and mangled characters.",
546
+                        E_USER_NOTICE);
547 547
             
548 548
         return array(xml_parser_create(), $source);
549 549
     }
@@ -589,17 +589,17 @@  discard block
 block discarded – undo
589 589
 // courtesy, Ryan Currie, [email protected]
590 590
 
591 591
 if (!function_exists('array_change_key_case')) {
592
-	define("CASE_UPPER",1);
593
-	define("CASE_LOWER",0);
592
+    define("CASE_UPPER",1);
593
+    define("CASE_LOWER",0);
594 594
 
595 595
 
596
-	function array_change_key_case($array,$case=CASE_LOWER) {
597
-       if ($case=CASE_LOWER) $cmd=strtolower;
598
-       elseif ($case=CASE_UPPER) $cmd=strtoupper;
599
-       foreach($array as $key=>$value) {
600
-               $output[$cmd($key)]=$value;
601
-       }
602
-       return $output;
603
-	}
596
+    function array_change_key_case($array,$case=CASE_LOWER) {
597
+        if ($case=CASE_LOWER) $cmd=strtolower;
598
+        elseif ($case=CASE_UPPER) $cmd=strtoupper;
599
+        foreach($array as $key=>$value) {
600
+                $output[$cmd($key)]=$value;
601
+        }
602
+        return $output;
603
+    }
604 604
 
605 605
 }
Please login to merge, or discard this patch.
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -449,6 +449,10 @@  discard block
 block discarded – undo
449 449
     /**
450 450
     * return XML parser, and possibly re-encoded source
451 451
     *
452
+    * @param string $source
453
+    * @param string $out_enc
454
+    * @param string|null $in_enc
455
+    * @param boolean $detect
452 456
     */
453 457
     public function create_parser($source, $out_enc, $in_enc, $detect) {
454 458
         if ( substr(phpversion(),0,1) == 5) {
@@ -558,6 +562,9 @@  discard block
 block discarded – undo
558 562
         }
559 563
     }
560 564
 
565
+    /**
566
+     * @param integer $lvl
567
+     */
561 568
     public function error ($errormsg, $lvl=E_USER_WARNING) {
562 569
         // append PHP's error message if track_errors enabled
563 570
         if ( isset($php_errormsg) ) { 
@@ -593,6 +600,9 @@  discard block
 block discarded – undo
593 600
 	define("CASE_LOWER",0);
594 601
 
595 602
 
603
+	/**
604
+	 * @param integer $case
605
+	 */
596 606
 	function array_change_key_case($array,$case=CASE_LOWER) {
597 607
        if ($case=CASE_LOWER) $cmd=strtolower;
598 608
        elseif ($case=CASE_UPPER) $cmd=strtoupper;
Please login to merge, or discard this patch.
main/inc/lib/banner.lib.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -42,20 +42,20 @@  discard block
 block discarded – undo
42 42
     $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
43 43
     $navigation['myprofile']['title'] = get_lang('ModifyProfile');
44 44
     $navigation['myprofile']['key'] = 'profile';
45
-	// Link to my agenda
45
+    // Link to my agenda
46 46
     $navigation['myagenda']['url'] = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=personal';
47 47
     $navigation['myagenda']['title'] = get_lang('MyAgenda');
48 48
     $navigation['myagenda']['key'] = 'agenda';
49 49
 
50
-	// Gradebook
51
-	if (api_get_setting('gradebook_enable') == 'true') {
50
+    // Gradebook
51
+    if (api_get_setting('gradebook_enable') == 'true') {
52 52
         $navigation['mygradebook']['url'] = api_get_path(WEB_CODE_PATH).'gradebook/gradebook.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
53 53
         $navigation['mygradebook']['title'] = get_lang('MyGradebook');
54 54
         $navigation['mygradebook']['key'] = 'gradebook';
55
-	}
55
+    }
56 56
 
57
-	// Reporting
58
-	if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
57
+    // Reporting
58
+    if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
59 59
         // Link to my space
60 60
         $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/'.(api_is_drh()?'session.php':'');
61 61
         $navigation['session_my_space']['title'] = get_lang('MySpace');
@@ -79,21 +79,21 @@  discard block
 block discarded – undo
79 79
         $navigation['session_my_progress']['key'] = 'my-progress';
80 80
     }
81 81
 
82
-	// Social
83
-	if (api_get_setting('allow_social_tool')=='true') {
82
+    // Social
83
+    if (api_get_setting('allow_social_tool')=='true') {
84 84
         $navigation['social']['url'] = api_get_path(WEB_CODE_PATH).'social/home.php';
85 85
         $navigation['social']['title'] = get_lang('SocialNetwork');
86 86
         $navigation['social']['key'] = 'social-network';
87
-	}
87
+    }
88 88
 
89
-	// Dashboard
90
-	if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
89
+    // Dashboard
90
+    if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
91 91
         $navigation['dashboard']['url'] = api_get_path(WEB_CODE_PATH).'dashboard/index.php';
92 92
         $navigation['dashboard']['title'] = get_lang('Dashboard');
93 93
         $navigation['dashboard']['key'] = 'dashboard';
94
-	}
94
+    }
95 95
 
96
-	// Reports
96
+    // Reports
97 97
     /*
98 98
 	if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
99 99
         $navigation['reports']['url'] = api_get_path(WEB_CODE_PATH).'reports/index.php';
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
     }
117 117
     // End Custom Tabs
118 118
 
119
-	// Platform administration
120
-	if (api_is_platform_admin(true)) {
119
+    // Platform administration
120
+    if (api_is_platform_admin(true)) {
121 121
         $navigation['platform_admin']['url'] = api_get_path(WEB_CODE_PATH).'admin/';
122 122
         $navigation['platform_admin']['title'] = get_lang('PlatformAdmin');
123 123
         $navigation['platform_admin']['key'] = 'admin';
124
-	}
124
+    }
125 125
 
126
-	return $navigation;
126
+    return $navigation;
127 127
 }
128 128
 
129 129
 /**
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
             }
352 352
         }
353 353
 
354
-		// Reports
354
+        // Reports
355 355
         if (!empty($possible_tabs['reports'])) {
356 356
             if (api_get_setting('show_tabs', 'reports') == 'true') {
357 357
                 if ((api_is_platform_admin() || api_is_drh() || api_is_session_admin()) && Rights::hasRight('show_tabs:reports')) {
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 
493 493
     $menu = null;
494 494
     if (!empty($lis)) {
495
-         $menu .= $lis;
495
+            $menu .= $lis;
496 496
     }
497 497
     return $menu;
498 498
 }
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
         $navigation_item_my_courses['title'] = get_lang('MyCourses');
549 549
         $navigation_item_my_courses['url'] = api_get_path(WEB_PATH).'user_portal.php';
550 550
         $navigation[] = $navigation_item_my_courses;
551
-        */
551
+         */
552 552
         $navigation[] = $navigation_item;
553 553
     }
554 554
 
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     $navigation['mycourses']['key'] = 'my-course';
40 40
 
41 41
     // My Profile
42
-    $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
42
+    $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '');
43 43
     $navigation['myprofile']['title'] = get_lang('ModifyProfile');
44 44
     $navigation['myprofile']['key'] = 'profile';
45 45
 	// Link to my agenda
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 	// Gradebook
51 51
 	if (api_get_setting('gradebook_enable') == 'true') {
52
-        $navigation['mygradebook']['url'] = api_get_path(WEB_CODE_PATH).'gradebook/gradebook.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
52
+        $navigation['mygradebook']['url'] = api_get_path(WEB_CODE_PATH).'gradebook/gradebook.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '');
53 53
         $navigation['mygradebook']['title'] = get_lang('MyGradebook');
54 54
         $navigation['mygradebook']['key'] = 'gradebook';
55 55
 	}
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
 	// Reporting
58 58
 	if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
59 59
         // Link to my space
60
-        $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/'.(api_is_drh()?'session.php':'');
60
+        $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/'.(api_is_drh() ? 'session.php' : '');
61 61
         $navigation['session_my_space']['title'] = get_lang('MySpace');
62 62
         $navigation['session_my_space']['key'] = 'my-space';
63 63
     } else if (api_is_student_boss()) {
64
-        $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH) . 'mySpace/student.php';
64
+        $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/student.php';
65 65
         $navigation['session_my_space']['title'] = get_lang('MySpace');
66 66
         $navigation['session_my_space']['key'] = 'my-space';
67 67
     } else {
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     }
81 81
 
82 82
 	// Social
83
-	if (api_get_setting('allow_social_tool')=='true') {
83
+	if (api_get_setting('allow_social_tool') == 'true') {
84 84
         $navigation['social']['url'] = api_get_path(WEB_CODE_PATH).'social/home.php';
85 85
         $navigation['social']['title'] = get_lang('SocialNetwork');
86 86
         $navigation['social']['key'] = 'social-network';
@@ -161,14 +161,14 @@  discard block
 block discarded – undo
161 161
         'id' => 'header-logo'
162 162
     );
163 163
     $testServer = api_get_setting('server_type');
164
-    if ($testServer == 'test' && is_file($logoBase . 'svg')) {
165
-        $logo = $logoBase . 'svg';
164
+    if ($testServer == 'test' && is_file($logoBase.'svg')) {
165
+        $logo = $logoBase.'svg';
166 166
         $attributes['width'] = '245';
167 167
         $attributes['height'] = '68';
168 168
         $imageUrl = api_get_path(WEB_CSS_PATH).'themes/'.$theme.'/images/header-logo.svg';
169 169
     } else {
170
-        $logo = $logoBase . 'png';
171
-        $customLogo = $customLogoBase . 'png';
170
+        $logo = $logoBase.'png';
171
+        $customLogo = $customLogoBase.'png';
172 172
         $imageUrl = api_get_path(WEB_CSS_PATH).'themes/'.$theme.'/images/header-logo.png';
173 173
         $customImageUrl = api_get_path(WEB_CSS_PATH).'themes/'.$theme.'/images/header-logo-custom.png';
174 174
     }
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
     $_course = api_get_course_info();
219 219
     $course_id = 0;
220 220
     if (!empty($_course)) {
221
-        $course_id  = $_course['code'];
221
+        $course_id = $_course['code'];
222 222
     }
223 223
 
224 224
     $user_id = api_get_user_id();
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
         if (api_get_setting('gradebook_enable') == 'true') {
316 316
             if (api_get_setting('show_tabs', 'my_gradebook') == 'true') {
317 317
                 $navigation['mygradebook'] = $possible_tabs['mygradebook'];
318
-            } else{
318
+            } else {
319 319
                 $menu_navigation['mygradebook'] = $possible_tabs['mygradebook'];
320 320
             }
321 321
         }
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
             if (api_get_setting('allow_social_tool') == 'true') {
341 341
                 $navigation['social'] = isset($possible_tabs['social']) ? $possible_tabs['social'] : null;
342 342
             }
343
-        } else{
343
+        } else {
344 344
             $menu_navigation['social'] = isset($possible_tabs['social']) ? $possible_tabs['social'] : null;
345 345
         }
346 346
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
             if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
350 350
                 $navigation['dashboard'] = isset($possible_tabs['dashboard']) ? $possible_tabs['dashboard'] : null;
351 351
             }
352
-        } else{
352
+        } else {
353 353
             $menu_navigation['dashboard'] = isset($possible_tabs['dashboard']) ? $possible_tabs['dashboard'] : null;
354 354
         }
355 355
 
@@ -440,32 +440,32 @@  discard block
 block discarded – undo
440 440
     $home_top = '';
441 441
 
442 442
     if (is_file($homep.$menutabs.'_'.$lang.$ext) && is_readable($homep.$menutabs.'_'.$lang.$ext)) {
443
-        $home_top = @(string)file_get_contents($homep.$menutabs.'_'.$lang.$ext);
443
+        $home_top = @(string) file_get_contents($homep.$menutabs.'_'.$lang.$ext);
444 444
     } elseif (is_file($homep.$menutabs.$lang.$ext) && is_readable($homep.$menutabs.$lang.$ext)) {
445
-        $home_top = @(string)file_get_contents($homep.$menutabs.$lang.$ext);
445
+        $home_top = @(string) file_get_contents($homep.$menutabs.$lang.$ext);
446 446
     } else {
447 447
         //$errorMsg = get_lang('HomePageFilesNotReadable');
448 448
     }
449 449
 
450 450
     $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
451 451
 
452
-    $open = str_replace('{rel_path}',api_get_path(REL_PATH), $home_top);
452
+    $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top);
453 453
     $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
454 454
 
455 455
     $open_mtloggedin = '';
456 456
     if (api_get_user_id() && !api_is_anonymous()) {
457 457
         if (is_file($homep.$mtloggedin.'_'.$lang.$ext) && is_readable($homep.$mtloggedin.'_'.$lang.$ext)) {
458
-            $home_top = @(string)file_get_contents($homep.$mtloggedin.'_'.$lang.$ext);
458
+            $home_top = @(string) file_get_contents($homep.$mtloggedin.'_'.$lang.$ext);
459 459
             $home_top = str_replace('::private', '', $home_top);
460 460
         } elseif (is_file($homep.$mtloggedin.$lang.$ext) && is_readable($homep.$mtloggedin.$lang.$ext)) {
461
-            $home_top = @(string)file_get_contents($homep.$mtloggedin.$lang.$ext);
461
+            $home_top = @(string) file_get_contents($homep.$mtloggedin.$lang.$ext);
462 462
             $home_top = str_replace('::private', '', $home_top);
463 463
         } else {
464 464
             //$errorMsg = get_lang('HomePageFilesNotReadable');
465 465
         }
466 466
 
467 467
         $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
468
-        $open_mtloggedin = str_replace('{rel_path}',api_get_path(REL_PATH), $home_top);
468
+        $open_mtloggedin = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top);
469 469
         $open_mtloggedin = api_to_system_encoding($open_mtloggedin, api_detect_encoding(strip_tags($open_mtloggedin)));
470 470
     }
471 471
 
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
     if (!empty($open) OR !empty($open_mtloggedin)) {
475 475
         if (strpos($open.$open_mtloggedin, 'show_menu') === false) {
476 476
             if (api_is_anonymous()) {
477
-                $navigation[SECTION_CAMPUS]  = null;
477
+                $navigation[SECTION_CAMPUS] = null;
478 478
             }
479 479
         } else {
480 480
             if (api_get_user_id() && !api_is_anonymous()) {
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
     if (count($navigation) > 0 || !empty($lis)) {
489 489
         $pre_lis = '';
490 490
         foreach ($navigation as $section => $navigation_info) {
491
-            $key = (!empty($navigation_info['key'])?'tab-'.$navigation_info['key']:'');
491
+            $key = (!empty($navigation_info['key']) ? 'tab-'.$navigation_info['key'] : '');
492 492
             if (isset($GLOBALS['this_section'])) {
493 493
                 $current = $section == $GLOBALS['this_section'] ? ' id="current" class="active '.$key.'" ' : ' class="'.$key.'"';
494 494
             } else {
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 
533 533
     if (!empty($_course) && !isset($_GET['hide_course_breadcrumb'])) {
534 534
 
535
-        $navigation_item['url'] = $web_course_path . $_course['path'].'/index.php'.(!empty($session_id) ? '?id_session='.$session_id : '');
535
+        $navigation_item['url'] = $web_course_path.$_course['path'].'/index.php'.(!empty($session_id) ? '?id_session='.$session_id : '');
536 536
         $_course['name'] = api_htmlentities($_course['name']);
537 537
         $course_title = cut($_course['name'], MAX_LENGTH_BREADCRUMB);
538 538
 
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
                 $navigation_item['title'] = Display::img(api_get_path(WEB_IMG_PATH).'home.png', $_course['name'].$my_session_name).' '.$course_title.$my_session_name;
548 548
                 break;
549 549
             default:
550
-                if (api_get_session_id() != -1 ) {
550
+                if (api_get_session_id() != -1) {
551 551
                     $navigation_item['title'] = Display::img(api_get_path(WEB_IMG_PATH).'home.png', $_course['name'].$my_session_name).' '.$course_title.$my_session_name;
552 552
                 } else {
553 553
                     $navigation_item['title'] = Display::img(api_get_path(WEB_IMG_PATH).'home.png', $_course['name']).' '.$course_title;
@@ -581,22 +581,22 @@  discard block
 block discarded – undo
581 581
             // titles for shared folders
582 582
             if ($breadcrumb_step['name'] == 'shared_folder') {
583 583
                 $navigation_item['title'] = get_lang('UserFolders');
584
-            } elseif(strstr($breadcrumb_step['name'], 'shared_folder_session_')) {
584
+            } elseif (strstr($breadcrumb_step['name'], 'shared_folder_session_')) {
585 585
                 $navigation_item['title'] = get_lang('UserFolders');
586
-            } elseif(strstr($breadcrumb_step['name'], 'sf_user_')) {
586
+            } elseif (strstr($breadcrumb_step['name'], 'sf_user_')) {
587 587
                 $userinfo = api_get_user_info(substr($breadcrumb_step['name'], 8));
588 588
                 $navigation_item['title'] = $userinfo['complete_name'];
589
-            } elseif($breadcrumb_step['name'] == 'chat_files') {
589
+            } elseif ($breadcrumb_step['name'] == 'chat_files') {
590 590
                 $navigation_item['title'] = get_lang('ChatFiles');
591
-            } elseif($breadcrumb_step['name'] == 'images') {
591
+            } elseif ($breadcrumb_step['name'] == 'images') {
592 592
                 $navigation_item['title'] = get_lang('Images');
593
-            } elseif($breadcrumb_step['name'] == 'video') {
593
+            } elseif ($breadcrumb_step['name'] == 'video') {
594 594
                 $navigation_item['title'] = get_lang('Video');
595
-            } elseif($breadcrumb_step['name'] == 'audio') {
595
+            } elseif ($breadcrumb_step['name'] == 'audio') {
596 596
                 $navigation_item['title'] = get_lang('Audio');
597
-            } elseif($breadcrumb_step['name'] == 'flash') {
597
+            } elseif ($breadcrumb_step['name'] == 'flash') {
598 598
                 $navigation_item['title'] = get_lang('Flash');
599
-            } elseif($breadcrumb_step['name'] == 'gallery') {
599
+            } elseif ($breadcrumb_step['name'] == 'gallery') {
600 600
                 $navigation_item['title'] = get_lang('Gallery');
601 601
             }
602 602
             // Fixes breadcrumb title now we applied the Security::remove_XSS and
@@ -663,35 +663,35 @@  discard block
 block discarded – undo
663 663
         if (!empty($final_navigation)) {
664 664
             // $home_link.= '<span class="divider">/</span>';
665 665
             if (!empty($home_link)) {
666
-                $lis.= Display::tag('li', $home_link);
666
+                $lis .= Display::tag('li', $home_link);
667 667
             }
668 668
 
669 669
             foreach ($final_navigation as $bread) {
670 670
                 $bread_check = trim(strip_tags($bread));
671 671
                 if (!empty($bread_check)) {
672
-                    if ($final_navigation_count-1 > $i) {
672
+                    if ($final_navigation_count - 1 > $i) {
673 673
                         $bread .= '';
674 674
                     }
675
-                    $lis.= Display::tag('li', $bread,array('class'=>'active'));
675
+                    $lis .= Display::tag('li', $bread, array('class'=>'active'));
676 676
                     $i++;
677 677
                 }
678 678
             }
679 679
         } else {
680 680
             if (!empty($home_link)) {
681
-                $lis.= Display::tag('li', $home_link);
681
+                $lis .= Display::tag('li', $home_link);
682 682
             }
683 683
         }
684 684
 
685 685
         // View as student/teacher link
686 686
         $view = null;
687 687
         if (!empty($view_as_student_link)) {
688
-            $view .= Display::tag('div', $view_as_student_link, array('id' => 'view_as_link','class' => 'pull-right'));
688
+            $view .= Display::tag('div', $view_as_student_link, array('id' => 'view_as_link', 'class' => 'pull-right'));
689 689
         }
690 690
 
691 691
         if (!empty($navigation_right)) {
692
-            foreach($navigation_right as $item){
692
+            foreach ($navigation_right as $item) {
693 693
                 $extra_class = isset($item['class']) ? $item['class'] : null;
694
-                $lis.= Display::tag('li', $item['title'], array('class' => $extra_class.' pull-right'));
694
+                $lis .= Display::tag('li', $item['title'], array('class' => $extra_class.' pull-right'));
695 695
             }
696 696
         }
697 697
 
Please login to merge, or discard this patch.
main/inc/lib/conditional_login.class.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
                     if (isset($condition['conditional_function']) && $condition['conditional_function']($user) == false) {
24 24
                         $_SESSION['conditional_login']['uid'] = $user['user_id'];
25 25
                         $_SESSION['conditional_login']['can_login'] = false;
26
-                        header("Location:". $condition['url']);
26
+                        header("Location:".$condition['url']);
27 27
                         exit();
28 28
                     }
29 29
                 }
Please login to merge, or discard this patch.
main/inc/lib/classmanager.lib.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         $table_user = Database :: get_main_table(TABLE_MAIN_USER);
81 81
         $sql = "SELECT * FROM $table_class_user cu, $table_user u WHERE cu.class_id = '".$class_id."' AND cu.user_id = u.user_id";
82 82
         $res = Database::query($sql);
83
-        $users = array ();
83
+        $users = array();
84 84
         while ($user = Database::fetch_array($res, 'ASSOC')) {
85 85
             $users[] = $user;
86 86
         }
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
         $table_course_class = Database :: get_main_table(TABLE_MAIN_COURSE_CLASS);
118 118
         $courses = ClassManager :: get_courses($class_id);
119 119
         if (count($courses) != 0) {
120
-            $course_codes = array ();
120
+            $course_codes = array();
121 121
             foreach ($courses as $index => $course) {
122 122
                 $course_codes[] = $course['course_code'];
123 123
                 $sql = "SELECT DISTINCT user_id FROM $table_class_user t1, $table_course_class t2 WHERE t1.class_id=t2.class_id AND course_code = '".$course['course_code']."' AND user_id = $user_id AND t2.class_id<>'$class_id'";
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         $table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
143 143
         $sql = "SELECT * FROM $table_class_course cc, $table_course c WHERE cc.class_id = '".$class_id."' AND cc.course_code = c.code";
144 144
         $res = Database::query($sql);
145
-        $courses = array ();
145
+        $courses = array();
146 146
         while ($course = Database::fetch_array($res, 'ASSOC')) {
147 147
             $courses[] = $course;
148 148
         }
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
         $table_course_class = Database :: get_main_table(TABLE_MAIN_COURSE_CLASS);
218 218
         $sql = "SELECT cl.* FROM $table_class cl, $table_course_class cc WHERE cc.course_code = '".Database::escape_string($course_code)."' AND cc.class_id = cl.id";
219 219
         $res = Database::query($sql);
220
-        $classes = array ();
220
+        $classes = array();
221 221
         while ($class = Database::fetch_array($res, 'ASSOC')) {
222 222
             $classes[] = $class;
223 223
         }
Please login to merge, or discard this patch.
main/inc/lib/app_view.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
      * Constructor, init tool path for rendering
20 20
      * @param string  tool name (optional)
21 21
      */
22
-    public function __construct($toolname = '', $template_path=null)
22
+    public function __construct($toolname = '', $template_path = null)
23 23
     {
24 24
         if (!empty($toolname)) {
25 25
             if (isset($template_path)) {
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
             if (is_dir($path)) {
31 31
                 $this->tool_path = $path;
32 32
             } else {
33
-                throw new ViewException('View::__construct() $path directory does not exist ' . $path);
33
+                throw new ViewException('View::__construct() $path directory does not exist '.$path);
34 34
             }
35 35
         }
36 36
     }
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     public function set_data($data)
43 43
     {
44 44
         if (!is_array($data)) {
45
-            throw new ViewException('View::set_data() $data must to be an array, you have sent a' . gettype( $data ));
45
+            throw new ViewException('View::set_data() $data must to be an array, you have sent a'.gettype($data));
46 46
         }
47 47
         $this->data = $data;
48 48
     }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      * Set layout view sent from a controller
52 52
      * @param string layout view
53 53
      */
54
-    public function set_layout( $layout )
54
+    public function set_layout($layout)
55 55
     {
56 56
         $this->layout = $layout;
57 57
     }
Please login to merge, or discard this patch.
main/inc/lib/kses-0.2.2/kses.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
  * @return string
98 98
  */
99 99
 function kses($string, $allowed_html, $allowed_protocols =
100
-               array('http', 'https', 'ftp', 'news', 'nntp', 'telnet',
101
-                     'gopher', 'mailto'))
100
+                array('http', 'https', 'ftp', 'news', 'nntp', 'telnet',
101
+                        'gopher', 'mailto'))
102 102
 {
103 103
     $string = kses_no_null($string);
104 104
     $string = kses_js_entities($string);
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
     // No attributes are allowed for closing elements
219 219
 
220 220
     return kses_attr("$slash$elem", $attrlist, $allowed_html,
221
-                   $allowed_protocols);
221
+                    $allowed_protocols);
222 222
 }
223 223
 
224 224
 /**
@@ -261,11 +261,11 @@  discard block
 block discarded – undo
261 261
     foreach ($attrarr as $arreach)
262 262
     {
263 263
         if (!@isset($allowed_html[strtolower($element)]
264
-                              [strtolower($arreach['name'])]))
264
+                                [strtolower($arreach['name'])]))
265 265
             continue; // the attribute is not allowed
266 266
 
267 267
         $current = $allowed_html[strtolower($element)]
268
-                              [strtolower($arreach['name'])];
268
+                                [strtolower($arreach['name'])];
269 269
         if ($current == '')
270 270
             continue; // the attribute is not allowed
271 271
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
             $ok = true;
280 280
             foreach ($current as $currkey => $currval)
281 281
                 if (!kses_check_attr_val($arreach['value'], $arreach['vless'],
282
-                                 $currkey, $currval))
282
+                                    $currkey, $currval))
283 283
                 { $ok = false; break; }
284 284
 
285 285
             if ( strtolower($arreach['name']) == 'style' ) {
Please login to merge, or discard this patch.
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -35,47 +35,47 @@  discard block
 block discarded – undo
35 35
  */
36 36
 
37 37
 $kses_allowedentitynames = array(
38
-    'nbsp',    'iexcl',  'cent',    'pound',  'curren', 'yen',
39
-    'brvbar',  'sect',   'uml',     'copy',   'ordf',   'laquo',
40
-    'not',     'shy',    'reg',     'macr',   'deg',    'plusmn',
41
-    'acute',   'micro',  'para',    'middot', 'cedil',  'ordm',
42
-    'raquo',   'iquest', 'Agrave',  'Aacute', 'Acirc',  'Atilde',
43
-    'Auml',    'Aring',  'AElig',   'Ccedil', 'Egrave', 'Eacute',
44
-    'Ecirc',   'Euml',   'Igrave',  'Iacute', 'Icirc',  'Iuml',
45
-    'ETH',     'Ntilde', 'Ograve',  'Oacute', 'Ocirc',  'Otilde',
46
-    'Ouml',    'times',  'Oslash',  'Ugrave', 'Uacute', 'Ucirc',
47
-    'Uuml',    'Yacute', 'THORN',   'szlig',  'agrave', 'aacute',
48
-    'acirc',   'atilde', 'auml',    'aring',  'aelig',  'ccedil',
49
-    'egrave',  'eacute', 'ecirc',   'euml',   'igrave', 'iacute',
50
-    'icirc',   'iuml',   'eth',     'ntilde', 'ograve', 'oacute',
51
-    'ocirc',   'otilde', 'ouml',    'divide', 'oslash', 'ugrave',
52
-    'uacute',  'ucirc',  'uuml',    'yacute', 'thorn',  'yuml',
53
-    'quot',    'amp',    'lt',      'gt',     'apos',   'OElig',
54
-    'oelig',   'Scaron', 'scaron',  'Yuml',   'circ',   'tilde',
55
-    'ensp',    'emsp',   'thinsp',  'zwnj',   'zwj',    'lrm',
56
-    'rlm',     'ndash',  'mdash',   'lsquo',  'rsquo',  'sbquo',
57
-    'ldquo',   'rdquo',  'bdquo',   'dagger', 'Dagger', 'permil',
58
-    'lsaquo',  'rsaquo', 'euro',    'fnof',   'Alpha',  'Beta',
59
-    'Gamma',   'Delta',  'Epsilon', 'Zeta',   'Eta',    'Theta',
60
-    'Iota',    'Kappa',  'Lambda',  'Mu',     'Nu',     'Xi',
61
-    'Omicron', 'Pi',     'Rho',     'Sigma',  'Tau',    'Upsilon',
62
-    'Phi',     'Chi',    'Psi',     'Omega',  'alpha',  'beta',
63
-    'gamma',   'delta',  'epsilon', 'zeta',   'eta',    'theta',
64
-    'iota',    'kappa',  'lambda',  'mu',     'nu',     'xi',
65
-    'omicron', 'pi',     'rho',     'sigmaf', 'sigma',  'tau',
66
-    'upsilon', 'phi',    'chi',     'psi',    'omega',  'thetasym',
67
-    'upsih',   'piv',    'bull',    'hellip', 'prime',  'Prime',
68
-    'oline',   'frasl',  'weierp',  'image',  'real',   'trade',
69
-    'alefsym', 'larr',   'uarr',    'rarr',   'darr',   'harr',
70
-    'crarr',   'lArr',   'uArr',    'rArr',   'dArr',   'hArr',
71
-    'forall',  'part',   'exist',   'empty',  'nabla',  'isin',
72
-    'notin',   'ni',     'prod',    'sum',    'minus',  'lowast',
73
-    'radic',   'prop',   'infin',   'ang',    'and',    'or',
74
-    'cap',     'cup',    'int',     'sim',    'cong',   'asymp',
75
-    'ne',      'equiv',  'le',      'ge',     'sub',    'sup',
76
-    'nsub',    'sube',   'supe',    'oplus',  'otimes', 'perp',
77
-    'sdot',    'lceil',  'rceil',   'lfloor', 'rfloor', 'lang',
78
-    'rang',    'loz',    'spades',  'clubs',  'hearts', 'diams',
38
+    'nbsp', 'iexcl', 'cent', 'pound', 'curren', 'yen',
39
+    'brvbar', 'sect', 'uml', 'copy', 'ordf', 'laquo',
40
+    'not', 'shy', 'reg', 'macr', 'deg', 'plusmn',
41
+    'acute', 'micro', 'para', 'middot', 'cedil', 'ordm',
42
+    'raquo', 'iquest', 'Agrave', 'Aacute', 'Acirc', 'Atilde',
43
+    'Auml', 'Aring', 'AElig', 'Ccedil', 'Egrave', 'Eacute',
44
+    'Ecirc', 'Euml', 'Igrave', 'Iacute', 'Icirc', 'Iuml',
45
+    'ETH', 'Ntilde', 'Ograve', 'Oacute', 'Ocirc', 'Otilde',
46
+    'Ouml', 'times', 'Oslash', 'Ugrave', 'Uacute', 'Ucirc',
47
+    'Uuml', 'Yacute', 'THORN', 'szlig', 'agrave', 'aacute',
48
+    'acirc', 'atilde', 'auml', 'aring', 'aelig', 'ccedil',
49
+    'egrave', 'eacute', 'ecirc', 'euml', 'igrave', 'iacute',
50
+    'icirc', 'iuml', 'eth', 'ntilde', 'ograve', 'oacute',
51
+    'ocirc', 'otilde', 'ouml', 'divide', 'oslash', 'ugrave',
52
+    'uacute', 'ucirc', 'uuml', 'yacute', 'thorn', 'yuml',
53
+    'quot', 'amp', 'lt', 'gt', 'apos', 'OElig',
54
+    'oelig', 'Scaron', 'scaron', 'Yuml', 'circ', 'tilde',
55
+    'ensp', 'emsp', 'thinsp', 'zwnj', 'zwj', 'lrm',
56
+    'rlm', 'ndash', 'mdash', 'lsquo', 'rsquo', 'sbquo',
57
+    'ldquo', 'rdquo', 'bdquo', 'dagger', 'Dagger', 'permil',
58
+    'lsaquo', 'rsaquo', 'euro', 'fnof', 'Alpha', 'Beta',
59
+    'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta', 'Theta',
60
+    'Iota', 'Kappa', 'Lambda', 'Mu', 'Nu', 'Xi',
61
+    'Omicron', 'Pi', 'Rho', 'Sigma', 'Tau', 'Upsilon',
62
+    'Phi', 'Chi', 'Psi', 'Omega', 'alpha', 'beta',
63
+    'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta',
64
+    'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi',
65
+    'omicron', 'pi', 'rho', 'sigmaf', 'sigma', 'tau',
66
+    'upsilon', 'phi', 'chi', 'psi', 'omega', 'thetasym',
67
+    'upsih', 'piv', 'bull', 'hellip', 'prime', 'Prime',
68
+    'oline', 'frasl', 'weierp', 'image', 'real', 'trade',
69
+    'alefsym', 'larr', 'uarr', 'rarr', 'darr', 'harr',
70
+    'crarr', 'lArr', 'uArr', 'rArr', 'dArr', 'hArr',
71
+    'forall', 'part', 'exist', 'empty', 'nabla', 'isin',
72
+    'notin', 'ni', 'prod', 'sum', 'minus', 'lowast',
73
+    'radic', 'prop', 'infin', 'ang', 'and', 'or',
74
+    'cap', 'cup', 'int', 'sim', 'cong', 'asymp',
75
+    'ne', 'equiv', 'le', 'ge', 'sub', 'sup',
76
+    'nsub', 'sube', 'supe', 'oplus', 'otimes', 'perp',
77
+    'sdot', 'lceil', 'rceil', 'lfloor', 'rfloor', 'lang',
78
+    'rang', 'loz', 'spades', 'clubs', 'hearts', 'diams',
79 79
 );
80 80
 
81 81
 /**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     global $pass_allowed_html, $pass_allowed_protocols;
146 146
     $pass_allowed_html = $allowed_html;
147 147
     $pass_allowed_protocols = $allowed_protocols;
148
-    return preg_replace_callback( '%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%', '_kses_split_callback', $string );
148
+    return preg_replace_callback('%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%', '_kses_split_callback', $string);
149 149
 }
150 150
 
151 151
 /**
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
  *
154 154
  * @access private
155 155
  */
156
-function _kses_split_callback( $match )
156
+function _kses_split_callback($match)
157 157
 {
158 158
     global $pass_allowed_html, $pass_allowed_protocols;
159
-    return kses_split2( $match[1], $pass_allowed_html, $pass_allowed_protocols );
159
+    return kses_split2($match[1], $pass_allowed_html, $pass_allowed_protocols);
160 160
 }
161 161
 
162 162
 /**
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
 
190 190
     if (preg_match('%^<!--(.*?)(-->)?$%', $string, $matches)) {
191 191
         $string = str_replace(array('<!--', '-->'), '', $matches[1]);
192
-        while ( $string != $newstring = kses($string, $allowed_html, $allowed_protocols) )
192
+        while ($string != $newstring = kses($string, $allowed_html, $allowed_protocols))
193 193
             $string = $newstring;
194
-        if ( $string == '' )
194
+        if ($string == '')
195 195
             return '';
196 196
         // prevent multiple dashes in comments
197 197
         $string = preg_replace('/--+/', '-', $string);
@@ -282,12 +282,12 @@  discard block
 block discarded – undo
282 282
                                  $currkey, $currval))
283 283
                 { $ok = false; break; }
284 284
 
285
-            if ( strtolower($arreach['name']) == 'style' ) {
285
+            if (strtolower($arreach['name']) == 'style') {
286 286
                 $orig_value = $arreach['value'];
287 287
 
288 288
                 $value = kses_safecss_filter_attr($orig_value);
289 289
 
290
-                if ( empty($value) )
290
+                if (empty($value))
291 291
                     continue;
292 292
 
293 293
                 $arreach['value'] = $value;
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
                 if (preg_match('/^\s+/', $attr)) // valueless
362 362
                 {
363 363
                     $working = 1; $mode = 0;
364
-                    if(FALSE === array_key_exists($attrname, $attrarr)) {
365
-                        $attrarr[$attrname] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y');
364
+                    if (FALSE === array_key_exists($attrname, $attrarr)) {
365
+                        $attrarr[$attrname] = array('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y');
366 366
                     }
367 367
                     $attr = preg_replace('/^\s+/', '', $attr);
368 368
                 }
@@ -379,12 +379,12 @@  discard block
 block discarded – undo
379 379
                         $thisval = $match[1];
380 380
                     } else {
381 381
                         $thisval = $match[1];
382
-                        if ( in_array(strtolower($attrname), $uris) )
382
+                        if (in_array(strtolower($attrname), $uris))
383 383
                             $thisval = kses_bad_protocol($thisval, $allowed_protocols);
384 384
                     }
385 385
 
386
-                    if(FALSE === array_key_exists($attrname, $attrarr)) {
387
-                        $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n');
386
+                    if (FALSE === array_key_exists($attrname, $attrarr)) {
387
+                        $attrarr[$attrname] = array('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n');
388 388
                     }
389 389
                     $working = 1; $mode = 0;
390 390
                     $attr = preg_replace('/^"[^"]*"(\s+|$)/', '', $attr);
@@ -395,11 +395,11 @@  discard block
 block discarded – undo
395 395
                     // 'value'
396 396
                 {
397 397
                     $thisval = $match[1];
398
-                    if ( in_array(strtolower($attrname), $uris) )
398
+                    if (in_array(strtolower($attrname), $uris))
399 399
                         $thisval = kses_bad_protocol($thisval, $allowed_protocols);
400 400
 
401
-                    if(FALSE === array_key_exists($attrname, $attrarr)) {
402
-                        $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname='$thisval'", 'vless' => 'n');
401
+                    if (FALSE === array_key_exists($attrname, $attrarr)) {
402
+                        $attrarr[$attrname] = array('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname='$thisval'", 'vless' => 'n');
403 403
                     }
404 404
                     $working = 1; $mode = 0;
405 405
                     $attr = preg_replace("/^'[^']*'(\s+|$)/", '', $attr);
@@ -410,11 +410,11 @@  discard block
 block discarded – undo
410 410
                     // value
411 411
                 {
412 412
                     $thisval = $match[1];
413
-                    if ( in_array(strtolower($attrname), $uris) )
413
+                    if (in_array(strtolower($attrname), $uris))
414 414
                         $thisval = kses_bad_protocol($thisval, $allowed_protocols);
415 415
 
416
-                    if(FALSE === array_key_exists($attrname, $attrarr)) {
417
-                        $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n');
416
+                    if (FALSE === array_key_exists($attrname, $attrarr)) {
417
+                        $attrarr[$attrname] = array('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n');
418 418
                     }
419 419
                     // We add quotes to conform to W3C's HTML spec.
420 420
                     $working = 1; $mode = 0;
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
     if ($mode == 1 && FALSE === array_key_exists($attrname, $attrarr))
435 435
         // special case, for when the attribute list ends with a valueless
436 436
         // attribute like "selected"
437
-        $attrarr[$attrname] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y');
437
+        $attrarr[$attrname] = array('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y');
438 438
 
439 439
     return $attrarr;
440 440
 }
@@ -579,12 +579,12 @@  discard block
 block discarded – undo
579 579
 {
580 580
     $outarray = array();
581 581
 
582
-    foreach ( (array) $inarray as $inkey => $inval)
582
+    foreach ((array) $inarray as $inkey => $inval)
583 583
     {
584 584
         $outkey = strtolower($inkey);
585 585
         $outarray[$outkey] = array();
586 586
 
587
-        foreach ( (array) $inval as $inkey2 => $inval2)
587
+        foreach ((array) $inval as $inkey2 => $inval2)
588 588
         {
589 589
             $outkey2 = strtolower($inkey2);
590 590
             $outarray[$outkey][$outkey2] = $inval2;
@@ -632,9 +632,9 @@  discard block
 block discarded – undo
632 632
 function kses_bad_protocol_once($string, $allowed_protocols)
633 633
 {
634 634
     $string2 = preg_split('/:|&#0*58;|&#x0*3a;/i', $string, 2);
635
-    if(isset($string2[1]) && !preg_match('%/\?%',$string2[0]))
635
+    if (isset($string2[1]) && !preg_match('%/\?%', $string2[0]))
636 636
     {
637
-        $string = kses_bad_protocol_once2($string2[0],$allowed_protocols).trim($string2[1]);
637
+        $string = kses_bad_protocol_once2($string2[0], $allowed_protocols).trim($string2[1]);
638 638
     }
639 639
     return $string;
640 640
 }
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
     $string2 = strtolower($string2);
661 661
 
662 662
     $allowed = false;
663
-    foreach ( (array) $allowed_protocols as $one_protocol)
663
+    foreach ((array) $allowed_protocols as $one_protocol)
664 664
         if (strtolower($one_protocol) == $string2)
665 665
         {
666 666
             $allowed = true;
@@ -711,11 +711,11 @@  discard block
 block discarded – undo
711 711
 function kses_named_entities($matches) {
712 712
     global $kses_allowedentitynames;
713 713
 
714
-    if ( empty($matches[1]) )
714
+    if (empty($matches[1]))
715 715
         return '';
716 716
 
717 717
     $i = $matches[1];
718
-    return ( ( ! in_array($i, $kses_allowedentitynames) ) ? "&amp;$i;" : "&$i;" );
718
+    return ((!in_array($i, $kses_allowedentitynames)) ? "&amp;$i;" : "&$i;");
719 719
 }
720 720
 
721 721
 /**
@@ -730,12 +730,12 @@  discard block
 block discarded – undo
730 730
  * @return string Correctly encoded entity
731 731
  */
732 732
 function kses_normalize_entities2($matches) {
733
-    if ( empty($matches[1]) )
733
+    if (empty($matches[1]))
734 734
         return '';
735 735
 
736 736
     $i = $matches[1];
737 737
     if (kses_valid_unicode($i)) {
738
-        $i = str_pad(ltrim($i,'0'), 3, '0', STR_PAD_LEFT);
738
+        $i = str_pad(ltrim($i, '0'), 3, '0', STR_PAD_LEFT);
739 739
         $i = "&#$i;";
740 740
     } else {
741 741
         $i = "&amp;#$i;";
@@ -756,11 +756,11 @@  discard block
 block discarded – undo
756 756
  * @return string Correctly encoded entity
757 757
  */
758 758
 function kses_normalize_entities3($matches) {
759
-    if ( empty($matches[1]) )
759
+    if (empty($matches[1]))
760 760
         return '';
761 761
 
762 762
     $hexchars = $matches[1];
763
-    return ( ( ! kses_valid_unicode(hexdec($hexchars)) ) ? "&amp;#x$hexchars;" : '&#x'.ltrim($hexchars,'0').';' );
763
+    return ((!kses_valid_unicode(hexdec($hexchars))) ? "&amp;#x$hexchars;" : '&#x'.ltrim($hexchars, '0').';');
764 764
 }
765 765
 
766 766
 /**
@@ -770,10 +770,10 @@  discard block
 block discarded – undo
770 770
  * @return bool true if the value was a valid Unicode number
771 771
  */
772 772
 function kses_valid_unicode($i) {
773
-    return ( $i == 0x9 || $i == 0xa || $i == 0xd ||
773
+    return ($i == 0x9 || $i == 0xa || $i == 0xd ||
774 774
             ($i >= 0x20 && $i <= 0xd7ff) ||
775 775
             ($i >= 0xe000 && $i <= 0xfffd) ||
776
-            ($i >= 0x10000 && $i <= 0x10ffff) );
776
+            ($i >= 0x10000 && $i <= 0x10ffff));
777 777
 }
778 778
 
779 779
 /**
@@ -800,8 +800,8 @@  discard block
 block discarded – undo
800 800
  * @param array $match preg match
801 801
  * @return string
802 802
  */
803
-function _kses_decode_entities_chr( $match ) {
804
-    return chr( $match[1] );
803
+function _kses_decode_entities_chr($match) {
804
+    return chr($match[1]);
805 805
 }
806 806
 
807 807
 /**
@@ -810,24 +810,24 @@  discard block
 block discarded – undo
810 810
  * @param array $match preg match
811 811
  * @return string
812 812
  */
813
-function _kses_decode_entities_chr_hexdec( $match ) {
814
-    return chr( hexdec( $match[1] ) );
813
+function _kses_decode_entities_chr_hexdec($match) {
814
+    return chr(hexdec($match[1]));
815 815
 }
816 816
 
817 817
 /**
818 818
  * Inline CSS filter
819 819
  *
820 820
  */
821
-function kses_safecss_filter_attr( $css ) {
821
+function kses_safecss_filter_attr($css) {
822 822
 
823 823
     $css = kses_no_null($css);
824
-    $css = str_replace(array("\n","\r","\t"), '', $css);
824
+    $css = str_replace(array("\n", "\r", "\t"), '', $css);
825 825
 
826
-    if ( preg_match( '%[\\(&=}]|/\*%', $css ) ) // remove any inline css containing \ ( & } = or comments
826
+    if (preg_match('%[\\(&=}]|/\*%', $css)) // remove any inline css containing \ ( & } = or comments
827 827
         return '';
828 828
 
829
-    $css_array = explode( ';', trim( $css ) );
830
-    $allowed_attr = array( 'text-align', 'margin', 'color', 'float',
829
+    $css_array = explode(';', trim($css));
830
+    $allowed_attr = array('text-align', 'margin', 'color', 'float',
831 831
         'border', 'background', 'background-color', 'border-bottom', 'border-bottom-color',
832 832
         'border-bottom-style', 'border-bottom-width', 'border-collapse', 'border-color', 'border-left',
833 833
         'border-left-color', 'border-left-style', 'border-left-width', 'border-right', 'border-right-color',
@@ -837,26 +837,26 @@  discard block
 block discarded – undo
837 837
         'font-variant', 'font-weight', 'height', 'letter-spacing', 'line-height', 'margin-bottom',
838 838
         'margin-left', 'margin-right', 'margin-top', 'overflow', 'padding', 'padding-bottom',
839 839
         'padding-left', 'padding-right', 'padding-top', 'text-decoration', 'text-indent', 'vertical-align',
840
-        'width' );
840
+        'width');
841 841
 
842
-    if ( empty($allowed_attr) )
842
+    if (empty($allowed_attr))
843 843
         return $css;
844 844
 
845 845
     $css = '';
846
-    foreach ( $css_array as $css_item ) {
847
-        if ( $css_item == '' )
846
+    foreach ($css_array as $css_item) {
847
+        if ($css_item == '')
848 848
             continue;
849
-        $css_item = trim( $css_item );
849
+        $css_item = trim($css_item);
850 850
         $found = false;
851
-        if ( strpos( $css_item, ':' ) === false ) {
851
+        if (strpos($css_item, ':') === false) {
852 852
             $found = true;
853 853
         } else {
854
-            $parts = split( ':', $css_item );
855
-            if ( in_array( strtolower( trim( $parts[0] ) ), $allowed_attr ) )
854
+            $parts = split(':', $css_item);
855
+            if (in_array(strtolower(trim($parts[0])), $allowed_attr))
856 856
                 $found = true;
857 857
         }
858
-        if ( $found ) {
859
-            if( $css != '' )
858
+        if ($found) {
859
+            if ($css != '')
860 860
                 $css .= ';';
861 861
             $css .= $css_item;
862 862
         }
Please login to merge, or discard this patch.
Braces   +135 added lines, -84 removed lines patch added patch discarded remove patch
@@ -183,16 +183,19 @@  discard block
 block discarded – undo
183 183
 {
184 184
     $string = kses_stripslashes($string);
185 185
 
186
-    if (substr($string, 0, 1) != '<')
187
-        return '&gt;';
186
+    if (substr($string, 0, 1) != '<') {
187
+            return '&gt;';
188
+    }
188 189
     // It matched a ">" character
189 190
 
190 191
     if (preg_match('%^<!--(.*?)(-->)?$%', $string, $matches)) {
191 192
         $string = str_replace(array('<!--', '-->'), '', $matches[1]);
192
-        while ( $string != $newstring = kses($string, $allowed_html, $allowed_protocols) )
193
-            $string = $newstring;
194
-        if ( $string == '' )
195
-            return '';
193
+        while ( $string != $newstring = kses($string, $allowed_html, $allowed_protocols) ) {
194
+                    $string = $newstring;
195
+        }
196
+        if ( $string == '' ) {
197
+                    return '';
198
+        }
196 199
         // prevent multiple dashes in comments
197 200
         $string = preg_replace('/--+/', '-', $string);
198 201
         // prevent three dashes closing a comment
@@ -201,20 +204,23 @@  discard block
 block discarded – undo
201 204
     }
202 205
     // Allow HTML comments
203 206
 
204
-    if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches))
205
-        return '';
207
+    if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches)) {
208
+            return '';
209
+    }
206 210
     // It's seriously malformed
207 211
 
208 212
     $slash = trim($matches[1]);
209 213
     $elem = $matches[2];
210 214
     $attrlist = $matches[3];
211 215
 
212
-    if (!@isset($allowed_html[strtolower($elem)]))
213
-        return '';
216
+    if (!@isset($allowed_html[strtolower($elem)])) {
217
+            return '';
218
+    }
214 219
     // They are using a not allowed HTML element
215 220
 
216
-    if ($slash != '')
217
-        return "<$slash$elem>";
221
+    if ($slash != '') {
222
+            return "<$slash$elem>";
223
+    }
218 224
     // No attributes are allowed for closing elements
219 225
 
220 226
     return kses_attr("$slash$elem", $attrlist, $allowed_html,
@@ -241,13 +247,15 @@  discard block
 block discarded – undo
241 247
     // Is there a closing XHTML slash at the end of the attributes?
242 248
 
243 249
     $xhtml_slash = '';
244
-    if (preg_match('%\s*/\s*$%', $attr))
245
-        $xhtml_slash = ' /';
250
+    if (preg_match('%\s*/\s*$%', $attr)) {
251
+            $xhtml_slash = ' /';
252
+    }
246 253
 
247 254
     // Are any attributes allowed at all for this element?
248 255
 
249
-    if (@count($allowed_html[strtolower($element)]) == 0)
250
-        return "<$element$xhtml_slash>";
256
+    if (@count($allowed_html[strtolower($element)]) == 0) {
257
+            return "<$element$xhtml_slash>";
258
+    }
251 259
 
252 260
     // Split it
253 261
 
@@ -261,42 +269,52 @@  discard block
 block discarded – undo
261 269
     foreach ($attrarr as $arreach)
262 270
     {
263 271
         if (!@isset($allowed_html[strtolower($element)]
264
-                              [strtolower($arreach['name'])]))
265
-            continue; // the attribute is not allowed
272
+                              [strtolower($arreach['name'])])) {
273
+                    continue;
274
+        }
275
+        // the attribute is not allowed
266 276
 
267 277
         $current = $allowed_html[strtolower($element)]
268 278
                               [strtolower($arreach['name'])];
269
-        if ($current == '')
270
-            continue; // the attribute is not allowed
279
+        if ($current == '') {
280
+                    continue;
281
+        }
282
+        // the attribute is not allowed
271 283
 
272
-        if (!is_array($current))
273
-            $attr2 .= ' '.$arreach['whole'];
284
+        if (!is_array($current)) {
285
+                    $attr2 .= ' '.$arreach['whole'];
286
+        }
274 287
         // there are no checks
275 288
 
276 289
         else
277 290
         {
278 291
             // there are some checks
279 292
             $ok = true;
280
-            foreach ($current as $currkey => $currval)
281
-                if (!kses_check_attr_val($arreach['value'], $arreach['vless'],
293
+            foreach ($current as $currkey => $currval) {
294
+                            if (!kses_check_attr_val($arreach['value'], $arreach['vless'],
282 295
                                  $currkey, $currval))
283
-                { $ok = false; break; }
296
+                { $ok = false;
297
+            }
298
+            break; }
284 299
 
285 300
             if ( strtolower($arreach['name']) == 'style' ) {
286 301
                 $orig_value = $arreach['value'];
287 302
 
288 303
                 $value = kses_safecss_filter_attr($orig_value);
289 304
 
290
-                if ( empty($value) )
291
-                    continue;
305
+                if ( empty($value) ) {
306
+                                    continue;
307
+                }
292 308
 
293 309
                 $arreach['value'] = $value;
294 310
 
295 311
                 $arreach['whole'] = str_replace($orig_value, $value, $arreach['whole']);
296 312
             }
297 313
 
298
-            if ($ok)
299
-                $attr2 .= ' '.$arreach['whole']; // it passed them
314
+            if ($ok) {
315
+                            $attr2 .= ' '.$arreach['whole'];
316
+            }
317
+            // it passed them
300 318
         } // if !is_array($current)
301 319
     } // foreach
302 320
 
@@ -351,16 +369,22 @@  discard block
 block discarded – undo
351 369
 
352 370
             case 1: // equals sign or valueless ("selected")
353 371
 
354
-                if (preg_match('/^\s*=\s*/', $attr)) // equals sign
372
+                if (preg_match('/^\s*=\s*/', $attr)) {
373
+                    // equals sign
355 374
                 {
356
-                    $working = 1; $mode = 2;
375
+                    $working = 1;
376
+                }
377
+                $mode = 2;
357 378
                     $attr = preg_replace('/^\s*=\s*/', '', $attr);
358 379
                     break;
359 380
                 }
360 381
 
361
-                if (preg_match('/^\s+/', $attr)) // valueless
382
+                if (preg_match('/^\s+/', $attr)) {
383
+                    // valueless
362 384
                 {
363
-                    $working = 1; $mode = 0;
385
+                    $working = 1;
386
+                }
387
+                $mode = 0;
364 388
                     if(FALSE === array_key_exists($attrname, $attrarr)) {
365 389
                         $attrarr[$attrname] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y');
366 390
                     }
@@ -371,16 +395,18 @@  discard block
 block discarded – undo
371 395
 
372 396
             case 2: // attribute value, a URL after href= for instance
373 397
 
374
-                if (preg_match('%^"([^"]*)"(\s+|/?$)%', $attr, $match))
375
-                    // "value"
398
+                if (preg_match('%^"([^"]*)"(\s+|/?$)%', $attr, $match)) {
399
+                                    // "value"
376 400
                 {
377 401
                     // MDL-2684 - kses stripping CSS styles that it thinks look like protocols
378 402
                     if ($attrname == 'style') {
379 403
                         $thisval = $match[1];
404
+                }
380 405
                     } else {
381 406
                         $thisval = $match[1];
382
-                        if ( in_array(strtolower($attrname), $uris) )
383
-                            $thisval = kses_bad_protocol($thisval, $allowed_protocols);
407
+                        if ( in_array(strtolower($attrname), $uris) ) {
408
+                                                    $thisval = kses_bad_protocol($thisval, $allowed_protocols);
409
+                        }
384 410
                     }
385 411
 
386 412
                     if(FALSE === array_key_exists($attrname, $attrarr)) {
@@ -391,12 +417,14 @@  discard block
 block discarded – undo
391 417
                     break;
392 418
                 }
393 419
 
394
-                if (preg_match("%^'([^']*)'(\s+|/?$)%", $attr, $match))
395
-                    // 'value'
420
+                if (preg_match("%^'([^']*)'(\s+|/?$)%", $attr, $match)) {
421
+                                    // 'value'
396 422
                 {
397 423
                     $thisval = $match[1];
398
-                    if ( in_array(strtolower($attrname), $uris) )
399
-                        $thisval = kses_bad_protocol($thisval, $allowed_protocols);
424
+                }
425
+                    if ( in_array(strtolower($attrname), $uris) ) {
426
+                                            $thisval = kses_bad_protocol($thisval, $allowed_protocols);
427
+                    }
400 428
 
401 429
                     if(FALSE === array_key_exists($attrname, $attrarr)) {
402 430
                         $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname='$thisval'", 'vless' => 'n');
@@ -406,12 +434,14 @@  discard block
 block discarded – undo
406 434
                     break;
407 435
                 }
408 436
 
409
-                if (preg_match("%^([^\s\"']+)(\s+|/?$)%", $attr, $match))
410
-                    // value
437
+                if (preg_match("%^([^\s\"']+)(\s+|/?$)%", $attr, $match)) {
438
+                                    // value
411 439
                 {
412 440
                     $thisval = $match[1];
413
-                    if ( in_array(strtolower($attrname), $uris) )
414
-                        $thisval = kses_bad_protocol($thisval, $allowed_protocols);
441
+                }
442
+                    if ( in_array(strtolower($attrname), $uris) ) {
443
+                                            $thisval = kses_bad_protocol($thisval, $allowed_protocols);
444
+                    }
415 445
 
416 446
                     if(FALSE === array_key_exists($attrname, $attrarr)) {
417 447
                         $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n');
@@ -424,17 +454,20 @@  discard block
 block discarded – undo
424 454
                 break;
425 455
         } // switch
426 456
 
427
-        if ($working == 0) // not well formed, remove and try again
457
+        if ($working == 0) {
458
+            // not well formed, remove and try again
428 459
         {
429 460
             $attr = kses_html_error($attr);
461
+        }
430 462
             $mode = 0;
431 463
         }
432 464
     } // while
433 465
 
434
-    if ($mode == 1 && FALSE === array_key_exists($attrname, $attrarr))
435
-        // special case, for when the attribute list ends with a valueless
466
+    if ($mode == 1 && FALSE === array_key_exists($attrname, $attrarr)) {
467
+            // special case, for when the attribute list ends with a valueless
436 468
         // attribute like "selected"
437 469
         $attrarr[$attrname] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y');
470
+    }
438 471
 
439 472
     return $attrarr;
440 473
 }
@@ -462,16 +495,18 @@  discard block
 block discarded – undo
462 495
             // greater than the given value. This can be used to avoid Buffer Overflows
463 496
             // in WWW clients and various Internet servers.
464 497
 
465
-            if (strlen($value) > $checkvalue)
466
-                $ok = false;
498
+            if (strlen($value) > $checkvalue) {
499
+                            $ok = false;
500
+            }
467 501
             break;
468 502
 
469 503
         case 'minlen':
470 504
             // The minlen check makes sure that the attribute value has a length not
471 505
             // smaller than the given value.
472 506
 
473
-            if (strlen($value) < $checkvalue)
474
-                $ok = false;
507
+            if (strlen($value) < $checkvalue) {
508
+                            $ok = false;
509
+            }
475 510
             break;
476 511
 
477 512
         case 'maxval':
@@ -481,20 +516,24 @@  discard block
 block discarded – undo
481 516
             // value is not greater than the given value.
482 517
             // This check can be used to avoid Denial of Service attacks.
483 518
 
484
-            if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value))
485
-                $ok = false;
486
-            if ($value > $checkvalue)
487
-                $ok = false;
519
+            if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value)) {
520
+                            $ok = false;
521
+            }
522
+            if ($value > $checkvalue) {
523
+                            $ok = false;
524
+            }
488 525
             break;
489 526
 
490 527
         case 'minval':
491 528
             // The minval check checks that the attribute value is a positive integer,
492 529
             // and that it is not smaller than the given value.
493 530
 
494
-            if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value))
495
-                $ok = false;
496
-            if ($value < $checkvalue)
497
-                $ok = false;
531
+            if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value)) {
532
+                            $ok = false;
533
+            }
534
+            if ($value < $checkvalue) {
535
+                            $ok = false;
536
+            }
498 537
             break;
499 538
 
500 539
         case 'valueless':
@@ -503,8 +542,9 @@  discard block
 block discarded – undo
503 542
             // is a "y" or a "Y", the attribute must not have a value.
504 543
             // If the given value is an "n" or an "N", the attribute must have one.
505 544
 
506
-            if (strtolower($checkvalue) != $vless)
507
-                $ok = false;
545
+            if (strtolower($checkvalue) != $vless) {
546
+                            $ok = false;
547
+            }
508 548
             break;
509 549
     } // switch
510 550
 
@@ -660,18 +700,20 @@  discard block
 block discarded – undo
660 700
     $string2 = strtolower($string2);
661 701
 
662 702
     $allowed = false;
663
-    foreach ( (array) $allowed_protocols as $one_protocol)
664
-        if (strtolower($one_protocol) == $string2)
703
+    foreach ( (array) $allowed_protocols as $one_protocol) {
704
+            if (strtolower($one_protocol) == $string2)
665 705
         {
666 706
             $allowed = true;
707
+    }
667 708
             break;
668 709
         }
669 710
 
670
-    if ($allowed)
671
-        return "$string2:";
672
-    else
673
-        return '';
674
-}
711
+    if ($allowed) {
712
+            return "$string2:";
713
+    } else {
714
+            return '';
715
+    }
716
+    }
675 717
 
676 718
 /**
677 719
  * Converts and fixes HTML entities.
@@ -711,8 +753,9 @@  discard block
 block discarded – undo
711 753
 function kses_named_entities($matches) {
712 754
     global $kses_allowedentitynames;
713 755
 
714
-    if ( empty($matches[1]) )
715
-        return '';
756
+    if ( empty($matches[1]) ) {
757
+            return '';
758
+    }
716 759
 
717 760
     $i = $matches[1];
718 761
     return ( ( ! in_array($i, $kses_allowedentitynames) ) ? "&amp;$i;" : "&$i;" );
@@ -730,8 +773,9 @@  discard block
 block discarded – undo
730 773
  * @return string Correctly encoded entity
731 774
  */
732 775
 function kses_normalize_entities2($matches) {
733
-    if ( empty($matches[1]) )
734
-        return '';
776
+    if ( empty($matches[1]) ) {
777
+            return '';
778
+    }
735 779
 
736 780
     $i = $matches[1];
737 781
     if (kses_valid_unicode($i)) {
@@ -756,8 +800,9 @@  discard block
 block discarded – undo
756 800
  * @return string Correctly encoded entity
757 801
  */
758 802
 function kses_normalize_entities3($matches) {
759
-    if ( empty($matches[1]) )
760
-        return '';
803
+    if ( empty($matches[1]) ) {
804
+            return '';
805
+    }
761 806
 
762 807
     $hexchars = $matches[1];
763 808
     return ( ( ! kses_valid_unicode(hexdec($hexchars)) ) ? "&amp;#x$hexchars;" : '&#x'.ltrim($hexchars,'0').';' );
@@ -823,8 +868,10 @@  discard block
 block discarded – undo
823 868
     $css = kses_no_null($css);
824 869
     $css = str_replace(array("\n","\r","\t"), '', $css);
825 870
 
826
-    if ( preg_match( '%[\\(&=}]|/\*%', $css ) ) // remove any inline css containing \ ( & } = or comments
871
+    if ( preg_match( '%[\\(&=}]|/\*%', $css ) ) {
872
+        // remove any inline css containing \ ( & } = or comments
827 873
         return '';
874
+    }
828 875
 
829 876
     $css_array = explode( ';', trim( $css ) );
830 877
     $allowed_attr = array( 'text-align', 'margin', 'color', 'float',
@@ -839,25 +886,29 @@  discard block
 block discarded – undo
839 886
         'padding-left', 'padding-right', 'padding-top', 'text-decoration', 'text-indent', 'vertical-align',
840 887
         'width' );
841 888
 
842
-    if ( empty($allowed_attr) )
843
-        return $css;
889
+    if ( empty($allowed_attr) ) {
890
+            return $css;
891
+    }
844 892
 
845 893
     $css = '';
846 894
     foreach ( $css_array as $css_item ) {
847
-        if ( $css_item == '' )
848
-            continue;
895
+        if ( $css_item == '' ) {
896
+                    continue;
897
+        }
849 898
         $css_item = trim( $css_item );
850 899
         $found = false;
851 900
         if ( strpos( $css_item, ':' ) === false ) {
852 901
             $found = true;
853 902
         } else {
854 903
             $parts = split( ':', $css_item );
855
-            if ( in_array( strtolower( trim( $parts[0] ) ), $allowed_attr ) )
856
-                $found = true;
904
+            if ( in_array( strtolower( trim( $parts[0] ) ), $allowed_attr ) ) {
905
+                            $found = true;
906
+            }
857 907
         }
858 908
         if ( $found ) {
859
-            if( $css != '' )
860
-                $css .= ';';
909
+            if( $css != '' ) {
910
+                            $css .= ';';
911
+            }
861 912
             $css .= $css_item;
862 913
         }
863 914
     }
Please login to merge, or discard this patch.
main/inc/lib/fileDisplay.lib.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
     $last_modified = 0;
212 212
     $return = 0;
213 213
     if (is_dir($dir)) {
214
-        while(($entry = $dir->read()) !== false)
214
+        while (($entry = $dir->read()) !== false)
215 215
         {
216 216
             if ($entry != '.' && $entry != '..')
217 217
                 continue;
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
         'props.session_id'
285 285
     );
286 286
 
287
-    $visibility_rule = ' props.visibility ' . ($can_see_invisible ? '<> 2' : '= 1');
287
+    $visibility_rule = ' props.visibility '.($can_see_invisible ? '<> 2' : '= 1');
288 288
 
289 289
     $sql = "SELECT SUM(table1.size) FROM (
290 290
                 SELECT size
Please login to merge, or discard this patch.
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -213,16 +213,19 @@
 block discarded – undo
213 213
     if (is_dir($dir)) {
214 214
         while(($entry = $dir->read()) !== false)
215 215
         {
216
-            if ($entry != '.' && $entry != '..')
217
-                continue;
216
+            if ($entry != '.' && $entry != '..') {
217
+                            continue;
218
+            }
218 219
 
219
-            if (!is_dir($dir_name.'/'.$entry))
220
-                $current_modified = filemtime($dir_name.'/'.$entry);
221
-            elseif ($do_recursive)
222
-                $current_modified = recent_modified_file_time($dir_name.'/'.$entry, true);
220
+            if (!is_dir($dir_name.'/'.$entry)) {
221
+                            $current_modified = filemtime($dir_name.'/'.$entry);
222
+            } elseif ($do_recursive) {
223
+                            $current_modified = recent_modified_file_time($dir_name.'/'.$entry, true);
224
+            }
223 225
 
224
-            if ($current_modified > $last_modified)
225
-                $last_modified = $current_modified;
226
+            if ($current_modified > $last_modified) {
227
+                            $last_modified = $current_modified;
228
+            }
226 229
         }
227 230
 
228 231
         $dir->close();
Please login to merge, or discard this patch.