PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - ext/dom - php_dom.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 719 764 94.1 %
Date: 2015-07-26 Functions: 48 50 96.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | PHP Version 7                                                        |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1997-2015 The PHP Group                                |
       6             :    +----------------------------------------------------------------------+
       7             :    | This source file is subject to version 3.01 of the PHP license,      |
       8             :    | that is bundled with this package in the file LICENSE, and is        |
       9             :    | available through the world-wide-web at the following url:           |
      10             :    | http://www.php.net/license/3_01.txt                                  |
      11             :    | If you did not receive a copy of the PHP license and are unable to   |
      12             :    | obtain it through the world-wide-web, please send a note to          |
      13             :    | license@php.net so we can mail you a copy immediately.               |
      14             :    +----------------------------------------------------------------------+
      15             :    | Authors: Christian Stocker <chregu@php.net>                          |
      16             :    |          Rob Richards <rrichards@php.net>                            |
      17             :    |          Marcus Borger <helly@php.net>                               |
      18             :    +----------------------------------------------------------------------+
      19             : */
      20             : 
      21             : /* $Id$ */
      22             : 
      23             : #ifdef HAVE_CONFIG_H
      24             : #include "config.h"
      25             : #endif
      26             : 
      27             : #include "php.h"
      28             : #if HAVE_LIBXML && HAVE_DOM
      29             : #include "ext/standard/php_rand.h"
      30             : #include "php_dom.h"
      31             : #include "dom_properties.h"
      32             : #include "zend_interfaces.h"
      33             : 
      34             : #include "ext/standard/info.h"
      35             : #define PHP_XPATH 1
      36             : #define PHP_XPTR 2
      37             : 
      38             : /* {{{ class entries */
      39             : PHP_DOM_EXPORT zend_class_entry *dom_node_class_entry;
      40             : PHP_DOM_EXPORT zend_class_entry *dom_domexception_class_entry;
      41             : PHP_DOM_EXPORT zend_class_entry *dom_domstringlist_class_entry;
      42             : PHP_DOM_EXPORT zend_class_entry *dom_namelist_class_entry;
      43             : PHP_DOM_EXPORT zend_class_entry *dom_domimplementationlist_class_entry;
      44             : PHP_DOM_EXPORT zend_class_entry *dom_domimplementationsource_class_entry;
      45             : PHP_DOM_EXPORT zend_class_entry *dom_domimplementation_class_entry;
      46             : PHP_DOM_EXPORT zend_class_entry *dom_documentfragment_class_entry;
      47             : PHP_DOM_EXPORT zend_class_entry *dom_document_class_entry;
      48             : PHP_DOM_EXPORT zend_class_entry *dom_nodelist_class_entry;
      49             : PHP_DOM_EXPORT zend_class_entry *dom_namednodemap_class_entry;
      50             : PHP_DOM_EXPORT zend_class_entry *dom_characterdata_class_entry;
      51             : PHP_DOM_EXPORT zend_class_entry *dom_attr_class_entry;
      52             : PHP_DOM_EXPORT zend_class_entry *dom_element_class_entry;
      53             : PHP_DOM_EXPORT zend_class_entry *dom_text_class_entry;
      54             : PHP_DOM_EXPORT zend_class_entry *dom_comment_class_entry;
      55             : PHP_DOM_EXPORT zend_class_entry *dom_typeinfo_class_entry;
      56             : PHP_DOM_EXPORT zend_class_entry *dom_userdatahandler_class_entry;
      57             : PHP_DOM_EXPORT zend_class_entry *dom_domerror_class_entry;
      58             : PHP_DOM_EXPORT zend_class_entry *dom_domerrorhandler_class_entry;
      59             : PHP_DOM_EXPORT zend_class_entry *dom_domlocator_class_entry;
      60             : PHP_DOM_EXPORT zend_class_entry *dom_domconfiguration_class_entry;
      61             : PHP_DOM_EXPORT zend_class_entry *dom_cdatasection_class_entry;
      62             : PHP_DOM_EXPORT zend_class_entry *dom_documenttype_class_entry;
      63             : PHP_DOM_EXPORT zend_class_entry *dom_notation_class_entry;
      64             : PHP_DOM_EXPORT zend_class_entry *dom_entity_class_entry;
      65             : PHP_DOM_EXPORT zend_class_entry *dom_entityreference_class_entry;
      66             : PHP_DOM_EXPORT zend_class_entry *dom_processinginstruction_class_entry;
      67             : PHP_DOM_EXPORT zend_class_entry *dom_string_extend_class_entry;
      68             : #if defined(LIBXML_XPATH_ENABLED)
      69             : PHP_DOM_EXPORT zend_class_entry *dom_xpath_class_entry;
      70             : #endif
      71             : PHP_DOM_EXPORT zend_class_entry *dom_namespace_node_class_entry;
      72             : /* }}} */
      73             : 
      74             : zend_object_handlers dom_object_handlers;
      75             : zend_object_handlers dom_nnodemap_object_handlers;
      76             : #if defined(LIBXML_XPATH_ENABLED)
      77             : zend_object_handlers dom_xpath_object_handlers;
      78             : #endif
      79             : 
      80             : static HashTable classes;
      81             : /* {{{ prop handler tables */
      82             : static HashTable dom_domstringlist_prop_handlers;
      83             : static HashTable dom_namelist_prop_handlers;
      84             : static HashTable dom_domimplementationlist_prop_handlers;
      85             : static HashTable dom_document_prop_handlers;
      86             : static HashTable dom_node_prop_handlers;
      87             : static HashTable dom_nodelist_prop_handlers;
      88             : static HashTable dom_namednodemap_prop_handlers;
      89             : static HashTable dom_characterdata_prop_handlers;
      90             : static HashTable dom_attr_prop_handlers;
      91             : static HashTable dom_element_prop_handlers;
      92             : static HashTable dom_text_prop_handlers;
      93             : static HashTable dom_typeinfo_prop_handlers;
      94             : static HashTable dom_domerror_prop_handlers;
      95             : static HashTable dom_domlocator_prop_handlers;
      96             : static HashTable dom_documenttype_prop_handlers;
      97             : static HashTable dom_notation_prop_handlers;
      98             : static HashTable dom_entity_prop_handlers;
      99             : static HashTable dom_processinginstruction_prop_handlers;
     100             : static HashTable dom_namespace_node_prop_handlers;
     101             : #if defined(LIBXML_XPATH_ENABLED)
     102             : static HashTable dom_xpath_prop_handlers;
     103             : #endif
     104             : /* }}} */
     105             : 
     106             : typedef int (*dom_read_t)(dom_object *obj, zval *retval);
     107             : typedef int (*dom_write_t)(dom_object *obj, zval *newval);
     108             : 
     109             : typedef struct _dom_prop_handler {
     110             :         dom_read_t read_func;
     111             :         dom_write_t write_func;
     112             : } dom_prop_handler;
     113             : 
     114        1010 : static zend_object_handlers* dom_get_obj_handlers(void) {
     115        1010 :         return &dom_object_handlers;
     116             : }
     117             : 
     118             : /* {{{ int dom_node_is_read_only(xmlNodePtr node) */
     119         267 : int dom_node_is_read_only(xmlNodePtr node) {
     120         267 :         switch (node->type) {
     121             :                 case XML_ENTITY_REF_NODE:
     122             :                 case XML_ENTITY_NODE:
     123             :                 case XML_DOCUMENT_TYPE_NODE:
     124             :                 case XML_NOTATION_NODE:
     125             :                 case XML_DTD_NODE:
     126             :                 case XML_ELEMENT_DECL:
     127             :                 case XML_ATTRIBUTE_DECL:
     128             :                 case XML_ENTITY_DECL:
     129             :                 case XML_NAMESPACE_DECL:
     130           0 :                         return SUCCESS;
     131             :                         break;
     132             :                 default:
     133         267 :                         if (node->doc == NULL) {
     134           1 :                                 return SUCCESS;
     135             :                         } else {
     136         266 :                                 return FAILURE;
     137             :                         }
     138             :         }
     139             : }
     140             : /* }}} end dom_node_is_read_only */
     141             : 
     142             : /* {{{ int dom_node_children_valid(xmlNodePtr node) */
     143         452 : int dom_node_children_valid(xmlNodePtr node) {
     144         452 :         switch (node->type) {
     145             :                 case XML_DOCUMENT_TYPE_NODE:
     146             :                 case XML_DTD_NODE:
     147             :                 case XML_PI_NODE:
     148             :                 case XML_COMMENT_NODE:
     149             :                 case XML_TEXT_NODE:
     150             :                 case XML_CDATA_SECTION_NODE:
     151             :                 case XML_NOTATION_NODE:
     152          48 :                         return FAILURE;
     153             :                         break;
     154             :                 default:
     155         404 :                         return SUCCESS;
     156             :         }
     157             : }
     158             : /* }}} end dom_node_children_valid */
     159             : 
     160             : /* {{{ dom_get_doc_props() */
     161        1190 : dom_doc_propsptr dom_get_doc_props(php_libxml_ref_obj *document)
     162             : {
     163             :         dom_doc_propsptr doc_props;
     164             : 
     165        1190 :         if (document && document->doc_props) {
     166         840 :                 return document->doc_props;
     167             :         } else {
     168         350 :                 doc_props = emalloc(sizeof(libxml_doc_props));
     169         350 :                 doc_props->formatoutput = 0;
     170         350 :                 doc_props->validateonparse = 0;
     171         350 :                 doc_props->resolveexternals = 0;
     172         350 :                 doc_props->preservewhitespace = 1;
     173         350 :                 doc_props->substituteentities = 0;
     174         350 :                 doc_props->stricterror = 1;
     175         350 :                 doc_props->recover = 0;
     176         350 :                 doc_props->classmap = NULL;
     177         350 :                 if (document) {
     178         349 :                         document->doc_props = doc_props;
     179             :                 }
     180         350 :                 return doc_props;
     181             :         }
     182             : }
     183             : 
     184           1 : static void dom_copy_doc_props(php_libxml_ref_obj *source_doc, php_libxml_ref_obj *dest_doc)
     185             : {
     186             :         dom_doc_propsptr source, dest;
     187             : 
     188           1 :         if (source_doc && dest_doc) {
     189             : 
     190           1 :                 source = dom_get_doc_props(source_doc);
     191           1 :                 dest = dom_get_doc_props(dest_doc);
     192             : 
     193           1 :                 dest->formatoutput = source->formatoutput;
     194           1 :                 dest->validateonparse = source->validateonparse;
     195           1 :                 dest->resolveexternals = source->resolveexternals;
     196           1 :                 dest->preservewhitespace = source->preservewhitespace;
     197           1 :                 dest->substituteentities = source->substituteentities;
     198           1 :                 dest->stricterror = source->stricterror;
     199           1 :                 dest->recover = source->recover;
     200           1 :                 if (source->classmap) {
     201           0 :                         ALLOC_HASHTABLE(dest->classmap);
     202           0 :                         zend_hash_init(dest->classmap, 0, NULL, NULL, 0);
     203           0 :                         zend_hash_copy(dest->classmap, source->classmap, NULL);
     204             :                 }
     205             : 
     206             :         }
     207           1 : }
     208             : 
     209           3 : int dom_set_doc_classmap(php_libxml_ref_obj *document, zend_class_entry *basece, zend_class_entry *ce)
     210             : {
     211             :         dom_doc_propsptr doc_props;
     212             : 
     213           3 :         if (document) {
     214           3 :                 doc_props = dom_get_doc_props(document);
     215           3 :                 if (doc_props->classmap == NULL) {
     216           1 :                         if (ce == NULL) {
     217           0 :                                 return SUCCESS;
     218             :                         }
     219           1 :                         ALLOC_HASHTABLE(doc_props->classmap);
     220           1 :                         zend_hash_init(doc_props->classmap, 0, NULL, NULL, 0);
     221             :                 }
     222           3 :                 if (ce) {
     223           2 :                         zend_hash_update_ptr(doc_props->classmap, basece->name, ce);
     224             :                 } else {
     225           1 :                         zend_hash_del(doc_props->classmap, basece->name);
     226             :                 }
     227             :         }
     228           3 :         return SUCCESS;
     229             : }
     230             : 
     231         564 : zend_class_entry *dom_get_doc_classmap(php_libxml_ref_obj *document, zend_class_entry *basece)
     232             : {
     233             :         dom_doc_propsptr doc_props;
     234             : 
     235         564 :         if (document) {
     236         564 :                 doc_props = dom_get_doc_props(document);
     237         564 :                 if (doc_props->classmap) {
     238           8 :                         zend_class_entry *ce = zend_hash_find_ptr(doc_props->classmap, basece->name);
     239           4 :                         if (ce) {
     240           3 :                                 return ce;
     241             :                         }
     242             :                 }
     243             :         }
     244             : 
     245         561 :         return basece;
     246             : }
     247             : /* }}} */
     248             : 
     249             : /* {{{ dom_get_strict_error() */
     250         227 : int dom_get_strict_error(php_libxml_ref_obj *document) {
     251             :         int stricterror;
     252             :         dom_doc_propsptr doc_props;
     253             : 
     254         227 :         doc_props = dom_get_doc_props(document);
     255         227 :         stricterror = doc_props->stricterror;
     256         227 :         if (document == NULL) {
     257           1 :                 efree(doc_props);
     258             :         }
     259             : 
     260         227 :         return stricterror;
     261             : }
     262             : /* }}} */
     263             : 
     264             : /* {{{ xmlNodePtr dom_object_get_node(dom_object *obj) */
     265        2257 : PHP_DOM_EXPORT xmlNodePtr dom_object_get_node(dom_object *obj)
     266             : {
     267        2257 :         if (obj && obj->ptr != NULL) {
     268        1854 :                 return ((php_libxml_node_ptr *)obj->ptr)->node;
     269             :         } else {
     270         403 :                 return NULL;
     271             :         }
     272             : }
     273             : /* }}} end dom_object_get_node */
     274             : 
     275             : /* {{{ dom_object *php_dom_object_get_data(xmlNodePtr obj) */
     276        1064 : PHP_DOM_EXPORT dom_object *php_dom_object_get_data(xmlNodePtr obj)
     277             : {
     278        1064 :         if (obj && obj->_private != NULL) {
     279         460 :                 return (dom_object *) ((php_libxml_node_ptr *) obj->_private)->_private;
     280             :         } else {
     281         604 :                 return NULL;
     282             :         }
     283             : }
     284             : /* }}} end php_dom_object_get_data */
     285             : 
     286             : /* {{{ dom_read_na */
     287           0 : static int dom_read_na(dom_object *obj, zval *retval)
     288             : {
     289           0 :         php_error_docref(NULL, E_ERROR, "Cannot read property");
     290           0 :         return FAILURE;
     291             : }
     292             : /* }}} */
     293             : 
     294             : /* {{{ dom_write_na */
     295           0 : static int dom_write_na(dom_object *obj, zval *newval)
     296             : {
     297           0 :         php_error_docref(NULL, E_ERROR, "Cannot write property");
     298           0 :         return FAILURE;
     299             : }
     300             : /* }}} */
     301             : 
     302             : /* {{{ dom_register_prop_handler */
     303     1852312 : static void dom_register_prop_handler(HashTable *prop_handler, char *name, dom_read_t read_func, dom_write_t write_func)
     304             : {
     305             :         dom_prop_handler hnd;
     306             : 
     307     1852312 :         hnd.read_func = read_func ? read_func : dom_read_na;
     308     1852312 :         hnd.write_func = write_func ? write_func : dom_write_na;
     309     1852312 :         zend_hash_str_add_mem(prop_handler, name, strlen(name), &hnd, sizeof(dom_prop_handler));
     310     1852312 : }
     311             : /* }}} */
     312             : 
     313           6 : static zval *dom_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot) /* {{{ */
     314             : {
     315           6 :         dom_object *obj = Z_DOMOBJ_P(object);
     316           6 :         zend_string *member_str = zval_get_string(member);
     317           6 :         zval *retval = NULL;
     318             : 
     319           6 :         if (!obj->prop_handler || !zend_hash_exists(obj->prop_handler, member_str)) {
     320           4 :                 zend_object_handlers *std_hnd = zend_get_std_object_handlers();
     321           4 :                 retval = std_hnd->get_property_ptr_ptr(object, member, type, cache_slot);
     322             :         }
     323             : 
     324             :         zend_string_release(member_str);
     325           6 :         return retval;
     326             : }
     327             : /* }}} */
     328             : 
     329             : /* {{{ dom_read_property */
     330        1295 : zval *dom_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv)
     331             : {
     332        1295 :         dom_object *obj = Z_DOMOBJ_P(object);
     333        1295 :         zend_string *member_str = zval_get_string(member);
     334             :         zval *retval;
     335        1295 :         dom_prop_handler *hnd = NULL;
     336             : 
     337        1295 :         if (obj->prop_handler != NULL) {
     338        2586 :                 hnd = zend_hash_find_ptr(obj->prop_handler, member_str);
     339           2 :         } else if (instanceof_function(obj->std.ce, dom_node_class_entry)) {
     340           2 :                 php_error(E_WARNING, "Couldn't fetch %s. Node no longer exists", obj->std.ce->name->val);
     341             :         }
     342             : 
     343        1295 :         if (hnd) {
     344        1291 :                 int ret = hnd->read_func(obj, rv);
     345        1291 :                 if (ret == SUCCESS) {
     346        1250 :                         retval = rv;
     347             :                 } else {
     348          41 :                         retval = &EG(uninitialized_zval);
     349             :                 }
     350             :         } else {
     351           4 :                 zend_object_handlers *std_hnd = zend_get_std_object_handlers();
     352           4 :                 retval = std_hnd->read_property(object, member, type, cache_slot, rv);
     353             :         }
     354             : 
     355             :         zend_string_release(member_str);
     356        1295 :         return retval;
     357             : }
     358             : /* }}} */
     359             : 
     360             : /* {{{ dom_write_property */
     361          49 : void dom_write_property(zval *object, zval *member, zval *value, void **cache_slot)
     362             : {
     363          49 :         dom_object *obj = Z_DOMOBJ_P(object);
     364          49 :         zend_string *member_str = zval_get_string(member);
     365          49 :         dom_prop_handler *hnd = NULL;
     366             : 
     367          49 :         if (obj->prop_handler != NULL) {
     368          98 :                 hnd = zend_hash_find_ptr(obj->prop_handler, member_str);
     369             :         }
     370          49 :         if (hnd) {
     371          47 :                 hnd->write_func(obj, value);
     372             :         } else {
     373           2 :                 zend_object_handlers *std_hnd = zend_get_std_object_handlers();
     374           2 :                 std_hnd->write_property(object, member, value, cache_slot);
     375             :         }
     376             : 
     377             :         zend_string_release(member_str);
     378          49 : }
     379             : /* }}} */
     380             : 
     381             : /* {{{ dom_property_exists */
     382           9 : static int dom_property_exists(zval *object, zval *member, int check_empty, void **cache_slot)
     383             : {
     384           9 :         dom_object *obj = Z_DOMOBJ_P(object);
     385           9 :         zend_string *member_str = zval_get_string(member);
     386           9 :         dom_prop_handler *hnd = NULL;
     387           9 :         int retval = 0;
     388             : 
     389           9 :         if (obj->prop_handler != NULL) {
     390          18 :                 hnd = zend_hash_find_ptr(obj->prop_handler, member_str);
     391             :         }
     392           9 :         if (hnd) {
     393             :                 zval tmp;
     394             : 
     395           7 :                 if (check_empty == 2) {
     396           0 :                         retval = 1;
     397           7 :                 } else if (hnd->read_func(obj, &tmp) == SUCCESS) {
     398           7 :                         if (check_empty == 1) {
     399           5 :                                 retval = zend_is_true(&tmp);
     400           2 :                         } else if (check_empty == 0) {
     401           2 :                                 retval = (Z_TYPE(tmp) != IS_NULL);
     402             :                         }
     403             :                         zval_dtor(&tmp);
     404             :                 }
     405             :         } else {
     406           2 :                 zend_object_handlers *std_hnd = zend_get_std_object_handlers();
     407           2 :                 retval = std_hnd->has_property(object, member, check_empty, cache_slot);
     408             :         }
     409             : 
     410             :         zend_string_release(member_str);
     411           9 :         return retval;
     412             : }
     413             : /* }}} */
     414             : 
     415           8 : static HashTable* dom_get_debug_info_helper(zval *object, int *is_temp) /* {{{ */
     416             : {
     417           8 :         dom_object                      *obj = Z_DOMOBJ_P(object);
     418             :         HashTable                       *debug_info,
     419           8 :                                                 *prop_handlers = obj->prop_handler,
     420             :                                                 *std_props;
     421             :         zend_string                     *string_key;
     422             :         dom_prop_handler        *entry;
     423             :         zval object_value;
     424             : 
     425           8 :         *is_temp = 1;
     426             : 
     427           8 :         std_props = zend_std_get_properties(object);
     428           8 :         debug_info = zend_array_dup(std_props);
     429             : 
     430           8 :         if (!prop_handlers) {
     431           2 :                 return debug_info;
     432             :         }
     433             : 
     434          12 :         ZVAL_STRING(&object_value, "(object value omitted)");
     435             : 
     436         266 :         ZEND_HASH_FOREACH_STR_KEY_PTR(prop_handlers, string_key, entry) {
     437             :                 zval value;
     438             : 
     439         130 :                 if (entry->read_func(obj, &value) == FAILURE || !string_key) {
     440           6 :                         continue;
     441             :                 }
     442             : 
     443         124 :                 if (Z_TYPE(value) == IS_OBJECT) {
     444             :                         zval_dtor(&value);
     445          24 :                         ZVAL_COPY(&value, &object_value);
     446             :                 }
     447             : 
     448         124 :                 zend_hash_add(debug_info, string_key, &value);
     449             :         } ZEND_HASH_FOREACH_END();
     450             : 
     451             :         zval_dtor(&object_value);
     452             : 
     453           6 :         return debug_info;
     454             : }
     455             : /* }}} */
     456             : 
     457           8 : static HashTable* dom_get_debug_info(zval *object, int *is_temp) /* {{{ */
     458             : {
     459           8 :        return dom_get_debug_info_helper(object, is_temp);
     460             : }
     461             : /* }}} */
     462             : 
     463         110 : void *php_dom_export_node(zval *object) /* {{{ */
     464             : {
     465             :         php_libxml_node_object *intern;
     466         110 :         xmlNodePtr nodep = NULL;
     467             : 
     468         110 :         intern = (php_libxml_node_object *) Z_DOMOBJ_P(object);
     469         110 :         if (intern->node) {
     470         110 :                 nodep = intern->node->node;
     471             :         }
     472             : 
     473         110 :         return nodep;
     474             : }
     475             : /* }}} */
     476             : 
     477             : /* {{{ proto somNode dom_import_simplexml(sxeobject node)
     478             :    Get a simplexml_element object from dom to allow for processing */
     479           1 : PHP_FUNCTION(dom_import_simplexml)
     480             : {
     481             :         zval *node;
     482           1 :         xmlNodePtr nodep = NULL;
     483             :         php_libxml_node_object *nodeobj;
     484             :         int ret;
     485             : 
     486           1 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &node) == FAILURE) {
     487           0 :                 return;
     488             :         }
     489             : 
     490           1 :         nodeobj = (php_libxml_node_object *) ((char *) Z_OBJ_P(node) - Z_OBJ_HT_P(node)->offset);
     491           1 :         nodep = php_libxml_import_node(node);
     492             : 
     493           2 :         if (nodep && nodeobj && (nodep->type == XML_ELEMENT_NODE || nodep->type == XML_ATTRIBUTE_NODE)) {
     494           1 :                 DOM_RET_OBJ((xmlNodePtr) nodep, &ret, (dom_object *)nodeobj);
     495             :         } else {
     496           0 :                 php_error_docref(NULL, E_WARNING, "Invalid Nodetype to import");
     497           0 :                 RETURN_NULL();
     498             :         }
     499             : }
     500             : /* }}} */
     501             : 
     502             : static dom_object* dom_objects_set_class(zend_class_entry *class_type, zend_bool hash_copy);
     503             : 
     504           2 : static zend_object *dom_objects_store_clone_obj(zval *zobject) /* {{{ */
     505             : {
     506           2 :         dom_object *intern = Z_DOMOBJ_P(zobject);
     507           2 :         dom_object *clone = dom_objects_set_class(intern->std.ce, 0);
     508             : 
     509           2 :         clone->std.handlers = dom_get_obj_handlers();
     510           2 :         zend_objects_clone_members(&clone->std, &intern->std);
     511             : 
     512           2 :         if (instanceof_function(intern->std.ce, dom_node_class_entry)) {
     513           2 :                 xmlNodePtr node = (xmlNodePtr)dom_object_get_node(intern);
     514           2 :                 if (node != NULL) {
     515           2 :                         xmlNodePtr cloned_node = xmlDocCopyNode(node, node->doc, 1);
     516           2 :                         if (cloned_node != NULL) {
     517             :                                 /* If we cloned a document then we must create new doc proxy */
     518           2 :                                 if (cloned_node->doc == node->doc) {
     519           1 :                                         clone->document = intern->document;
     520             :                                 }
     521           2 :                                 php_libxml_increment_doc_ref((php_libxml_node_object *)clone, cloned_node->doc);
     522           2 :                                 php_libxml_increment_node_ptr((php_libxml_node_object *)clone, cloned_node, (void *)clone);
     523           2 :                                 if (intern->document != clone->document) {
     524           1 :                                         dom_copy_doc_props(intern->document, clone->document);
     525             :                                 }
     526             :                         }
     527             : 
     528             :                 }
     529             :         }
     530             : 
     531           2 :         return &clone->std;
     532             : }
     533             : /* }}} */
     534             : 
     535     3073154 : static void dom_copy_prop_handler(zval *zv) /* {{{ */
     536             : {
     537     3073154 :         dom_prop_handler *hnd = Z_PTR_P(zv);
     538     3073154 :         Z_PTR_P(zv) = malloc(sizeof(dom_prop_handler));
     539     3073154 :         memcpy(Z_PTR_P(zv), hnd, sizeof(dom_prop_handler));
     540     3073154 : }
     541             : /* }}} */
     542             : 
     543     4933890 : static void dom_dtor_prop_handler(zval *zv) /* {{{ */
     544             : {
     545     4933890 :         free(Z_PTR_P(zv));
     546     4933890 : }
     547             : 
     548             : /* {{{ arginfo */
     549             : ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_import_simplexml, 0, 0, 1)
     550             :         ZEND_ARG_INFO(0, node)
     551             : ZEND_END_ARG_INFO()
     552             : /* }}} */
     553             : 
     554             : static const zend_function_entry dom_functions[] = {
     555             :         PHP_FE(dom_import_simplexml, arginfo_dom_import_simplexml)
     556             :         PHP_FE_END
     557             : };
     558             : 
     559             : static const zend_module_dep dom_deps[] = {
     560             :         ZEND_MOD_REQUIRED("libxml")
     561             :         ZEND_MOD_CONFLICTS("domxml")
     562             :         ZEND_MOD_END
     563             : };
     564             : 
     565             : zend_module_entry dom_module_entry = { /* {{{ */
     566             :         STANDARD_MODULE_HEADER_EX, NULL,
     567             :         dom_deps,
     568             :         "dom",
     569             :         dom_functions,
     570             :         PHP_MINIT(dom),
     571             :         PHP_MSHUTDOWN(dom),
     572             :         NULL,
     573             :         NULL,
     574             :         PHP_MINFO(dom),
     575             :         DOM_API_VERSION, /* Extension versionnumber */
     576             :         STANDARD_MODULE_PROPERTIES
     577             : };
     578             : /* }}} */
     579             : 
     580             : #ifdef COMPILE_DL_DOM
     581             : ZEND_GET_MODULE(dom)
     582             : #endif
     583             : 
     584             : void dom_objects_free_storage(zend_object *object);
     585             : void dom_nnodemap_objects_free_storage(zend_object *object);
     586             : static zend_object *dom_objects_store_clone_obj(zval *zobject);
     587             : static void dom_nnodemap_object_dtor(zend_object *object);
     588             : #if defined(LIBXML_XPATH_ENABLED)
     589             : void dom_xpath_objects_free_storage(zend_object *object);
     590             : #endif
     591             : 
     592             : /* {{{ PHP_MINIT_FUNCTION(dom) */
     593       21049 : PHP_MINIT_FUNCTION(dom)
     594             : {
     595             :         zend_class_entry ce;
     596             : 
     597       21049 :         memcpy(&dom_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
     598       21049 :         dom_object_handlers.offset = XtOffsetOf(dom_object, std);
     599       21049 :         dom_object_handlers.free_obj = dom_objects_free_storage;
     600       21049 :         dom_object_handlers.clone_obj = dom_objects_store_clone_obj;
     601       21049 :         dom_object_handlers.read_property = dom_read_property;
     602       21049 :         dom_object_handlers.write_property = dom_write_property;
     603       21049 :         dom_object_handlers.get_property_ptr_ptr = dom_get_property_ptr_ptr;
     604       21049 :         dom_object_handlers.clone_obj = dom_objects_store_clone_obj;
     605       21049 :         dom_object_handlers.has_property = dom_property_exists;
     606       21049 :         dom_object_handlers.get_debug_info = dom_get_debug_info;
     607             : 
     608       21049 :         memcpy(&dom_nnodemap_object_handlers, &dom_object_handlers, sizeof(zend_object_handlers));
     609       21049 :         dom_nnodemap_object_handlers.free_obj = dom_nnodemap_objects_free_storage;
     610       21049 :         dom_nnodemap_object_handlers.dtor_obj = dom_nnodemap_object_dtor;
     611       21049 :         dom_nnodemap_object_handlers.read_dimension = dom_nodelist_read_dimension;
     612       21049 :         dom_nnodemap_object_handlers.has_dimension = dom_nodelist_has_dimension;
     613             : 
     614       21049 :         zend_hash_init(&classes, 0, NULL, NULL, 1);
     615             : 
     616       21049 :         INIT_CLASS_ENTRY(ce, "DOMException", php_dom_domexception_class_functions);
     617       21049 :         dom_domexception_class_entry = zend_register_internal_class_ex(&ce, zend_exception_get_default());
     618       21049 :         dom_domexception_class_entry->ce_flags |= ZEND_ACC_FINAL;
     619       21049 :         zend_declare_property_long(dom_domexception_class_entry, "code", sizeof("code")-1, 0, ZEND_ACC_PUBLIC);
     620             : 
     621       21049 :         REGISTER_DOM_CLASS(ce, "DOMStringList", NULL, php_dom_domstringlist_class_functions, dom_domstringlist_class_entry);
     622             : 
     623       21049 :         zend_hash_init(&dom_domstringlist_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
     624       21049 :         dom_register_prop_handler(&dom_domstringlist_prop_handlers, "length", dom_domstringlist_length_read, NULL);
     625       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_domstringlist_prop_handlers);
     626             : 
     627       21049 :         REGISTER_DOM_CLASS(ce, "DOMNameList", NULL, php_dom_namelist_class_functions, dom_namelist_class_entry);
     628             : 
     629       21049 :         zend_hash_init(&dom_namelist_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
     630       21049 :         dom_register_prop_handler(&dom_namelist_prop_handlers, "length", dom_namelist_length_read, NULL);
     631       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_namelist_prop_handlers);
     632             : 
     633       21049 :         REGISTER_DOM_CLASS(ce, "DOMImplementationList", NULL, php_dom_domimplementationlist_class_functions, dom_domimplementationlist_class_entry);
     634             : 
     635       21049 :         zend_hash_init(&dom_domimplementationlist_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
     636       21049 :         dom_register_prop_handler(&dom_domimplementationlist_prop_handlers, "length", dom_domimplementationlist_length_read, NULL);
     637       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_domimplementationlist_prop_handlers);
     638             : 
     639       21049 :         REGISTER_DOM_CLASS(ce, "DOMImplementationSource", NULL, php_dom_domimplementationsource_class_functions, dom_domimplementationsource_class_entry);
     640       21049 :         REGISTER_DOM_CLASS(ce, "DOMImplementation", NULL, php_dom_domimplementation_class_functions, dom_domimplementation_class_entry);
     641             : 
     642       21049 :         REGISTER_DOM_CLASS(ce, "DOMNode", NULL, php_dom_node_class_functions, dom_node_class_entry);
     643             : 
     644       21049 :         zend_hash_init(&dom_node_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
     645       21049 :         dom_register_prop_handler(&dom_node_prop_handlers, "nodeName", dom_node_node_name_read, NULL);
     646       21049 :         dom_register_prop_handler(&dom_node_prop_handlers, "nodeValue", dom_node_node_value_read, dom_node_node_value_write);
     647       21049 :         dom_register_prop_handler(&dom_node_prop_handlers, "nodeType", dom_node_node_type_read, NULL);
     648       21049 :         dom_register_prop_handler(&dom_node_prop_handlers, "parentNode", dom_node_parent_node_read, NULL);
     649       21049 :         dom_register_prop_handler(&dom_node_prop_handlers, "childNodes", dom_node_child_nodes_read, NULL);
     650       21049 :         dom_register_prop_handler(&dom_node_prop_handlers, "firstChild", dom_node_first_child_read, NULL);
     651       21049 :         dom_register_prop_handler(&dom_node_prop_handlers, "lastChild", dom_node_last_child_read, NULL);
     652       21049 :         dom_register_prop_handler(&dom_node_prop_handlers, "previousSibling", dom_node_previous_sibling_read, NULL);
     653       21049 :         dom_register_prop_handler(&dom_node_prop_handlers, "nextSibling", dom_node_next_sibling_read, NULL);
     654       21049 :         dom_register_prop_handler(&dom_node_prop_handlers, "attributes", dom_node_attributes_read, NULL);
     655       21049 :         dom_register_prop_handler(&dom_node_prop_handlers, "ownerDocument", dom_node_owner_document_read, NULL);
     656       21049 :         dom_register_prop_handler(&dom_node_prop_handlers, "namespaceURI", dom_node_namespace_uri_read, NULL);
     657       21049 :         dom_register_prop_handler(&dom_node_prop_handlers, "prefix", dom_node_prefix_read, dom_node_prefix_write);
     658       21049 :         dom_register_prop_handler(&dom_node_prop_handlers, "localName", dom_node_local_name_read, NULL);
     659       21049 :         dom_register_prop_handler(&dom_node_prop_handlers, "baseURI", dom_node_base_uri_read, NULL);
     660       21049 :         dom_register_prop_handler(&dom_node_prop_handlers, "textContent", dom_node_text_content_read, dom_node_text_content_write);
     661       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_node_prop_handlers);
     662             : 
     663       21049 :         REGISTER_DOM_CLASS(ce, "DOMNameSpaceNode", NULL, NULL, dom_namespace_node_class_entry);
     664             : 
     665       21049 :         zend_hash_init(&dom_namespace_node_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
     666       21049 :         dom_register_prop_handler(&dom_namespace_node_prop_handlers, "nodeName", dom_node_node_name_read, NULL);
     667       21049 :         dom_register_prop_handler(&dom_namespace_node_prop_handlers, "nodeValue", dom_node_node_value_read, NULL);
     668       21049 :         dom_register_prop_handler(&dom_namespace_node_prop_handlers, "nodeType", dom_node_node_type_read, NULL);
     669       21049 :         dom_register_prop_handler(&dom_namespace_node_prop_handlers, "prefix", dom_node_prefix_read, NULL);
     670       21049 :         dom_register_prop_handler(&dom_namespace_node_prop_handlers, "localName", dom_node_local_name_read, NULL);
     671       21049 :         dom_register_prop_handler(&dom_namespace_node_prop_handlers, "namespaceURI", dom_node_namespace_uri_read, NULL);
     672       21049 :         dom_register_prop_handler(&dom_namespace_node_prop_handlers, "ownerDocument", dom_node_owner_document_read, NULL);
     673       21049 :         dom_register_prop_handler(&dom_namespace_node_prop_handlers, "parentNode", dom_node_parent_node_read, NULL);
     674       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_namespace_node_prop_handlers);
     675             : 
     676       21049 :         REGISTER_DOM_CLASS(ce, "DOMDocumentFragment", dom_node_class_entry, php_dom_documentfragment_class_functions, dom_documentfragment_class_entry);
     677       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_node_prop_handlers);
     678             : 
     679       21049 :         REGISTER_DOM_CLASS(ce, "DOMDocument", dom_node_class_entry, php_dom_document_class_functions, dom_document_class_entry);
     680       21049 :         zend_hash_init(&dom_document_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
     681       21049 :         dom_register_prop_handler(&dom_document_prop_handlers, "doctype", dom_document_doctype_read, NULL);
     682       21049 :         dom_register_prop_handler(&dom_document_prop_handlers, "implementation", dom_document_implementation_read, NULL);
     683       21049 :         dom_register_prop_handler(&dom_document_prop_handlers, "documentElement", dom_document_document_element_read, NULL);
     684       21049 :         dom_register_prop_handler(&dom_document_prop_handlers, "actualEncoding", dom_document_encoding_read, NULL);
     685       21049 :         dom_register_prop_handler(&dom_document_prop_handlers, "encoding", dom_document_encoding_read, dom_document_encoding_write);
     686       21049 :         dom_register_prop_handler(&dom_document_prop_handlers, "xmlEncoding", dom_document_encoding_read, NULL);
     687       21049 :         dom_register_prop_handler(&dom_document_prop_handlers, "standalone", dom_document_standalone_read, dom_document_standalone_write);
     688       21049 :         dom_register_prop_handler(&dom_document_prop_handlers, "xmlStandalone", dom_document_standalone_read, dom_document_standalone_write);
     689       21049 :         dom_register_prop_handler(&dom_document_prop_handlers, "version", dom_document_version_read, dom_document_version_write);
     690       21049 :         dom_register_prop_handler(&dom_document_prop_handlers, "xmlVersion", dom_document_version_read, dom_document_version_write);
     691       21049 :         dom_register_prop_handler(&dom_document_prop_handlers, "strictErrorChecking", dom_document_strict_error_checking_read, dom_document_strict_error_checking_write);
     692       21049 :         dom_register_prop_handler(&dom_document_prop_handlers, "documentURI", dom_document_document_uri_read, dom_document_document_uri_write);
     693       21049 :         dom_register_prop_handler(&dom_document_prop_handlers, "config", dom_document_config_read, NULL);
     694       21049 :         dom_register_prop_handler(&dom_document_prop_handlers, "formatOutput", dom_document_format_output_read, dom_document_format_output_write);
     695       21049 :         dom_register_prop_handler(&dom_document_prop_handlers, "validateOnParse", dom_document_validate_on_parse_read, dom_document_validate_on_parse_write);
     696       21049 :         dom_register_prop_handler(&dom_document_prop_handlers, "resolveExternals", dom_document_resolve_externals_read, dom_document_resolve_externals_write);
     697       21049 :         dom_register_prop_handler(&dom_document_prop_handlers, "preserveWhiteSpace", dom_document_preserve_whitespace_read, dom_document_preserve_whitespace_write);
     698       21049 :         dom_register_prop_handler(&dom_document_prop_handlers, "recover", dom_document_recover_read, dom_document_recover_write);
     699       21049 :         dom_register_prop_handler(&dom_document_prop_handlers, "substituteEntities", dom_document_substitue_entities_read, dom_document_substitue_entities_write);
     700             : 
     701       21049 :         zend_hash_merge(&dom_document_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
     702       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_document_prop_handlers);
     703             : 
     704       21049 :         INIT_CLASS_ENTRY(ce, "DOMNodeList", php_dom_nodelist_class_functions);
     705       21049 :         ce.create_object = dom_nnodemap_objects_new;
     706       21049 :         dom_nodelist_class_entry = zend_register_internal_class_ex(&ce, NULL);
     707       21049 :         dom_nodelist_class_entry->get_iterator = php_dom_get_iterator;
     708       21049 :         zend_class_implements(dom_nodelist_class_entry, 1, zend_ce_traversable);
     709             : 
     710       21049 :         zend_hash_init(&dom_nodelist_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
     711       21049 :         dom_register_prop_handler(&dom_nodelist_prop_handlers, "length", dom_nodelist_length_read, NULL);
     712       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_nodelist_prop_handlers);
     713             : 
     714       21049 :         INIT_CLASS_ENTRY(ce, "DOMNamedNodeMap", php_dom_namednodemap_class_functions);
     715       21049 :         ce.create_object = dom_nnodemap_objects_new;
     716       21049 :         dom_namednodemap_class_entry = zend_register_internal_class_ex(&ce, NULL);
     717       21049 :         dom_namednodemap_class_entry->get_iterator = php_dom_get_iterator;
     718       21049 :         zend_class_implements(dom_namednodemap_class_entry, 1, zend_ce_traversable);
     719             : 
     720       21049 :         zend_hash_init(&dom_namednodemap_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
     721       21049 :         dom_register_prop_handler(&dom_namednodemap_prop_handlers, "length", dom_namednodemap_length_read, NULL);
     722       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_namednodemap_prop_handlers);
     723             : 
     724       21049 :         REGISTER_DOM_CLASS(ce, "DOMCharacterData", dom_node_class_entry, php_dom_characterdata_class_functions, dom_characterdata_class_entry);
     725             : 
     726       21049 :         zend_hash_init(&dom_characterdata_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
     727       21049 :         dom_register_prop_handler(&dom_characterdata_prop_handlers, "data", dom_characterdata_data_read, dom_characterdata_data_write);
     728       21049 :         dom_register_prop_handler(&dom_characterdata_prop_handlers, "length", dom_characterdata_length_read, NULL);
     729       21049 :         zend_hash_merge(&dom_characterdata_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
     730       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_characterdata_prop_handlers);
     731             : 
     732       21049 :         REGISTER_DOM_CLASS(ce, "DOMAttr", dom_node_class_entry, php_dom_attr_class_functions, dom_attr_class_entry);
     733             : 
     734       21049 :         zend_hash_init(&dom_attr_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
     735       21049 :         dom_register_prop_handler(&dom_attr_prop_handlers, "name", dom_attr_name_read, NULL);
     736       21049 :         dom_register_prop_handler(&dom_attr_prop_handlers, "specified", dom_attr_specified_read, NULL);
     737       21049 :         dom_register_prop_handler(&dom_attr_prop_handlers, "value", dom_attr_value_read, dom_attr_value_write);
     738       21049 :         dom_register_prop_handler(&dom_attr_prop_handlers, "ownerElement", dom_attr_owner_element_read, NULL);
     739       21049 :         dom_register_prop_handler(&dom_attr_prop_handlers, "schemaTypeInfo", dom_attr_schema_type_info_read, NULL);
     740       21049 :         zend_hash_merge(&dom_attr_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
     741       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_attr_prop_handlers);
     742             : 
     743       21049 :         REGISTER_DOM_CLASS(ce, "DOMElement", dom_node_class_entry, php_dom_element_class_functions, dom_element_class_entry);
     744             : 
     745       21049 :         zend_hash_init(&dom_element_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
     746       21049 :         dom_register_prop_handler(&dom_element_prop_handlers, "tagName", dom_element_tag_name_read, NULL);
     747       21049 :         dom_register_prop_handler(&dom_element_prop_handlers, "schemaTypeInfo", dom_element_schema_type_info_read, NULL);
     748       21049 :         zend_hash_merge(&dom_element_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
     749       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_element_prop_handlers);
     750             : 
     751       21049 :         REGISTER_DOM_CLASS(ce, "DOMText", dom_characterdata_class_entry, php_dom_text_class_functions, dom_text_class_entry);
     752             : 
     753       21049 :         zend_hash_init(&dom_text_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
     754       21049 :         dom_register_prop_handler(&dom_text_prop_handlers, "wholeText", dom_text_whole_text_read, NULL);
     755       21049 :         zend_hash_merge(&dom_text_prop_handlers, &dom_characterdata_prop_handlers, dom_copy_prop_handler, 0);
     756       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_text_prop_handlers);
     757             : 
     758       21049 :         REGISTER_DOM_CLASS(ce, "DOMComment", dom_characterdata_class_entry, php_dom_comment_class_functions, dom_comment_class_entry);
     759       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_characterdata_prop_handlers);
     760             : 
     761       21049 :         REGISTER_DOM_CLASS(ce, "DOMTypeinfo", NULL, php_dom_typeinfo_class_functions, dom_typeinfo_class_entry);
     762             : 
     763       21049 :         zend_hash_init(&dom_typeinfo_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
     764       21049 :         dom_register_prop_handler(&dom_typeinfo_prop_handlers, "typeName", dom_typeinfo_type_name_read, NULL);
     765       21049 :         dom_register_prop_handler(&dom_typeinfo_prop_handlers, "typeNamespace", dom_typeinfo_type_namespace_read, NULL);
     766       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_typeinfo_prop_handlers);
     767             : 
     768       21049 :         REGISTER_DOM_CLASS(ce, "DOMUserDataHandler", NULL, php_dom_userdatahandler_class_functions, dom_userdatahandler_class_entry);
     769       21049 :         REGISTER_DOM_CLASS(ce, "DOMDomError", NULL, php_dom_domerror_class_functions, dom_domerror_class_entry);
     770             : 
     771       21049 :         zend_hash_init(&dom_domerror_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
     772       21049 :         dom_register_prop_handler(&dom_domerror_prop_handlers, "severity", dom_domerror_severity_read, NULL);
     773       21049 :         dom_register_prop_handler(&dom_domerror_prop_handlers, "message", dom_domerror_message_read, NULL);
     774       21049 :         dom_register_prop_handler(&dom_domerror_prop_handlers, "type", dom_domerror_type_read, NULL);
     775       21049 :         dom_register_prop_handler(&dom_domerror_prop_handlers, "relatedException", dom_domerror_related_exception_read, NULL);
     776       21049 :         dom_register_prop_handler(&dom_domerror_prop_handlers, "related_data", dom_domerror_related_data_read, NULL);
     777       21049 :         dom_register_prop_handler(&dom_domerror_prop_handlers, "location", dom_domerror_location_read, NULL);
     778       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_domerror_prop_handlers);
     779             : 
     780       21049 :         REGISTER_DOM_CLASS(ce, "DOMErrorHandler", NULL, php_dom_domerrorhandler_class_functions, dom_domerrorhandler_class_entry);
     781       21049 :         REGISTER_DOM_CLASS(ce, "DOMLocator", NULL, php_dom_domlocator_class_functions, dom_domlocator_class_entry);
     782             : 
     783       21049 :         zend_hash_init(&dom_domlocator_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
     784       21049 :         dom_register_prop_handler(&dom_domlocator_prop_handlers, "lineNumber", dom_domlocator_line_number_read, NULL);
     785       21049 :         dom_register_prop_handler(&dom_domlocator_prop_handlers, "columnNumber", dom_domlocator_column_number_read, NULL);
     786       21049 :         dom_register_prop_handler(&dom_domlocator_prop_handlers, "offset", dom_domlocator_offset_read, NULL);
     787       21049 :         dom_register_prop_handler(&dom_domlocator_prop_handlers, "relatedNode", dom_domlocator_related_node_read, NULL);
     788       21049 :         dom_register_prop_handler(&dom_domlocator_prop_handlers, "uri", dom_domlocator_uri_read, NULL);
     789       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_domlocator_prop_handlers);
     790             : 
     791       21049 :         REGISTER_DOM_CLASS(ce, "DOMConfiguration", NULL, php_dom_domconfiguration_class_functions, dom_domconfiguration_class_entry);
     792       21049 :         REGISTER_DOM_CLASS(ce, "DOMCdataSection", dom_text_class_entry, php_dom_cdatasection_class_functions, dom_cdatasection_class_entry);
     793       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_text_prop_handlers);
     794             : 
     795       21049 :         REGISTER_DOM_CLASS(ce, "DOMDocumentType", dom_node_class_entry, php_dom_documenttype_class_functions, dom_documenttype_class_entry);
     796             : 
     797       21049 :         zend_hash_init(&dom_documenttype_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
     798       21049 :         dom_register_prop_handler(&dom_documenttype_prop_handlers, "name", dom_documenttype_name_read, NULL);
     799       21049 :         dom_register_prop_handler(&dom_documenttype_prop_handlers, "entities", dom_documenttype_entities_read, NULL);
     800       21049 :         dom_register_prop_handler(&dom_documenttype_prop_handlers, "notations", dom_documenttype_notations_read, NULL);
     801       21049 :         dom_register_prop_handler(&dom_documenttype_prop_handlers, "publicId", dom_documenttype_public_id_read, NULL);
     802       21049 :         dom_register_prop_handler(&dom_documenttype_prop_handlers, "systemId", dom_documenttype_system_id_read, NULL);
     803       21049 :         dom_register_prop_handler(&dom_documenttype_prop_handlers, "internalSubset", dom_documenttype_internal_subset_read, NULL);
     804       21049 :         zend_hash_merge(&dom_documenttype_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
     805       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_documenttype_prop_handlers);
     806             : 
     807       21049 :         REGISTER_DOM_CLASS(ce, "DOMNotation", dom_node_class_entry, php_dom_notation_class_functions, dom_notation_class_entry);
     808             : 
     809       21049 :         zend_hash_init(&dom_notation_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
     810       21049 :         dom_register_prop_handler(&dom_notation_prop_handlers, "publicId", dom_notation_public_id_read, NULL);
     811       21049 :         dom_register_prop_handler(&dom_notation_prop_handlers, "systemId", dom_notation_system_id_read, NULL);
     812       21049 :         zend_hash_merge(&dom_notation_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
     813       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_notation_prop_handlers);
     814             : 
     815       21049 :         REGISTER_DOM_CLASS(ce, "DOMEntity", dom_node_class_entry, php_dom_entity_class_functions, dom_entity_class_entry);
     816             : 
     817       21049 :         zend_hash_init(&dom_entity_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
     818       21049 :         dom_register_prop_handler(&dom_entity_prop_handlers, "publicId", dom_entity_public_id_read, NULL);
     819       21049 :         dom_register_prop_handler(&dom_entity_prop_handlers, "systemId", dom_entity_system_id_read, NULL);
     820       21049 :         dom_register_prop_handler(&dom_entity_prop_handlers, "notationName", dom_entity_notation_name_read, NULL);
     821       21049 :         dom_register_prop_handler(&dom_entity_prop_handlers, "actualEncoding", dom_entity_actual_encoding_read, dom_entity_actual_encoding_write);
     822       21049 :         dom_register_prop_handler(&dom_entity_prop_handlers, "encoding", dom_entity_encoding_read, dom_entity_encoding_write);
     823       21049 :         dom_register_prop_handler(&dom_entity_prop_handlers, "version", dom_entity_version_read, dom_entity_version_write);
     824       21049 :         zend_hash_merge(&dom_entity_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
     825       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_entity_prop_handlers);
     826             : 
     827       21049 :         REGISTER_DOM_CLASS(ce, "DOMEntityReference", dom_node_class_entry, php_dom_entityreference_class_functions, dom_entityreference_class_entry);
     828       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_node_prop_handlers);
     829             : 
     830       21049 :         REGISTER_DOM_CLASS(ce, "DOMProcessingInstruction", dom_node_class_entry, php_dom_processinginstruction_class_functions, dom_processinginstruction_class_entry);
     831             : 
     832       21049 :         zend_hash_init(&dom_processinginstruction_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
     833       21049 :         dom_register_prop_handler(&dom_processinginstruction_prop_handlers, "target", dom_processinginstruction_target_read, NULL);
     834       21049 :         dom_register_prop_handler(&dom_processinginstruction_prop_handlers, "data", dom_processinginstruction_data_read, dom_processinginstruction_data_write);
     835       21049 :         zend_hash_merge(&dom_processinginstruction_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
     836       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_processinginstruction_prop_handlers);
     837             : 
     838       21049 :         REGISTER_DOM_CLASS(ce, "DOMStringExtend", NULL, php_dom_string_extend_class_functions, dom_string_extend_class_entry);
     839             : 
     840             : #if defined(LIBXML_XPATH_ENABLED)
     841       21049 :         memcpy(&dom_xpath_object_handlers, &dom_object_handlers, sizeof(zend_object_handlers));
     842       21049 :         dom_xpath_object_handlers.offset = XtOffsetOf(dom_xpath_object, dom) + XtOffsetOf(dom_object, std);
     843       21049 :         dom_xpath_object_handlers.free_obj = dom_xpath_objects_free_storage;
     844             : 
     845       21049 :         INIT_CLASS_ENTRY(ce, "DOMXPath", php_dom_xpath_class_functions);
     846       21049 :         ce.create_object = dom_xpath_objects_new;
     847       21049 :         dom_xpath_class_entry = zend_register_internal_class_ex(&ce, NULL);
     848             : 
     849       21049 :         zend_hash_init(&dom_xpath_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
     850       21049 :         dom_register_prop_handler(&dom_xpath_prop_handlers, "document", dom_xpath_document_read, NULL);
     851       21049 :         zend_hash_add_ptr(&classes, ce.name, &dom_xpath_prop_handlers);
     852             : #endif
     853             : 
     854       21049 :         REGISTER_LONG_CONSTANT("XML_ELEMENT_NODE",                    XML_ELEMENT_NODE,                       CONST_CS | CONST_PERSISTENT);
     855       21049 :         REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_NODE",          XML_ATTRIBUTE_NODE,                     CONST_CS | CONST_PERSISTENT);
     856       21049 :         REGISTER_LONG_CONSTANT("XML_TEXT_NODE",                               XML_TEXT_NODE,                          CONST_CS | CONST_PERSISTENT);
     857       21049 :         REGISTER_LONG_CONSTANT("XML_CDATA_SECTION_NODE",      XML_CDATA_SECTION_NODE,         CONST_CS | CONST_PERSISTENT);
     858       21049 :         REGISTER_LONG_CONSTANT("XML_ENTITY_REF_NODE",         XML_ENTITY_REF_NODE,            CONST_CS | CONST_PERSISTENT);
     859       21049 :         REGISTER_LONG_CONSTANT("XML_ENTITY_NODE",                     XML_ENTITY_NODE,                        CONST_CS | CONST_PERSISTENT);
     860       21049 :         REGISTER_LONG_CONSTANT("XML_PI_NODE",                         XML_PI_NODE,                            CONST_CS | CONST_PERSISTENT);
     861       21049 :         REGISTER_LONG_CONSTANT("XML_COMMENT_NODE",                    XML_COMMENT_NODE,                       CONST_CS | CONST_PERSISTENT);
     862       21049 :         REGISTER_LONG_CONSTANT("XML_DOCUMENT_NODE",                   XML_DOCUMENT_NODE,                      CONST_CS | CONST_PERSISTENT);
     863       21049 :         REGISTER_LONG_CONSTANT("XML_DOCUMENT_TYPE_NODE",      XML_DOCUMENT_TYPE_NODE,         CONST_CS | CONST_PERSISTENT);
     864       21049 :         REGISTER_LONG_CONSTANT("XML_DOCUMENT_FRAG_NODE",      XML_DOCUMENT_FRAG_NODE,         CONST_CS | CONST_PERSISTENT);
     865       21049 :         REGISTER_LONG_CONSTANT("XML_NOTATION_NODE",                   XML_NOTATION_NODE,                      CONST_CS | CONST_PERSISTENT);
     866       21049 :         REGISTER_LONG_CONSTANT("XML_HTML_DOCUMENT_NODE",      XML_HTML_DOCUMENT_NODE,         CONST_CS | CONST_PERSISTENT);
     867       21049 :         REGISTER_LONG_CONSTANT("XML_DTD_NODE",                                XML_DTD_NODE,                           CONST_CS | CONST_PERSISTENT);
     868       21049 :         REGISTER_LONG_CONSTANT("XML_ELEMENT_DECL_NODE",       XML_ELEMENT_DECL,                       CONST_CS | CONST_PERSISTENT);
     869       21049 :         REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_DECL_NODE",     XML_ATTRIBUTE_DECL,                     CONST_CS | CONST_PERSISTENT);
     870       21049 :         REGISTER_LONG_CONSTANT("XML_ENTITY_DECL_NODE",                XML_ENTITY_DECL,                        CONST_CS | CONST_PERSISTENT);
     871       21049 :         REGISTER_LONG_CONSTANT("XML_NAMESPACE_DECL_NODE",     XML_NAMESPACE_DECL,                     CONST_CS | CONST_PERSISTENT);
     872             : #ifdef XML_GLOBAL_NAMESPACE
     873             :         REGISTER_LONG_CONSTANT("XML_GLOBAL_NAMESPACE",                XML_GLOBAL_NAMESPACE,           CONST_CS | CONST_PERSISTENT);
     874             : #endif
     875       21049 :         REGISTER_LONG_CONSTANT("XML_LOCAL_NAMESPACE",         XML_LOCAL_NAMESPACE,            CONST_CS | CONST_PERSISTENT);
     876       21049 :         REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_CDATA",         XML_ATTRIBUTE_CDATA,            CONST_CS | CONST_PERSISTENT);
     877       21049 :         REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_ID",                    XML_ATTRIBUTE_ID,                       CONST_CS | CONST_PERSISTENT);
     878       21049 :         REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_IDREF",         XML_ATTRIBUTE_IDREF,            CONST_CS | CONST_PERSISTENT);
     879       21049 :         REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_IDREFS",                XML_ATTRIBUTE_IDREFS,           CONST_CS | CONST_PERSISTENT);
     880       21049 :         REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_ENTITY",                XML_ATTRIBUTE_ENTITIES,         CONST_CS | CONST_PERSISTENT);
     881       21049 :         REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_NMTOKEN",               XML_ATTRIBUTE_NMTOKEN,          CONST_CS | CONST_PERSISTENT);
     882       21049 :         REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_NMTOKENS",      XML_ATTRIBUTE_NMTOKENS,         CONST_CS | CONST_PERSISTENT);
     883       21049 :         REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_ENUMERATION",   XML_ATTRIBUTE_ENUMERATION,      CONST_CS | CONST_PERSISTENT);
     884       21049 :         REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_NOTATION",      XML_ATTRIBUTE_NOTATION,         CONST_CS | CONST_PERSISTENT);
     885             : 
     886             :         /* DOMException Codes */
     887       21049 :         REGISTER_LONG_CONSTANT("DOM_PHP_ERR",                         PHP_ERR,                                CONST_CS | CONST_PERSISTENT);
     888       21049 :         REGISTER_LONG_CONSTANT("DOM_INDEX_SIZE_ERR",          INDEX_SIZE_ERR,                 CONST_CS | CONST_PERSISTENT);
     889       21049 :         REGISTER_LONG_CONSTANT("DOMSTRING_SIZE_ERR",          DOMSTRING_SIZE_ERR,             CONST_CS | CONST_PERSISTENT);
     890       21049 :         REGISTER_LONG_CONSTANT("DOM_HIERARCHY_REQUEST_ERR",   HIERARCHY_REQUEST_ERR,  CONST_CS | CONST_PERSISTENT);
     891       21049 :         REGISTER_LONG_CONSTANT("DOM_WRONG_DOCUMENT_ERR",      WRONG_DOCUMENT_ERR,             CONST_CS | CONST_PERSISTENT);
     892       21049 :         REGISTER_LONG_CONSTANT("DOM_INVALID_CHARACTER_ERR",   INVALID_CHARACTER_ERR,  CONST_CS | CONST_PERSISTENT);
     893       21049 :         REGISTER_LONG_CONSTANT("DOM_NO_DATA_ALLOWED_ERR",     NO_DATA_ALLOWED_ERR,    CONST_CS | CONST_PERSISTENT);
     894       21049 :         REGISTER_LONG_CONSTANT("DOM_NO_MODIFICATION_ALLOWED_ERR", NO_MODIFICATION_ALLOWED_ERR, CONST_CS | CONST_PERSISTENT);
     895       21049 :         REGISTER_LONG_CONSTANT("DOM_NOT_FOUND_ERR",                   NOT_FOUND_ERR,                  CONST_CS | CONST_PERSISTENT);
     896       21049 :         REGISTER_LONG_CONSTANT("DOM_NOT_SUPPORTED_ERR",               NOT_SUPPORTED_ERR,              CONST_CS | CONST_PERSISTENT);
     897       21049 :         REGISTER_LONG_CONSTANT("DOM_INUSE_ATTRIBUTE_ERR",     INUSE_ATTRIBUTE_ERR,    CONST_CS | CONST_PERSISTENT);
     898       21049 :         REGISTER_LONG_CONSTANT("DOM_INVALID_STATE_ERR",               INVALID_STATE_ERR,              CONST_CS | CONST_PERSISTENT);
     899       21049 :         REGISTER_LONG_CONSTANT("DOM_SYNTAX_ERR",                      SYNTAX_ERR,                             CONST_CS | CONST_PERSISTENT);
     900       21049 :         REGISTER_LONG_CONSTANT("DOM_INVALID_MODIFICATION_ERR",        INVALID_MODIFICATION_ERR, CONST_CS | CONST_PERSISTENT);
     901       21049 :         REGISTER_LONG_CONSTANT("DOM_NAMESPACE_ERR",                   NAMESPACE_ERR,                  CONST_CS | CONST_PERSISTENT);
     902       21049 :         REGISTER_LONG_CONSTANT("DOM_INVALID_ACCESS_ERR",      INVALID_ACCESS_ERR,             CONST_CS | CONST_PERSISTENT);
     903       21049 :         REGISTER_LONG_CONSTANT("DOM_VALIDATION_ERR",          VALIDATION_ERR,                 CONST_CS | CONST_PERSISTENT);
     904             : 
     905       21049 :         php_libxml_register_export(dom_node_class_entry, php_dom_export_node);
     906             : 
     907       21049 :         return SUCCESS;
     908             : }
     909             : /* }}} */
     910             : 
     911             : /* {{{ */
     912         142 : PHP_MINFO_FUNCTION(dom)
     913             : {
     914         142 :         php_info_print_table_start();
     915         142 :         php_info_print_table_row(2, "DOM/XML", "enabled");
     916         142 :         php_info_print_table_row(2, "DOM/XML API Version", DOM_API_VERSION);
     917         142 :         php_info_print_table_row(2, "libxml Version", LIBXML_DOTTED_VERSION);
     918             : #if defined(LIBXML_HTML_ENABLED)
     919         142 :         php_info_print_table_row(2, "HTML Support", "enabled");
     920             : #endif
     921             : #if defined(LIBXML_XPATH_ENABLED)
     922         142 :         php_info_print_table_row(2, "XPath Support", "enabled");
     923             : #endif
     924             : #if defined(LIBXML_XPTR_ENABLED)
     925         142 :         php_info_print_table_row(2, "XPointer Support", "enabled");
     926             : #endif
     927             : #ifdef LIBXML_SCHEMAS_ENABLED
     928         142 :         php_info_print_table_row(2, "Schema Support", "enabled");
     929         142 :         php_info_print_table_row(2, "RelaxNG Support", "enabled");
     930             : #endif
     931         142 :         php_info_print_table_end();
     932         142 : }
     933             : /* }}} */
     934             : 
     935       21085 : PHP_MSHUTDOWN_FUNCTION(dom) /* {{{ */
     936             : {
     937       21085 :         zend_hash_destroy(&dom_domstringlist_prop_handlers);
     938       21085 :         zend_hash_destroy(&dom_namelist_prop_handlers);
     939       21085 :         zend_hash_destroy(&dom_domimplementationlist_prop_handlers);
     940       21085 :         zend_hash_destroy(&dom_document_prop_handlers);
     941       21085 :         zend_hash_destroy(&dom_node_prop_handlers);
     942       21085 :         zend_hash_destroy(&dom_namespace_node_prop_handlers);
     943       21085 :         zend_hash_destroy(&dom_nodelist_prop_handlers);
     944       21085 :         zend_hash_destroy(&dom_namednodemap_prop_handlers);
     945       21085 :         zend_hash_destroy(&dom_characterdata_prop_handlers);
     946       21085 :         zend_hash_destroy(&dom_attr_prop_handlers);
     947       21085 :         zend_hash_destroy(&dom_element_prop_handlers);
     948       21085 :         zend_hash_destroy(&dom_text_prop_handlers);
     949       21085 :         zend_hash_destroy(&dom_typeinfo_prop_handlers);
     950       21085 :         zend_hash_destroy(&dom_domerror_prop_handlers);
     951       21085 :         zend_hash_destroy(&dom_domlocator_prop_handlers);
     952       21085 :         zend_hash_destroy(&dom_documenttype_prop_handlers);
     953       21085 :         zend_hash_destroy(&dom_notation_prop_handlers);
     954       21085 :         zend_hash_destroy(&dom_entity_prop_handlers);
     955       21085 :         zend_hash_destroy(&dom_processinginstruction_prop_handlers);
     956             : #if defined(LIBXML_XPATH_ENABLED)
     957       21085 :         zend_hash_destroy(&dom_xpath_prop_handlers);
     958             : #endif
     959       21085 :         zend_hash_destroy(&classes);
     960             : 
     961             : /*      If you want do find memleaks in this module, compile libxml2 with --with-mem-debug and
     962             :         uncomment the following line, this will tell you the amount of not freed memory
     963             :         and the total used memory into apaches error_log  */
     964             : /*  xmlMemoryDump();*/
     965             : 
     966       21085 :         return SUCCESS;
     967             : }
     968             : /* }}} */
     969             : 
     970             : /* {{{ node_list_unlink */
     971          38 : void node_list_unlink(xmlNodePtr node)
     972             : {
     973             :         dom_object *wrapper;
     974             : 
     975          95 :         while (node != NULL) {
     976             : 
     977          19 :                 wrapper = php_dom_object_get_data(node);
     978             : 
     979          19 :                 if (wrapper != NULL ) {
     980           0 :                         xmlUnlinkNode(node);
     981             :                 } else {
     982          19 :                         if (node->type == XML_ENTITY_REF_NODE)
     983           0 :                                 break;
     984          19 :                         node_list_unlink(node->children);
     985             : 
     986          19 :                         switch (node->type) {
     987             :                                 case XML_ATTRIBUTE_DECL:
     988             :                                 case XML_DTD_NODE:
     989             :                                 case XML_DOCUMENT_TYPE_NODE:
     990             :                                 case XML_ENTITY_DECL:
     991             :                                 case XML_ATTRIBUTE_NODE:
     992             :                                 case XML_TEXT_NODE:
     993          19 :                                         break;
     994             :                                 default:
     995           0 :                                         node_list_unlink((xmlNodePtr) node->properties);
     996             :                         }
     997             : 
     998             :                 }
     999             : 
    1000          19 :                 node = node->next;
    1001             :         }
    1002          38 : }
    1003             : /* }}} end node_list_unlink */
    1004             : 
    1005             : #if defined(LIBXML_XPATH_ENABLED)
    1006             : /* {{{ dom_xpath_objects_free_storage */
    1007          10 : void dom_xpath_objects_free_storage(zend_object *object)
    1008             : {
    1009          10 :         dom_xpath_object *intern = php_xpath_obj_from_obj(object);
    1010             : 
    1011          10 :         zend_object_std_dtor(&intern->dom.std);
    1012             : 
    1013          10 :         if (intern->dom.ptr != NULL) {
    1014          10 :                 xmlXPathFreeContext((xmlXPathContextPtr) intern->dom.ptr);
    1015          10 :                 php_libxml_decrement_doc_ref((php_libxml_node_object *) &intern->dom);
    1016             :         }
    1017             : 
    1018          10 :         if (intern->registered_phpfunctions) {
    1019          10 :                 zend_hash_destroy(intern->registered_phpfunctions);
    1020          10 :                 FREE_HASHTABLE(intern->registered_phpfunctions);
    1021             :         }
    1022             : 
    1023          10 :         if (intern->node_list) {
    1024           0 :                 zend_hash_destroy(intern->node_list);
    1025           0 :                 FREE_HASHTABLE(intern->node_list);
    1026             :         }
    1027          10 : }
    1028             : /* }}} */
    1029             : #endif
    1030             : 
    1031             : /* {{{ dom_objects_free_storage */
    1032        1010 : void dom_objects_free_storage(zend_object *object)
    1033             : {
    1034        1010 :         dom_object *intern = php_dom_obj_from_obj(object);
    1035             : #if defined(__GNUC__) && __GNUC__ >= 3
    1036             :         int retcount __attribute__((unused)); /* keep compiler quiet */
    1037             : #else
    1038             :         int retcount;
    1039             : #endif
    1040             : 
    1041        1010 :         zend_object_std_dtor(&intern->std);
    1042             : 
    1043        1010 :         if (intern->ptr != NULL && ((php_libxml_node_ptr *)intern->ptr)->node != NULL) {
    1044        1575 :                 if (((xmlNodePtr) ((php_libxml_node_ptr *)intern->ptr)->node)->type != XML_DOCUMENT_NODE && ((xmlNodePtr) ((php_libxml_node_ptr *)intern->ptr)->node)->type != XML_HTML_DOCUMENT_NODE) {
    1045         601 :                         php_libxml_node_decrement_resource((php_libxml_node_object *) intern);
    1046             :                 } else {
    1047         373 :                         php_libxml_decrement_node_ptr((php_libxml_node_object *) intern);
    1048         373 :                         retcount = php_libxml_decrement_doc_ref((php_libxml_node_object *)intern);
    1049             :                 }
    1050         974 :                 intern->ptr = NULL;
    1051             :         }
    1052        1010 : }
    1053             : /* }}} */
    1054             : 
    1055         158 : void dom_namednode_iter(dom_object *basenode, int ntype, dom_object *intern, xmlHashTablePtr ht, xmlChar *local, xmlChar *ns) /* {{{ */
    1056             : {
    1057         158 :         dom_nnodemap_object *mapptr = (dom_nnodemap_object *) intern->ptr;
    1058             : 
    1059             :         //??? if (basenode)
    1060         158 :         ZVAL_OBJ(&mapptr->baseobj_zv, &basenode->std);
    1061         158 :         Z_ADDREF(mapptr->baseobj_zv);
    1062             : 
    1063         158 :         mapptr->baseobj = basenode;
    1064         158 :         mapptr->nodetype = ntype;
    1065         158 :         mapptr->ht = ht;
    1066         158 :         mapptr->local = local;
    1067         158 :         mapptr->ns = ns;
    1068         158 : }
    1069             : /* }}} */
    1070             : 
    1071        1179 : static dom_object* dom_objects_set_class(zend_class_entry *class_type, zend_bool hash_copy) /* {{{ */
    1072             : {
    1073        1179 :         dom_object *intern = ecalloc(1, sizeof(dom_object) + zend_object_properties_size(class_type));
    1074             : 
    1075        1179 :         zend_class_entry *base_class = class_type;
    1076        2363 :         while (base_class->type != ZEND_INTERNAL_CLASS && base_class->parent != NULL) {
    1077           5 :                 base_class = base_class->parent;
    1078             :         }
    1079             : 
    1080        2358 :         intern->prop_handler = zend_hash_find_ptr(&classes, base_class->name);
    1081             : 
    1082        1179 :         zend_object_std_init(&intern->std, class_type);
    1083        1179 :         if (hash_copy) {
    1084        1177 :                 object_properties_init(&intern->std, class_type);
    1085             :         }
    1086             : 
    1087        1179 :         return intern;
    1088             : }
    1089             : /* }}} */
    1090             : 
    1091             : /* {{{ dom_objects_new */
    1092        1008 : zend_object *dom_objects_new(zend_class_entry *class_type)
    1093             : {
    1094        1008 :         dom_object *intern = dom_objects_set_class(class_type, 1);
    1095        1008 :         intern->std.handlers = dom_get_obj_handlers();
    1096        1008 :         return &intern->std;
    1097             : }
    1098             : /* }}} */
    1099             : 
    1100             : #if defined(LIBXML_XPATH_ENABLED)
    1101             : /* {{{ zend_object_value dom_xpath_objects_new(zend_class_entry *class_type) */
    1102          10 : zend_object *dom_xpath_objects_new(zend_class_entry *class_type)
    1103             : {
    1104          10 :         dom_xpath_object *intern = ecalloc(1, sizeof(dom_xpath_object) + zend_object_properties_size(class_type));
    1105             : 
    1106          10 :         ALLOC_HASHTABLE(intern->registered_phpfunctions);
    1107          10 :         zend_hash_init(intern->registered_phpfunctions, 0, NULL, ZVAL_PTR_DTOR, 0);
    1108             : 
    1109          10 :         intern->dom.prop_handler = &dom_xpath_prop_handlers;
    1110          10 :         intern->dom.std.handlers = &dom_xpath_object_handlers;
    1111             : 
    1112          10 :         zend_object_std_init(&intern->dom.std, class_type);
    1113          10 :         object_properties_init(&intern->dom.std, class_type);
    1114             : 
    1115          10 :         return &intern->dom.std;
    1116             : }
    1117             : /* }}} */
    1118             : #endif
    1119             : 
    1120         169 : static void dom_nnodemap_object_dtor(zend_object *object) /* {{{ */
    1121             : {
    1122             :         dom_object *intern;
    1123             :         dom_nnodemap_object *objmap;
    1124             : 
    1125         169 :         intern = php_dom_obj_from_obj(object);
    1126         169 :         objmap = (dom_nnodemap_object *)intern->ptr;
    1127             : 
    1128         169 :         if (objmap) {
    1129         169 :                 if (objmap->local) {
    1130          40 :                         xmlFree(objmap->local);
    1131             :                 }
    1132         169 :                 if (objmap->ns) {
    1133           4 :                         xmlFree(objmap->ns);
    1134             :                 }
    1135         338 :                 if (!Z_ISUNDEF(objmap->baseobj_zv)) {
    1136         168 :                         zval_ptr_dtor(&objmap->baseobj_zv);
    1137             :                 }
    1138         169 :                 efree(objmap);
    1139         169 :                 intern->ptr = NULL;
    1140             :         }
    1141         169 : }
    1142             : /* }}} */
    1143             : 
    1144         169 : void dom_nnodemap_objects_free_storage(zend_object *object) /* {{{ */
    1145             : {
    1146         169 :         dom_object *intern = php_dom_obj_from_obj(object);
    1147             : 
    1148         169 :         php_libxml_decrement_doc_ref((php_libxml_node_object *)intern);
    1149             : 
    1150         169 :         zend_object_std_dtor(&intern->std);
    1151         169 : }
    1152             : /* }}} */
    1153             : 
    1154         169 : zend_object *dom_nnodemap_objects_new(zend_class_entry *class_type) /* {{{ */
    1155             : {
    1156             :         dom_object *intern;
    1157             :         dom_nnodemap_object *objmap;
    1158             : 
    1159         169 :         intern = dom_objects_set_class(class_type, 1);
    1160         169 :         intern->ptr = emalloc(sizeof(dom_nnodemap_object));
    1161         169 :         objmap = (dom_nnodemap_object *)intern->ptr;
    1162         169 :         ZVAL_UNDEF(&objmap->baseobj_zv);
    1163         169 :         objmap->baseobj = NULL;
    1164         169 :         objmap->nodetype = 0;
    1165         169 :         objmap->ht = NULL;
    1166         169 :         objmap->local = NULL;
    1167         169 :         objmap->ns = NULL;
    1168             : 
    1169         169 :         intern->std.handlers = &dom_nnodemap_object_handlers;
    1170             : 
    1171         169 :         return &intern->std;
    1172             : }
    1173             : /* }}} */
    1174             : 
    1175         168 : void php_dom_create_interator(zval *return_value, int ce_type) /* {{{ */
    1176             : {
    1177             :         zend_class_entry *ce;
    1178             : 
    1179         168 :         if (ce_type == DOM_NAMEDNODEMAP) {
    1180          10 :                 ce = dom_namednodemap_class_entry;
    1181             :         } else {
    1182         158 :                 ce = dom_nodelist_class_entry;
    1183             :         }
    1184             : 
    1185         168 :         object_init_ex(return_value, ce);
    1186         168 : }
    1187             : /* }}} */
    1188             : 
    1189             : /* {{{ php_dom_create_object */
    1190        1039 : PHP_DOM_EXPORT zend_bool php_dom_create_object(xmlNodePtr obj, zval *return_value, dom_object *domobj)
    1191             : {
    1192             :         zend_class_entry *ce;
    1193             :         dom_object *intern;
    1194             : 
    1195        1039 :         if (!obj) {
    1196           0 :                 ZVAL_NULL(return_value);
    1197           0 :                 return 0;
    1198             :         }
    1199             : 
    1200        1039 :         if ((intern = (dom_object *) php_dom_object_get_data((void *) obj))) {
    1201         457 :                 GC_REFCOUNT(&intern->std)++;
    1202         457 :                 ZVAL_OBJ(return_value, &intern->std);
    1203         457 :                 return 1;
    1204             :         }
    1205             : 
    1206         582 :         switch (obj->type) {
    1207             :                 case XML_DOCUMENT_NODE:
    1208             :                 case XML_HTML_DOCUMENT_NODE:
    1209             :                 {
    1210          15 :                         ce = dom_document_class_entry;
    1211          15 :                         break;
    1212             :                 }
    1213             :                 case XML_DTD_NODE:
    1214             :                 case XML_DOCUMENT_TYPE_NODE:
    1215             :                 {
    1216          11 :                         ce = dom_documenttype_class_entry;
    1217          11 :                         break;
    1218             :                 }
    1219             :                 case XML_ELEMENT_NODE:
    1220             :                 {
    1221         336 :                         ce = dom_element_class_entry;
    1222         336 :                         break;
    1223             :                 }
    1224             :                 case XML_ATTRIBUTE_NODE:
    1225             :                 {
    1226          39 :                         ce = dom_attr_class_entry;
    1227          39 :                         break;
    1228             :                 }
    1229             :                 case XML_TEXT_NODE:
    1230             :                 {
    1231         136 :                         ce = dom_text_class_entry;
    1232         136 :                         break;
    1233             :                 }
    1234             :                 case XML_COMMENT_NODE:
    1235             :                 {
    1236          11 :                         ce = dom_comment_class_entry;
    1237          11 :                         break;
    1238             :                 }
    1239             :                 case XML_PI_NODE:
    1240             :                 {
    1241           2 :                         ce = dom_processinginstruction_class_entry;
    1242           2 :                         break;
    1243             :                 }
    1244             :                 case XML_ENTITY_REF_NODE:
    1245             :                 {
    1246           2 :                         ce = dom_entityreference_class_entry;
    1247           2 :                         break;
    1248             :                 }
    1249             :                 case XML_ENTITY_DECL:
    1250             :                 case XML_ELEMENT_DECL:
    1251             :                 {
    1252           7 :                         ce = dom_entity_class_entry;
    1253           7 :                         break;
    1254             :                 }
    1255             :                 case XML_CDATA_SECTION_NODE:
    1256             :                 {
    1257           9 :                         ce = dom_cdatasection_class_entry;
    1258           9 :                         break;
    1259             :                 }
    1260             :                 case XML_DOCUMENT_FRAG_NODE:
    1261             :                 {
    1262           9 :                         ce = dom_documentfragment_class_entry;
    1263           9 :                         break;
    1264             :                 }
    1265             :                 case XML_NOTATION_NODE:
    1266             :                 {
    1267           5 :                         ce = dom_notation_class_entry;
    1268           5 :                         break;
    1269             :                 }
    1270             :                 case XML_NAMESPACE_DECL:
    1271             :                 {
    1272           0 :                         ce = dom_namespace_node_class_entry;
    1273           0 :                         break;
    1274             :                 }
    1275             :                 default:
    1276           0 :                         php_error_docref(NULL, E_WARNING, "Unsupported node type: %d", obj->type);
    1277           0 :                         ZVAL_NULL(return_value);
    1278           0 :                         return 0;
    1279             :         }
    1280             : 
    1281         582 :         if (domobj && domobj->document) {
    1282         564 :                 ce = dom_get_doc_classmap(domobj->document, ce);
    1283             :         }
    1284         582 :         object_init_ex(return_value, ce);
    1285             : 
    1286         582 :         intern = Z_DOMOBJ_P(return_value);
    1287         582 :         if (obj->doc != NULL) {
    1288         573 :                 if (domobj != NULL) {
    1289         559 :                         intern->document = domobj->document;
    1290             :                 }
    1291         573 :                 php_libxml_increment_doc_ref((php_libxml_node_object *)intern, obj->doc);
    1292             :         }
    1293             : 
    1294         582 :         php_libxml_increment_node_ptr((php_libxml_node_object *)intern, obj, (void *)intern);
    1295         582 :         return 0;
    1296             : }
    1297             : /* }}} end php_domobject_new */
    1298             : 
    1299           2 : void php_dom_create_implementation(zval *retval) {
    1300           2 :         object_init_ex(retval, dom_domimplementation_class_entry);
    1301           2 : }
    1302             : 
    1303             : /* {{{ int dom_hierarchy(xmlNodePtr parent, xmlNodePtr child) */
    1304         177 : int dom_hierarchy(xmlNodePtr parent, xmlNodePtr child)
    1305             : {
    1306             :         xmlNodePtr nodep;
    1307             : 
    1308         177 :     if (parent == NULL || child == NULL || child->doc != parent->doc) {
    1309          23 :         return SUCCESS;
    1310             :     }
    1311             : 
    1312         154 :         nodep = parent;
    1313             : 
    1314         588 :         while (nodep) {
    1315         282 :                 if (nodep == child) {
    1316           2 :                         return FAILURE;
    1317             :                 }
    1318         280 :                 nodep = nodep->parent;
    1319             :         }
    1320             : 
    1321         152 :     return SUCCESS;
    1322             : }
    1323             : /* }}} end dom_hierarchy */
    1324             : 
    1325             : /* {{{ dom_has_feature(char *feature, char *version) */
    1326           2 : int dom_has_feature(char *feature, char *version)
    1327             : {
    1328           2 :         int retval = 0;
    1329             : 
    1330           2 :         if (!(strcmp (version, "1.0") && strcmp (version,"2.0") && strcmp(version, ""))) {
    1331           2 :                 if ((!strcasecmp(feature, "Core") && !strcmp (version, "1.0")) || !strcasecmp(feature, "XML"))
    1332           2 :                         retval = 1;
    1333             :         }
    1334             : 
    1335           2 :         return retval;
    1336             : }
    1337             : /* }}} end dom_has_feature */
    1338             : 
    1339       66079 : xmlNode *dom_get_elements_by_tag_name_ns_raw(xmlNodePtr nodep, char *ns, char *local, int *cur, int index) /* {{{ */
    1340             : {
    1341       66079 :         xmlNodePtr ret = NULL;
    1342             : 
    1343      264176 :         while (nodep != NULL && (*cur <= index || index == -1)) {
    1344      132142 :                 if (nodep->type == XML_ELEMENT_NODE) {
    1345       66054 :                         if (xmlStrEqual(nodep->name, (xmlChar *)local) || xmlStrEqual((xmlChar *)"*", (xmlChar *)local)) {
    1346         142 :                                 if (ns == NULL || (nodep->ns != NULL && (xmlStrEqual(nodep->ns->href, (xmlChar *)ns) || xmlStrEqual((xmlChar *)"*", (xmlChar *)ns)))) {
    1347         130 :                                         if (*cur == index) {
    1348          60 :                                                 ret = nodep;
    1349          60 :                                                 break;
    1350             :                                         }
    1351          70 :                                         (*cur)++;
    1352             :                                 }
    1353             :                         }
    1354       65994 :                         ret = dom_get_elements_by_tag_name_ns_raw(nodep->children, ns, local, cur, index);
    1355       65994 :                         if (ret != NULL) {
    1356          64 :                                 break;
    1357             :                         }
    1358             :                 }
    1359      132018 :                 nodep = nodep->next;
    1360             :         }
    1361       66079 :         return ret;
    1362             : }
    1363             : /* }}} */
    1364             : /* }}} end dom_element_get_elements_by_tag_name_ns_raw */
    1365             : 
    1366             : /* {{{ void dom_normalize (xmlNodePtr nodep) */
    1367           2 : void dom_normalize (xmlNodePtr nodep)
    1368             : {
    1369             :         xmlNodePtr child, nextp, newnextp;
    1370             :         xmlAttrPtr attr;
    1371             :         xmlChar *strContent;
    1372             : 
    1373           2 :         child = nodep->children;
    1374           5 :         while(child != NULL) {
    1375           1 :                 switch (child->type) {
    1376             :                         case XML_TEXT_NODE:
    1377           1 :                                 nextp = child->next;
    1378           3 :                                 while (nextp != NULL) {
    1379           1 :                                         if (nextp->type == XML_TEXT_NODE) {
    1380           1 :                                                 newnextp = nextp->next;
    1381           1 :                                                 strContent = xmlNodeGetContent(nextp);
    1382           1 :                                                 xmlNodeAddContent(child, strContent);
    1383           1 :                                                 xmlFree(strContent);
    1384           1 :                                                 xmlUnlinkNode(nextp);
    1385           1 :                                                 php_libxml_node_free_resource(nextp);
    1386           1 :                                                 nextp = newnextp;
    1387             :                                         } else {
    1388           0 :                                                 break;
    1389             :                                         }
    1390             :                                 }
    1391           1 :                                 break;
    1392             :                         case XML_ELEMENT_NODE:
    1393           0 :                                 dom_normalize (child);
    1394           0 :                                 attr = child->properties;
    1395           0 :                                 while (attr != NULL) {
    1396           0 :                                         dom_normalize((xmlNodePtr) attr);
    1397           0 :                                         attr = attr->next;
    1398             :                                 }
    1399           0 :                                 break;
    1400             :                         case XML_ATTRIBUTE_NODE:
    1401           0 :                                 dom_normalize (child);
    1402             :                                 break;
    1403             :                         default:
    1404             :                                 break;
    1405             :                 }
    1406           1 :                 child = child->next;
    1407             :         }
    1408           2 : }
    1409             : /* }}} end dom_normalize */
    1410             : 
    1411             : 
    1412             : /* {{{ void dom_set_old_ns(xmlDoc *doc, xmlNs *ns) */
    1413           5 : void dom_set_old_ns(xmlDoc *doc, xmlNs *ns) {
    1414             :         xmlNs *cur;
    1415             : 
    1416           5 :         if (doc == NULL)
    1417           0 :                 return;
    1418             : 
    1419           5 :         if (doc->oldNs == NULL) {
    1420           2 :                 doc->oldNs = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
    1421           2 :                 if (doc->oldNs == NULL) {
    1422           0 :                         return;
    1423             :                 }
    1424           2 :                 memset(doc->oldNs, 0, sizeof(xmlNs));
    1425           2 :                 doc->oldNs->type = XML_LOCAL_NAMESPACE;
    1426           2 :                 doc->oldNs->href = xmlStrdup(XML_XML_NAMESPACE);
    1427           2 :                 doc->oldNs->prefix = xmlStrdup((const xmlChar *)"xml");
    1428             :         }
    1429             : 
    1430           5 :         cur = doc->oldNs;
    1431          16 :         while (cur->next != NULL) {
    1432           6 :                 cur = cur->next;
    1433             :         }
    1434           5 :         cur->next = ns;
    1435             : }
    1436             : /* }}} end dom_set_old_ns */
    1437             : 
    1438             : /*
    1439             : http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-DocCrElNS
    1440             : 
    1441             : NAMESPACE_ERR: Raised if
    1442             : 
    1443             : 1. the qualifiedName is a malformed qualified name
    1444             : 2. the qualifiedName has a prefix and the  namespaceURI is null
    1445             : */
    1446             : 
    1447             : /* {{{ int dom_check_qname(char *qname, char **localname, char **prefix, int uri_len, int name_len) */
    1448          45 : int dom_check_qname(char *qname, char **localname, char **prefix, int uri_len, int name_len) {
    1449          45 :         if (name_len == 0) {
    1450           0 :                 return NAMESPACE_ERR;
    1451             :         }
    1452             : 
    1453          45 :         *localname = (char *)xmlSplitQName2((xmlChar *)qname, (xmlChar **) prefix);
    1454          45 :         if (*localname == NULL) {
    1455          14 :                 *localname = (char *)xmlStrdup((xmlChar *)qname);
    1456          14 :                 if (*prefix == NULL && uri_len == 0) {
    1457           1 :                         return 0;
    1458             :                 }
    1459             :         }
    1460             : 
    1461             :         /* 1 */
    1462          44 :         if (xmlValidateQName((xmlChar *) qname, 0) != 0) {
    1463           7 :                 return NAMESPACE_ERR;
    1464             :         }
    1465             : 
    1466             :         /* 2 */
    1467          37 :         if (*prefix != NULL && uri_len == 0) {
    1468           2 :                 return NAMESPACE_ERR;
    1469             :         }
    1470             : 
    1471          35 :         return 0;
    1472             : }
    1473             : /* }}} */
    1474             : 
    1475             : /*
    1476             : http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-DocCrElNS
    1477             : 
    1478             : NAMESPACE_ERR: Raised if
    1479             : 
    1480             : 3. the qualifiedName has a prefix that is "xml" and the namespaceURI is different from "http://www.w3.org/XML/1998/namespace" [XML Namespaces]
    1481             : 4. the qualifiedName or its prefix is "xmlns" and the namespaceURI is different from  "http://www.w3.org/2000/xmlns/"
    1482             : 5. the namespaceURI is "http://www.w3.org/2000/xmlns/" and neither the        qualifiedName nor its prefix is "xmlns".
    1483             : */
    1484             : 
    1485             : /* {{{ xmlNsPtr dom_get_ns(xmlNodePtr nodep, char *uri, int *errorcode, char *prefix) */
    1486          25 : xmlNsPtr dom_get_ns(xmlNodePtr nodep, char *uri, int *errorcode, char *prefix) {
    1487          25 :         xmlNsPtr nsptr = NULL;
    1488             : 
    1489          25 :         *errorcode = 0;
    1490             : 
    1491          25 :         if (! ((prefix && !strcmp (prefix, "xml") && strcmp(uri, (char *)XML_XML_NAMESPACE)) ||
    1492             :                    (prefix && !strcmp (prefix, "xmlns") && strcmp(uri, (char *)DOM_XMLNS_NAMESPACE)) ||
    1493             :                    (prefix && !strcmp(uri, (char *)DOM_XMLNS_NAMESPACE) && strcmp (prefix, "xmlns")))) {
    1494          19 :                 nsptr = xmlNewNs(nodep, (xmlChar *)uri, (xmlChar *)prefix);
    1495             :         }
    1496             : 
    1497          25 :         if (nsptr == NULL) {
    1498           7 :                 *errorcode = NAMESPACE_ERR;
    1499             :         }
    1500             : 
    1501          25 :         return nsptr;
    1502             : 
    1503             : }
    1504             : /* }}} end dom_get_ns */
    1505             : 
    1506             : /* {{{ xmlNsPtr dom_get_nsdecl(xmlNode *node, xmlChar *localName) */
    1507           2 : xmlNsPtr dom_get_nsdecl(xmlNode *node, xmlChar *localName) {
    1508             :         xmlNsPtr cur;
    1509           2 :         xmlNs *ret = NULL;
    1510           2 :         if (node == NULL)
    1511           0 :                 return NULL;
    1512             : 
    1513           3 :         if (localName == NULL || xmlStrEqual(localName, (xmlChar *)"")) {
    1514           1 :                 cur = node->nsDef;
    1515           3 :                 while (cur != NULL) {
    1516           1 :                         if (cur->prefix == NULL  && cur->href != NULL) {
    1517           0 :                                 ret = cur;
    1518           0 :                                 break;
    1519             :                         }
    1520           1 :                         cur = cur->next;
    1521             :                 }
    1522             :         } else {
    1523           1 :                 cur = node->nsDef;
    1524           2 :                 while (cur != NULL) {
    1525           0 :                         if (cur->prefix != NULL && xmlStrEqual(localName, cur->prefix)) {
    1526           0 :                                 ret = cur;
    1527           0 :                                 break;
    1528             :                         }
    1529           0 :                         cur = cur->next;
    1530             :                 }
    1531             :         }
    1532           2 :         return ret;
    1533             : }
    1534             : /* }}} end dom_get_nsdecl */
    1535             : 
    1536           8 : zval *dom_nodelist_read_dimension(zval *object, zval *offset, int type, zval *rv) /* {{{ */
    1537             : {
    1538             :         zval offset_copy;
    1539             : 
    1540           8 :         if (!offset) {
    1541           1 :                 return NULL;
    1542             :         }
    1543             : 
    1544          14 :         ZVAL_LONG(&offset_copy, zval_get_long(offset));
    1545             : 
    1546           7 :         zend_call_method_with_1_params(object, Z_OBJCE_P(object), NULL, "item", rv, &offset_copy);
    1547             : 
    1548           7 :         return rv;
    1549             : } /* }}} end dom_nodelist_read_dimension */
    1550             : 
    1551           6 : int dom_nodelist_has_dimension(zval *object, zval *member, int check_empty)
    1552             : {
    1553           6 :         zend_long offset = zval_get_long(member);
    1554             :         zval rv;
    1555             : 
    1556           6 :         if (offset < 0) {
    1557           1 :                 return 0;
    1558             :         } else {
    1559           5 :                 zval *length = zend_read_property(Z_OBJCE_P(object), object, "length", sizeof("length") - 1, 0, &rv);
    1560             : 
    1561           5 :                 return length && offset < Z_LVAL_P(length);
    1562             :         }
    1563             : } /* }}} end dom_nodelist_has_dimension */
    1564             : 
    1565             : #endif /* HAVE_DOM */
    1566             : 
    1567             : /*
    1568             :  * Local variables:
    1569             :  * tab-width: 4
    1570             :  * c-basic-offset: 4
    1571             :  * End:
    1572             :  * vim600: noet sw=4 ts=4 fdm=marker
    1573             :  * vim<600: noet sw=4 ts=4
    1574             :  */

Generated by: LCOV version 1.10

Generated at Mon, 27 Jul 2015 02:32:17 +0000 (29 hours ago)

Copyright © 2005-2015 The PHP Group
All rights reserved.