@@ -41,19 +41,19 @@ discard block |
||
| 41 | 41 | var $Query_ID = 0; |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | - * Execute a query |
|
| 45 | - * |
|
| 46 | - * @param string $Query_String the query to be executed |
|
| 47 | - * @param int $line the line method was called from - use __LINE__ |
|
| 48 | - * @param string $file the file method was called from - use __FILE__ |
|
| 49 | - * @param int $offset row to start from, default 0 |
|
| 50 | - * @param int $num_rows number of rows to return (optional), default -1 = all, 0 will use $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'] |
|
| 51 | - * @param array|boolean $inputarr array for binding variables to parameters or false (default) |
|
| 52 | - * @param int $fetchmode =self::FETCH_BOTH self::FETCH_BOTH (default), self::FETCH_ASSOC or self::FETCH_NUM |
|
| 53 | - * @param boolean $reconnect =true true: try reconnecting if server closes connection, false: dont (mysql only!) |
|
| 54 | - * @return ADORecordSet or false, if the query fails |
|
| 55 | - * @throws EGroupware\Api\Db\Exception\InvalidSql with $this->Link_ID->ErrorNo() as code |
|
| 56 | - */ |
|
| 44 | + * Execute a query |
|
| 45 | + * |
|
| 46 | + * @param string $Query_String the query to be executed |
|
| 47 | + * @param int $line the line method was called from - use __LINE__ |
|
| 48 | + * @param string $file the file method was called from - use __FILE__ |
|
| 49 | + * @param int $offset row to start from, default 0 |
|
| 50 | + * @param int $num_rows number of rows to return (optional), default -1 = all, 0 will use $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'] |
|
| 51 | + * @param array|boolean $inputarr array for binding variables to parameters or false (default) |
|
| 52 | + * @param int $fetchmode =self::FETCH_BOTH self::FETCH_BOTH (default), self::FETCH_ASSOC or self::FETCH_NUM |
|
| 53 | + * @param boolean $reconnect =true true: try reconnecting if server closes connection, false: dont (mysql only!) |
|
| 54 | + * @return ADORecordSet or false, if the query fails |
|
| 55 | + * @throws EGroupware\Api\Db\Exception\InvalidSql with $this->Link_ID->ErrorNo() as code |
|
| 56 | + */ |
|
| 57 | 57 | function query($Query_String, $line = '', $file = '', $offset=0, $num_rows=-1, $inputarr=false, $fetchmode=self::FETCH_BOTH, $reconnect=true) |
| 58 | 58 | { |
| 59 | 59 | // New query, discard previous result. |
@@ -76,12 +76,12 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | - * Escape strings before sending them to the database |
|
| 80 | - * |
|
| 81 | - * @deprecated use quote($value,$type='') instead |
|
| 82 | - * @param string $str the string to be escaped |
|
| 83 | - * @return string escaped sting |
|
| 84 | - */ |
|
| 79 | + * Escape strings before sending them to the database |
|
| 80 | + * |
|
| 81 | + * @deprecated use quote($value,$type='') instead |
|
| 82 | + * @param string $str the string to be escaped |
|
| 83 | + * @return string escaped sting |
|
| 84 | + */ |
|
| 85 | 85 | function db_addslashes($str) |
| 86 | 86 | { |
| 87 | 87 | if (!isset($str) || $str == '') |
@@ -107,14 +107,14 @@ discard block |
||
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | - * Move to the next row in the results set |
|
| 111 | - * |
|
| 112 | - * Specifying a fetch_mode only works for newly fetched rows, the first row always gets fetched by query!!! |
|
| 113 | - * |
|
| 114 | - * @deprecated use foreach(query() or foreach(select() to loop over the query using the global db object |
|
| 115 | - * @param int $fetch_mode self::FETCH_BOTH = numerical+assoc keys (eGW default), self::FETCH_ASSOC or self::FETCH_NUM |
|
| 116 | - * @return bool was another row found? |
|
| 117 | - */ |
|
| 110 | + * Move to the next row in the results set |
|
| 111 | + * |
|
| 112 | + * Specifying a fetch_mode only works for newly fetched rows, the first row always gets fetched by query!!! |
|
| 113 | + * |
|
| 114 | + * @deprecated use foreach(query() or foreach(select() to loop over the query using the global db object |
|
| 115 | + * @param int $fetch_mode self::FETCH_BOTH = numerical+assoc keys (eGW default), self::FETCH_ASSOC or self::FETCH_NUM |
|
| 116 | + * @return bool was another row found? |
|
| 117 | + */ |
|
| 118 | 118 | function next_record($fetch_mode=self::FETCH_BOTH) |
| 119 | 119 | { |
| 120 | 120 | if (!$this->Query_ID) |
@@ -164,12 +164,12 @@ discard block |
||
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /** |
| 167 | - * Move to position in result set |
|
| 168 | - * |
|
| 169 | - * @deprecated use the result-object returned by query() or select() direct, so you can use the global db-object and not a clone |
|
| 170 | - * @param int $pos required row (optional), default first row |
|
| 171 | - * @return boolean true if sucessful or false if not found |
|
| 172 | - */ |
|
| 167 | + * Move to position in result set |
|
| 168 | + * |
|
| 169 | + * @deprecated use the result-object returned by query() or select() direct, so you can use the global db-object and not a clone |
|
| 170 | + * @param int $pos required row (optional), default first row |
|
| 171 | + * @return boolean true if sucessful or false if not found |
|
| 172 | + */ |
|
| 173 | 173 | function seek($pos = 0) |
| 174 | 174 | { |
| 175 | 175 | if (!$this->Query_ID || !$this->Query_ID->Move($this->Row = $pos)) |
@@ -180,74 +180,74 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
| 183 | - * Lock a table |
|
| 184 | - * |
|
| 185 | - * @deprecated not used anymore as it costs to much performance, use transactions if needed |
|
| 186 | - * @param string $table name of table to lock |
|
| 187 | - * @param string $mode type of lock required (optional), default write |
|
| 188 | - * @return bool True if sucessful, False if fails |
|
| 189 | - */ |
|
| 183 | + * Lock a table |
|
| 184 | + * |
|
| 185 | + * @deprecated not used anymore as it costs to much performance, use transactions if needed |
|
| 186 | + * @param string $table name of table to lock |
|
| 187 | + * @param string $mode type of lock required (optional), default write |
|
| 188 | + * @return bool True if sucessful, False if fails |
|
| 189 | + */ |
|
| 190 | 190 | function lock($table, $mode='write') |
| 191 | 191 | { |
| 192 | 192 | unset($table, $mode); // not used anymore |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
| 196 | - * Unlock a table |
|
| 197 | - * |
|
| 198 | - * @deprecated not used anymore as it costs to much performance, use transactions if needed |
|
| 199 | - * @return bool True if sucessful, False if fails |
|
| 200 | - */ |
|
| 196 | + * Unlock a table |
|
| 197 | + * |
|
| 198 | + * @deprecated not used anymore as it costs to much performance, use transactions if needed |
|
| 199 | + * @return bool True if sucessful, False if fails |
|
| 200 | + */ |
|
| 201 | 201 | function unlock() |
| 202 | 202 | {} |
| 203 | 203 | |
| 204 | 204 | /** |
| 205 | - * Number of rows in current result set |
|
| 206 | - * |
|
| 207 | - * @deprecated use the result-object returned by query/select()->NumRows(), so you can use the global db-object and not a clone |
|
| 208 | - * @return int number of rows |
|
| 209 | - */ |
|
| 205 | + * Number of rows in current result set |
|
| 206 | + * |
|
| 207 | + * @deprecated use the result-object returned by query/select()->NumRows(), so you can use the global db-object and not a clone |
|
| 208 | + * @return int number of rows |
|
| 209 | + */ |
|
| 210 | 210 | function num_rows() |
| 211 | 211 | { |
| 212 | 212 | return $this->Query_ID ? $this->Query_ID->RecordCount() : False; |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | - * Number of fields in current row |
|
| 217 | - * |
|
| 218 | - * @deprecated use the result-object returned by query() or select() direct, so you can use the global db-object and not a clone |
|
| 219 | - * @return int number of fields |
|
| 220 | - */ |
|
| 216 | + * Number of fields in current row |
|
| 217 | + * |
|
| 218 | + * @deprecated use the result-object returned by query() or select() direct, so you can use the global db-object and not a clone |
|
| 219 | + * @return int number of fields |
|
| 220 | + */ |
|
| 221 | 221 | function num_fields() |
| 222 | 222 | { |
| 223 | 223 | return $this->Query_ID ? $this->Query_ID->FieldCount() : False; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
| 227 | - * @deprecated use num_rows() |
|
| 228 | - */ |
|
| 227 | + * @deprecated use num_rows() |
|
| 228 | + */ |
|
| 229 | 229 | function nf() |
| 230 | 230 | { |
| 231 | 231 | return $this->num_rows(); |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | /** |
| 235 | - * @deprecated use print num_rows() |
|
| 236 | - */ |
|
| 235 | + * @deprecated use print num_rows() |
|
| 236 | + */ |
|
| 237 | 237 | function np() |
| 238 | 238 | { |
| 239 | 239 | print $this->num_rows(); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
| 243 | - * Return the value of a column |
|
| 244 | - * |
|
| 245 | - * @deprecated use the result-object returned by query() or select() direct, so you can use the global db-object and not a clone |
|
| 246 | - * @param string|integer $Name name of field or positional index starting from 0 |
|
| 247 | - * @param bool $strip_slashes string escape chars from field(optional), default false |
|
| 248 | - * depricated param, as correctly quoted values dont need any stripslashes! |
|
| 249 | - * @return string the field value |
|
| 250 | - */ |
|
| 243 | + * Return the value of a column |
|
| 244 | + * |
|
| 245 | + * @deprecated use the result-object returned by query() or select() direct, so you can use the global db-object and not a clone |
|
| 246 | + * @param string|integer $Name name of field or positional index starting from 0 |
|
| 247 | + * @param bool $strip_slashes string escape chars from field(optional), default false |
|
| 248 | + * depricated param, as correctly quoted values dont need any stripslashes! |
|
| 249 | + * @return string the field value |
|
| 250 | + */ |
|
| 251 | 251 | function f($Name, $strip_slashes = False) |
| 252 | 252 | { |
| 253 | 253 | if ($strip_slashes) |
@@ -258,26 +258,26 @@ discard block |
||
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | /** |
| 261 | - * Print the value of a field |
|
| 262 | - * |
|
| 263 | - * @deprecated use the result-object returned by query() or select() direct, so you can use the global db-object and not a clone |
|
| 264 | - * @param string $Name name of field to print |
|
| 265 | - * @param bool $strip_slashes string escape chars from field(optional), default false |
|
| 266 | - * depricated param, as correctly quoted values dont need any stripslashes! |
|
| 267 | - */ |
|
| 261 | + * Print the value of a field |
|
| 262 | + * |
|
| 263 | + * @deprecated use the result-object returned by query() or select() direct, so you can use the global db-object and not a clone |
|
| 264 | + * @param string $Name name of field to print |
|
| 265 | + * @param bool $strip_slashes string escape chars from field(optional), default false |
|
| 266 | + * depricated param, as correctly quoted values dont need any stripslashes! |
|
| 267 | + */ |
|
| 268 | 268 | function p($Name, $strip_slashes = True) |
| 269 | 269 | { |
| 270 | 270 | print $this->f($Name, $strip_slashes); |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
| 274 | - * Returns a query-result-row as an associative array (no numerical keys !!!) |
|
| 275 | - * |
|
| 276 | - * @deprecated use foreach(query() or foreach(select() to loop over the query using the global db object |
|
| 277 | - * @param bool $do_next_record should next_record() be called or not (default not) |
|
| 278 | - * @param string $strip ='' string to strip of the column-name, default '' |
|
| 279 | - * @return array/bool the associative array or False if no (more) result-row is availible |
|
| 280 | - */ |
|
| 274 | + * Returns a query-result-row as an associative array (no numerical keys !!!) |
|
| 275 | + * |
|
| 276 | + * @deprecated use foreach(query() or foreach(select() to loop over the query using the global db object |
|
| 277 | + * @param bool $do_next_record should next_record() be called or not (default not) |
|
| 278 | + * @param string $strip ='' string to strip of the column-name, default '' |
|
| 279 | + * @return array/bool the associative array or False if no (more) result-row is availible |
|
| 280 | + */ |
|
| 281 | 281 | function row($do_next_record=False,$strip='') |
| 282 | 282 | { |
| 283 | 283 | if ($do_next_record && !$this->next_record(self::FETCH_ASSOC) || !is_array($this->Record)) |
@@ -170,7 +170,7 @@ |
||
| 170 | 170 | * |
| 171 | 171 | * @param string/array $_contact_id contact_id or array with values for id or account_id |
| 172 | 172 | * @return array/boolean data if row could be retrived else False |
| 173 | - */ |
|
| 173 | + */ |
|
| 174 | 174 | function read($_contact_id) |
| 175 | 175 | { |
| 176 | 176 | if (is_array($_contact_id) && isset($_contact_id['account_id']) || |
@@ -41,33 +41,33 @@ discard block |
||
| 41 | 41 | var $contacts_id='id'; |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | - * @var string $accountName holds the accountname of the current user |
|
| 45 | - */ |
|
| 44 | + * @var string $accountName holds the accountname of the current user |
|
| 45 | + */ |
|
| 46 | 46 | var $accountName; |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | - * @var object $ldapServerInfo holds the information about the current used ldap server |
|
| 50 | - */ |
|
| 49 | + * @var object $ldapServerInfo holds the information about the current used ldap server |
|
| 50 | + */ |
|
| 51 | 51 | var $ldapServerInfo; |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | - * @var int $ldapLimit how many rows to fetch from ldap server |
|
| 55 | - */ |
|
| 54 | + * @var int $ldapLimit how many rows to fetch from ldap server |
|
| 55 | + */ |
|
| 56 | 56 | var $ldapLimit = 2000; |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | - * @var string $personalContactsDN holds the base DN for the personal addressbooks |
|
| 60 | - */ |
|
| 59 | + * @var string $personalContactsDN holds the base DN for the personal addressbooks |
|
| 60 | + */ |
|
| 61 | 61 | var $personalContactsDN; |
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | - * @var string $sharedContactsDN holds the base DN for the shared addressbooks |
|
| 65 | - */ |
|
| 64 | + * @var string $sharedContactsDN holds the base DN for the shared addressbooks |
|
| 65 | + */ |
|
| 66 | 66 | var $sharedContactsDN; |
| 67 | 67 | |
| 68 | 68 | /** |
| 69 | - * @var string $accountContactsDN holds the base DN for accounts addressbook |
|
| 70 | - */ |
|
| 69 | + * @var string $accountContactsDN holds the base DN for accounts addressbook |
|
| 70 | + */ |
|
| 71 | 71 | var $accountContactsDN; |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | var $accountsFilter = '(objectclass=posixaccount)'; |
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | - * @var string $allContactsDN holds the base DN of all addressbook |
|
| 81 | - */ |
|
| 80 | + * @var string $allContactsDN holds the base DN of all addressbook |
|
| 81 | + */ |
|
| 82 | 82 | var $allContactsDN; |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | var $never_change_dn = false; |
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | - * @var int $total holds the total count of found rows |
|
| 100 | - */ |
|
| 99 | + * @var int $total holds the total count of found rows |
|
| 100 | + */ |
|
| 101 | 101 | var $total; |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | * |
| 404 | 404 | * @param string|array $contact_id contact_id or array with values for id or account_id |
| 405 | 405 | * @return array/boolean data if row could be retrived else False |
| 406 | - */ |
|
| 406 | + */ |
|
| 407 | 407 | function read($contact_id) |
| 408 | 408 | { |
| 409 | 409 | if (is_array($contact_id) && isset($contact_id['account_id']) || |
@@ -858,9 +858,9 @@ |
||
| 858 | 858 | } |
| 859 | 859 | |
| 860 | 860 | /** |
| 861 | - * Deletes custom field data |
|
| 862 | - * Implemented to deal with LDAP backend, which saves CFs in SQL, but the account record is in LDAP |
|
| 863 | - */ |
|
| 861 | + * Deletes custom field data |
|
| 862 | + * Implemented to deal with LDAP backend, which saves CFs in SQL, but the account record is in LDAP |
|
| 863 | + */ |
|
| 864 | 864 | function delete_customfields($data) |
| 865 | 865 | { |
| 866 | 866 | $this->db->delete($this->extra_table,$data,__LINE__,__FILE__); |
@@ -447,10 +447,10 @@ discard block |
||
| 447 | 447 | * Important: PHP 5.0 introduced a bug that wasn't fixed until 5.1: the return value has to be the oposite! |
| 448 | 448 | * |
| 449 | 449 | * if(version_compare(PHP_VERSION,'5.0','>=') && version_compare(PHP_VERSION,'5.1','<')) |
| 450 | - * { |
|
| 450 | + * { |
|
| 451 | 451 | * $eof = !$eof; |
| 452 | 452 | * } |
| 453 | - * |
|
| 453 | + * |
|
| 454 | 454 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
| 455 | 455 | */ |
| 456 | 456 | function stream_eof ( ) |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | * See fseek() for more information about these parameters. |
| 486 | 486 | * |
| 487 | 487 | * @param integer $offset |
| 488 | - * @param integer $whence SEEK_SET - 0 - Set position equal to offset bytes |
|
| 488 | + * @param integer $whence SEEK_SET - 0 - Set position equal to offset bytes |
|
| 489 | 489 | * SEEK_CUR - 1 - Set position to current location plus offset. |
| 490 | 490 | * SEEK_END - 2 - Set position to end-of-file plus offset. (To move to a position before the end-of-file, you need to pass a negative value in offset.) |
| 491 | 491 | * @return boolean TRUE if the position was updated, FALSE otherwise. |
@@ -681,8 +681,8 @@ discard block |
||
| 681 | 681 | $maxdepth=10; |
| 682 | 682 | $depth2propagate = (int)$depth + 1; |
| 683 | 683 | if ($depth2propagate > $maxdepth) return is_dir($pathname); |
| 684 | - is_dir(Vfs::dirname($pathname)) || self::mkdir_recursive(Vfs::dirname($pathname), $mode, $depth2propagate); |
|
| 685 | - return is_dir($pathname) || @mkdir($pathname, $mode); |
|
| 684 | + is_dir(Vfs::dirname($pathname)) || self::mkdir_recursive(Vfs::dirname($pathname), $mode, $depth2propagate); |
|
| 685 | + return is_dir($pathname) || @mkdir($pathname, $mode); |
|
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | /** |
@@ -228,10 +228,10 @@ |
||
| 228 | 228 | * Important: PHP 5.0 introduced a bug that wasn't fixed until 5.1: the return value has to be the oposite! |
| 229 | 229 | * |
| 230 | 230 | * if(version_compare(PHP_VERSION,'5.0','>=') && version_compare(PHP_VERSION,'5.1','<')) |
| 231 | - * { |
|
| 231 | + * { |
|
| 232 | 232 | * $eof = !$eof; |
| 233 | 233 | * } |
| 234 | - * |
|
| 234 | + * |
|
| 235 | 235 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
| 236 | 236 | */ |
| 237 | 237 | function stream_eof ( ) |
@@ -80,10 +80,10 @@ |
||
| 80 | 80 | * Important: PHP 5.0 introduced a bug that wasn't fixed until 5.1: the return value has to be the oposite! |
| 81 | 81 | * |
| 82 | 82 | * if(version_compare(PHP_VERSION,'5.0','>=') && version_compare(PHP_VERSION,'5.1','<')) |
| 83 | - * { |
|
| 83 | + * { |
|
| 84 | 84 | * $eof = !$eof; |
| 85 | 85 | * } |
| 86 | - * |
|
| 86 | + * |
|
| 87 | 87 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
| 88 | 88 | */ |
| 89 | 89 | function stream_eof ( ); |
@@ -43,209 +43,209 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | class _parse_lockinfo |
| 45 | 45 | { |
| 46 | - /** |
|
| 47 | - * success state flag |
|
| 48 | - * |
|
| 49 | - * @var bool |
|
| 50 | - * @access public |
|
| 51 | - */ |
|
| 52 | - var $success = false; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * lock type, currently only "write" |
|
| 56 | - * |
|
| 57 | - * @var string |
|
| 58 | - * @access public |
|
| 59 | - */ |
|
| 60 | - var $locktype = ""; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * lock scope, "shared" or "exclusive" |
|
| 64 | - * |
|
| 65 | - * @var string |
|
| 66 | - * @access public |
|
| 67 | - */ |
|
| 68 | - var $lockscope = ""; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * lock owner information |
|
| 72 | - * |
|
| 73 | - * @var string |
|
| 74 | - * @access public |
|
| 75 | - */ |
|
| 76 | - var $owner = ""; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * flag that is set during lock owner read |
|
| 80 | - * |
|
| 81 | - * @var bool |
|
| 82 | - * @access private |
|
| 83 | - */ |
|
| 84 | - var $collect_owner = false; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * constructor |
|
| 88 | - * |
|
| 89 | - * @param string path of stream to read |
|
| 90 | - * @access public |
|
| 91 | - */ |
|
| 92 | - function __construct($path) |
|
| 93 | - { |
|
| 94 | - // we assume success unless problems occur |
|
| 95 | - $this->success = true; |
|
| 96 | - |
|
| 97 | - // remember if any input was parsed |
|
| 98 | - $had_input = false; |
|
| 99 | - |
|
| 100 | - // open stream |
|
| 101 | - $f_in = fopen($path, "r"); |
|
| 102 | - if (!$f_in) { |
|
| 103 | - $this->success = false; |
|
| 104 | - return; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - // create namespace aware parser |
|
| 108 | - $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
| 109 | - |
|
| 110 | - // set tag and data handlers |
|
| 111 | - xml_set_element_handler($xml_parser, |
|
| 112 | - array(&$this, "_startElement"), |
|
| 113 | - array(&$this, "_endElement")); |
|
| 114 | - xml_set_character_data_handler($xml_parser, |
|
| 115 | - array(&$this, "_data")); |
|
| 116 | - |
|
| 117 | - // we want a case sensitive parser |
|
| 118 | - xml_parser_set_option($xml_parser, |
|
| 119 | - XML_OPTION_CASE_FOLDING, false); |
|
| 120 | - |
|
| 121 | - // parse input |
|
| 122 | - while ($this->success && !feof($f_in)) { |
|
| 123 | - $line = fgets($f_in); |
|
| 124 | - if (is_string($line)) { |
|
| 125 | - $had_input = true; |
|
| 126 | - $this->success &= xml_parse($xml_parser, $line, false); |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - // finish parsing |
|
| 131 | - if ($had_input) { |
|
| 132 | - $this->success &= xml_parse($xml_parser, "", true); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - // check if required tags where found |
|
| 136 | - $this->success &= !empty($this->locktype); |
|
| 137 | - $this->success &= !empty($this->lockscope); |
|
| 138 | - |
|
| 139 | - // free parser resource |
|
| 140 | - xml_parser_free($xml_parser); |
|
| 141 | - |
|
| 142 | - // close input stream |
|
| 143 | - fclose($f_in); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * tag start handler |
|
| 149 | - * |
|
| 150 | - * @param resource parser |
|
| 151 | - * @param string tag name |
|
| 152 | - * @param array tag attributes |
|
| 153 | - * @return void |
|
| 154 | - * @access private |
|
| 155 | - */ |
|
| 156 | - function _startElement($parser, $name, $attrs) |
|
| 157 | - { |
|
| 158 | - // namespace handling |
|
| 159 | - if (strstr($name, " ")) { |
|
| 160 | - list($ns, $tag) = explode(" ", $name); |
|
| 161 | - } else { |
|
| 162 | - $ns = ""; |
|
| 163 | - $tag = $name; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - if ($this->collect_owner) { |
|
| 168 | - // everything within the <owner> tag needs to be collected |
|
| 169 | - $ns_short = ""; |
|
| 170 | - $ns_attr = ""; |
|
| 171 | - if ($ns) { |
|
| 172 | - if ($ns == "DAV:") { |
|
| 173 | - $ns_short = "D:"; |
|
| 174 | - } else { |
|
| 175 | - $ns_attr = " xmlns='$ns'"; |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - $this->owner .= "<$ns_short$tag$ns_attr>"; |
|
| 179 | - } else if ($ns == "DAV:") { |
|
| 180 | - // parse only the essential tags |
|
| 181 | - switch ($tag) { |
|
| 182 | - case "write": |
|
| 183 | - $this->locktype = $tag; |
|
| 184 | - break; |
|
| 185 | - case "exclusive": |
|
| 186 | - case "shared": |
|
| 187 | - $this->lockscope = $tag; |
|
| 188 | - break; |
|
| 189 | - case "owner": |
|
| 190 | - $this->collect_owner = true; |
|
| 191 | - break; |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * data handler |
|
| 198 | - * |
|
| 199 | - * @param resource parser |
|
| 200 | - * @param string data |
|
| 201 | - * @return void |
|
| 202 | - * @access private |
|
| 203 | - */ |
|
| 204 | - function _data($parser, $data) |
|
| 205 | - { |
|
| 206 | - // only the <owner> tag has data content |
|
| 207 | - if ($this->collect_owner) { |
|
| 208 | - $this->owner .= $data; |
|
| 209 | - } |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * tag end handler |
|
| 214 | - * |
|
| 215 | - * @param resource parser |
|
| 216 | - * @param string tag name |
|
| 217 | - * @return void |
|
| 218 | - * @access private |
|
| 219 | - */ |
|
| 220 | - function _endElement($parser, $name) |
|
| 221 | - { |
|
| 222 | - // namespace handling |
|
| 223 | - if (strstr($name, " ")) { |
|
| 224 | - list($ns, $tag) = explode(" ", $name); |
|
| 225 | - } else { |
|
| 226 | - $ns = ""; |
|
| 227 | - $tag = $name; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - // <owner> finished? |
|
| 231 | - if (($ns == "DAV:") && ($tag == "owner")) { |
|
| 232 | - $this->collect_owner = false; |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - // within <owner> we have to collect everything |
|
| 236 | - if ($this->collect_owner) { |
|
| 237 | - $ns_short = ""; |
|
| 238 | - $ns_attr = ""; |
|
| 239 | - if ($ns) { |
|
| 240 | - if ($ns == "DAV:") { |
|
| 241 | - $ns_short = "D:"; |
|
| 242 | - } else { |
|
| 243 | - $ns_attr = " xmlns='$ns'"; |
|
| 244 | - } |
|
| 245 | - } |
|
| 246 | - $this->owner .= "</$ns_short$tag$ns_attr>"; |
|
| 247 | - } |
|
| 248 | - } |
|
| 46 | + /** |
|
| 47 | + * success state flag |
|
| 48 | + * |
|
| 49 | + * @var bool |
|
| 50 | + * @access public |
|
| 51 | + */ |
|
| 52 | + var $success = false; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * lock type, currently only "write" |
|
| 56 | + * |
|
| 57 | + * @var string |
|
| 58 | + * @access public |
|
| 59 | + */ |
|
| 60 | + var $locktype = ""; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * lock scope, "shared" or "exclusive" |
|
| 64 | + * |
|
| 65 | + * @var string |
|
| 66 | + * @access public |
|
| 67 | + */ |
|
| 68 | + var $lockscope = ""; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * lock owner information |
|
| 72 | + * |
|
| 73 | + * @var string |
|
| 74 | + * @access public |
|
| 75 | + */ |
|
| 76 | + var $owner = ""; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * flag that is set during lock owner read |
|
| 80 | + * |
|
| 81 | + * @var bool |
|
| 82 | + * @access private |
|
| 83 | + */ |
|
| 84 | + var $collect_owner = false; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * constructor |
|
| 88 | + * |
|
| 89 | + * @param string path of stream to read |
|
| 90 | + * @access public |
|
| 91 | + */ |
|
| 92 | + function __construct($path) |
|
| 93 | + { |
|
| 94 | + // we assume success unless problems occur |
|
| 95 | + $this->success = true; |
|
| 96 | + |
|
| 97 | + // remember if any input was parsed |
|
| 98 | + $had_input = false; |
|
| 99 | + |
|
| 100 | + // open stream |
|
| 101 | + $f_in = fopen($path, "r"); |
|
| 102 | + if (!$f_in) { |
|
| 103 | + $this->success = false; |
|
| 104 | + return; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + // create namespace aware parser |
|
| 108 | + $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
| 109 | + |
|
| 110 | + // set tag and data handlers |
|
| 111 | + xml_set_element_handler($xml_parser, |
|
| 112 | + array(&$this, "_startElement"), |
|
| 113 | + array(&$this, "_endElement")); |
|
| 114 | + xml_set_character_data_handler($xml_parser, |
|
| 115 | + array(&$this, "_data")); |
|
| 116 | + |
|
| 117 | + // we want a case sensitive parser |
|
| 118 | + xml_parser_set_option($xml_parser, |
|
| 119 | + XML_OPTION_CASE_FOLDING, false); |
|
| 120 | + |
|
| 121 | + // parse input |
|
| 122 | + while ($this->success && !feof($f_in)) { |
|
| 123 | + $line = fgets($f_in); |
|
| 124 | + if (is_string($line)) { |
|
| 125 | + $had_input = true; |
|
| 126 | + $this->success &= xml_parse($xml_parser, $line, false); |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + // finish parsing |
|
| 131 | + if ($had_input) { |
|
| 132 | + $this->success &= xml_parse($xml_parser, "", true); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + // check if required tags where found |
|
| 136 | + $this->success &= !empty($this->locktype); |
|
| 137 | + $this->success &= !empty($this->lockscope); |
|
| 138 | + |
|
| 139 | + // free parser resource |
|
| 140 | + xml_parser_free($xml_parser); |
|
| 141 | + |
|
| 142 | + // close input stream |
|
| 143 | + fclose($f_in); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * tag start handler |
|
| 149 | + * |
|
| 150 | + * @param resource parser |
|
| 151 | + * @param string tag name |
|
| 152 | + * @param array tag attributes |
|
| 153 | + * @return void |
|
| 154 | + * @access private |
|
| 155 | + */ |
|
| 156 | + function _startElement($parser, $name, $attrs) |
|
| 157 | + { |
|
| 158 | + // namespace handling |
|
| 159 | + if (strstr($name, " ")) { |
|
| 160 | + list($ns, $tag) = explode(" ", $name); |
|
| 161 | + } else { |
|
| 162 | + $ns = ""; |
|
| 163 | + $tag = $name; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + if ($this->collect_owner) { |
|
| 168 | + // everything within the <owner> tag needs to be collected |
|
| 169 | + $ns_short = ""; |
|
| 170 | + $ns_attr = ""; |
|
| 171 | + if ($ns) { |
|
| 172 | + if ($ns == "DAV:") { |
|
| 173 | + $ns_short = "D:"; |
|
| 174 | + } else { |
|
| 175 | + $ns_attr = " xmlns='$ns'"; |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + $this->owner .= "<$ns_short$tag$ns_attr>"; |
|
| 179 | + } else if ($ns == "DAV:") { |
|
| 180 | + // parse only the essential tags |
|
| 181 | + switch ($tag) { |
|
| 182 | + case "write": |
|
| 183 | + $this->locktype = $tag; |
|
| 184 | + break; |
|
| 185 | + case "exclusive": |
|
| 186 | + case "shared": |
|
| 187 | + $this->lockscope = $tag; |
|
| 188 | + break; |
|
| 189 | + case "owner": |
|
| 190 | + $this->collect_owner = true; |
|
| 191 | + break; |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * data handler |
|
| 198 | + * |
|
| 199 | + * @param resource parser |
|
| 200 | + * @param string data |
|
| 201 | + * @return void |
|
| 202 | + * @access private |
|
| 203 | + */ |
|
| 204 | + function _data($parser, $data) |
|
| 205 | + { |
|
| 206 | + // only the <owner> tag has data content |
|
| 207 | + if ($this->collect_owner) { |
|
| 208 | + $this->owner .= $data; |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * tag end handler |
|
| 214 | + * |
|
| 215 | + * @param resource parser |
|
| 216 | + * @param string tag name |
|
| 217 | + * @return void |
|
| 218 | + * @access private |
|
| 219 | + */ |
|
| 220 | + function _endElement($parser, $name) |
|
| 221 | + { |
|
| 222 | + // namespace handling |
|
| 223 | + if (strstr($name, " ")) { |
|
| 224 | + list($ns, $tag) = explode(" ", $name); |
|
| 225 | + } else { |
|
| 226 | + $ns = ""; |
|
| 227 | + $tag = $name; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + // <owner> finished? |
|
| 231 | + if (($ns == "DAV:") && ($tag == "owner")) { |
|
| 232 | + $this->collect_owner = false; |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + // within <owner> we have to collect everything |
|
| 236 | + if ($this->collect_owner) { |
|
| 237 | + $ns_short = ""; |
|
| 238 | + $ns_attr = ""; |
|
| 239 | + if ($ns) { |
|
| 240 | + if ($ns == "DAV:") { |
|
| 241 | + $ns_short = "D:"; |
|
| 242 | + } else { |
|
| 243 | + $ns_attr = " xmlns='$ns'"; |
|
| 244 | + } |
|
| 245 | + } |
|
| 246 | + $this->owner .= "</$ns_short$tag$ns_attr>"; |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | ?> |
@@ -43,198 +43,198 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | class _parse_proppatch |
| 45 | 45 | { |
| 46 | - /** |
|
| 47 | - * |
|
| 48 | - * |
|
| 49 | - * @var |
|
| 50 | - * @access |
|
| 51 | - */ |
|
| 52 | - var $success; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * |
|
| 56 | - * |
|
| 57 | - * @var |
|
| 58 | - * @access |
|
| 59 | - */ |
|
| 60 | - var $props; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * |
|
| 64 | - * |
|
| 65 | - * @var |
|
| 66 | - * @access |
|
| 67 | - */ |
|
| 68 | - var $depth; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * |
|
| 72 | - * |
|
| 73 | - * @var |
|
| 74 | - * @access |
|
| 75 | - */ |
|
| 76 | - var $mode; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * |
|
| 80 | - * |
|
| 81 | - * @var |
|
| 82 | - * @access |
|
| 83 | - */ |
|
| 84 | - var $current; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * On return whole request, if $store_request == true was specified in constructor |
|
| 88 | - * |
|
| 89 | - * @var string |
|
| 90 | - */ |
|
| 91 | - var $request; |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * constructor |
|
| 95 | - * |
|
| 96 | - * @param string path of input stream |
|
| 97 | - * @param boolean $store_request =false if true whole request data will be made available in $this->request |
|
| 98 | - * @access public |
|
| 99 | - */ |
|
| 100 | - function __construct($path, $store_request=false) |
|
| 101 | - { |
|
| 102 | - $this->success = true; |
|
| 103 | - |
|
| 104 | - $this->depth = 0; |
|
| 105 | - $this->props = array(); |
|
| 106 | - $had_input = false; |
|
| 107 | - |
|
| 108 | - $f_in = fopen($path, "r"); |
|
| 109 | - if (!$f_in) { |
|
| 110 | - $this->success = false; |
|
| 111 | - return; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
| 115 | - |
|
| 116 | - xml_set_element_handler($xml_parser, |
|
| 117 | - array(&$this, "_startElement"), |
|
| 118 | - array(&$this, "_endElement")); |
|
| 119 | - |
|
| 120 | - xml_set_character_data_handler($xml_parser, |
|
| 121 | - array(&$this, "_data")); |
|
| 122 | - |
|
| 123 | - xml_parser_set_option($xml_parser, |
|
| 124 | - XML_OPTION_CASE_FOLDING, false); |
|
| 125 | - |
|
| 126 | - while($this->success && !feof($f_in)) { |
|
| 127 | - $line = fgets($f_in); |
|
| 128 | - if ($store_request) $this->request .= $line; |
|
| 129 | - if (is_string($line)) { |
|
| 130 | - $had_input = true; |
|
| 131 | - $this->success &= xml_parse($xml_parser, $line, false); |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - if($had_input) { |
|
| 136 | - $this->success &= xml_parse($xml_parser, "", true); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - xml_parser_free($xml_parser); |
|
| 140 | - |
|
| 141 | - fclose($f_in); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * tag start handler |
|
| 146 | - * |
|
| 147 | - * @param resource parser |
|
| 148 | - * @param string tag name |
|
| 149 | - * @param array tag attributes |
|
| 150 | - * @return void |
|
| 151 | - * @access private |
|
| 152 | - */ |
|
| 153 | - function _startElement($parser, $name, $attrs) |
|
| 154 | - { |
|
| 155 | - if (strstr($name, " ")) { |
|
| 156 | - list($ns, $tag) = explode(" ", $name); |
|
| 157 | - if ($ns == "") |
|
| 158 | - $this->success = false; |
|
| 159 | - } else { |
|
| 160 | - $ns = ""; |
|
| 161 | - $tag = $name; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - if ($this->depth == 1) { |
|
| 165 | - $this->mode = $tag; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - if ($this->depth == 3) { |
|
| 169 | - $prop = array("name" => $tag); |
|
| 170 | - $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200); |
|
| 171 | - if ($this->mode == "set") { |
|
| 172 | - $this->current["val"] = ""; // default set val |
|
| 173 | - } |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - if ($this->depth >= 4) { |
|
| 177 | - $this->current["val"] .= "<$tag"; |
|
| 178 | - if (isset($attr)) { |
|
| 179 | - foreach ($attr as $key => $val) { |
|
| 180 | - $this->current["val"] .= ' '.$key.'="'.str_replace('"','"', $val).'"'; |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - $this->current["val"] .= ">"; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - |
|
| 187 | - |
|
| 188 | - $this->depth++; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * tag end handler |
|
| 193 | - * |
|
| 194 | - * @param resource parser |
|
| 195 | - * @param string tag name |
|
| 196 | - * @return void |
|
| 197 | - * @access private |
|
| 198 | - */ |
|
| 199 | - function _endElement($parser, $name) |
|
| 200 | - { |
|
| 201 | - if (strstr($name, " ")) { |
|
| 202 | - list($ns, $tag) = explode(" ", $name); |
|
| 203 | - if ($ns == "") |
|
| 204 | - $this->success = false; |
|
| 205 | - } else { |
|
| 206 | - $ns = ""; |
|
| 207 | - $tag = $name; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - $this->depth--; |
|
| 211 | - |
|
| 212 | - if ($this->depth >= 4) { |
|
| 213 | - $this->current["val"] .= "</$tag>"; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - if ($this->depth == 3) { |
|
| 217 | - if (isset($this->current)) { |
|
| 218 | - $this->props[] = $this->current; |
|
| 219 | - unset($this->current); |
|
| 220 | - } |
|
| 221 | - } |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * input data handler |
|
| 226 | - * |
|
| 227 | - * @param resource parser |
|
| 228 | - * @param string data |
|
| 229 | - * @return void |
|
| 230 | - * @access private |
|
| 231 | - */ |
|
| 232 | - function _data($parser, $data) |
|
| 233 | - { |
|
| 234 | - if (isset($this->current)) { |
|
| 235 | - $this->current["val"] .= $data; |
|
| 236 | - } |
|
| 237 | - } |
|
| 46 | + /** |
|
| 47 | + * |
|
| 48 | + * |
|
| 49 | + * @var |
|
| 50 | + * @access |
|
| 51 | + */ |
|
| 52 | + var $success; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * |
|
| 56 | + * |
|
| 57 | + * @var |
|
| 58 | + * @access |
|
| 59 | + */ |
|
| 60 | + var $props; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * |
|
| 64 | + * |
|
| 65 | + * @var |
|
| 66 | + * @access |
|
| 67 | + */ |
|
| 68 | + var $depth; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * |
|
| 72 | + * |
|
| 73 | + * @var |
|
| 74 | + * @access |
|
| 75 | + */ |
|
| 76 | + var $mode; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * |
|
| 80 | + * |
|
| 81 | + * @var |
|
| 82 | + * @access |
|
| 83 | + */ |
|
| 84 | + var $current; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * On return whole request, if $store_request == true was specified in constructor |
|
| 88 | + * |
|
| 89 | + * @var string |
|
| 90 | + */ |
|
| 91 | + var $request; |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * constructor |
|
| 95 | + * |
|
| 96 | + * @param string path of input stream |
|
| 97 | + * @param boolean $store_request =false if true whole request data will be made available in $this->request |
|
| 98 | + * @access public |
|
| 99 | + */ |
|
| 100 | + function __construct($path, $store_request=false) |
|
| 101 | + { |
|
| 102 | + $this->success = true; |
|
| 103 | + |
|
| 104 | + $this->depth = 0; |
|
| 105 | + $this->props = array(); |
|
| 106 | + $had_input = false; |
|
| 107 | + |
|
| 108 | + $f_in = fopen($path, "r"); |
|
| 109 | + if (!$f_in) { |
|
| 110 | + $this->success = false; |
|
| 111 | + return; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
| 115 | + |
|
| 116 | + xml_set_element_handler($xml_parser, |
|
| 117 | + array(&$this, "_startElement"), |
|
| 118 | + array(&$this, "_endElement")); |
|
| 119 | + |
|
| 120 | + xml_set_character_data_handler($xml_parser, |
|
| 121 | + array(&$this, "_data")); |
|
| 122 | + |
|
| 123 | + xml_parser_set_option($xml_parser, |
|
| 124 | + XML_OPTION_CASE_FOLDING, false); |
|
| 125 | + |
|
| 126 | + while($this->success && !feof($f_in)) { |
|
| 127 | + $line = fgets($f_in); |
|
| 128 | + if ($store_request) $this->request .= $line; |
|
| 129 | + if (is_string($line)) { |
|
| 130 | + $had_input = true; |
|
| 131 | + $this->success &= xml_parse($xml_parser, $line, false); |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + if($had_input) { |
|
| 136 | + $this->success &= xml_parse($xml_parser, "", true); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + xml_parser_free($xml_parser); |
|
| 140 | + |
|
| 141 | + fclose($f_in); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * tag start handler |
|
| 146 | + * |
|
| 147 | + * @param resource parser |
|
| 148 | + * @param string tag name |
|
| 149 | + * @param array tag attributes |
|
| 150 | + * @return void |
|
| 151 | + * @access private |
|
| 152 | + */ |
|
| 153 | + function _startElement($parser, $name, $attrs) |
|
| 154 | + { |
|
| 155 | + if (strstr($name, " ")) { |
|
| 156 | + list($ns, $tag) = explode(" ", $name); |
|
| 157 | + if ($ns == "") |
|
| 158 | + $this->success = false; |
|
| 159 | + } else { |
|
| 160 | + $ns = ""; |
|
| 161 | + $tag = $name; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + if ($this->depth == 1) { |
|
| 165 | + $this->mode = $tag; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + if ($this->depth == 3) { |
|
| 169 | + $prop = array("name" => $tag); |
|
| 170 | + $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200); |
|
| 171 | + if ($this->mode == "set") { |
|
| 172 | + $this->current["val"] = ""; // default set val |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + if ($this->depth >= 4) { |
|
| 177 | + $this->current["val"] .= "<$tag"; |
|
| 178 | + if (isset($attr)) { |
|
| 179 | + foreach ($attr as $key => $val) { |
|
| 180 | + $this->current["val"] .= ' '.$key.'="'.str_replace('"','"', $val).'"'; |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + $this->current["val"] .= ">"; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + |
|
| 188 | + $this->depth++; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * tag end handler |
|
| 193 | + * |
|
| 194 | + * @param resource parser |
|
| 195 | + * @param string tag name |
|
| 196 | + * @return void |
|
| 197 | + * @access private |
|
| 198 | + */ |
|
| 199 | + function _endElement($parser, $name) |
|
| 200 | + { |
|
| 201 | + if (strstr($name, " ")) { |
|
| 202 | + list($ns, $tag) = explode(" ", $name); |
|
| 203 | + if ($ns == "") |
|
| 204 | + $this->success = false; |
|
| 205 | + } else { |
|
| 206 | + $ns = ""; |
|
| 207 | + $tag = $name; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + $this->depth--; |
|
| 211 | + |
|
| 212 | + if ($this->depth >= 4) { |
|
| 213 | + $this->current["val"] .= "</$tag>"; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + if ($this->depth == 3) { |
|
| 217 | + if (isset($this->current)) { |
|
| 218 | + $this->props[] = $this->current; |
|
| 219 | + unset($this->current); |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * input data handler |
|
| 226 | + * |
|
| 227 | + * @param resource parser |
|
| 228 | + * @param string data |
|
| 229 | + * @return void |
|
| 230 | + * @access private |
|
| 231 | + */ |
|
| 232 | + function _data($parser, $data) |
|
| 233 | + { |
|
| 234 | + if (isset($this->current)) { |
|
| 235 | + $this->current["val"] .= $data; |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /* |