@@ -3,10 +3,10 @@ |
||
3 | 3 | $general->logged_out_protect(); |
4 | 4 | if (isset($_POST['submit'])) |
5 | 5 | { if ($users->user_exists($_POST['username']) == true && !empty($_POST['username'])) |
6 | - { $errors[] = 'Sorry, username '.$_POST['username'].' is already exists!'; |
|
6 | + { $errors[] = 'Sorry, username '.$_POST['username'].' is already exists!'; |
|
7 | 7 | } |
8 | 8 | if ($users->email_exists($_POST['email']) == true && !empty($_POST['email'])) |
9 | - { $errors[] = 'Sorry, email '.$_POST['email'].' is already exists!'; |
|
9 | + { $errors[] = 'Sorry, email '.$_POST['email'].' is already exists!'; |
|
10 | 10 | } |
11 | 11 | if(empty($errors) === true) |
12 | 12 | { $fullname = $_POST['fullname']; |
@@ -12,8 +12,8 @@ |
||
12 | 12 | $resolutiontime = $_POST['resolutiontime']; |
13 | 13 | $slawarning = $_POST['slawarning']; |
14 | 14 | if ($slas->sla_exists($slaid) === true) { |
15 | - $errors[] = 'SLA ID is already exists!'; |
|
16 | - } else { |
|
15 | + $errors[] = 'SLA ID is already exists!'; |
|
16 | + } else { |
|
17 | 17 | $slas->add_sla($slaid,$namasla,$responsetime,$resolutiontime,$slawarning); |
18 | 18 | header('location:slalist.php'); |
19 | 19 | } |
@@ -397,10 +397,10 @@ |
||
397 | 397 | $f = fopen($path,'r'); |
398 | 398 | fseek($f,13,SEEK_SET); |
399 | 399 | $info = fread($f,3); |
400 | - fclose($f); |
|
401 | - $iUnit = ord($info{0}); |
|
402 | - $iX = ord($info{1}) * 256 + ord($info{2}); |
|
403 | - return array($iUnit, $iX); |
|
400 | + fclose($f); |
|
401 | + $iUnit = ord($info{0}); |
|
402 | + $iX = ord($info{1}) * 256 + ord($info{2}); |
|
403 | + return array($iUnit, $iX); |
|
404 | 404 | } |
405 | 405 | private function _html2text($text){ |
406 | 406 | $text = str_replace(' ',' ',$text); |
@@ -33,297 +33,297 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class HTMLParser { |
35 | 35 | |
36 | - /** |
|
37 | - * Field iNodeType. |
|
38 | - * May be one of the NODE_TYPE_* constants above. |
|
39 | - */ |
|
40 | - var $iNodeType; |
|
41 | - |
|
42 | - /** |
|
43 | - * Field iNodeName. |
|
44 | - * For elements, it's the name of the element. |
|
45 | - */ |
|
46 | - var $iNodeName = ""; |
|
47 | - |
|
48 | - /** |
|
49 | - * Field iNodeValue. |
|
50 | - * For text nodes, it's the text. |
|
51 | - */ |
|
52 | - var $iNodeValue = ""; |
|
53 | - |
|
54 | - /** |
|
55 | - * Field iNodeAttributes. |
|
56 | - * A string-indexed array containing attribute values |
|
57 | - * of the current node. Indexes are always lowercase. |
|
58 | - */ |
|
59 | - var $iNodeAttributes; |
|
60 | - |
|
61 | - // The following fields should be |
|
62 | - // considered private: |
|
63 | - |
|
64 | - var $iHtmlText; |
|
65 | - var $iHtmlTextLength; |
|
66 | - var $iHtmlTextIndex = 0; |
|
67 | - var $iHtmlCurrentChar; |
|
68 | - |
|
69 | - /** |
|
70 | - * Constructor. |
|
71 | - * Constructs an HTMLParser instance with |
|
72 | - * the HTML text given. |
|
73 | - */ |
|
74 | - function HTMLParser ($aHtmlText) { |
|
75 | - $this->iHtmlText = $aHtmlText; |
|
76 | - $this->iHtmlTextLength = strlen($aHtmlText); |
|
77 | - $this->setTextIndex (0); |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Method parse. |
|
82 | - * Parses the next node. Returns false only if |
|
83 | - * the end of the HTML text has been reached. |
|
84 | - * Updates values of iNode* fields. |
|
85 | - */ |
|
86 | - function parse() { |
|
87 | - $text = trim($this->skipToElement()); |
|
88 | - if ($text != "") { |
|
89 | - $this->iNodeType = NODE_TYPE_TEXT; |
|
90 | - $this->iNodeName = "Text"; |
|
91 | - $this->iNodeValue = $text; |
|
92 | - $this->iNodeAttributes = 0; |
|
93 | - return true; |
|
94 | - } |
|
95 | - return $this->readTag(); |
|
96 | - } |
|
97 | - |
|
98 | - function clearAttributes() { |
|
99 | - $this->iNodeAttributes = array(); |
|
100 | - } |
|
101 | - |
|
102 | - function readTag() { |
|
103 | - global $HTML_ATTRIBUTE_STAND_ALONE; |
|
104 | - if ($this->iCurrentChar != "<") { |
|
105 | - $this->iNodeType = NODE_TYPE_DONE; |
|
106 | - return false; |
|
107 | - } |
|
108 | - $this->skipInTag (array("<")); |
|
109 | - $this->clearAttributes(); |
|
110 | - $name = $this->skipToBlanksInTag(); |
|
111 | - $pos = strpos($name, "/"); |
|
112 | - if ($pos === 0) { |
|
113 | - $this->iNodeType = NODE_TYPE_ENDELEMENT; |
|
114 | - $this->iNodeName = substr ($name, 1); |
|
115 | - $this->iNodeValue = ""; |
|
116 | - } |
|
117 | - else { |
|
118 | - if (!$this->isValidTagIdentifier ($name)) { |
|
119 | - $comment = false; |
|
120 | - if ($name == "!--") { |
|
121 | - $rest = $this->skipToStringInTag ("-->"); |
|
122 | - if ($rest != "") { |
|
123 | - $this->iNodeType = NODE_TYPE_COMMENT; |
|
124 | - $this->iNodeName = "Comment"; |
|
125 | - $this->iNodeValue = "<" . $name . $rest; |
|
126 | - $comment = true; |
|
127 | - } |
|
128 | - } |
|
129 | - if (!$comment) { |
|
130 | - $this->iNodeType = NODE_TYPE_TEXT; |
|
131 | - $this->iNodeName = "Text"; |
|
132 | - $this->iNodeValue = "<" . $name; |
|
133 | - } |
|
134 | - return true; |
|
135 | - } |
|
136 | - else { |
|
137 | - $this->iNodeType = NODE_TYPE_ELEMENT; |
|
138 | - $this->iNodeValue = ""; |
|
139 | - $nameLength = strlen($name); |
|
140 | - if ($nameLength > 0 && substr($name, $nameLength - 1, 1) == "/") { |
|
141 | - $this->iNodeName = substr($name, 0, $nameLength - 1); |
|
142 | - }else { |
|
143 | - $this->iNodeName = $name; |
|
144 | - } |
|
145 | - $this->iNodeName = strtolower($this->iNodeName); |
|
146 | - } |
|
147 | - } |
|
148 | - while ($this->skipBlanksInTag()) { |
|
149 | - $attrName = $this->skipToBlanksOrEqualsInTag(); |
|
150 | - if ($attrName != "") { |
|
36 | + /** |
|
37 | + * Field iNodeType. |
|
38 | + * May be one of the NODE_TYPE_* constants above. |
|
39 | + */ |
|
40 | + var $iNodeType; |
|
41 | + |
|
42 | + /** |
|
43 | + * Field iNodeName. |
|
44 | + * For elements, it's the name of the element. |
|
45 | + */ |
|
46 | + var $iNodeName = ""; |
|
47 | + |
|
48 | + /** |
|
49 | + * Field iNodeValue. |
|
50 | + * For text nodes, it's the text. |
|
51 | + */ |
|
52 | + var $iNodeValue = ""; |
|
53 | + |
|
54 | + /** |
|
55 | + * Field iNodeAttributes. |
|
56 | + * A string-indexed array containing attribute values |
|
57 | + * of the current node. Indexes are always lowercase. |
|
58 | + */ |
|
59 | + var $iNodeAttributes; |
|
60 | + |
|
61 | + // The following fields should be |
|
62 | + // considered private: |
|
63 | + |
|
64 | + var $iHtmlText; |
|
65 | + var $iHtmlTextLength; |
|
66 | + var $iHtmlTextIndex = 0; |
|
67 | + var $iHtmlCurrentChar; |
|
68 | + |
|
69 | + /** |
|
70 | + * Constructor. |
|
71 | + * Constructs an HTMLParser instance with |
|
72 | + * the HTML text given. |
|
73 | + */ |
|
74 | + function HTMLParser ($aHtmlText) { |
|
75 | + $this->iHtmlText = $aHtmlText; |
|
76 | + $this->iHtmlTextLength = strlen($aHtmlText); |
|
77 | + $this->setTextIndex (0); |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Method parse. |
|
82 | + * Parses the next node. Returns false only if |
|
83 | + * the end of the HTML text has been reached. |
|
84 | + * Updates values of iNode* fields. |
|
85 | + */ |
|
86 | + function parse() { |
|
87 | + $text = trim($this->skipToElement()); |
|
88 | + if ($text != "") { |
|
89 | + $this->iNodeType = NODE_TYPE_TEXT; |
|
90 | + $this->iNodeName = "Text"; |
|
91 | + $this->iNodeValue = $text; |
|
92 | + $this->iNodeAttributes = 0; |
|
93 | + return true; |
|
94 | + } |
|
95 | + return $this->readTag(); |
|
96 | + } |
|
97 | + |
|
98 | + function clearAttributes() { |
|
99 | + $this->iNodeAttributes = array(); |
|
100 | + } |
|
101 | + |
|
102 | + function readTag() { |
|
103 | + global $HTML_ATTRIBUTE_STAND_ALONE; |
|
104 | + if ($this->iCurrentChar != "<") { |
|
105 | + $this->iNodeType = NODE_TYPE_DONE; |
|
106 | + return false; |
|
107 | + } |
|
108 | + $this->skipInTag (array("<")); |
|
109 | + $this->clearAttributes(); |
|
110 | + $name = $this->skipToBlanksInTag(); |
|
111 | + $pos = strpos($name, "/"); |
|
112 | + if ($pos === 0) { |
|
113 | + $this->iNodeType = NODE_TYPE_ENDELEMENT; |
|
114 | + $this->iNodeName = substr ($name, 1); |
|
115 | + $this->iNodeValue = ""; |
|
116 | + } |
|
117 | + else { |
|
118 | + if (!$this->isValidTagIdentifier ($name)) { |
|
119 | + $comment = false; |
|
120 | + if ($name == "!--") { |
|
121 | + $rest = $this->skipToStringInTag ("-->"); |
|
122 | + if ($rest != "") { |
|
123 | + $this->iNodeType = NODE_TYPE_COMMENT; |
|
124 | + $this->iNodeName = "Comment"; |
|
125 | + $this->iNodeValue = "<" . $name . $rest; |
|
126 | + $comment = true; |
|
127 | + } |
|
128 | + } |
|
129 | + if (!$comment) { |
|
130 | + $this->iNodeType = NODE_TYPE_TEXT; |
|
131 | + $this->iNodeName = "Text"; |
|
132 | + $this->iNodeValue = "<" . $name; |
|
133 | + } |
|
134 | + return true; |
|
135 | + } |
|
136 | + else { |
|
137 | + $this->iNodeType = NODE_TYPE_ELEMENT; |
|
138 | + $this->iNodeValue = ""; |
|
139 | + $nameLength = strlen($name); |
|
140 | + if ($nameLength > 0 && substr($name, $nameLength - 1, 1) == "/") { |
|
141 | + $this->iNodeName = substr($name, 0, $nameLength - 1); |
|
142 | + }else { |
|
143 | + $this->iNodeName = $name; |
|
144 | + } |
|
145 | + $this->iNodeName = strtolower($this->iNodeName); |
|
146 | + } |
|
147 | + } |
|
148 | + while ($this->skipBlanksInTag()) { |
|
149 | + $attrName = $this->skipToBlanksOrEqualsInTag(); |
|
150 | + if ($attrName != "") { |
|
151 | 151 | $attrName = strtolower($attrName); |
152 | 152 | if (array_search($attrName, $HTML_ATTRIBUTE_STAND_ALONE)!==false){ |
153 | 153 | $this->iNodeAttributes[$attrName] = 1; |
154 | 154 | }else{ |
155 | - $this->skipBlanksInTag(); |
|
156 | - if ($this->iCurrentChar == "=") { |
|
157 | - $this->skipEqualsInTag(); |
|
158 | - $this->skipBlanksInTag(); |
|
159 | - $value = $this->readValueInTag(); |
|
160 | - $this->iNodeAttributes[$attrName] = $value; |
|
161 | - }else { |
|
162 | - $this->iNodeAttributes[$attrName] = ""; |
|
163 | - } |
|
155 | + $this->skipBlanksInTag(); |
|
156 | + if ($this->iCurrentChar == "=") { |
|
157 | + $this->skipEqualsInTag(); |
|
158 | + $this->skipBlanksInTag(); |
|
159 | + $value = $this->readValueInTag(); |
|
160 | + $this->iNodeAttributes[$attrName] = $value; |
|
161 | + }else { |
|
162 | + $this->iNodeAttributes[$attrName] = ""; |
|
163 | + } |
|
164 | 164 | } |
165 | - } |
|
166 | - } |
|
167 | - $this->skipEndOfTag(); |
|
168 | - return true; |
|
169 | - } |
|
170 | - |
|
171 | - function isValidTagIdentifier ($name) { |
|
172 | - return preg_match ("/[A-Za-z0-9]+/", $name); |
|
173 | - } |
|
165 | + } |
|
166 | + } |
|
167 | + $this->skipEndOfTag(); |
|
168 | + return true; |
|
169 | + } |
|
170 | + |
|
171 | + function isValidTagIdentifier ($name) { |
|
172 | + return preg_match ("/[A-Za-z0-9]+/", $name); |
|
173 | + } |
|
174 | 174 | |
175 | - function skipBlanksInTag() { |
|
176 | - return "" != ($this->skipInTag (array (" ", "\t", "\r", "\n" ))); |
|
177 | - } |
|
178 | - |
|
179 | - function skipToBlanksOrEqualsInTag() { |
|
180 | - return $this->skipToInTag (array (" ", "\t", "\r", "\n", "=" )); |
|
181 | - } |
|
182 | - |
|
183 | - function skipToBlanksInTag() { |
|
184 | - return $this->skipToInTag (array (" ", "\t", "\r", "\n" )); |
|
185 | - } |
|
186 | - |
|
187 | - function skipEqualsInTag() { |
|
188 | - return $this->skipInTag (array ( "=" )); |
|
189 | - } |
|
190 | - |
|
191 | - function readValueInTag() { |
|
192 | - $ch = $this->iCurrentChar; |
|
193 | - $value = ""; |
|
194 | - if ($ch == "\"") { |
|
195 | - $this->skipInTag (array ( "\"" )); |
|
196 | - $value = $this->skipToInTag (array ( "\"" )); |
|
197 | - $this->skipInTag (array ( "\"" )); |
|
198 | - } |
|
199 | - else if ($ch == "'") { |
|
200 | - $this->skipInTag (array ( "'" )); |
|
201 | - $value = $this->skipToInTag (array ( "'" )); |
|
202 | - $this->skipInTag (array ( "'" )); |
|
203 | - } |
|
204 | - else { |
|
205 | - $value = $this->skipToBlanksInTag(); |
|
206 | - } |
|
207 | - return $value; |
|
208 | - } |
|
209 | - |
|
210 | - function setTextIndex ($index) { |
|
211 | - $this->iHtmlTextIndex = $index; |
|
212 | - if ($index >= $this->iHtmlTextLength) { |
|
213 | - $this->iCurrentChar = -1; |
|
214 | - } |
|
215 | - else { |
|
216 | - $this->iCurrentChar = $this->iHtmlText{$index}; |
|
217 | - } |
|
218 | - } |
|
219 | - |
|
220 | - function moveNext() { |
|
221 | - if ($this->iHtmlTextIndex < $this->iHtmlTextLength) { |
|
222 | - $this->setTextIndex ($this->iHtmlTextIndex + 1); |
|
223 | - return true; |
|
224 | - } |
|
225 | - else { |
|
226 | - return false; |
|
227 | - } |
|
228 | - } |
|
229 | - |
|
230 | - function skipEndOfTag() { |
|
231 | - $sb = ""; |
|
232 | - if (($ch = $this->iCurrentChar) !== -1) { |
|
233 | - $match = ($ch == ">"); |
|
234 | - if (!$match) { |
|
235 | - return $sb; |
|
236 | - } |
|
237 | - $sb .= $ch; |
|
238 | - $this->moveNext(); |
|
239 | - } |
|
240 | - return $sb; |
|
241 | - } |
|
242 | - |
|
243 | - function skipInTag ($chars) { |
|
244 | - $sb = ""; |
|
245 | - while (($ch = $this->iCurrentChar) !== -1) { |
|
246 | - if ($ch == ">") { |
|
247 | - return $sb; |
|
248 | - } else { |
|
249 | - if (array_search($ch,$chars) === false) |
|
250 | - return $sb; |
|
251 | - $sb .= $ch; |
|
252 | - $this->moveNext(); |
|
253 | - } |
|
254 | - } |
|
255 | - return $sb; |
|
256 | - } |
|
257 | - |
|
258 | - function skipToInTag ($chars) { |
|
259 | - $sb = ""; |
|
260 | - while (($ch = $this->iCurrentChar) !== -1) { |
|
261 | - if ($ch == '>' || array_search($ch,$chars) !== false) |
|
262 | - return $sb; |
|
263 | - $sb .= $ch; |
|
264 | - $this->moveNext(); |
|
265 | - } |
|
266 | - return $sb; |
|
267 | - } |
|
268 | - |
|
269 | - function skipToElement() { |
|
270 | - $sb = ""; |
|
271 | - while (($ch = $this->iCurrentChar) !== -1) { |
|
272 | - if ($ch == "<") { |
|
273 | - return $sb; |
|
274 | - } |
|
275 | - $sb .= $ch; |
|
276 | - $this->moveNext(); |
|
277 | - } |
|
278 | - return $sb; |
|
279 | - } |
|
280 | - |
|
281 | - /** |
|
282 | - * Returns text between current position and $needle, |
|
283 | - * inclusive, or "" if not found. The current index is moved to a point |
|
284 | - * after the location of $needle, or not moved at all |
|
285 | - * if nothing is found. |
|
286 | - */ |
|
287 | - function skipToStringInTag ($needle) { |
|
288 | - $pos = strpos ($this->iHtmlText, $needle, $this->iHtmlTextIndex); |
|
289 | - if ($pos === false) { |
|
290 | - return ""; |
|
291 | - } |
|
292 | - $top = $pos + strlen($needle); |
|
293 | - $retvalue = substr ($this->iHtmlText, $this->iHtmlTextIndex, $top - $this->iHtmlTextIndex); |
|
294 | - $this->setTextIndex ($top); |
|
295 | - return $retvalue; |
|
296 | - } |
|
175 | + function skipBlanksInTag() { |
|
176 | + return "" != ($this->skipInTag (array (" ", "\t", "\r", "\n" ))); |
|
177 | + } |
|
178 | + |
|
179 | + function skipToBlanksOrEqualsInTag() { |
|
180 | + return $this->skipToInTag (array (" ", "\t", "\r", "\n", "=" )); |
|
181 | + } |
|
182 | + |
|
183 | + function skipToBlanksInTag() { |
|
184 | + return $this->skipToInTag (array (" ", "\t", "\r", "\n" )); |
|
185 | + } |
|
186 | + |
|
187 | + function skipEqualsInTag() { |
|
188 | + return $this->skipInTag (array ( "=" )); |
|
189 | + } |
|
190 | + |
|
191 | + function readValueInTag() { |
|
192 | + $ch = $this->iCurrentChar; |
|
193 | + $value = ""; |
|
194 | + if ($ch == "\"") { |
|
195 | + $this->skipInTag (array ( "\"" )); |
|
196 | + $value = $this->skipToInTag (array ( "\"" )); |
|
197 | + $this->skipInTag (array ( "\"" )); |
|
198 | + } |
|
199 | + else if ($ch == "'") { |
|
200 | + $this->skipInTag (array ( "'" )); |
|
201 | + $value = $this->skipToInTag (array ( "'" )); |
|
202 | + $this->skipInTag (array ( "'" )); |
|
203 | + } |
|
204 | + else { |
|
205 | + $value = $this->skipToBlanksInTag(); |
|
206 | + } |
|
207 | + return $value; |
|
208 | + } |
|
209 | + |
|
210 | + function setTextIndex ($index) { |
|
211 | + $this->iHtmlTextIndex = $index; |
|
212 | + if ($index >= $this->iHtmlTextLength) { |
|
213 | + $this->iCurrentChar = -1; |
|
214 | + } |
|
215 | + else { |
|
216 | + $this->iCurrentChar = $this->iHtmlText{$index}; |
|
217 | + } |
|
218 | + } |
|
219 | + |
|
220 | + function moveNext() { |
|
221 | + if ($this->iHtmlTextIndex < $this->iHtmlTextLength) { |
|
222 | + $this->setTextIndex ($this->iHtmlTextIndex + 1); |
|
223 | + return true; |
|
224 | + } |
|
225 | + else { |
|
226 | + return false; |
|
227 | + } |
|
228 | + } |
|
229 | + |
|
230 | + function skipEndOfTag() { |
|
231 | + $sb = ""; |
|
232 | + if (($ch = $this->iCurrentChar) !== -1) { |
|
233 | + $match = ($ch == ">"); |
|
234 | + if (!$match) { |
|
235 | + return $sb; |
|
236 | + } |
|
237 | + $sb .= $ch; |
|
238 | + $this->moveNext(); |
|
239 | + } |
|
240 | + return $sb; |
|
241 | + } |
|
242 | + |
|
243 | + function skipInTag ($chars) { |
|
244 | + $sb = ""; |
|
245 | + while (($ch = $this->iCurrentChar) !== -1) { |
|
246 | + if ($ch == ">") { |
|
247 | + return $sb; |
|
248 | + } else { |
|
249 | + if (array_search($ch,$chars) === false) |
|
250 | + return $sb; |
|
251 | + $sb .= $ch; |
|
252 | + $this->moveNext(); |
|
253 | + } |
|
254 | + } |
|
255 | + return $sb; |
|
256 | + } |
|
257 | + |
|
258 | + function skipToInTag ($chars) { |
|
259 | + $sb = ""; |
|
260 | + while (($ch = $this->iCurrentChar) !== -1) { |
|
261 | + if ($ch == '>' || array_search($ch,$chars) !== false) |
|
262 | + return $sb; |
|
263 | + $sb .= $ch; |
|
264 | + $this->moveNext(); |
|
265 | + } |
|
266 | + return $sb; |
|
267 | + } |
|
268 | + |
|
269 | + function skipToElement() { |
|
270 | + $sb = ""; |
|
271 | + while (($ch = $this->iCurrentChar) !== -1) { |
|
272 | + if ($ch == "<") { |
|
273 | + return $sb; |
|
274 | + } |
|
275 | + $sb .= $ch; |
|
276 | + $this->moveNext(); |
|
277 | + } |
|
278 | + return $sb; |
|
279 | + } |
|
280 | + |
|
281 | + /** |
|
282 | + * Returns text between current position and $needle, |
|
283 | + * inclusive, or "" if not found. The current index is moved to a point |
|
284 | + * after the location of $needle, or not moved at all |
|
285 | + * if nothing is found. |
|
286 | + */ |
|
287 | + function skipToStringInTag ($needle) { |
|
288 | + $pos = strpos ($this->iHtmlText, $needle, $this->iHtmlTextIndex); |
|
289 | + if ($pos === false) { |
|
290 | + return ""; |
|
291 | + } |
|
292 | + $top = $pos + strlen($needle); |
|
293 | + $retvalue = substr ($this->iHtmlText, $this->iHtmlTextIndex, $top - $this->iHtmlTextIndex); |
|
294 | + $this->setTextIndex ($top); |
|
295 | + return $retvalue; |
|
296 | + } |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | class HTMLFileParser extends HTMLParser { |
300 | 300 | function HTMLFileParser($fileName){ |
301 | - $fp = fopen ($fileName, "r"); |
|
302 | - $content = ""; |
|
303 | - while (true) { |
|
304 | - $data = fread ($fp, 8192); |
|
305 | - if (strlen($data) == 0) { |
|
306 | - break; |
|
307 | - } |
|
308 | - $content .= $data; |
|
309 | - } |
|
310 | - fclose ($fp); |
|
301 | + $fp = fopen ($fileName, "r"); |
|
302 | + $content = ""; |
|
303 | + while (true) { |
|
304 | + $data = fread ($fp, 8192); |
|
305 | + if (strlen($data) == 0) { |
|
306 | + break; |
|
307 | + } |
|
308 | + $content .= $data; |
|
309 | + } |
|
310 | + fclose ($fp); |
|
311 | 311 | $this->HTMLParser($content); |
312 | 312 | } |
313 | 313 | } |
314 | 314 | |
315 | 315 | class HTMLURLParser extends HTMLParser { |
316 | 316 | function HTMLURLParser($url){ |
317 | - $fp = fopen ($url, "r"); |
|
318 | - $content = ""; |
|
319 | - while (true) { |
|
320 | - $data = fread ($fp, 8192); |
|
321 | - if (strlen($data) == 0) { |
|
322 | - break; |
|
323 | - } |
|
324 | - $content .= $data; |
|
325 | - } |
|
326 | - fclose ($fp); |
|
317 | + $fp = fopen ($url, "r"); |
|
318 | + $content = ""; |
|
319 | + while (true) { |
|
320 | + $data = fread ($fp, 8192); |
|
321 | + if (strlen($data) == 0) { |
|
322 | + break; |
|
323 | + } |
|
324 | + $content .= $data; |
|
325 | + } |
|
326 | + fclose ($fp); |
|
327 | 327 | $this->HTMLParser(file_get_contents($content)); |
328 | 328 | } |
329 | 329 | } |
@@ -341,29 +341,29 @@ discard block |
||
341 | 341 | * @desc Tao mot tree node cac phan tu cua HTML |
342 | 342 | */ |
343 | 343 | function TreeHTML($parser, $file=true){ |
344 | - $i = 0; |
|
345 | - if ($file){ |
|
346 | - while ($parser->parse()) |
|
347 | - if (strtolower($parser->iNodeName)=='body') break; |
|
348 | - } |
|
349 | - while ($parser->parse()){ |
|
350 | - if ($parser->iNodeType == NODE_TYPE_ENDELEMENT && strtolower($parser->iNodeName)=='body' && $file) break; |
|
351 | - |
|
352 | - $this->type[$i] = $parser->iNodeType; |
|
353 | - $this->name[$i] = $parser->iNodeName; |
|
354 | - if ($parser->iNodeType == NODE_TYPE_TEXT) |
|
355 | - $this->value[$i] = $parser->iNodeValue; |
|
356 | - if ($parser->iNodeType == NODE_TYPE_ELEMENT){ |
|
357 | - $this->attribute[$i] = $parser->iNodeAttributes; |
|
358 | - if (isset($parser->iNodeAttributes['name'])){ |
|
359 | - $this->field[$i] = trim($parser->iNodeAttributes['name'],"\"' "); |
|
360 | - } |
|
361 | - if ( ($file && $parser->iNodeName == 'input' && isset($this->attribute[$i]['type']) && $this->attribute[$i]['type']=='text' && !isset($this->attribute[$i]['onkeydown'])) |
|
362 | - || ($file && $parser->iNodeName == 'textarea')) |
|
363 | - $this->attribute[$i]['onkeyup'] = 'initTyper(this)'; |
|
364 | - } |
|
365 | - $i++; |
|
366 | - } |
|
344 | + $i = 0; |
|
345 | + if ($file){ |
|
346 | + while ($parser->parse()) |
|
347 | + if (strtolower($parser->iNodeName)=='body') break; |
|
348 | + } |
|
349 | + while ($parser->parse()){ |
|
350 | + if ($parser->iNodeType == NODE_TYPE_ENDELEMENT && strtolower($parser->iNodeName)=='body' && $file) break; |
|
351 | + |
|
352 | + $this->type[$i] = $parser->iNodeType; |
|
353 | + $this->name[$i] = $parser->iNodeName; |
|
354 | + if ($parser->iNodeType == NODE_TYPE_TEXT) |
|
355 | + $this->value[$i] = $parser->iNodeValue; |
|
356 | + if ($parser->iNodeType == NODE_TYPE_ELEMENT){ |
|
357 | + $this->attribute[$i] = $parser->iNodeAttributes; |
|
358 | + if (isset($parser->iNodeAttributes['name'])){ |
|
359 | + $this->field[$i] = trim($parser->iNodeAttributes['name'],"\"' "); |
|
360 | + } |
|
361 | + if ( ($file && $parser->iNodeName == 'input' && isset($this->attribute[$i]['type']) && $this->attribute[$i]['type']=='text' && !isset($this->attribute[$i]['onkeydown'])) |
|
362 | + || ($file && $parser->iNodeName == 'textarea')) |
|
363 | + $this->attribute[$i]['onkeyup'] = 'initTyper(this)'; |
|
364 | + } |
|
365 | + $i++; |
|
366 | + } |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
@@ -17,6 +17,6 @@ |
||
17 | 17 | $slas = new SLA($db); |
18 | 18 | $emails = new Emails($db); |
19 | 19 | } catch (Exception $e) { |
20 | - echo 'Caught exception: ', $e->getMessage(), "\n"; |
|
20 | + echo 'Caught exception: ', $e->getMessage(), "\n"; |
|
21 | 21 | } |
22 | 22 | ?> |
23 | 23 | \ No newline at end of file |