Hallo!
Ich habe ein Strato Powerweb-Paket, und benutze eine XML to object Klasse, die in meiner lokalen Testumgebung einwandfrei funktioniert, aber wie so oft, bei Strato Probleme bekommt.
Ich bin in Sachen PHP ziehmlicher Anfänger, daher erhoffe ich mir hier ein wenig Hilfe oder einen Lösungsansatz.
Ich bekam zunächst noch eine andere Fehlermeldung, nämlich:
Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in /mnt/be2/04/518/00000009/htdocs/galerie/admin/inc/XML.inc.php on line 61
Jedoch konnte ich, nach ein wenig Recherche, durch einfügen von
PHP-Code:
error_reporting( E_ERROR | E_PARSE );
in der Datei, die das Script per require_once included, unterbinden. Ich weiss nicht, ob der verbleibende Fehler hiermit zu tun hat (denke ich nicht), darum dachte ich, ich sollte es hier erwähnen.
Also, dies ist die Fehlermeldung, die noch bleibt:
Fatal error: Call to undefined function: new_child() in /mnt/be2/04/518/00000009/htdocs/galerie/admin/inc/XML.inc.php on line 73
Hier ist das Script, um das es geht (Datei XML.inc.php), ich poste mal den gesamten code, da darin zwei Klassen deklariert werden, und das Problem scheinbar damit zu tun hat, dass eine Funktion in der anderen Klasse nicht gefunden wird. Oder so.. :)
Jedenfalls ist die Funktion new_child sehr wohl in der XML_TAG Klasse vorhanden, allerdings weiss ich nicht, wie ich was geschickter machen sollte...
PHP-Code:
<?php
/*
* XML.inc.php
*
* Class to convert an XML file into an object
*
* Copyright (C) 2006 Oliver Strecke <oliver.strecke@browsertec.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
class XML{
var $_parser;
var $_xml_data;
var $_actual_tag;
//Constructor...
function xml(){
$this->_parser=xml_parser_create("ISO-8859-1");
$this->_xml_data="";
$this->_actual_tag=false;
xml_set_object($this->_parser,$this);
xml_parser_set_option($this->_parser,XML_OPTION_CASE_FOLDING,false);
xml_set_element_handler($this->_parser,"tag_open","tag_close");
xml_set_character_data_handler($this->_parser,"tag_data");
xml_set_default_handler($this->_parser,"tag_data");
}
//get XML data from file...
function file_read($xml_file){
if(file_exists($xml_file)){
$this->_xml_data=implode("",file($xml_file));
}
return 1;
}
//parse XML data...
function parse($xml_data=0){
if($xml_data)$this->_xml_data=$xml_data;
xml_parse($this->_parser,$this->_xml_data);
xml_parser_free($this->_parser);
return 1;
}
function tag_open($parser,$name,$attrs){
//create new tag...
$tag=new XML_TAG(&$this->_actual_tag);
$tag->_name=$name;
$tag->_param=$attrs;
//add tag object to parent/actual tag object...
if(is_object($this->_actual_tag)){
if(is_object($this->_actual_tag->$name) || is_array($this->_actual_tag->$name)){
//same child objects -> Array...
$last_index=$this->_actual_tag->new_child_array($tag,$name);
$this->_actual_tag=&$this->_actual_tag->{$name}[$last_index];
}else{
//add new child object to actual tag...
$this->_actual_tag->new_child($tag,$name);
$this->_actual_tag=&$this->_actual_tag->$name;
}
}else{
//copy first tag object in this object...
$this->$name=$tag;
$this->_actual_tag=&$this->{$name};
}
return 1;
}
function tag_data($parser,$string){
if(strlen(trim($string))>0)$this->_actual_tag->_value=$string;
return 1;
}
function tag_close($parser,$name){
$this->_actual_tag=&$this->_actual_tag->_parent;
return 1;
}
//Debug...
function debug($exit=0){
echo "<pre>";
print_r($this);
echo "</pre>";
if($exit)exit;
}
}
class XML_TAG{
var $_parent;
var $_name;
var $_value;
var $_param;
//Constructor...
function xml_tag($parent){
$this->_parent=&$parent;
$this->_name="";
$this->_value=false;
$this->_param=Array();
return 1;
}
//simply add ne child to this object...
function new_child($child,$child_name){
$this->$child_name=&$child;
}
//add child array for more same childs to this object...
function new_child_array($child,$child_name){
//create array and set old child object to the first array element...
if(is_object($this->$child_name)){
$tmp_obj=$this->$child_name;
$this->$child_name=Array();
$this->new_child_array($tmp_obj,$child_name);
}
//push child reference into child array...
$this->{$child_name}[]=&$child;
$last_index=count($this->$child_name)-1;
return $last_index;
}
//Debug...
function debug(){
echo "<pre>";
print_r($this);
echo "</pre>";
}
}
?>
Jetzt habe ich schon so ein tolles Programm gebaut (Bildergalerie-CMS, mit Flash Front-End für den Admin, is supi), und es funtioniert nicht dort, wo es funtionieren soll: auf dem Web-Server.. Enttäuschend.. :(
Naja, danke im Voraus :)
btw: Ich könnte natürlich dem Entwickler der Klasse ne Email schreiben aber naja, ich dachte sowas macht man nicht, lieber erst in nem Forum, wo Leute mit AHnung sind, nachfragen. War das richtig, oder ist es durchaus üblich, wenn der Autor ja bekannt ist, ihm direkt eine solche Frage per email zu stellen?