Now is fully working. I will add xpath referencing support at some point

This commit is contained in:
seek3r 2002-09-21 06:55:50 +00:00
parent 241d87cdd1
commit 00d77ea97b

View File

@ -239,7 +239,7 @@
break; break;
case 'object': case 'object':
$subnode = new xmltool('node', $nextkey); $subnode = new xmltool('node', $nextkey);
$subnode->set_value('PHP_SERIALIZED_OBJECT:'.serialize($val)); $subnode->set_value('PHP_SERIALIZED_OBJECT&:'.serialize($val));
$node->add_node($subnode); $node->add_node($subnode);
break; break;
case 'resource': case 'resource':
@ -252,7 +252,7 @@
} }
break; break;
case 'object': case 'object':
$node->set_value('PHP_SERIALIZED_OBJECT:'.serialize($value)); $node->set_value('PHP_SERIALIZED_OBJECT&:'.serialize($value));
break; break;
case 'resource': case 'resource':
echo 'Halt: Cannot package PHP resource pointers into XML<br>'; echo 'Halt: Cannot package PHP resource pointers into XML<br>';
@ -282,36 +282,21 @@
} }
} }
function export_var ($is_start = True) function export_var()
{ {
switch ($this->data_type) if($this->node_type == 'root')
{ {
case 'root': return $this->data->export_var();
break;
case 'node':
break;
case 'object':
break;
} }
if($this->data_type != 'node') if($this->data_type != 'node')
{ {
$data = $this->data; $found_at = strstr($this->data,'PHP_SERIALIZED_OBJECT&:');
$found_at = strstr($xmldata['value'],'PHP_SERIALIZED_OBJECT:');
if($found_at != False) if($found_at != False)
{ {
$data = str_replace ('PHP_SERIALIZED_OBJECT:', '', $this->data); return unserialize(str_replace ('PHP_SERIALIZED_OBJECT&:', '', $this->data));
$data = unserialize ($xmldata['value']);
} }
//if($is_start) return $this->data;
//{
// $xml_array[$this->data] = $data;
//}
//else
//{
return $data;
//}
} }
else else
{ {
@ -334,7 +319,8 @@
reset($this->data); reset($this->data);
while(list($key,$val) = each($this->data)) while(list($key,$val) = each($this->data))
{ {
//$xml_array[$val->name][] = $this->export_var($val,False);
$return_array[$val->name][] = $val->export_var();
} }
} }
else else
@ -342,13 +328,47 @@
reset($this->data); reset($this->data);
while(list($key,$val) = each($this->data)) while(list($key,$val) = each($this->data))
{ {
//$xml_array[$val->name] = $this->export_var($val,False); $return_array[$val->name] = $val->export_var();
} }
} }
return $return_array;
} }
return $xml_array;
} }
function export_struct()
{
if($this->node_type == 'root')
{
return $this->data->export_struct();
}
$retval['tag'] = $this->name;
$retval['attributes'] = $this->attributes;
if($this->data_type != 'node')
{
$found_at = strstr($this->data,'PHP_SERIALIZED_OBJECT&:');
if($found_at != False)
{
$retval['value'] = unserialize(str_replace ('PHP_SERIALIZED_OBJECT&:', '', $this->data));
}
else
{
$retval['value'] = $this->data;
}
return $retval;
}
else
{
reset($this->data);
while(list($key,$val) = each($this->data))
{
$retval['children'][] = $val->export_struct();
}
return $retval;
}
}
function import_xml_children($data, &$i, $parent_node) function import_xml_children($data, &$i, $parent_node)
{ {
while (++$i < count($data)) while (++$i < count($data))