Completed
Push — master ( adb512...260239 )
by Michael
03:10
created
admin/menu.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
 
43 43
 
44 44
 if (!file_exists($fileinc = $pathLanguage . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/' . 'main.php')) {
45
-    $fileinc = $pathLanguage . '/language/english/main.php';
45
+	$fileinc = $pathLanguage . '/language/english/main.php';
46 46
 }
47 47
 
48 48
 include_once $fileinc;
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
 // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
30 30
 
31 31
 $path = dirname(dirname(dirname(__DIR__)));
32
-include_once $path . '/mainfile.php';
32
+include_once $path.'/mainfile.php';
33 33
 
34 34
 $dirname         = basename(dirname(__DIR__));
35 35
 $moduleHandler   = xoops_getHandler('module');
36 36
 $module          = $moduleHandler->getByDirname($dirname);
37 37
 $pathIcon32      = $module->getInfo('icons32');
38 38
 $pathModuleAdmin = $module->getInfo('dirmoduleadmin');
39
-$pathLanguage    = $path . $pathModuleAdmin;
39
+$pathLanguage    = $path.$pathModuleAdmin;
40 40
 
41
-if (!file_exists($fileinc = $pathLanguage . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/' . 'main.php')) {
42
-    $fileinc = $pathLanguage . '/language/english/main.php';
41
+if (!file_exists($fileinc = $pathLanguage.'/language/'.$GLOBALS['xoopsConfig']['language'].'/'.'main.php')) {
42
+    $fileinc = $pathLanguage.'/language/english/main.php';
43 43
 }
44 44
 
45 45
 include_once $fileinc;
@@ -48,24 +48,24 @@  discard block
 block discarded – undo
48 48
 $i                      = 0;
49 49
 $adminmenu[$i]['title'] = _AM_MODULEADMIN_HOME;
50 50
 $adminmenu[$i]['link']  = 'admin/index.php';
51
-$adminmenu[$i]['icon']  = $pathIcon32 . '/home.png';
51
+$adminmenu[$i]['icon']  = $pathIcon32.'/home.png';
52 52
 ++$i;
53 53
 $adminmenu[$i]['title'] = planet_constant('MI_ADMENU_INDEX');
54 54
 $adminmenu[$i]['link']  = 'admin/main.php';
55
-$adminmenu[$i]['icon']  = $pathIcon32 . '/manage.png';
55
+$adminmenu[$i]['icon']  = $pathIcon32.'/manage.png';
56 56
 
57 57
 ++$i;
58 58
 $adminmenu[$i]['title'] = planet_constant('MI_ADMENU_CATEGORY');
59 59
 $adminmenu[$i]['link']  = 'admin/admin.category.php';
60
-$adminmenu[$i]['icon']  = $pathIcon32 . '/category.png';
60
+$adminmenu[$i]['icon']  = $pathIcon32.'/category.png';
61 61
 ++$i;
62 62
 $adminmenu[$i]['title'] = planet_constant('MI_ADMENU_BLOG');
63 63
 $adminmenu[$i]['link']  = 'admin/admin.blog.php';
64
-$adminmenu[$i]['icon']  = $pathIcon32 . '/translations.png';
64
+$adminmenu[$i]['icon']  = $pathIcon32.'/translations.png';
65 65
 ++$i;
66 66
 $adminmenu[$i]['title'] = planet_constant('MI_ADMENU_ARTICLE');
67 67
 $adminmenu[$i]['link']  = 'admin/admin.article.php';
68
-$adminmenu[$i]['icon']  = $pathIcon32 . '/content.png';
68
+$adminmenu[$i]['icon']  = $pathIcon32.'/content.png';
69 69
 //++$i;
70 70
 //$adminmenu[$i]['title'] = planet_constant("MI_ADMENU_BLOCK");
71 71
 //$adminmenu[$i]['link'] = "admin/admin.block.php";
@@ -73,4 +73,4 @@  discard block
 block discarded – undo
73 73
 ++$i;
74 74
 $adminmenu[$i]['title'] = _AM_MODULEADMIN_ABOUT;
75 75
 $adminmenu[$i]['link']  = 'admin/about.php';
76
-$adminmenu[$i]['icon']  = $pathIcon32 . '/about.png';
76
+$adminmenu[$i]['icon']  = $pathIcon32.'/about.png';
Please login to merge, or discard this patch.
class/class-IXR.php 3 patches
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 
167 167
     /**
168 168
      * IXR_Message constructor.
169
-     * @param $message
169
+     * @param string|boolean $message
170 170
      */
171 171
     public function __construct($message) {
172 172
         $this->message = $message;
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 
864 864
     /**
865 865
      * IXR_Base64 constructor.
866
-     * @param $data
866
+     * @param string $data
867 867
      */
868 868
     public function __construct($data) {
869 869
         $this->data = $data;
@@ -906,10 +906,10 @@  discard block
 block discarded – undo
906 906
     }
907 907
 
908 908
     /**
909
-     * @param $method
910
-     * @param $callback
911
-     * @param $args
912
-     * @param $help
909
+     * @param string $method
910
+     * @param string $callback
911
+     * @param string[] $args
912
+     * @param string $help
913 913
      */
914 914
     public function addCallback($method, $callback, $args, $help) {
915 915
         $this->callbacks[$method]  = $callback;
Please login to merge, or discard this patch.
Indentation   +954 added lines, -954 removed lines patch added patch discarded remove patch
@@ -14,132 +14,132 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class IXR_Value
16 16
 {
17
-    public $data;
18
-    public $type;
19
-
20
-    /**
21
-     * IXR_Value constructor.
22
-     * @param      $data
23
-     * @param bool $type
24
-     */
25
-    public function __construct($data, $type = false) {
26
-        $this->data = $data;
27
-        if (!$type) {
28
-            $type = $this->calculateType();
29
-        }
30
-        $this->type = $type;
31
-        if ($type === 'struct') {
32
-            /* Turn all the values in the array in to new IXR_Value objects */
33
-            foreach ($this->data as $key => $value) {
34
-                $this->data[$key] = new IXR_Value($value);
35
-            }
36
-        }
37
-        if ($type === 'array') {
38
-            for ($i = 0, $j = count($this->data); $i < $j; ++$i) {
39
-                $this->data[$i] = new IXR_Value($this->data[$i]);
40
-            }
41
-        }
42
-    }
43
-
44
-    /**
45
-     * @return string
46
-     */
47
-    public function calculateType() {
48
-        if ($this->data === true || $this->data === false) {
49
-            return 'boolean';
50
-        }
51
-        if (is_int($this->data)) {
52
-            return 'int';
53
-        }
54
-        if (is_float($this->data)) {
55
-            return 'double';
56
-        }
57
-        // Deal with IXR object types base64 and date
58
-        if (is_object($this->data) && is_a($this->data, 'IXR_Date')) {
59
-            return 'date';
60
-        }
61
-        if (is_object($this->data) && is_a($this->data, 'IXR_Base64')) {
62
-            return 'base64';
63
-        }
64
-        // If it is a normal PHP object convert it in to a struct
65
-        if (is_object($this->data)) {
66
-            $this->data = get_object_vars($this->data);
67
-
68
-            return 'struct';
69
-        }
70
-        if (!is_array($this->data)) {
71
-            return 'string';
72
-        }
73
-        /* We have an array - is it an array or a struct ? */
74
-        if ($this->isStruct($this->data)) {
75
-            return 'struct';
76
-        } else {
77
-            return 'array';
78
-        }
79
-    }
80
-
81
-    /**
82
-     * @return bool|string
83
-     */
84
-    public function getXml() {
85
-        /* Return XML for this value */
86
-        switch ($this->type) {
87
-            case 'boolean':
88
-                return '<boolean>' . ($this->data ? '1' : '0') . '</boolean>';
89
-                break;
90
-            case 'int':
91
-                return '<int>' . $this->data . '</int>';
92
-                break;
93
-            case 'double':
94
-                return '<double>' . $this->data . '</double>';
95
-                break;
96
-            case 'string':
97
-                return '<string>' . htmlspecialchars($this->data) . '</string>';
98
-                break;
99
-            case 'array':
100
-                $return = '<array><data>' . "\n";
101
-                foreach ($this->data as $item) {
102
-                    $return .= '  <value>' . $item->getXml() . "</value>\n";
103
-                }
104
-                $return .= '</data></array>';
105
-
106
-                return $return;
107
-                break;
108
-            case 'struct':
109
-                $return = '<struct>' . "\n";
110
-                foreach ($this->data as $name => $value) {
111
-                    $return .= "  <member><name>$name</name><value>";
112
-                    $return .= $value->getXml() . "</value></member>\n";
113
-                }
114
-                $return .= '</struct>';
115
-
116
-                return $return;
117
-                break;
118
-            case 'date':
119
-            case 'base64':
120
-                return $this->data->getXml();
121
-                break;
122
-        }
123
-
124
-        return false;
125
-    }
126
-
127
-    /**
128
-     * @param $array
129
-     * @return bool
130
-     */
131
-    public function isStruct($array) {
132
-        /* Nasty function to check if an array is a struct or not */
133
-        $expected = 0;
134
-        foreach ($array as $key => $value) {
135
-            if ((string)$key != (string)$expected) {
136
-                return true;
137
-            }
138
-            ++$expected;
139
-        }
140
-
141
-        return false;
142
-    }
17
+	public $data;
18
+	public $type;
19
+
20
+	/**
21
+	 * IXR_Value constructor.
22
+	 * @param      $data
23
+	 * @param bool $type
24
+	 */
25
+	public function __construct($data, $type = false) {
26
+		$this->data = $data;
27
+		if (!$type) {
28
+			$type = $this->calculateType();
29
+		}
30
+		$this->type = $type;
31
+		if ($type === 'struct') {
32
+			/* Turn all the values in the array in to new IXR_Value objects */
33
+			foreach ($this->data as $key => $value) {
34
+				$this->data[$key] = new IXR_Value($value);
35
+			}
36
+		}
37
+		if ($type === 'array') {
38
+			for ($i = 0, $j = count($this->data); $i < $j; ++$i) {
39
+				$this->data[$i] = new IXR_Value($this->data[$i]);
40
+			}
41
+		}
42
+	}
43
+
44
+	/**
45
+	 * @return string
46
+	 */
47
+	public function calculateType() {
48
+		if ($this->data === true || $this->data === false) {
49
+			return 'boolean';
50
+		}
51
+		if (is_int($this->data)) {
52
+			return 'int';
53
+		}
54
+		if (is_float($this->data)) {
55
+			return 'double';
56
+		}
57
+		// Deal with IXR object types base64 and date
58
+		if (is_object($this->data) && is_a($this->data, 'IXR_Date')) {
59
+			return 'date';
60
+		}
61
+		if (is_object($this->data) && is_a($this->data, 'IXR_Base64')) {
62
+			return 'base64';
63
+		}
64
+		// If it is a normal PHP object convert it in to a struct
65
+		if (is_object($this->data)) {
66
+			$this->data = get_object_vars($this->data);
67
+
68
+			return 'struct';
69
+		}
70
+		if (!is_array($this->data)) {
71
+			return 'string';
72
+		}
73
+		/* We have an array - is it an array or a struct ? */
74
+		if ($this->isStruct($this->data)) {
75
+			return 'struct';
76
+		} else {
77
+			return 'array';
78
+		}
79
+	}
80
+
81
+	/**
82
+	 * @return bool|string
83
+	 */
84
+	public function getXml() {
85
+		/* Return XML for this value */
86
+		switch ($this->type) {
87
+			case 'boolean':
88
+				return '<boolean>' . ($this->data ? '1' : '0') . '</boolean>';
89
+				break;
90
+			case 'int':
91
+				return '<int>' . $this->data . '</int>';
92
+				break;
93
+			case 'double':
94
+				return '<double>' . $this->data . '</double>';
95
+				break;
96
+			case 'string':
97
+				return '<string>' . htmlspecialchars($this->data) . '</string>';
98
+				break;
99
+			case 'array':
100
+				$return = '<array><data>' . "\n";
101
+				foreach ($this->data as $item) {
102
+					$return .= '  <value>' . $item->getXml() . "</value>\n";
103
+				}
104
+				$return .= '</data></array>';
105
+
106
+				return $return;
107
+				break;
108
+			case 'struct':
109
+				$return = '<struct>' . "\n";
110
+				foreach ($this->data as $name => $value) {
111
+					$return .= "  <member><name>$name</name><value>";
112
+					$return .= $value->getXml() . "</value></member>\n";
113
+				}
114
+				$return .= '</struct>';
115
+
116
+				return $return;
117
+				break;
118
+			case 'date':
119
+			case 'base64':
120
+				return $this->data->getXml();
121
+				break;
122
+		}
123
+
124
+		return false;
125
+	}
126
+
127
+	/**
128
+	 * @param $array
129
+	 * @return bool
130
+	 */
131
+	public function isStruct($array) {
132
+		/* Nasty function to check if an array is a struct or not */
133
+		$expected = 0;
134
+		foreach ($array as $key => $value) {
135
+			if ((string)$key != (string)$expected) {
136
+				return true;
137
+			}
138
+			++$expected;
139
+		}
140
+
141
+		return false;
142
+	}
143 143
 }
144 144
 
145 145
 /**
@@ -147,185 +147,185 @@  discard block
 block discarded – undo
147 147
  */
148 148
 class IXR_Message
149 149
 {
150
-    public $message;
151
-    public $messageType;  // methodCall / methodResponse / fault
152
-    public $faultCode;
153
-    public $faultString;
154
-    public $methodName;
155
-    public $params;
156
-    // Current variable stacks
157
-    public $_arraystructs      = array();   // The stack used to keep track of the current array/struct
158
-    public $_arraystructstypes = array(); // Stack keeping track of if things are structs or array
159
-    public $_currentStructName = array();  // A stack as well
160
-    public $_param;
161
-    public $_value;
162
-    public $_currentTag;
163
-    public $_currentTagContents;
164
-    // The XML parser
165
-    public $_parser;
166
-
167
-    /**
168
-     * IXR_Message constructor.
169
-     * @param $message
170
-     */
171
-    public function __construct($message) {
172
-        $this->message = $message;
173
-    }
174
-
175
-    /**
176
-     * @return bool
177
-     */
178
-    public function parse() {
179
-        // first remove the XML declaration
180
-        $this->message = preg_replace('/<\?xml(.*)?\?' . '>/', '', $this->message);
181
-        if (trim($this->message) == '') {
182
-            return false;
183
-        }
184
-        $this->_parser = xml_parser_create();
185
-        // Set XML parser to take the case of tags in to account
186
-        xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
187
-        // Set XML parser callback functions
188
-        xml_set_object($this->_parser, $this);
189
-        xml_set_element_handler($this->_parser, 'tag_open', 'tag_close');
190
-        xml_set_character_data_handler($this->_parser, 'cdata');
191
-        if (!xml_parse($this->_parser, $this->message)) {
192
-            /* die(sprintf('XML error: %s at line %d',
150
+	public $message;
151
+	public $messageType;  // methodCall / methodResponse / fault
152
+	public $faultCode;
153
+	public $faultString;
154
+	public $methodName;
155
+	public $params;
156
+	// Current variable stacks
157
+	public $_arraystructs      = array();   // The stack used to keep track of the current array/struct
158
+	public $_arraystructstypes = array(); // Stack keeping track of if things are structs or array
159
+	public $_currentStructName = array();  // A stack as well
160
+	public $_param;
161
+	public $_value;
162
+	public $_currentTag;
163
+	public $_currentTagContents;
164
+	// The XML parser
165
+	public $_parser;
166
+
167
+	/**
168
+	 * IXR_Message constructor.
169
+	 * @param $message
170
+	 */
171
+	public function __construct($message) {
172
+		$this->message = $message;
173
+	}
174
+
175
+	/**
176
+	 * @return bool
177
+	 */
178
+	public function parse() {
179
+		// first remove the XML declaration
180
+		$this->message = preg_replace('/<\?xml(.*)?\?' . '>/', '', $this->message);
181
+		if (trim($this->message) == '') {
182
+			return false;
183
+		}
184
+		$this->_parser = xml_parser_create();
185
+		// Set XML parser to take the case of tags in to account
186
+		xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
187
+		// Set XML parser callback functions
188
+		xml_set_object($this->_parser, $this);
189
+		xml_set_element_handler($this->_parser, 'tag_open', 'tag_close');
190
+		xml_set_character_data_handler($this->_parser, 'cdata');
191
+		if (!xml_parse($this->_parser, $this->message)) {
192
+			/* die(sprintf('XML error: %s at line %d',
193 193
                 xml_error_string(xml_get_error_code($this->_parser)),
194 194
                 xml_get_current_line_number($this->_parser))); */
195 195
 
196
-            return false;
197
-        }
198
-        xml_parser_free($this->_parser);
199
-        // Grab the error messages, if any
200
-        if ($this->messageType === 'fault') {
201
-            $this->faultCode   = $this->params[0]['faultCode'];
202
-            $this->faultString = $this->params[0]['faultString'];
203
-        }
204
-
205
-        return true;
206
-    }
207
-
208
-    /**
209
-     * @param $parser
210
-     * @param $tag
211
-     * @param $attr
212
-     */
213
-    public function tag_open($parser, $tag, $attr) {
214
-        $this->currentTag = $tag;
215
-        switch ($tag) {
216
-            case 'methodCall':
217
-            case 'methodResponse':
218
-            case 'fault':
219
-                $this->messageType = $tag;
220
-                break;
221
-            /* Deal with stacks of arrays and structs */
222
-            case 'data':    // data is to all intents and puposes more interesting than array
223
-                $this->_arraystructstypes[] = 'array';
224
-                $this->_arraystructs[]      = array();
225
-                break;
226
-            case 'struct':
227
-                $this->_arraystructstypes[] = 'struct';
228
-                $this->_arraystructs[]      = array();
229
-                break;
230
-        }
231
-    }
232
-
233
-    /**
234
-     * @param $parser
235
-     * @param $cdata
236
-     */
237
-    public function cdata($parser, $cdata) {
238
-        $this->_currentTagContents .= $cdata;
239
-    }
240
-
241
-    /**
242
-     * @param $parser
243
-     * @param $tag
244
-     */
245
-    public function tag_close($parser, $tag) {
246
-        $valueFlag = false;
247
-        switch ($tag) {
248
-            case 'int':
249
-            case 'i4':
250
-                $value                     = (int)trim($this->_currentTagContents);
251
-                $this->_currentTagContents = '';
252
-                $valueFlag                 = true;
253
-                break;
254
-            case 'double':
255
-                $value                     = (double)trim($this->_currentTagContents);
256
-                $this->_currentTagContents = '';
257
-                $valueFlag                 = true;
258
-                break;
259
-            case 'string':
260
-                $value                     = (string)trim($this->_currentTagContents);
261
-                $this->_currentTagContents = '';
262
-                $valueFlag                 = true;
263
-                break;
264
-            case 'dateTime.iso8601':
265
-                $value = new IXR_Date(trim($this->_currentTagContents));
266
-                // $value = $iso->getTimestamp();
267
-                $this->_currentTagContents = '';
268
-                $valueFlag                 = true;
269
-                break;
270
-            case 'value':
271
-                // "If no type is indicated, the type is string."
272
-                if (trim($this->_currentTagContents) != '') {
273
-                    $value                     = (string)$this->_currentTagContents;
274
-                    $this->_currentTagContents = '';
275
-                    $valueFlag                 = true;
276
-                }
277
-                break;
278
-            case 'boolean':
279
-                $value                     = (boolean)trim($this->_currentTagContents);
280
-                $this->_currentTagContents = '';
281
-                $valueFlag                 = true;
282
-                break;
283
-            case 'base64':
284
-                $value                     = base64_decode(trim($this->_currentTagContents));
285
-                $this->_currentTagContents = '';
286
-                $valueFlag                 = true;
287
-                break;
288
-            /* Deal with stacks of arrays and structs */
289
-            case 'data':
290
-            case 'struct':
291
-                $value = array_pop($this->_arraystructs);
292
-                array_pop($this->_arraystructstypes);
293
-                $valueFlag = true;
294
-                break;
295
-            case 'member':
296
-                array_pop($this->_currentStructName);
297
-                break;
298
-            case 'name':
299
-                $this->_currentStructName[] = trim($this->_currentTagContents);
300
-                $this->_currentTagContents  = '';
301
-                break;
302
-            case 'methodName':
303
-                $this->methodName          = trim($this->_currentTagContents);
304
-                $this->_currentTagContents = '';
305
-                break;
306
-        }
307
-        if ($valueFlag) {
308
-            /*
196
+			return false;
197
+		}
198
+		xml_parser_free($this->_parser);
199
+		// Grab the error messages, if any
200
+		if ($this->messageType === 'fault') {
201
+			$this->faultCode   = $this->params[0]['faultCode'];
202
+			$this->faultString = $this->params[0]['faultString'];
203
+		}
204
+
205
+		return true;
206
+	}
207
+
208
+	/**
209
+	 * @param $parser
210
+	 * @param $tag
211
+	 * @param $attr
212
+	 */
213
+	public function tag_open($parser, $tag, $attr) {
214
+		$this->currentTag = $tag;
215
+		switch ($tag) {
216
+			case 'methodCall':
217
+			case 'methodResponse':
218
+			case 'fault':
219
+				$this->messageType = $tag;
220
+				break;
221
+			/* Deal with stacks of arrays and structs */
222
+			case 'data':    // data is to all intents and puposes more interesting than array
223
+				$this->_arraystructstypes[] = 'array';
224
+				$this->_arraystructs[]      = array();
225
+				break;
226
+			case 'struct':
227
+				$this->_arraystructstypes[] = 'struct';
228
+				$this->_arraystructs[]      = array();
229
+				break;
230
+		}
231
+	}
232
+
233
+	/**
234
+	 * @param $parser
235
+	 * @param $cdata
236
+	 */
237
+	public function cdata($parser, $cdata) {
238
+		$this->_currentTagContents .= $cdata;
239
+	}
240
+
241
+	/**
242
+	 * @param $parser
243
+	 * @param $tag
244
+	 */
245
+	public function tag_close($parser, $tag) {
246
+		$valueFlag = false;
247
+		switch ($tag) {
248
+			case 'int':
249
+			case 'i4':
250
+				$value                     = (int)trim($this->_currentTagContents);
251
+				$this->_currentTagContents = '';
252
+				$valueFlag                 = true;
253
+				break;
254
+			case 'double':
255
+				$value                     = (double)trim($this->_currentTagContents);
256
+				$this->_currentTagContents = '';
257
+				$valueFlag                 = true;
258
+				break;
259
+			case 'string':
260
+				$value                     = (string)trim($this->_currentTagContents);
261
+				$this->_currentTagContents = '';
262
+				$valueFlag                 = true;
263
+				break;
264
+			case 'dateTime.iso8601':
265
+				$value = new IXR_Date(trim($this->_currentTagContents));
266
+				// $value = $iso->getTimestamp();
267
+				$this->_currentTagContents = '';
268
+				$valueFlag                 = true;
269
+				break;
270
+			case 'value':
271
+				// "If no type is indicated, the type is string."
272
+				if (trim($this->_currentTagContents) != '') {
273
+					$value                     = (string)$this->_currentTagContents;
274
+					$this->_currentTagContents = '';
275
+					$valueFlag                 = true;
276
+				}
277
+				break;
278
+			case 'boolean':
279
+				$value                     = (boolean)trim($this->_currentTagContents);
280
+				$this->_currentTagContents = '';
281
+				$valueFlag                 = true;
282
+				break;
283
+			case 'base64':
284
+				$value                     = base64_decode(trim($this->_currentTagContents));
285
+				$this->_currentTagContents = '';
286
+				$valueFlag                 = true;
287
+				break;
288
+			/* Deal with stacks of arrays and structs */
289
+			case 'data':
290
+			case 'struct':
291
+				$value = array_pop($this->_arraystructs);
292
+				array_pop($this->_arraystructstypes);
293
+				$valueFlag = true;
294
+				break;
295
+			case 'member':
296
+				array_pop($this->_currentStructName);
297
+				break;
298
+			case 'name':
299
+				$this->_currentStructName[] = trim($this->_currentTagContents);
300
+				$this->_currentTagContents  = '';
301
+				break;
302
+			case 'methodName':
303
+				$this->methodName          = trim($this->_currentTagContents);
304
+				$this->_currentTagContents = '';
305
+				break;
306
+		}
307
+		if ($valueFlag) {
308
+			/*
309 309
             if (!is_array($value) && !is_object($value)) {
310 310
                 $value = trim($value);
311 311
             }
312 312
             */
313
-            if (count($this->_arraystructs) > 0) {
314
-                // Add value to struct or array
315
-                if ($this->_arraystructstypes[count($this->_arraystructstypes) - 1] === 'struct') {
316
-                    // Add to struct
317
-                    $this->_arraystructs[count($this->_arraystructs)
318
-                                         - 1][$this->_currentStructName[count($this->_currentStructName) - 1]] = $value;
319
-                } else {
320
-                    // Add to array
321
-                    $this->_arraystructs[count($this->_arraystructs) - 1][] = $value;
322
-                }
323
-            } else {
324
-                // Just add as a paramater
325
-                $this->params[] = $value;
326
-            }
327
-        }
328
-    }
313
+			if (count($this->_arraystructs) > 0) {
314
+				// Add value to struct or array
315
+				if ($this->_arraystructstypes[count($this->_arraystructstypes) - 1] === 'struct') {
316
+					// Add to struct
317
+					$this->_arraystructs[count($this->_arraystructs)
318
+										 - 1][$this->_currentStructName[count($this->_currentStructName) - 1]] = $value;
319
+				} else {
320
+					// Add to array
321
+					$this->_arraystructs[count($this->_arraystructs) - 1][] = $value;
322
+				}
323
+			} else {
324
+				// Just add as a paramater
325
+				$this->params[] = $value;
326
+			}
327
+		}
328
+	}
329 329
 }
330 330
 
331 331
 /**
@@ -333,53 +333,53 @@  discard block
 block discarded – undo
333 333
  */
334 334
 class IXR_Server
335 335
 {
336
-    public $data;
337
-    public $callbacks = array();
338
-    public $message;
339
-    public $capabilities;
340
-
341
-    /**
342
-     * IXR_Server constructor.
343
-     * @param bool $callbacks
344
-     * @param bool $data
345
-     */
346
-    public function __construct($callbacks = false, $data = false) {
347
-        $this->setCapabilities();
348
-        if ($callbacks) {
349
-            $this->callbacks = $callbacks;
350
-        }
351
-        $this->setCallbacks();
352
-        $this->serve($data);
353
-    }
354
-
355
-    /**
356
-     * @param bool $data
357
-     */
358
-    public function serve($data = false) {
359
-        if (!$data) {
360
-            $http_raw_post_data = file_get_contents('php://input');
361
-            if (!$http_raw_post_data) {
362
-                die('XML-RPC server accepts POST requests only.');
363
-            }
364
-            $data = $http_raw_post_data;
365
-        }
366
-        $this->message = new IXR_Message($data);
367
-        if (!$this->message->parse()) {
368
-            $this->error(-32700, 'parse error. not well formed');
369
-        }
370
-        if ($this->message->messageType !== 'methodCall') {
371
-            $this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
372
-        }
373
-        $result = $this->call($this->message->methodName, $this->message->params);
374
-        // Is the result an error?
375
-        if (is_a($result, 'IXR_Error')) {
376
-            $this->error($result);
377
-        }
378
-        // Encode the result
379
-        $r         = new IXR_Value($result);
380
-        $resultxml = $r->getXml();
381
-        // Create the XML
382
-        $xml = <<<EOD
336
+	public $data;
337
+	public $callbacks = array();
338
+	public $message;
339
+	public $capabilities;
340
+
341
+	/**
342
+	 * IXR_Server constructor.
343
+	 * @param bool $callbacks
344
+	 * @param bool $data
345
+	 */
346
+	public function __construct($callbacks = false, $data = false) {
347
+		$this->setCapabilities();
348
+		if ($callbacks) {
349
+			$this->callbacks = $callbacks;
350
+		}
351
+		$this->setCallbacks();
352
+		$this->serve($data);
353
+	}
354
+
355
+	/**
356
+	 * @param bool $data
357
+	 */
358
+	public function serve($data = false) {
359
+		if (!$data) {
360
+			$http_raw_post_data = file_get_contents('php://input');
361
+			if (!$http_raw_post_data) {
362
+				die('XML-RPC server accepts POST requests only.');
363
+			}
364
+			$data = $http_raw_post_data;
365
+		}
366
+		$this->message = new IXR_Message($data);
367
+		if (!$this->message->parse()) {
368
+			$this->error(-32700, 'parse error. not well formed');
369
+		}
370
+		if ($this->message->messageType !== 'methodCall') {
371
+			$this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
372
+		}
373
+		$result = $this->call($this->message->methodName, $this->message->params);
374
+		// Is the result an error?
375
+		if (is_a($result, 'IXR_Error')) {
376
+			$this->error($result);
377
+		}
378
+		// Encode the result
379
+		$r         = new IXR_Value($result);
380
+		$resultxml = $r->getXml();
381
+		// Create the XML
382
+		$xml = <<<EOD
383 383
 <methodResponse>
384 384
   <params>
385 385
     <param>
@@ -391,154 +391,154 @@  discard block
 block discarded – undo
391 391
 </methodResponse>
392 392
 
393 393
 EOD;
394
-        // Send it
395
-        $this->output($xml);
396
-    }
397
-
398
-    /**
399
-     * @param $methodname
400
-     * @param $args
401
-     * @return IXR_Error|mixed
402
-     */
403
-    public function call($methodname, $args) {
404
-        if (!$this->hasMethod($methodname)) {
405
-            return new IXR_Error(-32601, 'server error. requested method ' . $methodname . ' does not exist.');
406
-        }
407
-        $method = $this->callbacks[$methodname];
408
-        // Perform the callback and send the response
409
-        if (count($args) == 1) {
410
-            // If only one paramater just send that instead of the whole array
411
-            $args = $args[0];
412
-        }
413
-        // Are we dealing with a function or a method?
414
-        if (substr($method, 0, 5) === 'this:') {
415
-            // It's a class method - check it exists
416
-            $method = substr($method, 5);
417
-            if (!method_exists($this, $method)) {
418
-                return new IXR_Error(-32601, 'server error. requested class method "' . $method . '" does not exist.');
419
-            }
420
-            // Call the method
421
-            $result = $this->$method($args);
422
-        } else {
423
-            // It's a function - does it exist?
424
-            if (is_array($method)) {
425
-                if (!method_exists($method[0], $method[1])) {
426
-                    return new IXR_Error(-32601,
427
-                                         'server error. requested object method "' . $method[1] . '" does not exist.');
428
-                }
429
-            } elseif (!function_exists($method)) {
430
-                return new IXR_Error(-32601, 'server error. requested function "' . $method . '" does not exist.');
431
-            }
432
-            // Call the function
433
-            $result = call_user_func($method, $args);
434
-        }
435
-
436
-        return $result;
437
-    }
438
-
439
-    /**
440
-     * @param      $error
441
-     * @param bool $message
442
-     */
443
-    public function error($error, $message = false) {
444
-        // Accepts either an error object or an error code and message
445
-        if ($message && !is_object($error)) {
446
-            $error = new IXR_Error($error, $message);
447
-        }
448
-        $this->output($error->getXml());
449
-    }
450
-
451
-    /**
452
-     * @param $xml
453
-     */
454
-    public function output($xml) {
455
-        $xml    = '<?xml version="1.0"?>' . "\n" . $xml;
456
-        $length = strlen($xml);
457
-        header('Connection: close');
458
-        header('Content-Length: ' . $length);
459
-        header('Content-Type: text/xml');
460
-        header('Date: ' . date('r'));
461
-        echo $xml;
462
-        exit;
463
-    }
464
-
465
-    /**
466
-     * @param $method
467
-     * @return bool
468
-     */
469
-    public function hasMethod($method) {
470
-        return in_array($method, array_keys($this->callbacks));
471
-    }
472
-
473
-    public function setCapabilities() {
474
-        // Initialises capabilities array
475
-        $this->capabilities = array(
476
-            'xmlrpc'           => array(
477
-                'specUrl'     => 'http://www.xmlrpc.com/spec',
478
-                'specVersion' => 1
479
-            ),
480
-            'faults_interop'   => array(
481
-                'specUrl'     => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
482
-                'specVersion' => 20010516
483
-            ),
484
-            'system.multicall' => array(
485
-                'specUrl'     => 'http://www.xmlrpc.com/discuss/msgReader$1208',
486
-                'specVersion' => 1
487
-            )
488
-        );
489
-    }
490
-
491
-    /**
492
-     * @param $args
493
-     * @return mixed
494
-     */
495
-    public function getCapabilities($args) {
496
-        return $this->capabilities;
497
-    }
498
-
499
-    public function setCallbacks() {
500
-        $this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
501
-        $this->callbacks['system.listMethods']     = 'this:listMethods';
502
-        $this->callbacks['system.multicall']       = 'this:multiCall';
503
-    }
504
-
505
-    /**
506
-     * @param $args
507
-     * @return array
508
-     */
509
-    public function listMethods($args) {
510
-        // Returns a list of methods - uses array_reverse to ensure user defined
511
-        // methods are listed before server defined methods
512
-        return array_reverse(array_keys($this->callbacks));
513
-    }
514
-
515
-    /**
516
-     * @param $methodcalls
517
-     * @return array
518
-     */
519
-    public function multiCall($methodcalls) {
520
-        // See http://www.xmlrpc.com/discuss/msgReader$1208
521
-        $return = array();
522
-        foreach ($methodcalls as $call) {
523
-            $method = $call['methodName'];
524
-            $params = $call['params'];
525
-            if ($method === 'system.multicall') {
526
-                $result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden');
527
-            } else {
528
-                $result = $this->call($method, $params);
529
-            }
530
-            if (is_a($result, 'IXR_Error')) {
531
-                $return[] = array(
532
-                    'faultCode'   => $result->code,
533
-                    'faultString' => $result->message
534
-                );
535
-            } else {
536
-                $return[] = array($result);
537
-            }
538
-        }
539
-
540
-        return $return;
541
-    }
394
+		// Send it
395
+		$this->output($xml);
396
+	}
397
+
398
+	/**
399
+	 * @param $methodname
400
+	 * @param $args
401
+	 * @return IXR_Error|mixed
402
+	 */
403
+	public function call($methodname, $args) {
404
+		if (!$this->hasMethod($methodname)) {
405
+			return new IXR_Error(-32601, 'server error. requested method ' . $methodname . ' does not exist.');
406
+		}
407
+		$method = $this->callbacks[$methodname];
408
+		// Perform the callback and send the response
409
+		if (count($args) == 1) {
410
+			// If only one paramater just send that instead of the whole array
411
+			$args = $args[0];
412
+		}
413
+		// Are we dealing with a function or a method?
414
+		if (substr($method, 0, 5) === 'this:') {
415
+			// It's a class method - check it exists
416
+			$method = substr($method, 5);
417
+			if (!method_exists($this, $method)) {
418
+				return new IXR_Error(-32601, 'server error. requested class method "' . $method . '" does not exist.');
419
+			}
420
+			// Call the method
421
+			$result = $this->$method($args);
422
+		} else {
423
+			// It's a function - does it exist?
424
+			if (is_array($method)) {
425
+				if (!method_exists($method[0], $method[1])) {
426
+					return new IXR_Error(-32601,
427
+										 'server error. requested object method "' . $method[1] . '" does not exist.');
428
+				}
429
+			} elseif (!function_exists($method)) {
430
+				return new IXR_Error(-32601, 'server error. requested function "' . $method . '" does not exist.');
431
+			}
432
+			// Call the function
433
+			$result = call_user_func($method, $args);
434
+		}
435
+
436
+		return $result;
437
+	}
438
+
439
+	/**
440
+	 * @param      $error
441
+	 * @param bool $message
442
+	 */
443
+	public function error($error, $message = false) {
444
+		// Accepts either an error object or an error code and message
445
+		if ($message && !is_object($error)) {
446
+			$error = new IXR_Error($error, $message);
447
+		}
448
+		$this->output($error->getXml());
449
+	}
450
+
451
+	/**
452
+	 * @param $xml
453
+	 */
454
+	public function output($xml) {
455
+		$xml    = '<?xml version="1.0"?>' . "\n" . $xml;
456
+		$length = strlen($xml);
457
+		header('Connection: close');
458
+		header('Content-Length: ' . $length);
459
+		header('Content-Type: text/xml');
460
+		header('Date: ' . date('r'));
461
+		echo $xml;
462
+		exit;
463
+	}
464
+
465
+	/**
466
+	 * @param $method
467
+	 * @return bool
468
+	 */
469
+	public function hasMethod($method) {
470
+		return in_array($method, array_keys($this->callbacks));
471
+	}
472
+
473
+	public function setCapabilities() {
474
+		// Initialises capabilities array
475
+		$this->capabilities = array(
476
+			'xmlrpc'           => array(
477
+				'specUrl'     => 'http://www.xmlrpc.com/spec',
478
+				'specVersion' => 1
479
+			),
480
+			'faults_interop'   => array(
481
+				'specUrl'     => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
482
+				'specVersion' => 20010516
483
+			),
484
+			'system.multicall' => array(
485
+				'specUrl'     => 'http://www.xmlrpc.com/discuss/msgReader$1208',
486
+				'specVersion' => 1
487
+			)
488
+		);
489
+	}
490
+
491
+	/**
492
+	 * @param $args
493
+	 * @return mixed
494
+	 */
495
+	public function getCapabilities($args) {
496
+		return $this->capabilities;
497
+	}
498
+
499
+	public function setCallbacks() {
500
+		$this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
501
+		$this->callbacks['system.listMethods']     = 'this:listMethods';
502
+		$this->callbacks['system.multicall']       = 'this:multiCall';
503
+	}
504
+
505
+	/**
506
+	 * @param $args
507
+	 * @return array
508
+	 */
509
+	public function listMethods($args) {
510
+		// Returns a list of methods - uses array_reverse to ensure user defined
511
+		// methods are listed before server defined methods
512
+		return array_reverse(array_keys($this->callbacks));
513
+	}
514
+
515
+	/**
516
+	 * @param $methodcalls
517
+	 * @return array
518
+	 */
519
+	public function multiCall($methodcalls) {
520
+		// See http://www.xmlrpc.com/discuss/msgReader$1208
521
+		$return = array();
522
+		foreach ($methodcalls as $call) {
523
+			$method = $call['methodName'];
524
+			$params = $call['params'];
525
+			if ($method === 'system.multicall') {
526
+				$result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden');
527
+			} else {
528
+				$result = $this->call($method, $params);
529
+			}
530
+			if (is_a($result, 'IXR_Error')) {
531
+				$return[] = array(
532
+					'faultCode'   => $result->code,
533
+					'faultString' => $result->message
534
+				);
535
+			} else {
536
+				$return[] = array($result);
537
+			}
538
+		}
539
+
540
+		return $return;
541
+	}
542 542
 }
543 543
 
544 544
 /**
@@ -546,47 +546,47 @@  discard block
 block discarded – undo
546 546
  */
547 547
 class IXR_Request
548 548
 {
549
-    public $method;
550
-    public $args;
551
-    public $xml;
552
-
553
-    /**
554
-     * IXR_Request constructor.
555
-     * @param $method
556
-     * @param $args
557
-     */
558
-    public function __construct($method, $args) {
559
-        $this->method = $method;
560
-        $this->args   = $args;
561
-        $this->xml    = <<<EOD
549
+	public $method;
550
+	public $args;
551
+	public $xml;
552
+
553
+	/**
554
+	 * IXR_Request constructor.
555
+	 * @param $method
556
+	 * @param $args
557
+	 */
558
+	public function __construct($method, $args) {
559
+		$this->method = $method;
560
+		$this->args   = $args;
561
+		$this->xml    = <<<EOD
562 562
 <?xml version="1.0"?>
563 563
 <methodCall>
564 564
 <methodName>{$this->method}</methodName>
565 565
 <params>
566 566
 
567 567
 EOD;
568
-        foreach ($this->args as $arg) {
569
-            $this->xml .= '<param><value>';
570
-            $v = new IXR_Value($arg);
571
-            $this->xml .= $v->getXml();
572
-            $this->xml .= "</value></param>\n";
573
-        }
574
-        $this->xml .= '</params></methodCall>';
575
-    }
576
-
577
-    /**
578
-     * @return int
579
-     */
580
-    public function getLength() {
581
-        return strlen($this->xml);
582
-    }
583
-
584
-    /**
585
-     * @return string
586
-     */
587
-    public function getXml() {
588
-        return $this->xml;
589
-    }
568
+		foreach ($this->args as $arg) {
569
+			$this->xml .= '<param><value>';
570
+			$v = new IXR_Value($arg);
571
+			$this->xml .= $v->getXml();
572
+			$this->xml .= "</value></param>\n";
573
+		}
574
+		$this->xml .= '</params></methodCall>';
575
+	}
576
+
577
+	/**
578
+	 * @return int
579
+	 */
580
+	public function getLength() {
581
+		return strlen($this->xml);
582
+	}
583
+
584
+	/**
585
+	 * @return string
586
+	 */
587
+	public function getXml() {
588
+		return $this->xml;
589
+	}
590 590
 }
591 591
 
592 592
 /**
@@ -594,144 +594,144 @@  discard block
 block discarded – undo
594 594
  */
595 595
 class IXR_Client
596 596
 {
597
-    public $server;
598
-    public $port;
599
-    public $path;
600
-    public $useragent;
601
-    public $response;
602
-    public $timeout;
603
-    public $vendor  = '';
604
-    public $message = false;
605
-    public $debug   = false;
606
-    // Storage place for an error message
607
-    public $error = false;
608
-
609
-    /**
610
-     * IXR_Client constructor.
611
-     * @param        $server
612
-     * @param bool   $path
613
-     * @param int    $port
614
-     * @param int    $timeout
615
-     * @param string $vendor
616
-     */
617
-    public function __construct($server, $path = false, $port = 80, $timeout = 30, $vendor = '') {
618
-        if (!$path) {
619
-            // Assume we have been given a URL instead
620
-            $bits         = parse_url($server);
621
-            $this->server = $bits['host'];
622
-            $this->port   = isset($bits['port']) ? $bits['port'] : 80;
623
-            $this->path   = isset($bits['path']) ? $bits['path'] : '/';
624
-            // Make absolutely sure we have a path
625
-            if (!$this->path) {
626
-                $this->path = '/';
627
-            }
628
-        } else {
629
-            $this->server  = $server;
630
-            $this->path    = $path;
631
-            $this->port    = $port;
632
-            $this->timeout = $timeout;
633
-        }
634
-        $this->useragent = 'The Incutio XML-RPC PHP Library';
635
-    }
636
-
637
-    /**
638
-     * @return bool
639
-     */
640
-    public function query() {
641
-        $args    = func_get_args();
642
-        $method  = array_shift($args);
643
-        $request = new IXR_Request($method, $args);
644
-        $length  = $request->getLength();
645
-        $xml     = $request->getXml();
646
-        $r       = "\r\n";
647
-        $request = "POST {$this->path} HTTP/1.0$r";
648
-        $request .= "Host: {$this->server}$r";
649
-        $request .= "Content-Type: text/xml$r";
650
-        $request .= "User-Agent: {$this->useragent}$r";
651
-        $request .= "Content-length: {$length}$r$r";
652
-        $request .= $xml;
653
-        // Now send the request
654
-        if ($this->debug) {
655
-            echo '<pre>' . htmlspecialchars($request) . "\n</pre>\n\n";
656
-        }
657
-        $fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);
658
-        if (!$fp) {
659
-            $this->error = new IXR_Error(-32300, 'transport error - could not open socket');
660
-
661
-            return false;
662
-        }
663
-        fwrite($fp, $request);
664
-        $contents       = '';
665
-        $gotFirstLine   = false;
666
-        $gettingHeaders = true;
667
-        while (!feof($fp)) {
668
-            $line = fgets($fp, 4096);
669
-            if (!$gotFirstLine) {
670
-                // Check line for '200'
671
-                if (false === strpos($line, '200')) {
672
-                    $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
673
-
674
-                    return false;
675
-                }
676
-                $gotFirstLine = true;
677
-            }
678
-            if (trim($line) == '') {
679
-                $gettingHeaders = false;
680
-            }
681
-            if (!$gettingHeaders) {
682
-                $contents .= trim($line) . "\n";
683
-            }
684
-        }
685
-        if ($this->debug) {
686
-            echo '<pre>' . htmlspecialchars($contents) . "\n</pre>\n\n";
687
-        }
688
-        // Now parse what we've got back
689
-        $this->message = new IXR_Message($contents);
690
-        if (!$this->message->parse()) {
691
-            // XML error
692
-            $this->error = new IXR_Error(-32700, 'parse error. not well formed');
693
-
694
-            return false;
695
-        }
696
-        // Is the message a fault?
697
-        if ($this->message->messageType === 'fault') {
698
-            $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
699
-
700
-            return false;
701
-        }
702
-
703
-        // Message must be OK
704
-        return true;
705
-    }
706
-
707
-    /**
708
-     * @return mixed
709
-     */
710
-    public function getResponse() {
711
-        // methodResponses can only have one param - return that
712
-        return $this->message->params[0];
713
-    }
714
-
715
-    /**
716
-     * @return bool
717
-     */
718
-    public function isError() {
719
-        return is_object($this->error);
720
-    }
721
-
722
-    /**
723
-     * @return mixed
724
-     */
725
-    public function getErrorCode() {
726
-        return $this->error->code;
727
-    }
728
-
729
-    /**
730
-     * @return mixed
731
-     */
732
-    public function getErrorMessage() {
733
-        return $this->error->message;
734
-    }
597
+	public $server;
598
+	public $port;
599
+	public $path;
600
+	public $useragent;
601
+	public $response;
602
+	public $timeout;
603
+	public $vendor  = '';
604
+	public $message = false;
605
+	public $debug   = false;
606
+	// Storage place for an error message
607
+	public $error = false;
608
+
609
+	/**
610
+	 * IXR_Client constructor.
611
+	 * @param        $server
612
+	 * @param bool   $path
613
+	 * @param int    $port
614
+	 * @param int    $timeout
615
+	 * @param string $vendor
616
+	 */
617
+	public function __construct($server, $path = false, $port = 80, $timeout = 30, $vendor = '') {
618
+		if (!$path) {
619
+			// Assume we have been given a URL instead
620
+			$bits         = parse_url($server);
621
+			$this->server = $bits['host'];
622
+			$this->port   = isset($bits['port']) ? $bits['port'] : 80;
623
+			$this->path   = isset($bits['path']) ? $bits['path'] : '/';
624
+			// Make absolutely sure we have a path
625
+			if (!$this->path) {
626
+				$this->path = '/';
627
+			}
628
+		} else {
629
+			$this->server  = $server;
630
+			$this->path    = $path;
631
+			$this->port    = $port;
632
+			$this->timeout = $timeout;
633
+		}
634
+		$this->useragent = 'The Incutio XML-RPC PHP Library';
635
+	}
636
+
637
+	/**
638
+	 * @return bool
639
+	 */
640
+	public function query() {
641
+		$args    = func_get_args();
642
+		$method  = array_shift($args);
643
+		$request = new IXR_Request($method, $args);
644
+		$length  = $request->getLength();
645
+		$xml     = $request->getXml();
646
+		$r       = "\r\n";
647
+		$request = "POST {$this->path} HTTP/1.0$r";
648
+		$request .= "Host: {$this->server}$r";
649
+		$request .= "Content-Type: text/xml$r";
650
+		$request .= "User-Agent: {$this->useragent}$r";
651
+		$request .= "Content-length: {$length}$r$r";
652
+		$request .= $xml;
653
+		// Now send the request
654
+		if ($this->debug) {
655
+			echo '<pre>' . htmlspecialchars($request) . "\n</pre>\n\n";
656
+		}
657
+		$fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);
658
+		if (!$fp) {
659
+			$this->error = new IXR_Error(-32300, 'transport error - could not open socket');
660
+
661
+			return false;
662
+		}
663
+		fwrite($fp, $request);
664
+		$contents       = '';
665
+		$gotFirstLine   = false;
666
+		$gettingHeaders = true;
667
+		while (!feof($fp)) {
668
+			$line = fgets($fp, 4096);
669
+			if (!$gotFirstLine) {
670
+				// Check line for '200'
671
+				if (false === strpos($line, '200')) {
672
+					$this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
673
+
674
+					return false;
675
+				}
676
+				$gotFirstLine = true;
677
+			}
678
+			if (trim($line) == '') {
679
+				$gettingHeaders = false;
680
+			}
681
+			if (!$gettingHeaders) {
682
+				$contents .= trim($line) . "\n";
683
+			}
684
+		}
685
+		if ($this->debug) {
686
+			echo '<pre>' . htmlspecialchars($contents) . "\n</pre>\n\n";
687
+		}
688
+		// Now parse what we've got back
689
+		$this->message = new IXR_Message($contents);
690
+		if (!$this->message->parse()) {
691
+			// XML error
692
+			$this->error = new IXR_Error(-32700, 'parse error. not well formed');
693
+
694
+			return false;
695
+		}
696
+		// Is the message a fault?
697
+		if ($this->message->messageType === 'fault') {
698
+			$this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
699
+
700
+			return false;
701
+		}
702
+
703
+		// Message must be OK
704
+		return true;
705
+	}
706
+
707
+	/**
708
+	 * @return mixed
709
+	 */
710
+	public function getResponse() {
711
+		// methodResponses can only have one param - return that
712
+		return $this->message->params[0];
713
+	}
714
+
715
+	/**
716
+	 * @return bool
717
+	 */
718
+	public function isError() {
719
+		return is_object($this->error);
720
+	}
721
+
722
+	/**
723
+	 * @return mixed
724
+	 */
725
+	public function getErrorCode() {
726
+		return $this->error->code;
727
+	}
728
+
729
+	/**
730
+	 * @return mixed
731
+	 */
732
+	public function getErrorMessage() {
733
+		return $this->error->message;
734
+	}
735 735
 }
736 736
 
737 737
 /**
@@ -739,24 +739,24 @@  discard block
 block discarded – undo
739 739
  */
740 740
 class IXR_Error
741 741
 {
742
-    public $code;
743
-    public $message;
744
-
745
-    /**
746
-     * IXR_Error constructor.
747
-     * @param $code
748
-     * @param $message
749
-     */
750
-    public function __construct($code, $message) {
751
-        $this->code    = $code;
752
-        $this->message = $message;
753
-    }
754
-
755
-    /**
756
-     * @return string
757
-     */
758
-    public function getXml() {
759
-        $xml = <<<EOD
742
+	public $code;
743
+	public $message;
744
+
745
+	/**
746
+	 * IXR_Error constructor.
747
+	 * @param $code
748
+	 * @param $message
749
+	 */
750
+	public function __construct($code, $message) {
751
+		$this->code    = $code;
752
+		$this->message = $message;
753
+	}
754
+
755
+	/**
756
+	 * @return string
757
+	 */
758
+	public function getXml() {
759
+		$xml = <<<EOD
760 760
 <methodResponse>
761 761
   <fault>
762 762
     <value>
@@ -776,8 +776,8 @@  discard block
 block discarded – undo
776 776
 
777 777
 EOD;
778 778
 
779
-        return $xml;
780
-    }
779
+		return $xml;
780
+	}
781 781
 }
782 782
 
783 783
 /**
@@ -785,73 +785,73 @@  discard block
 block discarded – undo
785 785
  */
786 786
 class IXR_Date
787 787
 {
788
-    public $year;
789
-    public $month;
790
-    public $day;
791
-    public $hour;
792
-    public $minute;
793
-    public $second;
794
-    public $timezone;
795
-
796
-    /**
797
-     * IXR_Date constructor.
798
-     * @param $time
799
-     */
800
-    public function __construct($time) {
801
-        // $time can be a PHP timestamp or an ISO one
802
-        if (is_numeric($time)) {
803
-            $this->parseTimestamp($time);
804
-        } else {
805
-            $this->parseIso($time);
806
-        }
807
-    }
808
-
809
-    /**
810
-     * @param $timestamp
811
-     */
812
-    public function parseTimestamp($timestamp) {
813
-        $this->year   = date('Y', $timestamp);
814
-        $this->month  = date('Y', $timestamp);
815
-        $this->day    = date('Y', $timestamp);
816
-        $this->hour   = date('H', $timestamp);
817
-        $this->minute = date('i', $timestamp);
818
-        $this->second = date('s', $timestamp);
819
-    }
820
-
821
-    /**
822
-     * @param $iso
823
-     */
824
-    public function parseIso($iso) {
825
-        $this->year     = substr($iso, 0, 4);
826
-        $this->month    = substr($iso, 4, 2);
827
-        $this->day      = substr($iso, 6, 2);
828
-        $this->hour     = substr($iso, 9, 2);
829
-        $this->minute   = substr($iso, 12, 2);
830
-        $this->second   = substr($iso, 15, 2);
831
-        $this->timezone = substr($iso, 17);
832
-    }
833
-
834
-    /**
835
-     * @return string
836
-     */
837
-    public function getIso() {
838
-        return $this->year . $this->month . $this->day . 'T' . $this->hour . ':' . $this->minute . ':' . $this->second
839
-               . $this->timezone;
840
-    }
841
-
842
-    /**
843
-     * @return string
844
-     */
845
-    public function getXml() {
846
-        return '<dateTime.iso8601>' . $this->getIso() . '</dateTime.iso8601>';
847
-    }
848
-
849
-    /**
850
-     * @return int
851
-     */
852
-    public function getTimestamp() {
853
-        return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
854
-    }
788
+	public $year;
789
+	public $month;
790
+	public $day;
791
+	public $hour;
792
+	public $minute;
793
+	public $second;
794
+	public $timezone;
795
+
796
+	/**
797
+	 * IXR_Date constructor.
798
+	 * @param $time
799
+	 */
800
+	public function __construct($time) {
801
+		// $time can be a PHP timestamp or an ISO one
802
+		if (is_numeric($time)) {
803
+			$this->parseTimestamp($time);
804
+		} else {
805
+			$this->parseIso($time);
806
+		}
807
+	}
808
+
809
+	/**
810
+	 * @param $timestamp
811
+	 */
812
+	public function parseTimestamp($timestamp) {
813
+		$this->year   = date('Y', $timestamp);
814
+		$this->month  = date('Y', $timestamp);
815
+		$this->day    = date('Y', $timestamp);
816
+		$this->hour   = date('H', $timestamp);
817
+		$this->minute = date('i', $timestamp);
818
+		$this->second = date('s', $timestamp);
819
+	}
820
+
821
+	/**
822
+	 * @param $iso
823
+	 */
824
+	public function parseIso($iso) {
825
+		$this->year     = substr($iso, 0, 4);
826
+		$this->month    = substr($iso, 4, 2);
827
+		$this->day      = substr($iso, 6, 2);
828
+		$this->hour     = substr($iso, 9, 2);
829
+		$this->minute   = substr($iso, 12, 2);
830
+		$this->second   = substr($iso, 15, 2);
831
+		$this->timezone = substr($iso, 17);
832
+	}
833
+
834
+	/**
835
+	 * @return string
836
+	 */
837
+	public function getIso() {
838
+		return $this->year . $this->month . $this->day . 'T' . $this->hour . ':' . $this->minute . ':' . $this->second
839
+			   . $this->timezone;
840
+	}
841
+
842
+	/**
843
+	 * @return string
844
+	 */
845
+	public function getXml() {
846
+		return '<dateTime.iso8601>' . $this->getIso() . '</dateTime.iso8601>';
847
+	}
848
+
849
+	/**
850
+	 * @return int
851
+	 */
852
+	public function getTimestamp() {
853
+		return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
854
+	}
855 855
 }
856 856
 
857 857
 /**
@@ -859,22 +859,22 @@  discard block
 block discarded – undo
859 859
  */
860 860
 class IXR_Base64
861 861
 {
862
-    public $data;
863
-
864
-    /**
865
-     * IXR_Base64 constructor.
866
-     * @param $data
867
-     */
868
-    public function __construct($data) {
869
-        $this->data = $data;
870
-    }
871
-
872
-    /**
873
-     * @return string
874
-     */
875
-    public function getXml() {
876
-        return '<base64>' . base64_encode($this->data) . '</base64>';
877
-    }
862
+	public $data;
863
+
864
+	/**
865
+	 * IXR_Base64 constructor.
866
+	 * @param $data
867
+	 */
868
+	public function __construct($data) {
869
+		$this->data = $data;
870
+	}
871
+
872
+	/**
873
+	 * @return string
874
+	 */
875
+	public function getXml() {
876
+		return '<base64>' . base64_encode($this->data) . '</base64>';
877
+	}
878 878
 }
879 879
 
880 880
 /**
@@ -882,161 +882,161 @@  discard block
 block discarded – undo
882 882
  */
883 883
 class IXR_IntrospectionServer extends IXR_Server
884 884
 {
885
-    public $signatures;
886
-    public $help;
887
-
888
-    /**
889
-     * IXR_IntrospectionServer constructor.
890
-     */
891
-    public function __construct() {
892
-        $this->setCallbacks();
893
-        $this->setCapabilities();
894
-        $this->capabilities['introspection'] = array(
895
-            'specUrl'     => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
896
-            'specVersion' => 1
897
-        );
898
-        $this->addCallback('system.methodSignature', 'this:methodSignature', array('array', 'string'),
899
-                           'Returns an array describing the return type and required parameters of a method');
900
-        $this->addCallback('system.getCapabilities', 'this:getCapabilities', array('struct'),
901
-                           'Returns a struct describing the XML-RPC specifications supported by this server');
902
-        $this->addCallback('system.listMethods', 'this:listMethods', array('array'),
903
-                           'Returns an array of available methods on this server');
904
-        $this->addCallback('system.methodHelp', 'this:methodHelp', array('string', 'string'),
905
-                           'Returns a documentation string for the specified method');
906
-    }
907
-
908
-    /**
909
-     * @param $method
910
-     * @param $callback
911
-     * @param $args
912
-     * @param $help
913
-     */
914
-    public function addCallback($method, $callback, $args, $help) {
915
-        $this->callbacks[$method]  = $callback;
916
-        $this->signatures[$method] = $args;
917
-        $this->help[$method]       = $help;
918
-    }
919
-
920
-    /**
921
-     * @param $methodname
922
-     * @param $args
923
-     * @return IXR_Error|mixed
924
-     */
925
-    public function call($methodname, $args) {
926
-        // Make sure it's in an array
927
-        if ($args && !is_array($args)) {
928
-            $args = array($args);
929
-        }
930
-        // Over-rides default call method, adds signature check
931
-        if (!$this->hasMethod($methodname)) {
932
-            return new IXR_Error(-32601,
933
-                                 'server error. requested method "' . $this->message->methodName . '" not specified.');
934
-        }
935
-        $method     = $this->callbacks[$methodname];
936
-        $signature  = $this->signatures[$methodname];
937
-        $returnType = array_shift($signature);
938
-        // Check the number of arguments
939
-        if (count($args) != count($signature)) {
940
-            // print 'Num of args: '.count($args).' Num in signature: '.count($signature);
941
-            return new IXR_Error(-32602, 'server error. wrong number of method parameters');
942
-        }
943
-        // Check the argument types
944
-        $ok         = true;
945
-        $argsbackup = $args;
946
-        for ($i = 0, $j = count($args); $i < $j; ++$i) {
947
-            $arg  = array_shift($args);
948
-            $type = array_shift($signature);
949
-            switch ($type) {
950
-                case 'int':
951
-                case 'i4':
952
-                    if (is_array($arg) || !is_int($arg)) {
953
-                        $ok = false;
954
-                    }
955
-                    break;
956
-                case 'base64':
957
-                case 'string':
958
-                    if (!is_string($arg)) {
959
-                        $ok = false;
960
-                    }
961
-                    break;
962
-                case 'boolean':
963
-                    if ($arg !== false && $arg !== true) {
964
-                        $ok = false;
965
-                    }
966
-                    break;
967
-                case 'float':
968
-                case 'double':
969
-                    if (!is_float($arg)) {
970
-                        $ok = false;
971
-                    }
972
-                    break;
973
-                case 'date':
974
-                case 'dateTime.iso8601':
975
-                    if (!is_a($arg, 'IXR_Date')) {
976
-                        $ok = false;
977
-                    }
978
-                    break;
979
-            }
980
-            if (!$ok) {
981
-                return new IXR_Error(-32602, 'server error. invalid method parameters');
982
-            }
983
-        }
984
-
985
-        // It passed the test - run the "real" method call
986
-        return parent::call($methodname, $argsbackup);
987
-    }
988
-
989
-    /**
990
-     * @param $method
991
-     * @return array|IXR_Error
992
-     */
993
-    public function methodSignature($method) {
994
-        if (!$this->hasMethod($method)) {
995
-            return new IXR_Error(-32601, 'server error. requested method "' . $method . '" not specified.');
996
-        }
997
-        // We should be returning an array of types
998
-        $types  = $this->signatures[$method];
999
-        $return = array();
1000
-        foreach ($types as $type) {
1001
-            switch ($type) {
1002
-                case 'string':
1003
-                    $return[] = 'string';
1004
-                    break;
1005
-                case 'int':
1006
-                case 'i4':
1007
-                    $return[] = 42;
1008
-                    break;
1009
-                case 'double':
1010
-                    $return[] = 3.1415;
1011
-                    break;
1012
-                case 'dateTime.iso8601':
1013
-                    $return[] = new IXR_Date(time());
1014
-                    break;
1015
-                case 'boolean':
1016
-                    $return[] = true;
1017
-                    break;
1018
-                case 'base64':
1019
-                    $return[] = new IXR_Base64('base64');
1020
-                    break;
1021
-                case 'array':
1022
-                    $return[] = array('array');
1023
-                    break;
1024
-                case 'struct':
1025
-                    $return[] = array('struct' => 'struct');
1026
-                    break;
1027
-            }
1028
-        }
1029
-
1030
-        return $return;
1031
-    }
1032
-
1033
-    /**
1034
-     * @param $method
1035
-     * @return mixed
1036
-     */
1037
-    public function methodHelp($method) {
1038
-        return $this->help[$method];
1039
-    }
885
+	public $signatures;
886
+	public $help;
887
+
888
+	/**
889
+	 * IXR_IntrospectionServer constructor.
890
+	 */
891
+	public function __construct() {
892
+		$this->setCallbacks();
893
+		$this->setCapabilities();
894
+		$this->capabilities['introspection'] = array(
895
+			'specUrl'     => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
896
+			'specVersion' => 1
897
+		);
898
+		$this->addCallback('system.methodSignature', 'this:methodSignature', array('array', 'string'),
899
+						   'Returns an array describing the return type and required parameters of a method');
900
+		$this->addCallback('system.getCapabilities', 'this:getCapabilities', array('struct'),
901
+						   'Returns a struct describing the XML-RPC specifications supported by this server');
902
+		$this->addCallback('system.listMethods', 'this:listMethods', array('array'),
903
+						   'Returns an array of available methods on this server');
904
+		$this->addCallback('system.methodHelp', 'this:methodHelp', array('string', 'string'),
905
+						   'Returns a documentation string for the specified method');
906
+	}
907
+
908
+	/**
909
+	 * @param $method
910
+	 * @param $callback
911
+	 * @param $args
912
+	 * @param $help
913
+	 */
914
+	public function addCallback($method, $callback, $args, $help) {
915
+		$this->callbacks[$method]  = $callback;
916
+		$this->signatures[$method] = $args;
917
+		$this->help[$method]       = $help;
918
+	}
919
+
920
+	/**
921
+	 * @param $methodname
922
+	 * @param $args
923
+	 * @return IXR_Error|mixed
924
+	 */
925
+	public function call($methodname, $args) {
926
+		// Make sure it's in an array
927
+		if ($args && !is_array($args)) {
928
+			$args = array($args);
929
+		}
930
+		// Over-rides default call method, adds signature check
931
+		if (!$this->hasMethod($methodname)) {
932
+			return new IXR_Error(-32601,
933
+								 'server error. requested method "' . $this->message->methodName . '" not specified.');
934
+		}
935
+		$method     = $this->callbacks[$methodname];
936
+		$signature  = $this->signatures[$methodname];
937
+		$returnType = array_shift($signature);
938
+		// Check the number of arguments
939
+		if (count($args) != count($signature)) {
940
+			// print 'Num of args: '.count($args).' Num in signature: '.count($signature);
941
+			return new IXR_Error(-32602, 'server error. wrong number of method parameters');
942
+		}
943
+		// Check the argument types
944
+		$ok         = true;
945
+		$argsbackup = $args;
946
+		for ($i = 0, $j = count($args); $i < $j; ++$i) {
947
+			$arg  = array_shift($args);
948
+			$type = array_shift($signature);
949
+			switch ($type) {
950
+				case 'int':
951
+				case 'i4':
952
+					if (is_array($arg) || !is_int($arg)) {
953
+						$ok = false;
954
+					}
955
+					break;
956
+				case 'base64':
957
+				case 'string':
958
+					if (!is_string($arg)) {
959
+						$ok = false;
960
+					}
961
+					break;
962
+				case 'boolean':
963
+					if ($arg !== false && $arg !== true) {
964
+						$ok = false;
965
+					}
966
+					break;
967
+				case 'float':
968
+				case 'double':
969
+					if (!is_float($arg)) {
970
+						$ok = false;
971
+					}
972
+					break;
973
+				case 'date':
974
+				case 'dateTime.iso8601':
975
+					if (!is_a($arg, 'IXR_Date')) {
976
+						$ok = false;
977
+					}
978
+					break;
979
+			}
980
+			if (!$ok) {
981
+				return new IXR_Error(-32602, 'server error. invalid method parameters');
982
+			}
983
+		}
984
+
985
+		// It passed the test - run the "real" method call
986
+		return parent::call($methodname, $argsbackup);
987
+	}
988
+
989
+	/**
990
+	 * @param $method
991
+	 * @return array|IXR_Error
992
+	 */
993
+	public function methodSignature($method) {
994
+		if (!$this->hasMethod($method)) {
995
+			return new IXR_Error(-32601, 'server error. requested method "' . $method . '" not specified.');
996
+		}
997
+		// We should be returning an array of types
998
+		$types  = $this->signatures[$method];
999
+		$return = array();
1000
+		foreach ($types as $type) {
1001
+			switch ($type) {
1002
+				case 'string':
1003
+					$return[] = 'string';
1004
+					break;
1005
+				case 'int':
1006
+				case 'i4':
1007
+					$return[] = 42;
1008
+					break;
1009
+				case 'double':
1010
+					$return[] = 3.1415;
1011
+					break;
1012
+				case 'dateTime.iso8601':
1013
+					$return[] = new IXR_Date(time());
1014
+					break;
1015
+				case 'boolean':
1016
+					$return[] = true;
1017
+					break;
1018
+				case 'base64':
1019
+					$return[] = new IXR_Base64('base64');
1020
+					break;
1021
+				case 'array':
1022
+					$return[] = array('array');
1023
+					break;
1024
+				case 'struct':
1025
+					$return[] = array('struct' => 'struct');
1026
+					break;
1027
+			}
1028
+		}
1029
+
1030
+		return $return;
1031
+	}
1032
+
1033
+	/**
1034
+	 * @param $method
1035
+	 * @return mixed
1036
+	 */
1037
+	public function methodHelp($method) {
1038
+		return $this->help[$method];
1039
+	}
1040 1040
 }
1041 1041
 
1042 1042
 /**
@@ -1044,34 +1044,34 @@  discard block
 block discarded – undo
1044 1044
  */
1045 1045
 class IXR_ClientMulticall extends IXR_Client
1046 1046
 {
1047
-    public $calls = array();
1048
-
1049
-    /**
1050
-     * IXR_ClientMulticall constructor.
1051
-     * @param      $server
1052
-     * @param bool $path
1053
-     * @param int  $port
1054
-     */
1055
-    public function __construct($server, $path = false, $port = 80) {
1056
-        parent::IXR_Client($server, $path, $port);
1057
-        $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
1058
-    }
1059
-
1060
-    public function addCall() {
1061
-        $args          = func_get_args();
1062
-        $methodName    = array_shift($args);
1063
-        $struct        = array(
1064
-            'methodName' => $methodName,
1065
-            'params'     => $args
1066
-        );
1067
-        $this->calls[] = $struct;
1068
-    }
1069
-
1070
-    /**
1071
-     * @return bool
1072
-     */
1073
-    public function query() {
1074
-        // Prepare multicall, then call the parent::query() method
1075
-        return parent::query('system.multicall', $this->calls);
1076
-    }
1047
+	public $calls = array();
1048
+
1049
+	/**
1050
+	 * IXR_ClientMulticall constructor.
1051
+	 * @param      $server
1052
+	 * @param bool $path
1053
+	 * @param int  $port
1054
+	 */
1055
+	public function __construct($server, $path = false, $port = 80) {
1056
+		parent::IXR_Client($server, $path, $port);
1057
+		$this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
1058
+	}
1059
+
1060
+	public function addCall() {
1061
+		$args          = func_get_args();
1062
+		$methodName    = array_shift($args);
1063
+		$struct        = array(
1064
+			'methodName' => $methodName,
1065
+			'params'     => $args
1066
+		);
1067
+		$this->calls[] = $struct;
1068
+	}
1069
+
1070
+	/**
1071
+	 * @return bool
1072
+	 */
1073
+	public function query() {
1074
+		// Prepare multicall, then call the parent::query() method
1075
+		return parent::query('system.multicall', $this->calls);
1076
+	}
1077 1077
 }
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
             }
36 36
         }
37 37
         if ($type === 'array') {
38
-            for ($i = 0, $j = count($this->data); $i < $j; ++$i) {
38
+            for ($i = 0, $j = count($this->data); $i<$j; ++$i) {
39 39
                 $this->data[$i] = new IXR_Value($this->data[$i]);
40 40
             }
41 41
         }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         /* We have an array - is it an array or a struct ? */
74 74
         if ($this->isStruct($this->data)) {
75 75
             return 'struct';
76
-        } else {
76
+        }else {
77 77
             return 'array';
78 78
         }
79 79
     }
@@ -85,31 +85,31 @@  discard block
 block discarded – undo
85 85
         /* Return XML for this value */
86 86
         switch ($this->type) {
87 87
             case 'boolean':
88
-                return '<boolean>' . ($this->data ? '1' : '0') . '</boolean>';
88
+                return '<boolean>'.($this->data ? '1' : '0').'</boolean>';
89 89
                 break;
90 90
             case 'int':
91
-                return '<int>' . $this->data . '</int>';
91
+                return '<int>'.$this->data.'</int>';
92 92
                 break;
93 93
             case 'double':
94
-                return '<double>' . $this->data . '</double>';
94
+                return '<double>'.$this->data.'</double>';
95 95
                 break;
96 96
             case 'string':
97
-                return '<string>' . htmlspecialchars($this->data) . '</string>';
97
+                return '<string>'.htmlspecialchars($this->data).'</string>';
98 98
                 break;
99 99
             case 'array':
100
-                $return = '<array><data>' . "\n";
100
+                $return = '<array><data>'."\n";
101 101
                 foreach ($this->data as $item) {
102
-                    $return .= '  <value>' . $item->getXml() . "</value>\n";
102
+                    $return .= '  <value>'.$item->getXml()."</value>\n";
103 103
                 }
104 104
                 $return .= '</data></array>';
105 105
 
106 106
                 return $return;
107 107
                 break;
108 108
             case 'struct':
109
-                $return = '<struct>' . "\n";
109
+                $return = '<struct>'."\n";
110 110
                 foreach ($this->data as $name => $value) {
111 111
                     $return .= "  <member><name>$name</name><value>";
112
-                    $return .= $value->getXml() . "</value></member>\n";
112
+                    $return .= $value->getXml()."</value></member>\n";
113 113
                 }
114 114
                 $return .= '</struct>';
115 115
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         /* Nasty function to check if an array is a struct or not */
133 133
         $expected = 0;
134 134
         foreach ($array as $key => $value) {
135
-            if ((string)$key != (string)$expected) {
135
+            if ((string) $key != (string) $expected) {
136 136
                 return true;
137 137
             }
138 138
             ++$expected;
@@ -148,15 +148,15 @@  discard block
 block discarded – undo
148 148
 class IXR_Message
149 149
 {
150 150
     public $message;
151
-    public $messageType;  // methodCall / methodResponse / fault
151
+    public $messageType; // methodCall / methodResponse / fault
152 152
     public $faultCode;
153 153
     public $faultString;
154 154
     public $methodName;
155 155
     public $params;
156 156
     // Current variable stacks
157
-    public $_arraystructs      = array();   // The stack used to keep track of the current array/struct
157
+    public $_arraystructs      = array(); // The stack used to keep track of the current array/struct
158 158
     public $_arraystructstypes = array(); // Stack keeping track of if things are structs or array
159
-    public $_currentStructName = array();  // A stack as well
159
+    public $_currentStructName = array(); // A stack as well
160 160
     public $_param;
161 161
     public $_value;
162 162
     public $_currentTag;
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
      */
178 178
     public function parse() {
179 179
         // first remove the XML declaration
180
-        $this->message = preg_replace('/<\?xml(.*)?\?' . '>/', '', $this->message);
180
+        $this->message = preg_replace('/<\?xml(.*)?\?'.'>/', '', $this->message);
181 181
         if (trim($this->message) == '') {
182 182
             return false;
183 183
         }
@@ -247,17 +247,17 @@  discard block
 block discarded – undo
247 247
         switch ($tag) {
248 248
             case 'int':
249 249
             case 'i4':
250
-                $value                     = (int)trim($this->_currentTagContents);
250
+                $value                     = (int) trim($this->_currentTagContents);
251 251
                 $this->_currentTagContents = '';
252 252
                 $valueFlag                 = true;
253 253
                 break;
254 254
             case 'double':
255
-                $value                     = (double)trim($this->_currentTagContents);
255
+                $value                     = (double) trim($this->_currentTagContents);
256 256
                 $this->_currentTagContents = '';
257 257
                 $valueFlag                 = true;
258 258
                 break;
259 259
             case 'string':
260
-                $value                     = (string)trim($this->_currentTagContents);
260
+                $value                     = (string) trim($this->_currentTagContents);
261 261
                 $this->_currentTagContents = '';
262 262
                 $valueFlag                 = true;
263 263
                 break;
@@ -270,13 +270,13 @@  discard block
 block discarded – undo
270 270
             case 'value':
271 271
                 // "If no type is indicated, the type is string."
272 272
                 if (trim($this->_currentTagContents) != '') {
273
-                    $value                     = (string)$this->_currentTagContents;
273
+                    $value                     = (string) $this->_currentTagContents;
274 274
                     $this->_currentTagContents = '';
275 275
                     $valueFlag                 = true;
276 276
                 }
277 277
                 break;
278 278
             case 'boolean':
279
-                $value                     = (boolean)trim($this->_currentTagContents);
279
+                $value                     = (boolean) trim($this->_currentTagContents);
280 280
                 $this->_currentTagContents = '';
281 281
                 $valueFlag                 = true;
282 282
                 break;
@@ -310,17 +310,17 @@  discard block
 block discarded – undo
310 310
                 $value = trim($value);
311 311
             }
312 312
             */
313
-            if (count($this->_arraystructs) > 0) {
313
+            if (count($this->_arraystructs)>0) {
314 314
                 // Add value to struct or array
315
-                if ($this->_arraystructstypes[count($this->_arraystructstypes) - 1] === 'struct') {
315
+                if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] === 'struct') {
316 316
                     // Add to struct
317 317
                     $this->_arraystructs[count($this->_arraystructs)
318
-                                         - 1][$this->_currentStructName[count($this->_currentStructName) - 1]] = $value;
319
-                } else {
318
+                                         - 1][$this->_currentStructName[count($this->_currentStructName)-1]] = $value;
319
+                }else {
320 320
                     // Add to array
321
-                    $this->_arraystructs[count($this->_arraystructs) - 1][] = $value;
321
+                    $this->_arraystructs[count($this->_arraystructs)-1][] = $value;
322 322
                 }
323
-            } else {
323
+            }else {
324 324
                 // Just add as a paramater
325 325
                 $this->params[] = $value;
326 326
             }
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
      */
403 403
     public function call($methodname, $args) {
404 404
         if (!$this->hasMethod($methodname)) {
405
-            return new IXR_Error(-32601, 'server error. requested method ' . $methodname . ' does not exist.');
405
+            return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
406 406
         }
407 407
         $method = $this->callbacks[$methodname];
408 408
         // Perform the callback and send the response
@@ -415,19 +415,19 @@  discard block
 block discarded – undo
415 415
             // It's a class method - check it exists
416 416
             $method = substr($method, 5);
417 417
             if (!method_exists($this, $method)) {
418
-                return new IXR_Error(-32601, 'server error. requested class method "' . $method . '" does not exist.');
418
+                return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
419 419
             }
420 420
             // Call the method
421 421
             $result = $this->$method($args);
422
-        } else {
422
+        }else {
423 423
             // It's a function - does it exist?
424 424
             if (is_array($method)) {
425 425
                 if (!method_exists($method[0], $method[1])) {
426 426
                     return new IXR_Error(-32601,
427
-                                         'server error. requested object method "' . $method[1] . '" does not exist.');
427
+                                         'server error. requested object method "'.$method[1].'" does not exist.');
428 428
                 }
429 429
             } elseif (!function_exists($method)) {
430
-                return new IXR_Error(-32601, 'server error. requested function "' . $method . '" does not exist.');
430
+                return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
431 431
             }
432 432
             // Call the function
433 433
             $result = call_user_func($method, $args);
@@ -452,12 +452,12 @@  discard block
 block discarded – undo
452 452
      * @param $xml
453 453
      */
454 454
     public function output($xml) {
455
-        $xml    = '<?xml version="1.0"?>' . "\n" . $xml;
455
+        $xml    = '<?xml version="1.0"?>'."\n".$xml;
456 456
         $length = strlen($xml);
457 457
         header('Connection: close');
458
-        header('Content-Length: ' . $length);
458
+        header('Content-Length: '.$length);
459 459
         header('Content-Type: text/xml');
460
-        header('Date: ' . date('r'));
460
+        header('Date: '.date('r'));
461 461
         echo $xml;
462 462
         exit;
463 463
     }
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
             $params = $call['params'];
525 525
             if ($method === 'system.multicall') {
526 526
                 $result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden');
527
-            } else {
527
+            }else {
528 528
                 $result = $this->call($method, $params);
529 529
             }
530 530
             if (is_a($result, 'IXR_Error')) {
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
                     'faultCode'   => $result->code,
533 533
                     'faultString' => $result->message
534 534
                 );
535
-            } else {
535
+            }else {
536 536
                 $return[] = array($result);
537 537
             }
538 538
         }
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
             if (!$this->path) {
626 626
                 $this->path = '/';
627 627
             }
628
-        } else {
628
+        }else {
629 629
             $this->server  = $server;
630 630
             $this->path    = $path;
631 631
             $this->port    = $port;
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
         $request .= $xml;
653 653
         // Now send the request
654 654
         if ($this->debug) {
655
-            echo '<pre>' . htmlspecialchars($request) . "\n</pre>\n\n";
655
+            echo '<pre>'.htmlspecialchars($request)."\n</pre>\n\n";
656 656
         }
657 657
         $fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);
658 658
         if (!$fp) {
@@ -679,11 +679,11 @@  discard block
 block discarded – undo
679 679
                 $gettingHeaders = false;
680 680
             }
681 681
             if (!$gettingHeaders) {
682
-                $contents .= trim($line) . "\n";
682
+                $contents .= trim($line)."\n";
683 683
             }
684 684
         }
685 685
         if ($this->debug) {
686
-            echo '<pre>' . htmlspecialchars($contents) . "\n</pre>\n\n";
686
+            echo '<pre>'.htmlspecialchars($contents)."\n</pre>\n\n";
687 687
         }
688 688
         // Now parse what we've got back
689 689
         $this->message = new IXR_Message($contents);
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
         // $time can be a PHP timestamp or an ISO one
802 802
         if (is_numeric($time)) {
803 803
             $this->parseTimestamp($time);
804
-        } else {
804
+        }else {
805 805
             $this->parseIso($time);
806 806
         }
807 807
     }
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
      * @return string
836 836
      */
837 837
     public function getIso() {
838
-        return $this->year . $this->month . $this->day . 'T' . $this->hour . ':' . $this->minute . ':' . $this->second
838
+        return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second
839 839
                . $this->timezone;
840 840
     }
841 841
 
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
      * @return string
844 844
      */
845 845
     public function getXml() {
846
-        return '<dateTime.iso8601>' . $this->getIso() . '</dateTime.iso8601>';
846
+        return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
847 847
     }
848 848
 
849 849
     /**
@@ -873,7 +873,7 @@  discard block
 block discarded – undo
873 873
      * @return string
874 874
      */
875 875
     public function getXml() {
876
-        return '<base64>' . base64_encode($this->data) . '</base64>';
876
+        return '<base64>'.base64_encode($this->data).'</base64>';
877 877
     }
878 878
 }
879 879
 
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
         // Over-rides default call method, adds signature check
931 931
         if (!$this->hasMethod($methodname)) {
932 932
             return new IXR_Error(-32601,
933
-                                 'server error. requested method "' . $this->message->methodName . '" not specified.');
933
+                                 'server error. requested method "'.$this->message->methodName.'" not specified.');
934 934
         }
935 935
         $method     = $this->callbacks[$methodname];
936 936
         $signature  = $this->signatures[$methodname];
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
         // Check the argument types
944 944
         $ok         = true;
945 945
         $argsbackup = $args;
946
-        for ($i = 0, $j = count($args); $i < $j; ++$i) {
946
+        for ($i = 0, $j = count($args); $i<$j; ++$i) {
947 947
             $arg  = array_shift($args);
948 948
             $type = array_shift($signature);
949 949
             switch ($type) {
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
      */
993 993
     public function methodSignature($method) {
994 994
         if (!$this->hasMethod($method)) {
995
-            return new IXR_Error(-32601, 'server error. requested method "' . $method . '" not specified.');
995
+            return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
996 996
         }
997 997
         // We should be returning an array of types
998 998
         $types  = $this->signatures[$method];
Please login to merge, or discard this patch.
class/feedcreator.class.php 3 patches
Doc Comments   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
     public $_feed;
353 353
 
354 354
     /**
355
-     * @param $format
355
+     * @param string $format
356 356
      */
357 357
     public function _setFormat($format) {
358 358
         switch (strtoupper($format)) {
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
     /**
530 530
      * Adds an FeedItem to the feed.
531 531
      *
532
-     * @param $item
532
+     * @param FeedItem $item
533 533
      * @internal param FeedItem $object $item The FeedItem to add to the feed.
534 534
      * @access   public
535 535
      */
@@ -547,6 +547,7 @@  discard block
 block discarded – undo
547 547
      * @static
548 548
      * @param string     string A string to be truncated.
549 549
      * @param int        length the maximum length the string should be truncated to
550
+     * @param integer $length
550 551
      * @return string the truncated string
551 552
      */
552 553
     public function iTrunc($string, $length) {
@@ -652,7 +653,7 @@  discard block
 block discarded – undo
652 653
     /**
653 654
      * @since  1.4
654 655
      * @access private
655
-     * @param $filename
656
+     * @param string $filename
656 657
      */
657 658
     public function _redirect($filename) {
658 659
         // attention, heavily-commented-out-area
@@ -807,7 +808,7 @@  discard block
 block discarded – undo
807 808
     /**
808 809
      * Gets the date stored in this FeedDate as an RFC 822 date.
809 810
      *
810
-     * @return a date in RFC 822 format
811
+     * @return string date in RFC 822 format
811 812
      */
812 813
     public function rfc822() {
813 814
         //return gmdate("r",$this->unix);
@@ -822,7 +823,7 @@  discard block
 block discarded – undo
822 823
     /**
823 824
      * Gets the date stored in this FeedDate as an ISO 8601 date.
824 825
      *
825
-     * @return a date in ISO 8601 format
826
+     * @return string date in ISO 8601 format
826 827
      */
827 828
     public function iso8601() {
828 829
         $date = gmdate("Y-m-d\TH:i:sO", $this->unix);
@@ -949,7 +950,7 @@  discard block
 block discarded – undo
949 950
     /**
950 951
      * Sets this RSS feed's version number.
951 952
      * @access private
952
-     * @param $version
953
+     * @param string $version
953 954
      */
954 955
     public function _setRSSVersion($version) {
955 956
         $this->RSSVersion = $version;
Please login to merge, or discard this patch.
Indentation   +1199 added lines, -1199 removed lines patch added patch discarded remove patch
@@ -197,43 +197,43 @@  discard block
 block discarded – undo
197 197
  */
198 198
 class FeedItem extends HtmlDescribable
199 199
 {
200
-    /**
201
-     * Mandatory attributes of an item.
202
-     */
203
-    public $title, $description, $link;
204
-
205
-    /**
206
-     * Optional attributes of an item.
207
-     */
208
-    public $author, $authorEmail, $image, $category, $comments, $guid, $source, $creator;
209
-
210
-    /**
211
-     * Publishing date of an item. May be in one of the following formats:
212
-     *
213
-     *  RFC 822:
214
-     *  "Mon, 20 Jan 03 18:05:41 +0400"
215
-     *  "20 Jan 03 18:05:41 +0000"
216
-     *
217
-     *  ISO 8601:
218
-     *  "2003-01-20T18:05:41+04:00"
219
-     *
220
-     *  Unix:
221
-     *  1043082341
222
-     */
223
-    public $date;
224
-
225
-    /**
226
-     * Any additional elements to include as an assiciated array. All $key => $value pairs
227
-     * will be included unencoded in the feed item in the form
228
-     *     <$key>$value</$key>
229
-     * Again: No encoding will be used! This means you can invalidate or enhance the feed
230
-     * if $value contains markup. This may be abused to embed tags not implemented by
231
-     * the FeedCreator class used.
232
-     */
233
-    public $additionalElements = array();
234
-
235
-    // on hold
236
-    // var $source;
200
+	/**
201
+	 * Mandatory attributes of an item.
202
+	 */
203
+	public $title, $description, $link;
204
+
205
+	/**
206
+	 * Optional attributes of an item.
207
+	 */
208
+	public $author, $authorEmail, $image, $category, $comments, $guid, $source, $creator;
209
+
210
+	/**
211
+	 * Publishing date of an item. May be in one of the following formats:
212
+	 *
213
+	 *  RFC 822:
214
+	 *  "Mon, 20 Jan 03 18:05:41 +0400"
215
+	 *  "20 Jan 03 18:05:41 +0000"
216
+	 *
217
+	 *  ISO 8601:
218
+	 *  "2003-01-20T18:05:41+04:00"
219
+	 *
220
+	 *  Unix:
221
+	 *  1043082341
222
+	 */
223
+	public $date;
224
+
225
+	/**
226
+	 * Any additional elements to include as an assiciated array. All $key => $value pairs
227
+	 * will be included unencoded in the feed item in the form
228
+	 *     <$key>$value</$key>
229
+	 * Again: No encoding will be used! This means you can invalidate or enhance the feed
230
+	 * if $value contains markup. This may be abused to embed tags not implemented by
231
+	 * the FeedCreator class used.
232
+	 */
233
+	public $additionalElements = array();
234
+
235
+	// on hold
236
+	// var $source;
237 237
 }
238 238
 
239 239
 /**
@@ -243,15 +243,15 @@  discard block
 block discarded – undo
243 243
  */
244 244
 class FeedImage extends HtmlDescribable
245 245
 {
246
-    /**
247
-     * Mandatory attributes of an image.
248
-     */
249
-    public $title, $url, $link;
250
-
251
-    /**
252
-     * Optional attributes of an image.
253
-     */
254
-    public $width, $height, $description;
246
+	/**
247
+	 * Mandatory attributes of an image.
248
+	 */
249
+	public $title, $url, $link;
250
+
251
+	/**
252
+	 * Optional attributes of an image.
253
+	 */
254
+	public $width, $height, $description;
255 255
 }
256 256
 
257 257
 /**
@@ -260,28 +260,28 @@  discard block
 block discarded – undo
260 260
  */
261 261
 class HtmlDescribable
262 262
 {
263
-    /**
264
-     * Indicates whether the description field should be rendered in HTML.
265
-     */
266
-    public $descriptionHtmlSyndicated;
267
-
268
-    /**
269
-     * Indicates whether and to how many characters a description should be truncated.
270
-     */
271
-    public $descriptionTruncSize;
272
-
273
-    /**
274
-     * Returns a formatted description field, depending on descriptionHtmlSyndicated and
275
-     * $descriptionTruncSize properties
276
-     * @return string the formatted description
277
-     */
278
-    public function getDescription() {
279
-        $descriptionField                = new FeedHtmlField($this->description);
280
-        $descriptionField->syndicateHtml = $this->descriptionHtmlSyndicated;
281
-        $descriptionField->truncSize     = $this->descriptionTruncSize;
282
-
283
-        return $descriptionField->output();
284
-    }
263
+	/**
264
+	 * Indicates whether the description field should be rendered in HTML.
265
+	 */
266
+	public $descriptionHtmlSyndicated;
267
+
268
+	/**
269
+	 * Indicates whether and to how many characters a description should be truncated.
270
+	 */
271
+	public $descriptionTruncSize;
272
+
273
+	/**
274
+	 * Returns a formatted description field, depending on descriptionHtmlSyndicated and
275
+	 * $descriptionTruncSize properties
276
+	 * @return string the formatted description
277
+	 */
278
+	public function getDescription() {
279
+		$descriptionField                = new FeedHtmlField($this->description);
280
+		$descriptionField->syndicateHtml = $this->descriptionHtmlSyndicated;
281
+		$descriptionField->truncSize     = $this->descriptionTruncSize;
282
+
283
+		return $descriptionField->output();
284
+	}
285 285
 }
286 286
 
287 287
 /**
@@ -292,50 +292,50 @@  discard block
 block discarded – undo
292 292
  */
293 293
 class FeedHtmlField
294 294
 {
295
-    /**
296
-     * Mandatory attributes of a FeedHtmlField.
297
-     */
298
-    public $rawFieldContent;
299
-
300
-    /**
301
-     * Optional attributes of a FeedHtmlField.
302
-     *
303
-     */
304
-    public $truncSize, $syndicateHtml;
305
-
306
-    /**
307
-     * Creates a new instance of FeedHtmlField.
308
-     * @param $parFieldContent
309
-     * @internal param $string : if given, sets the rawFieldContent property
310
-     */
311
-    public function __construct($parFieldContent) {
312
-        if ($parFieldContent) {
313
-            $this->rawFieldContent = $parFieldContent;
314
-        }
315
-    }
316
-
317
-    /**
318
-     * Creates the right output, depending on $truncSize, $syndicateHtml properties.
319
-     * @return string the formatted field
320
-     */
321
-    public function output() {
322
-        // when field available and syndicated in html we assume
323
-        // - valid html in $rawFieldContent and we enclose in CDATA tags
324
-        // - no truncation (truncating risks producing invalid html)
325
-        if (!$this->rawFieldContent) {
326
-            $result = '';
327
-        } elseif ($this->syndicateHtml) {
328
-            $result = '<![CDATA[' . $this->rawFieldContent . ']]>';
329
-        } else {
330
-            if ($this->truncSize && is_int($this->truncSize)) {
331
-                $result = FeedCreator::iTrunc(htmlspecialchars($this->rawFieldContent), $this->truncSize);
332
-            } else {
333
-                $result = htmlspecialchars($this->rawFieldContent);
334
-            }
335
-        }
336
-
337
-        return $result;
338
-    }
295
+	/**
296
+	 * Mandatory attributes of a FeedHtmlField.
297
+	 */
298
+	public $rawFieldContent;
299
+
300
+	/**
301
+	 * Optional attributes of a FeedHtmlField.
302
+	 *
303
+	 */
304
+	public $truncSize, $syndicateHtml;
305
+
306
+	/**
307
+	 * Creates a new instance of FeedHtmlField.
308
+	 * @param $parFieldContent
309
+	 * @internal param $string : if given, sets the rawFieldContent property
310
+	 */
311
+	public function __construct($parFieldContent) {
312
+		if ($parFieldContent) {
313
+			$this->rawFieldContent = $parFieldContent;
314
+		}
315
+	}
316
+
317
+	/**
318
+	 * Creates the right output, depending on $truncSize, $syndicateHtml properties.
319
+	 * @return string the formatted field
320
+	 */
321
+	public function output() {
322
+		// when field available and syndicated in html we assume
323
+		// - valid html in $rawFieldContent and we enclose in CDATA tags
324
+		// - no truncation (truncating risks producing invalid html)
325
+		if (!$this->rawFieldContent) {
326
+			$result = '';
327
+		} elseif ($this->syndicateHtml) {
328
+			$result = '<![CDATA[' . $this->rawFieldContent . ']]>';
329
+		} else {
330
+			if ($this->truncSize && is_int($this->truncSize)) {
331
+				$result = FeedCreator::iTrunc(htmlspecialchars($this->rawFieldContent), $this->truncSize);
332
+			} else {
333
+				$result = htmlspecialchars($this->rawFieldContent);
334
+			}
335
+		}
336
+
337
+		return $result;
338
+	}
339 339
 }
340 340
 
341 341
 /**
@@ -349,125 +349,125 @@  discard block
 block discarded – undo
349 349
  */
350 350
 class UniversalFeedCreator extends FeedCreator
351 351
 {
352
-    public $_feed;
353
-
354
-    /**
355
-     * @param $format
356
-     */
357
-    public function _setFormat($format) {
358
-        switch (strtoupper($format)) {
359
-
360
-            case '2.0':
361
-                // fall through
362
-            case 'RSS2.0':
363
-                $this->_feed = new RSSCreator20();
364
-                break;
365
-
366
-            case '1.0':
367
-                // fall through
368
-            case 'RSS1.0':
369
-                $this->_feed = new RSSCreator10();
370
-                break;
371
-
372
-            case '0.91':
373
-                // fall through
374
-            case 'RSS0.91':
375
-                $this->_feed = new RSSCreator091();
376
-                break;
377
-
378
-            case 'PIE0.1':
379
-                $this->_feed = new PIECreator01();
380
-                break;
381
-
382
-            case 'MBOX':
383
-                $this->_feed = new MBOXCreator();
384
-                break;
385
-
386
-            case 'OPML':
387
-                $this->_feed = new OPMLCreator();
388
-                break;
389
-
390
-            case 'ATOM':
391
-                // fall through: always the latest ATOM version
392
-
393
-            case 'ATOM0.3':
394
-                $this->_feed = new AtomCreator03();
395
-                break;
396
-
397
-            case 'HTML':
398
-                $this->_feed = new HTMLCreator();
399
-                break;
400
-
401
-            case 'JS':
402
-                // fall through
403
-            case 'JAVASCRIPT':
404
-                $this->_feed = new JSCreator();
405
-                break;
406
-
407
-            default:
408
-                $this->_feed = new RSSCreator091();
409
-                break;
410
-        }
411
-
412
-        $vars = get_object_vars($this);
413
-        foreach ($vars as $key => $value) {
414
-            // prevent overwriting of properties "contentType", "encoding"; do not copy "_feed" itself
415
-            //if (!in_array($key, array("_feed", "contentType", "encoding"))) {
416
-            $this->_feed->{$key} = $this->{$key};
417
-            //}
418
-        }
419
-    }
420
-
421
-    /**
422
-     * Creates a syndication feed based on the items previously added.
423
-     *
424
-     * @see        FeedCreator::addItem()
425
-     * @param    string    format    format the feed should comply to. Valid values are:
426
-     *                     "PIE0.1", "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM0.3", "HTML", "JS"
427
-     * @return string the contents of the feed.
428
-     */
429
-    public function createFeed($format = 'RSS0.91') {
430
-        $this->_setFormat($format);
431
-
432
-        return $this->_feed->createFeed();
433
-    }
434
-
435
-    /**
436
-     * Saves this feed as a file on the local disk. After the file is saved, an HTTP redirect
437
-     * header may be sent to redirect the use to the newly created file.
438
-     * @since    1.4
439
-     *
440
-     * @param string $format
441
-     * @param string $filename
442
-     * @param bool   $displayContents displayContents optional    send the content of the file or not. If true, the file will be sent in the body of the response.
443
-     * @internal param format $string format the feed should comply to. Valid values are:
444
-     *                                "PIE0.1" (deprecated), "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM", "ATOM0.3", "HTML", "JS"
445
-     * @internal param filename $string optional    the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()).
446
-     */
447
-    public function saveFeed($format = 'RSS0.91', $filename = '', $displayContents = true) {
448
-        $this->_setFormat($format);
449
-        $this->_feed->saveFeed($filename, $displayContents);
450
-    }
451
-
452
-    /**
453
-     * Turns on caching and checks if there is a recent version of this feed in the cache.
454
-     * If there is, an HTTP redirect header is sent.
455
-     * To effectively use caching, you should create the FeedCreator object and call this method
456
-     * before anything else, especially before you do the time consuming task to build the feed
457
-     * (web fetching, for example).
458
-     *
459
-     * @param string $format
460
-     * @param string $filename
461
-     * @param int    $timeout
462
-     * @internal param format $string format the feed should comply to. Valid values are:
463
-     *                     "PIE0.1" (deprecated), "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM0.3".
464
-     * @internal param string $filename optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()).
465
-     * @internal param int $timeout optional the timeout in seconds before a cached version is refreshed (defaults to 3600 = 1 hour)
466
-     */
467
-    public function useCached($format = 'RSS0.91', $filename = '', $timeout = 3600) {
468
-        $this->_setFormat($format);
469
-        $this->_feed->useCached($filename, $timeout);
470
-    }
352
+	public $_feed;
353
+
354
+	/**
355
+	 * @param $format
356
+	 */
357
+	public function _setFormat($format) {
358
+		switch (strtoupper($format)) {
359
+
360
+			case '2.0':
361
+				// fall through
362
+			case 'RSS2.0':
363
+				$this->_feed = new RSSCreator20();
364
+				break;
365
+
366
+			case '1.0':
367
+				// fall through
368
+			case 'RSS1.0':
369
+				$this->_feed = new RSSCreator10();
370
+				break;
371
+
372
+			case '0.91':
373
+				// fall through
374
+			case 'RSS0.91':
375
+				$this->_feed = new RSSCreator091();
376
+				break;
377
+
378
+			case 'PIE0.1':
379
+				$this->_feed = new PIECreator01();
380
+				break;
381
+
382
+			case 'MBOX':
383
+				$this->_feed = new MBOXCreator();
384
+				break;
385
+
386
+			case 'OPML':
387
+				$this->_feed = new OPMLCreator();
388
+				break;
389
+
390
+			case 'ATOM':
391
+				// fall through: always the latest ATOM version
392
+
393
+			case 'ATOM0.3':
394
+				$this->_feed = new AtomCreator03();
395
+				break;
396
+
397
+			case 'HTML':
398
+				$this->_feed = new HTMLCreator();
399
+				break;
400
+
401
+			case 'JS':
402
+				// fall through
403
+			case 'JAVASCRIPT':
404
+				$this->_feed = new JSCreator();
405
+				break;
406
+
407
+			default:
408
+				$this->_feed = new RSSCreator091();
409
+				break;
410
+		}
411
+
412
+		$vars = get_object_vars($this);
413
+		foreach ($vars as $key => $value) {
414
+			// prevent overwriting of properties "contentType", "encoding"; do not copy "_feed" itself
415
+			//if (!in_array($key, array("_feed", "contentType", "encoding"))) {
416
+			$this->_feed->{$key} = $this->{$key};
417
+			//}
418
+		}
419
+	}
420
+
421
+	/**
422
+	 * Creates a syndication feed based on the items previously added.
423
+	 *
424
+	 * @see        FeedCreator::addItem()
425
+	 * @param    string    format    format the feed should comply to. Valid values are:
426
+	 *                     "PIE0.1", "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM0.3", "HTML", "JS"
427
+	 * @return string the contents of the feed.
428
+	 */
429
+	public function createFeed($format = 'RSS0.91') {
430
+		$this->_setFormat($format);
431
+
432
+		return $this->_feed->createFeed();
433
+	}
434
+
435
+	/**
436
+	 * Saves this feed as a file on the local disk. After the file is saved, an HTTP redirect
437
+	 * header may be sent to redirect the use to the newly created file.
438
+	 * @since    1.4
439
+	 *
440
+	 * @param string $format
441
+	 * @param string $filename
442
+	 * @param bool   $displayContents displayContents optional    send the content of the file or not. If true, the file will be sent in the body of the response.
443
+	 * @internal param format $string format the feed should comply to. Valid values are:
444
+	 *                                "PIE0.1" (deprecated), "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM", "ATOM0.3", "HTML", "JS"
445
+	 * @internal param filename $string optional    the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()).
446
+	 */
447
+	public function saveFeed($format = 'RSS0.91', $filename = '', $displayContents = true) {
448
+		$this->_setFormat($format);
449
+		$this->_feed->saveFeed($filename, $displayContents);
450
+	}
451
+
452
+	/**
453
+	 * Turns on caching and checks if there is a recent version of this feed in the cache.
454
+	 * If there is, an HTTP redirect header is sent.
455
+	 * To effectively use caching, you should create the FeedCreator object and call this method
456
+	 * before anything else, especially before you do the time consuming task to build the feed
457
+	 * (web fetching, for example).
458
+	 *
459
+	 * @param string $format
460
+	 * @param string $filename
461
+	 * @param int    $timeout
462
+	 * @internal param format $string format the feed should comply to. Valid values are:
463
+	 *                     "PIE0.1" (deprecated), "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM0.3".
464
+	 * @internal param string $filename optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()).
465
+	 * @internal param int $timeout optional the timeout in seconds before a cached version is refreshed (defaults to 3600 = 1 hour)
466
+	 */
467
+	public function useCached($format = 'RSS0.91', $filename = '', $timeout = 3600) {
468
+		$this->_setFormat($format);
469
+		$this->_feed->useCached($filename, $timeout);
470
+	}
471 471
 }
472 472
 
473 473
 /**
@@ -480,246 +480,246 @@  discard block
 block discarded – undo
480 480
  */
481 481
 class FeedCreator extends HtmlDescribable
482 482
 {
483
-    /**
484
-     * Mandatory attributes of a feed.
485
-     */
486
-    public $title, $description, $link;
487
-
488
-    /**
489
-     * Optional attributes of a feed.
490
-     */
491
-    public $syndicationURL, $image, $language, $copyright, $pubDate, $lastBuildDate, $editor, $editorEmail, $webmaster, $category, $docs, $ttl, $rating, $skipHours, $skipDays;
492
-
493
-    /**
494
-     * The url of the external xsl stylesheet used to format the naked rss feed.
495
-     * Ignored in the output when empty.
496
-     */
497
-    public $xslStyleSheet = '';
498
-
499
-    public $cssStyleSheet = '';
500
-
501
-    /**
502
-     * @access private
503
-     */
504
-    public $items = array();
505
-
506
-    /**
507
-     * This feed's MIME content type.
508
-     * @since  1.4
509
-     * @access private
510
-     */
511
-    public $contentType = 'application/xml';
512
-
513
-    /**
514
-     * This feed's character encoding.
515
-     * @since 1.6.1
516
-     **/
517
-    public $encoding = 'ISO-8859-1';
518
-
519
-    /**
520
-     * Any additional elements to include as an assiciated array. All $key => $value pairs
521
-     * will be included unencoded in the feed in the form
522
-     *     <$key>$value</$key>
523
-     * Again: No encoding will be used! This means you can invalidate or enhance the feed
524
-     * if $value contains markup. This may be abused to embed tags not implemented by
525
-     * the FeedCreator class used.
526
-     */
527
-    public $additionalElements = array();
528
-
529
-    /**
530
-     * Adds an FeedItem to the feed.
531
-     *
532
-     * @param $item
533
-     * @internal param FeedItem $object $item The FeedItem to add to the feed.
534
-     * @access   public
535
-     */
536
-    public function addItem($item) {
537
-        $this->items[] = $item;
538
-    }
539
-
540
-    /**
541
-     * Truncates a string to a certain length at the most sensible point.
542
-     * First, if there's a '.' character near the end of the string, the string is truncated after this character.
543
-     * If there is no '.', the string is truncated after the last ' ' character.
544
-     * If the string is truncated, " ..." is appended.
545
-     * If the string is already shorter than $length, it is returned unchanged.
546
-     *
547
-     * @static
548
-     * @param string     string A string to be truncated.
549
-     * @param int        length the maximum length the string should be truncated to
550
-     * @return string the truncated string
551
-     */
552
-    public function iTrunc($string, $length) {
553
-        if (strlen($string) <= $length) {
554
-            return $string;
555
-        }
556
-
557
-        $pos = strrpos($string, '.');
558
-        if ($pos >= $length - 4) {
559
-            $string = substr($string, 0, $length - 4);
560
-            $pos    = strrpos($string, '.');
561
-        }
562
-        if ($pos >= $length * 0.4) {
563
-            return substr($string, 0, $pos + 1) . ' ...';
564
-        }
565
-
566
-        $pos = strrpos($string, ' ');
567
-        if ($pos >= $length - 4) {
568
-            $string = substr($string, 0, $length - 4);
569
-            $pos    = strrpos($string, ' ');
570
-        }
571
-        if ($pos >= $length * 0.4) {
572
-            return substr($string, 0, $pos) . ' ...';
573
-        }
574
-
575
-        return substr($string, 0, $length - 4) . ' ...';
576
-    }
577
-
578
-    /**
579
-     * Creates a comment indicating the generator of this feed.
580
-     * The format of this comment seems to be recognized by
581
-     * Syndic8.com.
582
-     */
583
-    public function _createGeneratorComment() {
584
-        return "<!-- generator=\"" . FEEDCREATOR_VERSION . "\" -->\n";
585
-    }
586
-
587
-    /**
588
-     * Creates a string containing all additional elements specified in
589
-     * $additionalElements.
590
-     * @param array  $elements
591
-     * @param string $indentString
592
-     * @return string the XML tags corresponding to $additionalElements
593
-     * @internal param array $elements an associative array containing key => value pairs
594
-     * @internal param string $indentString a string that will be inserted before every generated line
595
-     */
596
-    public function _createAdditionalElements($elements, $indentString = '') {
597
-        $ae = '';
598
-        if (is_array($elements)) {
599
-            foreach ($elements as $key => $value) {
600
-                $ae .= $indentString . "<$key>$value</$key>\n";
601
-            }
602
-        }
603
-
604
-        return $ae;
605
-    }
606
-
607
-    /**
608
-     * @return string
609
-     */
610
-    public function _createStylesheetReferences() {
611
-        $xml = '';
612
-        if ($this->cssStyleSheet) {
613
-            $xml .= "<?xml-stylesheet href=\"" . $this->cssStyleSheet . "\" type=\"text/css\"?>\n";
614
-        }
615
-        if ($this->xslStyleSheet) {
616
-            $xml .= "<?xml-stylesheet href=\"" . $this->xslStyleSheet . "\" type=\"text/xsl\"?>\n";
617
-        }
618
-
619
-        return $xml;
620
-    }
621
-
622
-    /**
623
-     * Builds the feed's text.
624
-     * @abstract
625
-     * @return string the feed's complete text
626
-     */
627
-    public function createFeed() {
628
-    }
629
-
630
-    /**
631
-     * Generate a filename for the feed cache file. The result will be $_SERVER["PHP_SELF"] with the extension changed to .xml.
632
-     * For example:
633
-     *
634
-     * echo $_SERVER["PHP_SELF"]."\n";
635
-     * echo FeedCreator::_generateFilename();
636
-     *
637
-     * would produce:
638
-     *
639
-     * /rss/latestnews.php
640
-     * latestnews.xml
641
-     *
642
-     * @return string the feed cache filename
643
-     * @since  1.4
644
-     * @access private
645
-     */
646
-    public function _generateFilename() {
647
-        $fileInfo = pathinfo($_SERVER['PHP_SELF']);
648
-
649
-        return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.xml';
650
-    }
651
-
652
-    /**
653
-     * @since  1.4
654
-     * @access private
655
-     * @param $filename
656
-     */
657
-    public function _redirect($filename) {
658
-        // attention, heavily-commented-out-area
659
-
660
-        // maybe use this in addition to file time checking
661
-        //Header("Expires: ".date("r",time()+$this->_timeout));
662
-
663
-        /* no caching at all, doesn't seem to work as good:
483
+	/**
484
+	 * Mandatory attributes of a feed.
485
+	 */
486
+	public $title, $description, $link;
487
+
488
+	/**
489
+	 * Optional attributes of a feed.
490
+	 */
491
+	public $syndicationURL, $image, $language, $copyright, $pubDate, $lastBuildDate, $editor, $editorEmail, $webmaster, $category, $docs, $ttl, $rating, $skipHours, $skipDays;
492
+
493
+	/**
494
+	 * The url of the external xsl stylesheet used to format the naked rss feed.
495
+	 * Ignored in the output when empty.
496
+	 */
497
+	public $xslStyleSheet = '';
498
+
499
+	public $cssStyleSheet = '';
500
+
501
+	/**
502
+	 * @access private
503
+	 */
504
+	public $items = array();
505
+
506
+	/**
507
+	 * This feed's MIME content type.
508
+	 * @since  1.4
509
+	 * @access private
510
+	 */
511
+	public $contentType = 'application/xml';
512
+
513
+	/**
514
+	 * This feed's character encoding.
515
+	 * @since 1.6.1
516
+	 **/
517
+	public $encoding = 'ISO-8859-1';
518
+
519
+	/**
520
+	 * Any additional elements to include as an assiciated array. All $key => $value pairs
521
+	 * will be included unencoded in the feed in the form
522
+	 *     <$key>$value</$key>
523
+	 * Again: No encoding will be used! This means you can invalidate or enhance the feed
524
+	 * if $value contains markup. This may be abused to embed tags not implemented by
525
+	 * the FeedCreator class used.
526
+	 */
527
+	public $additionalElements = array();
528
+
529
+	/**
530
+	 * Adds an FeedItem to the feed.
531
+	 *
532
+	 * @param $item
533
+	 * @internal param FeedItem $object $item The FeedItem to add to the feed.
534
+	 * @access   public
535
+	 */
536
+	public function addItem($item) {
537
+		$this->items[] = $item;
538
+	}
539
+
540
+	/**
541
+	 * Truncates a string to a certain length at the most sensible point.
542
+	 * First, if there's a '.' character near the end of the string, the string is truncated after this character.
543
+	 * If there is no '.', the string is truncated after the last ' ' character.
544
+	 * If the string is truncated, " ..." is appended.
545
+	 * If the string is already shorter than $length, it is returned unchanged.
546
+	 *
547
+	 * @static
548
+	 * @param string     string A string to be truncated.
549
+	 * @param int        length the maximum length the string should be truncated to
550
+	 * @return string the truncated string
551
+	 */
552
+	public function iTrunc($string, $length) {
553
+		if (strlen($string) <= $length) {
554
+			return $string;
555
+		}
556
+
557
+		$pos = strrpos($string, '.');
558
+		if ($pos >= $length - 4) {
559
+			$string = substr($string, 0, $length - 4);
560
+			$pos    = strrpos($string, '.');
561
+		}
562
+		if ($pos >= $length * 0.4) {
563
+			return substr($string, 0, $pos + 1) . ' ...';
564
+		}
565
+
566
+		$pos = strrpos($string, ' ');
567
+		if ($pos >= $length - 4) {
568
+			$string = substr($string, 0, $length - 4);
569
+			$pos    = strrpos($string, ' ');
570
+		}
571
+		if ($pos >= $length * 0.4) {
572
+			return substr($string, 0, $pos) . ' ...';
573
+		}
574
+
575
+		return substr($string, 0, $length - 4) . ' ...';
576
+	}
577
+
578
+	/**
579
+	 * Creates a comment indicating the generator of this feed.
580
+	 * The format of this comment seems to be recognized by
581
+	 * Syndic8.com.
582
+	 */
583
+	public function _createGeneratorComment() {
584
+		return "<!-- generator=\"" . FEEDCREATOR_VERSION . "\" -->\n";
585
+	}
586
+
587
+	/**
588
+	 * Creates a string containing all additional elements specified in
589
+	 * $additionalElements.
590
+	 * @param array  $elements
591
+	 * @param string $indentString
592
+	 * @return string the XML tags corresponding to $additionalElements
593
+	 * @internal param array $elements an associative array containing key => value pairs
594
+	 * @internal param string $indentString a string that will be inserted before every generated line
595
+	 */
596
+	public function _createAdditionalElements($elements, $indentString = '') {
597
+		$ae = '';
598
+		if (is_array($elements)) {
599
+			foreach ($elements as $key => $value) {
600
+				$ae .= $indentString . "<$key>$value</$key>\n";
601
+			}
602
+		}
603
+
604
+		return $ae;
605
+	}
606
+
607
+	/**
608
+	 * @return string
609
+	 */
610
+	public function _createStylesheetReferences() {
611
+		$xml = '';
612
+		if ($this->cssStyleSheet) {
613
+			$xml .= "<?xml-stylesheet href=\"" . $this->cssStyleSheet . "\" type=\"text/css\"?>\n";
614
+		}
615
+		if ($this->xslStyleSheet) {
616
+			$xml .= "<?xml-stylesheet href=\"" . $this->xslStyleSheet . "\" type=\"text/xsl\"?>\n";
617
+		}
618
+
619
+		return $xml;
620
+	}
621
+
622
+	/**
623
+	 * Builds the feed's text.
624
+	 * @abstract
625
+	 * @return string the feed's complete text
626
+	 */
627
+	public function createFeed() {
628
+	}
629
+
630
+	/**
631
+	 * Generate a filename for the feed cache file. The result will be $_SERVER["PHP_SELF"] with the extension changed to .xml.
632
+	 * For example:
633
+	 *
634
+	 * echo $_SERVER["PHP_SELF"]."\n";
635
+	 * echo FeedCreator::_generateFilename();
636
+	 *
637
+	 * would produce:
638
+	 *
639
+	 * /rss/latestnews.php
640
+	 * latestnews.xml
641
+	 *
642
+	 * @return string the feed cache filename
643
+	 * @since  1.4
644
+	 * @access private
645
+	 */
646
+	public function _generateFilename() {
647
+		$fileInfo = pathinfo($_SERVER['PHP_SELF']);
648
+
649
+		return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.xml';
650
+	}
651
+
652
+	/**
653
+	 * @since  1.4
654
+	 * @access private
655
+	 * @param $filename
656
+	 */
657
+	public function _redirect($filename) {
658
+		// attention, heavily-commented-out-area
659
+
660
+		// maybe use this in addition to file time checking
661
+		//Header("Expires: ".date("r",time()+$this->_timeout));
662
+
663
+		/* no caching at all, doesn't seem to work as good:
664 664
         Header("Cache-Control: no-cache");
665 665
         Header("Pragma: no-cache");
666 666
         */
667 667
 
668
-        // HTTP redirect, some feed readers' simple HTTP implementations don't follow it
669
-        //Header("Location: ".$filename);
670
-
671
-        header('Content-Type: ' . $this->contentType . '; charset=' . $this->encoding . '; filename='
672
-               . basename($filename));
673
-        header('Content-Disposition: inline; filename=' . basename($filename));
674
-        readfile($filename, 'r');
675
-        die();
676
-    }
677
-
678
-    /**
679
-     * Turns on caching and checks if there is a recent version of this feed in the cache.
680
-     * If there is, an HTTP redirect header is sent.
681
-     * To effectively use caching, you should create the FeedCreator object and call this method
682
-     * before anything else, especially before you do the time consuming task to build the feed
683
-     * (web fetching, for example).
684
-     * @since    1.4
685
-     * @param     filename  string  optional    the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()).
686
-     * @param int $timeout
687
-     * @internal param int $timeout optional    the timeout in seconds before a cached version is refreshed (defaults to 3600 = 1 hour)
688
-     */
689
-    public function useCached($filename = '', $timeout = 3600) {
690
-        $this->_timeout = $timeout;
691
-        if ($filename == '') {
692
-            $filename = $this->_generateFilename();
693
-        }
694
-        if (file_exists($filename) && (time() - filemtime($filename) < $timeout)) {
695
-            $this->_redirect($filename);
696
-        }
697
-    }
698
-
699
-    /**
700
-     * Saves this feed as a file on the local disk. After the file is saved, a redirect
701
-     * header may be sent to redirect the user to the newly created file.
702
-     * @since    1.4
703
-     *
704
-     * @param      filename  string  optional    the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()).
705
-     * @param bool $displayContents
706
-     * @internal param bool $redirect optional    send an HTTP redirect header or not. If true, the user will be automatically redirected to the created file.
707
-     */
708
-    public function saveFeed($filename = '', $displayContents = true) {
709
-        if ($filename == '') {
710
-            $filename = $this->_generateFilename();
711
-        }
712
-        $feedFile = fopen($filename, 'w+');
713
-        if ($feedFile) {
714
-            fwrite($feedFile, $this->createFeed());
715
-            fclose($feedFile);
716
-            if ($displayContents) {
717
-                $this->_redirect($filename);
718
-            }
719
-        } else {
720
-            echo '<br><b>Error creating feed file, please check write permissions.</b><br>';
721
-        }
722
-    }
668
+		// HTTP redirect, some feed readers' simple HTTP implementations don't follow it
669
+		//Header("Location: ".$filename);
670
+
671
+		header('Content-Type: ' . $this->contentType . '; charset=' . $this->encoding . '; filename='
672
+			   . basename($filename));
673
+		header('Content-Disposition: inline; filename=' . basename($filename));
674
+		readfile($filename, 'r');
675
+		die();
676
+	}
677
+
678
+	/**
679
+	 * Turns on caching and checks if there is a recent version of this feed in the cache.
680
+	 * If there is, an HTTP redirect header is sent.
681
+	 * To effectively use caching, you should create the FeedCreator object and call this method
682
+	 * before anything else, especially before you do the time consuming task to build the feed
683
+	 * (web fetching, for example).
684
+	 * @since    1.4
685
+	 * @param     filename  string  optional    the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()).
686
+	 * @param int $timeout
687
+	 * @internal param int $timeout optional    the timeout in seconds before a cached version is refreshed (defaults to 3600 = 1 hour)
688
+	 */
689
+	public function useCached($filename = '', $timeout = 3600) {
690
+		$this->_timeout = $timeout;
691
+		if ($filename == '') {
692
+			$filename = $this->_generateFilename();
693
+		}
694
+		if (file_exists($filename) && (time() - filemtime($filename) < $timeout)) {
695
+			$this->_redirect($filename);
696
+		}
697
+	}
698
+
699
+	/**
700
+	 * Saves this feed as a file on the local disk. After the file is saved, a redirect
701
+	 * header may be sent to redirect the user to the newly created file.
702
+	 * @since    1.4
703
+	 *
704
+	 * @param      filename  string  optional    the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()).
705
+	 * @param bool $displayContents
706
+	 * @internal param bool $redirect optional    send an HTTP redirect header or not. If true, the user will be automatically redirected to the created file.
707
+	 */
708
+	public function saveFeed($filename = '', $displayContents = true) {
709
+		if ($filename == '') {
710
+			$filename = $this->_generateFilename();
711
+		}
712
+		$feedFile = fopen($filename, 'w+');
713
+		if ($feedFile) {
714
+			fwrite($feedFile, $this->createFeed());
715
+			fclose($feedFile);
716
+			if ($displayContents) {
717
+				$this->_redirect($filename);
718
+			}
719
+		} else {
720
+			echo '<br><b>Error creating feed file, please check write permissions.</b><br>';
721
+		}
722
+	}
723 723
 }
724 724
 
725 725
 /**
@@ -728,120 +728,120 @@  discard block
 block discarded – undo
728 728
  */
729 729
 class FeedDate
730 730
 {
731
-    public $unix;
732
-
733
-    /**
734
-     * Creates a new instance of FeedDate representing a given date.
735
-     * Accepts RFC 822, ISO 8601 date formats as well as unix time stamps.
736
-     * @param mixed $dateString optional the date this FeedDate will represent. If not specified, the current date and time is used.
737
-     */
738
-    public function __construct($dateString = '') {
739
-        $tzOffset = 0;
740
-        if ($dateString == '') {
741
-            $dateString = date('r');
742
-        }
743
-
744
-        //if (is_integer($dateString)) {
745
-        if (is_numeric($dateString)) {
746
-            $this->unix = $dateString;
747
-
748
-            return;
749
-        }
750
-        if (preg_match("~(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\\s+)?(\\d{1,2})\\s+([a-zA-Z]{3})\\s+(\\d{4})\\s+(\\d{2}):(\\d{2}):(\\d{2})\\s+(.*)~",
751
-                       $dateString, $matches)) {
752
-            $months     = array(
753
-                'Jan' => 1,
754
-                'Feb' => 2,
755
-                'Mar' => 3,
756
-                'Apr' => 4,
757
-                'May' => 5,
758
-                'Jun' => 6,
759
-                'Jul' => 7,
760
-                'Aug' => 8,
761
-                'Sep' => 9,
762
-                'Oct' => 10,
763
-                'Nov' => 11,
764
-                'Dec' => 12
765
-            );
766
-            $this->unix = mktime($matches[4], $matches[5], $matches[6], $months[$matches[2]], $matches[1], $matches[3]);
767
-            if (substr($matches[7], 0, 1) == '+' || substr($matches[7], 0, 1) == '-') {
768
-                $tzOffset = (substr($matches[7], 0, 3) * 60 + substr($matches[7], -2)) * 60;
769
-            } else {
770
-                if (strlen($matches[7]) == 1) {
771
-                    $oneHour = 3600;
772
-                    $ord     = ord($matches[7]);
773
-                    if ($ord < ord('M')) {
774
-                        $tzOffset = (ord('A') - $ord - 1) * $oneHour;
775
-                    } elseif ($ord >= ord('M') && $matches[7] !== 'Z') {
776
-                        $tzOffset = ($ord - ord('M')) * $oneHour;
777
-                    } elseif ($matches[7] === 'Z') {
778
-                        $tzOffset = 0;
779
-                    }
780
-                }
781
-                switch ($matches[7]) {
782
-                    case 'UT':
783
-                    case 'GMT':
784
-                        $tzOffset = 0;
785
-                }
786
-            }
787
-            $this->unix += $tzOffset;
788
-
789
-            return;
790
-        }
791
-        if (preg_match("~(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(.*)~", $dateString, $matches)) {
792
-            $this->unix = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
793
-            if (substr($matches[7], 0, 1) == '+' || substr($matches[7], 0, 1) == '-') {
794
-                $tzOffset = (substr($matches[7], 0, 3) * 60 + substr($matches[7], -2)) * 60;
795
-            } else {
796
-                if ($matches[7] === 'Z') {
797
-                    $tzOffset = 0;
798
-                }
799
-            }
800
-            $this->unix += $tzOffset;
801
-
802
-            return;
803
-        }
804
-        $this->unix = 0;
805
-    }
806
-
807
-    /**
808
-     * Gets the date stored in this FeedDate as an RFC 822 date.
809
-     *
810
-     * @return a date in RFC 822 format
811
-     */
812
-    public function rfc822() {
813
-        //return gmdate("r",$this->unix);
814
-        $date = gmdate('D, d M Y H:i:s', $this->unix);
815
-        if (TIME_ZONE != '') {
816
-            $date .= ' ' . str_replace(':', '', TIME_ZONE);
817
-        }
818
-
819
-        return $date;
820
-    }
821
-
822
-    /**
823
-     * Gets the date stored in this FeedDate as an ISO 8601 date.
824
-     *
825
-     * @return a date in ISO 8601 format
826
-     */
827
-    public function iso8601() {
828
-        $date = gmdate("Y-m-d\TH:i:sO", $this->unix);
829
-        $date = substr($date, 0, 22) . ':' . substr($date, -2);
830
-        if (TIME_ZONE != '') {
831
-            $date = str_replace('+00:00', TIME_ZONE, $date);
832
-        }
833
-
834
-        return $date;
835
-    }
836
-
837
-    /**
838
-     * Gets the date stored in this FeedDate as unix time stamp.
839
-     *
840
-     * @return a date as a unix time stamp
841
-     */
842
-    public function unix() {
843
-        return $this->unix;
844
-    }
731
+	public $unix;
732
+
733
+	/**
734
+	 * Creates a new instance of FeedDate representing a given date.
735
+	 * Accepts RFC 822, ISO 8601 date formats as well as unix time stamps.
736
+	 * @param mixed $dateString optional the date this FeedDate will represent. If not specified, the current date and time is used.
737
+	 */
738
+	public function __construct($dateString = '') {
739
+		$tzOffset = 0;
740
+		if ($dateString == '') {
741
+			$dateString = date('r');
742
+		}
743
+
744
+		//if (is_integer($dateString)) {
745
+		if (is_numeric($dateString)) {
746
+			$this->unix = $dateString;
747
+
748
+			return;
749
+		}
750
+		if (preg_match("~(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\\s+)?(\\d{1,2})\\s+([a-zA-Z]{3})\\s+(\\d{4})\\s+(\\d{2}):(\\d{2}):(\\d{2})\\s+(.*)~",
751
+					   $dateString, $matches)) {
752
+			$months     = array(
753
+				'Jan' => 1,
754
+				'Feb' => 2,
755
+				'Mar' => 3,
756
+				'Apr' => 4,
757
+				'May' => 5,
758
+				'Jun' => 6,
759
+				'Jul' => 7,
760
+				'Aug' => 8,
761
+				'Sep' => 9,
762
+				'Oct' => 10,
763
+				'Nov' => 11,
764
+				'Dec' => 12
765
+			);
766
+			$this->unix = mktime($matches[4], $matches[5], $matches[6], $months[$matches[2]], $matches[1], $matches[3]);
767
+			if (substr($matches[7], 0, 1) == '+' || substr($matches[7], 0, 1) == '-') {
768
+				$tzOffset = (substr($matches[7], 0, 3) * 60 + substr($matches[7], -2)) * 60;
769
+			} else {
770
+				if (strlen($matches[7]) == 1) {
771
+					$oneHour = 3600;
772
+					$ord     = ord($matches[7]);
773
+					if ($ord < ord('M')) {
774
+						$tzOffset = (ord('A') - $ord - 1) * $oneHour;
775
+					} elseif ($ord >= ord('M') && $matches[7] !== 'Z') {
776
+						$tzOffset = ($ord - ord('M')) * $oneHour;
777
+					} elseif ($matches[7] === 'Z') {
778
+						$tzOffset = 0;
779
+					}
780
+				}
781
+				switch ($matches[7]) {
782
+					case 'UT':
783
+					case 'GMT':
784
+						$tzOffset = 0;
785
+				}
786
+			}
787
+			$this->unix += $tzOffset;
788
+
789
+			return;
790
+		}
791
+		if (preg_match("~(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(.*)~", $dateString, $matches)) {
792
+			$this->unix = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
793
+			if (substr($matches[7], 0, 1) == '+' || substr($matches[7], 0, 1) == '-') {
794
+				$tzOffset = (substr($matches[7], 0, 3) * 60 + substr($matches[7], -2)) * 60;
795
+			} else {
796
+				if ($matches[7] === 'Z') {
797
+					$tzOffset = 0;
798
+				}
799
+			}
800
+			$this->unix += $tzOffset;
801
+
802
+			return;
803
+		}
804
+		$this->unix = 0;
805
+	}
806
+
807
+	/**
808
+	 * Gets the date stored in this FeedDate as an RFC 822 date.
809
+	 *
810
+	 * @return a date in RFC 822 format
811
+	 */
812
+	public function rfc822() {
813
+		//return gmdate("r",$this->unix);
814
+		$date = gmdate('D, d M Y H:i:s', $this->unix);
815
+		if (TIME_ZONE != '') {
816
+			$date .= ' ' . str_replace(':', '', TIME_ZONE);
817
+		}
818
+
819
+		return $date;
820
+	}
821
+
822
+	/**
823
+	 * Gets the date stored in this FeedDate as an ISO 8601 date.
824
+	 *
825
+	 * @return a date in ISO 8601 format
826
+	 */
827
+	public function iso8601() {
828
+		$date = gmdate("Y-m-d\TH:i:sO", $this->unix);
829
+		$date = substr($date, 0, 22) . ':' . substr($date, -2);
830
+		if (TIME_ZONE != '') {
831
+			$date = str_replace('+00:00', TIME_ZONE, $date);
832
+		}
833
+
834
+		return $date;
835
+	}
836
+
837
+	/**
838
+	 * Gets the date stored in this FeedDate as unix time stamp.
839
+	 *
840
+	 * @return a date as a unix time stamp
841
+	 */
842
+	public function unix() {
843
+		return $this->unix;
844
+	}
845 845
 }
846 846
 
847 847
 /**
@@ -853,74 +853,74 @@  discard block
 block discarded – undo
853 853
  */
854 854
 class RSSCreator10 extends FeedCreator
855 855
 {
856
-    /**
857
-     * Builds the RSS feed's text. The feed will be compliant to RDF Site Summary (RSS) 1.0.
858
-     * The feed will contain all items previously added in the same order.
859
-     * @return string the feed's complete text
860
-     */
861
-    public function createFeed() {
862
-        $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
863
-        $feed .= $this->_createGeneratorComment();
864
-        if ($this->cssStyleSheet == '') {
865
-            $cssStyleSheet = 'http://www.w3.org/2000/08/w3c-synd/style.css';
866
-        }
867
-        $feed .= $this->_createStylesheetReferences();
868
-        $feed .= "<rdf:RDF\n";
869
-        $feed .= "    xmlns=\"http://purl.org/rss/1.0/\"\n";
870
-        $feed .= "    xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n";
871
-        $feed .= "    xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\"\n";
872
-        $feed .= "    xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";
873
-        $feed .= "    <channel rdf:about=\"" . $this->syndicationURL . "\">\n";
874
-        $feed .= '        <title>' . htmlspecialchars($this->title) . "</title>\n";
875
-        $feed .= '        <description>' . htmlspecialchars($this->description) . "</description>\n";
876
-        $feed .= '        <link>' . $this->link . "</link>\n";
877
-        if ($this->image != null) {
878
-            $feed .= "        <image rdf:resource=\"" . $this->image->url . "\" />\n";
879
-        }
880
-        $now = new FeedDate();
881
-        $feed .= '       <dc:date>' . htmlspecialchars($now->iso8601()) . "</dc:date>\n";
882
-        $feed .= "        <items>\n";
883
-        $feed .= "            <rdf:Seq>\n";
884
-        for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
885
-            $feed .= "                <rdf:li rdf:resource=\"" . htmlspecialchars($this->items[$i]->link) . "\"/>\n";
886
-        }
887
-        $feed .= "            </rdf:Seq>\n";
888
-        $feed .= "        </items>\n";
889
-        $feed .= "    </channel>\n";
890
-        if ($this->image != null) {
891
-            $feed .= "    <image rdf:about=\"" . $this->image->url . "\">\n";
892
-            $feed .= '        <title>' . $this->image->title . "</title>\n";
893
-            $feed .= '        <link>' . $this->image->link . "</link>\n";
894
-            $feed .= '        <url>' . $this->image->url . "</url>\n";
895
-            $feed .= "    </image>\n";
896
-        }
897
-        $feed .= $this->_createAdditionalElements($this->additionalElements, '    ');
898
-
899
-        for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
900
-            $feed .= "    <item rdf:about=\"" . htmlspecialchars($this->items[$i]->link) . "\">\n";
901
-            //$feed.= "        <dc:type>Posting</dc:type>\n";
902
-            $feed .= "        <dc:format>text/html</dc:format>\n";
903
-            if ($this->items[$i]->date != null) {
904
-                $itemDate = new FeedDate($this->items[$i]->date);
905
-                $feed .= '        <dc:date>' . htmlspecialchars($itemDate->iso8601()) . "</dc:date>\n";
906
-            }
907
-            if ($this->items[$i]->source != '') {
908
-                $feed .= '        <dc:source>' . htmlspecialchars($this->items[$i]->source) . "</dc:source>\n";
909
-            }
910
-            if ($this->items[$i]->author != '') {
911
-                $feed .= '        <dc:creator>' . htmlspecialchars($this->items[$i]->author) . "</dc:creator>\n";
912
-            }
913
-            $feed .= '        <title>' . htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", '  ')))
914
-                     . "</title>\n";
915
-            $feed .= '        <link>' . htmlspecialchars($this->items[$i]->link) . "</link>\n";
916
-            $feed .= '        <description>' . htmlspecialchars($this->items[$i]->description) . "</description>\n";
917
-            $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, '        ');
918
-            $feed .= "    </item>\n";
919
-        }
920
-        $feed .= "</rdf:RDF>\n";
921
-
922
-        return $feed;
923
-    }
856
+	/**
857
+	 * Builds the RSS feed's text. The feed will be compliant to RDF Site Summary (RSS) 1.0.
858
+	 * The feed will contain all items previously added in the same order.
859
+	 * @return string the feed's complete text
860
+	 */
861
+	public function createFeed() {
862
+		$feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
863
+		$feed .= $this->_createGeneratorComment();
864
+		if ($this->cssStyleSheet == '') {
865
+			$cssStyleSheet = 'http://www.w3.org/2000/08/w3c-synd/style.css';
866
+		}
867
+		$feed .= $this->_createStylesheetReferences();
868
+		$feed .= "<rdf:RDF\n";
869
+		$feed .= "    xmlns=\"http://purl.org/rss/1.0/\"\n";
870
+		$feed .= "    xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n";
871
+		$feed .= "    xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\"\n";
872
+		$feed .= "    xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";
873
+		$feed .= "    <channel rdf:about=\"" . $this->syndicationURL . "\">\n";
874
+		$feed .= '        <title>' . htmlspecialchars($this->title) . "</title>\n";
875
+		$feed .= '        <description>' . htmlspecialchars($this->description) . "</description>\n";
876
+		$feed .= '        <link>' . $this->link . "</link>\n";
877
+		if ($this->image != null) {
878
+			$feed .= "        <image rdf:resource=\"" . $this->image->url . "\" />\n";
879
+		}
880
+		$now = new FeedDate();
881
+		$feed .= '       <dc:date>' . htmlspecialchars($now->iso8601()) . "</dc:date>\n";
882
+		$feed .= "        <items>\n";
883
+		$feed .= "            <rdf:Seq>\n";
884
+		for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
885
+			$feed .= "                <rdf:li rdf:resource=\"" . htmlspecialchars($this->items[$i]->link) . "\"/>\n";
886
+		}
887
+		$feed .= "            </rdf:Seq>\n";
888
+		$feed .= "        </items>\n";
889
+		$feed .= "    </channel>\n";
890
+		if ($this->image != null) {
891
+			$feed .= "    <image rdf:about=\"" . $this->image->url . "\">\n";
892
+			$feed .= '        <title>' . $this->image->title . "</title>\n";
893
+			$feed .= '        <link>' . $this->image->link . "</link>\n";
894
+			$feed .= '        <url>' . $this->image->url . "</url>\n";
895
+			$feed .= "    </image>\n";
896
+		}
897
+		$feed .= $this->_createAdditionalElements($this->additionalElements, '    ');
898
+
899
+		for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
900
+			$feed .= "    <item rdf:about=\"" . htmlspecialchars($this->items[$i]->link) . "\">\n";
901
+			//$feed.= "        <dc:type>Posting</dc:type>\n";
902
+			$feed .= "        <dc:format>text/html</dc:format>\n";
903
+			if ($this->items[$i]->date != null) {
904
+				$itemDate = new FeedDate($this->items[$i]->date);
905
+				$feed .= '        <dc:date>' . htmlspecialchars($itemDate->iso8601()) . "</dc:date>\n";
906
+			}
907
+			if ($this->items[$i]->source != '') {
908
+				$feed .= '        <dc:source>' . htmlspecialchars($this->items[$i]->source) . "</dc:source>\n";
909
+			}
910
+			if ($this->items[$i]->author != '') {
911
+				$feed .= '        <dc:creator>' . htmlspecialchars($this->items[$i]->author) . "</dc:creator>\n";
912
+			}
913
+			$feed .= '        <title>' . htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", '  ')))
914
+					 . "</title>\n";
915
+			$feed .= '        <link>' . htmlspecialchars($this->items[$i]->link) . "</link>\n";
916
+			$feed .= '        <description>' . htmlspecialchars($this->items[$i]->description) . "</description>\n";
917
+			$feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, '        ');
918
+			$feed .= "    </item>\n";
919
+		}
920
+		$feed .= "</rdf:RDF>\n";
921
+
922
+		return $feed;
923
+	}
924 924
 }
925 925
 
926 926
 /**
@@ -932,141 +932,141 @@  discard block
 block discarded – undo
932 932
  */
933 933
 class RSSCreator091 extends FeedCreator
934 934
 {
935
-    /**
936
-     * Stores this RSS feed's version number.
937
-     * @access private
938
-     */
939
-    public $RSSVersion;
940
-
941
-    /**
942
-     * RSSCreator091 constructor.
943
-     */
944
-    public function __construct() {
945
-        $this->_setRSSVersion('0.91');
946
-        $this->contentType = 'application/rss+xml';
947
-    }
948
-
949
-    /**
950
-     * Sets this RSS feed's version number.
951
-     * @access private
952
-     * @param $version
953
-     */
954
-    public function _setRSSVersion($version) {
955
-        $this->RSSVersion = $version;
956
-    }
957
-
958
-    /**
959
-     * Builds the RSS feed's text. The feed will be compliant to RDF Site Summary (RSS) 1.0.
960
-     * The feed will contain all items previously added in the same order.
961
-     * @return string the feed's complete text
962
-     */
963
-    public function createFeed() {
964
-        $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
965
-        $feed .= $this->_createGeneratorComment();
966
-        $feed .= $this->_createStylesheetReferences();
967
-        $feed .= "<rss version=\"" . $this->RSSVersion . "\">\n";
968
-        $feed .= "    <channel>\n";
969
-        $feed .= '        <title>' . FeedCreator::iTrunc(htmlspecialchars($this->title), 100) . "</title>\n";
970
-        $this->descriptionTruncSize = 500;
971
-        $feed .= '        <description>' . $this->getDescription() . "</description>\n";
972
-        $feed .= '        <link>' . $this->link . "</link>\n";
973
-        $now = new FeedDate();
974
-        $feed .= '        <lastBuildDate>' . htmlspecialchars($now->rfc822()) . "</lastBuildDate>\n";
975
-        $feed .= '        <generator>' . FEEDCREATOR_VERSION . "</generator>\n";
976
-
977
-        if ($this->image != null) {
978
-            $feed .= "        <image>\n";
979
-            $feed .= '            <url>' . $this->image->url . "</url>\n";
980
-            $feed .= '            <title>' . FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100)
981
-                     . "</title>\n";
982
-            $feed .= '            <link>' . $this->image->link . "</link>\n";
983
-            if ($this->image->width != '') {
984
-                $feed .= '            <width>' . $this->image->width . "</width>\n";
985
-            }
986
-            if ($this->image->height != '') {
987
-                $feed .= '            <height>' . $this->image->height . "</height>\n";
988
-            }
989
-            if ($this->image->description != '') {
990
-                $feed .= '            <description>' . $this->image->getDescription() . "</description>\n";
991
-            }
992
-            $feed .= "        </image>\n";
993
-        }
994
-        if ($this->language != '') {
995
-            $feed .= '        <language>' . $this->language . "</language>\n";
996
-        }
997
-        if ($this->copyright != '') {
998
-            $feed .= '        <copyright>' . FeedCreator::iTrunc(htmlspecialchars($this->copyright), 100)
999
-                     . "</copyright>\n";
1000
-        }
1001
-        if ($this->editor != '') {
1002
-            $feed .= '        <managingEditor>' . FeedCreator::iTrunc(htmlspecialchars($this->editor), 100)
1003
-                     . "</managingEditor>\n";
1004
-        }
1005
-        if ($this->webmaster != '') {
1006
-            $feed .= '        <webMaster>' . FeedCreator::iTrunc(htmlspecialchars($this->webmaster), 100)
1007
-                     . "</webMaster>\n";
1008
-        }
1009
-        if ($this->pubDate != '') {
1010
-            $pubDate = new FeedDate($this->pubDate);
1011
-            $feed .= '        <pubDate>' . htmlspecialchars($pubDate->rfc822()) . "</pubDate>\n";
1012
-        }
1013
-        if ($this->category != '') {
1014
-            $feed .= '        <category>' . htmlspecialchars($this->category) . "</category>\n";
1015
-        }
1016
-        if ($this->docs != '') {
1017
-            $feed .= '        <docs>' . FeedCreator::iTrunc(htmlspecialchars($this->docs), 500) . "</docs>\n";
1018
-        }
1019
-        if ($this->ttl != '') {
1020
-            $feed .= '        <ttl>' . htmlspecialchars($this->ttl) . "</ttl>\n";
1021
-        }
1022
-        if ($this->rating != '') {
1023
-            $feed .= '        <rating>' . FeedCreator::iTrunc(htmlspecialchars($this->rating), 500) . "</rating>\n";
1024
-        }
1025
-        if ($this->skipHours != '') {
1026
-            $feed .= '        <skipHours>' . htmlspecialchars($this->skipHours) . "</skipHours>\n";
1027
-        }
1028
-        if ($this->skipDays != '') {
1029
-            $feed .= '        <skipDays>' . htmlspecialchars($this->skipDays) . "</skipDays>\n";
1030
-        }
1031
-        $feed .= $this->_createAdditionalElements($this->additionalElements, '    ');
1032
-
1033
-        for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
1034
-            $feed .= "        <item>\n";
1035
-            $feed .= '            <title>' . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)),
1036
-                                                                 100) . "</title>\n";
1037
-            $feed .= '            <link>' . htmlspecialchars($this->items[$i]->link) . "</link>\n";
1038
-            $feed .= '            <description>' . $this->items[$i]->getDescription() . "</description>\n";
1039
-
1040
-            if ($this->items[$i]->author != '') {
1041
-                $feed .= '            <author>' . htmlspecialchars($this->items[$i]->author) . "</author>\n";
1042
-            }
1043
-            /*
935
+	/**
936
+	 * Stores this RSS feed's version number.
937
+	 * @access private
938
+	 */
939
+	public $RSSVersion;
940
+
941
+	/**
942
+	 * RSSCreator091 constructor.
943
+	 */
944
+	public function __construct() {
945
+		$this->_setRSSVersion('0.91');
946
+		$this->contentType = 'application/rss+xml';
947
+	}
948
+
949
+	/**
950
+	 * Sets this RSS feed's version number.
951
+	 * @access private
952
+	 * @param $version
953
+	 */
954
+	public function _setRSSVersion($version) {
955
+		$this->RSSVersion = $version;
956
+	}
957
+
958
+	/**
959
+	 * Builds the RSS feed's text. The feed will be compliant to RDF Site Summary (RSS) 1.0.
960
+	 * The feed will contain all items previously added in the same order.
961
+	 * @return string the feed's complete text
962
+	 */
963
+	public function createFeed() {
964
+		$feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
965
+		$feed .= $this->_createGeneratorComment();
966
+		$feed .= $this->_createStylesheetReferences();
967
+		$feed .= "<rss version=\"" . $this->RSSVersion . "\">\n";
968
+		$feed .= "    <channel>\n";
969
+		$feed .= '        <title>' . FeedCreator::iTrunc(htmlspecialchars($this->title), 100) . "</title>\n";
970
+		$this->descriptionTruncSize = 500;
971
+		$feed .= '        <description>' . $this->getDescription() . "</description>\n";
972
+		$feed .= '        <link>' . $this->link . "</link>\n";
973
+		$now = new FeedDate();
974
+		$feed .= '        <lastBuildDate>' . htmlspecialchars($now->rfc822()) . "</lastBuildDate>\n";
975
+		$feed .= '        <generator>' . FEEDCREATOR_VERSION . "</generator>\n";
976
+
977
+		if ($this->image != null) {
978
+			$feed .= "        <image>\n";
979
+			$feed .= '            <url>' . $this->image->url . "</url>\n";
980
+			$feed .= '            <title>' . FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100)
981
+					 . "</title>\n";
982
+			$feed .= '            <link>' . $this->image->link . "</link>\n";
983
+			if ($this->image->width != '') {
984
+				$feed .= '            <width>' . $this->image->width . "</width>\n";
985
+			}
986
+			if ($this->image->height != '') {
987
+				$feed .= '            <height>' . $this->image->height . "</height>\n";
988
+			}
989
+			if ($this->image->description != '') {
990
+				$feed .= '            <description>' . $this->image->getDescription() . "</description>\n";
991
+			}
992
+			$feed .= "        </image>\n";
993
+		}
994
+		if ($this->language != '') {
995
+			$feed .= '        <language>' . $this->language . "</language>\n";
996
+		}
997
+		if ($this->copyright != '') {
998
+			$feed .= '        <copyright>' . FeedCreator::iTrunc(htmlspecialchars($this->copyright), 100)
999
+					 . "</copyright>\n";
1000
+		}
1001
+		if ($this->editor != '') {
1002
+			$feed .= '        <managingEditor>' . FeedCreator::iTrunc(htmlspecialchars($this->editor), 100)
1003
+					 . "</managingEditor>\n";
1004
+		}
1005
+		if ($this->webmaster != '') {
1006
+			$feed .= '        <webMaster>' . FeedCreator::iTrunc(htmlspecialchars($this->webmaster), 100)
1007
+					 . "</webMaster>\n";
1008
+		}
1009
+		if ($this->pubDate != '') {
1010
+			$pubDate = new FeedDate($this->pubDate);
1011
+			$feed .= '        <pubDate>' . htmlspecialchars($pubDate->rfc822()) . "</pubDate>\n";
1012
+		}
1013
+		if ($this->category != '') {
1014
+			$feed .= '        <category>' . htmlspecialchars($this->category) . "</category>\n";
1015
+		}
1016
+		if ($this->docs != '') {
1017
+			$feed .= '        <docs>' . FeedCreator::iTrunc(htmlspecialchars($this->docs), 500) . "</docs>\n";
1018
+		}
1019
+		if ($this->ttl != '') {
1020
+			$feed .= '        <ttl>' . htmlspecialchars($this->ttl) . "</ttl>\n";
1021
+		}
1022
+		if ($this->rating != '') {
1023
+			$feed .= '        <rating>' . FeedCreator::iTrunc(htmlspecialchars($this->rating), 500) . "</rating>\n";
1024
+		}
1025
+		if ($this->skipHours != '') {
1026
+			$feed .= '        <skipHours>' . htmlspecialchars($this->skipHours) . "</skipHours>\n";
1027
+		}
1028
+		if ($this->skipDays != '') {
1029
+			$feed .= '        <skipDays>' . htmlspecialchars($this->skipDays) . "</skipDays>\n";
1030
+		}
1031
+		$feed .= $this->_createAdditionalElements($this->additionalElements, '    ');
1032
+
1033
+		for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
1034
+			$feed .= "        <item>\n";
1035
+			$feed .= '            <title>' . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)),
1036
+																 100) . "</title>\n";
1037
+			$feed .= '            <link>' . htmlspecialchars($this->items[$i]->link) . "</link>\n";
1038
+			$feed .= '            <description>' . $this->items[$i]->getDescription() . "</description>\n";
1039
+
1040
+			if ($this->items[$i]->author != '') {
1041
+				$feed .= '            <author>' . htmlspecialchars($this->items[$i]->author) . "</author>\n";
1042
+			}
1043
+			/*
1044 1044
             // on hold
1045 1045
             if ($this->items[$i]->source!="") {
1046 1046
                     $feed.= "            <source>".htmlspecialchars($this->items[$i]->source)."</source>\n";
1047 1047
             }
1048 1048
             */
1049
-            if ($this->items[$i]->category != '') {
1050
-                $feed .= '            <category>' . htmlspecialchars($this->items[$i]->category) . "</category>\n";
1051
-            }
1052
-            if ($this->items[$i]->comments != '') {
1053
-                $feed .= '            <comments>' . htmlspecialchars($this->items[$i]->comments) . "</comments>\n";
1054
-            }
1055
-            if ($this->items[$i]->date != '') {
1056
-                $itemDate = new FeedDate($this->items[$i]->date);
1057
-                $feed .= '            <pubDate>' . htmlspecialchars($itemDate->rfc822()) . "</pubDate>\n";
1058
-            }
1059
-            if ($this->items[$i]->guid != '') {
1060
-                $feed .= '            <guid>' . htmlspecialchars($this->items[$i]->guid) . "</guid>\n";
1061
-            }
1062
-            $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, '        ');
1063
-            $feed .= "        </item>\n";
1064
-        }
1065
-        $feed .= "    </channel>\n";
1066
-        $feed .= "</rss>\n";
1067
-
1068
-        return $feed;
1069
-    }
1049
+			if ($this->items[$i]->category != '') {
1050
+				$feed .= '            <category>' . htmlspecialchars($this->items[$i]->category) . "</category>\n";
1051
+			}
1052
+			if ($this->items[$i]->comments != '') {
1053
+				$feed .= '            <comments>' . htmlspecialchars($this->items[$i]->comments) . "</comments>\n";
1054
+			}
1055
+			if ($this->items[$i]->date != '') {
1056
+				$itemDate = new FeedDate($this->items[$i]->date);
1057
+				$feed .= '            <pubDate>' . htmlspecialchars($itemDate->rfc822()) . "</pubDate>\n";
1058
+			}
1059
+			if ($this->items[$i]->guid != '') {
1060
+				$feed .= '            <guid>' . htmlspecialchars($this->items[$i]->guid) . "</guid>\n";
1061
+			}
1062
+			$feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, '        ');
1063
+			$feed .= "        </item>\n";
1064
+		}
1065
+		$feed .= "    </channel>\n";
1066
+		$feed .= "</rss>\n";
1067
+
1068
+		return $feed;
1069
+	}
1070 1070
 }
1071 1071
 
1072 1072
 /**
@@ -1078,12 +1078,12 @@  discard block
 block discarded – undo
1078 1078
  */
1079 1079
 class RSSCreator20 extends RSSCreator091
1080 1080
 {
1081
-    /**
1082
-     * RSSCreator20 constructor.
1083
-     */
1084
-    public function __construct() {
1085
-        parent::_setRSSVersion('2.0');
1086
-    }
1081
+	/**
1082
+	 * RSSCreator20 constructor.
1083
+	 */
1084
+	public function __construct() {
1085
+		parent::_setRSSVersion('2.0');
1086
+	}
1087 1087
 }
1088 1088
 
1089 1089
 /**
@@ -1096,52 +1096,52 @@  discard block
 block discarded – undo
1096 1096
  */
1097 1097
 class PIECreator01 extends FeedCreator
1098 1098
 {
1099
-    /**
1100
-     * PIECreator01 constructor.
1101
-     */
1102
-    public function __construct() {
1103
-        $this->encoding = 'utf-8';
1104
-    }
1105
-
1106
-    /**
1107
-     * @return string
1108
-     */
1109
-    public function createFeed() {
1110
-        $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
1111
-        $feed .= $this->_createStylesheetReferences();
1112
-        $feed .= "<feed version=\"0.1\" xmlns=\"http://example.com/newformat#\">\n";
1113
-        $feed .= '    <title>' . FeedCreator::iTrunc(htmlspecialchars($this->title), 100) . "</title>\n";
1114
-        $this->truncSize = 500;
1115
-        $feed .= '    <subtitle>' . $this->getDescription() . "</subtitle>\n";
1116
-        $feed .= '    <link>' . $this->link . "</link>\n";
1117
-        for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
1118
-            $feed .= "    <entry>\n";
1119
-            $feed .= '        <title>' . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100)
1120
-                     . "</title>\n";
1121
-            $feed .= '        <link>' . htmlspecialchars($this->items[$i]->link) . "</link>\n";
1122
-            $itemDate = new FeedDate($this->items[$i]->date);
1123
-            $feed .= '        <created>' . htmlspecialchars($itemDate->iso8601()) . "</created>\n";
1124
-            $feed .= '        <issued>' . htmlspecialchars($itemDate->iso8601()) . "</issued>\n";
1125
-            $feed .= '        <modified>' . htmlspecialchars($itemDate->iso8601()) . "</modified>\n";
1126
-            $feed .= '        <id>' . htmlspecialchars($this->items[$i]->guid) . "</id>\n";
1127
-            if ($this->items[$i]->author != '') {
1128
-                $feed .= "        <author>\n";
1129
-                $feed .= '            <name>' . htmlspecialchars($this->items[$i]->author) . "</name>\n";
1130
-                if ($this->items[$i]->authorEmail != '') {
1131
-                    $feed .= '            <email>' . $this->items[$i]->authorEmail . "</email>\n";
1132
-                }
1133
-                $feed .= "        </author>\n";
1134
-            }
1135
-            $feed .= "        <content type=\"text/html\" xml:lang=\"en-us\">\n";
1136
-            $feed .= "            <div xmlns=\"http://www.w3.org/1999/xhtml\">" . $this->items[$i]->getDescription()
1137
-                     . "</div>\n";
1138
-            $feed .= "        </content>\n";
1139
-            $feed .= "    </entry>\n";
1140
-        }
1141
-        $feed .= "</feed>\n";
1142
-
1143
-        return $feed;
1144
-    }
1099
+	/**
1100
+	 * PIECreator01 constructor.
1101
+	 */
1102
+	public function __construct() {
1103
+		$this->encoding = 'utf-8';
1104
+	}
1105
+
1106
+	/**
1107
+	 * @return string
1108
+	 */
1109
+	public function createFeed() {
1110
+		$feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
1111
+		$feed .= $this->_createStylesheetReferences();
1112
+		$feed .= "<feed version=\"0.1\" xmlns=\"http://example.com/newformat#\">\n";
1113
+		$feed .= '    <title>' . FeedCreator::iTrunc(htmlspecialchars($this->title), 100) . "</title>\n";
1114
+		$this->truncSize = 500;
1115
+		$feed .= '    <subtitle>' . $this->getDescription() . "</subtitle>\n";
1116
+		$feed .= '    <link>' . $this->link . "</link>\n";
1117
+		for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
1118
+			$feed .= "    <entry>\n";
1119
+			$feed .= '        <title>' . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100)
1120
+					 . "</title>\n";
1121
+			$feed .= '        <link>' . htmlspecialchars($this->items[$i]->link) . "</link>\n";
1122
+			$itemDate = new FeedDate($this->items[$i]->date);
1123
+			$feed .= '        <created>' . htmlspecialchars($itemDate->iso8601()) . "</created>\n";
1124
+			$feed .= '        <issued>' . htmlspecialchars($itemDate->iso8601()) . "</issued>\n";
1125
+			$feed .= '        <modified>' . htmlspecialchars($itemDate->iso8601()) . "</modified>\n";
1126
+			$feed .= '        <id>' . htmlspecialchars($this->items[$i]->guid) . "</id>\n";
1127
+			if ($this->items[$i]->author != '') {
1128
+				$feed .= "        <author>\n";
1129
+				$feed .= '            <name>' . htmlspecialchars($this->items[$i]->author) . "</name>\n";
1130
+				if ($this->items[$i]->authorEmail != '') {
1131
+					$feed .= '            <email>' . $this->items[$i]->authorEmail . "</email>\n";
1132
+				}
1133
+				$feed .= "        </author>\n";
1134
+			}
1135
+			$feed .= "        <content type=\"text/html\" xml:lang=\"en-us\">\n";
1136
+			$feed .= "            <div xmlns=\"http://www.w3.org/1999/xhtml\">" . $this->items[$i]->getDescription()
1137
+					 . "</div>\n";
1138
+			$feed .= "        </content>\n";
1139
+			$feed .= "    </entry>\n";
1140
+		}
1141
+		$feed .= "</feed>\n";
1142
+
1143
+		return $feed;
1144
+	}
1145 1145
 }
1146 1146
 
1147 1147
 /**
@@ -1162,70 +1162,70 @@  discard block
 block discarded – undo
1162 1162
  */
1163 1163
 class AtomCreator03 extends FeedCreator
1164 1164
 {
1165
-    /**
1166
-     * AtomCreator03 constructor.
1167
-     */
1168
-    public function __construct() {
1169
-        $this->contentType = 'application/atom+xml';
1170
-        $this->encoding    = 'utf-8';
1171
-    }
1172
-
1173
-    /**
1174
-     * @return string
1175
-     */
1176
-    public function createFeed() {
1177
-        $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
1178
-        $feed .= $this->_createGeneratorComment();
1179
-        $feed .= $this->_createStylesheetReferences();
1180
-        $feed .= "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\"";
1181
-        if ($this->language != '') {
1182
-            $feed .= " xml:lang=\"" . $this->language . "\"";
1183
-        }
1184
-        $feed .= ">\n";
1185
-        $feed .= '    <title>' . htmlspecialchars($this->title) . "</title>\n";
1186
-        $feed .= '    <tagline>' . htmlspecialchars($this->description) . "</tagline>\n";
1187
-        $feed .= "    <link rel=\"alternate\" type=\"text/html\" href=\"" . htmlspecialchars($this->link) . "\"/>\n";
1188
-        $feed .= '    <id>' . htmlspecialchars($this->link) . "</id>\n";
1189
-        $now = new FeedDate();
1190
-        $feed .= '    <modified>' . htmlspecialchars($now->iso8601()) . "</modified>\n";
1191
-        if ($this->editor != '') {
1192
-            $feed .= "    <author>\n";
1193
-            $feed .= '        <name>' . $this->editor . "</name>\n";
1194
-            if ($this->editorEmail != '') {
1195
-                $feed .= '        <email>' . $this->editorEmail . "</email>\n";
1196
-            }
1197
-            $feed .= "    </author>\n";
1198
-        }
1199
-        $feed .= '    <generator>' . FEEDCREATOR_VERSION . "</generator>\n";
1200
-        $feed .= $this->_createAdditionalElements($this->additionalElements, '    ');
1201
-        for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
1202
-            $feed .= "    <entry>\n";
1203
-            $feed .= '        <title>' . htmlspecialchars(strip_tags($this->items[$i]->title)) . "</title>\n";
1204
-            $feed .= "        <link rel=\"alternate\" type=\"text/html\" href=\""
1205
-                     . htmlspecialchars($this->items[$i]->link) . "\"/>\n";
1206
-            if ($this->items[$i]->date == '') {
1207
-                $this->items[$i]->date = time();
1208
-            }
1209
-            $itemDate = new FeedDate($this->items[$i]->date);
1210
-            $feed .= '        <created>' . htmlspecialchars($itemDate->iso8601()) . "</created>\n";
1211
-            $feed .= '        <issued>' . htmlspecialchars($itemDate->iso8601()) . "</issued>\n";
1212
-            $feed .= '        <modified>' . htmlspecialchars($itemDate->iso8601()) . "</modified>\n";
1213
-            $feed .= '        <id>' . htmlspecialchars($this->items[$i]->link) . "</id>\n";
1214
-            $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, '        ');
1215
-            if ($this->items[$i]->author != '') {
1216
-                $feed .= "        <author>\n";
1217
-                $feed .= '            <name>' . htmlspecialchars($this->items[$i]->author) . "</name>\n";
1218
-                $feed .= "        </author>\n";
1219
-            }
1220
-            if ($this->items[$i]->description != '') {
1221
-                $feed .= '        <summary>' . htmlspecialchars($this->items[$i]->description) . "</summary>\n";
1222
-            }
1223
-            $feed .= "    </entry>\n";
1224
-        }
1225
-        $feed .= "</feed>\n";
1226
-
1227
-        return $feed;
1228
-    }
1165
+	/**
1166
+	 * AtomCreator03 constructor.
1167
+	 */
1168
+	public function __construct() {
1169
+		$this->contentType = 'application/atom+xml';
1170
+		$this->encoding    = 'utf-8';
1171
+	}
1172
+
1173
+	/**
1174
+	 * @return string
1175
+	 */
1176
+	public function createFeed() {
1177
+		$feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
1178
+		$feed .= $this->_createGeneratorComment();
1179
+		$feed .= $this->_createStylesheetReferences();
1180
+		$feed .= "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\"";
1181
+		if ($this->language != '') {
1182
+			$feed .= " xml:lang=\"" . $this->language . "\"";
1183
+		}
1184
+		$feed .= ">\n";
1185
+		$feed .= '    <title>' . htmlspecialchars($this->title) . "</title>\n";
1186
+		$feed .= '    <tagline>' . htmlspecialchars($this->description) . "</tagline>\n";
1187
+		$feed .= "    <link rel=\"alternate\" type=\"text/html\" href=\"" . htmlspecialchars($this->link) . "\"/>\n";
1188
+		$feed .= '    <id>' . htmlspecialchars($this->link) . "</id>\n";
1189
+		$now = new FeedDate();
1190
+		$feed .= '    <modified>' . htmlspecialchars($now->iso8601()) . "</modified>\n";
1191
+		if ($this->editor != '') {
1192
+			$feed .= "    <author>\n";
1193
+			$feed .= '        <name>' . $this->editor . "</name>\n";
1194
+			if ($this->editorEmail != '') {
1195
+				$feed .= '        <email>' . $this->editorEmail . "</email>\n";
1196
+			}
1197
+			$feed .= "    </author>\n";
1198
+		}
1199
+		$feed .= '    <generator>' . FEEDCREATOR_VERSION . "</generator>\n";
1200
+		$feed .= $this->_createAdditionalElements($this->additionalElements, '    ');
1201
+		for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
1202
+			$feed .= "    <entry>\n";
1203
+			$feed .= '        <title>' . htmlspecialchars(strip_tags($this->items[$i]->title)) . "</title>\n";
1204
+			$feed .= "        <link rel=\"alternate\" type=\"text/html\" href=\""
1205
+					 . htmlspecialchars($this->items[$i]->link) . "\"/>\n";
1206
+			if ($this->items[$i]->date == '') {
1207
+				$this->items[$i]->date = time();
1208
+			}
1209
+			$itemDate = new FeedDate($this->items[$i]->date);
1210
+			$feed .= '        <created>' . htmlspecialchars($itemDate->iso8601()) . "</created>\n";
1211
+			$feed .= '        <issued>' . htmlspecialchars($itemDate->iso8601()) . "</issued>\n";
1212
+			$feed .= '        <modified>' . htmlspecialchars($itemDate->iso8601()) . "</modified>\n";
1213
+			$feed .= '        <id>' . htmlspecialchars($this->items[$i]->link) . "</id>\n";
1214
+			$feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, '        ');
1215
+			if ($this->items[$i]->author != '') {
1216
+				$feed .= "        <author>\n";
1217
+				$feed .= '            <name>' . htmlspecialchars($this->items[$i]->author) . "</name>\n";
1218
+				$feed .= "        </author>\n";
1219
+			}
1220
+			if ($this->items[$i]->description != '') {
1221
+				$feed .= '        <summary>' . htmlspecialchars($this->items[$i]->description) . "</summary>\n";
1222
+			}
1223
+			$feed .= "    </entry>\n";
1224
+		}
1225
+		$feed .= "</feed>\n";
1226
+
1227
+		return $feed;
1228
+	}
1229 1229
 }
1230 1230
 
1231 1231
 /**
@@ -1237,93 +1237,93 @@  discard block
 block discarded – undo
1237 1237
  */
1238 1238
 class MBOXCreator extends FeedCreator
1239 1239
 {
1240
-    /**
1241
-     * MBOXCreator constructor.
1242
-     */
1243
-    public function __construct() {
1244
-        $this->contentType = 'text/plain';
1245
-        $this->encoding    = 'ISO-8859-15';
1246
-    }
1247
-
1248
-    /**
1249
-     * @param string $input
1250
-     * @param int    $line_max
1251
-     * @return string
1252
-     */
1253
-    public function qp_enc($input = '', $line_max = 76) {
1254
-        $hex    = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
1255
-        $lines  = preg_split("/(?:\r\n|\r|\n)/", $input);
1256
-        $eol    = "\r\n";
1257
-        $escape = '=';
1258
-        $output = '';
1259
-        while (list(, $line) = each($lines)) {
1260
-            //$line = rtrim($line); // remove trailing white space -> no =20\r\n necessary
1261
-            $linlen  = strlen($line);
1262
-            $newline = '';
1263
-            for ($i = 0; $i < $linlen; ++$i) {
1264
-                $c   = substr($line, $i, 1);
1265
-                $dec = ord($c);
1266
-                if (($dec == 32) && ($i == ($linlen - 1))) { // convert space at eol only
1267
-                    $c = '=20';
1268
-                } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) { // always encode "\t", which is *not* required
1269
-                    $h2 = floor($dec / 16);
1270
-                    $h1 = floor($dec % 16);
1271
-                    $c  = $escape . $hex["$h2"] . $hex["$h1"];
1272
-                }
1273
-                if ((strlen($newline) + strlen($c)) >= $line_max) { // CRLF is not counted
1274
-                    $output .= $newline . $escape . $eol; // soft line break; " =\r\n" is okay
1275
-                    $newline = '';
1276
-                }
1277
-                $newline .= $c;
1278
-            } // end of for
1279
-            $output .= $newline . $eol;
1280
-        }
1281
-
1282
-        return trim($output);
1283
-    }
1284
-
1285
-    /**
1286
-     * Builds the MBOX contents.
1287
-     * @return string the feed's complete text
1288
-     */
1289
-    public function createFeed() {
1290
-        for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
1291
-            if ($this->items[$i]->author != '') {
1292
-                $from = $this->items[$i]->author;
1293
-            } else {
1294
-                $from = $this->title;
1295
-            }
1296
-            $itemDate = new FeedDate($this->items[$i]->date);
1297
-            $feed .= 'From ' . strtr(MBOXCreator::qp_enc($from), ' ', '_') . ' ' . date('D M d H:i:s Y',
1298
-                                                                                        $itemDate->unix()) . "\n";
1299
-            $feed .= "Content-Type: text/plain;\n";
1300
-            $feed .= "   charset=\"" . $this->encoding . "\"\n";
1301
-            $feed .= "Content-Transfer-Encoding: quoted-printable\n";
1302
-            $feed .= "Content-Type: text/plain\n";
1303
-            $feed .= "From: \"" . MBOXCreator::qp_enc($from) . "\"\n";
1304
-            $feed .= 'Date: ' . $itemDate->rfc822() . "\n";
1305
-            $feed .= 'Subject: ' . MBOXCreator::qp_enc(FeedCreator::iTrunc($this->items[$i]->title, 100)) . "\n";
1306
-            $feed .= "\n";
1307
-            $body = chunk_split(MBOXCreator::qp_enc($this->items[$i]->description));
1308
-            $feed .= preg_replace("~\nFrom ([^\n]*)(\n?)~", "\n>From $1$2\n", $body);
1309
-            $feed .= "\n";
1310
-            $feed .= "\n";
1311
-        }
1312
-
1313
-        return $feed;
1314
-    }
1315
-
1316
-    /**
1317
-     * Generate a filename for the feed cache file. Overridden from FeedCreator to prevent XML data types.
1318
-     * @return string the feed cache filename
1319
-     * @since  1.4
1320
-     * @access private
1321
-     */
1322
-    public function _generateFilename() {
1323
-        $fileInfo = pathinfo($_SERVER['PHP_SELF']);
1324
-
1325
-        return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.mbox';
1326
-    }
1240
+	/**
1241
+	 * MBOXCreator constructor.
1242
+	 */
1243
+	public function __construct() {
1244
+		$this->contentType = 'text/plain';
1245
+		$this->encoding    = 'ISO-8859-15';
1246
+	}
1247
+
1248
+	/**
1249
+	 * @param string $input
1250
+	 * @param int    $line_max
1251
+	 * @return string
1252
+	 */
1253
+	public function qp_enc($input = '', $line_max = 76) {
1254
+		$hex    = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
1255
+		$lines  = preg_split("/(?:\r\n|\r|\n)/", $input);
1256
+		$eol    = "\r\n";
1257
+		$escape = '=';
1258
+		$output = '';
1259
+		while (list(, $line) = each($lines)) {
1260
+			//$line = rtrim($line); // remove trailing white space -> no =20\r\n necessary
1261
+			$linlen  = strlen($line);
1262
+			$newline = '';
1263
+			for ($i = 0; $i < $linlen; ++$i) {
1264
+				$c   = substr($line, $i, 1);
1265
+				$dec = ord($c);
1266
+				if (($dec == 32) && ($i == ($linlen - 1))) { // convert space at eol only
1267
+					$c = '=20';
1268
+				} elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) { // always encode "\t", which is *not* required
1269
+					$h2 = floor($dec / 16);
1270
+					$h1 = floor($dec % 16);
1271
+					$c  = $escape . $hex["$h2"] . $hex["$h1"];
1272
+				}
1273
+				if ((strlen($newline) + strlen($c)) >= $line_max) { // CRLF is not counted
1274
+					$output .= $newline . $escape . $eol; // soft line break; " =\r\n" is okay
1275
+					$newline = '';
1276
+				}
1277
+				$newline .= $c;
1278
+			} // end of for
1279
+			$output .= $newline . $eol;
1280
+		}
1281
+
1282
+		return trim($output);
1283
+	}
1284
+
1285
+	/**
1286
+	 * Builds the MBOX contents.
1287
+	 * @return string the feed's complete text
1288
+	 */
1289
+	public function createFeed() {
1290
+		for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
1291
+			if ($this->items[$i]->author != '') {
1292
+				$from = $this->items[$i]->author;
1293
+			} else {
1294
+				$from = $this->title;
1295
+			}
1296
+			$itemDate = new FeedDate($this->items[$i]->date);
1297
+			$feed .= 'From ' . strtr(MBOXCreator::qp_enc($from), ' ', '_') . ' ' . date('D M d H:i:s Y',
1298
+																						$itemDate->unix()) . "\n";
1299
+			$feed .= "Content-Type: text/plain;\n";
1300
+			$feed .= "   charset=\"" . $this->encoding . "\"\n";
1301
+			$feed .= "Content-Transfer-Encoding: quoted-printable\n";
1302
+			$feed .= "Content-Type: text/plain\n";
1303
+			$feed .= "From: \"" . MBOXCreator::qp_enc($from) . "\"\n";
1304
+			$feed .= 'Date: ' . $itemDate->rfc822() . "\n";
1305
+			$feed .= 'Subject: ' . MBOXCreator::qp_enc(FeedCreator::iTrunc($this->items[$i]->title, 100)) . "\n";
1306
+			$feed .= "\n";
1307
+			$body = chunk_split(MBOXCreator::qp_enc($this->items[$i]->description));
1308
+			$feed .= preg_replace("~\nFrom ([^\n]*)(\n?)~", "\n>From $1$2\n", $body);
1309
+			$feed .= "\n";
1310
+			$feed .= "\n";
1311
+		}
1312
+
1313
+		return $feed;
1314
+	}
1315
+
1316
+	/**
1317
+	 * Generate a filename for the feed cache file. Overridden from FeedCreator to prevent XML data types.
1318
+	 * @return string the feed cache filename
1319
+	 * @since  1.4
1320
+	 * @access private
1321
+	 */
1322
+	public function _generateFilename() {
1323
+		$fileInfo = pathinfo($_SERVER['PHP_SELF']);
1324
+
1325
+		return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.mbox';
1326
+	}
1327 1327
 }
1328 1328
 
1329 1329
 /**
@@ -1335,53 +1335,53 @@  discard block
 block discarded – undo
1335 1335
  */
1336 1336
 class OPMLCreator extends FeedCreator
1337 1337
 {
1338
-    /**
1339
-     * OPMLCreator constructor.
1340
-     */
1341
-    public function __construct() {
1342
-        $this->encoding = 'utf-8';
1343
-    }
1344
-
1345
-    /**
1346
-     * @return string
1347
-     */
1348
-    public function createFeed() {
1349
-        $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
1350
-        $feed .= $this->_createGeneratorComment();
1351
-        $feed .= $this->_createStylesheetReferences();
1352
-        $feed .= "<opml xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n";
1353
-        $feed .= "    <head>\n";
1354
-        $feed .= '        <title>' . htmlspecialchars($this->title) . "</title>\n";
1355
-        if ($this->pubDate != '') {
1356
-            $date = new FeedDate($this->pubDate);
1357
-            $feed .= '         <dateCreated>' . $date->rfc822() . "</dateCreated>\n";
1358
-        }
1359
-        if ($this->lastBuildDate != '') {
1360
-            $date = new FeedDate($this->lastBuildDate);
1361
-            $feed .= '         <dateModified>' . $date->rfc822() . "</dateModified>\n";
1362
-        }
1363
-        if ($this->editor != '') {
1364
-            $feed .= '         <ownerName>' . $this->editor . "</ownerName>\n";
1365
-        }
1366
-        if ($this->editorEmail != '') {
1367
-            $feed .= '         <ownerEmail>' . $this->editorEmail . "</ownerEmail>\n";
1368
-        }
1369
-        $feed .= "    </head>\n";
1370
-        $feed .= "    <body>\n";
1371
-        for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
1372
-            $feed .= "    <outline type=\"rss\" ";
1373
-            $title = htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", '  ')));
1374
-            $feed .= " title=\"" . $title . "\"";
1375
-            $feed .= " text=\"" . $title . "\"";
1376
-            //$feed.= " description=\"".htmlspecialchars($this->items[$i]->description)."\"";
1377
-            $feed .= " url=\"" . htmlspecialchars($this->items[$i]->link) . "\"";
1378
-            $feed .= "/>\n";
1379
-        }
1380
-        $feed .= "    </body>\n";
1381
-        $feed .= "</opml>\n";
1382
-
1383
-        return $feed;
1384
-    }
1338
+	/**
1339
+	 * OPMLCreator constructor.
1340
+	 */
1341
+	public function __construct() {
1342
+		$this->encoding = 'utf-8';
1343
+	}
1344
+
1345
+	/**
1346
+	 * @return string
1347
+	 */
1348
+	public function createFeed() {
1349
+		$feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
1350
+		$feed .= $this->_createGeneratorComment();
1351
+		$feed .= $this->_createStylesheetReferences();
1352
+		$feed .= "<opml xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n";
1353
+		$feed .= "    <head>\n";
1354
+		$feed .= '        <title>' . htmlspecialchars($this->title) . "</title>\n";
1355
+		if ($this->pubDate != '') {
1356
+			$date = new FeedDate($this->pubDate);
1357
+			$feed .= '         <dateCreated>' . $date->rfc822() . "</dateCreated>\n";
1358
+		}
1359
+		if ($this->lastBuildDate != '') {
1360
+			$date = new FeedDate($this->lastBuildDate);
1361
+			$feed .= '         <dateModified>' . $date->rfc822() . "</dateModified>\n";
1362
+		}
1363
+		if ($this->editor != '') {
1364
+			$feed .= '         <ownerName>' . $this->editor . "</ownerName>\n";
1365
+		}
1366
+		if ($this->editorEmail != '') {
1367
+			$feed .= '         <ownerEmail>' . $this->editorEmail . "</ownerEmail>\n";
1368
+		}
1369
+		$feed .= "    </head>\n";
1370
+		$feed .= "    <body>\n";
1371
+		for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
1372
+			$feed .= "    <outline type=\"rss\" ";
1373
+			$title = htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", '  ')));
1374
+			$feed .= " title=\"" . $title . "\"";
1375
+			$feed .= " text=\"" . $title . "\"";
1376
+			//$feed.= " description=\"".htmlspecialchars($this->items[$i]->description)."\"";
1377
+			$feed .= " url=\"" . htmlspecialchars($this->items[$i]->link) . "\"";
1378
+			$feed .= "/>\n";
1379
+		}
1380
+		$feed .= "    </body>\n";
1381
+		$feed .= "</opml>\n";
1382
+
1383
+		return $feed;
1384
+	}
1385 1385
 }
1386 1386
 
1387 1387
 /**
@@ -1397,146 +1397,146 @@  discard block
 block discarded – undo
1397 1397
  */
1398 1398
 class HTMLCreator extends FeedCreator
1399 1399
 {
1400
-    public $contentType = 'text/html';
1401
-
1402
-    /**
1403
-     * Contains HTML to be output at the start of the feed's html representation.
1404
-     */
1405
-    public $header;
1406
-
1407
-    /**
1408
-     * Contains HTML to be output at the end of the feed's html representation.
1409
-     */
1410
-    public $footer;
1411
-
1412
-    /**
1413
-     * Contains HTML to be output between entries. A separator is only used in
1414
-     * case of multiple entries.
1415
-     */
1416
-    public $separator;
1417
-
1418
-    /**
1419
-     * Used to prefix the stylenames to make sure they are unique
1420
-     * and do not clash with stylenames on the users' page.
1421
-     */
1422
-    public $stylePrefix;
1423
-
1424
-    /**
1425
-     * Determines whether the links open in a new window or not.
1426
-     */
1427
-    public $openInNewWindow = true;
1428
-
1429
-    public $imageAlign = 'right';
1430
-
1431
-    /**
1432
-     * In case of very simple output you may want to get rid of the style tags,
1433
-     * hence this variable.  There's no equivalent on item level, but of course you can
1434
-     * add strings to it while iterating over the items ($this->stylelessOutput .= ...)
1435
-     * and when it is non-empty, ONLY the styleless output is printed, the rest is ignored
1436
-     * in the function createFeed().
1437
-     */
1438
-    public $stylelessOutput = '';
1439
-
1440
-    /**
1441
-     * Writes the HTML.
1442
-     * @return string the scripts's complete text
1443
-     */
1444
-    public function createFeed() {
1445
-        // if there is styleless output, use the content of this variable and ignore the rest
1446
-        if ($this->stylelessOutput != '') {
1447
-            return $this->stylelessOutput;
1448
-        }
1449
-
1450
-        //if no stylePrefix is set, generate it yourself depending on the script name
1451
-        if ($this->stylePrefix == '') {
1452
-            $this->stylePrefix = str_replace('.', '_', $this->_generateFilename()) . '_';
1453
-        }
1454
-
1455
-        //set an openInNewWindow_token_to be inserted or not
1456
-        if ($this->openInNewWindow) {
1457
-            $targetInsert = " target='_blank'";
1458
-        }
1459
-
1460
-        // use this array to put the lines in and implode later with "document.write" javascript
1461
-        $feedArray = array();
1462
-        if ($this->image != null) {
1463
-            $imageStr = "<a href='" . $this->image->link . "'" . $targetInsert . '>' . "<img src='" . $this->image->url
1464
-                        . "' border='0' alt='" . FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100)
1465
-                        . "' align='" . $this->imageAlign . "' ";
1466
-            if ($this->image->width) {
1467
-                $imageStr .= " width='" . $this->image->width . "' ";
1468
-            }
1469
-            if ($this->image->height) {
1470
-                $imageStr .= " height='" . $this->image->height . "' ";
1471
-            }
1472
-            $imageStr .= '/></a>';
1473
-            $feedArray[] = $imageStr;
1474
-        }
1475
-
1476
-        if ($this->title) {
1477
-            $feedArray[] = "<div class='" . $this->stylePrefix . "title'><a href='" . $this->link . "' " . $targetInsert
1478
-                           . " class='" . $this->stylePrefix . "title'>"
1479
-                           . FeedCreator::iTrunc(htmlspecialchars($this->title), 100) . '</a></div>';
1480
-        }
1481
-        if ($this->getDescription()) {
1482
-            $feedArray[] = "<div class='" . $this->stylePrefix . "description'>" . str_replace(']]>', '',
1483
-                                                                                               str_replace('<![CDATA[',
1484
-                                                                                                           '',
1485
-                                                                                                           $this->getDescription()))
1486
-                           . '</div>';
1487
-        }
1488
-
1489
-        if ($this->header) {
1490
-            $feedArray[] = "<div class='" . $this->stylePrefix . "header'>" . $this->header . '</div>';
1491
-        }
1492
-
1493
-        for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
1494
-            if ($this->separator && $i > 0) {
1495
-                $feedArray[] = "<div class='" . $this->stylePrefix . "separator'>" . $this->separator . '</div>';
1496
-            }
1497
-
1498
-            if ($this->items[$i]->title) {
1499
-                if ($this->items[$i]->link) {
1500
-                    $feedArray[] = "<div class='" . $this->stylePrefix . "item_title'><a href='"
1501
-                                   . $this->items[$i]->link . "' class='" . $this->stylePrefix . "item_title'"
1502
-                                   . $targetInsert . '>'
1503
-                                   . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100)
1504
-                                   . '</a></div>';
1505
-                } else {
1506
-                    $feedArray[] = "<div class='" . $this->stylePrefix . "item_title'>"
1507
-                                   . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100)
1508
-                                   . '</div>';
1509
-                }
1510
-            }
1511
-            if ($this->items[$i]->getDescription()) {
1512
-                $feedArray[] = "<div class='" . $this->stylePrefix . "item_description'>" . str_replace(']]>', '',
1513
-                                                                                                        str_replace('<![CDATA[',
1514
-                                                                                                                    '',
1515
-                                                                                                                    $this->items[$i]->getDescription()))
1516
-                               . '</div>';
1517
-            }
1518
-        }
1519
-        if ($this->footer) {
1520
-            $feedArray[] = "<div class='" . $this->stylePrefix . "footer'>" . $this->footer . '</div>';
1521
-        }
1522
-
1523
-        $feed = '' . implode($feedArray, "\r\n");
1524
-
1525
-        return $feed;
1526
-    }
1527
-
1528
-    /**
1529
-     * Overrrides parent to produce .html extensions
1530
-     *
1531
-     * @return string the feed cache filename
1532
-     * @since  1.4
1533
-     * @access private
1534
-     */
1535
-    public function _generateFilename() {
1536
-        $fileInfo = pathinfo($_SERVER['PHP_SELF']);
1537
-
1538
-        return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.html';
1539
-    }
1400
+	public $contentType = 'text/html';
1401
+
1402
+	/**
1403
+	 * Contains HTML to be output at the start of the feed's html representation.
1404
+	 */
1405
+	public $header;
1406
+
1407
+	/**
1408
+	 * Contains HTML to be output at the end of the feed's html representation.
1409
+	 */
1410
+	public $footer;
1411
+
1412
+	/**
1413
+	 * Contains HTML to be output between entries. A separator is only used in
1414
+	 * case of multiple entries.
1415
+	 */
1416
+	public $separator;
1417
+
1418
+	/**
1419
+	 * Used to prefix the stylenames to make sure they are unique
1420
+	 * and do not clash with stylenames on the users' page.
1421
+	 */
1422
+	public $stylePrefix;
1423
+
1424
+	/**
1425
+	 * Determines whether the links open in a new window or not.
1426
+	 */
1427
+	public $openInNewWindow = true;
1428
+
1429
+	public $imageAlign = 'right';
1430
+
1431
+	/**
1432
+	 * In case of very simple output you may want to get rid of the style tags,
1433
+	 * hence this variable.  There's no equivalent on item level, but of course you can
1434
+	 * add strings to it while iterating over the items ($this->stylelessOutput .= ...)
1435
+	 * and when it is non-empty, ONLY the styleless output is printed, the rest is ignored
1436
+	 * in the function createFeed().
1437
+	 */
1438
+	public $stylelessOutput = '';
1439
+
1440
+	/**
1441
+	 * Writes the HTML.
1442
+	 * @return string the scripts's complete text
1443
+	 */
1444
+	public function createFeed() {
1445
+		// if there is styleless output, use the content of this variable and ignore the rest
1446
+		if ($this->stylelessOutput != '') {
1447
+			return $this->stylelessOutput;
1448
+		}
1449
+
1450
+		//if no stylePrefix is set, generate it yourself depending on the script name
1451
+		if ($this->stylePrefix == '') {
1452
+			$this->stylePrefix = str_replace('.', '_', $this->_generateFilename()) . '_';
1453
+		}
1454
+
1455
+		//set an openInNewWindow_token_to be inserted or not
1456
+		if ($this->openInNewWindow) {
1457
+			$targetInsert = " target='_blank'";
1458
+		}
1459
+
1460
+		// use this array to put the lines in and implode later with "document.write" javascript
1461
+		$feedArray = array();
1462
+		if ($this->image != null) {
1463
+			$imageStr = "<a href='" . $this->image->link . "'" . $targetInsert . '>' . "<img src='" . $this->image->url
1464
+						. "' border='0' alt='" . FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100)
1465
+						. "' align='" . $this->imageAlign . "' ";
1466
+			if ($this->image->width) {
1467
+				$imageStr .= " width='" . $this->image->width . "' ";
1468
+			}
1469
+			if ($this->image->height) {
1470
+				$imageStr .= " height='" . $this->image->height . "' ";
1471
+			}
1472
+			$imageStr .= '/></a>';
1473
+			$feedArray[] = $imageStr;
1474
+		}
1475
+
1476
+		if ($this->title) {
1477
+			$feedArray[] = "<div class='" . $this->stylePrefix . "title'><a href='" . $this->link . "' " . $targetInsert
1478
+						   . " class='" . $this->stylePrefix . "title'>"
1479
+						   . FeedCreator::iTrunc(htmlspecialchars($this->title), 100) . '</a></div>';
1480
+		}
1481
+		if ($this->getDescription()) {
1482
+			$feedArray[] = "<div class='" . $this->stylePrefix . "description'>" . str_replace(']]>', '',
1483
+																							   str_replace('<![CDATA[',
1484
+																										   '',
1485
+																										   $this->getDescription()))
1486
+						   . '</div>';
1487
+		}
1488
+
1489
+		if ($this->header) {
1490
+			$feedArray[] = "<div class='" . $this->stylePrefix . "header'>" . $this->header . '</div>';
1491
+		}
1492
+
1493
+		for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
1494
+			if ($this->separator && $i > 0) {
1495
+				$feedArray[] = "<div class='" . $this->stylePrefix . "separator'>" . $this->separator . '</div>';
1496
+			}
1497
+
1498
+			if ($this->items[$i]->title) {
1499
+				if ($this->items[$i]->link) {
1500
+					$feedArray[] = "<div class='" . $this->stylePrefix . "item_title'><a href='"
1501
+								   . $this->items[$i]->link . "' class='" . $this->stylePrefix . "item_title'"
1502
+								   . $targetInsert . '>'
1503
+								   . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100)
1504
+								   . '</a></div>';
1505
+				} else {
1506
+					$feedArray[] = "<div class='" . $this->stylePrefix . "item_title'>"
1507
+								   . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100)
1508
+								   . '</div>';
1509
+				}
1510
+			}
1511
+			if ($this->items[$i]->getDescription()) {
1512
+				$feedArray[] = "<div class='" . $this->stylePrefix . "item_description'>" . str_replace(']]>', '',
1513
+																										str_replace('<![CDATA[',
1514
+																													'',
1515
+																													$this->items[$i]->getDescription()))
1516
+							   . '</div>';
1517
+			}
1518
+		}
1519
+		if ($this->footer) {
1520
+			$feedArray[] = "<div class='" . $this->stylePrefix . "footer'>" . $this->footer . '</div>';
1521
+		}
1522
+
1523
+		$feed = '' . implode($feedArray, "\r\n");
1524
+
1525
+		return $feed;
1526
+	}
1527
+
1528
+	/**
1529
+	 * Overrrides parent to produce .html extensions
1530
+	 *
1531
+	 * @return string the feed cache filename
1532
+	 * @since  1.4
1533
+	 * @access private
1534
+	 */
1535
+	public function _generateFilename() {
1536
+		$fileInfo = pathinfo($_SERVER['PHP_SELF']);
1537
+
1538
+		return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.html';
1539
+	}
1540 1540
 }
1541 1541
 
1542 1542
 /**
@@ -1547,36 +1547,36 @@  discard block
 block discarded – undo
1547 1547
  */
1548 1548
 class JSCreator extends HTMLCreator
1549 1549
 {
1550
-    public $contentType = 'text/javascript';
1551
-
1552
-    /**
1553
-     * writes the javascript
1554
-     * @return string the scripts's complete text
1555
-     */
1556
-    public function createFeed() {
1557
-        $feed      = parent::createFeed();
1558
-        $feedArray = explode("\n", $feed);
1559
-
1560
-        $jsFeed = '';
1561
-        foreach ($feedArray as $value) {
1562
-            $jsFeed .= "document.write('" . trim(addslashes($value)) . "');\n";
1563
-        }
1564
-
1565
-        return $jsFeed;
1566
-    }
1567
-
1568
-    /**
1569
-     * Overrrides parent to produce .js extensions
1570
-     *
1571
-     * @return string the feed cache filename
1572
-     * @since  1.4
1573
-     * @access private
1574
-     */
1575
-    public function _generateFilename() {
1576
-        $fileInfo = pathinfo($_SERVER['PHP_SELF']);
1577
-
1578
-        return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.js';
1579
-    }
1550
+	public $contentType = 'text/javascript';
1551
+
1552
+	/**
1553
+	 * writes the javascript
1554
+	 * @return string the scripts's complete text
1555
+	 */
1556
+	public function createFeed() {
1557
+		$feed      = parent::createFeed();
1558
+		$feedArray = explode("\n", $feed);
1559
+
1560
+		$jsFeed = '';
1561
+		foreach ($feedArray as $value) {
1562
+			$jsFeed .= "document.write('" . trim(addslashes($value)) . "');\n";
1563
+		}
1564
+
1565
+		return $jsFeed;
1566
+	}
1567
+
1568
+	/**
1569
+	 * Overrrides parent to produce .js extensions
1570
+	 *
1571
+	 * @return string the feed cache filename
1572
+	 * @since  1.4
1573
+	 * @access private
1574
+	 */
1575
+	public function _generateFilename() {
1576
+		$fileInfo = pathinfo($_SERVER['PHP_SELF']);
1577
+
1578
+		return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.js';
1579
+	}
1580 1580
 }
1581 1581
 
1582 1582
 /*** TEST SCRIPT *********************************************************
Please login to merge, or discard this patch.
Spacing   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
         if (!$this->rawFieldContent) {
326 326
             $result = '';
327 327
         } elseif ($this->syndicateHtml) {
328
-            $result = '<![CDATA[' . $this->rawFieldContent . ']]>';
329
-        } else {
328
+            $result = '<![CDATA['.$this->rawFieldContent.']]>';
329
+        }else {
330 330
             if ($this->truncSize && is_int($this->truncSize)) {
331 331
                 $result = FeedCreator::iTrunc(htmlspecialchars($this->rawFieldContent), $this->truncSize);
332
-            } else {
332
+            }else {
333 333
                 $result = htmlspecialchars($this->rawFieldContent);
334 334
             }
335 335
         }
@@ -550,29 +550,29 @@  discard block
 block discarded – undo
550 550
      * @return string the truncated string
551 551
      */
552 552
     public function iTrunc($string, $length) {
553
-        if (strlen($string) <= $length) {
553
+        if (strlen($string)<=$length) {
554 554
             return $string;
555 555
         }
556 556
 
557 557
         $pos = strrpos($string, '.');
558
-        if ($pos >= $length - 4) {
559
-            $string = substr($string, 0, $length - 4);
558
+        if ($pos>=$length-4) {
559
+            $string = substr($string, 0, $length-4);
560 560
             $pos    = strrpos($string, '.');
561 561
         }
562
-        if ($pos >= $length * 0.4) {
563
-            return substr($string, 0, $pos + 1) . ' ...';
562
+        if ($pos>=$length*0.4) {
563
+            return substr($string, 0, $pos+1).' ...';
564 564
         }
565 565
 
566 566
         $pos = strrpos($string, ' ');
567
-        if ($pos >= $length - 4) {
568
-            $string = substr($string, 0, $length - 4);
567
+        if ($pos>=$length-4) {
568
+            $string = substr($string, 0, $length-4);
569 569
             $pos    = strrpos($string, ' ');
570 570
         }
571
-        if ($pos >= $length * 0.4) {
572
-            return substr($string, 0, $pos) . ' ...';
571
+        if ($pos>=$length*0.4) {
572
+            return substr($string, 0, $pos).' ...';
573 573
         }
574 574
 
575
-        return substr($string, 0, $length - 4) . ' ...';
575
+        return substr($string, 0, $length-4).' ...';
576 576
     }
577 577
 
578 578
     /**
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
      * Syndic8.com.
582 582
      */
583 583
     public function _createGeneratorComment() {
584
-        return "<!-- generator=\"" . FEEDCREATOR_VERSION . "\" -->\n";
584
+        return "<!-- generator=\"".FEEDCREATOR_VERSION."\" -->\n";
585 585
     }
586 586
 
587 587
     /**
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
         $ae = '';
598 598
         if (is_array($elements)) {
599 599
             foreach ($elements as $key => $value) {
600
-                $ae .= $indentString . "<$key>$value</$key>\n";
600
+                $ae .= $indentString."<$key>$value</$key>\n";
601 601
             }
602 602
         }
603 603
 
@@ -610,10 +610,10 @@  discard block
 block discarded – undo
610 610
     public function _createStylesheetReferences() {
611 611
         $xml = '';
612 612
         if ($this->cssStyleSheet) {
613
-            $xml .= "<?xml-stylesheet href=\"" . $this->cssStyleSheet . "\" type=\"text/css\"?>\n";
613
+            $xml .= "<?xml-stylesheet href=\"".$this->cssStyleSheet."\" type=\"text/css\"?>\n";
614 614
         }
615 615
         if ($this->xslStyleSheet) {
616
-            $xml .= "<?xml-stylesheet href=\"" . $this->xslStyleSheet . "\" type=\"text/xsl\"?>\n";
616
+            $xml .= "<?xml-stylesheet href=\"".$this->xslStyleSheet."\" type=\"text/xsl\"?>\n";
617 617
         }
618 618
 
619 619
         return $xml;
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
     public function _generateFilename() {
647 647
         $fileInfo = pathinfo($_SERVER['PHP_SELF']);
648 648
 
649
-        return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.xml';
649
+        return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension'])+1)).'.xml';
650 650
     }
651 651
 
652 652
     /**
@@ -668,9 +668,9 @@  discard block
 block discarded – undo
668 668
         // HTTP redirect, some feed readers' simple HTTP implementations don't follow it
669 669
         //Header("Location: ".$filename);
670 670
 
671
-        header('Content-Type: ' . $this->contentType . '; charset=' . $this->encoding . '; filename='
671
+        header('Content-Type: '.$this->contentType.'; charset='.$this->encoding.'; filename='
672 672
                . basename($filename));
673
-        header('Content-Disposition: inline; filename=' . basename($filename));
673
+        header('Content-Disposition: inline; filename='.basename($filename));
674 674
         readfile($filename, 'r');
675 675
         die();
676 676
     }
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
         if ($filename == '') {
692 692
             $filename = $this->_generateFilename();
693 693
         }
694
-        if (file_exists($filename) && (time() - filemtime($filename) < $timeout)) {
694
+        if (file_exists($filename) && (time()-filemtime($filename)<$timeout)) {
695 695
             $this->_redirect($filename);
696 696
         }
697 697
     }
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
             if ($displayContents) {
717 717
                 $this->_redirect($filename);
718 718
             }
719
-        } else {
719
+        }else {
720 720
             echo '<br><b>Error creating feed file, please check write permissions.</b><br>';
721 721
         }
722 722
     }
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
         }
750 750
         if (preg_match("~(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\\s+)?(\\d{1,2})\\s+([a-zA-Z]{3})\\s+(\\d{4})\\s+(\\d{2}):(\\d{2}):(\\d{2})\\s+(.*)~",
751 751
                        $dateString, $matches)) {
752
-            $months     = array(
752
+            $months = array(
753 753
                 'Jan' => 1,
754 754
                 'Feb' => 2,
755 755
                 'Mar' => 3,
@@ -765,15 +765,15 @@  discard block
 block discarded – undo
765 765
             );
766 766
             $this->unix = mktime($matches[4], $matches[5], $matches[6], $months[$matches[2]], $matches[1], $matches[3]);
767 767
             if (substr($matches[7], 0, 1) == '+' || substr($matches[7], 0, 1) == '-') {
768
-                $tzOffset = (substr($matches[7], 0, 3) * 60 + substr($matches[7], -2)) * 60;
769
-            } else {
768
+                $tzOffset = (substr($matches[7], 0, 3)*60+substr($matches[7], -2))*60;
769
+            }else {
770 770
                 if (strlen($matches[7]) == 1) {
771 771
                     $oneHour = 3600;
772 772
                     $ord     = ord($matches[7]);
773
-                    if ($ord < ord('M')) {
774
-                        $tzOffset = (ord('A') - $ord - 1) * $oneHour;
775
-                    } elseif ($ord >= ord('M') && $matches[7] !== 'Z') {
776
-                        $tzOffset = ($ord - ord('M')) * $oneHour;
773
+                    if ($ord<ord('M')) {
774
+                        $tzOffset = (ord('A')-$ord-1)*$oneHour;
775
+                    } elseif ($ord>=ord('M') && $matches[7] !== 'Z') {
776
+                        $tzOffset = ($ord-ord('M'))*$oneHour;
777 777
                     } elseif ($matches[7] === 'Z') {
778 778
                         $tzOffset = 0;
779 779
                     }
@@ -791,8 +791,8 @@  discard block
 block discarded – undo
791 791
         if (preg_match("~(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(.*)~", $dateString, $matches)) {
792 792
             $this->unix = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
793 793
             if (substr($matches[7], 0, 1) == '+' || substr($matches[7], 0, 1) == '-') {
794
-                $tzOffset = (substr($matches[7], 0, 3) * 60 + substr($matches[7], -2)) * 60;
795
-            } else {
794
+                $tzOffset = (substr($matches[7], 0, 3)*60+substr($matches[7], -2))*60;
795
+            }else {
796 796
                 if ($matches[7] === 'Z') {
797 797
                     $tzOffset = 0;
798 798
                 }
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
         //return gmdate("r",$this->unix);
814 814
         $date = gmdate('D, d M Y H:i:s', $this->unix);
815 815
         if (TIME_ZONE != '') {
816
-            $date .= ' ' . str_replace(':', '', TIME_ZONE);
816
+            $date .= ' '.str_replace(':', '', TIME_ZONE);
817 817
         }
818 818
 
819 819
         return $date;
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
      */
827 827
     public function iso8601() {
828 828
         $date = gmdate("Y-m-d\TH:i:sO", $this->unix);
829
-        $date = substr($date, 0, 22) . ':' . substr($date, -2);
829
+        $date = substr($date, 0, 22).':'.substr($date, -2);
830 830
         if (TIME_ZONE != '') {
831 831
             $date = str_replace('+00:00', TIME_ZONE, $date);
832 832
         }
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
      * @return string the feed's complete text
860 860
      */
861 861
     public function createFeed() {
862
-        $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
862
+        $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n";
863 863
         $feed .= $this->_createGeneratorComment();
864 864
         if ($this->cssStyleSheet == '') {
865 865
             $cssStyleSheet = 'http://www.w3.org/2000/08/w3c-synd/style.css';
@@ -870,50 +870,50 @@  discard block
 block discarded – undo
870 870
         $feed .= "    xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n";
871 871
         $feed .= "    xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\"\n";
872 872
         $feed .= "    xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";
873
-        $feed .= "    <channel rdf:about=\"" . $this->syndicationURL . "\">\n";
874
-        $feed .= '        <title>' . htmlspecialchars($this->title) . "</title>\n";
875
-        $feed .= '        <description>' . htmlspecialchars($this->description) . "</description>\n";
876
-        $feed .= '        <link>' . $this->link . "</link>\n";
873
+        $feed .= "    <channel rdf:about=\"".$this->syndicationURL."\">\n";
874
+        $feed .= '        <title>'.htmlspecialchars($this->title)."</title>\n";
875
+        $feed .= '        <description>'.htmlspecialchars($this->description)."</description>\n";
876
+        $feed .= '        <link>'.$this->link."</link>\n";
877 877
         if ($this->image != null) {
878
-            $feed .= "        <image rdf:resource=\"" . $this->image->url . "\" />\n";
878
+            $feed .= "        <image rdf:resource=\"".$this->image->url."\" />\n";
879 879
         }
880 880
         $now = new FeedDate();
881
-        $feed .= '       <dc:date>' . htmlspecialchars($now->iso8601()) . "</dc:date>\n";
881
+        $feed .= '       <dc:date>'.htmlspecialchars($now->iso8601())."</dc:date>\n";
882 882
         $feed .= "        <items>\n";
883 883
         $feed .= "            <rdf:Seq>\n";
884
-        for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
885
-            $feed .= "                <rdf:li rdf:resource=\"" . htmlspecialchars($this->items[$i]->link) . "\"/>\n";
884
+        for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) {
885
+            $feed .= "                <rdf:li rdf:resource=\"".htmlspecialchars($this->items[$i]->link)."\"/>\n";
886 886
         }
887 887
         $feed .= "            </rdf:Seq>\n";
888 888
         $feed .= "        </items>\n";
889 889
         $feed .= "    </channel>\n";
890 890
         if ($this->image != null) {
891
-            $feed .= "    <image rdf:about=\"" . $this->image->url . "\">\n";
892
-            $feed .= '        <title>' . $this->image->title . "</title>\n";
893
-            $feed .= '        <link>' . $this->image->link . "</link>\n";
894
-            $feed .= '        <url>' . $this->image->url . "</url>\n";
891
+            $feed .= "    <image rdf:about=\"".$this->image->url."\">\n";
892
+            $feed .= '        <title>'.$this->image->title."</title>\n";
893
+            $feed .= '        <link>'.$this->image->link."</link>\n";
894
+            $feed .= '        <url>'.$this->image->url."</url>\n";
895 895
             $feed .= "    </image>\n";
896 896
         }
897 897
         $feed .= $this->_createAdditionalElements($this->additionalElements, '    ');
898 898
 
899
-        for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
900
-            $feed .= "    <item rdf:about=\"" . htmlspecialchars($this->items[$i]->link) . "\">\n";
899
+        for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) {
900
+            $feed .= "    <item rdf:about=\"".htmlspecialchars($this->items[$i]->link)."\">\n";
901 901
             //$feed.= "        <dc:type>Posting</dc:type>\n";
902 902
             $feed .= "        <dc:format>text/html</dc:format>\n";
903 903
             if ($this->items[$i]->date != null) {
904 904
                 $itemDate = new FeedDate($this->items[$i]->date);
905
-                $feed .= '        <dc:date>' . htmlspecialchars($itemDate->iso8601()) . "</dc:date>\n";
905
+                $feed .= '        <dc:date>'.htmlspecialchars($itemDate->iso8601())."</dc:date>\n";
906 906
             }
907 907
             if ($this->items[$i]->source != '') {
908
-                $feed .= '        <dc:source>' . htmlspecialchars($this->items[$i]->source) . "</dc:source>\n";
908
+                $feed .= '        <dc:source>'.htmlspecialchars($this->items[$i]->source)."</dc:source>\n";
909 909
             }
910 910
             if ($this->items[$i]->author != '') {
911
-                $feed .= '        <dc:creator>' . htmlspecialchars($this->items[$i]->author) . "</dc:creator>\n";
911
+                $feed .= '        <dc:creator>'.htmlspecialchars($this->items[$i]->author)."</dc:creator>\n";
912 912
             }
913
-            $feed .= '        <title>' . htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", '  ')))
913
+            $feed .= '        <title>'.htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", '  ')))
914 914
                      . "</title>\n";
915
-            $feed .= '        <link>' . htmlspecialchars($this->items[$i]->link) . "</link>\n";
916
-            $feed .= '        <description>' . htmlspecialchars($this->items[$i]->description) . "</description>\n";
915
+            $feed .= '        <link>'.htmlspecialchars($this->items[$i]->link)."</link>\n";
916
+            $feed .= '        <description>'.htmlspecialchars($this->items[$i]->description)."</description>\n";
917 917
             $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, '        ');
918 918
             $feed .= "    </item>\n";
919 919
         }
@@ -961,84 +961,84 @@  discard block
 block discarded – undo
961 961
      * @return string the feed's complete text
962 962
      */
963 963
     public function createFeed() {
964
-        $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
964
+        $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n";
965 965
         $feed .= $this->_createGeneratorComment();
966 966
         $feed .= $this->_createStylesheetReferences();
967
-        $feed .= "<rss version=\"" . $this->RSSVersion . "\">\n";
967
+        $feed .= "<rss version=\"".$this->RSSVersion."\">\n";
968 968
         $feed .= "    <channel>\n";
969
-        $feed .= '        <title>' . FeedCreator::iTrunc(htmlspecialchars($this->title), 100) . "</title>\n";
969
+        $feed .= '        <title>'.FeedCreator::iTrunc(htmlspecialchars($this->title), 100)."</title>\n";
970 970
         $this->descriptionTruncSize = 500;
971
-        $feed .= '        <description>' . $this->getDescription() . "</description>\n";
972
-        $feed .= '        <link>' . $this->link . "</link>\n";
971
+        $feed .= '        <description>'.$this->getDescription()."</description>\n";
972
+        $feed .= '        <link>'.$this->link."</link>\n";
973 973
         $now = new FeedDate();
974
-        $feed .= '        <lastBuildDate>' . htmlspecialchars($now->rfc822()) . "</lastBuildDate>\n";
975
-        $feed .= '        <generator>' . FEEDCREATOR_VERSION . "</generator>\n";
974
+        $feed .= '        <lastBuildDate>'.htmlspecialchars($now->rfc822())."</lastBuildDate>\n";
975
+        $feed .= '        <generator>'.FEEDCREATOR_VERSION."</generator>\n";
976 976
 
977 977
         if ($this->image != null) {
978 978
             $feed .= "        <image>\n";
979
-            $feed .= '            <url>' . $this->image->url . "</url>\n";
980
-            $feed .= '            <title>' . FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100)
979
+            $feed .= '            <url>'.$this->image->url."</url>\n";
980
+            $feed .= '            <title>'.FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100)
981 981
                      . "</title>\n";
982
-            $feed .= '            <link>' . $this->image->link . "</link>\n";
982
+            $feed .= '            <link>'.$this->image->link."</link>\n";
983 983
             if ($this->image->width != '') {
984
-                $feed .= '            <width>' . $this->image->width . "</width>\n";
984
+                $feed .= '            <width>'.$this->image->width."</width>\n";
985 985
             }
986 986
             if ($this->image->height != '') {
987
-                $feed .= '            <height>' . $this->image->height . "</height>\n";
987
+                $feed .= '            <height>'.$this->image->height."</height>\n";
988 988
             }
989 989
             if ($this->image->description != '') {
990
-                $feed .= '            <description>' . $this->image->getDescription() . "</description>\n";
990
+                $feed .= '            <description>'.$this->image->getDescription()."</description>\n";
991 991
             }
992 992
             $feed .= "        </image>\n";
993 993
         }
994 994
         if ($this->language != '') {
995
-            $feed .= '        <language>' . $this->language . "</language>\n";
995
+            $feed .= '        <language>'.$this->language."</language>\n";
996 996
         }
997 997
         if ($this->copyright != '') {
998
-            $feed .= '        <copyright>' . FeedCreator::iTrunc(htmlspecialchars($this->copyright), 100)
998
+            $feed .= '        <copyright>'.FeedCreator::iTrunc(htmlspecialchars($this->copyright), 100)
999 999
                      . "</copyright>\n";
1000 1000
         }
1001 1001
         if ($this->editor != '') {
1002
-            $feed .= '        <managingEditor>' . FeedCreator::iTrunc(htmlspecialchars($this->editor), 100)
1002
+            $feed .= '        <managingEditor>'.FeedCreator::iTrunc(htmlspecialchars($this->editor), 100)
1003 1003
                      . "</managingEditor>\n";
1004 1004
         }
1005 1005
         if ($this->webmaster != '') {
1006
-            $feed .= '        <webMaster>' . FeedCreator::iTrunc(htmlspecialchars($this->webmaster), 100)
1006
+            $feed .= '        <webMaster>'.FeedCreator::iTrunc(htmlspecialchars($this->webmaster), 100)
1007 1007
                      . "</webMaster>\n";
1008 1008
         }
1009 1009
         if ($this->pubDate != '') {
1010 1010
             $pubDate = new FeedDate($this->pubDate);
1011
-            $feed .= '        <pubDate>' . htmlspecialchars($pubDate->rfc822()) . "</pubDate>\n";
1011
+            $feed .= '        <pubDate>'.htmlspecialchars($pubDate->rfc822())."</pubDate>\n";
1012 1012
         }
1013 1013
         if ($this->category != '') {
1014
-            $feed .= '        <category>' . htmlspecialchars($this->category) . "</category>\n";
1014
+            $feed .= '        <category>'.htmlspecialchars($this->category)."</category>\n";
1015 1015
         }
1016 1016
         if ($this->docs != '') {
1017
-            $feed .= '        <docs>' . FeedCreator::iTrunc(htmlspecialchars($this->docs), 500) . "</docs>\n";
1017
+            $feed .= '        <docs>'.FeedCreator::iTrunc(htmlspecialchars($this->docs), 500)."</docs>\n";
1018 1018
         }
1019 1019
         if ($this->ttl != '') {
1020
-            $feed .= '        <ttl>' . htmlspecialchars($this->ttl) . "</ttl>\n";
1020
+            $feed .= '        <ttl>'.htmlspecialchars($this->ttl)."</ttl>\n";
1021 1021
         }
1022 1022
         if ($this->rating != '') {
1023
-            $feed .= '        <rating>' . FeedCreator::iTrunc(htmlspecialchars($this->rating), 500) . "</rating>\n";
1023
+            $feed .= '        <rating>'.FeedCreator::iTrunc(htmlspecialchars($this->rating), 500)."</rating>\n";
1024 1024
         }
1025 1025
         if ($this->skipHours != '') {
1026
-            $feed .= '        <skipHours>' . htmlspecialchars($this->skipHours) . "</skipHours>\n";
1026
+            $feed .= '        <skipHours>'.htmlspecialchars($this->skipHours)."</skipHours>\n";
1027 1027
         }
1028 1028
         if ($this->skipDays != '') {
1029
-            $feed .= '        <skipDays>' . htmlspecialchars($this->skipDays) . "</skipDays>\n";
1029
+            $feed .= '        <skipDays>'.htmlspecialchars($this->skipDays)."</skipDays>\n";
1030 1030
         }
1031 1031
         $feed .= $this->_createAdditionalElements($this->additionalElements, '    ');
1032 1032
 
1033
-        for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
1033
+        for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) {
1034 1034
             $feed .= "        <item>\n";
1035
-            $feed .= '            <title>' . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)),
1036
-                                                                 100) . "</title>\n";
1037
-            $feed .= '            <link>' . htmlspecialchars($this->items[$i]->link) . "</link>\n";
1038
-            $feed .= '            <description>' . $this->items[$i]->getDescription() . "</description>\n";
1035
+            $feed .= '            <title>'.FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)),
1036
+                                                                 100)."</title>\n";
1037
+            $feed .= '            <link>'.htmlspecialchars($this->items[$i]->link)."</link>\n";
1038
+            $feed .= '            <description>'.$this->items[$i]->getDescription()."</description>\n";
1039 1039
 
1040 1040
             if ($this->items[$i]->author != '') {
1041
-                $feed .= '            <author>' . htmlspecialchars($this->items[$i]->author) . "</author>\n";
1041
+                $feed .= '            <author>'.htmlspecialchars($this->items[$i]->author)."</author>\n";
1042 1042
             }
1043 1043
             /*
1044 1044
             // on hold
@@ -1047,17 +1047,17 @@  discard block
 block discarded – undo
1047 1047
             }
1048 1048
             */
1049 1049
             if ($this->items[$i]->category != '') {
1050
-                $feed .= '            <category>' . htmlspecialchars($this->items[$i]->category) . "</category>\n";
1050
+                $feed .= '            <category>'.htmlspecialchars($this->items[$i]->category)."</category>\n";
1051 1051
             }
1052 1052
             if ($this->items[$i]->comments != '') {
1053
-                $feed .= '            <comments>' . htmlspecialchars($this->items[$i]->comments) . "</comments>\n";
1053
+                $feed .= '            <comments>'.htmlspecialchars($this->items[$i]->comments)."</comments>\n";
1054 1054
             }
1055 1055
             if ($this->items[$i]->date != '') {
1056 1056
                 $itemDate = new FeedDate($this->items[$i]->date);
1057
-                $feed .= '            <pubDate>' . htmlspecialchars($itemDate->rfc822()) . "</pubDate>\n";
1057
+                $feed .= '            <pubDate>'.htmlspecialchars($itemDate->rfc822())."</pubDate>\n";
1058 1058
             }
1059 1059
             if ($this->items[$i]->guid != '') {
1060
-                $feed .= '            <guid>' . htmlspecialchars($this->items[$i]->guid) . "</guid>\n";
1060
+                $feed .= '            <guid>'.htmlspecialchars($this->items[$i]->guid)."</guid>\n";
1061 1061
             }
1062 1062
             $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, '        ');
1063 1063
             $feed .= "        </item>\n";
@@ -1107,33 +1107,33 @@  discard block
 block discarded – undo
1107 1107
      * @return string
1108 1108
      */
1109 1109
     public function createFeed() {
1110
-        $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
1110
+        $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n";
1111 1111
         $feed .= $this->_createStylesheetReferences();
1112 1112
         $feed .= "<feed version=\"0.1\" xmlns=\"http://example.com/newformat#\">\n";
1113
-        $feed .= '    <title>' . FeedCreator::iTrunc(htmlspecialchars($this->title), 100) . "</title>\n";
1113
+        $feed .= '    <title>'.FeedCreator::iTrunc(htmlspecialchars($this->title), 100)."</title>\n";
1114 1114
         $this->truncSize = 500;
1115
-        $feed .= '    <subtitle>' . $this->getDescription() . "</subtitle>\n";
1116
-        $feed .= '    <link>' . $this->link . "</link>\n";
1117
-        for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
1115
+        $feed .= '    <subtitle>'.$this->getDescription()."</subtitle>\n";
1116
+        $feed .= '    <link>'.$this->link."</link>\n";
1117
+        for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) {
1118 1118
             $feed .= "    <entry>\n";
1119
-            $feed .= '        <title>' . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100)
1119
+            $feed .= '        <title>'.FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100)
1120 1120
                      . "</title>\n";
1121
-            $feed .= '        <link>' . htmlspecialchars($this->items[$i]->link) . "</link>\n";
1121
+            $feed .= '        <link>'.htmlspecialchars($this->items[$i]->link)."</link>\n";
1122 1122
             $itemDate = new FeedDate($this->items[$i]->date);
1123
-            $feed .= '        <created>' . htmlspecialchars($itemDate->iso8601()) . "</created>\n";
1124
-            $feed .= '        <issued>' . htmlspecialchars($itemDate->iso8601()) . "</issued>\n";
1125
-            $feed .= '        <modified>' . htmlspecialchars($itemDate->iso8601()) . "</modified>\n";
1126
-            $feed .= '        <id>' . htmlspecialchars($this->items[$i]->guid) . "</id>\n";
1123
+            $feed .= '        <created>'.htmlspecialchars($itemDate->iso8601())."</created>\n";
1124
+            $feed .= '        <issued>'.htmlspecialchars($itemDate->iso8601())."</issued>\n";
1125
+            $feed .= '        <modified>'.htmlspecialchars($itemDate->iso8601())."</modified>\n";
1126
+            $feed .= '        <id>'.htmlspecialchars($this->items[$i]->guid)."</id>\n";
1127 1127
             if ($this->items[$i]->author != '') {
1128 1128
                 $feed .= "        <author>\n";
1129
-                $feed .= '            <name>' . htmlspecialchars($this->items[$i]->author) . "</name>\n";
1129
+                $feed .= '            <name>'.htmlspecialchars($this->items[$i]->author)."</name>\n";
1130 1130
                 if ($this->items[$i]->authorEmail != '') {
1131
-                    $feed .= '            <email>' . $this->items[$i]->authorEmail . "</email>\n";
1131
+                    $feed .= '            <email>'.$this->items[$i]->authorEmail."</email>\n";
1132 1132
                 }
1133 1133
                 $feed .= "        </author>\n";
1134 1134
             }
1135 1135
             $feed .= "        <content type=\"text/html\" xml:lang=\"en-us\">\n";
1136
-            $feed .= "            <div xmlns=\"http://www.w3.org/1999/xhtml\">" . $this->items[$i]->getDescription()
1136
+            $feed .= "            <div xmlns=\"http://www.w3.org/1999/xhtml\">".$this->items[$i]->getDescription()
1137 1137
                      . "</div>\n";
1138 1138
             $feed .= "        </content>\n";
1139 1139
             $feed .= "    </entry>\n";
@@ -1174,51 +1174,51 @@  discard block
 block discarded – undo
1174 1174
      * @return string
1175 1175
      */
1176 1176
     public function createFeed() {
1177
-        $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
1177
+        $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n";
1178 1178
         $feed .= $this->_createGeneratorComment();
1179 1179
         $feed .= $this->_createStylesheetReferences();
1180 1180
         $feed .= "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\"";
1181 1181
         if ($this->language != '') {
1182
-            $feed .= " xml:lang=\"" . $this->language . "\"";
1182
+            $feed .= " xml:lang=\"".$this->language."\"";
1183 1183
         }
1184 1184
         $feed .= ">\n";
1185
-        $feed .= '    <title>' . htmlspecialchars($this->title) . "</title>\n";
1186
-        $feed .= '    <tagline>' . htmlspecialchars($this->description) . "</tagline>\n";
1187
-        $feed .= "    <link rel=\"alternate\" type=\"text/html\" href=\"" . htmlspecialchars($this->link) . "\"/>\n";
1188
-        $feed .= '    <id>' . htmlspecialchars($this->link) . "</id>\n";
1185
+        $feed .= '    <title>'.htmlspecialchars($this->title)."</title>\n";
1186
+        $feed .= '    <tagline>'.htmlspecialchars($this->description)."</tagline>\n";
1187
+        $feed .= "    <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->link)."\"/>\n";
1188
+        $feed .= '    <id>'.htmlspecialchars($this->link)."</id>\n";
1189 1189
         $now = new FeedDate();
1190
-        $feed .= '    <modified>' . htmlspecialchars($now->iso8601()) . "</modified>\n";
1190
+        $feed .= '    <modified>'.htmlspecialchars($now->iso8601())."</modified>\n";
1191 1191
         if ($this->editor != '') {
1192 1192
             $feed .= "    <author>\n";
1193
-            $feed .= '        <name>' . $this->editor . "</name>\n";
1193
+            $feed .= '        <name>'.$this->editor."</name>\n";
1194 1194
             if ($this->editorEmail != '') {
1195
-                $feed .= '        <email>' . $this->editorEmail . "</email>\n";
1195
+                $feed .= '        <email>'.$this->editorEmail."</email>\n";
1196 1196
             }
1197 1197
             $feed .= "    </author>\n";
1198 1198
         }
1199
-        $feed .= '    <generator>' . FEEDCREATOR_VERSION . "</generator>\n";
1199
+        $feed .= '    <generator>'.FEEDCREATOR_VERSION."</generator>\n";
1200 1200
         $feed .= $this->_createAdditionalElements($this->additionalElements, '    ');
1201
-        for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
1201
+        for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) {
1202 1202
             $feed .= "    <entry>\n";
1203
-            $feed .= '        <title>' . htmlspecialchars(strip_tags($this->items[$i]->title)) . "</title>\n";
1203
+            $feed .= '        <title>'.htmlspecialchars(strip_tags($this->items[$i]->title))."</title>\n";
1204 1204
             $feed .= "        <link rel=\"alternate\" type=\"text/html\" href=\""
1205
-                     . htmlspecialchars($this->items[$i]->link) . "\"/>\n";
1205
+                     . htmlspecialchars($this->items[$i]->link)."\"/>\n";
1206 1206
             if ($this->items[$i]->date == '') {
1207 1207
                 $this->items[$i]->date = time();
1208 1208
             }
1209 1209
             $itemDate = new FeedDate($this->items[$i]->date);
1210
-            $feed .= '        <created>' . htmlspecialchars($itemDate->iso8601()) . "</created>\n";
1211
-            $feed .= '        <issued>' . htmlspecialchars($itemDate->iso8601()) . "</issued>\n";
1212
-            $feed .= '        <modified>' . htmlspecialchars($itemDate->iso8601()) . "</modified>\n";
1213
-            $feed .= '        <id>' . htmlspecialchars($this->items[$i]->link) . "</id>\n";
1210
+            $feed .= '        <created>'.htmlspecialchars($itemDate->iso8601())."</created>\n";
1211
+            $feed .= '        <issued>'.htmlspecialchars($itemDate->iso8601())."</issued>\n";
1212
+            $feed .= '        <modified>'.htmlspecialchars($itemDate->iso8601())."</modified>\n";
1213
+            $feed .= '        <id>'.htmlspecialchars($this->items[$i]->link)."</id>\n";
1214 1214
             $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, '        ');
1215 1215
             if ($this->items[$i]->author != '') {
1216 1216
                 $feed .= "        <author>\n";
1217
-                $feed .= '            <name>' . htmlspecialchars($this->items[$i]->author) . "</name>\n";
1217
+                $feed .= '            <name>'.htmlspecialchars($this->items[$i]->author)."</name>\n";
1218 1218
                 $feed .= "        </author>\n";
1219 1219
             }
1220 1220
             if ($this->items[$i]->description != '') {
1221
-                $feed .= '        <summary>' . htmlspecialchars($this->items[$i]->description) . "</summary>\n";
1221
+                $feed .= '        <summary>'.htmlspecialchars($this->items[$i]->description)."</summary>\n";
1222 1222
             }
1223 1223
             $feed .= "    </entry>\n";
1224 1224
         }
@@ -1260,23 +1260,23 @@  discard block
 block discarded – undo
1260 1260
             //$line = rtrim($line); // remove trailing white space -> no =20\r\n necessary
1261 1261
             $linlen  = strlen($line);
1262 1262
             $newline = '';
1263
-            for ($i = 0; $i < $linlen; ++$i) {
1263
+            for ($i = 0; $i<$linlen; ++$i) {
1264 1264
                 $c   = substr($line, $i, 1);
1265 1265
                 $dec = ord($c);
1266
-                if (($dec == 32) && ($i == ($linlen - 1))) { // convert space at eol only
1266
+                if (($dec == 32) && ($i == ($linlen-1))) { // convert space at eol only
1267 1267
                     $c = '=20';
1268
-                } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) { // always encode "\t", which is *not* required
1269
-                    $h2 = floor($dec / 16);
1270
-                    $h1 = floor($dec % 16);
1271
-                    $c  = $escape . $hex["$h2"] . $hex["$h1"];
1268
+                } elseif (($dec == 61) || ($dec<32) || ($dec>126)) { // always encode "\t", which is *not* required
1269
+                    $h2 = floor($dec/16);
1270
+                    $h1 = floor($dec%16);
1271
+                    $c  = $escape.$hex["$h2"].$hex["$h1"];
1272 1272
                 }
1273
-                if ((strlen($newline) + strlen($c)) >= $line_max) { // CRLF is not counted
1274
-                    $output .= $newline . $escape . $eol; // soft line break; " =\r\n" is okay
1273
+                if ((strlen($newline)+strlen($c))>=$line_max) { // CRLF is not counted
1274
+                    $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay
1275 1275
                     $newline = '';
1276 1276
                 }
1277 1277
                 $newline .= $c;
1278 1278
             } // end of for
1279
-            $output .= $newline . $eol;
1279
+            $output .= $newline.$eol;
1280 1280
         }
1281 1281
 
1282 1282
         return trim($output);
@@ -1287,22 +1287,22 @@  discard block
 block discarded – undo
1287 1287
      * @return string the feed's complete text
1288 1288
      */
1289 1289
     public function createFeed() {
1290
-        for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
1290
+        for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) {
1291 1291
             if ($this->items[$i]->author != '') {
1292 1292
                 $from = $this->items[$i]->author;
1293
-            } else {
1293
+            }else {
1294 1294
                 $from = $this->title;
1295 1295
             }
1296 1296
             $itemDate = new FeedDate($this->items[$i]->date);
1297
-            $feed .= 'From ' . strtr(MBOXCreator::qp_enc($from), ' ', '_') . ' ' . date('D M d H:i:s Y',
1298
-                                                                                        $itemDate->unix()) . "\n";
1297
+            $feed .= 'From '.strtr(MBOXCreator::qp_enc($from), ' ', '_').' '.date('D M d H:i:s Y',
1298
+                                                                                        $itemDate->unix())."\n";
1299 1299
             $feed .= "Content-Type: text/plain;\n";
1300
-            $feed .= "   charset=\"" . $this->encoding . "\"\n";
1300
+            $feed .= "   charset=\"".$this->encoding."\"\n";
1301 1301
             $feed .= "Content-Transfer-Encoding: quoted-printable\n";
1302 1302
             $feed .= "Content-Type: text/plain\n";
1303
-            $feed .= "From: \"" . MBOXCreator::qp_enc($from) . "\"\n";
1304
-            $feed .= 'Date: ' . $itemDate->rfc822() . "\n";
1305
-            $feed .= 'Subject: ' . MBOXCreator::qp_enc(FeedCreator::iTrunc($this->items[$i]->title, 100)) . "\n";
1303
+            $feed .= "From: \"".MBOXCreator::qp_enc($from)."\"\n";
1304
+            $feed .= 'Date: '.$itemDate->rfc822()."\n";
1305
+            $feed .= 'Subject: '.MBOXCreator::qp_enc(FeedCreator::iTrunc($this->items[$i]->title, 100))."\n";
1306 1306
             $feed .= "\n";
1307 1307
             $body = chunk_split(MBOXCreator::qp_enc($this->items[$i]->description));
1308 1308
             $feed .= preg_replace("~\nFrom ([^\n]*)(\n?)~", "\n>From $1$2\n", $body);
@@ -1322,7 +1322,7 @@  discard block
 block discarded – undo
1322 1322
     public function _generateFilename() {
1323 1323
         $fileInfo = pathinfo($_SERVER['PHP_SELF']);
1324 1324
 
1325
-        return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.mbox';
1325
+        return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension'])+1)).'.mbox';
1326 1326
     }
1327 1327
 }
1328 1328
 
@@ -1346,35 +1346,35 @@  discard block
 block discarded – undo
1346 1346
      * @return string
1347 1347
      */
1348 1348
     public function createFeed() {
1349
-        $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n";
1349
+        $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n";
1350 1350
         $feed .= $this->_createGeneratorComment();
1351 1351
         $feed .= $this->_createStylesheetReferences();
1352 1352
         $feed .= "<opml xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n";
1353 1353
         $feed .= "    <head>\n";
1354
-        $feed .= '        <title>' . htmlspecialchars($this->title) . "</title>\n";
1354
+        $feed .= '        <title>'.htmlspecialchars($this->title)."</title>\n";
1355 1355
         if ($this->pubDate != '') {
1356 1356
             $date = new FeedDate($this->pubDate);
1357
-            $feed .= '         <dateCreated>' . $date->rfc822() . "</dateCreated>\n";
1357
+            $feed .= '         <dateCreated>'.$date->rfc822()."</dateCreated>\n";
1358 1358
         }
1359 1359
         if ($this->lastBuildDate != '') {
1360 1360
             $date = new FeedDate($this->lastBuildDate);
1361
-            $feed .= '         <dateModified>' . $date->rfc822() . "</dateModified>\n";
1361
+            $feed .= '         <dateModified>'.$date->rfc822()."</dateModified>\n";
1362 1362
         }
1363 1363
         if ($this->editor != '') {
1364
-            $feed .= '         <ownerName>' . $this->editor . "</ownerName>\n";
1364
+            $feed .= '         <ownerName>'.$this->editor."</ownerName>\n";
1365 1365
         }
1366 1366
         if ($this->editorEmail != '') {
1367
-            $feed .= '         <ownerEmail>' . $this->editorEmail . "</ownerEmail>\n";
1367
+            $feed .= '         <ownerEmail>'.$this->editorEmail."</ownerEmail>\n";
1368 1368
         }
1369 1369
         $feed .= "    </head>\n";
1370 1370
         $feed .= "    <body>\n";
1371
-        for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
1371
+        for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) {
1372 1372
             $feed .= "    <outline type=\"rss\" ";
1373 1373
             $title = htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", '  ')));
1374
-            $feed .= " title=\"" . $title . "\"";
1375
-            $feed .= " text=\"" . $title . "\"";
1374
+            $feed .= " title=\"".$title."\"";
1375
+            $feed .= " text=\"".$title."\"";
1376 1376
             //$feed.= " description=\"".htmlspecialchars($this->items[$i]->description)."\"";
1377
-            $feed .= " url=\"" . htmlspecialchars($this->items[$i]->link) . "\"";
1377
+            $feed .= " url=\"".htmlspecialchars($this->items[$i]->link)."\"";
1378 1378
             $feed .= "/>\n";
1379 1379
         }
1380 1380
         $feed .= "    </body>\n";
@@ -1449,7 +1449,7 @@  discard block
 block discarded – undo
1449 1449
 
1450 1450
         //if no stylePrefix is set, generate it yourself depending on the script name
1451 1451
         if ($this->stylePrefix == '') {
1452
-            $this->stylePrefix = str_replace('.', '_', $this->_generateFilename()) . '_';
1452
+            $this->stylePrefix = str_replace('.', '_', $this->_generateFilename()).'_';
1453 1453
         }
1454 1454
 
1455 1455
         //set an openInNewWindow_token_to be inserted or not
@@ -1460,26 +1460,26 @@  discard block
 block discarded – undo
1460 1460
         // use this array to put the lines in and implode later with "document.write" javascript
1461 1461
         $feedArray = array();
1462 1462
         if ($this->image != null) {
1463
-            $imageStr = "<a href='" . $this->image->link . "'" . $targetInsert . '>' . "<img src='" . $this->image->url
1464
-                        . "' border='0' alt='" . FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100)
1465
-                        . "' align='" . $this->imageAlign . "' ";
1463
+            $imageStr = "<a href='".$this->image->link."'".$targetInsert.'>'."<img src='".$this->image->url
1464
+                        . "' border='0' alt='".FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100)
1465
+                        . "' align='".$this->imageAlign."' ";
1466 1466
             if ($this->image->width) {
1467
-                $imageStr .= " width='" . $this->image->width . "' ";
1467
+                $imageStr .= " width='".$this->image->width."' ";
1468 1468
             }
1469 1469
             if ($this->image->height) {
1470
-                $imageStr .= " height='" . $this->image->height . "' ";
1470
+                $imageStr .= " height='".$this->image->height."' ";
1471 1471
             }
1472 1472
             $imageStr .= '/></a>';
1473 1473
             $feedArray[] = $imageStr;
1474 1474
         }
1475 1475
 
1476 1476
         if ($this->title) {
1477
-            $feedArray[] = "<div class='" . $this->stylePrefix . "title'><a href='" . $this->link . "' " . $targetInsert
1478
-                           . " class='" . $this->stylePrefix . "title'>"
1479
-                           . FeedCreator::iTrunc(htmlspecialchars($this->title), 100) . '</a></div>';
1477
+            $feedArray[] = "<div class='".$this->stylePrefix."title'><a href='".$this->link."' ".$targetInsert
1478
+                           . " class='".$this->stylePrefix."title'>"
1479
+                           . FeedCreator::iTrunc(htmlspecialchars($this->title), 100).'</a></div>';
1480 1480
         }
1481 1481
         if ($this->getDescription()) {
1482
-            $feedArray[] = "<div class='" . $this->stylePrefix . "description'>" . str_replace(']]>', '',
1482
+            $feedArray[] = "<div class='".$this->stylePrefix."description'>".str_replace(']]>', '',
1483 1483
                                                                                                str_replace('<![CDATA[',
1484 1484
                                                                                                            '',
1485 1485
                                                                                                            $this->getDescription()))
@@ -1487,29 +1487,29 @@  discard block
 block discarded – undo
1487 1487
         }
1488 1488
 
1489 1489
         if ($this->header) {
1490
-            $feedArray[] = "<div class='" . $this->stylePrefix . "header'>" . $this->header . '</div>';
1490
+            $feedArray[] = "<div class='".$this->stylePrefix."header'>".$this->header.'</div>';
1491 1491
         }
1492 1492
 
1493
-        for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
1494
-            if ($this->separator && $i > 0) {
1495
-                $feedArray[] = "<div class='" . $this->stylePrefix . "separator'>" . $this->separator . '</div>';
1493
+        for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) {
1494
+            if ($this->separator && $i>0) {
1495
+                $feedArray[] = "<div class='".$this->stylePrefix."separator'>".$this->separator.'</div>';
1496 1496
             }
1497 1497
 
1498 1498
             if ($this->items[$i]->title) {
1499 1499
                 if ($this->items[$i]->link) {
1500
-                    $feedArray[] = "<div class='" . $this->stylePrefix . "item_title'><a href='"
1501
-                                   . $this->items[$i]->link . "' class='" . $this->stylePrefix . "item_title'"
1502
-                                   . $targetInsert . '>'
1500
+                    $feedArray[] = "<div class='".$this->stylePrefix."item_title'><a href='"
1501
+                                   . $this->items[$i]->link."' class='".$this->stylePrefix."item_title'"
1502
+                                   . $targetInsert.'>'
1503 1503
                                    . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100)
1504 1504
                                    . '</a></div>';
1505
-                } else {
1506
-                    $feedArray[] = "<div class='" . $this->stylePrefix . "item_title'>"
1505
+                }else {
1506
+                    $feedArray[] = "<div class='".$this->stylePrefix."item_title'>"
1507 1507
                                    . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100)
1508 1508
                                    . '</div>';
1509 1509
                 }
1510 1510
             }
1511 1511
             if ($this->items[$i]->getDescription()) {
1512
-                $feedArray[] = "<div class='" . $this->stylePrefix . "item_description'>" . str_replace(']]>', '',
1512
+                $feedArray[] = "<div class='".$this->stylePrefix."item_description'>".str_replace(']]>', '',
1513 1513
                                                                                                         str_replace('<![CDATA[',
1514 1514
                                                                                                                     '',
1515 1515
                                                                                                                     $this->items[$i]->getDescription()))
@@ -1517,10 +1517,10 @@  discard block
 block discarded – undo
1517 1517
             }
1518 1518
         }
1519 1519
         if ($this->footer) {
1520
-            $feedArray[] = "<div class='" . $this->stylePrefix . "footer'>" . $this->footer . '</div>';
1520
+            $feedArray[] = "<div class='".$this->stylePrefix."footer'>".$this->footer.'</div>';
1521 1521
         }
1522 1522
 
1523
-        $feed = '' . implode($feedArray, "\r\n");
1523
+        $feed = ''.implode($feedArray, "\r\n");
1524 1524
 
1525 1525
         return $feed;
1526 1526
     }
@@ -1535,7 +1535,7 @@  discard block
 block discarded – undo
1535 1535
     public function _generateFilename() {
1536 1536
         $fileInfo = pathinfo($_SERVER['PHP_SELF']);
1537 1537
 
1538
-        return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.html';
1538
+        return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension'])+1)).'.html';
1539 1539
     }
1540 1540
 }
1541 1541
 
@@ -1559,7 +1559,7 @@  discard block
 block discarded – undo
1559 1559
 
1560 1560
         $jsFeed = '';
1561 1561
         foreach ($feedArray as $value) {
1562
-            $jsFeed .= "document.write('" . trim(addslashes($value)) . "');\n";
1562
+            $jsFeed .= "document.write('".trim(addslashes($value))."');\n";
1563 1563
         }
1564 1564
 
1565 1565
         return $jsFeed;
@@ -1575,7 +1575,7 @@  discard block
 block discarded – undo
1575 1575
     public function _generateFilename() {
1576 1576
         $fileInfo = pathinfo($_SERVER['PHP_SELF']);
1577 1577
 
1578
-        return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.js';
1578
+        return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension'])+1)).'.js';
1579 1579
     }
1580 1580
 }
1581 1581
 
Please login to merge, or discard this patch.
class/magpie.inc.php 3 patches
Doc Comments   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 
303 303
     // smart append - field and namespace aware
304 304
     /**
305
-     * @param $el
305
+     * @param string $el
306 306
      * @param $text
307 307
      */
308 308
     public function append($el, $text) {
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
     }
385 385
 
386 386
     /**
387
-     * @return bool
387
+     * @return string|false
388 388
      */
389 389
     public function is_rss() {
390 390
         if ($this->feed_type == RSS) {
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
     }
396 396
 
397 397
     /**
398
-     * @return bool
398
+     * @return string|false
399 399
      */
400 400
     public function is_atom() {
401 401
         if ($this->feed_type == ATOM) {
@@ -407,10 +407,10 @@  discard block
 block discarded – undo
407 407
 
408 408
     /**
409 409
      * return XML parser, and possibly re-encoded source
410
-     * @param $source
411
-     * @param $out_enc
412
-     * @param $in_enc
413
-     * @param $detect
410
+     * @param string $source
411
+     * @param string $out_enc
412
+     * @param string|null $in_enc
413
+     * @param boolean $detect
414 414
      * @return array
415 415
      */
416 416
     public function create_parser($source, $out_enc, $in_enc, $detect) {
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 
518 518
     /**
519 519
      * @param $enc
520
-     * @return bool|string
520
+     * @return string|false
521 521
      */
522 522
     public function known_encoding($enc) {
523 523
         $enc = strtoupper($enc);
Please login to merge, or discard this patch.
Indentation   +536 added lines, -536 removed lines patch added patch discarded remove patch
@@ -33,457 +33,457 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class MagpieRSS
35 35
 {
36
-    public $parser;
37
-
38
-    public $current_item = array();  // item currently being parsed
39
-    public $items        = array();  // collection of parsed items
40
-    public $channel      = array();  // hash of channel fields
41
-    public $textinput    = array();
42
-    public $image        = array();
43
-    public $feed_type;
44
-    public $feed_version;
45
-    public $encoding     = '';       // output encoding of parsed rss
46
-
47
-    public $_source_encoding = '';     // only set if we have to parse xml prolog
48
-
49
-    public $ERROR   = '';
50
-    public $WARNING = '';
51
-
52
-    // define some constants
53
-
54
-    public $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright');
55
-    public $_KNOWN_ENCODINGS    = array('UTF-8', 'US-ASCII', 'ISO-8859-1');
56
-
57
-    // parser variables, useless if you're not a parser, treat as private
58
-    public $stack             = array(); // parser stack
59
-    public $inchannel         = false;
60
-    public $initem            = false;
61
-    public $incontent         = false; // if in Atom <content mode="xml"> field
62
-    public $intextinput       = false;
63
-    public $inimage           = false;
64
-    public $current_field     = '';
65
-    public $current_namespace = false;
66
-
67
-    /**
68
-     *  Set up XML parser, parse source, and return populated RSS object..
69
-     *
70
-     * @param string $source          string containing the RSS to be parsed
71
-     *
72
-     *  NOTE:  Probably a good idea to leave the encoding options alone unless
73
-     *         you know what you're doing as PHP's character set support is
74
-     *         a little weird.
75
-     *
76
-     *  NOTE:  A lot of this is unnecessary but harmless with PHP5
77
-     *
78
-     *
79
-     * @param string $output_encoding output the parsed RSS in this character
80
-     *                                set defaults to ISO-8859-1 as this is PHP's
81
-     *                                default.
82
-     *
83
-     *                                  NOTE: might be changed to UTF-8 in future
84
-     *                                  versions.
85
-     *
86
-     * @param string $input_encoding  the character set of the incoming RSS source.
87
-     *                                Leave blank and Magpie will try to figure it
88
-     *                                out.
89
-     *
90
-     *
91
-     * @param bool   $detect_encoding if false Magpie won't attempt to detect
92
-     *                                source encoding. (caveat emptor)
93
-     *
94
-     */
95
-    public function __construct(
96
-        $source,
97
-        $output_encoding = 'ISO-8859-1',
98
-        $input_encoding = null,
99
-        $detect_encoding = true
100
-    ) {
101
-        # if PHP xml isn't compiled in, die
102
-        #
103
-        if (!function_exists('xml_parser_create')) {
104
-            $this->error("Failed to load PHP's XML Extension. " . 'http://www.php.net/manual/en/ref.xml.php',
105
-                         E_USER_ERROR);
106
-        }
107
-
108
-        list($parser, $source) = $this->create_parser($source, $output_encoding, $input_encoding, $detect_encoding);
109
-
110
-        if (!is_resource($parser)) {
111
-            $this->error("Failed to create an instance of PHP's XML parser. "
112
-                         . 'http://www.php.net/manual/en/ref.xml.php', E_USER_ERROR);
113
-        }
114
-
115
-        $this->parser = $parser;
116
-
117
-        # pass in parser, and a reference to this object
118
-        # setup handlers
119
-        #
120
-        xml_set_object($this->parser, $this);
121
-        xml_set_element_handler($this->parser, 'feed_start_element', 'feed_end_element');
122
-
123
-        xml_set_character_data_handler($this->parser, 'feed_cdata');
124
-
125
-        $status = @xml_parse($this->parser, $source);
126
-
127
-        if (!$status) {
128
-            $errorcode = xml_get_error_code($this->parser);
129
-            if ($errorcode != XML_ERROR_NONE) {
130
-                $xml_error  = xml_error_string($errorcode);
131
-                $error_line = xml_get_current_line_number($this->parser);
132
-                $error_col  = xml_get_current_column_number($this->parser);
133
-                $errormsg   = "$xml_error at line $error_line, column $error_col";
134
-
135
-                $this->error($errormsg);
136
-            }
137
-        }
138
-
139
-        xml_parser_free($this->parser);
140
-
141
-        $this->normalize();
142
-    }
143
-
144
-    /**
145
-     * @param $p
146
-     * @param $element
147
-     * @param $attrs
148
-     */
149
-    public function feed_start_element($p, $element, &$attrs) {
150
-        $el    = $element = strtolower($element);
151
-        $attrs = array_change_key_case($attrs, CASE_LOWER);
152
-
153
-        // check for a namespace, and split if found
154
-        $ns = false;
155
-        if (strpos($element, ':')) {
156
-            list($ns, $el) = explode(':', $element, 2);
157
-        }
158
-        if ($ns && $ns !== 'rdf') {
159
-            $this->current_namespace = $ns;
160
-        }
161
-
162
-        # if feed type isn't set, then this is first element of feed
163
-        # identify feed from root element
164
-        #
165
-        if (!isset($this->feed_type)) {
166
-            if ($el === 'rdf') {
167
-                $this->feed_type    = RSS;
168
-                $this->feed_version = '1.0';
169
-            } elseif ($el === 'rss') {
170
-                $this->feed_type    = RSS;
171
-                $this->feed_version = $attrs['version'];
172
-            } elseif ($el === 'feed') {
173
-                $this->feed_type    = ATOM;
174
-                $this->feed_version = $attrs['version'];
175
-                $this->inchannel    = true;
176
-            }
177
-
178
-            return;
179
-        }
180
-
181
-        if ($el === 'channel') {
182
-            $this->inchannel = true;
183
-        } elseif ($el === 'item' || $el === 'entry') {
184
-            $this->initem = true;
185
-            if (isset($attrs['rdf:about'])) {
186
-                $this->current_item['about'] = $attrs['rdf:about'];
187
-            }
188
-        }
189
-
190
-        // if we're in the default namespace of an RSS feed,
191
-        //  record textinput or image fields
192
-        elseif ($this->feed_type == RSS && $this->current_namespace === '' && $el === 'textinput') {
193
-            $this->intextinput = true;
194
-        } elseif ($this->feed_type == RSS && $this->current_namespace === '' && $el === 'image') {
195
-            $this->inimage = true;
196
-        } # handle atom content constructs
197
-        elseif ($this->feed_type == ATOM && in_array($el, $this->_CONTENT_CONSTRUCTS)) {
198
-            // avoid clashing w/ RSS mod_content
199
-            if ($el === 'content') {
200
-                $el = 'atom_content';
201
-            }
202
-
203
-            $this->incontent = $el;
204
-        } // if inside an Atom content construct (e.g. content or summary) field treat tags as text
205
-        elseif ($this->feed_type == ATOM && $this->incontent) {
206
-            // if tags are inlined, then flatten
207
-            $attrs_str = implode(' ', array_map('map_attrs', array_keys($attrs), array_values($attrs)));
208
-
209
-            $this->append_content("<$element $attrs_str>");
210
-
211
-            array_unshift($this->stack, $el);
212
-        }
213
-
214
-        // Atom support many links per containging element.
215
-        // Magpie treats link elements of type rel='alternate'
216
-        // as being equivalent to RSS's simple link element.
217
-        //
218
-        elseif ($this->feed_type == ATOM && $el === 'link') {
219
-            if (isset($attrs['rel']) && $attrs['rel'] === 'alternate') {
220
-                $link_el = 'link';
221
-            } else {
222
-                $link_el = 'link_' . $attrs['rel'];
223
-            }
224
-
225
-            $this->append($link_el, $attrs['href']);
226
-        } // set stack[0] to current element
227
-        else {
228
-            array_unshift($this->stack, $el);
229
-        }
230
-    }
231
-
232
-    /**
233
-     * @param $p
234
-     * @param $text
235
-     */
236
-    public function feed_cdata($p, $text) {
237
-        if ($this->feed_type == ATOM && $this->incontent) {
238
-            $this->append_content($text);
239
-        } else {
240
-            $current_el = implode('_', array_reverse($this->stack));
241
-            $this->append($current_el, $text);
242
-        }
243
-    }
244
-
245
-    /**
246
-     * @param $p
247
-     * @param $el
248
-     */
249
-    public function feed_end_element($p, $el) {
250
-        $el = strtolower($el);
251
-
252
-        if ($el === 'item' || $el === 'entry') {
253
-            $this->items[]      = $this->current_item;
254
-            $this->current_item = array();
255
-            $this->initem       = false;
256
-        } elseif ($this->feed_type == RSS && $this->current_namespace === '' && $el === 'textinput') {
257
-            $this->intextinput = false;
258
-        } elseif ($this->feed_type == RSS && $this->current_namespace === '' && $el === 'image') {
259
-            $this->inimage = false;
260
-        } elseif ($this->feed_type == ATOM && in_array($el, $this->_CONTENT_CONSTRUCTS)) {
261
-            $this->incontent = false;
262
-        } elseif ($el === 'channel' || $el === 'feed') {
263
-            $this->inchannel = false;
264
-        } elseif ($this->feed_type == ATOM && $this->incontent) {
265
-            // balance tags properly
266
-            // note:  i don't think this is actually neccessary
267
-            if ($this->stack[0] == $el) {
268
-                $this->append_content("</$el>");
269
-            } else {
270
-                $this->append_content("<$el />");
271
-            }
272
-
273
-            array_shift($this->stack);
274
-        } else {
275
-            array_shift($this->stack);
276
-        }
277
-
278
-        $this->current_namespace = false;
279
-    }
280
-
281
-    /**
282
-     * @param        $str1
283
-     * @param string $str2
284
-     */
285
-    public function concat(&$str1, $str2 = '') {
286
-        if (!isset($str1)) {
287
-            $str1 = '';
288
-        }
289
-        $str1 .= $str2;
290
-    }
291
-
292
-    /**
293
-     * @param $text
294
-     */
295
-    public function append_content($text) {
296
-        if ($this->initem) {
297
-            $this->concat($this->current_item[$this->incontent], $text);
298
-        } elseif ($this->inchannel) {
299
-            $this->concat($this->channel[$this->incontent], $text);
300
-        }
301
-    }
302
-
303
-    // smart append - field and namespace aware
304
-    /**
305
-     * @param $el
306
-     * @param $text
307
-     */
308
-    public function append($el, $text) {
309
-        if (!$el) {
310
-            return;
311
-        }
312
-        if ($this->current_namespace) {
313
-            if ($this->initem) {
314
-                $this->concat($this->current_item[$this->current_namespace][$el], $text);
315
-            } elseif ($this->inchannel) {
316
-                $this->concat($this->channel[$this->current_namespace][$el], $text);
317
-            } elseif ($this->intextinput) {
318
-                $this->concat($this->textinput[$this->current_namespace][$el], $text);
319
-            } elseif ($this->inimage) {
320
-                $this->concat($this->image[$this->current_namespace][$el], $text);
321
-            }
322
-        } else {
323
-            if ($this->initem) {
324
-                $this->concat($this->current_item[$el], $text);
325
-            } elseif ($this->intextinput) {
326
-                $this->concat($this->textinput[$el], $text);
327
-            } elseif ($this->inimage) {
328
-                $this->concat($this->image[$el], $text);
329
-            } elseif ($this->inchannel) {
330
-                $this->concat($this->channel[$el], $text);
331
-            }
332
-        }
333
-    }
334
-
335
-    public function normalize() {
336
-        // if atom populate rss fields
337
-        if ($this->is_atom()) {
338
-            $this->channel['description'] = $this->channel['tagline'];
339
-            for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
340
-                $item = $this->items[$i];
341
-                if (isset($item['summary'])) {
342
-                    $item['description'] = $item['summary'];
343
-                }
344
-                if (isset($item['atom_content'])) {
345
-                    $item['content']['encoded'] = $item['atom_content'];
346
-                }
347
-
348
-                $atom_date = isset($item['issued']) ? $item['issued'] : @$item['modified'];
349
-                if ($atom_date) {
350
-                    $epoch = @parse_w3cdtf($atom_date);
351
-                    if ($epoch && $epoch > 0) {
352
-                        $item['date_timestamp'] = $epoch;
353
-                    }
354
-                }
355
-
356
-                $this->items[$i] = $item;
357
-            }
358
-        } elseif ($this->is_rss()) {
359
-            $this->channel['tagline'] = $this->channel['description'];
360
-            for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
361
-                $item = $this->items[$i];
362
-                if (isset($item['description'])) {
363
-                    $item['summary'] = $item['description'];
364
-                }
365
-                if (isset($item['content']['encoded'])) {
366
-                    $item['atom_content'] = $item['content']['encoded'];
367
-                }
368
-
369
-                if ($this->is_rss() === '1.0' && isset($item['dc']['date'])) {
370
-                    $epoch = @parse_w3cdtf($item['dc']['date']);
371
-                    if ($epoch && $epoch > 0) {
372
-                        $item['date_timestamp'] = $epoch;
373
-                    }
374
-                } elseif (isset($item['pubdate'])) {
375
-                    $epoch = @strtotime($item['pubdate']);
376
-                    if ($epoch > 0) {
377
-                        $item['date_timestamp'] = $epoch;
378
-                    }
379
-                }
380
-
381
-                $this->items[$i] = $item;
382
-            }
383
-        }
384
-    }
385
-
386
-    /**
387
-     * @return bool
388
-     */
389
-    public function is_rss() {
390
-        if ($this->feed_type == RSS) {
391
-            return $this->feed_version;
392
-        } else {
393
-            return false;
394
-        }
395
-    }
396
-
397
-    /**
398
-     * @return bool
399
-     */
400
-    public function is_atom() {
401
-        if ($this->feed_type == ATOM) {
402
-            return $this->feed_version;
403
-        } else {
404
-            return false;
405
-        }
406
-    }
407
-
408
-    /**
409
-     * return XML parser, and possibly re-encoded source
410
-     * @param $source
411
-     * @param $out_enc
412
-     * @param $in_enc
413
-     * @param $detect
414
-     * @return array
415
-     */
416
-    public function create_parser($source, $out_enc, $in_enc, $detect) {
417
-        if (substr(phpversion(), 0, 1) == 5) {
418
-            $parser = $this->php5_create_parser($in_enc, $detect);
419
-        } else {
420
-            list($parser, $source) = $this->php4_create_parser($source, $in_enc, $detect);
421
-        }
422
-        if ($out_enc) {
423
-            $this->encoding = $out_enc;
424
-            xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $out_enc);
425
-        }
426
-
427
-        return array($parser, $source);
428
-    }
429
-
430
-    /**
431
-     * Instantiate an XML parser under PHP5
432
-     *
433
-     * PHP5 will do a fine job of detecting input encoding
434
-     * if passed an empty string as the encoding.
435
-     *
436
-     * All hail libxml2!
437
-     * @param $in_enc
438
-     * @param $detect
439
-     * @return resource
440
-     */
441
-    public function php5_create_parser($in_enc, $detect) {
442
-        // by default php5 does a fine job of detecting input encodings
443
-        if (!$detect && $in_enc) {
444
-            return xml_parser_create($in_enc);
445
-        } else {
446
-            return xml_parser_create('');
447
-        }
448
-    }
449
-
450
-    /**
451
-     * Instaniate an XML parser under PHP4
452
-     *
453
-     * Unfortunately PHP4's support for character encodings
454
-     * and especially XML and character encodings sucks.  As
455
-     * long as the documents you parse only contain characters
456
-     * from the ISO-8859-1 character set (a superset of ASCII,
457
-     * and a subset of UTF-8) you're fine.  However once you
458
-     * step out of that comfy little world things get mad, bad,
459
-     * and dangerous to know.
460
-     *
461
-     * The following code is based on SJM's work with FoF
462
-     * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
463
-     * @param $source
464
-     * @param $in_enc
465
-     * @param $detect
466
-     * @return array
467
-     */
468
-    public function php4_create_parser($source, $in_enc, $detect) {
469
-        if (!$detect) {
470
-            return array(xml_parser_create($in_enc), $source);
471
-        }
472
-
473
-        if (!$in_enc) {
474
-            if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) {
475
-                $in_enc                = strtoupper($m[1]);
476
-                $this->source_encoding = $in_enc;
477
-            } else {
478
-                $in_enc = 'UTF-8';
479
-            }
480
-        }
481
-
482
-        if ($this->known_encoding($in_enc)) {
483
-            return array(xml_parser_create($in_enc), $source);
484
-        }
485
-
486
-        /*
36
+	public $parser;
37
+
38
+	public $current_item = array();  // item currently being parsed
39
+	public $items        = array();  // collection of parsed items
40
+	public $channel      = array();  // hash of channel fields
41
+	public $textinput    = array();
42
+	public $image        = array();
43
+	public $feed_type;
44
+	public $feed_version;
45
+	public $encoding     = '';       // output encoding of parsed rss
46
+
47
+	public $_source_encoding = '';     // only set if we have to parse xml prolog
48
+
49
+	public $ERROR   = '';
50
+	public $WARNING = '';
51
+
52
+	// define some constants
53
+
54
+	public $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright');
55
+	public $_KNOWN_ENCODINGS    = array('UTF-8', 'US-ASCII', 'ISO-8859-1');
56
+
57
+	// parser variables, useless if you're not a parser, treat as private
58
+	public $stack             = array(); // parser stack
59
+	public $inchannel         = false;
60
+	public $initem            = false;
61
+	public $incontent         = false; // if in Atom <content mode="xml"> field
62
+	public $intextinput       = false;
63
+	public $inimage           = false;
64
+	public $current_field     = '';
65
+	public $current_namespace = false;
66
+
67
+	/**
68
+	 *  Set up XML parser, parse source, and return populated RSS object..
69
+	 *
70
+	 * @param string $source          string containing the RSS to be parsed
71
+	 *
72
+	 *  NOTE:  Probably a good idea to leave the encoding options alone unless
73
+	 *         you know what you're doing as PHP's character set support is
74
+	 *         a little weird.
75
+	 *
76
+	 *  NOTE:  A lot of this is unnecessary but harmless with PHP5
77
+	 *
78
+	 *
79
+	 * @param string $output_encoding output the parsed RSS in this character
80
+	 *                                set defaults to ISO-8859-1 as this is PHP's
81
+	 *                                default.
82
+	 *
83
+	 *                                  NOTE: might be changed to UTF-8 in future
84
+	 *                                  versions.
85
+	 *
86
+	 * @param string $input_encoding  the character set of the incoming RSS source.
87
+	 *                                Leave blank and Magpie will try to figure it
88
+	 *                                out.
89
+	 *
90
+	 *
91
+	 * @param bool   $detect_encoding if false Magpie won't attempt to detect
92
+	 *                                source encoding. (caveat emptor)
93
+	 *
94
+	 */
95
+	public function __construct(
96
+		$source,
97
+		$output_encoding = 'ISO-8859-1',
98
+		$input_encoding = null,
99
+		$detect_encoding = true
100
+	) {
101
+		# if PHP xml isn't compiled in, die
102
+		#
103
+		if (!function_exists('xml_parser_create')) {
104
+			$this->error("Failed to load PHP's XML Extension. " . 'http://www.php.net/manual/en/ref.xml.php',
105
+						 E_USER_ERROR);
106
+		}
107
+
108
+		list($parser, $source) = $this->create_parser($source, $output_encoding, $input_encoding, $detect_encoding);
109
+
110
+		if (!is_resource($parser)) {
111
+			$this->error("Failed to create an instance of PHP's XML parser. "
112
+						 . 'http://www.php.net/manual/en/ref.xml.php', E_USER_ERROR);
113
+		}
114
+
115
+		$this->parser = $parser;
116
+
117
+		# pass in parser, and a reference to this object
118
+		# setup handlers
119
+		#
120
+		xml_set_object($this->parser, $this);
121
+		xml_set_element_handler($this->parser, 'feed_start_element', 'feed_end_element');
122
+
123
+		xml_set_character_data_handler($this->parser, 'feed_cdata');
124
+
125
+		$status = @xml_parse($this->parser, $source);
126
+
127
+		if (!$status) {
128
+			$errorcode = xml_get_error_code($this->parser);
129
+			if ($errorcode != XML_ERROR_NONE) {
130
+				$xml_error  = xml_error_string($errorcode);
131
+				$error_line = xml_get_current_line_number($this->parser);
132
+				$error_col  = xml_get_current_column_number($this->parser);
133
+				$errormsg   = "$xml_error at line $error_line, column $error_col";
134
+
135
+				$this->error($errormsg);
136
+			}
137
+		}
138
+
139
+		xml_parser_free($this->parser);
140
+
141
+		$this->normalize();
142
+	}
143
+
144
+	/**
145
+	 * @param $p
146
+	 * @param $element
147
+	 * @param $attrs
148
+	 */
149
+	public function feed_start_element($p, $element, &$attrs) {
150
+		$el    = $element = strtolower($element);
151
+		$attrs = array_change_key_case($attrs, CASE_LOWER);
152
+
153
+		// check for a namespace, and split if found
154
+		$ns = false;
155
+		if (strpos($element, ':')) {
156
+			list($ns, $el) = explode(':', $element, 2);
157
+		}
158
+		if ($ns && $ns !== 'rdf') {
159
+			$this->current_namespace = $ns;
160
+		}
161
+
162
+		# if feed type isn't set, then this is first element of feed
163
+		# identify feed from root element
164
+		#
165
+		if (!isset($this->feed_type)) {
166
+			if ($el === 'rdf') {
167
+				$this->feed_type    = RSS;
168
+				$this->feed_version = '1.0';
169
+			} elseif ($el === 'rss') {
170
+				$this->feed_type    = RSS;
171
+				$this->feed_version = $attrs['version'];
172
+			} elseif ($el === 'feed') {
173
+				$this->feed_type    = ATOM;
174
+				$this->feed_version = $attrs['version'];
175
+				$this->inchannel    = true;
176
+			}
177
+
178
+			return;
179
+		}
180
+
181
+		if ($el === 'channel') {
182
+			$this->inchannel = true;
183
+		} elseif ($el === 'item' || $el === 'entry') {
184
+			$this->initem = true;
185
+			if (isset($attrs['rdf:about'])) {
186
+				$this->current_item['about'] = $attrs['rdf:about'];
187
+			}
188
+		}
189
+
190
+		// if we're in the default namespace of an RSS feed,
191
+		//  record textinput or image fields
192
+		elseif ($this->feed_type == RSS && $this->current_namespace === '' && $el === 'textinput') {
193
+			$this->intextinput = true;
194
+		} elseif ($this->feed_type == RSS && $this->current_namespace === '' && $el === 'image') {
195
+			$this->inimage = true;
196
+		} # handle atom content constructs
197
+		elseif ($this->feed_type == ATOM && in_array($el, $this->_CONTENT_CONSTRUCTS)) {
198
+			// avoid clashing w/ RSS mod_content
199
+			if ($el === 'content') {
200
+				$el = 'atom_content';
201
+			}
202
+
203
+			$this->incontent = $el;
204
+		} // if inside an Atom content construct (e.g. content or summary) field treat tags as text
205
+		elseif ($this->feed_type == ATOM && $this->incontent) {
206
+			// if tags are inlined, then flatten
207
+			$attrs_str = implode(' ', array_map('map_attrs', array_keys($attrs), array_values($attrs)));
208
+
209
+			$this->append_content("<$element $attrs_str>");
210
+
211
+			array_unshift($this->stack, $el);
212
+		}
213
+
214
+		// Atom support many links per containging element.
215
+		// Magpie treats link elements of type rel='alternate'
216
+		// as being equivalent to RSS's simple link element.
217
+		//
218
+		elseif ($this->feed_type == ATOM && $el === 'link') {
219
+			if (isset($attrs['rel']) && $attrs['rel'] === 'alternate') {
220
+				$link_el = 'link';
221
+			} else {
222
+				$link_el = 'link_' . $attrs['rel'];
223
+			}
224
+
225
+			$this->append($link_el, $attrs['href']);
226
+		} // set stack[0] to current element
227
+		else {
228
+			array_unshift($this->stack, $el);
229
+		}
230
+	}
231
+
232
+	/**
233
+	 * @param $p
234
+	 * @param $text
235
+	 */
236
+	public function feed_cdata($p, $text) {
237
+		if ($this->feed_type == ATOM && $this->incontent) {
238
+			$this->append_content($text);
239
+		} else {
240
+			$current_el = implode('_', array_reverse($this->stack));
241
+			$this->append($current_el, $text);
242
+		}
243
+	}
244
+
245
+	/**
246
+	 * @param $p
247
+	 * @param $el
248
+	 */
249
+	public function feed_end_element($p, $el) {
250
+		$el = strtolower($el);
251
+
252
+		if ($el === 'item' || $el === 'entry') {
253
+			$this->items[]      = $this->current_item;
254
+			$this->current_item = array();
255
+			$this->initem       = false;
256
+		} elseif ($this->feed_type == RSS && $this->current_namespace === '' && $el === 'textinput') {
257
+			$this->intextinput = false;
258
+		} elseif ($this->feed_type == RSS && $this->current_namespace === '' && $el === 'image') {
259
+			$this->inimage = false;
260
+		} elseif ($this->feed_type == ATOM && in_array($el, $this->_CONTENT_CONSTRUCTS)) {
261
+			$this->incontent = false;
262
+		} elseif ($el === 'channel' || $el === 'feed') {
263
+			$this->inchannel = false;
264
+		} elseif ($this->feed_type == ATOM && $this->incontent) {
265
+			// balance tags properly
266
+			// note:  i don't think this is actually neccessary
267
+			if ($this->stack[0] == $el) {
268
+				$this->append_content("</$el>");
269
+			} else {
270
+				$this->append_content("<$el />");
271
+			}
272
+
273
+			array_shift($this->stack);
274
+		} else {
275
+			array_shift($this->stack);
276
+		}
277
+
278
+		$this->current_namespace = false;
279
+	}
280
+
281
+	/**
282
+	 * @param        $str1
283
+	 * @param string $str2
284
+	 */
285
+	public function concat(&$str1, $str2 = '') {
286
+		if (!isset($str1)) {
287
+			$str1 = '';
288
+		}
289
+		$str1 .= $str2;
290
+	}
291
+
292
+	/**
293
+	 * @param $text
294
+	 */
295
+	public function append_content($text) {
296
+		if ($this->initem) {
297
+			$this->concat($this->current_item[$this->incontent], $text);
298
+		} elseif ($this->inchannel) {
299
+			$this->concat($this->channel[$this->incontent], $text);
300
+		}
301
+	}
302
+
303
+	// smart append - field and namespace aware
304
+	/**
305
+	 * @param $el
306
+	 * @param $text
307
+	 */
308
+	public function append($el, $text) {
309
+		if (!$el) {
310
+			return;
311
+		}
312
+		if ($this->current_namespace) {
313
+			if ($this->initem) {
314
+				$this->concat($this->current_item[$this->current_namespace][$el], $text);
315
+			} elseif ($this->inchannel) {
316
+				$this->concat($this->channel[$this->current_namespace][$el], $text);
317
+			} elseif ($this->intextinput) {
318
+				$this->concat($this->textinput[$this->current_namespace][$el], $text);
319
+			} elseif ($this->inimage) {
320
+				$this->concat($this->image[$this->current_namespace][$el], $text);
321
+			}
322
+		} else {
323
+			if ($this->initem) {
324
+				$this->concat($this->current_item[$el], $text);
325
+			} elseif ($this->intextinput) {
326
+				$this->concat($this->textinput[$el], $text);
327
+			} elseif ($this->inimage) {
328
+				$this->concat($this->image[$el], $text);
329
+			} elseif ($this->inchannel) {
330
+				$this->concat($this->channel[$el], $text);
331
+			}
332
+		}
333
+	}
334
+
335
+	public function normalize() {
336
+		// if atom populate rss fields
337
+		if ($this->is_atom()) {
338
+			$this->channel['description'] = $this->channel['tagline'];
339
+			for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
340
+				$item = $this->items[$i];
341
+				if (isset($item['summary'])) {
342
+					$item['description'] = $item['summary'];
343
+				}
344
+				if (isset($item['atom_content'])) {
345
+					$item['content']['encoded'] = $item['atom_content'];
346
+				}
347
+
348
+				$atom_date = isset($item['issued']) ? $item['issued'] : @$item['modified'];
349
+				if ($atom_date) {
350
+					$epoch = @parse_w3cdtf($atom_date);
351
+					if ($epoch && $epoch > 0) {
352
+						$item['date_timestamp'] = $epoch;
353
+					}
354
+				}
355
+
356
+				$this->items[$i] = $item;
357
+			}
358
+		} elseif ($this->is_rss()) {
359
+			$this->channel['tagline'] = $this->channel['description'];
360
+			for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
361
+				$item = $this->items[$i];
362
+				if (isset($item['description'])) {
363
+					$item['summary'] = $item['description'];
364
+				}
365
+				if (isset($item['content']['encoded'])) {
366
+					$item['atom_content'] = $item['content']['encoded'];
367
+				}
368
+
369
+				if ($this->is_rss() === '1.0' && isset($item['dc']['date'])) {
370
+					$epoch = @parse_w3cdtf($item['dc']['date']);
371
+					if ($epoch && $epoch > 0) {
372
+						$item['date_timestamp'] = $epoch;
373
+					}
374
+				} elseif (isset($item['pubdate'])) {
375
+					$epoch = @strtotime($item['pubdate']);
376
+					if ($epoch > 0) {
377
+						$item['date_timestamp'] = $epoch;
378
+					}
379
+				}
380
+
381
+				$this->items[$i] = $item;
382
+			}
383
+		}
384
+	}
385
+
386
+	/**
387
+	 * @return bool
388
+	 */
389
+	public function is_rss() {
390
+		if ($this->feed_type == RSS) {
391
+			return $this->feed_version;
392
+		} else {
393
+			return false;
394
+		}
395
+	}
396
+
397
+	/**
398
+	 * @return bool
399
+	 */
400
+	public function is_atom() {
401
+		if ($this->feed_type == ATOM) {
402
+			return $this->feed_version;
403
+		} else {
404
+			return false;
405
+		}
406
+	}
407
+
408
+	/**
409
+	 * return XML parser, and possibly re-encoded source
410
+	 * @param $source
411
+	 * @param $out_enc
412
+	 * @param $in_enc
413
+	 * @param $detect
414
+	 * @return array
415
+	 */
416
+	public function create_parser($source, $out_enc, $in_enc, $detect) {
417
+		if (substr(phpversion(), 0, 1) == 5) {
418
+			$parser = $this->php5_create_parser($in_enc, $detect);
419
+		} else {
420
+			list($parser, $source) = $this->php4_create_parser($source, $in_enc, $detect);
421
+		}
422
+		if ($out_enc) {
423
+			$this->encoding = $out_enc;
424
+			xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $out_enc);
425
+		}
426
+
427
+		return array($parser, $source);
428
+	}
429
+
430
+	/**
431
+	 * Instantiate an XML parser under PHP5
432
+	 *
433
+	 * PHP5 will do a fine job of detecting input encoding
434
+	 * if passed an empty string as the encoding.
435
+	 *
436
+	 * All hail libxml2!
437
+	 * @param $in_enc
438
+	 * @param $detect
439
+	 * @return resource
440
+	 */
441
+	public function php5_create_parser($in_enc, $detect) {
442
+		// by default php5 does a fine job of detecting input encodings
443
+		if (!$detect && $in_enc) {
444
+			return xml_parser_create($in_enc);
445
+		} else {
446
+			return xml_parser_create('');
447
+		}
448
+	}
449
+
450
+	/**
451
+	 * Instaniate an XML parser under PHP4
452
+	 *
453
+	 * Unfortunately PHP4's support for character encodings
454
+	 * and especially XML and character encodings sucks.  As
455
+	 * long as the documents you parse only contain characters
456
+	 * from the ISO-8859-1 character set (a superset of ASCII,
457
+	 * and a subset of UTF-8) you're fine.  However once you
458
+	 * step out of that comfy little world things get mad, bad,
459
+	 * and dangerous to know.
460
+	 *
461
+	 * The following code is based on SJM's work with FoF
462
+	 * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
463
+	 * @param $source
464
+	 * @param $in_enc
465
+	 * @param $detect
466
+	 * @return array
467
+	 */
468
+	public function php4_create_parser($source, $in_enc, $detect) {
469
+		if (!$detect) {
470
+			return array(xml_parser_create($in_enc), $source);
471
+		}
472
+
473
+		if (!$in_enc) {
474
+			if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) {
475
+				$in_enc                = strtoupper($m[1]);
476
+				$this->source_encoding = $in_enc;
477
+			} else {
478
+				$in_enc = 'UTF-8';
479
+			}
480
+		}
481
+
482
+		if ($this->known_encoding($in_enc)) {
483
+			return array(xml_parser_create($in_enc), $source);
484
+		}
485
+
486
+		/*
487 487
         // the dectected encoding is not one of the simple encodings PHP knows
488 488
 
489 489
         // attempt to use the iconv extension to
@@ -512,44 +512,44 @@  discard block
 block discarded – undo
512 512
                      E_USER_NOTICE);
513 513
         */
514 514
 
515
-        return array(xml_parser_create(), $source);
516
-    }
517
-
518
-    /**
519
-     * @param $enc
520
-     * @return bool|string
521
-     */
522
-    public function known_encoding($enc) {
523
-        $enc = strtoupper($enc);
524
-        if (in_array($enc, $this->_KNOWN_ENCODINGS)) {
525
-            return $enc;
526
-        } else {
527
-            return false;
528
-        }
529
-    }
530
-
531
-    /**
532
-     * @param     $errormsg
533
-     * @param int $lvl
534
-     */
535
-    public function error($errormsg, $lvl = E_USER_WARNING) {
536
-        // append PHP's error message if track_errors enabled
537
-        if (!empty($php_errormsg)) {
538
-            $errormsg .= " ($php_errormsg)";
539
-        }
540
-        if (MAGPIE_DEBUG) {
541
-            trigger_error($errormsg, $lvl);
542
-        } else {
543
-            error_log($errormsg, 0);
544
-        }
545
-
546
-        $notices = E_USER_NOTICE | E_NOTICE;
547
-        if ($lvl & $notices) {
548
-            $this->WARNING = $errormsg;
549
-        } else {
550
-            $this->ERROR = $errormsg;
551
-        }
552
-    }
515
+		return array(xml_parser_create(), $source);
516
+	}
517
+
518
+	/**
519
+	 * @param $enc
520
+	 * @return bool|string
521
+	 */
522
+	public function known_encoding($enc) {
523
+		$enc = strtoupper($enc);
524
+		if (in_array($enc, $this->_KNOWN_ENCODINGS)) {
525
+			return $enc;
526
+		} else {
527
+			return false;
528
+		}
529
+	}
530
+
531
+	/**
532
+	 * @param     $errormsg
533
+	 * @param int $lvl
534
+	 */
535
+	public function error($errormsg, $lvl = E_USER_WARNING) {
536
+		// append PHP's error message if track_errors enabled
537
+		if (!empty($php_errormsg)) {
538
+			$errormsg .= " ($php_errormsg)";
539
+		}
540
+		if (MAGPIE_DEBUG) {
541
+			trigger_error($errormsg, $lvl);
542
+		} else {
543
+			error_log($errormsg, 0);
544
+		}
545
+
546
+		$notices = E_USER_NOTICE | E_NOTICE;
547
+		if ($lvl & $notices) {
548
+			$this->WARNING = $errormsg;
549
+		} else {
550
+			$this->ERROR = $errormsg;
551
+		}
552
+	}
553 553
 } // end class RSS
554 554
 
555 555
 /**
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
  * @return string
559 559
  */
560 560
 function map_attrs($k, $v) {
561
-    return "$k=\"$v\"";
561
+	return "$k=\"$v\"";
562 562
 }
563 563
 
564 564
 /**
@@ -566,50 +566,50 @@  discard block
 block discarded – undo
566 566
  * @return int
567 567
  */
568 568
 function parse_w3cdtf($date_str) {
569
-    # regex to match wc3dtf
570
-    $pat = "/(\d{4})-(\d{2})-(\d{2})[T]?(\d{2})?[:]?(\d{2})?(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/";
571
-
572
-    if (preg_match($pat, $date_str, $match)) {
573
-        list($year, $month, $day, $hours, $minutes, $seconds) = array(
574
-            $match[1],
575
-            $match[2],
576
-            $match[3],
577
-            $match[4],
578
-            $match[5],
579
-            $match[6]
580
-        );
581
-
582
-        # calc epoch for current date assuming GMT
583
-        $epoch = gmmktime((int)$hours, (int)$minutes, (int)$seconds, (int)$month, (int)$day, (int)$year);
584
-
585
-        $offset = 0;
586
-        if ($match[10] === 'Z') {
587
-            # zulu time, aka GMT
588
-        } else {
589
-            list($tz_mod, $tz_hour, $tz_min) = array($match[8], $match[9], $match[10]);
590
-
591
-            # zero out the variables
592
-            if (!$tz_hour) {
593
-                $tz_hour = 0;
594
-            }
595
-            if (!$tz_min) {
596
-                $tz_min = 0;
597
-            }
598
-
599
-            $offset_secs = (($tz_hour * 60) + $tz_min) * 60;
600
-
601
-            # is timezone ahead of GMT?  then subtract offset
602
-            #
603
-            if ($tz_mod == '+') {
604
-                $offset_secs = $offset_secs * -1;
605
-            }
606
-
607
-            $offset = $offset_secs;
608
-        }
609
-        $epoch = $epoch + $offset;
610
-
611
-        return $epoch;
612
-    } else {
613
-        return -1;
614
-    }
569
+	# regex to match wc3dtf
570
+	$pat = "/(\d{4})-(\d{2})-(\d{2})[T]?(\d{2})?[:]?(\d{2})?(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/";
571
+
572
+	if (preg_match($pat, $date_str, $match)) {
573
+		list($year, $month, $day, $hours, $minutes, $seconds) = array(
574
+			$match[1],
575
+			$match[2],
576
+			$match[3],
577
+			$match[4],
578
+			$match[5],
579
+			$match[6]
580
+		);
581
+
582
+		# calc epoch for current date assuming GMT
583
+		$epoch = gmmktime((int)$hours, (int)$minutes, (int)$seconds, (int)$month, (int)$day, (int)$year);
584
+
585
+		$offset = 0;
586
+		if ($match[10] === 'Z') {
587
+			# zulu time, aka GMT
588
+		} else {
589
+			list($tz_mod, $tz_hour, $tz_min) = array($match[8], $match[9], $match[10]);
590
+
591
+			# zero out the variables
592
+			if (!$tz_hour) {
593
+				$tz_hour = 0;
594
+			}
595
+			if (!$tz_min) {
596
+				$tz_min = 0;
597
+			}
598
+
599
+			$offset_secs = (($tz_hour * 60) + $tz_min) * 60;
600
+
601
+			# is timezone ahead of GMT?  then subtract offset
602
+			#
603
+			if ($tz_mod == '+') {
604
+				$offset_secs = $offset_secs * -1;
605
+			}
606
+
607
+			$offset = $offset_secs;
608
+		}
609
+		$epoch = $epoch + $offset;
610
+
611
+		return $epoch;
612
+	} else {
613
+		return -1;
614
+	}
615 615
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -35,16 +35,16 @@  discard block
 block discarded – undo
35 35
 {
36 36
     public $parser;
37 37
 
38
-    public $current_item = array();  // item currently being parsed
39
-    public $items        = array();  // collection of parsed items
40
-    public $channel      = array();  // hash of channel fields
38
+    public $current_item = array(); // item currently being parsed
39
+    public $items        = array(); // collection of parsed items
40
+    public $channel      = array(); // hash of channel fields
41 41
     public $textinput    = array();
42 42
     public $image        = array();
43 43
     public $feed_type;
44 44
     public $feed_version;
45
-    public $encoding     = '';       // output encoding of parsed rss
45
+    public $encoding     = ''; // output encoding of parsed rss
46 46
 
47
-    public $_source_encoding = '';     // only set if we have to parse xml prolog
47
+    public $_source_encoding = ''; // only set if we have to parse xml prolog
48 48
 
49 49
     public $ERROR   = '';
50 50
     public $WARNING = '';
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         # if PHP xml isn't compiled in, die
102 102
         #
103 103
         if (!function_exists('xml_parser_create')) {
104
-            $this->error("Failed to load PHP's XML Extension. " . 'http://www.php.net/manual/en/ref.xml.php',
104
+            $this->error("Failed to load PHP's XML Extension. ".'http://www.php.net/manual/en/ref.xml.php',
105 105
                          E_USER_ERROR);
106 106
         }
107 107
 
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
         elseif ($this->feed_type == ATOM && $el === 'link') {
219 219
             if (isset($attrs['rel']) && $attrs['rel'] === 'alternate') {
220 220
                 $link_el = 'link';
221
-            } else {
222
-                $link_el = 'link_' . $attrs['rel'];
221
+            }else {
222
+                $link_el = 'link_'.$attrs['rel'];
223 223
             }
224 224
 
225 225
             $this->append($link_el, $attrs['href']);
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
     public function feed_cdata($p, $text) {
237 237
         if ($this->feed_type == ATOM && $this->incontent) {
238 238
             $this->append_content($text);
239
-        } else {
239
+        }else {
240 240
             $current_el = implode('_', array_reverse($this->stack));
241 241
             $this->append($current_el, $text);
242 242
         }
@@ -266,12 +266,12 @@  discard block
 block discarded – undo
266 266
             // note:  i don't think this is actually neccessary
267 267
             if ($this->stack[0] == $el) {
268 268
                 $this->append_content("</$el>");
269
-            } else {
269
+            }else {
270 270
                 $this->append_content("<$el />");
271 271
             }
272 272
 
273 273
             array_shift($this->stack);
274
-        } else {
274
+        }else {
275 275
             array_shift($this->stack);
276 276
         }
277 277
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
             } elseif ($this->inimage) {
320 320
                 $this->concat($this->image[$this->current_namespace][$el], $text);
321 321
             }
322
-        } else {
322
+        }else {
323 323
             if ($this->initem) {
324 324
                 $this->concat($this->current_item[$el], $text);
325 325
             } elseif ($this->intextinput) {
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
         // if atom populate rss fields
337 337
         if ($this->is_atom()) {
338 338
             $this->channel['description'] = $this->channel['tagline'];
339
-            for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
339
+            for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) {
340 340
                 $item = $this->items[$i];
341 341
                 if (isset($item['summary'])) {
342 342
                     $item['description'] = $item['summary'];
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
                 $atom_date = isset($item['issued']) ? $item['issued'] : @$item['modified'];
349 349
                 if ($atom_date) {
350 350
                     $epoch = @parse_w3cdtf($atom_date);
351
-                    if ($epoch && $epoch > 0) {
351
+                    if ($epoch && $epoch>0) {
352 352
                         $item['date_timestamp'] = $epoch;
353 353
                     }
354 354
                 }
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
             }
358 358
         } elseif ($this->is_rss()) {
359 359
             $this->channel['tagline'] = $this->channel['description'];
360
-            for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
360
+            for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) {
361 361
                 $item = $this->items[$i];
362 362
                 if (isset($item['description'])) {
363 363
                     $item['summary'] = $item['description'];
@@ -368,12 +368,12 @@  discard block
 block discarded – undo
368 368
 
369 369
                 if ($this->is_rss() === '1.0' && isset($item['dc']['date'])) {
370 370
                     $epoch = @parse_w3cdtf($item['dc']['date']);
371
-                    if ($epoch && $epoch > 0) {
371
+                    if ($epoch && $epoch>0) {
372 372
                         $item['date_timestamp'] = $epoch;
373 373
                     }
374 374
                 } elseif (isset($item['pubdate'])) {
375 375
                     $epoch = @strtotime($item['pubdate']);
376
-                    if ($epoch > 0) {
376
+                    if ($epoch>0) {
377 377
                         $item['date_timestamp'] = $epoch;
378 378
                     }
379 379
                 }
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
     public function is_rss() {
390 390
         if ($this->feed_type == RSS) {
391 391
             return $this->feed_version;
392
-        } else {
392
+        }else {
393 393
             return false;
394 394
         }
395 395
     }
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
     public function is_atom() {
401 401
         if ($this->feed_type == ATOM) {
402 402
             return $this->feed_version;
403
-        } else {
403
+        }else {
404 404
             return false;
405 405
         }
406 406
     }
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
     public function create_parser($source, $out_enc, $in_enc, $detect) {
417 417
         if (substr(phpversion(), 0, 1) == 5) {
418 418
             $parser = $this->php5_create_parser($in_enc, $detect);
419
-        } else {
419
+        }else {
420 420
             list($parser, $source) = $this->php4_create_parser($source, $in_enc, $detect);
421 421
         }
422 422
         if ($out_enc) {
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
         // by default php5 does a fine job of detecting input encodings
443 443
         if (!$detect && $in_enc) {
444 444
             return xml_parser_create($in_enc);
445
-        } else {
445
+        }else {
446 446
             return xml_parser_create('');
447 447
         }
448 448
     }
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
             if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) {
475 475
                 $in_enc                = strtoupper($m[1]);
476 476
                 $this->source_encoding = $in_enc;
477
-            } else {
477
+            }else {
478 478
                 $in_enc = 'UTF-8';
479 479
             }
480 480
         }
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
         $enc = strtoupper($enc);
524 524
         if (in_array($enc, $this->_KNOWN_ENCODINGS)) {
525 525
             return $enc;
526
-        } else {
526
+        }else {
527 527
             return false;
528 528
         }
529 529
     }
@@ -539,14 +539,14 @@  discard block
 block discarded – undo
539 539
         }
540 540
         if (MAGPIE_DEBUG) {
541 541
             trigger_error($errormsg, $lvl);
542
-        } else {
542
+        }else {
543 543
             error_log($errormsg, 0);
544 544
         }
545 545
 
546 546
         $notices = E_USER_NOTICE | E_NOTICE;
547 547
         if ($lvl & $notices) {
548 548
             $this->WARNING = $errormsg;
549
-        } else {
549
+        }else {
550 550
             $this->ERROR = $errormsg;
551 551
         }
552 552
     }
@@ -580,12 +580,12 @@  discard block
 block discarded – undo
580 580
         );
581 581
 
582 582
         # calc epoch for current date assuming GMT
583
-        $epoch = gmmktime((int)$hours, (int)$minutes, (int)$seconds, (int)$month, (int)$day, (int)$year);
583
+        $epoch = gmmktime((int) $hours, (int) $minutes, (int) $seconds, (int) $month, (int) $day, (int) $year);
584 584
 
585 585
         $offset = 0;
586 586
         if ($match[10] === 'Z') {
587 587
             # zulu time, aka GMT
588
-        } else {
588
+        }else {
589 589
             list($tz_mod, $tz_hour, $tz_min) = array($match[8], $match[9], $match[10]);
590 590
 
591 591
             # zero out the variables
@@ -596,20 +596,20 @@  discard block
 block discarded – undo
596 596
                 $tz_min = 0;
597 597
             }
598 598
 
599
-            $offset_secs = (($tz_hour * 60) + $tz_min) * 60;
599
+            $offset_secs = (($tz_hour*60)+$tz_min)*60;
600 600
 
601 601
             # is timezone ahead of GMT?  then subtract offset
602 602
             #
603 603
             if ($tz_mod == '+') {
604
-                $offset_secs = $offset_secs * -1;
604
+                $offset_secs = $offset_secs*-1;
605 605
             }
606 606
 
607 607
             $offset = $offset_secs;
608 608
         }
609
-        $epoch = $epoch + $offset;
609
+        $epoch = $epoch+$offset;
610 610
 
611 611
         return $epoch;
612
-    } else {
612
+    }else {
613 613
         return -1;
614 614
     }
615 615
 }
Please login to merge, or discard this patch.
class/xmlparser.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@
 block discarded – undo
83 83
     }
84 84
 
85 85
     /**
86
-     * @return bool|string
86
+     * @return string|false
87 87
      */
88 88
     public function is_atom() {
89 89
         if ($this->feed_type == ATOM) {
Please login to merge, or discard this patch.
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -43,169 +43,169 @@
 block discarded – undo
43 43
  **/
44 44
 class xmlparser extends MagpieRSS
45 45
 {
46
-    public $content;
47
-    public $charset_in;
48
-    public $charset_out;
46
+	public $content;
47
+	public $charset_in;
48
+	public $charset_out;
49 49
 
50
-    /**
51
-     *  Set up XML parser, parse source, and return populated RSS object..
52
-     *
53
-     * @param string      $content    string containing the RSS to be parsed
54
-     *
55
-     *
56
-     * @param string      $input_charset
57
-     * @param null|string $output_charset
58
-     * @param array       $tags
59
-     * @internal param string $output_encoding output the parsed RSS in this character
60
-     *                                set defaults to ISO-8859-1 as this is PHP's
61
-     *                                default.
62
-     *
63
-     * @internal param string $input_encoding the character set of the incoming RSS source.
64
-     *                                Leave blank and Magpie will try to figure it
65
-     *                                out.
66
-     */
67
-    public function __construct($content, $input_charset, $output_charset = _CHARSET, $tags = array()) {
68
-        if (!in_array(strtoupper($input_charset), array('UTF-8', 'US-ASCII', 'ISO-8859-1'))) {
69
-            $content       = XoopsLocal::convert_encoding($content, 'UTF-8', $input_charset);
70
-            $content       = preg_replace('/(<\?xml.*encoding=[\'"])(.*?)([\'"].*\?>)/m', '$1UTF-8$3', $content);
71
-            $input_charset = 'UTF-8';
72
-        }
73
-        $this->content     = $content;
74
-        $this->charset_in  = $input_charset;
75
-        $this->charset_out = $output_charset;
50
+	/**
51
+	 *  Set up XML parser, parse source, and return populated RSS object..
52
+	 *
53
+	 * @param string      $content    string containing the RSS to be parsed
54
+	 *
55
+	 *
56
+	 * @param string      $input_charset
57
+	 * @param null|string $output_charset
58
+	 * @param array       $tags
59
+	 * @internal param string $output_encoding output the parsed RSS in this character
60
+	 *                                set defaults to ISO-8859-1 as this is PHP's
61
+	 *                                default.
62
+	 *
63
+	 * @internal param string $input_encoding the character set of the incoming RSS source.
64
+	 *                                Leave blank and Magpie will try to figure it
65
+	 *                                out.
66
+	 */
67
+	public function __construct($content, $input_charset, $output_charset = _CHARSET, $tags = array()) {
68
+		if (!in_array(strtoupper($input_charset), array('UTF-8', 'US-ASCII', 'ISO-8859-1'))) {
69
+			$content       = XoopsLocal::convert_encoding($content, 'UTF-8', $input_charset);
70
+			$content       = preg_replace('/(<\?xml.*encoding=[\'"])(.*?)([\'"].*\?>)/m', '$1UTF-8$3', $content);
71
+			$input_charset = 'UTF-8';
72
+		}
73
+		$this->content     = $content;
74
+		$this->charset_in  = $input_charset;
75
+		$this->charset_out = $output_charset;
76 76
 
77
-        /* TODO: parse specified tags only */
78
-        parent::__construct($content, $input_charset, $input_charset, false);
77
+		/* TODO: parse specified tags only */
78
+		parent::__construct($content, $input_charset, $input_charset, false);
79 79
 
80
-        //xoops_message($this);
81
-        unset($this->content);
82
-        $this->encoding_convert($tags);
83
-    }
80
+		//xoops_message($this);
81
+		unset($this->content);
82
+		$this->encoding_convert($tags);
83
+	}
84 84
 
85
-    /**
86
-     * @return bool|string
87
-     */
88
-    public function is_atom() {
89
-        if ($this->feed_type == ATOM) {
90
-            $this->feed_version = empty($this->feed_version) ? '0.3' : $this->feed_version;
85
+	/**
86
+	 * @return bool|string
87
+	 */
88
+	public function is_atom() {
89
+		if ($this->feed_type == ATOM) {
90
+			$this->feed_version = empty($this->feed_version) ? '0.3' : $this->feed_version;
91 91
 
92
-            return $this->feed_version;
93
-        } else {
94
-            return false;
95
-        }
96
-    }
92
+			return $this->feed_version;
93
+		} else {
94
+			return false;
95
+		}
96
+	}
97 97
 
98
-    public function normalize() {
99
-        if ($this->is_atom()):
100
-            if (empty($this->channel['tagline'])) {
101
-                /* ATOM */
102
-                $this->channel['tagline'] = @$this->channel['subtitle'];
103
-                unset($this->channel['subtitle']);
104
-            }
105
-            for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
106
-                // ATOM time
107
-                if ($date = @$this->items[$i]['modified']) {
108
-                    continue;
109
-                }
110
-                if (empty($date)) {
111
-                    $date = @$this->items[$i]['updated'];
112
-                }
113
-                if (empty($date)) {
114
-                    $date = @$this->items[$i]['issued'];
115
-                }
116
-                if (empty($date)) {
117
-                    $date = @$this->items[$i]['created'];
118
-                }
119
-                if (empty($date)) {
120
-                    $date = @$this->items[$i]['created'];
121
-                }
122
-                $this->items[$i]['modified'] = $date;
123
-            }
124
-        elseif ($this->is_rss() !== '1.0'):
125
-            for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
126
-                if ($date = @$this->items[$i]['pubdate']) {
127
-                    continue;
128
-                }
129
-                $this->items[$i]['pubdate'] = @$this->items[$i]['dc']['date'];
130
-            }
131
-        endif;
132
-        parent::normalize();
133
-        /* ATOM */
134
-        if (empty($this->channel['language']) && !empty($this->channel['dc']['language'])) {
135
-            $this->channel['language'] = $this->channel['dc']['language'];
136
-            unset($this->channel['dc']['language']);
137
-        }
138
-        if (empty($this->channel['language'])
139
-            && preg_match('/<link.*hreflang=[\'"](.*?)[\'"].*?>/m', $this->content, $match)
140
-        ) {
141
-            $this->channel['language'] = $match[1];
142
-        }
143
-        if (empty($this->channel['language'])
144
-            && preg_match('/<feed.*xml:lang=[\'"](.*?)[\'"].*?>/m', $this->content, $match)
145
-        ) {
146
-            $this->channel['language'] = $match[1];
147
-        }
148
-        /* remove to avoid redundant encoding conversion */
149
-        if (!empty($this->channel['tagline'])) {
150
-            unset($this->channel['tagline']);
151
-        }
98
+	public function normalize() {
99
+		if ($this->is_atom()):
100
+			if (empty($this->channel['tagline'])) {
101
+				/* ATOM */
102
+				$this->channel['tagline'] = @$this->channel['subtitle'];
103
+				unset($this->channel['subtitle']);
104
+			}
105
+			for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
106
+				// ATOM time
107
+				if ($date = @$this->items[$i]['modified']) {
108
+					continue;
109
+				}
110
+				if (empty($date)) {
111
+					$date = @$this->items[$i]['updated'];
112
+				}
113
+				if (empty($date)) {
114
+					$date = @$this->items[$i]['issued'];
115
+				}
116
+				if (empty($date)) {
117
+					$date = @$this->items[$i]['created'];
118
+				}
119
+				if (empty($date)) {
120
+					$date = @$this->items[$i]['created'];
121
+				}
122
+				$this->items[$i]['modified'] = $date;
123
+			}
124
+		elseif ($this->is_rss() !== '1.0'):
125
+			for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
126
+				if ($date = @$this->items[$i]['pubdate']) {
127
+					continue;
128
+				}
129
+				$this->items[$i]['pubdate'] = @$this->items[$i]['dc']['date'];
130
+			}
131
+		endif;
132
+		parent::normalize();
133
+		/* ATOM */
134
+		if (empty($this->channel['language']) && !empty($this->channel['dc']['language'])) {
135
+			$this->channel['language'] = $this->channel['dc']['language'];
136
+			unset($this->channel['dc']['language']);
137
+		}
138
+		if (empty($this->channel['language'])
139
+			&& preg_match('/<link.*hreflang=[\'"](.*?)[\'"].*?>/m', $this->content, $match)
140
+		) {
141
+			$this->channel['language'] = $match[1];
142
+		}
143
+		if (empty($this->channel['language'])
144
+			&& preg_match('/<feed.*xml:lang=[\'"](.*?)[\'"].*?>/m', $this->content, $match)
145
+		) {
146
+			$this->channel['language'] = $match[1];
147
+		}
148
+		/* remove to avoid redundant encoding conversion */
149
+		if (!empty($this->channel['tagline'])) {
150
+			unset($this->channel['tagline']);
151
+		}
152 152
 
153
-        for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
154
-            if ($date_timestamp = @$this->items[$i]['date_timestamp']) {
155
-                continue;
156
-            }
157
-            if ($date_timestamp = @$this->items[$i]['pubdate']) {
158
-                $this->items[$i]['date_timestamp'] = $date_timestamp;
159
-            } elseif ($date_timestamp = @$this->items[$i]['dc']['date']) {
160
-                $this->items[$i]['date_timestamp'] = $date_timestamp;
161
-            } else {
162
-                $this->items[$i]['date_timestamp'] = time();
163
-            }
164
-            if (!is_numeric($this->items[$i]['date_timestamp'])) {
165
-                if ($date = parse_w3cdtf($this->items[$i]['date_timestamp'])) {
166
-                    $this->items[$i]['date_timestamp'] = $date;
167
-                } elseif ($date = strtotime($this->items[$i]['date_timestamp'])) {
168
-                    $this->items[$i]['date_timestamp'] = $date;
169
-                }
170
-            }
153
+		for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
154
+			if ($date_timestamp = @$this->items[$i]['date_timestamp']) {
155
+				continue;
156
+			}
157
+			if ($date_timestamp = @$this->items[$i]['pubdate']) {
158
+				$this->items[$i]['date_timestamp'] = $date_timestamp;
159
+			} elseif ($date_timestamp = @$this->items[$i]['dc']['date']) {
160
+				$this->items[$i]['date_timestamp'] = $date_timestamp;
161
+			} else {
162
+				$this->items[$i]['date_timestamp'] = time();
163
+			}
164
+			if (!is_numeric($this->items[$i]['date_timestamp'])) {
165
+				if ($date = parse_w3cdtf($this->items[$i]['date_timestamp'])) {
166
+					$this->items[$i]['date_timestamp'] = $date;
167
+				} elseif ($date = strtotime($this->items[$i]['date_timestamp'])) {
168
+					$this->items[$i]['date_timestamp'] = $date;
169
+				}
170
+			}
171 171
 
172
-            /* remove to avoid redundant encoding conversion */
173
-            if (isset($this->items[$i]['summary'])) {
174
-                unset($this->items[$i]['summary']);
175
-            }
176
-            if (isset($this->items[$i]['atom_content'])) {
177
-                unset($this->items[$i]['atom_content']);
178
-            }
179
-        }
172
+			/* remove to avoid redundant encoding conversion */
173
+			if (isset($this->items[$i]['summary'])) {
174
+				unset($this->items[$i]['summary']);
175
+			}
176
+			if (isset($this->items[$i]['atom_content'])) {
177
+				unset($this->items[$i]['atom_content']);
178
+			}
179
+		}
180 180
 
181
-        return;
182
-    }
181
+		return;
182
+	}
183 183
 
184
-    /**
185
-     * @param array $tags
186
-     */
187
-    public function encoding_convert($tags = array()) {
188
-        if (empty($tags) || in_array('channel', $tags)) {
189
-            $this->channel = $this->_encoding($this->channel);
190
-        }
191
-        if (empty($tags) || in_array('items', $tags)) {
192
-            $this->items = $this->_encoding($this->items);
193
-        }
194
-    }
184
+	/**
185
+	 * @param array $tags
186
+	 */
187
+	public function encoding_convert($tags = array()) {
188
+		if (empty($tags) || in_array('channel', $tags)) {
189
+			$this->channel = $this->_encoding($this->channel);
190
+		}
191
+		if (empty($tags) || in_array('items', $tags)) {
192
+			$this->items = $this->_encoding($this->items);
193
+		}
194
+	}
195 195
 
196
-    /**
197
-     * @param $val
198
-     * @return array|mixed|string
199
-     */
200
-    public function _encoding($val) {
201
-        if (is_array($val)) {
202
-            foreach (array_keys($val) as $key) {
203
-                $val[$key] = $this->_encoding($val[$key]);
204
-            }
205
-        } else {
206
-            $val = XoopsLocal::convert_encoding($val, $this->charset_out, $this->charset_in);
207
-        }
196
+	/**
197
+	 * @param $val
198
+	 * @return array|mixed|string
199
+	 */
200
+	public function _encoding($val) {
201
+		if (is_array($val)) {
202
+			foreach (array_keys($val) as $key) {
203
+				$val[$key] = $this->_encoding($val[$key]);
204
+			}
205
+		} else {
206
+			$val = XoopsLocal::convert_encoding($val, $this->charset_out, $this->charset_in);
207
+		}
208 208
 
209
-        return $val;
210
-    }
209
+		return $val;
210
+	}
211 211
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
  */
31 31
 global $msg;
32 32
 
33
-require_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/class/magpie.inc.php';
33
+require_once XOOPS_ROOT_PATH.'/modules/'.$GLOBALS['moddirname'].'/class/magpie.inc.php';
34 34
 
35 35
 /**
36 36
  * XmlParser
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
             $this->feed_version = empty($this->feed_version) ? '0.3' : $this->feed_version;
91 91
 
92 92
             return $this->feed_version;
93
-        } else {
93
+        }else {
94 94
             return false;
95 95
         }
96 96
     }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
                 $this->channel['tagline'] = @$this->channel['subtitle'];
103 103
                 unset($this->channel['subtitle']);
104 104
             }
105
-            for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
105
+            for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) {
106 106
                 // ATOM time
107 107
                 if ($date = @$this->items[$i]['modified']) {
108 108
                     continue;
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
                 $this->items[$i]['modified'] = $date;
123 123
             }
124 124
         elseif ($this->is_rss() !== '1.0'):
125
-            for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
125
+            for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) {
126 126
                 if ($date = @$this->items[$i]['pubdate']) {
127 127
                     continue;
128 128
                 }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
             unset($this->channel['tagline']);
151 151
         }
152 152
 
153
-        for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
153
+        for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) {
154 154
             if ($date_timestamp = @$this->items[$i]['date_timestamp']) {
155 155
                 continue;
156 156
             }
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
                 $this->items[$i]['date_timestamp'] = $date_timestamp;
159 159
             } elseif ($date_timestamp = @$this->items[$i]['dc']['date']) {
160 160
                 $this->items[$i]['date_timestamp'] = $date_timestamp;
161
-            } else {
161
+            }else {
162 162
                 $this->items[$i]['date_timestamp'] = time();
163 163
             }
164 164
             if (!is_numeric($this->items[$i]['date_timestamp'])) {
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
             foreach (array_keys($val) as $key) {
203 203
                 $val[$key] = $this->_encoding($val[$key]);
204 204
             }
205
-        } else {
205
+        }else {
206 206
             $val = XoopsLocal::convert_encoding($val, $this->charset_out, $this->charset_in);
207 207
         }
208 208
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -120,8 +120,7 @@
 block discarded – undo
120 120
                     $date = @$this->items[$i]['created'];
121 121
                 }
122 122
                 $this->items[$i]['modified'] = $date;
123
-            }
124
-        elseif ($this->is_rss() !== '1.0'):
123
+            } elseif ($this->is_rss() !== '1.0'):
125 124
             for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
126 125
                 if ($date = @$this->items[$i]['pubdate']) {
127 126
                     continue;
Please login to merge, or discard this patch.
include/functions.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
      * @var mixed  $pattern
109 109
      * @var mixed  $replacement
110 110
      *
111
-     * @return bool true on success
111
+     * @return null|boolean true on success
112 112
      */
113 113
     function planet_parse_class($class_string, $pattern = '', $replacement = '') {
114 114
         if (empty($class_string)) {
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
      * @var mixed  $pattern
144 144
      * @var mixed  $replacement
145 145
      *
146
-     * @return bool true on success
146
+     * @return null|boolean true on success
147 147
      */
148 148
     function planet_parse_function($function_string, $pattern = '', $replacement = '') {
149 149
         if (empty($function_string)) {
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 
495 495
     /**
496 496
      * @param $url
497
-     * @return bool|string
497
+     * @return false|string
498 498
      */
499 499
     function planet_fetch_fopen($url) {
500 500
         if (!$fp = @fopen($url, 'r')) {
Please login to merge, or discard this patch.
Indentation   +490 added lines, -490 removed lines patch added patch discarded remove patch
@@ -29,502 +29,502 @@
 block discarded – undo
29 29
 
30 30
 $current_path = __FILE__;
31 31
 if (DIRECTORY_SEPARATOR !== '/') {
32
-    $current_path = str_replace(strpos($current_path, '\\\\', 2) ? '\\\\' : DIRECTORY_SEPARATOR, '/', $current_path);
32
+	$current_path = str_replace(strpos($current_path, '\\\\', 2) ? '\\\\' : DIRECTORY_SEPARATOR, '/', $current_path);
33 33
 }
34 34
 $url_arr               = explode('/', strstr($current_path, '/modules/'));
35 35
 $GLOBALS['moddirname'] = $url_arr[2];
36 36
 
37 37
 if (!defined('planet_FUNCTIONS')):
38
-    define('planet_FUNCTIONS', 1);
39
-
40
-    require XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/vars.php';
41
-    include_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
42
-    include_once XOOPS_ROOT_PATH . '/Frameworks/art/functions.php';
43
-
44
-    /**
45
-     * Function to display messages
46
-     *
47
-     * @var mixed $messages
48
-     * @return bool
49
-     */
50
-    function planet_message($message) {
51
-        return mod_message($message);
52
-    }
53
-
54
-    /**
55
-     * Function to parse arguments for a page according to $_SERVER['REQUEST_URI']
56
-     *
57
-     * @var array $args_numeric array of numeric variable values
58
-     * @var array $args         array of indexed variables: name and value
59
-     * @var array $args_string  array of string variable values
60
-     *
61
-     * @return bool true on args parsed
62
-     */
63
-
64
-    /* known issues:
38
+	define('planet_FUNCTIONS', 1);
39
+
40
+	require XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/vars.php';
41
+	include_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
42
+	include_once XOOPS_ROOT_PATH . '/Frameworks/art/functions.php';
43
+
44
+	/**
45
+	 * Function to display messages
46
+	 *
47
+	 * @var mixed $messages
48
+	 * @return bool
49
+	 */
50
+	function planet_message($message) {
51
+		return mod_message($message);
52
+	}
53
+
54
+	/**
55
+	 * Function to parse arguments for a page according to $_SERVER['REQUEST_URI']
56
+	 *
57
+	 * @var array $args_numeric array of numeric variable values
58
+	 * @var array $args         array of indexed variables: name and value
59
+	 * @var array $args_string  array of string variable values
60
+	 *
61
+	 * @return bool true on args parsed
62
+	 */
63
+
64
+	/* known issues:
65 65
      * - "/" in a string
66 66
      * - "&" in a string
67 67
     */
68
-    function planet_parse_args(&$args_numeric, &$args, &$args_string) {
69
-        $args_abb     = array(
70
-            'a' => 'article',
71
-            'b' => 'blog',
72
-            'c' => 'category',
73
-            'l' => 'list',
74
-            'o' => 'sort',
75
-            's' => 'start',
76
-            'u' => 'uid'
77
-        );
78
-        $args         = array();
79
-        $args_numeric = array();
80
-        $args_string  = array();
81
-        if (preg_match("/[^\?]*\.php[\/|\?]([^\?]*)/i", $_SERVER['REQUEST_URI'], $matches)) {
82
-            $vars = preg_split("/[\/|&]/", $matches[1]);
83
-            $vars = array_map('trim', $vars);
84
-            if (count($vars) > 0) {
85
-                foreach ($vars as $var) {
86
-                    if (is_numeric($var)) {
87
-                        $args_numeric[] = $var;
88
-                    } elseif (false === strpos($var, '=')) {
89
-                        if (is_numeric(substr($var, 1))) {
90
-                            $args[$args_abb[strtolower($var{0})]] = (int)substr($var, 1);
91
-                        } else {
92
-                            $args_string[] = urldecode($var);
93
-                        }
94
-                    } else {
95
-                        parse_str($var, $args);
96
-                    }
97
-                }
98
-            }
99
-        }
100
-
101
-        return (count($args) + count($args_numeric) + count($args_string) == 0) ? null : true;
102
-    }
103
-
104
-    /**
105
-     * Function to parse class prefix
106
-     *
107
-     * @var string $class_string string to be parsed
108
-     * @var mixed  $pattern
109
-     * @var mixed  $replacement
110
-     *
111
-     * @return bool true on success
112
-     */
113
-    function planet_parse_class($class_string, $pattern = '', $replacement = '') {
114
-        if (empty($class_string)) {
115
-            return;
116
-        }
117
-        $patterns     = array("/\[CLASS_PREFIX\]/");
118
-        $replacements = array(ucfirst(strtolower($GLOBALS['moddirname'])));
119
-        if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) {
120
-            $pattern     = array($pattern);
121
-            $replacement = array($replacement);
122
-        }
123
-        if (is_array($pattern) && count($pattern) > 0) {
124
-            $ii = 0;
125
-            foreach ($pattern as $pat) {
126
-                if (!in_array($pat, $patterns)) {
127
-                    $patterns[]     = $pat;
128
-                    $replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : '';
129
-                }
130
-                ++$ii;
131
-            }
132
-        }
133
-        $class_string = preg_replace($patterns, $replacements, $class_string);
134
-        eval($class_string);
135
-
136
-        return true;
137
-    }
138
-
139
-    /**
140
-     * Function to parse function prefix
141
-     *
142
-     * @var string $function_string string to be parsed
143
-     * @var mixed  $pattern
144
-     * @var mixed  $replacement
145
-     *
146
-     * @return bool true on success
147
-     */
148
-    function planet_parse_function($function_string, $pattern = '', $replacement = '') {
149
-        if (empty($function_string)) {
150
-            return;
151
-        }
152
-        $patterns     = array("/\[DIRNAME\]/", "/\[VAR_PREFIX\]/");
153
-        $replacements = array($GLOBALS['moddirname'], $GLOBALS['VAR_PREFIX']);
154
-        if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) {
155
-            $pattern     = array($pattern);
156
-            $replacement = array($replacement);
157
-        }
158
-        if (is_array($pattern) && count($pattern) > 0) {
159
-            $ii = 0;
160
-            foreach ($pattern as $pat) {
161
-                if (!in_array($pat, $patterns)) {
162
-                    $patterns[]     = $pat;
163
-                    $replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : '';
164
-                }
165
-                ++$ii;
166
-            }
167
-        }
168
-        $function_string = preg_replace($patterns, $replacements, $function_string);
169
-        eval($function_string);
170
-
171
-        return true;
172
-    }
173
-
174
-    /**
175
-     * Function to convert UNIX time to formatted time string
176
-     * @param        $time
177
-     * @param string $format
178
-     * @return string
179
-     */
180
-    function planet_formatTimestamp($time, $format = '') {
181
-        if (empty($time)) {
182
-            return '';
183
-        }
184
-
185
-        return formatTimestamp($time, $format);
186
-    }
187
-
188
-    /**
189
-     * Function to a list of user names associated with their user IDs
190
-     * @param      $userid
191
-     * @param int  $usereal
192
-     * @param bool $linked
193
-     * @return array
194
-     */
195
-    function &planet_getUnameFromId($userid, $usereal = 0, $linked = false) {
196
-        if (!is_array($userid)) {
197
-            $userid = array($userid);
198
-        }
199
-        $users =& mod_getUnameFromIds($userid, $usereal, $linked);
200
-
201
-        return $users;
202
-    }
203
-
204
-    /**
205
-     * Function to parse links, links are delimited by link break, URL and title of a link are delimited by space
206
-     *
207
-     * @var string $text raw content
208
-     *
209
-     * @return array associative array of link url and title
210
-     */
211
-    function &planet_parseLinks($text) {
212
-        $myts       = MyTextSanitizer::getInstance();
213
-        $link_array = preg_split("/(\r\n|\r|\n)( *)/", $text);
214
-        $links      = array();
215
-        if (count($link_array) > 0) {
216
-            foreach ($link_array as $link) {
217
-                @list($url, $title) = array_map('trim', preg_split('/ /', $link, 2));
218
-                if (empty($url)) {
219
-                    continue;
220
-                }
221
-                //if(empty($title)) $title = $url;
222
-                $links[] = array('url' => $url, 'title' => $myts->htmlSpecialChars($title));
223
-            }
224
-        }
225
-
226
-        return $links;
227
-    }
228
-
229
-    /**
230
-     * @param $pagename
231
-     * @return string
232
-     */
233
-    function planet_getTemplate($pagename) {
234
-        return $GLOBALS['VAR_PREFIX'] . '_' . $pagename . '.tpl';
235
-    }
236
-
237
-    /**
238
-     * @param int $currentoption
239
-     */
240
-    function planet_adminmenu($currentoption = -1) {
241
-        loadModuleAdminMenu($currentoption, '');
242
-
243
-        return;
244
-    }
245
-
246
-    /**
247
-     * Function to send a trackback
248
-     *
249
-     * @param $article
250
-     * @param $comment
251
-     * @return bool
252
-     */
253
-    function planet_com_trackback(&$article, &$comment) {
254
-        $blog_handler = xoops_getModuleHandler('blog', $GLOBALS['moddirname']);
255
-        $blog_obj     = $blog_handler->get($article->getVar('blog_id'));
256
-        if (!$pattern = $blog_obj->getVar('blog_trackback')) {
257
-            return false;
258
-        }
259
-        @list($pat, $rep) = array_map('trim', preg_split("#[\s]+#", $pattern));
260
-        $trackback_url = preg_replace('#' . $pat . '#', $rep, $article_obj->getVar('art_link'));
261
-
262
-        return planet_trackback($trackback_url, $article);
263
-    }
264
-
265
-    /**
266
-     * @param $trackback_url
267
-     * @param $article
268
-     * @return bool
269
-     */
270
-    function planet_trackback($trackback_url, &$article) {
271
-        global $myts, $xoopsConfig, $xoopsModule, $xoopsModuleConfig;
272
-
273
-        $title         = $article->getVar('art_title');
274
-        $excerpt       = $article->getVar('art_content');
275
-        $blog_name     = $xoopsConfig['sitename'] . '-' . $xoopsModule->getVar('name');
276
-        $title         = xoops_utf8_encode($title);
277
-        $excerpt       = xoops_utf8_encode($excerpt);
278
-        $blog_name     = xoops_utf8_encode($blog_name);
279
-        $charset       = 'utf-8';
280
-        $title1        = urlencode($title);
281
-        $excerpt1      = urlencode($excerpt);
282
-        $name1         = urlencode($blog_name);
283
-        $url           = urlencode(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php'
284
-                                   . URL_DELIMITER . '' . $article->getVar('art_id'));
285
-        $query_string  = "title=$title1&url=$url&blog_name=$name1&excerpt=$excerpt1&charset=$charset";
286
-        $trackback_url = parse_url($trackback_url);
287
-
288
-        $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?'
289
-                                                                                      . $trackback_url['query'] : '')
290
-                        . " HTTP/1.0\r\n";
291
-        $http_request .= 'Host: ' . $trackback_url['host'] . "\r\n";
292
-        $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . $charset . "\r\n";
293
-        $http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n";
294
-        $http_request .= 'User-Agent: XOOPS Blogs/' . XOOPS_VERSION;
295
-        $http_request .= "\r\n\r\n";
296
-        $http_request .= $query_string;
297
-        if ('' == $trackback_url['port']) {
298
-            $trackback_url['port'] = 80;
299
-        }
300
-        $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4);
301
-        @fwrite($fs, $http_request);
302
-        if ($xoopsModuleConfig['do_debug']) {
303
-            $debug_file = XOOPS_CACHE_PATH . '/' . $GLOBALS['moddirname'] . '_trackback.log';
304
-            $fr         = "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n";
305
-            $fr .= "CHARSET:$charset\n";
306
-            $fr .= "NAME:$blog_name\n";
307
-            $fr .= 'TITLE:' . $title . "\n";
308
-            $fr .= "EXCERPT:$excerpt\n\n";
309
-            while (!@feof($fs)) {
310
-                $fr .= @fgets($fs, 4096);
311
-            }
312
-            $fr .= "\n\n";
313
-
314
-            if ($fp = fopen($debug_file, 'a')) {
315
-                fwrite($fp, $fr);
316
-                fclose($fp);
317
-            } else {
318
-            }
319
-        }
320
-        @fclose($fs);
321
-
322
-        return true;
323
-    }
324
-
325
-    /**
326
-     * Function to ping servers
327
-     * @param $server
328
-     * @param $id
329
-     */
330
-    function planet_ping($server, $id) {
331
-        if (is_array($server)) {
332
-            foreach ($server as $serv) {
333
-                planet_ping($serv, $id);
334
-            }
335
-        }
336
-        include_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/class-IXR.php';
337
-
338
-        // using a timeout of 3 seconds should be enough to cover slow servers
339
-        $client          = new IXR_Client($server, false);
340
-        $client->timeout = 3;
341
-        $client->useragent .= ' -- XOOPS Article/' . XOOPS_VERSION;
342
-
343
-        // when set to true, this outputs debug messages by itself
344
-        $client->debug = false;
345
-
346
-        $blogname = xoops_utf8_encode($GLOBALS['xoopsModule']->getVar('name'));
347
-        $home     = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/';
348
-        $rss2_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php' . URL_DELIMITER . 'rss2.0/' . $id;
349
-
350
-        if (!$client->query('weblogUpdates.extendedPing', $blogname, $home, $rss2_url)) { // then try a normal ping
351
-            $client->query('weblogUpdates.ping', $blogname, $home);
352
-        }
353
-    }
354
-
355
-    /**
356
-     * Function to respond to a trackback
357
-     * @param int    $error
358
-     * @param string $error_message
359
-     */
360
-    function planet_trackback_response($error = 0, $error_message = '') {
361
-        $charset       = 'utf-8';
362
-        $error_message = xoops_utf8_encode($error_message);
363
-        header('Content-Type: text/xml; charset="' . $charset . '"');
364
-        if ($error) {
365
-            echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n";
366
-            echo "<response>\n";
367
-            echo "<error>1</error>\n";
368
-            echo "<message>$error_message</message>\n";
369
-            echo '</response>';
370
-            die();
371
-        } else {
372
-            echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n";
373
-            echo "<response>\n";
374
-            echo "<error>0</error>\n";
375
-            echo '</response>';
376
-        }
377
-    }
378
-
379
-    /**
380
-     * Function to set a cookie with module-specified name
381
-     *
382
-     * using customized serialization method
383
-     * @param        $name
384
-     * @param string $string
385
-     * @param int    $expire
386
-     */
387
-    function planet_setcookie($name, $string = '', $expire = 0) {
388
-        if (is_array($string)) {
389
-            $value = array();
390
-            foreach ($string as $key => $val) {
391
-                $value[] = $key . '|' . $val;
392
-            }
393
-            $string = implode(',', $value);
394
-        }
395
-        setcookie($GLOBALS['VAR_PREFIX'] . $name, $string, (int)$expire, '/');
396
-    }
397
-
398
-    /**
399
-     * @param      $name
400
-     * @param bool $isArray
401
-     * @return array|null
402
-     */
403
-    function planet_getcookie($name, $isArray = false) {
404
-        $value = isset($_COOKIE[$GLOBALS['VAR_PREFIX'] . $name]) ? $_COOKIE[$GLOBALS['VAR_PREFIX'] . $name] : null;
405
-        if ($isArray) {
406
-            $_value = $value ? explode(',', $value) : array();
407
-            $value  = array();
408
-            if (count($_value) > 0) {
409
-                foreach ($_value as $string) {
410
-                    $key         = substr($string, 0, strpos($string, '|'));
411
-                    $val         = substr($string, strpos($string, '|') + 1);
412
-                    $value[$key] = $val;
413
-                }
414
-            }
415
-            unset($_value);
416
-        }
417
-
418
-        return $value;
419
-    }
420
-
421
-    /**
422
-     * Function to filter text
423
-     *
424
-     * @param $document
425
-     * @return string filtered text
426
-     */
427
-    function &planet_html2text(&$document) {
428
-        $document = strip_tags($document);
429
-
430
-        return $document;
431
-    }
432
-
433
-    // Adapted from PMA_getIp() [phpmyadmin project]
434
-    /**
435
-     * @param bool $asString
436
-     * @return mixed
437
-     */
438
-    function planet_getIP($asString = false) {
439
-        return mod_getIP($asString);
440
-    }
441
-
442
-    /**
443
-     * @param $url
444
-     * @return bool|mixed|string
445
-     */
446
-    function planet_remote_content($url) {
447
-        if ($data = planet_fetch_snoopy($url)) {
448
-            return $data;
449
-        }
450
-        if ($data = planet_fetch_CURL($url)) {
451
-            return $data;
452
-        }
453
-        if ($data = planet_fetch_fopen($url)) {
454
-            return $data;
455
-        }
456
-
457
-        return false;
458
-    }
459
-
460
-    /**
461
-     * @param $url
462
-     * @return string
463
-     */
464
-    function planet_fetch_snoopy($url) {
465
-        require_once XOOPS_ROOT_PATH . '/class/snoopy.php';
466
-        $snoopy = new Snoopy;
467
-        $data   = '';
468
-        if (@$snoopy->fetch($url)) {
469
-            $data = is_array($snoopy->results) ? implode("\n", $snoopy->results) : $snoopy->results;
470
-        }
471
-
472
-        return $data;
473
-    }
474
-
475
-    /**
476
-     * @param $url
477
-     * @return bool|mixed
478
-     */
479
-    function planet_fetch_CURL($url) {
480
-        if (!function_exists('curl_init')) {
481
-            return false;
482
-        }
483
-        $ch = curl_init();    // initialize curl handle
484
-        curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
485
-        curl_setopt($ch, CURLOPT_FAILONERROR, 1);
486
-        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
487
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
488
-        curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 31s
489
-        $data = curl_exec($ch); // run the whole process
490
-        curl_close($ch);
491
-
492
-        return $data;
493
-    }
494
-
495
-    /**
496
-     * @param $url
497
-     * @return bool|string
498
-     */
499
-    function planet_fetch_fopen($url) {
500
-        if (!$fp = @fopen($url, 'r')) {
501
-            return false;
502
-        }
503
-        $data = '';
504
-        while (!feof($fp)) {
505
-            $data .= fgets($fp, 1024);
506
-        }
507
-        fclose($fp);
508
-
509
-        return $data;
510
-    }
511
-
512
-    /**
513
-     * @param     $haystack
514
-     * @param     $needle
515
-     * @param int $offset
516
-     * @return bool|int
517
-     */
518
-    function planet_strrpos($haystack, $needle, $offset = 0) {
519
-        if (substr(phpversion(), 0, 1) == 5) {
520
-            return strrpos($haystack, $needle, $offset);
521
-        }
522
-        $index = strpos(strrev($haystack), strrev($needle));
523
-        if ($index === false) {
524
-            return false;
525
-        }
526
-        $index = strlen($haystack) - strlen($needle) - $index;
527
-
528
-        return $index;
529
-    }
68
+	function planet_parse_args(&$args_numeric, &$args, &$args_string) {
69
+		$args_abb     = array(
70
+			'a' => 'article',
71
+			'b' => 'blog',
72
+			'c' => 'category',
73
+			'l' => 'list',
74
+			'o' => 'sort',
75
+			's' => 'start',
76
+			'u' => 'uid'
77
+		);
78
+		$args         = array();
79
+		$args_numeric = array();
80
+		$args_string  = array();
81
+		if (preg_match("/[^\?]*\.php[\/|\?]([^\?]*)/i", $_SERVER['REQUEST_URI'], $matches)) {
82
+			$vars = preg_split("/[\/|&]/", $matches[1]);
83
+			$vars = array_map('trim', $vars);
84
+			if (count($vars) > 0) {
85
+				foreach ($vars as $var) {
86
+					if (is_numeric($var)) {
87
+						$args_numeric[] = $var;
88
+					} elseif (false === strpos($var, '=')) {
89
+						if (is_numeric(substr($var, 1))) {
90
+							$args[$args_abb[strtolower($var{0})]] = (int)substr($var, 1);
91
+						} else {
92
+							$args_string[] = urldecode($var);
93
+						}
94
+					} else {
95
+						parse_str($var, $args);
96
+					}
97
+				}
98
+			}
99
+		}
100
+
101
+		return (count($args) + count($args_numeric) + count($args_string) == 0) ? null : true;
102
+	}
103
+
104
+	/**
105
+	 * Function to parse class prefix
106
+	 *
107
+	 * @var string $class_string string to be parsed
108
+	 * @var mixed  $pattern
109
+	 * @var mixed  $replacement
110
+	 *
111
+	 * @return bool true on success
112
+	 */
113
+	function planet_parse_class($class_string, $pattern = '', $replacement = '') {
114
+		if (empty($class_string)) {
115
+			return;
116
+		}
117
+		$patterns     = array("/\[CLASS_PREFIX\]/");
118
+		$replacements = array(ucfirst(strtolower($GLOBALS['moddirname'])));
119
+		if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) {
120
+			$pattern     = array($pattern);
121
+			$replacement = array($replacement);
122
+		}
123
+		if (is_array($pattern) && count($pattern) > 0) {
124
+			$ii = 0;
125
+			foreach ($pattern as $pat) {
126
+				if (!in_array($pat, $patterns)) {
127
+					$patterns[]     = $pat;
128
+					$replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : '';
129
+				}
130
+				++$ii;
131
+			}
132
+		}
133
+		$class_string = preg_replace($patterns, $replacements, $class_string);
134
+		eval($class_string);
135
+
136
+		return true;
137
+	}
138
+
139
+	/**
140
+	 * Function to parse function prefix
141
+	 *
142
+	 * @var string $function_string string to be parsed
143
+	 * @var mixed  $pattern
144
+	 * @var mixed  $replacement
145
+	 *
146
+	 * @return bool true on success
147
+	 */
148
+	function planet_parse_function($function_string, $pattern = '', $replacement = '') {
149
+		if (empty($function_string)) {
150
+			return;
151
+		}
152
+		$patterns     = array("/\[DIRNAME\]/", "/\[VAR_PREFIX\]/");
153
+		$replacements = array($GLOBALS['moddirname'], $GLOBALS['VAR_PREFIX']);
154
+		if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) {
155
+			$pattern     = array($pattern);
156
+			$replacement = array($replacement);
157
+		}
158
+		if (is_array($pattern) && count($pattern) > 0) {
159
+			$ii = 0;
160
+			foreach ($pattern as $pat) {
161
+				if (!in_array($pat, $patterns)) {
162
+					$patterns[]     = $pat;
163
+					$replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : '';
164
+				}
165
+				++$ii;
166
+			}
167
+		}
168
+		$function_string = preg_replace($patterns, $replacements, $function_string);
169
+		eval($function_string);
170
+
171
+		return true;
172
+	}
173
+
174
+	/**
175
+	 * Function to convert UNIX time to formatted time string
176
+	 * @param        $time
177
+	 * @param string $format
178
+	 * @return string
179
+	 */
180
+	function planet_formatTimestamp($time, $format = '') {
181
+		if (empty($time)) {
182
+			return '';
183
+		}
184
+
185
+		return formatTimestamp($time, $format);
186
+	}
187
+
188
+	/**
189
+	 * Function to a list of user names associated with their user IDs
190
+	 * @param      $userid
191
+	 * @param int  $usereal
192
+	 * @param bool $linked
193
+	 * @return array
194
+	 */
195
+	function &planet_getUnameFromId($userid, $usereal = 0, $linked = false) {
196
+		if (!is_array($userid)) {
197
+			$userid = array($userid);
198
+		}
199
+		$users =& mod_getUnameFromIds($userid, $usereal, $linked);
200
+
201
+		return $users;
202
+	}
203
+
204
+	/**
205
+	 * Function to parse links, links are delimited by link break, URL and title of a link are delimited by space
206
+	 *
207
+	 * @var string $text raw content
208
+	 *
209
+	 * @return array associative array of link url and title
210
+	 */
211
+	function &planet_parseLinks($text) {
212
+		$myts       = MyTextSanitizer::getInstance();
213
+		$link_array = preg_split("/(\r\n|\r|\n)( *)/", $text);
214
+		$links      = array();
215
+		if (count($link_array) > 0) {
216
+			foreach ($link_array as $link) {
217
+				@list($url, $title) = array_map('trim', preg_split('/ /', $link, 2));
218
+				if (empty($url)) {
219
+					continue;
220
+				}
221
+				//if(empty($title)) $title = $url;
222
+				$links[] = array('url' => $url, 'title' => $myts->htmlSpecialChars($title));
223
+			}
224
+		}
225
+
226
+		return $links;
227
+	}
228
+
229
+	/**
230
+	 * @param $pagename
231
+	 * @return string
232
+	 */
233
+	function planet_getTemplate($pagename) {
234
+		return $GLOBALS['VAR_PREFIX'] . '_' . $pagename . '.tpl';
235
+	}
236
+
237
+	/**
238
+	 * @param int $currentoption
239
+	 */
240
+	function planet_adminmenu($currentoption = -1) {
241
+		loadModuleAdminMenu($currentoption, '');
242
+
243
+		return;
244
+	}
245
+
246
+	/**
247
+	 * Function to send a trackback
248
+	 *
249
+	 * @param $article
250
+	 * @param $comment
251
+	 * @return bool
252
+	 */
253
+	function planet_com_trackback(&$article, &$comment) {
254
+		$blog_handler = xoops_getModuleHandler('blog', $GLOBALS['moddirname']);
255
+		$blog_obj     = $blog_handler->get($article->getVar('blog_id'));
256
+		if (!$pattern = $blog_obj->getVar('blog_trackback')) {
257
+			return false;
258
+		}
259
+		@list($pat, $rep) = array_map('trim', preg_split("#[\s]+#", $pattern));
260
+		$trackback_url = preg_replace('#' . $pat . '#', $rep, $article_obj->getVar('art_link'));
261
+
262
+		return planet_trackback($trackback_url, $article);
263
+	}
264
+
265
+	/**
266
+	 * @param $trackback_url
267
+	 * @param $article
268
+	 * @return bool
269
+	 */
270
+	function planet_trackback($trackback_url, &$article) {
271
+		global $myts, $xoopsConfig, $xoopsModule, $xoopsModuleConfig;
272
+
273
+		$title         = $article->getVar('art_title');
274
+		$excerpt       = $article->getVar('art_content');
275
+		$blog_name     = $xoopsConfig['sitename'] . '-' . $xoopsModule->getVar('name');
276
+		$title         = xoops_utf8_encode($title);
277
+		$excerpt       = xoops_utf8_encode($excerpt);
278
+		$blog_name     = xoops_utf8_encode($blog_name);
279
+		$charset       = 'utf-8';
280
+		$title1        = urlencode($title);
281
+		$excerpt1      = urlencode($excerpt);
282
+		$name1         = urlencode($blog_name);
283
+		$url           = urlencode(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php'
284
+								   . URL_DELIMITER . '' . $article->getVar('art_id'));
285
+		$query_string  = "title=$title1&url=$url&blog_name=$name1&excerpt=$excerpt1&charset=$charset";
286
+		$trackback_url = parse_url($trackback_url);
287
+
288
+		$http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?'
289
+																					  . $trackback_url['query'] : '')
290
+						. " HTTP/1.0\r\n";
291
+		$http_request .= 'Host: ' . $trackback_url['host'] . "\r\n";
292
+		$http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . $charset . "\r\n";
293
+		$http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n";
294
+		$http_request .= 'User-Agent: XOOPS Blogs/' . XOOPS_VERSION;
295
+		$http_request .= "\r\n\r\n";
296
+		$http_request .= $query_string;
297
+		if ('' == $trackback_url['port']) {
298
+			$trackback_url['port'] = 80;
299
+		}
300
+		$fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4);
301
+		@fwrite($fs, $http_request);
302
+		if ($xoopsModuleConfig['do_debug']) {
303
+			$debug_file = XOOPS_CACHE_PATH . '/' . $GLOBALS['moddirname'] . '_trackback.log';
304
+			$fr         = "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n";
305
+			$fr .= "CHARSET:$charset\n";
306
+			$fr .= "NAME:$blog_name\n";
307
+			$fr .= 'TITLE:' . $title . "\n";
308
+			$fr .= "EXCERPT:$excerpt\n\n";
309
+			while (!@feof($fs)) {
310
+				$fr .= @fgets($fs, 4096);
311
+			}
312
+			$fr .= "\n\n";
313
+
314
+			if ($fp = fopen($debug_file, 'a')) {
315
+				fwrite($fp, $fr);
316
+				fclose($fp);
317
+			} else {
318
+			}
319
+		}
320
+		@fclose($fs);
321
+
322
+		return true;
323
+	}
324
+
325
+	/**
326
+	 * Function to ping servers
327
+	 * @param $server
328
+	 * @param $id
329
+	 */
330
+	function planet_ping($server, $id) {
331
+		if (is_array($server)) {
332
+			foreach ($server as $serv) {
333
+				planet_ping($serv, $id);
334
+			}
335
+		}
336
+		include_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/class-IXR.php';
337
+
338
+		// using a timeout of 3 seconds should be enough to cover slow servers
339
+		$client          = new IXR_Client($server, false);
340
+		$client->timeout = 3;
341
+		$client->useragent .= ' -- XOOPS Article/' . XOOPS_VERSION;
342
+
343
+		// when set to true, this outputs debug messages by itself
344
+		$client->debug = false;
345
+
346
+		$blogname = xoops_utf8_encode($GLOBALS['xoopsModule']->getVar('name'));
347
+		$home     = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/';
348
+		$rss2_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php' . URL_DELIMITER . 'rss2.0/' . $id;
349
+
350
+		if (!$client->query('weblogUpdates.extendedPing', $blogname, $home, $rss2_url)) { // then try a normal ping
351
+			$client->query('weblogUpdates.ping', $blogname, $home);
352
+		}
353
+	}
354
+
355
+	/**
356
+	 * Function to respond to a trackback
357
+	 * @param int    $error
358
+	 * @param string $error_message
359
+	 */
360
+	function planet_trackback_response($error = 0, $error_message = '') {
361
+		$charset       = 'utf-8';
362
+		$error_message = xoops_utf8_encode($error_message);
363
+		header('Content-Type: text/xml; charset="' . $charset . '"');
364
+		if ($error) {
365
+			echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n";
366
+			echo "<response>\n";
367
+			echo "<error>1</error>\n";
368
+			echo "<message>$error_message</message>\n";
369
+			echo '</response>';
370
+			die();
371
+		} else {
372
+			echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n";
373
+			echo "<response>\n";
374
+			echo "<error>0</error>\n";
375
+			echo '</response>';
376
+		}
377
+	}
378
+
379
+	/**
380
+	 * Function to set a cookie with module-specified name
381
+	 *
382
+	 * using customized serialization method
383
+	 * @param        $name
384
+	 * @param string $string
385
+	 * @param int    $expire
386
+	 */
387
+	function planet_setcookie($name, $string = '', $expire = 0) {
388
+		if (is_array($string)) {
389
+			$value = array();
390
+			foreach ($string as $key => $val) {
391
+				$value[] = $key . '|' . $val;
392
+			}
393
+			$string = implode(',', $value);
394
+		}
395
+		setcookie($GLOBALS['VAR_PREFIX'] . $name, $string, (int)$expire, '/');
396
+	}
397
+
398
+	/**
399
+	 * @param      $name
400
+	 * @param bool $isArray
401
+	 * @return array|null
402
+	 */
403
+	function planet_getcookie($name, $isArray = false) {
404
+		$value = isset($_COOKIE[$GLOBALS['VAR_PREFIX'] . $name]) ? $_COOKIE[$GLOBALS['VAR_PREFIX'] . $name] : null;
405
+		if ($isArray) {
406
+			$_value = $value ? explode(',', $value) : array();
407
+			$value  = array();
408
+			if (count($_value) > 0) {
409
+				foreach ($_value as $string) {
410
+					$key         = substr($string, 0, strpos($string, '|'));
411
+					$val         = substr($string, strpos($string, '|') + 1);
412
+					$value[$key] = $val;
413
+				}
414
+			}
415
+			unset($_value);
416
+		}
417
+
418
+		return $value;
419
+	}
420
+
421
+	/**
422
+	 * Function to filter text
423
+	 *
424
+	 * @param $document
425
+	 * @return string filtered text
426
+	 */
427
+	function &planet_html2text(&$document) {
428
+		$document = strip_tags($document);
429
+
430
+		return $document;
431
+	}
432
+
433
+	// Adapted from PMA_getIp() [phpmyadmin project]
434
+	/**
435
+	 * @param bool $asString
436
+	 * @return mixed
437
+	 */
438
+	function planet_getIP($asString = false) {
439
+		return mod_getIP($asString);
440
+	}
441
+
442
+	/**
443
+	 * @param $url
444
+	 * @return bool|mixed|string
445
+	 */
446
+	function planet_remote_content($url) {
447
+		if ($data = planet_fetch_snoopy($url)) {
448
+			return $data;
449
+		}
450
+		if ($data = planet_fetch_CURL($url)) {
451
+			return $data;
452
+		}
453
+		if ($data = planet_fetch_fopen($url)) {
454
+			return $data;
455
+		}
456
+
457
+		return false;
458
+	}
459
+
460
+	/**
461
+	 * @param $url
462
+	 * @return string
463
+	 */
464
+	function planet_fetch_snoopy($url) {
465
+		require_once XOOPS_ROOT_PATH . '/class/snoopy.php';
466
+		$snoopy = new Snoopy;
467
+		$data   = '';
468
+		if (@$snoopy->fetch($url)) {
469
+			$data = is_array($snoopy->results) ? implode("\n", $snoopy->results) : $snoopy->results;
470
+		}
471
+
472
+		return $data;
473
+	}
474
+
475
+	/**
476
+	 * @param $url
477
+	 * @return bool|mixed
478
+	 */
479
+	function planet_fetch_CURL($url) {
480
+		if (!function_exists('curl_init')) {
481
+			return false;
482
+		}
483
+		$ch = curl_init();    // initialize curl handle
484
+		curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
485
+		curl_setopt($ch, CURLOPT_FAILONERROR, 1);
486
+		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
487
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
488
+		curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 31s
489
+		$data = curl_exec($ch); // run the whole process
490
+		curl_close($ch);
491
+
492
+		return $data;
493
+	}
494
+
495
+	/**
496
+	 * @param $url
497
+	 * @return bool|string
498
+	 */
499
+	function planet_fetch_fopen($url) {
500
+		if (!$fp = @fopen($url, 'r')) {
501
+			return false;
502
+		}
503
+		$data = '';
504
+		while (!feof($fp)) {
505
+			$data .= fgets($fp, 1024);
506
+		}
507
+		fclose($fp);
508
+
509
+		return $data;
510
+	}
511
+
512
+	/**
513
+	 * @param     $haystack
514
+	 * @param     $needle
515
+	 * @param int $offset
516
+	 * @return bool|int
517
+	 */
518
+	function planet_strrpos($haystack, $needle, $offset = 0) {
519
+		if (substr(phpversion(), 0, 1) == 5) {
520
+			return strrpos($haystack, $needle, $offset);
521
+		}
522
+		$index = strpos(strrev($haystack), strrev($needle));
523
+		if ($index === false) {
524
+			return false;
525
+		}
526
+		$index = strlen($haystack) - strlen($needle) - $index;
527
+
528
+		return $index;
529
+	}
530 530
 endif;
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
 if (!defined('planet_FUNCTIONS')):
38 38
     define('planet_FUNCTIONS', 1);
39 39
 
40
-    require XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/vars.php';
41
-    include_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
42
-    include_once XOOPS_ROOT_PATH . '/Frameworks/art/functions.php';
40
+    require XOOPS_ROOT_PATH.'/modules/'.$GLOBALS['moddirname'].'/include/vars.php';
41
+    include_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
42
+    include_once XOOPS_ROOT_PATH.'/Frameworks/art/functions.php';
43 43
 
44 44
     /**
45 45
      * Function to display messages
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      * - "&" in a string
67 67
     */
68 68
     function planet_parse_args(&$args_numeric, &$args, &$args_string) {
69
-        $args_abb     = array(
69
+        $args_abb = array(
70 70
             'a' => 'article',
71 71
             'b' => 'blog',
72 72
             'c' => 'category',
@@ -81,24 +81,24 @@  discard block
 block discarded – undo
81 81
         if (preg_match("/[^\?]*\.php[\/|\?]([^\?]*)/i", $_SERVER['REQUEST_URI'], $matches)) {
82 82
             $vars = preg_split("/[\/|&]/", $matches[1]);
83 83
             $vars = array_map('trim', $vars);
84
-            if (count($vars) > 0) {
84
+            if (count($vars)>0) {
85 85
                 foreach ($vars as $var) {
86 86
                     if (is_numeric($var)) {
87 87
                         $args_numeric[] = $var;
88 88
                     } elseif (false === strpos($var, '=')) {
89 89
                         if (is_numeric(substr($var, 1))) {
90
-                            $args[$args_abb[strtolower($var{0})]] = (int)substr($var, 1);
91
-                        } else {
90
+                            $args[$args_abb[strtolower($var{0})]] = (int) substr($var, 1);
91
+                        }else {
92 92
                             $args_string[] = urldecode($var);
93 93
                         }
94
-                    } else {
94
+                    }else {
95 95
                         parse_str($var, $args);
96 96
                     }
97 97
                 }
98 98
             }
99 99
         }
100 100
 
101
-        return (count($args) + count($args_numeric) + count($args_string) == 0) ? null : true;
101
+        return (count($args)+count($args_numeric)+count($args_string) == 0) ? null : true;
102 102
     }
103 103
 
104 104
     /**
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
             $pattern     = array($pattern);
121 121
             $replacement = array($replacement);
122 122
         }
123
-        if (is_array($pattern) && count($pattern) > 0) {
123
+        if (is_array($pattern) && count($pattern)>0) {
124 124
             $ii = 0;
125 125
             foreach ($pattern as $pat) {
126 126
                 if (!in_array($pat, $patterns)) {
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
             $pattern     = array($pattern);
156 156
             $replacement = array($replacement);
157 157
         }
158
-        if (is_array($pattern) && count($pattern) > 0) {
158
+        if (is_array($pattern) && count($pattern)>0) {
159 159
             $ii = 0;
160 160
             foreach ($pattern as $pat) {
161 161
                 if (!in_array($pat, $patterns)) {
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         if (!is_array($userid)) {
197 197
             $userid = array($userid);
198 198
         }
199
-        $users =& mod_getUnameFromIds($userid, $usereal, $linked);
199
+        $users = & mod_getUnameFromIds($userid, $usereal, $linked);
200 200
 
201 201
         return $users;
202 202
     }
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         $myts       = MyTextSanitizer::getInstance();
213 213
         $link_array = preg_split("/(\r\n|\r|\n)( *)/", $text);
214 214
         $links      = array();
215
-        if (count($link_array) > 0) {
215
+        if (count($link_array)>0) {
216 216
             foreach ($link_array as $link) {
217 217
                 @list($url, $title) = array_map('trim', preg_split('/ /', $link, 2));
218 218
                 if (empty($url)) {
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      * @return string
232 232
      */
233 233
     function planet_getTemplate($pagename) {
234
-        return $GLOBALS['VAR_PREFIX'] . '_' . $pagename . '.tpl';
234
+        return $GLOBALS['VAR_PREFIX'].'_'.$pagename.'.tpl';
235 235
     }
236 236
 
237 237
     /**
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
             return false;
258 258
         }
259 259
         @list($pat, $rep) = array_map('trim', preg_split("#[\s]+#", $pattern));
260
-        $trackback_url = preg_replace('#' . $pat . '#', $rep, $article_obj->getVar('art_link'));
260
+        $trackback_url = preg_replace('#'.$pat.'#', $rep, $article_obj->getVar('art_link'));
261 261
 
262 262
         return planet_trackback($trackback_url, $article);
263 263
     }
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 
273 273
         $title         = $article->getVar('art_title');
274 274
         $excerpt       = $article->getVar('art_content');
275
-        $blog_name     = $xoopsConfig['sitename'] . '-' . $xoopsModule->getVar('name');
275
+        $blog_name     = $xoopsConfig['sitename'].'-'.$xoopsModule->getVar('name');
276 276
         $title         = xoops_utf8_encode($title);
277 277
         $excerpt       = xoops_utf8_encode($excerpt);
278 278
         $blog_name     = xoops_utf8_encode($blog_name);
@@ -280,18 +280,18 @@  discard block
 block discarded – undo
280 280
         $title1        = urlencode($title);
281 281
         $excerpt1      = urlencode($excerpt);
282 282
         $name1         = urlencode($blog_name);
283
-        $url           = urlencode(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php'
284
-                                   . URL_DELIMITER . '' . $article->getVar('art_id'));
283
+        $url           = urlencode(XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.article.php'
284
+                                   . URL_DELIMITER.''.$article->getVar('art_id'));
285 285
         $query_string  = "title=$title1&url=$url&blog_name=$name1&excerpt=$excerpt1&charset=$charset";
286 286
         $trackback_url = parse_url($trackback_url);
287 287
 
288
-        $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?'
288
+        $http_request = 'POST '.$trackback_url['path'].($trackback_url['query'] ? '?'
289 289
                                                                                       . $trackback_url['query'] : '')
290 290
                         . " HTTP/1.0\r\n";
291
-        $http_request .= 'Host: ' . $trackback_url['host'] . "\r\n";
292
-        $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . $charset . "\r\n";
293
-        $http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n";
294
-        $http_request .= 'User-Agent: XOOPS Blogs/' . XOOPS_VERSION;
291
+        $http_request .= 'Host: '.$trackback_url['host']."\r\n";
292
+        $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.$charset."\r\n";
293
+        $http_request .= 'Content-Length: '.strlen($query_string)."\r\n";
294
+        $http_request .= 'User-Agent: XOOPS Blogs/'.XOOPS_VERSION;
295 295
         $http_request .= "\r\n\r\n";
296 296
         $http_request .= $query_string;
297 297
         if ('' == $trackback_url['port']) {
@@ -300,11 +300,11 @@  discard block
 block discarded – undo
300 300
         $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4);
301 301
         @fwrite($fs, $http_request);
302 302
         if ($xoopsModuleConfig['do_debug']) {
303
-            $debug_file = XOOPS_CACHE_PATH . '/' . $GLOBALS['moddirname'] . '_trackback.log';
303
+            $debug_file = XOOPS_CACHE_PATH.'/'.$GLOBALS['moddirname'].'_trackback.log';
304 304
             $fr         = "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n";
305 305
             $fr .= "CHARSET:$charset\n";
306 306
             $fr .= "NAME:$blog_name\n";
307
-            $fr .= 'TITLE:' . $title . "\n";
307
+            $fr .= 'TITLE:'.$title."\n";
308 308
             $fr .= "EXCERPT:$excerpt\n\n";
309 309
             while (!@feof($fs)) {
310 310
                 $fr .= @fgets($fs, 4096);
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
             if ($fp = fopen($debug_file, 'a')) {
315 315
                 fwrite($fp, $fr);
316 316
                 fclose($fp);
317
-            } else {
317
+            }else {
318 318
             }
319 319
         }
320 320
         @fclose($fs);
@@ -333,19 +333,19 @@  discard block
 block discarded – undo
333 333
                 planet_ping($serv, $id);
334 334
             }
335 335
         }
336
-        include_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/class-IXR.php';
336
+        include_once XOOPS_ROOT_PATH.'/modules/'.$GLOBALS['moddirname'].'/class-IXR.php';
337 337
 
338 338
         // using a timeout of 3 seconds should be enough to cover slow servers
339 339
         $client          = new IXR_Client($server, false);
340 340
         $client->timeout = 3;
341
-        $client->useragent .= ' -- XOOPS Article/' . XOOPS_VERSION;
341
+        $client->useragent .= ' -- XOOPS Article/'.XOOPS_VERSION;
342 342
 
343 343
         // when set to true, this outputs debug messages by itself
344 344
         $client->debug = false;
345 345
 
346 346
         $blogname = xoops_utf8_encode($GLOBALS['xoopsModule']->getVar('name'));
347
-        $home     = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/';
348
-        $rss2_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php' . URL_DELIMITER . 'rss2.0/' . $id;
347
+        $home     = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/';
348
+        $rss2_url = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/xml.php'.URL_DELIMITER.'rss2.0/'.$id;
349 349
 
350 350
         if (!$client->query('weblogUpdates.extendedPing', $blogname, $home, $rss2_url)) { // then try a normal ping
351 351
             $client->query('weblogUpdates.ping', $blogname, $home);
@@ -360,16 +360,16 @@  discard block
 block discarded – undo
360 360
     function planet_trackback_response($error = 0, $error_message = '') {
361 361
         $charset       = 'utf-8';
362 362
         $error_message = xoops_utf8_encode($error_message);
363
-        header('Content-Type: text/xml; charset="' . $charset . '"');
363
+        header('Content-Type: text/xml; charset="'.$charset.'"');
364 364
         if ($error) {
365
-            echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n";
365
+            echo '<?xml version="1.0" encoding="'.$charset.'"?'.">\n";
366 366
             echo "<response>\n";
367 367
             echo "<error>1</error>\n";
368 368
             echo "<message>$error_message</message>\n";
369 369
             echo '</response>';
370 370
             die();
371
-        } else {
372
-            echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n";
371
+        }else {
372
+            echo '<?xml version="1.0" encoding="'.$charset.'"?'.">\n";
373 373
             echo "<response>\n";
374 374
             echo "<error>0</error>\n";
375 375
             echo '</response>';
@@ -388,11 +388,11 @@  discard block
 block discarded – undo
388 388
         if (is_array($string)) {
389 389
             $value = array();
390 390
             foreach ($string as $key => $val) {
391
-                $value[] = $key . '|' . $val;
391
+                $value[] = $key.'|'.$val;
392 392
             }
393 393
             $string = implode(',', $value);
394 394
         }
395
-        setcookie($GLOBALS['VAR_PREFIX'] . $name, $string, (int)$expire, '/');
395
+        setcookie($GLOBALS['VAR_PREFIX'].$name, $string, (int) $expire, '/');
396 396
     }
397 397
 
398 398
     /**
@@ -401,14 +401,14 @@  discard block
 block discarded – undo
401 401
      * @return array|null
402 402
      */
403 403
     function planet_getcookie($name, $isArray = false) {
404
-        $value = isset($_COOKIE[$GLOBALS['VAR_PREFIX'] . $name]) ? $_COOKIE[$GLOBALS['VAR_PREFIX'] . $name] : null;
404
+        $value = isset($_COOKIE[$GLOBALS['VAR_PREFIX'].$name]) ? $_COOKIE[$GLOBALS['VAR_PREFIX'].$name] : null;
405 405
         if ($isArray) {
406 406
             $_value = $value ? explode(',', $value) : array();
407 407
             $value  = array();
408
-            if (count($_value) > 0) {
408
+            if (count($_value)>0) {
409 409
                 foreach ($_value as $string) {
410 410
                     $key         = substr($string, 0, strpos($string, '|'));
411
-                    $val         = substr($string, strpos($string, '|') + 1);
411
+                    $val         = substr($string, strpos($string, '|')+1);
412 412
                     $value[$key] = $val;
413 413
                 }
414 414
             }
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
      * @return string
463 463
      */
464 464
     function planet_fetch_snoopy($url) {
465
-        require_once XOOPS_ROOT_PATH . '/class/snoopy.php';
465
+        require_once XOOPS_ROOT_PATH.'/class/snoopy.php';
466 466
         $snoopy = new Snoopy;
467 467
         $data   = '';
468 468
         if (@$snoopy->fetch($url)) {
@@ -480,10 +480,10 @@  discard block
 block discarded – undo
480 480
         if (!function_exists('curl_init')) {
481 481
             return false;
482 482
         }
483
-        $ch = curl_init();    // initialize curl handle
483
+        $ch = curl_init(); // initialize curl handle
484 484
         curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
485 485
         curl_setopt($ch, CURLOPT_FAILONERROR, 1);
486
-        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
486
+        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // allow redirects
487 487
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
488 488
         curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 31s
489 489
         $data = curl_exec($ch); // run the whole process
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
         if ($index === false) {
524 524
             return false;
525 525
         }
526
-        $index = strlen($haystack) - strlen($needle) - $index;
526
+        $index = strlen($haystack)-strlen($needle)-$index;
527 527
 
528 528
         return $index;
529 529
     }
Please login to merge, or discard this patch.
view.archive.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -293,7 +293,7 @@
 block discarded – undo
293 293
 // Used in get_calendar
294 294
 /**
295 295
  * @param $num
296
- * @return mixed
296
+ * @return double
297 297
  */
298 298
 function planet_calendar_week_mod($num) {
299 299
     $base = 7;
Please login to merge, or discard this patch.
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
 include __DIR__ . '/header.php';
28 28
 
29 29
 if (planet_parse_args($args_num, $args, $args_str)) {
30
-    $args['year']  = @$args_num[0];
31
-    $args['month'] = @$args_num[1];
32
-    $args['day']   = @$args_num[2];
30
+	$args['year']  = @$args_num[0];
31
+	$args['month'] = @$args_num[1];
32
+	$args['day']   = @$args_num[2];
33 33
 }
34 34
 
35 35
 $day     = (int)(empty($_GET['day']) ? @$args['day'] : $_GET['day']);
@@ -50,31 +50,31 @@  discard block
 block discarded – undo
50 50
 
51 51
 $year = empty($year) ? date('Y') : $year;
52 52
 if ($month < 1) {
53
-    $month        = $day = 0;
54
-    $page['time'] = sprintf(planet_constant('MD_TIME_Y'), $year);
53
+	$month        = $day = 0;
54
+	$page['time'] = sprintf(planet_constant('MD_TIME_Y'), $year);
55 55
 } elseif ($day < 1) {
56
-    $day          = 0;
57
-    $page['time'] = sprintf(planet_constant('MD_TIME_YM'), $year, $month);
56
+	$day          = 0;
57
+	$page['time'] = sprintf(planet_constant('MD_TIME_YM'), $year, $month);
58 58
 } else {
59
-    $page['time'] = sprintf(planet_constant('MD_TIME_YMD'), $year, $month, $day);
59
+	$page['time'] = sprintf(planet_constant('MD_TIME_YMD'), $year, $month, $day);
60 60
 }
61 61
 $time = array('year' => $year, 'month' => $month, 'day' => $day);
62 62
 if ($xoopsUser) {
63
-    $timeoffset = ($xoopsUser->getVar('timezone_offset') - $xoopsConfig['server_TZ']) * 3600;
63
+	$timeoffset = ($xoopsUser->getVar('timezone_offset') - $xoopsConfig['server_TZ']) * 3600;
64 64
 } else {
65
-    $timeoffset = ($xoopsConfig['default_TZ'] - $xoopsConfig['server_TZ']) * 3600;
65
+	$timeoffset = ($xoopsConfig['default_TZ'] - $xoopsConfig['server_TZ']) * 3600;
66 66
 }
67 67
 
68 68
 $criteria = new CriteriaCompo();
69 69
 if ($blog_id) {
70
-    $criteria->add(new Criteria('blog_id', $blog_id));
70
+	$criteria->add(new Criteria('blog_id', $blog_id));
71 71
 }
72 72
 $criteria->add(new Criteria("YEAR(FROM_UNIXTIME(art_time_publish - $timeoffset))", $year));
73 73
 if ($month) {
74
-    $criteria->add(new Criteria("MONTH(FROM_UNIXTIME(art_time_publish - $timeoffset))", $month));
75
-    if ($day) {
76
-        $criteria->add(new Criteria("DAY(FROM_UNIXTIME(art_time_publish - $timeoffset))", $day));
77
-    }
74
+	$criteria->add(new Criteria("MONTH(FROM_UNIXTIME(art_time_publish - $timeoffset))", $month));
75
+	if ($day) {
76
+		$criteria->add(new Criteria("DAY(FROM_UNIXTIME(art_time_publish - $timeoffset))", $day));
77
+	}
78 78
 }
79 79
 $criteria->setStart($start);
80 80
 $criteria->setLimit($xoopsModuleConfig['articles_perpage']);
@@ -85,123 +85,123 @@  discard block
 block discarded – undo
85 85
 $articles = array();
86 86
 $blogs_id = array();
87 87
 foreach ($articles_obj as $id => $article) {
88
-    $articles[]                            = array(
89
-        'id'      => $id,
90
-        'blog'    => array('id' => $article->getVar('blog_id'), 'title' => ''),
91
-        'title'   => $article->getVar('art_title'),
92
-        'time'    => $article->getTime(),
93
-        'content' => $article->getVar('art_content')
94
-    );
95
-    $articles[]                            = $_article;
96
-    $blogs_id[$article->getVar('blog_id')] = 1;
97
-    unset($_article);
88
+	$articles[]                            = array(
89
+		'id'      => $id,
90
+		'blog'    => array('id' => $article->getVar('blog_id'), 'title' => ''),
91
+		'title'   => $article->getVar('art_title'),
92
+		'time'    => $article->getTime(),
93
+		'content' => $article->getVar('art_content')
94
+	);
95
+	$articles[]                            = $_article;
96
+	$blogs_id[$article->getVar('blog_id')] = 1;
97
+	unset($_article);
98 98
 }
99 99
 $criteria_blog = new Criteria('blog_id', '(' . implode(',', array_keys($blog_array)) . ')', 'IN');
100 100
 $blogs         = $blog_handler->getList($criteria_blog);
101 101
 foreach (array_keys($articles) as $key) {
102
-    $articles[$key]['blog']['title'] = $blogs[$articles[$key]['blog']['id']];
102
+	$articles[$key]['blog']['title'] = $blogs[$articles[$key]['blog']['id']];
103 103
 }
104 104
 if ($blog_id > 0) {
105
-    $page['blog'] = $blogs[$blog_id];;
105
+	$page['blog'] = $blogs[$blog_id];;
106 106
 }
107 107
 
108 108
 if ($articles_count > $xoopsModuleConfig['articles_perpage']) {
109
-    include XOOPS_ROOT_PATH . '/class/pagenav.php';
110
-    $nav     = new XoopsPageNav($articles_count, $xoopsModuleConfig['articles_perpage'], $start, 'start',
111
-                                'month=' . $month . '&amp;day=' . $day . '&amp;year=' . $year . '&amp;blog='
112
-                                . (int)$blog_id);
113
-    $pagenav = $nav->renderNav(4);
109
+	include XOOPS_ROOT_PATH . '/class/pagenav.php';
110
+	$nav     = new XoopsPageNav($articles_count, $xoopsModuleConfig['articles_perpage'], $start, 'start',
111
+								'month=' . $month . '&amp;day=' . $day . '&amp;year=' . $year . '&amp;blog='
112
+								. (int)$blog_id);
113
+	$pagenav = $nav->renderNav(4);
114 114
 } else {
115
-    $pagenav = '';
115
+	$pagenav = '';
116 116
 }
117 117
 
118 118
 $timenav  = null;
119 119
 $calendar = null;
120 120
 $months   = null;
121 121
 if (empty($start)) {
122
-    if ($blog_id) {
123
-        $blog_criteria = ' AND blog_id=' . $blog_id;
124
-    } else {
125
-        $blog_criteria = '';
126
-    }
127
-    // Get monthly list
128
-    if (empty($month)) {
129
-        $sql    = "SELECT MONTH(FROM_UNIXTIME(art_time - $timeoffset)) AS mon, COUNT(DISTINCT art_id) AS count
122
+	if ($blog_id) {
123
+		$blog_criteria = ' AND blog_id=' . $blog_id;
124
+	} else {
125
+		$blog_criteria = '';
126
+	}
127
+	// Get monthly list
128
+	if (empty($month)) {
129
+		$sql    = "SELECT MONTH(FROM_UNIXTIME(art_time - $timeoffset)) AS mon, COUNT(DISTINCT art_id) AS count
130 130
             FROM " . planet_DB_prefix('article') . "
131 131
             WHERE YEAR(FROM_UNIXTIME(art_time - $timeoffset)) = $year
132 132
             " . $blog_criteria . '
133 133
             GROUP BY mon
134 134
             ';
135
-        $result = $xoopsDB->query($sql);
136
-        $months = array();
137
-        while ($myrow = $xoopsDB->fetchArray($result)) {
138
-            $months[] = array(
139
-                'title' => planet_constant('MD_MONTH_' . (int)$myrow['mon']) . ' (' . (int)$myrow['count'] . ')',
140
-                'url'   => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . ''
141
-                           . $year . '/' . $myrow['mon'] . '/b' . $blog_id
142
-            );
143
-        }
144
-        $timenav['prev'] = array(
145
-            'url'   => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . ''
146
-                       . ($year - 1) . '/b' . $blog_id,
147
-            'title' => sprintf(planet_constant('MD_TIME_Y'), $year - 1)
148
-        );
149
-        if ($year < date('Y')) {
150
-            $timenav['next'] = array(
151
-                'url'   => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . ''
152
-                           . ($year + 1) . '/b' . $blog_id,
153
-                'title' => sprintf(planet_constant('MD_TIME_Y'), $year + 1)
154
-            );
155
-        }
156
-    } // Get daily list
157
-    elseif (empty($day)) {
158
-        $sql    = "SELECT DAY(FROM_UNIXTIME(art_time - $timeoffset)) AS day, COUNT(DISTINCT a.art_id) AS count
135
+		$result = $xoopsDB->query($sql);
136
+		$months = array();
137
+		while ($myrow = $xoopsDB->fetchArray($result)) {
138
+			$months[] = array(
139
+				'title' => planet_constant('MD_MONTH_' . (int)$myrow['mon']) . ' (' . (int)$myrow['count'] . ')',
140
+				'url'   => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . ''
141
+						   . $year . '/' . $myrow['mon'] . '/b' . $blog_id
142
+			);
143
+		}
144
+		$timenav['prev'] = array(
145
+			'url'   => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . ''
146
+					   . ($year - 1) . '/b' . $blog_id,
147
+			'title' => sprintf(planet_constant('MD_TIME_Y'), $year - 1)
148
+		);
149
+		if ($year < date('Y')) {
150
+			$timenav['next'] = array(
151
+				'url'   => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . ''
152
+						   . ($year + 1) . '/b' . $blog_id,
153
+				'title' => sprintf(planet_constant('MD_TIME_Y'), $year + 1)
154
+			);
155
+		}
156
+	} // Get daily list
157
+	elseif (empty($day)) {
158
+		$sql    = "SELECT DAY(FROM_UNIXTIME(art_time - $timeoffset)) AS day, COUNT(DISTINCT a.art_id) AS count
159 159
             FROM " . planet_DB_prefix('article') . "
160 160
             WHERE YEAR(FROM_UNIXTIME(art_time - $timeoffset)) = $year
161 161
             AND MONTH(FROM_UNIXTIME(art_time - $timeoffset)) = $month
162 162
             " . $blog_criteria . '
163 163
             GROUP BY day
164 164
             ';
165
-        $result = $xoopsDB->query($sql);
166
-        $days   = array();
167
-        while ($myrow = $xoopsDB->fetchArray($result)) {
168
-            $days[$myrow['day']]['count'] = $myrow['count'];
169
-        }
170
-        for ($i = 1; $i <= 31; ++$i) {
171
-            if (!isset($days[$i])) {
172
-                continue;
173
-            }
174
-            $days[$i] = array(
175
-                'title' => $days[$i]['count'],
176
-                'url'   => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . ''
177
-                           . $year . '/' . $month . '/' . $i . '/b' . $blog_id
178
-            );
179
-        }
180
-        $calendar   = planet_getCalendar($year, $month, $days);
181
-        $month_next = $month + 1;
182
-        $month_prev = $month - 1;
183
-        $_year      = $year;
184
-        if ($month == 12) {
185
-            $month_next = 1;
186
-            $_year      = $year + 1;
187
-        }
188
-        if ($month == 1) {
189
-            $month_pre = 12;
190
-            $_year     = $year - 1;
191
-        }
192
-        $timenav['prev'] = array(
193
-            'url'   => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . ''
194
-                       . $_year . '/' . $month_prev . '/b' . $blog_id,
195
-            'title' => planet_constant('MD_MONTH_' . $month_prev)
196
-        );
197
-        if ($year < date('Y') || $month < date('n')) {
198
-            $timenav['next'] = array(
199
-                'url'   => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . ''
200
-                           . $_year . '/' . $month_next . '/b' . $blog_id,
201
-                'title' => planet_constant('MD_MONTH_' . $month_next)
202
-            );
203
-        }
204
-    }
165
+		$result = $xoopsDB->query($sql);
166
+		$days   = array();
167
+		while ($myrow = $xoopsDB->fetchArray($result)) {
168
+			$days[$myrow['day']]['count'] = $myrow['count'];
169
+		}
170
+		for ($i = 1; $i <= 31; ++$i) {
171
+			if (!isset($days[$i])) {
172
+				continue;
173
+			}
174
+			$days[$i] = array(
175
+				'title' => $days[$i]['count'],
176
+				'url'   => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . ''
177
+						   . $year . '/' . $month . '/' . $i . '/b' . $blog_id
178
+			);
179
+		}
180
+		$calendar   = planet_getCalendar($year, $month, $days);
181
+		$month_next = $month + 1;
182
+		$month_prev = $month - 1;
183
+		$_year      = $year;
184
+		if ($month == 12) {
185
+			$month_next = 1;
186
+			$_year      = $year + 1;
187
+		}
188
+		if ($month == 1) {
189
+			$month_pre = 12;
190
+			$_year     = $year - 1;
191
+		}
192
+		$timenav['prev'] = array(
193
+			'url'   => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . ''
194
+					   . $_year . '/' . $month_prev . '/b' . $blog_id,
195
+			'title' => planet_constant('MD_MONTH_' . $month_prev)
196
+		);
197
+		if ($year < date('Y') || $month < date('n')) {
198
+			$timenav['next'] = array(
199
+				'url'   => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . ''
200
+						   . $_year . '/' . $month_next . '/b' . $blog_id,
201
+				'title' => planet_constant('MD_MONTH_' . $month_next)
202
+			);
203
+		}
204
+	}
205 205
 }
206 206
 
207 207
 $xoopsTpl->assign('dirname', $GLOBALS['moddirname']);
@@ -227,67 +227,67 @@  discard block
 block discarded – undo
227 227
  * @return string
228 228
  */
229 229
 function planet_getCalendar($year = null, $month = null, $days = null) {
230
-    $year      = empty($year) ? date('Y') : $year;
231
-    $month     = empty($month) ? date('n') : $month;
232
-    $unixmonth = mktime(0, 0, 0, $month, 1, $year);
230
+	$year      = empty($year) ? date('Y') : $year;
231
+	$month     = empty($month) ? date('n') : $month;
232
+	$unixmonth = mktime(0, 0, 0, $month, 1, $year);
233 233
 
234
-    ob_start();
235
-    echo '<table id="calendar">';
236
-    echo '<caption>';
237
-    printf(planet_constant('MD_TIME_YM'), $year, planet_constant('MD_MONTH_' . $month));
238
-    echo '</caption>';
234
+	ob_start();
235
+	echo '<table id="calendar">';
236
+	echo '<caption>';
237
+	printf(planet_constant('MD_TIME_YM'), $year, planet_constant('MD_MONTH_' . $month));
238
+	echo '</caption>';
239 239
 
240
-    for ($i = 1; $i <= 7; ++$i) {
241
-        echo "\n\t\t<th abbr=\"" . planet_constant('MD_WEEK_' . $i) . "\" scope=\"col\" title=\""
242
-             . planet_constant('MD_WEEK_' . $i) . "\">" . planet_constant('MD_WEEK_' . $i) . '</th>';
243
-    }
240
+	for ($i = 1; $i <= 7; ++$i) {
241
+		echo "\n\t\t<th abbr=\"" . planet_constant('MD_WEEK_' . $i) . "\" scope=\"col\" title=\""
242
+			 . planet_constant('MD_WEEK_' . $i) . "\">" . planet_constant('MD_WEEK_' . $i) . '</th>';
243
+	}
244 244
 
245
-    echo '<tr>';
245
+	echo '<tr>';
246 246
 
247
-    // See how much we should pad in the beginning
248
-    $week_begins = 1;
249
-    $pad         = planet_calendar_week_mod(date('w', $unixmonth) - $week_begins);
250
-    if (0 != $pad) {
251
-        echo "\n\t\t" . '<td colspan="' . $pad . '">&nbsp;</td>';
252
-    }
247
+	// See how much we should pad in the beginning
248
+	$week_begins = 1;
249
+	$pad         = planet_calendar_week_mod(date('w', $unixmonth) - $week_begins);
250
+	if (0 != $pad) {
251
+		echo "\n\t\t" . '<td colspan="' . $pad . '">&nbsp;</td>';
252
+	}
253 253
 
254
-    $daysinmonth = (int)date('t', $unixmonth);
255
-    for ($day = 1; $day <= $daysinmonth; ++$day) {
256
-        if (isset($newrow) && $newrow) {
257
-            echo "\n\t</tr>\n\t<tr>\n\t\t";
258
-        }
259
-        $newrow = false;
254
+	$daysinmonth = (int)date('t', $unixmonth);
255
+	for ($day = 1; $day <= $daysinmonth; ++$day) {
256
+		if (isset($newrow) && $newrow) {
257
+			echo "\n\t</tr>\n\t<tr>\n\t\t";
258
+		}
259
+		$newrow = false;
260 260
 
261
-        echo '<td>';
261
+		echo '<td>';
262 262
 
263
-        if (!empty($days[$day]['url'])) {
264
-            echo '<a href="' . $days[$day]['url'] . "\"";
265
-            if (!empty($days[$day]['title'])) {
266
-                echo "title=\"" . $days[$day]['title'] . "\"";
267
-            }
268
-            echo ">$day</a>";
269
-        } elseif (!empty($days[$day]['title'])) {
270
-            echo "<acronym title=\"" . $days[$day]['title'] . "\">$day</acronym>";
271
-        } else {
272
-            echo $day;
273
-        }
274
-        echo '</td>';
263
+		if (!empty($days[$day]['url'])) {
264
+			echo '<a href="' . $days[$day]['url'] . "\"";
265
+			if (!empty($days[$day]['title'])) {
266
+				echo "title=\"" . $days[$day]['title'] . "\"";
267
+			}
268
+			echo ">$day</a>";
269
+		} elseif (!empty($days[$day]['title'])) {
270
+			echo "<acronym title=\"" . $days[$day]['title'] . "\">$day</acronym>";
271
+		} else {
272
+			echo $day;
273
+		}
274
+		echo '</td>';
275 275
 
276
-        if (6 == planet_calendar_week_mod(date('w', mktime(0, 0, 0, $month, $day, $year)) - $week_begins)) {
277
-            $newrow = true;
278
-        }
279
-    }
276
+		if (6 == planet_calendar_week_mod(date('w', mktime(0, 0, 0, $month, $day, $year)) - $week_begins)) {
277
+			$newrow = true;
278
+		}
279
+	}
280 280
 
281
-    $pad = 7 - planet_calendar_week_mod(date('w', mktime(0, 0, 0, $month, $day, $year)) - $week_begins);
282
-    if ($pad != 0 && $pad != 7) {
283
-        echo "\n\t\t" . '<td class="pad" colspan="' . $pad . '">&nbsp;</td>';
284
-    }
281
+	$pad = 7 - planet_calendar_week_mod(date('w', mktime(0, 0, 0, $month, $day, $year)) - $week_begins);
282
+	if ($pad != 0 && $pad != 7) {
283
+		echo "\n\t\t" . '<td class="pad" colspan="' . $pad . '">&nbsp;</td>';
284
+	}
285 285
 
286
-    echo "\n\t</tr>\n\t</tbody>\n\t</table>";
287
-    $calendar = ob_get_contents();
288
-    ob_end_clean();
286
+	echo "\n\t</tr>\n\t</tbody>\n\t</table>";
287
+	$calendar = ob_get_contents();
288
+	ob_end_clean();
289 289
 
290
-    return $calendar;
290
+	return $calendar;
291 291
 }
292 292
 
293 293
 // Used in get_calendar
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
  * @return mixed
297 297
  */
298 298
 function planet_calendar_week_mod($num) {
299
-    $base = 7;
299
+	$base = 7;
300 300
 
301
-    return ($num - $base * floor($num / $base));
301
+	return ($num - $base * floor($num / $base));
302 302
 }
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 // URL: http://xoops.org                         //
25 25
 // Project: Article Project                                                 //
26 26
 // ------------------------------------------------------------------------ //
27
-include __DIR__ . '/header.php';
27
+include __DIR__.'/header.php';
28 28
 
29 29
 if (planet_parse_args($args_num, $args, $args_str)) {
30 30
     $args['year']  = @$args_num[0];
@@ -32,37 +32,37 @@  discard block
 block discarded – undo
32 32
     $args['day']   = @$args_num[2];
33 33
 }
34 34
 
35
-$day     = (int)(empty($_GET['day']) ? @$args['day'] : $_GET['day']);
36
-$year    = (int)(empty($_GET['year']) ? @$args['year'] : $_GET['year']);
37
-$month   = (int)(empty($_GET['month']) ? @$args['month'] : $_GET['month']);
38
-$blog_id = (int)(empty($_GET['blog']) ? @$args['blog'] : $_GET['blog']);
39
-$start   = (int)(empty($_GET['start']) ? @$args['start'] : $_GET['start']);
35
+$day     = (int) (empty($_GET['day']) ? @$args['day'] : $_GET['day']);
36
+$year    = (int) (empty($_GET['year']) ? @$args['year'] : $_GET['year']);
37
+$month   = (int) (empty($_GET['month']) ? @$args['month'] : $_GET['month']);
38
+$blog_id = (int) (empty($_GET['blog']) ? @$args['blog'] : $_GET['blog']);
39
+$start   = (int) (empty($_GET['start']) ? @$args['start'] : $_GET['start']);
40 40
 
41 41
 $page['title'] = planet_constant('MD_ACHIVE');
42 42
 
43 43
 $article_handler = xoops_getModuleHandler('article', $GLOBALS['moddirname']);
44 44
 $blog_handler    = xoops_getModuleHandler('blog', $GLOBALS['moddirname']);
45 45
 
46
-$xoopsOption['xoops_pagetitle'] = $xoopsModule->getVar('name') . ' - ' . planet_constant('MD_ACHIVE');
46
+$xoopsOption['xoops_pagetitle'] = $xoopsModule->getVar('name').' - '.planet_constant('MD_ACHIVE');
47 47
 $xoopsOption['template_main']   = planet_getTemplate('archive');
48
-include_once XOOPS_ROOT_PATH . '/header.php';
49
-include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php';
48
+include_once XOOPS_ROOT_PATH.'/header.php';
49
+include XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/include/vars.php';
50 50
 
51 51
 $year = empty($year) ? date('Y') : $year;
52
-if ($month < 1) {
52
+if ($month<1) {
53 53
     $month        = $day = 0;
54 54
     $page['time'] = sprintf(planet_constant('MD_TIME_Y'), $year);
55
-} elseif ($day < 1) {
55
+} elseif ($day<1) {
56 56
     $day          = 0;
57 57
     $page['time'] = sprintf(planet_constant('MD_TIME_YM'), $year, $month);
58
-} else {
58
+}else {
59 59
     $page['time'] = sprintf(planet_constant('MD_TIME_YMD'), $year, $month, $day);
60 60
 }
61 61
 $time = array('year' => $year, 'month' => $month, 'day' => $day);
62 62
 if ($xoopsUser) {
63
-    $timeoffset = ($xoopsUser->getVar('timezone_offset') - $xoopsConfig['server_TZ']) * 3600;
64
-} else {
65
-    $timeoffset = ($xoopsConfig['default_TZ'] - $xoopsConfig['server_TZ']) * 3600;
63
+    $timeoffset = ($xoopsUser->getVar('timezone_offset')-$xoopsConfig['server_TZ'])*3600;
64
+}else {
65
+    $timeoffset = ($xoopsConfig['default_TZ']-$xoopsConfig['server_TZ'])*3600;
66 66
 }
67 67
 
68 68
 $criteria = new CriteriaCompo();
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
 $criteria->setStart($start);
80 80
 $criteria->setLimit($xoopsModuleConfig['articles_perpage']);
81 81
 
82
-$articles_obj   =& $article_handler->getAll($criteria, array('uid', 'art_title', 'art_time', 'blog_id', 'art_content'));
82
+$articles_obj   = & $article_handler->getAll($criteria, array('uid', 'art_title', 'art_time', 'blog_id', 'art_content'));
83 83
 $articles_count = $article_handler->getCount($criteria);
84 84
 
85 85
 $articles = array();
86 86
 $blogs_id = array();
87 87
 foreach ($articles_obj as $id => $article) {
88
-    $articles[]                            = array(
88
+    $articles[] = array(
89 89
         'id'      => $id,
90 90
         'blog'    => array('id' => $article->getVar('blog_id'), 'title' => ''),
91 91
         'title'   => $article->getVar('art_title'),
@@ -96,22 +96,22 @@  discard block
 block discarded – undo
96 96
     $blogs_id[$article->getVar('blog_id')] = 1;
97 97
     unset($_article);
98 98
 }
99
-$criteria_blog = new Criteria('blog_id', '(' . implode(',', array_keys($blog_array)) . ')', 'IN');
99
+$criteria_blog = new Criteria('blog_id', '('.implode(',', array_keys($blog_array)).')', 'IN');
100 100
 $blogs         = $blog_handler->getList($criteria_blog);
101 101
 foreach (array_keys($articles) as $key) {
102 102
     $articles[$key]['blog']['title'] = $blogs[$articles[$key]['blog']['id']];
103 103
 }
104
-if ($blog_id > 0) {
105
-    $page['blog'] = $blogs[$blog_id];;
104
+if ($blog_id>0) {
105
+    $page['blog'] = $blogs[$blog_id]; ;
106 106
 }
107 107
 
108
-if ($articles_count > $xoopsModuleConfig['articles_perpage']) {
109
-    include XOOPS_ROOT_PATH . '/class/pagenav.php';
108
+if ($articles_count>$xoopsModuleConfig['articles_perpage']) {
109
+    include XOOPS_ROOT_PATH.'/class/pagenav.php';
110 110
     $nav     = new XoopsPageNav($articles_count, $xoopsModuleConfig['articles_perpage'], $start, 'start',
111
-                                'month=' . $month . '&amp;day=' . $day . '&amp;year=' . $year . '&amp;blog='
112
-                                . (int)$blog_id);
111
+                                'month='.$month.'&amp;day='.$day.'&amp;year='.$year.'&amp;blog='
112
+                                . (int) $blog_id);
113 113
     $pagenav = $nav->renderNav(4);
114
-} else {
114
+}else {
115 115
     $pagenav = '';
116 116
 }
117 117
 
@@ -120,46 +120,46 @@  discard block
 block discarded – undo
120 120
 $months   = null;
121 121
 if (empty($start)) {
122 122
     if ($blog_id) {
123
-        $blog_criteria = ' AND blog_id=' . $blog_id;
124
-    } else {
123
+        $blog_criteria = ' AND blog_id='.$blog_id;
124
+    }else {
125 125
         $blog_criteria = '';
126 126
     }
127 127
     // Get monthly list
128 128
     if (empty($month)) {
129
-        $sql    = "SELECT MONTH(FROM_UNIXTIME(art_time - $timeoffset)) AS mon, COUNT(DISTINCT art_id) AS count
130
-            FROM " . planet_DB_prefix('article') . "
129
+        $sql = "SELECT MONTH(FROM_UNIXTIME(art_time - $timeoffset)) AS mon, COUNT(DISTINCT art_id) AS count
130
+            FROM ".planet_DB_prefix('article')."
131 131
             WHERE YEAR(FROM_UNIXTIME(art_time - $timeoffset)) = $year
132
-            " . $blog_criteria . '
132
+            ".$blog_criteria.'
133 133
             GROUP BY mon
134 134
             ';
135 135
         $result = $xoopsDB->query($sql);
136 136
         $months = array();
137 137
         while ($myrow = $xoopsDB->fetchArray($result)) {
138 138
             $months[] = array(
139
-                'title' => planet_constant('MD_MONTH_' . (int)$myrow['mon']) . ' (' . (int)$myrow['count'] . ')',
140
-                'url'   => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . ''
141
-                           . $year . '/' . $myrow['mon'] . '/b' . $blog_id
139
+                'title' => planet_constant('MD_MONTH_'.(int) $myrow['mon']).' ('.(int) $myrow['count'].')',
140
+                'url'   => XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.archive.php'.URL_DELIMITER.''
141
+                           . $year.'/'.$myrow['mon'].'/b'.$blog_id
142 142
             );
143 143
         }
144 144
         $timenav['prev'] = array(
145
-            'url'   => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . ''
146
-                       . ($year - 1) . '/b' . $blog_id,
147
-            'title' => sprintf(planet_constant('MD_TIME_Y'), $year - 1)
145
+            'url'   => XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.archive.php'.URL_DELIMITER.''
146
+                       . ($year-1).'/b'.$blog_id,
147
+            'title' => sprintf(planet_constant('MD_TIME_Y'), $year-1)
148 148
         );
149
-        if ($year < date('Y')) {
149
+        if ($year<date('Y')) {
150 150
             $timenav['next'] = array(
151
-                'url'   => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . ''
152
-                           . ($year + 1) . '/b' . $blog_id,
153
-                'title' => sprintf(planet_constant('MD_TIME_Y'), $year + 1)
151
+                'url'   => XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.archive.php'.URL_DELIMITER.''
152
+                           . ($year+1).'/b'.$blog_id,
153
+                'title' => sprintf(planet_constant('MD_TIME_Y'), $year+1)
154 154
             );
155 155
         }
156 156
     } // Get daily list
157 157
     elseif (empty($day)) {
158
-        $sql    = "SELECT DAY(FROM_UNIXTIME(art_time - $timeoffset)) AS day, COUNT(DISTINCT a.art_id) AS count
159
-            FROM " . planet_DB_prefix('article') . "
158
+        $sql = "SELECT DAY(FROM_UNIXTIME(art_time - $timeoffset)) AS day, COUNT(DISTINCT a.art_id) AS count
159
+            FROM ".planet_DB_prefix('article')."
160 160
             WHERE YEAR(FROM_UNIXTIME(art_time - $timeoffset)) = $year
161 161
             AND MONTH(FROM_UNIXTIME(art_time - $timeoffset)) = $month
162
-            " . $blog_criteria . '
162
+            ".$blog_criteria.'
163 163
             GROUP BY day
164 164
             ';
165 165
         $result = $xoopsDB->query($sql);
@@ -167,38 +167,38 @@  discard block
 block discarded – undo
167 167
         while ($myrow = $xoopsDB->fetchArray($result)) {
168 168
             $days[$myrow['day']]['count'] = $myrow['count'];
169 169
         }
170
-        for ($i = 1; $i <= 31; ++$i) {
170
+        for ($i = 1; $i<=31; ++$i) {
171 171
             if (!isset($days[$i])) {
172 172
                 continue;
173 173
             }
174 174
             $days[$i] = array(
175 175
                 'title' => $days[$i]['count'],
176
-                'url'   => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . ''
177
-                           . $year . '/' . $month . '/' . $i . '/b' . $blog_id
176
+                'url'   => XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.archive.php'.URL_DELIMITER.''
177
+                           . $year.'/'.$month.'/'.$i.'/b'.$blog_id
178 178
             );
179 179
         }
180 180
         $calendar   = planet_getCalendar($year, $month, $days);
181
-        $month_next = $month + 1;
182
-        $month_prev = $month - 1;
181
+        $month_next = $month+1;
182
+        $month_prev = $month-1;
183 183
         $_year      = $year;
184 184
         if ($month == 12) {
185 185
             $month_next = 1;
186
-            $_year      = $year + 1;
186
+            $_year      = $year+1;
187 187
         }
188 188
         if ($month == 1) {
189 189
             $month_pre = 12;
190
-            $_year     = $year - 1;
190
+            $_year     = $year-1;
191 191
         }
192 192
         $timenav['prev'] = array(
193
-            'url'   => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . ''
194
-                       . $_year . '/' . $month_prev . '/b' . $blog_id,
195
-            'title' => planet_constant('MD_MONTH_' . $month_prev)
193
+            'url'   => XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.archive.php'.URL_DELIMITER.''
194
+                       . $_year.'/'.$month_prev.'/b'.$blog_id,
195
+            'title' => planet_constant('MD_MONTH_'.$month_prev)
196 196
         );
197
-        if ($year < date('Y') || $month < date('n')) {
197
+        if ($year<date('Y') || $month<date('n')) {
198 198
             $timenav['next'] = array(
199
-                'url'   => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . ''
200
-                           . $_year . '/' . $month_next . '/b' . $blog_id,
201
-                'title' => planet_constant('MD_MONTH_' . $month_next)
199
+                'url'   => XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.archive.php'.URL_DELIMITER.''
200
+                           . $_year.'/'.$month_next.'/b'.$blog_id,
201
+                'title' => planet_constant('MD_MONTH_'.$month_next)
202 202
             );
203 203
         }
204 204
     }
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 $xoopsTpl->assign('timenav', $timenav);
219 219
 $xoopsTpl->assign('pagenav', $pagenav);
220 220
 
221
-include_once __DIR__ . '/footer.php';
221
+include_once __DIR__.'/footer.php';
222 222
 
223 223
 /**
224 224
  * @param null $year
@@ -234,25 +234,25 @@  discard block
 block discarded – undo
234 234
     ob_start();
235 235
     echo '<table id="calendar">';
236 236
     echo '<caption>';
237
-    printf(planet_constant('MD_TIME_YM'), $year, planet_constant('MD_MONTH_' . $month));
237
+    printf(planet_constant('MD_TIME_YM'), $year, planet_constant('MD_MONTH_'.$month));
238 238
     echo '</caption>';
239 239
 
240
-    for ($i = 1; $i <= 7; ++$i) {
241
-        echo "\n\t\t<th abbr=\"" . planet_constant('MD_WEEK_' . $i) . "\" scope=\"col\" title=\""
242
-             . planet_constant('MD_WEEK_' . $i) . "\">" . planet_constant('MD_WEEK_' . $i) . '</th>';
240
+    for ($i = 1; $i<=7; ++$i) {
241
+        echo "\n\t\t<th abbr=\"".planet_constant('MD_WEEK_'.$i)."\" scope=\"col\" title=\""
242
+             . planet_constant('MD_WEEK_'.$i)."\">".planet_constant('MD_WEEK_'.$i).'</th>';
243 243
     }
244 244
 
245 245
     echo '<tr>';
246 246
 
247 247
     // See how much we should pad in the beginning
248 248
     $week_begins = 1;
249
-    $pad         = planet_calendar_week_mod(date('w', $unixmonth) - $week_begins);
249
+    $pad         = planet_calendar_week_mod(date('w', $unixmonth)-$week_begins);
250 250
     if (0 != $pad) {
251
-        echo "\n\t\t" . '<td colspan="' . $pad . '">&nbsp;</td>';
251
+        echo "\n\t\t".'<td colspan="'.$pad.'">&nbsp;</td>';
252 252
     }
253 253
 
254
-    $daysinmonth = (int)date('t', $unixmonth);
255
-    for ($day = 1; $day <= $daysinmonth; ++$day) {
254
+    $daysinmonth = (int) date('t', $unixmonth);
255
+    for ($day = 1; $day<=$daysinmonth; ++$day) {
256 256
         if (isset($newrow) && $newrow) {
257 257
             echo "\n\t</tr>\n\t<tr>\n\t\t";
258 258
         }
@@ -261,26 +261,26 @@  discard block
 block discarded – undo
261 261
         echo '<td>';
262 262
 
263 263
         if (!empty($days[$day]['url'])) {
264
-            echo '<a href="' . $days[$day]['url'] . "\"";
264
+            echo '<a href="'.$days[$day]['url']."\"";
265 265
             if (!empty($days[$day]['title'])) {
266
-                echo "title=\"" . $days[$day]['title'] . "\"";
266
+                echo "title=\"".$days[$day]['title']."\"";
267 267
             }
268 268
             echo ">$day</a>";
269 269
         } elseif (!empty($days[$day]['title'])) {
270
-            echo "<acronym title=\"" . $days[$day]['title'] . "\">$day</acronym>";
271
-        } else {
270
+            echo "<acronym title=\"".$days[$day]['title']."\">$day</acronym>";
271
+        }else {
272 272
             echo $day;
273 273
         }
274 274
         echo '</td>';
275 275
 
276
-        if (6 == planet_calendar_week_mod(date('w', mktime(0, 0, 0, $month, $day, $year)) - $week_begins)) {
276
+        if (6 == planet_calendar_week_mod(date('w', mktime(0, 0, 0, $month, $day, $year))-$week_begins)) {
277 277
             $newrow = true;
278 278
         }
279 279
     }
280 280
 
281
-    $pad = 7 - planet_calendar_week_mod(date('w', mktime(0, 0, 0, $month, $day, $year)) - $week_begins);
281
+    $pad = 7-planet_calendar_week_mod(date('w', mktime(0, 0, 0, $month, $day, $year))-$week_begins);
282 282
     if ($pad != 0 && $pad != 7) {
283
-        echo "\n\t\t" . '<td class="pad" colspan="' . $pad . '">&nbsp;</td>';
283
+        echo "\n\t\t".'<td class="pad" colspan="'.$pad.'">&nbsp;</td>';
284 284
     }
285 285
 
286 286
     echo "\n\t</tr>\n\t</tbody>\n\t</table>";
@@ -298,5 +298,5 @@  discard block
 block discarded – undo
298 298
 function planet_calendar_week_mod($num) {
299 299
     $base = 7;
300 300
 
301
-    return ($num - $base * floor($num / $base));
301
+    return ($num-$base*floor($num/$base));
302 302
 }
Please login to merge, or discard this patch.
index.php 2 patches
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -27,13 +27,13 @@  discard block
 block discarded – undo
27 27
 include __DIR__ . '/header.php';
28 28
 
29 29
 if (preg_match("/\/notification_update\.php/i", $_SERVER['REQUEST_URI'], $matches)) {
30
-    include XOOPS_ROOT_PATH . '/include/notification_update.php';
31
-    exit();
30
+	include XOOPS_ROOT_PATH . '/include/notification_update.php';
31
+	exit();
32 32
 }
33 33
 
34 34
 if ($REQUEST_URI_parsed = planet_parse_args($args_num, $args, $args_str)) {
35
-    $args['start'] = @$args_num[0];
36
-    $args['sort']  = @$args_str[0];
35
+	$args['start'] = @$args_num[0];
36
+	$args['sort']  = @$args_str[0];
37 37
 }
38 38
 
39 39
 /* Start */
@@ -51,34 +51,34 @@  discard block
 block discarded – undo
51 51
 
52 52
 // restore $_SERVER['REQUEST_URI']
53 53
 if (!empty($REQUEST_URI_parsed)) {
54
-    $args_REQUEST_URI = array();
55
-    $_args            = array('start', 'sort', 'uid', 'list');
56
-    foreach ($_args as $arg) {
57
-        if (!empty(${$arg})) {
58
-            $args_REQUEST_URI[] = $arg . '=' . ${$arg};
59
-        }
60
-    }
61
-    if (!empty($blog_id)) {
62
-        $args_REQUEST_URI[] = 'blog=' . $blog_id;
63
-    }
64
-    if (!empty($category_id)) {
65
-        $args_REQUEST_URI[] = 'category=' . $category_id;
66
-    }
67
-    $_SERVER['REQUEST_URI'] = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php'
68
-                              . (empty($args_REQUEST_URI) ? '' : '?' . implode('&', $args_REQUEST_URI));
54
+	$args_REQUEST_URI = array();
55
+	$_args            = array('start', 'sort', 'uid', 'list');
56
+	foreach ($_args as $arg) {
57
+		if (!empty(${$arg})) {
58
+			$args_REQUEST_URI[] = $arg . '=' . ${$arg};
59
+		}
60
+	}
61
+	if (!empty($blog_id)) {
62
+		$args_REQUEST_URI[] = 'blog=' . $blog_id;
63
+	}
64
+	if (!empty($category_id)) {
65
+		$args_REQUEST_URI[] = 'category=' . $category_id;
66
+	}
67
+	$_SERVER['REQUEST_URI'] = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php'
68
+							  . (empty($args_REQUEST_URI) ? '' : '?' . implode('&', $args_REQUEST_URI));
69 69
 }
70 70
 
71 71
 $xoopsOption['template_main'] = planet_getTemplate('index');
72 72
 $xoops_module_header          = '
73 73
     <link rel="alternate" type="application/rss+xml" title="' . $xoopsModule->getVar('name') . ' rss" href="'
74
-                                . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php".URL_DELIMITER."rss/c'
75
-                                . $category_id . '/b' . $blog_id . '/u' . $uid . '" />
74
+								. XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php".URL_DELIMITER."rss/c'
75
+								. $category_id . '/b' . $blog_id . '/u' . $uid . '" />
76 76
     <link rel="alternate" type="application/rss+xml" title="' . $xoopsModule->getVar('name') . ' rdf" href="'
77
-                                . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php".URL_DELIMITER."rdf/c'
78
-                                . $category_id . '/b' . $blog_id . '/u' . $uid . '" />
77
+								. XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php".URL_DELIMITER."rdf/c'
78
+								. $category_id . '/b' . $blog_id . '/u' . $uid . '" />
79 79
     <link rel="alternate" type="application/atom+xml" title="' . $xoopsModule->getVar('name') . ' atom" href="'
80
-                                . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php".URL_DELIMITER."atom/c'
81
-                                . $category_id . '/b' . $blog_id . '/u' . $uid . '" />
80
+								. XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php".URL_DELIMITER."atom/c'
81
+								. $category_id . '/b' . $blog_id . '/u' . $uid . '" />
82 82
     ';
83 83
 
84 84
 $xoopsOption['xoops_module_header'] = $xoops_module_header;
@@ -96,74 +96,74 @@  discard block
 block discarded – undo
96 96
 $article_prefix = '';
97 97
 /* Specific category */
98 98
 if ($category_id > 0) {
99
-    $category_obj = $category_handler->get($category_id);
100
-    $criteria->add(new Criteria('bc.cat_id', $category_id));
101
-    $uid            = 0;
102
-    $blog_id        = 0;
103
-    $category_data  = array('id' => $category_id, 'title' => $category_obj->getVar('cat_title'));
104
-    $query_type     = 'category';
105
-    $article_prefix = 'a.';
99
+	$category_obj = $category_handler->get($category_id);
100
+	$criteria->add(new Criteria('bc.cat_id', $category_id));
101
+	$uid            = 0;
102
+	$blog_id        = 0;
103
+	$category_data  = array('id' => $category_id, 'title' => $category_obj->getVar('cat_title'));
104
+	$query_type     = 'category';
105
+	$article_prefix = 'a.';
106 106
 }
107 107
 /* Specific blog */
108 108
 if ($blog_id > 0) {
109
-    $blog_obj =& $blog_handler->get($blog_id);
110
-    if ($blog_obj->getVar('blog_status')
111
-        || (is_object($xoopsUser)
112
-            && $xoopsUser->getVar('uid') == $blog_obj->getVar('blog_submitter'))
113
-    ) {
114
-        $criteria->add(new Criteria('blog_id', $blog_id));
115
-        $category_id      = 0;
116
-        $uid              = 0;
117
-        $bookmark_handler = xoops_getModuleHandler('bookmark', $GLOBALS['moddirname']);
118
-        $blog_data        = array(
119
-            'id'    => $blog_id,
120
-            'title' => $blog_obj->getVar('blog_title'),
121
-            'image' => $blog_obj->getImage(),
122
-            'title' => $blog_obj->getVar('blog_title'),
123
-            'feed'  => $blog_obj->getVar('blog_feed'),
124
-            'link'  => $blog_obj->getVar('blog_link'),
125
-            'desc'  => $blog_obj->getVar('blog_desc'),
126
-            'time'  => $blog_obj->getTime(),
127
-            'star'  => $blog_obj->getStar(),
128
-            'rates' => $blog_obj->getVar('blog_rates'),
129
-            'marks' => $blog_obj->getVar('blog_marks')
130
-        );
131
-    }
132
-    $query_type     = 'blog';
133
-    $article_prefix = '';
109
+	$blog_obj =& $blog_handler->get($blog_id);
110
+	if ($blog_obj->getVar('blog_status')
111
+		|| (is_object($xoopsUser)
112
+			&& $xoopsUser->getVar('uid') == $blog_obj->getVar('blog_submitter'))
113
+	) {
114
+		$criteria->add(new Criteria('blog_id', $blog_id));
115
+		$category_id      = 0;
116
+		$uid              = 0;
117
+		$bookmark_handler = xoops_getModuleHandler('bookmark', $GLOBALS['moddirname']);
118
+		$blog_data        = array(
119
+			'id'    => $blog_id,
120
+			'title' => $blog_obj->getVar('blog_title'),
121
+			'image' => $blog_obj->getImage(),
122
+			'title' => $blog_obj->getVar('blog_title'),
123
+			'feed'  => $blog_obj->getVar('blog_feed'),
124
+			'link'  => $blog_obj->getVar('blog_link'),
125
+			'desc'  => $blog_obj->getVar('blog_desc'),
126
+			'time'  => $blog_obj->getTime(),
127
+			'star'  => $blog_obj->getStar(),
128
+			'rates' => $blog_obj->getVar('blog_rates'),
129
+			'marks' => $blog_obj->getVar('blog_marks')
130
+		);
131
+	}
132
+	$query_type     = 'blog';
133
+	$article_prefix = '';
134 134
 }
135 135
 /* User bookmarks(favorites) */
136 136
 if ($uid > 0) {
137
-    $criteria->add(new Criteria('bm.bm_uid', $uid));
138
-    $category_id      = 0;
139
-    $blog_id          = 0;
140
-    $bookmark_handler = xoops_getModuleHandler('bookmark', $GLOBALS['moddirname']);
141
-    $user_data        = array(
142
-        'uid'   => $uid,
143
-        'name'  => XoopsUser::getUnameFromId($uid),
144
-        'marks' => $bookmark_handler->getCount(new Criteria('bm_uid', $uid))
145
-    );
146
-    $query_type       = 'bookmark';
147
-    $article_prefix   = 'a.';
137
+	$criteria->add(new Criteria('bm.bm_uid', $uid));
138
+	$category_id      = 0;
139
+	$blog_id          = 0;
140
+	$bookmark_handler = xoops_getModuleHandler('bookmark', $GLOBALS['moddirname']);
141
+	$user_data        = array(
142
+		'uid'   => $uid,
143
+		'name'  => XoopsUser::getUnameFromId($uid),
144
+		'marks' => $bookmark_handler->getCount(new Criteria('bm_uid', $uid))
145
+	);
146
+	$query_type       = 'bookmark';
147
+	$article_prefix   = 'a.';
148 148
 }
149 149
 
150 150
 /* Sort */
151 151
 $order = 'DESC';
152 152
 $sort  = empty($sort) ? 'time' : $sort;
153 153
 switch ($sort) {
154
-    case 'views':
155
-        $sortby = $article_prefix . 'art_views';
156
-        break;
157
-    case 'rating':
158
-        $sortby = $article_prefix . 'art_rating';
159
-        break;
160
-    case 'time':
161
-        $sortby = $article_prefix . 'art_time';
162
-        break;
163
-    case 'default':
164
-    default:
165
-        $sortby = '';
166
-        break;
154
+	case 'views':
155
+		$sortby = $article_prefix . 'art_views';
156
+		break;
157
+	case 'rating':
158
+		$sortby = $article_prefix . 'art_rating';
159
+		break;
160
+	case 'time':
161
+		$sortby = $article_prefix . 'art_time';
162
+		break;
163
+	case 'default':
164
+	default:
165
+		$sortby = '';
166
+		break;
167 167
 }
168 168
 $criteria->setSort($sortby);
169 169
 $criteria->setOrder($order);
@@ -171,120 +171,120 @@  discard block
 block discarded – undo
171 171
 $criteria->setLimit($limit);
172 172
 
173 173
 $tags = empty($list) ? '' : array(
174
-    $article_prefix . 'art_title',
175
-    $article_prefix . 'blog_id',
176
-    $article_prefix . 'art_time'
174
+	$article_prefix . 'art_title',
175
+	$article_prefix . 'blog_id',
176
+	$article_prefix . 'art_time'
177 177
 );
178 178
 switch ($query_type) {
179
-    case 'category':
180
-        $articles_obj  =& $article_handler->getByCategory($criteria, $tags);
181
-        $count_article = $article_handler->getCountByCategory($criteria);
182
-        break;
183
-    case 'bookmark':
184
-        $articles_obj  =& $article_handler->getByBookmark($criteria, $tags);
185
-        $count_article = $article_handler->getCountByBookmark($criteria);
186
-        break;
187
-    default:
188
-        $articles_obj  =& $article_handler->getAll($criteria, $tags);
189
-        $count_article = $article_handler->getCount($criteria);
190
-        break;
179
+	case 'category':
180
+		$articles_obj  =& $article_handler->getByCategory($criteria, $tags);
181
+		$count_article = $article_handler->getCountByCategory($criteria);
182
+		break;
183
+	case 'bookmark':
184
+		$articles_obj  =& $article_handler->getByBookmark($criteria, $tags);
185
+		$count_article = $article_handler->getCountByBookmark($criteria);
186
+		break;
187
+	default:
188
+		$articles_obj  =& $article_handler->getAll($criteria, $tags);
189
+		$count_article = $article_handler->getCount($criteria);
190
+		break;
191 191
 }
192 192
 
193 193
 if (!empty($blog_data)) {
194
-    $blogs[$blog_data['id']] = $blog_data['title'];
194
+	$blogs[$blog_data['id']] = $blog_data['title'];
195 195
 } else {
196
-    $blog_array = array();
197
-    foreach (array_keys($articles_obj) as $id) {
198
-        $blog_array[$articles_obj[$id]->getVar('blog_id')] = 1;
199
-    }
200
-    $criteria_blog = new Criteria('blog_id', '(' . implode(',', array_keys($blog_array)) . ')', 'IN');
201
-    $blogs         = $blog_handler->getList($criteria_blog);
196
+	$blog_array = array();
197
+	foreach (array_keys($articles_obj) as $id) {
198
+		$blog_array[$articles_obj[$id]->getVar('blog_id')] = 1;
199
+	}
200
+	$criteria_blog = new Criteria('blog_id', '(' . implode(',', array_keys($blog_array)) . ')', 'IN');
201
+	$blogs         = $blog_handler->getList($criteria_blog);
202 202
 }
203 203
 
204 204
 /* Objects to array */
205 205
 $articles = array();
206 206
 foreach (array_keys($articles_obj) as $id) {
207
-    $_article = array(
208
-        'id'    => $id,
209
-        'title' => $articles_obj[$id]->getVar('art_title'),
210
-        'time'  => $articles_obj[$id]->getTime(),
211
-        'blog'  => array(
212
-            'id'    => $articles_obj[$id]->getVar('blog_id'),
213
-            'title' => $blogs[$articles_obj[$id]->getVar('blog_id')]
214
-        )
215
-    );
216
-    if (empty($list)) {
217
-        $_article = array_merge($_article, array(
218
-            'author'   => $articles_obj[$id]->getVar('art_author'),
219
-            'views'    => $articles_obj[$id]->getVar('art_views'),
220
-            'comments' => $articles_obj[$id]->getVar('art_comments'),
221
-            'star'     => $articles_obj[$id]->getStar(),
222
-            'rates'    => $articles_obj[$id]->getVar('art_rates')
223
-        ));
224
-        if (!empty($xoopsModuleConfig['display_summary'])) {
225
-            $_article['content'] = $articles_obj[$id]->getSummary();
226
-        } else {
227
-            $_article['content'] = $articles_obj[$id]->getVar('art_content');
228
-        }
229
-    }
230
-    $articles[] = $_article;
231
-    unset($_article);
207
+	$_article = array(
208
+		'id'    => $id,
209
+		'title' => $articles_obj[$id]->getVar('art_title'),
210
+		'time'  => $articles_obj[$id]->getTime(),
211
+		'blog'  => array(
212
+			'id'    => $articles_obj[$id]->getVar('blog_id'),
213
+			'title' => $blogs[$articles_obj[$id]->getVar('blog_id')]
214
+		)
215
+	);
216
+	if (empty($list)) {
217
+		$_article = array_merge($_article, array(
218
+			'author'   => $articles_obj[$id]->getVar('art_author'),
219
+			'views'    => $articles_obj[$id]->getVar('art_views'),
220
+			'comments' => $articles_obj[$id]->getVar('art_comments'),
221
+			'star'     => $articles_obj[$id]->getStar(),
222
+			'rates'    => $articles_obj[$id]->getVar('art_rates')
223
+		));
224
+		if (!empty($xoopsModuleConfig['display_summary'])) {
225
+			$_article['content'] = $articles_obj[$id]->getSummary();
226
+		} else {
227
+			$_article['content'] = $articles_obj[$id]->getVar('art_content');
228
+		}
229
+	}
230
+	$articles[] = $_article;
231
+	unset($_article);
232 232
 }
233 233
 unset($articles_obj);
234 234
 
235 235
 if ($count_article > $limit) {
236
-    include XOOPS_ROOT_PATH . '/class/pagenav.php';
237
-    $start_link = array();
238
-    if ($sort) {
239
-        $start_link[] = 'sort=' . $sort;
240
-    }
241
-    if ($category_id) {
242
-        $start_link[] = 'category=' . $category_id;
243
-    }
244
-    if ($blog_id) {
245
-        $start_link[] = 'blog=' . $blog_id;
246
-    }
247
-    if ($list) {
248
-        $start_link[] = 'list=' . $list;
249
-    }
250
-    $nav     = new XoopsPageNav($count_article, $limit, $start, 'start', implode('&amp;', $start_link));
251
-    $pagenav = $nav->renderNav(4);
236
+	include XOOPS_ROOT_PATH . '/class/pagenav.php';
237
+	$start_link = array();
238
+	if ($sort) {
239
+		$start_link[] = 'sort=' . $sort;
240
+	}
241
+	if ($category_id) {
242
+		$start_link[] = 'category=' . $category_id;
243
+	}
244
+	if ($blog_id) {
245
+		$start_link[] = 'blog=' . $blog_id;
246
+	}
247
+	if ($list) {
248
+		$start_link[] = 'list=' . $list;
249
+	}
250
+	$nav     = new XoopsPageNav($count_article, $limit, $start, 'start', implode('&amp;', $start_link));
251
+	$pagenav = $nav->renderNav(4);
252 252
 } else {
253
-    $pagenav = '';
253
+	$pagenav = '';
254 254
 }
255 255
 
256 256
 $xoopsTpl->assign('xoops_module_header', $xoops_module_header);
257 257
 $xoopsTpl->assign('dirname', $GLOBALS['moddirname']);
258 258
 
259 259
 if ($category_id || $blog_id || $uid) {
260
-    $xoopsTpl->assign('link_index',
261
-                      "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/index.php\" title=\""
262
-                      . planet_constant('MD_INDEX') . "\" target=\"_self\">" . planet_constant('MD_INDEX') . '</a>');
260
+	$xoopsTpl->assign('link_index',
261
+					  "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/index.php\" title=\""
262
+					  . planet_constant('MD_INDEX') . "\" target=\"_self\">" . planet_constant('MD_INDEX') . '</a>');
263 263
 }
264 264
 
265 265
 $link_switch = "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php'
266
-               . (empty($category_id) ? '' : '/c' . $category_id) . (empty($uid) ? '' : '/u' . $uid)
267
-               . (empty($blog_id) ? '' : '/b' . $blog_id) . (empty($list) ? '/l1' : '') . "\" title=\""
268
-               . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW')) . "\">"
269
-               . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW')) . '</a>';
266
+			   . (empty($category_id) ? '' : '/c' . $category_id) . (empty($uid) ? '' : '/u' . $uid)
267
+			   . (empty($blog_id) ? '' : '/b' . $blog_id) . (empty($list) ? '/l1' : '') . "\" title=\""
268
+			   . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW')) . "\">"
269
+			   . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW')) . '</a>';
270 270
 $xoopsTpl->assign('link_switch', $link_switch);
271 271
 
272 272
 $link_blogs = "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.blogs.php'
273
-              . (empty($category_id) ? '' : '/c' . $category_id) . (empty($uid) ? '' : '/u' . $uid) . "\" title=\""
274
-              . planet_constant('MD_BLOGS') . "\">" . planet_constant('MD_BLOGS') . '</a>';
273
+			  . (empty($category_id) ? '' : '/c' . $category_id) . (empty($uid) ? '' : '/u' . $uid) . "\" title=\""
274
+			  . planet_constant('MD_BLOGS') . "\">" . planet_constant('MD_BLOGS') . '</a>';
275 275
 $xoopsTpl->assign('link_blogs', $link_blogs);
276 276
 
277 277
 if (empty($uid) && is_object($xoopsUser)) {
278
-    $xoopsTpl->assign('link_bookmark',
279
-                      "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER
280
-                      . 'u' . $xoopsUser->getVar('uid') . "\" title=\"" . planet_constant('MD_BOOKMARKS')
281
-                      . "\" target=\"_self\">" . planet_constant('MD_BOOKMARKS') . '</a>');
278
+	$xoopsTpl->assign('link_bookmark',
279
+					  "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER
280
+					  . 'u' . $xoopsUser->getVar('uid') . "\" title=\"" . planet_constant('MD_BOOKMARKS')
281
+					  . "\" target=\"_self\">" . planet_constant('MD_BOOKMARKS') . '</a>');
282 282
 }
283 283
 
284 284
 if ($xoopsModuleConfig['newblog_submit'] == 1 || is_object($xoopsUser)) {
285
-    $xoopsTpl->assign('link_submit',
286
-                      "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/action.blog.php\" title=\""
287
-                      . _SUBMIT . "\" target=\"_blank\">" . _SUBMIT . '</a>');
285
+	$xoopsTpl->assign('link_submit',
286
+					  "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/action.blog.php\" title=\""
287
+					  . _SUBMIT . "\" target=\"_blank\">" . _SUBMIT . '</a>');
288 288
 }
289 289
 
290 290
 $xoopsTpl->assign('pagetitle', $xoopsModule->getVar('name') . '::' . planet_constant('MD_ARTICLES'));
@@ -298,25 +298,25 @@  discard block
 block discarded – undo
298 298
 $xoopsTpl->assign('user_level', !is_object($xoopsUser) ? 0 : ($xoopsUser->isAdmin() ? 2 : 1));
299 299
 if (empty($xoopsModuleConfig['anonymous_rate']) && !is_object($xoopsUser)) {
300 300
 } elseif ($blog_id > 0) {
301
-    $xoopsTpl->assign('canrate', 1);
301
+	$xoopsTpl->assign('canrate', 1);
302 302
 }
303 303
 
304 304
 $sort_link   = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . (empty($category_id) ? '' : '/c'
305
-                                                                                                             . $category_id)
306
-               . (empty($uid) ? '' : '/u' . $uid) . (empty($blog_id) ? '' : '/b' . $blog_id)
307
-               . (empty($list) ? '' : '/l1');
305
+																											 . $category_id)
306
+			   . (empty($uid) ? '' : '/u' . $uid) . (empty($blog_id) ? '' : '/b' . $blog_id)
307
+			   . (empty($list) ? '' : '/l1');
308 308
 $valid_sorts = array(
309
-    'views'   => planet_constant('MD_VIEWS'),
310
-    'rating'  => planet_constant('MD_RATING'),
311
-    'time'    => planet_constant('MD_TIME'),
312
-    'default' => planet_constant('MD_DEFAULT')
309
+	'views'   => planet_constant('MD_VIEWS'),
310
+	'rating'  => planet_constant('MD_RATING'),
311
+	'time'    => planet_constant('MD_TIME'),
312
+	'default' => planet_constant('MD_DEFAULT')
313 313
 );
314 314
 $sortlinks   = array();
315 315
 foreach ($valid_sorts as $val => $name) {
316
-    if ($val == $sort) {
317
-        continue;
318
-    }
319
-    $sortlinks[] = "<a href=\"" . $sort_link . '/' . $val . "\">" . $name . '</a>';
316
+	if ($val == $sort) {
317
+		continue;
318
+	}
319
+	$sortlinks[] = "<a href=\"" . $sort_link . '/' . $val . "\">" . $name . '</a>';
320 320
 }
321 321
 $xoopsTpl->assign('link_sort', implode(' | ', $sortlinks));
322 322
 $xoopsTpl->assign('version', $xoopsModule->getVar('version'));
@@ -325,8 +325,8 @@  discard block
 block discarded – undo
325 325
 
326 326
 // for notification
327 327
 if (!empty($blog_id)) {
328
-    //$_SERVER['REQUEST_URI'] = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/index.php";
329
-    $_GET['blog'] = $blog_id;
328
+	//$_SERVER['REQUEST_URI'] = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/index.php";
329
+	$_GET['blog'] = $blog_id;
330 330
 }
331 331
 
332 332
 include_once __DIR__ . '/footer.php';
Please login to merge, or discard this patch.
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
 // URL: http://xoops.org                         //
25 25
 // Project: Article Project                                                 //
26 26
 // ------------------------------------------------------------------------ //
27
-include __DIR__ . '/header.php';
27
+include __DIR__.'/header.php';
28 28
 
29 29
 if (preg_match("/\/notification_update\.php/i", $_SERVER['REQUEST_URI'], $matches)) {
30
-    include XOOPS_ROOT_PATH . '/include/notification_update.php';
30
+    include XOOPS_ROOT_PATH.'/include/notification_update.php';
31 31
     exit();
32 32
 }
33 33
 
@@ -37,17 +37,17 @@  discard block
 block discarded – undo
37 37
 }
38 38
 
39 39
 /* Start */
40
-$start = (int)(empty($_GET['start']) ? @$args['start'] : $_GET['start']);
40
+$start = (int) (empty($_GET['start']) ? @$args['start'] : $_GET['start']);
41 41
 /* Specified Category */
42
-$category_id = (int)(empty($_GET['category']) ? @$args['category'] : $_GET['category']);
42
+$category_id = (int) (empty($_GET['category']) ? @$args['category'] : $_GET['category']);
43 43
 /* Specified Blog */
44
-$blog_id = (int)(empty($_GET['blog']) ? @$args['blog'] : $_GET['blog']);
44
+$blog_id = (int) (empty($_GET['blog']) ? @$args['blog'] : $_GET['blog']);
45 45
 /* Specified Bookmar(Favorite) UID */
46
-$uid = (int)(empty($_GET['uid']) ? @$args['uid'] : $_GET['uid']);
46
+$uid = (int) (empty($_GET['uid']) ? @$args['uid'] : $_GET['uid']);
47 47
 /* Sort by term */
48 48
 $sort = empty($_GET['sort']) ? @$args['sort'] : $_GET['sort'];
49 49
 /* Display as list */
50
-$list = (int)(empty($_GET['list']) ? @$args['list'] : $_GET['list']);
50
+$list = (int) (empty($_GET['list']) ? @$args['list'] : $_GET['list']);
51 51
 
52 52
 // restore $_SERVER['REQUEST_URI']
53 53
 if (!empty($REQUEST_URI_parsed)) {
@@ -55,35 +55,35 @@  discard block
 block discarded – undo
55 55
     $_args            = array('start', 'sort', 'uid', 'list');
56 56
     foreach ($_args as $arg) {
57 57
         if (!empty(${$arg})) {
58
-            $args_REQUEST_URI[] = $arg . '=' . ${$arg};
58
+            $args_REQUEST_URI[] = $arg.'='.${$arg};
59 59
         }
60 60
     }
61 61
     if (!empty($blog_id)) {
62
-        $args_REQUEST_URI[] = 'blog=' . $blog_id;
62
+        $args_REQUEST_URI[] = 'blog='.$blog_id;
63 63
     }
64 64
     if (!empty($category_id)) {
65
-        $args_REQUEST_URI[] = 'category=' . $category_id;
65
+        $args_REQUEST_URI[] = 'category='.$category_id;
66 66
     }
67
-    $_SERVER['REQUEST_URI'] = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php'
68
-                              . (empty($args_REQUEST_URI) ? '' : '?' . implode('&', $args_REQUEST_URI));
67
+    $_SERVER['REQUEST_URI'] = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'
68
+                              . (empty($args_REQUEST_URI) ? '' : '?'.implode('&', $args_REQUEST_URI));
69 69
 }
70 70
 
71 71
 $xoopsOption['template_main'] = planet_getTemplate('index');
72 72
 $xoops_module_header          = '
73
-    <link rel="alternate" type="application/rss+xml" title="' . $xoopsModule->getVar('name') . ' rss" href="'
74
-                                . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php".URL_DELIMITER."rss/c'
75
-                                . $category_id . '/b' . $blog_id . '/u' . $uid . '" />
76
-    <link rel="alternate" type="application/rss+xml" title="' . $xoopsModule->getVar('name') . ' rdf" href="'
77
-                                . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php".URL_DELIMITER."rdf/c'
78
-                                . $category_id . '/b' . $blog_id . '/u' . $uid . '" />
79
-    <link rel="alternate" type="application/atom+xml" title="' . $xoopsModule->getVar('name') . ' atom" href="'
80
-                                . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php".URL_DELIMITER."atom/c'
81
-                                . $category_id . '/b' . $blog_id . '/u' . $uid . '" />
73
+    <link rel="alternate" type="application/rss+xml" title="' . $xoopsModule->getVar('name').' rss" href="'
74
+                                . XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/xml.php".URL_DELIMITER."rss/c'
75
+                                . $category_id.'/b'.$blog_id.'/u'.$uid.'" />
76
+    <link rel="alternate" type="application/rss+xml" title="' . $xoopsModule->getVar('name').' rdf" href="'
77
+                                . XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/xml.php".URL_DELIMITER."rdf/c'
78
+                                . $category_id.'/b'.$blog_id.'/u'.$uid.'" />
79
+    <link rel="alternate" type="application/atom+xml" title="' . $xoopsModule->getVar('name').' atom" href="'
80
+                                . XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/xml.php".URL_DELIMITER."atom/c'
81
+                                . $category_id.'/b'.$blog_id.'/u'.$uid.'" />
82 82
     ';
83 83
 
84 84
 $xoopsOption['xoops_module_header'] = $xoops_module_header;
85
-include_once XOOPS_ROOT_PATH . '/header.php';
86
-include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php';
85
+include_once XOOPS_ROOT_PATH.'/header.php';
86
+include XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/include/vars.php';
87 87
 
88 88
 // Following part will not be executed after cache
89 89
 $category_handler = xoops_getModuleHandler('category', $GLOBALS['moddirname']);
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 $criteria       = new CriteriaCompo();
96 96
 $article_prefix = '';
97 97
 /* Specific category */
98
-if ($category_id > 0) {
98
+if ($category_id>0) {
99 99
     $category_obj = $category_handler->get($category_id);
100 100
     $criteria->add(new Criteria('bc.cat_id', $category_id));
101 101
     $uid            = 0;
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
     $article_prefix = 'a.';
106 106
 }
107 107
 /* Specific blog */
108
-if ($blog_id > 0) {
109
-    $blog_obj =& $blog_handler->get($blog_id);
108
+if ($blog_id>0) {
109
+    $blog_obj = & $blog_handler->get($blog_id);
110 110
     if ($blog_obj->getVar('blog_status')
111 111
         || (is_object($xoopsUser)
112 112
             && $xoopsUser->getVar('uid') == $blog_obj->getVar('blog_submitter'))
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     $article_prefix = '';
134 134
 }
135 135
 /* User bookmarks(favorites) */
136
-if ($uid > 0) {
136
+if ($uid>0) {
137 137
     $criteria->add(new Criteria('bm.bm_uid', $uid));
138 138
     $category_id      = 0;
139 139
     $blog_id          = 0;
@@ -152,13 +152,13 @@  discard block
 block discarded – undo
152 152
 $sort  = empty($sort) ? 'time' : $sort;
153 153
 switch ($sort) {
154 154
     case 'views':
155
-        $sortby = $article_prefix . 'art_views';
155
+        $sortby = $article_prefix.'art_views';
156 156
         break;
157 157
     case 'rating':
158
-        $sortby = $article_prefix . 'art_rating';
158
+        $sortby = $article_prefix.'art_rating';
159 159
         break;
160 160
     case 'time':
161
-        $sortby = $article_prefix . 'art_time';
161
+        $sortby = $article_prefix.'art_time';
162 162
         break;
163 163
     case 'default':
164 164
     default:
@@ -171,33 +171,33 @@  discard block
 block discarded – undo
171 171
 $criteria->setLimit($limit);
172 172
 
173 173
 $tags = empty($list) ? '' : array(
174
-    $article_prefix . 'art_title',
175
-    $article_prefix . 'blog_id',
176
-    $article_prefix . 'art_time'
174
+    $article_prefix.'art_title',
175
+    $article_prefix.'blog_id',
176
+    $article_prefix.'art_time'
177 177
 );
178 178
 switch ($query_type) {
179 179
     case 'category':
180
-        $articles_obj  =& $article_handler->getByCategory($criteria, $tags);
180
+        $articles_obj  = & $article_handler->getByCategory($criteria, $tags);
181 181
         $count_article = $article_handler->getCountByCategory($criteria);
182 182
         break;
183 183
     case 'bookmark':
184
-        $articles_obj  =& $article_handler->getByBookmark($criteria, $tags);
184
+        $articles_obj  = & $article_handler->getByBookmark($criteria, $tags);
185 185
         $count_article = $article_handler->getCountByBookmark($criteria);
186 186
         break;
187 187
     default:
188
-        $articles_obj  =& $article_handler->getAll($criteria, $tags);
188
+        $articles_obj  = & $article_handler->getAll($criteria, $tags);
189 189
         $count_article = $article_handler->getCount($criteria);
190 190
         break;
191 191
 }
192 192
 
193 193
 if (!empty($blog_data)) {
194 194
     $blogs[$blog_data['id']] = $blog_data['title'];
195
-} else {
195
+}else {
196 196
     $blog_array = array();
197 197
     foreach (array_keys($articles_obj) as $id) {
198 198
         $blog_array[$articles_obj[$id]->getVar('blog_id')] = 1;
199 199
     }
200
-    $criteria_blog = new Criteria('blog_id', '(' . implode(',', array_keys($blog_array)) . ')', 'IN');
200
+    $criteria_blog = new Criteria('blog_id', '('.implode(',', array_keys($blog_array)).')', 'IN');
201 201
     $blogs         = $blog_handler->getList($criteria_blog);
202 202
 }
203 203
 
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
         ));
224 224
         if (!empty($xoopsModuleConfig['display_summary'])) {
225 225
             $_article['content'] = $articles_obj[$id]->getSummary();
226
-        } else {
226
+        }else {
227 227
             $_article['content'] = $articles_obj[$id]->getVar('art_content');
228 228
         }
229 229
     }
@@ -232,24 +232,24 @@  discard block
 block discarded – undo
232 232
 }
233 233
 unset($articles_obj);
234 234
 
235
-if ($count_article > $limit) {
236
-    include XOOPS_ROOT_PATH . '/class/pagenav.php';
235
+if ($count_article>$limit) {
236
+    include XOOPS_ROOT_PATH.'/class/pagenav.php';
237 237
     $start_link = array();
238 238
     if ($sort) {
239
-        $start_link[] = 'sort=' . $sort;
239
+        $start_link[] = 'sort='.$sort;
240 240
     }
241 241
     if ($category_id) {
242
-        $start_link[] = 'category=' . $category_id;
242
+        $start_link[] = 'category='.$category_id;
243 243
     }
244 244
     if ($blog_id) {
245
-        $start_link[] = 'blog=' . $blog_id;
245
+        $start_link[] = 'blog='.$blog_id;
246 246
     }
247 247
     if ($list) {
248
-        $start_link[] = 'list=' . $list;
248
+        $start_link[] = 'list='.$list;
249 249
     }
250 250
     $nav     = new XoopsPageNav($count_article, $limit, $start, 'start', implode('&amp;', $start_link));
251 251
     $pagenav = $nav->renderNav(4);
252
-} else {
252
+}else {
253 253
     $pagenav = '';
254 254
 }
255 255
 
@@ -258,36 +258,36 @@  discard block
 block discarded – undo
258 258
 
259 259
 if ($category_id || $blog_id || $uid) {
260 260
     $xoopsTpl->assign('link_index',
261
-                      "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/index.php\" title=\""
262
-                      . planet_constant('MD_INDEX') . "\" target=\"_self\">" . planet_constant('MD_INDEX') . '</a>');
261
+                      "<a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname']."/index.php\" title=\""
262
+                      . planet_constant('MD_INDEX')."\" target=\"_self\">".planet_constant('MD_INDEX').'</a>');
263 263
 }
264 264
 
265
-$link_switch = "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php'
266
-               . (empty($category_id) ? '' : '/c' . $category_id) . (empty($uid) ? '' : '/u' . $uid)
267
-               . (empty($blog_id) ? '' : '/b' . $blog_id) . (empty($list) ? '/l1' : '') . "\" title=\""
268
-               . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW')) . "\">"
269
-               . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW')) . '</a>';
265
+$link_switch = "<a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'
266
+               . (empty($category_id) ? '' : '/c'.$category_id).(empty($uid) ? '' : '/u'.$uid)
267
+               . (empty($blog_id) ? '' : '/b'.$blog_id).(empty($list) ? '/l1' : '')."\" title=\""
268
+               . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW'))."\">"
269
+               . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW')).'</a>';
270 270
 $xoopsTpl->assign('link_switch', $link_switch);
271 271
 
272
-$link_blogs = "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.blogs.php'
273
-              . (empty($category_id) ? '' : '/c' . $category_id) . (empty($uid) ? '' : '/u' . $uid) . "\" title=\""
274
-              . planet_constant('MD_BLOGS') . "\">" . planet_constant('MD_BLOGS') . '</a>';
272
+$link_blogs = "<a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.blogs.php'
273
+              . (empty($category_id) ? '' : '/c'.$category_id).(empty($uid) ? '' : '/u'.$uid)."\" title=\""
274
+              . planet_constant('MD_BLOGS')."\">".planet_constant('MD_BLOGS').'</a>';
275 275
 $xoopsTpl->assign('link_blogs', $link_blogs);
276 276
 
277 277
 if (empty($uid) && is_object($xoopsUser)) {
278 278
     $xoopsTpl->assign('link_bookmark',
279
-                      "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER
280
-                      . 'u' . $xoopsUser->getVar('uid') . "\" title=\"" . planet_constant('MD_BOOKMARKS')
281
-                      . "\" target=\"_self\">" . planet_constant('MD_BOOKMARKS') . '</a>');
279
+                      "<a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'.URL_DELIMITER
280
+                      . 'u'.$xoopsUser->getVar('uid')."\" title=\"".planet_constant('MD_BOOKMARKS')
281
+                      . "\" target=\"_self\">".planet_constant('MD_BOOKMARKS').'</a>');
282 282
 }
283 283
 
284 284
 if ($xoopsModuleConfig['newblog_submit'] == 1 || is_object($xoopsUser)) {
285 285
     $xoopsTpl->assign('link_submit',
286
-                      "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/action.blog.php\" title=\""
287
-                      . _SUBMIT . "\" target=\"_blank\">" . _SUBMIT . '</a>');
286
+                      "<a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname']."/action.blog.php\" title=\""
287
+                      . _SUBMIT."\" target=\"_blank\">"._SUBMIT.'</a>');
288 288
 }
289 289
 
290
-$xoopsTpl->assign('pagetitle', $xoopsModule->getVar('name') . '::' . planet_constant('MD_ARTICLES'));
290
+$xoopsTpl->assign('pagetitle', $xoopsModule->getVar('name').'::'.planet_constant('MD_ARTICLES'));
291 291
 $xoopsTpl->assign('category', @$category_data);
292 292
 $xoopsTpl->assign('blog', @$blog_data);
293 293
 $xoopsTpl->assign('user', @$user_data);
@@ -297,13 +297,13 @@  discard block
 block discarded – undo
297 297
 
298 298
 $xoopsTpl->assign('user_level', !is_object($xoopsUser) ? 0 : ($xoopsUser->isAdmin() ? 2 : 1));
299 299
 if (empty($xoopsModuleConfig['anonymous_rate']) && !is_object($xoopsUser)) {
300
-} elseif ($blog_id > 0) {
300
+} elseif ($blog_id>0) {
301 301
     $xoopsTpl->assign('canrate', 1);
302 302
 }
303 303
 
304
-$sort_link   = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . (empty($category_id) ? '' : '/c'
304
+$sort_link = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'.(empty($category_id) ? '' : '/c'
305 305
                                                                                                              . $category_id)
306
-               . (empty($uid) ? '' : '/u' . $uid) . (empty($blog_id) ? '' : '/b' . $blog_id)
306
+               . (empty($uid) ? '' : '/u'.$uid).(empty($blog_id) ? '' : '/b'.$blog_id)
307 307
                . (empty($list) ? '' : '/l1');
308 308
 $valid_sorts = array(
309 309
     'views'   => planet_constant('MD_VIEWS'),
@@ -311,12 +311,12 @@  discard block
 block discarded – undo
311 311
     'time'    => planet_constant('MD_TIME'),
312 312
     'default' => planet_constant('MD_DEFAULT')
313 313
 );
314
-$sortlinks   = array();
314
+$sortlinks = array();
315 315
 foreach ($valid_sorts as $val => $name) {
316 316
     if ($val == $sort) {
317 317
         continue;
318 318
     }
319
-    $sortlinks[] = "<a href=\"" . $sort_link . '/' . $val . "\">" . $name . '</a>';
319
+    $sortlinks[] = "<a href=\"".$sort_link.'/'.$val."\">".$name.'</a>';
320 320
 }
321 321
 $xoopsTpl->assign('link_sort', implode(' | ', $sortlinks));
322 322
 $xoopsTpl->assign('version', $xoopsModule->getVar('version'));
@@ -329,4 +329,4 @@  discard block
 block discarded – undo
329 329
     $_GET['blog'] = $blog_id;
330 330
 }
331 331
 
332
-include_once __DIR__ . '/footer.php';
332
+include_once __DIR__.'/footer.php';
Please login to merge, or discard this patch.
action.blog.php 2 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -32,15 +32,15 @@  discard block
 block discarded – undo
32 32
 $blog_id = is_array($blog_id) ? array_map('intval', $blog_id) : (int)$blog_id;
33 33
 
34 34
 if (empty($xoopsModuleConfig['newblog_submit']) && (!is_object($xoopsUser) || !$xoopsUser->isAdmin())) {
35
-    redirect_header('index.php', 2, _NOPERM);
35
+	redirect_header('index.php', 2, _NOPERM);
36 36
 }
37 37
 
38 38
 if ($op === 'save' && !empty($_POST['fetch'])) {
39
-    $op = 'edit';
39
+	$op = 'edit';
40 40
 }
41 41
 
42 42
 if ($op === 'save' && !$GLOBALS['xoopsSecurity']->check()) {
43
-    redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_INVALID') . ': security check failed');
43
+	redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_INVALID') . ': security check failed');
44 44
 }
45 45
 include XOOPS_ROOT_PATH . '/header.php';
46 46
 include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php';
@@ -49,111 +49,111 @@  discard block
 block discarded – undo
49 49
 $category_handler = xoops_getModuleHandler('category', $GLOBALS['moddirname']);
50 50
 
51 51
 switch ($op) {
52
-    /* save a single blog */
53
-    case 'save':
54
-
55
-        if ($blog_id) {
56
-            $blog_obj =& $blog_handler->get($blog_id);
57
-            if ($xoopsUser->isAdmin()) {
58
-                $blog_obj->setVar('blog_status', @$_POST['blog_status']);
59
-            }
60
-        } else {
61
-            if ($blog_exists = $blog_handler->getCount(new Criteria('blog_feed',
62
-                                                                    $myts->addSlashes(trim($_POST['blog_feed']))))
63
-            ) {
64
-                redirect_header('index.php', 2, planet_constant('MD_BLOGEXISTS'));
65
-            }
66
-
67
-            $blog_obj =& $blog_handler->create();
68
-            $blog_obj->setVar('blog_submitter', is_object($xoopsUser) ? $xoopsUser->getVar('uid') : planet_getIP(true));
69
-
70
-            switch ($xoopsModuleConfig['newblog_submit']) {
71
-                case 2:
72
-                    if (!is_object($xoopsUser)) {
73
-                        $status = 0;
74
-                    } else {
75
-                        $status = 1;
76
-                    }
77
-                    break;
78
-                case 0:
79
-                case 3:
80
-                    $status = 1;
81
-                    break;
82
-                case 1:
83
-                default:
84
-                    if (!is_object($xoopsUser) || !$xoopsUser->isAdmin()) {
85
-                        $status = 0;
86
-                    } else {
87
-                        $status = 1;
88
-                    }
89
-                    break;
90
-            }
91
-
92
-            $blog_obj->setVar('blog_status', $status);
93
-        }
94
-
95
-        $blog_obj->setVar('blog_title', $_POST['blog_title']);
96
-        $blog_obj->setVar('blog_desc', $_POST['blog_desc']);
97
-        $blog_obj->setVar('blog_image', $_POST['blog_image']);
98
-        $blog_obj->setVar('blog_feed', $_POST['blog_feed']);
99
-        $blog_obj->setVar('blog_link', $_POST['blog_link']);
100
-        $blog_obj->setVar('blog_language', $_POST['blog_language']);
101
-        $blog_obj->setVar('blog_charset', $_POST['blog_charset']);
102
-        $blog_obj->setVar('blog_trackback', $_POST['blog_trackback']);
103
-        if ($blog_obj->isNew()) {
104
-            $blog_obj->setVar('blog_submitter', is_object($xoopsUser) ? $xoopsUser->getVar('uid') : planet_getIP(true));
105
-        }
106
-
107
-        if (!$blog_handler->insert($blog_obj)) {
108
-        } elseif (!empty($_POST['categories'])) {
109
-            $blog_id = $blog_obj->getVar('blog_id');
110
-            if (in_array(0, $_POST['categories'])) {
111
-                $_POST['categories'] = array();
112
-            }
113
-            $blog_handler->setCategories($blog_id, $_POST['categories']);
114
-        }
115
-        $message = planet_constant('MD_DBUPDATED');
116
-        redirect_header('index.php' . URL_DELIMITER . 'b' . $blog_id, 2, $message);
117
-
118
-    /* edit a single blog */
119
-    case 'edit':
120
-    default:
121
-        if (!empty($_POST['fetch'])) {
122
-            $blog_obj =& $blog_handler->fetch($_POST['blog_feed']);
123
-            $blog_obj->setVar('blog_id', $blog_id);
124
-        } else {
125
-            $blog_obj =& $blog_handler->get($blog_id);
126
-        }
127
-        $categories = isset($_POST['categories']) ? $_POST['categories'] : array();
128
-        if (in_array('-1', $categories)) {
129
-            $categories = array();
130
-        }
131
-        if (empty($categories) && $blog_id > 0) {
132
-            $crit       = new Criteria('bc.blog_id', $blog_id);
133
-            $categories = array_keys($category_handler->getByBlog($crit));
134
-        }
135
-        if (empty($categories)) {
136
-            $categories = array(0 => _NONE);
137
-        }
138
-
139
-        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _EDIT . '</legend>';
140
-        echo '<br>';
141
-        if (empty($blog_id) && $blog_obj->getVar('blog_feed')) {
142
-            $criteria  = new Criteria('blog_feed', $blog_obj->getVar('blog_feed'));
143
-            $blogs_obj =& $blog_handler->getList($criteria);
144
-            if (count($blogs_obj) > 0) {
145
-                echo "<div class=\"errorMsg\">" . planet_constant('MD_BLOGEXISTS');
146
-                foreach (array_keys($blogs_obj) as $bid) {
147
-                    echo "<br><a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php'
148
-                         . URL_DELIMITER . 'b' . $bid . "\" target=\"_blank\">" . $blogs_obj[$bid] . '</a>';
149
-                }
150
-                echo '</div>';
151
-                unset($blogs_obj, $criteria);
152
-            }
153
-        }
154
-        include XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/form.blog.php';
155
-        echo '</fieldset>';
156
-        break;
52
+	/* save a single blog */
53
+	case 'save':
54
+
55
+		if ($blog_id) {
56
+			$blog_obj =& $blog_handler->get($blog_id);
57
+			if ($xoopsUser->isAdmin()) {
58
+				$blog_obj->setVar('blog_status', @$_POST['blog_status']);
59
+			}
60
+		} else {
61
+			if ($blog_exists = $blog_handler->getCount(new Criteria('blog_feed',
62
+																	$myts->addSlashes(trim($_POST['blog_feed']))))
63
+			) {
64
+				redirect_header('index.php', 2, planet_constant('MD_BLOGEXISTS'));
65
+			}
66
+
67
+			$blog_obj =& $blog_handler->create();
68
+			$blog_obj->setVar('blog_submitter', is_object($xoopsUser) ? $xoopsUser->getVar('uid') : planet_getIP(true));
69
+
70
+			switch ($xoopsModuleConfig['newblog_submit']) {
71
+				case 2:
72
+					if (!is_object($xoopsUser)) {
73
+						$status = 0;
74
+					} else {
75
+						$status = 1;
76
+					}
77
+					break;
78
+				case 0:
79
+				case 3:
80
+					$status = 1;
81
+					break;
82
+				case 1:
83
+				default:
84
+					if (!is_object($xoopsUser) || !$xoopsUser->isAdmin()) {
85
+						$status = 0;
86
+					} else {
87
+						$status = 1;
88
+					}
89
+					break;
90
+			}
91
+
92
+			$blog_obj->setVar('blog_status', $status);
93
+		}
94
+
95
+		$blog_obj->setVar('blog_title', $_POST['blog_title']);
96
+		$blog_obj->setVar('blog_desc', $_POST['blog_desc']);
97
+		$blog_obj->setVar('blog_image', $_POST['blog_image']);
98
+		$blog_obj->setVar('blog_feed', $_POST['blog_feed']);
99
+		$blog_obj->setVar('blog_link', $_POST['blog_link']);
100
+		$blog_obj->setVar('blog_language', $_POST['blog_language']);
101
+		$blog_obj->setVar('blog_charset', $_POST['blog_charset']);
102
+		$blog_obj->setVar('blog_trackback', $_POST['blog_trackback']);
103
+		if ($blog_obj->isNew()) {
104
+			$blog_obj->setVar('blog_submitter', is_object($xoopsUser) ? $xoopsUser->getVar('uid') : planet_getIP(true));
105
+		}
106
+
107
+		if (!$blog_handler->insert($blog_obj)) {
108
+		} elseif (!empty($_POST['categories'])) {
109
+			$blog_id = $blog_obj->getVar('blog_id');
110
+			if (in_array(0, $_POST['categories'])) {
111
+				$_POST['categories'] = array();
112
+			}
113
+			$blog_handler->setCategories($blog_id, $_POST['categories']);
114
+		}
115
+		$message = planet_constant('MD_DBUPDATED');
116
+		redirect_header('index.php' . URL_DELIMITER . 'b' . $blog_id, 2, $message);
117
+
118
+	/* edit a single blog */
119
+	case 'edit':
120
+	default:
121
+		if (!empty($_POST['fetch'])) {
122
+			$blog_obj =& $blog_handler->fetch($_POST['blog_feed']);
123
+			$blog_obj->setVar('blog_id', $blog_id);
124
+		} else {
125
+			$blog_obj =& $blog_handler->get($blog_id);
126
+		}
127
+		$categories = isset($_POST['categories']) ? $_POST['categories'] : array();
128
+		if (in_array('-1', $categories)) {
129
+			$categories = array();
130
+		}
131
+		if (empty($categories) && $blog_id > 0) {
132
+			$crit       = new Criteria('bc.blog_id', $blog_id);
133
+			$categories = array_keys($category_handler->getByBlog($crit));
134
+		}
135
+		if (empty($categories)) {
136
+			$categories = array(0 => _NONE);
137
+		}
138
+
139
+		echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _EDIT . '</legend>';
140
+		echo '<br>';
141
+		if (empty($blog_id) && $blog_obj->getVar('blog_feed')) {
142
+			$criteria  = new Criteria('blog_feed', $blog_obj->getVar('blog_feed'));
143
+			$blogs_obj =& $blog_handler->getList($criteria);
144
+			if (count($blogs_obj) > 0) {
145
+				echo "<div class=\"errorMsg\">" . planet_constant('MD_BLOGEXISTS');
146
+				foreach (array_keys($blogs_obj) as $bid) {
147
+					echo "<br><a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php'
148
+						 . URL_DELIMITER . 'b' . $bid . "\" target=\"_blank\">" . $blogs_obj[$bid] . '</a>';
149
+				}
150
+				echo '</div>';
151
+				unset($blogs_obj, $criteria);
152
+			}
153
+		}
154
+		include XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/form.blog.php';
155
+		echo '</fieldset>';
156
+		break;
157 157
 }
158 158
 
159 159
 include XOOPS_ROOT_PATH . '/footer.php';
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 // Project: Article Project                                                 //
26 26
 // ------------------------------------------------------------------------ //
27 27
 
28
-include __DIR__ . '/header.php';
28
+include __DIR__.'/header.php';
29 29
 
30 30
 $op      = !empty($_POST['op']) ? $_POST['op'] : (!empty($_GET['op']) ? $_GET['op'] : '');
31 31
 $blog_id = !empty($_POST['blog']) ? $_POST['blog'] : (!empty($_GET['blog']) ? $_GET['blog'] : 0);
32
-$blog_id = is_array($blog_id) ? array_map('intval', $blog_id) : (int)$blog_id;
32
+$blog_id = is_array($blog_id) ? array_map('intval', $blog_id) : (int) $blog_id;
33 33
 
34 34
 if (empty($xoopsModuleConfig['newblog_submit']) && (!is_object($xoopsUser) || !$xoopsUser->isAdmin())) {
35 35
     redirect_header('index.php', 2, _NOPERM);
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
 }
41 41
 
42 42
 if ($op === 'save' && !$GLOBALS['xoopsSecurity']->check()) {
43
-    redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_INVALID') . ': security check failed');
43
+    redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_INVALID').': security check failed');
44 44
 }
45
-include XOOPS_ROOT_PATH . '/header.php';
46
-include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php';
45
+include XOOPS_ROOT_PATH.'/header.php';
46
+include XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/include/vars.php';
47 47
 
48 48
 $blog_handler     = xoops_getModuleHandler('blog', $GLOBALS['moddirname']);
49 49
 $category_handler = xoops_getModuleHandler('category', $GLOBALS['moddirname']);
@@ -53,25 +53,25 @@  discard block
 block discarded – undo
53 53
     case 'save':
54 54
 
55 55
         if ($blog_id) {
56
-            $blog_obj =& $blog_handler->get($blog_id);
56
+            $blog_obj = & $blog_handler->get($blog_id);
57 57
             if ($xoopsUser->isAdmin()) {
58 58
                 $blog_obj->setVar('blog_status', @$_POST['blog_status']);
59 59
             }
60
-        } else {
60
+        }else {
61 61
             if ($blog_exists = $blog_handler->getCount(new Criteria('blog_feed',
62 62
                                                                     $myts->addSlashes(trim($_POST['blog_feed']))))
63 63
             ) {
64 64
                 redirect_header('index.php', 2, planet_constant('MD_BLOGEXISTS'));
65 65
             }
66 66
 
67
-            $blog_obj =& $blog_handler->create();
67
+            $blog_obj = & $blog_handler->create();
68 68
             $blog_obj->setVar('blog_submitter', is_object($xoopsUser) ? $xoopsUser->getVar('uid') : planet_getIP(true));
69 69
 
70 70
             switch ($xoopsModuleConfig['newblog_submit']) {
71 71
                 case 2:
72 72
                     if (!is_object($xoopsUser)) {
73 73
                         $status = 0;
74
-                    } else {
74
+                    }else {
75 75
                         $status = 1;
76 76
                     }
77 77
                     break;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
                 default:
84 84
                     if (!is_object($xoopsUser) || !$xoopsUser->isAdmin()) {
85 85
                         $status = 0;
86
-                    } else {
86
+                    }else {
87 87
                         $status = 1;
88 88
                     }
89 89
                     break;
@@ -113,22 +113,22 @@  discard block
 block discarded – undo
113 113
             $blog_handler->setCategories($blog_id, $_POST['categories']);
114 114
         }
115 115
         $message = planet_constant('MD_DBUPDATED');
116
-        redirect_header('index.php' . URL_DELIMITER . 'b' . $blog_id, 2, $message);
116
+        redirect_header('index.php'.URL_DELIMITER.'b'.$blog_id, 2, $message);
117 117
 
118 118
     /* edit a single blog */
119 119
     case 'edit':
120 120
     default:
121 121
         if (!empty($_POST['fetch'])) {
122
-            $blog_obj =& $blog_handler->fetch($_POST['blog_feed']);
122
+            $blog_obj = & $blog_handler->fetch($_POST['blog_feed']);
123 123
             $blog_obj->setVar('blog_id', $blog_id);
124
-        } else {
125
-            $blog_obj =& $blog_handler->get($blog_id);
124
+        }else {
125
+            $blog_obj = & $blog_handler->get($blog_id);
126 126
         }
127 127
         $categories = isset($_POST['categories']) ? $_POST['categories'] : array();
128 128
         if (in_array('-1', $categories)) {
129 129
             $categories = array();
130 130
         }
131
-        if (empty($categories) && $blog_id > 0) {
131
+        if (empty($categories) && $blog_id>0) {
132 132
             $crit       = new Criteria('bc.blog_id', $blog_id);
133 133
             $categories = array_keys($category_handler->getByBlog($crit));
134 134
         }
@@ -136,24 +136,24 @@  discard block
 block discarded – undo
136 136
             $categories = array(0 => _NONE);
137 137
         }
138 138
 
139
-        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _EDIT . '</legend>';
139
+        echo "<fieldset><legend style='font-weight: bold; color: #900;'>"._EDIT.'</legend>';
140 140
         echo '<br>';
141 141
         if (empty($blog_id) && $blog_obj->getVar('blog_feed')) {
142 142
             $criteria  = new Criteria('blog_feed', $blog_obj->getVar('blog_feed'));
143
-            $blogs_obj =& $blog_handler->getList($criteria);
144
-            if (count($blogs_obj) > 0) {
145
-                echo "<div class=\"errorMsg\">" . planet_constant('MD_BLOGEXISTS');
143
+            $blogs_obj = & $blog_handler->getList($criteria);
144
+            if (count($blogs_obj)>0) {
145
+                echo "<div class=\"errorMsg\">".planet_constant('MD_BLOGEXISTS');
146 146
                 foreach (array_keys($blogs_obj) as $bid) {
147
-                    echo "<br><a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php'
148
-                         . URL_DELIMITER . 'b' . $bid . "\" target=\"_blank\">" . $blogs_obj[$bid] . '</a>';
147
+                    echo "<br><a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'
148
+                         . URL_DELIMITER.'b'.$bid."\" target=\"_blank\">".$blogs_obj[$bid].'</a>';
149 149
                 }
150 150
                 echo '</div>';
151 151
                 unset($blogs_obj, $criteria);
152 152
             }
153 153
         }
154
-        include XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/form.blog.php';
154
+        include XOOPS_ROOT_PATH.'/modules/'.$GLOBALS['moddirname'].'/include/form.blog.php';
155 155
         echo '</fieldset>';
156 156
         break;
157 157
 }
158 158
 
159
-include XOOPS_ROOT_PATH . '/footer.php';
159
+include XOOPS_ROOT_PATH.'/footer.php';
Please login to merge, or discard this patch.