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

Generated by: LCOV version 1.10

Generated at Tue, 26 Jul 2016 17:07:34 +0000 (3 days ago)

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